Skip to content

feat(harness): register and detect the prime-agent harness adapter - #4283

Closed
eduardstan wants to merge 15 commits into
kunchenguid:mainfrom
eduardstan:fm/fm-upstream-2062-rebase
Closed

eduardstan wants to merge 15 commits into
kunchenguid:mainfrom
eduardstan:fm/fm-upstream-2062-rebase

Conversation

@eduardstan

Copy link
Copy Markdown

Intent

Upstream firstmate (kunchenguid/firstmate) triaged our proposal issue #3953 and accepted the path: our three pull requests in order, #2062 first (register and detect the prime-agent harness adapter), then 2070 and 2075. On 9 September the maintainer's firstmate asked for the tip of 2062 to be re-raised through no-mistakes so the PR body attestation binds to the current head. The previous worker did that (attestation bound to 655d66a, CI green at the time). Since then upstream main moved again and GitHub now reports PR 2062 as conflicting (mergeable false, state dirty, head 655d66a, base b84e0e3 at last triage, now c191eac or later). The captain today: "Post the attestation thing as comment on PR 2062" (done, in his voice, asking for a re-run) and, on seeing the conflict, sent the GitHub notice "This branch has conflicts that must be resolved". The captain never wants to pressure the maintainers; our side must be clean before anyone is asked for anything.

What Changed

  • Register prime-agent as a supported harness: add .agents/skills/harness-adapters/references/harness/prime-agent.md, update the harness-adapters skill and docs (agent-control, architecture, configuration, trace-context, documentation-audiences.json, AGENTS.md) to list it among verified harnesses.
  • Detect prime-agent from an explicit launch marker (not ambient CLAUDECODE alone), scrub that marker at launch/teardown, and preflight the prime-agent executable before spawn, launching it via the resolved executable path; wire this through bin/fm-harness.sh, bin/fm-spawn.sh, bin/fm-control-lib.sh, bin/fm-bootstrap.sh, bin/fm-teardown.sh, and bin/fm-test-run.sh.
  • Add tests/fm-prime-agent-harness.test.sh and tests/fm-spawn-dispatch-profile.test.sh, and update existing harness tests (fm-cursor, fm-gemini, fm-kimi, fm-rovo, fm-secondmate, fm-trace-context-spawn) plus tests/lib.sh to scrub ambient prime-agent markers so detection tests stay isolated.

Risk Assessment

✅ Low: Change registers a new crewmate/scout-only harness (prime-agent) following the exact established pattern for prior adapters (omp/pi-signed); every case-statement site that needed the new branch has it, sites that correctly exclude it (secondmate-only lists, primary-lock detection, busy-state wiring deliberately unimplemented) match documented, pre-existing precedent for other crewmate-only adapters (muse/gemini/rovo), and the added tests exercise real subprocess behavior (env markers, ancestry fakes, launch command capture) rather than source-text greps; the branch's own history shows two real bugs (bare prime-agent in launch template, missing preflight) already caught and fixed in later commits within this same range.

Testing

Drove the real fm-harness.sh/fm-control-lib.sh/fm-spawn.sh scripts through their existing behavior test suites (no mocks of the code under test); every prime-agent-specific scenario (detection precedence, ancestry guard, lifecycle table, spawn launch/marker, missing-executable preflight refusal, secondmate refusal) passed. The touched sibling harness suites (cursor/gemini/kimi/rovo/secondmate/trace-context), whose only edits were unrelated marker-scrub unsets, also passed except one pre-existing flaky timing test (test_config_reread_serializes_concurrent_pushes, unrelated to prime-agent code) which I reproduced identically on the base commit, confirming it is a pre-existing environment timing issue and not caused by this change.

  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Prime Agent launch marker is detected as prime-agent, not misclassified as Pi or Claude ✅ pass live bash tests/fm-prime-agent-harness.test.sh -> ok - Prime Agent detection splits its Pi-family marker without relabelling Pi or Claude
