Give the fixture the checkpoint column its guard depends on
The test schema omitted `projection_turns.checkpoint_turn_count`, which is the column `dropPendingTurnStarts` keys its "spare checkpoint rows" guard on. Every existing test therefore ran the degraded path where the clause is dropped for schema drift, so the guard's real behavior was never exercised. Added the column (migration 005 has it) and a case covering what the clause is for: a pending row carrying a checkpoint survives the delete. Confirmed the case fails when the clause is removed. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
1 parent
28a69713ed
commit
a37db1a837
1 file changed
+38
-1
@@ -46,10 +46,13 @@ function createSchema(
|
||||
database.exec(`CREATE TABLE projection_thread_sessions (
|
||||
thread_id TEXT PRIMARY KEY, status TEXT NOT NULL, provider_name TEXT,
|
||||
active_turn_id TEXT, last_error TEXT, updated_at TEXT NOT NULL)`);
|
||||
// Mirrors migration 005: `checkpoint_turn_count` matters because
|
||||
// dropPendingTurnStarts keys its guard on it, and a fixture without the
|
||||
// column only ever exercises the degraded path.
|
||||
database.exec(`CREATE TABLE projection_turns (
|
||||
row_id INTEGER PRIMARY KEY AUTOINCREMENT, thread_id TEXT NOT NULL, turn_id TEXT,
|
||||
state TEXT NOT NULL, requested_at TEXT NOT NULL, completed_at TEXT,
|
||||
checkpoint_files_json TEXT NOT NULL,
|
||||
checkpoint_turn_count INTEGER, checkpoint_files_json TEXT NOT NULL,
|
||||
UNIQUE (thread_id, turn_id))`);
|
||||
database.exec(`CREATE TABLE projection_thread_proposed_plans (
|
||||
plan_id TEXT PRIMARY KEY, thread_id TEXT NOT NULL, plan_markdown TEXT NOT NULL,
|
||||
@@ -372,6 +375,40 @@ describe("seedDevDatabase", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// The delete mirrors the server's predicate, which spares rows carrying a
|
||||
// checkpoint. Without the `checkpoint_turn_count IS NULL` clause a checkpoint
|
||||
// row that happened to be pending would be destroyed along with the starts.
|
||||
it("spares a pending row that carries a checkpoint", () => {
|
||||
withDatabases(({ source, target }) => {
|
||||
// A checkpoint row on a thread inside the copied range.
|
||||
const sourceDatabase = new NodeSqlite.DatabaseSync(source);
|
||||
sourceDatabase
|
||||
.prepare(
|
||||
`INSERT INTO projection_turns (thread_id, turn_id, state, requested_at,
|
||||
checkpoint_turn_count, checkpoint_files_json) VALUES ('t4', NULL, 'pending', ?, 7, '[]')`,
|
||||
)
|
||||
.run(SEEDED_AT);
|
||||
sourceDatabase.close();
|
||||
|
||||
seedDevDatabase({
|
||||
sourceDbPath: source,
|
||||
targetDbPath: target,
|
||||
threadLimit: 3,
|
||||
activityLimit: 10,
|
||||
seededAt: SEEDED_AT,
|
||||
});
|
||||
|
||||
const checkpoints = query<{ checkpoint_turn_count: number }>(
|
||||
target,
|
||||
"SELECT checkpoint_turn_count FROM projection_turns WHERE checkpoint_turn_count IS NOT NULL",
|
||||
);
|
||||
assert.deepStrictEqual(
|
||||
checkpoints.map((row) => row.checkpoint_turn_count),
|
||||
[7],
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// Nothing will ever stream into a copied message, so a carried-over flag
|
||||
// renders a caret that never resolves.
|
||||
it("clears the streaming flag on copied messages", () => {
|
||||
|
||||
Reference in new issue
Block a user