Skip to content

feat(bin): add opt-in host-root supervision - #1238

Open
YrFnS wants to merge 128 commits into
kunchenguid:mainfrom
YrFnS:feat/host-root-mode-upstream
Open

feat(bin): add opt-in host-root supervision#1238
YrFnS wants to merge 128 commits into
kunchenguid:mainfrom
YrFnS:feat/host-root-mode-upstream

Conversation

@YrFnS

@YrFnS YrFnS commented Jul 29, 2026

Copy link
Copy Markdown

Intent

Keep FirstMate operable from an opt-in external instruction root (FM_HOST_ROOT) while preserving normal unset behavior, isolated target-worktree workers, native Windows Herdr support, endpoint identity, teardown safety, and SecondMate recovery.

What Changed

  • Added opt-in host-root supervision and host-owned task/session authority.
  • Launches ordinary workers from isolated FM_TARGET_WORKTREE checkouts; primary Pi/OpenCode host plugins stay inert inside target workers.
  • Binds tmux lifecycle actions to the recorded cwd/socket/marker instead of ambient tmux state.
  • Binds Herdr lifecycle actions to the exact workspace/tab/pane/task-label relationship, uses nonce-scoped cwd probes, and revalidates immediately before cleanup.
  • Makes authorized host relaunch and SecondMate recovery transactional, including restoration of all prior per-task artifacts after failed recovery.
  • Stops and verifies endpoints before returning target worktrees.
  • Extends changed-source test routing so host-root, spawn recovery, and every OpenCode primary plugin select their behavioral regressions.

Safety Fixes Included

This update closes all confirmed review and audit blockers:

  1. Recorded tmux authority for control and foreground inspection.
  2. Authorized host-root relaunch without wrong-root takeover.
  3. Transactional SecondMate metadata/status/turn-end/harness recovery.
  4. Nonce-bound native Windows Herdr cwd polling.
  5. Origin-host authority for decision decline/repair.
  6. fm_tmux_cli use for tmux foreground probes.
  7. Pi/OpenCode primary-plugin isolation in target workers.
  8. Home-wide host session authority for unset or conflicting roots.
  9. Herdr workspace/tab/pane/task-label ownership validation.
  10. Immediate Herdr ownership recheck before close and stop-before-return ordering.
  11. Relaunch authority validation before fm-guard.sh can mutate supervision state.
  12. Refusal to open host-A records from host B.
  13. Conservative changed-test routing with independent plugin-path regressions.

Risk Assessment

High-touch lifecycle change, mitigated. The code affects spawn, control, recovery, and cleanup boundaries, so regressions could otherwise target the wrong endpoint or return an in-use worktree. The implementation now fails closed on identity/authority mismatch and has behavioral regressions at each destructive boundary. No known implementation blocker remains from the completed reviews.

Validation

Validated at head 7c8d4675f5ea0577421944f09f641bcdb7c9c7c0, rebased onto origin/main f1a4af426d7199c1781bc91ccd143b8e1f732d10:

  • bash bin/fm-lint.sh
  • bash bin/fm-doc-audience-check.sh
  • bin/fm-test-run.sh --check-coverage
  • git diff --check
  • Bash syntax checks for every modified shell file
  • Focused host control/relaunch, host authority, Pi/OpenCode isolation, backend stop verification, Herdr binding/cwd/reuse, SecondMate recovery, teardown, and decision-lifecycle regressions
  • Full tests/fm-secondmate-liveness.test.sh
  • Full tests/fm-decision-hold-lifecycle.test.sh
  • Canonical targeted SecondMate, decision-lifecycle, Pi-plugin-isolation, lint, and documentation-audience families
  • Two independent whole-diff Pi reviews plus a final routing review; all actionable findings were fixed

The full local suite still encounters pre-existing MSYS/Windows fixture limitations also reproduced on the baseline (symlink handling, CRLF-sensitive Herdr output, process ancestry/ps, date-sensitive fixtures, and the existing fm-test-run jobs-scheduling fixture). Hosted GitHub workflows are pending upstream maintainer approval.

Merge

This PR has not been merged. Please approve and run the hosted workflows before merge.

@kunchenguid

kunchenguid commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#1238 at eb42af2e.

@YrFnS
YrFnS force-pushed the feat/host-root-mode-upstream branch from eb42af2 to 39e7244 Compare July 30, 2026 07:48
@YrFnS YrFnS changed the title feat: activate FirstMate from external host roots feat: add external host-root mode Jul 30, 2026
@kunchenguid kunchenguid removed the wheelhouse:pending-contributor-action Managed by Wheelhouse label Jul 30, 2026
@kunchenguid

