Skip to content

fix: pre-register Claude trust for secondmate homes - #4262

Merged
kunchenguid merged 2 commits into
mainfrom
fm/fm-secondmate-claude-trust-standalone-home-r1
Sep 12, 2026
Merged

kunchenguid merged 2 commits into
mainfrom
fm/fm-secondmate-claude-trust-standalone-home-r1

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Routed firstmate fix, captain approved (main firstmate corr=0f149f24b15a3312; nudge corr=22bcb3cf668db4e4).
BUG: bin/fm-spawn.sh --secondmate on the claude harness does not pre-register Claude workspace trust (hasTrustDialogAccepted) for a STANDALONE-CLONE secondmate home (an explicit path like ~/fm-homes/), so the launched claude secondmate wedges at the "Is this a project you trust?" dialog. Hit live today creating the nomistakes-n1 secondmate.
ROOT CAUSE: bin/fm-claude-trust.sh only registers LINKED git worktrees and by design refuses a primary checkout / standalone home / plain dir. A treehouse-leased ("-") secondmate home is a linked worktree so trust works, but an explicit standalone-clone home is skipped, so no trust is registered and the dialog appears.

What Changed

  • Pre-register Claude workspace trust before launching secondmates in standalone-clone or leased-worktree homes.
  • Add a fail-closed secondmate-home trust mode that validates seed markers, identity, instance files, and operational directory boundaries.
  • Expand automated coverage and documentation for secondmate trust registration, refusal cases, and launch behavior.

Risk Assessment

✅ Low: The change is well-bounded, fail-closed, preserves existing worktree behavior, and behaviorally covers both standalone-clone and leased-worktree secondmate homes.

Testing

The targeted trust/spawn behavior suite passed; the previous standalone-clone refusal was reproduced, the fixed helper persisted trust that real Claude consumed without showing the project-trust dialog, and adversarial homes were refused without state changes. Full live fm-spawn --secondmate was blocked by the gate-agent safety guard, so its wiring was exercised through the focused executable integration test with fake tmux. No screenshot was captured because this is terminal startup behavior rather than a visual-layout change; the rendered tmux pane transcript is preserved.

  • Live validation: ✅ go - 2 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Register a standalone-clone secondmate home and enter real Claude without the project-trust dialog ✅ pass live live-registration.log records hasTrustDialogAccepted: true; live-claude-pane-clean.txt shows real Claude advancing to “Let's get started” and theme selection rather than “Is this a project you t…
Spawn a Claude secondmate into a standalone-clone home and deliver its charter using the same trusted store ⏸️ untested no A real fleet spawn is intentionally refused in this environment because NO_MISTAKES_GATE=1 and the checkout is a no-mistakes gate worktree. Re-run from a normal firstmate checkout outside an active…
Refuse homes marked for another secondmate or whose operational directory escapes the home ✅ pass live live-boundary-and-baseline.log shows both executable invocations exiting 1 with specific refusal diagnostics and trusted=false.
Refuse the secondmate spawn when trust cannot be recorded instead of launching a wedged pane ⏸️ untested no The no-mistakes gate-agent guard prevents a real fleet spawn here. Re-run the focused failure scenario from a normal firstmate environment with a disposable unsafe Claude store to verify the real back…
Evidence: Targeted Claude trust and spawn behavior suite

Source: Targeted Claude trust and spawn behavior suite

ok - fm-claude-trust.sh: a fresh task worktree is trusted
ok - fm-claude-trust.sh: repeat registration is idempotent
ok - fm-claude-trust.sh: refuses the primary checkout
ok - fm-claude-trust.sh: an exported CDPATH cannot defeat the scope refusal
ok - fm-claude-trust.sh: inherited git environment overrides cannot defeat the scope refusal
ok - fm-claude-trust.sh: refuses a home directory the git checks would accept
ok - fm-claude-trust.sh: refuses the Claude config directory
ok - fm-claude-trust.sh: refuses a relative CLAUDE_CONFIG_DIR
ok - fm-claude-trust.sh: refuses a directory that is not a git worktree
ok - fm-claude-trust.sh: refuses a path that does not exist
ok - fm-claude-trust.sh: refuses a worktree belonging to another project
ok - fm-claude-trust.sh: refuses a subdirectory of the worktree
ok - fm-claude-trust.sh: preserves unrelated store content
ok - fm-claude-trust.sh: refuses a store symlinked to another user's file
ok - fm-claude-trust.sh: follows a store symlink to this user's own file and leaves the link intact
ok - fm-claude-trust.sh: refuses an unparseable store and leaves it untouched
ok - fm-claude-trust.sh: a missing node is refused rather than degraded
ok - fm-claude-trust.sh: a scope refusal stays fail-closed without node
ok - fm-spawn.sh: a claude spawn pre-trusts its worktree and launches with the brief
ok - fm-spawn.sh: a trust-refused claude spawn leaves no task state behind
ok - fm-spawn.sh: a claude secondmate spawn pre-trusts a standalone-clone home
ok - fm-spawn.sh: a claude secondmate spawn pre-trusts a leased worktree home
ok - fm-claude-trust.sh: home-level trust is refused for everything but a home seeded for this secondmate
ok - fm-claude-trust.sh: worktree mode still refuses a secondmate home
ok - fm-spawn.sh: a claude secondmate spawn refuses when home trust cannot be recorded
Evidence: Live standalone-home trust registration and persisted vendor state

Source: Live standalone-home trust registration and persisted vendor state

trusted: ~/.no-mistakes/worktrees/52b07e9083e7/01M29VP8DVACPVK3X2366BWMVM/.test-live-claude-trust/standalone-home
{
  "path": "~/.no-mistakes/worktrees/52b07e9083e7/01M29VP8DVACPVK3X2366BWMVM/.test-live-claude-trust/standalone-home",
  "hasTrustDialogAccepted": true
}
Evidence: Real Claude interactive pane after trust registration

Source: Real Claude interactive pane after trust registration

     *                                       █████▓▓░
                                 *         ███▓░     ░░
            ░░░░░░                        ███▓░
    ░░░   ░░░░░░░░░░                      ███▓░
   ░░░░░░░░░░░░░░░░░░░    *                ██▓░░      ▓
                                             ░▓▓███▓▓░
 *                                 ░░░░
                                 ░░░░░░░░
                               ░░░░░░░░░░░░░░░░
       █████████                                        *
      ██▄█████▄██                        *
       █████████      *
.......█ █   █ █..........................................

 Let's get started.

 Choose the text style that looks best with your terminal
 To change this later, run /theme

   1. Auto (match terminal)
 ❯ 2. Dark mode ✔
   3. Light mode
   4. Dark mode (colorblind-friendly)
   5. Light mode (colorblind-friendly)
   6. Dark mode (ANSI colors only)
   7. Light mode (ANSI colors only)

 ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
  1  function greet() {
  2 -  console.log("Hello, World!");                                                                               
  2 +  console.log("Hello, Claude!");                                                                              
  3  }
 ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌
  Syntax theme: Monokai Extended (ctrl+t to disable)
Evidence: Baseline reproduction and adversarial boundary refusals

Source: Baseline reproduction and adversarial boundary refusals

SCENARIO: baseline reproduces standalone-home trust failure
error: refusing to pre-register Claude trust: '~/.no-mistakes/worktrees/52b07e9083e7/01M29VP8DVACPVK3X2366BWMVM/.test-live-claude-trust/standalone-home' is a primary checkout, not an isolated worktree
baseline_exit=1

SCENARIO: marker for another secondmate is refused without state change
error: refusing to pre-register Claude trust: '~/.no-mistakes/worktrees/52b07e9083e7/01M29VP8DVACPVK3X2366BWMVM/.test-live-claude-trust/standalone-home' is marked for secondmate 'other-n1', not 'nomistakes-n1'
wrong_id_exit=1
wrong_id_trusted=false (store not created)

SCENARIO: escaping projects directory is refused without state change
error: refusing to pre-register Claude trust: '~/.no-mistakes/worktrees/52b07e9083e7/01M29VP8DVACPVK3X2366BWMVM/.test-live-claude-trust/standalone-home/projects' resolves to '~/.no-mistakes/worktrees/52b07e9083e7/01M29VP8DVACPVK3X2366BWMVM/.test-live-claude-trust/outside-projects', outside the home, so '~/.no-mistakes/worktrees/52b07e9083e7/01M29VP8DVACPVK3X2366BWMVM/.test-live-claude-trust/standalone-home' is not a safe secondmate home
escaping_dir_exit=1
escaping_dir_trusted=false (store not created)

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 - 2 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Register a standalone-clone secondmate home and enter real Claude without the project-trust dialog ✅ pass live live-registration.log records hasTrustDialogAccepted: true; live-claude-pane-clean.txt shows real Claude advancing to “Let's get started” and theme selection rather than “Is this a project you t…
Spawn a Claude secondmate into a standalone-clone home and deliver its charter using the same trusted store ⏸️ untested no A real fleet spawn is intentionally refused in this environment because NO_MISTAKES_GATE=1 and the checkout is a no-mistakes gate worktree. Re-run from a normal firstmate checkout outside an active…
Refuse homes marked for another secondmate or whose operational directory escapes the home ✅ pass live live-boundary-and-baseline.log shows both executable invocations exiting 1 with specific refusal diagnostics and trusted=false.
Refuse the secondmate spawn when trust cannot be recorded instead of launching a wedged pane ⏸️ untested no The no-mistakes gate-agent guard prevents a real fleet spawn here. Re-run the focused failure scenario from a normal firstmate environment with a disposable unsafe Claude store to verify the real back…
  • tests/fm-claude-trust.test.sh
  • Executed the base-commit trust helper against a standalone clone to reproduce the primary-checkout refusal.
  • Executed bin/fm-claude-trust.sh --secondmate-home <standalone-home> nomistakes-n1 with an isolated Claude store and inspected the persisted JSON contract.
  • Launched the installed Claude Code 2.1.269 interactively in tmux using the isolated trusted store and captured its first rendered screen.
  • Executed wrong-secondmate-ID and escaping-projects-directory adversarial registrations and verified neither created trust state.
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.