Skip to content

feat(herdr): add optional presentation spaces - #784

Merged
kunchenguid merged 5 commits into
mainfrom
fm/fm-herdr-presentation-projection
Jul 21, 2026
Merged

kunchenguid merged 5 commits into
mainfrom
fm/fm-herdr-presentation-projection

Conversation

@kunchenguid

Copy link
Copy Markdown
Owner

Intent

Implement Stage 1 of the captain-approved two-stage Herdr plan as a small default-off presentation-only disposable single-task projection. When the local config/herdr-presentation-spaces flag is present, only a clean fresh task with no metadata and no journal may atomically claim one task-scoped critical section shared by all spawn backends, record a random 128-bit visual correlator before external create, create a no-focus workspace, create the ordinary fm task tab from exact response IDs through a projection-specific path, and prune only the exact seeded tab from that same workspace-create response. Preserve existing Treehouse behavior and ordinary endpoint metadata, and retain no placeholder. Task endpoint records remain sole authority. Teardown closes only the exact recorded pane and never a workspace. Crash, restart, response loss, stale state, missing or renamed tokens, and duplicate-token ambiguity must never authorize adoption, reuse, close, or deletion; safe recovery degrades to the flat home workspace only when duplicate live-agent risk is independently absent. Claims must remain truthful: grouping is presentation-only and best-effort, disappears after Herdr restart, may leave stale spaces for manual cleanup, and exposes the token in the title. Do not add provider/API changes, a contiguity engine, cross-home cleanup, an ownership registry, Treehouse Stage 2 changes, or revive closed PR 751 or the dropped upstream Herdr request. Validate with unit tests and the guarded isolated-Herdr lab, including focus preservation, last-pane removal isolation, restart behavior, zero mutations for ambiguous token cases, byte-identical Treehouse commands and metadata shape except Herdr container IDs, exact seeded-tab-only pruning, and cross-backend concurrent-spawn serialization.

What Changed

  • Add a default-off config/herdr-presentation-spaces mode that gives clean, fresh Herdr tasks disposable single-task presentation workspaces while preserving existing endpoint metadata and default workspace behavior.
  • Serialize same-task spawns across backends and safely fall back to flat Herdr workspaces when stale or ambiguous projection state cannot authorize adoption or cleanup.
  • Restrict teardown to exact recorded panes, quarantine uncertain projection journals, and add documentation plus unit and isolated Herdr E2E coverage for projection safety and lifecycle behavior.

Risk Assessment

✅ Low: The default-off change is well-bounded, the prior response-loss cleanup defect is corrected before launch submission, and the reviewed source now conforms to the stated authority, recovery, and teardown constraints.

Testing

The successful baseline and repeated full suite were supplemented by focused Orca, Herdr, and teardown tests plus a guarded real-Herdr 0.7.4 lab that directly exercised the Stage 1 projection acceptance criteria; all relevant checks passed. No screenshot was captured because the isolated Herdr lab is headless and tears down its named session, so the direct CLI/API behavior transcript is provided instead.

Evidence: Guarded Herdr presentation E2E evidence

Real Herdr 0.7.4 transcript demonstrating focus preservation, exact-pane teardown isolation, restart fallback, ambiguous-token safety, and default-session protection.

ok - real Herdr lab: projected create leaves one normal task pane, no placeholder, and does not steal focus
ok - real Herdr lab: Treehouse commands and metadata shape are byte-identical except for Herdr container IDs
ok - real Herdr lab: exact task-pane close removes only the last-tab projection workspace and leaves its neighbor untouched
ok - real Herdr lab: restart preserves the token label as an agent-free husk that is left untouched while the task respawns flat
warning: no exact herdr presentation token match for missing1; leaving any stale space untouched and spawning flat
warning: no exact herdr presentation token match for renamed1; leaving any stale space untouched and spawning flat
warning: 2 exact herdr presentation token matches for duplicate1 are quarantined; inspecting only for duplicate-agent risk
warning: quarantined herdr presentation for duplicate1 is dead or agent-free; leaving it untouched and spawning flat
warning: 2 exact herdr presentation token matches for duplicate1 are quarantined; inspecting only for duplicate-agent risk
error: quarantined herdr presentation for duplicate1 has a live pane; refusing duplicate launch
ok - real Herdr lab: missing, renamed, and duplicate tokens trigger zero destructive or adoptive calls, and live duplicate risk refuses launch
ok - real Herdr lab validation completed on Herdr 0.7.4 with the default-session tripwire intact
- Outcome: 🔧 1 issue found → auto-fixed ✅ across 2 runs (2h9m35s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • 🚨 bin/fm-spawn.sh:1172 - Intent requires that "Crash [and] response loss ... must never authorize ... close or deletion," but cleanup remains armed through spawn_send_key "$T" Enter and is disabled only afterward. If Herdr accepts Enter and its response is lost, set -e invokes the EXIT trap, which closes the now-running task pane and can implicitly delete its last-pane workspace. Disarm projection abort cleanup before the ambiguous Enter submission, accepting a stale space when submission cannot be confirmed.

🔧 Fix: Captain, disarm Herdr cleanup before launch submission
✅ Re-checked - no issues remain.

🔧 **Test** - 1 issue found → auto-fixed ✅
  • 🚨 tests failed with exit code 1
  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"

🔧 Fix: Correct stale Orca metadata failure fixture
✅ Re-checked - no issues remain.

  • command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • Supplied successful baseline: command -v tmux >/dev/null || { echo "tmux is required for e2e tests" >&2; exit 1; }; tmux -V; rc=0; for t in tests/*.test.sh; do echo "== $t =="; bash "$t" || rc=1; done; exit "$rc"
  • bash tests/fm-backend-orca.test.sh
  • bash tests/fm-backend-herdr.test.sh
  • bash tests/fm-teardown.test.sh
  • bash tests/fm-backend-herdr-presentation-e2e.test.sh
  • Repeated the unchanged configured full-suite command and observed it traverse all test scripts to completion
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.