Repository navigation
feat(herdr): order presentation spaces while preserving focus - #790
Merged
Merged
Conversation
JTInventory
added a commit
to JTInventory/firstmate
that referenced
this pull request
Jul 26, 2026
#77) * feat(herdr): add optional presentation spaces (kunchenguid#784) * feat(herdr): add optional presentation spaces * no-mistakes(review): Harden Herdr projection creation and spawn serialization * no-mistakes(review): Captain, disarm Herdr cleanup before launch submission * no-mistakes(test): Correct stale Orca metadata failure fixture * no-mistakes(document): Document Herdr presentation projection accurately * feat(herdr): order presentation spaces while preserving focus (kunchenguid#790) * feat(herdr): order presentation worker spaces * fix(herdr): preserve focus during projected cleanup * no-mistakes(review): Serialize Herdr cleanup and protect active seeded tabs * no-mistakes(review): Serialize Herdr aborts with guarded focus regressions * no-mistakes(review): Fall back flat when Herdr serialization is unavailable * no-mistakes(test): Stabilize watcher startup and AFK handoff tests * no-mistakes(document): Correct Herdr ordering and focus documentation * fix(herdr): group projected children beneath owning parents (kunchenguid#821) * feat(herdr): correct all-home child presentation topology Inherit the presentation opt-in to secondmate homes, label new projected spaces with the approved corner format, insert each child under its owning parent under one session-scoped lock, and keep flat non-destructive fallback. * no-mistakes(review): Exclude secondmates from Herdr presentation projection * no-mistakes(review): Harden shared Herdr locks and ambiguous child ordering * no-mistakes(review): Use adjacency-only Herdr child ownership * no-mistakes(review): Reject foreign legacy projections safely * no-mistakes(review): Validate Herdr session sockets before projection * no-mistakes(test): Fix Herdr teardown fixture session socket metadata * fix(herdr): canonicalize presentation lock socket paths Always resolve the session socket parent directory so symlink parents such as /tmp -> /private/tmp cannot split the shared cross-home lock identity. Refuse relative socket paths. Clarify lock-unavailable warnings. * no-mistakes(test): Fix Bash-compatible GitLab merge request URL parsing * no-mistakes(document): Document all-home Herdr child topology * no-mistakes(lint): Quote fallback provenance string for ShellCheck * feat: require pinned real-Herdr CI coverage (kunchenguid#838) * feat: add required pinned Herdr CI lane Install exact Herdr 0.7.4 and Treehouse 2.0.1 with official assets and SHA-256 pins, run the real-herdr-gated family serially through fm-test-run with hard-fail on herdr-not-found, and keep portable Behavior free of claimed Herdr coverage. * no-mistakes(document): Consolidate real-Herdr CI documentation ownership * no-mistakes: apply CI fixes * no-mistakes: apply CI fixes * no-mistakes: apply CI fixes * fix(herdr): reclaim resumed task projections after restart (kunchenguid#967) * fix(herdr): reclaim resumed task projections safely * no-mistakes(review): Enforce safe Herdr reclaim close boundaries * no-mistakes(document): docs: clarify Herdr restart projection contract * fix(herdr): clean stale projections at session start (kunchenguid#996) * Clean stale Herdr projections at session start * no-mistakes(document): Document stale Herdr session-start projection cleanup * no-mistakes(review): Enforce locked exact Herdr projection cleanup * no-mistakes(review): Fail closed on unverified session lock ownership * no-mistakes(review): Serialize session lock acquisition atomically * no-mistakes(document): Align session-start and Herdr cleanup documentation * no-mistakes(document): Generalize lock-refusal diagnostics * no-mistakes(lint): Avoid reserved keyword in concurrency test * no-mistakes: apply CI fixes * no-mistakes: apply CI fixes * fix(send): treat opencode busy-queued composer state as submitted (kunchenguid#775) * fix(send): treat opencode busy-queued composer state as submitted When fm-send sends a message to a BUSY opencode crewmate on the tmux backend, opencode accepts the Enter and queues the message for the next turn, but leaves the typed text visible in the composer row. The submit-verification loop sees a pending composer, exhausts retries, and reports a false "Enter swallowed" failure while the message is actually delivered. Fix: after Enter retries are exhausted and the composer still shows pending, check fm_pane_is_busy. If the pane is busy (agent mid-turn, footer shows "esc interrupt"), the harness queued the message, so return "empty" (accepted). On an idle pane, keep returning "pending" (genuine swallow detection preserved). Regression tests cover four scenarios: - busy pane + pending composer -> empty (message queued) - idle pane + pending composer -> pending (genuine swallow) - busy pane + composer clears on first Enter -> empty - idle pane + composer clears on first Enter -> empty (existing path) * docs: document busy-queued Enter exception across backend docs and skills Add explanatory comments and backend documentation for the busy-queued Enter fix (opencode 1.18.4 accepts Enter mid-turn but keeps typed text in composer until the turn ends): - bin/fm-tmux-lib.sh: document the busy-aware fallback in the file header and above fm_tmux_submit_enter_core - .agents/skills/afk/SKILL.md: daemon-facing policy note - .agents/skills/harness-adapters/SKILL.md: harness-specific fact - docs/tmux-backend.md: submit-acknowledgement section with the busy-queue exception - docs/herdr-backend.md: record the known gap - docs/architecture.md: cross-reference in the daemon section * test(tmux): fix SC2181 and make busy-submit test executable * fix: prevent AFK idle stalls and stale run attribution (kunchenguid#758) * fix(supervision): verb-aware captain relevance, AFK wedge, head-bound state Stop free-text tokens like "merged" from promoting nonterminal working: lines to captain-relevant, so AFK no longer permanently suppresses idle recovery. Defend wedge aging independently for nonterminal progress verbs, bind no-mistakes current-state attribution to code identity (not branch alone), and mark setup-complete as nonterminal in the ship brief scaffold. * no-mistakes(review): Enforce nonterminal suppression and head-bound run attribution * no-mistakes(document): Document current-code-bound run attribution * no-mistakes(test): Wait for stable Herdr shell readiness * no-mistakes(test): Make Herdr and watcher readiness tests deterministic * no-mistakes(test): Make tmux capture and watcher lifecycle deterministic * no-mistakes(document): Document corrected supervision contracts * fix(herdr): preserve fork labels across upstream reliability series * fix(bin): send literal config reread nudges after pushes (kunchenguid#809) * Send literal config reread after inherited config push When declared inherited config changes under an already-running secondmate, build a per-home instruction from validated destination post-write bytes and deliver it on the routed secondmate path. Unchanged config sends nothing; ABSENT represents removal; captain-shared is never inlined. Covers mid-session config-push and the locked bootstrap convergence path without hardening spawn against deliberate runtime choice. * no-mistakes(review): Fix config reread framing, partial propagation, and respawn order * no-mistakes(review): Send config rereads via durable single-line pointers * no-mistakes(review): Make failed config rereads retryable * no-mistakes(review): Make config reread retries generation-safe * no-mistakes(review): Make config rereads durable and ordered * no-mistakes(review): Drain retries, bound history, preserve detect-only read-only mode * no-mistakes(review): Retain write retries and quarantine stale respawn generations * no-mistakes(review): Preserve exact config reread retries and delivery order * no-mistakes(review): Preserve exact retry bytes and bounded quarantine pruning * no-mistakes(document): Consolidated config-reread documentation * fix(herdr): reconcile upstream reliability with fork contracts * no-mistakes(review): Harden Herdr lifecycle and real-CI coverage * no-mistakes(review): Harden Herdr lifecycle, delivery, and CI contracts * no-mistakes(review): Harden Herdr lifecycle, inheritance, and CI * no-mistakes(review): Harden Herdr recovery, teardown, and inheritance contracts * no-mistakes(review): Harden Herdr send and lifecycle uncertainty handling * no-mistakes(review): Harden Herdr mutation and teardown failure handling * no-mistakes(review): Enforce Herdr identity and truthful pending verdicts * no-mistakes(review): Implement truthful Herdr final Enter submission * no-mistakes(review): Harden Herdr final Enter ownership verification * no-mistakes(review): Require idle proof for Herdr final Enter * no-mistakes(review): Order Herdr ownership before idle proof * no-mistakes(test): Restore flat Herdr spawning without presentation locks * no-mistakes(document): Correct Herdr documentation and proof references * no-mistakes(document): Isolate Herdr routing test from gate refusal * no-mistakes(lint): Remove unused Herdr lint variables * no-mistakes: apply CI fixes * no-mistakes: apply CI fixes --------- Co-authored-by: Kun Chen <[email protected]> Co-authored-by: Kostadin Pop-Kochev <[email protected]> Co-authored-by: jjames27th-eng <[email protected]>
samchu8
added a commit
to SABS-Technology/firstmate
that referenced
this pull request
Jul 28, 2026
Intent
Ship the narrow Herdr presentation ordering follow-up on merged Stage 1. When config/herdr-presentation-spaces is enabled, keep firstmate first, one stable contiguous primary-worker block immediately after it, and unchanged secondmate relative order. Use only the exact response-derived current projected workspace ID and Herdr protocol 16 workspace.move. Keep ordering presentation-only, best-effort, non-destructive, and warning-only on unavailable, ambiguous, or failed moves. Preserve the flag-off command sequence and all Stage 1 crash, restart, response-loss, task-record, Treehouse, flat-fallback, and no-adoption guarantees. Fix the live focus regression identified at exact projected task pane close: every projected create, task-tab create, seeded prune, move, abort cleanup, and normal cleanup must preserve the named session's exact active workspace and active tab; serialize concurrent focus-sensitive cleanup, restore only the exact pre-operation tab when Herdr moves focus, and refuse cleanup if the target is the active tab or focus authority is ambiguous. Validate only in the guarded named Herdr lab, including raw per-operation focus instrumentation, repeated concurrent create/order/cleanup waves, forced move failure, feature-off behavior, exact order, and zero workspace close/delete/adoption authority.
What Changed
firstmateusing the exact response-derived workspace ID and Herdr protocol 16workspace.move, while preserving secondmate order and falling back safely when ordering is unavailable.Risk Assessment
✅ Low: Captain, the bounded contention path now falls back before publishing a journal or performing projection operations, while the serialized projection, cleanup, exact-ID, focus, and guarded-lab contracts remain intact.
Testing
The pre-supplied full-suite baseline passed; targeted Herdr backend tests, a guarded real-Herdr end-to-end run with direct CLI evidence, and three repetitions each of both prior timing failures all passed, demonstrating stable presentation ordering, exact focus preservation, warning-only fallbacks, and non-destructive recovery.
Evidence: Herdr presentation E2E evidence
Real Herdr 0.7.4 lab transcript demonstrating flag-off parity, exact ordering, warning-only move failure, focus restoration, repeated concurrent waves, and zero destructive adoption.Evidence: Herdr backend regression evidence
Evidence: AFK watcher triage repeated evidence
Evidence: Watcher lock repeated evidence
Pipeline
Updates from git push no-mistakes
✅ **intent** - passed
✅ No issues found.
✅ **Rebase** - passed
✅ No issues found.
🔧 **Review** - 2 issues found → auto-fixed (3) ✅
bin/fm-spawn.sh:245- Required criterion: "serialize concurrent focus-sensitive cleanup." The exit trap releases.herdr-presentation-order.lockbefore callingfm_backend_herdr_projection_cleanup_exact; abort cleanup can therefore overlap another create or cleanup and interleave focus snapshots/restoration. Keep or acquire the session's presentation lock through abort cleanup.bin/backends/herdr.sh:971- Required criterion: "refuse cleanup if the target is the active tab." The projected seeded-tab path captures focus but then calls the legacy prune helper, which directly closes its pane without checking whether its tab matches the snapshot's active tab. If the seeded tab becomes active before pruning, this destroys the exact focus being preserved. Route the prune close through the active-tab-refusing helper or perform an equivalent exact-tab check.🔧 Fix: Serialize Herdr cleanup and protect active seeded tabs
2 errors still open:
bin/fm-spawn.sh:883- Required criterion: "serialize concurrent focus-sensitive cleanup." The projected spawn releases.herdr-presentation-order.lockhere, while abort cleanup remains armed until line 1222. Any later Treehouse or harness-setup failure therefore reachesspawn_abort_cleanupwithHERDR_PRESENTATION_ORDER_LOCK_HELD=0, so the reordered trap still performs cleanup without serialization. The new test masks this by manually setting the held flag. Keep the lock through the armed abort window or reacquire it before cleanup.tests/fm-backend-herdr-presentation-e2e.test.sh:430- Required criterion: "Validate only in the guarded named Herdr lab," with focused coverage for concurrent abort cleanup and active seeded-tab refusal. The guarded E2E still exercises only successful seeded pruning and normal teardown; both new scenarios exist solely as fake/unit tests, so the required live focus behavior is not validated. Add forced active-seeded-tab and concurrent post-create abort cases to this named-session lab suite.🔧 Fix: Serialize Herdr aborts with guarded focus regressions
1 error still open:
bin/fm-spawn.sh:861- Required criterion: "Keep .herdr-presentation-order.lock held continuously through every armed post-create abort point." Acquisition still times out after five seconds and this branch continues projected creation withHERDR_PRESENTATION_ORDER_LOCK_HELD=0. Because the lock is now held through Treehouse and harness setup, an ordinary concurrent spawn can exceed that timeout, create/prune without serialization, and remain unlocked throughout its armed abort window. The new lab test fails both fixtures immediately, so it never exercises this timeout path. Wait for the focus-safety lock, use a separate best-effort ordering lock, or refuse projection when serialization is unavailable.🔧 Fix: Fall back flat when Herdr serialization is unavailable
✅ Re-checked - no issues remain.
🔧 **Test** - 1 issue found → auto-fixed ✅
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: Stabilize watcher startup and AFK handoff tests
✅ 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"Pre-supplied 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"passed.Inspectedgit diff 628292d0018dc8947447f598823a8187ba394822..1cad76d607ca7c2be38593a807c1c09149c0ab1fand the acceptance assertions intests/fm-backend-herdr-presentation-e2e.test.sh.bash tests/fm-watcher-lock.test.shrepeated 3 times.bash tests/fm-watch-triage.test.shrepeated 3 times, including the AFK changed-paused-pane handoff.bash tests/fm-backend-herdr-presentation-e2e.test.shagainst the guarded named Herdr 0.7.4 lab.bash tests/fm-backend-herdr.test.sh.Verifiedgit status --shortwas empty after testing and checked for transient build/cache directories.✅ **Document** - passed
✅ No issues found.
✅ **Lint** - passed
✅ No issues found.
✅ **Push** - passed
✅ No issues found.