Skip to content

feat(bin): settle declared captain holds from forge PR events - #8422

Merged
kunchenguid merged 7 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/up-8368-hold-settle
Nov 13, 2026
Merged

kunchenguid merged 7 commits into
kunchenguid:mainfrom
tiago-peixoto:fm/up-8368-hold-settle

Conversation

@tiago-peixoto

@tiago-peixoto tiago-peixoto commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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:

  • When the PR a held task gates merges or is closed, the hold is settled with that forge event recorded as the evidence, without a captain answer and without a model turn.
  • A hold whose question the PR event does not settle is not closed, and the record makes clear which holds a PR event may settle.
  • A PR closed without merging is reported, so a hold on it can be settled or re-asked with that fact.
  • The captain is not asked a decision whose object is already merged or closed.

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 #8368

What Changed

  • bin/fm-captain-hold.sh gains two commands behind the new opt-in config/hold-pr-settle presence flag. pr-policy <task> <PR-url> <merged|closed|terminal> <close|release> declares which forge event answers one hold and writes data/<task>/hold-pr-policy.json. settle-pr <task> <PR-url> reads the contribution observer's validated terminal observation, records it as forge-closed or forge-released reconciliation 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, a release policy 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.sh calls settle-pr for fresh and retained merged or closed PR observations, so settlement needs no model turn. It also publishes one durable closed pending 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_hold in bin/fm-afk-contract.sh accepts an optional timeout so the release path defers quickly on a busy lock.
  • tests/fm-contributions.test.sh adds 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, and docs/scripts.md document 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.sh and bin/fm-afk-contract.sh against eight disposable homes, with a local gh emulator 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 own tests/fm-contributions.test.sh also 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).

  • Live validation: ✅ go - 8 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Local home, emulated GitHub: a PR merges and the watcher's check shim settles the two declared holds (close marks the task done, release only lifts the hold), prints nothing and queues no wake, while… ✅ pass live live-transcript.txt section S1: check output 0 bytes, empty wake queue, task body shows 'Resolution mode: forge-closed' and 'Forge PR merged: https://github.com/o/r/pull/8&#39;, no 'Captain decision:' lin…
Local home, emulated GitHub: a PR closes without merging; a terminal close declaration settles its hold, the held task without a declaration gets one closed event and one wake, and a task without… ✅ pass live live-transcript.txt section S2: pending closed events are ["delivery"], one wake-queue line, repeat poll silent with no new wake
Opt-in: without config/hold-pr-settle the declaration is refused and a merged PR settles nothing; creating the flag applies the retained merged observation on the next poll ✅ pass live live-transcript.txt section S3: 'fm-captain-hold: config/hold-pr-settle is required' with exit 1, silent poll with the hold still open, then the hold settled after the flag was created
Adversarial: the declaration says merged but the PR closes unmerged; the hold stays open, the poll prints one diagnostic, the closure is reported, and the next poll is silent ✅ pass live live-transcript.txt section S4: poll line 'PR hold settlement failed for delivery ... the PR is closed and can no longer reach the declared event; the hold stays open', then 0 bytes on the repeat poll
Adversarial: the task is held again with a different question after the declaration; a merged PR does not settle the new question ✅ pass live live-transcript.txt section S5: after the merge poll the task is still an open captain hold and not done
Linking a follow-up PR and a report to the held task after the declaration still lets the merged PR settle the hold ✅ pass live live-transcript.txt section S6: links show pull/8, pull/10 and report:data/delivery/report.md, and the hold is settled with a silent poll
Away home: a declared release is deferred silently while the away record exists and is applied on the first poll after the captain returns, without completing the work ✅ pass live live-transcript.txt section S7: hold open and declaration kept while away, hold released and task not done after fm-afk-contract.sh archive
Busy away-record lock: another process holds the lock, the poll returns in about 2 seconds without releasing the hold, and the next poll releases it ✅ pass live live-transcript.txt section S8: 'poll took 2s under a held away-record lock (no timeout override)', hold open, then released after the lock was freed
Evidence: Live transcript of all 8 scenarios (29 checks, 0 failed)

Source: Live transcript of all 8 scenarios (29 checks, 0 failed)


===== S1 merged PR settles declared holds (close and release); undeclared hold on unrelated work stays open =====
$ {run-worktree}/bin/fm-captain-hold.sh hold q-close --reason Approve this PR?
q-close
[exit 0]
$ {run-worktree}/bin/fm-captain-hold.sh pr-policy q-close https://github.com/o/r/pull/8 merged close
pr-policy: q-close https://github.com/o/r/pull/8 merged close
[exit 0]
$ {run-worktree}/bin/fm-captain-hold.sh hold q-release --reason Wait for the PR
q-release
[exit 0]
$ {run-worktree}/bin/fm-captain-hold.sh pr-policy q-release https://github.com/o/r/pull/8 merged release
pr-policy: q-release https://github.com/o/r/pull/8 merged release
[exit 0]
$ {run-worktree}/bin/fm-captain-hold.sh hold delivery --reason Unrelated unfinished work
delivery
[exit 0]
policy record: {
  "schema": "fm-hold-pr.v1",
  "task": "q-close",
  "url": "https://github.com/o/r/pull/8",
  "on": "merged",
  "action": "close",
  "fingerprint": "6fe107d2088e601ccbd25a127e133a07509386fe6ecf3f71f45286a866708490",
  "occurrence": 1
}

(forge emulator: PR 8 is now merged)
$ bash state/contributions.check.sh   (the shim the watcher runs)

