Skip to content

feat(bin): add omp as a first-class verified harness - #7

Merged
EvanAgee merged 4 commits into
mainfrom
fm/fm-verify-omp-adapter
Aug 19, 2026
Merged

EvanAgee merged 4 commits into
mainfrom
fm/fm-verify-omp-adapter

Conversation

@EvanAgee

@EvanAgee EvanAgee commented Aug 19, 2026 •

Copy link
Copy Markdown
Owner

Intent

Make omp (Oh My Pi) a first-class verified Firstmate harness at full Pi-family parity. Add omp to every verified/known-harness allowlist and gate in bin/ without weakening any other harness, including bootstrap dispatch/recovery validation, spawn/control lifecycle support, remote doctor and remote secondmate control, and all other whole-tree verified-list omissions. Mirror Pi mechanics for omp: single Escape interrupt, one press, no composer clear or acknowledgement source, /quit exit, /no-mistakes skill invocation, extension-owned supervision, and Pi-family delivery/composer and liveness behavior where applicable. Wire bin/fm-busy-lib.sh and spawn generation arming to the existing omp per-task extension so agent_start reports busy and only agent_end with willContinue=false reports idle, with source isolation and behavior tests. Document omp in .agents/skills/harness-adapters/SKILL.md with busy source, exit, interrupt, skill invocation, --auto-approve, OMPCODE=1, omp models list, launch-profile row, and 2026-08-19 live smoke evidence. Preserve the verified facts: omp 17.3.5; glm52-phala from phala-vision-router; 1M context; image support; no thinking levels, so effort remains recorded in metadata but no thinking flag is launched. Run npx unslop on changed files before validation.

What Changed

  • Added omp to every verified/known-harness allowlist and gate across bin/ — bootstrap dispatch validation and liveness, spawn/control lifecycle (interrupt, exit, family, wiring paths), remote doctor, and remote secondmate control — with Pi-family mechanics (single Escape interrupt, one press, no composer clear or ack source, /quit exit).
  • Wired omp busy state to a dedicated omp-ext per-task extension in fm-busy-lib.sh and fm-spawn.sh arming, added extension-owned supervision routing (fm_omp_extension_owns_supervision / fm_extension_owns_supervision in fm-wake-lib.sh), session-start extension-load nudge, and supervision/composer handling; effort stays in metadata with no thinking flag launched.
  • Documented omp in .agents/skills/harness-adapters/SKILL.md and refreshed related docs; added and updated tests for busy-source isolation, spawn dispatch profile, supervision instructions, session start, and liveness.

Risk Assessment

✅ Low: Well-bounded allowlist/gate additions that mirror the existing Pi-family path with isolated markers; the effort-omits-thinking requirement is correctly implemented, every intent-named allowlist is covered, and new tests drive real extension behavior.

Testing

Ran the targeted omp behavior suites (busy-adapter-wiring, spawn-dispatch-profile, supervision-instructions, the omp session-start case, bootstrap, busy-state) — all pass. These execute real behavior: they spawn omp, load the generated per-task extension in a Node host, fire lifecycle handlers, and assert the observed busy/idle classification rather than grepping source. I also captured product-level evidence by spawning a real omp task and driving its generated extension through the full lifecycle, confirming spawn=busy, turn_end=notification-only, willContinue=true stays busy, terminal agent_end=idle, and agent_start=busy — matching the intent exactly. omp identity precedence (OMPCODE=1 outranking CLAUDECODE=1 and PI_CODING_AGENT=true) also verified. One case in the unchanged tests/fm-omp-harness.test.sh (no-markers => unknown) reports 'claude' because the local run happens inside a live Claude Code session whose parent process the ancestry walk correctly matches; that file and bin/fm-harness.sh did not change in this range and the case passes on clean CI. This change is CLI/shell-only with no rendered UI surface, so evidence is a CLI transcript rather than a screenshot.

