Files
Jyotisha/scripts/research/measure_consult_evidence_card.ts
T
Jesse_ChenandClaude Opus 5.5 db17074430 feat(consult): evidence card v2 per the astrologer's review
TASK-consult-evidence-card-v2-20260927 T3. Card version evidence-card-v2.

- Base section (every card): the engine's D9 summary (D9 lagna, each
  planet's D9 sign and dignity, Vargottama, D1/D9 reversals); D9 houses and
  aspects stay out.
- Career: + AL (engine pada A1), 10H SAV, SAV of the Jupiter / Saturn
  transit signs.
- Marriage: + 5H / 5L, day / night, Punarphoo (observation_only), Double
  Transit on 7H / 7L (house-7 run) and DK / UL, Vivah Saham, gender unknown.
- Wealth: 8H / 12H named.
- Annual: the annual Tajika chart verbatim (parameter_sensitive), or
  年盘未接入 when the pack is blocked / not attached (never natal data);
  houses 1 + running / next AD lords' houses + the year's Jupiter / Saturn
  transit houses, with their basis; ingress / station dates only.
- Timing: Rahu / Ketu with ingress dates, Jupiter / Saturn SAV and BAV,
  Double Transit conclusions (no degrees); vargas follow the turn's other
  domain, D9 when alone.
- Chara Dasha leaves every card; KP is never on a card. The lookup enum adds
  karakamsha, dispositor_chains, inter_chart_linkage, argala, moon_transit;
  a KP lookup travels with its blocked note.
- System prompt and tool descriptions name the D9 summary, the
  parameter_sensitive / observation_only tags, 年盘未接入 and the lookups.
- Telemetry card version / agentVersion bumped to v2 (three-column notes in
  the touched tests).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
2026-09-27 16:44:19 +08:00

91 lines
4.5 KiB
TypeScript

/**
* Measure what the answer model sees after the evidence card
* (TASK-consult-evidence-card-20260927 T3), on the research's own cached
* engine responses (3 public AA charts x 10 questions, produced by
* consult_evidence_card_run.py --cache <dir>; evidence card v2 adds the annual
* and timing questions, files `<chart>__annual.workflow.json` /
* `<chart>__timing.workflow.json`). Read-only; runs the production
* calculation tool with the cached workflow standing in for the engine.
*
* node frontend/node_modules/tsx/dist/cli.mjs scripts/research/measure_consult_evidence_card.ts <cache-dir> [out.json]
*/
import { readdirSync, readFileSync, writeFileSync } from "node:fs";
import { join } from "node:path";
import {
createConsultationRuntimeState,
createConsultationTools,
} from "../../frontend/src/mastra/consultation-tools.ts";
import type { ConsultationDomain } from "../../frontend/src/lib/consultation-domain-registry.ts";
const QUESTIONS: Record<string, { domain: ConsultationDomain; question: string }> = {
career: { domain: "career", question: "未来一年,事业和收入该关注什么?" },
marriage: { domain: "marriage", question: "我的关系模式是什么?" },
wealth: { domain: "wealth", question: "我的财富增长方式和风险点是什么?" },
health: { domain: "health", question: "我近期的身心压力模式和调节重点是什么?" },
education: { domain: "education", question: "我的学习优势、瓶颈和进阶方向是什么?" },
migration: { domain: "migration", question: "迁居、置业或海外发展更适合怎样规划?" },
family: { domain: "family", question: "我的家庭关系与责任边界该如何理解?" },
general: { domain: "general", question: "请综合说明我当前最值得关注的主题。" },
parents: { domain: "parents", question: "我和父母关系如何" },
children: { domain: "children", question: "我和子女的关系如何" },
annual: { domain: "annual", question: "未来一年重点是什么?" },
timing: { domain: "timing", question: "接下来一年哪些时间点重要?" },
};
const [cacheDir, outPath] = process.argv.slice(2);
if (!cacheDir) {
process.stderr.write("usage: measure_consult_evidence_card.ts <cache-dir> [out.json]\n");
process.exit(2);
}
const serverChart = {
name: "public",
toolInput: { year: 2000, month: 1, day: 1, hour: 0, minute: 0, city: "cache", lat: 0, lon: 0, tz: 0, ayanamsa: "raman" },
truth: { birthTimeSource: "reported" },
};
async function main(dir: string) {
const rows: Array<Record<string, unknown>> = [];
for (const file of readdirSync(dir).filter((name) => name.endsWith(".workflow.json")).sort()) {
const [chart, questionId] = file.replace(".workflow.json", "").split("__");
const question = QUESTIONS[questionId ?? ""];
if (!question) continue;
const workflow = JSON.parse(readFileSync(join(dir, file), "utf8"));
const state = createConsultationRuntimeState();
const tools = createConsultationTools({
userId: "u", sessionId: "s", requestId: `measure-${chart}-${questionId}`, consultationMode: "verified_chart",
serverChart: serverChart as never, state,
runWorkflow: async () => structuredClone(workflow),
});
const view = await tools["run-jyotish-consultation"].execute!(
{ question: question.question, domains: [question.domain] } as never,
{ writer: { custom: async () => {} } } as never,
) as Record<string, unknown>;
const text = JSON.stringify(view);
const methodology = view.methodology ? JSON.stringify(view.methodology).length : 0;
const { claim_cards, evidence_card, methodology: _m, ...contract } = view;
void _m;
rows.push({
id: `${chart}__${questionId}`,
chart,
question: questionId,
domain: question.domain,
model_visible_chars: text.length,
card_chars: JSON.stringify({ claim_cards, evidence_card }).length,
contract_chars: JSON.stringify(contract).length,
methodology_chars: methodology,
without_methodology_chars: text.length - (methodology ? methodology + ",\"methodology\":".length : 0),
token_estimate: Math.round(text.length / 3.5),
gaps: (evidence_card as { gaps?: string[] }).gaps ?? [],
technique_rows: state.techniqueAuditTable?.length ?? 0,
});
}
const summary = JSON.stringify(rows, null, 1);
if (outPath) writeFileSync(outPath, summary);
for (const row of rows) {
process.stdout.write(`${row.id}\tvisible=${row.model_visible_chars}\tcard=${row.card_chars}\tcontract=${row.contract_chars}\tmethodology=${row.methodology_chars}\tgaps=${(row.gaps as string[]).join(",")}\n`);
}
}
void main(cacheDir);