[exit 0] [check output bytes: 0]
CHECK PASS: watcher check printed nothing, so no wake / model turn
CHECK PASS: no wake queued
CHECK PASS: q-close hold settled
CHECK PASS: q-close task is done
CHECK PASS: q-release hold released
CHECK PASS: q-release work NOT completed
CHECK PASS: unrelated delivery hold still open
CHECK PASS: forge event recorded as evidence
CHECK PASS: no captain answer invented
CHECK PASS: policy files retired
--- q-close task after settlement ---
task:
  id: q-close
  title: "Approve this PR? https://github.com/o/r/pull/8"
  state: done
  blocked: no
  blocked_by: none
  held: no
  hold_reason: "Approve this PR?"
  hold_kind: captain
  hold_until: "-"
  kind: task
  repo: "-"
  priority: "-"
  created: "-"
  closed: 2026-11-13
  deps: none
  links: "pr:https://github.com/o/r/pull/8"
  body: "Resolution recorded by fm-captain-hold.\nDecision digest: 7c8b2a021e21d35a92c1aa9e75d12885a52fd37f43d84b9242f8d5b446ab9fcd\nResolution mode: forge-closed\n\nReconciliation evidence:\nForge PR merged: https://github.com/o/r/pull/8\nObserved at: 2026-09-16T08:00:00Z\nSettlement policy: merged -> close"
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: repeat poll is silent and changes nothing

===== S2 PR closed without merging: terminal policy settles; held task without policy is told; unheld task is not =====
$ {run-worktree}/bin/fm-captain-hold.sh pr-policy q-term https://github.com/o/r/pull/8 terminal close
pr-policy: q-term https://github.com/o/r/pull/8 terminal close
[exit 0]
(forge emulator: PR 8 is now closed)
$ fm-contributions.sh poll
contribution-wake: check: contributions delivery 6cbca417a504d1619d611b8f16cb0f791ebe5ea6567a784980c5915aa3903b21
[exit 0] [poll output bytes: 113]
CHECK PASS: q-term settled and done with closed evidence
CHECK PASS: held-without-policy task still open
pending closed events: ["delivery"]
CHECK PASS: closed event reported to exactly the still-held task
CHECK PASS: closure queued a wake
wake queue: 1794525789	1	check	contribution-6cbca417a504d1619d611b8f16cb0f791ebe5ea6567a784980c5915aa3903b21	check: contributions delivery 6cbca417a504d1619d611b8f16cb0f791ebe5ea6567a784980c5915aa3903b21
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: closure reported once (repeat poll silent, no new wake)

===== S3 opt-in: flag absent -> declaration refused, nothing settles; creating the flag applies the retained observation =====
$ {run-worktree}/bin/fm-captain-hold.sh pr-policy delivery https://github.com/o/r/pull/8 merged close
fm-captain-hold: config/hold-pr-settle is required
[exit 1]
CHECK PASS: pr-policy refused without config/hold-pr-settle
$ {run-worktree}/bin/fm-captain-hold.sh pr-policy delivery https://github.com/o/r/pull/8 merged close
pr-policy: delivery https://github.com/o/r/pull/8 merged close
[exit 0]
(forge emulator: PR 8 is now merged)
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: flag absent: hold untouched and poll silent
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: flag created: retained merged observation settles the hold

===== S4 adversarial: policy says merged, PR closed unmerged -> not settled, policy dropped with a diagnostic, closure reported =====
(forge emulator: PR 8 is now closed)
$ fm-contributions.sh poll
contributions: PR hold settlement failed for delivery https://github.com/o/r/pull/8: fm-captain-hold: dropped the PR policy for delivery: the PR is closed and can no longer reach the declared event; the hold stays open
contribution-wake: check: contributions delivery 6cbca417a504d1619d611b8f16cb0f791ebe5ea6567a784980c5915aa3903b21
[exit 0] [poll output bytes: 332]
CHECK PASS: hold stays open
CHECK PASS: diagnostic names the dropped policy
CHECK PASS: closed event raised for the still-held task
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: diagnostic is not repeated

===== S5 adversarial: question changed (re-held) after the declaration -> merged PR must not settle the new question =====
$ {run-worktree}/bin/fm-captain-hold.sh hold delivery --reason A different question about this work
delivery
[exit 0]
(forge emulator: PR 8 is now merged)
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: new question stays open and unfinished

===== S6 follow-up PR link and retained report link do not invalidate the declaration =====
$ {run-worktree}/bin/fm-tasks-axi.sh update delivery --pr https://github.com/o/r/pull/10 --report data/delivery/report.md
ok: updated delivery (links)
task:
  id: delivery
  title: "Contribution delivery https://github.com/o/r/pull/8 https://github.com/o/r/pull/\n... (truncated, 106 chars total - use show delivery --full to see complete text)"
  state: queued
  blocked: no
  blocked_by: none
  held: yes
  hold_reason: "fm-hold-v1:TWVyZ2UgdGhpcyBQUj8="
  hold_kind: captain
  hold_until: "-"
  kind: ship
  repo: sample
  priority: "-"
  created: "-"
  closed: "-"
  deps: none
  links: "pr:https://github.com/o/r/pull/8,pr:https://github.com/o/r/pull/10,report:data/delivery/report.md"
  body: "Captain hold set: 2026-11-12T23:23:27Z"
help[1]:
  - Run `tasks-axi show delivery --full` to see the result
[exit 0]
(forge emulator: PR 8 is now merged)
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: hold settled despite added links

===== S7 away home: release deferred silently, applied on the first attended poll; close action unaffected =====
(forge emulator: PR 8 is now merged)
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: away: hold stays, poll silent, policy kept
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: attended: hold released, work not completed

