feat(chat): KP support and resistance as strip stretch reasons beside the BUG-2310 rules — running lord leaning to the matter's houses (with the cusp's promise) or to the negating houses; same four labels, plain words, KP names only in 判断依据 (BUG-2325)

Separate on purpose: on the public chart it turns career from 4/6 to 6/6 「有机会,但费力」 (BUG-2326), so it can be dropped until the labels weigh their reasons.

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-24 19:06:06 +08:00
co-authored by Claude Opus 5.5
parent 041069ebaa
commit aacf363df8
3 changed files with 64 additions and 3 deletions
+3 -1
View File
@@ -31471,8 +31471,10 @@
- 问答(`chat-transit-window.ts` `attachKpTransitLords`,`consultation-tools.ts` 在快星行运之后调用):只有事业、钱、感情领域才调,起点和慢星行运同一天,372 天;失败记 blocked(和快星行运一样留在那一层),不挡回答,也不出 KP 日子。
- 程序判断(新文件 `frontend/src/lib/chat-kp-timing.ts`,卡建好后由 `buildEvidenceCard` 调 `attachKpTiming`):(1)承诺:事业 10 宫头、钱 2 和 11 宫头、感情 7 宫头的 Sub Lord 指到这件事的宫(事业 2、6、10、11;钱 2、6、11;感情 2、7、11),否定宫事业 5、8、12,钱 8、12,感情 1、6、10。(2)一颗星指哪几宫:宫头一侧和行星一侧的 A–D 合起来;罗睺、计都再带上星座主和星宿主指的宫。(3)窗口:卡上的小运或细运主星指到这件事的宫、太阳走在它的星宿的那些天;其中月亮也走在它星宿的日子(最多 3 天);木星走在指到这件事的运期主星星宿时记一笔;主星也指到否定宫时记「要先过一道关」。没有承诺就不出窗口。每个领域最多 10 个窗口。卡上写成 `domain_sections.<领域>.kp.timing`(承诺、主星、窗口三张小表)。
- 给写的人:`timing` 卡的预算表加 `kp_windows`(每行「〔KP1 W3〕2027 年 2 月 19 日到 3 月 4 日|工作上的事会有回音,但要先过一道关|其中 2 月 25 日最明显」,按所在时间条段落标 W 编号;时间条之外的窗口不给)和读法 `kp_windows_reading`:在那一段的那句话里用平常话带上日子,句末加 KP 编号,正文不写 KP 名词,不改那一段的说法。判断依据加 KP 行(`timing.kp_windows`),KP 名词只在这里。
- 时间条说法(协调窗口转述占星师的目标:「KP 结合星历、本命宫头与指示星、大运和行运,分析某类人生变化有哪些支持与阻力,以及哪些时间段可能更容易出现相关变化」):`chat-strip-status.ts` 在 BUG-2310 的规则旁边加两条段落理由,标签还是那四种。K1 支持:小运或细运主星主要指到这件事的宫,而且宫头有承诺。K2 阻力:主星主要指到否定宫(事业 5、8、12,钱 8、12,感情 1、6、10,协调窗口给的分组)。两边一样多就两条都算。白话只写生活上的事,例如事业 K1「工作上的变动更容易落地」、K2「工作上容易拖延,或者要另起炉灶」;KP 名词只在判断依据里。盖住整年的小运理由照 BUG-2310 进「这一年的底色」。
- 实测:开发机冷算一年 0.41 秒 CPU,命中缓存约 0.1 毫秒;公开盘事业卡多 890 字符(原 145,395)。
- 验证:新增 `frontend/tests/chat-kp-timing-2325.test.ts`(9 条:significator 合并和罗睺代理、窗口和月亮日子、没承诺不出窗口、不相关的星宿不出窗口、只在三个领域上卡、引擎失败或没请求时不出日子也不记缺口、写给写的人的行和判断依据行同一编号且正文行没有 KP 名词和工程用词、时间条之外的窗口丢掉、日期写法、卡上 KP 段和行的大小上限)和 `tests/test_ondemand_kp_transit_lords_2325.py`(6 条:注册和整段覆盖、月亮约一天一换、缓存键与本命无关、上限和岁差检查、进程岁差恢复、一年 CPU 上限)。读改动文件的前端测试和三个守护测试逐个跑;tsc、ESLint 0 错误;快检。钉住的卡片大小测试(`consult-dasha-horizon-20261105`)用的样例盘没有 KP 层,数字不变,所以没改;KP 的增量由新测试单独钉住。真实路由(同 BUG-2281 的桩,默认模型,公开盘,每题一次,用户没提 KP):事业时间条最后一段写「10 月 12 日到 23 日更容易谈下来」;钱有三段带日子(「其中 2 月下旬到 3 月初钱上的事更容易谈成」等);感情四段带日子(「其中 12 月 29 日到 1 月 10 日更容易进一步」等)。三条回答的正文和时间条都没有 KP 名词,判断依据里有 KP 行。
- 验证:新增 `frontend/tests/chat-kp-timing-2325.test.ts`(10 条:significator 合并和罗睺代理、窗口和月亮日子、没承诺不出窗口、不相关的星宿不出窗口、只在三个领域上卡、引擎失败或没请求时不出日子也不记缺口、写给写的人的行和判断依据行同一编号且正文行没有 KP 名词和工程用词、时间条之外的窗口丢掉、日期写法、卡上 KP 段和行的大小上限、K1 和 K2 进时间条说法)和 `tests/test_ondemand_kp_transit_lords_2325.py`(6 条:注册和整段覆盖、月亮约一天一换、缓存键与本命无关、上限和岁差检查、进程岁差恢复、一年 CPU 上限)。读改动文件的前端测试和三个守护测试逐个跑;tsc、ESLint 0 错误;快检。钉住的卡片大小测试(`consult-dasha-horizon-20261105`)用的样例盘没有 KP 层,数字不变,所以没改;KP 的增量由新测试单独钉住。真实路由(同 BUG-2281 的桩,默认模型,公开盘,每题一次,用户没提 KP):事业时间条最后一段写「10 月 12 日到 23 日更容易谈下来」;钱有三段带日子(「其中 2 月下旬到 3 月初钱上的事更容易谈成」等);感情四段带日子(「其中 12 月 29 日到 1 月 10 日更容易进一步」等)。三条回答的正文和时间条都没有 KP 名词,判断依据里有 KP 行。
- 加了 K1、K2 之后的时间条(公开盘,按程序离线建卡,没有再调用模型):事业 6 段,原来是 有机会 / 有机会 / 有机会,但费力 ×4,现在 6 段全是「有机会,但费力」。原因是金星细运在 KP 里只指到第 5 宫(否定宫),前两段多了一条阻力。钱 7 段不变(较费力 / 不标 / 有机会 / 有机会,但费力 ×2 / 有机会 ×2)。感情 5 段是 有机会 / 有机会 / 有机会,但费力 / 有机会 / 有机会,但费力。事业这一条正是 BUG-2326 的问题:说法只看有没有支持、有没有阻力,理由越多,越容易每段都是「两样都有」。上卡前要先定 BUG-2326 的权衡办法,或者先只用 KP 的日子、不用 K1、K2(这部分单独一个提交,可以整体撤掉)。
- 已知不足:只问「推运」、没落到事业、钱、感情的追问(路由为「时运」)不带 KP 日子;运期用产品的 Raman Vimshottari,没有另算 KP 大运;罗睺、计都的代理没算合相和相位;月亮按天取样;Ruling Planets 没用(问答没有提问时刻)。方案和待占星师复核的问题:`/workspace/eval-read-1116/kp-timing-proposal-20261124.md`。
- 防复发:KP 的日子只由 `chat-kp-timing.ts` 算,写的人只照 `kp_windows` 写;正文禁用 KP 名词的检查(`BODY_TERMS`)不变。
- 关联记录:BUG-1701(KP 上卡)、BUG-1884(年度 KP 宫头精度分支)、BUG-2229(快星行运的同类引擎调用)、BUG-2310(时间条按领域分段)、BUG-2326(同一截图里的两处旁证)。
+35 -2
View File
@@ -30,6 +30,7 @@
import type { EvidenceCard } from "./consultation-evidence-card.ts";
import { ANSWER_TONE_LABELS, type AnswerTone } from "./chat-answer-shape.ts";
import { slowBodyTimeline } from "./consultation-evidence-card.ts";
import { KP_DOMAIN_RULES, isKpDomain, kpTimingFromCard, type KpTiming } from "./chat-kp-timing.ts";
import { doubleTransitHouses, periodCoverageRows, pressureRanges, transitWindow, windowPeriods, type Period, type Span } from "./chat-period-coverage.ts";
type Rec = Record<string, unknown>;
@@ -49,7 +50,7 @@ const UPACHAYA_SKIP = new Set([6, 11]);
export type StripLabel = AnswerTone;
/** The words beside each colour (none: no tag, neutral fill). */
export const STRIP_LABEL_TEXT = ANSWER_TONE_LABELS;
export type RuleId = "S1" | "S2" | "S3" | "R1" | "R2" | "R3" | "R4";
export type RuleId = "S1" | "S2" | "S3" | "R1" | "R2" | "R3" | "R4" | "K1" | "K2";
export type StripReason = Readonly<{
rule: RuleId;
@@ -171,6 +172,8 @@ const PLAIN: Readonly<Record<RuleId | "R3node", Readonly<Record<StripDomain, str
R1: { career: "工作上会出反复,要多花力气收拾", wealth: "钱上会有额外的支出", marriage: "感情上会有误会,要多花心思", general: "事情会反复,要多花力气" },
R2: { career: "工作上两头的要求拧着,协调费劲", wealth: "钱上进出两头对不上,要多算一步", marriage: "两个人的节奏对不上,要多磨合", general: "几件事的要求互相拧着" },
R3: { career: "工作上责任重,推进慢", wealth: "钱进得慢,要守住支出", marriage: "感情进展慢,对方冷一点", general: "事情推得慢" },
K1: { career: "工作上的变动更容易落地", wealth: "钱上的事更容易落实下来", marriage: "感情上的事更容易往前走", general: "" },
K2: { career: "工作上容易拖延,或者要另起炉灶", wealth: "钱上容易多出开销、要多走手续", marriage: "感情上容易冷下来、各忙各的", general: "" },
R3node: { career: "工作上变数多,计划会被打乱", wealth: "钱上会有意外的进出", marriage: "感情上忽冷忽热,变数多", general: "变数多,计划会被打乱" },
R4: { career: "心里压力大、精力紧,工作上更明显", wealth: "心里压力大,花钱上更要收着", marriage: "心里压力大,感情上更敏感", general: "心里压力大,精力要省着用" },
};
@@ -208,10 +211,41 @@ function lordReasons(chart: Chart, period: Period, houses: readonly number[], do
return out;
}
const kpCache = new WeakMap<object, KpTiming | null>();
function kpOf(card: EvidenceCard, domain: string): KpTiming | null {
if (kpCache.has(card)) return kpCache.get(card)!;
const timing = kpTimingFromCard(card, domain);
kpCache.set(card, timing);
return timing;
}
function kpReasons(kp: KpTiming, period: Period, domain: "career" | "wealth" | "marriage"): StripReason[] {
const lord = kp.lords[period.lord];
if (!lord) return [];
const rule = KP_DOMAIN_RULES[domain];
const dates = `${period.start} 至 ${period.end}`;
const promise = kp.promise.map((row) => `${row.cusp} 宫头 Sub Lord ${zh(row.subLord)}`).join("、");
const out: StripReason[] = [];
// The side the lord leans to (KP: a planet gives the houses it signifies most); an even split gives both.
const leansGood = lord.good.length >= lord.bad.length;
const leansBad = lord.bad.length >= lord.good.length;
if (kp.promised && lord.good.length && leansGood) {
out.push({ rule: "K1", side: "support", fact: `kp+:${period.level}:${period.lord}:${period.start}`, plain: PLAIN.K1[domain], basis: `KP:${levelZh(period)}(${dates})是第 ${list(lord.good)} 宫的 significator(这件事的宫:${list(rule.good)};${promise}指到这件事的宫)` });
}
if (lord.bad.length && leansBad) {
out.push({ rule: "K2", side: "resistance", fact: `kp-:${period.level}:${period.lord}:${period.start}`, plain: PLAIN.K2[domain], basis: `KP:${levelZh(period)}(${dates})${lord.good.length ? "也是" : "是"}第 ${list(lord.bad)} 宫的 significator(这件事的否定宫:${list(rule.bad)})` });
}
return out;
}
function reasonsAt(chart: Chart, moment: Moment, domain: StripDomain, card: EvidenceCard): StripReason[] {
const houses = DOMAIN_HOUSES[domain];
const out: StripReason[] = [];
for (const period of [moment.ad, moment.pd]) if (period) out.push(...lordReasons(chart, period, houses, domain));
// BUG-2325: KP — a running lord that signifies the matter's houses (support, only when the cusp promises it) or its
// negating houses (resistance), from the card's KP significators.
const kp = isKpDomain(domain) ? kpOf(card, domain) : null;
if (kp && isKpDomain(domain)) for (const period of [moment.ad, moment.pd]) if (period) out.push(...kpReasons(kp, period, domain));
if (moment.md && moment.ad && moment.md.lord !== moment.ad.lord) {
const mdAt = chart.house[moment.md.lord];
const adAt = chart.house[moment.ad.lord];
@@ -271,7 +305,6 @@ function reasonsAt(chart: Chart, moment: Moment, domain: StripDomain, card: Evid
out.push({ rule: "R3", side: "resistance", fact: `${node}:${moment.signs[node]}`, plain: PLAIN.R3node[domain], basis: `${zh(node)}这段时间走到第 ${at} 宫(${SIGN_ZH[moment.signs[node]!]})` });
}
}
void card;
return out;
}
@@ -13,6 +13,7 @@ import {
import { claimCardsWithStripStretches, programKpLines, programStretches } from "../src/lib/chat-answer-timeline.ts";
import { evidenceKeyRows } from "../src/lib/chat-evidence-keys.ts";
import { STRIP_ENGINEERING_WORDS } from "../src/lib/chat-answer-shape.ts";
import { statusStretches } from "../src/lib/chat-strip-status.ts";
const SIGNS = ["Aries", "Taurus", "Gemini", "Cancer", "Leo", "Virgo", "Libra", "Scorpio", "Sagittarius", "Capricorn", "Aquarius", "Pisces"];
const FROM = "2026-12-01";
@@ -184,3 +185,28 @@ test("BUG-2325 size: the card view and the writer's lines stay small at the wind
assert.ok(JSON.stringify(lines).length <= 800, `lines ${JSON.stringify(lines).length}`);
assert.ok(KP_WINDOWS_READING.length <= 400, `reading ${KP_WINDOWS_READING.length}`);
});
test("BUG-2325 strip: KP support and resistance are stretch reasons beside the BUG-2310 rules (same labels, plain words)", () => {
const career = card("career");
const list = statusStretches(career, { from: FROM, to: TO });
// Venus sub-sub-period (2027-03-01..06-01) signifies the career houses 2, 10 and the negating 5: it leans to career.
const venus = list.find((item) => item.from === "2027-03-01")!;
const kpRules = (item: { reasons: ReadonlyArray<{ rule: string }> }) => item.reasons.map((reason) => reason.rule).filter((rule) => rule.startsWith("K")).sort();
assert.deepEqual(kpRules(venus), ["K1"]);
assert.equal(venus.reasons.find((reason) => reason.rule === "K1")!.plain, "工作上的变动更容易落地");
assert.match(venus.reasons.find((reason) => reason.rule === "K1")!.basis, /^KP:金星细运(2027-03-01 至 2027-06-01)是第 2、10 宫的 significator(这件事的宫:2、6、10、11;10 宫头 Sub Lord 水星指到这件事的宫)$/u);
// Ketu (the rest of the year) signifies neither group: no KP reason.
assert.deepEqual(list.filter((item) => item !== venus).map(kpRules), [[], []]);
// No promise: no KP support.
const unpromised = statusStretches(card("career", { cuspSub: "Moon" }), { from: FROM, to: TO }).find((item) => item.from === "2027-03-01")!;
assert.deepEqual(kpRules(unpromised), []);
// A lord that signifies mostly the negating houses (Mars here: 5, 8 and, as every house's lord in this layer, 12 — against 6) is resistance; an even split is both.
const negating = { domains: ["career"], base: base([["Ketu", "Ketu", "Ketu", "2026-01-01", "2027-03-01"], ["Ketu", "Ketu", "Mars", "2027-03-01", "2027-06-01"], ["Ketu", "Ketu", "Ketu", "2027-06-01", "2028-06-01"]]), domain_sections: { career: { kp: { status: "parameter_sensitive" } } }, meta: { gaps: [] } } as unknown as EvidenceCard;
const layer = kpLayer();
(layer.planets as Record<string, unknown>).Mars = { significators: { A: 5, B: 8, C: [], D: [6] } };
attachKpTiming(negating, () => ({ kp_placidus: layer, kp_transit_lords: { calculation_status: "executed", raw: transits() } }));
const mars = statusStretches(negating, { from: FROM, to: TO }).find((item) => item.from === "2027-03-01")!;
assert.deepEqual(kpRules(mars), ["K2"]);
assert.match(mars.reasons.find((reason) => reason.rule === "K2")!.basis, /)也是第 5、8、12 宫的 significator(这件事的否定宫:5、8、12)$/u);
for (const reason of [...venus.reasons, ...mars.reasons]) assert.doesNotMatch(reason.plain, /KP|星宿|significator|Sub/u);
});