Ambient/leaked Prime Agent markers cannot spoof the identity without real process ancestry, and higher-precedence markers (cursor/gemini/rovo) still win ✅ pass live bash tests/fm-prime-agent-harness.test.sh -> ok - fm-harness: the cursor, gemini, and rovo markers outrank inherited Prime Agent markers; ok - a prime-agent ancestor alone never claims the identity;…
fm-control-lib registers prime-agent's full lifecycle table (supported harness, family, secondmate-kind refusal, interrupt key/repeat/clear-key, exit command, wiring path) ✅ pass live bash tests/fm-prime-agent-harness.test.sh -> ok - fm-control-lib: prime-agent's lifecycle table matches its verified facts
fm-spawn launches prime-agent, stamps the FM_PI_HARNESS=prime-agent marker its own detection needs, and threads model/effort dispatch validation ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh -> ok - a prime-agent launch establishes the harness marker its own detection needs
Adversarial: missing prime-agent executable refuses safely before endpoint/metadata creation instead of launching a broken pane ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh -> ok - prime-agent refuses safely and actionably when the selected executable is unavailable
Adversarial: a --secondmate spawn on prime-agent is refused by name (no primary supervision protocol), not silently treated as an unknown harness ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh -> ok - a prime-agent secondmate spawn is refused by name, not as an unknown harness
Regression: sibling harness detection/spawn suites touched only by the shared marker-scrub in tests/lib.sh still pass unchanged ✅ pass live bash tests/fm-cursor-harness.test.sh, bash tests/fm-gemini-harness.test.sh, bash tests/fm-kimi-harness.test.sh, bash tests/fm-rovo-harness.test.sh, bash tests/fm-trace-context-spawn.test.sh…
  • Outcome: ⚠️ 1 info across 1 run (17m4s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

✅ **Review** - passed

✅ No issues found.

⚠️ **Test** - 1 info
  • ℹ️ tests/fm-secondmate-harness.test.sh:2222 - tests/fm-secondmate-harness.test.sh:test_config_reread_serializes_concurrent_pushes fails with 'first config push did not reach pointer delivery' in this sandbox. This test is untouched by the diff (only earlier, unrelated tests in the same file got new env-unsets for the prime-agent markers) and reproduces identically when running the base commit's (de00521) copy of the same test file, so it is a pre-existing timing-sensitive flake in this environment, not a regression from the prime-agent change.
  • Live validation: ✅ go - 7 of 7 scenarios driven live against the product
Scenario Result Live Evidence
Prime Agent launch marker is detected as prime-agent, not misclassified as Pi or Claude ✅ pass live bash tests/fm-prime-agent-harness.test.sh -> ok - Prime Agent detection splits its Pi-family marker without relabelling Pi or Claude
Ambient/leaked Prime Agent markers cannot spoof the identity without real process ancestry, and higher-precedence markers (cursor/gemini/rovo) still win ✅ pass live bash tests/fm-prime-agent-harness.test.sh -> ok - fm-harness: the cursor, gemini, and rovo markers outrank inherited Prime Agent markers; ok - a prime-agent ancestor alone never claims the identity;…
fm-control-lib registers prime-agent's full lifecycle table (supported harness, family, secondmate-kind refusal, interrupt key/repeat/clear-key, exit command, wiring path) ✅ pass live bash tests/fm-prime-agent-harness.test.sh -> ok - fm-control-lib: prime-agent's lifecycle table matches its verified facts
fm-spawn launches prime-agent, stamps the FM_PI_HARNESS=prime-agent marker its own detection needs, and threads model/effort dispatch validation ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh -> ok - a prime-agent launch establishes the harness marker its own detection needs
Adversarial: missing prime-agent executable refuses safely before endpoint/metadata creation instead of launching a broken pane ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh -> ok - prime-agent refuses safely and actionably when the selected executable is unavailable
Adversarial: a --secondmate spawn on prime-agent is refused by name (no primary supervision protocol), not silently treated as an unknown harness ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh -> ok - a prime-agent secondmate spawn is refused by name, not as an unknown harness
Regression: sibling harness detection/spawn suites touched only by the shared marker-scrub in tests/lib.sh still pass unchanged ✅ pass live bash tests/fm-cursor-harness.test.sh, bash tests/fm-gemini-harness.test.sh, bash tests/fm-kimi-harness.test.sh, bash tests/fm-rovo-harness.test.sh, bash tests/fm-trace-context-spawn.test.sh…
  • bash tests/fm-prime-agent-harness.test.sh
  • bash tests/fm-spawn-dispatch-profile.test.sh
  • bash tests/fm-cursor-harness.test.sh
  • bash tests/fm-gemini-harness.test.sh
  • bash tests/fm-kimi-harness.test.sh
  • bash tests/fm-rovo-harness.test.sh
  • bash tests/fm-secondmate-harness.test.sh
  • bash tests/fm-trace-context-spawn.test.sh
  • control run: base commit de00521b9e6 version of tests/fm-secondmate-harness.test.sh + tests/lib.sh, restored via git checkout afterward
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@eduardstan

Copy link
Copy Markdown
Author

Opened by the pipeline by mistake; the change lives in #2062.

@eduardstan eduardstan closed this Sep 12, 2026
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