Repository navigation
feat(bin): recover workers from a crash-stranded no-mistakes gate ref via a fresh branch - #4938
Open
markhomexa wants to merge 3 commits into
Open
markhomexa wants to merge 3 commits into
markhomexa wants to merge 3 commits into
Conversation
…workers to a safe fresh-branch remedy Add bin/fm-nm-stranded-gate.sh, a read-only check that compares the gate mirror's ref for the current branch with HEAD by cherry-pick equivalence and prints the fresh-branch command only when the mirror ref holds nothing HEAD lacks; any unlanded commit, including a merge, is refused. The no-mistakes Definition of done points workers at it, and stuck-crewmate-recovery tells firstmate how to treat a refusal.
21 tasks
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
A pipeline crash strands the validation gate ref, and no supported path recovers it. Hit TWICE on 2026-09-18/19, on two different lanes, hours apart.
After a daemon crash or a killed fix round, the private validation mirror (~/.no-mistakes/repos/.git) keeps the PRE-rebase ref for the branch while custody recovery leaves the worker on the rebased head, so every later
no-mistakes axi rundies before its first step with "push to gate: ! [rejected] (non-fast-forward)". The tool's own structured path is a dead end:axi sync --checkreports relation=equal, custody_returned, next_action=run_pipeline, andaxi sync --recover --keep-localruns as a documented no-op (changed=false) and leaves the ref unmoved. Both workers independently concluded the only ways out were forcing the shared mirror ref or updating the shared daemon, and both correctly refused - that daemon serves every lane on the machine.The workaround that worked both times: verify with
git log --cherry-pick --left-only/--right-onlythat the stranded ref holds nothing the current head lacks, then re-run on a FRESH branch name, which the mirror accepts as an ordinary new ref.What Changed
bin/fm-nm-stranded-gate.sh, a read-only check that detects a mirror ref left on the pre-rebase tip after a crash. Whengit rev-list --cherry-pick --left-onlyshows that every stranded commit is already inHEAD, it printsfresh_branch:andnext:lines with the safe fresh-branch remedy. It refuses in three cases: the ref holds commitsHEADlacks (listed asunlanded:), a PR is open on the stranded branch (open_pr:), or it can't prove that no such PR exists. It never fetches, pushes, or writes to the mirror, and it never contacts the daemon. Exit codes: 0 means the remedy is safe, 1 means refused, 2 means an error, 3 means not stranded.tests/fm-nm-stranded-gate.test.shcovers the helper.bin/fm-dod-lib.shnow covers apush to gatenon-fast-forward rejection thataxi syncreports nothing to recover from. It gives the helper's absolute path, forbids forcing the mirror ref or touching the daemon, and says how to act on each helper outcome.tests/fm-brief.test.shchecks that no-mistakes briefs name an executable helper path and that direct-PR briefs leave it out.stuck-crewmate-recoveryskill trigger (in the skill and inAGENTS.md) now includes a non-fast-forward gate push refusal. The skill routes that case to the helper, and when the helper refuses it says to preserve the work and escalate.docs/scripts.mdlists the new helper.🤖 Generated with Claude Code
Risk Assessment
✅ Low: The change adds a read-only helper and brief routing for a stranded gate ref. The fix round does what the user asked: the helper now refuses when a PR is open on the stranded branch or when gh cannot rule one out, and the unlanded-commit refusal is still checked first. It only lists PRs, never changes one, and queries them the same way the existing teardown and pr-check scripts do. A fake gh covers the three cases (open PR, failed query, no PR), and the brief now routes any other helper outcome to rule 7's blocked report.
Testing
Ran the two focused test files (the helper's tests and the brief's new test); both passed. Then I drove the helper live against real git bare mirrors and the real gh CLI. First I reproduced the crash symptom: a rebased branch's gate push was rejected as non-fast-forward. The helper recommended <branch>-r2. Following its next: lines produced a push the mirror accepted as a new branch, and the stranded ref was left unchanged. In the adversarial checks the helper refused in each case: unlanded mirror commits, a real open PR (#4935, which stayed open and untouched), a gh auth failure, and gh missing from PATH. I also checked the not-stranded (exit 3) and missing-remote (exit 2) outcomes and captured the rendered worker brief. Every scenario passed. The daemon-backedno-mistakes axi runitself was not driven, because this phase must not init or run another pipeline; a git push to a bare mirror stood in for its first step. There is no UI surface, so no screenshots.no-mistakes axi runagainst the shared daemon from the fresh branch succeedsno-mistakes axi runfrom a fresh b…Evidence: Live transcript: crash-stranded ref reproduced, fresh-branch remedy accepted by mirror, unlanded-commit refusal, exit 3/2 outcomes
Source: Live transcript: crash-stranded ref reproduced, fresh-branch remedy accepted by mirror, unlanded-commit refusal, exit 3/2 outcomes
Evidence: Live transcript: refusal on real open PR #4935, gh auth failure, gh missing; mirror fingerprint unchanged, PR still open
Source: Live transcript: refusal on real open PR #4935, gh auth failure, gh missing; mirror fingerprint unchanged, PR still open
Evidence: Rendered no-mistakes worker brief excerpt routing to the helper
Source: Rendered no-mistakes worker brief excerpt routing to the helper
Evidence: Focused helper test run
Source: Focused helper test run
Notes
action_required, held for maintainer approval as fork PRs are. They have zero jobs, so nothing failed. The pipeline's CI step was accepted with no code change, and nothing was auto-fixed on top.axi sync --recovershould return custody without leaving the gate mirror stranded at the pre-rebase ref. An upstream report has not been filed.Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed ✅
bin/fm-nm-stranded-gate.sh:143- The fresh-branch remedy says onlygit switch -c <base>-rNand 're-run the same no-mistakes axi run invocation'. It never checks for, or mentions, a PR that is already open on origin for the stranded branch. The intent's trigger includes a 'killed fix round', and a CI fix round can run after the pipeline has already pushed the old branch and opened its PR. In that case, following thesenext:lines makes the pipeline open a second PR fromfm/<id>-r2, and the original PR stays open with nothing tracking it. Teardown resolves PRs from the current branch or the recordedpr=, so it never sees the old one. Fixing this means adding PR detection or supersede/close guidance to the remedy, which goes beyond the workaround the intent describes, so the author needs to decide whether the helper or the brief should cover it.bin/fm-dod-lib.sh:290- The brief tells the worker what to do when the helper printsfresh_branch:(exit 0) or refuses (exit 1). It says nothing for exit 3 (not-stranded) or exit 2 (for example, nono-mistakesremote). A worker whose non-fast-forward push has some other cause would get no direction. A short clause routing those outcomes to the existing rule-7 block report would close the gap.🔧 Fix applied.
✅ Re-checked - no issues remain.
✅ **Test** - passed
✅ No issues found.
no-mistakes axi runagainst the shared daemon from the fresh branch succeedsno-mistakes axi runfrom a fresh b…bash tests/fm-nm-stranded-gate.test.sh(8 behavior tests, fake gh, all ok)bash tests/fm-brief.test.sh(new test_no_mistakes_dod_names_stranded_gate_helper ok)Live repro: bare mirror asno-mistakesremote, pushed the pre-rebase tip, rebased onto an advanced main, realgit pushrejected non-fast-forward, ran helper with the real gh against kunchenguid/firstmate, rangit switch -c <branch>-r2and pushed; mirror accepted the new ref and the stranded ref was unchangedLive adversarial: rewrote the mirror ref to include a commit HEAD lacks -> helper refused with unlanded: line, exit 1Live adversarial: stranded branch named fm/fm-ship-4784, which has real open PR #4935 -> real gh query, helper refused with open_pr URL, exit 1; PR still OPEN afterwards; mirror byte fingerprint identical; no fresh branch createdLive adversarial: bogus GH_TOKEN plus empty GH_CONFIG_DIR, and gh removed from PATH -> both refused with 'could not prove no PR is open'Live: fast-forwardable branch -> not-stranded exit 3; missing no-mistakes remote -> error exit 2Rendered a real no-mistakes brief withbin/fm-brief.sh --mode no-mistakesand captured the stranded-gate guidance, which names the helper by absolute path✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.