iterate.com / kernel

git clone https://git.iterate.com/repos/kernel

The engine's test covers a cursor of another generation: tables of another schema are made again

A run of 24 deliberate faults against the engine left one alive: a cursor of another generation
that is trusted. Nothing in the test changed the generation. It now does: the tables are made
again for another schema, filled again from the catalog's rows, and the watcher's old cursor,
which fits the new tables by its numbers alone, gets every row.

Session: agy b859a067-e1f8-4f91-8d14-337c9a19b40b on beelink
Worker: claude 02c7d409-d06c-4792-af54-c1861507c2e0 on beelink

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NCuxgWcYQGgMn3WtDburVD

Jonas Templestein, 2026-11-26 22:42 UTC · dc1cadf241f4ccb5943c6f1b8c87fa1a38bf5f7d · parent d8e4c19

1 file changed

M core/itx/src/context/reactive-catalog.test.ts
@@ -372,6 +372,33 @@
   expect(calls).toBe(5);
 });
 
+test("tables of another schema are made again and filled again, and a cursor of the old ones gets every row", () => {
+  const source = [task(1, "open", 10), task(2, "open", 20)];
+  using object = fakeObject((after, limit) =>
+    source.filter((row) => byteOrder(row.path, after) > 0).slice(0, limit),
+  );
+  const client = new Client();
+  client.connect(object.wake());
+  const spec = { where: { status: "open" }, limit: 5 };
+  client.subscribe(object.wake(), "open", spec);
+  const sub = client.subs.get("open")!;
+  expect(sub.answers.at(-1)).toMatchObject({ reset: true, put: 2 });
+  const generation = sub.gen;
+
+  // a later release of the kernel keeps its tables in another shape
+  object.db.exec("UPDATE rcat_meta SET v = 'an earlier schema' WHERE k = 'schema'");
+  client.socket!.close();
+  object.sockets.delete(client.socket!);
+  const later = object.wake();
+  client.connect(later);
+  // The watcher's cursor fits the new tables by its numbers alone: the two rows have the same
+  // revisions and the same keys again. Only the generation says that it is of other tables.
+  client.subscribe(later, "open", spec, true);
+  expect(sub.answers.at(-1)).toMatchObject({ reset: true, put: 2 });
+  expect(sub).not.toMatchObject({ gen: generation });
+  expect(later.watches({ verify: true })).toMatchObject({ active: true, rows: 2, faults: [] });
+});
+
 test("one write is one message for a socket, over all of its queries", () => {
   using object = fakeObject();
   const catalog = object.wake();