kunchenguid commented Jul 30, 2026

Copy link
Copy Markdown
Owner

Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#1238 at 39e72446.

@kunchenguid

Copy link
Copy Markdown
Owner

Automated reminder: thanks for the PR! This branch currently has a merge conflict with the base branch.

When you get a chance, please rebase onto (or merge) the latest base branch, resolve the conflict, and push. After that, checks will re-run and the PR will get looked at again.

Noted for firstmate#1238 at baa5ef04.

@YrFnS
YrFnS force-pushed the feat/host-root-mode-upstream branch from baa5ef0 to 929cbb4 Compare August 1, 2026 11:27
@YrFnS

YrFnS commented Aug 1, 2026

Copy link
Copy Markdown
Author

Rebased this PR onto current main and updated the host-root topology: the external host remains the supervisor authority, while ordinary ship/scout workers launch in their isolated target worktrees and load target-repository instructions natively. FirstMate briefs, completion signaling, recovery metadata, teardown safety, and SecondMate isolation remain intact.

Validation at head 929cbb4c passed no-mistakes review, focused host-root/Orca/real-Herdr checks, the complete behavior suite, documentation checks, and pinned ShellCheck lint. One unrelated Calm/Pi 12-second notification wait was intermittent; it passed in the preceding full run and on immediate isolated retry.

The new upstream Actions runs are currently action_required with no jobs, so they need maintainer approval before CI can execute:

@YrFnS
YrFnS force-pushed the feat/host-root-mode-upstream branch from 929cbb4 to 03c25bc Compare August 2, 2026 07:08
@YrFnS YrFnS changed the title feat: add external host-root mode feat: add optional host-root mode Aug 2, 2026
@YrFnS
YrFnS force-pushed the feat/host-root-mode-upstream branch 2 times, most recently from 3fc65f4 to 7a05d4f Compare August 3, 2026 01:35
@YrFnS YrFnS changed the title feat: add optional host-root mode feat: add optional host-root supervisor mode Aug 3, 2026
@YrFnS YrFnS changed the title feat: add optional host-root supervisor mode feat: add optional host-root mode Aug 3, 2026
YrFnS and others added 23 commits August 15, 2026 20:13
Keep the synthetic Claude process identity portable across Bash builds and ensure the host-root Herdr acceptance uses its compatible tasks-axi fixture for decision inventory.
@YrFnS
YrFnS force-pushed the feat/host-root-mode-upstream branch from 3bec19f to 7c8d467 Compare August 15, 2026 17:19
YrFnS added 5 commits August 16, 2026 09:32
# Conflicts:
#	.pi/extensions/fm-primary-pi-watch.ts
#	tests/fm-pi-watch-extension.test.sh
# Conflicts:
#	.agents/skills/secondmate-provisioning/SKILL.md
#	.pi/extensions/fm-primary-pi-watch.ts
#	AGENTS.md
#	bin/backends/herdr.sh
#	bin/backends/zellij.sh
#	bin/fm-backend.sh
#	bin/fm-control.sh
#	bin/fm-decision-hold.sh
#	bin/fm-host-root-lib.sh
#	bin/fm-promote.sh
#	bin/fm-remote-secondmate-control.sh
#	bin/fm-send.sh
#	bin/fm-session-start.sh
#	bin/fm-spawn.sh
#	bin/fm-supervision-instructions.sh
#	bin/fm-teardown.sh
#	bin/fm-tmux-lib.sh
#	bin/fm-wake-lib.sh
#	docs/sessionstart-nudge.md
#	docs/verification/runtime-backends.md
#	tests/fm-backend-herdr-host-root-e2e.test.sh
#	tests/fm-backend-herdr.test.sh
#	tests/fm-backend.test.sh
#	tests/fm-calm-pi-extension.test.sh
#	tests/fm-control-relaunch.test.sh
#	tests/fm-control.test.sh
#	tests/fm-gotmp.test.sh
#	tests/fm-host-root-mode.test.sh
#	tests/fm-pi-primary-types.test.sh
#	tests/fm-secondmate-liveness.test.sh
#	tests/fm-teardown.test.sh
#	tests/fm-turnend-guard.test.sh
#	tests/fm-watcher-lock.test.sh
# Conflicts:
#	.agents/skills/secondmate-provisioning/SKILL.md
#	bin/fm-x-link.sh
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