===== S8 busy away-record lock: poll returns promptly and defers, then applies =====
(forge emulator: PR 8 is now merged)
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
poll took 2s under a held away-record lock (no timeout override)
CHECK PASS: locked: deferred silently within 10s
$ fm-contributions.sh poll

[exit 0] [poll output bytes: 0]
CHECK PASS: unlocked: released

===== RESULT: 0 failed checks =====
Evidence: Driver script that produced the transcript

Source: Driver script that produced the transcript

#!/usr/bin/env bash
# Live drive: real bin/fm-captain-hold.sh, bin/fm-contributions.sh, bin/fm-tasks-axi.sh and
# bin/fm-afk-contract.sh against disposable homes; only `gh` (the forge) is a local emulator.
set -u
ROOT=$PWD
T=$ROOT/tests/fm-contributions.test.sh
TMP_ROOT=$(mktemp -d "${TMPDIR:-/tmp}/fm-hold-settle.XXXXXX")
trap 'rm -rf "$TMP_ROOT"' EXIT
NOW=2026-09-16T08:00:00Z HEAD_A=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
fail() { printf 'FIXTURE FAIL: %s\n' "$*"; exit 1; }
# Fixture builders (home layout + forge emulator) reused from the repository test file.
eval "$(sed -n '11,19p;27,41p;107,159p' "$T")"
PR=https://github.com/o/r/pull/8
FAILS=0
h() { printf '\n===== %s =====\n' "$*"; }
run() { printf '$ %s\n' "$*"; with_home "$HOME_" "$@" 2>&1; local rc=$?; printf '[exit %s]\n' "$rc"; return $rc; }
hold() { run "$ROOT/bin/fm-captain-hold.sh" "$@"; }
tasks() { run "$ROOT/bin/fm-tasks-axi.sh" "$@"; }
poll() { printf '$ fm-contributions.sh poll\n'; POLL=$(with_home "$HOME_" "$ROOT/bin/fm-contributions.sh" poll 2>&1); printf '%s\n[exit %s] [poll output bytes: %s]\n' "$POLL" "$?" "${#POLL}"; }
forge() { printf '(forge emulator: PR 8 is now %s)\n' "$1"; printf '%s\n' "$1" > "$HOME_/forge/state"; }
is_open() { with_home "$HOME_" "$ROOT/bin/fm-captain-hold.sh" open "$1" >/dev/null 2>&1; }
state() { with_home "$HOME_" "$ROOT/bin/fm-tasks-axi.sh" show "$1" --full | sed -n 's/^  state: //p'; }
body() { with_home "$HOME_" "$ROOT/bin/fm-tasks-axi.sh" show "$1" --full; }
check() { if eval "$2"; then printf 'CHECK PASS: %s\n' "$1"; else printf 'CHECK FAIL: %s\n' "$1"; FAILS=$((FAILS+1)); fi; }
home() { HOME_=$(new_home "$1"); forge_home "$HOME_"; rm "$HOME_/state/delivery.meta"; }
closed_tasks() { with_home "$HOME_" "$ROOT/bin/fm-contributions.sh" pending | jq -c '[.[] | select(.type == "closed") | .task] | sort'; }

h 'S1 merged PR settles declared holds (close and release); undeclared hold on unrelated work stays open'
home s1; touch "$HOME_/config/hold-pr-settle"
tasks add q-close 'Approve this PR?' --pr $PR >/dev/null; hold hold q-close --reason 'Approve this PR?'
hold pr-policy q-close $PR merged close
tasks add q-release 'Wait for PR before continuing work' --pr $PR >/dev/null; hold hold q-release --reason 'Wait for the PR'
hold pr-policy q-release $PR merged release
hold hold delivery --reason 'Unrelated unfinished work'
printf 'policy record: '; cat "$HOME_/data/q-close/hold-pr-policy.json"; echo
run "$ROOT/bin/fm-contributions.sh" arm >/dev/null
forge merged
printf '$ bash state/contributions.check.sh   (the shim the watcher runs)\n'
OUT=$(with_home "$HOME_" bash "$HOME_/state/contributions.check.sh" 2>&1); printf '%s\n[exit %s] [check output bytes: %s]\n' "$OUT" "$?" "${#OUT}"
check 'watcher check printed nothing, so no wake / model turn' '[ -z "$OUT" ]'
check 'no wake queued' '[ ! -s "$HOME_/state/.wake-queue" ]'
check 'q-close hold settled' '! is_open q-close'
check 'q-close task is done' '[ "$(state q-close)" = done ]'
check 'q-release hold released' '! is_open q-release'
check 'q-release work NOT completed' '[ "$(state q-release)" != done ]'
check 'unrelated delivery hold still open' 'is_open delivery'
check 'forge event recorded as evidence' 'body q-close | grep -qF "Forge PR merged: $PR"'
check 'no captain answer invented' '! body q-close | grep -qF "Captain decision:"'
check 'policy files retired' '[ ! -e "$HOME_/data/q-close/hold-pr-policy.json" ] && [ ! -e "$HOME_/data/q-release/hold-pr-policy.json" ]'
printf -- '--- q-close task after settlement ---\n'; body q-close
cp "$HOME_/data/backlog.md" "$HOME_/before.md"; poll
check 'repeat poll is silent and changes nothing' '[ -z "$POLL" ] && cmp -s "$HOME_/data/backlog.md" "$HOME_/before.md"'

