Files
Jyotisha/frontend/tests/rectification-evidence-quote.test.ts
Jesse_Chen fe87a9ecdb fix(web): isolate rectification answers from tool-step planning text
Mastra intermediate text-delta was published as answer.delta, then set-focus domain errors reset the attempt and replayed evidence. Publish only the terminal no-tool step, persist the next probe on the server, and ground batch quotes in the source turn.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-24 21:26:57 +08:00

37 lines
1.3 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { resolveEvidenceQuote, publicEvidenceItemStatus } from "../src/lib/rectification-agentic/v9/evidence-quote.ts";
const SOURCE = "2020年4月开始实习 6月转正 10月离职";
test("uses exact source-turn offsets for evidence quotes", () => {
const intern = resolveEvidenceQuote(SOURCE, { quoteStart: 0, quoteEnd: 11 });
assert.equal(intern.ok, true);
if (intern.ok) assert.equal(intern.quote, "2020年4月开始实习");
const rewritten = resolveEvidenceQuote(SOURCE, { quote: "2020年6月转正" });
assert.equal(rewritten.ok, false);
if (!rewritten.ok) assert.equal(rewritten.errorCode, "quote_mismatch");
const original = resolveEvidenceQuote(SOURCE, { quote: "6月转正" });
assert.equal(original.ok, true);
if (original.ok) assert.equal(original.quote, "6月转正");
});
test("returns per-item evidence batch results", () => {
assert.equal(publicEvidenceItemStatus({
outcome: "accepted",
idempotent: false,
errorCode: null,
}), "created");
assert.equal(publicEvidenceItemStatus({
outcome: "accepted",
idempotent: true,
errorCode: null,
}), "already_exists");
assert.equal(publicEvidenceItemStatus({
outcome: "rejected",
idempotent: false,
errorCode: "quote_not_grounded",
}), "quote_mismatch");
});