Repository navigation
feat(bin): add read-only no-mistakes gate-ref divergence check - #87
Merged
Merged
Conversation
Add bin/fm-nomistakes-gate-check.sh to detect whether a local branch's HEAD has diverged from the no-mistakes pipeline's gate ref. The script resolves the no-mistakes remote, reads the gate config (v2:<sha>), and uses two git merge-base --is-ancestor checks to classify the relationship as equal, ahead, behind, or diverged. Wire a one-line pointer into the no-mistakes DOD block instructing workers to run the script after custody recovery on rebased branches. Add colocated test suite and the nomistakes-gate-ref-divergence-bug report with the detection recipe as a documented addendum. Co-authored-by: captain <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Add a read-only detection script, bin/fm-nomistakes-gate-check.sh, that checks whether a local branch's HEAD has diverged from the no-mistakes pipeline's own gate ref before pushing. It must resolve the gate repo hash, read the gate ref, run ancestry checks (git merge-base --is-ancestor in both directions) against local HEAD, and print exactly one of: equal, ahead, behind, diverged. It must never write or attempt to fix anything - detection only. Wire a one-line pointer into the ship brief scaffold (bin/fm-brief.sh) near its existing custody-recovery guidance (Rule 7 area): after any custody recovery on a rebased branch, run this script before pushing, and treat a 'diverged' result as an immediate blocked: report rather than pushing anyway. Also attach the detection recipe (the exact merge-base/ancestry approach used) as an addendum to the existing task nomistakes-gate-ref-divergence-bug's upstream report, so that report documents both the bug and the detection method. This originates from session-friction-gap-review Incident 4 (data/backlog.md task sfg-nomistakes-gate-check-tool) and is scoped as detection tooling only - it does not fix the underlying gate-ref divergence bug itself.
What Changed
bin/fm-nomistakes-gate-check.sh, a read-only script that resolves the no-mistakes remote, reads the gate config hash (v2:<hash>), and runsgit merge-base --is-ancestorin both directions against local HEAD (optionally a named branch), printing exactly one ofequal,ahead,behind, ordiverged; it exits 1 on usage errors, git errors, or an unreadable/invalid gate config and never writes or repairs anything.bin/fm-dod-lib.shbeside the existing custody-recovery guidance: after custody recovery on a rebased branch, run the script before pushing and treatdivergedas an immediateblocked:report.docs/scripts.mdtoolbelt inventory and addstests/fm-nomistakes-gate-check.test.shcovering the four status outcomes plus the error and--helppaths.Risk Assessment
✅ Low: Self-contained read-only detection script plus a one-line brief pointer; the previously flagged wrong-result paths (branch arg ignored in ancestry, fail-open diverged, unnormalized gate hash, gutted diagnostic) are all fixed and pinned by behavior tests, leaving only a redundant test-duplication note.
Testing
Beyond the green baseline
bin/fm-test-run.sh --changed, I ran the change's own 13-test suite (all pass) and then drove the script by hand against a purpose-built repo with a real no-mistakes gate remote, capturing a CLI transcript that walks an operator through all four status outputs, the branch argument, the unresolvable-gate refusal, and a before/after proof that nothing was written. I also rendered the definition-of-done block that fm-brief.sh emits to confirm the "run this before pushing, treat diverged as blocked:" line reaches the brief a crewmate reads. This is a CLI/text change with no rendered UI surface, so the transcript and rendered brief are the end-user-visible artifacts. No failures or flakiness observed.Evidence: CLI transcript: equal/ahead/behind/diverged, branch arg, refusal, read-only proof
Source: CLI transcript: equal/ahead/behind/diverged, branch arg, refusal, read-only proof
Evidence: Rendered brief showing the gate-check pointer a crewmate reads
Source: Rendered brief showing the gate-check pointer a crewmate reads
Evidence: Status outputs in sequence
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
tests/fm-nomistakes-gate-check.test.sh:263- Simplification: test_output_clean rebuilds all four fixture scenarios (equal/ahead/behind/diverged) only to assert the output is one of those four words with no trailing space — a strictly weaker assertion than tests 1-4, which already pin the exact word for each identical setup. Nothing in the intent requires a second parallel copy of the four-outcome matrix; removing it loses no coverage and drops ~90 lines of duplicated fixture code.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh --changed --exclude-family real-herdr-gatedbash tests/fm-nomistakes-gate-check.test.sh— all 13 behaviour tests pass (the prior round's failure no longer reproduces)Manual CLI walkthrough in a scratch repo with a realno-mistakesgate remote:bin/fm-nomistakes-gate-check.shat gate →equal, +1 local commit →ahead, reset before gate →behind, rewritten history →divergedbin/fm-nomistakes-gate-check.sh atgate— branch argument resolves the named branch (equal) while the checked-out branch isdivergedUnresolvable gate value (v2:44d8c1e6…) → exit 1 with the offending hash and config path in stderrRead-only check: HEAD,git status --porcelain, and gate repo contents identical before/after a runbin/fm-nomistakes-gate-check.sh --help— usage text matches the headerfm_dod_block no-mistakes demo-task— rendered brief contains the custody-recovery gate-check pointerbin/fm-nomistakes-gate-check.sh:1- The intent requires attaching the detection recipe as an addendum to task nomistakes-gate-ref-divergence-bug's upstream report. That report lives outside this worktree (no data/ directory here), so it cannot be written or verified from this change. Previously declined in review round 1 as missing-upstream-report-addendum; noted only.✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.