h 'S2 PR closed without merging: terminal policy settles; held task without policy is told; unheld task is not'
home s2; touch "$HOME_/config/hold-pr-settle"
tasks add q-term 'Decide this PR' --pr $PR >/dev/null; hold hold q-term --reason 'Decide this PR' >/dev/null
hold pr-policy q-term $PR terminal close
hold hold delivery --reason 'Rework or drop?' >/dev/null
tasks add bystander 'Work without a captain hold' --pr $PR >/dev/null
forge closed; poll
check 'q-term settled and done with closed evidence' '! is_open q-term && [ "$(state q-term)" = done ] && body q-term | grep -qF "Forge PR closed: $PR"'
check 'held-without-policy task still open' 'is_open delivery'
printf 'pending closed events: %s\n' "$(closed_tasks)"
check 'closed event reported to exactly the still-held task' '[ "$(closed_tasks)" = "[\"delivery\"]" ]'
check 'closure queued a wake' '[ -s "$HOME_/state/.wake-queue" ]'
printf 'wake queue: '; cat "$HOME_/state/.wake-queue"
N=$(wc -l < "$HOME_/state/.wake-queue"); poll
check 'closure reported once (repeat poll silent, no new wake)' '[ -z "$POLL" ] && [ "$(wc -l < "$HOME_/state/.wake-queue")" = "$N" ]'

h 'S3 opt-in: flag absent -> declaration refused, nothing settles; creating the flag applies the retained observation'
home s3
hold hold delivery --reason 'Merge this PR?' >/dev/null
hold pr-policy delivery $PR merged close; RC=$?
check 'pr-policy refused without config/hold-pr-settle' '[ "$RC" -ne 0 ]'
touch "$HOME_/config/hold-pr-settle"; hold pr-policy delivery $PR merged close; rm "$HOME_/config/hold-pr-settle"
forge merged; poll
check 'flag absent: hold untouched and poll silent' 'is_open delivery && [ -z "$POLL" ]'
touch "$HOME_/config/hold-pr-settle"; poll
check 'flag created: retained merged observation settles the hold' '! is_open delivery'

h 'S4 adversarial: policy says merged, PR closed unmerged -> not settled, policy dropped with a diagnostic, closure reported'
home s4; touch "$HOME_/config/hold-pr-settle"
hold hold delivery --reason 'Merge this PR?' >/dev/null
hold pr-policy delivery $PR merged close >/dev/null
forge closed; poll
check 'hold stays open' 'is_open delivery && [ "$(state delivery)" != done ]'
check 'diagnostic names the dropped policy' 'printf %s "$POLL" | grep -qF "PR hold settlement failed for delivery $PR"'
check 'closed event raised for the still-held task' '[ "$(closed_tasks)" = "[\"delivery\"]" ]'
poll; check 'diagnostic is not repeated' '[ -z "$POLL" ]'

h 'S5 adversarial: question changed (re-held) after the declaration -> merged PR must not settle the new question'
home s5; touch "$HOME_/config/hold-pr-settle"
hold hold delivery --reason 'Merge this PR?' >/dev/null
hold pr-policy delivery $PR merged close >/dev/null
hold hold delivery --reason 'A different question about this work'
forge merged; poll
check 'new question stays open and unfinished' 'is_open delivery && [ "$(state delivery)" != done ]'

h 'S6 follow-up PR link and retained report link do not invalidate the declaration'
home s6; touch "$HOME_/config/hold-pr-settle"
hold hold delivery --reason 'Merge this PR?' >/dev/null
hold pr-policy delivery $PR merged close >/dev/null
mkdir -p "$HOME_/data/delivery"; echo report > "$HOME_/data/delivery/report.md"
tasks update delivery --pr https://github.com/o/r/pull/10 --report data/delivery/report.md
forge merged; poll
check 'hold settled despite added links' '! is_open delivery && [ -z "$POLL" ]'

h 'S7 away home: release deferred silently, applied on the first attended poll; close action unaffected'
home s7; touch "$HOME_/config/hold-pr-settle"
hold hold delivery --reason 'Merge this PR?' >/dev/null
hold pr-policy delivery $PR merged release >/dev/null
run "$ROOT/bin/fm-afk-contract.sh" enter --words 'watch the fleet' >/dev/null
forge merged; poll
check 'away: hold stays, poll silent, policy kept' 'is_open delivery && [ -z "$POLL" ] && [ -f "$HOME_/data/delivery/hold-pr-policy.json" ]'
run "$ROOT/bin/fm-afk-contract.sh" archive >/dev/null; poll
check 'attended: hold released, work not completed' '! is_open delivery && [ "$(state delivery)" != done ]'

h 'S8 busy away-record lock: poll returns promptly and defers, then applies'
home s8; touch "$HOME_/config/hold-pr-settle"
hold hold delivery --reason 'Merge this PR?' >/dev/null
hold pr-policy delivery $PR merged release >/dev/null
FM_STATE_OVERRIDE="$HOME_/state" bash -c '. "$1"; fm_lock_acquire_wait "$2" || exit 10; echo ready > "$3"; while [ ! -e "$4" ]; do sleep 0.05; done; fm_lock_release "$2"' \
  _ "$ROOT/bin/fm-wake-lib.sh" "$HOME_/state/.afk-contract.lock" "$HOME_/ready" "$HOME_/release" &
HP=$!; for i in $(seq 100); do [ -s "$HOME_/ready" ] && break; sleep 0.05; done
forge merged; S=$SECONDS; poll; D=$((SECONDS-S)); printf 'poll took %ss under a held away-record lock (no timeout override)\n' "$D"
touch "$HOME_/release"; wait $HP
check 'locked: deferred silently within 10s' 'is_open delivery && [ -z "$POLL" ] && [ "$D" -lt 10 ]'
poll; check 'unlocked: released' '! is_open delivery'

