Task 1: Rewrite the integration contract for client-mode
Summary
Rewrite the Herdr integration contract for parent plan #436 client-mode. The additive stack on task-17-shell-templates (PR #435 / #394) still treats Local as default, sqlite profiles as catalog rows, and profile_runtime_mappings / session_runtime_mappings / profiles.worktree_path as association caches. This task inverts that architecture in the contract, without switching production defaults or deleting those tables yet.
Keep the pinned Herdr v0.9.0 Linux probe (JSON protocol 22, endpoint generation 1). Do not re-prove frame semantics, controller exclusivity, DSR/DA, or sidecar checksums already recorded in docs/herdr-integration.md and herdr_contract.rs. Reuse that evidence. Replace the #394 mapping ("Local default, mapping tables, path cache") with this plan: a 2code project stays a sqlite row; a profile is a Herdr workspace (workspace_id), derived live from worktree.list / workspace.list / session.snapshot keyed by the project's repo path; sqlite profiles is not source of truth.
Linux live probe against the existing pin. Docs + tests only.
Dependencies: Parent plan #436. No prerequisite #436 sub-issues. Checkout base: task-17-shell-templates (PR #435). Open #394 issues #395–#434 do not block this rewrite and must not be implemented or closed here.
Work to complete
-
Replace the #394 architecture mapping
- Update
docs/herdr-integration.mdso later #436 tasks depend on this contract, not Local-default / mapping-table / path-cache rules from #394. - Keep the pin table, checksums, reproduction, JSON/CLI transports, frame semantics, exclusivity, and lifecycle evidence. Do not bump the pin off v0.9.0. Do not retarget
latest. - Decision for this plan: proceed on Linux x86_64 (executed) for #436 Tasks 2–10, gated only on capabilities this probe marks verified. Remap every "Task N" / Blocked / Later-task row that still numbers #394 Tasks 2–23 so it names #436 tasks (or explicitly "#394 leftover, not this plan").
- Record that Herdr is the intended default runtime for this plan. Do not change
RuntimeRouter::new(still Local). Switching the default is Task 2. - State that Local may remain only as an explicit fallback until Task 9 deletes it, and that Local must never own a worktree/workspace Herdr already owns.
- Update
-
Document project ↔ Herdr binding (path → worktree group)
- Join key: canonical absolute
projects.folder↔ Herdr checkout path / workspace cwd. No parallel sqliteworktree_path(or mapping row) that can disagree with live Herdr and still win. - A 2code profile id is the Herdr
workspace_id(stablewNin a session; restored across server restart per existing identity table). It is not a UUID 2code mints intoprofiles.id. - Default checkout for a project: the open Herdr workspace whose checkout path is the project folder (primary / non-linked).
- Linked git worktrees are additional profiles in the same repo group (
worktree.create/is_linked_worktree). - Non-git project folders:
workspace.create(notworktree.*). Probe this on a disposable non-git directory and record whetherworktree.listis inapplicable. - Empty Herdr (no open workspaces for that path) → empty profile list for that project. Do not fall back to leftover sqlite
profilesrows. Task 10 later starts/adopts a workspace so the GUI is not stuck empty; this task only documents the empty case. - Git worktrees that exist on disk but are not open in Herdr (
open_workspace_idabsent) are not profiles untilworktree.open/ Task 10. Listing them as sqlite-style profiles is a contract failure.
- Join key: canonical absolute
-
Linux live probe: list/join payloads
- Extend
herdr_contract.rswith a focused probe (new test, not a rewrite of frame/controller tests). Same harness isolation: short/tmpsockets, disposable repo,HERDR_CONTRACT_REQUIRED=1, never the user default session. - Exercise JSON (not only CLI)
worktree.listwith absolutecwd= the disposable repo, andworkspace.list/session.snapshot. - Sequence: empty server → list (no open workspaces) →
workspace.create --cwdprimary →worktree.createlinked → list again. Capture sanitized fixtures of list/snapshot entries (path, branch,open_workspace_id/workspace_id,is_linked_worktree, cwd, andrepo_keyif present). - Prove the group is repo-scoped: a second disposable repo's workspaces do not appear in the first repo's
worktree.list. - Re-open /
already_openmust keep the sameworkspace_id(already verified forworktree.open; confirm the list/snapshot still keys the profile as that id). - Require
worktree.listandworkspace.listin the schema-excerpt method check if they are not already required. - If v0.9.0 cannot join by path the way #436 needs, file a blocking gap issue and mark the contract block for Tasks 3–4/10. Do not invent a sqlite cache to paper over it. Do not change the pin to another release inside this task without recorded evidence and a separate issue.
- Extend
-
Inventory sqlite tables that die vs stay
- Stay (2code authority):
projects,project_groups. - Die as authority (later #436 tasks, not this PR):
profiles(Task 8),profile_runtime_mappings(Task 5),session_runtime_mappings(Task 6),pty_sessionsas the Herdr session store (Task 6), andherdr_namespacesif it exists only to scope those mappings. profiles.worktree_path/branch_name/is_defaultare not path or profile authority. Default checkout is Herdr's workspace at the project folder.- Notes: parent plan keeps notes as a 2code feature. Today they live on
profiles.notes. Record that they cannot remain onprofilesafter Task 8; moving them to a project- orworkspace_id-keyed 2code table is not this task. Do not store notes in Herdr. - One-shot import of existing sqlite profiles into Herdr is allowed in Task 5 or 6; this task only says those rows are ignored as source of truth after import.
- Stay (2code authority):
-
Prove docs/tests only
- No production adapter, handler, frontend, Diesel migration, or
RuntimeRouterdefault change. - Do not INSERT/DELETE
profiles, drop mapping tables, spawn Local PTYs from the probe except as already required by the existing harness, or callserver.stopagainst a non-fixture socket. - Existing
cargo test -p infra --test herdr_contractcoverage must keep passing. New live tests skip without the binary unlessHERDR_CONTRACT_REQUIRED=1. - If the line count of this rewrite grows past the estimate below, open a tracking issue; do not fold Task 2+ into this branch.
- No production adapter, handler, frontend, Diesel migration, or
Likely files and directories
- Update:
docs/herdr-integration.md— client-mode mapping, join key, table inventory, #436 task gating, proceed/block decision. Keep pin/reproduction/frame/lifecycle sections unless a live finding contradicts them (then mark verified vs superseded, do not silently delete evidence). - Update:
src-tauri/crates/infra/tests/herdr_contract.rs— path→group list/snapshot probe; requireworktree.list/workspace.listin the schema method list. - New fixtures as needed:
src-tauri/crates/infra/tests/fixtures/herdr/— sanitizedworktree.list/workspace.list/ snapshot excerpts for the join key (no user paths). - Update if the excerpt must list the join methods:
schema-excerpt.json. - Do not change:
src-tauri/crates/service/src/runtime.rsdefault Local, mapping repos,profilesmigrations, frontend profile switcher, PTY/Local adapters, sidecar acquisition.
Estimated changes: 200–400 lines total, additions plus deletions, including tests and docs; excluding generated files, lockfile churn and binary artifacts. Material scope growth should become a separate issue.
Acceptance criteria
- [ ] The contract documents client-mode:
projectsstay sqlite; a profile is a Herdrworkspace_id; listing/create/delete/restore go through Herdr; sqliteprofilesis not source of truth. - [ ] Join key is canonical project folder path ↔ live Herdr checkout/cwd (worktree group). No sqlite
worktree_path/ mapping table is documented as authority. - [ ] Tables that die vs stay are explicit and mapped to later #436 task numbers.
pty_sessionsis not the Herdr session store. Notes-on-profilesis called out as dying with that table. - [ ] Linux live probe (pinned v0.9.0, not
latest) capturesworktree.list/workspace.list/session.snapshotevidence for empty server, primary workspace, linked worktree, second-repo isolation, and non-gitworkspace.create. Sanitized fixtures exist. Reproduction still usesHERDR_CONTRACT_REQUIRED=1and cleans up sockets/state. - [ ] Disk git worktrees without an open
workspace_idare not profiles. Empty Herdr → empty profile list (no sqlite fallback) is explicit. - [ ] #394 task numbering in the contract is remapped or labeled leftover. Proceed/block for #436 Tasks 2–10 is explicit. New capability holes are linked blocking issues, not silent passes.
- [ ] Production default remains Local on this branch. No GUI, migration, or Local/PTY deletion. Existing contract tests still pass:
HERDR_CONTRACT_REQUIRED=1 cargo test -p infra --test herdr_contract -- --nocapture --test-threads=1. If Rust/docs-only:cargo test --workspacefromsrc-tauri(or--exclude codewhere GTK is unavailable). Frontend lint/typecheck/tests only if frontend scope is introduced (none expected). - [ ] Another developer can rerun the new probe from the doc and clean up its processes, endpoints, and temp state.
Out of scope
- Making Herdr the default runtime (Task 2), including env/flag fallback wiring beyond documenting that it will exist.
- Sidebar/profile switcher reading Herdr (Task 3), create/delete through Herdr in the GUI (Task 4), dropping mapping writes (Task 5), session restore from snapshot (Task 6), Git/file-tree path consumers (Task 7), dropping
profiles(Task 8), deleting Local PTY (Task 9), launch/adopt on project open (Task 10). - Production sidecar, socket client, sync, or adapter behavior changes.
- Implementing or closing #394 issues #395–#434 (including remaining #394 Tasks 18–23, gap issues, and line-count trackers).
- Remote Herdr machines.
- Opening a pull request (parent plan: no PR until #436 is complete).
Standing constraints
- Do not treat sqlite
profilesas source of truth in this contract. projects(and project groups / notes-as-2code-data) remain 2code sqlite.- Join key is path ↔ live Herdr cwd/worktree group. No competing
worktree_pathauthority. - Switching the default runtime is in scope for Task 2, not this task. Deleting Local PTY /
profilesrows is in scope for Tasks 8–9, not this task. - Never let Local and Herdr own the same worktree.
- Preserve existing 2code interaction (project list, profile switcher, create/delete profile, Git, file tree, notes, terminal tabs). Do not redesign those flows. UX change is allowed only when Herdr cannot back the old clicks/labels; that exception must be named in the sub-issue that needs it. This task has no UX.
- One task; stack on
task-17-shell-templates. Do not open a PR until the parent plan is complete.