@devries-cameron20 / t3code-1 / commits / 490a0d687b
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

fix(server): Antigravity usage skips agy index databases instead of reporting partial history (#39435)

Julius Marminge committed Nov 19, 2026 at 16:07 UTC 490a0d687bde4f29a869fdb62ea7c8241e35e082
2 files changed +35 -25
apps/server/src/provider/Drivers/antigravityUsageReader.test.ts
+32 -21
@@ -587,27 +587,38 @@ describe("readAntigravityUsage", () => {
587 }).pipe(Effect.provide(NodeServices.layer)),
588 );
589
590 - it.effect("reads Antigravity step-only stores and reports malformed databases", () =>
591 - Effect.gen(function* () {
592 - const fileSystem = yield* FileSystem.FileSystem;
593 - const path = yield* Path.Path;
594 - const dir = yield* tempDir;
595 - yield* seedDatabase(path.join(dir, "steps.db"), (db) =>
596 - Effect.gen(function* () {
597 - yield* db.exec("CREATE TABLE steps (idx INTEGER, metadata BLOB)");
598 - const usage = [...protoNumber(1, 246), ...protoNumber(2, 10), ...protoNumber(3, 5)];
599 - yield* db.run("INSERT INTO steps VALUES (?, ?)", [
600 - 0,
601 - new Uint8Array([...protoBytes(9, usage), ...protoBytes(8, protoNumber(1, 1780000000))]),
602 - ]);
603 - }),
604 - );
605 - yield* fileSystem.writeFileString(path.join(dir, "broken.db"), "not a sqlite database");
606 - const result = yield* readAntigravityUsage(dir, 0);
607 - assert.strictEqual(result.errors.length, 1);
608 - assert.strictEqual(records(result)[0]?.model, "gemini-2.5-pro");
609 - assert.strictEqual(records(result)[0]?.totals.outputTokens, 5);
610 - }).pipe(Effect.provide(NodeServices.layer)),
590 + it.effect(
591 + "reads Antigravity step-only stores, skips index files and reports malformed databases",
592 + () =>
593 + Effect.gen(function* () {
594 + const fileSystem = yield* FileSystem.FileSystem;
595 + const path = yield* Path.Path;
596 + const dir = yield* tempDir;
597 + // agy 1.5.x keeps this index beside its conversations; it is not a conversation store.
598 + yield* seedDatabase(path.join(dir, "conversation_summaries.db"), (db) =>
599 + db.exec(
600 + "CREATE TABLE conversation_summaries (conversation_id TEXT PRIMARY KEY, title TEXT, step_count INTEGER)",
601 + ),
602 + );
603 + yield* seedDatabase(path.join(dir, "steps.db"), (db) =>
604 + Effect.gen(function* () {
605 + yield* db.exec("CREATE TABLE steps (idx INTEGER, metadata BLOB)");
606 + const usage = [...protoNumber(1, 246), ...protoNumber(2, 10), ...protoNumber(3, 5)];
607 + yield* db.run("INSERT INTO steps VALUES (?, ?)", [
608 + 0,
609 + new Uint8Array([
610 + ...protoBytes(9, usage),
611 + ...protoBytes(8, protoNumber(1, 1780000000)),
612 + ]),
613 + ]);
614 + }),
615 + );
616 + yield* fileSystem.writeFileString(path.join(dir, "broken.db"), "not a sqlite database");
617 + const result = yield* readAntigravityUsage(dir, 0);
618 + assert.deepStrictEqual(result.errors, [path.join(dir, "broken.db")]);
619 + assert.strictEqual(records(result)[0]?.model, "gemini-2.5-pro");
620 + assert.strictEqual(records(result)[0]?.totals.outputTokens, 5);
621 + }).pipe(Effect.provide(NodeServices.layer)),
622 );
623
624 it.effect("ignores large values in unused Antigravity protobuf fields", () =>
apps/server/src/provider/Drivers/antigravityUsageReader.ts
+3 -4
@@ -253,9 +253,8 @@ const readDatabase = Effect.fn("readDatabase")(function* (
253 "SELECT name FROM sqlite_master WHERE type = 'table'",
254 )).map((row) => row.name),
255 );
256 - if (!tables.has("gen_metadata") && !tables.has("steps")) {
257 - return yield* new AntigravityDatabaseDecodeError({ path });
258 - }
256 + // Not a conversation store, e.g. agy's conversation_summaries.db index.
257 + if (!tables.has("gen_metadata") && !tables.has("steps")) return null;
258 // Seek by rowid regardless of indexes; idx normally aliases rowid, but sort for layouts where it does not.
259 const readMetadata = Effect.fnUntraced(function* (
260 query: string,
@@ -421,7 +420,7 @@ export const readAntigravityUsage = Effect.fn("readAntigravityUsage")(function*
420 const files: Array<{ root: string; path: string; records: UsageRecord[] }> = [];
421 const errors: string[] = [];
422 const models = new Map<number, string | null>();
424 - const pending: Array<{ data: CachedDatabase["data"]; fileIndex: number }> = [];
423 + const pending: Array<{ data: NonNullable<CachedDatabase["data"]>; fileIndex: number }> = [];
424 const identities = new Map<string, number>();
425 const groups: Array<
426 UsageCandidate & { parent: number; size: number; owner: number; fileIndex: number }