Skip to content

feat(pi): surface opted-in model-stream silence for Pi workers - #7212

Merged
kunchenguid merged 28 commits into
kunchenguid:mainfrom
kesslerio:fix/pi-stream-silence-6881-t3-20261013
Oct 31, 2026
Merged

kunchenguid merged 28 commits into
kunchenguid:mainfrom
kesslerio:fix/pi-stream-silence-6881-t3-20261013

Conversation

@kesslerio

@kesslerio kesslerio commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Changed

  • Adds the opt-in FM_STREAM_SILENT_MAX_SECS path: spawn-time Pi extension instrumentation emits generation- and request-fenced open/progress/close stream evidence through the new fm-busy-event.sh stream verb, with the record and ordering contract owned by fm-busy-lib.sh; activation is gated to verified Pi 1.2.0, and other versions keep legacy wiring with a warning.
  • Routes an expired current stream into the existing inspection-only wedge cadence in bin/fm-watch.sh, naming model-stream silence and its observed duration in the escalation reason, and revalidating the stream snapshot under the publication lock (including a new guarded wake append) so fresh progress, close, or request replacement withdraws the escalation instead of publishing an obsolete one.
  • Documents the option, state files, and real-Pi verification, and adds focused writer/watcher suites plus a live SDK guard covering default-off behavior, background provider traffic exclusion, tool/completion phases, and the instrumentation deadline.

Risk Assessment

✅ Low: The observation capability is opt-in and version-gated, preserves existing fallback behavior, and revalidates stream evidence under publication locks; no material introduced defects were substantiated.

Testing

Every runtime scenario this change introduces was driven live with real product code: a private real tmux server whose pane keeps ticking, the real watcher and real busy-event writer for the opt-in silence escalation, cancellation, cap, counter-fault, and default-off parity cases, a real held publication lock with a live holder pid for the revalidation cases, and a real spawn-generated Pi extension executed through the real Pi 1.2.0 SDK chained into the real writer and then the real watcher (verified version) plus the installed Pi 1.4.0 for the unverified inert path. Escalation reasons name model-stream silence, cancelled observations leave no wake, timer, count, or cap marker, the option is inert when unset/zero/invalid, and an unverified Pi only warns and installs no stream handlers. The new watcher-triage stream cases, the busy-state suite, the adapter-wiring stream case, and the documentation inventory suite pass; the whole-file adapter-wiring run still stops at the already-recorded pre-existing secondmate-stall case that reproduces on the base commit. No UI surface is involved, so no screenshots; the reviewer-visible evidence is the captured CLI transcripts and per-scenario logs in the evidence directory. The documentation scenario was not driven against the running product in this run, so it is reported untested with empty evidence.

  • Live validation: ✅ go - 8 of 9 scenarios driven live against the product
Scenario Result Live Evidence
With the option on and a foreground Pi request silent past the threshold on a pane that keeps changing, the watcher escalates early and its reason names model-stream silence ✅ pass live watcher-live-matrix.log mode=enabled: real private tmux pane ticking every poll, real bin/fm-watch.sh + bin/fm-busy-event.sh published `stale: firstmate:fm-stream-enabled (idle 3s, possible wedge, e…
Live close, progress, or a replacement foreground request during the silence window cancels the escalation, leaving no wake, no inspection timer, and no escalation count ✅ pass live watcher-live-matrix.log modes fresh/close/replace: each entered the model-stream ladder, then the real writer changed the observation and the watcher stayed alive with empty stdout, no wake-queue ro…
An observation that changes while the watcher is blocked on the publication lock is revalidated and never published (queue and recovery locks, close/progress/replace) ✅ pass live watcher-live-lock.log: all six cases held the real lock with a live holder pid (blocked=yes), the writer closed/refreshed/replaced the request during the wait, and after release the watcher stayed…
Unset, zero, and malformed option values leave the general busy bound in force: no escalation, no inspection timer, no wake ✅ pass live watcher-live-matrix.log modes disabled (0) and invalid, plus default-off-drive.log part 1 which ran with FM_STREAM_SILENT_MAX_SECS unset against a backdated stream observation written by the rea…
The spawn-generated Pi extension records foreground stream open/progress/close through the real writer and clears the evidence at assistant completion and tool execution, driven through the real Pi 1.… ✅ pass live combined-live-drive.log steps 1-3 and 5-7: real fm-spawn generated the extension for the opt-in value, the real Pi 1.2.0 SDK agent loop produced stream.model-stream/stream.model-progress evidenc…
On an unverified Pi release the spawn warns with the exact message and installs an inert extension that records no stream evidence, keeping the existing busy/idle bound ✅ pass live live-pi-1.4.0.log: real installed Pi 1.4.0 spawn emitted the exact unverified-version warning, installed no stream handlers, recorded no model evidence, and kept busy/idle behaviour
A spawn with the option unset instruments nothing (no stream warning, no model markers) while semantic busy/idle still moves ✅ pass live default-off-drive.log part 2: real fm-spawn with the variable unset, then the generated extension driven through the real Pi 1.2.0 SDK with a held foreground request showed `model-stream marker pres…
A cap fire publishes one terminal wake carrying the model-stream evidence, and a refused escalation-count write on the uncapped stream route still delivers exactly one wake without wedging ✅ pass live watcher-live-matrix.log mode=cap: one PERMANENTLY-WEDGED wake retaining model stream silent for ..., both cap markers written; mode=counterfault: the count write was refused, the triage log reco…
The opt-in option and its live-Pi verification evidence are documented, and the documented knob is the one the product honours ⏸️ untested no The prior payload only recorded static documentation artifacts (documentation-artifact.txt, targeted-documentation.log) and asserted the documented variable matched names seen in other runs; it re…
Evidence: Live watcher matrix (real tmux + real watcher + real writer): escalation, parity, cancellation, cap, counter fault

Source: Live watcher matrix (real tmux + real watcher + real writer): escalation, parity, cancellation, cap, counter fault


\### mode=enabled (real tmux pane changing each poll; verify escalation names model-stream silence)
--- enabled watcher_alive_after_wait=no exit=n/a
--- enabled watch stdout:
stale: firstmate:fm-stream-enabled (idle 3s, possible wedge, escalation 1, model stream silent for 604s (foreground request))
--- enabled wake queue:
1793452614	1	stale	firstmate:fm-stream-enabled	stale: firstmate:fm-stream-enabled (idle 3s, possible wedge, escalation 1, model stream silent for 604s (foreground request))
--- enabled escalation count:
1
--- enabled cap markers:
(none)
--- enabled episode marker:
g1793452610.121295.2359 1 1 1793452010--- enabled triage log:
[2026-10-31T06:16:51-0700] absorbed busy (model stream silent) timer reset: firstmate:fm-stream-enabled
PASS mode=enabled

\### mode=disabled (FM_STREAM_SILENT_MAX_SECS=0 must leave the general busy bound in force)
--- disabled watcher_alive_after_wait=yes exit=n/a
--- disabled watch stdout:
--- disabled wake queue:
(none)
--- disabled escalation count:
(none)
--- disabled cap markers:
(none)
--- disabled episode marker:
(none)
--- disabled triage log:
(none)
PASS mode=disabled

\### mode=invalid (FM_STREAM_SILENT_MAX_SECS=invalid must leave the general busy bound in force)
--- invalid watcher_alive_after_wait=yes exit=n/a
--- invalid watch stdout:
--- invalid wake queue:
(none)
--- invalid escalation count:
(none)
--- invalid cap markers:
(none)
--- invalid episode marker:
(none)
--- invalid triage log:
(none)
PASS mode=invalid

\### mode=fresh (live foreground progress during the silence window cancels publication)
--- fresh watcher_alive_after_wait=yes exit=n/a
--- fresh watch stdout:
--- fresh wake queue:
(none)
--- fresh escalation count:
(none)
--- fresh cap markers:
(none)
--- fresh episode marker:
(none)
--- fresh triage log:
[2026-10-31T06:16:59-0700] absorbed busy (model stream silent) timer reset: firstmate:fm-stream-fresh
PASS mode=fresh

\### mode=close (live close during the silence window cancels publication)
--- close watcher_alive_after_wait=yes exit=n/a
--- close watch stdout:
--- close wake queue:
(none)
--- close escalation count:
(none)
--- close cap markers:
(none)
--- close episode marker:
(none)
--- close triage log:
[2026-10-31T06:17:04-0700] absorbed busy (model stream silent) timer reset: firstmate:fm-stream-close
PASS mode=close

\### mode=replace (a new foreground request during the silence window cancels publication)
--- replace watcher_alive_after_wait=yes exit=n/a
--- replace watch stdout:
--- replace wake queue:
(none)
--- replace escalation count:
(none)
--- replace cap markers:
(none)
--- replace episode marker:
(none)
--- replace triage log:
[2026-10-31T06:17:08-0700] absorbed busy (model stream silent) timer reset: firstmate:fm-stream-replace
PASS mode=replace

\### mode=cap (FM_WEDGE_MAX_ESCALATIONS=1 publishes one terminal model-stream wake)
--- cap watcher_alive_after_wait=no exit=n/a
--- cap watch stdout:
stale: firstmate:fm-stream-cap (idle 3s, possible wedge, escalation 1, model stream silent for 604s (foreground request)), PERMANENTLY-WEDGED: FM_WEDGE_MAX_ESCALATIONS=1 reached - no further wedge escalations for this WINDOW while its cap marker stands: until FM_CAP_HORIZON_SECS elapses, the crew resumes, or the operator manually removes STATE/.wedge-permanent-<key>
--- cap wake queue:
1793452636	1	stale	firstmate:fm-stream-cap	stale: firstmate:fm-stream-cap (idle 3s, possible wedge, escalation 1, model stream silent for 604s (foreground request)), PERMANENTLY-WEDGED: FM_WEDGE_MAX_ESCALATIONS=1 reached - no further wedge escalations for this WINDOW while its cap marker stands: until FM_CAP_HORIZON_SECS elapses, the crew resumes, or the operator manually removes STATE/.wedge-permanent-<key>
--- cap escalation count:
--- cap cap markers:
/tmp/fm-watch-live.JhdgXn/live-cap/state/.wedge-permanent-firstmate_fm-stream-cap
/tmp/fm-watch-live.JhdgXn/live-cap/state/.wedge-terminal-queued-firstmate_fm-stream-cap
--- cap episode marker:
g1793452632.186930.10167 1 1 1793452032--- cap triage log:
[2026-10-31T06:17:13-0700] absorbed busy (model stream silent) timer reset: firstmate:fm-stream-cap
[2026-10-31T06:17:16-0700] wedge permanently capped: firstmate:fm-stream-cap (escalation 1, max 1, hash d41d8cd98f00)
PASS mode=cap

