Skip to content

fix(bin): keep armed merge polls and status cursors valid across remounts and respawns - #8150

Closed
AgardnerAU wants to merge 7 commits into
kunchenguid:mainfrom
AgardnerAU:fm/upstream-6249-remount-fix-clean
Closed

AgardnerAU wants to merge 7 commits into
kunchenguid:mainfrom
AgardnerAU:fm/upstream-6249-remount-fix-clean

Conversation

@AgardnerAU

Copy link
Copy Markdown
Contributor

What Changed

  • Merge poll authentication (bin/fm-pr-lib.sh) now matches a registration's recorded sidecar and check identities by inode only, through the new fm_pr_recorded_identity_matches. Each file must still pass the live private-file check against the state directory's current device. This replaces the device-shift re-record path (fm_pr_poll_registration_device_shifted / _rerecord_device) and the watcher's rerecord_device_shifted_pr_poll retry. Status file cursors, markers and snapshots in bin/fm-classify-lib.sh, fm-wake-lib.sh, fm-wake-drain.sh, fm-branch-outcome.sh and the Pi branch-dispatch extension now compare identities without the device field (_fm_status_ident_same). Because of this, a state volume remount that renumbers st_dev no longer resets cursors or replays a task's history, and the reported status signature also ignores the device.
  • bin/fm-spawn.sh now carries the existing pr=/pr_head= block forward as the last part of the republished task record. It does this on a relaunch, and also on a fresh spawn over an existing ship or scout record. It uses the new fm_pr_metadata_block_print, so an armed merge poll still authenticates. Secondmates are excluded.
  • When the watcher rejects a state check, its wake now names the first validation cause for each path (check: rejected unauthenticated state checks: <path> (<cause>)). The causes come from the new FM_PR_POLL_REJECTION, FM_PR_META_REJECTION and FM_CUSTOM_CHECK_REJECTION values. These are set by the poll, task record and custom check validators in bin/fm-pr-lib.sh and bin/fm-check-lib.sh. docs/architecture.md and the related tests are updated to match.

🤖 Generated with Claude Code

Risk Assessment

⚠️ Medium: The change loosens how the security-relevant merge-poll check compares recorded file identities: it now matches by inode only. Every caller still checks first that the file is private, has a single link, and is on the same device as the state directory, and the content hashes are unchanged, so I found no reachable bypass. Because the code is authentication logic and the change also touches many status-cursor paths and how fm-spawn republishes task records, it is not trivial.

Testing

