Skip to content

feat: add per-worker Claude Code Mode trial - #20

Merged
Profreshor merged 2 commits into
mainfrom
fm/fm-spawn-claude-code-mode
Nov 18, 2026
Merged

Profreshor merged 2 commits into
mainfrom
fm/fm-spawn-claude-code-mode

Conversation

@Profreshor

@Profreshor Profreshor commented Nov 18, 2026 •

Copy link
Copy Markdown
Owner

Intent

Trial on one Claude worker

That is the answer to this question: "Should I trial Claude Code's experimental Code Mode in the fleet?" The chosen option read: "I start the next suitable Claude worker with the setting on for that worker only and report: did it start, did anything get refused, did the work go faster. Nothing else changes, and the worker's session is thrown away at the end of its task as usual."

Code Mode is an experimental, off-by-default Claude Code feature (https://code.claude.com/docs/en/code-mode.md). It is switched on by the environment variable CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1 in the shell or in user settings. A first attempt set the variable on the bin/fm-spawn.sh command; the worker reported the variable unset, because a worker terminal takes its environment from the terminal daemon, not from the spawn command. The user settings file is not an option: it would switch the feature on for every session.

What Changed

  • Add a per-spawn --code-mode opt-in for canonical Claude ship and scout launches, injecting the experimental environment setting without changing Claude user settings.
  • Persist the opt-in in task metadata so relaunches retain it, while refusing batches, non-Claude or raw launches, secondmates, and T3 Code before allocation.
  • Document the one-worker trial and add coverage for launch, relaunch, allowlist handling, and refusal paths.

Risk Assessment

✅ Low: The implementation is bounded to canonical single-worker Claude launches, preserves the opt-in only in task metadata for relaunch, and refuses batch dispatch before the worker-creation loop.

Testing

The focused spawn-profile suite passed, exercising emitted launch commands, metadata persistence, relaunch, allowlist behavior, and refusals. A disposable live lab confirmed the batch guard and produced a CLI transcript; this CLI-only change has no rendered UI surface, so no screenshot applies.

  • Live validation: ⚠️ inconclusive - 1 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A single Claude ship or scout starts with Code Mode enabled ⏸️ untested no Automated executable coverage passed, but a real worker was not spawned because this validation did not allocate a disposable project worktree and manually accept Claude’s required one-time confirmati…
A Code Mode task relaunches with its recorded opt-in ⏸️ untested no Automated executable coverage passed, but no real Claude task session was created and relaunched in this run.
Unsupported Code Mode targets refuse before creating task state ⏸️ untested no Covered by executable tests only; the live lab exercise focused on the batch boundary.
Batch dispatch with --code-mode refuses before either worker is created ✅ pass live Live batch-refusal transcript
Evidence: Live batch-refusal transcript

Source: Live batch-refusal transcript

fm-gate-refuse: gate agent lifecycle permitted only against lab home /tmp/fm-lab.xTwecR
error: --code-mode is for one worker; batch dispatch is unsupported
exit=1
Evidence: Focused spawn-profile test transcript

Source: Focused spawn-profile test transcript

ok - allowlist=absent preserves the operational floor and filters only when opted in
ok - allowlist=missing-config preserves the operational floor and filters only when opted in
ok - allowlist=enabled preserves the operational floor and filters only when opted in
ok - allowlist=empty preserves the operational floor and filters only when opted in
ok - invalid allowlist names refuse before launch or task publication
ok - inaccessible config with present allowlist refuses before launch or task publication
ok - inaccessible config with absent allowlist refuses before launch or task publication
ok - inaccessible ancestor with present allowlist refuses before launch or task publication
ok - inaccessible ancestor with absent allowlist refuses before launch or task publication
ok - secondmate launch inherits the allowlist for subsequent worker launches
ok - local inheritance preserves the allowlist on source errors and mirrors proven absence
ok - remote inheritance preserves the allowlist on source errors and mirrors proven absence
ok - Claude ship Code Mode survives absent filtering and relaunch from its record
ok - Claude ship Code Mode survives allowlist filtering and relaunch from its record
ok - Claude scout Code Mode survives absent filtering and relaunch from its record
ok - Claude scout Code Mode survives allowlist filtering and relaunch from its record
ok - Code Mode refuses other harnesses, raw commands, secondmates, and explicit or configured t3code before allocation
ok - Codex absent, bypass, and restricted modes preserve flags for ships, scouts, and secondmates
ok - invalid Codex permission files refuse spawns and relaunches before mutation
ok - Codex restricted mode leaves other harness launch flags unchanged
WORKER-RAN
WORKER-RAN
WORKER-RAN
WORKER-RAN
WORKER-RAN
WORKER-RAN
skip: fish not found (fish pane launch); only a static syntax check ran
ok - launch appends the hooks config while preserving inherited Git credentials in sh, bash and zsh
ok - fm-spawn: actual ship/scout launch commands deliver the worker role contract
ok - no --model/--effort records defaults and types the claude launch instructions
ok - a claude launch publishes the brief as an operational-inbox record and passes only the doorbell
ok - a secondmate claude launch publishes its brief record into the secondmate's own home
ok - a claude spawn whose launch-brief record cannot publish stops with a clear error and sends no launch
ok - non-cursor launches clear inherited Cursor identity markers
ok - relative home overrides ignore CDPATH and become absolute before spawn launch construction
ok - FM_HOME defaults resolve relative paths and preserve absolute spellings
ok - absolute override spellings are preserved in spawn launch paths
ok - unresolvable relative spawn overrides fail with named diagnostics
ok - active crew-dispatch profile requires an explicit harness for ship spawns
ok - active crew-dispatch profile requires an explicit harness for scout spawns
ok - a non-clear dispatch record accepts the explicit flags of the manual intake
ok - a recorded dispatch selection refuses conflicting explicit launch flags
ok - a recorded dispatch selection allows the matching launch flags
ok - a task override with its reason permits a different launch and is recorded
ok - an effort the clear selection leaves unset is not bound
ok - a clear dispatch selection refuses a raw launch command unless a task override is recorded
ok - active dispatch refuses a spawn whose task has no recorded resolution
ok - batch dispatch checks each task against its own recorded selection
ok - active crew-dispatch profile allows the legacy positional harness form
ok - active crew-dispatch profile allows the raw launch-command escape hatch
ok - a raw launch ending in a separator or a comment still runs the worker, its disarm, and config warnings
ok - a raw launch keeps a reporter only for an established agent below its native floor
ok - a chained raw launch commits through the AI-trailer strip in every step
ok - claude receives --model and --effort profile flags
ok - codex receives --model and model_reasoning_effort profile flags
ok - codex Luna receives --model and model_reasoning_effort max profile flags
ok - codex omits max for models without the catalog capability
ok - a codex crewmate requests no hook layer and keeps its turn-end signal
ok - a codex secondmate keeps its project hooks and uses automatic approval review
ok - Codex defaults remain bypass; persistent fallback is direct and invalid values refuse
ok - grok receives --model and --reasoning-effort profile flags
ok - grok omits unsupported max reasoning effort
ok - grok omits unsupported xhigh reasoning effort
ok - cursor receives its model-qualified reasoning class and exact task workspace
ok - cursor refuses model ids absent from its resolved binary's live catalog
ok - cursor preserves the requested model when its live catalog is unreachable
ok - opencode receives the model and effort through its config
ok - opencode without an effort keeps the model pin and omits variant
ok - opencode emits the variant for an effort the openai family exposes
ok - opencode omits the variant for an effort outside the model family's list
ok - opencode 1.x keeps the --model flag and the variant-only config
ok - opencode 1.x without an effort keeps its permission-only launch config
ok - opencode probe and launch share the same resolved executable path
ok - opencode with an unparseable version falls back to the 1.x launch path
ok - opencode 2 delivery gate accepts an auto-submitted brief without pressing Enter
ok - opencode 2 delivery gate sends exactly one Enter for a brief left in the composer
ok - opencode 2 delivery gate keeps polling an unknown composer and sends one Enter once it reads pending
ok - opencode 2 delivery gate sends its one Enter at the deadline when the composer only reads unknown
ok - opencode 2 delivery gate fails the spawn when the brief turn never starts
ok - opencode 1.x launches keep their pre-gate delivery
ok - opencode provisions a busy-state plugin for every detected major, including the 1.x fallback
ok - native effort validator checks harness and model as separate axes
ok - Ultra is explicit for native Pi and Pi-signed, including direct-PR, and refuses unsupported profiles before provisioning
ok - batch dispatch preserves native Ultra in metadata and launch flags
ok - Pi scout spawn enters the recorded worktree before launch
ok - pi receives --model and --thinking max profile flags
ok - Pi launch probing omits --tui-mode on older Pi and preserves it on supporting Pi
ok - pi-signed shares Pi launch semantics while preserving its configured and recorded identity
ok - pi-signed refuses safely and actionably when the selected executable is unavailable
ok - pi-signed is a distinct persistent secondmate runtime with shared Pi supervision semantics
ok - seeded Pi/pi-signed secondmate launches carry session --approve when advertised
ok - ordinary Pi worker launches omit --approve
ok - Pi approve probing omits --approve when help does not advertise it
ok - Pi and pi-signed ship and scout launches carry the configured tool exclusions
ok - Claude ship and scout launches carry the configured tool exclusions ahead of the prompt
ok - a Claude exclusion list adds only its own flag to the launch
ok - Pi worker registries report unmatched and unverified exclusions without reporting exact matches
ok - an absent or empty exclusion list leaves every runtime unaffected
ok - a runtime that cannot hide tools, or a raw launch, refuses a non-empty exclusion list
ok - a malformed exclusion entry refuses the spawn before any launch or record
ok - Pi and pi-signed ship and scout launches refuse when the exclusion file disappears after its checks
ok - exclusions stay in the home that configured them and skip secondmate agents
ok - batch dispatch forwards shared --harness, --model, and --effort to every pair
ok - Code Mode refuses batch dispatch before spawning either worker
ok - claude forwards firstmate's CLAUDE_CONFIG_DIR so the crewmate uses the same credential store
ok - the primary-owned Lavish server address reaches every worker launch
cat: /tmp/fm-spawn-dispatch-profile.iE1ECn/profile-lavish-ambient/pane.log: No such file or directory
ok - absent Lavish configuration preserves the destination environment
ok - claude omits the config-dir prefix when firstmate runs with the single-store default
ok - absent config/claude-permission-mode defaults to --dangerously-skip-permissions
ok - config/claude-permission-mode=auto opts into the model-reviewed launch
ok - explicit config/claude-permission-mode=bypass uses --dangerously-skip-permissions
ok - config/claude-permission-mode=auto reaches scout launches too
ok - claude worker launches cover the task-channel directories in bypass and auto modes
ok - an unrecognized config/claude-permission-mode token refuses before any endpoint or metadata
ok - config/claude-permission-mode changes claude launches only
ok - non-claude harnesses do not receive the claude CLAUDE_CONFIG_DIR prefix
ok - a claude task launch establishes only Firstmate's task control channels through the system prompt
ok - a persistent claude secondmate keeps its supervisor contract without a task-worker authority overlay
ok - fm-spawn: a Claude launch longer than 1024 bytes is delivered intact through the staging path
ok - a claude crewmate launch carries the attribution-off policy in its own settings
ok - keep-ai-trailers omits Claude attribution settings and the pane strip hooks
ok - keep-ai-trailers is inherited so a secondmate's crew launch keeps AI trailers
ok - a claude secondmate launch carries the attribution-off policy too
ok - active crew-dispatch profile does not block secondmate launches
# all fm-spawn-dispatch-profile tests passed
- Outcome: ⚠️ 1 warning across 1 run (14m39s)

Trial activation and validation limits

Validation coverage: a live isolated invocation of fm-spawn.sh verified that any batch dispatch with --code-mode refuses before creating task state.
The executable spawn-profile suite passed and executed emitted launch commands to cover single Claude ship/scout opt-in, recorded relaunch, environment allowlist filtering, and refusals for other harnesses, raw commands, secondmates, and T3 Code.
Those single-worker, relaunch, and unsupported-target scenarios were covered by the suite only; they were not driven against a real Claude worker in this validation run.
Firstmate will perform the live Claude proof after merge on the first real spawn with --code-mode, including the required human confirmation; startup refusals and speed remain to be observed.

Activation: pass --code-mode on the selected Claude ship or scout spawn.
That worker's launch assigns CLAUDE_CODE_EXPERIMENTAL_CODE_MODE=1.
A person must answer Claude Code's one-time confirmation dialog before the trial can proceed.

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

⏭️ **Rebase** - skipped

Step was skipped.

🔧 **Review** - 2 issues found → auto-fixed ✅
  • 🚨 bin/fm-spawn.sh:2244 - --code-mode is forwarded to every id=repo batch member. A two-pair Claude batch therefore starts two Code Mode workers, as the changed test intentionally verifies. This contradicts the required “Trial on one Claude worker” / “for that worker only” and “Nothing else changes” criteria. Remove batch forwarding or explicitly refuse Code Mode in batch mode; this is also the unrequired batch-expansion component.
  • 🚨 bin/fm-spawn.sh:2649 - A relaunch accepts a new --code-mode even when the existing task has no code_mode=1 record. For a prior Claude backend=t3code task, fm-spawn.sh ID --relaunch --code-mode skips the fresh-only T3 refusal, writes code_mode=1, but T3 ignores the pane $LAUNCH, so Code Mode is not enabled. Track whether the flag was supplied and reject it on relaunch; derive this setting solely from recorded task metadata.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⚠️ **Test** - 1 warning
  • ⚠️ live validation verdict: inconclusive (1 of 4 scenarios were driven live against the product); untested: A single Claude ship or scout starts with Code Mode enabled, A Code Mode task relaunches with its recorded opt-in, Unsupported Code Mode targets refuse before creating task state
  • Live validation: ⚠️ inconclusive - 1 of 4 scenarios driven live against the product
Scenario Result Live Evidence
A single Claude ship or scout starts with Code Mode enabled ⏸️ untested no Automated executable coverage passed, but a real worker was not spawned because this validation did not allocate a disposable project worktree and manually accept Claude’s required one-time confirmati…
A Code Mode task relaunches with its recorded opt-in ⏸️ untested no Automated executable coverage passed, but no real Claude task session was created and relaunched in this run.
Unsupported Code Mode targets refuse before creating task state ⏸️ untested no Covered by executable tests only; the live lab exercise focused on the batch boundary.
Batch dispatch with --code-mode refuses before either worker is created ✅ pass live Live batch-refusal transcript
  • tests/fm-spawn-dispatch-profile.test.sh (exit 0)
  • FM_HOME=<disposable lab> TMUX_TMPDIR=<private lab socket> bin/fm-spawn.sh code-mode-live-a=<worktree> code-mode-live-b=<worktree> --harness claude --code-mode --mode no-mistakes --yolo off (exit 1, expected)
  • git diff <base> | jev find "a change unrelated to experimental Claude Code Mode single-worker launch, recorded relaunch, guard refusals, or documentation" (no unrelated hunks flagged)
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T05:43:48.576624Z 682fb9e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Profreshor
Profreshor merged commit 0c82d6d into main Nov 18, 2026
46 of 48 checks passed
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