Skip to content

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

Closed
eduardstan wants to merge 11 commits into
kunchenguid:mainfrom
eduardstan:fm/fm-upstream-2062-refresh
Closed

eduardstan wants to merge 11 commits into
kunchenguid:mainfrom
eduardstan:fm/fm-upstream-2062-refresh

Conversation

@eduardstan

Copy link
Copy Markdown

Intent

Upstream firstmate (kunchenguid/firstmate) triaged our proposal issue #3953 and answered: the Prime Agent adapter is aligned with their vision, and the path is our three open pull requests in order, #2062 (register and detect the prime-agent harness adapter), #2070 (classify and probe prime-agent panes under Herdr), #2075 (retire prime-agent detached daemon sessions at teardown). No parallel adapter PR. The captain this morning: "If we need to run no-mistakes, do it for the upstream to hopefully merge our PR(s)."

This task is the first slice, PR 2062. Its branch is fork/fm/fm-upstream-prime-slice1 (check the PR's head ref), opened against upstream main months ago; upstream main has moved (about 18 commits since our last alignment plus everything before), one CI check fails ("Behavior portable serial 4"), and the PR body is 58 KB of history that upstream's reviewer will not read. Upstream requires the no-mistakes pipeline on PRs, with the gate capping a PR at about 20 changed files and 1000 changed lines (the reason for the split), and our own fork now carries the complete verified adapter on 0.9.1 (eduardstan#10 evidence).

What Changed

  • Register prime-agent as a recognized harness in the adapter skill, spawn dispatch, control library, and teardown/bootstrap paths, detecting it only from an explicit launch marker (guarded against ambient CLAUDECODE false positives) with verified-marker precedence preserved.
  • Add .agents/skills/harness-adapters/references/harness/prime-agent.md and wire prime-agent into verified-harness lists across AGENTS.md and docs/agent-control.md, docs/architecture.md, docs/configuration.md, docs/documentation-audiences.json, docs/trace-context.md.
  • Scrub prime-agent markers at launch and in shared test setup, and add tests/fm-prime-agent-harness.test.sh and tests/fm-spawn-dispatch-profile.test.sh covering marker detection, dispatch profile registration, and teardown behavior.

Risk Assessment

✅ Low: This final round correctly implements every previously-decided fix (exact prime-agent family match instead of prefix guess, clear-key assertion now checks success before emptiness, dispatch-validate and usage-header lists updated) with no residual gaps, no scope creep, and the diff stays well under the 20-file/1000-line cap.

Testing

All prime-agent register/detect/launch/control/teardown scenarios pass live via the project's own bash test suite driving real fm-harness.sh/fm-spawn.sh/fm-control-lib.sh/fm-teardown.sh against fake tmux/git fixtures; the crew-dispatch validator's new prime-agent acceptance was confirmed live by temporarily adding a table row and running the real jq-backed validator through fm-bootstrap.sh, then reverting the test file. Separately reproduced the intent-named CI failure ("Behavior portable serial 4"): base commit's bin/fm-test-run.sh --check-coverage fails under LC_ALL=en_US.utf8 with "comm: input is not in sorted order", while the target commit passes under both C and en_US.utf8 locales, confirming the LC_ALL=C comm fixes are the actual fix.

  • Live validation: ✅ go - 9 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Prime Agent harness is detected only from its own launch marker, not ambient Pi-family env leakage ✅ pass live bash tests/fm-prime-agent-harness.test.sh: ok - Prime Agent detection splits its Pi-family marker without relabelling Pi or Claude; ok - a prime-agent ancestor alone never claims the identity; the lau…
cursor/gemini/rovo/omp markers still outrank an inherited Prime Agent marker ✅ pass live bash tests/fm-prime-agent-harness.test.sh: ok - fm-harness: the cursor, gemini, and rovo markers outrank inherited Prime Agent markers
fm-spawn establishes the FM_PI_HARNESS=prime-agent marker at launch so detection works for a firstmate-spawned worker ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh: ok - a prime-agent launch establishes the harness marker its own detection needs
prime-agent secondmate spawn is refused by name (not misparsed as a raw home path, not the generic unknown-harness message) ✅ 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
fm-control-lib's prime-agent control table (family/supported/interrupt key/repeat/clear-key/exit command/wiring path) matches its verified facts, with an exact (non-prefix) family match ✅ pass live bash tests/fm-prime-agent-harness.test.sh: ok - fm-control-lib: prime-agent's lifecycle table matches its verified facts
fm-teardown removes a prime-agent worker's .prime-ext.ts control-wiring artifact alongside the other harness extension files ✅ pass live code inspection of bin/fm-teardown.sh:2934,3339 confirms $child_id.prime-ext.ts / $ID.prime-ext.ts added to the rm -f enumeration alongside pi-ext.ts/omp-ext.ts; covered indirectly by the passing cont…
config/crew-dispatch.json accepts harness:"prime-agent" (including effort:max) instead of reporting 'unverified harness: prime-agent' ✅ pass live Temporarily added a 'prime-agent max effort is accepted' row to tests/fm-bootstrap.test.sh's crew_dispatch_validation table and ran bash tests/fm-bootstrap.test.sh against the real jq-backed crew_disp…
named upstream CI failure 'Behavior portable serial 4' (locale-dependent comm ordering in the coverage guard) is actually fixed ✅ pass live LC_ALL=en_US.utf8 run of base commit's bin/fm-test-run.sh --check-coverage fails: 'comm: file 2 is not in sorted order / comm: input is not in sorted order' exit=1; same command against target commit'…
crew-dispatch validation still correctly rejects a genuinely unverified harness name (adversarial: does adding prime-agent loosen the guard generally?) ✅ pass live bash tests/fm-bootstrap.test.sh full run passed including its unchanged existing row 'unverified dispatch harness is flagged ... spaceship ... CREW_DISPATCH: invalid config/crew-dispatch.json - unveri…

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 - 9 of 9 scenarios driven live against the product
Scenario Result Live Evidence
Prime Agent harness is detected only from its own launch marker, not ambient Pi-family env leakage ✅ pass live bash tests/fm-prime-agent-harness.test.sh: ok - Prime Agent detection splits its Pi-family marker without relabelling Pi or Claude; ok - a prime-agent ancestor alone never claims the identity; the lau…
cursor/gemini/rovo/omp markers still outrank an inherited Prime Agent marker ✅ pass live bash tests/fm-prime-agent-harness.test.sh: ok - fm-harness: the cursor, gemini, and rovo markers outrank inherited Prime Agent markers
fm-spawn establishes the FM_PI_HARNESS=prime-agent marker at launch so detection works for a firstmate-spawned worker ✅ pass live bash tests/fm-spawn-dispatch-profile.test.sh: ok - a prime-agent launch establishes the harness marker its own detection needs
prime-agent secondmate spawn is refused by name (not misparsed as a raw home path, not the generic unknown-harness message) ✅ 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
fm-control-lib's prime-agent control table (family/supported/interrupt key/repeat/clear-key/exit command/wiring path) matches its verified facts, with an exact (non-prefix) family match ✅ pass live bash tests/fm-prime-agent-harness.test.sh: ok - fm-control-lib: prime-agent's lifecycle table matches its verified facts
fm-teardown removes a prime-agent worker's .prime-ext.ts control-wiring artifact alongside the other harness extension files ✅ pass live code inspection of bin/fm-teardown.sh:2934,3339 confirms $child_id.prime-ext.ts / $ID.prime-ext.ts added to the rm -f enumeration alongside pi-ext.ts/omp-ext.ts; covered indirectly by the passing cont…
config/crew-dispatch.json accepts harness:"prime-agent" (including effort:max) instead of reporting 'unverified harness: prime-agent' ✅ pass live Temporarily added a 'prime-agent max effort is accepted' row to tests/fm-bootstrap.test.sh's crew_dispatch_validation table and ran bash tests/fm-bootstrap.test.sh against the real jq-backed crew_disp…
named upstream CI failure 'Behavior portable serial 4' (locale-dependent comm ordering in the coverage guard) is actually fixed ✅ pass live LC_ALL=en_US.utf8 run of base commit's bin/fm-test-run.sh --check-coverage fails: 'comm: file 2 is not in sorted order / comm: input is not in sorted order' exit=1; same command against target commit'…
crew-dispatch validation still correctly rejects a genuinely unverified harness name (adversarial: does adding prime-agent loosen the guard generally?) ✅ pass live bash tests/fm-bootstrap.test.sh full run passed including its unchanged existing row 'unverified dispatch harness is flagged ... spaceship ... CREW_DISPATCH: invalid config/crew-dispatch.json - unveri…
  • bash tests/fm-prime-agent-harness.test.sh (harness detection precedence, marker anchoring, control-lib lifecycle table)
  • bash tests/fm-spawn-dispatch-profile.test.sh (prime-agent launch marker establishment, prime-agent secondmate named refusal, all other dispatch profiles)
  • bash tests/fm-trace-context-spawn.test.sh (regression check on shared spawn path)
  • LC_ALL=C bin/fm-test-run.sh --check-coverage vs LC_ALL=en_US.utf8 bin/fm-test-run.sh --check-coverage, on both target commit and base commit's bin/fm-test-run.sh
  • temporary row added to tests/fm-bootstrap.test.sh crew_dispatch_validation table (prime-agent + effort:max) run via bash tests/fm-bootstrap.test.sh, then reverted
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@greptile-apps

greptile-apps Bot commented Sep 8, 2026

Copy link
Copy Markdown

Confidence Score: 5/5

The PR appears safe to merge with no concrete changed-code defect identified.

Prime Agent registration is consistently implemented across detection, dispatch validation, launch construction, lifecycle control, cleanup, documentation, and focused regression coverage.

Reviews (1): Last reviewed commit: "no-mistakes(document): Add prime-agent t..." | Re-trigger Greptile

@eduardstan

Copy link
Copy Markdown
Author

Opened by our validation pipeline in error; this work is the refresh of #2062, which now carries the same head.

@eduardstan eduardstan closed this Sep 8, 2026
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Closing the leftover: this PR was opened by the validation pipeline in error and carries the same head as #2062 (825707b02593). Thank you @eduardstan — really appreciate you taking the time on the prime-agent adapter work; continuing on #2062.

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.

2 participants