I ran the real watcher in disposable lab homes. A merge poll armed before a simulated remount (only the recorded device number changed) still authenticated and ran its forge check. When the fake PR was merged, the watcher reported the merge and retired the poll. A byte-identical check that replaced the original file was refused and never ran, and the wake named the cause. An unregistered custom check and a task record with a key after its pr= block were also refused, each with its cause in the wake. The new targeted tests passed: relaunch and traced relaunch, respawn, completion attestation, unchanged status after a device renumber, and the presentation cursor after a volume renumber. One concurrency test in the relaunch file failed with a 5-second wait timeout while five suites ran at once. It passed when I ran the file alone, so that was load, not a defect. The watch-triage, captain-hold and solo relaunch runs stopped at my time caps with 0 failures; the new tests in them had already passed. Nothing in this change has a visual surface, so the evidence is the CLI transcript.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Merge poll armed before a remount (registration device renumbered, PR open) still authenticates: the watcher runs its gh check and does not reject it ✅ pass live live-remount-transcript.txt S1: recorded device 66313 vs live 66306; gh log shows pr view https://github.com/o/r/pull/11 --json state; no rejection; poll still armed
Renumbered merge poll with a merged PR shows 'merged' and retires the poll ✅ pass live live-remount-transcript.txt S2: check: .../t-merged.check.sh: merged, check file removed
Adversarial: a byte-identical replacement check after the renumber is refused, never runs, and the wake names the cause ✅ pass live live-remount-transcript.txt S3: (merge poll: the sidecar or check is not the file its registration was armed with); gh log is empty
An unregistered custom check is rejected and the wake names the cause ✅ pass live live-remount-transcript.txt S4: rogue.check.sh (custom check: it is not registered (bin/fm-check-register.sh))
A merge poll whose task record has a key after its pr= block is rejected and the wake names the key ✅ pass live live-remount-transcript.txt S5: t-meta.check.sh (merge poll: the task record has key model after its pr= block)
Relaunch, respawn and completion attestation keep the pr= block as the record's tail, so an armed poll still authenticates ✅ pass live test-fm-control-relaunch*.log, test-fm-backlog-atomicity.log, test-fm-captain-hold-lifecycle.log: ok - ... lands ahead of the pr= block ..., ok - a respawn keeps the task&#39;s pr= block ...
Status presentation cursor and reported status survive a device renumber, and a replaced status file still reads as new ✅ pass live test-fm-wake-drain-unread-status.log ok - a volume renumber keeps the presentation cursor while a replaced file still starts unread; test-fm-watch-triage.log `ok - an unchanged reported status survi…
Evidence: Live watcher transcript (S1-S5)

Source: Live watcher transcript (S1-S5)

\### Lab state dir device: 66306

=== S1: armed poll survives device renumbering (PR still OPEN) ===
registration identity lines after simulated reboot:
66313:937334
66313:937335
watcher exit=0
--- watcher wake output:
check: /tmp/fm-lab.o8iycd/home1/state/zz-stop.check.sh: stop-cycle
--- gh calls:
pr view https://github.com/o/r/pull/11 --json state -q .state
S1 RESULT: PASS (poll ran, still armed, no rejection)

=== S2: renumbered poll detects merge and retires ===
watcher exit=0
--- watcher wake output:
check: /tmp/fm-lab.o8iycd/home2/state/t-merged.check.sh: merged
S2 RESULT: PASS (merge surfaced, poll retired)

=== S3 (adversarial): byte-identical replaced check after renumber is refused with cause ===
watcher exit=0
--- watcher wake output:
check: rejected unauthenticated state checks: /tmp/fm-lab.o8iycd/home3/state/t-swap.check.sh (merge poll: the sidecar or check is not the file its registration was armed with)
--- gh calls:
S3 RESULT: PASS (refused, cause named, never executed)

=== S4: unregistered custom check rejection names its cause ===
watcher exit=0
--- watcher wake output:
check: rejected unauthenticated state checks: /tmp/fm-lab.o8iycd/home4/state/rogue.check.sh (custom check: it is not registered (bin/fm-check-register.sh))
S4 RESULT: PASS

=== S5: merge poll whose task record has a key after pr= is refused naming it ===
watcher exit=0
--- watcher wake output:
check: rejected unauthenticated state checks: /tmp/fm-lab.o8iycd/home5/state/t-meta.check.sh (merge poll: the task record has key model after its pr= block)
S5 RESULT: PASS
Evidence: Live lab driver script

Source: Live lab driver script

#!/usr/bin/env bash
# Live driver: real bin/fm-watch.sh against a disposable lab FM_HOME.
# Only gh (external forge boundary) is faked.
set -u
ROOT=$1
LAB=$(mktemp -d "${TMPDIR:-/tmp}/fm-lab.XXXXXX")
trap 'rm -rf "$LAB"' EXIT
FB=$LAB/fakebin; mkdir -p "$FB" "$LAB/wt"
git -C "$LAB/wt" init -q; git -C "$LAB/wt" commit -q --allow-empty -m init
cat > "$FB/gh" <<'SH'
#!/usr/bin/env bash
printf '%s\n' "$*" >> "$GH_LOG"
case " $* " in *" pr view "*"--json state "*) echo "${GH_STATE:-OPEN}";; esac
SH
chmod +x "$FB/gh"
N=0
fresh() { N=$((N+1)); H=$LAB/home$N; "$ROOT/bin/fm-lab-home.sh" create "$H" >/dev/null || { echo "lab create failed"; exit 1; }; S=$H/state; : > "$LAB/gh.log"; }
fresh
. "$ROOT/bin/fm-pr-lib.sh"
arm() { # id url
  printf 'window=fm-%s\nworktree=%s\nkind=ship\npr=%s\n' "$1" "$LAB/wt" "$2" > "$S/$1.meta"; chmod 600 "$S/$1.meta"
  fm_pr_url_parse "$2" && fm_pr_poll_prepare "$S" "$1" "$FM_PR_PROVIDER" "$2" "$FM_PR_HOST" "$FM_PR_PATH" "$FM_PR_NUMBER" "$ROOT/bin/fm-pr-poll.sh" && fm_pr_poll_publish_prepared
}
renumber() { # id : rewrite recorded device as a reboot would leave it
  local reg=$S/$1.pr-poll-registration dev tmp; dev=$(fm_pr_file_device "$S")
  tmp=$(mktemp "$S/.tmp.XXXXXX"); sed -E "s/^${dev}:([0-9]+)$/$((dev+7)):\1/" "$reg" > "$tmp"; chmod 600 "$tmp"; mv -f "$tmp" "$reg"
}
watch_once() { # out-file [gh-state]
  if [ "${NOSTOP:-0}" = 0 ]; then printf '#!/usr/bin/env bash\necho stop-cycle\n' > "$S/zz-stop.check.sh"; chmod 700 "$S/zz-stop.check.sh"
  FM_HOME=$H "$ROOT/bin/fm-check-register.sh" zz-stop >/dev/null; fi
  env -u NO_MISTAKES_GATE -u FM_ROOT_OVERRIDE -u FM_STATE_OVERRIDE GH_LOG=$LAB/gh.log GH_STATE=${2:-OPEN} FM_HOME=$H FM_CHECK_INTERVAL=0 FM_POLL=0.02 FM_HEARTBEAT=999999 FM_SIGNAL_GRACE=0 PATH="$FB:$PATH" \
    timeout 60 "$ROOT/bin/fm-watch.sh" > "$1" 2>"$1.err"; echo "watcher exit=$?"
}
echo "### Lab state dir device: $(fm_pr_file_device "$S")"
echo; echo "=== S1: armed poll survives device renumbering (PR still OPEN) ==="
arm t-open https://github.com/o/r/pull/11
renumber t-open
echo "registration identity lines after simulated reboot:"; grep -E '^[0-9]+:[0-9]+$' "$S/t-open.pr-poll-registration"
watch_once "$LAB/w1.out" OPEN; echo "--- watcher wake output:"; cat "$LAB/w1.out"
echo "--- gh calls:"; cat "$LAB/gh.log"
grep -q 'rejected unauthenticated' "$LAB/w1.out" && echo "S1 RESULT: FAIL (rejected)" || { grep -q 'pr view https://github.com/o/r/pull/11 --json state' "$LAB/gh.log" && [ -e "$S/t-open.check.sh" ] && echo "S1 RESULT: PASS (poll ran, still armed, no rejection)" || echo "S1 RESULT: FAIL"; }
rm -f "$S"/t-open.*
fresh; echo; echo "=== S2: renumbered poll detects merge and retires ==="
: > "$LAB/gh.log"; arm t-merged https://github.com/o/r/pull/12; renumber t-merged
watch_once "$LAB/w2.out" MERGED; echo "--- watcher wake output:"; cat "$LAB/w2.out"
grep -q 't-merged.check.sh: merged' "$LAB/w2.out" && [ ! -e "$S/t-merged.check.sh" ] && echo "S2 RESULT: PASS (merge surfaced, poll retired)" || echo "S2 RESULT: FAIL"
fresh; echo; echo "=== S3 (adversarial): byte-identical replaced check after renumber is refused with cause ==="
: > "$LAB/gh.log"; arm t-swap https://github.com/o/r/pull/13; renumber t-swap
cp -p "$S/t-swap.check.sh" "$S/.x"; mv -f "$S/.x" "$S/t-swap.check.sh"
NOSTOP=1 watch_once "$LAB/w3.out" MERGED; echo "--- watcher wake output:"; cat "$LAB/w3.out"
echo "--- gh calls:"; cat "$LAB/gh.log"
grep -q 't-swap.check.sh (merge poll: the sidecar or check is not the file its registration was armed with)' "$LAB/w3.out" && ! grep -q pull/13 "$LAB/gh.log" && echo "S3 RESULT: PASS (refused, cause named, never executed)" || echo "S3 RESULT: FAIL"
rm -f "$S"/t-swap.*
fresh; echo; echo "=== S4: unregistered custom check rejection names its cause ==="
printf '#!/usr/bin/env bash\necho hi\n' > "$S/rogue.check.sh"; chmod 700 "$S/rogue.check.sh"
NOSTOP=1 watch_once "$LAB/w4.out"; echo "--- watcher wake output:"; cat "$LAB/w4.out"
grep -q 'rogue.check.sh (custom check: it is not registered (bin/fm-check-register.sh))' "$LAB/w4.out" && echo "S4 RESULT: PASS" || echo "S4 RESULT: FAIL"
rm -f "$S/rogue.check.sh"
fresh; echo; echo "=== S5: merge poll whose task record has a key after pr= is refused naming it ==="
arm t-meta https://github.com/o/r/pull/14; echo "model=opus" >> "$S/t-meta.meta"
NOSTOP=1 watch_once "$LAB/w5.out"; echo "--- watcher wake output:"; cat "$LAB/w5.out"
grep -q 't-meta.check.sh (merge poll: .*model' "$LAB/w5.out" && echo "S5 RESULT: PASS" || echo "S5 RESULT: FAIL"
Evidence: Rejection wakes with causes
check: rejected unauthenticated state checks: .../t-swap.check.sh (merge poll: the sidecar or check is not the file its registration was armed with)
check: rejected unauthenticated state checks: .../rogue.check.sh (custom check: it is not registered (bin/fm-check-register.sh))
check: rejected unauthenticated state checks: .../t-meta.check.sh (merge poll: the task record has key model after its pr= block)
Evidence: Relaunch suite rerun alone

Source: Relaunch suite rerun alone

ok - fm-spawn --relaunch: tracked opencode wiring is retired as on main
ok - fm-control removes the dialog file after exit and after relaunch
ok - fm-control exit removes the dialog file before it releases the control lock
ok - fm-control relaunch: a same-harness relaunch replaces the agent in the same endpoint and worktree
ok - fm-control relaunch: pending composer text refuses before the exit command is typed
ok - fm-control relaunch: an unreadable composer fails safe before the exit command is typed
ok - fm-control relaunch: a linked spawning home preserves committed and unfinished work in the recorded copy
ok - fm-control relaunch: an armed PR poll survives replacement launch publication
ok - fm-control relaunch: a traced replacement keeps an armed PR poll authenticated
ok - fm-control relaunch: lifecycle keys land ahead of the pr= block, so an armed merge poll still authenticates
ok - fm-control relaunch: the trace carrier lands ahead of the pr= block, so an armed merge poll still authenticates
ok - fm-control relaunch: delivery and concurrent task metadata publication serialize
ok - fm-control relaunch: disabling tracing clears metadata and pane context
ok - fm-control relaunch: progress and the Firstmate-worktree worker identity reach the replacement
ok - fm-control relaunch: the progress note's inbox listing is silent on an empty inbox
ok - fm-control relaunch: a ship task refuses without the progress note its replacement needs
ok - fm-control relaunch: switching harness is one ordinary relaunch, and the old wiring goes with the old agent
ok - fm-control relaunch: a refused relaunch onto polytoken keeps the project's own hook layer and the running agent
ok - fm-control relaunch: a refused polytoken profile leaves the running agent untouched
ok - fm-spawn --relaunch: retiring a raw polytoken launch's wiring keeps the project's own layers
ok - fm-control relaunch: a harness switch resets model and effort unless they are named too
ok - fm-control relaunch: a prefixed recorded harness can switch adapters transactionally
ok - fm-control relaunch: a prefixed command requires an explicit replacement harness
ok - fm-control relaunch: a same-harness relaunch keeps the profile axes it was running with
ok - native Ultra relaunch preserves its profile and rejects an unsupported model before stopping
ok - fm-control relaunch: a signed-out worker account pin refuses before the old agent stops
ok - fm-control relaunch: the replacement follows the home's current worker account pin
ok - fm-control relaunch: a declared account list keeps the account the task records
ok - fm-control relaunch: only an explicit --account moves a task to another declared account
ok - fm-control relaunch: undeclared, newline-split, signed-out, unrecorded, retired, and wrong-runner accounts refuse before the old agent stops
ok - fm-control relaunch: mate pins are re-read for Claude and Pi, and unusable pins refuse before stopping the agent
ok - fm-control relaunch: a Pi replacement keeps the home's tool exclusions
ok - fm-control relaunch: exclusion-list refusals happen before the running agent stops
ok - fm-control relaunch: explicit model and effort win over the recorded ones
ok - fm-control relaunch: refuses to relaunch onto an adapter with no verified mechanics
ok - fm-control relaunch: the retired incarnation's global turn-end token is revoked
ok - fm-control relaunch: wiring cleanup failure refuses replacement arming
ok - fm-control-lib: one owner resolves each harness's turn-end registry entry, and refuses a malformed token
ok - fm-control relaunch: a secondmate relaunch re-resolves its durable configured harness pin
ok - fm-control relaunch: a claude secondmate keeps settings.local.json and retires the state settings file and the Stop pointer
ok - fm-control relaunch: a mate with a per-mate override line lands on that override, not the default pin
ok - fm-control relaunch: a mate with no override line still resolves the default pin
ok - fm-control relaunch: a legacy secondmate pin file still relaunches the mate onto its first line
ok - fm-control relaunch: an unparseable secondmate pin refuses before anything is stopped
ok - fm-control relaunch: invalid configured effort is ignored before stop
ok - fm-control relaunch: an adapter unverified for this task kind refuses before the agent is stopped
ok - fm-control relaunch: explicit secondmate harness resets unnamed profile axes
ok - fm-control relaunch: a ship task keeps its recorded harness instead of re-reading crew config
ok - fm-spawn --relaunch: with no explicit harness it reuses the task's recorded one, never the crew default
ok - fm-spawn --relaunch: a promoted scout with a recorded custom branch relaunches on it instead of being refused
ok - fm-promote/fm-spawn --relaunch: the current ship contract supersedes stale scout delivery text
ok - fm-spawn --relaunch: wiring armed under a prefixed harness name is still retired
ok - fm-spawn --relaunch: switching away from muse retires its session binding
ok - fm-spawn --relaunch: switching away from cursor retires its session binding
ok - fm-control relaunch: an unaccountable local copy refuses before the agent is touched
ok - fm-spawn --relaunch: a recorded worktree that is the primary home refuses
ok - fm-spawn --relaunch: a recorded worktree that is the project primary checkout refuses
ok - fm-spawn --relaunch: inherited Git overrides do not hide the project primary checkout
ok - fm-control relaunch: a worker with nothing to work from is never launched
ok - fm-control relaunch: a refusal before the agent is stopped leaves the durable record untouched
ok - fm-control relaunch: checkpoint inspection failures refuse before stopping
ok - fm-control relaunch: a launch failure after the stop keeps the prior record and reports the real state
ok - fm-control relaunch: unpublished rollback keeps concurrent durable metadata
ok - fm-control relaunch: post-publication failure keeps the new durable record
ok - fm-control relaunch: partial stop reconciles actual agent state
ok - fm-control relaunch: failed journal replacement preserves durable phase
ok - fm-spawn relaunch: prepublication abort removes replacement state
ok - fm-control relaunch: the checkpoint records the exact unlanded work it preserved
ok - fm-control relaunch: a secondmate's child work is accounted for and its charter is left alone
ok - fm-control relaunch: a secondmate home that is not this secondmate's is refused
ok - fm-control relaunch: unreadable child records fail checkpoint
ok - fm-control relaunch: unlistable state fails checkpoint
exit=124
Evidence: Backlog atomicity (respawn keeps pr= block)

Source: Backlog atomicity (respawn keeps pr= block)

ok - backend resolution preserves unreadable configuration errors for every caller
ok - backend resolution preserves environment, project, user, and default precedence
ok - backlog readers and mutations refuse unresolved backends without touching either backlog
ok - captain hold refuses backend errors and preserves relocated addressing for valid configuration
ok - dispatch publishes the record and moves the backlog item In flight in one run
ok - a respawn keeps the task's pr= block, so its armed merge poll still authenticates
ok - dispatch omits the markdown file when probing a Beads backlog
ok - a leftover markdown symlink does not brick a Beads home's dispatch
ok - completion applies and closes a Beads backlog without any markdown file
ok - dispatch refuses to supersede a pending authoritative close
ok - dispatch refuses held rows before creating resources
ok - dispatch refuses dependency-blocked rows before creating resources
ok - dispatch refuses held In-flight rows before relaunch
ok - dispatch reads backlog rows from the backlog addressing root
ok - recovery uses the parent of a trailing-slash data record
ok - completion targets nested relative data from the caller directory
ok - an immediate-child absolute data path keeps one paired backlog
ok - bare relative data addresses one backlog through dispatch and completion
ok - dispatch refuses symlinked backlogs without crossing homes
ok - automatic homes refuse lifecycle mutation without compatible tasks-axi
ok - dispatch refuses an unresolvable backlog data directory
ok - completion refuses before mutation when backlog data is unresolvable
ok - dispatch refuses, before creating anything, when the home has no item for the id
ok - dispatch distinguishes backlog read failures from missing items
ok - dispatch refuses a closed item instead of silently reopening it
ok - dispatch cannot commit without a verified task-record publication
ok - a failed backlog transition fails the dispatch loudly and leaves no record
ok - dispatch reports when failed-transition rollback cannot remove its record
ok - dispatch verifies both task and busy records during rollback
ok - dispatch commits neither record nor backlog state before launch delivery succeeds
ok - dispatch retries interrupted transitions before honoring termination
ok - a signal-deferred spawn verifies its preserved state and repairs a row that did not move
ok - a signal-deferred spawn reports attempted preservation as attempted when it cannot be verified
ok - a signal-deferred spawn bounds its verification so an unresponsive tasks-axi cannot hold the meta lock forever
ok - fm_tasks_axi bounds the call through its perl watchdog when no timeout binary exists
ok - fm_tasks_axi's perl watchdog passes the child status and output through unchanged
ok - fm_tasks_axi fails closed rather than running unbounded when no bounding mechanism exists
ok - fm_tasks_axi's GNU timeout kills a child that ignores SIGTERM after one further bound
ok - Kimi readiness interruptions fail before backlog commit
ok - dispatch does not resurrect a row closed after preflight
ok - dispatch fails when its backlog row vanishes after preflight
ok - completion closes a local-only ship, with its landing note, before reporting success
ok - completion closes a scout item against its report
ok - completion leaves legacy records open when no incarnation can be recorded
ok - completion refuses ambiguous task incarnations
ok - completion records relocated scout reports relative to the backlog root
ok - space-containing scout report paths round-trip through recovery
ok - control-byte data paths fail closed before paired transitions
ok - unreplayable data paths are refused before destructive cleanup
ok - completion preserves recovery state when task-record removal fails
ok - completion refuses to report success while its item is still open, and records what it owes
ok - restart recovers closes recorded before destructive cleanup
ok - completion refuses directory-symlink close targets
ok - completion reports failure until its durable close marker is removed
ok - session start retries a close whose marker could not be removed
ok - session start reports owned backlog rows it cannot read
ok - Orca cleanup recovery is excluded from backlog lifecycle transitions
ok - session start marks an item In flight when this home already owns a worker for it
ok - session start rejects internal worker-record symlinks
ok - session start rejects symlinked worker records
ok - session start finishes a close an interrupted cleanup recorded but never landed
ok - session start replays a recorded Gerrit close with its change URL as a note
ok - recovery backfills recorded links onto already Done items
ok - session start preserves a pending close across a transient backlog read failure
ok - recovery preserves incomplete-cleanup evidence across a failed replay
ok - session start finishes a close for the matching meta incarnation
ok - recovery preserves closes for ambiguous task incarnations
ok - recovery preserves both records when meta removal fails
ok - recovery preserves closes beside symlinked metadata
ok - recovery binds close-marker identity to its locked filename
ok - recovery rejects close markers targeting another home's data
ok - recovery validates an unterminated final marker field
ok - recovery rejects lexical traversal before resolving marker data
ok - recovery rejects marker control bytes before parsing
ok - recovery rejects malformed PR URL values
ok - a retained pending close is never started by reconciliation
ok - recovery rejects close-marker arguments outside its protocol
ok - recovery reports and rejects dangling symlink close markers
ok - session start drops a close recorded for an older meta incarnation
ok - session start rejects an unversioned close marker
ok - bootstrap rechecks worker-record containment after locking
ok - lifecycle files reject ancestor symlinks outside home roots
ok - same-home state overrides remain supported
ok - bootstrap refuses symlinked state before reconciliation
ok - bootstrap stops when backlog data disappears before reconciliation
ok - bootstrap preserves secondmate, manual, and absent-backlog exemptions
ok - session start leaves a captain-held item where the captain put it
ok - no-backlog teardown refuses symlinked records before resource actions
ok - teardown rechecks record parents after locking
ok - teardown refuses symlinked state before resource actions
ok - a home with no backlog remains exempt from lifecycle transitions
ok - spawn refuses a special-file tasks-axi config instead of blocking on it
ok - spawn refuses an unsafe tasks-axi config before any exemption is derived from it
ok - spawn refuses a data directory symlinked outside the home
ok - a configured adapter refuses a data directory outside the home
ok - dispatch and completion transition structurally with evidence
ok - refused teardown leaves the backlog item in flight
ok - environment-selected adapters bypass the legacy markdown file override
ok - a manual-backlog home dispatches and completes without a hard failure
ok - a secondmate home keeps its own books paired through dispatch and completion
ok - dispatching a persistent secondmate needs no backlog item
fm-backlog-atomicity exit=0
Evidence: Wake drain (volume renumber does not replay history)

Source: Wake drain (volume renumber does not replay history)

ok - a note: answer buried under a later routine note: is surfaced with both lines
ok - already-presented note: lines are not re-surfaced on the next drain
ok - a brand-new note: after presentation is surfaced without replaying handled lines
ok - a queued status signal annotates every unread note, not only the newest
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 1385964.1793799535.9kMYLG
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 1385964.1793799535.9kMYLG
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 1385964.1793799535.9kMYLG
ok - a pending-reply resolution buried under a later note surfaces once and closes OPEN DECISIONS
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 1408983.1793799550.KBP8E0
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 1408983.1793799550.KBP8E0
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 1408983.1793799550.KBP8E0
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 2 --recovery-generation 1408983.1793799550.KBP8E0
ok - a self-announced pending-reply close does not wake yet still surfaces once in UNREAD STATUS
ok - unread status over the former byte cap preserves every line
ok - presentation cursor advances only through its captured endpoint
ok - a reused task id starts its replacement status log unread at byte zero
ok - fallback identity still presents and advances status state
ok - a volume renumber keeps the presentation cursor while a replaced file still starts unread
ok - snapshot failures are reported visibly
ok - OPEN DECISIONS still folds needs-decision/blocked independently of unread notes
WAKE_ACK_REQUIRED: after handling completes run bin/fm-wake-drain.sh --ack-through 1 --recovery-generation 1525240.1793799633.LcF0D1
ok - an empty-queue backstop presentation still preserves the status for its later signal annotation
ok - routine working and branch-covered done lines print nothing on an empty-queue drain
fm-wake-drain-unread-status exit=0
  • Outcome: ⚠️ 1 info across 1 run (22m27s)

Pipeline

Updates from git push no-mistakes

⏭️ **Intent** - skipped

Step was skipped.

🔧 **Rebase** - 5 issues found → auto-fixed ✅
  • ⚠️ bin/fm-pr-lib.sh - merge conflict rebasing onto origin/main
  • ⚠️ bin/fm-spawn.sh - merge conflict rebasing onto origin/main
  • ⚠️ bin/fm-watch.sh - merge conflict rebasing onto origin/main
  • ⚠️ tests/fm-control-relaunch.test.sh - merge conflict rebasing onto origin/main
  • ⚠️ tests/fm-pr-check-security.test.sh - merge conflict rebasing onto origin/main

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-classify-lib.sh:1754 - status_observed_signature now removes the device from the identity before it encodes the r1 signature. Every .seen-* or heartbeat marker written by the earlier code stores a signature that still includes the device. After the upgrade, each such marker therefore fails to match once in status_presentation_marker_reported_matches. This can cause one extra wake-scan hit per status file through fm_wake_signal_seen_current (bin/fm-wake-lib.sh:3084). This is the same effect one remount had before the fix. Presented history is not replayed, because the classified and cursor offsets already compare without the device. The next report commit repairs each marker. This is a one-time migration cost, and no action is needed unless a silent upgrade matters.
⚠️ **Test** - 1 info
  • ℹ️ tests/fm-control-relaunch.test.sh:616 - test_relaunch_serializes_concurrent_durable_metadata_publication failed once ('relaunch did not reach trace delivery') while five suites ran at once. It waits at most 5 seconds (500 x 0.01s), so load can break it. It passed when the file ran alone. This was not caused by this change.
  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Merge poll armed before a remount (registration device renumbered, PR open) still authenticates: the watcher runs its gh check and does not reject it ✅ pass live live-remount-transcript.txt S1: recorded device 66313 vs live 66306; gh log shows pr view https://github.com/o/r/pull/11 --json state; no rejection; poll still armed
Renumbered merge poll with a merged PR shows 'merged' and retires the poll ✅ pass live live-remount-transcript.txt S2: check: .../t-merged.check.sh: merged, check file removed
Adversarial: a byte-identical replacement check after the renumber is refused, never runs, and the wake names the cause ✅ pass live live-remount-transcript.txt S3: (merge poll: the sidecar or check is not the file its registration was armed with); gh log is empty
An unregistered custom check is rejected and the wake names the cause ✅ pass live live-remount-transcript.txt S4: rogue.check.sh (custom check: it is not registered (bin/fm-check-register.sh))
A merge poll whose task record has a key after its pr= block is rejected and the wake names the key ✅ pass live live-remount-transcript.txt S5: t-meta.check.sh (merge poll: the task record has key model after its pr= block)
Relaunch, respawn and completion attestation keep the pr= block as the record's tail, so an armed poll still authenticates ✅ pass live test-fm-control-relaunch*.log, test-fm-backlog-atomicity.log, test-fm-captain-hold-lifecycle.log: ok - ... lands ahead of the pr= block ..., ok - a respawn keeps the task&#39;s pr= block ...
Status presentation cursor and reported status survive a device renumber, and a replaced status file still reads as new ✅ pass live test-fm-wake-drain-unread-status.log ok - a volume renumber keeps the presentation cursor while a replaced file still starts unread; test-fm-watch-triage.log `ok - an unchanged reported status survi…
  • bin/fm-lab-home.sh create to make disposable lab homes (one for each scenario), then the real bin/fm-watch.sh with only gh faked: driver at ~/.no-mistakes/evidence/01M6KA9VHD117BB35E0VVCKKSD/driver/live-remount.sh
  • S1: armed merge poll whose registration records a renumbered device, with the PR open
  • S2: renumbered poll with the PR merged
  • S3: byte-identical check replaced (new inode) after the renumber
  • S4: unregistered custom check
  • S5: task record with key model after its pr= block
  • bash tests/fm-control-relaunch.test.sh (once in parallel, once alone)
  • bash tests/fm-backlog-atomicity.test.sh
  • bash tests/fm-wake-drain-unread-status.test.sh
  • bash tests/fm-watch-triage.test.sh (stopped at a 900s cap with 0 failures; the new renumber test passed)
  • bash tests/fm-captain-hold-lifecycle.test.sh (stopped at a 900s cap with 0 failures; the new attestation test passed)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

