Skip to content

feat: sync fork with upstream firstmate (weekly refit) - #115

Merged
DereKk8 merged 65 commits into
mainfrom
fm/fm-refit-sync-20261101
Nov 1, 2026
Merged

DereKk8 merged 65 commits into
mainfrom
fm/fm-refit-sync-20261101

Conversation

@DereKk8

@DereKk8 DereKk8 commented Nov 1, 2026

Copy link
Copy Markdown
Owner

Intent

"1. Start now" - the captain's go for the weekly refit full sync, given on 2026-11-01 after the refit check report.

This is the weekly refit full sync of this fork (DereKk8/firstmate, remote origin) with canonical upstream (kunchenguid/firstmate, remote upstream). The check pass found real incoming content since the last refit (merge-base 127f0f3, fork PR #114): about 64 upstream commits, 211 files, +25441/-1371. Highlights: watcher stale-lock and auto-arm fixes (kunchenguid#8025, kunchenguid#8018, kunchenguid#7931, kunchenguid#7912), a per-project pr=manual registry token (kunchenguid#7937), dispatch quota_scope binding, shared_quota opt-out and provider-family preference (kunchenguid#8020, kunchenguid#7894, kunchenguid#7876), agy promoted to primary/secondmate (kunchenguid#7941), the experimental hc backend (kunchenguid#7963), a Kiro adapter (kunchenguid#7979), supervision-host idle compaction (kunchenguid#7807), and a configurable /updatefirstmate source (kunchenguid#5603). A merge simulation reported 12 conflicted paths but a valid tree: .agents/skills/operational-home-layout/SKILL.md, bin/fm-brief.sh, bin/fm-claude-stop-autoarm.sh, bin/fm-project-mode.sh, docs/scripts.md, docs/supervision-host.md, docs/trace-context.md, docs/watcher-continuity.md, README.md, tests/fm-merge-local.test.sh, tests/fm-supervision-host.test.sh, and tests/fm-watch-triage.test.sh.

The check report's fit verdicts for how this home uses the arriving capabilities: adopt the watcher stale-lock and auto-arm fixes through the full sync; adopt the pr=manual registry token and register the PRED projects with it after the sync; adopt quota_scope binding, the shared_quota opt-out, and provider-family preference with the sync, with no dispatch configuration change until the profiles are reviewed; adopt supervision-host idle compaction with the sync; keep agy in its current role in this home (Gemini is a workhorse only, never a supervisor) and re-test agy exit and relaunch after the sync; keep the current /updatefirstmate source because this home has a single fork origin; the Kiro harness, the omp remote secondmate, the hc backend, the systemone and openai decision providers, credential-source keys, and local-only spawn from the primary checkout are not used here (reject, and monitor hc and Pi repeated-read containment).

Later captain words: 'Validation will run on opus medium'.

What Changed

  • Merges 64 upstream kunchenguid/firstmate commits into the fork. The 12 conflicted paths are resolved, including bin/fm-brief.sh, bin/fm-claude-stop-autoarm.sh, bin/fm-project-mode.sh, README.md, and the supervision-host, watch-triage, and merge-local test suites.
  • Brings in watcher and supervision fixes: recovery from stale and interrupted watch locks, bounded auto-arm failures, wake grants kept when queue-lock acquisition fails, idle compaction in the supervision host, a refused captain-hold release while the away record exists, and teardown and merge-local safety proofs.
  • Adds new upstream capabilities:
    • Dispatch: the per-project pr=manual registry token, quota_scope binding, the shared_quota opt-out, provider-family preference, credential-source keys, and the systemone and openai decision providers.
    • Harnesses and backends: agy as a primary and secondmate harness, a Kiro harness adapter, omp as a remote secondmate, and the experimental explicit-only hc backend.
    • Pi: repeated-read containment and model-stream silence reporting for Pi workers.
    • Updates: a configurable /updatefirstmate source.
    • Docs, CI workflow updates, and tests for all of the above.

Risk Assessment

⚠️ Medium: This is a large upstream sync (about 64 commits, 25k+ lines) that touches watcher and supervision-host continuity, but the conflict resolutions I checked keep the fork's behavior (ticketed branch templates plus pr=manual in fm-brief/fm-project-mode, the fast-forward test, the triage alias, per-case cleanup) or knowingly take upstream's reworked hand-back logic, and I found no contradiction with the stated intent.

Testing

I ran the targeted suites for the 12 conflict areas and the adopted capabilities: stop-autoarm, the supervision-host suite and its hook, park, and drain splits, project-mode, merge-local, watch-triage, and brief. All of them pass except one Windows-tagged lock-holder case in the park suite, which fails the same way on base 9cd2c5c and upstream 41a47c0. I drove the pr=manual registry token through bin/fm-project-mode.sh against a disposable lab home. The token and both of its refusal guards work. I ran the real Claude auto-arm regression twice on the sync. Then I ran a copy with relaxed count checks side by side on base, upstream, and the sync. All three refs gave the same result: 4 arm runs, 2 drains, only the first hook-owned rewake delivered, and no arm command from the model. The upstream test's exact-count assertion fails on every ref. I removed all temporary clones and labs, and the worktree is clean.

  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Captain registers a PRED project with [no-mistakes pr=manual]: fm-project-mode reports 'no-mistakes off' and --pr reports 'manual', and an unannotated project reports 'auto' ✅ pass live round4-pr-manual-registry.txt
Adversarial: pr=manual on a direct-PR project, and pr=manual outside the brackets, are both refused with a clear error (the misplaced token exits 3) ✅ pass live round4-pr-manual-registry.txt
A real Claude session that starts with a stale lock gets the session-start digest, reclaims the lock, and receives a hook-owned rewake with no model-issued arm, the same as on base and upstream ✅ pass live round4-live-autoarm-parity.md (base, upstream, and sync all give 4 arms, 2 drains, rewake fixture-rapid-1, and model calls only bin/fm-wake-drain.sh)
The merged conflict files (autoarm, supervision-host hook/park/drain, merge-local, watch-triage, brief, project-mode) keep their tested behavior ⏸️ untested no The prior payload did not establish a live result for this scenario. Its only support was the repository's own fixture-driven suites (round4-fm-*.log), which are not a live run of the product. Those s…
Evidence: Live auto-arm parity table: base vs upstream vs sync

Source: Live auto-arm parity table: base vs upstream vs sync

# Round 4 live Claude auto-arm parity (real `claude -p`, isolated FM_HOME, stale lock pid 9999999)

| ref | role | arm runs | drains | rewake reasons in transcript | model Bash calls |
|-----|------|----------|--------|------------------------------|------------------|
| 9cd2c5cb | base (fork before sync) | 4 | 2 | fixture-rapid-1 | bin/fm-wake-drain.sh |
| 41a47c09 | upstream main | 4 | 2 | fixture-rapid-1 | bin/fm-wake-drain.sh |
| 2a92f40a | sync merge | 4 | 2 | fixture-rapid-1 | bin/fm-wake-drain.sh |

Unmodified test on 2a92f40a: `not ok - expected exactly 2 hook-owned arm cycles, got 4`.
All three refs behave identically: SessionStart digest delivered, stale lock reclaimed,
first hook-owned rewake delivered, model never issued an arm command. The second
rewake (fixture-rapid-2) never reaches the model on any ref.
Evidence: pr=manual registry token CLI transcript

Source: pr=manual registry token CLI transcript

$ fm-project-mode.sh pred-api -> no-mistakes off
$ fm-project-mode.sh --pr pred-api -> manual
$ fm-project-mode.sh pred-web -> 
$ fm-project-mode.sh --pr pred-web -> 
$ fm-project-mode.sh plain -> no-mistakes off
$ fm-project-mode.sh --pr plain -> auto
$ fm-project-mode.sh --pr broken
refused: misplaced annotation "pr=manual" for broken in ~/.cache/tmp/fm-lab.YuZ9kt/data/projects.md: branch=, forge=, pr=, and +yolo are read only inside the [mode ...] brackets; correct data/projects.md
exit=3
Evidence: Unmodified live auto-arm e2e on the sync

Source: Unmodified live auto-arm e2e on the sync

not ok - expected exactly 2 hook-owned arm cycles, got 4: arm-run=1 pid=3823254
arm-run=2 pid=3823455
arm-run=3 pid=3830648
arm-run=4 pid=3831006
exit=1
Evidence: Real Claude transcript (sync, behavior probe)

Source: Real Claude transcript (sync, behavior probe)

{"type":"system","subtype":"hook_started","hook_id":"557a8ba3-d857-4952-b326-43654e70bf06","hook_name":"SessionStart:startup","hook_event":"SessionStart","uuid":"5e541903-300d-43e8-b58b-98d4802b6833","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_started","hook_id":"b5d83f40-9430-41fe-b278-de4aedbfc25f","hook_name":"SessionStart:startup","hook_event":"SessionStart","uuid":"323d8801-64a1-42ac-ba6a-fed94cd77d4b","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_started","hook_id":"a08debf0-5cfc-441f-8c94-a60ddfe9f5f2","hook_name":"SessionStart:startup","hook_event":"SessionStart","uuid":"dc27e6cc-f9ad-409b-8830-1ddf9316661a","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_started","hook_id":"f9f07f7c-ef1e-423d-b7e5-e55ea615c5ca","hook_name":"SessionStart:startup","hook_event":"SessionStart","uuid":"e9f344f5-05ed-4a70-a77e-e10bba6d3842","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_response","hook_id":"a08debf0-5cfc-441f-8c94-a60ddfe9f5f2","hook_name":"SessionStart:startup","hook_event":"SessionStart","output":"","stdout":"","stderr":"","exit_code":0,"outcome":"success","uuid":"7a082760-8d1a-4815-8cac-fdfa00958f47","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_response","hook_id":"b5d83f40-9430-41fe-b278-de4aedbfc25f","hook_name":"SessionStart:startup","hook_event":"SessionStart","output":"bin: ~/.local/share/mise/installs/node/26.10.0/bin/chrome-devtools-axi\ndescription: Agent ergonomic interface for controlling Chrome browser session. Prefer this over other browser automation tools.\nbrowser: no active session\nhelp[1]:\n  Run `chrome-devtools-axi open <url>` to start browsing\n","stdout":"bin: ~/.local/share/mise/installs/node/26.10.0/bin/chrome-devtools-axi\ndescription: Agent ergonomic interface for controlling Chrome browser session. Prefer this over other browser automation tools.\nbrowser: no active session\nhelp[1]:\n  Run `chrome-devtools-axi open <url>` to start browsing\n","stderr":"","exit_code":0,"outcome":"success","uuid":"e25ed992-ce7f-4a5b-8a59-53ec3bbebce0","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_response","hook_id":"557a8ba3-d857-4952-b326-43654e70bf06","hook_name":"SessionStart:startup","hook_event":"SessionStart","output":"bin: ~/.local/share/mise/installs/node/26.10.0/bin/gh-axi\ndescription: Agent ergonomic wrapper around Github CLI. Prefer this over `gh` and other methods for Github operations.\nissues: 0 open\nprs: 0 open\nhelp[1]:\n  Run `gh-axi <command> <subcommand>` — commands: issue, pr, run, release, repo, label, secret, variable\n","stdout":"bin: ~/.local/share/mise/installs/node/26.10.0/bin/gh-axi\ndescription: Agent ergonomic wrapper around Github CLI. Prefer this over `gh` and other methods for Github operations.\nissues: 0 open\nprs: 0 open\nhelp[1]:\n  Run `gh-axi <command> <subcommand>` — commands: issue, pr, run, release, repo, label, secret, variable\n","stderr":"","exit_code":0,"outcome":"success","uuid":"679c55e1-c3a9-49b8-85c2-95fc5192fe5b","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_progress","hook_id":"f9f07f7c-ef1e-423d-b7e5-e55ea615c5ca","hook_name":"SessionStart:startup","hook_event":"SessionStart","stdout":"\n================================================================================\nSESSION START - ~/.no-mistakes/worktrees/b6eb6f6aa8bf/01M6C56HPG6BRW00RXW8T657WV/.claude-autoarm-live-e2e.3849576/fmhome\n================================================================================\n\nLOCK\n--------------------------------------------------------------------------------\nlock acquired: harness pid 3850011\n\nHOME ROLE\n--------------------------------------------------------------------------------\nfm-role: user (default)\n","stderr":"","output":"\n================================================================================\nSESSION START - ~/.no-mistakes/worktrees/b6eb6f6aa8bf/01M6C56HPG6BRW00RXW8T657WV/.claude-autoarm-live-e2e.3849576/fmhome\n================================================================================\n\nLOCK\n--------------------------------------------------------------------------------\nlock acquired: harness pid 3850011\n\nHOME ROLE\n--------------------------------------------------------------------------------\nfm-role: user (default)\n","uuid":"4e6bf48b-7ee2-4cf9-8fdc-fde56cda7155","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"system","subtype":"hook_response","hook_id":"f9f07f7c-ef1e-423d-b7e5-e55ea615c5ca","hook_name":"SessionStart:startup","hook_event":"SessionStart","output":"\n================================================================================\nSESSION START - ~/.no-mistakes/worktrees/b6eb6f6aa8bf/01M6C56HPG6BRW00RXW8T657WV/.claude-autoarm-live-e2e.3849576/fmhome\n================================================================================\n\nLOCK\n--------------------------------------------------------------------------------\nlock acquired: harness pid 3850011\n\nHOME ROLE\n--------------------------------------------------------------------------------\nfm-role: user (default)\n\nBOOTSTRAP\n--------------------------------------------------------------------------------\n(silent - all good)\n\nWAKE QUEUE\n--------------------------------------------------------------------------------\nstale: fixture-rapid drained\n================================================================================\nSUPERVISION OPERATING INSTRUCTIONS - primary harness: claude\n================================================================================\nCurrent state:\n- Lock: held by this session; this session owns normal supervision unless away mode says otherwise.\n- Away/quiet mode: inactive.\n- X mode: inactive; use the default watcher cadence.\n- Supervision host: on; it takes away-posture wakes and, where the dialog mirror is verified, eligible attended wakes itself, and hands the rest to you (protocol at the end of this block).\n- Ordinary wake: the Stop-owned auto-arm (bin/fm-claude-stop-autoarm.sh) already owns watcher continuity; drain and handle the wake, and do not arm another cycle yourself.\n\nMode: Claude Stop-hook-owned supervision.\n\nWhen this session owns supervision and away mode is not active:\n1. Drain first with `bin/fm-wake-drain.sh`.\n   After handling all emitted wakes and reconciling open decisions and unread status lines, run the exact `--ack-through` command printed as `WAKE_ACK_REQUIRED`; until then the work remains durable for idempotent re-handling after interruption.\n2. Routine watcher arm and re-arm are owned by the Stop `asyncRewake` hook (`bin/fm-claude-stop-autoarm.sh`), never by you.\n   Every turn end while supervision is needed launches or attaches one home-scoped watcher cycle with no model command and no model tokens.\n   An actionable close wakes you through the hook's exit-2 rewake, delivered as a `Stop hook feedback` message.\n3. On a `Stop hook feedback` wake (`signal:`, `stale:`, `check:`, or `heartbeat`), run `bin/fm-wake-drain.sh` first and handle the wake.\n   Do not run `bin/fm-watch-arm.sh` after an ordinary wake; the next turn end re-arms automatically when supervision is still needed.\n   Do not invent a wake from an attach-status line alone; drain and act only on real wake records, the drain's `OPEN DECISIONS` and `UNREAD STATUS` entries, or a real watcher reason line.\n4. On the one `Stop hook feedback` automatic-mechanism failure notice (`firstmate watcher auto-arm FAILED ...`), drain, inspect the automatic mechanism failure, and do not turn the notice into a repeating manual-arm loop.\n5. If the Stop hook does not claim the home or reports an exhausted failure, inspect its registration and watcher startup path before ending blind.\n   Keep the Stop-owned automatic mechanism as the only Claude arm owner.\n6. Treat `watcher: started ...` and `watcher: attached ...` inside automatic arm output as proof that one live cycle exists.\n   On attach, the arm fo

... [61595 bytes truncated] ...

=======================\n\ndata/projects.md\n--------------------------------------------------------------------------------\nABSENT\n\ndata/secondmates.md\n--------------------------------------------------------------------------------\nABSENT\n\ndata/captain.md\n--------------------------------------------------------------------------------\nABSENT\n\ndata/captain-shared.md (shared, main-authoritative, read-only in secondmate homes)\n--------------------------------------------------------------------------------\nABSENT\n\ndata/learnings.md\n--------------------------------------------------------------------------------\nABSENT\n\n================================================================================\nNEXT STEP\n================================================================================\nFollow the supervision operating instructions block above for harness 'claude'.\nThis script never starts supervision itself.\n\nThe digest above is complete for this session start. The READ-ONCE CONTRACT\nsection near the top of it governs what may still be read from disk.","numLines":168,"startLine":1,"totalLines":168}},"tool_result_meta":[{"id":"toolu_015cVKXzwSrCKThqXU7XAMhX","permission_decision":{"decision":"accept","source":"config","reason_type":"mode"}}]}
{"type":"assistant","message":{"model":"claude-opus-5-5","id":"msg_011CgcjfeDYuuEgzmVsH4bpN","type":"message","role":"assistant","content":[{"type":"text","text":"CYCLE0"}],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":2,"cache_creation_input_tokens":5189,"cache_read_input_tokens":51231,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":5189},"output_tokens":8,"service_tier":"standard","inference_geo":"global","speed":"standard"},"input_transformations":[],"diagnostics":null,"context_management":null},"parent_tool_use_id":null,"session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd","uuid":"e631b823-eb42-45db-b955-712cc008c6e9","timestamp":"2026-11-01T19:10:12.286Z","request_id":"req_011CgcjfdyfbtRuPS8GgtfGv"}
{"type":"rate_limit_event","rate_limit_info":{"status":"allowed","resetsAt":1793574000,"rateLimitType":"five_hour","overageStatus":"rejected","overageDisabledReason":"org_level_disabled","isUsingOverage":false,"unifiedWindows":{"five_hour":{"utilization":0.23,"resetsAt":1793574000,"status":"allowed"},"seven_day":{"utilization":0.5,"resetsAt":1793678400,"status":"allowed"}}},"uuid":"51d57701-c7d3-4e64-9e52-46fce55413f9","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd"}
{"type":"user","message":{"role":"user","content":[{"type":"text","text":"Stop hook feedback:\n[[ -z \"${GROK_AGENT:-}${GROK_HOOK_EVENT:-}\" ] || exit 0; exec \"$CLAUDE_PROJECT_DIR\"/bin/fm-claude-stop-autoarm.sh]: firstmate watcher wake - one supervision event needs a handling turn now.\nstale: fixture-rapid-1\nRun bin/fm-wake-drain.sh first, handle the wake, then run its exact WAKE_ACK_REQUIRED --ack-through command. Until that post-handling acknowledgement, interruption leaves the wake durable for idempotent re-handling. This Stop hook owns watcher continuity: when the handling turn ends, the next needed cycle arms automatically - do NOT run bin/fm-watch-arm.sh after an ordinary wake.\n"}]},"parent_tool_use_id":null,"session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd","uuid":"1c581f21-2af2-4192-a473-a7f9a6347918","timestamp":"2026-11-01T19:10:12.797Z","isSynthetic":true}
{"type":"system","subtype":"notification","key":"stop-hook-error","text":"Stop hook error occurred · ctrl+o to see","priority":"immediate","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd","uuid":"81c9fcd6-e87c-474f-8f8e-83431329d36d"}
{"type":"assistant","message":{"model":"claude-opus-5-5","id":"msg_011CgcjfkfFTeR6hv1QumZsS","type":"message","role":"assistant","content":[{"type":"tool_use","id":"toolu_01FCU7LbdZhZpFxBhmMrnfoX","name":"Bash","input":{"command":"bin/fm-wake-drain.sh","description":"Drain the wake queue"},"caller":{"type":"direct"}}],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":4,"cache_creation_input_tokens":296,"cache_read_input_tokens":56420,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":296},"output_tokens":16,"service_tier":"standard","inference_geo":"global","speed":"standard"},"input_transformations":[],"diagnostics":null,"context_management":null},"parent_tool_use_id":null,"session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd","uuid":"e539cb91-ebea-48fd-adcf-d7aedb311a1a","timestamp":"2026-11-01T19:10:14.873Z","request_id":"req_011CgcjfkQ8HmvdhQFjoCWQ5"}
{"type":"user","message":{"role":"user","content":[{"tool_use_id":"toolu_01FCU7LbdZhZpFxBhmMrnfoX","type":"tool_result","content":"stale: fixture-rapid drained","is_error":false}]},"parent_tool_use_id":null,"session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd","uuid":"7a73783f-dea3-4f42-95ca-a344e3d55724","timestamp":"2026-11-01T19:10:14.991Z","tool_use_result":{"stdout":"stale: fixture-rapid drained","stderr":"","interrupted":false,"isImage":false,"noOutputExpected":false},"tool_result_meta":[{"id":"toolu_01FCU7LbdZhZpFxBhmMrnfoX","permission_decision":{"decision":"accept","source":"config","reason_type":"mode"}}]}
{"type":"assistant","message":{"model":"claude-opus-5-5","id":"msg_011Cgcjfv3ZFw5zMmV7TRV4k","type":"message","role":"assistant","content":[{"type":"text","text":"ACK"}],"container":null,"stop_reason":null,"stop_sequence":null,"stop_details":null,"usage":{"input_tokens":2,"cache_creation_input_tokens":107,"cache_read_input_tokens":56716,"cache_creation":{"ephemeral_5m_input_tokens":0,"ephemeral_1h_input_tokens":107},"output_tokens":5,"service_tier":"standard","inference_geo":"global","speed":"standard"},"input_transformations":[],"diagnostics":null,"context_management":null},"parent_tool_use_id":null,"session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd","uuid":"ef460894-c9ae-40be-b4a7-f308eda8df77","timestamp":"2026-11-01T19:10:15.906Z","request_id":"req_011CgcjfupAA9sLEN86WeMRk"}
{"duration_api_ms":7816,"stop_reason":"end_turn","session_id":"69e9c5c9-9f8b-457f-864e-09098c869bfd","total_cost_usd":0.40871419999999997,"usage":{"input_tokens":10,"cache_creation_input_tokens":45779,"cache_read_input_tokens":175411,"output_tokens":368,"output_tokens_details":{"thinking_tokens":59},"server_tool_use":{"web_search_requests":0,"web_fetch_requests":0},"service_tier":"standard","cache_creation":{"ephemeral_1h_input_tokens":45779,"ephemeral_5m_input_tokens":0},"inference_geo":"global","iterations":[],"speed":"standard","fallback_credit":null},"modelUsage":{"claude-opus-5-5":{"inputTokens":10,"outputTokens":368,"cacheReadInputTokens":175411,"cacheCreationInputTokens":45779,"webSearchRequests":0,"costUSD":0.40871419999999997,"contextWindow":1000000,"maxOutputTokens":128000,"thinkingTokens":59,"cacheCreationEphemeral5mInputTokens":0,"cacheCreationEphemeral1hInputTokens":45779,"canonicalModel":"claude-opus-5-5","provider":"firstParty","costBasis":"list"}},"permission_denials":[],"terminal_reason":"completed","fast_mode_state":"off","fast_mode_disabled_reason":"sdk_opt_in_required","subagent_stats":{"spawned":0,"requested":{"background":0,"foreground":0,"unset":0},"started_in_background":0,"max_depth":0,"spawned_by_subagents":0,"completed":0,"failed":0,"killed":{"parent":0,"user":0,"system":0},"refused":{"depth_limit":0,"concurrency_limit":0,"budget":0},"by_type":{}},"safety_stops":0,"is_error":false,"num_turns":4,"subtype":"success","api_error_status":null,"result":"ACK","ttft_ms":2381,"type":"result","duration_ms":9123,"uuid":"6de37830-481f-4b50-a12b-257904b75b0c","ttft_stream_ms":1275,"time_to_request_ms":149,"first_content_frame_ms":1275,"queued_turn_count":0,"result_index":0,"model_usage_since_last_result":{"claude-opus-5-5":{"inputTokens":10,"outputTokens":368,"cacheReadInputTokens":175411,"cacheCreationInputTokens":45779,"webSearchRequests":0,"costUSD":0.40871419999999997,"contextWindow":1000000,"maxOutputTokens":128000,"thinkingTokens":59,"cacheCreationEphemeral5mInputTokens":0,"cacheCreationEphemeral1hInputTokens":45779,"canonicalModel":"claude-opus-5-5","provider":"firstParty","costBasis":"list"}}}
Evidence: Supervision-host park suite log