printf '\n===== RESULT: %s failed checks =====\n' "$FAILS"
exit $((FAILS > 0))
Evidence: Output of tests/fm-contributions.test.sh (exit 0)

Source: Output of tests/fm-contributions.test.sh (exit 0)

ok - a declared release waits while the home is away and applies on the next attended poll
ok - a declared release waits while another process holds the away-record lock
ok - linking a follow-up PR keeps the declared policy valid
ok - a closed PR of a task without a captain hold raises no event
ok - a hold linked after the closure gets its own closed event once
ok - retained delivery keeps its PR policy and interrupted settlement replays once
ok - errored evidence, a different PR, and a changed question cannot settle a hold
ok - forge events settle only declared questions and preserve unfinished work
ok - disabled, unmatched, and superseded policies cannot settle a hold
ok - only required-captain contributions are rows; other actors are counted
ok - replaced-head verdict is stale and cannot create a captain requirement
ok - unchecked ownership is disclosed and cannot prove silence
ok - newest check with no verdict is distinct from passing and pending
ok - new maintainer comment wakes once and stays pending until acknowledged
ok - new maintainer review wakes once and stays pending until acknowledged
ok - new maintainer inline wakes once and stays pending until acknowledged
ok - a listed collaborator bot and its re-raise remain review-bot fleet signals
ok - review-bot watching is off until a home lists a bot
ok - the armed allowlist is stable across working directories and policy toggles
ok - ready-for-pr on a filed issue becomes a planning wake
ok - a fresh open issue remains measured maintainer triage
ok - an absent check lane remains missing across repeated observations
ok - mixed freshness retains measured captain work and discloses the gap
ok - malformed durable evidence cannot prove silence
ok - a transient ready-for-pr label wakes and its exact acknowledgement survives replay
ok - recorded judgment keeps its exact head and is stale immediately on a published replacement
ok - verdict help and refusal name exactly the actors the command accepts
ok - a current forge observation refreshes a verdict after a replacement
ok - an unavailable current head leaves verdict freshness unknown
ok - away yolo delivery is fleet work without granting merge authority
actionable: PR https://github.com/o/r/pull/8 is registered but its ready line did not reach the parent channel (rc=3)
ok - cross-home away yolo delivery is fleet work
ok - retired ownership persists and unsupported forge remains visibly unmeasured
ok - unsupported forge coverage is disclosed without inventing fleet work
ok - held unsupported forge coverage remains unmeasured
ok - unsupported ownership stays silent and unmeasured; legacy errors clear without fabricated evidence
ok - legacy cleanup preserves unsupported ownership and supported missing-evidence failure in the same file
ok - shared contribution signal wakes once while retaining both acknowledgements
ok - watcher keeps observer diagnostics separate from contribution wakes
ok - expired child unsupported-forge coverage remains unmeasured
ok - watcher surfaces one newly durable contribution signal without re-ringing it
ok - parent consumes measured child coverage and refuses expired child silence
ok - unreadable pending signals refuse an empty-inbox claim
ok - record task identity is the directory dirname/basename named
ok - snapshot and pending create nothing in a home without state
ok - budget exhausted mid-observation (exhaust) keeps the prior record and stays silent
ok - budget exhausted mid-observation (hang) keeps the prior record and stays silent
ok - a genuine forge failure inside the budget still records the error, its cause and wakes
ok - one HTTP 500 is retried once and a successful retry stays healthy
ok - two transient failures wake once and name the failed read in the record
ok - an HTTP 404 is reported without retrying
ok - real gh error shapes drive the intended retry decision and keep their error
ok - a URL never inherits the previous URL read diagnostic
jq: error (at /tmp/fm-contributions.rZ8h4p/after.json:1): null (null) cannot be matched, as it is not a string
ok - a URL owned by two tasks is observed once and every owner receives the result
ok - a merged or closed contribution settles once, is not re-read, and never wakes again
ok - a late owner inherits a terminal observation without a forge read or wake
ok - a retry converges every owner whose saved row is not terminal, keeping its own acknowledgement state
ok - an open PR linked from a done task keeps being observed
ok - a home with many settled records still observes its open PR within the check bound
ok - a home with many settled records and a malformed one still observes its open PR within the check bound
ok - a record without a trailing newline stays readable beside its neighbours
ok - records beyond one read batch are all read
ok - a later URL waits when fewer than fifteen seconds remain for its observation
ok - eight 3-second PR reads complete fresh within one 20-second poll cycle
ok - a read killed at the five-second bound is budget refusal and stays silent
ok - rotation preserves timed-out records and refreshes every slow PR on successive cycles
ok - the effective budget is cut down to the watcher per-check bound with margin
ok - generated checks enforce configured and inherited budgets at runtime
ok - a genuinely unavailable forge records an error and wakes once per failure episode
ok - a late owner does not restart a shared forge failure episode
ok - retire stops the unavailable check, leaves rotation and restores complete coverage
ok - a late owner settled beside a retired final record stays unretired and known
ok - retire is idempotent and refuses non-captain, unknown, malformed and signal-bearing pairs
ok - an acknowledged unanswered thread under a hold is raised again after a day, daily, until the author replies
ok - a resolved thread with no reply counts as answered
ok - only inline threads and reviews requesting changes with text, no author reply, resolution or later verdict are tracked as unanswered
ok - the reply age is a validated seconds setting
ok - a closed pull request stops raising its threads
ok - the unanswered re-raise and the review-thread read stay off unless a reply age is configured
ok - arm copies a configured reply age into the generated check
ok - a many-review PR stores only classified review fields and stays readable
Evidence: Settled task after the emulated merge (from the S1 transcript)
$ bash state/contributions.check.sh (the shim the watcher runs)
[exit 0] [check output bytes: 0]

