fix(chat): aspect tables on the card (what each planet aspects, who aspects each house / planet / lord, transit Jupiter / Saturn per sign stay) checked by the fact guard, 「进 A 再到 B」 checked inside its period, Karma Saham named 「事业」 everywhere (BUG-2241)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DbBXp2Vp62Ur3C7yRWQdSq
This commit is contained in:
2026-11-23 10:43:40 +08:00
co-authored by Claude Opus 5.5
parent 5201bd4be1
commit f19edb88ba
11 changed files with 696 additions and 15 deletions
+2 -1
View File
@@ -112,7 +112,8 @@ export const SAHAM_TERMS: Readonly<Record<string, { gloss: string; short: string
Matri_Saham: { gloss: "母亲", short: "母" },
Putra_Saham: { gloss: "子女", short: "子" },
Jeeva_Saham: { gloss: "生命", short: "命" },
Karma_Saham: { gloss: "行动与工作", short: "行" },
// BUG-2241 (owner 2026-11-23): Karma Saham is 「事业」 on every surface (the annual report already said so).
Karma_Saham: { gloss: "事业", short: "业" },
Roga_Saham: { gloss: "疾病", short: "病" },
Kali_Saham: { gloss: "大不顺", short: "厄" },
Sastra_Saham: { gloss: "学问", short: "典" },
+6
View File
@@ -9,6 +9,7 @@
import type { EvidenceCard } from "./consultation-evidence-card.ts";
import { PERIOD_COVERAGE_READING, periodCoverageRows } from "./chat-period-coverage.ts";
import { ARGALA_READING, argalaTable, SAHAM_READING, sahamTable, savOrder } from "./chat-point-checks.ts";
import { ASPECT_READING, natalAspectTables, TRANSIT_ASPECT_READING, transitAspectRows } from "./chat-aspect-checks.ts";
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- card JSON is read loosely; every value is checked where used
type J = Record<string, any>;
@@ -766,6 +767,8 @@ export function precomputedTables(card: EvidenceCard): { natal: J; timing: J } {
sav_order: safe(() => savOrder(card), ""),
argala_reading: ARGALA_READING,
argala: safe(() => argalaTable(card), []),
// BUG-2241: what each planet aspects, who aspects each house / planet / house lord and who does not.
...((aspects) => ({ aspects_reading: ASPECT_READING, aspects_by_planet: aspects.by_planet, aspects_on_house: aspects.on_house, aspects_on_planet: aspects.on_planet, aspects_on_lords: aspects.on_lords }))(safe(() => natalAspectTables(card), { by_planet: [], on_house: [], on_planet: [], on_lords: [] })),
},
timing: {
reading: `${TABLES_READING} overlaps 每行【】里是这一段的运期和主星;后面按类列出和这一段重叠的行运和运程,「全段」表示整段都重叠,否则写出重叠的起止;表里没有的就是不重叠,不写成同时。`,
@@ -778,6 +781,9 @@ export function precomputedTables(card: EvidenceCard): { natal: J; timing: J } {
// BUG-2239: every sub-period and sub-sub-period with its double-transit / slow-planet coverage and stations.
period_coverage_reading: PERIOD_COVERAGE_READING,
period_coverage: safe(() => periodCoverageRows(card).map((row) => row.text), []),
// BUG-2241: the natal houses and planets transit Jupiter / Saturn aspect in each sign stay.
transit_aspects_reading: TRANSIT_ASPECT_READING,
transit_aspects: safe(() => transitAspectRows(card), []),
},
};
}
+500
View File
@@ -0,0 +1,500 @@
/**
* BUG-2241: aspect (照) facts precomputed for the chat writer and checked in its answers.
*
* After BUG-2239 three of the seven errors left in the 11-23 end-to-end answers were aspect facts the model worked out
* itself: Saturn's 7th-house aspect on Mercury called a 「特殊相位」 (twice), 「土星照第 10 宫主金星」 (Saturn in the 1st
* aspects the 3rd, 7th and 10th; Venus is in the 6th), and a transit put in the next period's house (「木星进第 11 宫再
* 到第 10 宫」 in a sub-sub-period that ends before Jupiter returns to the 10th).
*
* The rule is the backend's (scripts/aspects.py `calc_house_aspects`, consultation_native_layers DRISHTI_CASTERS):
* whole-sign Parashari aspects counted from the caster's house; every graha the 7th; Mars also the 4th / 8th, Jupiter the
* 5th / 9th, Saturn the 3rd / 10th; Rahu and Ketu receive aspects but cast none. Here the natal chart gets four plain
* tables — what each planet aspects (houses, the planets in them, the aspect kind in fixed words), which planets aspect
* each house and each planet and which do not, and one line per house lord — and the transit window gets one row per
* Jupiter / Saturn sign stay with the houses and natal planets it aspects. The checks read the same rules: a sentence
* that says planet A aspects / does not aspect house N or planet B, or names the kind, must agree — a natal sentence with
* the natal chart, a dated or transit sentence with the transit rows for its dates; an ambiguous sentence is left alone.
* Mismatches feed the fact guard's sentence repair with the table rows; nothing is substituted in place.
*/
import { slowBodyTimeline, type EvidenceCard } from "./consultation-evidence-card.ts";
import type { AnswerFactMismatch } from "./consultation-answer-fact-guard.ts";
type Rec = Record<string, unknown>;
const rec = (value: unknown): Rec => (value && typeof value === "object" && !Array.isArray(value) ? value as Rec : {});
type Emit = (item: AnswerFactMismatch, status?: "match" | "mismatch" | "not_on_card") => void;
const PLANETS = ["Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu"] as const;
/** The casters (consultation_native_layers DRISHTI_CASTERS): the nodes cast no aspect in this product. */
export const CASTERS = ["Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn"] as const;
/** Houses counted from the caster's own house (aspects.py SPECIAL_ASPECTS; every graha the 7th). */
export const ASPECT_OFFSETS: Readonly<Record<string, readonly number[]>> = {
Sun: [7], Moon: [7], Mercury: [7], Venus: [7], Mars: [4, 7, 8], Jupiter: [5, 7, 9], Saturn: [3, 7, 10],
};
const PLANET_ZH: Readonly<Record<string, string>> = { Sun: "太阳", Moon: "月亮", Mars: "火星", Mercury: "水星", Jupiter: "木星", Venus: "金星", Saturn: "土星", Rahu: "罗睺", Ketu: "计都" };
const ZH_PLANET: Readonly<Record<string, string>> = { ...Object.fromEntries(Object.entries(PLANET_ZH).map(([en, zh]) => [zh, en])), 罗喉: "Rahu" };
const SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"] as const;
const SIGN_ZH: Readonly<Record<string, string>> = { Aries: "白羊", Taurus: "金牛", Gemini: "双子", Cancer: "巨蟹", Leo: "狮子", Virgo: "处女", Libra: "天秤", Scorpio: "天蝎", Sagittarius: "射手", Capricorn: "摩羯", Aquarius: "水瓶", Pisces: "双鱼" };
const ZH_SIGN: Readonly<Record<string, string>> = Object.fromEntries(Object.entries(SIGN_ZH).map(([en, zh]) => [zh, en]));
const SIGN_LORD: Readonly<Record<string, string>> = { Aries: "Mars", Taurus: "Venus", Gemini: "Mercury", Cancer: "Moon", Leo: "Sun", Virgo: "Mercury", Libra: "Venus", Scorpio: "Mars", Sagittarius: "Jupiter", Capricorn: "Saturn", Aquarius: "Saturn", Pisces: "Jupiter" };
const houseFrom = (house: number, nth: number) => ((house - 1 + nth - 1) % 12) + 1;
const zh = (planet: string) => PLANET_ZH[planet] ?? planet;
const joinZh = (planets: readonly string[]) => planets.map(zh).join("、");
/** The fixed words for an aspect kind. */
export function aspectKind(nth: number): string {
return nth === 7 ? "对冲相位(第 7 宫相位)" : `特殊相位(第 ${nth} 宫相位)`;
}
// ---- natal chart --------------------------------------------------------------------------------------------------
type Natal = { lagna: string; house: Record<string, number> };
function natalOf(card: EvidenceCard): Natal | null {
const natal = rec(rec(card.base).natal);
const lagna = String(rec(natal.ascendant).sign ?? "");
if (!(SIGNS as readonly string[]).includes(lagna)) return null;
const house: Record<string, number> = {};
for (const [name, raw] of Object.entries(rec(natal.planets))) {
const value = rec(raw).house;
if (typeof value === "number") house[name] = value;
}
return Object.keys(house).length ? { lagna, house } : null;
}
const signOfHouse = (natal: Natal, house: number) => SIGNS[(SIGNS.indexOf(natal.lagna as typeof SIGNS[number]) + house - 1) % 12]!;
const occupants = (natal: Natal, house: number) => PLANETS.filter((planet) => natal.house[planet] === house);
const houseLabel = (natal: Natal, house: number) => {
const inside = occupants(natal, house);
return `第 ${house} 宫${SIGN_ZH[signOfHouse(natal, house)]}(${inside.length ? joinZh(inside) : "没有星"})`;
};
/** The aspect `caster` (sitting in `from`) casts on `target`, or null (nodes cast none). */
export function aspectNth(caster: string, from: number, target: number): number | null {
const offsets = ASPECT_OFFSETS[caster];
if (!offsets) return null;
return offsets.find((nth) => houseFrom(from, nth) === target) ?? null;
}
/** Casters aspecting a natal house, with the kind. A planet in that house is not aspecting its own house. */
function castersOn(natal: Natal, house: number): Array<{ caster: string; nth: number }> {
return CASTERS.flatMap((caster) => {
const from = natal.house[caster];
if (from === undefined) return [];
const nth = aspectNth(caster, from, house);
return nth === null ? [] : [{ caster, nth }];
});
}
const byLine = (list: ReadonlyArray<{ caster: string; nth: number }>, natal: Natal) =>
list.map(({ caster, nth }) => `${zh(caster)}(从第 ${natal.house[caster]} 宫,${aspectKind(nth)})`).join("、");
function receivedLine(natal: Natal, house: number, self?: string): string {
const by = castersOn(natal, house).filter((item) => item.caster !== self);
const not = CASTERS.filter((caster) => caster !== self && natal.house[caster] !== undefined && !by.some((item) => item.caster === caster));
return `${by.length ? `被${byLine(by, natal)}照` : "没有星照"};不被${not.length ? joinZh(not) : "(无)"}照`;
}
export type NatalAspectTables = { by_planet: string[]; on_house: string[]; on_planet: string[]; on_lords: string[] };
export function natalAspectTables(card: EvidenceCard): NatalAspectTables {
const natal = natalOf(card);
if (!natal) return { by_planet: [], on_house: [], on_planet: [], on_lords: [] };
const byPlanet = CASTERS.flatMap((caster) => {
const from = natal.house[caster];
if (from === undefined) return [];
const targets = ASPECT_OFFSETS[caster]!.map((nth) => `${houseLabel(natal, houseFrom(from, nth))},${aspectKind(nth)}`);
return [`${zh(caster)}在第 ${from} 宫,照:${targets.join(";")}`];
});
const nodes = (["Rahu", "Ketu"] as const).filter((node) => natal.house[node] !== undefined);
if (nodes.length) byPlanet.push(`${nodes.map((node) => `${zh(node)}(第 ${natal.house[node]} 宫)`).join("、")}:不算照别的宫和星,只算别的星照它们`);
const onHouse = Array.from({ length: 12 }, (_, index) => `${houseLabel(natal, index + 1)}:${receivedLine(natal, index + 1)}`);
const onPlanet = PLANETS.flatMap((planet) => {
const house = natal.house[planet];
return house === undefined ? [] : [`${zh(planet)}(第 ${house} 宫):${receivedLine(natal, house, planet)}`];
});
const onLords = Array.from({ length: 12 }, (_, index) => {
const lord = SIGN_LORD[signOfHouse(natal, index + 1)]!;
const house = natal.house[lord];
return house === undefined ? "" : `第 ${index + 1} 宫宫主${zh(lord)}:落第 ${house} 宫,${receivedLine(natal, house, lord)}`;
}).filter(Boolean);
return { by_planet: byPlanet, on_house: onHouse, on_planet: onPlanet, on_lords: onLords };
}
export const ASPECT_READING =
"相位(照)只照这几张表写,不自己数:每颗星都照它所在宫起第 7 宫,叫「对冲相位(第 7 宫相位,所有星都有)」;火星另照第 4、8 宫,木星另照第 5、9 宫,土星另照第 3、10 宫,这几种才叫「特殊相位」;罗睺、计都不算照别的宫和星。aspects_by_planet 是每颗星照哪几宫、宫里有哪些星和相位种类;aspects_on_house、aspects_on_planet 是每一宫、每颗星被谁照、不被谁照;aspects_on_lords 是每一宫的宫主被谁照、不被谁照。表上写「不被」的就是不照,不写成照。本命的相位照这几张表;行运的相位照 timing 的 transit_aspects,按那段时间的行。";
// ---- transit rows -------------------------------------------------------------------------------------------------
const TRANSIT_CASTERS = ["Jupiter", "Saturn"] as const;
type Segment = { from: string; to: string; sign: string; house: number };
function transitSegments(card: EvidenceCard, body: string): Segment[] {
return slowBodyTimeline(card, body).flatMap(([from, to, sign, house]) => (typeof house === "number" ? [{ from, to, sign, house }] : []));
}
/** One row per Jupiter / Saturn sign stay in the transit window: the natal houses (and planets) it aspects. */
export function transitAspectRows(card: EvidenceCard): string[] {
const natal = natalOf(card);
if (!natal) return [];
return TRANSIT_CASTERS.flatMap((body) => transitSegments(card, body).map((seg) => {
const targets = ASPECT_OFFSETS[body]!.map((nth) => `${houseLabel(natal, houseFrom(seg.house, nth))},${aspectKind(nth)}`);
return `${zh(body)} ${seg.from} 至 ${seg.to} 在${SIGN_ZH[seg.sign] ?? seg.sign}(本命第 ${seg.house} 宫,宫内本命${occupants(natal, seg.house).length ? joinZh(occupants(natal, seg.house)) : "没有星"}):照${targets.join(";")}`;
}));
}
export const TRANSIT_ASPECT_READING =
"transit_aspects 每行是行运木星或土星在一个星座的那段时间:它在本命第几宫、照本命哪几宫和宫里的星、相位种类。写某段时间行运木星、土星照哪一宫、照哪颗本命星,只照那段时间的行;跨两行的时间,两行都要看,不把后一段的宫写进前一段。";
// ---- sentence checks ----------------------------------------------------------------------------------------------
const PZ = "(?:太阳|月亮|火星|水星|木星|金星|土星|罗睺|罗喉|计都)";
const SUBJ = `(${PZ}(?:\\s*(?:、|和|与|及|跟)\\s*${PZ})*)`;
const MID = `((?:(?!${PZ})[^,。;:!?\\n,]){0,16}?)`;
const ACTIVE_VERB = "(照射到|照射|照到|照向|照着|照住|照|相位(?:落在|落到|打在|打到|投到|投在|作用到|指向|到))";
const TARGET = `\\s*(?:到|向|在)?\\s*(?:你的?|本命的?|本命盘的?|出生盘的?|命盘的?)?\\s*(?:(第\\s*\\d{1,2}(?:\\s*(?:、|和|与|及)\\s*(?:第\\s*)?\\d{1,2})*\\s*宫)\\s*(?:的|里的|内的|上的|中的)?\\s*(宫主星?|主星|之主|主)?\\s*(${PZ})?|(${PZ}))`;
const ACTIVE = new RegExp(`${SUBJ}${MID}${ACTIVE_VERB}${TARGET}`, "gu");
const PASSIVE = new RegExp(`(被|受到|受|遭到)\\s*${SUBJ}${MID}(相位照射|相位照|照射|照到|照)`, "gu");
const NEG_END = /(?:不|没有|没|未|并不|并没有|并未|不会|并非)\s*(?:再|会|能|直接|同时|也|都)?\s*$/u;
const NEG_ANY = /不|没有|没|未|并非|但|却|而/u;
const FALSE_VERB_BEFORE = /[按对参依关拍映观]$/u;
const SPECIAL = /特殊相位|特殊的相位|特别相位|特殊照/u;
const NTH_WORD = /第\s*(\d{1,2}|[三四五七八九十])\s*宫?\s*相位|(\d{1,2})\s*宫相位|(对冲|对宫|七分)相位|对冲/u;
const CN_NTH: Readonly<Record<string, number>> = { 三: 3, 四: 4, 五: 5, 七: 7, 八: 8, 九: 9, 十: 10 };
/** Layers and readings these tables do not describe (vargas, the annual chart, from-Moon counting, sign aspects, KP …). */
const OTHER_LAYER = /D\d{1,2}|分盘|九分|年盘|Tajika|Muntha|Varsha|KP|宫头|月亮起|从月亮|Chandra|Chalit|Sudar[sś]han|Karakam|灵魂|Jaimini|星座相照|星座相位|整星座相位|Rasi|Argala|Navam|若|如果|假如|要是|一旦|倘若|传统上|书上/u;
const CONDITIONAL_CLAUSE = /若|如果|假如|要是|一旦|倘若|则/u;
/** A 「传统说法」 line states the book's rule first; only its sentences about this chart are read. */
const BOOK_LEAD = /^\s*(?:[-*+]\s+)?(?:\*\*)?\s*(?:传统说法|书上说|古书|经典说法)/u;
const THIS_CHART = /这张盘|本盘|你的|你这/u;
const TRANSIT_WORD = /行运|过境|流年|双重行运|走到|走进|进入|进到|回到|退回|换座|这段时间|这一段|这段|期间|届时|那时|这时|此时|到时|今年|明年|后年|现在|目前|眼下|当前/u;
const NOW_WORD = /现在|目前|眼下|当前|此刻|今天/u;
const NATAL_WORD = /本命盘|出生盘|命盘|原局|天生|出生时|这张盘|盘面/u;
const UNRESOLVED_TARGET = /(?:这一宫|这宫|该宫|此宫|它|它们|这颗星|这里|这两颗星|两颗星|二者)\s*(?:也|又|都|还|同时|则|就)?\s*$/u;
type Claim = {
casters: string[]; negative: boolean; houses: number[]; planet?: string; special: boolean; nth?: number; fromHouse?: number;
at: number; end: number; text: string;
};
const castersOf = (subject: string) => [...subject.matchAll(new RegExp(PZ, "gu"))].map((m) => ZH_PLANET[m[0]]!).filter(Boolean);
const housesOf = (text: string) => [...text.matchAll(/\d{1,2}/gu)].map((m) => Number(m[0])).filter((n) => n >= 1 && n <= 12);
function kindOf(text: string): { special: boolean; nth?: number } {
const special = SPECIAL.test(text);
const m = NTH_WORD.exec(text);
if (!m) return { special };
if (m[3] || /^对冲$/u.test(m[0])) return { special, nth: 7 };
const raw = m[1] ?? m[2]!;
const nth = /\d/u.test(raw) ? Number(raw) : CN_NTH[raw];
return { special, nth: nth && nth >= 2 && nth <= 12 ? nth : undefined };
}
/** Text with bracketed glosses and quoted rules (「土星照第 10 宫主则……」) blanked (same length, so offsets hold). */
const blank = (text: string) => text.replace(/([^)]*)|\([^)]*\)|“[^”]*”|「[^」]*」|"[^"]*"/gu, (hit) => " ".repeat(hit.length));
/** 「宫主月亮与宫内两星同时被……照」: the passive's subject is not the planet next to it. */
const GROUP_SUBJECT = /两星|两颗|几颗|诸星|它们|这些|宫内|宫里|同宫/u;
function claimsIn(sentence: string, natal: Natal): Claim[] {
const text = blank(sentence);
const out: Claim[] = [];
for (const m of text.matchAll(ACTIVE)) {
const at = m.index ?? 0;
const mid = m[2]!;
if (/(?:被|受到|受|遭到)\s*$/u.test(text.slice(Math.max(0, at - 3), at))) continue;
if (FALSE_VERB_BEFORE.test(mid) && m[3] === "照") continue;
const negative = NEG_END.test(mid);
if (!negative && NEG_ANY.test(mid)) continue;
const casters = castersOf(m[1]!);
let houses: number[] = [];
let planet: string | undefined;
if (m[4]) {
const listed = housesOf(m[4]);
if (m[6]) planet = ZH_PLANET[m[6]];
else if (m[5] && listed.length === 1) planet = SIGN_LORD[signOfHouse(natal, listed[0]!)];
else houses = listed;
} else if (m[7]) planet = ZH_PLANET[m[7]];
const from = /(?:从|在|于|落在?|自)\s*第\s*(\d{1,2})\s*宫/u.exec(mid);
out.push({ casters, negative, houses, planet, ...kindOf(`${mid}${m[3]}`), fromHouse: from ? Number(from[1]) : undefined, at, end: at + m[0].length, text: m[0] });
}
for (const m of text.matchAll(PASSIVE)) {
const at = m.index ?? 0;
const mid = m[3]!;
if (NEG_ANY.test(mid)) continue;
const before = text.slice(0, at);
const negative = /(?:不|没有|没|未|并不|并未|并没有)\s*$/u.test(before);
const lead = before.replace(/(?:不|没有|没|未|并不|并未|并没有)\s*$/u, "");
if (UNRESOLVED_TARGET.test(lead)) continue;
const casters = castersOf(m[2]!);
const house = /第\s*(\d{1,2})\s*宫\s*(?:也|又|都|还|同时|则|就)?\s*$/u.exec(lead);
let houses: number[] = [];
let planet: string | undefined;
// 「被太阳、水星照,不被月亮、火星照」: the second half has the first half's subject.
const previous = out[out.length - 1];
if (previous && /^(?:被|受|遭)/u.test(previous.text) && /^[\s,,、;]*$/u.test(lead.slice(previous.end))) { houses = previous.houses; planet = previous.planet; }
else if (house) houses = [Number(house[1])];
else {
const hits = [...lead.matchAll(new RegExp(PZ, "gu"))].filter((hit) => !casters.includes(ZH_PLANET[hit[0]]!));
const last = hits[hits.length - 1];
// 「第 6 宫主又燃烧并被土星所照」: a house lord written after the last planet is the subject.
const lords = [...lead.matchAll(new RegExp(`第\\s*(\\d{1,2})\\s*宫\\s*(?:的)?\\s*宫?主星?\\s*(${PZ})?`, "gu"))];
const lord = lords[lords.length - 1];
const lordAt = lord ? (lord.index ?? 0) : -1;
if (lord && (!last || lordAt + lord[0].length >= (last.index ?? 0) + last[0].length) && lead.length - lordAt <= 40) {
planet = lord[2] ? ZH_PLANET[lord[2]] : SIGN_LORD[signOfHouse(natal, Number(lord[1]))];
} else {
if (!last || lead.length - (last.index ?? 0) > 40) continue;
if (GROUP_SUBJECT.test(lead.slice((last.index ?? 0) + last[0].length))) continue;
planet = ZH_PLANET[last[0]];
}
}
out.push({ casters, negative, houses, planet, ...kindOf(`${mid}${m[4]}`), at, end: at + m[0].length, text: m[0] });
}
return out;
}
type Verdict = { ok: boolean; kindWrong: boolean; reason: string; rows?: string[] } | null;
/** Natal reading of one claim; null when there is nothing to check (no target, a target the chart lacks). */
function natalVerdict(claim: Claim, natal: Natal): Verdict {
const targets = claim.planet ? (natal.house[claim.planet] !== undefined ? [natal.house[claim.planet]!] : []) : claim.houses;
if (!targets.length || !claim.casters.length) return null;
const reasons: string[] = [];
let kindWrong = false;
for (const caster of claim.casters) {
if (caster === claim.planet) return null;
const from = natal.house[caster];
if (from === undefined) return null;
for (const target of targets) {
const label = claim.planet ? `${zh(claim.planet)}(第 ${target} 宫)` : `第 ${target} 宫`;
if (caster === "Rahu" || caster === "Ketu") {
if (!claim.negative) reasons.push(`${zh(caster)}不算照别的宫和星`);
continue;
}
const nth = aspectNth(caster, from, target);
if (claim.negative ? nth !== null : nth === null) {
reasons.push(nth === null ? `${zh(caster)}在第 ${from} 宫,照第 ${ASPECT_OFFSETS[caster]!.map((n) => houseFrom(from, n)).join("、")} 宫,不照${label}` : `${zh(caster)}从第 ${from} 宫以${aspectKind(nth)}照${label}`);
continue;
}
if (nth === null || claim.negative) continue;
if ((claim.special && nth === 7) || (claim.nth !== undefined && claim.nth !== nth)) {
kindWrong = true;
reasons.push(`${zh(caster)}照${label}是${aspectKind(nth)}${nth === 7 ? ",所有星都有,不是特殊相位" : ""}`);
}
}
}
return { ok: !reasons.length, kindWrong, reason: reasons.join(";") };
}
type Span = { from: string; to: string };
/** A sign stay counts for a span when they share more than two days, or the span is one day inside the stay. */
const overlaps = (seg: { from: string; to: string }, span: Span) => {
const from = seg.from > span.from ? seg.from : span.from;
const to = seg.to < span.to ? seg.to : span.to;
if (span.from === span.to) return seg.from <= span.from && span.from <= seg.to;
return Date.parse(`${to}T00:00:00Z`) - Date.parse(`${from}T00:00:00Z`) > 2 * 86_400_000;
};
const shift = (iso: string, days: number) => new Date(Date.parse(`${iso}T00:00:00Z`) + days * 86_400_000).toISOString().slice(0, 10);
/** Transit reading of one claim over [span]; null when the card has no rows for it (other casters, outside the window). */
function transitVerdict(claim: Claim, natal: Natal, card: EvidenceCard, span: Span): Verdict {
const targets = claim.planet ? (natal.house[claim.planet] !== undefined ? [natal.house[claim.planet]!] : []) : claim.houses;
if (!targets.length || !claim.casters.length) return null;
const reasons: string[] = [];
const rows: string[] = [];
let kindWrong = false;
for (const caster of claim.casters) {
if (!(TRANSIT_CASTERS as readonly string[]).includes(caster)) return null;
const segments = transitSegments(card, caster);
if (!segments.length || span.from < segments[0]!.from || span.to > segments[segments.length - 1]!.to) return null;
const inSpan = segments.filter((seg) => overlaps(seg, span));
rows.push(...inSpan.map((seg) => `${zh(caster)} ${seg.from} 至 ${seg.to} 在${SIGN_ZH[seg.sign] ?? seg.sign}(本命第 ${seg.house} 宫),照第 ${ASPECT_OFFSETS[caster]!.map((n) => houseFrom(seg.house, n)).join("、")} 宫`));
for (const target of targets) {
const label = claim.planet ? `本命${zh(claim.planet)}(第 ${target} 宫)` : `本命第 ${target} 宫`;
const kinds = inSpan.map((seg) => aspectNth(caster, seg.house, target)).filter((nth): nth is number => nth !== null);
const occupies = inSpan.some((seg) => seg.house === target);
if (claim.negative ? kinds.length > 0 : !kinds.length && !occupies) {
reasons.push(`${span.from} 至 ${span.to} 行运${zh(caster)}${claim.negative ? "照" : "不照"}${label}`);
continue;
}
if (claim.negative || !kinds.length) continue;
if ((claim.special && kinds.every((nth) => nth === 7)) || (claim.nth !== undefined && !kinds.includes(claim.nth))) {
kindWrong = true;
reasons.push(`${span.from} 至 ${span.to} 行运${zh(caster)}照${label}是${[...new Set(kinds)].map(aspectKind).join("、")}`);
}
}
}
return { ok: !reasons.length, kindWrong, reason: reasons.join(";"), rows };
}
// Dates: ISO days, 「2029 年 12 月 13 日」, 「2029 年 12 月」, a month or day without a year taking the last year before it.
const pad = (n: number) => String(n).padStart(2, "0");
const lastDay = (y: number, m: number) => new Date(Date.UTC(y, m, 0)).getUTCDate();
function dateSpan(text: string, context: string): Span | null {
const years = [...context.matchAll(/((?:19|20)\d{2})\s*(?:年|-)/gu)];
let year: number | undefined = years.length ? Number(years[years.length - 1]![1]) : undefined;
const days: string[] = [];
for (const m of text.matchAll(/((?:19|20)\d{2})-(\d{1,2})-(\d{1,2})|(?:((?:19|20)\d{2})\s*年\s*)?(\d{1,2})\s*月(?:\s*(\d{1,2})\s*日)?|((?:19|20)\d{2})\s*年/gu)) {
if (m[1]) { year = Number(m[1]); days.push(`${m[1]}-${pad(Number(m[2]))}-${pad(Number(m[3]))}`); continue; }
if (m[7]) { year = Number(m[7]); days.push(`${year}-01-01`, `${year}-12-31`); continue; }
if (m[4]) year = Number(m[4]);
if (year === undefined) return null;
const month = Number(m[5]);
if (month < 1 || month > 12) continue;
if (m[6]) days.push(`${year}-${pad(month)}-${pad(Number(m[6]))}`);
else days.push(`${year}-${pad(month)}-01`, `${year}-${pad(month)}-${pad(lastDay(year, month))}`);
}
if (!days.length) return null;
days.sort();
return { from: days[0]!, to: days[days.length - 1]! };
}
const TRANSIT_SECTION = /时间线|年盘|行运|流年|时间|什么时候|何时|应期/u;
function sentencesOf(line: string): Array<{ start: number; end: number }> {
const out: Array<{ start: number; end: number }> = [];
let depth = 0;
let start = 0;
for (let index = 0; index < line.length; index += 1) {
const char = line[index]!;
if (char === "(" || char === "(") depth += 1;
else if (char === ")" || char === ")") depth = Math.max(0, depth - 1);
else if (depth === 0 && /[。!?;;]/u.test(char)) { out.push({ start, end: index }); start = index + 1; }
}
out.push({ start, end: line.length });
return out;
}
/** The comma clause holding a claim (transit wording elsewhere in the sentence describes another clause). */
function clauseOf(sentence: string, claim: Claim): string {
const from = Math.max(...[",", ",", ":", ":"].map((mark) => sentence.lastIndexOf(mark, claim.at))) + 1;
const next = [",", ",", ";"].map((mark) => sentence.indexOf(mark, claim.end)).filter((index) => index >= 0);
return sentence.slice(from, next.length ? Math.min(...next) : sentence.length);
}
/** The comma clause around [at, end) of a sentence (for conditionals that only govern their own clause). */
function clauseAround(sentence: string, at: number): string {
const before = sentence.slice(0, at);
const from = Math.max(before.lastIndexOf(","), before.lastIndexOf(","), before.lastIndexOf(":"), before.lastIndexOf(":")) + 1;
return sentence.slice(from, at);
}
/**
* A sentence saying planet A aspects / does not aspect house N or planet B, or naming the kind: a natal sentence (no
* dates, no transit wording) is read against the natal chart; a dated or transit sentence against the Jupiter / Saturn
* transit rows for its dates (the line's lead dates when the sentence has none, the reference day for 「现在」). A dated
* sentence that agrees with the natal chart but not the transit rows, without transit wording, is ambiguous and left
* alone; so is an undated sentence in a timeline / transit section that disagrees with the natal chart.
*/
export function checkAspects(answer: string, card: EvidenceCard, push: Emit) {
const natal = natalOf(card);
if (!natal || !/照|相位/u.test(answer)) return;
const reference = String(rec(rec(rec(card.base).timing).transits_detail).reference_date ?? "").slice(0, 10);
const tables = natalAspectTables(card);
let offset = 0;
let heading = "";
for (const line of answer.split("\n")) {
const lineOffset = offset;
offset += line.length + 1;
if (/^\s*(?:#{1,6}\s|\*\*[^*]{1,24}\*\*\s*$)/u.test(line)) { heading = line; continue; }
if (!/照|相位/u.test(line)) continue;
const transitSection = TRANSIT_SECTION.test(heading);
for (const range of sentencesOf(line)) {
const sentence = line.slice(range.start, range.end);
if (!/照|相位/u.test(sentence)) continue;
if (BOOK_LEAD.test(line) && !THIS_CHART.test(sentence)) continue;
// 「传统说法:……;土星照到第 10 宫主时,传统会提醒……。在这张盘里:……」: the book's sentences up to 「这张盘」 are its rule.
const book = line.lastIndexOf("传统说法", range.start);
if (book >= 0 && !THIS_CHART.test(line.slice(book, range.end))) continue;
if (/传统|书上|古书|经典/u.test(sentence) && !THIS_CHART.test(sentence)) continue;
const claims = claimsIn(sentence, natal);
if (!claims.length) continue;
const own = dateSpan(blank(sentence), line.slice(0, range.start));
const head = own ? null : dateSpan(line.slice(0, range.start), "");
const nowSpan = NOW_WORD.test(sentence) && reference ? { from: reference, to: reference } : null;
const span = own ?? head ?? nowSpan;
const transitWords = TRANSIT_WORD.test(sentence);
const natalWords = NATAL_WORD.test(sentence);
for (const claim of claims) {
// A layer named before the claim governs it (「D9 里土星照……」); one named after it is another clause's (「……,第 12 宫的 Argala……」).
if (OTHER_LAYER.test(blank(sentence.slice(0, claim.end)).replace(/如果你|要是你/gu, ""))) continue;
if (CONDITIONAL_CLAUSE.test(clauseAround(sentence, claim.at))) continue;
// 「土星照到第 10 宫主时,……」: a 「when」 clause states a rule, not this chart.
if (/^\s*(?:时|的时候|之时|时候)/u.test(sentence.slice(claim.end, claim.end + 4))) continue;
const natalResult = natalVerdict(claim, natal);
const timed = Boolean(own || head) || transitWords;
let verdict: Verdict = null;
let reading: "natal" | "transit" = "natal";
if (timed) {
const transit = span ? transitVerdict(claim, natal, card, span) : null;
if (!transit) {
if (!natalWords || own || head) continue;
verdict = natalResult;
} else if (transit.ok) verdict = transit;
else if (natalResult?.ok && !TRANSIT_WORD.test(clauseOf(sentence, claim))) continue;
else { verdict = transit; reading = "transit"; }
if (transit?.ok) reading = "transit";
} else {
if (claim.fromHouse !== undefined && claim.casters.some((caster) => natal.house[caster] !== claim.fromHouse)) continue;
if (transitSection && !natalWords && !natalResult?.ok) continue;
verdict = natalResult;
}
if (!verdict) continue;
const target = claim.planet ? zh(claim.planet) : `第 ${claim.houses.join("、")} 宫`;
const natalRows = [
...claim.casters.map((caster) => tables.by_planet.find((row) => row.startsWith(`${zh(caster)}在第`) || row.includes(`${zh(caster)}(第`)) ?? ""),
claim.planet ? tables.on_planet.find((row) => row.startsWith(`${zh(claim.planet!)}(`)) ?? "" : claim.houses.map((house) => tables.on_house[house - 1] ?? "").join(";"),
].filter(Boolean);
push({
kind: verdict.kindWrong && verdict.ok === false && !verdict.reason.includes("不照") ? "aspect_kind" : "aspect",
layer: reading === "transit" ? "行运相位(按日期)" : "本命相位",
entity: `aspect:${claim.casters.join("+")}>${claim.planet ?? claim.houses.join("+")}`,
reference: reading === "transit" && span ? `${span.from} 至 ${span.to}` : "本命盘",
claimed: `${joinZh(claim.casters)}${claim.negative ? "不照" : "照"}${target}${claim.special ? "(特殊相位)" : claim.nth ? `(第 ${claim.nth} 宫相位)` : ""}`,
card: `${verdict.reason ? `${verdict.reason}。` : ""}${reading === "transit" ? (verdict.rows ?? []).join(";") : natalRows.join(";")}`,
fact_id: reading === "transit" ? "transit_aspects" : "natal_aspects",
source_path: reading === "transit" ? "base.timing.transits_detail.key_dates(aspects.py 规则)" : "base.natal.planets(aspects.py calc_house_aspects 规则)",
quote: sentence, start: lineOffset + range.start, end: lineOffset + range.end,
}, verdict.ok ? "match" : "mismatch");
}
}
}
}
// ---- transit sequences ----------------------------------------------------------------------------------------------
const PLACE = `(?:本命)?\\s*(?:(白羊|金牛|双子|巨蟹|狮子|处女|天秤|天蝎|射手|摩羯|水瓶|双鱼)座?|第\\s*(\\d{1,2})\\s*宫)`;
const SEQUENCE = new RegExp(`(木星|土星|罗睺|罗喉|计都)[^,。;:\\d]{0,6}?(?:进入|进到|进|走到|走进|到了|转到|回到|退回)\\s*${PLACE}\\s*[,、]?\\s*(?:再|又|然后|随后|接着|之后)\\s*(?:回到|退回|进入|进到|进|走到|转到|回|到)\\s*${PLACE}`, "gu");
/**
* 「木星进第 11 宫再到第 10 宫」 inside a dated period: the second place must begin after the first one and inside the
* period (two days' tolerance), on the card's slow-planet timeline. Only sentences whose period the line or the sentence
* dates, inside the transit window, are read.
*/
export function checkTransitSequence(line: string, offset: number, card: EvidenceCard, push: Emit) {
if (!/再|又|然后|随后|接着|之后/u.test(line)) return;
for (const range of sentencesOf(line)) {
const sentence = line.slice(range.start, range.end);
const span = dateSpan(blank(sentence), line.slice(0, range.start)) ?? dateSpan(line.slice(0, range.start), "");
if (!span) continue;
for (const m of blank(sentence).matchAll(SEQUENCE)) {
const body = ZH_PLANET[m[1]!]!;
const segments = transitSegments(card, body);
if (!segments.length || span.from < segments[0]!.from || span.to > segments[segments.length - 1]!.to) continue;
const matches = (seg: Segment, sign?: string, house?: string) => (sign ? seg.sign === ZH_SIGN[sign] : seg.house === Number(house));
const inSpan = segments.filter((seg) => overlaps(seg, span));
const first = inSpan.find((seg) => matches(seg, m[2], m[3]));
const second = first ? segments.find((seg) => seg.from > first.from && matches(seg, m[4], m[5]) && seg.from <= shift(span.to, 2)) : undefined;
const rows = segments.filter((seg) => !(shift(seg.to, 120) < span.from || shift(seg.from, -120) > span.to))
.map((seg) => `${zh(body)} ${seg.from} 至 ${seg.to} 在${SIGN_ZH[seg.sign] ?? seg.sign}(本命第 ${seg.house} 宫)`);
push({
kind: "transit_sequence", layer: "行运先后(按日期)", entity: `sequence:${body}`, reference: `${span.from} 至 ${span.to}`,
claimed: m[0].trim(),
card: `${first && !second ? `这段时间(${span.from} 至 ${span.to})里${zh(body)}进了第二个位置之后没有再换到后一个位置,后一个位置在下一段。` : !first ? `这段时间(${span.from} 至 ${span.to})里${zh(body)}不在前一个位置。` : ""}${rows.join(";")}`,
fact_id: `transit:${body}`, source_path: "base.timing.transits_detail.key_dates",
quote: sentence, start: offset + range.start, end: offset + range.end,
}, first && second ? "match" : "mismatch");
}
}
}
+3 -2
View File
@@ -31,7 +31,8 @@ const ANNUAL_SPELLING: Readonly<Record<string, string>> = { Yasa: "Yashas", Bhra
/** Sahams the chart page has no gloss for (the annual list's Prasava). */
const EXTRA_GLOSS: Readonly<Record<string, string>> = { Prasava: "生育" };
/** Other Chinese names already used in the product for the same Saham (the annual report's SAHAM_CN). */
const ZH_ALIASES: Readonly<Record<string, readonly string[]>> = { Karma: ["事业"], Rajya: ["地位"], Karyasiddhi: ["事成", "成事"], Punya: ["福德"] };
// BUG-2241: Karma's gloss is now 「事业」 itself, so it needs no alias.
const ZH_ALIASES: Readonly<Record<string, readonly string[]>> = { Rajya: ["地位"], Karyasiddhi: ["事成", "成事"], Punya: ["福德"] };
/** Canonical key of a Saham name (「Karma_Saham」「Karma」「Raja」 → Karma / Rajya). */
export function sahamKey(name: string): string {
@@ -73,7 +74,7 @@ export function sahamPoints(card: EvidenceCard): SahamPoint[] {
return out;
}
/** One plain row per Saham: 「年盘 Karma Saham(行动与工作):处女,年盘第 1 宫」. */
/** One plain row per Saham: 「年盘 Karma Saham(事业):处女,年盘第 1 宫」. */
export function sahamTable(card: EvidenceCard): string[] {
return sahamPoints(card).map((point) => {
const gloss = sahamGloss(point.key);
@@ -24,6 +24,7 @@ import {
import { slowBodyTimeline } from "./consultation-evidence-card.ts";
import { checkPeriodCoverage, checkStations, periodCoverageRows } from "./chat-period-coverage.ts";
import { checkArgalaPlanets, checkSahams, checkSavRank } from "./chat-point-checks.ts";
import { checkAspects, checkTransitSequence } from "./chat-aspect-checks.ts";
type Json = unknown;
type Rec = Record<string, Json>;
@@ -86,7 +87,9 @@ export type FactGuardKind = "varga_sign" | "varga_lagna" | "varga_house_lord" |
| "karakamsha_sign" | "karakamsha_house" | "karakamsha_lord" | "karakamsha_lord_house" | "arudha_sign" | "arudha_lord" | "arudha_house" | "arudha_lord_house" | "yoga_status" | "varga_house"
| "planet_dignity" | "saturn_moon" | "node_on_planet" | "neecha_mitigation" | "transit_house" | "transit_dated" | "double_transit_houses"
// BUG-2239: period coverage of the double transit, station dates, Saham rows, the SAV order and the Argala planets.
| "period_coverage" | "station" | "saham_place" | "saham_name" | "sav_rank" | "argala_planets";
| "period_coverage" | "station" | "saham_place" | "saham_name" | "sav_rank" | "argala_planets"
// BUG-2241: aspects (natal and dated transit) against the aspect tables, and 「进 A 再到 B」 inside a dated period.
| "aspect" | "aspect_kind" | "transit_sequence";
export type AnswerFactClaim = AnswerFactMismatch & { status: "match" | "mismatch" | "not_on_card" };
type Emit = (item: AnswerFactMismatch, status?: AnswerFactClaim["status"]) => void;
@@ -364,11 +367,14 @@ export function findAnswerFactClaims(answer: string, card: EvidenceCard): Answer
() => checkSahams(line, offset, card, push),
() => checkSavRank(line, offset, card, push),
() => checkArgalaPlanets(line, offset, card, push),
() => checkTransitSequence(line, offset, card, push),
]) {
try { check(); } catch { /* not checked */ }
}
offset += line.length + 1;
}
// BUG-2241: the aspect check reads the whole answer (it needs the section headings).
try { checkAspects(answer, card, push); } catch { /* not checked */ }
return out.sort((a, b) => a.start - b.start);
}
@@ -1450,6 +1456,8 @@ export function consultationFactRepairPrompt(units: readonly FactGuardUnit[]): s
"- 分清层与实体:婚姻分盘(D9)里的木星、Karakamsha 星座所在的宫、Karakamsha 主星的本命落宫,是三件不同的事,不能互相照抄。",
"- 分盘宫位:从哪里起算就按哪里数,写明起算点;从上升数和从某一宫数是两件事,不能互相照抄。",
"- 运期覆盖、转向日期、Saham、SAV 名次、Argala:照下面给出的那一行写(覆盖词和有的那几段日期、转向日期、Saham 的中文名和星座宫位、SAV 最高最低的宫、Argala 的全部星),只覆盖一部分的不写成整段。",
// BUG-2241: aspects and period order.
"- 相位和行运先后:照下面给出的那一行写(照不照、是对冲相位(第 7 宫相位,所有星都有)还是特殊相位、行运按那段时间的位置),表上不照的不写成照;后一段才发生的换宫不写进这一段。",
"- 格局状态:照卡上给出的状态文字改写,不写「成立」「不成立」「非成立」「落空」,除非卡上的状态文字本身就是这个意思。",
"- 不新增计算、技法或执行状态:不写 executed / blocked / 已执行 / 已核验一类的词,不加审计表行,不换行,不写「|」。",
"- 只输出 JSON 数组:[{\"id\": 1, \"text\": \"重写后的整句\"}],不要别的文字。",
+152
View File
@@ -0,0 +1,152 @@
import assert from "node:assert/strict";
import test from "node:test";
import { precomputedTables } from "../src/lib/chat-answer-tables.ts";
import { aspectKind, natalAspectTables, transitAspectRows } from "../src/lib/chat-aspect-checks.ts";
import { sahamTable } from "../src/lib/chat-point-checks.ts";
import { SAHAM_TERMS } from "../src/lib/chart-data-terms.ts";
import {
consultationFactRepairPrompt,
factGuardUnits,
findAnswerFactClaims,
findAnswerFactMismatches,
} from "../src/lib/consultation-answer-fact-guard.ts";
import type { EvidenceCard } from "../src/lib/consultation-evidence-card.ts";
/**
* BUG-2241: the public test chart (Rodden AA) as the 11-23 end-to-end cards carried it, cut to what the aspect checks
* read: lagna Capricorn, every natal planet's sign and house, Jupiter's and Saturn's ingresses over the 4-year window.
*/
function card(): EvidenceCard {
const planet = (sign: string, house: number) => ({ sign, house });
return {
domains: ["career"],
base: {
natal: {
ascendant: { sign: "Capricorn" },
planets: {
Sun: planet("Cancer", 7), Moon: planet("Taurus", 5), Mars: planet("Virgo", 9), Mercury: planet("Cancer", 7), Jupiter: planet("Capricorn", 1),
Venus: planet("Gemini", 6), Saturn: planet("Capricorn", 1), Rahu: planet("Leo", 8), Ketu: planet("Aquarius", 2),
},
more: { natal_sahams_and_points: { rows: { Karma_Saham: ["Sagittarius", 12] } } },
},
timing: {
transits_detail: {
reference_date: "2026-11-23",
bodies: { Jupiter: { sign: "Leo" }, Saturn: { sign: "Pisces" } },
key_dates_window: { start: "2026-11-23", end: "2030-11-23" },
key_dates: [
["2027-02-05", "Cancer"], ["2027-06-17", "Leo"], ["2027-11-16", "Virgo"], ["2028-03-11", "Leo"], ["2028-07-15", "Virgo"], ["2028-12-16", "Libra"],
["2029-04-10", "Virgo"], ["2029-08-16", "Libra"], ["2030-01-15", "Scorpio"], ["2030-05-13", "Libra"], ["2030-09-14", "Scorpio"],
].map(([date, to_sign]) => ({ kind: "ingress", date, body: "jupiter", to_sign })).concat([
["2027-05-20", "Aries"], ["2027-11-08", "Pisces"], ["2028-02-07", "Aries"], ["2029-07-17", "Taurus"], ["2029-10-28", "Aries"], ["2030-04-05", "Taurus"],
].map(([date, to_sign]) => ({ kind: "ingress", date, body: "saturn", to_sign }))),
},
annual_more: { annual_chart_sahams: { rows: [["Karma", "Virgo", 1]] } },
},
},
domain_sections: {},
} as unknown as EvidenceCard;
}
const kinds = (text: string) => findAnswerFactMismatches(text, card()).map((item) => item.kind);
test("BUG-2241: natal aspect tables follow the backend rule (7th for all, Mars 4/8, Jupiter 5/9, Saturn 3/10, nodes cast none)", () => {
assert.equal(aspectKind(7), "对冲相位(第 7 宫相位)");
assert.equal(aspectKind(10), "特殊相位(第 10 宫相位)");
const tables = natalAspectTables(card());
assert.equal(tables.by_planet.find((row) => row.startsWith("土星")),
"土星在第 1 宫,照:第 3 宫双鱼(没有星),特殊相位(第 3 宫相位);第 7 宫巨蟹(太阳、水星),对冲相位(第 7 宫相位);第 10 宫天秤(没有星),特殊相位(第 10 宫相位)");
assert.ok(tables.by_planet.some((row) => row.startsWith("罗睺(第 8 宫)、计都(第 2 宫):不算照别的宫和星")));
assert.equal(tables.on_planet.find((row) => row.startsWith("水星")),
"水星(第 7 宫):被木星(从第 1 宫,对冲相位(第 7 宫相位))、土星(从第 1 宫,对冲相位(第 7 宫相位))照;不被太阳、月亮、火星、金星照");
assert.equal(tables.on_lords.find((row) => row.startsWith("第 10 宫")), "第 10 宫宫主金星:落第 6 宫,没有星照;不被太阳、月亮、火星、水星、木星、土星照");
assert.equal(tables.on_house[9], "第 10 宫天秤(没有星):被土星(从第 1 宫,特殊相位(第 10 宫相位))照;不被太阳、月亮、火星、水星、木星、金星照");
// A co-tenant does not aspect its own house: Saturn sits with Jupiter in the 1st and does not aspect it.
assert.ok(tables.on_planet.find((row) => row.startsWith("木星"))!.includes("不被月亮、火星、金星、土星照"));
const transit = transitAspectRows(card());
assert.ok(transit.includes("木星 2029-08-16 至 2030-01-15 在天秤(本命第 10 宫,宫内本命没有星):照第 2 宫水瓶(计都),特殊相位(第 5 宫相位);第 4 宫白羊(没有星),对冲相位(第 7 宫相位);第 6 宫双子(金星),特殊相位(第 9 宫相位)"), transit.join("\n"));
const pre = precomputedTables(card());
assert.ok(Array.isArray(pre.natal.aspects_on_lords) && (pre.natal.aspects_on_lords as string[]).length === 12);
assert.ok(Array.isArray(pre.timing.transit_aspects) && (pre.timing.transit_aspects as string[]).length === transit.length);
assert.match(String(pre.natal.aspects_reading), /对冲相位(第 7 宫相位,所有星都有)/u);
});
test("BUG-2241: the three 11-23 error sentences are flagged (fails before: no aspect check in the fact guard)", () => {
// Followup: Saturn's 7th aspect on Mercury called special; Saturn said to aspect the 10th lord Venus.
assert.deepEqual(kinds("**第三,土星的特殊相位落在水星上,而水星正好管第 6、9 宫、还燃烧(离太阳太近)。**"), ["aspect_kind"]);
assert.deepEqual(kinds("- **传统说法**:第 1 宫主落回第 1 宫主自食其力;第 10 宫主落第 6 宫时,被土星照则辛劳而回报薄。在这张盘里:土星照第 10 宫主金星这一点对上,但金星是功能大吉星兼管第 5 宫。"), ["aspect"]);
// Migration: the same special-aspect error in passive form.
assert.deepEqual(kinds("第 9 宫主水星落在第 7 宫巨蟹,同时水星燃烧(离太阳太近,判断力会被盖住)、又受到土星的特殊相位照射,第 9 宫 SAV 只有 25。"), ["aspect_kind"]);
// Migration: a transit put into the next period's house.
assert.deepEqual(kinds("- **2029 年 12 月 13 日—2030 年 2 月 5 日(细运火星,第 4、11 宫主)**:木星进第 11 宫再到第 10 宫,土星在第 4 宫。"), ["transit_sequence"]);
});
test("BUG-2241: correct sentences from the saved answers are not flagged", () => {
const ok = [
"- **压力落在水星**:土星照第 7 宫的水星,水星管第 6、9 宫、燃烧、被木星与土星同时照。",
"- **文书、版权、分成(水星相关的段落)**:本命水星燃烧、又被土星照,管第 6、9 宫。",
"在这张盘里金星并不受土星照(土星照的是第 10 宫本身、不是金星),且金星是 Yogakaraka。",
"依据:第 10 宫宫主金星同时管第 5、10 宫,月亮(AmK)入旺在第 5 宫,土星入庙在命宫且照第 10 宫。",
"- **土星是这张盘的功能吉星,不是阻力来源**:第 1 宫摩羯,土星入庙 3.46°、逆行,管第 1、2 宫,功能吉星,照第 3、7、10 宫,同宫木星、被太阳与水星照。",
"第 3 宫主木星落本命第 1 宫,第 4 宫主火星落本命第 9 宫(处女,中性)并照第 3、4、12 宫。",
"第 8 宫主太阳落在第 7 宫,被土星照。",
"- 「底子够」的支撑:第 7 宫主月亮在金牛 11.49 度、本命第 5 宫、入旺、被木星照、Shadbala 8.33 Rupa(本方法最低线 6)。",
"宫主水星在巨蟹 10.46 度、第 7 宫,中性,燃烧,被土星和木星照,Shadbala 7.08 Rupa/最低线 7。",
"- **身体的两处薄弱**:命宫 SAV 23(挑战档)、火星状态名次三组都在最弱一档且照第 4、3、12 宫。",
"土星以第 7 宫相位照水星,以特殊相位照第 10 宫。",
// A book rule, a quoted rule and a transit sentence that is right for its dates.
"- **传统说法**:第 10 宫主落第 6 宫,工作常与司法、机构有关;土星照第 10 宫主则一生辛劳回报薄,吉星照第 10 宫主则居有权威之位。",
"那段里“土星照第 10 宫主则职位低”的条件在这张盘没有落上(土星照的是水星与太阳),这一句不取。",
// Found in the BUG-2241 end-to-end run (career first turn): a book rule after 「传统说法:」 in the middle of a line.
"反向拉的是:第 10 宫的 SAV 是 33。传统说法:第 10 宫主落第 6 宫,职业常和规章、审查相关;土星照到第 10 宫主时,传统会提醒“长期在一个薪水不高的岗位上”。",
"- **2029 年 8 月 16 日至 2030 年 1 月 15 日**:行运木星在天秤,照到第 6 宫的金星和第 2 宫。",
// The double-transit wording of BUG-2228 (「照到」 for a transit) without a planet subject.
"**双重行运(木星和土星同时作用到同一宫)**:第 10 宫被点到 2026 年 11 月 23 日到 2027 年 2 月 5 日。这两颗星在这一层都是“照到”第 10 宫。",
// A dated sentence that restates the natal aspect without transit words is ambiguous: left alone.
"- **2027 年 7 月 17 日 到 10 月 12 日(月亮细运)**:月亮管第 7 宫、在第 5 宫入旺,并且照到第 11 宫。",
"- **2028 年 3 月 11 日至 7 月 15 日**:土星照第 10 宫,长合约与固定节奏对你是加分项。",
// A sequence inside its period.
"- **2029 年 8 月 1 日至 2030 年 2 月 5 日**:木星进第 10 宫再到第 11 宫。",
];
for (const sentence of ok) assert.deepEqual(kinds(sentence), [], sentence);
});
test("BUG-2241: sentences the first end-to-end run let through are flagged; a 「被……照,不被……照」 pair keeps its subject", () => {
// Migration: an Argala clause after the claim no longer hides it.
assert.deepEqual(kinds("- **手续反复。** 依据是第 9 宫主水星燃烧、又被土星以特殊相位照着,第 12 宫的 Argala 支持来自第 1 宫的木星与土星,等于要靠你自己去推。"), ["aspect_kind"]);
// Marriage: the UL 2nd lord Jupiter (1st) is aspected by neither Mars (9th) nor Saturn (1st).
assert.deepEqual(kinds("UL 起第 2 宫在双鱼、本命第 3 宫,宫内没有星,主星木星在本命第 1 宫,被火星(从第 9 宫)、土星(从第 1 宫)照。"), ["aspect"]);
assert.deepEqual(kinds("UL 起第 2 宫(双鱼,本命第 3 宫)内无星,主星木星位于本命第 1 宫,被太阳(从第 7 宫)、水星(从第 7 宫)照,不被月亮、火星、金星、土星照。"), []);
});
test("BUG-2241: wrong transit aspects for the sentence's dates and wrong natal aspects are flagged; ambiguous ones are not", () => {
assert.deepEqual(kinds("- **2029 年 8 月 16 日至 2030 年 1 月 15 日**:行运木星从天秤照到第 3 宫。"), ["aspect"]);
assert.deepEqual(kinds("2030 年 2 月行运木星照到本命金星。"), ["aspect"], "Jupiter is in Scorpio (11th) then: it aspects 3, 5, 7");
assert.deepEqual(kinds("土星照月亮,压力落在第 5 宫。"), ["aspect"]);
assert.deepEqual(kinds("土星不照第 10 宫。"), ["aspect"]);
assert.deepEqual(kinds("罗睺照第 2 宫。"), ["aspect"], "nodes cast no aspect in this product");
// Mars in the 9th: its 4th lands on the 12th, its 7th on the 3rd, its 8th on the 4th.
assert.deepEqual(kinds("火星以特殊相位照第 3 宫。"), ["aspect_kind"]);
assert.deepEqual(kinds("火星以特殊相位照第 4 宫和第 12 宫。"), []);
});
test("BUG-2241: the repair prompt carries the table rows", () => {
const answer = "**第三,土星的特殊相位落在水星上,而水星正好管第 6、9 宫。**";
const units = factGuardUnits(answer, findAnswerFactMismatches(answer, card()));
assert.equal(units.length, 1);
const prompt = consultationFactRepairPrompt(units);
assert.match(prompt, /对冲相位(第 7 宫相位),所有星都有,不是特殊相位/u);
assert.ok(findAnswerFactClaims("土星以对冲相位照水星。", card()).some((claim) => claim.kind === "aspect" && claim.status === "match"));
});
test("BUG-2241: Karma Saham is 「事业」 on the chart page glossary and the chat rows", () => {
// 原值:Karma_Saham gloss 「行动与工作」 short 「行」
// 新值:gloss 「事业」 short 「业」
// 原因:负责人 2026-11-23 定 Karma Saham 各处统一叫「事业」(年运报告 SAHAM_CN 原来就是 Karma(事业))。
assert.deepEqual(SAHAM_TERMS.Karma_Saham, { gloss: "事业", short: "业" });
assert.ok(sahamTable(card()).includes("年盘 Karma Saham(事业):处女,年盘第 1 宫"));
assert.ok(sahamTable(card()).includes("本命 Karma Saham(事业):射手,本命第 12 宫"));
assert.deepEqual(kinds("年盘上的事业 Saham 在处女、年盘第 1 宫。"), []);
assert.deepEqual(kinds("年盘上的行动与工作 Saham 在处女。"), ["saham_name"], "the old name is no longer a product name");
});
+6 -2
View File
@@ -89,7 +89,10 @@ test("BUG-2239: each sub-period row on the card gives the double-transit coverag
assert.ok(rahu.text.includes("(行运只算 2026-11-23 至 2027-12-12)"), rahu.text);
const tables = precomputedTables(card());
assert.ok((tables.timing.period_coverage as string[]).some((row) => row.startsWith("金星细运")));
assert.ok((tables.natal.sahams as string[]).includes("年盘 Karma Saham(行动与工作):处女,年盘第 1 宫"));
// 原值:年盘 Karma Saham(行动与工作)
// 新值:年盘 Karma Saham(事业)
// 原因:BUG-2241,负责人 2026-11-23 定 Karma Saham 各处统一叫「事业」(年运报告原来就是「事业」)。
assert.ok((tables.natal.sahams as string[]).includes("年盘 Karma Saham(事业):处女,年盘第 1 宫"));
assert.ok((tables.natal.sahams as string[]).includes("本命 Paradesa Saham(异地):金牛,本命第 5 宫"));
assert.match(String(tables.natal.sav_order), /^SAV 从高到低:第 11 宫 37、第 10 宫 33/u);
assert.ok((tables.natal.argala as string[]).some((row) => row.startsWith("第 10 宫 Argala 待定:出手的星 木星、土星(第 1 宫,待定);金星(第 6 宫,待定)")));
@@ -127,7 +130,8 @@ test("BUG-2239: the same facts written as the rows say are not flagged", () => {
assert.deepEqual(kinds("月亮的 Shadbala 达到最低线,第 5 宫的 SAV 是 31 分。"), [], "「最低线」 is the Shadbala threshold");
assert.deepEqual(kinds("第 10 宫 Argala 待定:第 1 宫的木星、土星和第 6 宫的金星在出手,第 7 宫的太阳、水星在挡。"), []);
assert.deepEqual(kinds("第 11 宫的 Argala 受阻、宫主火星是功能凶星。"), [], "a lord named after the verdict is not an Argala list");
assert.deepEqual(kinds("年盘上的 Karma Saham(行动与工作)在处女、年盘第 1 宫;本命盘上的 Karma Saham 在射手、本命第 12 宫。"), []);
// 原值:Karma Saham(行动与工作);新值:Karma Saham(事业);原因:BUG-2241 统一 Karma Saham 中文名。
assert.deepEqual(kinds("年盘上的 Karma Saham(事业)在处女、年盘第 1 宫;本命盘上的 Karma Saham 在射手、本命第 12 宫。"), []);
assert.deepEqual(kinds("年盘上的 Paradesa Saham(异地)在双子、年盘第 10 宫。"), []);
assert.deepEqual(kinds("年盘上的 Karma Saham 在处女,也就是本命第 9 宫。"), [], "a natal house for an annual Saham is a different reference");
// Found in the BUG-2239 end-to-end run: two houses' Argala in one sentence, and a lord's houses in a bracketed head.
@@ -321,7 +321,8 @@ test("size: single-domain turns stay within 68,000 characters with the astrologe
// 原值: 68_000 / 新值: 96_000(实测最大 93,390,elizabeth_taylor/annual) / 原因: BUG-2229 卡上补全后端已算的层(全部细运、全年 Mudda、12 宫 SAV
// 和 Argala、全部 Arudha、Shadbala 分量、定位星链、其余格局)、四项引擎新增层,以及给模型的预先算好的表(负责人 2026-11-22「先把数据补全」)
// 原值: 96_000 / 新值: 102_000(实测最大 99,535,elizabeth_taylor/annual) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok(contractAndCard <= 102_000, `${chart.id}/${domain}: contract + card ${contractAndCard}`);
// 原值: 102_000 / 新值: 106_000(实测最大 103,464,elizabeth_taylor/annual) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok(contractAndCard <= 106_000, `${chart.id}/${domain}: contract + card ${contractAndCard}`);
// 原值(2): 26_000 / 新值(2): 40_000(2026-11-07 实测最大:年运 38,377、时运 36,886;契约 + 卡不变,最大 10,641) / 原因(2): BUG-1696/BUG-1697 产品 2026-11-07:聊天完整运行占星师 skill(上游 SKILL.md 原文 + 路由全文 + 判断手册),不再摘录
// 原值(3): 40_000 / 新值(3): 64_000(卡片分支)与 45_000(专业模式分支) / 新值(4): 68_000(合并后实测最大 64,558) / 原因(4): 产品 2026-11-07 占星师方案:完整数据上卡 + 按派别交付子 skill,两者合并
// 原值: 68_000 / 新值: 75_000(合并引擎新层后实测最大 71,040) / 原因: BUG-1699 产品 2026-11-07:受克证据、Sade Sati 换座、书籍规则、事业分析与 16 项上游技法上卡后的合并实测
@@ -333,7 +334,8 @@ test("size: single-domain turns stay within 68,000 characters with the astrologe
// 原值: 113_000 / 新值: 117_000(实测最大 115,852,barack_obama/annual;改前同一项 111,816) / 原因: BUG-1982 证据包第一步补全(产品负责人 2026-11-18 定结论核查走 A):卡顶加 evidence_index(快照编号、按路径的编号模板、状态码与图例),卡上每条可引用事实都能解析出编号和状态,实测索引最大 4,187 字符
// 原值: 117_000 / 新值: 145_000(实测最大 141,749,elizabeth_taylor/annual) / 原因: BUG-2229,同上
// 原值: 145_000 / 新值: 150_000(实测最大 147,894,elizabeth_taylor/annual) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok(total <= 150_000, `${chart.id}/${domain}: ${total}`);
// 原值: 150_000 / 新值: 155_000(实测最大 151,823,elizabeth_taylor/annual) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok(total <= 155_000, `${chart.id}/${domain}: ${total}`);
} else {
// 原值: 20_000 / 新值: 45_000(2026-11-07 实测最大:关系 43,408、财富 40,915、事业 39,993;其余 35–37k,约 24.9k 是路由全文) / 原因: BUG-1696/BUG-1697 产品 2026-11-07:聊天完整运行占星师 skill(上游 SKILL.md 原文 + 路由全文 + 判断手册),不再摘录
// 原值(2): 45_000 / 新值(2): 68_000(卡片分支)与 53_000(专业模式分支) / 新值(3): 76_000(合并后实测最大 72,466) / 原因(3): 产品 2026-11-07 占星师方案:完整数据上卡 + 按派别交付子 skill,两者合并
@@ -349,7 +351,8 @@ test("size: single-domain turns stay within 68,000 characters with the astrologe
// 原值: 123_000 / 新值: 127_000(实测最大 125,269,elizabeth_taylor/wealth;改前同一项 121,217) / 原因: BUG-1982 证据包第一步补全(产品负责人 2026-11-18 定结论核查走 A):卡顶加 evidence_index(快照编号、按路径的编号模板、状态码与图例),卡上每条可引用事实都能解析出编号和状态,实测索引最大 4,187 字符
// 原值: 127_000 / 新值: 157_000(实测最大 153,702,elizabeth_taylor/wealth) / 原因: BUG-2229,同上
// 原值: 157_000 / 新值: 162_000(实测最大 160,577,elizabeth_taylor/wealth) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok(total <= 162_000, `${chart.id}/${domain}: ${total}`);
// 原值: 162_000 / 新值: 167_000(实测最大 164,506,elizabeth_taylor/wealth) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok(total <= 167_000, `${chart.id}/${domain}: ${total}`);
}
}
}
@@ -239,11 +239,13 @@ test("size: the long-range question keeps contract + card within the card budget
// 原值: 24_000 / 新值: 24_500(实测最大 24,177,barack_obama/wealth) / 原因: BUG-2228 主题宫的双重过境行带上每颗星的 jupiter_pac / saturn_pac(进入还是照到)。
// 原值: 24_500 / 新值: 37_000(实测最大 35,804,steve_jobs/wealth) / 原因: BUG-2229 卡上补全后端已算的层、四项引擎新增层和给模型的预先算好的表(负责人 2026-11-22「先把数据补全」)
// 原值: 37_000 / 新值: 39_000(实测最大 37,689,steve_jobs/wealth) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok(JSON.stringify(rest).length <= 39_000, `${figure.id}/${domain} contract + card ${JSON.stringify(rest).length}`);
// 原值: 39_000 / 新值: 43_000(实测最大 40,927,steve_jobs/wealth) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok(JSON.stringify(rest).length <= 43_000, `${figure.id}/${domain} contract + card ${JSON.stringify(rest).length}`);
// 原值: 12_000 / 新值: 20_000(与契约 + 卡同一上限) / 原因: 产品 2026-11-07 占星师方案:参数、KP、全部大运、年运精简块、Argala 等上卡
// 原值: 20_000 / 新值: 30_000(实测最大 29,003,steve_jobs/wealth) / 原因: BUG-2229 卡上补全后端已算的层、四项引擎新增层和给模型的预先算好的表(负责人 2026-11-22「先把数据补全」)
// 原值: 30_000 / 新值: 32_000(实测最大 30,888,steve_jobs/wealth) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok((state.evidenceCardChars ?? Infinity) <= 32_000, `${figure.id}/${domain} card ${state.evidenceCardChars}`);
// 原值: 32_000 / 新值: 36_000(实测最大 34,126,steve_jobs/wealth) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok((state.evidenceCardChars ?? Infinity) <= 36_000, `${figure.id}/${domain} card ${state.evidenceCardChars}`);
}
}
});
@@ -515,7 +515,8 @@ test("model-visible size falls to card scale; only the method can push it past 3
// 原值: 75_000 / 新值: 79_000(实测最大 77,517,elizabeth_taylor/general;改前同一项 73,319) / 原因: BUG-1982 证据包第一步补全(产品负责人 2026-11-18 定结论核查走 A):卡顶加 evidence_index(快照编号、按路径的编号模板、状态码与图例),卡上每条可引用事实都能解析出编号和状态,实测索引最大 4,187 字符
// 原值: 79_000 / 新值: 112_000(实测最大 107,786,elizabeth_taylor/general) / 原因: BUG-2229 卡上补全后端已算的层、四项引擎新增层和给模型的预先算好的表(负责人 2026-11-22「先把数据补全」)
// 原值: 112_000 / 新值: 116_000(实测最大 113,661,elizabeth_taylor/general) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok(withoutMethod <= 116_000, `${chart.id}/${domain}: contract + card ${withoutMethod}`);
// 原值: 116_000 / 新值: 120_000(实测最大 117,590,elizabeth_taylor/general) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok(withoutMethod <= 120_000, `${chart.id}/${domain}: contract + card ${withoutMethod}`);
// 原值(2): 非 methodHeavy ≤ 20_000,全部 ≤ 26_000
// 新值(2): 非 methodHeavy ≤ 38_000(2026-11-07 实测最大:父母 36,832),全部 ≤ 45_000(实测最大:关系 43,408、财富 40,915、事业 39,993)
// 原因(2): BUG-1696/BUG-1697 产品 2026-11-07:聊天完整运行占星师 skill(上游 SKILL.md 原文 + 路由全文 + 判断手册),不再摘录
@@ -532,7 +533,8 @@ test("model-visible size falls to card scale; only the method can push it past 3
// 原值: 123_000 / 新值: 127_000(实测最大 125,269,elizabeth_taylor/wealth;改前同一项 121,217) / 原因: BUG-1982 证据包第一步补全(产品负责人 2026-11-18 定结论核查走 A):卡顶加 evidence_index(快照编号、按路径的编号模板、状态码与图例),卡上每条可引用事实都能解析出编号和状态,实测索引最大 4,187 字符
// 原值: 127_000 / 新值: 154_000(实测最大 149,387,elizabeth_taylor/general) / 原因: BUG-2229 卡上补全后端已算的层、四项引擎新增层和给模型的预先算好的表(负责人 2026-11-22「先把数据补全」)
// 原值: 154_000 / 新值: 158_000(实测最大 155,264,elizabeth_taylor/general) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
if (!methodHeavy.has(domain)) assert.ok(total <= 158_000, `${chart.id}/${domain}: ${total}`);
// 原值: 158_000 / 新值: 162_000(实测最大 159,193,elizabeth_taylor/general) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
if (!methodHeavy.has(domain)) assert.ok(total <= 162_000, `${chart.id}/${domain}: ${total}`);
// 原值: 76_000 / 新值: 83_000(合并引擎新层后实测最大 78,948) / 原因: BUG-1699 产品 2026-11-07:受克证据、Sade Sati 换座、书籍规则、事业分析与 16 项上游技法上卡后的合并实测
// 原值: 83_000 / 新值: 87_000(参数块与书籍规则交给模型后实测最大 82,704) / 原因: 产品 2026-11-07:parameters 与 book_rules 原先只在卡上、未进模型可见内容;年运路线的书籍规则约 1 万字
// 原值: 87_000 / 新值: 93_000(年运精简块、Argala、Narayana 下一子运、上游大运合并后实测最大 88,232) / 原因: 产品 2026-11-07「需要补缺口」:财富等问时间的回答带年运、Argala 与已接入的大运
@@ -545,7 +547,8 @@ test("model-visible size falls to card scale; only the method can push it past 3
// 原值: 123_000 / 新值: 127_000(同上) / 原因: BUG-1982 证据包第一步补全(产品负责人 2026-11-18 定结论核查走 A):卡顶加 evidence_index(快照编号、按路径的编号模板、状态码与图例),卡上每条可引用事实都能解析出编号和状态,实测索引最大 4,187 字符
// 原值: 127_000 / 新值: 160_000(实测最大 154,563,elizabeth_taylor/wealth) / 原因: BUG-2229 卡上补全后端已算的层、四项引擎新增层和给模型的预先算好的表(负责人 2026-11-22「先把数据补全」)
// 原值: 160_000 / 新值: 164_000(实测最大 160,577,elizabeth_taylor/wealth) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok(total <= 164_000, `${chart.id}/${domain}: ${total} (methodology ${JSON.stringify(methodology ?? null).length})`);
// 原值: 164_000 / 新值: 167_000(实测最大 164,506,elizabeth_taylor/wealth) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok(total <= 167_000, `${chart.id}/${domain}: ${total} (methodology ${JSON.stringify(methodology ?? null).length})`);
}
}
});
@@ -411,7 +411,8 @@ test("size: contract + card stay under 34,000 characters without the checklist,
// 原值: 75_000 / 新值: 79_000(实测最大 77,517,elizabeth_taylor/general;改前同一项 73,319) / 原因: BUG-1982 证据包第一步补全(产品负责人 2026-11-18 定结论核查走 A):卡顶加 evidence_index(快照编号、按路径的编号模板、状态码与图例),卡上每条可引用事实都能解析出编号和状态,实测索引最大 4,187 字符
// 原值: 79_000 / 新值: 112_000(实测最大 107,786,elizabeth_taylor/general) / 原因: BUG-2229 卡上补全后端已算的层、四项引擎新增层和给模型的预先算好的表(负责人 2026-11-22「先把数据补全」)
// 原值: 112_000 / 新值: 116_000(实测最大 113,661,elizabeth_taylor/general) / 原因: BUG-2239 卡上给每个小运和细运加双重行运 / 慢星覆盖词和转向日期、Saham 中文名表、SAV 排序和 Argala 全行(负责人 2026-11-23「现在修」)
assert.ok(JSON.stringify(rest).length <= 116_000, `${chart.id}/${domain} contract + card ${JSON.stringify(rest).length}`);
// 原值: 116_000 / 新值: 120_000(实测最大 117,590,elizabeth_taylor/general) / 原因: BUG-2241 卡上加相位表(每颗星照哪几宫和星、每宫 / 每颗星 / 每个宫主被谁照不被谁照)和行运木星、土星每段照的宫(负责人 2026-11-23)
assert.ok(JSON.stringify(rest).length <= 120_000, `${chart.id}/${domain} contract + card ${JSON.stringify(rest).length}`);
// 原值(2): gaps 全空 / 新值(2): 除去「:not_available_yet」后为空 / 原因(2): 产品 2026-11-07 占星师方案:回答模型拿到完整数据(参数块、领域路由、KP Placidus、全部大运当前层、行运细节、瑜伽成立条件、特殊点、Avastha / Bhava Bala 上卡)
const gaps = (dig(view, "evidence_card", "gaps") ?? []) as string[];
assert.deepEqual(gaps.filter((gap) => !gap.endsWith(":not_available_yet")), [], `${chart.id}/${domain} gaps`);