refactor: Fix alias duplication for unit and eval tests

This commit is contained in:
2026-07-07 07:26:48 +05:30
parent 0d0b1e5dd8
commit 1aa00532ed
8 changed files with 79 additions and 49 deletions

0
docs/memory.md Normal file
View File

View File

@@ -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": "",

View File

@@ -72,6 +72,7 @@ export interface IAttribute {
name: string,
value: string,
visibility: AttributeVisibility,
allowedEntities: Set<string> | 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");
}

View File

@@ -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");
});
});

2
tests/evals/setup.ts Normal file
View File

@@ -0,0 +1,2 @@
import dotenv from "dotenv";
dotenv.config();

View File

@@ -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")
}
}
});

View File

@@ -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"],
},
},
],
},
});

View File

@@ -1,6 +0,0 @@
import { defineWorkspace } from "vitest/config";
export default defineWorkspace([
"packages/*",
"tests/*"
]);