task:
id: q-close
state: done
held: no
links: "pr:https://github.com/o/r/pull/8"
body: "Resolution recorded by fm-captain-hold.\nDecision digest: 7c8b2a02...\nResolution mode: forge-closed\n\nReconciliation evidence:\nForge PR merged: https://github.com/o/r/pull/8\nObserved at: 2026-09-16T08:00:00Z\nSettlement policy: merged -> close"
Evidence: Mismatched declaration is dropped with one diagnostic (from the S4 transcript)
$ fm-contributions.sh poll
contributions: PR hold settlement failed for delivery https://github.com/o/r/pull/8: fm-captain-hold: dropped the PR policy for delivery: the PR is closed and can no longer reach the declared event; the hold stays open
contribution-wake: check: contributions delivery 6cbca417...
$ fm-contributions.sh poll
[exit 0] [poll output bytes: 0]

Pipeline

Updates from git push no-mistakes

✅ **Intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 2 infos
  • ⚠️ bin/fm-captain-hold.sh:1904 - The recorded round 1 decision to fix this is not in the reviewed commit. settle-pr with action release still runs tasks_axi unhold with no release_attended check, while command_answer --release (line 1348, 1355) and the keyed-answer intake (line 1606) refuse while state/.afk reads away or the away-posture record exists. Concrete sequence: firstmate declares pr-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: in command_settle_pr, when the action is release and release_attended fails, return 0 before write_resolution_record so 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. The close action is not affected.
  • ⚠️ bin/fm-contributions.sh:656 - The recorded round 1 decision to fix this is not in the reviewed commit. With config/hold-pr-settle present, every poll calls terminal_hold_event for every settled (task, URL) pair before the live forge reads. Each call spawns two jq processes (lines 572 and 580). For a closed-unmerged PR whose closed token is already in seen, the second jq still prints the unchanged row, so line 587 also runs write_record (two more jq and a rename) and publish_pending on 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 (state closed and no closed token in seen), call settle-pr only where $DATA/$task/hold-pr-policy.json exists, and emit nothing from the jq at line 580 when the token is already seen. Sibling in bin/fm-captain-hold.sh command_settle_pr: a policy whose task was answered or whose fingerprint went stale is never removed, so each poll spawns settle-pr (lock, jq, tasks-axi show) for it indefinitely. Remove the policy file on those return 0 paths (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. The closed pending 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 example fm-captain-hold.sh open &#34;$task&#34;, 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's seen list through settle_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, and test_forge_settles_only_declared_holds, which should also assert that an unheld task owning the closed PR gets no closed event.
  • ⚠️ bin/fm-captain-hold.sh:1821 - pr_hold_fingerprint hashes the title field of tasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: after tasks-axi update t1 --pr .../pull/2 the shown title read x https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declares pr-policy task .../pull/8 merged close, then a follow-up PR is linked with tasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, so settle-pr returns 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 shown links field 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 after pr-policy and expects settlement. Re-linking the same URL is idempotent and is not affected.
  • ⚠️ bin/fm-captain-hold.sh:1910 - settle-pr prints pr-settled: ... on stdout, and terminal_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 not contribution-wake: check: contributions ... as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate with check: 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 (&gt;/dev/null at 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-pr with action release still runs tasks_axi unhold with no release_attended check, while command_answer --release (line 1348, 1355) and the keyed-answer intake (line 1606) refuse while state/.afk reads away or the away-posture record exists. Concrete sequence: firstmate declares pr-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: in command_settle_pr, when the action is release and release_attended fails, return 0 before write_resolution_record so 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. The close action is not affected.
  • ⚠️ bin/fm-captain-hold.sh:1821 - pr_hold_fingerprint hashes the title field of tasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: after tasks-axi update t1 --pr .../pull/2 the shown title read x https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declares pr-policy task .../pull/8 merged close, then a follow-up PR is linked with tasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, so settle-pr returns 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 shown links field 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 after pr-policy and expects settlement. Re-linking the same URL is idempotent and is not affected.
  • ⚠️ bin/fm-captain-hold.sh:1910 - settle-pr prints pr-settled: ... on stdout, and terminal_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 not contribution-wake: check: contributions ... as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate with check: 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 (&gt;/dev/null at 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 for fingerprint-covers-links-in-shown-title. pr_hold_fingerprint removes only pr: links from the shown title, but the markdown backend also shows a report: link there. I confirmed this with tasks-axi update t1 --report data/t1/report.md: the title became Title one https://github.com/o/r/pull/8 data/t1/report.md and links became pr:...,report:data/t1/report.md. Concrete sequence: firstmate holds an investigation task and declares pr-policy task URL merged close. The worker finishes, and cleanup keeps the held row through fm_backlog_retain (bin/fm-backlog-transition-lib.sh:578), which runs update --report &lt;path&gt;. The title now differs, so when the PR merges settle-pr reaches 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 only pr: ones, for example match *&#34;,report:$word,&#34;* beside the pr: pattern. Extend the comment-backed case at tests/fm-contributions.test.sh:2113 with a --report update 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-pr with action release still runs tasks_axi unhold with no release_attended check, while command_answer --release (line 1348, 1355) and the keyed-answer intake (line 1606) refuse while state/.afk reads away or the away-posture record exists. Concrete sequence: firstmate declares pr-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: in command_settle_pr, when the action is release and release_attended fails, return 0 before write_resolution_record so 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. The close action is not affected.
  • ⚠️ bin/fm-captain-hold.sh:1821 - pr_hold_fingerprint hashes the title field of tasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: after tasks-axi update t1 --pr .../pull/2 the shown title read x https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declares pr-policy task .../pull/8 merged close, then a follow-up PR is linked with tasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, so settle-pr returns 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 shown links field 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 after pr-policy and expects settlement. Re-linking the same URL is idempotent and is not affected.
  • ⚠️ bin/fm-captain-hold.sh:1910 - settle-pr prints pr-settled: ... on stdout, and terminal_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 not contribution-wake: check: contributions ... as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate with check: 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 (&gt;/dev/null at 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 for fingerprint-covers-links-in-shown-title. pr_hold_fingerprint removes only pr: links from the shown title, but the markdown backend also shows a report: link there. I confirmed this with tasks-axi update t1 --report data/t1/report.md: the title became Title one https://github.com/o/r/pull/8 data/t1/report.md and links became pr:...,report:data/t1/report.md. Concrete sequence: firstmate holds an investigation task and declares pr-policy task URL merged close. The worker finishes, and cleanup keeps the held row through fm_backlog_retain (bin/fm-backlog-transition-lib.sh:578), which runs update --report &lt;path&gt;. The title now differs, so when the PR merges settle-pr reaches 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 only pr: ones, for example match *&#34;,report:$word,&#34;* beside the pr: pattern. Extend the comment-backed case at tests/fm-contributions.test.sh:2113 with a --report update 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 for release-bypasses-attended-only. settle-pr with action release reads release_attended once and then writes the resolution record and runs tasks_axi unhold without holding the away-record lock. The captain's own release path does hold it: command_answer --release calls fm_afk_contract_lock_hold &#34;$STATE&#34; at bin/fm-captain-hold.sh:1359 and re-checks release_attended at 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 declared merged release PR merges, the poll runs settle-pr, the check at line 1905 passes, the captain's /afk entry 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 is release, call fm_afk_contract_lock_hold &#34;$STATE&#34; || return 0 before the release_attended check, so a locked or away record defers to the next poll. No other site needs the change: the close action is not gated, and line 1611 only pre-screens before command_answer takes 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-pr with action release still runs tasks_axi unhold with no release_attended check, while command_answer --release (line 1348, 1355) and the keyed-answer intake (line 1606) refuse while state/.afk reads away or the away-posture record exists. Concrete sequence: firstmate declares pr-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: in command_settle_pr, when the action is release and release_attended fails, return 0 before write_resolution_record so 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. The close action is not affected.
  • ⚠️ bin/fm-captain-hold.sh:1821 - pr_hold_fingerprint hashes the title field of tasks-axi show, and on the markdown backend that field carries every structured link. I confirmed this in a temp directory: after tasks-axi update t1 --pr .../pull/2 the shown title read x https://github.com/o/r/pull/1 https://github.com/o/r/pull/2. Concrete sequence: firstmate declares pr-policy task .../pull/8 merged close, then a follow-up PR is linked with tasks-axi update task --pr .../pull/9. The question did not change, but the fingerprint no longer matches, so settle-pr returns 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 shown links field 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 after pr-policy and expects settlement. Re-linking the same URL is idempotent and is not affected.
  • ⚠️ bin/fm-captain-hold.sh:1910 - settle-pr prints pr-settled: ... on stdout, and terminal_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 not contribution-wake: check: contributions ... as a diagnostic and queues a wake with it. Result: each successful settlement wakes firstmate with check: 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 (&gt;/dev/null at 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 for fingerprint-covers-links-in-shown-title. pr_hold_fingerprint removes only pr: links from the shown title, but the markdown backend also shows a report: link there. I confirmed this with tasks-axi update t1 --report data/t1/report.md: the title became Title one https://github.com/o/r/pull/8 data/t1/report.md and links became pr:...,report:data/t1/report.md. Concrete sequence: firstmate holds an investigation task and declares pr-policy task URL merged close. The worker finishes, and cleanup keeps the held row through fm_backlog_retain (bin/fm-backlog-transition-lib.sh:578), which runs update --report &lt;path&gt;. The title now differs, so when the PR merges settle-pr reaches 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 only pr: ones, for example match *&#34;,report:$word,&#34;* beside the pr: pattern. Extend the comment-backed case at tests/fm-contributions.test.sh:2113 with a --report update 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 for release-bypasses-attended-only. settle-pr with action release reads release_attended once and then writes the resolution record and runs tasks_axi unhold without holding the away-record lock. The captain's own release path does hold it: command_answer --release calls fm_afk_contract_lock_hold &#34;$STATE&#34; at bin/fm-captain-hold.sh:1359 and re-checks release_attended at 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 declared merged release PR merges, the poll runs settle-pr, the check at line 1905 passes, the captain's /afk entry 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 is release, call fm_afk_contract_lock_hold &#34;$STATE&#34; || return 0 before the release_attended check, so a locked or away record defers to the next poll. No other site needs the change: the close action is not gated, and line 1611 only pre-screens before command_answer takes the lock.
  • ⚠️ bin/fm-captain-hold.sh:1906 - Round 3 (commit 7e567cc) introduced this defect. settle-pr with action release calls fm_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 after FM_CHECK_TIMEOUT (default 30 seconds, bin/fm-watch.sh:366 and 3335). Concrete sequence: bin/fm-pr-merge.sh holds the away-record lock for more than about 25 seconds while it waits on the forge, a task has a release policy, and its PR is terminal. The poll blocks inside terminal_hold_event (bin/fm-contributions.sh:579), the watcher kills it, and the watcher reports timed 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 deferred release policy adds its own wait. The round 3 test test_forge_release_waits_for_the_away_record_lock sets FM_TEST_AFK_CONTRACT_LOCK_TIMEOUT=1, so it cannot detect the production wait. Fix: a busy lock already means defer, so settle-pr must not wait. Check release_attended first (as command_answer does 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: the close action 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-pr writes the evidence and closes the task, then publish_parent_hold returns rc 2 or more, so settle-pr fails with could not publish PR settlement and 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 persistent tasks-axi failure. This differs from the existing observation unavailable line, 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 a closed release or terminal release policy is deferred (home away, or the away-record lock is busy), settle-pr returns 0 with the policy still present, so terminal_hold_event falls through and raises the closed pending 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.

  • Live validation: ✅ go - 8 of 8 scenarios driven live against the product
Scenario Result Live Evidence
Local home, emulated GitHub: a PR merges and the watcher's check shim settles the two declared holds (close marks the task done, release only lifts the hold), prints nothing and queues no wake, while… ✅ pass live live-transcript.txt section S1: check output 0 bytes, empty wake queue, task body shows 'Resolution mode: forge-closed' and 'Forge PR merged: https://github.com/o/r/pull/8&#39;, no 'Captain decision:' lin…
Local home, emulated GitHub: a PR closes without merging; a terminal close declaration settles its hold, the held task without a declaration gets one closed event and one wake, and a task without… ✅ pass live live-transcript.txt section S2: pending closed events are ["delivery"], one wake-queue line, repeat poll silent with no new wake
Opt-in: without config/hold-pr-settle the declaration is refused and a merged PR settles nothing; creating the flag applies the retained merged observation on the next poll ✅ pass live live-transcript.txt section S3: 'fm-captain-hold: config/hold-pr-settle is required' with exit 1, silent poll with the hold still open, then the hold settled after the flag was created
Adversarial: the declaration says merged but the PR closes unmerged; the hold stays open, the poll prints one diagnostic, the closure is reported, and the next poll is silent ✅ pass live live-transcript.txt section S4: poll line 'PR hold settlement failed for delivery ... the PR is closed and can no longer reach the declared event; the hold stays open', then 0 bytes on the repeat poll
Adversarial: the task is held again with a different question after the declaration; a merged PR does not settle the new question ✅ pass live live-transcript.txt section S5: after the merge poll the task is still an open captain hold and not done
Linking a follow-up PR and a report to the held task after the declaration still lets the merged PR settle the hold ✅ pass live live-transcript.txt section S6: links show pull/8, pull/10 and report:data/delivery/report.md, and the hold is settled with a silent poll
Away home: a declared release is deferred silently while the away record exists and is applied on the first poll after the captain returns, without completing the work ✅ pass live live-transcript.txt section S7: hold open and declaration kept while away, hold released and task not done after fm-afk-contract.sh archive
Busy away-record lock: another process holds the lock, the poll returns in about 2 seconds without releasing the hold, and the next poll releases it ✅ pass live live-transcript.txt section S8: 'poll took 2s under a held away-record lock (no timeout override)', hold open, then released after the lock was freed
  • bash ~/.no-mistakes/evidence/01M78YEZXZVNVNE4NTHMWX875B/drive.sh from the worktree root (live driver, 8 scenarios, 29 checks, exit 0)
  • bin/fm-captain-hold.sh pr-policy &lt;task&gt; https://github.com/o/r/pull/8 &lt;merged|terminal&gt; &lt;close|release&gt; with and without config/hold-pr-settle
  • bin/fm-contributions.sh arm then bash state/contributions.check.sh (the check shim the watcher runs) after the emulated PR merged
  • bin/fm-contributions.sh poll and bin/fm-contributions.sh pending after emulated merge and unmerged closure
  • bin/fm-afk-contract.sh enter --words &#39;watch the fleet&#39; and archive around a declared release settlement
  • bash 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

@greptile-apps

greptile-apps Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[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

Comment thread bin/fm-captain-hold.sh Resolved
Comment thread bin/fm-contributions.sh Resolved
…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
@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Nov 13, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

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 8e0a79cd against main ed7fbb84: I read the whole diff (bin/fm-captain-hold.sh, bin/fm-contributions.sh, bin/fm-afk-contract.sh, the hold skill and docs, tests/fm-contributions.test.sh). It has no workflow, CI, network or credential changes. The no-mistakes attestation binds this head with no skipped steps. Live validation is go (8 of 8 scenarios). Greptile is 5/5 on this head, and both earlier threads are resolved. Repo invariants, the Test coverage guard and the no-mistakes check all pass. The red "Full suite" row is only the label gate.

Contract class (my own read): opt-in. Every new path checks config/hold-pr-settle first. Without the flag, pr-policy refuses, settle-pr and the closure notification do nothing, and the observer's settled and final rows behave as they do on main.

Full suite queued. The maintainer full-ci label is going on now. Nothing is waiting on you.

@kunchenguid
kunchenguid merged commit 34c77d5 into kunchenguid:main Nov 13, 2026
34 of 35 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @tiago-peixoto — really appreciate you taking the time on this.

zestysoft added a commit to zestysoft/firstmate that referenced this pull request Nov 20, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

full-ci Maintainer go-ahead: run the full CI suite on this outside pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A task held for the captain stays open after the PR it gates merges or closes, so the captain is asked again about a settled PR

2 participants