Repository navigation
feat(bin): add the Phase A zcode crewmate/scout adapter surface - #2
Merged
Merged
Conversation
Integrate the zcode coding-agent CLI (Linux via the zcode-app-cli wrapper) as a crewmate/scout-class harness, Phase A only: - fm-harness.sh detects zcode by anchored ancestry on the wrapper and runtime process names (zcode, zcode-cli, zcode-c, zco - observed live on zcode-runtime 0.16.5) plus a bare-node args fallback on the zcode bin path; FM_ZCODE_HARNESS=zcode is a Firstmate-owned precedence override that counts only under real zcode ancestry, the omp pattern. - fm-spawn.sh launches the verified headless single-prompt template: --prompt carries the brief, --mode yolo is pinned explicitly, --cwd anchors the run, foreign markers are cleared, and a missing zcode bin refuses the spawn. Model and effort follow the record-and-omit contract because the headless flag set has neither (verified against 0.16.5 --help), and zcode is refused for --secondmate. - fm-busy-lib.sh adds the zcode configured-signature rendered-tail arm: no default busy signature ships because headless -p renders nothing mid-turn (verified over pipe and PTY across streaming text, a thinking block, and a tool-call turn), so FM_BUSY_ZCODE_REGEX is the only path to busy and a non-matching tail is unknown, never idle. - fm-control-lib.sh pins the signal-shaped control mechanics: interrupt is C-c (SIGINT through the pane's foreground process group, verified live to cancel a mid-turn run), no composer clear, no ack source, and no typed exit command - the headless process IS the turn. - fm-crew-state.sh feeds the zcode busy arm through the grok-style pre-captured pane tail. - tests pin detection, control tables, busy scoping, the launch line, record-and-omit axes, no-wiring, bin refusal, and the secondmate refusal, and extend the busy-adapter-wiring, control, and crew-state shared assertions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
zcode harness integration, Phase A (code surface)
Implements the code half of the zcode Phase A plan from
data/zcode-research/report.mdsection 3, against the design contract the merged docs half (PR #1,references/harness/zcode.md) fixed.Scope is
bin/+tests/only; docs surfaces stay with the sibling docs worker.Change-to-plan mapping
FM_ZCODE_HARNESS=zcodemarker entry plus ancestry rule on the zcode binbin/fm-harness.sh: marker block requiring real zcode ancestry (ancestry_names_zcode), anchored comm nameszcode|zcode-cli|zcode-c|zco, and a*zcode*args arm for the bare node launchernode <...>/.bin/zcodelauncher with runtime children at commzcode-c/zco, process titlezcode-cli; pinned bytests/fm-zcode-harness.test.shdetection cases-p/--printtemplate, worker mode pinned, foreign-marker clearing, bin-resolution refusal, crewmate/scout-onlybin/fm-spawn.sh:zcode)template (--mode yolo --cwd <worktree> --prompt <encoded brief>,FM_ZCODE_HARNESS=zcode,ZCODE_DISABLE_UPDATE_CHECK=1, full foreign-marker clear),__ZCODEBIN__resolution refusing when absent,--secondmaterefusal, no busy wiring armedtests/fm-zcode-harness.test.sh;--modedefault and flag set verified against the captured0.16.5 --help--modeland no effort flag (/modelis a TUI slash command only), so both stay in task metadata--model/--effortasserted absent from the launch line whilemodel=/effort=land in meta (tests/fm-zcode-harness.test.sh)bin/fm-busy-lib.sh:zcodearm in the rovo/agy best-effort shape, but with NO default signature -FM_BUSY_ZCODE_REGEXis the only path tobusy, non-match staysunknown, never idletests/fm-zcode-harness.test.shandtests/fm-busy-adapter-wiring.test.shbin/fm-control-lib.sh: interrupt keyC-c(SIGINT through the pane's foreground process group, the host-contract signal path), repeat 1, no clear key, no ack source, and deliberately NO typed exit commandC-ccancels the turn and the process exits to the pane shell; SIGTERM printsError: Turn was cancelled.; pinned intests/fm-zcode-harness.test.shand the family table intests/fm-control.test.shfm_backend_agent_state+ crew-state tail capture (grok precedent)bin/fm-crew-state.sh: zcode joins grok's pre-captured pane-tail feed into the classifier;fm_backend_agent_stateitself needs no zcode entry (it is harness-agnostic and dispatches to the backend classifier - see notes)tests/fm-crew-state.test.shzcode case readsunknown zcode-regexthrough the crew path even on a busy-looking tailtests/fm-zcode-harness.test.sh(9 cases);tests/fm-busy-adapter-wiring.test.sh,tests/fm-control.test.sh,tests/fm-crew-state.test.shextendedKnown gotcha encoded (report section 2)
Headless error paths exit 0: reproduced on 0.16.5 - the request-signing failure exits 0 with a stack trace while the unconfigured path exits 1.
The classification and control surfaces therefore never read exit status; the fact is recorded in the spawn header and the busy-arm comments.
Evidence beyond the scout report (mock-provider probes, key-free)
All probes ran against the real wrapper/runtime (zcode-app-cli 3.11.2-24, zcode-runtime 0.16.5) with a local mock provider, no Z.AI key:
--jsonprints one final JSON object (sessionId, turnId, response, usage, projection.status), not a live event stream.C-cmid-turn cancels and exits silently; SIGTERM cancels and printsError: Turn was cancelled.ZCODE_API_KEYformat isid.secret(one dot), and a workspace.zcode/config.jsonprovider override redirects the provider endpoint.Files intentionally NOT changed (out of the task's file list)
bin/fm-agent-process-lib.shandbin/fm-session-lock-lib.sh: a live zcode pane reports#{pane_current_command}=node(the wrapper is a node launcher), so without a zcode entry in the shared process-name vocabularyfm_backend_agent_statereads a mid-turn zcode pane asambiguous- conservative, neverdead, so it licenses no duplicate launch, but it also never proves liveness. The entry (anchored names plus the zcode bin path component) should land with the live verification gate together with the observed process-name evidence.bin/fm-control.sh:verify_interrupt_running's agent-must-stay-alive postcondition anddo_exit's typed-command path are TUI-shaped. For headless zcode the process IS the turn, so a landed interrupt legitimately ends the process (pane back at shell is the success shape) and mid-turn exit must be signal-shaped rather than a typed command. The interrupt key delivery works today through the existing executor; these two executor refinements should land before firstmate dispatches zcode work.AGENTS.mdsection 4 andREADME.mdverified-list lines: docs surfaces belong to the sibling docs worker; zcode correctly stays out of the dispatchable list until the live verification gate passes.Local gates
bin/fm-lint.sh(pinned ShellCheck 0.11.0, changed-file mode) andbin/fm-lint-workflows.sh(actionlint 1.7.12): clean.tests/fm-zcode-harness.test.sh,tests/fm-busy-adapter-wiring.test.sh,tests/fm-control.test.sh,tests/fm-crew-state.test.sh: all pass.bin/fm-test-run.sh --check-coveragereports the same sort-order complaint on clean main as on this branch (pre-existing).