Source: Supervision-host park suite log

1..20
ok - host: two engine errors latch the session, main keeps every away wake in the cooldown, a failed probe doubles it up to its cap, and a report recovers it silently
ok - host: an attended close in a latched session reaches main as the arm printed it and leaves the latch as it was, and a home that opted out with off never reads it
ok - host: attended, two engine errors latch the session, main keeps every close unchanged in the cooldown, a failed probe doubles it up to its cap, and a routine probe's recovery stays in the ledger, off main
ok - host: an engine turn is bounded, and tool processes outside its process group are reaped
ok - host: a restarted host stops, by recorded identity, the cycle a killed predecessor left running
ok - host: an idle engine conversation is compacted once across hosts
ok - host: a conversation the next turn would not resume is not compacted
ok - host: a compaction abandoned at the park boundary is not marked done
ok - host: the park ends itself with a boundary wake and a stopped watcher
ok - host: waiting closes cannot carry the park past its boundary
ok - host: a close whose margin runs out while the successor starts reaches main at the boundary without a turn
ok - host: the park's test clock is inert without the test marker
ok - host: a park at or beyond the Stop-hook registration falls back to the default boundary
ok - host: an owner's later park limit lets a turn outlive the boundary, and no other limit does
ok - host: the first cycle's status streams once, --restart replaces a stale watcher, and an owner predecessor makes a handling successor
ok - host: an unchanged held outcome reaches the captain once across cadences, and a later decision on the task still does
ok - host: a home naming an unverified engine hands every away wake to main with the reason
ok - host: a host outside the session-lock owner stands down without arming
not ok - tagged: the host never started a watcher cycle: supervision-host stood down: this session does not own supervision
- Outcome: ⚠️ 2 warnings across 4 runs (53m15s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ bin/fm-claude-stop-autoarm.sh:682 - The merge resolution drops two fork-local hand-back patches and takes the upstream versions instead. (1) Commit 6c6a524 had removed the ! fm_watcher_healthy guard from the lost-hand-back branch, and the merged code restores it at bin/fm-claude-stop-autoarm.sh:682. (2) Commits 6c6a524/5da40016 had made the pass-through downtime-unrestored path emit before exit 1, and the merged code at bin/fm-supervision-host.sh:1322-1328 again exits 1 without emitting. Both fork patches were no-mistakes test-step fixes, not captain decisions. Upstream reworked the same flow in bb3e690/e2e4e564: line 604 now breaks on any nonzero host exit before the healthy-watcher dismissal, and an empty or failed host output retries and then reaches the failure notice. Taking upstream is consistent with the intent to adopt the watcher auto-arm fixes through the full sync. The fork's per-case process cleanup from the same area was carried over correctly as fm_test_after_each (tests/lib.sh:152, tests/supervision-host-helpers.sh:239). The test step should confirm that the split supervision-host suites (fm-supervision-host-hook/-park/-drain) pass on the upstream semantics.
⚠️ **Test** - 2 warnings
  • 🚨 tests/fm-claude-stop-autoarm-live-e2e.test.sh:121 - The live auto-arm regression gets 4 arm cycles where it expects 2, and upstream 41a47c0 fails the same way. Decide whether to ship the sync with this failure and report it to kunchenguid/firstmate.
  • 🚨 tests/fm-supervision-host-park.test.sh:613 - The Windows-tagged lock holder case fails on Linux ('this session does not own supervision'), and it fails identically on upstream 41a47c0. Report it upstream.
  • 🚨 live validation verdict: no-go (5 of 6 scenarios were driven live against the product); failed: Real Claude session with a stale lock gets exactly two hook-owned auto-arm cycles
  • Live validation: ❌ no-go - 5 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Captain registers a project with [no-mistakes pr=manual]: --pr reports manual, and bad or misplaced tokens are refused ✅ pass live pr-manual-registry.txt
Real Claude session with a stale lock gets exactly two hook-owned auto-arm cycles ❌ fail live live-autoarm-rerun.log, upstream-live-autoarm.log
Supervision host's real Claude engine drains an away wake and resumes the conversation ✅ pass live live-fm-supervision-host-live-e2e.log
Idle Claude primary in a Herdr lab and the engine are each compacted once (kunchenguid#7807) ✅ pass live live-fm-warm-compact-herdr-live-e2e.log
agy primary/secondmate hooks and launch work after the sync ✅ pass live live-fm-agy-primary-live-e2e.log
Split supervision-host suites pass on the upstream semantics ⏸️ untested no The prior payload did not establish a live result for this scenario. Only deterministic test suites ran for it, not the live product. Those suites showed the hook and drain suites passing, and one par…
  • bash tests/fm-claude-stop-autoarm.test.sh (exit 0)
  • bash tests/fm-supervision-host-hook.test.sh (exit 0)
  • bash tests/fm-supervision-host-drain.test.sh (exit 0)
  • bash tests/fm-supervision-host.test.sh (exit 0)
  • bash tests/fm-supervision-host-park.test.sh (exit 1, run twice: one case fails, the Windows-tagged lock holder; the same case fails on a 41a47c09 export)
  • bash tests/fm-merge-local.test.sh (exit 0)
  • bash tests/fm-watch-triage.test.sh (exit 0)
  • bash tests/fm-brief.test.sh (exit 0)
  • bash tests/fm-project-mode.test.sh (exit 0)
  • bash tests/fm-warm-compact.test.sh (exit 0)
  • Live: bin/fm-project-mode.sh [--pr] &lt;name&gt; against a disposable lab-home registry
  • Live: FM_CLAUDE_LIVE_E2E=1 tests/fm-claude-stop-autoarm-live-e2e.test.sh on the merged tree and on upstream 41a47c09 (both fail with 4 arm cycles)
  • Live: FM_SUPERVISION_HOST_LIVE_E2E=1 tests/fm-supervision-host-live-e2e.test.sh (exit 0)
  • Live: FM_WARM_COMPACT_LIVE_E2E=1 tests/fm-warm-compact-herdr-live-e2e.test.sh (exit 0)
  • Live: FM_AGY_PRIMARY_LIVE=1 tests/fm-agy-primary-live-e2e.test.sh (exit 0)

🔧 No changes applied.
3 issues (1 error, 2 warnings) still open:

  • ⚠️ tests/fm-claude-stop-autoarm-live-e2e.test.sh:121 - The live auto-arm test expects 2 arm cycles but gets 4. This is not a sync regression: base 9cd2c5c and upstream 41a47c0 fail the same way. Cause: the supervision host is on by default for a Claude primary, and it starts its own handling-successor arm ('pass-through successor-unrecorded'). It then retries arms on closes without a wake. The fixture counts every arm as if no host ran. The session behavior the test protects still works: stale-lock reclaim, the hook-owned rewake, and no model-issued arm. Firstmate upstream owns this test, so report it to kunchenguid/firstmate. Do not patch it in the fork.
  • ⚠️ tests/fm-supervision-host-park.test.sh:613 - The Windows-tagged lock holder case fails on Linux with 'this session does not own supervision'. It fails the same way on base 9cd2c5c and upstream 41a47c0, so this sync did not cause it. Report it to kunchenguid/firstmate.
  • 🚨 live validation verdict: no-go (6 of 7 scenarios were driven live against the product); failed: Live auto-arm regression test expects exactly 2 hook-owned arm cycles
  • Live validation: ❌ no-go - 6 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Real Claude session with a stale dead-owner lock reclaims the lock at session start, gets a hook-owned rewake (stale: fixture-rapid-1), and the model never runs an arm command ✅ pass live Kept-lab live run on the merged tree: .lock rewritten from 9999999, the digest says 'lock acquired: harness pid', the transcript has the Stop hook feedback with stale: fixture-rapid-1, and tool-calls.…
Live auto-arm regression test expects exactly 2 hook-owned arm cycles ❌ fail live live-autoarm-rerun.log, the kept-lab rerun, and base-9cd2c5cb-live-autoarm.log all show 4 cycles
Sync introduces no live auto-arm behavior change compared with the pre-sync base ✅ pass live Merged tree and base 9cd2c5c snapshot produce the same 4-cycle pattern in the same live test
Registering PRED projects with pr=manual: --pr reports manual, the mode output stays unchanged, and an invalid pr=auto is refused with exit 3 ✅ pass live pr-manual-registry-round2.txt (disposable lab home)
Split supervision-host hook, drain, and park suites pass on the upstream hand-back semantics adopted by the merge ⏸️ untested no The prior payload established this scenario only through unit-level test suites (round2-fm-supervision-host-{hook,drain,park}.log), not a live product run, so it did not establish a live result. Those…
Supervision host handles away wakes and warm-cache idle compaction works under Herdr with a real engine ✅ pass live live-fm-supervision-host-live-e2e.log, live-fm-warm-compact-herdr-live-e2e.log (round 1, same commit 2a92f40)
agy keeps its role and still exits, relaunches, and delivers wakes after the sync ✅ pass live live-fm-agy-primary-live-e2e.log (round 1, same commit 2a92f40)
  • Live diagnostic copy of tests/fm-claude-stop-autoarm-live-e2e.test.sh on the merged tree with the lab kept (real Claude 2.1.311): inspected arm-ran, drain-ran, .supervision-host.log, tool-calls.log, .lock, and the stream-json transcript
  • Same live test (FM_CLAUDE_LIVE_E2E=1 bash tests/fm-claude-stop-autoarm-live-e2e.test.sh) on a throwaway git snapshot of base 9cd2c5cb
  • bash tests/fm-supervision-host.test.sh on the base 9cd2c5cb snapshot (tagged-holder case)
  • bin/fm-project-mode.sh and bin/fm-project-mode.sh --pr against a disposable fm-lab home whose registry has pr=manual, +yolo pr=manual, no token, and an invalid pr=auto
  • bash tests/fm-supervision-host-hook.test.sh
  • bash tests/fm-supervision-host-drain.test.sh
  • bash tests/fm-supervision-host-park.test.sh
  • bash tests/fm-claude-stop-autoarm.test.sh
  • Round-1 live evidence for the same commit: fm-supervision-host-live-e2e, fm-warm-compact-herdr-live-e2e, fm-agy-primary-live-e2e

🔧 No changes applied.
3 issues (1 error, 2 warnings) still open:

  • ⚠️ tests/fm-claude-stop-autoarm-live-e2e.test.sh:121 - The live auto-arm e2e test expects 2 arm cycles but gets 4. Round 3 reproduced this result with no code change. Base 9cd2c5c and upstream 41a47c0 fail the same way, so this sync did not cause the failure. The test protects stale-lock reclaim, hook-owned rewake, and no model-issued arm, and all three still work. Upstream (kunchenguid/firstmate) owns this test. Decide whether to ship the sync with this known upstream failure and report the test to upstream. Another auto-fix round in the fork cannot clear it.
  • ⚠️ tests/fm-supervision-host-park.test.sh:613 - The Windows-tagged lock-holder case fails on Linux with 'this session does not own supervision'. It fails the same way on base 9cd2c5c and upstream 41a47c0, so this sync did not cause it. Decide whether to ship with this failure and report it to kunchenguid/firstmate.
  • 🚨 live validation verdict: no-go (2 of 6 scenarios were driven live against the product); failed: Real Claude session with a stale lock gets exactly two hook-owned auto-arm cycles
  • Live validation: ❌ no-go - 2 of 6 scenarios driven live against the product
Scenario Result Live Evidence
Real Claude session with a stale lock gets exactly two hook-owned auto-arm cycles ❌ fail live round3-live-autoarm.log; upstream-live-autoarm.log; base-9cd2c5cb-live-autoarm.log
Claude Stop hook auto-arms, reclaims a stale lock, and does not dismiss a lost hand-back (merged upstream semantics) ⏸️ untested no The prior payload did not establish a live result. This scenario ran only as a fixture-home test suite (round3-fm-claude-stop-autoarm.log, 63 ok), not against a live harness session.
Supervision-host hook and drain paths behave correctly after the conflicted merge ⏸️ untested no The prior payload did not establish a live result. This scenario ran only as fixture-home test suites (round3-fm-supervision-host-hook.log, round3-fm-supervision-host-drain.log), not against the live…
Supervision-host park, including a Windows-tagged lock holder ⏸️ untested no The prior payload did not establish a live result. The fixture-home park suite failed the tagged-holder case on Linux with 'this session does not own supervision' (same on upstream), but that is a tes…
A registry entry with pr=manual reports manual, and an unknown pr value is refused ✅ pass live pr-manual-registry-round2.txt; round3-fm-project-mode.log
Conflicted watch-triage, merge-local, and brief paths still work ⏸️ untested no The prior payload did not establish a live result. This scenario ran only as fixture-home test suites (round3-fm-watch-triage.log, round3-fm-merge-local.log, round3-fm-brief.log), not against the live…
  • bash tests/fm-claude-stop-autoarm.test.sh (63 ok)
  • bash tests/fm-supervision-host-hook.test.sh (24 ok)
  • bash tests/fm-supervision-host-drain.test.sh (17 ok)
  • bash tests/fm-supervision-host-park.test.sh (18 ok, 1 not ok: tagged holder)
  • bash tests/fm-project-mode.test.sh (12 ok)
  • bash tests/fm-watch-triage.test.sh (127 ok)
  • bash tests/fm-merge-local.test.sh (9 ok)
  • bash tests/fm-brief.test.sh (46 ok)
  • FM_CLAUDE_LIVE_E2E=1 bash tests/fm-claude-stop-autoarm-live-e2e.test.sh against the real Claude CLI and login in an isolated FM_HOME (fails: 4 cycles, not 2)
  • Earlier rounds: the same live e2e and the park suite on base 9cd2c5cb and upstream 41a47c09 (identical failures); a pr=manual registry check through bin/fm-project-mode.sh in a lab home

🔧 No changes applied.
2 warnings still open:

  • ⚠️ tests/fm-claude-stop-autoarm-live-e2e.test.sh:121 - The live Claude auto-arm test fails on the sync with 4 arm cycles where it expects 2. Round 4 ran the same probe side by side on base 9cd2c5c, upstream 41a47c0, and the sync 2a92f40, and all three gave identical results: 4 arms, 2 drains, only the first rewake (fixture-rapid-1) delivered, and no arm command from the model. The second hook-owned rewake (fixture-rapid-2) never reaches the model on any ref. That gap is an upstream defect or test-fixture defect, not a sync regression. Decide whether to ship the sync with this known failure and report it to kunchenguid/firstmate. Another fork auto-fix round cannot clear it.
  • ⚠️ tests/fm-supervision-host-park.test.sh:613 - The Windows-tagged lock-holder case fails on Linux with 'this session does not own supervision'. Earlier rounds confirmed that the case fails the same way on base 9cd2c5c and upstream 41a47c0, so this sync did not cause it. Decide whether to ship with this failure and report it to kunchenguid/firstmate.
  • Live validation: ✅ go - 3 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Captain registers a PRED project with [no-mistakes pr=manual]: fm-project-mode reports 'no-mistakes off' and --pr reports 'manual', and an unannotated project reports 'auto' ✅ pass live round4-pr-manual-registry.txt
Adversarial: pr=manual on a direct-PR project, and pr=manual outside the brackets, are both refused with a clear error (the misplaced token exits 3) ✅ pass live round4-pr-manual-registry.txt
A real Claude session that starts with a stale lock gets the session-start digest, reclaims the lock, and receives a hook-owned rewake with no model-issued arm, the same as on base and upstream ✅ pass live round4-live-autoarm-parity.md (base, upstream, and sync all give 4 arms, 2 drains, rewake fixture-rapid-1, and model calls only bin/fm-wake-drain.sh)
The merged conflict files (autoarm, supervision-host hook/park/drain, merge-local, watch-triage, brief, project-mode) keep their tested behavior ⏸️ untested no The prior payload did not establish a live result for this scenario. Its only support was the repository's own fixture-driven suites (round4-fm-*.log), which are not a live run of the product. Those s…
  • bash tests/fm-claude-stop-autoarm.test.sh
  • bash tests/fm-supervision-host.test.sh
  • bash tests/fm-supervision-host-hook.test.sh
  • bash tests/fm-supervision-host-park.test.sh (1 pre-existing upstream failure: tagged holder)
  • bash tests/fm-supervision-host-drain.test.sh
  • bash tests/fm-project-mode.test.sh
  • bash tests/fm-merge-local.test.sh
  • bash tests/fm-watch-triage.test.sh
  • bash tests/fm-brief.test.sh
  • Live: FM_HOME=$LAB bin/fm-project-mode.sh [--pr] &lt;project&gt; against a disposable lab registry with pr=manual entries
  • Live: FM_CLAUDE_LIVE_E2E=1 bash tests/fm-claude-stop-autoarm-live-e2e.test.sh on the sync (real claude)
  • Live: the same test with relaxed count checks, run side by side on 9cd2c5cb, 41a47c09, and 2a92f40a in disposable clones
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

kunchenguid and others added 30 commits October 26, 2026 13:41
…is warm (kunchenguid#7807)

* feat(bin): add opt-in warm-cache compaction for the Claude primary and host engine

Refs kunchenguid#7755

* no-mistakes(review): Persist engine compaction marker, run it abortable, match resume predicate

* no-mistakes(review): Run engine compaction in host shell; skip marker on abandon

* no-mistakes(review): Test abandoned engine compaction is not marked done

* no-mistakes(document): Clarify warm-compact episode and engine resume rules

* no-mistakes(lint): Fix ShellCheck SC2015 in engine compaction marker

* no-mistakes(ci): Test coverage guard and portable parallel 2 failed because the two new warm-compact tests had no timing hint. The runner packed them at the 45000 ms default, pushing the largest serial shard to 1204066 ms, over the 1200000 ms limit. I added measured hints in bin/fm-test-run.sh (fm-warm-compact.test.sh 1500, fm-warm-compact-herdr-live-e2e.test.sh 170). `bin/fm-test-run.sh --check-coverage` now passes (largest serial shard 1194253 ms), and tests/fm-supervision-instructions.test.sh passes. A full run of tests/fm-test-run.test.sh was killed at its time limit and did not finish, so it is unverified. The serial-shard failures in the logs were watcher/timing tests unrelated to warm-compact. I did not reproduce them locally. main also has a failing run. They need a rerun, not a code change
…7810)

* refuse remote Rex servers during spawn

* no-mistakes(document): Clarify Rex locality requirements and remote-worker guidance
* fix(bin): read a Windows win:<pid> session lock in the supervision host and Claude auto-arm

On Git Bash the session lock records its holder as a tagged win:<pid>
(kunchenguid#6300), but four readers still passed that value to the numeric-only
fm_pid_identity and fm_pid_alive: fm_supervision_host_main_key produced no
key, fm_autoarm_claim_next pinned no lock-holder identity and dropped
owner_session_id, fm_autoarm_claim_open rejected the non-numeric lock so a
live claim never read as open, and fm_autoarm_midturn_healthy read a live
holder as lapsed.

Add fm_session_pid_alive and fm_session_pid_identity beside the tagged-pid
contract in fm-session-lock-lib.sh. A tagged pid is answered from the
Windows process table; every other value falls straight through to the
existing numeric helpers, so POSIX behaviour is unchanged. The claim
read-back checks the lock shape with fm_session_pid_valid.

tests/fm-session-lock-windows-consumers.test.sh covers each reader on a
faked Git Bash host, including an exited holder, a reissued Windows pid,
and the tag off Windows, plus a parity case proving untagged values get
exactly the numeric helpers' answers.

Fixes kunchenguid#7739

* no-mistakes(document): Document tagged Windows session-lock consumers

* no-mistakes(ci): Fixed tests/fm-afk-return.test.sh partial host fixtures to copy fm-session-lock-lib.sh alongside fm-supervision-engine-lib.sh in all three affected paths. The focused host/latch tests and tests/fm-session-lock-windows-consumers.test.sh pass; the full afk-return suite exceeded the 180s local timeout after earlier cases passed
)

* test: fail required watcher-triage cases without tasks-axi

* no-mistakes(document): Document required watcher-test dependency and failure rationale

* no-mistakes(ci): Rebased onto 2ba4c45 successfully. New HEAD: 5902c09. Preserved all changes in the relocated pause suite. No conflicts or tracked changes remain. Missing-dependency regression, syntax, and diff checks passed. Command guards blocked the installed-dependency test loop and backup cleanup. Untracked .ci-rebase-backup.bundle remains

* Untrack pipeline backup bundle

* no-mistakes(review): Untrack pipeline backup bundle; exclusion remains blocked

* Untrack excluded pipeline backup bundle

* no-mistakes(document): Document watcher test prerequisite and remove stale count

* no-mistakes(ci): Fixed SC2329 with a one-line annotation for the function exported to child Bash. Tier 3 applies because static analysis cannot trace that indirect use. Focused lint, all four missing-dependency cases, syntax, and diff checks passed
…unchenguid#7875)

* fix(scout): authorize task-scoped empty-inventory completion (#103)

Allow scouts to run only their generated complete --none command for an empty inventory, without granting metadata or backlog edit authority. Keep non-empty inventories and refused attestations with firstmate.

Fork carry for kunchenguid#7862 pending upstream validation.

* fix(scout): allow scoped empty-inventory attestation

* no-mistakes(document): point lifecycle doc at scout brief boundary test
* Add opt-in reminders for overdue open worker decisions

* no-mistakes(document): Align overdue-decision documentation with watcher behavior

* no-mistakes(ci): Fixed ci-1 with a tier-1 structural correction: AWK now compares both task and key as exact strings. Added behavioral regressions for keys 1/01 and task IDs 1/01, including independent backoff. Reproduced the failure before the fix. All focused reminder, decision-key and cursor tests passed, as did stock /bin/bash verification, canonical lint and git diff --check. Only the two intended files changed. No scratch files remain. Publication and PR updates remain with the outer executor
* fix(pi): contain repeated successful unchanged primary reads

Add an off-by-default Linux Pi primary safeguard with bounded configurable
limits, verified ownership, durable stopping, and deliberate user reset.
Preserve ignored legacy guards and require explicit collision migration.

Cover policy, SDK compatibility, installed RPC behavior, and test selection.
Refs kunchenguid#7805.

* no-mistakes(test): Fixed locale-dependent coverage checks; coverage and shard packing passed
…uid#7886)

* fix(bin): reclaim a lock whose dead holder's pid was reused

The generic lock in fm-wake-lib.sh judged a record stale only by asking
whether its pid was alive. Once the holder died and the kernel handed that
pid to an unrelated process, the lock read as held forever and every
acquirer spun and gave up - each watcher re-arm paid for it while trying
to append to the cycle ledger.

Acquisition now records the holder's start time beside its pid, and a
record whose live pid no longer has that start time is stale, so the
ordinary stale-owner takeover reclaims it and reports the pid it took over.
Start time alone is the key because a holder may exec another program,
which keeps its pid and start time but replaces its command line. A record
without a start time, or a pid whose start time cannot be read, keeps the
old pid-liveness answer. The bounded wait's handoff drops the helper's
start time before the pid changes hands and records the caller's after.

Refs kunchenguid#7885

* no-mistakes(document): Note reused-pid lock staleness in FM_LOCK_STALE_AFTER
… work (kunchenguid#7352)

* feat(bin): add opt-in config/spawn-base-primary-checkout for local landings

A fresh pooled task worktree is reset to origin/<default>. A local-only
project lands work on the primary checkout's default branch through
fm-merge-local.sh and never pushes, so that ref stays frozen at the last
push and every fresh task starts behind work already landed, loading the
project's instruction files from the stale tree. The always-on fix proposed
in kunchenguid#3812 replaced the specified origin-only refresh for every home; this
rework keeps that rule as the default and moves the new base behind an
explicit, default-off presence flag, following the existing config/<flag>
pattern.

With config/spawn-base-primary-checkout present:
- fm-spawn.sh starts a fresh local-only ship, or a scout without
  --base-branch, from the primary checkout's <default> when it strictly
  contains origin's tip. Publishing modes and named base branches keep
  origin's tip, because that work is delivered against origin. A diverged
  primary keeps origin's tip and prints a note counting both sides. The
  commit is read from the local object store, so nothing extra is fetched,
  and the clean-slot refusal still runs first.
- fm-review-diff.sh anchors a remote-backed task without base_branch= on the
  branch it delivers to: publishing modes stay on origin/<default>, while a
  local-only ship or a scout is compared against whichever of the local
  <default> and origin/<default> meets the branch later, so the review shows
  the task's own work instead of every locally landed commit.
- fm-promote.sh tells a scout promoted to a publishing mode to return to
  origin's default branch, because in this home the scout may have started
  from the primary checkout's branch, whose unpushed commits would otherwise
  be published with the work.

fm-dod-lib.sh gains fm_mode_publishes as the one predicate those three
readers share. Without the flag every path is unchanged: the spawn resets
to origin's tip, the review anchors on origin/<default>, and promotion keeps
its wording; the existing tests run unmodified. Treehouse 3 (verified on
3.1.3) already hands a slot out at whichever of the local and remote default
branch is further ahead, so with the flag the refresh keeps that slot where
Treehouse put it for a local landing instead of rewinding it, and a project
without origin is untouched as before.

Supersedes kunchenguid#3812.

* no-mistakes(document): Drop change-relative wording from spawn-base config docs

* no-mistakes(ci): The Greptile Review check failed on two review findings, not on a broken build or test. I fixed both as the user directed, and the tests and lint pass. ci-1 (bin/fm-promote.sh): promotion must name origin's default branch only when spawn could actually have started the scout from the primary checkout. Spawn does that only when the project has an origin remote and is recorded on the task. Before this fix, the opt-in flag alone made promotion to no-mistakes or direct-PR say "copy of origin's default branch...", even on a project with no origin. - The new wording now also requires a recorded project (`[ -n "$PROMOTE_PROJECT" ]`) whose `git remote get-url origin` succeeds. That is the same check bin/fm-review-diff.sh already makes. The empty-project guard is needed because `git -C ""` would run in the current directory. Otherwise the existing "default-branch base" wording stays. - The three places that read the flag now agree: spawn, review-diff and promote. - I updated the header and inline comments in fm-promote.sh, and the promote line in docs/configuration.md, to say this applies only to a project with an origin remote. - Test: `test_promote_names_origin_for_a_publishing_mode_in_an_opted_in_home` in tests/fm-task-delivery.test.sh now records a real `project=` with a registry entry, and covers flag on/off × origin/none × direct-PR/no-mistakes/local-only. Only flag on + origin + a publishing mode gets the new wording. The named-base case is unchanged. - Before the fix, the test fails with "not ok - flag on, remote none, direct-PR: the promotion changed the default-branch wording". With the fix, it passes. ci-2 (tests/fm-spawn-pool-base-freshen.test.sh): with the flag set, both publishing modes must start from origin's tip and print no divergence note. - The opted-in spawn test now covers no-mistakes as well as direct-PR, local-only and scout. - The expectations no longer single out direct-PR. Both publishing modes now expect origin's tip, no "note: pooled worktree", and a review anchored at the slot's start, in the leading, diverged and trailing cases. Verification: - `bash tests/fm-task-delivery.test.sh`: exit 0. - `bash tests/fm-spawn-pool-base-freshen.test.sh`: exit 0. - `bin/fm-lint.sh` on the three changed shell files: exit 0 (ShellCheck 0.11.0, pinned, with extended analysis)
…enguid#7915)

* fix(teardown): distinguish unavailable content-landed proof

* no-mistakes(document): Clarify teardown proof failure documentation

* no-mistakes(ci): Captain, CI failed in unchanged watcher recovery code, independent of this PR. The focused failing case passed locally with exit 0. The full suite stalled earlier and was stopped. No tracked changes. Command guard rejected cleanup; scratch remains at .ci-7915/ and tests/.ci-7915-cycle.sh

* chore: untrack CI validation scratch
…kunchenguid#7876)

* feat(dispatch): prefer configured provider family

* no-mistakes(review): drop policy_why field and dead auth fixture from preference tests

* no-mistakes(document): docs: record preferred_provider in schema, diagnostics, verification
)

* fix: pin local-only landing to its accepted done head

Persist the accepted local-only commit in task metadata and refuse landing when the branch or the recorded head changes. Merge the full commit ID under the task control and metadata locks.

Closes kunchenguid#7782

* no-mistakes(test): Refuse local landing races with atomic ref transactions

* no-mistakes(document): Document pinned local landing and recovery contracts

* no-mistakes(ci): Applied only the verified incremental patch and preserved existing repairs. Complete diff matches the supplied candidate hash. Both focused test files, default lint, and source-aware lint passed with exit 0. Evidence retained at /tmp/up7782-local-repair/ci-phase-fresh-*. No commits, pushes, or pipeline-control actions performed; publication remains with the outer executor

* no-mistakes(ci): Fixed both SC2031 false positives in tests/fm-merge-local.test.sh with narrowly scoped suppressions. Tier 2 lint correction; runtime changes were unnecessary. Default lint, source-aware lint, all 8 focused tests, and git diff --check passed. No commits, pushes, or pipeline-control actions performed
…henguid#7928)

* fix(procevent): coalesce unhandled extension host errors

* no-mistakes(document): Document host-error coalescing and recovery semantics
…uid#7912)

* fix: stop wake grants when lock acquisition fails

* no-mistakes(document): Document wake grant lock acquisition failure behavior
* fix: send remote steers over stdin

* fix: version remote stdin send protocol

* no-mistakes(document): document stdin transport for remote steer in fm-send header

* no-mistakes(ci): Two tests failed in CI. One is caused by this PR; the other is not. 1. Behavior portable serial 5: `tests/fm-secondmate-reconcile.test.sh` failed with "supervision did not deliver the durable reconcile request later". This PR caused it. The PR now sends a remote steer's body on stdin, using `fm-on.sh --stdin` with the `send-stdin` verb. This test's fake ssh started with `cat > /dev/null`, so it threw the body away before it ran the real `fm-remote-secondmate-control.sh`. `cmd_send_stdin` then read an empty message, died with "remote steer message must be nonempty", and no inbox record was written. Rule that broke: a fake ssh that runs the real remote leg must pass the caller's stdin through, as real ssh does. I checked every fake ssh that runs the real leg. `fm-send-remote-delivery.test.sh` already passes stdin through. `fm-secondmate-sync.test.sh` (`make_remote_leg_ssh_stub`) had the same discard line. The stub in `fm-send-resolve-key.test.sh` never runs the leg, so it is fine. The fix deletes the `cat > /dev/null` line in the reconcile and sync stubs. Calls made without `--stdin` still get /dev/null from fm-on, so nothing else changes. Checks run locally: the reconcile test fails before the fix with the same CI message. After the fix, the reconcile test passes (rc=0) and the sync test passes (rc=0). 2. Behavior portable serial 3: `tests/fm-wake-queue.test.sh` failed in `test_concurrent_append_and_drain` with "wake drain: queue lock could not be acquired safely". This PR did not cause it. The PR does not touch `bin/fm-wake-drain.sh`, the wake tests or the wake helpers. The failure is lock contention: 40 appenders run at the same time as a drain, on a loaded CI runner. Locally the whole test passed (70 ok, rc=0). I made no change for it. It is an existing flake in wake-queue lock acquisition and needs its own fix outside this PR. Open PR kunchenguid#7912 ("preserve wake grants when queue-lock acquisition fails") works in the same area
…owner manages (kunchenguid#7357)

* fix(herdr): never start a server an external owner manages or is replacing

fm_backend_herdr_server_ensure started a detached herdr server whenever
status reported the session not running. When a service manager owns the
server, that races a unit restart or a server live-handoff and splits panes
across two servers.

The session directory reported by herdr session list can now carry a
firstmate-server-owner marker (persistent, naming the owner) and a
firstmate-server-replacing marker (for the duration of a restart or handoff).
While either exists and the server is not running, server_ensure never starts
a server: it waits a bounded time (FM_BACKEND_HERDR_EXTERNAL_SERVER_POLLS,
default 30s) for the server to report running, and otherwise fails naming the
owner or the replacement. A running server is still used at once, and a
session with no marker keeps the Firstmate-owned autostart unchanged.

Fixes kunchenguid#7320

* no-mistakes(review): Enforce herdr replacement marker on fast path; fixed wait bound

* no-mistakes(ci): Both CI failures had one cause in this PR, and I fixed it in code; no test assertions changed. `fm_backend_herdr_server_ensure` had started running `herdr session list --json` on every call to find the session directory for the ownership markers. Two existing tests treat that call as a sign of something else: - `tests/fm-control-relaunch.test.sh` failed with "a herdr reclaim touched a session the record does not name: session list --json", because it allows only `--session fmlab` calls and `status --json`. - `tests/fm-backend-herdr-presentation-e2e.test.sh` failed with "opted-out spawn added presentation-ordering capability or socket calls", because there `session list` means presentation ordering ran. Invariant: `server_ensure` must not make Herdr calls beyond its own `status` read, so ordinary spawns and reclaims stay free of `session list` and only touch the session they name. Every caller goes through `server_ensure`, so fixing it there covers all of them. Fix (`bin/backends/herdr.sh`): the session directory now comes from the `status --json` read `server_ensure` already makes. It is the directory containing `.server.socket`. I removed the `fm_backend_herdr_session_dir` helper. On a running server, the only added work is one check for the replacement marker, which is what the user asked for. I checked this against real Herdr 0.9.5: - `status` reports the socket even when the server is stopped, for both the default and named sessions. - The socket's directory is the same `session_dir` that `session list` reports, and it follows `XDG_CONFIG_HOME`. - With `--session`, an inherited `HERDR_SOCKET_PATH` does not change it. - The read creates nothing on disk. If a Herdr version omits the socket, `server_ensure` keeps the old Firstmate-owned behavior, as the docs already said for a missing `session_dir`. Other changes: the marker-test fakes now report the socket under the session directory, and I removed the `session list` stub this PR had added to the shared fake. `docs/herdr-backend.md` and `docs/verification/runtime-backends.md` ("Session directory") now describe and record the `status`-socket measurement. Verification: - `tests/fm-backend-herdr.test.sh` passes: 239 ok, 0 not ok, including all the externally-managed and replacement-marker tests. - `tests/fm-control-relaunch.test.sh` passes; it was the shard 3 failure. - shellcheck shows only existing info-level notes. Not verified locally: the real-Herdr presentation test. Here it stopped earlier, at an unrelated Treehouse timeout ("treehouse get did not enter an isolated worktree within 60s"). After the fix `server_ensure` no longer runs `session list`, which is the call that assertion caught. No lab session was left running, and I removed the test's temp directory
)

* fix: classify actionable heartbeat backstop as a check

* no-mistakes(document): Correct heartbeat routing docs and remove stale test count

* fix: preserve heartbeat routing when resetting actionable backoff
…mputes (kunchenguid#7931)

* fix(bin): reclaim a lock whose recorded pid-identity no longer recomputes

kunchenguid#7886 made fm_lock_holder_alive reject a live pid whose start time no
longer matches the lock's recorded pid-start. A holder that predates that
record still falls back to pid liveness, which leaves issue kunchenguid#7801 open: on
a /proc-less host outside UTC, a watcher started before fm_pid_identity
pinned TZ=UTC0 recorded a local-time pid-identity. After the update that
live holder no longer matches its own identity, so the health predicate
rejects it, yet every new watcher stands down beside it and the home stays
unsupervised.

fm_lock_holder_alive now also requires a recorded pid-identity, when
present, to still recompute for the pid, after the existing start-time
check and with the same missing-evidence fallbacks: no record, a pid
rewritten mid-read, or an unreadable value keeps the pid-liveness answer.
Both records go through one helper, _fm_lock_record_matches. Only
long-lived holders that never exec write a pid-identity (the watcher, the
supervise daemon), so a genuine holder still matches. A watcher replaced
this way stands down unsignalled at its next poll through the existing
self-eviction. The fm_pid_identity comment and docs/turnend-guard.md
claimed the upgrade-window residual is cleared by the post-update restart,
which never reaches a primary home's own watcher; they now say the next
lock claim clears it.

Verification:
- Drove: real bin/fm-watch.sh processes with /proc hidden through
  FM_PROC_ROOT_OVERRIDE and TZ=America/Los_Angeles: a live genuine watcher
  whose lock record was rewritten to its own local-time ps lstart identity
  with no pid-start, as a pre-pin build wrote it, then a fresh watcher;
  plus fm_lock_try_acquire against a live pid with a mismatched, matching,
  and unrecorded pid-identity and no pid-start.
- Observed: on the unchanged library the fresh watcher exits "lock held by
  live pid ... but heartbeat is stale" and fm_lock_try_acquire returns
  held for the mismatch. With this change the fresh watcher takes the
  lock, the legacy holder exits 0 by standing down, the live pid is never
  signalled, and matching or unrecorded identities stay held.
- Re-check: tests/fm-watcher-lock.test.sh cases
  test_watch_replaces_live_holder_with_legacy_local_time_identity and
  test_lock_reclaims_holder_whose_identity_no_longer_recomputes.

* no-mistakes(review): Limit pid-identity lock reclaim to the watch lock

* no-mistakes(document): Correct fm_lock_holder_alive comment on non-watch identity locks

* no-mistakes(ci): I made two small fixes. CI and "Require no-mistakes" never ran: GitHub shows both as `action_required`, waiting for approval to run workflows from a fork, so the code didn't cause those. Greptile failed because it scored the PR 4/5 against a required 5/5, with one P2 comment. 1. **Greptile P2, test children left running (`tests/fm-watcher-lock.test.sh`).** The two new lock tests start a `sleep 300` holder that only gets killed after every assertion passes, and the suite's cleanup only reaps processes whose command line contains the fixture root. Each holder now starts as `(exec -a "$dir/holder" sleep 300)`, so cleanup reaps it if the test fails early. To check, I forced a `fail` right after the child starts: on HEAD the `sleep 300` was still running afterwards, and with the fix it was reaped. Both tests pass normally. 2. **Flaky takeover test (`bin/fm-watch.sh`).** This edit was already uncommitted in the worktree. Twelve isolated runs passed without it, so I first dropped it as out of scope, but the full suite then failed on exactly this race. When a successor takes over a live watcher's lock, it deletes the lock and recreates it while holding `.watch.lock.steal`. If the old watcher checks during that gap, it sees no lock `pid` and exits as "state directory was torn down", not by standing down cleanly as the PR intends. That race only happens once this PR lets a healthy, live watcher's lock be taken. The guard treats a missing `pid` as teardown only when no `.steal` marker exists, with a comment explaining why. With it restored, 15 runs of the takeover test (three at a time, to add load) all passed, and all three PR tests passed in the full suite. **Remaining failures:** with the guard restored, I ran the full suite three times and it failed each time, but always on tests this change doesn't touch: "bounded child cleanup regression" twice and "bounded ledger cycle 2 did not start" once. The host's load average was about 100, and these tests depend on timing; one of them runs before any watcher starts. I didn't confirm they also fail on the base commit. shellcheck reports nothing in the test file beyond info notes about files it didn't follow, and one existing warning in `fm-watch.sh` at line 2598, not from this change. I deleted the leftover temporary runner `tests/.tmp-one.sh`. Nothing is committed or pushed

* fix(bin): re-read the watch lock holder after the steal check

The steal-gap guard read the lock pid, then the steal mutex. A successor
that removed and relinked the lock between those reads let the old
watcher see no pid and then no steal mutex, so it exited as "state
directory was torn down" instead of standing down. Upstream CI hit this
in tests/fm-watcher-lock.test.sh
(test_watch_replaces_live_holder_with_legacy_local_time_identity).

The teardown branch now re-reads the pid after the steal mutex. The
steal mutex is held for the whole remove-and-relink, so a steal that
finished between the first two reads has already relinked the lock by
the third read, and the self-eviction below stands the watcher down.

Verification:
- Drove: the takeover test (real bin/fm-watch.sh processes) 48 times,
  six at a time, with and without this change, plus the whole
  tests/fm-watcher-lock.test.sh file.
- Observed: the interleaving is too narrow to hit locally (48 of 48
  passed either way); the whole file passes with this change. The
  failing CI run shows the old watcher's exit 1 teardown message.
- Re-check: Behavior portable serial 6 on this PR's CI.

* no-mistakes(review): Scope fm_pid_identity residual comment to the watch lock

* no-mistakes(review): Align fm_pid_identity residual comment with autoarm reclaim behaviour

* no-mistakes(document): Note watch-lock identity mismatch skips lock stale grace

* fix(bin): tell a released watch lock from a torn-down state directory

A watcher replaced by a successor still exited 1 as "state directory was
torn down" on upstream CI. The successor that reclaims the lock delivers
its recovery wake and exits, releasing the lock, and on a fast runner
that happens before the old watcher's next poll. The old watcher then
found no lock holder and no steal in progress, which the teardown check
read as a recreated state directory.

The watcher now holds its state directory open (fd 6) from startup, and
a lock with no holder is a teardown only when the directory at that path
is no longer the one it holds; otherwise the lock was released by a
successor and the self-eviction stands the watcher down with exit 0. The
held descriptor keeps the inode from being reused by a recreated
directory. A host that cannot open a directory keeps the old reading.
This replaces the steal-marker check and pid re-read, which only covered
a successor still relinking the lock.

Verification:
- Drove: real bin/fm-watch.sh processes. A new regression,
  test_watch_replaced_holder_stands_down_after_successor_exits, pauses
  the old holder (SIGSTOP, only while it holds no other state lock) until
  the successor has delivered its wake and exited, then resumes it. Also
  a standalone run with the old watcher polling every 5s.
- Observed: on the previous head the old watcher exits 1 "state
  directory was torn down (singleton lock removed)", the CI failure,
  every time; with this change it exits 0 by standing down. Both
  takeover tests passed 20 of 20 runs four at a time on one loaded CPU.
  The teardown tests in tests/fm-watch-arm.test.sh (state directory and
  home removed) still pass.
- Re-check: tests/fm-watcher-lock.test.sh and Behavior portable serial 6.

* no-mistakes(test): Hold the watcher's state directory open before claiming the lock

* no-mistakes(document): Docs already match watch-lock identity reclaim change

---------

Co-authored-by: mangocabs2025 <250559406+mangocabs2025@users.noreply.github.com>
…nguid#7911)

* Fix non-GNU timeout fallback

* no-mistakes(review): Assert INT reaches watcher in non-GNU timeout fallback test

* no-mistakes(document): Document GNU-only timeout selection in watch checkpoint

* no-mistakes(ci): Greptile flagged that only the non-GNU-timeout-to-Perl path had an isolated test. I added two isolated tests in tests/fm-watch-checkpoint.test.sh, as you asked. The production code is unchanged. The rule being tested: run_bounded must run GNU `timeout` first, then GNU `gtimeout`, then Perl. Whichever GNU command it runs must receive `--signal=INT --kill-after=<bound>s <seconds> <watcher>`. What changed: - **Shared setup:** a new helper, `make_isolated_checkpoint`, copies the checkpoint into a temporary root. It also builds a PATH that holds only the named host tools, so the stubs decide which timeout is found. The existing Perl-fallback test now uses this helper too. Its assertions are the same. - **Stubs:** a non-GNU stub reports `uutils` for `--version` and exits 137 if it is ever used. A GNU stub reports `GNU coreutils` and writes its own name and arguments to `$FM_HOME/timeout-calls`, then exits 124. - **`test_gnu_timeout_runs_the_watcher_bound`:** GNU `timeout` and GNU `gtimeout` are both on PATH. The test asserts exit 124, the quiet checkpoint line, and exactly one call: `timeout --signal=INT --kill-after=5s 1 <root>/bin/fm-watch.sh`. - **`test_non_gnu_timeout_uses_gnu_gtimeout`:** a non-GNU `timeout` is next to a GNU `gtimeout`. The test asserts the same exact call, made by `gtimeout`. - In both new tests, Perl is not on PATH. So if the code picked Perl by mistake, the run would fail with 127. How I checked it: - The full test file passes: all 14 tests. - I broke the code on purpose twice. When I swapped the order to try `gtimeout` first, the GNU timeout test failed. When the code always picked Perl, the run exited 127 instead of 124. I then put the production file back; `git status` shows only the test file changed. - `shellcheck -x` passes on the test file. This is a change to tests only, so there is nothing a user would see to check by hand
* fix: recover ownerless extension readiness and announce cleanup refusals

* no-mistakes(review): Reset cleanup failure episodes and classify failure wakes

* no-mistakes(document): Document ownerless readiness recovery and cleanup failure wakes

* no-mistakes(document): Clarify cleanup failure documentation ownership

---------

Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
kunchenguid#7874)

* Keep malformed remote reply captures from wedging

* no-mistakes(document): Fix garbled remote reply source failure comment

* no-mistakes(document): Document remote reply failure handling

---------

Co-authored-by: Pitch Perfekt Collective <pitchperfekt@Pitchs-Mac-Studio.local>
…n PR text (kunchenguid#7937)

* feat(bin): per-project pr=manual registry token for hand-written PR text

A no-mistakes ship on a project where an outside maintainer reviews the PR let
the pipeline's pr step rewrite the hand-written title and body on every
validated push. The registry now records pr=manual, resolved by
fm-project-mode.sh --pr and carried by fm-brief.sh --pr, fm-spawn.sh and
fm-promote.sh like forge=. The generated brief skips pr and ci, and the worker
writes and publishes the PR text itself.

* no-mistakes(review): Drop pr_text key; fix manual-PR checks wait and base

* no-mistakes(review): Remove dead PR_TEXT and timeout example

* no-mistakes(document): Fix README pr=manual sentence grammar

* test(bin): restore the displaced placeholder comment and rename the spawn agreement test

The comment for the leftover-placeholder test sat above the new pr=manual tests.
The spawn test said it recorded the PR text, but it only checks that a launch happens.
* fix(teardown): detect untracked work regardless of Git status config

* test(watcher): avoid blocking FIFO contention handshakes

* no-mistakes(document): Document hidden-untracked teardown safety

---------

Co-authored-by: Kun Chen <3233006+kunchenguid@users.noreply.github.com>
* fix: prefer current run over stale overview row

* fix: preserve newest run precedence over stale status

* no-mistakes(document): Document live-run precedence in crew-state attribution

* fix: use ledger order for same-minute run precedence

* test: cover both overview orders for same-minute run attribution

Document and pin newer-first (recorded AXI) and historical-first overview
orders. Same-minute ledger timestamps use row order as the tie-break so an
older live bare status cannot hide a newer completed run.

* no-mistakes(review): Treat failed as overridable terminal overview status

* no-mistakes(review): Fix equal-head live run precedence with identity ordering

* no-mistakes(document): Updated run identity ordering documentation

* no-mistakes(lint): Fix ShellCheck export warning

* no-mistakes(review): Prove same-head ordering or report unknown

* no-mistakes(review): Guard failed selected-run reads and drop dead same-head ordering

* no-mistakes(ci): I fixed both Greptile findings (ci-1, ci-2) in bin/fm-crew-state.sh. The change is in the working tree. I did not commit it, push it, or reply to the Greptile threads, because those steps belong to the outer pipeline. ci-1. Invariant: a live run from bare `axi status` may replace a terminal overview selection only when it is proven newer than every other run on the same branch. Previously the code compared it only against the selected run. Now crew-state reads each other candidate with `axi status --run <id>` and compares the live run against each one: - If another candidate is also live, it reports `unknown`, "competing live runs". This keeps the competing-live-runs check. - If two runs share a head and a ULID timestamp, it reports `unknown`, "same-head run ordering unverified", as before. - It promotes the live run only when it is proven newer than all other candidates. - If the live run is newer than the selected run but not proven newer than some other candidate, it reports `unknown`, "run ordering unverified", and names every run id. This means neither the stale selected run nor the live run can hide a newer failed run. This branch is the one judgement call: without it, the stale "done" row A would still hide C's failure. - In all other cases the overview's selection stands. The lib helper is now a pairwise compare called `fm_nm_run_is_newer_than` (it was `fm_nm_run_is_newer_than_selected`). The selected run's detail from the loop is reused when the read succeeded, as in the round-1 fix. I updated the sentence in docs/architecture.md to match. ci-2. Invariant: the `no-mistakes runs` ledger is read only to order runs with different heads. It is now fetched lazily, at most once, and only when a candidate's head differs from the live run's head. Same-head ULID comparisons never call it. Regression test: `test_live_run_newer_than_selection_does_not_hide_newer_failed_run` covers A (stale completed, listed first), C (newer failed) and B (live, created between them). All three share one head and use ULID ids. It expects `state: unknown`, C's id in the output, and no `state: working`. Before the fix it fails: with the fixed code stashed it printed `state: working ... run: 01M1...` (run B). On the original base 3fbace9 the overview would select A, so the output would be `done`, which also fails the `unknown` check. I did not run that base case. Verification: `bash tests/fm-crew-state.test.sh` passes in full ("all fm-crew-state tests passed", the new test included). `shellcheck` on the three changed shell files reports only the existing info-level SC1091 "not following sourced file" notes. No end-to-end run against a live no-mistakes daemon was possible here. I checked the change with the crew-state test harness and its fake `no-mistakes` CLI

---------

Co-authored-by: mehulbhagwani <mehulbhagwani@users.noreply.github.com>
Co-authored-by: Pitch Perfekt Collective <pitchperfekt@Pitchs-Mac-Studio.local>
WTF-Am-ID and others added 28 commits October 29, 2026 23:17
…rce (kunchenguid#5409)

* feat(dispatch): read Typesafe key from Keychain

* no-mistakes(review): Share Keychain key lookup with bootstrap; hard-code service name

* no-mistakes(review): Use one readable-secret Keychain check for bootstrap and resolver

* no-mistakes(document): Point AGENTS key row to owner; record Keychain bootstrap evidence

* feat(dispatch): read provider keys from a declared credential source

bin/fm-dispatch-resolve.sh took the typesafe.ai and OpenRouter keys only
from the environment or $FM_HOME/.env, so a home that keeps its key in the
macOS Keychain needed a wrapper to supply it, and the documented direct
call reported off.

Let the resolver consume an optional, provider-keyed declaration in the
effective config directory, config/dispatch-credential-sources.json. It
names where a key lives and never holds one. macos-keychain is the first
adapter (service, optional account), kept behind a small schema and adapter
registry in bin/fm-credential-source-lib.sh so the shared surface binds to
no one OS or provider.

- Precedence is the environment, then .env, then the declared source, which
  is read only when neither supplied a key and only for the selected
  provider.
- No entry and no key stays off, exactly as before. An unreadable or
  invalid declaration exits 2 with a line that names the problem and never
  a declared value.
- A declared source that this host cannot run, that yields no key, or that
  does not answer within FM_CREDENTIAL_SOURCE_TIMEOUT ends as a structured
  error outcome with nothing sent, so it is not mistaken for an
  unconfigured resolver.
- The key is captured into the same private variable as before and still
  reaches curl only as an fd 3 header. The adapter puts only the service
  and account on argv and discards the tool's stderr.
- --supports-credential-source <source> answers supported or unsupported
  without reading a declaration or running the credential tool, so an
  installer can refuse an unsupported activation before it writes anything.

The resolver tests cover the mapping, effective-home and provider
isolation, precedence, the three failure kinds, and secret containment
with a stubbed security and uname.

Closes kunchenguid#7879

* no-mistakes(review): Gate bootstrap typed checks on declared source; fix timeout

* no-mistakes(review): Document storing the declared Keychain item without access dialog

* no-mistakes(document): Clarify that only a typesafe declaration keeps resolver on

* no-mistakes(document): Merge dispatch key-source precedence into one configuration sentence

---------

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
…guid#6489)

* fix(bin): clean remote reply temp paths on every exit

The remote reply adapter left its temporary staging directory and fetch files behind on several exit paths.
The ingest staging directory leaked on the continuity-broken return, whose EXIT trap fired after its local tmp left scope.
The trap cmd_ingest installed also replaced the lifecycle-lock release of the handle subshell.
One EXIT trap now owns every temporary path, each lock subshell runs it before releasing its lock, and the empty hash no longer stages a file.
A test under a private TMPDIR covers the continuity return, a die after staging, a locked handle, and a signal during a document fetch.

* no-mistakes(document): Document remote-reply temporary-file cleanup

* no-mistakes(ci): Fixed ci-1 in tests/fm-remote-reply.test.sh: interrupt the blocked SSH child before waiting, fail if it already exited, and require adapter exit status 143 before checking cleanup. Confirmed the strengthened test rejects an adapter that ignores TERM; the temporary mutation was restored. The full remote-reply suite passed on a serial rerun, and syntax, pinned ShellCheck, and diff checks passed. One earlier run alongside lint timed out waiting for the third reply generation

* fix(bin): clean up the staged source-read output on every exit path

The source leg stages the remote read's output in a temporary file. Track it
with the adapter's other temporary paths so a signal during the read removes
it, and extend the regression test and docs to cover that path.
* chore: gitignore Claude Code's per-user local settings file

* no-mistakes(ci): Addressed ci-1 by preserving the staged --no-index correction for both Claude settings assertions in tests/fm-gitignore-config.test.sh, making ignore-rule checks independent of tracking state. Reproduced the original false pass with tracked shared settings and an overly broad .claude/ rule; the corrected test rejects it. Verified normal tracked/untracked settings cases and rejection of a missing local-settings ignore rule. Targeted test runner, pinned ShellCheck, Bash syntax check, and diff checks all passed. No unrelated changes were made
…uid#7905)

* fix(inbox): prefilter idempotent steering history

* no-mistakes(document): Clarify delivery mode in steering retry contract

* test(inbox): cover acknowledgement before prefilter opens
…unchenguid#7956) (kunchenguid#7979)

* feat(bin): add Kiro CLI as a crewmate/scout harness adapter

Port of kunchenguid#7956 onto current main so it gets a fresh CI run.

Adds a `kiro` (Kiro CLI, V2 engine) harness adapter, crewmate/scout only
(--secondmate launches are refused). fm-harness.sh detects it by kiro-cli
ancestry; fm-spawn.sh launches it with a per-task KIRO_HOME under
state/<id>.kiro-home (generated userPromptSubmit and stop hooks plus
chat.disableTrustAllConfirmation); busy, control, send, watch, procevent,
teardown and bootstrap wiring recognise it. Composer ghost-text and busy
footer matching is scoped to FM_COMPOSER_HARNESS=kiro, so other harnesses
read exactly as before. Adds references/harness/kiro.md,
docs/verification/kiro.md, tests/fm-kiro-harness.test.sh and an opt-in
live e2e signals guard.

Conflicts with main were resolved by keeping main's agy promotion and
adding kiro to the crewmate-only lists next to it.

Co-authored-by: kiatng <1106470+kiatng@users.noreply.github.com>
Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>

* fix(send): detect kiro on meta-less explicit targets

An explicit session:window send has no task meta, so TARGET_HARNESS stayed
empty and the kiro composer rules never applied. A finished kiro idle
placeholder then read as pending, extra Enters were pressed, and fm-send
exited 3 even though kiro accepted the message.

Resolve kiro from the live pane's foreground process group when meta is
absent, and keep every other explicit-target send on the unknown-harness
path. Move the kiro live e2e version probe to after the live gate so an
opted-out run never starts kiro-cli.

Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>

---------

Co-authored-by: kiatng <1106470+kiatng@users.noreply.github.com>
Co-authored-by: Marsjohn-11 <74795701+Marsjohn-11@users.noreply.github.com>
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
…d#6777)

* fix(captain-hold): refuse a previous origin's answer after an incomplete hold move

A hold moved to a new origin wrote its stamp and origin before the backend
hold. A process stopped between those writes, or a refused hold whose rollback
also failed, left the task associated with the new origin while it carried
only the earlier call's answer, and complete and verify accepted that answer.

Verification now treats an open, unheld task that leads with a hold-set stamp
above a recorded answer as a re-hold that never completed, so the answer no
longer satisfies the new origin however the move was interrupted. A refused
hold also restores the body the attempt started from, and the origin lookup
runs before any write, so a clean failure leaves the earlier answer valid.

Closes kunchenguid#6461

* no-mistakes(review): Publish hold origins only after backend success

* no-mistakes(review): Publish verified holds before origin writes

* no-mistakes(document): Clarify hold-origin durability documentation and regression coverage

* no-mistakes(lint): Quote done subcommand to resolve ShellCheck warning

* no-mistakes(document): Clarify recorded-origin provenance guarantees
…e backend (kunchenguid#7963)

* feat(backends): add experimental explicit-only hc (herdr-core) runtime backend

herdr-core is the terminal core under Herdr.app and is not Herdr 1.
The adapter follows the tmux shape: one login-shell terminal per task,
Treehouse keeps the worktree, and fm-spawn drives it through the same
send/current-path primitives.

- bin/backends/hc.sh: create, capture, visible capture, send line, typed
  literal through hc keys, named keys, current path, composer state,
  submit, native busy state, recovery agent state from the foreground
  process and its process group, and a close that proves the terminal gone.
  Targets are <session>:<address>; every call pins that HC_SESSION, and an
  empty session never reaches hc. Task and home labels gate input and close.
- bin/fm-backend.sh, bin/fm-spawn.sh: hc arms, explicit-only selection,
  endpoint validation, hc_session/hc_terminal metadata, secondmate refusal.
- tests: fake-CLI suite and a real-hc smoke test on a private core.
- docs: hc-backend.md, configuration, verification record, README links.

* fix(hc): submit the spawn launch line by paste and add the hc liveness live guard

The launch line always carries a + that hc keys cannot type, so fm-spawn
pastes it with hc send and consumes the Enter that follows. The launch
environment floor keeps HC_SESSION, HC_TERMINAL_ID, HC_TERMINAL_SOCKET and
HC_SCOPE. tests/fm-backend-hc-liveness-live-e2e.test.sh launches every
installed harness bare in a private core and requires alive. The
verification record gains the end-to-end spawn, steer, peek and teardown run.

* no-mistakes(review): Allow hc interrupt keys and drop unused hc send_literal

* no-mistakes(document): Sync hc backend inventories and adapter header comment

* no-mistakes(ci): Fixed. When an hc task was torn down, the kill function read the task's expected label from the wrong argument, so it ended up accepting any terminal in the same home and could close another task's worker. - Invariant: every hc close must be gated by the task label that teardown passes as the third argument to fm_backend_kill. - Where it must hold: fm-teardown.sh calls `fm_backend_kill <backend> <target> <zellij_tab_id> fm-<id>` at all its sites (around lines 3482, 3491, 3494, 3876, 3986 and 3995). The dispatcher at bin/fm-backend.sh:1156 passes "$@" through to fm_backend_hc_kill, and that function is the only hc close path. So fixing that one function's arguments covers every teardown site. - Fix in bin/backends/hc.sh:279: the signature is now `<target> [unused] [expected-label]` and it reads `expected=${3:-'*'}`, the same shape tern, rex, cmux and paseo use. The label value matches what hc terminals carry: spawn creates them with firstmate.task=$W where W="fm-$ID" (bin/fm-spawn.sh:4545 and 4955), and teardown passes "fm-$ID". - New test in tests/fm-backend-hc.test.sh, test_kill_refuses_another_tasks_terminal, goes through the public fm_backend_kill path. A terminal labeled fm-other is refused for expected label fm-a1, stays alive and gets no `hc kill`. The terminal labeled fm-a1 is closed and removed. Before the fix the test failed ("expected a refusal"), and after it the whole suite passes. - Checks: `bash tests/fm-backend-hc.test.sh` passes every test and `shellcheck -x` is clean on both files. The live smoke and e2e hc tests call kill without a label, which keeps the existing behavior of accepting any task label from this home. I did not run them because they need a real herdr-core. VERIFIED with the unit tests on the fake hc CLI, not against a real hc core

* fix(hc): keep the live liveness guard from repointing the operator's claude

A real claude started under the guard's scratch XDG_DATA_HOME can self-update into it and repoint ~/.local/bin/claude there, leaving the link dangling once the scratch directory is removed.
Export DISABLE_AUTOUPDATER=1, as bin/fm-live-lab.sh already does for its live harnesses.

* fix(hc): drop an inherited HC_SOCKET so the session pin holds

* no-mistakes(document): Document hc dropping inherited HC_SOCKET for session pin

* no-mistakes(ci): I fixed both Greptile findings. The hc unit suite passes all 12 tests, three runs in a row, and `shellcheck -x` is clean on the 4 touched files. VERIFIED with unit tests (a fake hc CLI plus a real process group). NOT VERIFIED against a real hc core, because the live tests need herdr-core. ci-1, live tests could stop an unrelated core - Invariant: every direct `hc` call a test makes must reach only its private scratch core, so an inherited HC_SOCKET (which wins over HC_SESSION in hc 0.1.14) must never be set. - Where it must hold: the two suites that call `hc` directly (`hc server status` at startup and `hc server stop` in cleanup), `tests/fm-backend-hc-liveness-live-e2e.test.sh` and `tests/fm-backend-hc-smoke.test.sh`. Adapter calls already go through `fm_backend_hc_cli`, which drops HC_SOCKET. - Fix: both suites add HC_SOCKET to the `unset HC_TERMINAL_ID HC_TERMINAL_SOCKET HC_SCOPE` line, before any `hc` call. ci-2, a shell wrapper running a live worker was reported as dead - Invariant: `fm_backend_hc_agent_state` may return `dead` only when neither the foreground process nor anything else in its process group is a harness. - Where it must hold: there is one classification path, `bin/backends/hc.sh` around line 326. Before the fix, the `shell` branch returned `dead` before the process-group check ran. Callers such as the inbox ring and the watcher read this value through `fm_backend_agent_state`, so fixing this one function covers all of them. - Fix: the result is now `alive` when the foreground process is a harness. Otherwise the process group is checked, which can also give `alive`. After that a shell gives `dead` and anything else gives `ambiguous`. An idle shell, whose group holds no harness, is still `dead`, and the existing test_agent_state_classifies_foreground_and_absence still passes (`t2=dead`). - New test `test_agent_state_reads_a_shell_wrappers_group` in `tests/fm-backend-hc.test.sh`. It starts a real `bash` wrapper in its own process group with a child that runs as `claude`, and points the fake hc terminal's foreground at the wrapper. With the old code the test fails ("expected 'dead', got 'alive'"). With the fix it passes. The comment in the code was updated. `docs/hc-backend.md` already describes the process-group read, so it did not need a change. Not run: `fm-backend-hc-smoke.test.sh` and `fm-backend-hc-liveness-live-e2e.test.sh`, because they need a real hc core
* docs(herdr): record the Apache-2.0 relicense and herdrdev org rename

Herdr relicensed from AGPL-3.0-or-later to Apache-2.0 in 0.8.0 and the
GitHub organization moved ogulcancelik/herdr to herdrdev/herdr. The old
release URLs redirect to the same assets, so the CI installer and the
version-floor guard now fetch via the canonical org with the pinned
version and checksums unchanged; verified end to end by running the
installer against the new URL.

* no-mistakes(document): Clarify Herdr product boundaries and preserve historical evidence
…relaunched (kunchenguid#7996)

* Preserve PR poll authentication on relaunch

* no-mistakes(review): Keep trace and polytoken meta ahead of PR lines
…se (kunchenguid#7837)

* fix(tests): pin lock staleness in malformed presentation lock case

A plain-file presentation lock older than FM_LOCK_STALE_AFTER (default 2s) is reclaimed as garbage, so a slow runner could age the malformed-lock fixture into a successful acquire. Pin the staleness window far above the case runtime so the case is deterministic.

* test(wake-queue): correct the malformed presentation lock staleness comment

---------

Co-authored-by: Trillium Smith <5898009+trillium@users.noreply.github.com>
…unchenguid#5603)

* feat(bin): let /updatefirstmate follow a configured self-update source

An optional local config/self-update-source ("<remote> <branch>") makes
fm-update.sh fast-forward the primary from that one remote branch instead of
origin/<default>, under the same fast-forward-only guards, and makes local
secondmates advance to the primary's resulting commit (a standalone clone
imports it from the primary first). A home can then run its own fixes from a
branch that carries them on top of upstream, while worker spawns, review
diffs, the cleanup landed-work test, lint and default-branch detection keep
using origin, so new contributions still branch from upstream.

Absent, behaviour is unchanged. An unreadable or malformed file, an unknown
remote or an invalid branch name refuses the whole update before anything
moves rather than falling back to origin. A remote secondmate's host follows
its own code root's config, which the docs record as the limit.

* no-mistakes(document): List config/self-update-source in AGENTS.md config inventory

* no-mistakes(document): Mention self-update source in updatefirstmate skill description
…unchenguid#8018)

* fix(bin): commit the attended alarm from the exhausted Stop auto-arm

A Claude failure episode could suppress indefinitely without ever raising
the attended alarm. On every Stop cycle the auto-arm opens its generation
claim before the guard's sync-wait decision, so the guard always steps
aside; terminal_fail_open is never reached and no participant knew that
automatic continuation was exhausted. The block budget still climbed
because the guard's step-aside path accounts for the epoch, so Stops kept
rewaking with empty failed-suppressed bodies forever.

The auto-arm is the only participant that knows its own continuation is
exhausted, so it now owns the terminal escalation: once the failure
notice was consumed and the session block budget is over, the terminal
failure path commits .claude-autoarm-failure-alarmed and the
failed-suppressed outcome inside the owner lock (owner then budget, the
same order the guard's writer uses), then emits one loud final rewake
telling the operator to keep the session attended and diagnose the
Stop-hook supervision. A healthy watcher verified inside that hold resets
the episode instead of alarming, and a refused commit stays suppressed
without a false alarm.

Later Stops in the same episode see the alarm, record failed-suppressed,
and exit 0 so no further continuation or alarm is produced. Positive
watcher recovery still clears the notice, the alarm, and the budget.

Every failed-suppressed commit now carries a one-line stderr reason
naming why the operator notice is not repeated and whether the
Stop-owned retry stays alive, replacing the silent empty bodies that
made suppressed Stops indistinguishable from a wedged hook.

Adds an integrated guard/auto-arm regression driving both hooks through
the exhaustion boundary and asserting the single alarm, post-alarm
suppression, and clean recovery; updates existing tests for the reasoned
suppression contract.

* fix(bin): outlast an unpublished lock pid for one freshness window

CI run 40805704864 ("recovery drain after forced arm interruption")
failed because a dying watcher could not publish .watcher-down inside
its bounded cleanup window, so the drain saw no downtime marker to ack.

The blocker was an empty-pid lock artifact: fm_lock_claim and the
bounded-wait handoff published ownerdir/pid with a truncating write,
and a creator killed mid-write (the bounded handoff helper runs under
timeout -k with a process-group KILL) left a resolvable symlink whose
pid file stayed empty forever. fm_lock_try_acquire treats that as a
fresh mid-acquire hold for a full freshness window, cannot steal it,
and a bounded waiter whose bound equals the window gave up before the
evidence expired.

Two changes. First, both pid writes now go through a same-directory
pid.tmp file renamed into place, so a killed write can no longer leave
a live lock with a permanently empty pid; fm_lock_clean_known_files
sweeps leftover tmp files. Second, fm_lock_acquire_wait_max polls one
extra freshness window when the remaining blocker still has no
published pid, so a waiter outlives the residue instead of failing at
its bound; the moment a pid publishes or the artifact goes stale the
ordinary live-holder and steal rules apply unchanged, and published
live holders keep the original bound.

Adds a regression test that links an owner dir with no pid and asserts
the bounded wait outlasts the freshness window to reclaim it, while a
live holder still fails at the nominal bound; verified to fail against
the pre-change implementation.

* no-mistakes(review): Route every suppressed exit through alarm decision

* no-mistakes(document): Clarify exhaustion and lock-wait documentation

* no-mistakes(lint): Quote empty grace deadline assignment for ShellCheck

* no-mistakes(ci): Fixed tests/fm-x-mode.test.sh: atomic lock-pid publication consumed its overly broad injected mv failure. Targeted the counter-record destination and asserted injection occurred. Reproduced failure before fix; full X-mode test script, pinned lint, bash syntax, and diff checks pass afterward. Full suite failure is downstream of this lane failure; no separate fix needed

* no-mistakes(ci): Fixed Full suite’s underlying shard timeout: the PR marker test’s broad mv failure injection blocked atomic lock-PID publication indefinitely. Restricted injection to the marker destination. Reproduced the hang before fixing; targeted regression, all 49 PR-security tests, ShellCheck, bash syntax, and diff checks pass

* no-mistakes(ci): Fixed load-sensitive remote lifecycle test timeout: all three inheritance/launch barrier waits now honor the existing convergence budget instead of failing after 30 seconds. Full suite failure is downstream of this shard. Full lifecycle E2E, Bash syntax, ShellCheck excluding SC1091, and diff checks pass. Production behavior unchanged

* no-mistakes(ci): Fixed remote-reply fixture races, preserved the committing auto-arm’s final rewake on signals, and asserted the live-holder wait bound. Remote-reply and turnend-guard suites and focused lock test pass; signal regression fails before fix and passes after. Full watcher-lock suite fails earlier in an unchanged macOS watcher-replacement test. Full suite CI failure is downstream of the shard failure

* no-mistakes(ci): Fixed teardown race in tests/fm-watch-arm.test.sh: atomically rename state/home/root fixtures away before deleting contents after process exit. Preserved all existing assertions; production code unchanged. Affected suite passed three runs, including two concurrent copies; targeted unpublished-PID lock test and syntax/diff checks passed. Additional full lock suite failed twice at a separate watcher-replacement exit assertion. Standalone ShellCheck reported existing warnings
…ld completion (kunchenguid#6732)

* fix(bin): keep PR merge polls authenticated across relaunch

A relaunch rewrote the task record with control_relaunch_tx after the
preserved pr= line. fm_pr_metadata_identity_parse rejects any key after
pr= other than pr_head= and x_*, so the watcher stopped authenticating
the armed merge poll and reported it as an unauthenticated state check,
and the merged-PR wake never arrived. Write the transaction id before
the preserved lines, as fm-remote-secondmate-relaunch.sh already does.

* no-mistakes(review): Keep pr= last for traceparent and completion writes

* no-mistakes(document): Note completion record placement ahead of pr= lines

* no-mistakes(ci): Fixed the Greptile P1 finding (ci-1) as the user decided. **Invariant:** a task's `.meta` record holds exactly one `decisions_reviewed`/`decision_keys` pair, and it sits before `pr=`. Then `meta_value` (which reads the last match) returns the current inventory, and `fm_pr_metadata_identity_parse` still sees `pr=` last. The only place that writes this pair is the awk rewrite in `command_complete` (`bin/fm-captain-hold.sh`). The other hits for these keys under `bin/` are only a comment and an error message. `verify` and later `complete` calls read the pair through `meta_value`, so fixing this one writer fixes them too. **Fix:** added one awk rule, `/^(decisions_reviewed|decision_keys)=/ { next }`. It removes every existing occurrence of both keys, in either the old layout (pair after `pr=`) or the new one, before the single updated pair is written ahead of `pr=` (or at the end if there is no `pr=`). When there is no existing pair the output is the same as before, so the normal path is unaffected. **Regression test:** added `test_completion_replaces_a_pair_recorded_after_pr` to `tests/fm-captain-hold-lifecycle.test.sh` and registered it in the runner list. It builds a record in the old layout (`pr=` followed by `decisions_reviewed=1` / `decision_keys=old-call`), then runs `complete <id> new-call`. It checks that exactly one `decision_keys=new-call,old-call` line and one `decisions_reviewed` line remain, that `verify` passes, and that `fm_pr_metadata_identity_parse` still accepts the PR identity. **Verification:** - The full `tests/fm-captain-hold-lifecycle.test.sh` suite passes with the fix (exit code 0, every result `ok`), including the new test. Some tests were skipped because this environment has a markdown-only tasks-axi. - I meant to also run the suite with the fix removed, but both attempts to take the line out left the file unchanged, so that run also tested the fixed code. The new test has not been shown to fail without the fix. - Instead I ran the old and new awk programs directly on an old-layout record. The old program leaves `decision_keys=old` after `pr=`, so the last match is the stale inventory and `pr=` is no longer last. The new program writes a single `decision_keys=new,old` before `pr=`. - The worktree file has the fix (the diff shows the added awk line)

* no-mistakes(ci): The branch is rebased onto base dbcb5ab and the rebase completed cleanly. All 4 commits applied, and the only remaining change is one staged, uncommitted file (listed below). **Why it conflicted:** upstream kunchenguid#7996 had already landed the same relaunch fix. It writes `control_relaunch_tx` before the preserved `pr=` lines, and its shared helper `spawn_meta_rewrite_before_pr` keeps the traceparent write ahead of `pr=`. **Invariant:** an armed `pr=` block must stay last in `<id>.meta`, because `fm_pr_metadata_identity_parse` rejects any key after it. Three writers must respect this. Upstream now covers two: the relaunch rewrite and the traceparent write, both in `bin/fm-spawn.sh`. The branch still covers the third: the completion write in `bin/fm-captain-hold.sh`, which removes any older copies of the completion fields and writes them once, before `pr=`. **How the conflicts were resolved:** 1. **Relaunch reorder in `bin/fm-spawn.sh`:** the code was already identical upstream. The branch keeps only its two-line comment explaining why the preserved lines go last. 2. **Traceparent write in `bin/fm-spawn.sh`:** I took upstream's helper version of `spawn_record_traceparent` and dropped the branch's inline awk, which did the same thing. 3. **`tests/fm-control-relaunch.test.sh`:** I restored it to the base version. This change is staged but not committed yet. - Upstream's `test_relaunch_preserves_durable_task_metadata` already covers an untraced relaunch with an armed poll. - Upstream's `test_traced_relaunch_keeps_an_armed_pr_poll_authenticated` covers the traced case. - The branch's version redefined that traced test, so upstream's would have been silently replaced and run twice. **Net diff against base:** - The completion-write fix in `bin/fm-captain-hold.sh`. - Its regression tests in `tests/fm-captain-hold-lifecycle.test.sh`. - A one-line note in `docs/captain-hold-lifecycle.md`. - The comment in `bin/fm-spawn.sh`. **Checks:** - `bash -n` passes on `bin/fm-spawn.sh` and `bin/fm-captain-hold.sh`. - `tests/fm-control-relaunch.test.sh` exits 0, including upstream's armed-poll and traced-relaunch PR poll tests. - `tests/fm-captain-hold-lifecycle.test.sh` exits 0, including the test that a completion record written after `pr=` by the old code gets replaced. No file-mode or authentication check was changed

* no-mistakes(document): Clarify completion pair replacement ahead of pr= lines
Last-resort port of kunchenguid#7575. Keep main's fm_backend_endpoint_u64_valid and
the PR's fm_backend_worktree_identity_repair_hint, with the existing
validate_task_endpoint call site.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: thelad-dev <80847374+thelad-dev@users.noreply.github.com>
Co-authored-by: Kun Chen <kunchenguid@users.noreply.github.com>
…kunchenguid#8025)

* fix(bin): bound watcher startup locks and defer arm TERM to the safe point

Under host CPU/fork contention a fresh watcher could outrun the arm's
fixed confirmation budget, so the timeout TERM landed before the child
installed its EXIT cleanup trap. The killed startup left .watch.lock
and micro-locks recorded against a dead pid, and each next arm
inherited a slower stale-lock walk - a cascade that made loaded hosts
progressively less able to keep a watcher armed.

The watcher now installs watcher_cleanup immediately after claiming the
singleton and publishes its home-bound lock identity (fm-home,
watcher-path, pid-identity) right after, so an interruption past that
point can only abandon locks recorded against the watcher's own pid;
the cleanup releases those outright before its bounded downtime
publication, so a stop taken inside a marker or queue critical section
cannot self-block or strand the singleton.

Every pre-identity lock the watcher takes is bounded by
FM_WATCHER_STARTUP_LOCK_BOUND (default 60s): the steal's downtime
publish, the recovery reopen and arm-check transitions, and the
successor's queued-row check. A bound spent against a live foreign
holder ends the child with the typed line
`watcher: FAILED - startup lock <path> held by live pid <n>`, which the
arm relays; a dying or clearing holder retries instead.

The arm's confirmation is now a liveness backstop rather than a fork
budget: FM_ARM_CONFIRM_TIMEOUT defaults to FM_GUARD_GRACE and never
drops below the legacy 10s/30s-on-MSYS floor, so host load stretches
how long the arm waits instead of how soon it kills. Signal forwarding
and the deadline TERM share one safe-point helper that waits for the
child's published lock identity; a child still mid-claim at the
deadline is killed outright and its dirs reap as ordinary dead
evidence. The already-live successor handoff keeps its own short bound,
FM_ARM_SUCCESSOR_CONFIRM_TIMEOUT (10s, 30 on MSYS), which the Stop
auto-arm now also uses for its successor status wait.

The state-directory teardown check is fixed for macOS, where devfs
serves each /dev/fd entry on its own device so -ef never matched and a
missing lock pid alone read as a torn-down state directory; the poll
now compares the held directory's recorded device+inode.

Regression tests cover a post-claim startup slower than the legacy
budget confirming under the grace-tracked backstop, a live foreign
startup-lock holder ending the child with the relayed typed line while
keeping downtime drainable, and a stop forced before the safe point
leaving no dead lock evidence a re-arm cannot reclaim.

* no-mistakes(review): Invalidate inherited watcher beacon at singleton claim

* no-mistakes(review): Defer deadline TERM to startup safe point, leave no locks

* no-mistakes(review): Exit watcher startup if identity cannot publish

* no-mistakes(test): Clean interrupted watcher lock-owner staging

* no-mistakes(test): Join in-flight lock mutations before watcher cleanup

* no-mistakes(document): Correct startup deadline documentation

* no-mistakes(ci): Fixed both attached-arm tests to configure the independent successor timeout, and quoted both escalation tokens flagged by ShellCheck. Full suite failure is downstream of failed lanes. Both focused behavioral tests, direct ShellCheck, bash syntax, and diff checks pass. Broader verification was limited by an earlier concurrency-test failure and timeouts in canonical lint and pending-reply tests

* no-mistakes(review): Read successor queue state inside arm-check hold

* no-mistakes(document): Clarify startup lock bound scope

* no-mistakes(ci): Fixed dead-watcher reclamation to exit with a typed watcher: FAILED diagnostic naming the downtime marker when publication fails, preserving bounded live-pid contention. Added a deterministic directory-marker regression that reproduced the pre-fix hang and now passes. Shell syntax, five focused behavioral tests, and git diff --check passed
kunchenguid#8021)

* fix(bin): allow cd to the home itself and give fm-pr-merge.sh a --help

The cd-guard denied a top-level cd whose single literal absolute target
resolves to the primary checkout, although that cd cannot move the shell
out of the home. The transport now passes the checkout as --home and the
policy allows exactly that target after realpath resolution on both sides.
Every other cd, pushd, and popd keeps its deny, including a child, sibling,
parent, relative, expanded, option-bearing, or glob target.

fm-pr-merge.sh refused -h and --help as an invalid merge request with exit
2. It now prints its header, which gained a usage block, and exits 0.

The issue's suggested test that runs every bin/fm-*.sh --help and expects
exit 0 is left out: a survey of the 222 scripts shows more than 50 fail
--help today (usage printed with exit 2, missing FM_HOME, argument parsing
that treats --help as a task or path), and two installer scripts start a
download on it, so that test is neither cheap nor stable. The new test
covers fm-pr-merge.sh alone.

Fixes kunchenguid#7995

* no-mistakes(ci): The guard now allows a home `cd` only when the target resolves to the home under both rules. The logical rule uses `fs.realpathSync`, which collapses `..` first. The physical rule uses `fs.realpathSync.native`, which follows symlinks per component, as `set -P` does. If either resolution fails, the guard denies. I changed `bin/fm-cd-command-policy.mjs` and updated its header comment and the home-exemption paragraph in `docs/cd-guard.md`. I added H16 to `tests/fm-cd-pretool-check.test.sh`. It puts `escape-link` inside the primary fixture, pointing outside it, and expects `cd <primary>/escape-link/..` to be denied. With the policy change stashed, H16 failed (it was allowed, exit 0). With the change applied, `tests/fm-cd-pretool-check.test.sh` has 0 failures, and H01-H07 still pass
…enguid#7212)

* feat(pi): record opt-in foreground stream activity

* feat(watch): inspect opt-in Pi stream silence

* test(pi): verify worker stream phases with the real SDK

* fix(review): harden Pi stream observation lifecycle

* fix(review): reject stale inspection before recovery publication

* no-mistakes(document): Clarify Pi stream observation and busy-age documentation

* no-mistakes(ci): Fixed both lint failures by explicitly discarding unused stream-record fields in fm-busy-event.sh and fm-watch.sh. Source-aware lint, normal lint, workflow/docs checks, and focused writer/watcher behavior tests passed. Behavior portable parallel 1 remains blocked by pre-existing TS2339 errors in two unchanged primary Pi extensions explicitly outside scope. Local type-check verification skipped because tsc is unavailable

* no-mistakes(test): Validation blocked by conflicting authentic Git metadata access requirements

* no-mistakes(test): Preserve gate identity in isolated Pi stream tests

* no-mistakes(document): Correct Pi stream close ordering documentation

* no-mistakes(ci): Captain, fixed S1 with an exact identity allowlist and SDK environment assertions. Corrected E1 by separating read-only launcher controls from writable output. Real Pi SDK, focused suites, CLI inspection, six race cases, and fallback checks passed. Signed Pi remains unavailable. Evidence: /home/art/.no-mistakes/evidence/01M4SVYM577RRP7SBS7M9Y8NFN/ci-S1-E1-0lj00bwx/output/REPORT.md

* test(pi): give each live stream case its own spawn world

The rebased base's fake tmux now records the window it created, so the three
live Pi cases that share one fakebin are refused as a duplicate window after
the first case. Give every case its own fakebin, like every other spawn suite
in this repository. No assertion changes.

* no-mistakes(document): Classify Pi stream-silence plan

* fix(pi): accept any Pi release at or above the stream floor

CI installs the latest published Pi, so the exact 1.2.0 gate disabled the
new instrumentation on 1.3.0 and the live guard failed instead of exercising
it. Move the version contract into the busy library as a floor, have spawn
and the real-SDK guard share it, and print the release actually verified.
The guard still exercises the installed SDK every run, and prerelease or
unreadable versions keep the gate closed behind the general busy bound.

* fix(test): restart a superseded remote-reply listener inside the bound

Handling a generation re-arms the source, which supersedes the live runner's
launch floor: that runner exits without a result. The wait sampled the owner
once, so a claim observed just before release suppressed the replacement and
the next generation waited out the full 40s bound with nothing listening.
Re-check the owner on a one-second cadence and start a replacement only while
nothing owns the source; the total bound and every assertion are unchanged.

* no-mistakes(review): Restore Pi verification boundary and fix terminal publication guards

* no-mistakes(review): Clear stream episode caps and fix uncapped test launch

* no-mistakes(lint): Fix ShellCheck single-iteration version loop

* no-mistakes(ci): Fixed the failing Pi stream-version regression: only verified Pi 1.2.0 is accepted; newer versions are checked as rejected, matching the production gate and the unverified-version requirement. `tests/fm-busy-state.test.sh` and `git diff --check` pass. The recorded request to accept newer versions conflicts with the verified-only invariant, so the test now reflects the verified-only behavior

* no-mistakes(review): Cover stream counter failures and clarify verified-version test

* no-mistakes(review): Isolate terminal publication fixtures from regular regression cases

* test(pi): make the live stream guard prove the unverified-version path

The live Pi guard passed on an unverified Pi version while checking nothing
about that version: the unverified case replaced the enabled/disabled/stalled
cases and the script still reported the verified-lifecycle pass line, so a
widened version gate or a dropped spawn warning would have gone unnoticed on
any host without Pi 1.2.0 installed.

The unverified case now asserts the load-bearing invariants instead: the exact
spawn warning text, that the generated worker extension registers none of the
model-stream handlers, and that the retained busy bound still works, which the
real-SDK run proves with state=busy and state=idle written by pi-ext while
stream evidence stays empty. The pass line names the behavior actually proved,
so an unverified host no longer reads as a verified one.

Verified by mutation: altering the warning wording fails with "missing exact
unverified-version warning", and forcing streamMonitoring on for an unverified
version fails with "unverified worker installed stream handlers".

Documentation states the same boundary in one place: stream observation stays
off on every unverified version until that version is verified, with a warning
and the general busy bound retained. The verification record gains the dated
Pi 1.4.0 run and its exact output for the inert path, alongside the existing
Pi 1.2.0 evidence for the verified path.

The version gate itself is unchanged and still accepts only Pi 1.2.0.

* test(pi): name the harness and version when the inert-path guard fails

The unverified-version assertions failed as bare "missing exact unverified-version warning" and "unverified worker installed stream handlers".
That is precisely the case where the harness and version are the diagnosis, because the guard only reaches those assertions on a Pi release the version gate has not verified.
Every other failure in the guard already names both.
Both messages now read "Pi <version>: ...", the final pass line branches on an explicit verified flag instead of comparing the case-list string, and the header states what an unverified host proves.
The version gate is unchanged and still accepts only Pi 1.2.0.
Verified on installed Pi 1.4.0 with Node v24.22.1: the guard passes with "ok - real Pi 1.4.0 unverified-version warning, inert stream observation, and existing busy/idle behavior".
Both mutations fail by name: rewriting the spawn warning yields "not ok - Pi 1.4.0: missing exact unverified-version warning", and forcing streamMonitoring on for an unverified version yields "not ok - Pi 1.4.0: unverified worker installed stream handlers".

* no-mistakes(document): Document Pi stream cap ordering and state files

* test(pi): name the version gate for what it checks

The gate accepts only the verified Pi release and rejects every other
version, so the old name (accepts verified and newer) described the
opposite of the assertion it holds.

* no-mistakes(document): Document Pi stream option must reach spawn and watcher

* no-mistakes(document): Document Pi stream revalidation, lib ownership, extension scope

* no-mistakes(document): Clarify Pi stream writer contract in header and prose
…nguid#8020)

* feat(dispatch): bind a profile to an explicit quota_scope row

Antigravity reports tier scopes (gemini, claude_gpt) that the resolver never matched,
so every agy candidate stayed unranked even when its tier was exhausted (kunchenguid#5602).
An optional profile quota_scope names the exact quota row to bind; profiles without
it resolve as before. Follows the explicit-declaration rule of kunchenguid#5319.

* no-mistakes(ci): Fixed ci-2: both quota_scope checks in bin/fm-dispatch-resolve.sh (use and default) now require an object entry before has("quota_scope"), so "use":["codex"] and "default":["codex"] get the malformed-profile error, not "not JSON". Added tests for both shapes. Fixed ci-3: the code already blocks a declared 0% row; added a test with 0% remaining and runway through_reset that asserts "not eligible" and no profile emitted. ci-1 needs no code change, because it is the maintainer full-ci label gate and nothing ran. The tests/fm-dispatch-resolve.test.sh suite fails here at an openai assertion, and it fails the same way without my changes (so likely environment-specific). With a non-fatal `fail` override in a temp copy, only the 7 openai assertions failed; the new quota_scope and malformed-profile cases passed. I did not run the mutation check on the ci-3 test
…d#8029)

The watcher classifies every busy Herdr pane on every poll. Each sample ran
four jq processes per foreground process, and the "other" verdict resamples up
to ten times, so with a large fleet one stale-scan pass outran the 300-second
beacon grace and the watcher read as dead while it was still working.

fm_backend_herdr_pane_process_state_sample now validates the process-info
response and emits every process's pid, name, argv0 and args as NUL-separated
fields from a single jq call. Verdicts and field values are unchanged. The
stale scan already refreshes the beacon per window through beat.

Tests pin multi-process parsing, args with spaces and tabs, missing and
malformed fields, the shell verdict, and that jq calls do not grow with the
process count.
…unchenguid#8028)

* fix(bin): refuse captain-hold release while the away record exists

`fm-captain-hold.sh answer --release` checked nothing about who answers,
so the away session could release a captain hold with its own words and
then steer the held work past the fm-send guard. A script cannot prove
the words are the captain's; this closes the unattended path instead.

While the away posture record (state/.afk-contract) or the away daemon
flag (state/.afk) reads away, `answer --release` and a `release` line on
the keyed-answer intake are refused before any write, naming the
attended-session requirement. A quiet record is a present captain and no
record is attended, so both still release. A closing answer without
--release is unchanged.

* no-mistakes(ci): Fixed the release race in bin/fm-captain-hold.sh: after taking the task control lock, answer --release takes the away-record lock (fm_afk_contract_lock_hold), rechecks posture under it, and holds it through the release write. The cleanup trap releases the lock. The keyed-answer intake reaches the same path through `answer --release`. Added test_release_rechecks_away_after_waiting_on_task_lock; it passes with the fix and goes red with the recheck removed. Only the three release tests were run, because the full lifecycle suite takes over 10 minutes here and was killed at the time limit. ci-1 (missing full-ci label) was declined, so no code change applies to it
…uid#8037)

* feat(bin): add experimental herdr-core runtime backend

Herdr Core (the hc CLI, 0.1.x) is a separate product line from the
stable herdr TUI - persistent terminals in flat named sessions with
OSC 7501 status - so it gets its own adapter rather than changing
backend=herdr, which keeps driving the TUI unchanged.

The adapter maps the fm_backend_* contract onto hc: version/protocol
gates (hc x.y.z floor 0.1.14, hello generation 1), per-home sessions
fm-<hometag> with ambient HC_* markers stripped, task terminals as
labeled `hc run` shells (<session>:<tN>), a pending-buffer send model
because hc send is atomic paste+Enter, structured verdicts from its
exit codes, and kill+rm with ownership re-reads. Poll-only this stage;
no auto-detection, no secondmates, no supervisor/afk/relaunch claims.

Ships with an isolated lab helper (scratch XDG roots, pinned socket,
fleet tripwire, session-process teardown), a pinned installer, a
portable fake-hc suite, and a gated real-hc smoke.

* hc: consolidate Stage-1 onto the upstream hc backend

Upstream's bin/backends/hc.sh already owns the Herdr Core adapter, so the
parallel herdr-core backend world (adapter, docs, tests, lab, installer,
ci-cleanup) is removed. The Stage-1 capabilities it carried are ported onto
hc: a binary gate (FM_HC_BIN, then herdr-core, then hc; `hc x.y.z` version
shape with a 0.1.14 floor), a protocol-generation-1 hello handshake in
container_ensure, `--` delimiters on send/keys, and send_text_submit driven
by `hc send --wait` (native started/working proof, exit-9 blocked is a hard
stop, conservative composer fallback).

The lab world lands as fm-hc-lab.sh with a fleet-state tripwire and a
serve/hold daemon sweep that excludes the caller's process tree by process
group (an exported HC_SESSION otherwise self-matches forever). The smoke
and the default-on liveness e2e run inside lab sessions; fm-install-hc.sh
pins 0.1.14 with SHA-256 verification; a required tests-hc CI lane mirrors
tests-herdr with snapshot/cleanup around a serial `--family hc` run.

* no-mistakes(review): Pin hc test binary, resolver, stat, lab XDG roots

* no-mistakes(document): Correct hc setup and verification documentation

* no-mistakes(ci): Fixed all three findings: private validated lab/socket roots and exclusive sessions, cleanup in both live-test EXIT handlers, and fail-closed fleet snapshot reads. Added behavioral regressions; confirmed they reject the original implementation. Adapter tests (16), targeted regressions, injected cleanup failures, shell syntax, ShellCheck, and diff checks passed. Real-Core live tests skipped because hc/herdr-core is unavailable

* no-mistakes(document): Correct hc setup and cleanup documentation
…nguid#7589)

* fix(tests): start suites from CI's environment, not the launching terminal's

A suite run directly from a terminal hosted by herdr inherited that launcher's
identity (HERDR_ENV, HERDR_PANE_ID, HERDR_SOCKET_PATH and siblings), its
TERM_PROGRAM marker, the FM_BACKEND selector bin/fm-spawn.sh exports into task
panes, and any home/state override (FM_HOME, FM_*_OVERRIDE) a supervisor shell
exports. Spawn and backend fixtures then bound to the host's real herdr session
instead of the isolated one their case creates: several suites failed with
`herdr launcher pane '...' belongs to the server at ... not session 'default'`,
and fm-spawn-worktree-settle recorded a real workspace's pane path as a fixture
worktree, while the same suites passed in CI. The effect only appears on a
herdr-hosted machine.

Clear that inherited environment once in tests/lib.sh, the shared fixture
layer. bin/fm-test-run.sh already cleared the overrides and FM_BACKEND per
worker, but not the herdr identity, and a direct `bash tests/x.test.sh` run got
neither. A case that deliberately exercises a launcher identity, a backend, or a
home/state override still exports its own value after sourcing the library.

* no-mistakes(review): Remove unneeded HERDR_CONTAINER_RAW and TERM_PROGRAM_VERSION from test unset list

* no-mistakes(review): Add launcher environment regression test and correct lib comments

* no-mistakes(review): Preserve operator config override in T3 live suites

* no-mistakes(test): Accept subreaper adoption in session-lock recycled-chain test

* test: keep the session-lock subreaper fix out of this offer

The reparent assertion in fm-session-lock-ancestry fails the same way on
untouched upstream under a child subreaper, so it is a pre-existing host
portability issue this change did not cause. Restore the file so the offer
carries only what the launcher-environment fix requires.

---------

Co-authored-by: yeti <yeti@alps>
@DereKk8
DereKk8 merged commit aa0c5b9 into main Nov 1, 2026
22 checks passed
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.