Skip to content

cargo fmt: 103 pre-existing dirty files block Quality Guardrails CI (step 3 of 15) #38

Open

Description

@KooshaPari

Summary

cargo fmt --all -- --check exits 1 on the current HEAD (38af5e024) because of 103
pre-existing dirty files
. The dirt is not introduced by this branch — it is inherited from
upstream and from earlier fork work — but it sits third in the CI Quality Guardrails job and
silently prevents every later step in that job from running.

Correction (2026-10-09): an earlier draft of this body said 102 files and "step #5". Both
were wrong. The count is 103 (re-measured on both the stable and nightly
rustfmt channels — they agree exactly, 103 files, zero divergence) and the fmt step is #3
("Check formatting"), not #5. See "Verification" below.

Why this is more than cosmetic

The CI Quality Guardrails job (.github/workflows/ci.yml:20) runs cargo fmt --all -- --check
as its third step, and that step is a hard prerequisite for everything after it. The real
step order is:

job: Quality Guardrails  (.github/workflows/ci.yml:20)
 1. Configure SSH for cargo git dependencies   (conditional; DEPLOY_KEY_PRESENT)
      - actions/checkout@v4
      - dtolnay/rust-toolchain@stable
      - webfactory/[email protected] (conditional)
      - Swatinem/rust-cache@v2
 2. Check module declarations resolve          python3 scripts/check_module_files.py
 3. Check formatting                          cargo fmt --all -- --check   <-- FAILS HERE
 4. Check all targets and all features        cargo check --all-targets --all-features   SKIPPED
 5. Run clippy with warnings denied           cargo clippy --all-targets --all-features -- -D warnings   SKIPPED
 6. Enforce Cargo.lock is up to date          cargo metadata --locked ...               SKIPPED
 7. Enforce warning budget                    scripts/check_warning_budget.sh          SKIPPED
 8. Enforce oversized-file ratchet            python3 scripts/check_code_size_budget.py   SKIPPED
 9. Enforce oversized-test ratchet            python3 scripts/check_test_size_budget.py    SKIPPED
10. Enforce panic-prone usage ratchet         python3 scripts/check_panic_budget.py        SKIPPED
11. Enforce swallowed-error usage ratchet     python3 scripts/check_swallowed_error_budget.py  SKIPPED
12. Enforce crate dependency boundaries       python3 scripts/check_dependency_boundaries.py  SKIPPED
13. Enforce Rust and TypeScript SDK parity    (parity check step)                        SKIPPED
14. Enforce wildcard re-export ratchet        python3 scripts/check_wildcard_reexport_budget.py  SKIPPED
15. Enforce no unused dependencies            (unused-dep check step)                    SKIPPED

Consequence: a CI run that reports Quality Guardrails: passed proves only that the fmt
step passed. Steps 4-15 are never reached at that head. That is the more serious half of the
problem: not just dirty formatting, but a coverage hole in the guardrails job — clippy,
cargo check --all-targets, and all eight budget/ratchet gates are unexercised while fmt is red.

Scope correction (2026-10-09): an earlier draft of this body also listed deny, RUSTSEC
and secret scan as steps this failure skips. They are not steps in this job. Do not claim
them here.

Evidence the dirt is pre-existing

Cross-validated on a detached checkout of 115170054 (the fork parent of the v0.88.0 merge)
in a separate worktree:

HEAD dirty files
115170054 (fork parent) 111
current HEAD (post-merge) 103

The merge reduced the dirt by 8 files (not 9 — see correction note). The 103 figure is the
post-merge floor, not a regression. Full provenance in 08_FINAL_EVIDENCE.md §4.

Verification performed for this body (2026-10-09)

Re-measured rather than paraphrased, because the previously recorded number was stale by one:

Check Command Result
dirty files at HEAD (stable channel) cargo +stable fmt --all -- --check 103 unique files, 388 diff hunks
dirty files at HEAD (nightly channel) cargo fmt --all -- --check 103 unique files
channel disagreement set difference of the two lists 0 files — the two channels agree exactly
dirty files at the doc commit 8ee60a85 same command in a temp detached worktree 103 unique files
drift between 8ee60a85 and 94db64687 set difference of the two dirty lists 0 files — 94db64687 touches only docs/sessions/...

So 103 is the correct figure at every commit in this branch, on both fmt channels. The
"102" recorded in the session docs (05_KNOWN_ISSUES.md §2, 00_SESSION_OVERVIEW.md,
01_RESEARCH.md, 02_SPECIFICATIONS.md, 03_DAG_WBS.md) is a stale off-by-one with the same
root cause as this correction: it was measured once and never re-run after a small edit landed.
The session docs are being corrected to cite 103 with this provenance.

The dirt is not branch-introduced

Tested the overlap between the 103 dirty files and the 535 files this PR touches:

Category Count
fmt-dirty AND branch-touched 27
... of which touched by a fork (non-merge) commit after 115170054 22
... of which introduced by the merge commit 41fae89f3 alone 5

Every one of the 27 overlaps is either upstream content carried in by the merge or a file the
fork has been editing for its own reasons. Neither is a formatting regression introduced by
this branch.

Proposed approaches

Option A — land the format-only diff (103 files).
Mechanical, no logic changes. Large diff but low risk. Also unblocks every subsequent step in
the guardrails job permanently.

Option B (recommended) — decouple the fmt step from the budget gates.
Make the Quality Guardrails job run fmt as a non-blocking prerequisite, so the budget
and clippy gates always execute regardless of fmt state, with fmt reported separately. This
fixes the coverage hole without requiring a 103-file format diff to be reviewed in one sitting.

Option C — land Option A in slices. Break the 103-file diff into reviewable chunks (e.g.
per-crate, or one PR per top-level directory) so each diff stays reviewable, and keep Option B
as the belt-and-braces guard.

Recommendation

Option B first, then Option C. Option B is a small, low-risk CI change that immediately
closes the coverage hole. Option A is then safe to land incrementally knowing that a red fmt
step no longer blinds the rest of the job.

Scope

  • In scope: the fmt-check failure, the 103-file count with its provenance, the CI step-order
    evidence, and the coverage-hole consequence.
  • Out of scope: the actual formatting changes (whatever option is chosen is separate work),
    and any change to the deny / RUSTSEC / secret-scan steps, which live in other jobs.

Acceptance criteria

  • Chosen option is landed and the Quality Guardrails job runs past Check formatting.
  • Steps 4-15 of the guardrails job are observed executing at least once at a head where
    cargo fmt --all -- --check is allowed to fail, proving the decoupling.
  • If the 103-file diff is landed: cargo fmt --all -- --check exits 0 and the diff is
    formatting-only (verified with git diff --stat showing no non-whitespace logic change).

Effort

  • Option A: ~1 hour to generate, plus review time on a 103-file diff.
  • Option B: ~15 minutes of workflow YAML plus one CI run to confirm.
  • Option C: ~2-3 hours across several PRs.

Provenance

  • Measured at 38af5e024 (current feature/upstream-0.88-sync head, KooshaPari/KCode)
    on 2026-10-09, on both +stable and default nightly rustfmt channels (103 each, zero
    divergence). The 94db646 measurements agree exactly (see table above).
  • Cross-checked at 8ee60a85 in a temporary detached worktree (103, zero drift).
  • CI step order read directly from .github/workflows/ci.yml:20 (Quality Guardrails),
    15 steps enumerated; fmt is step 3.
  • Detailed session analysis: docs/sessions/20260924-upstream-0.88-sync/05_KNOWN_ISSUES.md §2.

tx-task: #24
tx-scope: ci
tx-agent: jcode

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions