Title: fix(ci): auto-format stages only the listed files — treefmt companion changes (rustfmt mod children) fail the commit or are silently dropped (#3198) · Issue #5014 · developing-today/code · GitHub
Open Graph Title: fix(ci): auto-format stages only the listed files — treefmt companion changes (rustfmt mod children) fail the commit or are silently dropped (#3198) · Issue #5014 · developing-today/code
X Title: fix(ci): auto-format stages only the listed files — treefmt companion changes (rustfmt mod children) fail the commit or are silently dropped (#3198) · Issue #5014 · developing-today/code
Description: 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 f...
Open Graph Description: 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 ...
X Description: 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...
Opengraph URL: https://github.com/developing-today/code/issues/5014
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"fix(ci): auto-format stages only the listed files — treefmt companion changes (rustfmt mod children) fail the commit or are silently dropped (#3198)","articleBody":"## Finding\n\nThe 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:\n\n- `.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.\n- 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.\n- 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.\n\nPR #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 df09437d) 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, https://github.com/developing-today/code/pull/3198#discussion_r4433106457); it was never addressed or replied to, and the PR merged as-is (2026-11-02).\n\n## Evidence\n\n- PR: https://github.com/developing-today/code/pull/3198 — MERGED, head `1cc7de210e`; the hunk replaced `git add -A` with `git add -- \"${format_files[@]}\"` while `git diff --quiet` stayed whole-worktree.\n- Current main `0467ae0f98876cef0dfffe9fc75d61c68aeacd67`: `.github/workflows/auto-format.yml:111-120` as quoted above; `treefmt.toml` configures rustfmt as plain `rustfmt --edition 2024` with no `skip_children` / `--skip-children`.\n- Verified on the laptop (2026-11-03, rustfmt 1.9.0): a formatted `parent.rs` declaring `mod child;` plus an unformatted `child.rs` — running `rustfmt --edition 2024 parent.rs` (only the parent passed, treefmt's exact invocation shape) reformats `child.rs`. Replaying the workflow's git sequence on that tree: `git diff --quiet` reports dirty, `git add -- parent.rs` stages nothing, `git commit` exits 1 with \"no changes added to commit\".\n- Dedupe: issue searches for the auto-format staging / companion-file problem (titles and bodies, all states, 2026-11-03) return no covering issue. #3118/#3198 are the closed workflow-push problem; open #4787 is about scheduled runs not firing and the record_success token scope — a different failure.\n\n## Why it matters\n\nThe 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.\n\n## Acceptance criteria\n\n- [ ] 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.\n- [ ] Workflow files remain pushable under the current REPO_AUTOMATION_TOKEN PAT arrangement (the #3118 regression does not return in another form).\n- [ ] 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.\n- [ ] The existing auto-format workflow tests still pass.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-11-03T16:12:04Z","url":"https://github.com/developing-today/code/issues/5014"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fba0fdae-375b-e68e-afb2-ea509176fc6a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B458:1D2D33:10300F1:1582F96:6B065237 |
| html-safe-nonce | 939d22c546927f3dc55376b690e3fa8a4a74adbb092129b477815249c38f7437 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNDU4OjFEMkQzMzoxMDMwMEYxOjE1ODJGOTY6NkIwNjUyMzciLCJ2aXNpdG9yX2lkIjoiNDgyNjcxNjM3MTEwMDc4MzE1OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0e0a58da152127108244e94323664abb16346c85b2d808009d0ca785136545ab |
| hovercard-subject-tag | issue:6186507680 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/5014/issue_layout |
| twitter:image | https://opengraph.githubassets.com/546f3ffcaab7dc904dd04a2471717ac9b2a41505b838f535683795713ab50f54/developing-today/code/issues/5014 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/546f3ffcaab7dc904dd04a2471717ac9b2a41505b838f535683795713ab50f54/developing-today/code/issues/5014 |
| og:image:alt | 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 ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 772b6997ca4daa0428dd49a25d76052e765555ae560fe9c88517eb828bbd861e |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f1f9a08f7c769a37f1dfc18ad43d463c222a7eea |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width