Repository navigation
feat(tui): migrate lessons.db / sessions.db to os.UserConfigDir() with workspace isolation #265
Copy link
Copy link
Closed
Labels
loop-systemAgent loop core: budget, gates, delegationAgent loop core: budget, gates, delegation
Description
Context
The runtime databases for the SIN-Code agent are currently written to
project-relative paths:
cmd/sin-code/tui/.sin-code/lessons.db(via TUI agent_runner.go:160)cmd/sin-code/tui/.sin-code/sessions.db(via TUI agent_runner.go:147)cmd/sin-code/internal/.sin-code/index.bin(via index_cmd.go:113)
This is dangerous for two reasons:
- Source-tree leakage: a
git statusafter runningsin-code chat
in a repo shows newlessons.db,sessions.db, orindex.binfiles
in the working tree. The.gitignoreonly maskscmd/sin-code/tui/.sin-code/
(issue chore: .gitignore — add cmd/sin-code/tui/.sin-code/ (runtime SQLite files) #61) — other workspace locations still leak. - Cross-project pollution: the workspace-relative files share one
lessons.dbper project, but the schema-wide defaults in
internal/lessons/store.go:DefaultPath()andinternal/session/store.go:DefaultPath()
already point at~/.local/share/sin-code/. The TUI is the
one-and-onlycmd/sin-code/...caller that bypasses the defaults.
The proper fix (cited verbatim by AGENTS.md §11.1) is to migrate the
TUI agent runner to the user-config-dir defaults, with workspace
isolation so lessons/sessions for project A and project B do not
collide.
Goals
agent_runner.goopenssessions.dbandlessons.dbfrom
internal/session.DefaultPath()andinternal/lessons.DefaultPath()
by default — or, whenConfig.DBHomeis set, from<DBHome>.- Per-workspace isolation: each workspace gets a sub-directory keyed
by a stable short hash ofcfg.Workspace, so two projects do not
share lesson fingerprints. - The
cmd/sin-code/internal/.sin-code/index.binindex migration is
out of scope for this issue — the per-workspace index is a
deliberate feature, not a leak (issue is tracked separately). - Add a one-shot migration message on first run: when an old
project-relative.sin-code/directory is detected, log a
pointer to the new location and do not move the files (the
user can runsin-code sessions migrateif desired — out of
scope for v1 here).
Acceptance Criteria
cmd/sin-code/internal/tui/agent_runner.gono longer writes
<workspace>/.sin-code/{lessons,sessions}.dbwhen
Config.DBHome == "".- New test:
TestNewAgentRunner_UsesDBHomeWhenSetverifies the paths
honourDBHome. - New test:
TestNewAgentRunner_DefaultsAreUserScopedswaps the
package hook forlessons.DefaultPath/session.DefaultPathand
asserts that the resulting files are NOT insidecfg.Workspace. AGENTS.md §11.1updated:sessions.dbandlessons.dbrows are
marked "moved toos.UserConfigDir()(issue [v3.8.0] feat: Vane bridge (citation-backed research) + stack command #62)"; theindex.bin
row keeps its current note.BACKLOG.mdentry removed.CHANGELOG.mdv3.22.0 entry added (or next release tag).
Non-Goals
- Auto-migration of existing per-workspace
.sin-code/directories. - Re-hashing or re-fingerprinting existing lessons.
- The
index.binlocation. - New
sin-code sessions migratesubcommand.
References
AGENTS.md §11.1— the existing roadmap note.BACKLOG.md— the backlog entry.cmd/sin-code/internal/lessons/store.go:56-66—DefaultPath().cmd/sin-code/internal/session/store.go:80-85—DefaultPath().cmd/sin-code/internal/tui/agent_runner.go:147-161— the bypass.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
loop-systemAgent loop core: budget, gates, delegationAgent loop core: budget, gates, delegation
Activity
Delqhi commentedon Jun 17, 2026
Implemented in PR #266 (commit add1184).
feat(tui): migrate lessons.db / sessions.db to os.UserConfigDir() wit…