AgardnerAU and others added 7 commits November 4, 2026 21:12
…nd relaunches

A merge poll registration recorded each file as device:inode, and APFS
renumbers the device at every reboot, so every armed poll failed validation
at once. Recorded identities now match by inode, with the file proven live on
the state directory's own filesystem first. This replaces the watcher's
locked re-record step, which is no longer needed, and also covers pending
retirement receipts.

The status presentation cursor, the open-decisions cursor, the seen markers,
and the home-append ledger compared status file identities including the
device, so a reboot replayed every task's whole history. Every status identity
comparison now goes through one device-blind helper, mirrored in the Pi
branch dispatcher. The custom check trust binding records only a content hash
and needed no change.

fm-spawn now ends every republished task record with the pr= block that the
metadata parser requires as the tail: a relaunch writes its lifecycle keys
ahead of it, and a fresh spawn over a ship or scout's existing record keeps
the block, so the armed poll keeps naming the task's still-open PR.

A rejected state check now names its cause in the wake, such as a task record
with no pr= line, a key after the pr= block, a replaced file, or an
unregistered custom check.
…d permissions). Rule that was broken: a published task record must keep owner-only mode (0600), whatever umask the caller inherits. In this file, `complete` (bin/fm-captain-hold.sh:1679) is the only path that stages and publishes a replacement for state/<id>.meta. The other staged files in that script already use `umask 077`. Fix: the staging redirection now runs in a subshell under `umask 077`, so $meta_tmp is created with 0600 before fm_backlog_atomic_transition publishes it. Test: I extended test_completion_attestation_keeps_an_armed_merge_poll_verifiable in tests/fm-captain-hold-lifecycle.test.sh. It sets the record to 0600, runs `complete --none` under `umask 022`, and asserts that the record is still exactly 0600 (`find -perm 0600`). The existing checks still pass: the pr= block stays last and the armed poll still authenticates. Before the fix, this test failed with the record at -rw-r--r--. After the fix it passes, and the full tests/fm-captain-hold-lifecycle.test.sh passes (54 ok, 0 not ok). `shellcheck -x` is clean on both files. As the user decided, I did not change ci-2
…34) that FM_PR_POLL_REJECTION in bin/fm-pr-lib.sh and FM_CUSTOM_CHECK_REJECTION in bin/fm-check-lib.sh are set but never read. Both are output variables that bin/fm-watch.sh reads after it sources the library, which shellcheck cannot see. I added the repository's usual `# shellcheck disable=SC2034 # Read by the sourcing watcher (bin/fm-watch.sh) on rejection.` comment above the flagged line in each file. FM_PR_META_REJECTION, the other new variable, is read inside its own library and needs no comment. Before the change, shellcheck 0.11.0 showed the same two warnings locally. After it, `shellcheck -x bin/fm-pr-lib.sh bin/fm-check-lib.sh bin/fm-watch.sh` passes with no warnings. Behavior portable parallel 1 is not caused by this PR, and I made no code change for it. Its only failing test is tests/fm-pi-primary-types.test.sh, with TS2339 errors ('prompt' does not exist on BeforeAgentStartEvent) in fm-branch-supervision.ts and fm-primary-pi-watch.ts. This PR does not change those files. The upstream main CI run at the base commit 6407052 (run 38316792015, job 115035229020) fails this same test with the same two errors. I did not run the behaviour tests locally; the change only adds the two comments
@greptile-apps