Evidence: omp live spawn + busy/idle lifecycle transcript (generated extension + observed state transitions)

Source: omp live spawn + busy/idle lifecycle transcript (generated extension + observed state transitions)

### omp first-class harness — live spawn + busy/idle lifecycle

1) spawn omp task -> generated per-task extension written at:
   $STATE/omp-evid-1.omp-ext.ts

----- generated omp extension (product artifact) -----
// Firstmate semantic busy-state events + turn-end notification; written by
// fm-spawn under the contract owned by bin/fm-busy-lib.sh.
// omp event mapping: agent_start -> busy; agent_end (willContinue=false) ->
// idle; turn_end -> touch turn-end marker. omp has no agent_settled+isIdle;
// agent_end.willContinue is the settled guard (auto-retry/compaction keep it
// true, so only a genuine terminal settle marks idle).
import { execFile } from "node:child_process";
const busyEvent = (state: string, event: string) =>
  new Promise<void>((resolve) => {
    execFile("/Users/evanagee/.no-mistakes/worktrees/b99440365b40/01M0E19N5GJ0BEVHJK7E3S6N0K/bin/fm-busy-event.sh", [
      "apply", "/private/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T/fm-busy-adapter-wiring.T62qp0/omp-evid/home/state", "omp-evid-1", state,
      "--gen", "g1787178018.74104.13405", "--source", "omp-ext", "--event", event,
    ], () => resolve());
  });
export default function (omp: any) {
  omp.on("agent_start", () => busyEvent("busy", "agent-start"));
  omp.on("agent_end", (event: any) => {
    if (event && event.willContinue) return;
    return busyEvent("idle", "agent-end");
  });
  omp.on("turn_end", () => execFile("touch", ["/private/var/folders/k4/bmrhcryx7ld7c_w81zly9mh40000gn/T/fm-busy-adapter-wiring.T62qp0/omp-evid/home/state/omp-evid-1.turn-ended"]));
}
------------------------------------------------------

2) state right after spawn:
   classify => busy fm-spawn   (expect: busy fm-spawn)

3) fire turn_end handler (notification only, not a state edge):
   turn-ended marker present? yes
   classify => busy fm-spawn   (expect: still busy fm-spawn)

4) fire agent_end willContinue=true (agent keeps working):
   classify => busy fm-spawn   (expect: still busy)

5) fire agent_end willContinue=false (terminal, agent done):
   classify => idle omp-ext   (expect: idle omp-ext)

6) fire agent_start (new run begins):
   classify => busy omp-ext   (expect: busy omp-ext)
