From 3b2a85aeaf836f93430c422fd38a1fd7d4ed0aff Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Wed, 15 Jul 2026 18:19:34 +0530 Subject: [PATCH] fix(tests): Incorporate TimeDeltaGenerator short-circuit for tests --- .codegraph/.gitignore | 5 +++++ apps/gui/next-env.d.ts | 2 +- packages/memory/src/handoff.ts | 2 +- packages/memory/src/ledger.ts | 4 ++-- tests/integration/actor-monologue.test.ts | 14 ++++++-------- tests/integration/game-loop.test.ts | 8 ++------ 6 files changed, 17 insertions(+), 18 deletions(-) create mode 100644 .codegraph/.gitignore diff --git a/.codegraph/.gitignore b/.codegraph/.gitignore new file mode 100644 index 0000000..d20c0fe --- /dev/null +++ b/.codegraph/.gitignore @@ -0,0 +1,5 @@ +# CodeGraph data files — local to each machine, not for committing. +# Ignore everything in .codegraph/ except this file itself, so transient +# files (the database, daemon.pid, sockets, logs) never show up in git. +* +!.gitignore diff --git a/apps/gui/next-env.d.ts b/apps/gui/next-env.d.ts index 9edff1c..c4b7818 100644 --- a/apps/gui/next-env.d.ts +++ b/apps/gui/next-env.d.ts @@ -1,6 +1,6 @@ /// /// -import "./.next/types/routes.d.ts"; +import "./.next/dev/types/routes.d.ts"; // NOTE: This file should not be edited // see https://nextjs.org/docs/app/api-reference/config/typescript for more information. diff --git a/packages/memory/src/handoff.ts b/packages/memory/src/handoff.ts index 20e7597..c38b8fe 100644 --- a/packages/memory/src/handoff.ts +++ b/packages/memory/src/handoff.ts @@ -239,7 +239,7 @@ ${candidatesList} } const result = response.data; - const db = (this.bufferRepo as unknown as { db: Record }).db; + const db = (this.bufferRepo as unknown as { db: { transaction: (fn: () => void) => void } }).db; const ledgerEntries: LedgerEntry[] = []; for (const chunk of result.chunks) { diff --git a/packages/memory/src/ledger.ts b/packages/memory/src/ledger.ts index 0a79fc5..68c1c97 100644 --- a/packages/memory/src/ledger.ts +++ b/packages/memory/src/ledger.ts @@ -186,7 +186,7 @@ export class LedgerRepository { if (rows.length === 0) return []; - const entryIds = rows.map((r) => r.id); + const entryIds = rows.map((r) => r.id as string); const placeholders = entryIds.map(() => "?").join(","); const entitiesRows = this.db .prepare( @@ -205,7 +205,7 @@ export class LedgerRepository { entitiesMap.get(er.entry_id)!.push(er.entity_id); } - return rows.map((row) => this.mapRowToEntry(row, entitiesMap.get(row.id) || [])); + return rows.map((row) => this.mapRowToEntry(row, entitiesMap.get(row.id as string) || [])); } private fetchRawNeighbors(ownerId: string, timestamp: string): LedgerEntry[] { diff --git a/tests/integration/actor-monologue.test.ts b/tests/integration/actor-monologue.test.ts index 0b509ec..c352e18 100644 --- a/tests/integration/actor-monologue.test.ts +++ b/tests/integration/actor-monologue.test.ts @@ -88,10 +88,9 @@ describe("Actor Agent + Monologue Intent Integration (Tier 2)", () => { ], }; - // 3. Architect: dialogue is always valid (0 min), action is valid (2 min). + // 3. Architect: dialogue is always valid (1 min), action is valid (2 min). // NOTE: monologue never reaches the validator/delta generator. const mockDialogueValidation = { isValid: true, reason: "Alice can speak." }; - const mockDialogueTimeDelta = { minutesToAdvance: 0, explanation: "Speech is instantaneous." }; const mockActionValidation = { isValid: true, reason: "The ledger is within reach." }; const mockActionTimeDelta = { minutesToAdvance: 2, explanation: "Reaching for the ledger takes 2 minutes." }; @@ -99,9 +98,8 @@ describe("Actor Agent + Monologue Intent Integration (Tier 2)", () => { mockActorProse, // 1. Actor generation mockDecodedSequence, // 2. IntentDecoder mockDialogueValidation, // 3. Architect.validateIntent (dialogue) - mockDialogueTimeDelta, // 4. TimeDeltaGenerator (dialogue) - mockActionValidation, // 5. Architect.validateIntent (action) - mockActionTimeDelta, // 6. TimeDeltaGenerator (action) + mockActionValidation, // 4. Architect.validateIntent (action) + mockActionTimeDelta, // 5. TimeDeltaGenerator (action) ]); const actor = new ActorAgent(llmProvider, bufferRepo); @@ -143,7 +141,7 @@ describe("Actor Agent + Monologue Intent Integration (Tier 2)", () => { expect(intents[0].type).toBe("monologue"); expect(writtenEntries[0].outcome).toBeUndefined(); - // 4. Dialogue: valid, 0-minute delta, no outcome field. + // 4. Dialogue: valid, 1-minute delta, no outcome field. expect(writtenEntries[1].outcome).toBeUndefined(); // 5. Action: valid, 2-minute delta, outcome attached. @@ -152,8 +150,8 @@ describe("Actor Agent + Monologue Intent Integration (Tier 2)", () => { reason: "The ledger is within reach.", }); - // 6. Clock advanced by exactly 2 minutes (dialogue 0 + action 2). - const expectedTime = new Date(startTime.getTime() + 2 * 60_000); + // 6. Clock advanced by exactly 3 minutes (dialogue 1 + action 2). + const expectedTime = new Date(startTime.getTime() + 3 * 60_000); expect(world.clock.get().toISOString()).toBe(expectedTime.toISOString()); // 7. All three intents persisted to Alice's memory buffer. diff --git a/tests/integration/game-loop.test.ts b/tests/integration/game-loop.test.ts index 05b4ed0..ea30edf 100644 --- a/tests/integration/game-loop.test.ts +++ b/tests/integration/game-loop.test.ts @@ -52,7 +52,6 @@ describe("Omnia Integration Tests (Tier 2)", () => { // 2. Architect validation & delta generation responses const mockDialogueValidation = { isValid: true, reason: "Alice is able to speak to Bob." }; - const mockDialogueTimeDelta = { minutesToAdvance: 0, explanation: "Dialogue is instantaneous." }; const mockActionValidation = { isValid: true, reason: "The door is unlocked and reachable." }; const mockActionTimeDelta = { minutesToAdvance: 3, explanation: "Creeping silently and opening a door takes 3 minutes." }; @@ -60,7 +59,6 @@ describe("Omnia Integration Tests (Tier 2)", () => { const llmProvider = new MockLLMProvider([ mockIntentSequence, // Used by IntentDecoder mockDialogueValidation, // Used by Architect.validateIntent (Dialogue) - mockDialogueTimeDelta, // Used by TimeDeltaGenerator (Dialogue) mockActionValidation, // Used by Architect.validateIntent (Action) mockActionTimeDelta // Used by TimeDeltaGenerator (Action) ]); @@ -77,7 +75,7 @@ describe("Omnia Integration Tests (Tier 2)", () => { // 2. Process first intent (dialogue) const result1 = await architect.processIntent(world, decodedSequence.intents[0]); expect(result1.isValid).toBe(true); - expect(result1.timeDelta!.minutesToAdvance).toBe(0); + expect(result1.timeDelta!.minutesToAdvance).toBe(1); // 3. Process second intent (action) const result2 = await architect.processIntent(world, decodedSequence.intents[1]); @@ -85,7 +83,7 @@ describe("Omnia Integration Tests (Tier 2)", () => { expect(result2.timeDelta!.minutesToAdvance).toBe(3); // 4. Verify local state clock advanced by the time deltas - const expectedTime = new Date(startTime.getTime() + 3 * 60_000); // 3 minutes total + const expectedTime = new Date(startTime.getTime() + 4 * 60_000); // 4 minutes total (dialogue 1 + action 3) expect(world.clock.get().toISOString()).toBe(expectedTime.toISOString()); // 5. Verify database state clock was advanced and persisted @@ -133,12 +131,10 @@ describe("Omnia Integration Tests (Tier 2)", () => { const mockActionValidation = { isValid: false, reason: "Hairpins cannot pick high-security locks." }; // For intent2 (dialogue): const mockDialogueValidation = { isValid: true, reason: "Alice is free to talk." }; - const mockDialogueTimeDelta = { minutesToAdvance: 1, explanation: "Speaking takes 1 minute." }; const llmProvider = new MockLLMProvider([ mockActionValidation, // Used by Architect.validateIntent (Action) mockDialogueValidation, // Used by Architect.validateIntent (Dialogue) - mockDialogueTimeDelta // Used by TimeDeltaGenerator (Dialogue) ]); const architect = new Architect(llmProvider, repo);