Skip to content

fix(ci): auto-format stages only the listed files — treefmt companion changes (rustfmt mod children) fail the commit or are silently dropped (#3198) #5014

Closed

Description

@dezren39

Finding

The auto-format workflow decides "treefmt changed something" with a whole-worktree check but stages only the files it passed to the formatter. treefmt's rustfmt invocation can change files that were never in that list — rustfmt formats a file's out-of-line mod children along with it — so a companion change is either stranded or breaks the run:

  • .github/workflows/auto-format.yml on current main (0467ae0f9887): line 111 runs nix run .#format -- "${format_files[@]}", line 112 checks git diff --quiet (whole worktree), line 119 stages with git add -- "${format_files[@]}" and line 120 commits unconditionally.
  • If the listed files were already formatted but a companion changed, nothing is staged and git commit exits 1 ("no changes added to commit"); under set -euo pipefail the step fails, nothing is pushed, and record_success never runs — so every later 15-minute run re-diffs the same range and fails the same way until the range moves on.
  • If some listed file did change, the commit succeeds and the companion change is silently discarded with the runner: the unformatted child stays on main.

PR #3198 introduced the restricted staging (it replaced git add -A to keep workflow files out of the bot's push, #3118). The later PAT rework (PR #4797, commit df09437) removed the workflow-file exclusion — format_files is now all changed files and the header comment says nothing is excluded from the write pass — but kept the restricted git add, so the companion gap survived. CodeRabbit flagged exactly this on PR #3198 (Minor / potential_issue, #3198 (comment)); it was never addressed or replied to, and the PR merged as-is (2026-11-02).

Evidence

Why it matters

The auto-format bot is the fleet's formatting safety net: it runs every 15 minutes and keeps main formatted without gating merges. This gap makes it fail loudly and repeatedly for an entire diff range whenever a merged PR leaves an unformatted module child next to a formatted parent (formatting never gates a merge, so drift on main is expected), and in the mixed case it silently throws away formatting it already computed. Either way the bot stops doing the one job it exists for, with no issue on file.

Acceptance criteria

  • The write pass stages every tracked change treefmt actually made (or equivalently decides "nothing to commit" from the staged diff, not the worktree diff), so a companion-file change can neither fail the commit with "no changes added to commit" nor be silently discarded.
  • Workflow files remain pushable under the current REPO_AUTOMATION_TOKEN PAT arrangement (the fix(ci): auto-format push is rejected when the format diff touches workflow files (PR #2148) #3118 regression does not return in another form).
  • A regression test in scripts/tests/test_auto_format_workflow.py, executing the workflow's real run block like the existing tests, covers the companion case: a listed file already formatted whose formatter run changes an unlisted tracked file — the run exits 0 and the companion change is in the pushed commit.
  • The existing auto-format workflow tests still pass.

Activity

  1. added
    kind/ciCI/CD pipelines, workflows, and build automation
    task/triageQueue packet kind: verify, reproduce, and route this item
    priority/normalOrdinary priority (the default)
    queue/queuedHas a queued task in the Supabase agent queue
    area/ciCI/CD pipelines, workflows, and build automation (area)
    effort/sSmall: expected under 2 hours of work
    on Nov 3, 2026
  2. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: pr-diff-review-b
    • Session / ID: pr-diff-review-b run 2026-11-03 09:18 CST (job pr-diff-review-b)
    • Found via: filed this run
    • Task: Fix the auto-format write pass so treefmt companion changes are staged — PR fix(ci): prevent workflow format diffs from blocking auto-format push (#3118) #3198 restricted staging to the listed files while git diff --quiet stays whole-worktree; rustfmt reformats out-of-line mod children of a listed .rs file (verified on the laptop with treefmt's exact invocation), so a companion-only change fails git commit with "no changes added to commit" (and wedges every later run on the same range) or is silently discarded. Still live on main 0467ae0 at .github/workflows/auto-format.yml:112/119.
    • Expectation: effort/s — done when the write pass stages everything treefmt changed (or judges from the staged diff), the companion case is pinned by a real-run-block test in scripts/tests/test_auto_format_workflow.py, and the existing auto-format tests pass.
    • Links: source PR fix(ci): prevent workflow format diffs from blocking auto-format push (#3118) #3198 (head 1cc7de2; CodeRabbit Minor r4433106457 unaddressed); queue packet enqueued this run (repo-health-code-pilot).
  3. developing-today commented on Nov 3, 2026

    @developing-today
    Contributor

    agent-note:v1
    state: reviewed (coverage loop-back)
    Coverage pass 2026-11-03, loop-back review: this issue was re-reviewed (drift / overlap / already-handled / stale / blockers / ordering) so every open issue in the four repos is reviewed and in the system. Verdict: still live; in the system as task 8492 (triage, queued, priority 50) in repo-health-code-pilot. Labels audited and synced. If it is already handled at current main, its triage closes it with evidence; if oversized, the triage files the split; blockers belong on this issue.
    Found via: coverage loop-back 2026-11-03

  4. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 4, 2026
  5. 5 remaining items

  6. added
    queue/queuedHas a queued task in the Supabase agent queue
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    queue/queuedHas a queued task in the Supabase agent queue
    on Nov 4, 2026
  7. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

    Revalidated fresh: issue #5014 OPEN, no hard-stop labels, no open PR covers it, no existing queue/9028 branch. Proceeding on the laptop worktree.

  8. added 2 commits that reference this issue on Nov 4, 2026
  9. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · done (fixed & merged)

    Done: PR #5304 merged (merge commit 0dab47d); this issue auto-closed by the merge.

    • Fix: the write pass now stages every tracked treefmt change (git add -u) and decides "nothing to commit" from the staged diff, so companion changes (rustfmt mod children) can neither fail the commit nor be silently dropped.
    • Tests: scripts/tests/test_auto_format_workflow.py 5/5 pass on the laptop worktree, including the new companion-case regression test (fails rc=1 on the unmodified workflow). Note: all 4 pre-existing tests failed on clean main before this PR (REPO_AUTOMATION_TOKEN: unbound variable in the stub env) — harness fixed; two tests updated from the superseded GITHUB_TOKEN workflow-skip expectations to the PAT arrangement (fix(ci): auto-format push is rejected when the format diff touches workflow files (PR #2148) #3118).
    • Codex review on PR fix(ci): auto-format stages every tracked treefmt change (#5014) #5304: completed, no findings. Checks: CodeRabbit skipping; repo CI runs on main.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area/ciCI/CD pipelines, workflows, and build automation (area)effort/sSmall: expected under 2 hours of workkind/ciCI/CD pipelines, workflows, and build automationpriority/normalOrdinary priority (the default)source/pr-diff-reviewFiled by the pr-diff-review jobtask/triageQueue packet kind: verify, reproduce, and route this item

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions