Skip to content

feat(herdr): group home spaces by worktree and stamp worker owner tokens - #29

Merged
brchue-ux merged 7 commits into
mainfrom
fm/herdr-sm-space-grouping
Aug 22, 2026
Merged

feat(herdr): group home spaces by worktree and stamp worker owner tokens#29
brchue-ux merged 7 commits into
mainfrom
fm/herdr-sm-space-grouping

Conversation

@brchue-ux

Copy link
Copy Markdown
Owner

What Changed

  • fm_backend_herdr_workspace_ensure now opens a home's workspace through Herdr's worktree open path instead of a plain workspace create, so the workspace carries worktree membership and Herdr's sidebar groups a secondmate's linked-worktree home under the primary home's main-checkout workspace; the home workspace is now anchored at the home directory itself (fm-spawn.sh passes a resolved home cwd) rather than at whichever project cwd first created it. Every failure mode (not a git worktree, no parent workspace open yet, unreadable response, failed rename) degrades safely to the pre-existing flat workspace create/adoption path and never fails a spawn.
  • fm-spawn.sh stamps each spawned crewmate/scout pane with an owner metadata token (via new fm_backend_herdr_report_owner_token) naming the calling mate, published under a dedicated FM_BACKEND_HERDR_METADATA_SOURCE so it merges with rather than clobbers tokens from other sources; secondmate panes are deliberately left unstamped so Herdr's agents panel can filter workers by token presence.
  • Added tests/fm-backend-herdr-space-grouping-e2e.test.sh and registered it in the Herdr real-binary test lane (fm-test-isolation-proof.sh, fm-test-run.sh); extended tests/fm-backend-herdr.test.sh; documented the grouping and owner-token contracts in docs/herdr-backend.md, docs/architecture.md, and docs/verification/runtime-backends.md.

Risk Assessment

✅ Low: The change adds worktree-backed herdr workspace grouping and a worker owner-metadata token with exhaustive, self-consistent fallback logic; every failure path degrades safely to the pre-existing flat/ungrouped behavior without ever failing a spawn, and the branch's own commit history shows the author already iterating through and closing edge cases (adoption discipline, basename-collision guard, degrade-reporting ordering) before this review, backed by both fake-based unit tests and a real-binary e2e test plus source-line-cited documentation.

Testing

The new herdr worktree-backed space-grouping and owner-token behavior is fully exercised and passes end-to-end against the real, CI-pinned herdr 0.7.4 binary (fm-backend-herdr-space-grouping-e2e.test.sh, all 9 checks), with no regressions in the related fm-backend-herdr.test.sh and fm-backend-herdr-workspace-per-home-e2e.test.sh suites. The one failure seen on the first attempt was caused by testing against this machine's newer ambient herdr 0.8.0 (behavior drift from the 0.7.4 pin the code assumes); installing and testing against the pinned build resolved it, confirming this is a herdr version issue rather than a firstmate code defect. During manual reproduction I briefly and accidentally created a stray workspace in the user's live 'default' herdr session by omitting an explicit --session pin; it was identified and closed immediately, restoring the session to its prior 10 workspaces, with no other user state touched.

Pipeline

Updates from git push no-mistakes

⏭️ **intent** - skipped

✅ No issues found.

🔧 **Rebase** - 1 issue found → auto-fixed ✅
  • ⚠️ docs/herdr-backend.md - merge conflict rebasing onto origin/main

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

✅ **Review** - passed

✅ No issues found.

✅ **Test** - passed

✅ No issues found.

  • ./bin/fm-test-run.sh tests/fm-backend-herdr-space-grouping-e2e.test.sh against pinned herdr 0.7.4 (installed via ./bin/fm-install-herdr.sh) — all 9 assertions pass: no-parent guard fallback, worktree-backed grouping of a secondmate under its primary, shared repo_key/is_linked_worktree grouping precondition, label lookup for both homes, owner-token stamping on worker panes vs unstamped secondmate panes, owner stamping for a worker spawned from a secondmate, and adoption discipline for a pre-existing workspace
  • ./bin/fm-test-run.sh tests/fm-backend-herdr.test.sh against pinned herdr 0.7.4 — full pass, including the extended coverage in this diff (send-text/submit confirmation, wait-transition, escalation dedupe)
  • ./bin/fm-test-run.sh tests/fm-backend-herdr-workspace-per-home-e2e.test.sh against pinned herdr 0.7.4 — full pass, confirming no regression to existing workspace-per-home behavior
  • manual reproduction: reran the same guard scenario by hand against ambient herdr 0.8.0 to isolate the cause of the one failure seen under the un-pinned local herdr; confirmed a plain workspace create --cwd <linked-worktree-path> populates a non-null worktree block on 0.8.0 (unlike the pinned 0.7.4 the code was verified against), explaining the assertion mismatch as a version issue rather than a code defect
✅ **Document** - passed

✅ No issues found.

✅ **Lint** - passed

✅ No issues found.

✅ **Push** - passed

✅ No issues found.

Herdr's sidebar groups workspaces by git repo key and indents every
member whose worktree is linked, but it reads that grouping only from a
workspace's stored worktree membership. A plain `workspace create`
leaves that block null regardless of its path, so every home workspace
was ungrouped and secondmate homes never rendered under the primary.

Create home workspaces through Herdr's worktree path instead. A main
checkout is opened as its own repo parent; a linked worktree is opened
against the already-resolved parent workspace. Membership has to be
stamped at creation because a workspace's git identity is otherwise
derived from its live panes, and the seeded default tab is pruned once
the first task tab exists.

Anchor the home workspace at the home directory rather than at whichever
project its first task used, so the primary home is the un-indented
parent by construction and secondmate homes are linked worktrees of it.

When no workspace is open on the repo's main checkout, fall back to the
flat create. Given only a cwd, Herdr invents a parent labelled from the
repo directory basename - for this repo, literally "firstmate" - which
would collide with the primary home's own label and break workspace
lookup by label. Passing a resolved parent id makes that impossible.

Also stamp every crewmate and scout pane with an `owner` metadata token
naming the calling mate. A worker's environment carries no home identity
to derive it from, so firstmate publishes it at spawn. Mate panes are
left unstamped so the token's presence identifies workers.

Verified against real Herdr 0.7.5 in isolated lab sessions.
@brchue-ux
brchue-ux merged commit 0eacc20 into main Aug 22, 2026
10 checks 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.

1 participant