Task 5: Stop persisting profile mappings
Summary
Stop persisting profile mappings as authority for parent plan #436. After Task 4 (#443 on task-4-herdr-create-delete) create/delete go through Herdr without INSERT/DELETE sqlite profiles, but leftover profile_runtime_mappings and writes to profiles.worktree_path can still disagree with live Herdr and win. This task stops treating those rows/columns as identity or path authority.
A profile remains an open Herdr workspace. The profile id is the Herdr workspace_id (wN). Join key: canonical projects.folder ↔ live checkout / pane cwd (Task 1 contract, docs/herdr-integration.md). One-shot import of leftover sqlite extras into Herdr is this task (worktree.open only). Default / project-folder checkouts stay unopened until Task 10. Do not DROP profiles / mapping tables (Task 8). Do not drop session_runtime_mappings / pty_sessions as the session store (Task 6). Do not start HerdrRuntimeSync / events.subscribe. Do not redesign project/profile/Git/file-tree/notes/tab clicks or labels. Pin stays v0.9.0. Local remains TWOCODE_RUNTIME=local until Task 9. Local must never own a worktree Herdr already owns.
Dependencies: Parent plan #436. Prerequisites: #437 (Task 1), #439 (Task 2), #441 (Task 3), #443 (Task 4). Open #438, #440, #444 are line-count tracking only — not blockers. Open #394 issues #395–#434 must not be implemented or closed here.
Work to complete
-
Stop mapping /
worktree_pathauthority- Herdr list/create/close/identity join live
workspace_idor leftover sqlite checkout path. Do not bind/unbind/replaceprofile_runtime_mappingson those paths. Do not writeprofiles.worktree_pathfromworktree.list. - Notes overlay leftover sqlite
profiles.noteswhenworktree_pathmatches the live checkout. Mapping rows that point at a different workspace must not win. Herdr-only workspaces with no leftover path stay empty until Task 8. - Local list (
TWOCODE_RUNTIME=local) keeps the sqlite cache and does not call Herdr to refresh it. - Mapping, if present, is a dual-ownership lock on Local-flag GUI delete (
delete_sqlite_identity/refuse_mapped_without_runtime), not a Herdrworkspace_id. Do notgit worktree removea leftover checkout that this task opened. Do not route Local delete through Herdrworktree.removebecause a leftover mapping exists.
- Herdr list/create/close/identity join live
-
One-shot leftover extra import
- After successful GUI Herdr JSON connect (
connect_gui_herdr), import leftover sqlite extras with JSONworktree.open.already_openis success. Skip the default / project-folder checkout (Task 10). Do not INSERT mapping rows. Do not retry uncertainworktree.open. Do notworktree.create/git worktree add/workspace.create. - Log per-profile Failed outcomes (including uncertain open) and outer import errors. Do not fail Herdr connect or flip the selector to Local.
TWOCODE_RUNTIME=localskips import. Do not call import fromlib.rssetup.
- After successful GUI Herdr JSON connect (
-
Prove without swallowing later tasks
- Colocated tests: notes overlay by path; Local list does not persist listed paths; leftover mapping is not identity; extras import without mapping writes; default skipped; uncertain open not retried; Local-flag mapped delete fails closed without git remove; production source guards (no mapping writes, no
HerdrRuntimeSync/events.subscribeinlib.rs). - Update
docs/herdr-integration.md: Task 5 done on this branch. Do not bump v0.9.0. If line count grows past the estimate, open a tracking issue; do not fold Task 6+ into this branch.
- Colocated tests: notes overlay by path; Local list does not persist listed paths; leftover mapping is not identity; extras import without mapping writes; default skipped; uncertain open not retried; Local-flag mapped delete fails closed without git remove; production source guards (no mapping writes, no
Acceptance criteria
- [ ] Herdr list/create/close/import do not write
profile_runtime_mappingsorprofiles.worktree_path. sqliteprofilesis not source of truth. - [ ] Notes overlay leftover sqlite
profiles.notesby checkout path, not mapping membership. - [ ] GUI Herdr connect imports leftover extras via
worktree.open(already_openok), skips the project-folder checkout, does not retry uncertain opens, and logs per-profile Failed outcomes plus outer import errors without flipping the selector. - [ ] Local-flag GUI delete (
delete_with_runtime→delete_sqlite_identity) fails closed when a leftover mapping exists: nogit worktree remove, no Herdrworktree.remove. Unmapped Local extras still use today’s git delete. - [ ] sqlite
profiles/ mapping tables are not DROPped.session_runtime_mappings/pty_sessionsstay the session store. No launch/adopt of the project-folder default. NoHerdrRuntimeSync/events.subscribe. No Local PTY deletion. Pin stays v0.9.0. GUI clicks/labels stay New Profile / Delete Profile. GUI exit still does notserver stop. - [ ] Tests:
cargo test --workspacefromsrc-tauri(orcargo test --workspace --exclude codewhere GTK is unavailable). - [ ] No pull request until parent #436 is complete.
Out of scope
- Sessions from
session.snapshot; droppingpty_sessions/session_runtime_mappingsas authority (Task 6). StartingHerdrRuntimeSync/events.subscribe. - Pointing every Git/file-tree/watcher consumer at live cwd (Task 7).
- DROP sqlite
profiles/ mapping tables (Task 8), deleting the Local PTY runtime (Task 9), launch/adopt on project open (Task 10). - Live path join so Local-flag delete of unmapped leftover extras cannot git-remove a Herdr-open checkout (follow-up; mapping lock only covers mapped rows).
leftover_sqlite_idpinning New Tabpty_sessions.profile_idto a leftover sqlite UUID (Task 6).- Implementing or closing #394 issues #395–#434 or line-count trackers.
- Opening a pull request.
Standing constraints
- Do not treat sqlite
profilesas source of truth. Do not add a path cache that can disagree with live Herdr and still win. projects(and project groups / notes-as-2code-data) remain 2code sqlite.- Join key remains path ↔ live Herdr cwd/worktree group.
- Never let Local and Herdr own the same worktree.
- Preserve existing 2code interaction. UX change is allowed only when Herdr cannot back the old clicks/labels; named exceptions remain route ids as
workspace_idand empty profile list until Task 10. - One task; stack on
task-4-herdr-create-delete. Do not open a PR until the parent plan is complete.
Estimated changes: 400–700 lines total, additions plus deletions, including tests; excluding generated files. Material scope growth should become a separate issue.