57 lines
2.7 KiB
TypeScript
57 lines
2.7 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
import test from "node:test";
|
|
|
|
const route = readFileSync(new URL("../src/app/api/consult/route.ts", import.meta.url), "utf8");
|
|
const reportsRoute = readFileSync(new URL("../src/app/api/reports/route.ts", import.meta.url), "utf8");
|
|
const mastra = readFileSync(new URL("../src/mastra/index.ts", import.meta.url), "utf8");
|
|
|
|
test("runs the Jyotish workflow before streaming a commercial consultation", () => {
|
|
const chartBranch = route.slice(route.indexOf("const toolInput = consultationInputSchema.parse"));
|
|
|
|
assert.match(route, /runConsultationWorkflow/);
|
|
assert.match(chartBranch, /await runConsultationWorkflow\(toolInput, \{ foreground: true \}\)/);
|
|
assert.match(chartBranch, /getJyotishAgent\(selectedModel, workflowContext\)\.stream/);
|
|
assert.ok(
|
|
chartBranch.indexOf("await runConsultationWorkflow(toolInput, { foreground: true })")
|
|
< chartBranch.indexOf("getJyotishAgent(selectedModel, workflowContext).stream"),
|
|
);
|
|
});
|
|
|
|
test("defers optional external evidence only for foreground chat", () => {
|
|
assert.match(mastra, /defer_optional_external_evidence: options\?\.foreground === true/);
|
|
assert.match(reportsRoute, /runWorkflow: \(input\) => runConsultationWorkflow\(input\)/);
|
|
assert.doesNotMatch(reportsRoute, /foreground:\s*true/);
|
|
});
|
|
|
|
test("grounds the answer in the server-computed workflow without a second tool run", () => {
|
|
assert.match(mastra, /function getJyotishAgent\(model: ResolvedLanguageModel, workflowContext\?/);
|
|
assert.match(mastra, /workflowContext \? \{\} : \{ consultationTool \}/);
|
|
assert.match(mastra, /server-computed Jyotish workflow/);
|
|
});
|
|
|
|
test("validates and emits a non-sensitive workflow receipt", () => {
|
|
assert.match(mastra, /consultationWorkflowResponseSchema/);
|
|
assert.match(mastra, /safeParse\(data\)/);
|
|
assert.match(mastra, /consultationWorkflowReceipt/);
|
|
assert.match(route, /workflowReceipt/);
|
|
assert.match(route, /x-jyotish-workflow-route/);
|
|
assert.match(route, /x-jyotish-workflow-status/);
|
|
});
|
|
|
|
test("carries commercial technique truth into the model contract", () => {
|
|
assert.match(mastra, /technique_truth/);
|
|
assert.match(mastra, /deterministic_claims_forbidden_for/);
|
|
assert.match(mastra, /reference_only/);
|
|
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/);
|
|
});
|