Skip to content

feat(bin): support zcode as a primary session harness - #7

Merged
d-ploutarchos merged 5 commits into
mainfrom
zcode-primary-session
Sep 15, 2026
Merged

d-ploutarchos merged 5 commits into
mainfrom
zcode-primary-session

Conversation

@d-ploutarchos

Copy link
Copy Markdown

What Changed

  • Recognize zcode as a primary session harness: FM_HARNESS_RE now anchors the zcode and zcode-cli process names (but not the per-call zcode-node-repl MCP kernel), bin/fm-supervision-instructions.sh emits zcode wake and repair lines from a new docs/supervision-protocols/zcode.md background-notify protocol, and bin/fm-spawn.sh no longer lists zcode among the crewmate/scout-only harnesses (a zcode --secondmate is still refused, with its own message, until a secondmate live pass exists).
  • Extract the structural zcode process-identity rule into a new bin/fm-zcode-lib.sh, sourced by the pane-liveness classifier, the session-lock ancestry walk, and bin/fm-harness.sh; own-harness detection now uses that argv rule instead of a *zcode* substring glob, so unrelated node command lines that merely mention zcode never match.
  • Add unit and e2e session-lock tests for zcode ancestry (engine and node-launcher shapes, MCP kernel and zcodegraph decoys, real fm-lock.sh acquisition/refusal), a supervision-instructions zcode case, an opt-in tests/fm-zcode-primary-live-e2e.test.sh registered in the live family, and update the harness-adapter skill, README, and docs inventories to record zcode's primary role.

Risk Assessment

