Skip to content

chore: stop repairing the same checkout drift by hand every run - #237

Merged
github-actions[bot] merged 1 commit into
mainfrom
chore/preflight-drift-check
Sep 2, 2026
Merged

chore: stop repairing the same checkout drift by hand every run#237
github-actions[bot] merged 1 commit into
mainfrom
chore/preflight-drift-check

Conversation

@catomean

@catomean catomean commented Sep 2, 2026

Copy link
Copy Markdown
Collaborator

Why

Three separate sessions have opened this repo, found the working copy silently wrong, and spent part of the run repairing it before any real work could start:

When What was wrong
2026-08-29 Local main held a commit origin never got — git pull --ff-only failed for every run entering the repo
2026-08-31 Local main 2 commits behind origin (#232, #233)
2026-09-02 Local main 3 commits behind (#234#236), two squash-merged worktrees still checked out, and frontend/node_modules predating the prettier devDependency from #233 — so the first gate of npm run verify died on prettier: not found

A bare git status reports "clean" in all three cases. That's why each run rediscovers it the hard way instead of inheriting the previous one's fix. Per the repo's never-twice rule, the third instance gets automation, not a fourth manual repair.

What

npm run preflight — read-only, exits 1 on drift. npm run preflight -- --fix repairs.

It checks exactly the three things git status cannot see:

  1. Divergence from origin, after an explicit git fetch. Reports ahead and behind; only fast-forwards when purely behind, and flags "ahead" loudly since that usually means a timed-out run left unpushed commits.
  2. Merged worktree branches still checked out. Compares patch ids with git cherry rather than git branch --merged, which cannot see a squash-merge. Under --fix it refuses to remove a worktree with uncommitted changes.
  3. node_modules older than its package-lock.json. The failure that reads most like a repo bug and never is.

Verification

Both paths exercised on this branch:

npm run verify green locally: format:check ✓ · lint 0 errors / 161 warnings · tsc clean · 46/46 tests · build ✓.

Docs live in .claude/CLAUDE.md next to the existing verify guidance, with the receipts inline so the next session knows why the check exists.

🤖 Generated with Claude Code

https://claude.ai/code/session_01PtVWdxno5WtK9zYLkrBz3P

Three separate sessions have now opened this repo, found the working copy
silently wrong, and spent part of the run repairing it before any real work
could start:

  2026-08-29  local main held a commit origin never got, so `git pull --ff-only`
              failed for every run entering the repo.
  2026-08-31  local main was 2 commits behind origin (#232, #233).
  2026-09-02  local main was 3 commits behind (#234-#236), two squash-merged
              worktrees were still checked out, and frontend/node_modules
              predated the prettier devDependency from #233 — so the first gate
              of `npm run verify` died on "prettier: not found".

A bare `git status` reports "clean" in all three cases, which is why each run
rediscovers it the hard way instead of inheriting the last one's fix. Per the
never-twice rule, the third instance gets the automation, not a fourth repair.

`npm run preflight` checks the three invisible ones — divergence from origin
(after an explicit fetch), merged worktree branches still checked out (compared
by patch id via `git cherry`, since `git branch --merged` cannot see a squash),
and node_modules older than its lockfile. Read-only by default, exit 1 on drift;
`npm run preflight -- --fix` repairs what it finds and refuses to touch a
worktree with uncommitted changes.

Both paths exercised on this branch: the read-only run caught backend/
node_modules as stale against the #229/#230 security bumps, and --fix
reinstalled it to clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PtVWdxno5WtK9zYLkrBz3P
@github-actions
github-actions Bot merged commit 55683d4 into main Sep 2, 2026
1 check passed
@github-actions
github-actions Bot deleted the chore/preflight-drift-check branch September 2, 2026 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant