Imported from agentty-xyz/agentty (
crates/ag-store/AGENTS.md). Install upstream withnpx skills add agentty-xyz/agentty --skill ag-store. Copyright stays with the author.
ag-store
Reusable persistence contracts, SQLite adapters, and embedded migrations.
Boundaries
- Keep Agentty filesystem layout, TUI state, Git workflows, and rendering out of this crate.
- Use shared models from
ag-sessionand transport-independent settings fromag-contracts. Implement the worker-ownedOperationRepositorycontract fromag-worker; keepag-agentprovider transports andagenttyout of persistence. - Expose repository mocks through
test-utilswhen dependents need deterministic persistence tests.
Integration
- Hosts choose database paths and open
Database, which applies embedded migrations and exposesAppRepositories. Inject narrow repository traits into workflows. - Inject
TimestampSourcewhen the host controls time. Use in-memory SQLite and injected timestamps for deterministic repository tests. - Consult
crates/ag-store/src/connection.rsfor initialization andcrates/ag-store/tests/repository.rsfor consumer examples.
SQLite Invariants
- Use SQLx directly, without an ORM, and prefer checked query macros. Keep
crates/ag-store/.sqlx/metadata current for offline builds. - Keep migrations embedded and connection setup configured for foreign keys and WAL.
- Never edit an existing migration. Add a numbered
crates/ag-store/migrations/NNN_description.sqlfile and run the migration check. - Use singular
snake_casetable names andsnake_casecolumns. New foreign keys use<table>_id, booleans useis_orhas_, and timestamps end in_at. - Translate
sqlx::Errorinto the crate's typed error surface.
Documentation
Follow skills/development/references/sqlx.md for offline-query metadata regeneration
and docs/site/content/docs/architecture/change-recipes.md for schema changes. Update
docs/site/content/docs/architecture/testability-boundaries.md when repository or clock
contracts change.