\### mode=counterfault (refused count-file write; uncapped route still delivers one wake)
--- counterfault watcher_alive_after_wait=no exit=n/a
--- counterfault watch stdout:
rm: cannot remove '/tmp/fm-watch-live.JhdgXn/live-counterfault/state/.wedge-escalations-firstmate_fm-stream-counterfault': Is a directory
stale: firstmate:fm-stream-counterfault (idle 2s, possible wedge, escalation 1, model stream silent for 603s (foreground request))
--- counterfault wake queue:
1793452639	1	stale	firstmate:fm-stream-counterfault	stale: firstmate:fm-stream-counterfault (idle 2s, possible wedge, escalation 1, model stream silent for 603s (foreground request))
--- counterfault escalation count:
(none)
--- counterfault cap markers:
(none)
--- counterfault episode marker:
g1793452636.201029.28411 1 1 1793452036--- counterfault triage log:
[2026-10-31T06:17:17-0700] absorbed busy (model stream silent) timer reset: firstmate:fm-stream-counterfault
[2026-10-31T06:17:19-0700] wedge_timer_check: escalation counter write FAILED for firstmate:fm-stream-counterfault (/tmp/fm-watch-live.JhdgXn/live-counterfault/state/.wedge-escalations-firstmate_fm-stream-counterfault); the next poll restarts this window's count at 1
PASS mode=counterfault

ALL LIVE WATCHER MATRIX CHECKS PASSED
Evidence: Live publication-lock revalidation (queue and recovery locks, close/progress/replace)

Source: Live publication-lock revalidation (queue and recovery locks, close/progress/replace)


\### queue-close: worker close during the queue lock wait
--- held the queue lock with live pid 224885 before publication: blocked=yes
--- watcher alive after release: yes
--- watch stdout: (empty)
--- wake queue: (none)
--- escalation count: (none)
--- triage log: (none)
PASS queue-close

\### queue-progress: worker progress during the queue lock wait
--- held the queue lock with live pid 224885 before publication: blocked=yes
--- watcher alive after release: yes
--- watch stdout: (empty)
--- wake queue: (none)
--- escalation count: (none)
--- triage log: (none)
PASS queue-progress

\### queue-replace: worker replace during the queue lock wait
--- held the queue lock with live pid 224885 before publication: blocked=yes
--- watcher alive after release: yes
--- watch stdout: (empty)
--- wake queue: (none)
--- escalation count: (none)
--- triage log: (none)
PASS queue-replace

\### recovery-close: worker close during the recovery lock wait
--- held the recovery lock with live pid 224885 before publication: blocked=yes
--- watcher alive after release: yes
--- watch stdout: (empty)
--- wake queue: (none)
--- escalation count: (none)
--- triage log: (none)
PASS recovery-close

\### recovery-progress: worker progress during the recovery lock wait
--- held the recovery lock with live pid 224885 before publication: blocked=yes
--- watcher alive after release: yes
--- watch stdout: (empty)
--- wake queue: (none)
--- escalation count: (none)
--- triage log: (none)
PASS recovery-progress

\### recovery-replace: worker replace during the recovery lock wait
--- held the recovery lock with live pid 224885 before publication: blocked=yes
--- watcher alive after release: yes
--- watch stdout: (empty)
--- wake queue: (none)
--- escalation count: (none)
--- triage log: (none)
PASS recovery-replace

ALL LIVE PUBLICATION LOCK CHECKS PASSED
Evidence: Combined live chain: real spawn + real Pi 1.2.0 SDK extension -> real writer -> real watcher on a real tmux window

Source: Combined live chain: real spawn + real Pi 1.2.0 SDK extension -> real writer -> real watcher on a real tmux window


\### 1. spawn a Pi worker with the opt-in option set (real fm-spawn + real pi 1.2.0)
spawned stream harness=pi kind=ship mode=no-mistakes yolo=off window=firstmate:fm-stream worktree=/tmp/fm-combined-lab.R6T4L8/wt
recorded meta window: firstmate:fm-stream
recorded harness: harness=pi
busy record after spawn: v1 gen=g1793452968.733478.25098 seq=1 state=busy source=fm-spawn event=launch-brief ts=1793452968

\### 2. stand the spawned window up as a REAL tmux window on a private server
1: fm-stream* (1 panes) [80x24] [layout b25d,80x24,0,0,0] @0 (active)
foreground command: tmux

\### 3. drive the spawned extension through the real Pi 1.2.0 SDK, holding a stalled stream
live foreground stream evidence: v1 gen=g1793452968.733478.25098 request=1793452970784 rev=2 ts=1793452970
model progress anchor:          v1 gen=g1793452968.733478.25098 request=1793452970784 rev=2 ts=1793452970
busy record:                    v1 gen=g1793452968.733478.25098 seq=2 state=busy source=pi-ext event=agent-start ts=1793452970

\### 4. sustained live silence: the real watcher must escalate early naming model-stream silence
stale: firstmate:fm-stream (idle 1s, possible wedge, escalation 1, model stream silent for 10s (foreground request))
wake-queue row: 1793452980	1	stale	firstmate:fm-stream	stale: firstmate:fm-stream (idle 1s, possible wedge, escalation 1, model stream silent for 10s (foreground request))
escalation count: 1

\### 5. settle phase one through the real extension, then acknowledge the wake
after assistant completion: model-stream marker absent, busy record v1 gen=g1793452968.733478.25098 seq=3 state=idle source=pi-ext event=agent-settled ts=1793452980
wake acknowledged through the real drain

\### 6. adversarial: live progress during the watcher's silence window must prevent the escalation
second request evidence: v1 gen=g1793452968.733478.25098 request=1793452982226 rev=1 ts=1793452982
progress refreshed mid-window: v1 gen=g1793452968.733478.25098 request=1793452982226 rev=2 ts=1793452982
watcher output empty; no inspection timer, no escalation count for the silent-while-progressing request

\### 7. close phase two through the real extension and confirm clean settle
ok - real Pi worker phases completed; final marker empty
final busy record: v1 gen=g1793452968.733478.25098 seq=5 state=idle source=pi-ext event=agent-settled ts=1793452988

ALL COMBINED LIVE CHECKS PASSED
Evidence: Published escalation naming model-stream silence

Source: Published escalation naming model-stream silence

stale: firstmate:fm-stream (idle 1s, possible wedge, escalation 1, model stream silent for 10s (foreground request))
Evidence: Default-off live drive: unset option parity and unset-spawn instrumentation

Source: Default-off live drive: unset option parity and unset-spawn instrumentation


\### 1. watcher with FM_STREAM_SILENT_MAX_SECS unset ignores a backdated stream observation (real tmux pane)
backdated stream evidence: v1 gen=g1793453071.837294.18010 request=1 rev=1 ts=1793452471
--- watcher alive after two polls: yes
--- watch stdout:
(empty)
--- wake queue:
(none)
--- inspection timer:
(none)
--- escalation count:
(none)
--- triage log:
(none)
PASS unset option leaves the general busy bound in force

\### 2. spawn with FM_STREAM_SILENT_MAX_SECS unset: no warning, and the spawned extension records no stream evidence
spawned stream harness=pi kind=ship mode=no-mistakes yolo=off window=firstmate:fm-stream worktree=/tmp/fm-default-off-lab.A1z1pD/wt
warning: /tmp/fm-default-off-lab.A1z1pD/home/data/stream/launch-brief.md records no ship branch; defaulting to legacy branch fm/stream
warning: /tmp/fm-default-off-lab.A1z1pD/home/data/stream/launch-brief.md records no delivery contract line (scaffolded before ship briefs recorded one); launching on the explicit --mode no-mistakes - confirm its definition of done matches
spawn output carried no model-stream warning for documented default-off
busy record while the foreground request is held: v1 gen=g1793453077.849509.30638 seq=2 state=busy source=pi-ext event=agent-start ts=1793453079
model-stream marker present: no
model-progress marker present: no
ok - real Pi worker phases completed; final marker empty
PASS default-off spawn instruments nothing while semantic busy/idle still moves

ALL LIVE DEFAULT-OFF CHECKS PASSED
Evidence: Real Pi 1.2.0 verified-version live harness run

Source: Real Pi 1.2.0 verified-version live harness run

$ PATH=/tmp/piv120bin:$PATH bash bin/fm-test-run.sh tests/fm-pi-worker-stream-live-e2e.test.sh
FM_TEST_BEGIN 2026-10-31T13:15:42Z tests/fm-pi-worker-stream-live-e2e.test.sh family=live-harness-optin expected_gate_skip=live-capability
ok - real Pi 1.2.0 stream, tool, completion, and background request phases
ok - real Pi 1.2.0 default-off worker
Firstmate model-stream observation write failed; inspect worker instrumentation.
ok - real Pi 1.2.0 instrumentation deadline terminated writer and output-holding descendant
ok - real Pi 1.2.0 stream, tool, completion, and background request phases
# pi-signed unavailable: signed executable not exercised
ok - real Pi 1.2.0 worker stream lifecycle, background exclusion, and default-off behavior
FM_TEST_END 2026-10-31T13:16:08Z tests/fm-pi-worker-stream-live-e2e.test.sh exit=0 duration_ms=25692 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=25747
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=1 duration_ms=25692 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-pi-worker-stream-live-e2e.test.sh duration_ms=25692
EXIT=0
Evidence: Installed Pi 1.4.0 unverified-version live harness run (exact warning, inert observation)

Source: Installed Pi 1.4.0 unverified-version live harness run (exact warning, inert observation)

$ installed pi version: 1.4.0
$ bash bin/fm-test-run.sh tests/fm-pi-worker-stream-live-e2e.test.sh
FM_TEST_BEGIN 2026-10-31T13:16:11Z tests/fm-pi-worker-stream-live-e2e.test.sh family=live-harness-optin expected_gate_skip=live-capability
ok - real Pi 1.4.0 default-off worker
# pi-signed unavailable: signed executable not exercised
ok - real Pi 1.4.0 unverified-version warning, inert stream observation, and existing busy/idle behavior
FM_TEST_END 2026-10-31T13:16:18Z tests/fm-pi-worker-stream-live-e2e.test.sh exit=0 duration_ms=6554 gate_skip=false
FM_TEST_SUMMARY total=1 failed=0 skipped_gate=0 duration_ms=6608
FM_TEST_SUMMARY_FAMILY family=live-harness-optin count=1 duration_ms=6554 failed=0
FM_TEST_SLOWEST rank=1 script=tests/fm-pi-worker-stream-live-e2e.test.sh duration_ms=6554
EXIT=0
Evidence: New watcher-triage Pi stream cases (silence timer, progress anchor, lock revalidation, terminal append, counter faults, capped episode restart)

Source: New watcher-triage Pi stream cases (silence timer, progress anchor, lock revalidation, terminal append, counter faults, capped episode restart)

$ FM_TEST_ONLY=test_pi_stream_silence_uses_inspection_timer bash tests/fm-watch-triage.test.sh
ok - opted-in current stream silence uses inspection delay across changing panes; disabled, tool, and foreign phases do not
EXIT=0

$ FM_TEST_ONLY=test_pi_model_progress_and_legacy_fallback bash tests/fm-watch-triage.test.sh
ok - model progress extends only opted-in bounds and obsolete stream episodes reset before legacy fallback
EXIT=0

$ FM_TEST_ONLY=test_pi_stream_publication_lock_revalidation bash tests/fm-watch-triage.test.sh
ok - stream close, progress, and replacement cancel publication after queue and recovery lock waits
EXIT=0

$ FM_TEST_ONLY=test_pi_stream_uninterrupted_publication bash tests/fm-watch-triage.test.sh
ok - stream close, progress, and replacement cancel publication after queue and recovery lock waits
EXIT=0

$ FM_TEST_ONLY=test_pi_stream_terminal_publication bash tests/fm-watch-triage.test.sh
ok - stream close, progress, and replacement cancel publication after queue and recovery lock waits
EXIT=0

$ FM_TEST_ONLY=test_pi_stream_counter_write_failures bash tests/fm-watch-triage.test.sh
rm: cannot remove '/tmp/fm-watch-triage-tests.LqBQT0/pi-counter-uncapped/state/.wedge-escalations-test_fm-counter-uncapped': Is a directory
ok - stream count writes and cap truncation defend failures while uncapped delivery continues
EXIT=0

$ FM_TEST_ONLY=test_pi_stream_resume_restarts_capped_episode bash tests/fm-watch-triage.test.sh
ok - a capped stream that resumes and stalls before rearming starts a fresh episode
EXIT=0
Evidence: Busy-state suite (verified-only Pi version gate)

Source: Busy-state suite (verified-only Pi version gate)

$ bash tests/fm-busy-state.test.sh
ok - failed close invalidates observation before persistence and denies late replay
ok - model streams preserve state and reject stale, closed, superseded, foreign, and retired events
ok - native progress is generation-bound, separately recorded, and cleared on arm and retire
ok - the turn-ended notification rides the apply generation check
ok - arm mints a gen sidecar and seeds busy fm-spawn at seq=1
ok - apply advances seq under the armed gen and attributes the writing source
ok - firstmate-owned interrupt and recovery events bind to the current gen
ok - apply is refused for a task whose busy contract was never armed
ok - retire waits for the writer lock and cannot remove a new incarnation
ok - retire treats only an absent sidecar as already retired
ok - the writer breaks a stale lock instead of dying on GNU stat output
ok - a late event from a previous incarnation is rejected, record unchanged
ok - a record from a stale incarnation classifies unknown, never idle
ok - a converted adapter with no record classifies unknown, never idle
ok - malformed records classify unknown malformed, never busy or idle
ok - a record with no armed gen sidecar classifies unknown
ok - a record is trusted only by the adapter whose source wrote it
ok - converted adapters never classify busy from rendered footer text
ok - a Claude launch parked on its trust or external-imports dialog classifies unknown launch-prompt
ok - a Pi-family launch (pi, pi-signed, omp) parked on the project-trust dialog classifies unknown launch-prompt
ok - the Pi signature requires both the dialog heading and its decline option, not the bare word trust
ok - a Gemini launch parked on its trust, auth-picker, or API-key dialog classifies unknown launch-prompt
ok - the launch-prompt backstop never reclassifies a genuinely working launch
ok - the launch-prompt backstop is scoped to harnesses with a verified signature
ok - the launch-prompt backstop only ever touches the untouched fm-spawn seed
ok - the launch-prompt backstop never runs without a captured tail
ok - the grok fallback is regex-scoped to grok and classifies only grok tasks
ok - codex classifies unknown until a semantic source passes its verification gate
ok - standalone kimi classifies unknown until the live verification gate opens
ok - Pi stream gate accepts only the verified release, rejects newer, older, prerelease, and malformed
ok - cursor classifies only from its transcript fold, never rendered text or native state
ok - endpoint death is the only process-level override and yields dead, never busy
ok - herdr's native verdict is trusted for busy only, and records outrank it
ok - tern's native verdict is trusted for busy only (source tern-native), and records outrank it
ok - record parsing never clobbers the caller's positional parameters, glob setting, or fields
ok - the boolean view reports busy only on an exact busy verdict
all fm-busy-state tests passed
EXIT=0
Evidence: Generated-Pi stream wiring case (real spawn + generated extension + real writer)

Source: Generated-Pi stream wiring case (real spawn + generated extension + real writer)

$ bash tests/.tmp-only-stream.test.sh   # disposable copy of tests/fm-busy-adapter-wiring.test.sh with only the new stream case registered
ok - generated Pi wiring gates stream observation and clears model phases without accepting late updates
all fm-busy-adapter-wiring tests passed
EXIT=0
Evidence: Whole adapter-wiring file run: stops at the recorded pre-existing secondmate-stall case

Source: Whole adapter-wiring file run: stops at the recorded pre-existing secondmate-stall case

$ bash tests/fm-busy-adapter-wiring.test.sh
not ok - a secondmate inside an armed turn published a durable stall notification
EXIT=1
Evidence: Documentation inventory suite

Source: Documentation inventory suite

$ bash tests/fm-documentation-audiences.test.sh
ok - documentation inventory classifies every maintained prose surface exactly once
ok - classification, setup routing, and maintained-prose scope fail safely
ok - required documentation owner pointers cannot silently disappear
ok - local links resolve while dates, versions, commands, and incident prose remain semantically reviewed
EXIT=0
Evidence: Documented option text plus the live-Pi verification guard section it points at

Source: Documented option text plus the live-Pi verification guard section it points at

# Documented opt-in option and its live-Pi evidence (docs/configuration.md, docs/verification/runtime-backends.md)

## docs/configuration.md:3191-3200
Pi worker model-stream observation is optional.
Set `FM_STREAM_SILENT_MAX_SECS=300` before launching workers and their watcher to inspect a foreground request that stops producing substantive content for five minutes.
It must be present in the environment that launches both the worker and its watcher: a value only the watcher sees, such as one added only to `config/watch.env`, instruments no worker, so a worker spawned without it records no stream evidence and keeps the general busy bound.
The interval includes foreground request preparation; the existing wedge delay and declared-wait deferrals still apply before an inspection notification, and no worker is interrupted or restarted.
Background provider/cache warming is excluded, and observation closes at assistant message completion, tool execution start, or settled idle state.
Changed nonempty text, thinking, or tool-call content refreshes stream evidence at most once per second and supplies a separate progress anchor for the general busy bound; empty or unchanged snapshots do not.
New instrumentation is version-gated to Pi 1.2.0 and takes effect on launch or relaunch; stream observation stays off on every unverified version until verified, with a warning and the general busy bound retained.
Observation writes have a five-second subprocess deadline and one-second termination grace; a failed write reports an instrumentation warning while Pi continues.
Unset, empty, zero, negative, malformed, and values longer than nine decimal digits disable the option, including its separate normal-model progress anchor.
`bin/fm-busy-lib.sh` owns stream evidence and ordering; the [real-Pi verification guard](verification/runtime-backends.md#pi-worker-model-stream-observation) refreshes the vendor evidence.

## docs/configuration.md:3327
FM_STREAM_SILENT_MAX_SECS=         # opt-in Pi worker foreground model-stream silence threshold; off by default; see the option above and bin/fm-busy-lib.sh

## docs/verification/runtime-backends.md: Pi worker model-stream observation (live harness command)
3223:## Pi worker model-stream observation
3224-
3225-Verified on 2026-10-13 with the installed Pi 1.2.0 SDK and Node v24.13.0.
3226-On an unverified Pi version, the guard exercises the spawn-time inert path with its exact warning, no stream handlers, and ordinary busy/idle classification; stream observation stays off until the version is verified.
3227-Refresh this token-free guard after a Pi upgrade:
3228-
3229-`` `sh
3230-bash bin/fm-test-run.sh tests/fm-pi-worker-stream-live-e2e.test.sh
3231-`` `
3232-
3233-Observed output:
3234-
3235-`` `text
3236-ok - real Pi 1.2.0 stream, tool, completion, and background request phases
3237-ok - real Pi 1.2.0 default-off worker
3238-Firstmate model-stream observation write failed; inspect worker instrumentation.
3239-ok - real Pi 1.2.0 instrumentation deadline terminated writer and output-holding descendant
3240-ok - real Pi 1.2.0 stream, tool, completion, and background request phases
3241-# pi-signed unavailable: signed executable not exercised
3242-ok - real Pi 1.2.0 worker stream lifecycle, background exclusion, and default-off behavior
3243-`` `
3244-
3245-The guard runs the generated worker extension through Pi's real resource loader, model runtime, agent loop, and custom tool execution in isolated directories.
3246-Synthetic transport holds an accepted response, supplies substantive and empty events, enters a tool phase, and completes a subsequent request.
3247-The real provider callback is also exercised outside the foreground agent loop to disconfirm background-request tracking.
3248-An isolated copy of the toolkit injects one stalled writer command and a descendant that retains output, proving the real extension's deadline ends both processes and Pi continues through its remaining phases.
3249-No external provider, credentials, primary extension, or live fleet is used.
3250-The signed executable was absent and is not credited as live-verified on this version.
3251-The portable busy-state, adapter-wiring, and watcher-triage suites own generation/request rejection and inspection notification behavior.
3252-
3253-The unverified-version fallback was checked on 2026-10-31 with installed Pi 1.4.0 and Node v24.22.1 using the same command above.
3254-The guard asserted the exact spawn warning and absence of stream handlers, then exercised ordinary busy/idle behavior through the real SDK.
3255-Observed output:
3256-
3257-`` `text
3258-ok - real Pi 1.4.0 default-off worker
3259-# pi-signed unavailable: signed executable not exercised
3260-ok - real Pi 1.4.0 unverified-version warning, inert stream observation, and existing busy/idle behavior
3261-`` `
3262-
3263-## Native Codex through Pi
Evidence: Repro script: live publication-lock revalidation

Source: Repro script: live publication-lock revalidation

#!/usr/bin/env bash
# Live publication-lock revalidation drive: REAL tmux panes, REAL bin/fm-watch.sh,
# REAL bin/fm-busy-event.sh, and a REAL held lock (a live pid in the state lock).
# The worker changes the stream observation while the watcher is blocked in the
# lock wait, so the observation it captured must not survive to publication.
set -u
ROOT=~/.no-mistakes/worktrees/9f75ec418609/01M691BS1E935R4G6VD0D4CGR1
# shellcheck source=/dev/null
. "$ROOT/tests/fixtures.sh"
TMP_ROOT=$(fm_test_tmproot fm-watch-live-lock)
# shellcheck source=/dev/null
. "$ROOT/tests/watch-triage-helpers.sh"

WATCH="$ROOT/bin/fm-watch.sh"
BUSY="$ROOT/bin/fm-busy-event.sh"

TMUXDIR=$(mktemp -d "${TMPDIR:-/tmp}/fm-live-lock-tmux.XXXXXX")
export TMUX_TMPDIR="$TMUXDIR"
AGENTBIN="$TMUXDIR/agentbin"
mkdir -p "$AGENTBIN"
cat > "$AGENTBIN/pi" <<'PI'
#!/usr/bin/env bash
while :; do sleep 1; done
PI
chmod +x "$AGENTBIN/pi"
tmux new-session -d -s firstmate -n fm-pub-queue-close "$AGENTBIN/pi"
tmux new-window -d -t firstmate -n fm-pub-queue-progress "$AGENTBIN/pi"
tmux new-window -d -t firstmate -n fm-pub-queue-replace "$AGENTBIN/pi"
tmux new-window -d -t firstmate -n fm-pub-recovery-close "$AGENTBIN/pi"
tmux new-window -d -t firstmate -n fm-pub-recovery-progress "$AGENTBIN/pi"
tmux new-window -d -t firstmate -n fm-pub-recovery-replace "$AGENTBIN/pi"
cleanup() {
  tmux kill-server 2>/dev/null || true
  chmod -R u+w "$TMUXDIR" 2>/dev/null || true
  rm -rf "$TMUXDIR" 2>/dev/null || true
}
trap cleanup EXIT

for lock_kind in queue recovery; do
  for action in close progress replace; do
    mode="$lock_kind-$action"
    printf '\n### %s: worker %s during the %s lock wait\n' "$mode" "$action" "$lock_kind"
    dir=$(make_case "live-lock-$mode"); state="$dir/state"; fakebin="$dir/fakebin"
    out="$dir/watch.out"; window="firstmate:fm-pub-$mode"
    key=$(printf '%s' "$window" | tr ':/.' '___')
    printf 'window=%s\nkind=ship\nharness=pi\n' "$window" > "$state/stream.meta"
    printf 'working: setup complete\n' > "$state/stream.status"
    seen_sig "$state/stream.status" > "$state/.seen-stream_status"
    gen=$("$BUSY" arm "$state" stream)
    "$BUSY" apply "$state" stream busy --gen "$gen" --source pi-ext --event agent-start
    "$BUSY" stream "$state" stream open --gen "$gen" --request 1
    printf 'v1 gen=%s request=1 rev=1 ts=%s\n' "$gen" "$(( $(date +%s) - 600 ))" > "$state/stream.model-stream"
    # The observation has already crossed its bound, so the next poll reaches
    # publication immediately: the held lock is the only thing stopping it.
    echo $(( $(date +%s) - 500 )) > "$state/.stale-since-$key"
    if [ "$lock_kind" = recovery ]; then
      lock="$state/.watcher-down.lock"
      prior=$(cat "$state/.watcher-down" 2>/dev/null || true)
    else
      lock="$state/.wake-queue.lock"
      prior=''
    fi
    # Real held lock: a directory carrying the live driver's pid, exactly the
    # shape the production claim/steal logic recognizes as a live holder.
    mkdir "$lock"
    printf '%s\n' "$$" > "$lock/pid"
    PATH="$PATH" FM_STATE_OVERRIDE="$state" FM_CREW_STATE_BIN="$fakebin/fm-crew-state.sh" \
      FM_FAKE_CREW_STATE='state: working · source: live · publication lock drive' \
      env FM_STREAM_SILENT_MAX_SECS=300 FM_BUSY_TURN_MAX_SECS=99999 \
      FM_WEDGE_MAX_ESCALATIONS=1 FM_STALE_ESCALATE_SECS=1 FM_POLL=1 FM_SIGNAL_GRACE=1 \
      FM_CHECK_INTERVAL=999999 FM_HEARTBEAT=999999 "$WATCH" > "$out" 2>&1 &
    pid=$!
    sleep 3
    blocked=no
    [ -s "$out" ] || [ -s "$state/.wake-queue" ] || blocked=yes
    printf -- '--- held the %s lock with live pid %s before publication: blocked=%s\n' \
      "$lock_kind" "$$" "$blocked"
    case "$action" in
      close) "$BUSY" stream "$state" stream close --gen "$gen" --request 1 ;;
      progress) "$BUSY" stream "$state" stream progress --gen "$gen" --request 1 ;;
      replace) "$BUSY" stream "$state" stream open --gen "$gen" --request 2 ;;
    esac
    sleep 1
    rm -f "$lock/pid"
    rmdir "$lock"
    if ! wait_poll_cycle "$state" "$pid" 200; then
      reap "$pid"
      echo "FAIL $mode watcher exited before revalidating: $(cat "$out")"
      exit 1
    fi
    wait_poll_cycle "$state" "$pid" 200 || true
    [ "$blocked" = yes ] || { reap "$pid"; echo "FAIL $mode never blocked before publication"; exit 1; }
    [ ! -s "$out" ] || { reap "$pid"; echo "FAIL $mode published obsolete silence: $(cat "$out")"; exit 1; }
    [ ! -s "$state/.wake-queue" ] || { reap "$pid"; echo 'FAIL obsolete wake survived'; exit 1; }
    [ ! -e "$state/.stale-since-$key" ] || { reap "$pid"; echo 'FAIL rejected publication retained escalation timer'; exit 1; }
    [ ! -e "$state/.wedge-escalations-$key" ] || { reap "$pid"; echo 'FAIL rejected publication retained escalation count'; exit 1; }
    [ ! -e "$state/.wedge-permanent-$key" ] && [ ! -e "$state/.wedge-terminal-queued-$key" ] || { reap "$pid"; echo 'FAIL obsolete terminal append retained cap'; exit 1; }
    if [ "$lock_kind" = recovery ]; then
      [ "$(cat "$state/.watcher-down" 2>/dev/null || true)" = "$prior" ] || { reap "$pid"; echo 'FAIL rejected append changed the prior recovery marker'; exit 1; }
    fi
    printf -- '--- watcher alive after release: %s\n' "$(kill -0 "$pid" 2>/dev/null && echo yes || echo no)"
    printf -- '--- watch stdout: '; cat "$out"; [ -s "$out" ] || echo '(empty)'
    printf -- '--- wake queue: '; cat "$state/.wake-queue" 2>/dev/null || echo '(none)'
    printf -- '--- escalation count: '; cat "$state/.wedge-escalations-$key" 2>/dev/null || echo '(none)'
    printf -- '--- triage log: '; cat "$state/.watch-triage.log" 2>/dev/null || echo '(none)'
    reap "$pid"
    echo "PASS $mode"
  done
done

printf '\nALL LIVE PUBLICATION LOCK CHECKS PASSED\n'

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 8 of 9 scenarios driven live against the product
Scenario Result Live Evidence
With the option on and a foreground Pi request silent past the threshold on a pane that keeps changing, the watcher escalates early and its reason names model-stream silence ✅ pass live watcher-live-matrix.log mode=enabled: real private tmux pane ticking every poll, real bin/fm-watch.sh + bin/fm-busy-event.sh published `stale: firstmate:fm-stream-enabled (idle 3s, possible wedge, e…
Live close, progress, or a replacement foreground request during the silence window cancels the escalation, leaving no wake, no inspection timer, and no escalation count ✅ pass live watcher-live-matrix.log modes fresh/close/replace: each entered the model-stream ladder, then the real writer changed the observation and the watcher stayed alive with empty stdout, no wake-queue ro…
An observation that changes while the watcher is blocked on the publication lock is revalidated and never published (queue and recovery locks, close/progress/replace) ✅ pass live watcher-live-lock.log: all six cases held the real lock with a live holder pid (blocked=yes), the writer closed/refreshed/replaced the request during the wait, and after release the watcher stayed…
Unset, zero, and malformed option values leave the general busy bound in force: no escalation, no inspection timer, no wake ✅ pass live watcher-live-matrix.log modes disabled (0) and invalid, plus default-off-drive.log part 1 which ran with FM_STREAM_SILENT_MAX_SECS unset against a backdated stream observation written by the rea…
The spawn-generated Pi extension records foreground stream open/progress/close through the real writer and clears the evidence at assistant completion and tool execution, driven through the real Pi 1.… ✅ pass live combined-live-drive.log steps 1-3 and 5-7: real fm-spawn generated the extension for the opt-in value, the real Pi 1.2.0 SDK agent loop produced stream.model-stream/stream.model-progress evidenc…
On an unverified Pi release the spawn warns with the exact message and installs an inert extension that records no stream evidence, keeping the existing busy/idle bound ✅ pass live live-pi-1.4.0.log: real installed Pi 1.4.0 spawn emitted the exact unverified-version warning, installed no stream handlers, recorded no model evidence, and kept busy/idle behaviour
A spawn with the option unset instruments nothing (no stream warning, no model markers) while semantic busy/idle still moves ✅ pass live default-off-drive.log part 2: real fm-spawn with the variable unset, then the generated extension driven through the real Pi 1.2.0 SDK with a held foreground request showed `model-stream marker pres…
A cap fire publishes one terminal wake carrying the model-stream evidence, and a refused escalation-count write on the uncapped stream route still delivers exactly one wake without wedging ✅ pass live watcher-live-matrix.log mode=cap: one PERMANENTLY-WEDGED wake retaining model stream silent for ..., both cap markers written; mode=counterfault: the count write was refused, the triage log reco…
The opt-in option and its live-Pi verification evidence are documented, and the documented knob is the one the product honours ⏸️ untested no The prior payload only recorded static documentation artifacts (documentation-artifact.txt, targeted-documentation.log) and asserted the documented variable matched names seen in other runs; it re…
  • PATH=/tmp/piv120bin:$PATH bash bin/fm-test-run.sh tests/fm-pi-worker-stream-live-e2e.test.sh (real Pi 1.2.0 verified path)
  • bash bin/fm-test-run.sh tests/fm-pi-worker-stream-live-e2e.test.sh (installed Pi 1.4.0 unverified/inert path)
  • bash watcher-live-matrix.sh — real tmux pane + real bin/fm-watch.sh + real bin/fm-busy-event.sh: modes enabled, disabled(0), invalid, fresh, close, replace, cap, counterfault
  • bash watcher-live-lock.sh — held queue and recovery locks with a live holder pid, worker close/progress/replace during the wait (6 cases)
  • bash combined-live-drive.sh — real fm-spawn.sh + real Pi 1.2.0 SDK worker holding a foreground stream -> real writer -> real watcher on a real tmux window; escalation, adversarial mid-window progress cancellation, clean settle
  • bash default-off-drive.sh — watcher with FM_STREAM_SILENT_MAX_SECS unset against backdated stream evidence, and spawn with the option unset driven through the real Pi 1.2.0 SDK
  • bash tests/fm-busy-state.test.sh
  • FM_TEST_ONLY=&lt;case&gt; bash tests/fm-watch-triage.test.sh for test_pi_stream_silence_uses_inspection_timer, test_pi_model_progress_and_legacy_fallback, test_pi_stream_publication_lock_revalidation, test_pi_stream_uninterrupted_publication, test_pi_stream_terminal_publication, test_pi_stream_counter_write_failures, test_pi_stream_resume_restarts_capped_episode
  • bash tests/.tmp-only-stream.test.sh — disposable filtered copy of tests/fm-busy-adapter-wiring.test.sh registering only the new generated-Pi stream lifecycle case (copy removed afterwards)
  • bash tests/fm-documentation-audiences.test.sh
  • bash tests/fm-busy-adapter-wiring.test.sh (whole file; stops at the already-recorded pre-existing secondmate-stall failure before reaching the stream case, so the stream case was run separately above)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Closes #6881

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio for #6881. Tip 8659b1ff has a MATCH no-mistakes attestation and solid live evidence (8/9; signed Pi skip is fine). I read the unconfigured path myself.

Contract-class (my own read): opt-in. FM_STREAM_SILENT_MAX_SECS defaults off; spawn sets streamMonitoring=false unless configured and Pi is 1.2.0; the watcher silence path stays gated. Legacy busy bound is preserved when off.

