From 1aa00532ed51239772a90d78784c04f9f06ba82d Mon Sep 17 00:00:00 2001 From: Aditya Gupta Date: Tue, 7 Jul 2026 07:26:48 +0530 Subject: [PATCH] refactor: Fix alias duplication for unit and eval tests --- docs/memory.md | 0 package.json | 6 ++-- packages/core/src/attribute.ts | 8 ++++-- tests/evals/intent-decoder.eval.ts | 45 ++++++++++++++++++++++++++++++ tests/evals/setup.ts | 2 ++ vitest.config.evals.ts | 28 ------------------- vitest.config.ts | 33 +++++++++++++++------- vitest.workspace.ts | 6 ---- 8 files changed, 79 insertions(+), 49 deletions(-) create mode 100644 docs/memory.md create mode 100644 tests/evals/intent-decoder.eval.ts create mode 100644 tests/evals/setup.ts delete mode 100644 vitest.config.evals.ts delete mode 100644 vitest.workspace.ts diff --git a/docs/memory.md b/docs/memory.md new file mode 100644 index 0000000..e69de29 diff --git a/package.json b/package.json index 165d9a3..fb92307 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,9 @@ "format": "prettier . --write", "format:check": "prettier . --check", "watch": "tsc -b --watch", - "test": "vitest run", - "test:watch": "vitest", - "test:evals": "vitest run --config vitest.config.evals.ts" + "test": "vitest run --project unit", + "test:watch": "vitest --project unit", + "test:evals": "vitest run --project evals" }, "keywords": [], "author": "", diff --git a/packages/core/src/attribute.ts b/packages/core/src/attribute.ts index f3e1123..931fbb0 100644 --- a/packages/core/src/attribute.ts +++ b/packages/core/src/attribute.ts @@ -72,6 +72,7 @@ export interface IAttribute { name: string, value: string, visibility: AttributeVisibility, + allowedEntities: Set | null, ): void; getVisibleAttributesFor(viewerId: string): Attribute[]; } @@ -118,8 +119,11 @@ export function serializeAttributes(attributes: Attribute[]): string { const lines: string[] = []; for (const attr of attributes) { const aclList = Array.from(attr.getAllowedEntities()); - const aclStr = aclList.length > 0 ? ` (Visible to: ${aclList.join(", ")})` : ""; - lines.push(`* ${attr.name}: ${attr.getValue()} (Visibility: ${attr.getVisibility()})${aclStr}`); + const aclStr = + aclList.length > 0 ? ` (Visible to: ${aclList.join(", ")})` : ""; + lines.push( + `* ${attr.name}: ${attr.getValue()} (Visibility: ${attr.getVisibility()})${aclStr}`, + ); } return lines.join("\n"); } diff --git a/tests/evals/intent-decoder.eval.ts b/tests/evals/intent-decoder.eval.ts new file mode 100644 index 0000000..823c45c --- /dev/null +++ b/tests/evals/intent-decoder.eval.ts @@ -0,0 +1,45 @@ +import { describe, test, expect } from "vitest"; +import { WorldState, Entity } from "@omnia/core"; +import { GeminiProvider, llmConfig } from "@omnia/llm"; +import { IntentDecoder } from "@omnia/intent"; + +describe("IntentDecoder Live Eval (Tier 3)", () => { + test("decodes real complex narrative prose using live Gemini API", async () => { + expect(llmConfig.GOOGLE_API_KEY).toBeDefined(); + + // 1. Initialize live provider and decoder + const provider = new GeminiProvider(llmConfig.GOOGLE_API_KEY); + const decoder = new IntentDecoder(provider); + + // 2. Setup a mock world state for target reference resolution + const world = new WorldState("world-xyz"); + const alice = new Entity("alice"); + const bob = new Entity("bob"); + world.addEntity(alice); + world.addEntity(bob); + + // 3. Narrative prose containing both a dialogue and physical action + const narrativeProse = '"Let\'s see if this key opens the main vault," Alice said to Bob. She slipped the silver key into the keyhole and turned it slowly.'; + + // 4. Decode prose using live Gemini model + const result = await decoder.decode(world, "alice", narrativeProse); + + // 5. Assert structure and content correctness + expect(result).toBeDefined(); + expect(result.intents).toBeDefined(); + expect(result.intents.length).toBeGreaterThanOrEqual(1); + + // Verify first intent is dialogue spoken to Bob + const dialogueIntent = result.intents.find(i => i.type === "dialogue"); + expect(dialogueIntent).toBeDefined(); + expect(dialogueIntent!.actorId).toBe("alice"); + expect(dialogueIntent!.targetIds).toContain("bob"); + expect(dialogueIntent!.originalText).toContain("Let's see if this key opens the main vault"); + + // Verify second intent is action + const actionIntent = result.intents.find(i => i.type === "action"); + expect(actionIntent).toBeDefined(); + expect(actionIntent!.actorId).toBe("alice"); + expect(actionIntent!.originalText).toContain("slipped the silver key"); + }); +}); diff --git a/tests/evals/setup.ts b/tests/evals/setup.ts new file mode 100644 index 0000000..7ff27f7 --- /dev/null +++ b/tests/evals/setup.ts @@ -0,0 +1,2 @@ +import dotenv from "dotenv"; +dotenv.config(); diff --git a/vitest.config.evals.ts b/vitest.config.evals.ts deleted file mode 100644 index ac34003..0000000 --- a/vitest.config.evals.ts +++ /dev/null @@ -1,28 +0,0 @@ -import { defineConfig } from "vitest/config"; -import dotenv from "dotenv"; -import path from "path"; -import { fileURLToPath } from "url"; - -const __filename = fileURLToPath(import.meta.url); -const __dirname = path.dirname(__filename); - -// Load environment variables for evals at test process startup -dotenv.config(); - -export default defineConfig({ - test: { - include: ["tests/evals/**/*.eval.ts"], - exclude: ["**/node_modules/**", "**/dist/**"] - }, - resolve: { - alias: { - "@omnia/core": path.resolve(__dirname, "./packages/core/src"), - "@omnia/llm": path.resolve(__dirname, "./packages/llm/src"), - "@omnia/architect": path.resolve(__dirname, "./packages/architect/src"), - "@omnia/intent": path.resolve(__dirname, "./packages/intent/src"), - "@omnia/memory": path.resolve(__dirname, "./packages/memory/src"), - "@omnia/spatial": path.resolve(__dirname, "./packages/spatial/src"), - "@omnia/cli": path.resolve(__dirname, "./cli/src") - } - } -}); diff --git a/vitest.config.ts b/vitest.config.ts index eea943d..f7906d2 100644 --- a/vitest.config.ts +++ b/vitest.config.ts @@ -6,13 +6,6 @@ const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); export default defineConfig({ - test: { - exclude: [ - "**/node_modules/**", - "**/dist/**", - "tests/evals/**" - ] - }, resolve: { alias: { "@omnia/core": path.resolve(__dirname, "./packages/core/src"), @@ -21,7 +14,27 @@ export default defineConfig({ "@omnia/intent": path.resolve(__dirname, "./packages/intent/src"), "@omnia/memory": path.resolve(__dirname, "./packages/memory/src"), "@omnia/spatial": path.resolve(__dirname, "./packages/spatial/src"), - "@omnia/cli": path.resolve(__dirname, "./cli/src") - } - } + "@omnia/cli": path.resolve(__dirname, "./cli/src"), + }, + }, + test: { + projects: [ + { + extends: true, + test: { + name: "unit", + exclude: ["**/node_modules/**", "**/dist/**", "tests/evals/**"], + }, + }, + { + extends: true, + test: { + name: "evals", + include: ["tests/evals/**/*.eval.ts"], + exclude: ["**/node_modules/**", "**/dist/**"], + setupFiles: ["./tests/evals/setup.ts"], + }, + }, + ], + }, }); diff --git a/vitest.workspace.ts b/vitest.workspace.ts deleted file mode 100644 index aa2d39e..0000000 --- a/vitest.workspace.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { defineWorkspace } from "vitest/config"; - -export default defineWorkspace([ - "packages/*", - "tests/*" -]);