greptile-apps Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 4/5

[Medium impact] The changes affect merge-poll checks, task-record publishing, and status history in watcher-driven workflows.

Correct the contradictory rejection fixture before merging.

Reviews (1) · Last reviewed commit: "no-mistakes(document): Document merge po..." · Reviewed by Greptile

Comment on lines +4009 to +4010
printf 'control_relaunch_tx=tx-1\n' >> "$state/task-a.meta"
expected='task-a.check.sh (merge poll: the task record has key control_relaunch_tx after its pr= block)'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Rejection test cannot pass

The key-after-pr case expects rejection for control_relaunch_tx, but fm_pr_metadata_identity_parse explicitly allows that key after pr=. The watcher accepts the poll instead of producing the expected rejection, so test_rejection_names_its_cause fails. With the PR still open and no stop check, it can reach the 60-second guard first.

Append a forbidden key such as model and update the expected cause.

Suggested change
printf 'control_relaunch_tx=tx-1\n' >> "$state/task-a.meta"
expected='task-a.check.sh (merge poll: the task record has key control_relaunch_tx after its pr= block)'
printf 'model=opus\n' >> "$state/task-a.meta"
expected='task-a.check.sh (merge poll: the task record has key model after its pr= block)'

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @AgardnerAU. This looks like a clean re-raise of #6249 on current main. It also takes care of the remaining point there: status_observed_signature now drops the device (07cc8a3d), so a remount no longer re-fires status wakes. The review step's note on a one-time marker mismatch after upgrade is fine as is.