Where this stands: waiting on you for lint.

  1. Lint 1 — SC2034 unused stream_ts in bin/fm-busy-event.sh (~line 282).
  2. Lint 2 — SC2034 unused stream_gen / stream_request / stream_rev in bin/fm-watch.sh (~line 1561).

Please fix those (underscore or use the fields) and re-raise through git push no-mistakes so the attestation binds the new tip.

Parallel 1's fm-pi-primary-types / BeforeAgentStartEvent.prompt failure is the same drift already red on main — not on this PR. Every other behavior shard and Herdr passed.

VISION per rule: one captain/one interface: aligns. Authority explicit: aligns (off unless configured). Scripts vs judgment: aligns. Restart non-event: aligns. Delegation with a spine: aligns. Vendor-neutral: aligns (version-gated). Scope: aligns.

Main is red this wake, so no merges either way. Once lint is green on an attested tip and main is green, this is an auto-merge candidate.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Please fix those (underscore or use the fields) and re-raise through git push no-mistakes so the attestation binds the new tip.

Both lint fixes are published through the existing no-mistakes run at ffd918c2d8e575196b2a6f8304c08c512228c8ac. The repair explicitly discards unused snapshot fields in fm-busy-event.sh and fm-watch.sh; the ownership checks are unchanged. I verified that the published attestation binds this tip.

The replacement lint jobs are still running. Parallel 1 again fails only fm-pi-primary-types, with the same BeforeAgentStartEvent.prompt errors reproduced on the base. I kept that primary-extension compatibility repair outside this PR, as discussed. No green-CI or merge-readiness claim yet.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @kesslerio. That was a quick, clean turnaround.

What changed since my 06:22Z stamp: the new tip is ffd918c2, and the no-mistakes attestation MATCHES it. The repair discards the unused snapshot fields (read -r … _) in bin/fm-busy-event.sh and bin/fm-watch.sh, and the generation and request ownership checks are unchanged. I reviewed it: no workflow changes and no security concerns.

CI on ffd918c2 (run 38356679779):

  • Lint 1 and Lint 2 are green now. That was the only thing I'd asked you for.
  • Behavior portable parallel 1 still fails only on fm-pi-primary-types / BeforeAgentStartEvent.prompt. That's the same drift that's red on main, and keeping the fix out of this PR is the right call.
  • Behavior portable serial 4 failed once in fm-remote-reply.test.sh ("the header-collision line was not captured"). This PR doesn't touch that suite, it passed on your previous head, and it passed on a rerun I started. So I'm treating it as a flake.
  • Serial 2 was cancelled at the time limit. That's a known infra tripwire, so I've started one rerun.

Where it stands: waiting on CI, not on you. Contract-class (my own read of the unconfigured path) is still opt-in: FM_STREAM_SILENT_MAX_SECS is unset by default, so stream monitoring stays off and the legacy busy bound holds. VISION still aligns with every rule.

Main is red this wake, so nothing merges right now. Once main's Pi type fix lands and this head shows parallel 1 green against it, this is an auto-merge candidate. Nothing is needed from you in the meantime.

@kesslerio
kesslerio force-pushed the fix/pi-stream-silence-6881-t3-20261013 branch from ffd918c to 4ba5b66 Compare October 17, 2026 19:45
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio. I re-read the thread and the new tip e777bbad against the current main.

Contract-class (my own read of the unconfigured path): still opt-in. fm_busy_stream_seconds prints 0 for unset, invalid or zero FM_STREAM_SILENT_MAX_SECS, so spawn keeps streamMonitoring=false, the watcher never takes the stream snapshot branch, and the legacy busy bound and fm_wake_append path stay the same. The new fm_wake_append_guarded is only reached when a stream snapshot exists. There are no .github/workflows changes and I found no security concerns in the diff.

CI on e777bbad (run 39066857803): everything is green except two jobs:

  • Behavior portable serial 5 failed once in tests/fm-remote-job.test.sh ("TERM did not stop the idle worker"). This PR doesn't touch remote-job, and every other remote-job case passed, so this looks like a flake.
  • Behavior portable serial 2 was cancelled at the 30-minute ceiling (in fm-branch-supervision.test.sh). That's the known infra limit tracked in fix(pi): keep the Pi watcher armed after a successor or arm child dies #7255, not this PR.

I started one re-run of the failed jobs. If both come back green, I'll treat this as an opt-in auto-merge candidate.

Where it stands: waiting on CI, not on you. Your PR body still says "Author hold". When you're satisfied with the race-wait acknowledgements, please drop that line from the body so I know it's ready from your side. The live evidence (8/9, with signed Pi untested) is fine as it is. Nothing else is needed from you.

VISION per rule: one captain/one interface aligns (the inspection is only noted, with no automatic interruption). Authority explicit aligns (off unless configured). Scripts vs judgment aligns. Restart non-event aligns (generation/request records on disk). Delegation with a spine aligns. Vendor-neutral aligns (Pi 1.2.0 version-gated adapter). Scope aligns.

@kesslerio
kesslerio force-pushed the fix/pi-stream-silence-6881-t3-20261013 branch from e777bba to c1970ed Compare October 21, 2026 12:37
@kesslerio kesslerio changed the title fix: detect silent Pi worker model streams feat(watch): detect silent Pi model streams Oct 21, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @kesslerio for the rebase and for writing up the CI results so clearly.

I re-read head d8fb88fa against main 2c93247f. The body says Closes kunchenguid/firstmate#6881, so that's confirmed. The no-mistakes attestation matches this head. The rebase keeps upstream's opt-in wedge-evidence guard, and the stream-silence path is still gated: fm_busy_stream_seconds prints 0 for unset, invalid, or zero FM_STREAM_SILENT_MAX_SECS, busy_turn_over_age and busy_stream_snapshot_current return early when it's 0, and without a snapshot wedge_timer_check still calls plain fm_wake_append. No .github changes, and I have no security concerns.

