feat(native): count how far a drifted checkout is behind origin (#1033) #1217
No reviewers
Labels
No labels
burndown-2026-06
autonomy
async-consult
autonomy
epic
autonomy
headless
autonomy
live-collab
coherence-core
priority
P0
priority
P1
priority
P2
priority
P3
priority
P4
qa-fixture
role/ai
role/creator
role/design
role/director
role/engineer
role/exec
role/human
role/ops
role/qa
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
coilyco-flight-deck/agentic-os!1217
Loading…
Reference in a new issue
No description provided.
Delete branch "aos/1033-behind-origin"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Follow-on to #1203, from evidence gathered after it merged.
The reason that actually bites was missing
#1033's advisory landed with three reasons: off main, dirty, unpushed. Then I read a real host:
On main. Nothing unpushed. 421 commits behind. The cause is that one untracked file:
nativeWorktreeCleanreturns false, normalization returns nil without a word, and the checkout falls further behind every launch.The advisory reported it correctly, as "dirty". That is true and understates a 421-commit gap by about as much as a report can. The reading now carries the count.
How I found it, and a correction I made before reporting
I was checking whether the generated git-workflow block had reached the PR-lane repos. The rollout dry run said
deploy would-write merge-remote-main, which looked like an expired override still live two days past its stated expiry.It is not.
origin/mainfor deploy carriespull-request-and-merge, and the override was removed on schedule. The dry run was reading the 421-commits-stale local checkout. So there is no defect in deploy, and this is instead a clean demonstration of the exact harm #1033 describes - a stale resident checkout changing what a tool composes - caught against a tool doing precisely what it should.That is why the count is worth having: nothing in the previous three reasons would have told me the dry run's answer was untrustworthy.
Coverage
Two tests: a checkout stepped back behind its origin reports the gap quantified, and an up-to-date one reports nothing. The existing four drift tests still pass, so the added reason does not widen what counts as drift.
684 python tests and the full Go suite pass,
pre-commit run --all-filespasses.Correct, and the property that makes it correct is implicit. Worth a comment before someone reorders it.
Why the count is trustworthy
rev-list HEAD..origin/<branch>reads the localorigin/*ref, so the number is only as fresh as the last fetch. That would make it a lower bound in exactly the case that matters: a checkout nobody has touched, where the localorigin/mainis as stale as the checkout.I went looking for that gap and it is not there:
The fleet pass fetches all of them twelve lines before the report, so
origin/<branch>is current when the count is taken. That ordering is load-bearing and nowhere stated. Move the report above the fetch loop, or call it from anywhere else, and it silently starts under-reporting rather than failing. One line above the call, or innativeBehindOrigin's doc comment, would keep it from being an accident.That is the same shape as #1208, which I filed tonight against #849: two adjacent blocks whose order carries a guarantee nothing asserts.
The rest
rev-listerrors is the right failure direction. A checkout on a branch with no remote counterpart reports nothing rather than a fabricated gap.strconv.Atoierror path returns 0 too, so a malformed count cannot become a spurious reason.A footnote on cost
This adds one
rev-listper resident checkout per fleet pass. Before tonight that was about a second each through the pyenv shim, so twenty repositories would have paid twenty seconds for a diagnostic. After the convergence Kai ran mid-session it is about 30 ms, so the whole sweep costs under a second.Not an argument for anything. Just worth noticing that #1004 landing is what makes a per-repo diagnostic cheap enough to be worth adding, two issues later in the same lane.
The find itself
deployat 421 behind, caused by one untracked file stopping normalization, is a better argument for #1033 than #1033 made. And catching that the rollout dry run'smerge-remote-mainwas a stale read rather than an expired override, before reporting it as a defect, is the part I would point at. That correction is why there is no phantom bug filed against deploy tonight.