Repository navigation
feat(bin): settle declared captain holds from forge PR events - #8422
Conversation
Keep forge settlement opt-in and preserve unfinished work through an explicit release policy. Record merge or closure evidence without claiming a captain answer, and report unmerged closures through contribution notifications. Fixes kunchenguid#8368
[Medium impact] The PR appears safe to merge; both previous findings are fixed and no new actionable issues remain. Reviews (2) · Last reviewed commit: "no-mistakes(ci): Both selected Greptile ..." · Reviewed by Greptile |
…ktree; nothing is committed. Invariants and sites: - ci-2: the contribution poll must never wait on a lock longer than the watcher's 30-second check bound. `settle-pr` takes two locks. The away-record lock was already bounded to 1 second. The task control lock was the only unbounded site, so `command_settle_pr` in bin/fm-captain-hold.sh now takes it with `fm_lock_acquire_wait_bounded ... 1` and returns 0 silently when busy. The policy file stays, so a later poll retries. The other callers of `acquire_task_control_lock` are captain or firstmate commands, not the poll, and are unchanged. - ci-3: a `closed` event and wake go only to a task that is an open captain hold at the moment the event is raised. `terminal_hold_event` in bin/fm-contributions.sh is the single place that raises it (the settled, final and live paths all call it). It now runs `fm-captain-hold.sh open <task>` after the cheap snapshot filter and before `write_record`, so only rows about to raise an event pay for the process. Tests added to tests/fm-contributions.test.sh: - `test_forge_settlement_defers_while_the_task_is_busy`: a held control lock makes the poll and a direct `settle-pr` return 0 with no output inside the bound, keep the policy and the hold, then settle once the lock is free. - `test_settled_task_gets_no_closed_event_for_its_other_pr`: one task with two closed PRs, the first settles the hold, the second raises no poll line, wake or `closed` event. I confirmed it fails without the bin/fm-contributions.sh fix (`not ok - the second closed PR woke a task settled in the same poll`) and passes with it. - The lock-holder fixture of the existing away-record-lock test became a shared `hold_lock` helper. docs/captain-hold-lifecycle.md gained one sentence on the busy-task deferral and an updated test list. Verification: `nice -n 10 bash bin/fm-test-run.sh tests/fm-contributions.test.sh` exited 0 (`FM_TEST_SUMMARY total=1 failed=0`, about 335 seconds). No other suite was run, as instructed. ci-1 (Full suite) remains a recorded CI override: it is only the full-ci label gate, no code or workflow was changed for it, and the hosted full suite did not pass. Not checked and risks: - The busy-lock test was not run against the old code, because the old unbounded wait would hang the test instead of failing it. - When a busy control lock defers settlement of a closed PR, the policy file remains, so that poll still raises the `closed` event and wake for the still-held task. That matches the existing away-deferral behaviour and was left unchanged. - Shellcheck was not run
|
Speaking as Kun's firstmate: thanks @tiago-peixoto. This settles a held task only when its hold declares which PR event answers it, and records that as forge evidence rather than a captain answer. That fits the condition from the #8368 notes: a merge or closure retires only the hold whose question it answers, and leaves unrelated work alone. What I checked on head Contract class (my own read): opt-in. Every new path checks Full suite queued. The maintainer |
|
Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this. |
A captain hold now requires --class. The forge PR-event settlement cases that arrived on the default branch with kunchenguid#8422 held calls without one: the merge and PR-decision holds are merge-or-landing-outside-authority calls, and the unrelated, rework, and reopen holds use product-or-scope-expansion.
Intent
Implement #8368, which Kun's side approved for a PR (ready-for-pr): a task held for the captain stays open after the PR it gates merges or is closed on the forge, so the captain is asked again about a settled PR.
What the issue expects:
Our comment on the issue (#8368 (comment)) narrows the cause: held tasks can already carry structured PR links through tasks-axi add/update --pr, and bin/fm-contributions.sh and the merge poll can observe those PRs after the worker stops. What is missing is settling the held task itself. A merge or closure must not complete unrelated unfinished work.
Build the new behaviour opt-in from the first commit.
Fixes
#8368What Changed
bin/fm-captain-hold.shgains two commands behind the new opt-inconfig/hold-pr-settlepresence flag.pr-policy <task> <PR-url> <merged|closed|terminal> <close|release>declares which forge event answers one hold and writesdata/<task>/hold-pr-policy.json.settle-pr <task> <PR-url>reads the contribution observer's validated terminal observation, records it asforge-closedorforge-releasedreconciliation evidence (never as a captain answer), then closes or unholds the task. A structured PR link alone never settles a hold. A policy is dropped with a diagnostic when the held question changed or the PR ended in the other terminal state, areleasepolicy waits while the home is away or the away-posture lock is busy, and an interrupted settlement resumes without a second resolution record.bin/fm-contributions.shcallssettle-prfor fresh and retained merged or closed PR observations, so settlement needs no model turn. It also publishes one durableclosedpending event per owning task that is still an open captain hold when a PR closes without merging. With the flag absent, neither the settlement nor the closure notification runs.fm_afk_contract_lock_holdinbin/fm-afk-contract.shaccepts an optional timeout so the release path defers quickly on a busy lock.tests/fm-contributions.test.shadds cases for declared-only settlement, default-off behavior, policy guards, retry after interruption, rejected uncertain evidence, away deferral, follow-up PR links, and closure reports. The captain-hold skill,docs/captain-hold-lifecycle.md,docs/configuration.md, anddocs/scripts.mddocument the flag and the settlement policy.Risk Assessment
✅ Low: The change is opt-in behind config/hold-pr-settle, every earlier finding is fixed in the current code as I traced it (away deferral under the away-record lock with a 1-second bound, hold-only closed events, one jq pass for retained rows, silent success), and I found no reachable wrong settlement, only two informational tradeoffs.
Testing
I drove the real
bin/fm-captain-hold.sh,bin/fm-contributions.sh,bin/fm-tasks-axi.shandbin/fm-afk-contract.shagainst eight disposable homes, with a localghemulator standing in for GitHub. The eight scenarios covered merged and unmerged closure, the opt-in flag, two attempts to settle a hold the PR event does not answer, added links, an away home and a busy away-record lock; all 29 checks passed. The repository's owntests/fm-contributions.test.shalso passed with exit 0. No UI surface exists, so the evidence is a command transcript, not a screenshot. Not exercised: real GitHub, and a full watcher process (I ran the check shim that the watcher runs, not the watcher itself).terminal closedeclaration settles its hold, the held task without a declaration gets oneclosedevent and one wake, and a task without…config/hold-pr-settlethe declaration is refused and a merged PR settles nothing; creating the flag applies the retained merged observation on the next pollmergedbut the PR closes unmerged; the hold stays open, the poll prints one diagnostic, the closure is reported, and the next poll is silentreleaseis deferred silently while the away record exists and is applied on the first poll after the captain returns, without completing the workfm-afk-contract.sh archiveEvidence: Live transcript of all 8 scenarios (29 checks, 0 failed)
Source: Live transcript of all 8 scenarios (29 checks, 0 failed)
Evidence: Driver script that produced the transcript
Source: Driver script that produced the transcript
Evidence: Output of tests/fm-contributions.test.sh (exit 0)
Source: Output of tests/fm-contributions.test.sh (exit 0)
Evidence: Settled task after the emulated merge (from the S1 transcript)
Evidence: Mismatched declaration is dropped with one diagnostic (from the S4 transcript)
Pipeline
Updates from git push no-mistakes
✅ **Intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-captain-hold.sh:1904- The recorded round 1 decision to fix this is not in the reviewed commit.settle-prwith actionreleasestill runstasks_axi unholdwith norelease_attendedcheck, whilecommand_answer --release(line 1348, 1355) and the keyed-answer intake (line 1606) refuse whilestate/.afkreads away or the away-posture record exists. Concrete sequence: firstmate declarespr-policy task URL merged release, the captain goes away, the PR merges, the next contribution poll frees the captain-gated work item unattended. Fix consistent with the existing rule: incommand_settle_pr, when the action isreleaseandrelease_attendedfails, return 0 beforewrite_resolution_recordso the policy file stays and a later poll retries after the captain returns. Also state the deferral in docs/captain-hold-lifecycle.md (PR settlement section) and add a test with the away record present. Thecloseaction is not affected.bin/fm-contributions.sh:656- The recorded round 1 decision to fix this is not in the reviewed commit. Withconfig/hold-pr-settlepresent, every poll callsterminal_hold_eventfor every settled (task, URL) pair before the live forge reads. Each call spawns twojqprocesses (lines 572 and 580). For a closed-unmerged PR whoseclosedtoken is already inseen, the second jq still prints the unchanged row, so line 587 also runswrite_record(two more jq and a rename) andpublish_pendingon every poll forever.test_many_settled_records_keep_the_poll_inside_the_check_bound(151 settled records, 50 ms per jq, 20-second bound) passes only because the flag is absent there. Fix without changing behaviour: select the pairs that need work with one jq pass over$TMP/saved.json(stateclosedand noclosedtoken inseen), callsettle-pronly where$DATA/$task/hold-pr-policy.jsonexists, and emit nothing from the jq at line 580 when the token is already seen. Sibling in bin/fm-captain-hold.shcommand_settle_pr: a policy whose task was answered or whose fingerprint went stale is never removed, so each poll spawnssettle-pr(lock, jq,tasks-axi show) for it indefinitely. Remove the policy file on thosereturn 0paths (task done, hold kind not captain, fingerprint mismatch). The live-loop call at line 718 is one call per fresh observation and is fine.bin/fm-contributions.sh:580- The recorded round 1 decision to fix this is not in the reviewed commit. Theclosedpending event and its wake are still raised for every task that owns a closed-unmerged PR, not only for tasks with an open captain hold. The first poll after someone creates the flag replays retained observations and raises one wake per historical closed-unmerged PR in the home. Narrow the event to tasks that are an open captain hold (for examplefm-captain-hold.sh open "$task", checked only for the few rows that pass the cheap closed-and-unseen filter). That also decides the related gap: a hold task linked after another owner already received the event inherits that owner'sseenlist throughsettle_final(line 603) and never gets its own event. Sibling text that must follow the same scope: docs/configuration.md:830 ("whether or not that event settles a hold" stays true, but add that only held tasks are reported), the header comment at bin/fm-contributions.sh:100-104, andtest_forge_settles_only_declared_holds, which should also assert that an unheld task owning the closed PR gets noclosedevent.bin/fm-captain-hold.sh:1821-pr_hold_fingerprinthashes thetitlefield oftasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: aftertasks-axi update t1 --pr .../pull/2the shown title readx https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declarespr-policy task .../pull/8 merged close, then a follow-up PR is linked withtasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, sosettle-prreturns 0 silently at line 1900 when PR 8 merges. The hold stays open and the captain is asked about a merged PR, which is the failure issue 8368 reports. Nothing tells firstmate the policy went stale. Fix: strip the link URLs listed in the shownlinksfield from the title before hashing (or hash only the hold reason, hold-set timestamp and record count), and print one line when a declared policy is dropped as stale. Add a test that links a second PR afterpr-policyand expects settlement. Re-linking the same URL is idempotent and is not affected.bin/fm-captain-hold.sh:1910-settle-prprintspr-settled: ...on stdout, andterminal_hold_event(bin/fm-contributions.sh:576) does not redirect it, so the line becomes poll output. bin/fm-watch.sh:4273-4284 treats every poll line that is notcontribution-wake: check: contributions ...as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate withcheck: contributions.check.sh: pr-settled: ..., in the same channel as observer failures. The settlement itself completes without a model turn, so the intent line "without a captain answer and without a model turn" is met, but the wake is undocumented and the parent channel already publishes the resolution. Decide one: discard the success line in the observer (>/dev/nullat the call) for silent settlement, or keep the wake and document it in docs/configuration.md. No test asserts either behaviour today.🔧 Fix applied.
4 warnings still open:
bin/fm-captain-hold.sh:1904- The recorded round 1 decision to fix this is not in the reviewed commit.settle-prwith actionreleasestill runstasks_axi unholdwith norelease_attendedcheck, whilecommand_answer --release(line 1348, 1355) and the keyed-answer intake (line 1606) refuse whilestate/.afkreads away or the away-posture record exists. Concrete sequence: firstmate declarespr-policy task URL merged release, the captain goes away, the PR merges, the next contribution poll frees the captain-gated work item unattended. Fix consistent with the existing rule: incommand_settle_pr, when the action isreleaseandrelease_attendedfails, return 0 beforewrite_resolution_recordso the policy file stays and a later poll retries after the captain returns. Also state the deferral in docs/captain-hold-lifecycle.md (PR settlement section) and add a test with the away record present. Thecloseaction is not affected.bin/fm-captain-hold.sh:1821-pr_hold_fingerprinthashes thetitlefield oftasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: aftertasks-axi update t1 --pr .../pull/2the shown title readx https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declarespr-policy task .../pull/8 merged close, then a follow-up PR is linked withtasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, sosettle-prreturns 0 silently at line 1900 when PR 8 merges. The hold stays open and the captain is asked about a merged PR, which is the failure issue 8368 reports. Nothing tells firstmate the policy went stale. Fix: strip the link URLs listed in the shownlinksfield from the title before hashing (or hash only the hold reason, hold-set timestamp and record count), and print one line when a declared policy is dropped as stale. Add a test that links a second PR afterpr-policyand expects settlement. Re-linking the same URL is idempotent and is not affected.bin/fm-captain-hold.sh:1910-settle-prprintspr-settled: ...on stdout, andterminal_hold_event(bin/fm-contributions.sh:576) does not redirect it, so the line becomes poll output. bin/fm-watch.sh:4273-4284 treats every poll line that is notcontribution-wake: check: contributions ...as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate withcheck: contributions.check.sh: pr-settled: ..., in the same channel as observer failures. The settlement itself completes without a model turn, so the intent line "without a captain answer and without a model turn" is met, but the wake is undocumented and the parent channel already publishes the resolution. Decide one: discard the success line in the observer (>/dev/nullat the call) for silent settlement, or keep the wake and document it in docs/configuration.md. No test asserts either behaviour today.bin/fm-captain-hold.sh:1834- Sibling left behind by the round 1 fix forfingerprint-covers-links-in-shown-title.pr_hold_fingerprintremoves onlypr:links from the shown title, but the markdown backend also shows areport:link there. I confirmed this withtasks-axi update t1 --report data/t1/report.md: the title becameTitle one https://github.com/o/r/pull/8 data/t1/report.mdand links becamepr:...,report:data/t1/report.md. Concrete sequence: firstmate holds an investigation task and declarespr-policy task URL merged close. The worker finishes, and cleanup keeps the held row throughfm_backlog_retain(bin/fm-backlog-transition-lib.sh:578), which runsupdate --report <path>. The title now differs, so when the PR mergessettle-prreaches line 1922, removes the policy, and fails with 'its question changed'. The hold stays open and the captain is asked about a merged PR, which is the case the change exists to prevent. The failure direction is safe, because nothing is closed wrongly. Fix: drop every structured link word from the title, not onlypr:ones, for example match*",report:$word,"*beside thepr:pattern. Extend the comment-backed case at tests/fm-contributions.test.sh:2113 with a--reportupdate so the retained report path is exercised. No other sibling site: the fingerprint is computed only at lines 1855 and 1922, both through this function.🔧 Fix applied.
5 warnings still open:
bin/fm-captain-hold.sh:1904- The recorded round 1 decision to fix this is not in the reviewed commit.settle-prwith actionreleasestill runstasks_axi unholdwith norelease_attendedcheck, whilecommand_answer --release(line 1348, 1355) and the keyed-answer intake (line 1606) refuse whilestate/.afkreads away or the away-posture record exists. Concrete sequence: firstmate declarespr-policy task URL merged release, the captain goes away, the PR merges, the next contribution poll frees the captain-gated work item unattended. Fix consistent with the existing rule: incommand_settle_pr, when the action isreleaseandrelease_attendedfails, return 0 beforewrite_resolution_recordso the policy file stays and a later poll retries after the captain returns. Also state the deferral in docs/captain-hold-lifecycle.md (PR settlement section) and add a test with the away record present. Thecloseaction is not affected.bin/fm-captain-hold.sh:1821-pr_hold_fingerprinthashes thetitlefield oftasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: aftertasks-axi update t1 --pr .../pull/2the shown title readx https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declarespr-policy task .../pull/8 merged close, then a follow-up PR is linked withtasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, sosettle-prreturns 0 silently at line 1900 when PR 8 merges. The hold stays open and the captain is asked about a merged PR, which is the failure issue 8368 reports. Nothing tells firstmate the policy went stale. Fix: strip the link URLs listed in the shownlinksfield from the title before hashing (or hash only the hold reason, hold-set timestamp and record count), and print one line when a declared policy is dropped as stale. Add a test that links a second PR afterpr-policyand expects settlement. Re-linking the same URL is idempotent and is not affected.bin/fm-captain-hold.sh:1910-settle-prprintspr-settled: ...on stdout, andterminal_hold_event(bin/fm-contributions.sh:576) does not redirect it, so the line becomes poll output. bin/fm-watch.sh:4273-4284 treats every poll line that is notcontribution-wake: check: contributions ...as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate withcheck: contributions.check.sh: pr-settled: ..., in the same channel as observer failures. The settlement itself completes without a model turn, so the intent line "without a captain answer and without a model turn" is met, but the wake is undocumented and the parent channel already publishes the resolution. Decide one: discard the success line in the observer (>/dev/nullat the call) for silent settlement, or keep the wake and document it in docs/configuration.md. No test asserts either behaviour today.bin/fm-captain-hold.sh:1834- Sibling left behind by the round 1 fix forfingerprint-covers-links-in-shown-title.pr_hold_fingerprintremoves onlypr:links from the shown title, but the markdown backend also shows areport:link there. I confirmed this withtasks-axi update t1 --report data/t1/report.md: the title becameTitle one https://github.com/o/r/pull/8 data/t1/report.mdand links becamepr:...,report:data/t1/report.md. Concrete sequence: firstmate holds an investigation task and declarespr-policy task URL merged close. The worker finishes, and cleanup keeps the held row throughfm_backlog_retain(bin/fm-backlog-transition-lib.sh:578), which runsupdate --report <path>. The title now differs, so when the PR mergessettle-prreaches line 1922, removes the policy, and fails with 'its question changed'. The hold stays open and the captain is asked about a merged PR, which is the case the change exists to prevent. The failure direction is safe, because nothing is closed wrongly. Fix: drop every structured link word from the title, not onlypr:ones, for example match*",report:$word,"*beside thepr:pattern. Extend the comment-backed case at tests/fm-contributions.test.sh:2113 with a--reportupdate so the retained report path is exercised. No other sibling site: the fingerprint is computed only at lines 1855 and 1922, both through this function.bin/fm-captain-hold.sh:1905- Sibling gap left by the round 2 fix forrelease-bypasses-attended-only.settle-prwith actionreleasereadsrelease_attendedonce and then writes the resolution record and runstasks_axi unholdwithout holding the away-record lock. The captain's own release path does hold it:command_answer --releasecallsfm_afk_contract_lock_hold "$STATE"at bin/fm-captain-hold.sh:1359 and re-checksrelease_attendedat line 1360, because bin/fm-afk-contract.sh:118-121 requires a reader that acts on the record to hold the lock across both the read and the action. Concrete sequence: a declaredmerged releasePR merges, the poll runssettle-pr, the check at line 1905 passes, the captain's/afkentry writes the away record, then line 1930 releases the captain hold while the home is away. That is the outcome the recorded decision forbids, in a window of roughly one second per settlement. Fix: when the action isrelease, callfm_afk_contract_lock_hold "$STATE" || return 0before therelease_attendedcheck, so a locked or away record defers to the next poll. No other site needs the change: thecloseaction is not gated, and line 1611 only pre-screens beforecommand_answertakes the lock.🔧 Fix applied.
6 warnings still open:
bin/fm-captain-hold.sh:1904- The recorded round 1 decision to fix this is not in the reviewed commit.settle-prwith actionreleasestill runstasks_axi unholdwith norelease_attendedcheck, whilecommand_answer --release(line 1348, 1355) and the keyed-answer intake (line 1606) refuse whilestate/.afkreads away or the away-posture record exists. Concrete sequence: firstmate declarespr-policy task URL merged release, the captain goes away, the PR merges, the next contribution poll frees the captain-gated work item unattended. Fix consistent with the existing rule: incommand_settle_pr, when the action isreleaseandrelease_attendedfails, return 0 beforewrite_resolution_recordso the policy file stays and a later poll retries after the captain returns. Also state the deferral in docs/captain-hold-lifecycle.md (PR settlement section) and add a test with the away record present. Thecloseaction is not affected.bin/fm-captain-hold.sh:1821-pr_hold_fingerprinthashes thetitlefield oftasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: aftertasks-axi update t1 --pr .../pull/2the shown title readx https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declarespr-policy task .../pull/8 merged close, then a follow-up PR is linked withtasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, sosettle-prreturns 0 silently at line 1900 when PR 8 merges. The hold stays open and the captain is asked about a merged PR, which is the failure issue 8368 reports. Nothing tells firstmate the policy went stale. Fix: strip the link URLs listed in the shownlinksfield from the title before hashing (or hash only the hold reason, hold-set timestamp and record count), and print one line when a declared policy is dropped as stale. Add a test that links a second PR afterpr-policyand expects settlement. Re-linking the same URL is idempotent and is not affected.bin/fm-captain-hold.sh:1910-settle-prprintspr-settled: ...on stdout, andterminal_hold_event(bin/fm-contributions.sh:576) does not redirect it, so the line becomes poll output. bin/fm-watch.sh:4273-4284 treats every poll line that is notcontribution-wake: check: contributions ...as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate withcheck: contributions.check.sh: pr-settled: ..., in the same channel as observer failures. The settlement itself completes without a model turn, so the intent line "without a captain answer and without a model turn" is met, but the wake is undocumented and the parent channel already publishes the resolution. Decide one: discard the success line in the observer (>/dev/nullat the call) for silent settlement, or keep the wake and document it in docs/configuration.md. No test asserts either behaviour today.bin/fm-captain-hold.sh:1834- Sibling left behind by the round 1 fix forfingerprint-covers-links-in-shown-title.pr_hold_fingerprintremoves onlypr:links from the shown title, but the markdown backend also shows areport:link there. I confirmed this withtasks-axi update t1 --report data/t1/report.md: the title becameTitle one https://github.com/o/r/pull/8 data/t1/report.mdand links becamepr:...,report:data/t1/report.md. Concrete sequence: firstmate holds an investigation task and declarespr-policy task URL merged close. The worker finishes, and cleanup keeps the held row throughfm_backlog_retain(bin/fm-backlog-transition-lib.sh:578), which runsupdate --report <path>. The title now differs, so when the PR mergessettle-prreaches line 1922, removes the policy, and fails with 'its question changed'. The hold stays open and the captain is asked about a merged PR, which is the case the change exists to prevent. The failure direction is safe, because nothing is closed wrongly. Fix: drop every structured link word from the title, not onlypr:ones, for example match*",report:$word,"*beside thepr:pattern. Extend the comment-backed case at tests/fm-contributions.test.sh:2113 with a--reportupdate so the retained report path is exercised. No other sibling site: the fingerprint is computed only at lines 1855 and 1922, both through this function.bin/fm-captain-hold.sh:1905- Sibling gap left by the round 2 fix forrelease-bypasses-attended-only.settle-prwith actionreleasereadsrelease_attendedonce and then writes the resolution record and runstasks_axi unholdwithout holding the away-record lock. The captain's own release path does hold it:command_answer --releasecallsfm_afk_contract_lock_hold "$STATE"at bin/fm-captain-hold.sh:1359 and re-checksrelease_attendedat line 1360, because bin/fm-afk-contract.sh:118-121 requires a reader that acts on the record to hold the lock across both the read and the action. Concrete sequence: a declaredmerged releasePR merges, the poll runssettle-pr, the check at line 1905 passes, the captain's/afkentry writes the away record, then line 1930 releases the captain hold while the home is away. That is the outcome the recorded decision forbids, in a window of roughly one second per settlement. Fix: when the action isrelease, callfm_afk_contract_lock_hold "$STATE" || return 0before therelease_attendedcheck, so a locked or away record defers to the next poll. No other site needs the change: thecloseaction is not gated, and line 1611 only pre-screens beforecommand_answertakes the lock.bin/fm-captain-hold.sh:1906- Round 3 (commit 7e567cc) introduced this defect.settle-prwith actionreleasecallsfm_afk_contract_lock_hold, which waits up to 120 seconds for the away-record lock (_FM_AFK_CONTRACT_LOCK_TIMEOUT=120, bin/fm-afk-contract.sh:167, sized for "a merge waiting on the forge"). The only intended caller is the contribution poll, which the watcher cuts afterFM_CHECK_TIMEOUT(default 30 seconds, bin/fm-watch.sh:366 and 3335). Concrete sequence:bin/fm-pr-merge.shholds the away-record lock for more than about 25 seconds while it waits on the forge, a task has areleasepolicy, and its PR is terminal. The poll blocks insideterminal_hold_event(bin/fm-contributions.sh:579), the watcher kills it, and the watcher reportstimed out after 30s(bin/fm-watch.sh:3432). That line is a wake, so the deferral costs a model turn, which the intent forbids ("without a model turn"). The retained-settlement branch runs before the live forge reads (bin/fm-contributions.sh:670-681), so no open PR is observed in that cycle either. Each further deferredreleasepolicy adds its own wait. The round 3 testtest_forge_release_waits_for_the_away_record_locksetsFM_TEST_AFK_CONTRACT_LOCK_TIMEOUT=1, so it cannot detect the production wait. Fix: a busy lock already means defer, sosettle-prmust not wait. Checkrelease_attendedfirst (ascommand_answerdoes at bin/fm-captain-hold.sh:1353), then take the lock with one non-blocking attempt or a wait of about 1 second, and return 0 on contention. Make the test pass without the timeout override, or assert that the poll returns inside the check bound. No sibling site: thecloseaction takes no away-record lock.🔧 Fix applied.
2 infos still open:
bin/fm-contributions.sh:583- A settlement failure that does not remove the policy prints the diagnostic line on every poll, and the watcher turns each diagnostic line into a wake (bin/fm-watch.sh:4283). Concrete sequence:settle-prwrites the evidence and closes the task, thenpublish_parent_holdreturns rc 2 or more, sosettle-prfails withcould not publish PR settlementand keeps the policy for retry. Each 300-second sweep repeats the line until the parent channel recovers. The same holds for a corrupted policy file (invalid PR settlement policy) and a persistenttasks-axifailure. This differs from the existingobservation unavailableline, which wakes once per failure episode. I judge it an acceptable tradeoff, because the hold is half-settled and needs attention, and a once-per-episode rule would need new durable state. No action required.bin/fm-contributions.sh:580- When aclosed releaseorterminal releasepolicy is deferred (home away, or the away-record lock is busy),settle-prreturns 0 with the policy still present, soterminal_hold_eventfalls through and raises theclosedpending event and its wake for a hold that the policy settles on the next attended poll. The event stays pending on the released task until someone acknowledges it. The report is truthful and occurs once, so this is a noted tradeoff of the round 2 away deferral, not a defect. No action required.✅ **Test** - passed
✅ No issues found.
terminal closedeclaration settles its hold, the held task without a declaration gets oneclosedevent and one wake, and a task without…config/hold-pr-settlethe declaration is refused and a merged PR settles nothing; creating the flag applies the retained merged observation on the next pollmergedbut the PR closes unmerged; the hold stays open, the poll prints one diagnostic, the closure is reported, and the next poll is silentreleaseis deferred silently while the away record exists and is applied on the first poll after the captain returns, without completing the workfm-afk-contract.sh archivebash ~/.no-mistakes/evidence/01M78YEZXZVNVNE4NTHMWX875B/drive.shfrom the worktree root (live driver, 8 scenarios, 29 checks, exit 0)bin/fm-captain-hold.sh pr-policy <task> https://github.com/o/r/pull/8 <merged|terminal> <close|release>with and withoutconfig/hold-pr-settlebin/fm-contributions.sh armthenbash state/contributions.check.sh(the check shim the watcher runs) after the emulated PR mergedbin/fm-contributions.sh pollandbin/fm-contributions.sh pendingafter emulated merge and unmerged closurebin/fm-afk-contract.sh enter --words 'watch the fleet'andarchivearound a declaredreleasesettlementbash tests/fm-contributions.test.sh(targeted test file for this change, exit 0)✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.
Issues
Closes #8368