重建会话记录逻辑
This commit is contained in:
@@ -339,28 +339,33 @@ export class LearningOrchestrator {
|
||||
source: "review" as const,
|
||||
traceId: input.requestContext.traceId,
|
||||
};
|
||||
const result =
|
||||
proposal.action === "add"
|
||||
? await this.memoryStore.upsert(proposal.scope as MemoryScope, scopeKey, draft)
|
||||
: proposal.action === "replace"
|
||||
? await this.memoryStore.replace(
|
||||
proposal.scope as MemoryScope,
|
||||
scopeKey,
|
||||
proposal.target_id ?? "",
|
||||
draft,
|
||||
)
|
||||
: await this.memoryStore.remove(
|
||||
proposal.scope as MemoryScope,
|
||||
scopeKey,
|
||||
proposal.target_id ?? "",
|
||||
);
|
||||
const accepted =
|
||||
"entry" in result ? Boolean(result.entry) : Boolean(result.changed);
|
||||
let accepted = false;
|
||||
let detail = "memory rejected";
|
||||
if (proposal.action === "add") {
|
||||
const result = await this.memoryStore.upsert(proposal.scope as MemoryScope, scopeKey, draft);
|
||||
accepted = Boolean(result.entry);
|
||||
detail = result.detail;
|
||||
} else if (proposal.action === "replace") {
|
||||
const result = await this.memoryStore.replace(
|
||||
proposal.scope as MemoryScope,
|
||||
scopeKey,
|
||||
proposal.target_id ?? "",
|
||||
draft,
|
||||
);
|
||||
accepted = Boolean(result.changed);
|
||||
detail = result.detail;
|
||||
} else {
|
||||
const result = await this.memoryStore.remove(
|
||||
proposal.scope as MemoryScope,
|
||||
scopeKey,
|
||||
proposal.target_id ?? "",
|
||||
);
|
||||
accepted = Boolean(result.changed);
|
||||
detail = result.detail;
|
||||
}
|
||||
await writeLearningAuditLog({
|
||||
action: `memory-${proposal.action}`,
|
||||
detail: sanitizeAuditDetail(
|
||||
"detail" in result ? result.detail : result.changed ? "memory stored" : "memory deduped",
|
||||
),
|
||||
detail: sanitizeAuditDetail(detail),
|
||||
outcome: accepted ? "accepted" : "rejected",
|
||||
projectId: input.requestContext.projectId,
|
||||
proposal: sanitizeMemoryProposalForAudit(proposal),
|
||||
|
||||
Reference in New Issue
Block a user