Where it stands: waiting on you.

  • Serial 6 fails on this PR's own new test: not ok - Pi 1.3.0: worker stream contract verified only on 1.2.0. Hosted CI now installs Pi 1.3.0, and the live suite treats an unverified version as a failure. The fix belongs in this PR. Either verify the stream contract on 1.3.0 and widen the gate, or have the suite report a clean, named skip on an unverified Pi version instead of failing. On the second path, the feature also stays inert on 1.3.0 hosts, which is worth saying in the docs. Pinning the CI Pi install would be a workflow change, so please don't go that route here.
  • Serial 5 matches the current main failure (fm-remote-secondmate-lifecycle-e2e), and serial 2 hit the known 30-minute ceiling (fix(pi): keep the Pi watcher armed after a successor or arm child dies #7255/ci: add a tenth portable serial shard and split the supervision host suite #7587). Neither counts against you. Serial 4 (fm-remote-reply header-collision) looks like the same flake we saw on ffd918c2. I'll rerun it once serial 6 is fixed.
  • Author hold: the body still says "Author hold". Please remove that line when you're ready.
  • Live validation: this head's pipeline run drove 0 of 2 scenarios live (it hit the Pi 1.3.0 version guard). Your body notes that you reran fm-pi-worker-stream-live-e2e by hand against a pinned 1.2.0 and all three cases passed. When you re-raise, please have git push no-mistakes record that run (or post the transcript here) so the attestation and the evidence point at the same head.

contract-class: opt-in (my own read, unchanged): off unless FM_STREAM_SILENT_MAX_SECS is set. Once CI is green with an attested head and the hold is gone, this is an auto-merge candidate.

VISION: One captain aligns (silence is only reported, with no automatic interrupt) · Authority aligns (off unless configured) · Scripts aligns · Restart aligns (generation/request records on disk) · Delegation pending green CI and live evidence on this head · Vendor aligns (version-gated Pi adapter; the 1.3.0 handling above is the open piece) · Scope aligns.

@kesslerio

Copy link
Copy Markdown
Contributor Author

@kunchenguid — CI on this PR is 15 of 19 green. Three of the four red jobs need no code change and want a re-run; the fourth is a policy decision for you.

Head d8fb88fa, rebased onto 2c93247f with four conflicts resolved keeping both sides (upstream's wedge-guard deferral in bin/fm-watch.sh and the branch's stream snapshot revalidated immediately before a wake; upstream's config/wedge-defer-worker-wait clauses; upstream's operator-guard paragraph; upstream's dialog_name in bin/fm-supervise-daemon.sh). The "Author hold" line is dropped from the body, at your request.

Red jobs:

  • Behavior portable serial 4 — tests/fm-remote-reply.test.sh, "the header-collision line was not captured". This branch's diff touches no remote-reply path, and the previous head's own CI log already recorded this exact failure with no causal link found.
  • Behavior portable serial 5 — tests/fm-remote-secondmate-lifecycle-e2e.test.sh, "the watcher did not exit on its auto-relaunch wake within the bound". The identical failure is on the current origin/main CI run 39583761157 at 2c93247f; this diff touches no process-event path.
  • Behavior portable serial 2 — cancelled at the job's 30-minute ceiling, the repo-wide limit tracked by ci: add a tenth portable serial shard and split the supervision host suite #7587.
  • Behavior portable serial 6 — this one is a decision, not a flake. The branch's own live suite refuses any Pi it has not verified, and it verifies the stream contract on Pi 1.2.0. The hosted CI installs the latest @earendil-works/pi-coding-agent, and Pi 1.3.0 is now the latest — so the branch correctly refuses a version it has not verified. This is the same class of problem as upstream commit b55f2782 ("CI installs unpinned @earendil-works/pi-coding-agent"). Either pin the CI's Pi install to the verified 1.2.0, or extend the verified contract to the installed version. I have not chosen for you, because both are legitimate and the second changes what the branch claims.

Ask — re-run serials 4 and 5 on this head; kesslerio has no admin rights on kunchenguid/firstmate and cannot trigger a re-run itself. And a decision on the Pi version policy for serial 6.

Signed Pi remains untested live — no signed executable exists on this host — and is not presented as a pass. Re-verified green at this head: the three live Pi stream cases against real Pi 1.2.0 via a disposable install, the four selected fm-watch-triage stream cases, fm-busy-state and fm-busy-adapter-wiring.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @kesslerio for the clear CI write-up, and for dropping the author-hold line.

On the Pi version question: this PR doesn't need a captain decision. It can be resolved inside the PR. Pinning the CI's Pi install would be a workflow change, and that stays out of this PR, as I mentioned earlier. So the two in-PR paths from my last note still stand:

  1. Verify the stream contract on Pi 1.3.0 and widen the gate, or
  2. have fm-pi-worker-stream-live-e2e report a clean, named skip on an unverified Pi version instead of failing, and say in the docs that the feature stays inert there.

Either one is fine from my side. Path 2 keeps the claim narrow, and that fits the version-pinned-adapter language in VISION. Path 1 is only worth it if you can actually verify the contract on 1.3.0. I'll pass the broader CI-pin question to Kun separately. It isn't something this PR has to wait on.

On reruns: I'm holding off for now. Serial 6 fails on this PR's own new test, so it needs a push either way, and a push re-runs every shard. If serial 4 (fm-remote-reply header collision) or serial 5 (fm-remote-secondmate-lifecycle-e2e, also red on main) flakes again on the next head, I'll rerun it. Neither counts against you, and serial 2 is the known #7587 ceiling. For context, main 83b70ef4's own red run failed at the npm install step, not in tests, and it is being re-run now.

Where it stands: waiting on you for the serial 6 fix. When you push it, please re-raise with git push no-mistakes so the attestation and the live Pi 1.2.0 run point at the new head.

Contract-class: opt-in (my own read, unchanged). It's off unless FM_STREAM_SILENT_MAX_SECS is set, and without a stream snapshot the watcher stays on plain fm_wake_append. VISION: every rule aligns, as in my last stamp. Once CI is green on an attested head, this is an auto-merge candidate.

@kesslerio

Copy link
Copy Markdown
Contributor Author

@kunchenguid — a measurement that changes the Pi question I raised above, so it is not a coin flip.

On this host Pi 1.3.0 is installed (~/.npm-packages/lib/node_modules/@earendil-works/pi-coding-agent, pi --version → 1.3.0). I ran the branch's own live suite against it, with only the version gate relaxed:

# as shipped
not ok - Pi 1.3.0: worker stream contract verified only on 1.2.0

# with the gate relaxed to accept 1.3.0
Error: Pi 1.2.0: timeout waiting for foreground progress
    at until (tests/fm-pi-worker-stream-live.mjs:20:39)
    at async (tests/fm-pi-worker-stream-live.mjs:114:5)
not ok - Pi 1.3.0: real worker stream guard failed (enabled)

The generated worker extension never writes the stream.model-progress marker on Pi 1.3.0, so the harness times out waiting for foreground progress. The version gate is load-bearing, not conservative: relaxing it would publish a claim this branch cannot reproduce on the version CI actually installs.

So the fix belongs on the CI side, not in the gate. The root cause is upstream b55f2782 ("CI installs unpinned @earendil-works/pi-coding-agent") — the lane installs whatever is latest, so when latest moved to 1.3.0 every branch verifying a 1.2.0-pinned contract went red. That leaves two honest options, and they are no longer equally weighted:

  1. Pin the CI install for the lane that runs this suite to the verified 1.2.0. Smallest change, keeps the branch's claim exactly as verified. It does mean the lane stops exercising the newest Pi, which is a repo-wide tradeoff.
  2. Teach the detection Pi 1.3.0's shape — a real compatibility task, needing someone to own the 1.3.0 stream surface. Pi 1.3.0 still exposes provider_stream_event, before_provider_request and after_provider_response, so the event names are not what changed; whatever differs is downstream of them.

I am not making this call — it is a repo-wide CI policy question and you own it. But you now have the measurement rather than a choice between two guesses.

To reproduce: PATH="$HOME/.npm-packages/bin:$PATH" bash tests/fm-pi-worker-stream-live-e2e.test.sh on any host with Pi 1.3.0 installed.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Thank you @kesslerio for actually measuring 1.3.0. That settles path 1: the gate is load-bearing, and widening it would be wrong.

That leaves path 2, which is still an in-PR fix. On this head, bin/fm-spawn.sh already keeps the feature inert on any Pi other than 1.2.0. It leaves streamMonitoring off, prints the "model-stream observation unavailable ... verified version: 1.2.0; existing busy bound remains active" warning, and keeps the old busy bound. So on a 1.3.0 host, the product does what your docs should say. Only the live e2e turns "not verified on this version" into a failure. Please have tests/fm-pi-worker-stream-live-e2e.test.sh report a named skip on an unverified Pi version, or better, assert the inert path and the warning there. Then say in the docs that the feature stays off on unverified Pi versions until someone verifies them. That keeps the claim exactly as verified, with no workflow change.

On the CI Pi pin: that one is a repo-wide question for Kun, and I'm passing it on separately. This PR doesn't need to wait for it.

Where it stands: waiting on you for that serial 6 change. Head d8fb88fa and CI run 39606881836 are unchanged since my last stamp. When you push, please re-raise with git push no-mistakes so the attestation binds the new head.

Contract-class: opt-in, unchanged. It's off unless FM_STREAM_SILENT_MAX_SECS is set, and it's also off on unverified Pi versions. Once CI is green on an attested head with no hold, this is an auto-merge candidate.

@kesslerio
kesslerio force-pushed the fix/pi-stream-silence-6881-t3-20261013 branch from d8fb88f to 74d4db6 Compare October 28, 2026 07:02
@kesslerio kesslerio changed the title feat(watch): detect silent Pi model streams fix(watcher): detect silent Pi model streams Oct 28, 2026
@greptile-apps

greptile-apps Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new actionable issues were found.

Reviews (6) · Last reviewed commit: "no-mistakes(document): Clarify Pi stream..." · Reviewed by Greptile

Comment thread tests/fm-busy-state.test.sh Resolved
@kesslerio

Copy link
Copy Markdown
Contributor Author

CI validation summary — head ee3276ea

One required check failed and it is unrelated to this branch. Behavior portable serial 10 (job 122787925586) failed in tests/fm-remote-job.test.sh — "the replacement did not finish its own TERM shutdown". That test file is unmodified by this branch (verified: git diff origin/main HEAD -- tests/fm-remote-job.test.sh is empty; last touched by merged commits ce69740 / 9ea0c41). Its 30-second wall-clock deadline for the TERM'd replacement process to reach zombie state elapsed without exit — a timing-sensitive shutdown under loaded runners. Every other assertion in that file and all 21 other checks passed, including all branch-specific watcher/stream suites (portable serial 1–9, parallel 1–2, Lint 1/2, Herdr, macOS snapshot, invariants, coverage guard).

I do not have admin rights on this repository, so I could not rerun the job myself. Requesting a maintainer rerun of that single job on head ee3276ea; no code change is warranted — changing an unmodified main-branch test belongs in a separate PR if maintainers want the deadline widened.

What this PR's pipeline validated on ee3276ea

  • Review: cleared after multiple fix rounds (seat dispatch/route publication before either backend delivers executable work; fractional-safe consolidated startup confirmation gated on pooled-or-parent-operation; terminal-publication contention now actually exercised — terminal fixture isolated from regular regression cases; stream counter-write fault coverage added for the stream route at the post-append, terminal, and cap-fire truncation sites; verified-only Pi version test decision recorded, not silently overridden).
  • Test: completed.
  • Document/lint/push/PR: completed; PR is MERGEABLE at ee3276ea.
  • Live-evidence note carried from the Test gate: the Pi-signed variant is unavailable in this environment, so live Pi-signed stream scenarios could not be driven; targeted watcher regression tests assert the capped-episode admission and terminal-publication revalidation behavior.

@kesslerio

Copy link
Copy Markdown
Contributor Author

The unverified-version path now proves what it claims instead of reporting a verified pass.

  • On any Pi outside the verified gate, tests/fm-pi-worker-stream-live-e2e.test.sh asserts the exact spawn warning (warning: pi model-stream observation unavailable for version <v>; verified version: 1.2.0; existing busy bound remains active), that the generated worker extension registers none of the four model-stream handlers, and that the retained busy bound still classifies busy then idle through the real Pi SDK while stream evidence stays empty.
  • No skip: the guard passes only after those assertions, and its pass line names the inert path rather than the stream lifecycle.
  • The version gate is unchanged and still accepts only Pi 1.2.0.
  • docs/configuration.md states the boundary in its existing instrumentation sentence: stream observation stays off on every unverified version until verified, with the warning and general busy bound retained.
  • docs/verification/runtime-backends.md records the dated Pi 1.4.0 / Node v24.22.1 run with exact output for the inert path, alongside the Pi 1.2.0 evidence.

Verified on installed Pi 1.4.0 with Node v24.22.1: bash tests/fm-pi-worker-stream-live-e2e.test.sh prints ok - real Pi 1.4.0 unverified-version warning, inert stream observation, and existing busy/idle behavior, and tests/fm-busy-state.test.sh, bin/fm-lint.sh, and bin/fm-doc-audience-check.sh are green.

Mutation-checked so the new assertions cannot pass vacuously: rewriting the warning wording fails with not ok - Pi 1.4.0: missing exact unverified-version warning, and forcing streamMonitoring on for an unverified version fails with not ok - Pi 1.4.0: unverified worker installed stream handlers.

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @kesslerio for staying with this through all the Pi version churn. I re-read head ee3276ea against main 095db3bc.

The serial 6 ask from my 10-22 note is met on this head. On any Pi outside the verified gate, tests/fm-pi-worker-stream-live-e2e.test.sh now runs the unverified case. It asserts the exact spawn warning, checks that the generated extension registers none of the four stream handlers, and then still drives the real Pi SDK with observation off. docs/verification/runtime-backends.md states the inert-path boundary. The gate itself still accepts only 1.2.0. The attestation binds ee3276ea with no skipped steps, live validation is 5 of 5, Greptile's P1 on the version loop is resolved, and every shard but one is green.

Serial 10: tests/fm-remote-job.test.sh, "the replacement did not finish its own TERM shutdown". This PR doesn't touch that suite, so I agree it's a timing flake. I've started one rerun of that job.

Two small things to check, neither of them a blocker:

  • Your 06:00Z note describes a pass line that "names the inert path" (ok - real Pi 1.4.0 unverified-version warning, inert stream observation, and existing busy/idle behavior) and a dated Pi 1.4.0 / Node v24.22.1 record in runtime-backends.md. Neither is on ee3276ea: the pass line still reads "worker stream lifecycle, background exclusion, and default-off behavior", and the last commit is from 10-28. If you meant to push that, please re-raise through git push no-mistakes so the attestation binds the new head. If not, the current head is fine as it is.
  • The PR body no longer has the Closes kunchenguid/firstmate#6881 line it carried on 10-21. If this still closes Pi workers: a model stream that stalls mid-response reads as a normal busy turn for about an hour #6881, please add it back.

Contract-class: opt-in (my own read, unchanged). It's off unless FM_STREAM_SILENT_MAX_SECS is set, and also off on every unverified Pi. Without a stream snapshot, the watcher stays on plain fm_wake_append. VISION: every rule aligns, as in my earlier stamps.

Where it stands: waiting on CI, not on you. Once serial 10 is green, the full suite is the next step on our side, and if that's green this is an opt-in auto-merge candidate.

@kesslerio
kesslerio force-pushed the fix/pi-stream-silence-6881-t3-20261013 branch from ee3276e to 00ee70d Compare October 31, 2026 06:37
@kesslerio kesslerio changed the title fix(watcher): detect silent Pi model streams feat(bin): inspect opt-in Pi foreground model-stream silence Oct 31, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @kesslerio. I re-read the new head 00ee70d3 against main 095db3bc, and the inert-path work from your 06:00Z note is on it now. tests/fm-pi-worker-stream-live-e2e.test.sh passes with real Pi <version> unverified-version warning, inert stream observation, and existing busy/idle behavior on any unverified Pi. docs/verification/runtime-backends.md has the dated Pi 1.4.0 / Node v24.22.1 record. The gate still accepts exactly 1.2.0. The quick checks pass, Greptile's threads are resolved, and contract-class stays opt-in (my own read: off unless FM_STREAM_SILENT_MAX_SECS is set, and off on every unverified Pi). VISION is unchanged, and every rule aligns.

Two things are waiting on you before I can put this in front of the full suite:

A tiny optional one while you're there: test_pi_stream_version_floor_accepts_verified_and_newer now rejects every newer version, so its name reads the opposite of what it checks.

Once both are done, the next steps are ours: the full-ci label and the full suite. If that's green, this is an opt-in auto-merge.

…used 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
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".
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.
@kesslerio
kesslerio force-pushed the fix/pi-stream-silence-6881-t3-20261013 branch from 00ee70d to 49711f1 Compare October 31, 2026 10:58
@kesslerio kesslerio changed the title feat(bin): inspect opt-in Pi foreground model-stream silence feat(bin): inspect opted-in Pi foreground model-stream silence Oct 31, 2026
@kesslerio kesslerio changed the title feat(bin): inspect opted-in Pi foreground model-stream silence feat(watch): inspect opt-in Pi worker model-stream silence Oct 31, 2026
@kesslerio kesslerio changed the title feat(watch): inspect opt-in Pi worker model-stream silence feat(bin): add opt-in Pi model-stream silence observation for busy workers Oct 31, 2026
@kesslerio kesslerio changed the title feat(bin): add opt-in Pi model-stream silence observation for busy workers feat(pi): surface opted-in model-stream silence for Pi workers Oct 31, 2026
@kunchenguid kunchenguid added the full-ci Maintainer go-ahead: run the full CI suite on this outside pull request label Oct 31, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @kesslerio, this covers both asks from my 10:18Z note. I re-read head a13b83e3 against main bb3e6906. The attestation binds this head with intent completed and no skipped steps, and it carries live_validation (go, 8 of 9). Closes kunchenguid/firstmate#6881 is back in the body, and the version-gate test name now matches what it checks. The gate still accepts exactly Pi 1.2.0, the quick checks pass, and Greptile's thread is resolved.

Contract-class stays opt-in (my own read: off unless FM_STREAM_SILENT_MAX_SECS is set, and off on every unverified Pi). VISION aligns on every rule, as before.

Nothing more is needed from you. I've added the full-ci label so the Full suite runs on this head. If it's green, this is on the opt-in path to merge.

@kesslerio

Copy link
Copy Markdown
Contributor Author

Behavior portable serial 4 (job 124561907374) is a pre-existing supervision-host cleanup race, not this PR

The lane failed on a13b83e at:

wait_until_deadline: host_exited timed out for /tmp/fm-supervision-host.KDfilo/away-grok
not ok - away grok: the host did not stop on TERM

(tests/fm-supervision-host.test.sh:409, the away-grok step of test_primary_without_a_verified_mirror_runs_away_only.)

Why it is not this diff:

  1. The failing surface is untouched. git diff bb3e6906..a13b83e3 reports 0 changed lines in tests/fm-supervision-host.test.sh, tests/supervision-host-helpers.sh, bin/fm-supervision-host.sh, and bin/fm-wake-grant.sh. bb3e6906 is main's head, whose full CI ran the byte-identical serial-4 lane green at 11:17Z today.
  2. The one shared file's new code is unreachable there. bin/fm-wake-lib.sh gains an optional guard argument on the wake-append path (fm_wake_append_guarded, new lock calls only inside it and inside the guard-reject branch of _fm_recovery_marker_publish). Those run only when FM_STREAM_SILENT_MAX_SECS > 0 and a live state/<task>.model-stream record exists; the supervision fixture sets neither, so the added lines are inert in this lane.
  3. The mechanism is the TERM/settle race the suite already documents. The process tree captured at the 60 s deadline shows the away-grok host (pid 123295) with a single child, fm-wake-grant.sh release host-123295-1793458303, sitting at etime 00:59 — the entire window — in the release path's queue-lock wait, so the lock was still owned by a live holder that the host's own cleanup could not reclaim. That is exactly the hazard called out at tests/fm-supervision-host.test.sh:78-80 ("a TERM that lands just after a handled wake, while the host settles its successor handoff under the queue and marker locks ... wedged the host instead of exiting") and covered with a tighter 10 s bound by test_host_stopped_right_after_a_handled_wake_exits_and_frees_the_queue; the away-grok case walks the same window with a 60 s bound.
  4. Same head, same file: green here. bash tests/fm-supervision-host.test.sh passes 29/29 (FM_TEST_COMPLETE, EXIT=0) in two consecutive local runs on a13b83e.

Supporting timing evidence on unrelated heads: Behavior portable serial 9 flaked the same way twice today — "remote respawn never reached its blocked launch" on fm/fm-5602-agy-quota-scope (job 124561894777) and "first inheritance transaction never reached its blocked write" on fm/fm-7995-cd-home-help (job 124561884057) — both lock/timing-bound harness cases, neither related to this branch.

Branch left as-is (no rebase, no new push). Could a maintainer re-run Behavior portable serial 4?

@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thanks @kesslerio for the careful write-up on Behavior portable serial 4. I agree with your read. The failure is not ok - away grok: the host did not stop on TERM in tests/fm-supervision-host.test.sh, and this PR doesn't touch that test or bin/fm-supervision-host.sh. The bin/fm-wake-lib.sh change only does anything when a guard predicate is passed: with no guard, fm_wake_append_locked and _fm_recovery_marker_publish take the same path as before. So I'm treating it as a timing flake, not your code.

I've re-run the failed jobs once on head a13b83e3 (the head is unchanged since my 14:20Z note), and that includes the Full suite. Nothing is needed from you. If it comes back green, this stays on the opt-in path to merge.

@kunchenguid
kunchenguid merged commit 8fdf262 into kunchenguid:main Oct 31, 2026
54 of 57 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

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

nathanjgaul-agile added a commit to nathanjgaul-agile/firstmate that referenced this pull request Nov 2, 2026
* fix(bin): keep failed or non-schema remote reply reads out of captures (#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 <[email protected]>

* feat(bin): add per-project pr=manual registry token for worker-written PR text (#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: refuse teardown when Git hides untracked files (#7909)

* 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 <[email protected]>

* fix(bin): keep newest run attribution in crew-state (#5954)

* 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 3fbace9f 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 <[email protected]>
Co-authored-by: Pitch Perfekt Collective <[email protected]>

* chore(ci): run the full suite on outside pull requests only after the full-ci label

Outside pull requests run only the coverage guard and repo invariants until the full-ci label is added; lint and every test lane wait.

A new Full suite check fails naming the full-ci label until it is added, and fails whenever a lane fails or is cancelled.

The label starts the full suite, and later pushes run it again; main pushes, own branches and write-access authors run everything as before.

Other labels run no job at all: their skipped checks take a 'Not run for label - ' prefix, so they cannot hide an earlier failure or a later pass.

Close main pushes keep only the newest run; CONTRIBUTING.md explains the label, and the full-ci label now exists.

* feat(bin): add opt-in systemone and openai decision providers to dispatch resolution (#7664)

* feat(bin): add opt-in systemone and openai providers to typed dispatch resolution

Extend the FM_DISPATCH_PROVIDER/FM_DISPATCH_MODEL seam with a generic
systemone provider (any System One-compatible host at FM_DISPATCH_BASE_URL,
optional FM_DISPATCH_API_KEY) and an openai provider that maps the Choice
request to OpenAI's Decisions API and its answer back. No provider set keeps
the original off line; the never-send check runs on the endpoint and the final
per-provider body. Live provider captures are recorded as pending.

Refs #7643, builds on #7149.

* docs(verification): record the live OpenAI Decisions capture for dispatch resolution

Add a dated 2026-10-23 section for the openai provider: 25 hand-labeled
synthetic briefs against gpt-6-luna, outcome and latency tables, the usage
and header fields actually returned, a calibration note, and one verbatim
request and response pair. The systemone live check stays pending.

Refs #7643.

* docs(verification): record the live Clef capture for the systemone provider

Replace the pending systemone section with a dated 2026-10-23 run against
Cloudflare Workers AI's @cf/cloudflare/clef, reached through a local
test-only relay because Workers AI serves System One at /ai/run/<model> in
a {result, success} envelope. Adds the outcome and latency tables, a
calibration note compared with the gpt-6-luna run, and one verbatim request
and envelope pair. A direct Workers AI option stays out of scope.

Refs #7643.

* feat(bin): promote agy to a full primary and secondmate harness (#7941)

* feat(agy): promote Antigravity CLI to full primary and secondmate harness

Add tracked .agents/hooks.json, bin/fm-sessionstart-agy.sh, bin/fm-turnend-guard-agy.sh, PreToolUse --agy seatbelt flags, session-lock agy ancestry, autoarm supervision model, and --secondmate agy workspace trust pre-registration and spawn support.

* no-mistakes(review): Fix agy Stop-hook park, hooks.json shape, and live coverage

* no-mistakes(review): Unbound agy Stop park, raise ceiling, prove live deny

* no-mistakes(review): Correct agy verification doc park-bound wording

* no-mistakes(document): Document agy as verified primary and secondmate harness

* no-mistakes(ci): I fixed all three selected findings, and every check I ran passed, including the live agy end-to-end run. **ci-1 (`tests/fm-agy-primary-live-e2e.test.sh`):** The invariant is that the live Stop-hook test passes only if a real watcher starts and its wake reaches a follow-up turn. The old test passed as soon as `.agy-park-owner` existed. I replaced the Stop-hook park block with the one the user specified. It waits until both `.agy-park-owner` and `.last-watcher-beat` exist, wakes the watcher with a `done:` status line, and asserts that the park owner was recorded, the watcher started, and `DONE` appears in the agy output. **ci-2 (agy away daemon):** The invariant is that `/afk` must not launch a separate away daemon on any primary whose home runs the supervision host. The agy Stop-hook guard already runs the host when it is enabled, but `fm_afk_launch_host_primary` left agy out. I added `agy` there, which is the one shared check all three callers use. I also added agy to: - the header comment in `bin/fm-afk-launch.sh`; - the three harness loops and the pass message in `tests/fm-afk-launch.test.sh`; - the primary lists and counts in `docs/supervision-host.md`, the matching lines in its engine-selection section, and a new Antigravity (`agy`) row in its Arm owners table; - the header comment in `bin/fm-supervision-instructions.sh`. **user-1 (`.agents/hooks.json`):** The invariant is that each hook command stays one script under Windows `cmd /c` and exits 0 when `sh` is missing. All 5 commands now use `sh -c "..." || cd .`. This does not change behaviour on Linux or macOS, because the `--agy` hooks report deny or continue as JSON on stdout and exit 0. The file keeps its live-verified `{"firstmate":{...}}` shape, matchers and 28800s Stop timeout. **Verification:** - `tests/fm-agy-primary.test.sh` passes, including running the SessionStart hook command from both `.agents/` and the repo root. - `tests/fm-afk-launch.test.sh` has no failures, and the new agy check passes. Its rex end-to-end cases were skipped because the rex CLI is not installed. - `tests/fm-supervision-instructions.test.sh` has no failures. - `bin/fm-lint.sh` and `bin/fm-doc-audience-check.sh` pass. - `FM_AGY_PRIMARY_LIVE=1 tests/fm-agy-primary-live-e2e.test.sh` printed all four `ok` lines and no failures, including "Stop hook parks on a real watcher and delivers its wake to a follow-up turn". The output went through `tail`, so the exit code shown is `tail`'s, not the test script's

* feat(bin): add shared_quota opt-out from quota-based dispatch ranking (#7894)

* feat(dispatch): add shared_quota home opt-out from quota-based ranking

A home whose Claude and other provider usage draws on one combined AI
budget has no meaningful per-provider quota rows, so spendPriority
ranking and runway gates pick the wrong candidate. An optional
top-level "shared_quota": true in config/crew-dispatch.json now opts
the home out: the typed resolver makes no quota-axi call, applies no
quota floor or runway gate, ranks nothing by spendPriority, and
resolves the matched rule's use profiles in declared order, printing
every candidate line with quota ranking off by home declaration.
Firstmate's quota-array-dispatch intake honors the same declaration.
Without the setting, behavior is unchanged. Non-boolean values are
actionable configuration errors in both the resolver and bootstrap.

* test(dispatch): cover shared-quota bypass of unmet rule and profile floors

The shared_quota opt-out test picked a rule with no quota floor, so the
separate rule-floor and profile-floor bypass paths stayed untested.
Two cases now run against the same fixture: a rule whose model:fable
floor (20%) exceeds the snapshot's 15%, and a profile whose all_models
floor (50%) exceeds codex's 31%, each asserting the declared-order pick
still wins with no quota-axi invocation.

* no-mistakes(review): Narrow shared-quota skill opt-out to quota-only gates

* no-mistakes(review): Document preferred_provider under shared_quota opt-out and test it

* no-mistakes(document): Document shared_quota in schema example and verification inventory

* fix(bin): distinguish recycled reaper PIDs in tombstone cleanup (#7958)

* fix(bin): distinguish recycled reaper PIDs in tombstone cleanup

* no-mistakes(ci): ci-2 fixed in tests/fm-watcher-lock.test.sh (test_lock_tombstone_tracks_reaper_start_time). Invariant: no fixture child may outlive a SIGKILLed runner without a bound. (1) The paused reaper's wait loop now also stops when FM_TEST_SUITE_PID is no longer alive or when SECONDS reaches FM_TEST_STUB_MAX_BLOCK_SECONDS. (2) The one sibling child in the same test, the unrelated `sleep 300`, now sleeps for FM_TEST_STUB_MAX_BLOCK_SECONDS so it uses the same bound. Verification, run serially: bash tests/fm-watcher-lock.test.sh. The new test passed on 4 of 4 runs. Red-before still holds: with the base bin/fm-wake-lib.sh from c9da5523, the test fails with 'not ok - recycled reaper pid kept an abandoned tombstone alive'. Separately, the known stand-down flake ('the replaced watcher did not stand down on its own', watch-legacy-local-time-identity) failed on every run on this host and also fails on base c9da5523 without this change, so the test file still exits 1; left unfixed as instructed. ci-1 (Full suite waiting on the full-ci maintainer label) was ignored per the user's decision

* feat(bin): allow omp as a remote secondmate harness (#7939)

* feat: allow omp as a remote secondmate harness

* test: cover omp on the remote secondmate gates

* fix: retire a remote secondmate whose busy state left with its home

* docs: record omp remote retirement evidence

* review: Refresh pinned remote doctor bootstrap checksum

* fix(bin): name a consumed branch grant instead of a wiring bug (#7969)

* fix(bin): name a consumed branch grant instead of a wiring bug

When a supervision branch's own acknowledgement consumes every granted
row, the drain removes the branch-eligible row snapshot while the owner
record stays live. A repeat drain or acknowledgement in the same turn then
refused with a message implying a broken handoff. Say instead that the
grant was already consumed; the refusal and its exit status are unchanged.

* no-mistakes(document): Document consumed-grant refusal in watcher continuity doc

---------

Co-authored-by: c-c6aw <[email protected]>

* fix: preserve literal ampersands in spawn and supervision paths (#7906)

* feat(bin): read dispatch provider keys from a declared credential source (#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 #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 <[email protected]>

* fix: clean up remote reply temporary files and locks on exit (#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: ignore Claude Code per-user settings (#6482)

* 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

* fix: prefilter inbox history for idempotent remote steering (#7905)

* fix(inbox): prefilter idempotent steering history

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

* test(inbox): cover acknowledgement before prefilter opens

* feat(bin): add Kiro CLI as a crewmate/scout harness adapter (port of #7956) (#7979)

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

Port of #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 <[email protected]>
Co-authored-by: Marsjohn-11 <[email protected]>

* 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 <[email protected]>

---------

Co-authored-by: kiatng <[email protected]>
Co-authored-by: Marsjohn-11 <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
Co-authored-by: Kun Chen <[email protected]>

* fix(bin): publish hold origins only after backend success (#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 #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

* feat(backends): add experimental explicit-only hc (herdr-core) runtime backend (#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

* fix: refresh Herdr upstream references and licensing (#8000)

* 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

* fix(pi): stop repeated numbered and byte excerpt reads (#7992)

Fixes #7990

* fix(bin): keep the PR merge watch working when a worker with a PR is relaunched (#7996)

* Preserve PR poll authentication on relaunch

* no-mistakes(review): Keep trace and polytoken meta ahead of PR lines

* test: pin lock staleness in malformed presentation lock wake-queue case (#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 <[email protected]>

* feat(bin): add configurable self-update source for /updatefirstmate (#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

* fix: bound watcher auto-arm failures and recover interrupted locks (#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

* fix(bin): cut stat forks in the wake drain by reading identity and size together (#6271)

Local cherry-pick of https://github.com/kunchenguid/firstmate/pull/6271 pending upstream merge.

* fix(bin): keep pr= merge-poll identity last when recording captain-hold completion (#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 dbcb5abb 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 #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

* fix: explain how to recover missing worktree identity (#8027)

Last-resort port of #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 <[email protected]>
Co-authored-by: thelad-dev <[email protected]>
Co-authored-by: Kun Chen <[email protected]>

* fix: prevent watcher startup interruptions from cascading stale locks (#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

* fix(bin): allow cd to the home itself and add --help to fm-pr-merge.sh (#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 https://github.com/kunchenguid/firstmate/issues/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

* feat(pi): surface opted-in model-stream silence for Pi workers (#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

* feat(dispatch): bind a profile to an explicit quota_scope row (#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 (#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 #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

* fix(herdr): read pane foreground processes in one jq pass (#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.

* fix(bin): refuse captain-hold release while the away record exists (#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

* fix: harden herdr-core compatibility and message submission (#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

* Fix host mirror deduplication before text capping (#7914)

* test: clear inherited launcher environment in shared fixtures (#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 o…
domenicodigangi added a commit to domenicodigangi/firstmate that referenced this pull request Nov 12, 2026
* fix(bin): publish lock pids atomically and outlast an unpublished pid

A watcher killed inside its lock-pid write left a linked lock whose pid
stayed empty. Contenders defer to that residue for a whole freshness
window, and the dying watcher's bounded cleanup wait equals that window,
so it could not publish .watcher-down and the next drain had nothing to
acknowledge (fm-watch-wedge-cap "priming ack failed" on main).

Port the lock hunks of upstream kunchenguid#8018: fm_lock_claim and the bounded-wait
handoff publish the pid through a same-directory tmp file and rename,
fm_lock_clean_known_files sweeps leftover tmp files, and
fm_lock_acquire_wait_max allows one extra freshness window only while the
blocker's pid is unpublished. A published pid keeps the original bound.

Adds the upstream regression to tests/fm-watcher-lock.test.sh (fails
before, passes after) and narrows the injected mv failures in
fm-x-mode and fm-pr-check-security to their intended destinations so the
pid rename is not caught by them.

* test: fix the flaky and toolchain-dependent tests behind red CI

- fm-calm-pi-extension: seed pendingBashComponents on the fixture host,
  which Pi 1.5 iterates in updatePendingMessagesDisplay.
- tests/lib.sh fm_node_ts_gate: skip, with the reason, sections that load
  .ts modules on a node that cannot (Node <22.18); fails under CI=true so
  CI coverage is unchanged. Used by fm-calm-pi-extension and
  fm-spawn-dispatch-profile.
- fm-bearings-snapshot: prove concurrent local reads by observing two
  reads in flight instead of comparing wall-clock times.
- fm-extension-binding: wait for the recorded runner process groups
  (upstream kunchenguid#8210).
- fm-remote-reply: stop the listener between fixtures and restart a dead
  reply owner while awaiting a reply (upstream kunchenguid#8018, kunchenguid#7212).
- fm-remote-secondmate-lifecycle-e2e: barrier waits honor the
  convergence budget (upstream kunchenguid#8018).
- fm-watch-arm: retire removed fixture paths atomically (upstream kunchenguid#8018),
  and strip the inherited epoch outside the date-shim heredoc, which
  bash before 5.2 does not decode.
- fm-control-relaunch: wait for relaunch markers while the relaunch
  process lives instead of fixed 2-5s polls.
- fm-busy-adapter-wiring: give surfacing stall checkpoints a 30s bound;
  quiet checks keep their short bound.

* no-mistakes(document): document node .ts test gate in CONTRIBUTING

* no-mistakes(ci): I ported the two upstream commits you asked for, kunchenguid/firstmate 8b1618a (kunchenguid#8191) and 470757e (kunchenguid#8265), and nothing else. Both patches applied cleanly in order with `git apply`; the only differences from upstream were line offsets. `bash tests/fm-procevent.test.sh` passed in full: all 147 tests are ok, exit code 0, in about 11 minutes. That includes the new regressions from both commits: - **kunchenguid#8191:** reconcile and ensure-listening refresh the lease at detached launch and still stop after it expires; inherited runner callers cannot renew owner presence. - **kunchenguid#8265:** confirming a launch leaves the source lock free until a claim exists. The extension-binding orphan-readiness section is left for CI to verify, as you instructed. What changed: - `bin/fm-procevent.sh`: `detach_runner` now calls `owner_lease_refresh` before `isolate_runner detach` (kunchenguid#8191). A new `claim_recorded` helper means `confirm_launched_runners` and `generation_is_listening` only try the source lock once a claim file exists (kunchenguid#8265). This stops the confirmation loop from starving the runner's claim under load, which is the orphan-readiness failure in serial shard 4. - `tests/fm-procevent.test.sh`: added the upstream regressions from both commits. - `docs/configuration.md` and `docs/verification/process-event-sources.md`: added the upstream lines. I did not edit `tests/fm-extension-binding.test.sh`, skip or remove any required section, retry CI, or add attribution lines. I also deleted the untracked `tests/_dbg-eb.test.sh`. The timed-out earlier agent left it behind: it was a copy of `fm-extension-binding.test.sh` with three DBG echo lines added. Its `.test.sh` name could have pulled it into the test suite
joergoss pushed a commit to joergoss/firstmate that referenced this pull request Nov 23, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pi workers: a model stream that stalls mid-response reads as a normal busy turn for about an hour

2 participants