mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-06-13 18:31:16 +08:00
Stop role card names from populating cognition owners
This commit is contained in:
@@ -896,10 +896,6 @@ function inferKnowledgeFromChangedNodes(
|
||||
const normalizedChangedNodeIds = uniqueIds(changedNodeIds);
|
||||
if (normalizedChangedNodeIds.length === 0) return;
|
||||
|
||||
const activeCharacterOwner = resolveKnowledgeOwner(graph, {
|
||||
ownerType: OWNER_TYPE_CHARACTER,
|
||||
ownerName: scopeRuntime.activeCharacterOwner,
|
||||
});
|
||||
const activeUserOwner = resolveKnowledgeOwner(graph, {
|
||||
ownerType: OWNER_TYPE_USER,
|
||||
ownerName: scopeRuntime.activeUserOwner,
|
||||
@@ -946,22 +942,7 @@ function inferKnowledgeFromChangedNodes(
|
||||
}
|
||||
|
||||
if (node.type === "character") {
|
||||
const selfOwner = ensureKnowledgeOwnerState(
|
||||
graph,
|
||||
{
|
||||
ownerType: OWNER_TYPE_CHARACTER,
|
||||
ownerName: node?.fields?.name,
|
||||
nodeId: node.id,
|
||||
},
|
||||
{
|
||||
updatedAt: Date.now(),
|
||||
lastSource: source,
|
||||
},
|
||||
);
|
||||
if (selfOwner.ownerState) {
|
||||
applyKnowledgeNodeIds(selfOwner.ownerState, "knownNodeIds", [node.id]);
|
||||
applyVisibilityPatch(selfOwner.ownerState, node.id, 1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
const mentionedOwners = collectCharacterMentionOwners(graph, node);
|
||||
@@ -975,16 +956,6 @@ function inferKnowledgeFromChangedNodes(
|
||||
applyVisibilityPatch(ownerResult.ownerState, node.id, 0.92);
|
||||
}
|
||||
|
||||
if (activeCharacterOwner.ownerKey && !mentionedOwners.length) {
|
||||
const ownerResult = ensureKnowledgeOwnerState(graph, activeCharacterOwner, {
|
||||
updatedAt: Date.now(),
|
||||
lastSource: source,
|
||||
});
|
||||
if (ownerResult.ownerState) {
|
||||
applyVisibilityPatch(ownerResult.ownerState, node.id, 0.55);
|
||||
}
|
||||
}
|
||||
|
||||
if (activeUserOwner.ownerKey) {
|
||||
const ownerResult = ensureKnowledgeOwnerState(graph, activeUserOwner, {
|
||||
updatedAt: Date.now(),
|
||||
@@ -1513,7 +1484,6 @@ export function getKnowledgeOwnerEntry(graph, ownerKey = "") {
|
||||
export function listKnowledgeOwners(graph) {
|
||||
normalizeGraphCognitiveState(graph);
|
||||
const owners = new Map();
|
||||
const userAliasContext = buildUserAliasContext(graph);
|
||||
|
||||
for (const entry of Object.values(graph.knowledgeState.owners || {})) {
|
||||
const normalizedEntry = createDefaultKnowledgeOwnerState(entry);
|
||||
@@ -1543,49 +1513,6 @@ export function listKnowledgeOwners(graph) {
|
||||
);
|
||||
}
|
||||
|
||||
for (const characterNode of getCharacterNodes(graph)) {
|
||||
if (
|
||||
shouldResolveCharacterOwnerAsUser(
|
||||
graph,
|
||||
characterNode?.fields?.name,
|
||||
"",
|
||||
userAliasContext,
|
||||
)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
const resolvedOwner = resolveKnowledgeOwner(graph, {
|
||||
ownerType: OWNER_TYPE_CHARACTER,
|
||||
ownerName: characterNode?.fields?.name,
|
||||
nodeId: characterNode?.id,
|
||||
userAliasContext,
|
||||
});
|
||||
if (!resolvedOwner.ownerKey) continue;
|
||||
const displayEntry = {
|
||||
ownerKey: resolvedOwner.ownerKey,
|
||||
ownerType: resolvedOwner.ownerType,
|
||||
ownerName: resolvedOwner.ownerName,
|
||||
nodeId: resolvedOwner.nodeId,
|
||||
aliases: [...(resolvedOwner.aliases || [])],
|
||||
knownCount: 0,
|
||||
mistakenCount: 0,
|
||||
manualKnownCount: 0,
|
||||
manualHiddenCount: 0,
|
||||
updatedAt: 0,
|
||||
lastSource: "",
|
||||
};
|
||||
const equivalentEntry =
|
||||
owners.get(resolvedOwner.ownerKey) ||
|
||||
findEquivalentCharacterOwnerEntry(owners, displayEntry);
|
||||
const targetKey = equivalentEntry?.ownerKey || resolvedOwner.ownerKey;
|
||||
owners.set(
|
||||
targetKey,
|
||||
owners.has(targetKey)
|
||||
? mergeListedKnowledgeOwnerEntry(owners.get(targetKey), displayEntry)
|
||||
: displayEntry,
|
||||
);
|
||||
}
|
||||
|
||||
return Array.from(owners.values()).sort((left, right) => {
|
||||
const updatedDelta = Number(right.updatedAt || 0) - Number(left.updatedAt || 0);
|
||||
if (updatedDelta !== 0) return updatedDelta;
|
||||
|
||||
@@ -196,6 +196,60 @@ addNode(
|
||||
const syntheticOwners = listKnowledgeOwners(syntheticGraph);
|
||||
assert.equal(syntheticOwners.some((entry) => entry.ownerType === "character"), false);
|
||||
|
||||
const roleCardGraph = createEmptyGraph();
|
||||
const roleCardEvent = createNode({
|
||||
type: "event",
|
||||
fields: { title: "天气变化", summary: "窗外下起了雨" },
|
||||
seq: 1,
|
||||
});
|
||||
addNode(roleCardGraph, roleCardEvent);
|
||||
applyCognitionUpdates(
|
||||
roleCardGraph,
|
||||
[],
|
||||
{
|
||||
changedNodeIds: [roleCardEvent.id],
|
||||
scopeRuntime: {
|
||||
activeCharacterOwner: "旁白卡",
|
||||
activeUserOwner: "玩家",
|
||||
},
|
||||
},
|
||||
);
|
||||
const roleCardOwners = listKnowledgeOwners(roleCardGraph);
|
||||
assert.equal(
|
||||
roleCardOwners.some(
|
||||
(entry) =>
|
||||
entry.ownerType === "character" && entry.ownerName === "旁白卡",
|
||||
),
|
||||
false,
|
||||
);
|
||||
|
||||
const characterNodeGraph = createEmptyGraph();
|
||||
const plainCharacterNode = createNode({
|
||||
type: "character",
|
||||
fields: { name: "旁白卡", state: "仅角色卡实体" },
|
||||
seq: 1,
|
||||
});
|
||||
addNode(characterNodeGraph, plainCharacterNode);
|
||||
applyCognitionUpdates(
|
||||
characterNodeGraph,
|
||||
[],
|
||||
{
|
||||
changedNodeIds: [plainCharacterNode.id],
|
||||
scopeRuntime: {
|
||||
activeCharacterOwner: "旁白卡",
|
||||
activeUserOwner: "玩家",
|
||||
},
|
||||
},
|
||||
);
|
||||
const characterNodeOwners = listKnowledgeOwners(characterNodeGraph);
|
||||
assert.equal(
|
||||
characterNodeOwners.some(
|
||||
(entry) =>
|
||||
entry.ownerType === "character" && entry.ownerName === "旁白卡",
|
||||
),
|
||||
false,
|
||||
);
|
||||
|
||||
const duplicateCharacterGraph = createEmptyGraph();
|
||||
const roleCardNameNode = createNode({
|
||||
type: "character",
|
||||
@@ -227,8 +281,8 @@ const dedupedCharacterOwners = listKnowledgeOwners(duplicateCharacterGraph).filt
|
||||
assert.equal(dedupedCharacterOwners.length, 1);
|
||||
assert.equal(dedupedCharacterOwners[0].knownCount >= 1, true);
|
||||
assert.equal(
|
||||
dedupedCharacterOwners[0].aliases.includes("艾 琳"),
|
||||
true,
|
||||
dedupedCharacterOwners[0].ownerName,
|
||||
"艾琳",
|
||||
);
|
||||
assert.equal(
|
||||
dedupedCharacterOwners[0].aliases.includes("艾琳"),
|
||||
|
||||
Reference in New Issue
Block a user