mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-06-13 18:31:16 +08:00
Normalize mistaken user owners across extraction and cognition
This commit is contained in:
@@ -209,4 +209,78 @@ globalThis.__stBmeTestContext = {
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
const graph = createEmptyGraph();
|
||||
globalThis.__stBmeTestContext.name1 = "邱谁";
|
||||
globalThis.__stBmeTestContext.name2 = "群像卡";
|
||||
const restore = setTestOverrides({
|
||||
llm: {
|
||||
async callLLMForJSON() {
|
||||
return {
|
||||
operations: [
|
||||
{
|
||||
action: "create",
|
||||
type: "pov_memory",
|
||||
scope: {
|
||||
layer: "pov",
|
||||
ownerType: "character",
|
||||
ownerName: "邱 谁",
|
||||
ownerId: "邱 谁",
|
||||
},
|
||||
fields: { summary: "她感觉对方在试探自己的底线" },
|
||||
},
|
||||
],
|
||||
cognitionUpdates: [
|
||||
{
|
||||
ownerType: "character",
|
||||
ownerName: "【邱谁】",
|
||||
knownRefs: [],
|
||||
},
|
||||
],
|
||||
regionUpdates: {},
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const result = await extractMemories({
|
||||
graph,
|
||||
messages: [{ seq: 7, role: "assistant", content: "用户名误标测试" }],
|
||||
startSeq: 7,
|
||||
endSeq: 7,
|
||||
schema: DEFAULT_NODE_SCHEMA,
|
||||
embeddingConfig: null,
|
||||
settings: {},
|
||||
});
|
||||
|
||||
assert.equal(result.success, true);
|
||||
const povNode = graph.nodes.find(
|
||||
(node) => !node.archived && node.type === "pov_memory",
|
||||
);
|
||||
assert.ok(povNode);
|
||||
assert.equal(povNode.scope?.ownerType, "user");
|
||||
assert.equal(povNode.scope?.ownerName, "邱谁");
|
||||
const knowledgeOwners = Object.values(graph.knowledgeState?.owners || {});
|
||||
assert.equal(
|
||||
knowledgeOwners.some(
|
||||
(entry) =>
|
||||
String(entry?.ownerType || "") === "character" &&
|
||||
String(entry?.ownerName || "") === "邱谁",
|
||||
),
|
||||
false,
|
||||
);
|
||||
assert.equal(
|
||||
knowledgeOwners.some(
|
||||
(entry) =>
|
||||
String(entry?.ownerType || "") === "user" &&
|
||||
String(entry?.ownerName || "") === "邱谁",
|
||||
),
|
||||
true,
|
||||
);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
}
|
||||
|
||||
console.log("extractor-owner-scope tests passed");
|
||||
|
||||
Reference in New Issue
Block a user