Skip to content

feat(bin): pin a local omp secondmate to its own omp profile - #7738

Merged
kunchenguid merged 3 commits into
kunchenguid:mainfrom
craighurdman:fm/omp-profile-secondmate-2
Oct 25, 2026
Merged

kunchenguid merged 3 commits into
kunchenguid:mainfrom
craighurdman:fm/omp-profile-secondmate-2

Conversation

@craighurdman

Copy link
Copy Markdown
Contributor

Intent

Add support for launching a local omp secondmate with its own isolated omp --profile <name> auth/session/cache profile, distinct from the primary's own omp credentials.

Context: the captain runs two separate omp identities today, by hand: a default profile for one set of clients, and a dedicated omp --profile speak4 identity (its own auth, sessions, cache under ~/.omp/profiles/speak4/) for their most important client, speak4. Firstmate is about to seed a persistent speak4 secondmate whose own omp agent should launch under that same isolated speak4 profile rather than the primary's ambient omp credentials. bin/fm-spawn.sh currently has no way to pass --profile to an omp launch at all, local secondmate or otherwise - every omp launch uses whatever the ambient omp binary resolves by default.

What Changed

  • Added bin/fm-omp-profile-lib.sh, which reads an opt-in pin from config/secondmate-accounts/<id>/omp-profile in the primary home. Only a local secondmate's own omp agent uses it. The name must follow omp's profile rule: ^[a-z0-9][a-z0-9._-]{0,63}$, no trailing ., and no Windows reserved device names. A file that is empty, malformed, unreadable or not a regular file causes a refusal, and so does a raw omp launch command for a pinned mate. When the file is absent, nothing about the launch changes.
  • bin/fm-spawn.sh checks the pin before any endpoint, worktree or record exists. With a pin, the omp launch template gets --profile '<name>' right after the omp binary through a new __OMPPROFILE__ placeholder, and the model-catalog check (omp models --json) runs under the same profile. The spawn also writes omp_profile= to the task record and the spawned line, and keeps it through relaunches. bin/fm-control.sh checks the pin before a relaunch stops the live agent.
  • Documented the pin in docs/configuration.md ("Per-secondmate omp profile"), the omp harness adapter reference, docs/agent-control.md, the operational-home-layout skill and the runtime-backends verification notes. Added coverage in tests/fm-omp-harness.test.sh.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The change is opt-in and only adds a flag when a pin file exists; an absent file leaves the launch unchanged. Spawn and relaunch both check the pin before any fleet change, and remote secondmates cannot run omp at all, so the only gaps are a rare reserved-name edge case and an optional record field.

Testing

I ran the targeted omp harness test file (it passes, including the new profile-pin cases). I then drove four scenarios live against real omp and real firstmate scripts in a disposable lab home with a private tmux socket and an isolated omp HOME: a pinned spawn, an unpinned spawn, a spawn refused for a reserved-name pin, and a relaunch refused before stop for a malformed pin. All four passed. I captured the CLI output, the task records, the live process argv, and the pane content as evidence, then tore the lab down. This is a CLI and process change with no visual UI, so there are text transcripts and no screenshots. Not exercised: a relaunch with a valid pin that completes. The stop step refused because the unauthenticated lab omp sat on a model error screen, which the control layer reads as an 'ambiguous' state. That refusal comes from the existing control layer, not from this change. Re-reading the pin on relaunch is shown by the pre-stop refusal.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Captain pins local omp secondmate 'sm' to a profile; spawning it launches real omp with --profile <name> right after the executable, omp creates its own isolated profile state, and the record and spaw… ✅ pass live pinned-spawn.txt: ps shows omp --profile fmlab4 --config …; sm.meta has omp_profile=fmlab4; spawned line ends omp_profile=fmlab4; $LAB/ohome/.omp/profiles/fmlab4/{agent,cache,logs,run} created by th…
Secondmate with no pin file launches omp exactly as before (no --profile, ambient profile, no omp_profile field) ✅ pass live unpinned-spawn.txt: live omp argv starts omp --config; 0 omp_profile lines in sm2.meta; spawned line has no omp_profile; no new profile dir
Adversarial: a Windows-reserved pin name (aux) refuses the spawn before any endpoint, record, or launch ✅ pass live malformed-pin-refusal.txt: exit 1, error names config/secondmate-accounts/sm2/omp-profile; no sm2 state files; no fm-sm2 tmux window
Adversarial: a malformed pin (nul.x) refuses fm-control relaunch --harness omp before the running omp agent is stopped ✅ pass live relaunch-prestop-refusal.txt: exit 1 with the pin-file error; omp PID 32802 still running afterwards
Evidence: Pinned omp secondmate spawn: spawned line, task record, live omp argv with --profile fmlab4, isolated profile dir, pane

