feat: Added Alias Resolver DeltaGenerator

This commit is contained in:
2026-07-09 09:26:56 +05:30
10 changed files with 187 additions and 880 deletions

View File

@@ -64,12 +64,6 @@
"value": "A clean, sterile grey jumpsuit with 'Alpha' embroidered in black lettering on the chest pocket.",
"visibility": "PUBLIC"
},
{
"name": "knowledge",
"value": "I woke up here. I know my name is Alpha. I know I agreed to participate in a paid scientific experiment, but my memories of who I was or my life before this room are gone.",
"visibility": "PRIVATE",
"allowedEntities": ["7c9b83b3-8cfb-4e89-8d77-626a5757d591"]
},
{
"name": "neural_erasure_dose",
"value": "150mg Compound-TR9",
@@ -77,18 +71,15 @@
"allowedEntities": []
}
],
"aliases": {
"bf3f29d2-cf11-4b11-9a99-b13c126d400e": "the person in the Beta jumpsuit"
},
"initialMemories": [
{
"id": "alpha-wake",
"timestamp": "2026-07-09T07:58:00.000Z",
"locationId": "white-room",
"intent": {
"type": "action",
"originalText": "I woke up on the floor. I stood up and looked around the white room, realizing my memories were wiped.",
"description": "wake up on the cold floor and stand up",
"type": "monologue",
"originalText": "I didn't have a choice. I would have been sent to jail if I hadn't agreed to do this experiement.",
"description": "",
"actorId": "7c9b83b3-8cfb-4e89-8d77-626a5757d591",
"targetIds": []
}
@@ -115,12 +106,6 @@
"value": "A clean, sterile grey jumpsuit with 'Beta' embroidered in black lettering on the chest pocket.",
"visibility": "PUBLIC"
},
{
"name": "knowledge",
"value": "I remember my name is Beta. I remember signing up for a paid research study. My past memories have been completely erased. I am disoriented.",
"visibility": "PRIVATE",
"allowedEntities": ["bf3f29d2-cf11-4b11-9a99-b13c126d400e"]
},
{
"name": "neural_erasure_dose",
"value": "150mg Compound-TR9",
@@ -128,9 +113,6 @@
"allowedEntities": []
}
],
"aliases": {
"7c9b83b3-8cfb-4e89-8d77-626a5757d591": "the person in the Alpha jumpsuit"
},
"initialMemories": [
{
"id": "beta-wake",
@@ -138,8 +120,8 @@
"locationId": "white-room",
"intent": {
"type": "action",
"originalText": "I opened my eyes, sitting against the wall. I rubbed my temples, trying to remember how I got here.",
"description": "wake up sitting against the wall and rub temples",
"originalText": "Why can't I remember anything before the research agreement. It's like my memory was erased.",
"description": "",
"actorId": "bf3f29d2-cf11-4b11-9a99-b13c126d400e",
"targetIds": []
}

View File

@@ -64,25 +64,30 @@ describe("Talking Room Demo Scenario Test (Tier 1)", () => {
expect(alphaName.hasAccess(alphaId)).toBe(true);
expect(alphaName.hasAccess(betaId)).toBe(false);
// Check private knowledge attribute visibility
const alphaKnowledge = alpha!.attributes.get("knowledge")!;
expect(alphaKnowledge.visibility).toBe("PRIVATE");
expect(alphaKnowledge.hasAccess(alphaId)).toBe(true);
expect(alphaKnowledge.hasAccess(betaId)).toBe(false);
// Check system-only attribute (neural_erasure_dose)
const alphaDose = alpha!.attributes.get("neural_erasure_dose")!;
expect(alphaDose.visibility).toBe("PRIVATE");
expect(alphaDose.hasAccess(alphaId)).toBe(false);
expect(alphaDose.hasAccess(betaId)).toBe(false);
// Check subjective aliases
expect(alpha!.aliases.get(betaId)).toBe("the person in the Beta jumpsuit");
// Verify subjective aliases are initially undefined
expect(alpha!.aliases.get(betaId)).toBeUndefined();
const beta = world!.getEntity(betaId);
expect(beta).toBeDefined();
expect(beta!.locationId).toBe("white-room");
expect(beta!.aliases.get(alphaId)).toBe("the person in the Alpha jumpsuit");
expect(beta!.aliases.get(alphaId)).toBeUndefined();
// Verify subjective aliases can be dynamically resolved via AliasDeltaGenerator
const { AliasDeltaGenerator } = await import("@omnia/architect");
const { MockLLMProvider } = await import("@omnia/llm");
const llmProvider = new MockLLMProvider([{ alias: "the person in the Beta jumpsuit" }]);
const aliasGenerator = new AliasDeltaGenerator(llmProvider);
const generatedAlias = await aliasGenerator.generate(alpha!, beta!);
expect(generatedAlias).toBe("the person in the Beta jumpsuit");
alpha!.aliases.set(betaId, generatedAlias);
expect(alpha!.aliases.get(betaId)).toBe("the person in the Beta jumpsuit");
// Verify subjective world state serializes the location attributes (epistemic inclusion)
const { serializeSubjectiveWorldState } = await import("@omnia/core");
@@ -103,12 +108,16 @@ describe("Talking Room Demo Scenario Test (Tier 1)", () => {
const alphaMemories = bufferRepo.listForOwner(alphaId);
expect(alphaMemories).toHaveLength(1);
expect(alphaMemories[0].id).toBe("alpha-wake");
expect(alphaMemories[0].intent.description).toBe("wake up on the cold floor and stand up");
expect(alphaMemories[0].intent.type).toBe("monologue");
expect(alphaMemories[0].intent.originalText).toContain("jail");
expect(alphaMemories[0].intent.description).toBe("");
const betaMemories = bufferRepo.listForOwner(betaId);
expect(betaMemories).toHaveLength(1);
expect(betaMemories[0].id).toBe("beta-wake");
expect(betaMemories[0].intent.description).toBe("wake up sitting against the wall and rub temples");
expect(betaMemories[0].intent.type).toBe("action");
expect(betaMemories[0].intent.originalText).toContain("agreement");
expect(betaMemories[0].intent.description).toBe("");
db.close();
});