feat: add strict workflow taxonomy and claim badges

This commit is contained in:
732642856
2026-07-21 16:56:20 +08:00
parent 878ff96dc5
commit 3427b30fd4
7 changed files with 106 additions and 16 deletions
@@ -0,0 +1,16 @@
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
import test from "node:test";
const rowSource = readFileSync(new URL("../src/components/chat-message-row.tsx", import.meta.url), "utf8");
const badgeSource = readFileSync(new URL("../src/components/claim-boundary-badge.tsx", import.meta.url), "utf8");
const globalStyles = readFileSync(new URL("../src/app/globals.css", import.meta.url), "utf8");
test("assistant messages render a claim boundary badge from technique truth", () => {
assert.match(rowSource, /ClaimBoundaryBadge/);
assert.match(rowSource, /status=\{message\.techniqueTruth\}/);
assert.match(badgeSource, /不把未闭环内容包装成确定预测/);
assert.match(badgeSource, /observation_only/);
assert.match(badgeSource, /reference_only/);
assert.match(globalStyles, /\.claim-boundary-badge/);
});
@@ -34,3 +34,11 @@ test("carries commercial technique truth into the model contract", () => {
assert.match(mastra, /Do not use a restricted technique/);
assert.match(route, /x-jyotish-technique-truth/);
});
test("projects consultation themes through explicit strict workflow taxonomy", () => {
const projection = readFileSync(new URL("../src/lib/consultation-workflow-request.ts", import.meta.url), "utf8");
assert.match(projection, /strictWorkflowRoute/);
assert.match(projection, /claimBoundary/);
assert.match(projection, /requiredLayers/);
assert.match(projection, /negative holdout gate/);
});
@@ -11,11 +11,13 @@ test("timing questions use a legal report theme and preserve a timing route hint
// When: its workflow request is projected for the Python service.
const request = projectConsultationWorkflowRequest(question, "timing");
// Then: the illegal public theme is converted to a legal report theme with a route hint.
assert.deepEqual(request, {
question: "应期与阶段问题:未来哪些阶段值得把握?",
themes: ["career"],
});
// Then: the illegal public theme is converted to a legal report theme with strict route metadata.
assert.equal(request.question, "应期与阶段问题:未来哪些阶段值得把握?");
assert.deepEqual(request.themes, ["career"]);
assert.equal(request.strictWorkflowRoute, "timing");
assert.ok(request.requiredLayers.includes("Narayana"));
assert.ok(request.requiredLayers.includes("negative holdout gate"));
assert.equal(request.claimBoundary, "candidate_day_month_window_only_until_holdout_passes");
});
test("timing input projects only legal private workflow fields", async () => {