mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
fix: finalize deepfix p2 recall binding and p3 validation matrix
This commit is contained in:
@@ -882,6 +882,86 @@ result = {
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const harness = await createGraphPersistenceHarness({
|
||||
chatId: "chat-sync-refresh-merge",
|
||||
chatMetadata: {
|
||||
integrity: "chat-sync-refresh-merge-ready",
|
||||
},
|
||||
});
|
||||
harness.api.setCurrentGraph(
|
||||
normalizeGraphRuntimeState(
|
||||
createMeaningfulGraph("chat-sync-refresh-merge", "stale-runtime-merge"),
|
||||
"chat-sync-refresh-merge",
|
||||
),
|
||||
);
|
||||
harness.api.setGraphPersistenceState({
|
||||
loadState: "loaded",
|
||||
chatId: "chat-sync-refresh-merge",
|
||||
reason: "runtime-stale",
|
||||
revision: 3,
|
||||
lastPersistedRevision: 3,
|
||||
dbReady: true,
|
||||
writesBlocked: false,
|
||||
});
|
||||
harness.api.setIndexedDbSnapshot(
|
||||
buildSnapshotFromGraph(
|
||||
createMeaningfulGraph("chat-sync-refresh-merge", "fresh-indexeddb-merge"),
|
||||
{
|
||||
chatId: "chat-sync-refresh-merge",
|
||||
revision: 8,
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
const runtimeOptions = harness.api.buildBmeSyncRuntimeOptions();
|
||||
await runtimeOptions.onSyncApplied({
|
||||
chatId: "chat-sync-refresh-merge",
|
||||
action: "merge",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
harness.api.getCurrentGraph().nodes[0]?.fields?.title,
|
||||
"事件-fresh-indexeddb-merge",
|
||||
"merge 后应刷新当前运行时图谱",
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const harness = await createGraphPersistenceHarness({
|
||||
chatId: "chat-sync-refresh-active",
|
||||
chatMetadata: {
|
||||
integrity: "chat-sync-refresh-active-ready",
|
||||
},
|
||||
});
|
||||
harness.api.setCurrentGraph(
|
||||
normalizeGraphRuntimeState(
|
||||
createMeaningfulGraph("chat-sync-refresh-active", "active-runtime"),
|
||||
"chat-sync-refresh-active",
|
||||
),
|
||||
);
|
||||
harness.api.setGraphPersistenceState({
|
||||
loadState: "loaded",
|
||||
chatId: "chat-sync-refresh-active",
|
||||
reason: "runtime-active",
|
||||
revision: 4,
|
||||
dbReady: true,
|
||||
writesBlocked: false,
|
||||
});
|
||||
|
||||
const runtimeOptions = harness.api.buildBmeSyncRuntimeOptions();
|
||||
await runtimeOptions.onSyncApplied({
|
||||
chatId: "chat-sync-refresh-other",
|
||||
action: "download",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
harness.api.getCurrentGraph().nodes[0]?.fields?.title,
|
||||
"事件-active-runtime",
|
||||
"active chat 与 sync payload chat 不一致时不应覆盖当前运行时图谱",
|
||||
);
|
||||
}
|
||||
|
||||
{
|
||||
const sharedSession = new Map();
|
||||
const writer = await createGraphPersistenceHarness({
|
||||
|
||||
@@ -712,7 +712,12 @@ async function testSyncAppliedHook() {
|
||||
const mergeResult = await syncNow("chat-hook-merge", runtime);
|
||||
assert.equal(mergeResult.action, "merge");
|
||||
|
||||
assert.equal(downloadResult.revision, 3);
|
||||
assert.equal(mergeResult.revision, 5);
|
||||
|
||||
assert.deepEqual(hookCalls.map((item) => item.action), ["download", "merge"]);
|
||||
assert.deepEqual(hookCalls.map((item) => item.chatId), ["chat-hook-download", "chat-hook-merge"]);
|
||||
assert.deepEqual(hookCalls.map((item) => item.revision), [3, 5]);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
|
||||
@@ -1929,6 +1929,91 @@ async function testGenerationRecallTransactionDedupesDoubleHookBySameKey() {
|
||||
assert.equal(harness.runRecallCalls[0].hookName, "GENERATION_AFTER_COMMANDS");
|
||||
}
|
||||
|
||||
async function testGenerationRecallTransactionDedupesReverseHookOrder() {
|
||||
const harness = await createGenerationRecallHarness();
|
||||
harness.chat = [{ is_user: true, mes: "逆序同轮输入" }];
|
||||
|
||||
await harness.result.onBeforeCombinePrompts();
|
||||
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||
|
||||
assert.equal(harness.runRecallCalls.length, 1);
|
||||
assert.equal(
|
||||
harness.runRecallCalls[0].hookName,
|
||||
"GENERATE_BEFORE_COMBINE_PROMPTS",
|
||||
);
|
||||
}
|
||||
|
||||
async function testGenerationRecallHistoryModesUseSameBindingAcrossHooks() {
|
||||
for (const generationType of ["continue", "regenerate", "swipe"]) {
|
||||
const harness = await createGenerationRecallHarness();
|
||||
const userMessage = `历史输入-${generationType}`;
|
||||
harness.chat = [
|
||||
{ is_user: true, mes: userMessage },
|
||||
{ is_user: false, mes: "assistant-tail" },
|
||||
];
|
||||
|
||||
await harness.result.onGenerationAfterCommands(generationType, {}, false);
|
||||
await harness.result.onBeforeCombinePrompts();
|
||||
|
||||
assert.equal(harness.runRecallCalls.length, 1, `${generationType} 应只执行一次召回`);
|
||||
assert.equal(harness.runRecallCalls[0].hookName, "GENERATION_AFTER_COMMANDS");
|
||||
assert.equal(harness.runRecallCalls[0].targetUserMessageIndex, 0);
|
||||
assert.equal(harness.runRecallCalls[0].overrideUserMessage, userMessage);
|
||||
}
|
||||
}
|
||||
|
||||
async function testGenerationRecallFrozenBindingSurvivesCrossHookInputDrift() {
|
||||
const harness = await createGenerationRecallHarness();
|
||||
harness.chat = [{ is_user: true, mes: "稳定输入-A" }];
|
||||
|
||||
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||
harness.chat = [{ is_user: true, mes: "稳定输入-B" }];
|
||||
await harness.result.onBeforeCombinePrompts();
|
||||
|
||||
assert.equal(harness.runRecallCalls.length, 1);
|
||||
assert.equal(harness.runRecallCalls[0].overrideUserMessage, "稳定输入-A");
|
||||
}
|
||||
|
||||
async function testGenerationRecallSkipsUntilTargetUserFloorAvailable() {
|
||||
const harness = await createGenerationRecallHarness();
|
||||
harness.chat = [{ is_user: false, mes: "assistant-only" }];
|
||||
|
||||
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||
assert.equal(harness.runRecallCalls.length, 0);
|
||||
|
||||
harness.chat = [{ is_user: true, mes: "补齐 user 楼层" }];
|
||||
await harness.result.onBeforeCombinePrompts();
|
||||
assert.equal(harness.runRecallCalls.length, 1);
|
||||
assert.equal(
|
||||
harness.runRecallCalls[0].hookName,
|
||||
"GENERATE_BEFORE_COMBINE_PROMPTS",
|
||||
);
|
||||
}
|
||||
|
||||
async function testGenerationRecallSameKeyCanRunAgainImmediatelyAsNewGeneration() {
|
||||
const harness = await createGenerationRecallHarness();
|
||||
harness.chat = [{ is_user: true, mes: "同 key 连续生成" }];
|
||||
|
||||
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||
|
||||
assert.equal(harness.runRecallCalls.length, 2);
|
||||
assert.equal(harness.runRecallCalls[0].recallKey, harness.runRecallCalls[1].recallKey);
|
||||
}
|
||||
|
||||
async function testGenerationRecallSameKeyCanRunAgainAfterBridgeWindow() {
|
||||
const harness = await createGenerationRecallHarness();
|
||||
harness.chat = [{ is_user: true, mes: "同 key 重复生成" }];
|
||||
|
||||
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||
const transaction = [...harness.result.generationRecallTransactions.values()][0];
|
||||
transaction.updatedAt = Date.now() - 5000;
|
||||
harness.result.generationRecallTransactions.set(transaction.id, transaction);
|
||||
await harness.result.onGenerationAfterCommands("normal", {}, false);
|
||||
|
||||
assert.equal(harness.runRecallCalls.length, 2);
|
||||
}
|
||||
|
||||
async function testGenerationRecallBeforeCombineRunsStandalone() {
|
||||
const harness = await createGenerationRecallHarness();
|
||||
harness.chat = [{ is_user: true, mes: "仅 before combine" }];
|
||||
@@ -2471,6 +2556,12 @@ await testBatchStatusSemanticFailureDoesNotHideCoreSuccess();
|
||||
await testBatchStatusFinalizeFailureIsNotCompleteSuccess();
|
||||
await testProcessedHistoryAdvanceRequiresCompleteStrongSuccess();
|
||||
await testGenerationRecallTransactionDedupesDoubleHookBySameKey();
|
||||
await testGenerationRecallTransactionDedupesReverseHookOrder();
|
||||
await testGenerationRecallHistoryModesUseSameBindingAcrossHooks();
|
||||
await testGenerationRecallFrozenBindingSurvivesCrossHookInputDrift();
|
||||
await testGenerationRecallSkipsUntilTargetUserFloorAvailable();
|
||||
await testGenerationRecallSameKeyCanRunAgainImmediatelyAsNewGeneration();
|
||||
await testGenerationRecallSameKeyCanRunAgainAfterBridgeWindow();
|
||||
await testGenerationRecallBeforeCombineRunsStandalone();
|
||||
await testGenerationRecallDifferentKeyCanRunAgain();
|
||||
await testGenerationRecallSkippedStateDoesNotLoopToBeforeCombine();
|
||||
|
||||
Reference in New Issue
Block a user