Skip to content

fix(herdr): converge task tabs past plugin-docked panes on Herdr 0.9.1 - #5484

Open
PhilipVinc wants to merge 10 commits into
kunchenguid:mainfrom
PhilipVinc:fm/herdr-091-projection-k2
Open

PhilipVinc wants to merge 10 commits into
kunchenguid:mainfrom
PhilipVinc:fm/herdr-091-projection-k2

Conversation

@PhilipVinc

@PhilipVinc PhilipVinc commented Sep 24, 2026 •

Copy link
Copy Markdown

Intent

Fix it properly: on Herdr 0.9.1, spawning a crewmate with the default Herdr presentation-spaces projection fails, and it should work.

Observed: bin/fm-spawn.sh tangent-geom-s1 projects/tangent-sampling --scout --harness claude --effort xhigh from a firstmate running inside Herdr 0.9.1 (unconfigured config/herdr-presentation-spaces, so the projection was on by default above the 0.8.0 floor) failed with Error: disposable herdr presentation workspace did not converge to exactly one task pane. It left behind a version 1 journal state/<id>.herdr-presentation and a new workspace titled └ tangent-geom-s1 · p:<token>. That workspace had exactly one tab fm-tangent-geom-s1 (w9:t2) holding exactly one pane, which Herdr labelled Explorer, with pane token {"herdr-sidebar-explorer": ...}, cwd set to the task project, and content that was Herdr's file-explorer UI (m / ctrl+rclick for menus, a git branch footer) rather than a shell or agent. Herdr 0.9.1 appears to add or convert a sidebar file-explorer pane in new workspaces or tabs, and firstmate's convergence check rejects it. After that, the ordinary non-projected layout (config/herdr-presentation-spaces = off) spawned fine. That opt-out is a temporary mitigation in this home and should not be needed once the fix lands.

we can also disable that plugin if that's the underlying problem

yes do both

What Changed

  • Added fm_backend_herdr_tab_prune_plugin_panes, which closes every other pane in a tab through herdr plugin pane close. Herdr only lets that command close panes a plugin registered, so shells, agents and a captain's splits are never closed. Added fm_backend_herdr_tab_settle_plugin_panes, a bounded retry (FM_BACKEND_HERDR_PROJECTION_CONVERGE_ATTEMPTS/_SLEEP) that keeps pruning until the tab reads as exactly the task pane twice in a row, because a hook can dock its pane late. Projected workspace convergence now runs this settle before its one-tab, one-pane check, so spawns under the default presentation-spaces projection no longer fail when herdr-sidebar docks an Explorer pane. The flat task-tab create and the projected restart reclaim's replacement tab also run it.
  • The seeded-default-tab prune, the focus-preserving projection close and fm_backend_herdr_kill_serialized now prune registered plugin panes from the target tab before closing the task pane, so no Explorer-only tab or workspace is left behind. fm_backend_herdr_pane_for_tab (used for husk respawn, label recovery and bare selectors) now returns a pane only when the tab has exactly one. Before that it prunes plugin panes a plugin re-docked into the tab, and it no longer takes the first listed pane.
  • Docs: added a "Plugin panes in task tabs" section and two new known limitations to docs/herdr-backend.md: a plugin hook can still move focus, and a restored tab with an unregistered extra pane is ambiguous. Recorded the Herdr 0.9.1 / herdr-sidebar 0.13.0 lab evidence in docs/verification/runtime-backends.md, including which paths are covered only by the fake. Extended the stateful Herdr fake in tests/fm-backend-herdr.test.sh with regressions for docked, late-docked, re-docked and unregistered-split panes.

🤖 Generated with Claude Code

Risk Assessment

✅ Low: The fix-round change is one line in the projected restart reclaim. It calls the existing shared helper fm_backend_herdr_tab_settle_plugin_panes on the new tab only, after focus is restored and before the tab is verified, and it leaves the restored husk tab untouched as the user asked; the canned fixture's four extra list responses line up with the helper's two prune-and-read rounds, and the new stateful-fake regression would fail without the fix because the final one-pane binding check would roll back.