What I checked (tip 356c06fb vs main bb8dd209): the inode-only identity match in bin/fm-pr-lib.sh, which replaces main's device-shift re-record. Every artifact still has to be private, single-link, on the state directory's live device, and match its hashes. I also read the device-blind status identities in the classify/wake/drain/branch-outcome paths and the Pi extension, the pr= block carry-forward in bin/fm-spawn.sh, and the named rejection causes in the watcher wake. There are no workflow, network or credential changes.

My verdict. Contract-class: new-default. The poll authentication rule changes (device-blind instead of re-recording a shifted device), a fresh spawn over an existing record now keeps its pr= block, and the rejection wake text changes. Because this is security-relevant authentication logic, Kun makes the final call once it's ready. VISION: Restart is a non-event aligns strongly (an armed merge poll and status cursors survive a remount). One captain aligns (no replayed history, and a rejection now says why). Scripts own mechanics aligns (exact identity checks in scripts). Authority aligns (the refusal path stays: a swapped check is still refused, and your live S3 shows that). Delegation and Vendor are neutral (the Pi extension change mirrors the shell). Scope aligns.

Waiting on you for two things:

  1. A clean no-mistakes run with no skipped steps. The attestation for 356c06fb shows intent: skipped. Under our current rule, any skipped step blocks the next gate, so please re-raise with git push no-mistakes and let every step run.
  2. Greptile's P1 on tests/fm-pr-check-security.test.sh. In test_rejection_names_its_cause, the key-after-pr case appends control_relaunch_tx=tx-1. fm_pr_metadata_identity_parse explicitly allows that key after pr=, so the poll is accepted and the expected rejection never comes. Your live S5 already uses model=opus. Using a forbidden key like that, with the matching expected cause, fixes it.

One housekeeping question, your call: if #8150 replaces #6249, feel free to close #6249 or say so here, so we track a single PR.

(The red "Full suite" check is our gate for outside PRs, not something you need to fix.)

@AgardnerAU

Copy link
Copy Markdown
Contributor Author

This fix is now carried in #6249.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants