feat: enforce commercial Jyotish workflow contracts
This commit is contained in:
@@ -17,3 +17,23 @@ test("passes transparent public-case references into the agent context", () => {
|
||||
assert.match(source, /Jupiter and Saturn relative houses/);
|
||||
assert.match(source, /exact_triggers as technical trigger points/);
|
||||
});
|
||||
|
||||
test("keeps strength, Ashtakavarga, and timing evidence available to the answer model", () => {
|
||||
const source = readFileSync(new URL("../src/mastra/index.ts", import.meta.url), "utf8");
|
||||
assert.match(source, /shadbala: chart\.shadbala/);
|
||||
assert.match(source, /shadbala_boundary:/);
|
||||
assert.match(source, /ashtakavarga: modules\.ashtakavarga/);
|
||||
assert.match(source, /dasha_boundaries: modules\.dasha_boundaries/);
|
||||
assert.match(source, /narayana_dasha: modules\.narayana_dasha/);
|
||||
assert.match(source, /evidence_contract:/);
|
||||
assert.match(source, /missing_route_layers: consumerContext\.missing_route_layers/);
|
||||
assert.match(source, /answer_policy: consumerContext\.answer_policy/);
|
||||
assert.match(source, /evidence_contract\.answer_policy/);
|
||||
assert.match(source, /can_answer_precise_timing/);
|
||||
assert.match(source, /boundary: "not_auto_rectified"/);
|
||||
assert.match(source, /rectification\.boundary=not_auto_rectified/);
|
||||
assert.match(source, /external_engine_evidence:/);
|
||||
assert.match(source, /runtime_truth: record\(data\.runtime_truth\)/);
|
||||
assert.match(source, /numerical_parity: record\(data\.external_parity_gate\)/);
|
||||
assert.match(source, /real_case_calibration: record\(data\.real_case_calibration\)/);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
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 mastra = readFileSync(new URL("../src/mastra/index.ts", import.meta.url), "utf8");
|
||||
|
||||
test("runs the Jyotish workflow before streaming a commercial consultation", () => {
|
||||
assert.match(route, /runConsultationWorkflow/);
|
||||
assert.match(route, /await runConsultationWorkflow\(toolInput\)/);
|
||||
assert.match(route, /getJyotishAgent\(selectedModel, workflowContext\)\.stream/);
|
||||
assert.ok(route.indexOf("await runConsultationWorkflow(toolInput)") < route.indexOf(".stream(["));
|
||||
});
|
||||
|
||||
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/);
|
||||
});
|
||||
@@ -0,0 +1,29 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
|
||||
const root = new URL("../../", import.meta.url);
|
||||
const readRoot = (path: string) => readFileSync(new URL(path, root), "utf8");
|
||||
const mastra = readRoot("frontend/src/mastra/index.ts");
|
||||
const rectification = readRoot("frontend/src/lib/birth-time-journey-engine.ts");
|
||||
const synastry = readRoot("frontend/src/app/api/synastry/route.ts");
|
||||
const apiServer = readRoot("scripts/jyotish_api_server.py");
|
||||
|
||||
test("commercial Jyotish paths resolve to a registered Python handler", () => {
|
||||
for (const path of [
|
||||
"/api/consultation_workflow",
|
||||
"/api/active_rectification_questions",
|
||||
"/api/active_rectification_score",
|
||||
"/api/active_rectification_events",
|
||||
"/api/varga_full",
|
||||
"/api/synastry",
|
||||
]) {
|
||||
assert.match(apiServer, new RegExp(`['\"]${path.replaceAll("/", "\\/")}['\"]`));
|
||||
}
|
||||
assert.match(mastra, /\/api\/consultation_workflow/);
|
||||
assert.match(rectification, /\/api\/active_rectification_questions/);
|
||||
assert.match(rectification, /\/api\/active_rectification_score/);
|
||||
assert.match(rectification, /\/api\/active_rectification_events/);
|
||||
assert.match(synastry, /\/api\/varga_full/);
|
||||
assert.match(synastry, /\/api\/synastry/);
|
||||
});
|
||||
@@ -0,0 +1,13 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFileSync } from "node:fs";
|
||||
import test from "node:test";
|
||||
|
||||
const page = readFileSync(new URL("../src/app/page.tsx", import.meta.url), "utf8");
|
||||
|
||||
test("loads birth-time rectification only when its onboarding stage is reached", () => {
|
||||
assert.match(page, /import dynamic from "next\/dynamic"/);
|
||||
assert.match(page, /const BirthTimeRectification = dynamic\(/);
|
||||
assert.match(page, /import\("@\/components\/birth-time-rectification"\)/);
|
||||
assert.match(page, /ssr: false/);
|
||||
assert.match(page, /role="status"/);
|
||||
});
|
||||
Reference in New Issue
Block a user