Repository navigation
feat(db): sqlite schema, append-only triggers, and typed accessors (T03) - #4
Merged
Merged
Conversation
Implements ARCHITECTURE.md §7.3 and §8: global tables, schema_meta versioning, idempotent ensure_schema, per-fingerprint chunks trio (external-content FTS5 + vec0 float[768] cosine) created on demand, append-only enforcement on runs/run_results/spot_checks/feedback, and typed accessors for every table. sqlite-vec loaded in connect(); WAL + foreign keys on. Depends on T02 (fp8 suffixes); names dependent tasks T07-T15.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Task T03 from docs/ARCHITECTURE.md §14.2 (spec §7.3, §8).
What
src/caliper/schema.sql: all global tables (§8.2–§8.8) with CHECK constraints, indexes, and the §8.9 append-only triggers (UPDATE blocked onrunsonce terminal; unconditional UPDATE/DELETE blocks onrun_results/spot_checks/feedback; DELETE blocked on all four;requests+ children deliberately editable; chunks trio deliberately mutable per FR-02).src/caliper/db.py:connect()(sqlite-vec loaded, WAL, foreign keys), idempotentensure_schema()withschema_metaversion guard,ensure_chunks_tables(conn, fp8)(chunks + external-content FTS5 +vec0 float[768] cosine+ sync triggers), typed accessors for every table.dbis a leaf — noconfigimport, no business logic.Decisions (recorded in docs/TASKS.md Notes)
runsrows must be born in statusrunning.ingest_runsupsert = one row per fingerprint, resetsfinished_at/pages_*.insert_chunks,get_chunks,delete_chunks,insert_chunk_embeddings).Verification
uv run pytest63 passed (25 new: 19 unit, 6 integration for triggers);ruff check,ruff format --check,mypystrict all clean. sqlite-vec loads on Windows (vec_version()called in tests); vec0 cosine distance verified ≈ 0 on a unit vector.Dependent tasks (per §14.4)
T07 (ingest orchestration) uses
ensure_chunks_tables/insert_chunks/delete_chunks; T09 (retrieval) queries the frozenchunks_<fp8>trio shape; T13–T15 read theruns/run_results/spot_checksaccessors. Dependents: re-run integration tests after this merges.