mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-06-14 02:40:45 +08:00
fix(vector): align authority apply item identity
This commit is contained in:
@@ -169,6 +169,10 @@ function createMockTriviumClient({
|
|||||||
path: "/bme/vector-apply",
|
path: "/bme/vector-apply",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
const itemWithTopLevelId = payload.items?.find((item) => item?.id !== undefined);
|
||||||
|
if (itemWithTopLevelId) {
|
||||||
|
throw new Error("bmeVectorApply items must not send top-level Trivium id");
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
ok: true,
|
ok: true,
|
||||||
database: payload.database || "st_bme_vectors",
|
database: payload.database || "st_bme_vectors",
|
||||||
@@ -266,6 +270,11 @@ assert.equal(isAuthorityVectorConfig(config), true);
|
|||||||
assert.equal(applyCall.items.every((item) => item.payload?.vectorSpaceId === applyCall.vectorSpaceId), true);
|
assert.equal(applyCall.items.every((item) => item.payload?.vectorSpaceId === applyCall.vectorSpaceId), true);
|
||||||
assert.equal(applyCall.items.every((item) => item.payload?.observedDim === 2), true);
|
assert.equal(applyCall.items.every((item) => item.payload?.observedDim === 2), true);
|
||||||
assert.equal(applyCall.items.every((item) => Array.isArray(item.vector) && item.vector.length > 0), true);
|
assert.equal(applyCall.items.every((item) => Array.isArray(item.vector) && item.vector.length > 0), true);
|
||||||
|
assert.equal(applyCall.items[0].id, undefined);
|
||||||
|
assert.equal(applyCall.items[0].externalId, "node-a");
|
||||||
|
assert.equal(applyCall.items[0].nodeId, "node-a");
|
||||||
|
assert.equal(applyCall.items[0].payload.nodeId, "node-a");
|
||||||
|
assert.equal(applyCall.items[0].payload.externalId, "node-a");
|
||||||
assert.equal(result.timings.authorityDiagnostics.upsert.operation, "bmeVectorApply");
|
assert.equal(result.timings.authorityDiagnostics.upsert.operation, "bmeVectorApply");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -261,6 +261,7 @@ function buildAuthorityNodePayload(node = {}, entry = {}, { chatId = "", modelSc
|
|||||||
return {
|
return {
|
||||||
chatId,
|
chatId,
|
||||||
nodeId: normalizeRecordId(node?.id || entry?.nodeId),
|
nodeId: normalizeRecordId(node?.id || entry?.nodeId),
|
||||||
|
externalId: normalizeRecordId(node?.id || entry?.nodeId),
|
||||||
type: String(node?.type || ""),
|
type: String(node?.type || ""),
|
||||||
archived: Boolean(node?.archived),
|
archived: Boolean(node?.archived),
|
||||||
seqStart: Number(seqRange[0] ?? node?.seq ?? 0) || 0,
|
seqStart: Number(seqRange[0] ?? node?.seq ?? 0) || 0,
|
||||||
@@ -295,7 +296,6 @@ function buildAuthorityVectorItems(graph, entries = [], options = {}) {
|
|||||||
if (!node) return null;
|
if (!node) return null;
|
||||||
const payload = buildAuthorityNodePayload(node, entry, options);
|
const payload = buildAuthorityNodePayload(node, entry, options);
|
||||||
return {
|
return {
|
||||||
id: nodeId,
|
|
||||||
externalId: nodeId,
|
externalId: nodeId,
|
||||||
nodeId,
|
nodeId,
|
||||||
text: String(entry?.text || ""),
|
text: String(entry?.text || ""),
|
||||||
|
|||||||
Reference in New Issue
Block a user