- Outcome: ⚠️ 1 info across 1 run (7m23s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 info
  • ℹ️ tests/fm-spawn-dispatch-profile.test.sh:636 - tests/fm-spawn-dispatch-profile.test.sh (test_omp_threads_model_and_records_omitted_effort_axis) asserts on generated-extension source strings (e.g. 'omp.on("agent_start"', 'event.willContinue', '"--source", "omp-ext"'). These are source-content assertions, but the generated .ts is an owned generated artifact and the true busy/idle behavior is separately proven by test_omp_extension_semantic_lifecycle in fm-busy-adapter-wiring.test.sh, which loads the extension in a node host and asserts observed classification. This mirrors the pre-existing pi test at the same file (lines ~687-694), so it is a same-pattern follow-on, not a new anti-pattern. No action needed.
⚠️ **Test** - 1 info
  • ℹ️ tests/fm-omp-harness.test.sh:69 - tests/fm-omp-harness.test.sh case test_no_markers_is_unknown returns 'claude' instead of 'unknown' when run inside a live Claude Code session: with all env markers unset, fm-harness.sh walks the process ancestry and correctly matches the real Claude Code parent process. This is a test-environment artifact of executing the local suite from inside Claude Code, not a product defect. The file and the identity logic (bin/fm-harness.sh) are both unchanged in this base..target range, and all omp-specific precedence cases (OMPCODE=1 outranking CLAUDECODE=1 and PI_CODING_AGENT=true) pass. On clean CI without a Claude parent process it passes.
  • ./tests/fm-busy-adapter-wiring.test.sh (omp extension lifecycle: agent_start busy, agent_end willContinue=false idle, turn_end notification-only)
  • ./tests/fm-spawn-dispatch-profile.test.sh (omp threads --auto-approve --model glm52-phala, omits --thinking, arms busy-gen/busy-state, writes omp-ext.ts)
  • ./tests/fm-supervision-instructions.test.sh (omp repair-line, ordinary-wake continuity, and effective extension-path rendering)
  • tests/fm-session-start.test.sh::test_omp_primary_reports_missing_explicit_extensions (missing omp turnend-guard/watch extension reporting)
  • ./tests/fm-bootstrap.test.sh, ./tests/fm-busy-state.test.sh
  • omp identity precedence cases from tests/fm-omp-harness.test.sh (OMPCODE=1 outranks CLAUDECODE=1 and PI_CODING_AGENT=true; cursor/grok/claude/pi markers unchanged)
  • Live evidence driver: real omp spawn -> generated per-task extension -> drove agent_start/turn_end/agent_end(willContinue true/false) handlers and observed classify transitions busy->busy->busy->idle->busy
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Summary by CodeRabbit

  • New Features

    • Added verified support for the OMP harness across local and remote launches.
    • Added OMP model and effort configuration, including support through the maximum effort level.
    • Added OMP lifecycle tracking, busy-state detection, interruption, exit, and supervision handling.
    • Added extension-based watcher and turn-end protection for OMP sessions.
  • Bug Fixes

    • Improved resume guidance by directing unsupported cases to relaunch with preserved context.
  • Documentation

    • Updated configuration, architecture, runtime, and harness documentation for OMP support.

@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f519f712-328c-4633-82c8-21b941d9be4b

📥 Commits

Reviewing files that changed from the base of the PR and between 45ceef1 and e6d70ed.

📒 Files selected for processing (40)
  • .agents/skills/afk/SKILL.md
  • .agents/skills/harness-adapters/SKILL.md
  • AGENTS.md
  • bin/backends/tmux.sh
  • bin/fm-bootstrap.sh
  • bin/fm-busy-lib.sh
  • bin/fm-composer-lib.sh
  • bin/fm-control-lib.sh
  • bin/fm-control.sh
  • bin/fm-remote-doctor.sh
  • bin/fm-remote-entrypoint.sh
  • bin/fm-remote-home-seed.sh
  • bin/fm-remote-secondmate-control.sh
  • bin/fm-session-start.sh
  • bin/fm-spawn.sh
  • bin/fm-supervision-instructions.sh
  • bin/fm-tmux-lib.sh
  • bin/fm-wake-lib.sh
  • docs/agent-control.md
  • docs/architecture.md
  • docs/configuration.md
  • docs/remote-secondmates.md
  • docs/sessionstart-nudge.md
  • docs/tmux-backend.md
  • docs/trace-context.md
  • docs/turnend-guard.md
  • docs/verification/runtime-backends.md
  • tests/fm-bootstrap.test.sh
  • tests/fm-busy-adapter-wiring.test.sh
  • tests/fm-busy-state.test.sh
  • tests/fm-composer-ghost.test.sh
  • tests/fm-composer-lib.test.sh
  • tests/fm-control.test.sh
  • tests/fm-guard-stale-banner.test.sh
  • tests/fm-on.test.sh
  • tests/fm-secondmate-liveness.test.sh
  • tests/fm-session-start.test.sh
  • tests/fm-spawn-dispatch-profile.test.sh
  • tests/fm-supervision-instructions.test.sh
  • tests/fm-tmux-agent-liveness.test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The PR adds verified omp harness support across dispatch, lifecycle supervision, busy-state tracking, control commands, tmux detection, remote launch paths, documentation, and regression tests. It also fixes empty project iteration under Bash 3.2 nounset mode.

Changes

OMP harness integration

Layer / File(s) Summary
Dispatch and control contracts
AGENTS.md, bin/fm-bootstrap.sh, bin/fm-control*.sh, bin/fm-remote-*.sh, tests/fm-bootstrap.test.sh, tests/fm-control.test.sh, tests/fm-spawn-dispatch-profile.test.sh
omp is accepted as a verified harness with model, effort, launch, exit, interrupt, family, and wiring support.
Extension supervision and busy state
bin/fm-busy-lib.sh, bin/fm-session-start.sh, bin/fm-spawn.sh, bin/fm-supervision-instructions.sh, bin/fm-wake-lib.sh, tests/fm-busy-adapter-wiring.test.sh, tests/fm-guard-stale-banner.test.sh, tests/fm-session-start.test.sh, tests/fm-supervision-instructions.test.sh
OMP uses explicit watcher and turn-end extensions. Extension ownership and lifecycle busy-state transitions are validated.
Process identity and composer handling
bin/backends/tmux.sh, bin/fm-composer-lib.sh, bin/fm-tmux-lib.sh, tests/fm-busy-state.test.sh, tests/fm-composer-*.test.sh, tests/fm-tmux-agent-liveness.test.sh
OMP is recognized for tmux liveness and Pi-family composer classification.
Documentation and compatibility fixes
.agents/skills/harness-adapters/SKILL.md, docs/architecture.md, docs/configuration.md, docs/sessionstart-nudge.md, docs/tmux-backend.md, docs/turnend-guard.md, docs/verification/runtime-backends.md, bin/fm-remote-home-seed.sh
Documentation records OMP support and supervision paths. Empty project iteration is guarded under Bash 3.2 nounset mode.

Estimated code review effort: 4 (Complex) | ~45 minutes

Merge Risk: ⚪ Minimal · up to e6d70

This PR adds OMP as a verified harness with isolated lifecycle and busy-state behavior, supported by targeted tests and live lifecycle evidence. No actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: kunchenguid

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.86% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes adding omp as a verified harness, which is the primary change in the pull request.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fm/fm-verify-omp-adapter

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@EvanAgee
EvanAgee merged commit b8e7201 into main Aug 19, 2026
14 checks passed
EvanAgee added a commit that referenced this pull request Aug 28, 2026
* refactor: extract Pi-compatible watcher core (#2)

* feat: add OMP worker harness support (#3)

* feat: add OMP primary tmux support (#4)

* feat: add OMP secondmate tmux support (#5)

* feat: verify OMP lifecycle on Herdr (#6)

* test: verify OMP support contract (#7)

* fix: address OMP branch review findings (#7)

* test: harden OMP branch regression fixtures (#7)

* docs: close OMP branch standards review (#7)

* fix: close OMP harness verification gaps (#7)

* test: stabilize guarded OMP Herdr evidence (#7)

* no-mistakes(review): bound exact-OMP ancestry probe to innermost harness

* no-mistakes(review): untrack .omc runtime artifacts and ignore them

* no-mistakes(document): document OMP session-start, watcher continuity, and state artifacts

* fix: correct OMP branch regressions

* no-mistakes(review): bind OMP harness marker to ancestry; scope tmux unknown branch; dedupe identity

* no-mistakes(document): document OMP scope, marker ancestry, and tmux submit exception

* test: correct OMP Herdr live matrix fixture

* no-mistakes(review): admit bare Herdr client reads; assert refusal log

* no-mistakes(review): log every fixture Herdr refusal through shared refuse path; matrix rerun still in flight, doc transcript not yet replaced

* no-mistakes(review): record green corrected OMP Herdr matrix rerun evidence

* no-mistakes(document): correct stale OMP Herdr verification evidence provenance and pointers

* no-mistakes(document): drop one-off draft-PR CI chronology from verification doc

* no-mistakes(document): record green corrected-head combined OMP runner evidence

* test: align Herdr fixtures with merged cleanup calls

* test(herdr): advance session-list fixture responses

* test(herdr): model session inventory and native reads

* fix(composer): strip prompt glyphs independent of locale

* test(composer): cover Unicode prompts under C locale

* fix(tmux): recognize OMP waiting busy footer

Treat OMP's spinner-backed Waiting tool footer as an active turn alongside Running while preserving the existing Working signature and exact row anchoring. Add regression fixtures for both active tool states and an idle model status bar.

* test(herdr): require fresh watcher before role matrix

Make the live Herdr role matrix verify the shared supervision beacon by mtime within the guard grace period and drain the blocked escalation wake before the next guarded send. Keep the diagnostic scope limited to the existing fixture.

* fix(omp): await watcher readiness before arm success

Make the OMP watcher tool report success only after a fresh owner is ready, and bind the live Herdr matrix drains to the exact watcher notifications they consume.

* docs(omp): refresh final lifecycle evidence

Record the clean 17-script tmux and Herdr matrix at the final source head, including event-bound watcher delivery and the observed backend limits.

* no-mistakes(review): confirm OMP abort endpoint stop before destructive cleanup

* no-mistakes(review): make herdr spawn fixture pane presence stateful

* no-mistakes(document): correct stale OMP head-bound evidence and arm readiness contract

* no-mistakes(document): point Pi generation-owner docs at shared watcher core

* no-mistakes(lint): bind and drain secondmate recovery wake before resumed exit

* no-mistakes(lint): bind OMP submit snapshot offset to complete JSONL boundary

* no-mistakes(lint): quarantine native OMP agent read probe form

* no-mistakes(lint): bind primary wake drain and route blocked answer via captain

* no-mistakes(lint): accept structured ask selectedOptions for routed worker choice

* no-mistakes(lint): accept idle-captain path for blocked worker answer

* no-mistakes(lint): harden Herdr matrix JSONL offsets and event predicates

* no-mistakes(lint): reuse production JSONL offset owner and tolerate ask-close race

* no-mistakes(lint): drop duplicate secondmate status wake requirement

* no-mistakes(lint): replace fixture wake drain with primary-owned settle wait

* no-mistakes(lint): confirm OMP blocked-ask answers via structured selectedOptions

* no-mistakes(lint): require exact structured ask result for blocked OMP answers

* no-mistakes(lint): distinguish same-second turn-end markers in watcher signal scan

* no-mistakes(lint): add same-second turn-end marker regression test

* no-mistakes(lint): order watcher signal signature as inode:size:mtime

* no-mistakes(lint): bind OMP session offset newline check to recorded size

* no-mistakes(lint): add deterministic OMP offset TOCTOU regression test

* no-mistakes(lint): omit explicit deliverAs for OMP watcher notifications

* docs(omp): refresh final lifecycle evidence

* no-mistakes(review): bind watcher marker version to core, re-resolve OMP bun, gate tmux OMP probe

* no-mistakes(document): document OMP marker version, herdr ask proof, tmux gate

* docs(omp): bind lifecycle evidence to corrected head

* fix(ci): align snapshot and Herdr fixtures

* no-mistakes(document): document OMP toolbelt scripts and AFK harness binding

* docs(examples): refresh crew-dispatch Sonnet 5 profiles to Opus 4.8

Update docs/examples/crew-dispatch.json, the starting-point example for
config/crew-dispatch.json:
- claude harness: claude-sonnet-5 -> claude-opus-4-8 (bare full-name form)
- pi harness: anthropic/claude-sonnet-5 -> anthropic/claude-opus-4-8
  (confirmed present in authenticated `pi --list-models`)

Rule structure and all other profiles (grok, claude/haiku, codex/gpt-5.5)
are unchanged. Validated against the repo's crew-dispatch schema in
bin/fm-bootstrap.sh crew_dispatch_validate: all harnesses verified and every
effort/harness pair supported (claude:low/high, codex:high/medium, pi:medium).
The schema does not validate model identifiers; they pass through to fm-spawn.

* fix(watcher): preserve ownership across factory rebinds

* no-mistakes(review): guard superseded watcher bindings from reclaiming ownership

* no-mistakes(document): document watcher factory re-bind regression coverage

* docs(readme): add fork note for native OMP support

Flag near the top that dnth/firstmate is a fork of kunchenguid/firstmate that adds native OMP support as a primary harness and crew runtime, without rewriting the upstream overview or duplicating the body's implementation details.

* no-mistakes(document): point README clone URL at the fork

* fix(omp): align native OMP tests and supervision with the fork's behavior

Follow-up to the OMP merge, fixing what the merge left inconsistent:

- fm-spawn.sh: run the harness=omp backend-allowlist refusal before the
  orca runtime check, so an OMP-on-orca spawn names the OMP allowlist
  rather than a missing-orca runtime error.
- fm-wake-lib.sh: keep the watcher signal signature as size:mtime (the
  fork's self-announce append relies on size being the first field). The
  upstream inode-prefixed signature is a general fix deferred to a later
  stage. Point OMP supervision-ownership at the native
  .omp-primary-extension-loaded marker via the native marker reader.
- fm-watch.sh: correct the signature-format comment to size:mtime.
- Native OMP dispatch tests: pass the ship delivery contract
  (--mode/--yolo), which the fork requires, and assert the fork's native
  OMP launch and diagnostic text; drop the superseded old-model OMP case.
- Session-start and guard tests: compute the Pi marker with the
  single-file adapter hash the fork's self-contained Pi watcher uses, and
  build the native OMP marker for the ownership check.
- Revert the two watcher tests' seen-signature helpers to size:mtime to
  match the watcher.

* fix(omp): finish OMP merge reconciliation for launch, width, and herdr prune

Wraps up the upstream OMP worker-runtime merge with the fork's own launch
path, state model, and safety choices.

- Launch a primary OMP session by running plain `omp` from the Firstmate
  root (native `.omp/extensions/fm-primary-omp.ts` discovery); drop the
  `bin/fm-omp.sh` launcher wrapper and its README/scripts references.
- Add `fm_composer_terminal_width` / `fm_composer_node_width` so standalone
  OMP measures glyph width through a Node fallback pinned to OMP 17.3.8 /
  Bun 1.3.14 fixtures instead of Bun.stringWidth.
- Harden the herdr seeded-tab prune to close only on a positively confirmed
  no-agent state; working, idle, done, blocked, and unreadable all preserve
  the tab.
- Defer upstream's screen-based and session-file OMP steer detection behind
  FM_OMP_SCREEN_DETECTION; the fork reads OMP busy/idle from the omp-ext
  marker, so those subtests self-skip and the omp-ext lifecycle is covered
  by the opt-in real-omp live E2E suite. Follow-up: fm-omp-inputbox-detection.
- Record OMP's position outside the composer matrix in the runtime-backends
  verification doc; drop the retired omp-adapter-verification.md and its
  audience entry; fix a stale turnend-guard anchor and a Pi extension name.

* fix(omp): restore the OMP endpoint identity path the merge dropped

The merge pulled in upstream's OMP-aware callers (fm-send.sh, fm-spawn.sh,
fm-bootstrap.sh) but kept the fork's fm-backend.sh, which had neither the
fm_backend_agent_record_identity function nor the source line that provides
the OMP process-identity helpers. Sending to an OMP worker died with
`fm_backend_agent_record_identity: command not found`, and fm_backend_agent_state
ignored the metadata argument every OMP caller now passes.

- Source fm-omp-process-lib.sh from fm-backend.sh, as upstream does.
- Add fm_backend_agent_record_identity (OMP-only; the fork has no hermes
  runtime) to validate a task's durable endpoint binding and export
  FM_BACKEND_AGENT_OMP_BUN/BIN before a process verdict uses them.
- Let fm_backend_agent_state accept the optional task-meta, populate the OMP
  identity vars, and pass them to the tmux adapter; a non-OMP record keeps
  the fork's existing classifier untouched.
- Add fm_backend_tmux_bun_agent_state so a generic `bun`/`omp` pane is
  attributed to the exact metadata-bound Bun and OMP entry through the shared
  process-identity probe, so PATH drift or a same-named stranger never earns
  an alive verdict.

The identity gate and tmux Bun attribution are covered always-on by
tests/fm-secondmate-liveness.test.sh. fm-send-strict's OMP subtest also
confirmed delivery by reading the OMP composer, which the fork defers behind
FM_OMP_SCREEN_DETECTION, so its composer half now self-skips like the sibling
OMP composer tests while the identity coverage stays in secondmate-liveness.

* fix(omp): require OMP launch-bound identity, not a bare name, in the session lock

The merge kept `omp` in FM_HARNESS_RE and FM_HARNESS_NAMES and added a `bun`
interpreter fallback, so fm_harness_process_matches accepted any process whose
command was `omp` or `bun` on name alone. That let an OMP worker with the wrong
launch-bound Bun and OMP entry pass the ancestry and liveness checks it should
fail.

Match upstream's OMP-is-identity-only contract: drop `omp` from FM_HARNESS_RE
and FM_HARNESS_NAMES, and remove the bun interpreter fallback and its
script-path extraction. OMP is now accepted only through fm_omp_process_matches,
which proves the exact launch-bound Bun and OMP realpaths. The fork's Cursor
ancestry fallback is unchanged.

Covered by tests/fm-omp-primary.test.sh, which asserts a bare `omp` process
title cannot bypass the Bun argv boundary.

* fix(pi): retire a superseded Pi-watch binding instead of orphaning its arm child

The merge brought in upstream's rewritten Pi-watch extension test, which asserts
that a fresh factory bind supersedes the prior binding and leaves exactly one
process-exit fallback. The fork's generation-based extension did not implement
that: a second default() call activated a new generation without stopping the
old one, so the prior binding's arm child was orphaned and a stale session_start
on that superseded binding could re-arm it.

- activateGeneration now stops the outgoing active generation when a different
  generation takes over, so a rebind retires the prior arm child. Re-activating
  the same generation (an ordinary session_start) stays a no-op.
- The session_start handler no-ops when this binding has been superseded
  (activeGeneration is a different object), so a stale session_start on a
  retired binding cannot resurrect a live generation.

Covered by tests/fm-pi-watch-extension.test.sh's rebind-supersession case; the
30 other subtests, including the same-binding /new/resume/fork self-restart
cycle, still pass.

* refactor(watch): share the primary-watcher signal helpers instead of duplicating

The merge landed bin/fm-primary-watch-core.ts (upstream's OMP watch core) as a
near-clone of .pi/extensions/fm-primary-pi-watch.ts, with byte-identical copies
of actionableLine, parentPid, and pidAlive. The AI-slop CI gate correctly
flagged those exact clones as newly introduced error-tier findings.

Share the three pure signal helpers instead of copying them: export them from
fm-primary-watch-core.ts (already covered by the watcher version hash, so the
shared file set does not grow) and import them into the Pi runtime adapter,
which drops its own copies. The Pi adapter now imports the core the same way the
OMP adapter already does.

Every Pi-watch test fixture that loads the extension now copies the watcher core
alongside it so the ../../bin import resolves: the pi-watch, calm-renderer, and
calm interactive-E2E fixtures. Behavior is unchanged; the helpers were identical.

* test(omp): report bun comm for the secondmate fixture's held process

The tmux OMP secondmate subtest holds a real process that runs node standing in
for bun, so its real command name is node. The fork's tmux Bun/OMP identity
probe (fm_backend_tmux_bun_agent_state) reads ps -o comm= to confirm the process
is a bun/omp runtime before attributing it to the task's launch-bound Bun and
OMP entry. The fixture's ps mock answered tpgid and args for the held pid but
let comm fall through to the real ps, which reports node, so the probe refused
the process and the secondmate never bound.

Report bun for the held pid's comm so the mock is consistent with the args line
and pane command it already returns. On Linux the held process's /proc/<pid>/exe
still resolves to the real node (the task's omp_bun), so the identity match holds
end to end. Verified: fm_backend_agent_state returns alive for this fixture shape.

* test(watch): give the same-second turn-end subtest the same wait budget as its siblings

The same-second turn-end subtest waited only wait_for_exit "$pid" 40 (4s) for
the watcher to surface the recreated marker and exit, while every other watch_bg
subtest in this file uses 80 or 100. Four seconds is too tight on a loaded CI
runner: the watcher polls once a second, needs a poll cycle or two to surface
the signal, then drains and exits, so the run intermittently timed out. It
passes locally; align the budget to 80 to remove the flake.

* fix(watch): distinguish same-second turn-end signals on whole-second filesystems

The wake-signal signature was size:mtime, and on Linux it used stat -c '%s:%Y',
whose mtime is only whole seconds. A 0-byte turn-ended marker removed and
recreated for the next turn inside one second kept the identical signature
0:<second>, so the .seen-* dedup swallowed the second real turn-end and the
crew's finish was never surfaced. macOS did not hit this because its stat -f
'%Fm' carries sub-second mtime.

Add the inode (recreation allocates a new one) and sub-second mtime to both
branches: size:inode:mtime, via '%z:%i:%Fm' on macOS and '%s:%i:%.9Y' on Linux.
The signature stays an opaque dedup key whose only parsed field is the leading
size, so the guarded self-announced append is unaffected. Verified: two
same-second recreations now produce different signatures.

Fixes the same-second turn-end regression seen on the Linux CI runner in
tests/fm-watch-triage.test.sh.

* test(watch): compute primed .seen signatures through the one owner

Four watcher tests reimplemented the wake-signal signature inline as
size:mtime to prime .seen-* markers. That copy drifted from
bin/fm-wake-lib.sh's fm_wake_signal_sig the moment the signature gained the
inode and sub-second mtime, so a primed marker no longer matched what the
watcher computes and the primed status was treated as unseen.

Have each helper (seen_sig, prime_seen, status_signature, and the two inline
primers in fm-wake-queue) call fm_wake_signal_sig, the single owner of the
format, so they can never drift again.

* fix(omp): address PR review findings on the upstream merge

- harness-adapters: drop the three stale fork omp rows that contradicted the
  new OMP facts (thinking flag, model discovery, skill invocation); the new OMP
  section is the single source of truth.
- fm-harness.sh: stop the OMP ancestry walk on a nested muse or Cursor process
  so a foreign harness started under an OMP worker (which inherits
  FM_OMP_HARNESS=omp) keeps its own identity instead of being reported as omp.
- fm-omp-detection: call `fm-harness.sh crew` directly for the crew-resolution
  test instead of threading a duplicate harness path through detect_with.
- fm-omp-primary: drop the mid-file `set +e`/`set -e`, which wrongly turned
  errexit on for the rest of the file (it was never on; the file uses set -u).
- fm-pi-watch-extension: write the arm-log line before the pid file in the
  fixture stub, so the harness that waits on the pid file never asserts on a
  not-yet-written arm log.
- fm-backend-herdr, fm-tmux-submit-busy: pass an explicit empty OMP entry to
  fm_composer_terminal_width so the width measurement does not depend on an
  ambient FM_OMP_BIN.

---------

Co-authored-by: dnth <[email protected]>
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