Source: Pinned omp secondmate spawn: spawned line, task record, live omp argv with --profile fmlab4, isolated profile dir, pane

== spawn output
fm-gate-refuse: gate agent lifecycle permitted only against lab home /private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab.lHvouB
warning: secondmate sm sync skipped before launch: primary default-branch commit cannot be resolved
spawned sm harness=omp kind=secondmate mode=secondmate yolo=off window=primary:fm-sm worktree=/private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm.OaPoCl omp_profile=fmlab4
== task record state/sm.meta
window=primary:fm-sm
endpoint_task_id=sm
worktree=/private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm.OaPoCl
project=/private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm.OaPoCl
harness=omp
kind=secondmate
mode=secondmate
yolo=off
tasktmp=/tmp/fm-sm
model=default
effort=default
omp_profile=fmlab4
busy_gen=g1792885750.31988.12334
spawn_gen=s1792885750.31554.11773
home=/private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm.OaPoCl
projects=
== lab tmux windows
primary:bash pid=28597 cmd=bash
primary:fm-sm pid=31973 cmd=bun
== live omp process (pane pid 31973 and descendants)
  PID  PPID COMMAND
31973 28596 -zsh
32802 31973 bun ~/.bun/bin/omp --profile fmlab4 --config ~/.no-mistakes/worktrees/5294d2e8c5bb/01M5QZ1V50G3Z4EQDNE1HN6J4X/.omp/fm-worker-overlay.yml --auto-approve --cwd /private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm.OaPoCl -e /private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab.lHvouB/state/sm.omp-ext.ts M-bM^AM-#FIRSTMATE_OP: v1 launch-brief: charter
32802 bun ~/.bun/bin/omp --profile fmlab4 --config ~/.no-mistakes/worktrees/5294d2e8c5bb/01M5QZ1V50G3Z4EQDNE1HN6J4X/.omp/fm-worker-overlay.yml --auto-approve --cwd /private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm.OaPoCl -e /private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab.lHvouB/state/sm.omp-ext.ts M-bM^AM-#FIRSTMATE_OP: v1 launch-brief: charter
38341 /bin/zsh -c source ~/.claude/shell-snapshots/snapshot-zsh-1792885544658-58w976.sh 2>/dev/null || true && setopt NO_EXTENDED_GLOB NO_BARE_GLOB_QUAL 2>/dev/null || true && { \builtin unalias -- 'unsetenv'; \builtin unset -f -- 'unsetenv'; } >/dev/null 2>&1 || true && eval 'LAB=$(cat /tmp/fmlab-path); E=~/.no-mistakes/evidence/01M5QZ1V50G3Z4EQDNE1HN6J4X\012T() { TMUX_TMPDIR=$LAB/tmux tmux -L fm-lab "$@"; }\012{ echo "== spawn output"; cat $LAB/spawn.out; echo "== task record state/sm.meta"; cat $LAB/state/sm.meta; echo "== lab tmux windows"; T list-windows -a -F '"'"'#{session_name}:#{window_name} pid=#{pane_pid} cmd=#{pane_current_command}'"'"'; } > $E/pinned-spawn.
== isolated profile dir created by the live omp
$LAB/ohome/.omp
$LAB/ohome/.omp/profiles
$LAB/ohome/.omp/profiles/fmlab4
$LAB/ohome/.omp/profiles/fmlab4/cache
$LAB/ohome/.omp/profiles/fmlab4/agent
$LAB/ohome/.omp/profiles/fmlab4/logs
$LAB/ohome/.omp/profiles/fmlab4/run
== secondmate pane
│ deepseek-coder-v2:latest │                                                                       │
│          ollama          │                                                                       │
│                          │ ───────────────────────────────────────────────────────────────────── │
│                          │ Recent sessions                                                       │
│                          │ No recent sessions                                                    │
│                          │                                                                       │
│                          │                                                                       │
│                          │                                                                       │
│                          │                                                                       │
╰──────────────────────────┴───────────────────────────────────────────────────────────────────────╯
 Tip: Drop the word `ultrathink` in your message for harder multi-step reasoning — watch it glow
      rainbow as you type
 ⁣FIRSTMATE_OP: v1 launch-brief: charter
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 Update Available
 New version 18.12.6 is available. Run: omp update
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
 ✘ 400 registry.ollama.ai/library/deepseek-coder-v2:latest does not support tools
   registry.ollama.ai/library/deepseek-coder-v2:latest does not support tools (type=invalid_request_error)
   raw-http-request=/private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab.lHvouB/ohome/.omp/profiles/fmlab4/logs/http-400-requests/1792885754286-353iqod5p5vz6.json
 Dismissed when you send your next message.
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
❯
 π · ⬢ deepseek-coder-v2:latest · 🗑 fm-lab-sm.OaPoCl · ⑂ main ?3 · ◫ 3.9%/164K ⟲
