Owner decision 2026-11-26: the product stops using VedAstro. - scripts/vedastro_switch: VEDASTRO_ENABLED=1 turns it on; default off. - Adapter, gateway, foreground session, consult gate, orchestrator, user entrypoint, REST/MCP/SDK bridges answer "disabled" at once: no network, no subprocess, no wait, no cache writes. - vedastro_priority: a disabled snapshot leaves the local chart as is; an official chart replaces it only when every chart/house answer echoes the requested time, place and ayanamsa. - Model input drops VedAstro audit rows, cross-check and must-use layer; privacy policy drops the VedAstro data line. - VEDASTRO_API_KEY optional and unused; env examples, deploy/README, AGENTS.md updated. Frozen files untouched. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoyn7Hj3LCW3BUs5bZ8
267 lines
15 KiB
TypeScript
267 lines
15 KiB
TypeScript
import assert from "node:assert/strict";
|
||
import { readFileSync } from "node:fs";
|
||
import test from "node:test";
|
||
import { createConsultationPlan } from "../src/lib/consultation-plan.ts";
|
||
import { toAgentConsultationContext, toModelOutput } from "../src/mastra/consultation-workflow.ts";
|
||
import { mastraSourceWithContract } from "./natal-instruction-source-test-support.ts";
|
||
|
||
|
||
// 原值: 锁系统提示里 reference_transparency 一整段(公开案例相似度、timing_state、narayana / transit 状态、
|
||
// exact_triggers、method_variants、Shadbala 分量差异)
|
||
// 新值: 这一段删除——数据卡(toModelEvidenceView)不带 reference_transparency,模型从来看不到这些字段;
|
||
// 工作流仍把它留在服务端上下文里;分盘不得说没算、性别只作补充两条照旧
|
||
// 原因: BUG-1540 第二步(产品 2026-11-04 拍板):agent 收到的指令约 2.45 万字、是盘面数据的 2.7 倍;英文必做清单、公开案例段、与口吻重复的英文总则把回答拉向报告体,按六条删减(必做清单、清单里会被照念的写法、技能摘录只留边界、公开案例段、重复总则、校正规则移到工具说明)
|
||
test("public-case references stay server-side; the agent prompt no longer explains fields it never sees", () => {
|
||
const workflowSource = readFileSync(new URL("../src/mastra/consultation-workflow.ts", import.meta.url), "utf8");
|
||
// 原值:只读 src/mastra/index.ts 源码 / 新值:index.ts 加 references/product_runtime_contract.md / 原因:BUG-1728 本命产品指令搬进合同文件
|
||
const agentSource = mastraSourceWithContract();
|
||
|
||
assert.match(workflowSource, /reference_transparency:\s*record\(data\.reference_transparency\)/);
|
||
assert.match(workflowSource, /vedastro_gateway:\s*record\(data\.vedastro_gateway\)/);
|
||
assert.match(workflowSource, /ashtakavarga:\s*chart\.ashtakavarga/);
|
||
assert.doesNotMatch(agentSource, /When reference_transparency is present|high_similarity_public_references_available|timing_state/);
|
||
assert.match(agentSource, /D2, D11/);
|
||
assert.match(agentSource, /gender-specific spouse significators are supplements/);
|
||
assert.match(agentSource, /male.*Venus/);
|
||
assert.match(agentSource, /female.*Jupiter\/Mars/);
|
||
});
|
||
|
||
test("keeps strength, Ashtakavarga, and timing evidence available to the answer model", () => {
|
||
const workflowSource = readFileSync(new URL("../src/mastra/consultation-workflow.ts", import.meta.url), "utf8");
|
||
// 原值:只读 src/mastra/index.ts 源码 / 新值:index.ts 加 references/product_runtime_contract.md / 原因:BUG-1728 本命产品指令搬进合同文件
|
||
const agentSource = mastraSourceWithContract();
|
||
|
||
// 原值: /shadbala: chart\.shadbala/;新值: 经 shadbalaWithoutBand 再放进上下文;原因: BUG-1961,没有来源的分档不交给模型
|
||
assert.match(workflowSource, /shadbala: shadbalaWithoutBand\(chart\.shadbala\)/);
|
||
assert.match(workflowSource, /shadbala_boundary:/);
|
||
assert.match(workflowSource, /ashtakavarga: modules\.ashtakavarga/);
|
||
// This line used to pin the misspelling: it asserted the packet read
|
||
// `modules.dasha_boundaries` without anything checking that the engine writes
|
||
// that key. tests/test_consultation_consumer_context.py now compares the names
|
||
// across the boundary; this only pins that timing evidence is still passed.
|
||
assert.match(workflowSource, /dasha_sub_periods: modules\.dasha_sub_periods/);
|
||
assert.match(workflowSource, /varga_spectrum: modules\.varga_spectrum/);
|
||
assert.match(workflowSource, /technique_audit_table: consumerContext\.technique_audit_table/);
|
||
// 原值: assert.match(agentSource, /evidence_contract\.technique_audit_table/)(提示要求模型通读审计表)
|
||
// 新值: 审计表仍由工作流带回、留在服务端回执与「本轮技法」面板;提示改为数据卡是清单、审计记录留在服务端
|
||
// 原因: TASK-consult-evidence-card-20260927 D3/T4(推翻「technique_audit_table is the invocation record… Use every executed layer」)
|
||
assert.doesNotMatch(agentSource, /evidence_contract\.technique_audit_table/);
|
||
assert.match(agentSource, /the full invocation record \(executed \/ blocked \/ not applicable per technique\) stays with the server/);
|
||
assert.match(workflowSource, /evidence_contract:/);
|
||
assert.match(workflowSource, /missing_route_layers: consumerContext\.missing_route_layers/);
|
||
assert.match(workflowSource, /answer_policy: consumerContext\.answer_policy/);
|
||
assert.match(agentSource, /evidence_contract\.answer_policy/);
|
||
assert.match(agentSource, /can_answer_precise_timing/);
|
||
assert.match(workflowSource, /function rectificationBoundaryFromGate/);
|
||
assert.match(agentSource, /rectification\.boundary=not_auto_rectified/);
|
||
assert.match(workflowSource, /external_engine_evidence:/);
|
||
assert.match(workflowSource, /runtime_truth: record\(data\.runtime_truth\)/);
|
||
assert.match(workflowSource, /numerical_parity: record\(data\.external_parity_gate\)/);
|
||
assert.match(workflowSource, /real_case_calibration: record\(data\.real_case_calibration\)/);
|
||
});
|
||
|
||
test("projects only bounded server-selected evidence to the model", () => {
|
||
const context = toAgentConsultationContext({
|
||
success: true,
|
||
question: "事业如何",
|
||
chart: {
|
||
birth: { date: "1990-01-02", time: "03:04", latitude: 25.03, longitude: 121.56 },
|
||
ascendant: { sign: "Leo", degree: 12.5, reported_time: "private-reported-time" },
|
||
planets: [{ name: "Sun", sign: "Capricorn", degree: 4.2, lng: "private-lng" }],
|
||
houses: { first: { sign: "Leo" } },
|
||
dasha: { current: "Mars", next: "Rahu", utc_offset: "private-utc-offset" },
|
||
shadbala: { planets: { Sun: { total_rupa: 7.1 } } },
|
||
ashtakavarga: { house_scores: { "10": 31 } },
|
||
modules: {
|
||
shadbala: { total: 412 },
|
||
ashtakavarga: { total: 28 },
|
||
varga_spectrum: {
|
||
status: "used",
|
||
mode: "full_spectrum",
|
||
counts: { formal: 20, research_dn: 40, extended: 3, blocked: 0 },
|
||
formal: { D9: { lagna: "Leo", planets: { Sun: "Capricorn" }, name: "Navamsa" } },
|
||
research_dn: { D13: { lagna: "Aries", planets: { Moon: "Taurus" }, boundary: "generic D-N; not a formal named varga" } },
|
||
},
|
||
dasha_sub_periods: {
|
||
current: { antardasha: { lord: "Saturn", start: "2025-10-17", end: "2027-05-18" } },
|
||
boundary_count: 9,
|
||
utc_offset: "private-module-utc-offset",
|
||
},
|
||
narayana_dasha: { current: "Aries" },
|
||
functional_benefic_malefic: {
|
||
status: "used",
|
||
functional_benefics: ["Jupiter"],
|
||
functional_malefics: ["Mercury"],
|
||
},
|
||
kakshya: { status: "observation_only", boundary: "not verified day/month timing" },
|
||
yogas: { status: "executed", count: 1, yogas: [{ name: "Gaja Kesari", planets: ["Jupiter", "Moon"] }] },
|
||
arudha_padas: {
|
||
padas: {
|
||
A10: { name: "Karma Pada (A10)", sign: "Capricorn" },
|
||
UL: { name: "Upapada (UL)", sign: "Libra" },
|
||
},
|
||
},
|
||
gulika: { sign: "Scorpio", claim_boundary: "observation_only" },
|
||
kp_cusps: { houses: { "10": { sign: "Taurus", sublord: "Saturn" } } },
|
||
chara_dasha: {
|
||
status: "executed",
|
||
current: { sign: "Libra", lord: "Venus", duration_years: 8 },
|
||
sequence: [{ sign: "Libra", lord: "Venus", duration_years: 8 }],
|
||
},
|
||
transits: {
|
||
status: "executed",
|
||
sade_sati: { phase: "none", moon_sign: "Taurus", saturn_sign: "Pisces" },
|
||
search_period: { start: "2026-07-14", end: "2026-10-12" },
|
||
triggers: [{ date: "2026-08-21", planet: "Saturn", target: "Moon", kind: "exact_hit", orb: 0.08 }],
|
||
boundary: "observation windows, not guaranteed events",
|
||
},
|
||
},
|
||
},
|
||
routing: { primary_theme: "career" },
|
||
thematic_report: {
|
||
themes: {
|
||
career: {
|
||
theme: "career",
|
||
summary: "保留这条服务端证据摘要",
|
||
narrative: "事业证据叙事",
|
||
strength: "strong",
|
||
account_balance: "private-account-balance",
|
||
recommendations: ["保持稳健推进"],
|
||
evidence: [{
|
||
technique: "D10-Dashamsha-local",
|
||
chart: "D10",
|
||
conclusion: "D10 事业分盘已进入证据链",
|
||
sentiment: "positive",
|
||
strength: "strong",
|
||
details: {
|
||
source: "chart",
|
||
derived: true,
|
||
entitlements: "private-entitlements",
|
||
access_scopes: "private-access-scopes",
|
||
},
|
||
}],
|
||
},
|
||
},
|
||
},
|
||
consumer_context: {
|
||
route: "career", core_status: "ready", available_layers: ["natal", "timing"],
|
||
missing_route_layers: [], hard_blockers: [],
|
||
technique_truth: { status: "verified", access_scopes: "private-validation-scopes" },
|
||
answer_policy: {
|
||
can_answer_direction: true,
|
||
can_answer_precise_timing: false,
|
||
entitlements: "private-policy-entitlements",
|
||
},
|
||
user_facing_limitation: "精确月份暂不可用",
|
||
technique_audit_table: [
|
||
{ technique: "Formal Vargas D1–D60", status: "executed", system: "jyotish", boundary: "20/20 named traditional charts" },
|
||
{ technique: "Yogas", status: "executed", system: "jyotish" },
|
||
{ technique: "Arudha / UL / A10", status: "executed", system: "jyotish" },
|
||
{ technique: "Narayana Dasha", status: "executed", system: "jyotish" },
|
||
{ technique: "Functional Benefic/Malefic", status: "executed", key_functional_benefics: ["Jupiter"] },
|
||
{ technique: "Western natal (tropical)", status: "executed", system: "western" },
|
||
{ technique: "VedAstro Cloud State", status: "executed", boundary: "official_cloud_evidence_available" },
|
||
{ technique: "MEVG / Global Web Evidence", status: "blocked", boundary: "caps_claims_until_global_web_evidence_runs" },
|
||
],
|
||
varga_spectrum: {
|
||
status: "used",
|
||
counts: { formal: 20, research_dn: 40 },
|
||
formal: { D9: { lagna: "Leo", planets: { Sun: "Capricorn" } } },
|
||
},
|
||
western_spectrum: {
|
||
status: "executed",
|
||
natal: { sun: "Aries", moon: "Taurus", ascendant: "Leo" },
|
||
techniques: {
|
||
transits: {
|
||
status: "executed",
|
||
target_date: "2026-07-14",
|
||
aspects: [{ transit_planet: "saturn", natal_point: "moon", aspect: "square", orb: 0.4 }],
|
||
},
|
||
},
|
||
},
|
||
vedastro_cross_check: {
|
||
status: "executed",
|
||
official_closure_state: "official_verified",
|
||
natal: { sun: "Leo", moon: "Cancer", ascendant: "Scorpio" },
|
||
},
|
||
},
|
||
reference_transparency: { similar_public_cases: { status: "public_context_only" } },
|
||
rectification: { summary: "none" },
|
||
vedastro_gateway: {
|
||
official_closure_state: "official_verified",
|
||
official_raw_response: { lat: 25.03, lon: 121.56, hour: 3, minute: 4 },
|
||
},
|
||
});
|
||
const output = toModelOutput(context);
|
||
const careerPlan = createConsultationPlan({ userIntent: "事业如何", theme: "career" });
|
||
const careerOutput = toModelOutput(context, careerPlan);
|
||
const serialized = JSON.stringify(output);
|
||
|
||
assert.equal(output.packet_version, "consultation-evidence-packet-v2");
|
||
assert.equal("birth" in output, false);
|
||
assert.equal(serialized.includes("1990-01-02"), false);
|
||
assert.equal(serialized.includes("03:04"), false);
|
||
assert.equal(serialized.includes("25.03"), false);
|
||
assert.equal(serialized.includes("121.56"), false);
|
||
for (const privateValue of [
|
||
"private-reported-time", "private-lng", "private-utc-offset", "private-module-utc-offset",
|
||
"private-account-balance", "private-entitlements", "private-access-scopes",
|
||
"private-validation-scopes", "private-policy-entitlements",
|
||
]) {
|
||
assert.equal(serialized.includes(privateValue), false);
|
||
}
|
||
for (const privateKey of [
|
||
"reported_time", "lng", "utc_offset", "account_balance", "entitlements", "access_scopes",
|
||
]) {
|
||
assert.equal(serialized.includes(`"${privateKey}"`), false);
|
||
}
|
||
assert.equal(serialized.includes("保留这条服务端证据摘要"), true);
|
||
assert.equal(serialized.includes("D10-Dashamsha-local"), true);
|
||
assert.equal(serialized.includes("total_rupa"), true);
|
||
assert.equal(serialized.includes("house_scores"), true);
|
||
assert.equal(serialized.includes('"dasha"'), true);
|
||
assert.equal(serialized.includes("narayana_dasha"), true);
|
||
// Antardasha boundaries are what an answer needs to name a month at all, and
|
||
// they were absent from every packet while this field named a module key the
|
||
// engine never wrote.
|
||
assert.equal(serialized.includes("dasha_sub_periods"), true);
|
||
assert.equal(serialized.includes("2027-05-18"), true);
|
||
assert.equal(serialized.includes('"status":"verified"'), true);
|
||
const answerPolicy = output.evidence_contract.answer_policy as Record<string, unknown>;
|
||
assert.equal(answerPolicy.can_answer_precise_timing, false);
|
||
assert.deepEqual(output.claim_cards.map((card) => card.category), ["natal_foundation", "domain", "timing", "validation"]);
|
||
assert.deepEqual(careerOutput.claim_cards.map((card) => card.category), ["natal_foundation", "domain", "timing", "validation"]);
|
||
assert.equal(JSON.stringify(careerOutput).includes('"dasha"'), true);
|
||
assert.equal(serialized.includes("consultation-evidence-packet-v2"), true);
|
||
assert.equal(output.presentation.template, "skill_level_2");
|
||
assert.equal(output.presentation.required_blocks.includes("technique_audit_table"), true);
|
||
assert.equal(serialized.includes("Formal Vargas"), true);
|
||
assert.equal(serialized.includes("varga_spectrum"), true);
|
||
assert.equal(serialized.includes('"D13"'), true);
|
||
assert.equal(serialized.includes("western_spectrum"), true);
|
||
assert.equal(serialized.includes("technique_audit_table"), true);
|
||
assert.equal(serialized.includes("functional_benefics"), true);
|
||
assert.equal(serialized.includes("Jupiter"), true);
|
||
assert.equal(serialized.includes("Gaja Kesari"), true);
|
||
assert.equal(serialized.includes("Karma Pada (A10)"), true);
|
||
assert.equal(serialized.includes("chara_dasha"), true);
|
||
assert.equal(serialized.includes("Venus"), true);
|
||
assert.equal(serialized.includes("sade_sati"), true);
|
||
assert.equal(serialized.includes("Taurus"), true);
|
||
assert.equal(serialized.includes("2026-08-21"), true);
|
||
assert.equal(serialized.includes("search_period"), true);
|
||
assert.equal(serialized.includes('"square"'), true);
|
||
const mustUse = output.evidence_contract.must_use_layers;
|
||
assert.equal(Array.isArray(mustUse), true);
|
||
assert.equal((mustUse as string[]).includes("Yogas"), true);
|
||
assert.equal((mustUse as string[]).includes("Arudha / UL / A10"), true);
|
||
// BUG-2427: VedAstro is off by owner decision; its rows, cross-check and must-use layer never reach the model.
|
||
assert.equal((mustUse as string[]).includes("VedAstro Cloud State"), false);
|
||
assert.equal((mustUse as string[]).includes("MEVG / Global Web Evidence"), false);
|
||
assert.equal(serialized.includes("Scorpio"), true);
|
||
assert.equal(/vedastro/i.test(serialized), false);
|
||
assert.equal(serialized.includes("official_verified"), false);
|
||
assert.equal(serialized.includes("official_closure"), false);
|
||
assert.equal(serialized.includes("https://"), false);
|
||
});
|