Repository navigation
feat: Add Kiro CLI crewmate harness with V3 engine default - #8
Merged
Merged
Conversation
Claude-shaped kiro-cli adapter (V2 engine only; v3/KAS out of scope, unsupported on Amazon Linux 2). Ancestry detection on the anchored process name kiro-cli in fm-harness.sh and liveness naming in fm-agent-process-lib.sh; launch template in fm-spawn.sh carries the brief positionally on --agent-engine v2 with --agent, --trust-all-tools, model, and full low|medium|high|xhigh|max effort, plus reachable-catalog model validation. Turn-end and busy hooks (userPromptSubmit opens, stop closes and keeps the turn-ended touch) live in a firstmate-owned per-task agent config written under state/<id>.kiro-home/agents/firstmate.json and reached by relocating KIRO_HOME, never the worktree's own .kiro/ (--agent is name-only, so a config path is rejected); the same per-task home seeds chat.disableTrustAllConfirmation to suppress the --trust-all-tools modal, while auth in the XDG data dir is untouched. Two independent busy signals: the kiro-hook record (primary) and the rendered Kiro is working footer (fm-busy-lib.sh / fm-composer-lib.sh). Control mechanics in fm-control-lib.sh (Escape interrupt, /quit exit, crewmate/scout-only refusal, out-of-tree wiring retirement); teardown removes the per-task home. Router entry and references/harness/kiro.md, dated docs/verification/kiro.md, portable regression plus opt-in live drift guard. Verified live on kiro-cli 2.21.4 (V2): per-turn userPromptSubmit and stop hooks, busy footer, single-Escape cancel, and /quit exit with its resume-id line.
…fail" This reverts commit 7092df1681802c2357f697d3194bbb9a4875f2eb. That round strengthened three live-guard assertions at once and each strengthening carried its own defect: the leading-glyph predicate compared one byte and so rejected kiro's real composer row outside a UTF-8 locale, the foreground-name predicate was added but never called by the guard, a portable negative ended in `|| true` and asserted nothing, the resume-line hard fail could redden on a healthy tool because a full-screen TUI exit leaves no captured output, and the union settled-pane negative ran at a settle point no tool call precedes, where the row it looks for cannot appear. The weaknesses it aimed at are real and are recorded as unproven instead, along with the traps any future attempt has to avoid. Strengthening the guard is separate work from adding the adapter.
The guard's resume-line check passes whether or not the resume line appears, it never asserts the composer glyph, and its settled-pane negative runs against a signature with no production caller. Record all three as unproven rather than leaving the guard's header implying otherwise, and record the union stale-row hazard as an inference from the token list and delivery path - not an observation, since no run has been seen doing it. Also record the four traps that make strengthening those assertions its own piece of work: byte-wise glyph matching breaks outside UTF-8, an inline assertion leaves the portable negatives proving an unused predicate, a trailing `|| true` swallows both outcomes, and a resume-line check after exit can redden on a healthy tool.
The guard waits on real model turns, so its runtime is unbounded and a step-capped agent invocation cannot contain it - one attempt spent 64 minutes across two invocations and died on a 30-minute cap without reporting a result. Say so in its header, and say where a reader meets it that the portable regression is what CI enforces and does not cover the vendor-rendered surface, so a green suite is not evidence these signals still work.
…ble model listing
A validation run driving the real kiro-cli reports that the real idle kiro composer classifies as pending rather than proven-empty, so fm-send never types a steer into a kiro worker. Ten of its eleven live scenarios passed and this was the one failure. Recorded as that run's observation, not as an established fact, because it is not independently reproduced. Two candidate causes are ruled out by measurement: restoring the absent kiro entry to the fleet-wide idle-placeholder set changes no verdict, and the bare composer row classifies unknown rather than pending, so the verdict comes from the surrounding screen. A worker that cannot be steered does not satisfy the crewmate contract, so this blocks using the adapter.
My earlier record said the real idle kiro composer classifies as unknown at both styled and unstyled capture. That was measured with no capability argument and a row carrying no dim escape codes, which is not a styled capture, so the verdict was an artifact of the input. With the capabilities a styled capture actually carries the styled row classifies empty, matching the portable fixture, and the inference that the pending verdict came from the surrounding screen rested on the bad measurement and is withdrawn. What stands: restoring the absent kiro idle-placeholder entry changes no verdict, re-tested with correct inputs. The fixture's empty result is reproducible on its own input but is not confirmed faithful to the real pane, since the live run measured pending there. Say that at both sites, and mark the reference page's composer row as an open defect so an agent handed it at spawn does not read empty as established.
…read empty A real idle kiro composer classified as pending, and the doorbell defers on an exact pending, so every steer to a kiro worker was skipped and the watcher re-rang forever. The cause is a colour threshold, not anything kiro-specific: kiro draws its placeholder in truecolor near-gray at luminance 158, above the 128 ghost ceiling, so the strip left it in place and it read as typed text. rovo has the same defect at 162.9 and recorded it as an open gap needing a harness-scoped signal the shared classifier does not carry. Chromaticity is that signal, and it is intrinsic to the run, so nothing had to be threaded through the shared composer entry points. A near-achromatic truecolor run now gets a higher ceiling (default 180 within a channel spread of 12); anything more saturated keeps 128. That separates every measured case: kiro's ghost at spread 0 and rovo's at spread 3 strip, rovo's real typed text is near-gray but separated by luminance at 207.0 and is kept, and muse's real glyph at spread 165 is unreachable by any luminance ceiling. Non-truecolor runs are unchanged. Verified two ways: the four measured cases are pinned and fail on pre-fix code, with rovo's real text and muse's glyph as explicit non-regression assertions; and a capture of a live kiro pane classified with tmux's own descriptor returns empty where it returned pending. Fixes the recorded rovo gap in the same change.
The 256-colour fix reached further than authorized: it also treated the 6x6x6 cube diagonal as grey, and pinned that with a test asserting a cube index must strip. Only the 232-255 greyscale ramp was approved, because that range alone has RGB fixed by definition rather than by a theme, so it needs no palette guessing. Narrow the predicate to the ramp and turn that test around into a scope guard: an index outside 232-255 must be untouched. That case is what stops the next widening into indices where palette dependence is real. Record why the gap existed at all. The carve-out saying a 38;5 index is never luminance-tested was written down, which made it checkable, and driving a real crewmate on a pane without COLORTERM turned it from a footnote into a defect: the fix worked on every truecolor pane and left the original failure fully live everywhere else. A limit stated plainly can be tested against reality.
Upstream's codex 0.154 starfield fixture used near-gray cells incidentally, so its non-vacuousness guard broke once the near-gray ghost ceiling stripped them. Correct that guard and its comment to the present truth - the ceiling clears both starfield rows - and re-express its divergence as a colour one, since redrawing those positions as letters in a kept colour is what now proves the verdict comes from the ghost strip. The braille-furniture rule keeps its coverage in test_braille_furniture_rule, built on chromatic cells (38;2;120;190;255, luminance 176.5, channel spread 135) that survive the strip at any gray ceiling, so the rule is proven by shape rather than by a colour accident. The same cells as letters stay pending.
… this PR adds two portable-serial test scripts (tests/fm-kiro-harness.test.sh, tests/fm-kiro-signals-live-e2e.test.sh) with no duration hint in bin/fm-test-run.sh, taking the unmeasured serial share from 25/173 (14.5%) to 27/175 (15.4%), over PORTABLE_SERIAL_MAX_UNHINTED_PERCENT (15). That fails "Test coverage guard" directly, and tests/fm-test-run.test.sh (in "Behavior portable parallel 1") fails on the same guard call — its CI log ends immediately after the guard output with exit=1. Fix (smallest correct, evidence-based): - bin/fm-test-run.sh: added two lines to portable_serial_weight_hints with the durations measured by the green serial shards of the PR's own run 35171933923 — tests/fm-kiro-harness.test.sh 24667, tests/fm-kiro-signals-live-e2e.test.sh 76 (the live guard is gate-skipped in CI, so its value matches the existing 20-76 ms convention for other CI-skipped live-e2e scripts). - docs/fm-test-portable-shards.md: recorded the provenance of those two hints (one sample each, from run 35171933923, first run to include them) and stated plainly that the 76 ms is the gate-skip cost, not a measurement of the live guard's work. Verified locally: bin/fm-test-run.sh --check-coverage now prints FM_TEST_COVERAGE ok total=215 parallel=24 parallel_unhinted=0 serial=175 serial_shards=5 serial_unhinted=25 herdr=16. Running tests/fm-test-run.test.sh, all shard/hint assertions pass: "portable shard union, disjointness, and coverage guard hold", "portable parallel lanes are fully hinted and packed within 5% of each other", "portable serial shards are a deterministic disjoint cover of the serial lane", "coverage guard reports and bounds the unmeasured portable serial share"; "portable serial shard lanes refuse mismatched, out-of-range, and countless names" passes when run in isolation. Local-environment caveat (not a code defect, no change made for it): a full run of tests/fm-test-run.test.sh on this machine aborts in an unrelated later test with "mktemp: mkdtemp failed ... No space left on device" — the host data volume has ~275 MB free. That is host disk exhaustion, not the PR; the same test passes standalone. No other code, test, or behavior was changed; no new guards or machinery added
The wholesale KIRO_HOME relocation is recorded as the forced choice it is, but the additive alternative sat in that sentence as a bare contrast with gemini. Name it as follow-up work so a reader does not read the empty per-task home as a harness limitation.
…e union at settle
Bring in John Marshall's Kiro CLI crewmate/scout adapter from kunchenguid#4679 (head 9637826) with its authorship intact, so the fork can build a V3-engine launch on top of it. The PR branched from 65a3bac, 122 commits behind upstream main. Main has since added the devin adapter, the worker-account pin and staged launch files, so the conflicts were mostly adapter lists. Resolution: - Keep devin and add kiro in every adapter list, including the new interrupt arm, press-gap and hazard helpers in fm-control-lib.sh, the AFK test pin and the supervision-branch primary pin. - Keep main's worker-account block and the PR's kiro model and hook path validation as separate steps. - Union the delivery busy regex so both the devin rows and the kiro footer acknowledge a submit. - Remove a secondmate child's kiro home in teardown as well. - Teach the kiro test's fake tmux to read the staged launch file that main's kunchenguid#4994 now sources, so launch assertions see the real command. Claude-Session: https://claude.ai/code/session_01B4Krq5gHjEPXbmzMaaeTHs
Kiro serves several vendors' models on Kiro credits, so quota-aware dispatch must read quota-axi's own kiro provider row rather than the claude row. Neither harness-to-provider table knew kiro, so the resolver demanded an explicit provider on every kiro profile and the legacy chooser refused kiro as an unknown harness. Add kiro -> kiro to both tables in fm-quota-axi-lib.sh. quota-axi reports kiro with unknown quota semantics, so the resolver keeps a kiro profile eligible but unranked with the uncertainty disclosed, and the legacy chooser, which dispatches only on positive evidence, refuses it until a known row exists. The quota-choose suite pins both outcomes. Claude-Session: https://claude.ai/code/session_01B4Krq5gHjEPXbmzMaaeTHs
The kiro adapter from kunchenguid#4679 pins `--agent-engine v2` and wires its busy and turn-end hooks through a per-task agent config reached by relocating KIRO_HOME. The captain runs `kiro-cli --v3`, and reading the kiro-cli 2.24.1 V3 agent service shows it resolves agents, standalone hooks and its task store from the real $HOME/.kiro and never reads KIRO_HOME. A V3 launch on that wiring would load no agent, fire no hook, and leave the seeded busy record open forever. Make the engine a setting and give V3 its own hook path: - config/kiro-engine selects v3 (the default when absent) or v2, is validated before any pane exists, and is inherited by secondmates. - The launch and the model check pass the selected engine. V2 keeps `--agent firstmate` and its agent config byte for byte; V3 names no agent. - V3 installs one firstmate-owned hook file and two dispatchers under ~/.kiro/hooks. Each dispatcher is a silent exit-0 no-op unless the hook's cwd holds a git-excluded .fm-kiro-hook token that names a private registry entry, which names the task's kiro home. It then runs the same per-task scripts V2 uses, so one busy contract serves both engines. This is the grok global-hook shape. - Relaunch and teardown retire the token, registry entry and pointer, and a secondmate child's teardown now removes its kiro home too. - Both engines keep --trust-all-tools with the seeded confirmation setting, the unattended posture every other adapter uses. The docs record what KIRO_HOME still isolates on V3 (TUI settings and session history only), that the macOS login lives outside it, and which V3 lifecycle checks remain unproven until a live canary. Claude-Session: https://claude.ai/code/session_01B4Krq5gHjEPXbmzMaaeTHs
Bring fork main (2f9a106, the 2026-09-26 upstream sync plus fork fixes #2-#6) into the Kiro V3 crew branch so PR #8 merges cleanly. A merge, not a rebase, keeps the upstream PR kunchenguid#4679 merge and its authorship intact. Textual conflicts (1): - bin/fm-test-run.sh, family_for_basename live-e2e list: this branch added fm-kiro-signals-live-e2e.test.sh on its own line; main added fm-herdr-agent-liveness-live-e2e.test.sh beside the version-floor test. Kept both entries, so both live tests stay classified in the live-harness-optin family. Auto-merged files touched by both sides, checked by hand: - bin/fm-spawn.sh: main's agy Opus --effort omission (fork fix #5) sits in the agy arm next to this branch's new kiro effort arm; effort_flag_for_harness keeps the (harness, effort, model) signature on both sides. - agy.md, docs/configuration.md, docs/verification/runtime-backends.md: disjoint hunks. Semantic review: the Kiro adapter adds no arm to bin/backends/herdr.sh or fm_harness_pid_alive. Kiro reaches the fork's registration- independent Herdr liveness (fork fix #3) through fm_agent_process_classify_name, where kiro-cli classifies as agent. It is worker-only, so it stays out of the primary session-lock harness table. Claude-Session: https://claude.ai/code/session_01B4Krq5gHjEPXbmzMaaeTHs
… in tests/fm-remote-secondmate-lifecycle-e2e.test.sh, and I fixed it with a one-line change. Every test in the script passed on CI. The script then exited 1 because its cleanup step couldn't delete the fixture directory ("Directory not empty"). Cause: the "unreachable remote secondmate" watcher step starts `remote_env "$ROOT/bin/fm-watch.sh" &`. That backgrounds a subshell running the `remote_env` function, and fm-watch.sh runs as a child of that subshell. So `watch_pid=$!` held the subshell's pid, and `kill "$watch_pid"` stopped only the subshell. fm-watch.sh was left orphaned (parent pid 1) and kept writing heartbeat files (such as `.last-watcher-beat`) into `watch-liveness-unreachable/`. Those writes raced the cleanup's `rm -rf "$TMP_ROOT"`, which is why the failure came and went: the same code passed on caab39c, and the only later change is docs. Evidence: I added temporary logging to the cleanup step and ran the script locally. It captured an orphaned `bash .../bin/fm-watch.sh` (parent pid 1) still running at teardown, plus beat files written in the last minute under watch-liveness-unreachable/. Fix: the leg now runs `remote_env exec "$ROOT/bin/fm-watch.sh" ... &`, with a short comment explaining why. The subshell becomes fm-watch.sh itself, so `$!` is the watcher and killing it stops the real process. Nothing else in the test or the product code changed. Verification: `bash -n` passes. The full script exits 0 with "ALL TESTS PASSED". Checked with pgrep right after the script exited, no fm-watch.sh from this worktree was still running. One limit: I didn't recheck at the exact moment the cleanup ran; the before-fix check was done at that moment. The orphan from the earlier run had already exited by the time I looked afterwards
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.
Intent
Add Kiro CLI as a Firstmate crewmate and scout harness on the owner's fork (davidtandoh/firstmate) so 'kiro' can appear in config/crew-dispatch.json as a quota-aware fallback after codex and agy. The owner runs Kiro with the V3 agent engine ('kiro-cli --v3'), a Claude Code captain, Codex crewmates and the Herdr backend. Decisions: build on upstream PR kunchenguid#4679 (John Marshall's Kiro adapter, merged in with --no-ff to keep his 42 commits and authorship) rather than a parallel adapter; add config/kiro-engine (v3 default, v2 kept byte-identical to kunchenguid#4679, any other value refuses the spawn before a pane exists; secondmates inherit it); engine-aware launch and --list-models pass --agent-engine ; V2 keeps --agent firstmate, V3 names no agent. Because Kiro 2.24.1's V3 engine resolves agents, hooks and ~/.kiro/tasks from the real HOME and ignores KIRO_HOME except for TUI settings/history (verified by reading the installed bundles and a guarded quota probe), the V3 busy/turn-end path installs a global hook pair ~/.kiro/hooks/firstmate-crew.json with dispatchers that stay silent unless the cwd holds a git-excluded .fm-kiro-hook token registered under ~/.kiro/hooks/fm-kiro.d/, so ordinary Kiro sessions are unaffected; relaunch and teardown retire the token. Tool trust keeps --trust-all-tools plus the seeded chat.disableTrustAllConfirmation, matching other unattended adapters, rejecting an explicit --trust-tools= list because unlisted tools would prompt with nobody to answer. Quota maps harness kiro to quota-axi provider kiro (never claude); the owner's quota-axi fork reads Kiro credits only while Kiro is idle, so dispatch sees Kiro quota as unknown while a Kiro crewmate runs, which quota-array-dispatch treats as eligible with disclosed uncertainty. Known race: a quota read starting within ~1s of a Kiro launch can clear that task's running status; accepted and documented. The branch then merged the synced fork main (2f9a106) with --no-ff (merge caab39c); the only textual conflict was bin/fm-test-run.sh's live-e2e family list (kept both). Kiro only runs as a crewmate, so it stays out of fm-session-lock-lib's FM_HARNESS_NAMES; it uses the fork's registration-independent Herdr liveness via the exact name kiro-cli. Adding kiro to tests/fm-herdr-agent-liveness-live-e2e.test.sh is deferred because it would start kiro-cli chat; the owner-approved live canary (spawn one Kiro scout, confirm busy/turn-end and liveness in Herdr, teardown) will prove the V3 lifecycle after merge. Four tests fail identically on clean origin/main on this Mac (fm-harness-precedence, fm-session-start, fm-procevent needs setsid, fm-backend under zsh) and are pre-existing. Existing PR #8 was opened directly with gh and must be published through no-mistakes.
What Changed
kiro(Kiro CLI) as a crewmate and scout harness, built on upstream PR feat(bin): run crewmates and scouts on Kiro CLI kunchenguid/firstmate#4679's adapter. The branch merges that PR's commits with--no-ff. Changes spanbin/fm-spawn.sh,fm-harness.sh,fm-control-lib.sh,fm-composer-lib.sh,fm-busy-lib.sh,fm-teardown.sh,fm-dispatch-resolve.shandfm-agent-process-lib.sh:config/kiro-enginefile selectsv3(the default) orv2. Any other value refuses the spawn before a pane exists, and secondmates inherit the setting.--list-modelspass--agent-engine <engine>. V2 keeps--agent firstmate; V3 names no agent.KIRO_HOMEwithchat.disableTrustAllConfirmationseeded, so--trust-all-toolsruns unattended.~/.kiro/hooks/firstmate-crew.json. Its dispatchers do nothing unless the working directory holds a git-excluded.fm-kiro-hooktoken registered under~/.kiro/hooks/fm-kiro.d/, so ordinary Kiro sessions are unaffected. Relaunch and teardown retire the token and remove the per-task Kiro home.kiroto quota-axi providerkiro. The branch also merges the synced fork main and keeps both sides of thebin/fm-test-run.shlive-e2e list conflict. It addsdocs/verification/kiro.mdandreferences/harness/kiro.md, updates configuration, architecture and skill docs, and addstests/fm-kiro-harness.test.shandtests/fm-kiro-signals-live-e2e.test.sh, plus Kiro cases in the busy-wiring, composer, dispatch, bootstrap and quota tests.Risk Assessment
Testing
Six focused test scripts passed, run one at a time through fm-test-run.sh. They were the Kiro harness fixture suite plus the busy-wiring, composer, quota-choose, dispatch-resolve and bootstrap tests, with timing JSON kept for each. Two checks ran live against the real kiro-cli 2.24.1 and the real fm-spawn.sh in a disposable lab home. The first confirmed that the engine-aware model listing works on v3 and v2 and that kiro-cli rejects any other engine value. The second confirmed that unknown engines and unlisted models are refused before any state or pane is created, and that ~/.kiro/hooks is untouched. A successful V3 spawn was deliberately not run. It would start a paid kiro-cli chat and write global hooks under the real ~/.kiro, and the intent reserves that for the owner's post-merge canary. The guard hook blocked removal of two small temp dirs in $TMPDIR, and they were left in place. The worktree is clean.
Evidence: Live fm-spawn kiro guard transcript (lab home)
Source: Live fm-spawn kiro guard transcript (lab home)
Evidence: Live kiro-cli --agent-engine --list-models per engine
Source: Live kiro-cli --agent-engine --list-models per engine
Evidence: Kiro harness test output
Source: Kiro harness test output
Evidence: Kiro harness timing
Source: Kiro harness timing
Evidence: Busy adapter wiring test output
Source: Busy adapter wiring test output
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
bin/fm-control-lib.sh:425- The kiro arm of fm_control_harness_wiring_paths retires the V3 worktree pointer (.fm-kiro-hook) but not the state-side token file $state/$id.kiro-hook-token. The grok and kimi arms list their token files in the same place. Example: a V3 kiro task is relaunched onto another harness. clear_relaunch_harness_wiring deletes the registry entry and the pointer, but the stale token file stays until teardown. Teardown then reads it and runs rm -f on a registry path that no longer exists. This is harmless, but it breaks the grok/kimi retirement shape. Separately, the comment above this arm still says "nothing in the captain's real ~/.kiro is touched", which is no longer true now that V3 installs ~/.kiro/hooks/firstmate-crew.json and the fm-kiro.d registry. Fix: add printf '%s\n' "$state/$id.kiro-hook-token" to the kiro arm, extend the expected list in test_kiro_wiring_path_is_the_out_of_tree_hook_config, and update the comment.✅ **Test** - passed
✅ No issues found.
bin/fm-test-run.sh tests/fm-kiro-harness.test.sh --jobs 1 --per-script-timeout-secs 300 --max-wall-ms 400000 --json <evidence>/kiro-harness-timing.json(26 kiro cases ok)bin/fm-test-run.sh tests/fm-busy-adapter-wiring.test.sh(rc=0)bin/fm-test-run.sh tests/fm-composer-lib.test.sh(rc=0)bin/fm-test-run.sh tests/fm-quota-choose.test.sh(rc=0)bin/fm-test-run.sh tests/fm-dispatch-resolve.test.sh(rc=0)bin/fm-test-run.sh tests/fm-bootstrap.test.sh(rc=0)Live:KIRO_HOME=<tmp> kiro-cli chat --agent-engine {v3,v2,bogus} --list-models -f jsonagainst the real kiro-cli 2.24.1Live:bin/fm-spawn.sh ... --harness kiroin a disposable fm-lab-home (lab tmux socket), with config/kiro-engine=v9, then absent (v3) + --model not-a-real-model, then v2 + --model not-a-real-model✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.