Repository navigation
fix(opencode): retry undetermined primacy probes - #54
Merged
levelupself merged 3 commits intoAug 14, 2026
Merged
Conversation
An actionable arm close restores continuity by re-checking that the root is a primary checkout. isPrimaryRoot() answered that question with a bare boolean, so "this is not a primary checkout" and "primacy could not be determined right now" collapsed into the same false. restoreAfterActionableClose() treats not-primary as a settled verdict and breaks out of its retry loop, so a single transient git spawn failure under process pressure permanently abandoned watcher continuity with the retry budget untouched. classifyPrimaryRoot() now returns primary, not-primary, or primacy-undetermined. Only the settled verdicts end restoration; an undetermined probe spends the ordinary bounded retries, which is the behaviour the same failure class already gets one step later when the successor arm's own spawn fails. Measured on one machine against the existing five-second poll in test_opencode_pre_ready_actionable_close_preserves_its_successor, with a real git failing rev-parse once at the post-release transition: before, the close completed in 8.6ms, restoration finished in 21.9ms and then stopped, and the poll expired at 5053.6ms holding two arm rows; after, the same condition recovers in 39.4ms with three rows. With no fault the transition takes 30.0ms against that unchanged 5000ms bound, so the deadline was never the constraint. The new regression test drives the coordinator through its public hook with a real git that fails --git-dir exactly once after the first arm has run, and asserts the fault actually fired so the case cannot pass vacuously.
levelupself
pushed a commit
that referenced
this pull request
Aug 16, 2026
origin/main advanced by two commits while this branch waited on a merge decision: #55 (render fleet panes to drawn geometry) and #57 (require local suite evidence when CI is unavailable). The opencode primacy-probe fix (#54) was already an ancestor of this branch. One conflict, in bin/fm-brief.sh, and it lands on a file this branch had already resolved once. #57 replaces the literal no-mistakes deliverable sentence with a $READY_DELIVERABLE variable selected by whether the repository can demonstrate a working CI check gate. The incoming variable is kept, because that feature is the point of #57 - but both of its definitions reintroduced "This project ships", silently reverting the per-task noun this branch had unified across the direct-PR, local-only and no-mistakes blocks. The noun is re-applied to both definitions, so the generated brief stays internally consistent. The other four files touched by the incoming work had also been resolved once on this branch (AGENTS.md, bin/backends/herdr.sh, docs/herdr-backend.md, tests/fm-brief.test.sh). Each auto-merged, and each round-one decision was re-verified as still present rather than assumed.
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
Fix an abandonment defect in .opencode/plugins/fm-primary-watch-arm.js: a primacy probe that could not complete must be distinguishable from a genuine not-primary result, and the undetermined case must spend its existing bounded retries.
BACKGROUND AND SUPERSESSION. This task was originally briefed as a test-side change: replace a deadline-based post-release wait in tests/fm-pi-watch-extension.test.sh with a signalled checkpoint, on the theory that the post-release child-close and restoration chain was completing late and overrunning a fixed five-second poll. That instruction has been explicitly WITHDRAWN and must NOT be implemented. Instrumented measurement disproved the scheduling theory: the post-release transition completes in 30-41ms against the unchanged 5000ms bound (50-160x margin), and 36/36 runs passed under 12-way parallelism. The real defect is coordinator state, not scheduling.
THE DEFECT. isPrimaryRoot() answered a three-way question with a bare boolean: "this is not a primary checkout" and "primacy could not be determined right now" both returned false, because runProcess() maps a failed git spawn to a non-zero code. restoreAfterActionableClose() treats not-primary as a settled verdict and breaks out of its retry loop, so one transient git spawn failure under process pressure permanently abandoned watcher continuity with the retry budget untouched. The same transient failure class one step later, when the successor arm's own spawn fails, is already retried and recovers - that asymmetry is the proof it was unintended.
THE ACCEPTED FIX (option a, scoped). classifyPrimaryRoot() returns primary, not-primary, or primacy-undetermined. Only settled verdicts (not-primary, read-only, skipped) end restoration; primacy-undetermined falls through to the ordinary bounded retries. A new regression test drives the coordinator through its public hook against a real git that fails --git-dir exactly once after the first arm has run, and asserts the injected fault actually fired so the case cannot pass vacuously. docs/watcher-continuity.md records the distinction at its existing owner paragraph.
HARD EXCLUSIONS. Do not enlarge the five-second poll, add a retry, insert a sleep, or relax any assertion in tests/fm-pi-watch-extension.test.sh - the existing deadline is deliberately untouched, because leaving it untouched is what proves the deadline was never the defect. Do not undertake a file-wide sweep of the other deadline-based waits in that file (31 bounded polls and 10 unconditional sleeps remain); that is real and is being filed as separate work, and bundling it here would turn a one-line correctness fix into an unreviewable change. Do not convert this into a test-only change.
VERIFICATION ALREADY ESTABLISHED. Previously failing assertion, same machine, existing 5000ms poll, with a real git failing rev-parse once at the post-release transition: before the fix, close observed at 8.6ms, restoration finished at 21.9ms and then stopped, poll expired at 5053.6ms holding 2 arm rows (FAIL); after the fix, the same condition recovers at 39.4ms with 3 rows (PASS). With no fault injected the transition takes 30.0ms against the unchanged 5000ms bound. The new regression test was confirmed red-first: reverting only the plugin to HEAD yields "restoration abandoned its successor after an undetermined primacy probe" with a single arm row.
PRE-EXISTING SUITE STATE. The full suite at this commit reports total=153 failed=6 skipped_gate=20. All six failing scripts (fm-remote-job-orphan-reap, fm-remote-secondmate-lifecycle-e2e, fm-secondmate-sync, fm-startup-memory-budget, fm-bootstrap, fm-cockpit-herdr-e2e) fail identically at the base commit db7a847 and are unrelated to this change; the watcher-wake-lock family containing the changed test reports failed=0.
ARTIFACT STYLE CONSTRAINT. Pipeline-authored risk rationales, fix summaries, and PR bodies must use role-neutral prose with no second person and no captain, user, firstmate, or crewmate role nouns. This constraint does not apply to product code, prompts, or user-facing copy.
What Changed
primacy-undeterminedprobe failures from settlednot-primaryresults so watcher restoration uses its existing bounded retries.Risk Assessment
✅ Low: The change is narrowly scoped and correctly preserves settled primacy verdicts while routing an undetermined probe through the existing bounded restoration retries, with behavioral regression coverage and no forbidden deadline changes.
Testing
Scope inspection, diff validation, and the targeted watcher-extension behavioral family all passed; the public OpenCode coordinator hook demonstrably spent its bounded retry after an injected one-shot Git primacy-probe failure and restored watcher continuity, with the transcript preserved as reviewer evidence.
Evidence: Targeted watcher-extension behavioral transcript
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
✅ **Review** - passed
✅ No issues found.
✅ **Test** - passed
✅ No issues found.
git diff --check a5fb89d1d4d020d4de8a29f87033be80b70fe686..a8f095e3078d0758ba0148f6f388d4847b0ea575Inspectedgit diff a5fb89d1d4d020d4de8a29f87033be80b70fe686..a8f095e3078d0758ba0148f6f388d4847b0ea575to confirm the withdrawn deadline/sleep/assertion changes were absentbash tests/fm-pi-watch-extension.test.sh 2>&1 | tee /tmp/no-mistakes-evidence/01KZZV0YM8P1GD6M2DNFTMXT1P/fm-pi-watch-extension-targeted.logVerified the test left the git worktree free of transient test artifacts withgit status --short✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.