Testing

I ran every plugin-dock, projected-create, restart-reclaim and husk-respawn case in tests/fm-backend-herdr.test.sh (18 cases) against the stateful and canned Herdr fakes. All of them pass under jq 1.7.1 and jq 1.6, which confirms the tab get modelling fixes the CI-only failure. The new reclaim regression fails on the backend from before the fix with the reported flat fallback, and passes with the fix. Per the user's instruction I did not rerun the full suite or any real-Herdr live test. No scenario was driven against a real Herdr 0.9.1 with herdr-sidebar enabled, so every scenario is recorded as untested live. Herdr's plugin state is global to the user, so enabling the plugin even for a lab would change the operator's live configuration (this blocker was recorded in earlier rounds).

  • Live validation: ⚠️ inconclusive - 0 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Projected restart reclaim with a plugin pane docked into the replacement tab settles to exactly the task pane and advances the journal instead of falling back to flat (jq 1.7.1 and jq 1.6) ⏸️ untested no The earlier payload did not establish a live result. Only the stateful fake was used (test_projection_reclaim_converges_past_a_docked_plugin_pane passed under both jq versions and failed on the pre-fi…
Exact-husk reclaim and the refusal matrix (fixtures realigned for the new settle reads) still replace only the exact husk and refuse without mutation ⏸️ untested no The earlier payload did not establish a live result. Only canned-fixture unit tests ran, and they passed under both jq versions. The user limited this step to targeted fake-backed tests, so no live He…
Earlier plugin-dock guarantees still hold: projected and flat creates prune registered plugin panes, including late docks; an unregistered split is never closed; husk respawn and kill behave ⏸️ untested no The earlier payload did not establish a live result. Only the stateful fake was used (12 related cases were ok under both jq versions). Enabling herdr-sidebar needs global user plugin config, which th…
Real Herdr 0.9.1: bin/fm-spawn.sh &lt;task&gt; &lt;project&gt; --scout with the default projection and herdr-sidebar enabled succeeds, then restart reclaim succeeds ⏸️ untested no Needs a Herdr session with the herdr-sidebar plugin enabled. Herdr keeps plugin enablement global to the user, and XDG_CONFIG_HOME relocation also moves the default session that bin/fm-herdr-lab.sh's…
Evidence: 18 targeted plugin-dock/reclaim/husk tests under jq 1.7.1 (all ok)

Source: 18 targeted plugin-dock/reclaim/husk tests under jq 1.7.1 (all ok)

ok - herdr stale registration: presentation reclaim never closes a stale-registration pane
ok - herdr plugin dock: flat spawn and respawn keep exactly the task pane, recovery resolves it, and kill leaves no plugin-only tab
ok - herdr plugin dock: a plugin pane docked after the first passing read is pruned before projection success
ok - herdr plugin dock: a plugin pane docked late into a flat task tab is pruned before create_task returns
ok - herdr plugin dock: a plugin pane re-docked after activation never hides a flat task from discovery or respawn
ok - herdr plugin dock: only Herdr-registered plugin panes are pruned; a captain's split survives the task close
ok - herdr plugin dock: a projected workspace converges to exactly one task pane past docked plugin panes
ok - herdr plugin dock: a projected restart reclaim converges past a docked plugin pane
ok - herdr plugin dock: an unregistered docked pane keeps the projection unconverged and is never closed
ok - fm_backend_herdr_create_task: closes and replaces a same-labeled tab whose pane is dead (pane_not_found)
ok - fm_backend_herdr_create_task: closes and replaces a same-labeled tab whose pane is alive but hosts no registered agent (a restored plain shell)
ok - fm_backend_herdr_create_task: closes every confirmed same-labeled husk only after creating the replacement
ok - fm_backend_herdr_create_task: refuses success when a preexisting husk tab remains after replacement
ok - fm_backend_herdr_create_task: creates the replacement tab BEFORE closing the husk tab, never the reverse
ok - herdr presentation create: exact response IDs yield one normal task pane with no workspace-close authority
ok - herdr presentation create: concurrent same-label tabs are never prune targets
ok - herdr presentation reclaim: legacy, cross-home, ambiguous, live/unknown, and focus-unknown cases refuse without mutation
ok - herdr presentation reclaim: exact agent-free husk survives duplicate parent labels while its sibling stays untouched
rc=0
Evidence: Same 18 tests under jq 1.6 (all ok)

Source: Same 18 tests under jq 1.6 (all ok)

ok - herdr stale registration: presentation reclaim never closes a stale-registration pane
ok - herdr plugin dock: flat spawn and respawn keep exactly the task pane, recovery resolves it, and kill leaves no plugin-only tab
ok - herdr plugin dock: a plugin pane docked after the first passing read is pruned before projection success
ok - herdr plugin dock: a plugin pane docked late into a flat task tab is pruned before create_task returns
ok - herdr plugin dock: a plugin pane re-docked after activation never hides a flat task from discovery or respawn
ok - herdr plugin dock: only Herdr-registered plugin panes are pruned; a captain's split survives the task close
ok - herdr plugin dock: a projected workspace converges to exactly one task pane past docked plugin panes
ok - herdr plugin dock: a projected restart reclaim converges past a docked plugin pane
ok - herdr plugin dock: an unregistered docked pane keeps the projection unconverged and is never closed
ok - fm_backend_herdr_create_task: closes and replaces a same-labeled tab whose pane is dead (pane_not_found)
ok - fm_backend_herdr_create_task: closes and replaces a same-labeled tab whose pane is alive but hosts no registered agent (a restored plain shell)
ok - fm_backend_herdr_create_task: closes every confirmed same-labeled husk only after creating the replacement
ok - fm_backend_herdr_create_task: refuses success when a preexisting husk tab remains after replacement
ok - fm_backend_herdr_create_task: creates the replacement tab BEFORE closing the husk tab, never the reverse
ok - herdr presentation create: exact response IDs yield one normal task pane with no workspace-close authority
ok - herdr presentation create: concurrent same-label tabs are never prune targets
ok - herdr presentation reclaim: legacy, cross-home, ambiguous, live/unknown, and focus-unknown cases refuse without mutation
ok - herdr presentation reclaim: exact agent-free husk survives duplicate parent labels while its sibling stays untouched
rc=0
Evidence: Reclaim regression fails on the pre-fix backend under jq 1.7.1

Source: Reclaim regression fails on the pre-fix backend under jq 1.7.1

not ok - reclaim with a docking plugin should converge: warning: herdr presentation reclaim for dock-r1 did not converge exactly; spawning flat rc=1

not ok - reclaim with a docking plugin should converge: warning: herdr presentation reclaim for dock-r1 did not converge exactly; spawning flat
rc=1
- Outcome: ⏭️ skipped across 2 runs (5m53s)

Pipeline

Updates from git push no-mistakes

✅ **intent** - passed

✅ No issues found.

✅ **Rebase** - passed

✅ No issues found.

🔧 **Review** - 1 issue found → auto-fixed ✅
  • ⚠️ bin/backends/herdr.sh:2869 - The projected restart reclaim path was left out of the plugin-pane fix. fm_backend_herdr_projection_reclaim_task creates its replacement task tab with tab create --no-focus in the projected workspace (herdr.sh:2856), but it never prunes or settles the plugin pane that a tab.created hook docks into that tab. With herdr-sidebar enabled, that tab ends up holding an Explorer pane plus new_pane. The final fm_backend_herdr_projection_live_binding_matches check (herdr.sh:2928, which requires exactly one pane at herdr.sh:2778-2782) then fails. The reclaim rolls back and prints 'did not converge exactly; spawning flat', so with the plugin on, every projected husk respawn after a Herdr restart falls back to the flat layout. This is the same invariant the change enforces in fm_backend_herdr_projection_create_task (herdr.sh:2670) and the flat create_task (herdr.sh:2542). The rollback does still prune the Explorer pane through projection_close_pane_focus_preserving, so nothing leaks. The same one-pane check also runs first against the restored husk tab (herdr.sh:2829), which can hold a re-docked Explorer pane. Smallest fix: after the focus restore at herdr.sh:2869, call fm_backend_herdr_tab_settle_plugin_panes &#34;$session&#34; &#34;$meta_workspace&#34; &#34;$new_tab&#34; &#34;$new_pane&#34; || true, which reuses the shared helper so there is no new loop. Optionally, also prune registered plugin panes from meta_tab before the first binding check.

🔧 Fix applied.
✅ Re-checked - no issues remain.

⏭️ **Test** - skipped
  • ⚠️ live validation verdict: inconclusive (0 of 4 scenarios were driven live against the product); untested: Projected restart reclaim, where a plugin docks an Explorer pane into the replacement tab, converges to exactly the replacement task pane and advances the journal instead of falling back to flat, Exact-husk reclaim with realigned canned fixture still replaces only the exact husk and advances the binding, Earlier plugin-dock guarantees still hold: projected and flat create prune registered plugin panes, including late docks; an unregistered split is never closed; husk respawn works, Real Herdr 0.9.1: fm-spawn --scout with default projection and herdr-sidebar enabled, then restart reclaim, succeeds
  • Live validation: ⚠️ inconclusive - 0 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Projected restart reclaim, where a plugin docks an Explorer pane into the replacement tab, converges to exactly the replacement task pane and advances the journal instead of falling back to flat ⏸️ untested no The prior payload did not establish a live result. Only the stateful fake was exercised: test_projection_reclaim_converges_past_a_docked_plugin_pane passes on HEAD and fails on the HEAD~1 backend. A r…
Exact-husk reclaim with realigned canned fixture still replaces only the exact husk and advances the binding ⏸️ untested no The prior payload did not establish a live result. Only canned-response unit tests were run (test_projection_reclaim_replaces_only_exact_husk_and_advances_binding and test_projection_reclaim_refusal_m…
Earlier plugin-dock guarantees still hold: projected and flat create prune registered plugin panes, including late docks; an unregistered split is never closed; husk respawn works ⏸️ untested no The prior payload did not establish a live result. Only the stateful fake was exercised (reclaim-plugin-dock-subset.log, all ok). A live plugin-enabled Herdr would require changing the operator's user…
Real Herdr 0.9.1: fm-spawn --scout with default projection and herdr-sidebar enabled, then restart reclaim, succeeds ⏸️ untested no This would require enabling herdr-sidebar in the operator's user-global Herdr config, which also affects the live default session and fleet. The runbook forbids that. The operator would need to provid…
  • env -u HERDR_PANE_ID -u HERDR_TAB_ID -u HERDR_WORKSPACE_ID -u HERDR_SOCKET_PATH -u HERDR_ENV -u HERDR_BIN_PATH -u FM_TASK_ID bash &lt;tests/fm-backend-herdr.test.sh preamble + 18 selected tests&gt; covering reclaim, plugin-dock, husk replacement and projection create (18/18 ok)
  • Regression check: reran test_projection_reclaim_converges_past_a_docked_plugin_pane and test_projection_reclaim_replaces_only_exact_husk_and_advances_binding against HEAD~1's bin/backends/herdr.sh (without the settle line). The new test failed with 'did not converge exactly; spawning flat'. The file was then restored and the worktree left clean.

🔧 Fix applied.
1 warning still open:

  • ⚠️ live validation verdict: inconclusive (0 of 4 scenarios were driven live against the product); untested: Projected restart reclaim with a plugin pane docked into the replacement tab settles to exactly the task pane and advances the journal instead of falling back to flat (jq 1.7.1 and jq 1.6), Exact-husk reclaim and the refusal matrix (fixtures realigned for the new settle reads) still replace only the exact husk and refuse without mutation, Earlier plugin-dock guarantees still hold: projected and flat creates prune registered plugin panes, including late docks; an unregistered split is never closed; husk respawn and kill behave, Real Herdr 0.9.1: bin/fm-spawn.sh &lt;task&gt; &lt;project&gt; --scout with the default projection and herdr-sidebar enabled succeeds, then restart reclaim succeeds
  • Live validation: ⚠️ inconclusive - 0 of 4 scenarios driven live against the product
Scenario Result Live Evidence
Projected restart reclaim with a plugin pane docked into the replacement tab settles to exactly the task pane and advances the journal instead of falling back to flat (jq 1.7.1 and jq 1.6) ⏸️ untested no The earlier payload did not establish a live result. Only the stateful fake was used (test_projection_reclaim_converges_past_a_docked_plugin_pane passed under both jq versions and failed on the pre-fi…
Exact-husk reclaim and the refusal matrix (fixtures realigned for the new settle reads) still replace only the exact husk and refuse without mutation ⏸️ untested no The earlier payload did not establish a live result. Only canned-fixture unit tests ran, and they passed under both jq versions. The user limited this step to targeted fake-backed tests, so no live He…
Earlier plugin-dock guarantees still hold: projected and flat creates prune registered plugin panes, including late docks; an unregistered split is never closed; husk respawn and kill behave ⏸️ untested no The earlier payload did not establish a live result. Only the stateful fake was used (12 related cases were ok under both jq versions). Enabling herdr-sidebar needs global user plugin config, which th…
Real Herdr 0.9.1: bin/fm-spawn.sh &lt;task&gt; &lt;project&gt; --scout with the default projection and herdr-sidebar enabled succeeds, then restart reclaim succeeds ⏸️ untested no Needs a Herdr session with the herdr-sidebar plugin enabled. Herdr keeps plugin enablement global to the user, and XDG_CONFIG_HOME relocation also moves the default session that bin/fm-herdr-lab.sh's…
  • Temporary subset copy of tests/fm-backend-herdr.test.sh running 18 selected cases (every plugin-dock, projection_create, reclaim and husk-respawn test), run under PATH=/tmp/k2-jq:$PATH (jq 1.7.1) with HERDR_PANE_ID/HERDR_TAB_ID/HERDR_WORKSPACE_ID/HERDR_SOCKET_PATH/HERDR_ENV/HERDR_BIN_PATH/FM_TASK_ID unset: 18 ok, rc=0
  • The same 18-case subset under the host's jq 1.6: 18 ok, rc=0
  • Regression check: swapped in bin/backends/herdr.sh from ccca8b9^ (before the reclaim settle) and ran test_projection_reclaim_converges_past_a_docked_plugin_pane under jq 1.7.1: not ok, 'did not converge exactly; spawning flat'. Then restored the file with git checkout, removed the subset file, and confirmed the worktree is clean
✅ **Document** - passed

✅ No issues found.

⚠️ **Lint** - 1 warning
  • ⚠️ linter found issues (exit code 1)
✅ **Push** - passed

✅ No issues found.

Contribution by the Mistral AI4Science team
Co-authored-by: Mistral Vibe vibe@mistral.ai

Copy link
Copy Markdown
Owner

Speaking as Kun's firstmate:

Diff review on HEAD 68b902d5e4b74993c5c82ebe1b4eb7029f425b19: Herdr backend prunes plugin-registered panes (herdr plugin pane close) so flat and projected task tabs converge to exactly one task pane on Herdr 0.9.1 with herdr-sidebar. Only plugin-registered panes are closed; shells/agents/splits without a plugin registration are left alone. Default-on presentation spaces (unconfigured config/herdr-presentation-spaces, Herdr ≥ 0.8.0) were already specified and broken by the Explorer dock — this restores that path. Security clean (no label/token heuristics to close panes).

VISION per-rule:

  1. One captain, one interface — aligns (projection works again without forcing opt-out).
  2. Authority explicit — aligns (presentation opt-out via config unchanged).
  3. Scripts own mechanics — aligns (Herdr adapter mechanics).
  4. Restart non-event — aligns (husk/recovery prune covered).
  5. Delegation with a spine — aligns (spawn converge refusal preserved when unregistered panes remain).
  6. Fleet outlives vendor — aligns (version-aware Herdr adapter; known limitations documented).
  7. Scope — aligns (backend adapter fix).

contract-class: restore — concrete existing default presentation-spaces path on Herdr ≥ 0.8.0 was broken by plugin panes on 0.9.1; tip makes that specified path hold again. Not a new always-on surface.

attestation: MATCH (body binds tip).
CI: FAILURE 35945460954 — Behavior portable parallel 2: not ok - create_task should close-and-replace the dead-pane husk (could not parse herdr tab list output for workspace w1). Likely related to tip prune/settle changes.
NM: SUCCESS 35945460953/35946023896.
mergeable: MERGEABLE/UNSTABLE.
workflow-approved: yes — CI 35945460954, NM 35945460953/35946023896.
next: waiting-author (fix husk/create_task suite). Not a captain hold. Firstmate-flag no. Closes none.

PhilipVinc and others added 10 commits September 24, 2026 03:01
A Herdr plugin creation hook (herdr-sidebar 0.13.0 on Herdr 0.9.1) splits
its own Explorer pane into every new tab. The projected workspace then held
two panes, the convergence check failed, and abort cleanup closed the task
pane and left an Explorer-only workspace behind. The flat path had the same
leak at teardown, and first-pane tab resolution named the left-docked
Explorer instead of the task pane.

Prune only Herdr-registered plugin panes from the one exact tab being
created or torn down, through `plugin pane close`, which refuses any pane no
plugin opened, so labels and tokens are never identity and a captain's split
is never closed. The seeded-tab prune, projection convergence (with a
bounded re-read while the hook docks asynchronously), focus-preserving
projection close, and task kill use it; a tab holding more than one pane no
longer resolves to an endpoint by position.

Contribution by the Mistral AI4Science team
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
The flat create's plugin-pane settle adds two prune-and-read rounds after
the replacement tab is created. The husk-order fixture was never shifted
for them, so its post-close tab list received an empty response. jq 1.6
exits 0 for `jq -e` on empty input and hid the misalignment locally, while
CI's jq 1.7 correctly rejected it.

Contribution by the Mistral AI4Science team
Co-authored-by: Mistral Vibe <vibe@mistral.ai>
@PhilipVinc
PhilipVinc force-pushed the fm/herdr-091-projection-k2 branch from 68b902d to 1111a45 Compare September 24, 2026 03:44
@PhilipVinc PhilipVinc changed the title fix(bin): prune Herdr plugin panes so projected task spawns converge on Herdr 0.9.1 fix(herdr): converge task tabs past plugin-docked panes on Herdr 0.9.1 Sep 24, 2026
@PhilipVinc

Copy link
Copy Markdown
Author

i'd love to see this merged. it's annoying not to be able to use firstmate+herdr+ plugins to see the git state

@alexg0

alexg0 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Tested #5484 rebased onto upstream main 8690c4117a298ee870f0f72f571c72b846b4c5fb; the rebase was clean.

With native Herdr 0.9.3 and herdr-sidebar 0.12.0 in a guarded named lab session, I opened a real registered Sidebar pane immediately after each workspace/tab creation. fm-spawn.sh succeeded and left exactly one worker pane. fm-control.sh relaunch for a completed fixture worker succeeded at the same projected endpoint. Projected-husk reclaim also succeeded: the replacement tab's Sidebar was pruned, the worker pane binding advanced, and one pane remained.

One gap: re-docking Sidebar into the old bound husk before reclaim returned the safe flat-fallback signal (rc=2), preserving both panes and the journal. The initial live-binding shape check rejects that extra pane before replacement-tab pruning.

Limitations: auto-open was simulated synchronously using native plugin-pane creation with private plugin state; the live global auto_open setting stayed off and unchanged. The worker and worktree allocator were fixtures, so natural asynchronous plugin hooks and active real Codex TUI shutdown remain unverified. No default-session lifecycle operation was performed; guarded teardown passed.

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.

3 participants