Repository navigation
Run control storage through in-process SQLite - #305
Merged
Merged
Conversation
Use a single writer and read-only WAL pool, bind record and Telegram values, and run backup through database/sql. Preserve the in-memory authority and existing schema. Work in progress: full validation and fresh review remain. Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
Update the sibling host-loss test to the driver Open signature and retain saved host starts across the full record-kind round trip. Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
Describe command reads and incremental commits more concisely. Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
Adapt the merged upgrade reopen test to Open(path) and cover its record with the existing complete store round trip. Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
Use the fake bot mutex when tests change failure counters so canceled HTTP handlers cannot race a reset. Keep the existing behavior assertions and deadlines. Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
Preserve fleet-aware command fixtures, host pause and move handling, and usage-limit choices while resolving the store-open signature and documentation conflicts. Co-authored-by: Codex (gpt-6.1-sol) <noreply@openai.com>
dinoderek
added a commit
that referenced
this pull request
Nov 23, 2026
## 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.com/claude-code) https://claude.ai/code/session_012F3VVCLzRGGgXRmsf9hjTb
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.
Objective
Run control database storage in process through
modernc.org/sqliteanddatabase/sql, including migrations, Telegram delivery state, andserve --backup. Keep the records table, schema version, process ownership lock, and in-memory command authority.Gates
./dev test(every required lane)2c9a1f22a0ded274e5fa8423051e4bc3ec030636, run 2026-11-23 04:01:39Z: all ten lanes PASS; statement coverage 93.1% (minimum 80%)../dev deps./dev testtest-ai-resultsconfirms all ten lanes PASS.internal/control/database_test.go: all record kinds, including host and upgrade records, survive reopen without sqlite3; reader connections and replacements have the required pragmas and reject writes; WAL snapshots remain stable beside writes; command reads work with database handles closed.internal/control/memory_test.go,store_test.go: audit changed rows through SQLite triggers; failed commit and partial write roll back; a lost commit report reloads durable state and the retry remains idempotent.internal/control/migrate_test.go,plan_status_test.go,telegram_test.go: migrate legacy schemas and round-trip Telegram state through the driver.internal/controlcmd/serve_test.go: backup with no sqlite3 on PATH produces a database that opens.devtools/internal/dev/dev_test.go,internal/serverops/serverops_test.go: doctor names the Codex prerequisite and reports it missing; missing sqlite3 on the server makes the offline database check unknown.Rulings
Ruling (risk: review): Keep the offline server status quick check on sqlite3 and report the database check unknown when that executable is absent.
User notices: when the server does not answer and sqlite3 is unavailable, status names the missing check; a healthy API remains sufficient for the database status.
Alternative: add an engine command to run the quick check in process.
If wrong: another PR changes the status implementation and introduces or wires a suitable engine entry point.
Operator resolution update 2901 required the baseline Go vulnerability fix separately; it is merged here. Resolution update 2942 identifies default-branch test timeouts as host contention and reduces mac session slots; it directs the full rerun and, if necessary, reruns of failing lanes below about 24 load. Every limit remains unchanged.
Review
a1cc8f7: APPROVED, no findings, after the storage-doc trim.09ea8ea: APPROVED, no findings, after refreshing the sibling upgrade work and covering its record.58187c347c5b6ed4a62f45181ad5c72625db8ad8: APPROVED, no findings, after the setup-doc budget trim.8c5a78c: APPROVED, no findings, including mutex-protected fake-bot failure counters; followed by the required main refresh.8d30a1880659ebae462e4a2b7bc8950ad094ec03: APPROVED, no findings, after merging the quiet-session work.2c9a1f22a0ded274e5fa8423051e4bc3ec030636against base67468f894dd47b652b8b05257677e069f0623129: APPROVED, no must-fix findings, after preserving the fleet-aware helper and storage documentation.internal/control/database.go(connection setup, read-only pool and transaction lifetime),store.go(recovery and backup),telegram.go(typed scans and atomic saves).Deviations
None. SQLRunner-dependent test seams are replaced with SQLite triggers and a commit boundary; the behavior assertions remain covered. Existing sqlite3 absence skips are removed for control storage; Codex reader tests still require that executable.
Built with Codex / gpt-6.1-sol.