Evidence: Unpinned omp secondmate spawn: no --profile, no omp_profile record

Source: Unpinned omp secondmate spawn: no --profile, no omp_profile record

== no pin file for sm2
$ bin/fm-spawn.sh sm2 <home> omp --secondmate
spawned sm2 harness=omp kind=secondmate mode=secondmate yolo=off window=primary:fm-sm2 worktree=/private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm2.dMygsa
UNP_RC=0
== task record omp_profile lines:
0
== live omp process for sm2:
61344 60317 bun ~/.bun/bin/omp --config ~/.no-mistakes/worktrees/5294d2e8c5bb/01M5QZ1V50G3Z4EQDNE1HN6J4X/.omp/fm-worker-overlay.yml --auto-approve --cwd /private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab-sm2.dMygsa -e /private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab.lHvouB/state/sm2.omp-ext.ts M-bM^AM-#FIRSTMATE_OP: v1 launch-brief: charter
== profiles dir under lab HOME (only sm's fmlab4 exists):
fmlab4
== default (ambient) agent dir:
/private/var/folders/cl/4fbxfdf906vbhrb4drljpbk40000gn/T/fm-lab.lHvouB/ohome/.omp/agent
Evidence: Reserved-name pin (aux) refuses the spawn before any state or window

Source: Reserved-name pin (aux) refuses the spawn before any state or window

== pin: aux
$ bin/fm-spawn.sh sm2 <home> omp --secondmate
fm-gate-refuse: gate agent lifecycle permitted only against lab home $LAB
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
●  WATCHER DOWN - SUPERVISION IS OFF
●  1 task(s) in flight, but no watcher has a fresh beacon (last beat: never, grace 300s).
●  Trust the emitted supervision protocol for this harness; do not use shell & for watcher repair.
●  This is a supervision warning only; the guarded operation WILL still run.
●  watcher supervision needs Stop-owned automatic recovery; inspect the hook registration and startup status before ending the turn.
●━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
error: $LAB/config/secondmate-accounts/sm2/omp-profile must hold one omp profile name on a single line, matching ^[a-z0-9][a-z0-9._-]{0,63}$, not ending in '.', and not a Windows reserved device name (con, prn, aux, nul, com0-9, lpt0-9, alone or with an extension), with no other lines or control characters
BAD_RC=1
== state files for sm2:
(none)
== lab windows:
bash
fm-sm
Evidence: Malformed pin (nul.x) refuses fm-control relaunch before the live omp is stopped

Source: Malformed pin (nul.x) refuses fm-control relaunch before the live omp is stopped

== pin file: nul.x
== live omp pid before: 32802
$ bin/fm-control.sh sm relaunch --harness omp
fm-gate-refuse: gate agent lifecycle permitted only against lab home $LAB
error: $LAB/config/secondmate-accounts/sm/omp-profile must hold one omp profile name on a single line, matching ^[a-z0-9][a-z0-9._-]{0,63}$, not ending in '.', and not a Windows reserved device name (con, prn, aux, nul, com0-9, lpt0-9, alone or with an extension), with no other lines or control characters
exit=1
== omp still running after refusal:
  PID COMMAND
32802 bun ~/.bun/bin/omp --profile fmlab4 --config ~/.no-mistakes/worktrees/5294d2e8c5bb/01M5QZ1V5
Evidence: Live pinned omp argv
bun ~/.bun/bin/omp --profile fmlab4 --config …/.omp/fm-worker-overlay.yml --auto-approve --cwd …/fm-lab-sm.OaPoCl -e …/state/sm.omp-ext.ts <launch-brief>
spawned sm harness=omp kind=secondmate mode=secondmate yolo=off window=primary:fm-sm worktree=… omp_profile=fmlab4
- Outcome: 🔧 1 issue found → no changes applied ✅ across 2 runs (41m17s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

⚠️ **Review** - 1 warning
  • ℹ️ bin/fm-omp-profile-lib.sh:42 - The pin check claims to match omp's own profile rule, but it skips one part of that rule: omp also rejects Windows reserved device names on every platform (con, prn, aux, nul, com0-9, lpt0-9, and any of those with an extension, such as nul.x). The verification record in docs/verification/runtime-backends.md:3216 shows this in omp's own error. So a pin like aux passes fm_omp_profile_read. Then omp_model_validate swallows omp's failure, because an unreadable listing returns 0 (bin/fm-spawn.sh:2488). The spawn goes on to create the endpoint, worktree and record, and only the launched omp fails. That contradicts the documented promise to refuse "before any endpoint, local copy, or task record exists" (docs/configuration.md:1327). Fix: in the perl check, also exit 6 when the name matches /\A(con|prn|aux|nul|com[0-9]|lpt[0-9])(.|\z)/, and add that to the error text in fm_omp_profile_select (line 73). The same check covers the fm-control pre-stop path because it shares the same function.
  • ⚠️ bin/fm-spawn.sh:6572 - Simplification: the change records the pin as omp_profile= in the task record (bin/fm-spawn.sh:6572, plus its entry in the preserve_relaunch_meta key list at 6531) and on the spawned line (bin/fm-spawn.sh:7398). Nothing in bin/ reads this field back. The intent only requires that a local omp secondmate launch with --profile &lt;name&gt;. This is extra observability that copies the account-pin precedent, not something the intent asks for. Remedy: remove the record and spawned-line output (and the related docs sentence at docs/configuration.md:1331), unless the author wants it for operator visibility.

🔧 Fix applied.
1 warning still open:

  • ⚠️ bin/fm-spawn.sh:6572 - Simplification: the change records the pin as omp_profile= in the task record (bin/fm-spawn.sh:6572, plus its entry in the preserve_relaunch_meta key list at 6531) and on the spawned line (bin/fm-spawn.sh:7398). Nothing in bin/ reads this field back. The intent only requires that a local omp secondmate launch with --profile &lt;name&gt;. This is extra observability that copies the account-pin precedent, not something the intent asks for. Remedy: remove the record and spawned-line output (and the related docs sentence at docs/configuration.md:1331), unless the author wants it for operator visibility.
🔧 **Test** - 1 issue found → no changes applied ✅
  • ⚠️ The Test agent did not finish within its invocation budget. Reported: agent run tests timed out after 30m0s: agent last produced output 10m13s ago (21 observed); agent reported: claude exited: signal: killed:. This is a budget or provider-slowness cut, not a code failure. Re-running the same request costs another full budget, so no further attempt is made automatically. If this repository's targeted tests or evidence gathering routinely approach the default 30m0s, raise test_agent_timeout in global config. Respond with fix to spend another budget: a repair turn runs only for selected findings other than this budget cut, then validation re-runs. Or abort and retry after raising the budget.

🔧 No changes applied.
✅ Re-checked - no issues remain.

  • Live validation: ✅ go - 4 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Captain pins local omp secondmate 'sm' to a profile; spawning it launches real omp with --profile <name> right after the executable, omp creates its own isolated profile state, and the record and spaw… ✅ pass live pinned-spawn.txt: ps shows omp --profile fmlab4 --config …; sm.meta has omp_profile=fmlab4; spawned line ends omp_profile=fmlab4; $LAB/ohome/.omp/profiles/fmlab4/{agent,cache,logs,run} created by th…
Secondmate with no pin file launches omp exactly as before (no --profile, ambient profile, no omp_profile field) ✅ pass live unpinned-spawn.txt: live omp argv starts omp --config; 0 omp_profile lines in sm2.meta; spawned line has no omp_profile; no new profile dir
Adversarial: a Windows-reserved pin name (aux) refuses the spawn before any endpoint, record, or launch ✅ pass live malformed-pin-refusal.txt: exit 1, error names config/secondmate-accounts/sm2/omp-profile; no sm2 state files; no fm-sm2 tmux window
Adversarial: a malformed pin (nul.x) refuses fm-control relaunch --harness omp before the running omp agent is stopped ✅ pass live relaunch-prestop-refusal.txt: exit 1 with the pin-file error; omp PID 32802 still running afterwards
  • bash tests/fm-omp-harness.test.sh (targeted omp harness suite, including the three new omp-profile cases, all ok)
  • Live lab: bin/fm-lab-home.sh create $LAB, private tmux server tmux -L fm-lab with FM_HOME=$LAB and HOME=$LAB/ohome, then bin/fm-spawn.sh sm &lt;sm-home&gt; omp --secondmate with config/secondmate-accounts/sm/omp-profile=fmlab4; checked the live omp argv via ps, the sm.meta record, the spawned line, the $LAB/ohome/.omp/profiles/fmlab4 tree, and the omp pane
  • Live lab: wrote nul.x to the pin, ran bin/fm-control.sh sm relaunch --harness omp, and confirmed it refused naming the file while the live omp PID kept running
  • Live lab: bin/fm-spawn.sh sm2 &lt;sm2-home&gt; omp --secondmate with the pin aux; confirmed exit 1, the error names the file, and there is no sm2 state or tmux window
  • Live lab: same sm2 spawn with no pin file; confirmed the live omp argv has no --profile, the record has no omp_profile line, and the spawned line has no omp_profile
  • Teardown: tmux -L fm-lab kill-server, then removed the lab home, both secondmate homes, and /tmp/fm-sm*
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

Add the opt-in config/secondmate-accounts/<id>/omp-profile file in the
primary home. When present, that local secondmate's omp agent launches
with --profile <name> and its pre-launch catalog check reads the same
profile; the pin is recorded as omp_profile= in the task record and on
the spawned line. A malformed file refuses before any endpoint, local
copy, or record exists, and a relaunch checks it before stopping the
running agent. An absent file leaves every launch unchanged.
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: thank you @craighurdman, this is a clean, narrow change, and the live table covers both the refusal paths and the unpinned case.

What I checked on head 280aba28. The no-mistakes attestation binds this head (live 4 of 4 go). The diff touches bin/tests/docs/skills only, with no workflow edits and no network or credential surface. The pin name is regex-restricted and shell-quoted before it reaches the launch line. So I approved the first-time fork runs on this head: CI 40144811735 and Require no-mistakes 40144811725.

Contract-class: opt-in. fm_omp_profile_select returns nothing unless the harness is omp, the task is a local secondmate, and config/secondmate-accounts/<id>/omp-profile exists. With no file, __OMPPROFILE__ expands to empty and no omp_profile= line is written, so the launch line, the task record and the spawned line stay byte-identical. VISION: one captain, authority (an explicit per-mate captain config, never inferred), scripts own the mechanics (one lib owns parsing and refusals, checked before any endpoint and before a relaunch stops the agent), restart (the pin is re-read on relaunch/recovery), delegation, vendor (binds to omp's own --profile), and scope (credentials stay in the private home) all align.

Next step: once CI is green and the branch still merges cleanly, this can merge on the next pass. It's waiting on CI now, not on you.

@kunchenguid
kunchenguid merged commit 147b267 into kunchenguid:main Oct 25, 2026
19 checks passed
@kunchenguid

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate: this is merged. Thank you @craighurdman — really appreciate you taking the time on this.

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