Fix recall rerank stability and card binding

This commit is contained in:
Youzini-afk
2026-04-03 16:37:23 +08:00
parent 12f77e234d
commit 338a03aa1c
5 changed files with 195 additions and 21 deletions

View File

@@ -3532,6 +3532,70 @@ async function testPersistentRecallSourceResolutionAndTargetRouting() {
assert.equal(fallback.injectionText, "persisted");
}
async function testGenerationRecallFinalInjectionRebindsLatestMatchingUserFloor() {
{
const harness = await createGenerationRecallHarness({ realApplyFinal: true });
harness.chat = [
{ is_user: true, mes: "当前输入" },
{ is_user: false, mes: "assistant-tail" },
];
harness.result.recordRecallSentUserMessage(0, "当前输入", "message-sent");
const resolution =
harness.result.applyFinalRecallInjectionForGeneration({
generationType: "normal",
hookName: "GENERATION_AFTER_COMMANDS",
freshRecallResult: {
status: "completed",
didRecall: true,
injectionText: "fresh-memory",
},
transaction: {
frozenRecallOptions: {
generationType: "normal",
targetUserMessageIndex: null,
overrideUserMessage: "当前输入",
},
},
});
assert.equal(resolution.targetUserMessageIndex, 0);
}
{
const harness = await createGenerationRecallHarness({ realApplyFinal: true });
harness.chat = [
{ is_user: true, mes: "尾部 user 仍可匹配" },
{ is_user: false, mes: "assistant-tail" },
];
const resolution =
harness.result.applyFinalRecallInjectionForGeneration({
generationType: "normal",
hookName: "GENERATION_AFTER_COMMANDS",
freshRecallResult: {
status: "completed",
didRecall: true,
injectionText: "fresh-memory",
sourceCandidates: [
{
text: "尾部 user 仍可匹配",
},
],
},
transaction: {
frozenRecallOptions: {
generationType: "normal",
targetUserMessageIndex: null,
overrideUserMessage: "尾部 user 仍可匹配",
},
},
});
assert.equal(resolution.targetUserMessageIndex, 0);
}
}
async function testRecallSubGraphAndDataLayerEntryPoints() {
// Sub-graph build test (pure function, no DOM needed)
const { buildRecallSubGraph } = await import("../recall-message-ui.js");
@@ -4340,6 +4404,7 @@ await testGenerationRecallAppliesFinalInjectionOncePerTransaction();
await testGenerationRecallDeferredRewriteMutatesFinalMesSendPayload();
await testPersistentRecallDataLayerLifecycleAndCompatibility();
await testPersistentRecallSourceResolutionAndTargetRouting();
await testGenerationRecallFinalInjectionRebindsLatestMatchingUserFloor();
await testRecallCardMountsOnStandardUserMessageDom();
await testRecallCardSkipsMountWithoutStableMessageIndex();
await testRecallCardDelayedDomInsertionEventuallyRenders();

View File

@@ -279,6 +279,8 @@ assert.equal(llmPoolResult.meta.retrieval.diversityApplied, true);
assert.equal(llmPoolResult.meta.retrieval.candidatePoolBeforeDpp, 3);
assert.equal(llmPoolResult.meta.retrieval.candidatePoolAfterDpp, 2);
assert.equal(state.llmOptions[0].returnFailureDetails, true);
assert.equal(state.llmOptions[0].maxRetries, 2);
assert.equal(state.llmOptions[0].maxCompletionTokens, 512);
state.vectorCalls.length = 0;
state.diffusionCalls.length = 0;