Skip to content

Prove the SQL store end to end on a migrated version 6 database - #317

Merged
dinoderek merged 5 commits into
mainfrom
task/engine-381
Nov 23, 2026
Merged

dinoderek merged 5 commits into
mainfrom
task/engine-381

Conversation

@dinoderek

Copy link
Copy Markdown
Owner

Objective

End-to-end acceptance tests for the SQL store, run on a copy of the version 6 fixture database (internal/control/testdata/records-v6.sql) that is migrated as it opens. The main suite runs a real engine serve with an empty PATH, so no sqlite3. The relational schema is version 7, because version 6 was already taken. So opening the fixture writes <db>.pre-v7, and a version 8 database is refused. The tests changed no production code and no docs; they showed no doc to be untrue.

Gates

Lane Result Evidence
./dev test (every required lane) PASS all 10 lanes PASS at head 9a5b991 (after merging main), run with umask 022. Each fix round was gated green too: 8fbd023, 84f55dd.
O3 benchmark gate (internal/control/bench_test.go) PASS TestStoreAnswersWithinItsPerformanceTargets and TestOpeningWithTenTimesTheHistoryStaysWithinTheBound pass at their 10× bound. Run locally with the bound set to 1× (reverted, not committed), both passed 3 of 3 runs. BenchmarkStore (200 runs, mean per op, Ryzen 9 5900HX): get 0.07 ms, updates 0.13 ms, session-view 0.56 ms (1 ms targets); inbox 0.74 ms, overview 2.28 ms, plan-detail 1.06 ms, say 0.28 ms, one-record write 0.10 ms (5 ms targets).
  • New or changed tests:
    • internal/cli/store_acceptance_test.go: a real engine serve with no sqlite3 on PATH, on the version 6 fixture.

      • O2: opening writes an owner-only .pre-v7 copy, migrates to version 7 and drops the records table. All 40 recorded reads answer as the version 6 server did.
      • O6: every update snapshot holds only kept fields, with state and version, both in the API answer and in the stored row.
      • O3: reads from the WAL database answer, without seeing the uncommitted write, while a write transaction is held open.
      • O1: a session writes with the credential the version 6 server issued it. Request keys replay and are refused when reused for another command.
      • O6: after aging, one write sweeps every receipt except the dispatch receipts of the attempts still dispatching.
      • O1: serve --backup writes an owner-only version 7 copy, and the database reopens.
      • O2: a version 8 database and an already-taken backup path are both refused, and neither database is changed.
    • internal/cli/store_dashboard_acceptance_test.go: O5. A real engine ui against that server, through a proxy that records each call and holds it until three are in flight. The refresh routes, requested together, make exactly three calls (overview, plan-detail, updates with after set to the cursor), all in flight at once. The thread holds only updates after the cursor.

    • internal/controlrun/fixture_scope_test.go: O4. On the migrated fixture, with a second coordinating plan in a second repository, each plan's View:

      • runs no query naming the other plan's records, nor the fixture repository's other plan;
      • walks no table and holds only its own plan's tasks;
      • for the fixture plan, is the same View it had alone.

      A full pass over both plans walks no table.

    • internal/cli/store_docs_acceptance_test.go: O7. Every paragraph, list item and table row in the persistent docs that names sqlite3 names it for a Codex host, the tests' tool lists or the offline status check.

    • internal/cli/stack_test.go, internal/controlrun/coordinator_test.go: startDashboardOn and coordinatorOn split out of the existing helpers.

    • Mutation checks, each applied, run and reverted: serialising the dashboard's upstream calls, reading the thread from 0, a View that reads other plans' items, and a doc row saying the server needs sqlite3. Each makes its test fail. The reviewers also mutated backup mode, snapshot slimming, retention, the reader pool and overview sharing.

  • Not run, with reason: none. This host has no Chromium, so TestDashboardInBrowser skips locally as before; CI installs one.

Rulings

None. O7: docs/operator-setup.md still says the offline engine server status database check is unknown without sqlite3 on the server. That stays, following the earlier review ruling on the driver change (#305). It is a diagnostic, not a server prerequisite, and the docs test allows it by name.

Review

  • Fresh reviewers: Claude Code (claude-opus-5-5), three rounds.
    • Round 1: CHANGES_REQUESTED at 6ed010c.
      • Must-fix: the main test failed 16 of 30 runs under -race -cpu 1. http.DefaultClient left an idle connection that held engine serve's shutdown past its 5 s deadline. Fixed: the test uses a client of its own, which it closes before SIGTERM, and the dashboard proxy uses it too. Now 30 of 30 pass.
      • Optional, all fixed: busy timeout on the test's database connections; subtests failing their own t, not the parent's; a 30 s deadline on each refusal run; a comment worded as history.
    • Round 2: APPROVED at 8fbd023.
      • Taken: assert WAL in the held-write subtest and reword its comment; check one migrated credential over HTTP; split table rows in the docs test; drop a LookPath check that could never fail.
      • Declined: the 0600 checks only prove something under umask 022, which CI and these gate runs use.
    • Round 3: APPROVED at 9a5b991, after main was merged in.
  • Declined findings (round 3, all optional and low), kept out so the merge head is the reviewed one:
    • numbered-list items in the docs test are not split: no doc lists sqlite3 in a numbered list beside Codex, and the check's failure is shown by mutation;
    • stop after a SIGTERM timeout can race Wait: only on a path that has already failed;
    • no deadline on reading the server's first line, and none on the dashboard fetch: a hang still ends at the go test timeout;
    • itoa via json.Marshal: cosmetic.
  • Review hard: internal/cli/store_dashboard_acceptance_test.go: the commandLog barrier is what makes "in parallel" a real check.

Deviations

  • O4 is proven in process, in internal/controlrun, on the migrated fixture, not through the engine serve subprocess. A subprocess's queries can't be traced. The pass builds each View with the same Coordinator.view the test traces.
  • The card's v5, v6 and v7 are the shipped v6, v7 and v8 (see Objective).

Implemented by Claude Code (claude-opus-5-5).

🤖 Generated with Claude Code

https://claude.ai/code/session_012F3VVCLzRGGgXRmsf9hjTb

dinoderek and others added 5 commits November 23, 2026 08:30
Acceptance tests against a real engine serve, with no sqlite3 on its PATH,
on a copy of the version 6 fixture migrated on open: the private backup and
migration, every recorded read, slimmed snapshots, reads beside a held write,
writes and request keys, receipt retention, backup and the refusals; a
dashboard refresh through a recording proxy; each coordinator View of two
plans in two repositories; and the docs' sqlite3 mentions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012F3VVCLzRGGgXRmsf9hjTb
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012F3VVCLzRGGgXRmsf9hjTb
The default client could leave a connection open that held engine serve's
shutdown past its deadline. Subtests fail their own test, the test's database
connections wait for the server's writer, and a refusal that regressed fails
within 30 seconds instead of hanging.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012F3VVCLzRGGgXRmsf9hjTb
…tance tests

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012F3VVCLzRGGgXRmsf9hjTb
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012F3VVCLzRGGgXRmsf9hjTb
@dinoderek
dinoderek merged commit f80a5f2 into main Nov 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant