Repository navigation
fix(bin): close the away-mode delivery wedge and add compact hooks - #3
Conversation
…nnot blind a session start (kunchenguid#4027) * fix(bin): bound each backlog row read so one wedged backend cannot blind a session start bin/fm-bootstrap.sh's reconcile and close-replay sweeps read the backlog backend once per item through fm_backlog_row_show, and that read was unbounded. A single wedged `tasks-axi show` therefore consumed the whole FM_SESSION_START_TIMEOUT and truncated the digest before the wake queue, supervision instructions, fleet state, and context sections ever printed, leaving the fleet unsupervised with no live watcher. The harm was a blind startup, not a slow one. Bound the read with the existing shared timeout primitive (bin/fm-timeout-lib.sh), so a wedged backend degrades to a loud partial reconcile: the sweep's existing BACKLOG_RECONCILE diagnostic names the item it could not read and the loop continues to the next one. The first bound hit also latches FM_BACKLOG_ROW_SHOW_WEDGED, so a sweep over many items pays one bound rather than one per item and still names every item it skipped, which is what keeps the digest whole on a home carrying a large fleet. The bound holds regardless of any particular tasks-axi install, so it does not depend on the 0.2.5 `show` hang being resolved separately. * fix(bin): set the wedged-backend latch where it survives, and prove it The latch added with the read bound was inert. fm_backlog_row_show runs inside a command substitution in both of its status-capturing callers, so the subshell read the inherited value correctly but its write died with the subshell. Every item still paid a full bound and reported `exceeded`, never `skipped`, which left the large-fleet case the latch existed to cover completely uncovered. Move the write to the two callers that capture the read's status and own the surviving shell, and leave fm_backlog_row_show reading the latch only. Correct the comments that claimed an ownership the function never had. The test that was supposed to cover this asserted only that the second read finished under a generous ceiling, which is true whether or not the latch works. Assert instead that a latched read is strictly faster than one bound and that it reports its own item as skipped, so an inert latch fails the test. * test: cover every item the wedged-backend latch skips The latch assertion exercised a single skipped item, so "every skipped item is still named" was inferred rather than tested. Probe three items instead and assert each skipped one names itself and costs less than a bound. Verified as a real guard by removing both latch writes: the suite then fails on the first skipped item instead of passing. * no-mistakes(review): distinguish backlog read-bound hits from absent rows * no-mistakes(review): preserve read-bound status through the captain verify gates * no-mistakes(review): Preserve backlog read-bound hits through resolve_entry and reconcile instead of spending them as absent rows * no-mistakes(review): Preserve backlog read-bound 124 through migrated-prefix scan and remaining task_show call sites * no-mistakes(document): Document bounded backlog row reads and FM_BACKLOG_ROW_TIMEOUT_SECS * no-mistakes(ci): Fixed all four failing CI checks with one root-cause fix plus one test-heredity fix. (1) bin/fm-captain-hold.sh: task_show carries the row in TASK_SHOW_OUTPUT and emits no stdout, but four call sites still used the stale command-substitution convention show=$(task_show ...), leaving show empty: task_show_or_fail (every captain hold failed with 'did not retain its hold-set stamp' - broke fm-captain-hold-lifecycle in parallel 1 and fm-bearings-board in serial 3), resolve_migrated_entry (migrated-prefix resolution could never match), reconcile-requests (existing rows were refused as absent), and command_open --identity (printed a constant '#0' identity, so fm-watch-triage's re-held captain call inherited the previous call's silence in serial 1). This is also the Greptile P1. Fixed by invoking task_show in the current shell and reading show=$TASK_SHOW_OUTPUT, the convention the other eight call sites already use; read-bound hits still stop loudly by name. (2) tests/fm-backlog-read-bound.test.sh (serial 4, unclassified family): the new e2e half implicitly relied on the author's process tree containing a harness process so fm-lock.sh would grant the fleet lock; on CI runners the lock is refused, the reconcile sweep is skipped, and the final BACKLOG_RECONCILE assertion fails. Reproduced by simulating a CI ancestry via a ps shim, fixed by pinning the lock evidence with the established fake-ps harness fixture pattern from tests/fm-session-start.test.sh. Verified: shellcheck clean; parallel-1, serial-3, and serial-4 lanes fully green locally (failed=0); serial-1 lane green except fm-gemini-harness, which fails only under local Node v26 (comm=node-MainThread); CI's default Node 22 reports comm=node, the branch that test passes on, so it is not a CI failure * no-mistakes(document): Verified bounded backlog read docs accurate across branch
…guid#4285) * fix(merge): serialize the away-authority check with a synchronous merge bin/fm-pr-merge.sh read the away-posture record for merge authority (the per-task merge grant and the yolo/away-grant decision) and handed the merge to the forge afterwards. An archive at the captain's return or a grant revoked by a replacement record could land in between, so a merge could proceed on away authority that no longer held. The away record now carries a cross-subsystem lock, built on the existing bounded lock primitive rather than a new lock format: the record-mutating subcommands hold it across their mutation, and the merge holds it across both its authority read and the forge command. Because a queued or auto merge returns before the pull request lands, and would therefore outlive the lock, an away merge is now refused whenever it could land asynchronously: a requested --auto, a base branch whose merge-queue state does not prove an immediate merge, and GitLab's asynchronous flags and configuration. What remains permitted while away is the synchronous merge that lands inside the lock. This closes the common away-record/merge race against a live lock owner. It does not make the merge atomic in every case, and two narrow races are accepted and documented at their sites rather than hidden, both confused-agent-grade in the sense bin/fm-lease-lib.sh already uses: - A merge-queue rule change or a PR base change in the window between the queue-free preflight and the forge call can still enqueue the merge, which can then land after its grant lapses. - Killing the lock-owning shell while its gh or glab child is still running lets stale-owner recovery reclaim the lock and the record be archived or replaced, after which the orphaned child can complete the merge on lapsed authority. Closing either one needs landing verification or an ownership handoff, which is deliberately out of scope here. No existing gate is relaxed. The lock is taken after the live green-at-head verify and the captain-hold check, the in-lock authority read is unchanged, and a lock that cannot be taken refuses the merge rather than proceeding unlocked. The away grant stays a structured field; no prose is parsed. * no-mistakes(review): Fix GitHub rollup fixture base branch * no-mistakes(document): Document atomic away-authority merge locking * no-mistakes(ci): Updated two executable GitHub API fixtures to include the required baseRefName. Both previously failing test suites now pass: fm-captain-hold-lifecycle.test.sh and fm-pr-check-security.test.sh. git diff --check also passes
During the away posture the watcher's heartbeat schedule still backed off per consecutive no-change heartbeat up to the 2h cap, although the away branch hands every scheduled heartbeat to the daemon precisely so an expired external wait surfaces within one base cadence. Overnight 2026-09-10/11 that decayed fleet scans to 2h blind spots (8 heartbeats in 7.5h) while the AGY task sat on an expired 20:55 UTC recheck. While .afk stands, pin the interval to the base HEARTBEAT and hold the durable streak at zero before wake() adds its one, so a decayed schedule cannot survive the return either.
The captain asked for compact hooks: stow before compaction, start after it. Neither Claude Code nor Codex delivers a PreCompact hook's output to the model, and shell cannot perform /stow's semantic memory curation, so the pre-compact half is a gate that asks once: a manual compaction blocks one attempt with a visible /stow instruction (Claude exit 2, Codex continue:false) and the retry always passes, with a stale window so a crashed ask never silences later ones. Auto compaction is never blocked because blocking an error-recovery auto-compact fails the in-flight request on Claude Code. The post-compact half needs no new registration: both harnesses discard PostCompact hook stdout, so the model-visible restart stays the tracked SessionStart hook (Claude source=compact; codex exec rehydrates a compacted thread as a resume the nudge path already owns). Codex 0.154 probing is recorded in docs/verification/supervision.md: exec dispatches no PreCompact/PostCompact around /compact, and project-hook trust stays interactive-only, so the gate activates wherever a codex surface actually dispatches it. Portable coverage extends tests/fm-sessionstart-nudge.test.sh; the live guard drives a real gated /compact in the TUI probe and adds a codex exec post-compaction reopen probe. The claude live refresh is recorded as pending an account window.
The away branch wrote 0 to state/.heartbeat-streak but the shared wake() boundary in bin/fm-push-transition-lib.sh immediately incremented it to 1 on every heartbeat exit, so the first post-return watcher computed its interval from streak 1 and delayed the first post-return heartbeat to twice the base cadence, the exact decay the pin promised to prevent. Seed -1 instead so wake()'s increment lands on 0, and sanitize the main-loop interval read so a -1 left behind by a crashed exit reads as 0 rather than feeding a negative shift count. The regression now asserts the zero end state.
The captain rejected the advisory containment: the preCompact hook must itself do stow, and a postCompact registration must exist. Redesign bin/fm-precompact-stow.sh from a one-shot ask into a runner that performs the work: every compaction, manual or auto, launches a detached headless agent that resumes the compacting session where the payload carries a session id and executes the stow skill's required startup-memory pass and knowledge sweep, then the compaction proceeds immediately. The hook never blocks, prints, or asks, so the unarmable-marker wedge class is gone outright: marker writes are guarded, a state directory that rejects writes loses bookkeeping only, a failed or unavailable agent records no cooldown and retries on the next compaction, a live pass is not stacked onto, and a completed pass inside FM_PRECOMPACT_STOW_SECS satisfies the window. Register the precompact-stow operational-input kind so the headless prompt stays marked as firstmate input rather than captain words, and rewrite the portable gate coverage for the new contract.
The live lab copied the tracked PostCompact registrations into its harness configs but never linked bin/fm-postcompact-start.sh, so a Claude version that dispatches PostCompact would exec a missing script (127) instead of exercising the registration, and a codex surface would silently skip at its executable check - defeating the guard's recorded purpose of surfacing any version that starts dispatching the events. Link the real starter plus the operational-input and timeout libraries the pre-compact runner's detached child sources, wire a stub headless stow agent through FM_PRECOMPACT_STOW_AGENT into both the TUI and exec compaction probes, and rewrite those probes for the runner contract: a dispatched PreCompact must launch the marked stub pass and still compact immediately, with no blocking and no retry step.
…act phrasing The live guard's claude legs assumed the fresh-folder trust dialog defaults to the trusting option, but 2.1.269 defaults to 'No, exit', so the guard's bare Enter quit the lab session and the session-open hook never fired; move the dialog cursor onto the short trusting option line before confirming. codex-cli 0.154.0 now reports a completed exec /compact as 'Compacted.' where the 2026-09-11 evidence recorded 'Context compacted.', so accept both phrasings, and drop the pi lab's now-redundant copy of fm-operational-input.sh that the shared link already provides. docs/verification/supervision.md records the refreshed evidence: claude 2.1.269 performs the detached stow pass on a dispatched PreCompact and compacts immediately, the linked PostCompact starter drives the recorder's compact source, and every harness leg passed on 2026-09-12.
The recovered pipeline head was content-identical to the head already recorded in the no-mistakes gate, so a new run's gate push had no ref work to do and the runner closed its pipe before git could report cleanly; advance the branch by one explicit commit so the gate fast-forwards again. No code change.
…ument compact hooks
The recovered pipeline head was content-identical to the head already recorded in the no-mistakes gate, so a new run's gate push had no ref work to do and the runner closed its pipe before git could report cleanly; advance the branch by one explicit commit so the gate fast-forwards again. No code change.
…ivered one-shot presentations
The previous run updated the no-mistakes gate to its final head but failed while writing the pipeline attestation against the closed inherited pull request, so a fresh run's gate push would have no ref work to do and trips the runner's up-to-date pipe defect; advance the branch by one explicit commit so the gate fast-forwards again. No code change.
There was a problem hiding this comment.
Devin Review found 1 potential issue.
2 flags not posted on this PR by your GitHub settings — view them in Devin Review. (Configure)
| nohup "$SCRIPT_DIR/fm-precompact-stow.sh" "${AGENT_ARGS[@]}" \ | ||
| >/dev/null 2>&1 </dev/null & |
There was a problem hiding this comment.
🔴 Concurrent compactions duplicate stow passes
Overlapping PreCompact calls can both launch because RUN_FILE is created only by the detached child. Concurrent passes can overwrite shared records, and either pass can erase the other's live marker.
Learn more
The parent checks run_pid_is_live, but it does not claim the run slot before launching the child. Two hook processes can therefore observe no marker and both execute this launch. Each child later overwrites RUN_FILE with its PID, and each unconditionally removes that same path when done. The stow skill can update shared home records, so duplicate passes are not harmless redundant reads.
Example: Two automatic compactions arrive together. Both parents see no live marker and launch agents A and B. B overwrites A's PID; A then finishes first and removes B's marker, allowing a third compaction to launch agent C while B still runs.
Recommended fix: Serialize the check-and-claim operation with a lock or atomic directory creation before spawning. Give each run a generation token, pass it to the child, and remove the marker only when its token still matches. Roll back the parent claim if process creation fails.
Was this helpful? React with 👍 or 👎 to provide feedback.
…rt-nudge.test.sh wait_for_stub_calls - the loop ran 'for i in 1 2 ... 20' without referencing i. Replaced with the repo's house-style count-only loop 'local _; for _ in $(seq 1 20)' (identical 20x0.2s polling). Reproduced the exact SC2034 on the pre-fix file with the pinned ShellCheck 0.11.0, then verified the fixed file passes shellcheck --norc --external-sources and bin/fm-lint.sh with full extended analysis (exit 0), and the full test file passes (36 ok, exit 0). PR must be raised via no-mistakes: attestation failure, not code - it reports the pipeline's test and document steps as skipped and resolves when the outer no-mistakes pipeline completes those phases and pushes; same finding was declined in an earlier round, so no code change made for it
…kunchenguid#3578) * fix(bin): let verified harness ancestry outrank retained markers (#3) * fix(bin): let a structural harness ancestor outrank a retained marker bin/fm-harness.sh treated a verified environment marker as unconditionally authoritative, so a Codex session started from an environment that had retained CLAUDECODE=1 detected as claude. Session start then emitted Claude's Stop-owned supervision protocol to a Codex primary, and every turn end was blocked for missing Claude recovery. The defect is the precedence boundary, not any one harness. codex, opencode, kimi, and muse publish no identity marker at all, so with markers winning outright any retained CLAUDECODE renamed them; the Cursor-before-Claude ordering was a point patch on the same class of problem, and the launch-time marker clearing only ever covered sessions fm-spawn started. Markers and ancestry are now separate evidence layers that detect_own arbitrates: - no ancestry match, or no marker: the single available layer answers, unchanged; - same harness family: the marker's finer verdict stands, so a launch-selected pi-signed is not flattened to pi by an ancestry walk that can only see the shared launcher name; - different harness with a structural (command-name) ancestor: ancestry wins, because only ancestry proves who owns the process tree; - different harness with only a bare-interpreter script-path match: the marker wins, since a harness-shaped path in some node process's arguments is weaker evidence than a harness publishing its own identity. The correction is symmetric: a retained CURSOR_AGENT no longer renames a claude worker nested under cursor either. Adds fm-harness.sh ancestry [<pid>], ancestry evidence with no marker layer, so a real harness process can be asked what the walk makes of it. tests/fm-harness-precedence.test.sh is the portable regression, built from real renamed processes with no harness installed. Every case drives the two layers apart and asserts each alone as well as the combination, so no case can pass vacuously; it also pins Codex's real two-process install topology, since the fix depends on the native binary being what a tool subprocess meets first. The opt-in drift guard gains the matching live half: each installed harness's real running process must still be identified by the ancestry walk, and it fails naming the harness and version when a release changes that name. Documentation follows the corrected contract in the script header, the harness-adapters detection section, the codex, opencode, kimi, and cursor references, and a dated verification record. * fix(tests): drop the unused argument pass-through in the shim-topology helper bin/fm-lint.sh refused the branch: run_shim declared a `[ancestry]` argument and forwarded "$@", but every call site that varies the environment or passes the ancestry subcommand invokes the shim entry point directly, so the helper is only ever called with no arguments (ShellCheck SC2120/SC2119). Behavior is unchanged: with no arguments "$@" expanded to nothing. * fix(bin): examine the top of the process chain instead of assuming init harness_ancestry stopped as soon as the next pid was 1, on the assumption that pid 1 is always init and can never be a harness. Inside a PID namespace that assumption inverts: the harness itself is pid 1, so the walk never examined the one process that proves who owns the tree, reported no ancestry at all, and handed the verdict straight back to a retained marker. A real Codex session under `codex sandbox`, holding CLAUDECODE=1 and CLAUDE_CODE_ENTRYPOINT=cli, is exactly that shape: it resolved claude and rendered Claude's Stop-owned supervision protocol even with the marker-vs-ancestry precedence boundary in place. The same probe now resolves codex and renders the Codex foreground checkpoint. A host's real pid 1 (init, systemd, launchd) matches no harness name, so examining it costs one ps call and can introduce no false positive; the walk still stops once that top process has been read, and a non-numeric or zero ppid still ends it. tests/fm-harness-precedence.test.sh pins the namespace shape with a fake ps that reports every process as bash with ppid 1 and pid 1 as the harness. The case asserts the marker still answers alone when pid 1 is host-shaped, so it cannot pass vacuously, and it fails against the previous stop condition. * docs(verification): record the real-Codex retained-marker evidence The existing record proved the precedence boundary with the portable regression and recorded each installed harness's process name behind the ancestry walk, but it had no evidence from a real Codex process actually holding a retained Claude marker, which is the failure the boundary exists for. Adds the dated before/after result from codex-cli 0.152.0 under `codex sandbox`, with the exact command and the decisive verdict and rendered protocol on each side, and records the second boundary that shape exposed: the walk must examine the top of the process chain, because inside a PID namespace the harness is pid 1. Refreshes the portable regression's observed output for the case it gained. * no-mistakes(review): blind ancestry in marker-pinned harness tests * no-mistakes(review): blind ancestry in the Pi guard-routing test * no-mistakes(review): classify precedence suite, dedupe ps stub, soften claims * no-mistakes(review): model the spawn-and-wait Codex shim topology * no-mistakes(document): correct stale muse marker-clearing detection claims * no-mistakes: apply CI fixes * fix(bin): examine the top of the chain in the lock and nudge walks too The pid-1 defect corrected in bin/fm-harness.sh survived unchanged in the two other harness-ancestry walks, on the exact topology the branch verified against a real Codex process. bin/fm-session-lock-lib.sh's fm_harness_ancestry_pids stopped as soon as the next pid was 1, so a firstmate whose harness is pid 1 of its own PID namespace could not find that harness at all and did not recognize its own session lock. bin/fm-sessionstart-nudge.sh carried the same stop plus a blanket rejection of a lock pid of 1, so the same session was told to run session start again on every turn. Both walks now compare the top process before stopping, matching the shape used in bin/fm-harness.sh. For the lock walk this is safe because fm_harness_process_matches rejects a host's real pid 1. For the nudge, `kill -0` still gates the lock pid, and on a host an unprivileged `kill -0 1` fails, so a lock file that wrongly names pid 1 leaves the hook silent rather than acting on init. Each walk gains one regression case. The lock case drives a deterministic process table whose pid 1 is the harness and asserts a host-shaped pid 1 still finds nothing, so it cannot pass vacuously. The nudge case needs a real PID namespace, because the builtin `kill -0` gate cannot be reached through a fake ps, and it first proves the same fixture nudges with no lock present; it skips explicitly where unprivileged namespaces are unavailable. * no-mistakes(review): assert comm-strength detection from subprocess vantage in drift guard * fix(bin): verify the live harness guard at the strength the guarantee needs The marker-versus-ancestry boundary this branch ships is a strength claim: detect_own hands an args-strength verdict straight back to a retained foreign marker, so a harness is only protected where the ancestry walk reaches it at comm strength. The installed-harness drift guard probed the pane process alone. Under an interpreter shim the pane process IS the shim, whose own script path is args strength, while the native binary that carries comm strength is its child. The guard therefore observed args for Codex, passed, and would have kept passing if a release stopped spawning that native child at all, while real sessions silently regressed to the original bug. fm-harness.sh gains `ancestry-subtree`, which asks the walk from the pane process and every descendant of it, the vantage a tool subprocess actually occupies. The guard now requires comm strength somewhere in that set and requires every vantage to name the same harness. This supersedes the preceding commit's in-guard leaf walk, which reached the same vantage but left the logic inside the test file, where CI could not pin it and nothing else could reuse it. A harness-dependent check needs both halves: `tests/fm-harness-precedence.test.sh` now carries a portable case proving the subtree probe reaches a strength the top-of-session probe cannot, mutation checked twice, once against the pre-change script and once by disabling descendant enumeration. The subtree walk also avoids depending on tty and process-group semantics that differ between Linux and macOS. Verified live: codex-cli 0.152.0 reports [args codex;comm codex] and Claude Code 2.1.257 reports [comm claude]. * no-mistakes(review): narrow drift guard to the upward vantage path * no-mistakes(review): judge only comm-strength vantages in drift guard * no-mistakes(document): drop duplicated rationale in detection precedence evidence * no-mistakes(review): fix pid-1 nudge case vacuity and descent no-arg expansion * no-mistakes(document): drop branch-relative phrasing in detection precedence evidence * no-mistakes(review): guard remaining empty positional expansions in fm-harness * no-mistakes(document): scope cursor marker-ordering claim to the marker layer * no-mistakes(review): Prefer comm-strength leaves in equal-depth descent ties * no-mistakes(document): Document comm-strength descent tie-break --------- * no-mistakes(review): Blind ancestry in stale gemini/rovo marker-precedence tests * no-mistakes(document): Add missing equal-depth-tie test line to precedence evidence transcript * no-mistakes(review): Fix stale/vacuous agy precedence test, add agy to precedence suite and docs * no-mistakes(document): Fix stale kimi.md marker doc missed by ancestry-precedence fix --------- Co-authored-by: NewAiCoder <[email protected]>
…etection (#8) * feat(bin): add Antigravity CLI (agy) as third worker/scout adapter (kunchenguid#4200) * feat(agy): verify Antigravity CLI as third worker/scout adapter Detection by anchored ancestry in fm-harness.sh (no marker of its own); bootstrap harness and effort validation; launch template with model and effort mapping plus reachable-catalog model validation; rendered-tail busy fallback in fm-busy-lib.sh with delivery footer in fm-composer-lib.sh; control mechanics with crewmate/scout-only refusal; tmux liveness naming; router entry with concise adapter reference; dated verification record; portable regression plus opt-in live drift guard. Verified live on agy 1.2.0: supervised spawn, durable steering, same-copy relaunch, and exit, with Herdr-native busy agreement. * no-mistakes(review): bound agy model probe, gate trust dialog, narrow busy signature * no-mistakes(review): pre-register agy workspace trust, make readiness gate strict * no-mistakes(review): Close Orca terminal on gate failure; isolate live-guard HOME; tighten agy matching * no-mistakes(document): Document agy adapter in stale harness enumerations * no-mistakes(review): Clamp non-positive FM_AGY_MODELS_TIMEOUT to the default bound * no-mistakes(document): Fix stale test-shard snapshots after agy lane additions * no-mistakes(ci): Fixed ci-3 (tests/fm-agy-harness.test.sh:519). Root cause: the agy spawn fixture's default base PATH (/usr/bin:/bin:/usr/sbin:/sbin) omits node's directory, but the spawn drives the real bin/fm-agy-trust.sh (which hard-requires node to record trust) and the fixture's fake tmux trust lookup (node -e) under that PATH. On the ubuntu-latest CI runner node lives in the toolcache (/usr/local/bin), so trust pre-registration failed on portable serial 2; on typical Arch hosts node is in /usr/bin, masking the defect. Fix (smallest, following the existing tests/fm-kimi-harness.test.sh precedent of carrying the interpreter's resolved directory): resolve node from the invoking environment (failing the test with 'test needs node' if absent, as kimi does for python3) and prepend its directory to the fixture's default base PATH; the FM_TEST_BASE_PATH override contract is untouched. Verified locally: (1) pre-fix reproduction with a CI-shaped base PATH (system bins minus node) produced exactly the reported failure — 'node is required to record workspace trust and was not found on PATH' plus the fake tmux 'node: command not found'; (2) post-fix, all 29 tests in the file pass both with node available only via a leading non-standard dir in the base PATH (CI's shape) and with the default base PATH on this host. bash -n clean; ShellCheck is not installed in this worktree (previously recorded as environmental) * no-mistakes(test): Give agy typed sends a longer submit-confirm budget * no-mistakes(document): Document agy send budget, trust gate, and control coverage * no-mistakes(document): Document agy busy fallback inventory and send-timing evidence * feat(afk): add quiet supervision mode for a present captain (kunchenguid#4337) * feat(afk): add quiet supervision mode for a present captain Adds a first-class quiet supervision mode alongside /afk for kunchenguid#2356: the same away-mode daemon, injection, busy/composer guards, classification policy, and reliability properties, but the captain staying present and chatting no longer exits it - only an explicit /quiet off does. state/.afk's first line now declares its mode (away, the default, or quiet); fm_afk_mode() in bin/fm-wake-lib.sh is the single reader, falling back to away for missing/empty/unreadable/unrecognized content (including the legacy bare-epoch-timestamp format written before mode existed) so nothing regresses. fm_afk_flag_write() preserves the on-disk mode on a bare refresh (no explicit mode given) rather than defaulting to away, which is what keeps the daemon's own redundant terminal-side re-write from silently resetting a captain's quiet mode back to away underneath them. New .agents/skills/quiet/SKILL.md is a thin wrapper cross-referencing /afk for every shared mechanism, per the one-owner rule. AGENTS.md gains the state/.afk table entry and section 8's exit-trigger line. bin/fm-supervision-instructions.sh, bin/fm-session-start.sh, and bin/fm-guard.sh's stale-watcher banner all become mode-aware so a quiet-mode captain is never misdirected to /afk in captain-facing text. Closes kunchenguid#2356 * no-mistakes(review): Fix AFK epoch parsing and quiet-mode digest wording for two-line flag * no-mistakes(document): Fix turnend-guard.md daemon-ownership contract for quiet mode --------- Co-authored-by: NewAiCoder <[email protected]> Co-authored-by: NewAiCoder <[email protected]> * fix(bin): let verified harness ancestry outrank retained markers (#3) (kunchenguid#3578) * fix(bin): let verified harness ancestry outrank retained markers (#3) * fix(bin): let a structural harness ancestor outrank a retained marker bin/fm-harness.sh treated a verified environment marker as unconditionally authoritative, so a Codex session started from an environment that had retained CLAUDECODE=1 detected as claude. Session start then emitted Claude's Stop-owned supervision protocol to a Codex primary, and every turn end was blocked for missing Claude recovery. The defect is the precedence boundary, not any one harness. codex, opencode, kimi, and muse publish no identity marker at all, so with markers winning outright any retained CLAUDECODE renamed them; the Cursor-before-Claude ordering was a point patch on the same class of problem, and the launch-time marker clearing only ever covered sessions fm-spawn started. Markers and ancestry are now separate evidence layers that detect_own arbitrates: - no ancestry match, or no marker: the single available layer answers, unchanged; - same harness family: the marker's finer verdict stands, so a launch-selected pi-signed is not flattened to pi by an ancestry walk that can only see the shared launcher name; - different harness with a structural (command-name) ancestor: ancestry wins, because only ancestry proves who owns the process tree; - different harness with only a bare-interpreter script-path match: the marker wins, since a harness-shaped path in some node process's arguments is weaker evidence than a harness publishing its own identity. The correction is symmetric: a retained CURSOR_AGENT no longer renames a claude worker nested under cursor either. Adds fm-harness.sh ancestry [<pid>], ancestry evidence with no marker layer, so a real harness process can be asked what the walk makes of it. tests/fm-harness-precedence.test.sh is the portable regression, built from real renamed processes with no harness installed. Every case drives the two layers apart and asserts each alone as well as the combination, so no case can pass vacuously; it also pins Codex's real two-process install topology, since the fix depends on the native binary being what a tool subprocess meets first. The opt-in drift guard gains the matching live half: each installed harness's real running process must still be identified by the ancestry walk, and it fails naming the harness and version when a release changes that name. Documentation follows the corrected contract in the script header, the harness-adapters detection section, the codex, opencode, kimi, and cursor references, and a dated verification record. * fix(tests): drop the unused argument pass-through in the shim-topology helper bin/fm-lint.sh refused the branch: run_shim declared a `[ancestry]` argument and forwarded "$@", but every call site that varies the environment or passes the ancestry subcommand invokes the shim entry point directly, so the helper is only ever called with no arguments (ShellCheck SC2120/SC2119). Behavior is unchanged: with no arguments "$@" expanded to nothing. * fix(bin): examine the top of the process chain instead of assuming init harness_ancestry stopped as soon as the next pid was 1, on the assumption that pid 1 is always init and can never be a harness. Inside a PID namespace that assumption inverts: the harness itself is pid 1, so the walk never examined the one process that proves who owns the tree, reported no ancestry at all, and handed the verdict straight back to a retained marker. A real Codex session under `codex sandbox`, holding CLAUDECODE=1 and CLAUDE_CODE_ENTRYPOINT=cli, is exactly that shape: it resolved claude and rendered Claude's Stop-owned supervision protocol even with the marker-vs-ancestry precedence boundary in place. The same probe now resolves codex and renders the Codex foreground checkpoint. A host's real pid 1 (init, systemd, launchd) matches no harness name, so examining it costs one ps call and can introduce no false positive; the walk still stops once that top process has been read, and a non-numeric or zero ppid still ends it. tests/fm-harness-precedence.test.sh pins the namespace shape with a fake ps that reports every process as bash with ppid 1 and pid 1 as the harness. The case asserts the marker still answers alone when pid 1 is host-shaped, so it cannot pass vacuously, and it fails against the previous stop condition. * docs(verification): record the real-Codex retained-marker evidence The existing record proved the precedence boundary with the portable regression and recorded each installed harness's process name behind the ancestry walk, but it had no evidence from a real Codex process actually holding a retained Claude marker, which is the failure the boundary exists for. Adds the dated before/after result from codex-cli 0.152.0 under `codex sandbox`, with the exact command and the decisive verdict and rendered protocol on each side, and records the second boundary that shape exposed: the walk must examine the top of the process chain, because inside a PID namespace the harness is pid 1. Refreshes the portable regression's observed output for the case it gained. * no-mistakes(review): blind ancestry in marker-pinned harness tests * no-mistakes(review): blind ancestry in the Pi guard-routing test * no-mistakes(review): classify precedence suite, dedupe ps stub, soften claims * no-mistakes(review): model the spawn-and-wait Codex shim topology * no-mistakes(document): correct stale muse marker-clearing detection claims * no-mistakes: apply CI fixes * fix(bin): examine the top of the chain in the lock and nudge walks too The pid-1 defect corrected in bin/fm-harness.sh survived unchanged in the two other harness-ancestry walks, on the exact topology the branch verified against a real Codex process. bin/fm-session-lock-lib.sh's fm_harness_ancestry_pids stopped as soon as the next pid was 1, so a firstmate whose harness is pid 1 of its own PID namespace could not find that harness at all and did not recognize its own session lock. bin/fm-sessionstart-nudge.sh carried the same stop plus a blanket rejection of a lock pid of 1, so the same session was told to run session start again on every turn. Both walks now compare the top process before stopping, matching the shape used in bin/fm-harness.sh. For the lock walk this is safe because fm_harness_process_matches rejects a host's real pid 1. For the nudge, `kill -0` still gates the lock pid, and on a host an unprivileged `kill -0 1` fails, so a lock file that wrongly names pid 1 leaves the hook silent rather than acting on init. Each walk gains one regression case. The lock case drives a deterministic process table whose pid 1 is the harness and asserts a host-shaped pid 1 still finds nothing, so it cannot pass vacuously. The nudge case needs a real PID namespace, because the builtin `kill -0` gate cannot be reached through a fake ps, and it first proves the same fixture nudges with no lock present; it skips explicitly where unprivileged namespaces are unavailable. * no-mistakes(review): assert comm-strength detection from subprocess vantage in drift guard * fix(bin): verify the live harness guard at the strength the guarantee needs The marker-versus-ancestry boundary this branch ships is a strength claim: detect_own hands an args-strength verdict straight back to a retained foreign marker, so a harness is only protected where the ancestry walk reaches it at comm strength. The installed-harness drift guard probed the pane process alone. Under an interpreter shim the pane process IS the shim, whose own script path is args strength, while the native binary that carries comm strength is its child. The guard therefore observed args for Codex, passed, and would have kept passing if a release stopped spawning that native child at all, while real sessions silently regressed to the original bug. fm-harness.sh gains `ancestry-subtree`, which asks the walk from the pane process and every descendant of it, the vantage a tool subprocess actually occupies. The guard now requires comm strength somewhere in that set and requires every vantage to name the same harness. This supersedes the preceding commit's in-guard leaf walk, which reached the same vantage but left the logic inside the test file, where CI could not pin it and nothing else could reuse it. A harness-dependent check needs both halves: `tests/fm-harness-precedence.test.sh` now carries a portable case proving the subtree probe reaches a strength the top-of-session probe cannot, mutation checked twice, once against the pre-change script and once by disabling descendant enumeration. The subtree walk also avoids depending on tty and process-group semantics that differ between Linux and macOS. Verified live: codex-cli 0.152.0 reports [args codex;comm codex] and Claude Code 2.1.257 reports [comm claude]. * no-mistakes(review): narrow drift guard to the upward vantage path * no-mistakes(review): judge only comm-strength vantages in drift guard * no-mistakes(document): drop duplicated rationale in detection precedence evidence * no-mistakes(review): fix pid-1 nudge case vacuity and descent no-arg expansion * no-mistakes(document): drop branch-relative phrasing in detection precedence evidence * no-mistakes(review): guard remaining empty positional expansions in fm-harness * no-mistakes(document): scope cursor marker-ordering claim to the marker layer * no-mistakes(review): Prefer comm-strength leaves in equal-depth descent ties * no-mistakes(document): Document comm-strength descent tie-break --------- * no-mistakes(review): Blind ancestry in stale gemini/rovo marker-precedence tests * no-mistakes(document): Add missing equal-depth-tie test line to precedence evidence transcript * no-mistakes(review): Fix stale/vacuous agy precedence test, add agy to precedence suite and docs * no-mistakes(document): Fix stale kimi.md marker doc missed by ancestry-precedence fix --------- Co-authored-by: NewAiCoder <[email protected]> * fix(bin): pre-approve external CLAUDE.md import dialog for spawned workers (kunchenguid#3944) Claude Code's external-imports check (hasClaudeMdExternalIncludesApproved) reads only the canonical git-root project entry in ~/.claude.json, which its own worktree-to-primary-checkout canonicalization means is never the task worktree fm-claude-trust.sh registered. The trust dialog kept working previously only because its check has an ancestor-walk fallback that happens to reach the worktree entry; the external-imports check has no such fallback. Verified by disassembling the installed claude binary and reproducing in an isolated three-way tmux launch: identical flags registered only at the worktree key still showed the external-imports dialog, and registering them at the primary checkout key suppressed both dialogs. fm-claude-trust.sh now registers all three flags on both the worktree entry and the primary-checkout entry in one atomic write, and refuses when the <project> argument is not itself a primary checkout (its own write target would then be wrong). Extends the harness-adapters Claude reference and the trust test suite. Co-authored-by: NewAiCoder <[email protected]> * fix(afk-return): treat an acked watcher-down marker as no gap (kunchenguid#4355) The marker lifecycle (fm-wake-lib.sh _fm_recovery_marker_ack) leaves state/.watcher-down behind in an acked:* state after a downtime episode is handled. health_snapshot's presence check reported that as an open gap on every later return, so a handled episode kept surfacing as a false GAP forever. * fix(bin): rebind fm-procevent-when trust bindings after a self-update (kunchenguid#4361) * fix(update): rebind fm-procevent-when watches after a self-update A self-update fast-forwards bin/ in place, changing an armed watch's action executable bytes with no tampering involved. The watch's trust binding was hashed at arm time, so the very next fire was refused as not matching the registered binding and the watch died silently. Add fm-procevent-when.sh rebind-all: it re-hashes and republishes the trust binding for every watch whose action executable lives under FM_ROOT, using the same spec/trust validation as an ordinary fire, and leaves any watch whose action lives outside FM_ROOT untouched. Wire it into fm-update.sh right after a successful fast-forward, for both the primary home and any local secondmate home that advances. * no-mistakes(review): Canonicalize FM_ROOT for rebind-all's containment check * no-mistakes(document): Document fm-update.sh's automatic watch rebind and its verification evidence * no-mistakes(lint): fix(tests): double-quote printf scripts to satisfy shellcheck SC2016 * no-mistakes(review): Reload trust binding from disk before firing to reach live pollers * no-mistakes(review): Lock the fire-time trust reload against rebind_one's publish race * no-mistakes(document): Document rebind-all's self-update guarantee and its two review-round test rows --------- Co-authored-by: NewAiCoder <[email protected]> * feat(brief): require poteto-mode in generated worker briefs by default Ship and scout briefs now carry a Poteto mode section instructing the worker to run the task under the poteto-mode skill. config/poteto-mode gates it: absence or "on" enables, "off" omits, and any other value refuses the scaffold so a typo cannot silently drop the requirement. Secondmate charters never receive the section and never read the file. The unguarded section authorizes exactly the skill's own lifecycle - renaming the worker's own pane, one run tab, splits inside it, and role and watchdog panes it started - and forbids touching another run's or the fleet's panes, so the brief no longer tells a worker to perform and avoid the same step. A --herdr-lab brief runs the playbook in-host instead, because its lab contract governs every Herdr call. Where the skill's playbook duplicates a review, validation, or shipping step the delivery path already covers, the delivery path satisfies it, keeping AGENTS.md section 7's prohibition on stacked reviews intact. The setting is inherited into secondmate homes. B21's concurrent-push wait now ends on the marker or the child's exit instead of a wall-clock bound that failed under load. * feat(bin): automatic main-session handover on context and quota exhaustion (#4) * feat(bin): add main-session resource protection command and its handover skill fm-primary-resource.sh owns observe/arm/check/decide/commit/helper for the main Firstmate session: a reliable context reading at or above 175000 tokens hands over to the same harness, and a provider quota window at or above 97 percent used hands over to an independent provider, with quota taking precedence. An unavailable or uncertain reading alerts and never closes the session, and one immutable receipt per incident is reserved before any terminal action so a successor cannot repeat it. The primary agent runs stow itself and passes a structured reset-safe attestation bound to the incident and generation; commit revalidates the binding, context, and quota under the resource lock before reserving. A bounded helper in a backend-owned terminal proves the pane occupant is the recorded session, sends the exit command once, and launches the successor only into a proven shell. Herdr stays alert-only until a guarded live lab proves that transaction end to end. * feat: arm main-session resource protection and observe its context binding Bootstrap arms the standing check in the locked main-home path only, never in a secondmate home, and reports an arm failure as PRIMARY_RESOURCE: not armed rather than silently continuing without the protection. The turn-end guard passes its already-read payload to observe so the reading is bound to the lock-owning session; it never changes the guard's exit status or output. AGENTS.md records the new private state directory and the handover skill trigger, bootstrap-diagnostics owns the new prefix, and the test inventory maps the new suite to the watcher family. * docs: classify the main-session handover skill as agent-runtime The repository documentation audience check refuses an unclassified surface, so the new skill left bin/fm-doc-audience-check.sh failing and with it tests/fm-documentation-audiences.test.sh. Classify it beside the other agent-loaded skills. * no-mistakes(review): Fix primary resource review findings * no-mistakes(review): Narrow resource handovers to verified adapters * no-mistakes(review): Remove stale decide command documentation * no-mistakes(review): Always refresh quota and reconcile successor generations * no-mistakes(review): Validate incident IDs before resource state writes * no-mistakes(review): Preserve spawned Codex bypass flag * no-mistakes(review): Reject malformed destination quota ranges * no-mistakes(review): Gate handovers on validated live prerequisites * feat(bin): hand over the main session on Herdr, not just tmux The captain's decision removes the tmux-only narrowing: a main session running on Herdr must hand over, not merely alert. pr_launch_helper now creates the bounded helper's own non-focused workspace pane through the session-scoped CLI wrapper, the same shape bin/fm-afk-launch.sh uses, and reclaims that endpoint if the helper command cannot start. The three sites that converted a valid handover into an alert are gone. Commit-time revalidation also recomputes the launch-reconstruction guard instead of assuming it: a session whose launch command cannot be rebuilt is refused at the moment of acting, not only during the periodic check, and the refusal names that concrete cause rather than reporting a generic mismatch. Verified live on herdr 0.9.0 inside isolated fm-lab-* sessions created by bin/fm-herdr-lab.sh, with teardown installed before provisioning: the real launch path built its own workspace distinct from the stand-in primary pane, the exit command left that pane shell-only, and a successor ran there. The default session was untouched and no lab session leaked. The pane-level sequence is proven; a full-fidelity run with a Herdr-recognised agent in the lab pane is not, and the accompanying report says so. Three test corrections, none of which weaken the guard: a case asserted a codex binding while running under another harness, which is impossible since codex is detected by process ancestry rather than a marker; a wall-clock budget was tuned to the removed quota cache; and the new Herdr case needed a reconstructable launch argv for the probe to read. * no-mistakes(review): Harden Herdr handover ownership and helper cleanup * no-mistakes(review): Authority exit PID via immutable receipt; unconditional helper pane cleanup * no-mistakes(review): Delete launch files before helper pane close; alert terminal failures once * no-mistakes(document): Document seven bootstrap sweeps; complete resource schema header * no-mistakes(review): Clear stale episodes per provider, lock outcome writes, fail malformed source windows closed, stage-specific stalled-successor bound, drop redundant force-owner guard * no-mistakes(review): Quote arm shim paths with printf %q for bash 3.2 * no-mistakes(document): Fix stale sweep counts and quota schema docs * no-mistakes(review): repair portable resource handover paths * no-mistakes(review): fail argv capture closed to /proc, quota wins over argv guard, add live Herdr lab e2e * no-mistakes(document): Correct stale test-seam facts in primary-resource header * no-mistakes(document): Record primary-resource verification grades; narrow adapter claims * no-mistakes(review): restructure lock-holder fixture, narrow MISSING assertion, fix serial hint * no-mistakes(document): fix stale agy session-lock vocabulary claims in docs * fix(bin): layer approved agy fixes onto the auss-main-based rebase lineage Carry the captain-approved deltas from the upstream-based validation lineage onto the auss:main-based rebase (e6dc1e0) so the branch descends from auss/firstmate:main and PR #8 is a clean fast-forward: the restored agy composer-verdict subsystem with its palette-8 ghost stripper and Herdr separated-pair admission, the agy 1.2.2 spinner status-row signature fix, their tests, and the rebase-doc verification updates. * no-mistakes(review): Fix stale usage() header range in fm-procevent-when.sh * no-mistakes(document): fix stale skill cross-references and restore dropped rovo * no-mistakes(ci): CI Lint failed on two ShellCheck SC2100 warnings in bin/fm-pending-reply-lib.sh lines 1081/1084: unquoted assignments token=pending-reply-missed and token=pending-reply-delivery-unknown, whose hyphenated bare values parse as arithmetic under full extended analysis (--external-sources). Fixed by quoting both values, matching the already-quoted recovery-delivery branch. Verified: reproduced both warnings locally with pinned ShellCheck 0.11.0 in the exact CI mode before the edit; after the fix shellcheck --norc --external-sources on the file exits 0 with no findings, and bin/fm-lint.sh bin/fm-pending-reply-lib.sh (full extended analysis plus backend-purity check) exits 0. These were the only findings in the CI Lint log (actionlint reported all 3 workflow files valid), so no other root is affected --------- Co-authored-by: AnPod <[email protected]> Co-authored-by: NewAiCoder-bot <[email protected]> Co-authored-by: NewAiCoder <[email protected]> Co-authored-by: NewAiCoder <[email protected]> Co-authored-by: NewAiCoder <[email protected]>
Intent
The captain went away overnight under firstmate's away mode on 2026-09-10 (entered about 21:24 UTC, returned about 04:50 UTC on 2026-09-11, a confirmed 7h26m away window) and came back to find no expected progress.
On return, the captain said the tasks given together with
/afkshould have been recorded and started before the absence was confirmed; recording them in the return report does not count as carrying out the order.Firstmate filed this repair with the captain's standing direction (backlog item
fm-afk-delivery-wedge, 2026-09-11):"During the confirmed 7h26m AFK, supervision had a gap, an escalation stayed undelivered for 26,571 s, and the first return attempt did not stop the process; a retry closed the return and rebuilt results from durable records.
Consequence: the AGY adapter task stayed overnight on an expired external wait even though its quota had renewed, and the captain got no update.
Diagnose the cause from the recorded logs and artifacts; add regression coverage for delivery, liveness, and retry shutdown.
Keep a single supervision session and every authority boundary. Delivery: no-mistakes, yolo off."
On 2026-09-11 the captain added:
"chcialbym, zeby w twoim katalogu byly hooki, ktore przy preCompact zrobia stow a postCompact zrobia start"
(meaning: the firstmate directory should carry hooks that run stow on PreCompact and run session start on PostCompact)
What Changed
.afk-contract.lock, owned byfm-afk-contract.sh) across both the authority read and the forge command, andfm-pr-merge.shrefuses GitHub--auto/merge-queue and GitLab auto-merge paths while the away record exists, so a merge under away authority is synchronous only and cannot act on lapsed authority.FM_BACKLOG_ROW_TIMEOUT_SECS(default 10s) with a first-hit sweep latch infm-backlog-transition-lib.sh, so a wedged backend no longer consumes the whole session-start digest;fm-captain-hold.shreports a bound hit by name instead of spending it as row absence, andfm-watch.shpins the away heartbeat to the base cadence (streak seeded at -1) so expired external waits surface within one cycle.PreCompact/PostCompacthooks for Claude and Codex:fm-precompact-stow.shperforms the stow pass itself by launching a bounded detached agent (cooldown, no stacking onto a live pass, never blocks compaction), andfm-postcompact-start.shruns the compact-source session start with the status presentation marked undelivered (FM_WAKE_PRESENTATION_UNDELIVERED=1, honored byfm-wake-drain.shandfm-branch-outcome.shstartup-replay) so no one-shot receipt commits against discarded stdout; new and extended tests plus docs cover the delivery, liveness, and compact channels.Risk Assessment
Testing
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-precompact-stow.sh:245- The cooldown comparison[ "$age" -lt "$STOW_SECS" ]uses FM_PRECOMPACT_STOW_SECS unsanitized (line 60), while the script sanitizes RUN_SECS in both of its uses (run_pid_is_live and run_agent_pass). A non-numeric value (e.g.3600s) makes test(1) error, the condition evaluates false, and the hook silently loses the header's cooldown contract (lines 21-23): every compaction launches a full bounded headless stow pass (up to 900s of agent work resuming the session) with no cooldown, no error, and no log naming the bad value. Concrete trace: FM_PRECOMPACT_STOW_SECS=3600s → first pass completes and writes .precompact-stow-last → next compaction reads age=0 →[ 0 -lt 3600s ]fails to a syntax error → pass relaunched immediately, repeating per compaction. Remedy mirrors the existing RUN_SECS pattern:case "$STOW_SECS" in ''|*[!0-9]*) STOW_SECS=3600 ;; esac(0 can keep meaning 'no cooldown' deliberately).⏭️ **Test** - skipped
Step was skipped.
⏭️ **Document** - skipped
Step was skipped.
⏭️ **Lint** - skipped
Step was skipped.
✅ **Push** - passed
✅ No issues found.