Task 8: Drop sqlite `profiles` (and mapping tables)
Summary
Drop sqlite profiles and mapping tables for parent plan #436. After Task 7 (#449 on task-7-herdr-live-cwd) Git, the file tree, and watchers already resolve checkout from live Herdr cwd, but leftover profiles, profile_runtime_mappings, session_runtime_mappings, and herdr_namespaces still exist. Notes still live on profiles.notes and overlay by leftover worktree_path. Local-flag list/create/delete still treat sqlite extras as a nested catalog. This task moves notes to a 2code table keyed by project_id + canonical checkout path, then DROPs those tables. projects / project_groups stay. pty_sessions stays until Task 9 (Local PTY), but its FK to profiles cannot.
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). Do not store notes in Herdr. Do not reintroduce mapping / worktree_path authority. Do not delete Local PTY (Task 9). Do not launch/adopt the project-folder default (Task 10). Do not start a second events.subscribe / name HerdrRuntimeSync in lib.rs. Pin stays v0.9.0. TWOCODE_RUNTIME=local remains until Task 9. Local must never own a worktree Herdr already owns.
This branch is the chosen resolution for #446 (drop leftover sqlite extras so Local-flag delete cannot git worktree remove a Herdr-open checkout). Finish removing leftover sqlite UUID joins called out in #447 (sqlite_profile_id_for_checkout, live_workspace_for_sqlite_profile). Do not implement a live-path Local-delete lock instead of DROP.
Dependencies: Parent plan #436. Prerequisites: #437 (Task 1), #439 (Task 2), #441 (Task 3), #443 (Task 4), #445 (Task 5), #448 (Task 6), #449 (Task 7). Open #438, #440, #442, #444, #450 are line-count tracking only — not blockers. Open #446 / #447 are resolved by this DROP / leftover-UUID removal, not by restoring mappings. Open #394 issues #395–#434 (including #394 Task 8 / #417) must not be implemented or closed here.
Work to complete
-
Move notes off
profilesbefore DROP- Add a 2code sqlite table (suggested name
checkout_notes) keyed byproject_id(FK →projects.idON DELETE CASCADE) + canonicalcheckout_path. Columns:notestext,created_at. Unique on(project_id, checkout_path). Do not key notes by Herdrworkspace_id. Do not store notes in Herdr. - One-shot migrate non-empty leftover
profiles.noteswhoseworktree_pathis non-empty into that table (same path-equality helper as today's overlay). Then overlay/list/update read this table only. notes_overlay/update_notes_with_runtime: Herdr save upserts by live cwd fromreconcile_profile_checkout. A Herdr-only workspace with no leftover row can save notes (closes the Task 5 empty-notes hole). Do not INSERT aprofilesstub. Do not invent a sqlite UUID.- IPC DTO
Profile(id,notes,is_default,worktree_path, …) stays as a derived GUI type. Decouple it from Diesel#[diesel(table_name = profiles)]. Notes UI (ProfileNotesEditor,useUpdateProfileNotes) keeps the same clicks/labels. - Delete notes rows only via project CASCADE (and optional cleanup when a checkout path is gone). Do not fail Herdr
worktree.removeif a notes row is missing.
- Add a 2code sqlite table (suggested name
-
Diesel DROP +
pty_sessionsFK- New embedded migration, in order: create
checkout_notes+ copy leftover notes; recreatepty_sessionswithoutREFERENCES profiles(id)and withproject_idTEXT NOT NULL REFERENCESprojects(id)ON DELETE CASCADE (copyproject_idfrom the old profiles join; fallbackdefault-{project_id}→ that project); DROPsession_runtime_mappings,profile_runtime_mappings,herdr_namespaces, thenprofiles. Keepprojects/project_groups. Do not DROPpty_sessions(Task 9). - Regenerate
src-tauri/crates/model/src/schema.rsvia Diesel (diesel print-schema/ project convention). Do not hand-edit schema. Remove DieselNewProfile/ table-backedProfile/ mapping models once unused. repo::pty::list_by_projectmust filter onpty_sessions.project_id, notINNER JOIN profiles.
- New embedded migration, in order: create
-
Delete leftover sqlite profile / mapping seams
- Stop
insert_defaultoncreate_from_folderand every other production caller. New projects areprojectsrows only. Empty Herdr →profiles: []until Task 10 (already named). - Remove production reads/writes of
profiles/ mapping tables:repo::profileCRUD,repo::runtime_mappingbind/unbind/find,import_leftover_sqlite_profiles(no leftover extras to import),sqlite_profile_id_for_checkout,live_workspace_for_sqlite_profile/ leftover UUID branch ofbound_workspace,refuse_mapped_without_runtime. Herdr create dual-backend refuse uses liveworktree.list/ snapshot only, not sqlite extras. - Herdr list/create/close/session-store/Git/FS/watcher stay on the Task 3–7 live seams. Do not fall back to sqlite when Herdr is empty or down.
- Stop
-
Local flag without a
profilescatalogTWOCODE_RUNTIME=localstill exists until Task 9. Nested sqlite extras are gone.- Local list synthesizes at most one implicit default checkout per project from
projects.folder(id=default-{project_id},is_default= true, notes fromcheckout_notesfor that folder). Do not list leftover extras. Do notgit worktree add/git worktree remove. - Local New Profile / Delete Profile for extras fail closed. Local delete of the implicit default stays refused (primary). Local Git/FS/watcher/PTY use
projects.folderfor that synthetic id (reconcile_local_profile_checkout). Local PTY may keep writingpty_sessionswith unconstrainedprofile_id=default-{project_id}andproject_idset. - Named UX exception (Local flag only): the old nested sqlite profile catalog cannot be backed without
profiles. Default Herdr GUI clicks/labels stay New Profile / Delete Profile. Do not add a Settings runtime toggle. Do not flip the selector to Local.
-
Prove without swallowing later tasks
- Colocated / integration tests: after migrate,
profiles/ mapping /herdr_namespacestables are absent;projectsremain; leftover notes round-trip oncheckout_notesby path; Herdr-only workspace notes save without a sqlite UUID; Herdr list still liveworkspace_id;create_from_folderdoes not INSERT a profile row; Local list is the synthetic folder checkout only; Local extras create/delete fail closed (no git remove); Herdr-down does not sqlite-fill;list_by_projectsessions do not JOINprofiles; production source guards (noinsert_default/ mapping bind /import_leftover_sqlite_profiles/HerdrRuntimeSync/events.subscribeinlib.rs). - Rewrite or delete tests that
INSERT INTO profiles/bind_profile_workspaceas production fixtures. Keep Local-flag coverage for the synthetic folder checkout + fail-closed extras. - Update
docs/herdr-integration.md: Task 8 done on this branch; notes live oncheckout_notes; mapping/profilesDROPped;pty_sessionsremains until Task 9; Local nested extras gone. Do not bump v0.9.0. If line count grows past the estimate, open a tracking issue; do not fold Task 9–10 into this branch.
- Colocated / integration tests: after migrate,
Likely files and directories
- New:
src-tauri/migrations/<timestamp>_drop_profiles_and_runtime_mappings/—checkout_notes,pty_sessionsrecreate, DROP mappings +profiles. - Update:
src-tauri/crates/model/src/schema.rs(regenerate),src-tauri/crates/model/src/profile.rs,src-tauri/crates/model/src/runtime_mapping.rs,src-tauri/crates/model/src/pty.rs(project_idon session records). - Update:
src-tauri/crates/repo/src/profile.rs(remove or replace withcheckout_notesrepo),src-tauri/crates/repo/src/runtime_mapping.rs,src-tauri/crates/repo/src/pty.rs,src-tauri/crates/repo/src/project.rs(list_all_with_profiles). - Update:
src-tauri/crates/service/src/project.rs,src-tauri/crates/service/src/profile.rs,src-tauri/crates/service/src/runtime_adoption.rs,src-tauri/crates/service/src/runtime.rs,src-tauri/crates/service/src/runtime/herdr.rs,src-tauri/crates/service/src/runtime/local.rs(mapping lock only; do not delete Local PTY). - Update:
docs/herdr-integration.md— Task 8 done on this branch. - Update tests: colocated service/repo tests plus
src-tauri/tests/integration_project.rs,src-tauri/tests/integration_pty_db.rs,src-tauri/tests/integration_migrations.rs. - Touch only if IPC DTO fields change:
src-tauri/src/handler/profile.rs, frontend notes hooks.bun run typegenif signatures change; do not editsrc/generated/by hand. - Do not change: Local PTY spawn/adapter internals (Task 9), sidecar pin, Settings runtime toggle, launch/adopt on project open (Task 10), Git/file-tree/notes UI redesign,
lib.rsnamingHerdrRuntimeSync.
Estimated changes: 500–800 lines total, additions plus deletions, including tests and migration SQL; excluding generated files, lockfile churn and binary artifacts. Material scope growth should become a separate issue.
Acceptance criteria
- [ ] Diesel migration DROPs
profiles,profile_runtime_mappings,session_runtime_mappings, andherdr_namespaces.projects/project_groupsremain. sqliteprofilesis not source of truth and is not a table. - [ ] Notes live on a 2code
checkout_notes(or equivalent) table keyed byproject_id+ canonical checkout path. They are not stored in Herdr. Herdr-only workspaces can save/load notes via live cwd. Overlay no longer readsprofiles.notes. - [ ]
pty_sessionsremains for Local until Task 9, withproject_idand no FK toprofiles. Herdr still must not INSERT/UPDATE/DELETEpty_sessions. - [ ]
create_from_folder/ Herdr create/delete / leftover import do not writeprofilesor mapping rows. Leftover UUID joins (sqlite_profile_id_for_checkout,live_workspace_for_sqlite_profile) are gone.import_leftover_sqlite_profilesis gone. - [ ]
TWOCODE_RUNTIME=locallists only the syntheticprojects.folderdefault (no nested extras). Local extras create/delete fail closed and do notgit worktree remove. Default Herdr New Profile / Delete Profile clicks and labels stay. - [ ] Named UX exceptions: route ids are
workspace_id; tab ids arepane_id; empty Herdr profile list until Task 10; splits flattened as extra tabs; non-git New Profile is folderworkspace.create; Local-flag nested sqlite extras are gone (old Local catalog cannot be backed withoutprofiles). The Task 5 “Herdr-only notes stay empty” exception is closed. - [ ] No launch/adopt of the project-folder default. No Local PTY deletion. No second
events.subscribe.lib.rsstill does not nameHerdrRuntimeSync. Pin stays v0.9.0. GUI exit still does notserver stop. - [ ] Tests:
cargo test --workspacefromsrc-tauri(orcargo test --workspace --exclude codewhere GTK is unavailable). Frontend lint/typecheck/tests if frontend scope is introduced.bun run typegenif IPC signatures change; do not editsrc/generated/by hand. - [ ] No pull request until parent #436 is complete.
Out of scope
- Deleting the Local PTY runtime, Local adapter, or DROPping
pty_sessions(Task 9). - Launch/adopt of the project-folder default (
worktree.open/workspace.createon project open) (Task 10). - Reintroducing
profile_runtime_mappings/ a path-cache column as authority, or a live-path Local-delete lock as a substitute for DROP (#446 is resolved by this DROP). - Starting a new
HerdrRuntimeSync/events.subscribe, changing the v0.9.0 pin, or #394 Task 16 / #432. - Implementing or closing #394 issues #395–#434 (including #394 Task 8 / #417) 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; this task names one new exception: Local-flag nested sqlite extras are gone. Default Herdr GUI is unchanged aside from notes now working on Herdr-only workspaces.
- One task; stack on
task-7-herdr-live-cwd. Do not open a PR until the parent plan is complete.