Feature 02 task 1: SQLite connection and embedded migration runner #10

Member

Implements task aa75e790 (Feature 02, task 1 of 4).

Done-condition: internal/store opens $MEALQUEST_DATA_DIR/mealquest.db with modernc.org/sqlite (CGO_ENABLED=0 build works) with WAL, foreign_keys=ON, busy_timeout=5000, one writer connection and a read pool; migrations/*.sql embedded and applied in filename order at boot inside transactions, recording each in schema_migrations; tests prove fresh DB latest version, second run no-op, broken migration rolls back leaving the previous version intact and fails boot, and PRAGMA foreign_keys=1 on every connection.

Evidence (orchestrator-run): gofmt -l . empty; go vet ./... clean; go test -race -count=1 ./... ok for all packages including internal/store; CGO_ENABLED=0 go build ./... ok. Only approved dependency modernc.org/sqlite added (v1.59.0).

Base: feature/b9c21d67-...-sqlite-data-layer-and-schema (dev 65b27a7).

Implements task aa75e790 (Feature 02, task 1 of 4). Done-condition: internal/store opens $MEALQUEST_DATA_DIR/mealquest.db with modernc.org/sqlite (CGO_ENABLED=0 build works) with WAL, foreign_keys=ON, busy_timeout=5000, one writer connection and a read pool; migrations/*.sql embedded and applied in filename order at boot inside transactions, recording each in schema_migrations; tests prove fresh DB latest version, second run no-op, broken migration rolls back leaving the previous version intact and fails boot, and PRAGMA foreign_keys=1 on every connection. Evidence (orchestrator-run): gofmt -l . empty; go vet ./... clean; go test -race -count=1 ./... ok for all packages including internal/store; CGO_ENABLED=0 go build ./... ok. Only approved dependency modernc.org/sqlite added (v1.59.0). Base: feature/b9c21d67-...-sqlite-data-layer-and-schema (dev 65b27a7).
dev_agent added 1 commit 2026-10-03 00:48:19 -04:00
Add SQLite store and embedded migration runner
CI / ci (pull_request) Successful in 56s
CI / ci (push) Successful in 49s
Independent review Not signed off — 0 high, 1 medium (#10)
c777668ef5
internal/store opens $MEALQUEST_DATA_DIR/mealquest.db with modernc.org/sqlite
(CGO-free) as one writer connection and a read-only pool of four, with
busy_timeout=5000, journal_mode=WAL and foreign_keys=ON on every connection.

migrations/*.sql are embedded and applied at boot in filename order, each
in its own transaction together with its schema_migrations row, so a failing
migration rolls back and fails boot. A database holding a version this build
does not know is refused. 0001_init.sql is a placeholder until the v1 schema
lands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
review_agent left a comment
Member

Independent review — Codex gpt-6-sol, reasoning high

Verdict: CHANGES_REQUIRED
Reviewed SHA: c777668ef55b0a11b841f15a0e96d86e45dd2b66

{
  "verdict": "CHANGES_REQUIRED",
  "reviewed_sha": "c777668ef55b0a11b841f15a0e96d86e45dd2b66",
  "summary": "The connection setup and migration runner match the requested design on static inspection, but the placeholder migration creates an upgrade defect. gofmt was clean and go mod verify passed. Go vet, race tests, and the CGO-disabled build could not run because this read-only sandbox prevents Go from creating build files.",
  "findings": [
    {
      "id": "F1",
      "severity": "medium",
      "location": "migrations/0001_init.sql:2; internal/store/migrate.go:53",
      "failure_case": "A database started with this commit records 0001_init as applied. When task 3 replaces that file with the real schema, the runner skips it, leaving the database without the new tables.",
      "evidence": "0001_init.sql contains only comments and explicitly says it will be replaced. Migrate skips any filename already recorded in schema_migrations. The embedded-migration test checks the version row but does not check for schema objects.",
      "suggested_correction": "Keep 0001_init.sql immutable and put the later schema in a new migration filename, or add the real schema before this version can be recorded."
    }
  ]
}

Posted unaltered by review_agent. This is transport, not a second review.

## Independent review — Codex `gpt-6-sol`, reasoning high Verdict: **CHANGES_REQUIRED** Reviewed SHA: `c777668ef55b0a11b841f15a0e96d86e45dd2b66` ```json { "verdict": "CHANGES_REQUIRED", "reviewed_sha": "c777668ef55b0a11b841f15a0e96d86e45dd2b66", "summary": "The connection setup and migration runner match the requested design on static inspection, but the placeholder migration creates an upgrade defect. gofmt was clean and go mod verify passed. Go vet, race tests, and the CGO-disabled build could not run because this read-only sandbox prevents Go from creating build files.", "findings": [ { "id": "F1", "severity": "medium", "location": "migrations/0001_init.sql:2; internal/store/migrate.go:53", "failure_case": "A database started with this commit records 0001_init as applied. When task 3 replaces that file with the real schema, the runner skips it, leaving the database without the new tables.", "evidence": "0001_init.sql contains only comments and explicitly says it will be replaced. Migrate skips any filename already recorded in schema_migrations. The embedded-migration test checks the version row but does not check for schema objects.", "suggested_correction": "Keep 0001_init.sql immutable and put the later schema in a new migration filename, or add the real schema before this version can be recorded." } ] } ``` --- Posted unaltered by `review_agent`. This is transport, not a second review.
dev_agent added 1 commit 2026-10-03 00:52:11 -04:00
Make the placeholder migration an immutable 0000_bootstrap
CI / ci (push) Successful in 49s
CI / ci (pull_request) Successful in 48s
Independent review Approved — 0 high findings (#10)
a36cae4517
The runner skips versions already recorded by filename, so replacing the
contents of the applied 0001_init.sql placeholder with the real schema
would leave upgraded databases without the new tables. Rename it to
0000_bootstrap.sql, document it as a permanent no-op, and leave
0001_init.sql free for the v1 schema as a brand-new version.

Add a test that migrates with the embedded set, then adds a fixture
0001_init.sql and proves it applies on the existing database.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
review_agent left a comment
Member

Independent review — Codex gpt-6-sol, reasoning high

Verdict: APPROVED
Reviewed SHA: a36cae4517b68460e72da2deecc967c422c6645b

{
  "verdict": "APPROVED",
  "reviewed_sha": "a36cae4517b68460e72da2deecc967c422c6645b",
  "summary": "The change meets the task’s done-condition. Connection tests verify the required pragmas on distinct reader connections and the writer; migration tests cover ordering, reruns, and rollback; boot propagates migration errors. gofmt, go vet, race tests, the CGO-free build, and module verification passed. The checkout is clean.",
  "findings": []
}

Posted unaltered by review_agent. This is transport, not a second review.

## Independent review — Codex `gpt-6-sol`, reasoning high Verdict: **APPROVED** Reviewed SHA: `a36cae4517b68460e72da2deecc967c422c6645b` ```json { "verdict": "APPROVED", "reviewed_sha": "a36cae4517b68460e72da2deecc967c422c6645b", "summary": "The change meets the task’s done-condition. Connection tests verify the required pragmas on distinct reader connections and the writer; migration tests cover ordering, reruns, and rollback; boot propagates migration errors. gofmt, go vet, race tests, the CGO-free build, and module verification passed. The checkout is clean.", "findings": [] } ``` --- Posted unaltered by `review_agent`. This is transport, not a second review.
approver_agent merged commit e9ee4e768a into feature/b9c21d67-bf72-411a-901d-77e57352d398-sqlite-data-layer-and-schema 2026-10-03 00:54:03 -04:00
Sign in to join this conversation.
No Reviewers
No labels
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: Maniacs_Mansion/MealQuest#10