feat(consult): the answer model reads the answer contract plus an evidence card
New frontend/src/lib/consultation-evidence-card.ts ports the research CARD_SPECS: base section (ascendant, house signs, placements with degrees, functional benefics/malefics with lordship, Vimshottari MD/AD/PD with dates, Narayana md/ad/pd) plus a section per domain; values copied verbatim from the projection or engine context, gaps listed, never filled. The tool now returns toModelEvidenceView: status, evidence_contract (policy, blockers, layers, limitation), claim_cards = the card, evidence_card meta (D4 line, supplementable sections), rectification, methodology, domains; the audit table, spectra, must_use_layers and presentation stay server-side and the single-domain consultations copy is gone. 「本轮技法」 rows are unchanged. Golden tests over three public AA engine captures. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017eEAG8HD3mm8gsKXgk8uU8
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
5c65834dda
commit
850f18605b
@@ -0,0 +1,86 @@
|
||||
/**
|
||||
* 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>). 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: "我和子女的关系如何" },
|
||||
};
|
||||
|
||||
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);
|
||||
Reference in New Issue
Block a user