-
Notifications
You must be signed in to change notification settings - Fork 2
RFC: SQLite-based state management for ToolHive #41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Proposes replacing file-based local state management with a single SQLite database. Phase 1 targets skills to unblock skills lifecycle management. Later phases will migrate workload statuses and groups. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Signed-off-by: Juan Antonio Osorio <ozz@stacklok.com>
rdimitrov
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't looked deeper at the database model, but overall LGTM
blkt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First review, I've yet to read past the Dependency Graph section, but this should represent most of it.
|
Responding to the discussion around normalizing Good suggestion. I looked into this carefully. The tradeoffs: Normalized junction table gives you efficient per-client queries and relational integrity, but at this scale (dozens of rows, 1-3 client apps per skill) those benefits are marginal. It also introduces complexity around whether skills and groups share the same junction table or have separate ones — since skills associate client_apps per-installation (scope + project) while groups associate them at the group level, a shared table needs qualifiers that get awkward fast. JSONB array maps directly to the Go Going with JSONB for now. If query patterns evolve to justify normalization, it's a straightforward migration. Same pattern will apply to groups when they're migrated. Also renaming the column from |
Revise schema based on reviewer feedback from blkt, rdimitrov, and aponcedeleonch: - Add thin `entries` identity table shared across lifecycle-tracked entities (skills, workloads). Groups are standalone. - Change scope model from user/system to user/project with project_root column for multi-project support. - Use JSONB (BLOB) for tags and client_apps columns, confirmed supported by modernc.org/sqlite (SQLite 3.51.2). - Rename clients to client_apps to align with ClientApp domain type. - Add OCI artifact tracking (reference, tag, digest) from skillet. - Add skill_dependencies and oci_tags tables. - Document cross-platform XDG paths via adrg/xdg library. - Drop premature status index. - Remove resolved open questions (WAL checkpoint, client normalization). - Update future phase tables, alternatives, and references. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
5b92436
blkt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! 🚀
Summary
Proposes replacing ToolHive's file-based local state management with a single SQLite database (
toolhive.db).Phase 1 targets the skills subsystem to unblock toolhive#3648. Later phases will migrate workload statuses and groups. RunConfigs and
config.yamlremain file-based.Key Design Decisions
modernc.org/sqlite(pure Go) -- required because ToolHive builds withCGO_ENABLED=0thv serve, CLI commands, and detached proxiespkg/storage/package with domain-specific interfaces (not extending the stream-orientedpkg/state/)toolhive.dbat$XDG_STATE_HOME/toolhive/rather than per-subsystem databasesRelated
🤖 Generated with Claude Code