The card's model view gains evidence_index: the snapshot id and coverage, one id template per fact path, status codes with a legend and the per-id exceptions. Positions, houses, roles, afflictions, Arudha and derived houses, points, SAV, KP, Argala, transits, double transit, Saturn cycles, the annual chart, every dasha level, judgment and participation rows now resolve; rows that name their own id keep it. Branch rows carry their #br: id from the facts packet. A coverage check lists any card leaf that is neither a fact nor marked not citable; it is empty on all public golden cards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
55 lines
3.3 KiB
TypeScript
55 lines
3.3 KiB
TypeScript
/**
|
|
* BUG-1982: list every citable fact on the chat card that does not resolve to an evidence id.
|
|
*
|
|
* Builds the model-visible card for the three public golden charts x every domain through the
|
|
* production calculation tool (the golden workflow stands in for the engine). With a facts
|
|
* directory from scripts/research/card_evidence_facts.py the cards carry the facts packet as
|
|
* production does (participation rows, the evidence base, the snapshot id).
|
|
*
|
|
* node frontend/node_modules/tsx/dist/cli.mjs scripts/research/card_evidence_coverage.ts [facts-dir] [dump-dir]
|
|
*
|
|
* Prints, per card: ids, uncovered facts (should be 0), evidence_index characters, snapshot present.
|
|
*/
|
|
import { mkdirSync, readFileSync, writeFileSync, existsSync } from "node:fs";
|
|
import { join } from "node:path";
|
|
import { createConsultationRuntimeState, createConsultationTools } from "../../frontend/src/mastra/consultation-tools.ts";
|
|
import { consultationDomainIds } from "../../frontend/src/lib/consultation-domain-registry.ts";
|
|
import { cardEvidenceRoots, expandCardEvidence, uncoveredCardFacts } from "../../frontend/src/lib/card-evidence-index.ts";
|
|
|
|
const [factsDir, dumpDir] = process.argv.slice(2);
|
|
const golden = JSON.parse(readFileSync(new URL("../../frontend/tests/fixtures/consult-evidence-card-golden.json", import.meta.url), "utf8"));
|
|
const serverChart = {
|
|
name: "public",
|
|
toolInput: { year: 2000, month: 1, day: 1, hour: 0, minute: 0, city: "fixture", lat: 0, lon: 0, tz: 0, ayanamsa: "raman" },
|
|
truth: { birthTimeSource: "reported" },
|
|
};
|
|
async function main() {
|
|
if (dumpDir) mkdirSync(dumpDir, { recursive: true });
|
|
let uncoveredTotal = 0;
|
|
for (const chart of golden.charts) {
|
|
for (const domain of consultationDomainIds) {
|
|
const workflow = structuredClone(domain === "annual" ? chart.annual_workflow : domain === "timing" ? chart.timing_workflow : chart.workflow);
|
|
const factsFile = factsDir ? join(factsDir, `${chart.id}__${domain}.facts.json`) : "";
|
|
if (factsFile && existsSync(factsFile)) workflow.consult_card_facts = JSON.parse(readFileSync(factsFile, "utf8"));
|
|
const state = createConsultationRuntimeState();
|
|
const tools = createConsultationTools({
|
|
userId: "u", sessionId: "s", requestId: `coverage-${chart.id}-${domain}`, consultationMode: "verified_chart",
|
|
serverChart: serverChart as never, state,
|
|
runWorkflow: async () => structuredClone(workflow) as never,
|
|
});
|
|
const view = await tools["run-jyotish-consultation"].execute!({ question: "测试问题", domains: [domain] } as never, { writer: { custom: async () => {} } } as never) as Record<string, unknown>;
|
|
const roots = cardEvidenceRoots(view);
|
|
const left = uncoveredCardFacts(roots);
|
|
uncoveredTotal += left.length;
|
|
const { ids } = expandCardEvidence(roots);
|
|
const index = view.evidence_index as Record<string, unknown> | undefined;
|
|
console.log(`${chart.id}/${domain} ids=${ids.size} uncovered=${left.length} index_chars=${JSON.stringify(index ?? null).length} snapshot=${Boolean(index?.snapshot_id)} total_chars=${JSON.stringify(view).length}`);
|
|
for (const path of left.slice(0, 20)) console.log(` uncovered ${path}`);
|
|
if (dumpDir) writeFileSync(join(dumpDir, `${chart.id}__${domain}.json`), JSON.stringify(view, null, 1));
|
|
}
|
|
}
|
|
console.log(`uncovered total ${uncoveredTotal}`);
|
|
}
|
|
|
|
void main();
|