Cover the command-receipts delete in the fixture
Completing the fixture audit: `orchestration_command_receipts` is one of the three tables the seed clears, but the fixture never created it, so that delete only ever ran its table-missing skip path. Added the table (migration 002) with a receipt row, and extended the event-log test to assert receipts go too — a receipt left behind records a command whose events the seed deleted, so re-issuing that command would be treated as already applied and produce nothing. Confirmed the assertion fails when the delete is removed. The audit is now complete: every table the seed writes or clears exists in the fixture, and every column it keys on is present. The remaining schema gaps are columns copied generically by column intersection, where no seeder behavior depends on them. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
dc375f336d
commit
9c61dbed19
1 file changed
+21
@@ -70,6 +70,13 @@ function createSchema(
|
||||
database.exec(`CREATE TABLE provider_session_runtime (
|
||||
thread_id TEXT PRIMARY KEY, provider_name TEXT NOT NULL, adapter_key TEXT NOT NULL,
|
||||
status TEXT NOT NULL, last_seen_at TEXT NOT NULL)`);
|
||||
// Cleared alongside the event log: a receipt records a command whose events
|
||||
// the seed just deleted, so a retry of that command would be treated as
|
||||
// already applied.
|
||||
database.exec(`CREATE TABLE orchestration_command_receipts (
|
||||
command_id TEXT PRIMARY KEY, aggregate_kind TEXT NOT NULL, aggregate_id TEXT NOT NULL,
|
||||
accepted_at TEXT NOT NULL, result_sequence INTEGER NOT NULL, status TEXT NOT NULL,
|
||||
error TEXT)`);
|
||||
}
|
||||
|
||||
/** Source DB with `threadCount` threads, oldest first so recency ordering is testable. */
|
||||
@@ -192,6 +199,11 @@ function makeTarget(path: string, options?: { readonly dropProposedPlans?: boole
|
||||
.prepare(`INSERT INTO provider_session_runtime
|
||||
VALUES ('stale-thread','claude','claude-code','running','${SEEDED_AT}')`)
|
||||
.run();
|
||||
// A receipt for a command whose events the seed is about to delete.
|
||||
database
|
||||
.prepare(`INSERT INTO orchestration_command_receipts
|
||||
VALUES ('old-command','thread','stale-thread','${SEEDED_AT}',1,'accepted',NULL)`)
|
||||
.run();
|
||||
if (options?.dropProposedPlans) {
|
||||
// A target far enough behind that a whole table is missing (migration 013).
|
||||
database.exec("DROP TABLE projection_thread_proposed_plans");
|
||||
@@ -578,6 +590,15 @@ describe("seedDevDatabase", () => {
|
||||
"SELECT COUNT(*) count FROM orchestration_events",
|
||||
);
|
||||
assert.equal(events?.count, 0);
|
||||
|
||||
// Receipts go with them: one left behind records a command whose events
|
||||
// no longer exist, so re-issuing that command would be treated as
|
||||
// already applied and produce nothing.
|
||||
const [receipts] = query<{ count: number }>(
|
||||
target,
|
||||
"SELECT COUNT(*) count FROM orchestration_command_receipts",
|
||||
);
|
||||
assert.equal(receipts?.count, 0);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user