Skip to content

feat(self-fix): worktree-based self-fix flow for firstmate's own tracked code - #2

Merged
chanjdaniel merged 3 commits into
mainfrom
fix/self-fix-bootstrap
Jul 11, 2026
Merged

chanjdaniel merged 3 commits into
mainfrom
fix/self-fix-bootstrap

Conversation

@chanjdaniel

Copy link
Copy Markdown
Collaborator

Intent

Bootstrap firstmate's self-fix capability. firstmate could not ship fixes to its own tracked code (bin/, AGENTS.md, .agents/skills/, docs/) because this repo is not treehouse-pooled (so fm-spawn cannot get an isolated worktree for it) and the primary checkout must stay on its default branch (the tangle guard alarms otherwise). This change adds a worktree-based self-fix flow so it can: new bin/fm-self-fix.sh creates an isolated plain git worktree of this repo on a fix/<id> branch rooted outside any FM_HOME, then dispatches a crewmate into it via a new fm-spawn --worktree mode. The primary checkout never leaves its default branch. This is the one-time human-bootstrap commit for keystone task fm-self-fixable-k1; thereafter every self-fix ships through this flow.

What changed

  • Add bin/fm-self-fix.sh - creates the isolated worktree and dispatches the crewmate.
  • Extend bin/fm-spawn.sh with a flag-gated --worktree mode (selffix=1 meta marker); it reuses the existing isolation assertion to reject a bad worktree path.
  • Extend bin/fm-teardown.sh with a selffix=1 cleanup branch that reuses the existing landed-work safety check unchanged and only swaps the cleanup verb to git worktree remove.
  • Document the flow in AGENTS.md, docs/architecture.md, docs/scripts.md.

Deliberate decisions

  1. Plain git worktree rather than treehouse-pooling this repo - intentionally lighter, no pool setup.
  2. Scoped to the tmux backend only for this bootstrap; herdr/zellij/orca/cmux are a deliberate later follow-up.
  3. Every change is gated behind the --worktree flag / selffix=1 marker, so all existing spawn and teardown paths are byte-identical when the flag is absent - zero behavior change for normal tasks.
  4. Teardown's --force in the selffix branch is safe by construction because it runs only after the landed-work safety check has already passed; it never bypasses unlanded-work protection.

Validation

Passed the full gate: code review (two findings applied and approved - enforce tmux-only, skip fleet-sync on selffix teardown), test suite passed clean, docs written, lint clean.

…s own fixes through the gate

Add bin/fm-self-fix.sh, which creates an isolated git worktree of this repo on a
fix branch (rooted outside any FM_HOME) and dispatches a crewmate into it via a
new fm-spawn --worktree mode - so firstmate can fix its own tracked code through
the no-mistakes gate without treehouse pooling and without moving the primary
checkout off its default branch.

- fm-spawn.sh: --worktree <path> skips treehouse get, uses the pre-created
  isolated worktree (same isolation assertion), starts the tmux window in it, and
  records selffix=1 in meta. All paths are byte-unchanged when the flag is absent.
- fm-teardown.sh: selffix=1 tasks are cleaned with git worktree remove (after the
  unchanged landed-work safety check), not a treehouse return.

Scoped to the tmux backend; other backends are a later follow-up.
@chanjdaniel
chanjdaniel merged commit 1b16a82 into main Jul 11, 2026
chanjdaniel added a commit that referenced this pull request Jul 11, 2026
…ked code (#2)

* feat(self-fix): worktree-based self-fix flow so firstmate can ship its own fixes through the gate

Add bin/fm-self-fix.sh, which creates an isolated git worktree of this repo on a
fix branch (rooted outside any FM_HOME) and dispatches a crewmate into it via a
new fm-spawn --worktree mode - so firstmate can fix its own tracked code through
the no-mistakes gate without treehouse pooling and without moving the primary
checkout off its default branch.

- fm-spawn.sh: --worktree <path> skips treehouse get, uses the pre-created
  isolated worktree (same isolation assertion), starts the tmux window in it, and
  records selffix=1 in meta. All paths are byte-unchanged when the flag is absent.
- fm-teardown.sh: selffix=1 tasks are cleaned with git worktree remove (after the
  unchanged landed-work safety check), not a treehouse return.

Scoped to the tmux backend; other backends are a later follow-up.

* no-mistakes(review): enforce tmux-only self-fix and skip fleet-sync on selffix teardown

* no-mistakes(document): document worktree-based self-fix flow in scripts, AGENTS, architecture docs
chanjdaniel added a commit that referenced this pull request Jul 11, 2026
…ked code (#2)

* feat(self-fix): worktree-based self-fix flow so firstmate can ship its own fixes through the gate

Add bin/fm-self-fix.sh, which creates an isolated git worktree of this repo on a
fix branch (rooted outside any FM_HOME) and dispatches a crewmate into it via a
new fm-spawn --worktree mode - so firstmate can fix its own tracked code through
the no-mistakes gate without treehouse pooling and without moving the primary
checkout off its default branch.

- fm-spawn.sh: --worktree <path> skips treehouse get, uses the pre-created
  isolated worktree (same isolation assertion), starts the tmux window in it, and
  records selffix=1 in meta. All paths are byte-unchanged when the flag is absent.
- fm-teardown.sh: selffix=1 tasks are cleaned with git worktree remove (after the
  unchanged landed-work safety check), not a treehouse return.

Scoped to the tmux backend; other backends are a later follow-up.

* no-mistakes(review): enforce tmux-only self-fix and skip fleet-sync on selffix teardown

* no-mistakes(document): document worktree-based self-fix flow in scripts, AGENTS, architecture docs
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