✅ Low: The fix round is four one-line edits that each verifiably resolve their prior finding (the skill index now matches AGENTS.md, README, docs/configuration.md, fm-spawn.sh's secondmate refusal, and the adapter reference; the new opt-in live guard is enumerated in the live-harness-optin family so its fm_live_gate skip is covered; the tmux comment and the live test both point at bin/fm-zcode-lib.sh, which is self-contained and safe to source alone), and the underlying change remains an anchored, structurally-bounded identity extension whose lock, detection, and classifier paths are exercised by behavioral fixtures rather than source greps.

Testing

Drove the change against the real installed zcode harness: the opt-in live guard passed, and a second real zcode session ran a base-vs-target probe from its own tool shell showing the base commit refusing the fleet lock while the target acquires it naming the zcode-cli engine pid and verifies it live. Real orphaned process trees confirmed the kernel, decoy, launcher, unrelated-node, and stale-holder boundaries against the real fm-lock.sh and fm-harness.sh. The supervision renderer emits the zcode primary protocol, and the test runner now schedules the new guard in the live-harness-optin family. The lock-ancestry, supervision-instructions, and zcode-harness unit suites all pass, but the secondmate refusal and the ancestry suite coverage were only exercised through those suites (fake tmux backend and fixtures), so they are recorded as untested rather than live passes. The harness-adapters SKILL.md prose fix has no runtime surface and is left untested. Every scenario driven live passed. Overall result: go.

  • Live validation: ✅ go - 8 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Inside a real zcode session, fm-harness.sh reports zcode as the own harness ✅ pass live zcode-live-session-probe.txt: ancestry shows bash → zcode-cli → node /usr/local/bin/zcode; target fm-harness.sh: zcode
Inside a real zcode session, fm-lock.sh acquires the fleet lock naming the zcode-cli engine pid and status verifies it live (base commit refused, reproducing the read-only failure) ✅ pass live zcode-live-session-probe.txt: base error: cannot locate harness process in ancestry rc=1; target lock acquired: harness pid 3278010 rc=0; lock: held by live harness pid 3278010; holder comm=zcod…
Opt-in live guard FM_ZCODE_PRIMARY_LIVE=1 tests/fm-zcode-primary-live-e2e.test.sh passes against the installed zcode ✅ pass live zcode-primary-live-e2e.log: ok line, exit=0
A tool shell under a zcode-node-repl MCP kernel resolves the zcode-cli engine above it as lock owner, never the kernel, and the same tree is refused by the base commit ✅ pass live real-process-lock-scenarios.txt cases 1 and 2: target lock acquired: harness pid <zcode-cli pid> with kernel pid skipped; base cannot locate harness process in ancestry (harness-named stages are b…
Adversarial: a lone zcode-node-repl kernel, a zcodegraph decoy, and an unrelated node script mentioning zcode in later args are all refused the lock ✅ pass live real-process-lock-scenarios.txt cases 3, 4, 6: rc=1, lock: free, no lock file; fm-harness.sh prints unknown for the decoy and unrelated node cases
The node launcher shape (node <...>/zcode-app-cli/bin/zcode) is claimed as harness identity for detection and lock, and a lock whose engine exited reads stale ✅ pass live real-process-lock-scenarios.txt case 5: fm-harness.sh → zcode, lock acquired: harness pid &lt;node pid&gt;, status live; case 7: lock: stale (pid 3314851 dead or not a harness)
fm-supervision-instructions.sh renders the zcode primary background-notify protocol and its repair line ✅ pass live supervision-instructions-zcode.txt: primary harness: zcode, Mode: Zcode background-notify supervision., ordinary-wake and repair lines naming the zcode Bash tool background task
fm-test-run.sh schedules the new live guard in the live-harness-optin family instead of the serial unclassified residual ✅ pass live test-run-family-classification.txt: target lists tests/fm-zcode-primary-live-e2e.test.sh under live-harness-optin and not under unclassified; the base runner listed it under unclassified
A zcode secondmate spawn is refused with the not-yet-verified-secondmate message ⏸️ untested no Only exercised through tests/fm-zcode-harness.test.sh, which runs bin/fm-spawn.sh behind the suite's fake tmux backend rather than a real tmux-spawned zcode secondmate, so no live result was establish…
Session-lock ancestry suite covers the zcode engine, launcher, kernel, and decoy shapes plus real lock acquisition and refusal fixtures ⏸️ untested no This is a unit-suite run of tests/fm-session-lock-ancestry.test.sh against fixtures, not a drive of the running product, so no live result was established. The equivalent behaviors were driven live in…
harness-adapters SKILL.md index states zcode is verified for the primary session and points at the 2026-09-15 pass ⏸️ untested no Documentation prose read by the supervisor model has no runtime surface to drive; the machine-rendered counterpart (docs/supervision-protocols/zcode.md) was driven live through fm-supervision-instruct…
Evidence: Real zcode session probe: base refuses the lock, target acquires it naming the zcode-cli engine pid

Source: Real zcode session probe: base refuses the lock, target acquires it naming the zcode-cli engine pid

=== probe.out (written by the probe from inside the zcode tool shell) ===
== ancestry of the zcode tool shell (pid ppid comm args) ==
3280498 3280496 bash            bash /tmp/fm-zcode-manual.OvFwZo/probe.sh
3280496 3278010 bash            /usr/bin/bash -c . '/tmp/fm-zcode-manual.OvFwZo/home/.zcode/cli/exec/shell-snapshots/snapshot-bash-1789471524493-idfsb
3278010 3277998 zcode-cli       zcode-cli
3277998 3277980 node            node /usr/local/bin/zcode --mode yolo --cwd /tmp/fm-zcode-manual.OvFwZo/workspace --prompt Run this one exact shell co
3277980 3277979 bash            -bash
3277979 2439782 tmux: server    tmux -L fm-zcode-manual-3277969 new-session -d -s zp -n zcode -x 200 -y 60 -c /tmp/fm-zcode-manual.OvFwZo/workspace
2439782       1 systemd         /usr/lib/systemd/systemd --user
== own-harness detection ==
target fm-harness.sh: zcode
base   fm-harness.sh: zcode
== fleet lock, BASE commit 78ab09414421fb64b631fbf92e5ba5a6f612ae93 ==
error: cannot locate harness process in ancestry
rc=1
== fleet lock, TARGET commit ==
lock acquired: harness pid 3278010
rc=0
== lock status, TARGET ==
lock: held by live harness pid 3278010
== lock status read by BASE lib on the same lock file ==
lock: stale (pid 3278010 dead or not a harness)
== recorded holder: pid 3278010 comm=zcode-cli ==
=== lab lock files ===
target lock: 3278010
base lock:   <absent>
Evidence: tmux pane transcript of the real zcode session answering the probe

Source: tmux pane transcript of the real zcode session answering the probe

HOME="/tmp/fm-zcode-manual.OvFwZo/home" zcode --mode yolo --cwd '/tmp/fm-zcode-manual.OvFwZo/workspace' --prompt 'Run this one exact shell command and reply with only its exact output, nothing else: b
ash /tmp/fm-zcode-manual.OvFwZo/probe.sh 2>&1 | tee /tmp/fm-zcode-manual.OvFwZo/probe.out'
root@vultr:/tmp/fm-zcode-manual.OvFwZo/workspace# HOME="/tmp/fm-zcode-manual.OvFwZo/home" zcode --mode yolo --cwd '/tmp/fm-zcode-manual.OvFwZo/workspace' --prompt 'Run this one exact shell command and
 reply with only its exact output, nothing else: bash /tmp/fm-zcode-manual.OvFwZo/probe.sh 2>&1 | tee /tmp/fm-zcode-manual.OvFwZo/probe.out'
`` `
== ancestry of the zcode tool shell (pid ppid comm args) ==
3280498 3280496 bash            bash /tmp/fm-zcode-manual.OvFwZo/probe.sh
3280496 3278010 bash            /usr/bin/bash -c . '/tmp/fm-zcode-manual.OvFwZo/home/.zcode/cli/exec/shell-snapshots/snapshot-bash-1789471524493-idfsb
3278010 3277998 zcode-cli       zcode-cli
3277998 3277980 node            node /usr/local/bin/zcode --mode yolo --cwd /tmp/fm-zcode-manual.OvFwZo/workspace --prompt Run this one exact shell co
3277980 3277979 bash            -bash
3277979 2439782 tmux: server    tmux -L fm-zcode-manual-3277969 new-session -d -s zp -n zcode -x 200 -y 60 -c /tmp/fm-zcode-manual.OvFwZo/workspace
2439782       1 systemd         /usr/lib/systemd/systemd --user
== own-harness detection ==
target fm-harness.sh: zcode
base   fm-harness.sh: zcode
== fleet lock, BASE commit 78ab09414421fb64b631fbf92e5ba5a6f612ae93 ==
error: cannot locate harness process in ancestry
rc=1
== fleet lock, TARGET commit ==
lock acquired: harness pid 3278010
rc=0
== lock status, TARGET ==
lock: held by live harness pid 3278010
== lock status read by BASE lib on the same lock file ==
lock: stale (pid 3278010 dead or not a harness)
== recorded holder: pid 3278010 comm=zcode-cli ==
`` `
root@vultr:/tmp/fm-zcode-manual.OvFwZo/workspace#
Evidence: Opt-in live guard tests/fm-zcode-primary-live-e2e.test.sh result

Source: Opt-in live guard tests/fm-zcode-primary-live-e2e.test.sh result

ok - a real zcode session detects itself, acquires the fleet lock naming its engine pid, and verifies the holder live exit=0

ok - a real zcode session detects itself, acquires the fleet lock naming its engine pid, and verifies the holder live
exit=0
Evidence: Real-process lock boundary drives: engine vs kernel, decoy, node launcher, unrelated node, stale holder

Source: Real-process lock boundary drives: engine vs kernel, decoy, node launcher, unrelated node, stale holder

# Real orphaned process trees driven through bin/fm-harness.sh and bin/fm-lock.sh.
# Claude env markers are cleared and every tree re-parents to pid 1 before probing, so the ancestry walk never reaches this runner's own harness. Harness-named stages are /bin/bash symlinks (comm = link name), the same technique tests/fm-session-lock-ancestry.test.sh uses.

## 1. zcode-cli engine -> zcode-node-repl MCP kernel -> tool shell (TARGET): lock must name the engine, not the kernel
\### case: engine-kernel
-- ancestry (pid ppid comm args) --
3316162 3316161 bash            bash /tmp/fm-zcode-adv.IlVG5Q/tool.sh /tmp/fm-zcode-adv.IlVG5Q/engine-kernel.o
3316161 3314851 zcode-node-repl /tmp/fm-zcode-adv.IlVG5Q/bin/zcode-node-repl -c /tmp/fm-zcode-adv.IlVG5Q/tool.
3314851 2439782 zcode-cli       /tmp/fm-zcode-adv.IlVG5Q/bin/zcode-cli -c . /tmp/fm-zcode-adv.IlVG5Q/orphan-wa
2439782       1 systemd         /usr/lib/systemd/systemd --user
-- fm-harness.sh --
zcode
-- fm-lock.sh --
lock acquired: harness pid 3314851
rc=0
-- fm-lock.sh status --
lock: held by live harness pid 3314851
-- lock file --
3314851
done

## 2. same tree with the BASE commit's bin/ (regression shape: base must refuse)
\### case: engine-kernel-BASE
-- ancestry (pid ppid comm args) --
3317697 3317696 bash            bash /tmp/fm-zcode-adv.IlVG5Q/tool.sh /tmp/fm-zcode-adv.IlVG5Q/engine-kernel-B
3317696 3316354 zcode-node-repl /tmp/fm-zcode-adv.IlVG5Q/bin/zcode-node-repl -c /tmp/fm-zcode-adv.IlVG5Q/tool.
3316354 2439782 zcode-cli       /tmp/fm-zcode-adv.IlVG5Q/bin/zcode-cli -c . /tmp/fm-zcode-adv.IlVG5Q/orphan-wa
2439782       1 systemd         /usr/lib/systemd/systemd --user
-- fm-harness.sh --
zcode
-- fm-lock.sh --
error: cannot locate harness process in ancestry
rc=1
-- fm-lock.sh status --
lock: free
-- lock file --
<absent>
done

## 3. zcode-node-repl kernel only, no engine above: refused (a per-call kernel is not session identity)
\### case: kernel-only
-- ancestry (pid ppid comm args) --
3319188 3317875 bash            bash /tmp/fm-zcode-adv.IlVG5Q/tool.sh /tmp/fm-zcode-adv.IlVG5Q/kernel-only.out
3317875 2439782 zcode-node-repl /tmp/fm-zcode-adv.IlVG5Q/bin/zcode-node-repl -c . /tmp/fm-zcode-adv.IlVG5Q/orp
2439782       1 systemd         /usr/lib/systemd/systemd --user
-- fm-harness.sh --
zcode
-- fm-lock.sh --
error: cannot locate harness process in ancestry
rc=1
-- fm-lock.sh status --
lock: free
-- lock file --
<absent>
done

## 4. decoy named zcodegraph: must never own the lock
\### case: decoy-zcodegraph
-- ancestry (pid ppid comm args) --
3320679 3319349 bash            bash /tmp/fm-zcode-adv.IlVG5Q/tool.sh /tmp/fm-zcode-adv.IlVG5Q/decoy-zcodegrap
3319349 2439782 zcodegraph      /tmp/fm-zcode-adv.IlVG5Q/bin/zcodegraph -c . /tmp/fm-zcode-adv.IlVG5Q/orphan-w
2439782       1 systemd         /usr/lib/systemd/systemd --user
-- fm-harness.sh --
unknown
-- fm-lock.sh --
error: cannot locate harness process in ancestry
rc=1
-- fm-lock.sh status --
lock: free
-- lock file --
<absent>
done

## 5. node launcher shape (node <...>/zcode-app-cli/bin/zcode): claimed structurally
\### case: node-launcher
-- ancestry (pid ppid comm args) --
3322182 3322173 bash            bash /tmp/fm-zcode-adv.IlVG5Q/tool.sh /tmp/fm-zcode-adv.IlVG5Q/node-launcher.o
3322173 3320863 node            node /tmp/fm-zcode-adv.IlVG5Q/node_modules/zcode-app-cli/bin/zcode /tmp/fm-zco
3320863 2439782 bash            bash -c . /tmp/fm-zcode-adv.IlVG5Q/orphan-wait.sh; node /tmp/fm-zcode-adv.IlVG
2439782       1 systemd         /usr/lib/systemd/systemd --user
-- fm-harness.sh --
zcode
-- fm-lock.sh --
lock acquired: harness pid 3322173
rc=0
-- fm-lock.sh status --
lock: held by live harness pid 3322173
-- lock file --
3322173
done

## 6. adversarial: unrelated node script that merely mentions zcode in later arguments is NOT zcode
\### case: node-unrelated-mentions-zcode
-- ancestry (pid ppid comm args) --
3323704 3323695 bash            bash /tmp/fm-zcode-adv.IlVG5Q/tool.sh /tmp/fm-zcode-adv.IlVG5Q/node-unrelated-
3323695 3322375 node            node /tmp/fm-zcode-adv.IlVG5Q/other/app.js /tmp/fm-zcode-adv.IlVG5Q/tool.sh /t
3322375 2439782 bash            bash -c . /tmp/fm-zcode-adv.IlVG5Q/orphan-wait.sh; node /tmp/fm-zcode-adv.IlVG
2439782       1 systemd         /usr/lib/systemd/systemd --user
-- fm-harness.sh --
unknown
-- fm-lock.sh --
error: cannot locate harness process in ancestry
rc=1
-- fm-lock.sh status --
lock: free
-- lock file --
<absent>
done

## 7. stale read: after the engine of case 1 has exited, its recorded lock reads stale
$ FM_HOME=<case-1 home> bin/fm-lock.sh status
lock: stale (pid 3314851 dead or not a harness)
Evidence: Rendered zcode primary supervision instructions and repair line

Source: Rendered zcode primary supervision instructions and repair line

$ bin/fm-supervision-instructions.sh --harness zcode
================================================================================
SUPERVISION OPERATING INSTRUCTIONS - primary harness: zcode
================================================================================
Current state:
- Lock: held by this session; this session owns normal supervision unless away mode says otherwise.
- Away/quiet mode: inactive.
- X mode: inactive; use the default watcher cadence.
- Ordinary wake: re-arm exactly one bin/fm-watch-arm.sh zcode Bash tool background task (run_in_background) as directed below.

Mode: Zcode background-notify supervision.

When this session owns supervision and away mode is not active:
1. Drain first with `bin/fm-wake-drain.sh`.
   After handling all emitted wakes and reconciling open decisions and unread status lines, run the exact `--ack-through` command printed as `WAKE_ACK_REQUIRED`; until then the work remains durable for idempotent re-handling after interruption.
2. Source `~/.no-mistakes/worktrees/7f0ec18181b6/01M2JC4F00B06FDP163BTXT58P/config/x-mode.env` first when Relay is active.
3. First cycle: arm with the Bash tool's tracked background mechanism, as its own call with `run_in_background: true` on:

   `[ -f '~/.no-mistakes/worktrees/7f0ec18181b6/01M2JC4F00B06FDP163BTXT58P/config/x-mode.env' ] && . '~/.no-mistakes/worktrees/7f0ec18181b6/01M2JC4F00B06FDP163BTXT58P/config/x-mode.env'; exec bin/fm-watch-arm.sh`

4. Trust only the arm's one-line status.
5. `watcher: started ...` or `watcher: attached ...` means a live cycle exists.
   On attach, the background task follows verified identity-matched successors instead of exiting when the first cycle ends.
6. Failure or missing cycle only: `watcher: FAILED ...` means supervision is down; fix and re-arm.
7. After a successful start or attach status, end the turn.
   The background arm remains the live wait until it returns an actionable wake or failure.
8. Waiting is silent.
9. Never use shell `&` for firstmate supervision.
10. Never bundle the arm onto another command or run it in the foreground of an ordinary tool call.

Zcode re-invokes the model with a task notification when a background task completes, whether the arm exits with a wake reason or a FAILED line, so cycle completion is itself both the wake path and the failure path.
When you see a background-task-completed notification for the arm:
1. Run `bin/fm-wake-drain.sh` first.
2. Read the arm task's output for the reason line.
3. Handle `signal`, `stale`, `check`, or `heartbeat` using the harness-neutral contract in `AGENTS.md`.
4. Ordinary wake: re-arm the next cycle with the same background `bin/fm-watch-arm.sh` call if the home still needs supervision, as `bin/fm-supervision-lib.sh` defines it.
5. Do not invent a wake from an attach-status line alone.
   Drain the queue and act only on real wake records, the drain's `OPEN DECISIONS` and `UNREAD STATUS` entries, or a real watcher reason line.
   Re-arm attaches to an existing healthy cycle when one is already present and follows its verified successor chain.
   See [`watcher-continuity.md`](../watcher-continuity.md) for the arm-layer successor and clean-close failure contract.

Zcode has no turn-end guard backstop yet: the arm task's completion notification is the only cycle-end signal, so a healthy background arm must exist before every turn ends.
The crew-side Stop hook pair (`bin/fm-zcode-turnend-hook.sh`) is task-scoped and never arms primary supervision.

Interactive TUI primary sessions are the supported supervision host.
Headless `zcode --prompt` is the one-shot crewmate launch shape and cannot host the primary's supervision cycle.
Verified live on zcode-app-cli 3.11.2-24 wrapping zcode-runtime 0.16.5: the TUI Bash tool's background tasks survive the tool call and re-invoke the model on completion (observed in the live TUI primary session, 2026-09-15), and a session acquires the fleet lock through the `zcode-cli` engine in its own ancestry (`tests/fm-zcode-primary-live-e2e.test.sh`, opt-in, refreshes the lock and detection facts against the installed harness on demand).


$ bin/fm-supervision-instructions.sh --harness zcode --repair-line
repair missing watcher supervision with bin/fm-watch-arm.sh as its own zcode Bash tool background task (run_in_background), never shell &.
exit=0
Evidence: Test-runner family classification of the new live guard (target vs base)

Source: Test-runner family classification of the new live guard (target vs base)

$ bin/fm-test-run.sh --list --family live-harness-optin | grep zcode tests/fm-zcode-primary-live-e2e.test.sh tests/fm-zcode-signals-live-e2e.test.sh $ bin/fm-test-run.sh --list --family unclassified | grep zcode (no zcode test in unclassified) # base commit runner: $ bash <base fm-test-run.sh> --list --family unclassified | grep zcode tests/fm-zcode-primary-live-e2e.test.sh

$ bin/fm-test-run.sh --list --family live-harness-optin | grep zcode
tests/fm-zcode-primary-live-e2e.test.sh
tests/fm-zcode-signals-live-e2e.test.sh

$ bin/fm-test-run.sh --list --family unclassified | grep zcode
(no zcode test in unclassified)

# base commit for comparison:
$ git show 78ab094:bin/fm-test-run.sh > /tmp/fm-test-run-base.sh; bash /tmp/fm-test-run-base.sh --list --family unclassified | grep zcode
tests/fm-zcode-primary-live-e2e.test.sh
Evidence: Lock-ancestry and supervision-instructions suites

Source: Lock-ancestry and supervision-instructions suites

== tests/fm-session-lock-ancestry.test.sh ==
ok - session-lock: a version-named Claude Code session is identified from its install path and argv[0]
ok - session-lock: a harness that is pid 1 of its own namespace is examined, not skipped
ok - session-lock: ordinary script paths under a harness directory are not harness processes
ok - session-lock: ownership stops at the first non-harness gap above the contiguous run
ok - session-lock: a live version-named session holding the lock is not mistaken for a stale owner
ok - session-lock: zcode resolves its engine in both shapes and never the MCP kernel or a fragment decoy
ok - session-lock e2e: a version-named session claims the home and arms supervision
ok - session-lock e2e: a session parented by a harness-named daemon claims the home and arms supervision
ok - session-lock e2e: a version-named session under a harness-named daemon keeps its own lock
ok - session-lock e2e: a zcode-named session acquires the fleet lock as its own harness pid
ok - session-lock e2e: a plain bash session with no harness ancestry is refused the lock
exit=0
== tests/fm-supervision-instructions.test.sh ==
ok - renderer prints exactly the selected harness block
ok - renderer falls back to unknown.md for unverified harness names
ok - renderer includes read-only, afk, and effective x-mode current-state stanzas
ok - renderer's away/quiet stanzas are mode-aware, default to away, and fall back safely on garbage input
ok - renderer repair-line mode is harness-aware and honors conditional state
ok - renderer preserves every harness ordinary-continuation and missing-cycle repair path
ok - pi-signed keeps its identity while sharing Pi's supervision protocol
ok - grok supervision is Claude-shaped background notify with passive Stop-hook backstop
ok - zcode supervision is grok-shaped background notify through the Bash tool's tracked background tasks
ok - grok rendered command sources the effective x-mode config
ok - pi supervision snippet renders the effective extension path
exit=0
Evidence: zcode harness suite including the secondmate refusal

Source: zcode harness suite including the secondmate refusal

ok - fm-harness: ancestry detects the wrapper and kernel comm names, not ps artifacts
ok - fm-harness: ancestry rejects unrelated zcode mentions and claims a bare node only via its zcode path
ok - fm-harness: FM_ZCODE_HARNESS is a precedence override that needs real zcode ancestry
ok - fm-agent-process-lib: every zcode surface classifies agent; unrelated node and fragment decoys stay out
ok - fm-control-lib: zcode control is signal-shaped - C-c interrupt and signal exit, no composer
ok - fm-busy-lib: zcode classifies busy only through FM_BUSY_ZCODE_REGEX and never falls to idle
ok - zcode hook install is idempotent and removal restores the pre-install config exactly
ok - zcode hook removal restores the vendor-default, enabled-true, and enabled-absent shapes exactly
ok - zcode hook install refuses missing, malformed, symlinked, and surprising config without writing
ok - zcode hook install refuses without jq before any config write
ok - fm-spawn: the zcode launch pins headless yolo, records the axes, and never passes model/effort/resume flags
ok - fm-spawn: --zcode-tui launches bare, delivers the brief pointer, and proves it through the hook record
ok - fm-spawn: a pre-interactivity swallow is recovered by the verify-and-retry delivery
ok - fm-spawn: --zcode-tui is refused on a non-zcode harness
ok - fm-spawn: --zcode-tui cannot override a relaunch, whose variant comes from the record
ok - fm-spawn: a relaunch reuses the recorded zcode launch variant in both directions
ok - fm-spawn: zcode installs its hook, arms the busy record, and binds the token
ok - zcode hook opens, closes, and records only through the firstmate token
ok - fm-spawn: an unsafe zcode global config refuses the spawn
ok - fm-spawn: a missing zcode bin refuses the spawn naming the zcode-app-cli package
ok - zcode is refused as a secondmate because secondmate launches are not verified for it
ok - fm-teardown: zcode pointer, registry token, and session sidecar are removed
all fm-zcode-harness tests passed
exit=0

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 5 issues found → auto-fixed ✅
  • ⚠️ .agents/skills/harness-adapters/SKILL.md:38 - The harness-adapters skill index still states that zcode is verified only for crewmate and scout work and never a primary, and cites only the 2026-09-14 pass. AGENTS.md instructs the supervisor to load this skill before every spawn, recovery, and adapter verification, so a firstmate on zcode would read a rule that contradicts AGENTS.md, README.md, docs/configuration.md, and the updated adapter reference in the same change. Fix: move zcode out of the crewmate/scout-only sentence on line 38 and update line 39 to name the 2026-09-15 primary pass and docs/supervision-protocols/zcode.md.
  • ⚠️ bin/fm-test-run.sh:349 - The new opt-in live guard tests/fm-zcode-primary-live-e2e.test.sh is not enumerated in the live-harness family list in bin/fm-test-run.sh, unlike its sibling fm-zcode-signals-live-e2e.test.sh and every other *-primary-live-e2e guard. It therefore lands in the serial unclassified residual, where its fm_live_gate opt-in skip is not covered by the family's live-capability expected-gate-skip class. Fix: add the basename to the live family alternation next to fm-zcode-signals-live-e2e.test.sh.
  • ⚠️ bin/fm-session-lock-lib.sh:32 - Simplification: the ^zcode$ token added to FM_HARNESS_RE accepts a process whose comm is the bare word zcode. No such process exists in the verified tree: the wrapper is a node script (comm node) and the runtime child renames itself zcode-cli, which is the shape the live pass, the unit fixture, and the e2e fixture all rely on. The intent (a firstmate inside the zcode TUI acquires and verifies the fleet lock) is satisfied by ^zcode-cli$ alone. Recommend removing the ^zcode$ alternative.
  • ⚠️ bin/fm-session-lock-lib.sh:96 - Simplification: the new fm_zcode_args_are_zcode call inside fm_harness_process_matches claims a bare node /path/to/zcode launcher as lock-owning harness identity. In the real tree the tool shell is parented by the zcode-cli engine, so the ancestry walk matches the engine first and stops before ever reaching the wrapper, and a lock never names the wrapper pid for fm_harness_pid_alive to check. This path is exercised only by the synthetic launcher shape in the unit test, which models an engine that does not rename itself. No stated requirement needs it; recommend removing the branch and the launcher fixture shape.
  • ℹ️ bin/backends/tmux.sh:339 - The comment says fm_zcode_args_are_zcode lives in bin/fm-agent-process-lib.sh, but this change moved it to bin/fm-zcode-lib.sh (the tmux backend still gets it transitively). The new live test at tests/fm-zcode-primary-live-e2e.test.sh:116 likewise sources fm-agent-process-lib.sh to reach the function. Point both at bin/fm-zcode-lib.sh so the single-owner claim in the new file's header stays true.

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

✅ **Test** - passed

✅ No issues found.

  • Live validation: ✅ go - 8 of 11 scenarios driven live against the product
Scenario Result Live Evidence
Inside a real zcode session, fm-harness.sh reports zcode as the own harness ✅ pass live zcode-live-session-probe.txt: ancestry shows bash → zcode-cli → node /usr/local/bin/zcode; target fm-harness.sh: zcode
Inside a real zcode session, fm-lock.sh acquires the fleet lock naming the zcode-cli engine pid and status verifies it live (base commit refused, reproducing the read-only failure) ✅ pass live zcode-live-session-probe.txt: base error: cannot locate harness process in ancestry rc=1; target lock acquired: harness pid 3278010 rc=0; lock: held by live harness pid 3278010; holder comm=zcod…
Opt-in live guard FM_ZCODE_PRIMARY_LIVE=1 tests/fm-zcode-primary-live-e2e.test.sh passes against the installed zcode ✅ pass live zcode-primary-live-e2e.log: ok line, exit=0
A tool shell under a zcode-node-repl MCP kernel resolves the zcode-cli engine above it as lock owner, never the kernel, and the same tree is refused by the base commit ✅ pass live real-process-lock-scenarios.txt cases 1 and 2: target lock acquired: harness pid &lt;zcode-cli pid&gt; with kernel pid skipped; base cannot locate harness process in ancestry (harness-named stages are b…
Adversarial: a lone zcode-node-repl kernel, a zcodegraph decoy, and an unrelated node script mentioning zcode in later args are all refused the lock ✅ pass live real-process-lock-scenarios.txt cases 3, 4, 6: rc=1, lock: free, no lock file; fm-harness.sh prints unknown for the decoy and unrelated node cases
The node launcher shape (node <...>/zcode-app-cli/bin/zcode) is claimed as harness identity for detection and lock, and a lock whose engine exited reads stale ✅ pass live real-process-lock-scenarios.txt case 5: fm-harness.sh → zcode, lock acquired: harness pid &lt;node pid&gt;, status live; case 7: lock: stale (pid 3314851 dead or not a harness)
fm-supervision-instructions.sh renders the zcode primary background-notify protocol and its repair line ✅ pass live supervision-instructions-zcode.txt: primary harness: zcode, Mode: Zcode background-notify supervision., ordinary-wake and repair lines naming the zcode Bash tool background task
fm-test-run.sh schedules the new live guard in the live-harness-optin family instead of the serial unclassified residual ✅ pass live test-run-family-classification.txt: target lists tests/fm-zcode-primary-live-e2e.test.sh under live-harness-optin and not under unclassified; the base runner listed it under unclassified
A zcode secondmate spawn is refused with the not-yet-verified-secondmate message ⏸️ untested no Only exercised through tests/fm-zcode-harness.test.sh, which runs bin/fm-spawn.sh behind the suite's fake tmux backend rather than a real tmux-spawned zcode secondmate, so no live result was establish…
Session-lock ancestry suite covers the zcode engine, launcher, kernel, and decoy shapes plus real lock acquisition and refusal fixtures ⏸️ untested no This is a unit-suite run of tests/fm-session-lock-ancestry.test.sh against fixtures, not a drive of the running product, so no live result was established. The equivalent behaviors were driven live in…
harness-adapters SKILL.md index states zcode is verified for the primary session and points at the 2026-09-15 pass ⏸️ untested no Documentation prose read by the supervisor model has no runtime surface to drive; the machine-rendered counterpart (docs/supervision-protocols/zcode.md) was driven live through fm-supervision-instruct…
  • FM_ZCODE_PRIMARY_LIVE=1 bash tests/fm-zcode-primary-live-e2e.test.sh (real zcode one-shot session in tmux, real model turn)
  • Manual live drive: real zcode --mode yolo --prompt session in tmux running a probe from its own tool shell that prints its ancestry, then runs target bin/fm-harness.sh, base-commit fm-harness.sh, base-commit fm-lock.sh, target bin/fm-lock.sh, bin/fm-lock.sh status, and base-lib fm-lock.sh status on the target's lock
  • Real orphaned process trees through bin/fm-lock.sh, bin/fm-lock.sh status, and bin/fm-harness.sh: zcode-cli engine → zcode-node-repl kernel → tool shell (target and base bin/), zcode-node-repl kernel only, zcodegraph decoy, node &lt;...&gt;/zcode-app-cli/bin/zcode launcher, unrelated node app.js ... --tag zcode /usr/local/bin/zcode, and stale read after the engine exits
  • bin/fm-supervision-instructions.sh --harness zcode and --harness zcode --repair-line
  • bin/fm-test-run.sh --list --family live-harness-optin and --list --family unclassified on target vs. base-commit runner
  • bash tests/fm-session-lock-ancestry.test.sh
  • bash tests/fm-supervision-instructions.test.sh
  • bash tests/fm-zcode-harness.test.sh (includes test_zcode_is_refused_as_a_secondmate)
🔧 **Document** - 2 issues found → auto-fixed (2) ✅
  • ℹ️ docs/architecture.md:257 - Two harness inventories predate this change and still omit zcode: docs/architecture.md line 257 lists the adapters spawn launch stays compatible with (claude ... omp, and agy) without zcode, and docs/tmux-backend.md line 51 lists the pane-liveness classifier identities without zcode even though bin/fm-agent-process-lib.sh classifies zcode/zcode-cli/zcode-node-repl as agent. Both were stale before this branch (zcode became a crewmate adapter earlier), so they were left untouched under scope discipline; a one-word addition to each is the follow-up.
  • ℹ️ bin/fm-test-run.sh:1363 - bin/fm-test-run.sh's changed-file family mapping has an explicit entry for bin/fm-agent-process-lib.sh (backend-dispatch, real-herdr-gated, pure-contract-unit) but none for the new bin/fm-zcode-lib.sh, which that classifier, bin/fm-session-lock-lib.sh, and bin/fm-harness.sh now all source. This is executable test-selection behavior rather than documentation, so it was not changed here; decide whether the new lib should map to the same families so a change to it selects the tmux, herdr, and session-lock suites.

🔧 Fix applied.
2 infos still open:

  • ℹ️ bin/fm-test-run.sh:1363 - No explicit family entry is needed for bin/fm-zcode-lib.sh. Verified with a temporary probe commit (removed afterwards): a change to only that file already selects tests/fm-tmux-agent-liveness.test.sh, tests/fm-backend-herdr.test.sh, tests/fm-session-lock-ancestry.test.sh, tests/fm-zcode-harness.test.sh, tests/fm-cursor-primary.test.sh, tests/fm-claude-stop-autoarm.test.sh, tests/fm-turnend-guard.test.sh, and both zcode live guards (137 scripts total) through families_for_unmapped_bin, which scans test references and the lib's consumers (fm-agent-process-lib.sh, fm-session-lock-lib.sh, fm-harness.sh). Since this is executable test-selection behavior and the fallback already covers the requested suites, the runner was left unchanged.
  • ℹ️ docs/tmux-backend.md:51 - The pane-liveness identity sentence I extended with Zcode still omits Gemini and omp, both of which bin/fm-agent-process-lib.sh classifies as agent (omp anchored by name, Gemini through bin/fm-gemini-lib.sh's node-launcher rule). Both omissions predate this branch and are unrelated to zcode, so I applied only the selected one-word zcode fix; adding the two names is a trivial follow-up.

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

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Promotes zcode from a crewmate/scout-only adapter to a verified primary
session harness: a firstmate running inside the zcode TUI can now acquire
and verify the per-home fleet lock, and session start renders a named
supervision protocol instead of the unknown-harness fallback.

- bin/fm-zcode-lib.sh is new and owns zcode's structural process identity
  (fm_zcode_path_is_zcode, fm_zcode_args_are_zcode), moved verbatim from
  bin/fm-agent-process-lib.sh so the pane-liveness classifier, the
  session-lock ancestry walk, and the own-harness detector read one rule.
- bin/fm-session-lock-lib.sh adds the anchored ^zcode$|^zcode-cli$ tokens
  to FM_HARNESS_RE (the per-call zcode-node-repl MCP kernel stays excluded
  because it is not a session-lifetime process) and claims a wrapper that
  presents as `node /path/to/zcode` through the structural argv rule.
- bin/fm-harness.sh replaces its loose *zcode* args glob with the same
  structural rule, so an unrelated node command line that merely mentions
  zcode never claims the identity.
- bin/fm-supervision-instructions.sh renders the new zcode protocol,
  docs/supervision-protocols/zcode.md: the grok-shaped background-notify
  cycle where one Bash-tool background task (run_in_background) arms
  bin/fm-watch-arm.sh and the harness task notification is both the wake
  and the failure path; the interactive TUI is the supported host.
- bin/fm-spawn.sh keeps refusing a zcode secondmate with its own honest
  reason (secondmate launches have no dated live pass), distinct from the
  muse/gemini/agy no-primary-protocol refusal it previously shared.
- AGENTS.md, README.md, docs/configuration.md, the audiences inventory,
  and the harness-adapters zcode reference move zcode into the verified
  primary set with dated live-pass records.
- tests pin both layers: portable unit and end-to-end cases in
  fm-session-lock-ancestry.test.sh (engine and launcher shapes, MCP-kernel
  and fragment-decoy exclusions, real lock acquisition and refusal trees),
  renderer coverage in fm-supervision-instructions.test.sh, and a new
  opt-in live guard fm-zcode-primary-live-e2e.test.sh that proves inside a
  real zcode session (zcode-app-cli 3.11.2-24 wrapping zcode-runtime
  0.16.5) that detection resolves zcode and the lock is acquired naming
  the session's own engine pid and verified live.
@d-ploutarchos
d-ploutarchos merged commit 2ee4168 into main Sep 15, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant