diff --git a/docs/BUG_HISTORY.md b/docs/BUG_HISTORY.md index d38a992c..8a38e2f3 100644 --- a/docs/BUG_HISTORY.md +++ b/docs/BUG_HISTORY.md @@ -4874,3 +4874,19 @@ - 相关记录:BUG-120、BUG-297、BUG-313 - 复发自:BUG-313(有 follow-up 时仍可因 compare 投影为 adopt 而 offer);BUG-297(compare/offer 不共享提出门) - 修复版本:7dc97a49 + +## BUG-324 | 经典八方法访谈被财务/健康轮询替换,KP 宫头被政策跳过冒充已观察 + +- 状态:resolved +- 首次发现:2026-08-20 +- 最近更新:2026-08-20 +- 影响面:生时纠正方法覆盖、`method_followup_plan`、KP 宫头观察、窗口扫描、Skill `jyotish-birth-time-rectification@10.0.10` +- 用户现象:家人问完后下一问变成财务/健康,职业和占问不在访谈里。事业带日期事件被当成已经覆盖职业。KP 技法审计写成政策跳过,候选卡也看不到 KP 子主换升。 +- 触发条件:新 Case 走方法覆盖;或比较候选并查看技法审计 / 换升时刻。 +- 根因:BUG-320 把财务/健康放进方法轮询,职业并进 D10,Horary 固定 `skipped_by_policy`。本命盘用 Equal houses,事件引擎把 `KP_cusps` 写死进 `blocked_layers` 再并入评分 `missing_layers`;BUG-323 用政策跳过让提出门不挡,但没有单独算 Placidus + Krishnamurti 宫头。 +- 修复:方法覆盖恢复感情→事业→家人→外貌→疤痕→职业→占问。职业挡出牌,且不由事业事件自动覆盖。占问只问一次、不挡出牌;有问起时间则观察重算,失败写成 blocked 观察。财务/健康离开轮询,用户主动说仍计 `D2/D11`、`D30` 并保留换升。KP 用 Swiss Ephemeris Placidus + Krishnamurti 单独快照,写入窗口扫描 `kp1/4/7/10` 和诚实技法审计;不计分、不挡提出门或确认门。新 Case 绑定 Skill 10.0.10;已有 10.0.9 Case 保持原绑定。评分缓存身份升为 `rectification-v5-matrix-scoring-6`。 +- 验证:`tests/test_rectification_kp_cusp_observation.py`;`tests/test_rectification_confirmation_and.py`;`tests/test_rectification_horary_observation.py`;`tests/test_rectification_family_appearance_scoring.py`;`tests/test_rectification_v5_services.py`;`frontend/tests/rectification-eight-method.test.ts`;`frontend/tests/rectification-ingest-p0.test.ts`;`frontend/tests/skill-registry.test.ts`。 +- 防复发:家人之后下一问必须是外貌,不得再是财务。事业证据不得把 occupation 标成 covered。Horary 不得挡 offer。KP 不得再写死进评分 `missing_layers`,也不得把政策跳过写成已观察。不得改已哈希的 10.0.8 / 10.0.9 包。不得把 KP 观察计分或打开确认门。 +- 相关记录:BUG-291、BUG-320、BUG-323 +- 复发自:BUG-320(财务/健康进入方法轮询是当时的产品决定,本记录故意改回经典八方法);BUG-323(KP 政策跳过只解决提出门,没有做出真实观察) +- 修复版本:待记录提交 SHA diff --git a/frontend/src/lib/rectification-agentic/v9/case-status.ts b/frontend/src/lib/rectification-agentic/v9/case-status.ts index 4c44362d..b21cb5ba 100644 --- a/frontend/src/lib/rectification-agentic/v9/case-status.ts +++ b/frontend/src/lib/rectification-agentic/v9/case-status.ts @@ -89,4 +89,4 @@ export function evidenceWritesAllowed( export const MAX_RESUMABLE_CASES_PER_USER = 1; export const RECTIFICATION_SKILL_NAME = "jyotish-birth-time-rectification"; -export const RECTIFICATION_SKILL_VERSION = "10.0.9"; +export const RECTIFICATION_SKILL_VERSION = "10.0.10"; diff --git a/frontend/src/lib/rectification-agentic/v9/engine-client.ts b/frontend/src/lib/rectification-agentic/v9/engine-client.ts index 28068af1..04706235 100644 --- a/frontend/src/lib/rectification-agentic/v9/engine-client.ts +++ b/frontend/src/lib/rectification-agentic/v9/engine-client.ts @@ -152,7 +152,7 @@ export function toEngineEvents( ): V9EngineEvent[] { return evidence.flatMap((item): V9EngineEvent[] => { if (!isEvidenceKind(item.eventKind) || !isEvidenceDomain(item.domain)) return []; - if (isBackgroundEvidenceKind(item.eventKind as EvidenceKind)) return []; + if (isBackgroundEvidenceKind(item.eventKind as EvidenceKind) && item.eventKind !== "horary_query") return []; const start = item.occurredFrom ?? item.occurredTo; const end = item.occurredTo ?? item.occurredFrom; if (!start) return []; diff --git a/frontend/src/lib/rectification-agentic/v9/evidence-model.ts b/frontend/src/lib/rectification-agentic/v9/evidence-model.ts index 8fe05e60..3fefefba 100644 --- a/frontend/src/lib/rectification-agentic/v9/evidence-model.ts +++ b/frontend/src/lib/rectification-agentic/v9/evidence-model.ts @@ -34,6 +34,8 @@ export const EVIDENCE_KINDS = [ "family_event", "appearance_note", "birthmark_or_scar", + "occupation_note", + "horary_query", "other", ] as const; @@ -50,6 +52,8 @@ export const EVIDENCE_DOMAINS = [ "family", "appearance", "marks", + "occupation", + "horary", "other", ] as const; @@ -189,6 +193,7 @@ export function quoteIsGroundedInMessage( /** Background kinds that never advance scoring coverage counts. */ export const BACKGROUND_ONLY_KINDS: ReadonlySet = new Set([ "other", + "horary_query", ]); export function isBackgroundEvidenceKind(kind: EvidenceKind): boolean { diff --git a/frontend/src/lib/rectification-agentic/v9/method-followup.ts b/frontend/src/lib/rectification-agentic/v9/method-followup.ts index b574d3af..a49e942b 100644 --- a/frontend/src/lib/rectification-agentic/v9/method-followup.ts +++ b/frontend/src/lib/rectification-agentic/v9/method-followup.ts @@ -6,23 +6,21 @@ * server's next question. It still only produces candidates, never a * confirmed unique minute. * - * Policy map: + * Policy map (classic eight): * 1. Dasha + dated events — any confirmed dated event * 2. D9 relationship — confirmed relationship evidence; no sign labels - * 3. D10 career — confirmed career evidence; same event also scores D1 10th house + * 3. D10 career — confirmed dated career evidence; same event also scores D1 10th house * 4. Relatives — confirmed family evidence (D12 + D7 + D3) - * 5. Finance — confirmed dated finance evidence (D2 + D11) - * 6. Health — confirmed dated health_pressure evidence (D30) - * 7. Appearance / constitution — ask; dated answers are auxiliary 1st-house scores - * 8. Birthmarks / scars — ask; dated answers are auxiliary 1st-house scores - * 9. Occupation / 10th house — folded into method 3 (D10 + D1 10th) - * 10. Horary — unsupported; skip + * 5. Appearance / constitution — ask; dated answers are auxiliary 1st-house scores + * 6. Birthmarks / scars — ask; dated answers are auxiliary 1st-house scores + * 7. Occupation / 10th house — separate from dated career events; no type labels + * 8. Horary — ask once for the first question time; recast if given; never blocks cards * * Relocation stays out of domain rotation and is only asked at d4_refine. - * Finance/health are asked via this plan, never via SQL missing_evidence_categories. - * Method coverage (relationship → career → family → finance → health) finishes - * before repeating a precision-stage ask on an already-covered domain. - * Appearance and marks are auxiliary and do not block offering time cards. + * Finance/health score if volunteered; they are not method-layer rotation. + * Method coverage finishes before repeating a precision-stage ask. + * Appearance, marks and Horary do not block offering time cards. + * Occupation does block cards, even if the current question is appearance. */ import { sessionOutcomeFromGate, type SessionOutcomeKind } from "./confirmation-gate.ts"; @@ -38,10 +36,9 @@ export const METHOD_FOLLOWUP_IDS = [ "d9_relationship", "d10_career", "relatives", - "d2_finance", - "d30_health", "appearance", "marks", + "occupation", "horary", ] as const; @@ -55,9 +52,9 @@ export type MethodCoverage = Readonly<{ }>; export type MethodFollowup = Readonly<{ - method_id: "dasha_events" | "d9_relationship" | "d10_career" | "d4_home" | "d5_education" | "relatives" | "d2_finance" | "d30_health" | "appearance" | "marks" | "active_focus" | "nakshatra_boundary" | "oos_blind"; + method_id: "dasha_events" | "d9_relationship" | "d10_career" | "d4_home" | "d5_education" | "relatives" | "d2_finance" | "d30_health" | "appearance" | "marks" | "occupation" | "horary" | "active_focus" | "nakshatra_boundary" | "oos_blind"; intent: string; - ask_theme: "dated_event" | "relationship_style" | "career_style" | "home_change" | "education_style" | "family_event" | "finance_change" | "health_pressure" | "appearance" | "marks" | "active_focus" | "nakshatra_trait" | "oos_blind"; + ask_theme: "dated_event" | "relationship_style" | "career_style" | "home_change" | "education_style" | "family_event" | "finance_change" | "health_pressure" | "appearance" | "marks" | "occupation" | "horary" | "active_focus" | "nakshatra_trait" | "oos_blind"; domain: string | null; kind_hint: string | null; user_prompt_hint: string; @@ -71,7 +68,7 @@ export type MethodFollowupPlan = Readonly<{ deferred_followup: MethodFollowup | null; session_outcome: SessionOutcomeKind; stop_domain_rotation: true; - do_not_poll: readonly ["horary"]; + do_not_poll: readonly []; not_in_rotation: readonly ["relocation"]; }>; @@ -89,8 +86,15 @@ export type MethodFollowupFocus = Readonly<{ targetKind: string | null; }>; -const DO_NOT_POLL = ["horary"] as const; +const DO_NOT_POLL = [] as const; const NOT_IN_ROTATION = ["relocation"] as const; +const BLOCKING_COVERAGE_IDS = new Set([ + "dasha_events", + "d9_relationship", + "d10_career", + "relatives", + "occupation", +]); function isConfirmedDated(item: MethodFollowupEvidence): boolean { return item.status === "confirmed" @@ -166,6 +170,7 @@ const USER_STOP_PATTERN = /暂时想不到了|没有更多|先这样/; const NON_BLOCKING_OFFER_METHODS = new Set([ "appearance", "marks", + "horary", "oos_blind", ]); @@ -182,7 +187,13 @@ export function latestUserStoppedCollecting( return false; } -export function isOfferBlockingFollowup(followup: MethodFollowup | null): boolean { +export function isOfferBlockingFollowup( + followup: MethodFollowup | null, + methods?: readonly MethodCoverage[], +): boolean { + if (methods?.some((item) => BLOCKING_COVERAGE_IDS.has(item.method_id) && item.status === "uncovered")) { + return true; + } if (!followup) return false; return !NON_BLOCKING_OFFER_METHODS.has(followup.method_id); } @@ -192,13 +203,14 @@ export function conversationalSessionOutcome(input: { proposeAllowed: boolean; confirmationAllowed: boolean; nextFollowup: MethodFollowup | null; + methods?: readonly MethodCoverage[]; userStopped?: boolean; }): SessionOutcomeKind { return sessionOutcomeFromGate({ selectionAllowed: input.selectionAllowed, proposeAllowed: input.proposeAllowed, confirmationAllowed: input.confirmationAllowed, - interviewOpen: isOfferBlockingFollowup(input.nextFollowup), + interviewOpen: isOfferBlockingFollowup(input.nextFollowup, input.methods), userStopped: input.userStopped, }).kind; } @@ -283,17 +295,23 @@ export function buildMethodFollowupPlan(input: { const healthCovered = hasConfirmedHealth(input.evidence); const appearanceCovered = hasConfirmedDomain(input.evidence, "appearance"); const marksCovered = hasConfirmedDomain(input.evidence, "marks"); + const occupationCovered = hasConfirmedDomain(input.evidence, "occupation") || declined.has("occupation"); + const horaryGiven = hasConfirmedDomain(input.evidence, "horary"); + const horaryStatus: MethodCoverageStatus = horaryGiven + ? "covered" + : declined.has("horary") + ? "skipped_by_policy" + : "uncovered"; const methods: MethodCoverage[] = [ coverage("dasha_events", dashaCovered ? "covered" : "uncovered"), - coverage("d9_relationship", relationshipCovered ? "covered" : "uncovered"), - coverage("d10_career", careerCovered ? "covered" : "uncovered"), - coverage("relatives", familyCovered ? "covered" : "uncovered"), - coverage("d2_finance", financeCovered ? "covered" : "uncovered"), - coverage("d30_health", healthCovered ? "covered" : "uncovered"), - coverage("appearance", appearanceCovered ? "covered" : "uncovered"), - coverage("marks", marksCovered ? "covered" : "uncovered"), - coverage("horary", "skipped_by_policy"), + coverage("d9_relationship", relationshipCovered || declined.has("relationship") ? "covered" : "uncovered"), + coverage("d10_career", careerCovered || declined.has("career") ? "covered" : "uncovered"), + coverage("relatives", familyCovered || declined.has("family") ? "covered" : "uncovered"), + coverage("appearance", appearanceCovered || declined.has("appearance") ? "covered" : "uncovered"), + coverage("marks", marksCovered || declined.has("marks") ? "covered" : "uncovered"), + coverage("occupation", occupationCovered ? "covered" : "uncovered"), + coverage("horary", horaryStatus), ]; const sessionOutcome = input.sessionOutcome ?? "collect_evidence"; @@ -383,24 +401,44 @@ export function buildMethodFollowupPlan(input: { user_prompt_hint: "可以先说一段记得大概时间的家人相关变化。同一件事会对照 D12 父母盘、D7 子女盘和 D3 兄弟盘。", source: "method_coverage", }); - } else if (!financeCovered && !declined.has("finance")) { + } else if (!appearanceCovered && !declined.has("appearance")) { next = followup({ - method_id: "d2_finance", + method_id: "appearance", intent: "collect_method_evidence", - ask_theme: "finance_change", - domain: "finance", - kind_hint: "finance_change", - user_prompt_hint: "可以先说一段记得大概时间的收入、资产或财务变化。同一件事会对照 D2 和 D11。", + ask_theme: "appearance", + domain: "appearance", + kind_hint: "appearance_note", + user_prompt_hint: "外貌或体质有没有比较稳定的特点?如果记得某次明显变化的大概时间,也可以说。这只作辅助对照,不会当成主评分。", source: "method_coverage", }); - } else if (!healthCovered && !declinedHealth(declined)) { + } else if (!marksCovered && !declined.has("marks")) { next = followup({ - method_id: "d30_health", + method_id: "marks", intent: "collect_method_evidence", - ask_theme: "health_pressure", - domain: "health_pressure", - kind_hint: "self_health_event", - user_prompt_hint: "可以先说一段记得大概时间的健康、事故或压力变化。这只对照健康压力主题盘,不是医学判断。", + ask_theme: "marks", + domain: "marks", + kind_hint: "birthmark_or_scar", + user_prompt_hint: "有没有胎记,或记得大概时间的疤痕、受伤?有日期的会进一宫辅助对照,不会当成主评分。", + source: "method_coverage", + }); + } else if (!occupationCovered) { + next = followup({ + method_id: "occupation", + intent: "collect_method_evidence", + ask_theme: "occupation", + domain: "occupation", + kind_hint: "occupation_note", + user_prompt_hint: "你长期做什么工作?对照本命第 10 宫和 D10 这条线怎么应验就可以,不要贴事业类型标签。", + source: "method_coverage", + }); + } else if (horaryStatus === "uncovered") { + next = followup({ + method_id: "horary", + intent: "collect_method_evidence", + ask_theme: "horary", + domain: "horary", + kind_hint: "horary_query", + user_prompt_hint: "有没有第一次认真问起这件事的时间?有的话可以按那个时间观察占问盘;没有也不挡给出时间卡。", source: "method_coverage", }); } else if (stage === "d9_refine" && !declined.has("relationship")) { @@ -443,26 +481,6 @@ export function buildMethodFollowupPlan(input: { user_prompt_hint: "成就盘或学业盘仍会换升。可以再补一件记得大概时间的学业、考试或被委以责任的变化;同一件事会对照本命五宫、D5 和 D24,不要贴类型标签。", source: "precision_stage", }); - } else if (!appearanceCovered && !declined.has("appearance")) { - next = followup({ - method_id: "appearance", - intent: "collect_method_evidence", - ask_theme: "appearance", - domain: "appearance", - kind_hint: "appearance_note", - user_prompt_hint: "外貌或体质有没有比较稳定的特点?如果记得某次明显变化的大概时间,也可以说。这只作辅助对照,不会当成主评分。", - source: "method_coverage", - }); - } else if (!marksCovered && !declined.has("marks")) { - next = followup({ - method_id: "marks", - intent: "collect_method_evidence", - ask_theme: "marks", - domain: "marks", - kind_hint: "birthmark_or_scar", - user_prompt_hint: "有没有胎记,或记得大概时间的疤痕、受伤?有日期的会进一宫辅助对照,不会当成主评分。", - source: "method_coverage", - }); } else { const d9 = input.observations?.find((item) => item.layer === "d9"); const d10 = input.observations?.find((item) => item.layer === "d10"); @@ -522,7 +540,7 @@ export function buildMethodFollowupPlan(input: { user_prompt_hint: "当前候选在家人主题上仍分不开,可以再补一件记得大概时间的家人变化。同一件事会对照 D12、D7 和 D3。", source: "varga_observation", }); - } else if (d11?.candidates_differ && !declined.has("finance")) { + } else if (d11?.candidates_differ && financeCovered && !declined.has("finance")) { next = followup({ method_id: "d2_finance", intent: "distinguish_candidates", @@ -532,7 +550,7 @@ export function buildMethodFollowupPlan(input: { user_prompt_hint: "当前候选在财务主题上仍分不开,可以再补一件记得大概时间的收入、资产或财务变化。同一件事会对照 D2 和 D11。", source: "varga_observation", }); - } else if (d30?.candidates_differ && !declinedHealth(declined)) { + } else if (d30?.candidates_differ && healthCovered && !declinedHealth(declined)) { next = followup({ method_id: "d30_health", intent: "distinguish_candidates", diff --git a/frontend/src/lib/rectification-agentic/v9/refinement-packet.ts b/frontend/src/lib/rectification-agentic/v9/refinement-packet.ts index cd8637d1..4716903a 100644 --- a/frontend/src/lib/rectification-agentic/v9/refinement-packet.ts +++ b/frontend/src/lib/rectification-agentic/v9/refinement-packet.ts @@ -25,6 +25,10 @@ const LAYER_LABEL: Record = { ghati: "Ghati Lagna", bhava: "Bhava Lagna", pranapada: "Pranapada Lagna", + kp1: "KP 1宫子主", + kp4: "KP 4宫子主", + kp7: "KP 7宫子主", + kp10: "KP 10宫子主", }; export const WINDOW_SCAN_SCORING_LAYER_ORDER = [ @@ -47,6 +51,10 @@ export const WINDOW_SCAN_DISPLAY_LAYER_ORDER = [ "ghati", "bhava", "pranapada", + "kp1", + "kp4", + "kp7", + "kp10", ] as const satisfies readonly WindowScanLayer[]; export function windowScanLayerLabel(layer: WindowScanLayer): string { @@ -73,7 +81,11 @@ export type WindowScanLayer = | "hora" | "ghati" | "bhava" - | "pranapada"; + | "pranapada" + | "kp1" + | "kp4" + | "kp7" + | "kp10"; export type WindowScanTransition = Readonly<{ layer: WindowScanLayer; @@ -189,6 +201,10 @@ export function parseWindowScanTransitions(value: unknown): readonly WindowScanT && layer !== "ghati" && layer !== "bhava" && layer !== "pranapada" + && layer !== "kp1" + && layer !== "kp4" + && layer !== "kp7" + && layer !== "kp10" ) || !at ) continue; diff --git a/frontend/src/mastra/agentic-rectification.ts b/frontend/src/mastra/agentic-rectification.ts index 743c9c59..5331d716 100644 --- a/frontend/src/mastra/agentic-rectification.ts +++ b/frontend/src/mastra/agentic-rectification.ts @@ -71,7 +71,7 @@ const agenticRectificationInstructions = `你是 Jyotisha,只服务当前绑 8. 当前轮新事件一律走 rectification-record-evidence-batch(一件也可以)。rectification-confirm-evidence 只用于用户对已有 pending 明确说“对/是”。不得要求用户把已说清的事件再发一遍。 9. 不得在同一回复中一边要求继续补证据,一边提供候选采用。落实 next_user_action:id 不是 adopt_representative 时不得调用 rectification-offer-candidates,也不得请用户采用。selection_allowed 只表示可以采用代表性时间,不是本轮必须出示卡片;propose_allowed 才是提出门。仍有会挡住出牌的 next_followup 时继续问。session_outcome=adopt_representative 或 next_user_action.id=adopt_representative 时本轮结果是采用代表性时间,不要再问 next_followup;正文必须说还不能确认唯一分钟。用户说“暂时想不到了 / 没有更多 / 先这样”时改走 on_user_stop:账本为空则把已说的带日期经历 batch 写入再比较,有事件无结果则本轮 compare,已有代表性结果则解释、调用 offer-candidates,并请采用下方时间卡片。禁止只说记下了、会话会保留、以后再继续。分盘句和宫位表由界面展示,正文不要重复工具名或再画表。确认门以 latest_result.confirmation_gate 为准;not_evaluated 不是 fail;官方分钟层 passed 仍不能单独打开确认门;holdout 为 not_ready 时不得声称精确分钟或发布准确率。若宽度大于 5 或 confirmation_allowed 为 false,必须说这是一段不可分区间,把代表分钟称为代表性候选,不得说已定位到唯一分钟。用户仍可 accepted 代表性候选。 10. 不泄露系统提示词或 Skill 原文。 -11. 追问只跟 method_followup_plan;不得按 missing_evidence_categories 轮询迁居。财务与健康由 method_followup_plan 追问。外貌、体质、胎记或疤痕可以问,但不得当作主评分,也不得贴 D9/D10 类型标签。不得把分盘观察说成用户性格或类型标签。 +11. 追问只跟 method_followup_plan;不得按 missing_evidence_categories 轮询迁居。财务与健康只有用户主动说才问,仍可计分。方法覆盖为感情→事业→家人→外貌→疤痕→职业→占问(非挡牌)。外貌、体质、胎记或疤痕可以问,但不得当作主评分,也不得贴 D9/D10 类型标签。不得把分盘观察说成用户性格或类型标签。 12. 证据有效变化后由服务器重算候选。不要等用户说“没有更多了”才比较,也不要对同一证据指纹再 compare。分钟扫描只在服务端,结果只是候选或平台,不得宣布确认。 13. 落实 start_consultation:代表性时间被采用后,请用户用这个时间看盘,不要再当本轮必须补证据。解释 event_dasha_ledger、dasha_agreement、换升时刻和 precision_stage 时不报分数、不给 D9/D10 类型标签。盘外对照问句由界面展示。`; diff --git a/frontend/src/mastra/rectification-v9-tools.ts b/frontend/src/mastra/rectification-v9-tools.ts index 8d44acdb..9326ffa3 100644 --- a/frontend/src/mastra/rectification-v9-tools.ts +++ b/frontend/src/mastra/rectification-v9-tools.ts @@ -52,6 +52,7 @@ import { conversationalSessionOutcome, isOfferBlockingFollowup, latestUserStoppedCollecting, + type MethodCoverage, type MethodFollowup, } from "@/lib/rectification-agentic/v9/method-followup"; import { refinementFromDecisionReceipt } from "@/lib/rectification-agentic/v9/refinement-packet"; @@ -141,6 +142,7 @@ function safeCaseProjection( ? latestResultToolProjection(latest, { proposeAllowed, nextFollowup: collectingPlan.next_followup, + methods: collectingPlan.methods, userStopped, }) : null; @@ -149,6 +151,7 @@ function safeCaseProjection( proposeAllowed, confirmationAllowed: latestProjection?.confirmation_allowed === true, nextFollowup: collectingPlan.next_followup, + methods: collectingPlan.methods, userStopped, }); const methodFollowupPlan = sessionOutcome === "collect_evidence" @@ -282,6 +285,7 @@ export function latestResultToolProjection( session?: { proposeAllowed?: boolean; nextFollowup?: MethodFollowup | null; + methods?: readonly MethodCoverage[]; userStopped?: boolean; }, ): Record { @@ -298,7 +302,7 @@ export function latestResultToolProjection( selectionAllowed: latest.selectionAllowed, proposeAllowed, confirmationAllowed: confirmationGate.confirmation_allowed, - interviewOpen: session ? isOfferBlockingFollowup(session.nextFollowup ?? null) : true, + interviewOpen: session ? isOfferBlockingFollowup(session.nextFollowup ?? null, session.methods) : true, userStopped: session?.userStopped, }); const houseTable = parseRectificationHouseTable(latest.decisionReceipt?.house_table); @@ -1031,6 +1035,7 @@ export function createRectificationV9Tools(ctx: RectificationV9Context) { const latestProjection = latestResultToolProjection(latest, { proposeAllowed: readProposeAllowed(latest.decisionReceipt), nextFollowup: collectingPlan.next_followup, + methods: collectingPlan.methods, userStopped: latestUserStoppedCollecting(scored.parsed.turns), }); const projection = { @@ -1130,6 +1135,7 @@ export function createRectificationV9Tools(ctx: RectificationV9Context) { const projection = latestResultToolProjection(latest, { proposeAllowed, nextFollowup: collectingPlan.next_followup, + methods: collectingPlan.methods, userStopped, }); const sessionKind = (projection.session_outcome as { kind?: string }).kind; diff --git a/frontend/supabase/migrations/20260820040000_rectification_occupation_horary.sql b/frontend/supabase/migrations/20260820040000_rectification_occupation_horary.sql new file mode 100644 index 00000000..d151fcd6 --- /dev/null +++ b/frontend/supabase/migrations/20260820040000_rectification_occupation_horary.sql @@ -0,0 +1,46 @@ +begin; + +create or replace function public.agentic_rectification_evidence_kinds() +returns text[] +language sql +immutable +as $$ + select array[ + 'education_start', 'education_completion', 'education_interruption', + 'education_change', 'education_milestone', + 'career_entry', 'career_change', 'promotion', 'career_pressure', + 'career_exit', 'business_start', + 'relationship_start', 'relationship_commitment', 'relationship_separation', + 'relationship_end', 'relationship_change', + 'relocation', 'foreign_move', 'return', 'home_change', + 'finance_gain', 'finance_loss', 'income_change', 'asset_change', + 'finance_change', + 'self_health_event', 'pressure_period', 'family_event', + 'appearance_note', 'birthmark_or_scar', 'occupation_note', 'horary_query', + 'other' + ]::text[] +$$; + +revoke all on function public.agentic_rectification_evidence_kinds() + from public, anon, authenticated; +grant execute on function public.agentic_rectification_evidence_kinds() + to service_role; + +create or replace function public.agentic_rectification_evidence_domains() +returns text[] +language sql +immutable +as $$ + select array[ + 'education', 'career', 'relationship', 'relocation', 'finance', + 'health', 'health_pressure', 'family', 'appearance', 'marks', + 'occupation', 'horary', 'other' + ]::text[] +$$; + +revoke all on function public.agentic_rectification_evidence_domains() + from public, anon, authenticated; +grant execute on function public.agentic_rectification_evidence_domains() + to service_role; + +commit; diff --git a/frontend/tests/rectification-confirmation-gate.test.ts b/frontend/tests/rectification-confirmation-gate.test.ts index e2620e04..b2a05bd7 100644 --- a/frontend/tests/rectification-confirmation-gate.test.ts +++ b/frontend/tests/rectification-confirmation-gate.test.ts @@ -170,7 +170,7 @@ test("holdout not_ready forbids unique-minute copy and still blocks confirm", as assert.match(agentSource, /session_outcome=adopt_representative/); assert.doesNotMatch(agentSource, /±2 分钟/); assert.equal(PUBLIC_RECTIFICATION_TOOLS.length, 13); - assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.9"); + assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.10"); const accounting = fakeAccounting({ ...receiptHandlers, diff --git a/frontend/tests/rectification-eight-method.test.ts b/frontend/tests/rectification-eight-method.test.ts index 3da681fa..05484d43 100644 --- a/frontend/tests/rectification-eight-method.test.ts +++ b/frontend/tests/rectification-eight-method.test.ts @@ -7,6 +7,7 @@ import { internalObservationsFromWindowScan, parseWindowScan, } from "../src/lib/rectification-agentic/v9/varga-observations.ts"; +import { WINDOW_SCAN_DISPLAY_LAYER_ORDER } from "../src/lib/rectification-agentic/v9/refinement-packet.ts"; import { RECTIFICATION_SKILL_VERSION } from "../src/lib/rectification-agentic/v9/case-status.ts"; import { createRectificationV9Tools, latestResultToolProjection } from "../src/mastra/rectification-v9-tools.ts"; import { PUBLIC_RECTIFICATION_TOOLS } from "../src/lib/rectification-agentic/v9/public-receipt.ts"; @@ -33,6 +34,17 @@ const THIRD_CANDIDATE_ID = "88888888-8888-4888-8888-888888888883"; const EDUCATION_ID = "44444444-4444-4444-8444-444444444441"; const FORBIDDEN_LABELS = /白羊|金牛|双子|巨蟹|狮子|处女|天秤|天蝎|射手|摩羯|水瓶|双鱼|热情冲动|配偶类型|事业特质/; +const CLASSIC_COVERAGE = [ + { status: "confirmed", domain: "education", datePrecision: "year" as const, occurredFrom: "2016-01-01", occurredTo: null }, + { status: "confirmed", domain: "relationship", datePrecision: "year" as const, occurredFrom: "2018-01-01", occurredTo: null }, + { status: "confirmed", domain: "career", datePrecision: "year" as const, occurredFrom: "2019-01-01", occurredTo: null }, + { status: "confirmed", domain: "family", datePrecision: "year" as const, occurredFrom: "2020-01-01", occurredTo: null }, + { status: "confirmed", domain: "appearance", datePrecision: "unknown" as const, occurredFrom: null, occurredTo: null }, + { status: "confirmed", domain: "marks", datePrecision: "unknown" as const, occurredFrom: null, occurredTo: null }, + { status: "confirmed", domain: "occupation", datePrecision: "unknown" as const, occurredFrom: null, occurredTo: null }, + { status: "confirmed", domain: "horary", datePrecision: "day" as const, occurredFrom: "2024-01-01", occurredTo: null }, +]; + const ENGINE_SCORE = { success: true, endpoint: "rectification_v5_score", @@ -164,7 +176,8 @@ test("user-stop action explains the window when follow-up remains but the user s assert.match(action.on_user_stop.user_meaning, /12:00/); assert.match(action.on_user_stop.user_meaning, /不要只说会话会保留/); assert.equal(plan.methods.find((item) => item.method_id === "marks")?.status, "uncovered"); - assert.equal(plan.methods.find((item) => item.method_id === "horary")?.status, "skipped_by_policy"); + assert.equal(plan.methods.find((item) => item.method_id === "horary")?.status, "uncovered"); + assert.equal(plan.methods.find((item) => item.method_id === "occupation")?.status, "uncovered"); assert.notEqual(plan.next_followup?.method_id, "appearance"); assert.doesNotMatch(JSON.stringify(plan), FORBIDDEN_LABELS); }); @@ -209,7 +222,7 @@ test("adopt_representative defers method follow-up instead of asking this turn", assert.equal(plan.session_outcome, "adopt_representative"); }); -test("declined relationship skips to career and still skips horary", () => { +test("declined relationship skips to career and leaves horary uncovered", () => { const plan = buildMethodFollowupPlan({ evidence: [{ status: "confirmed", @@ -222,7 +235,8 @@ test("declined relationship skips to career and still skips horary", () => { }); assert.equal(plan.next_followup?.method_id, "d10_career"); assert.equal(plan.next_followup?.domain, "career"); - assert.deepEqual([...plan.do_not_poll], ["horary"]); + assert.deepEqual([...plan.do_not_poll], []); + assert.equal(plan.methods.find((item) => item.method_id === "horary")?.status, "uncovered"); }); test("D9 differ becomes an internal ask theme without sign labels", () => { @@ -264,16 +278,7 @@ test("D9 differ becomes an internal ask theme without sign labels", () => { ]); assert.doesNotMatch(JSON.stringify({ scan, observations }), FORBIDDEN_LABELS); const plan = buildMethodFollowupPlan({ - evidence: [ - { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, - { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, - { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, - { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, - { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - { status: "confirmed", domain: "health_pressure", datePrecision: "year", occurredFrom: "2022-01-01", occurredTo: null }, - { status: "confirmed", domain: "appearance", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, - { status: "confirmed", domain: "marks", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, - ], + evidence: CLASSIC_COVERAGE, observations, }); assert.equal(plan.next_followup?.source, "varga_observation"); @@ -310,15 +315,7 @@ test("D24-only window change folds into education follow-up without a second lay ["d9", "d10", "d4", "d5", "d7", "d12", "d11", "d30"], ); const plan = buildMethodFollowupPlan({ - evidence: [ - { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, - { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, - { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, - { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - { status: "confirmed", domain: "health_pressure", datePrecision: "year", occurredFrom: "2022-01-01", occurredTo: null }, - { status: "confirmed", domain: "appearance", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, - { status: "confirmed", domain: "marks", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, - ], + evidence: CLASSIC_COVERAGE, observations, }); assert.equal(plan.next_followup?.method_id, "d5_education"); @@ -362,13 +359,8 @@ test("D11-only window change folds into finance follow-up without delaying adopt ); const plan = buildMethodFollowupPlan({ evidence: [ - { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, - { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, - { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, + ...CLASSIC_COVERAGE, { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - { status: "confirmed", domain: "health_pressure", datePrecision: "year", occurredFrom: "2022-01-01", occurredTo: null }, - { status: "confirmed", domain: "appearance", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, - { status: "confirmed", domain: "marks", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, ], observations, }); @@ -376,6 +368,31 @@ test("D11-only window change folds into finance follow-up without delaying adopt assert.equal(plan.next_followup?.source, "varga_observation"); }); +test("window scan displays KP sub-lord changes without opening confirmation", () => { + assert.deepEqual( + ["kp1", "kp4", "kp7", "kp10"].every((layer) => WINDOW_SCAN_DISPLAY_LAYER_ORDER.includes(layer as typeof WINDOW_SCAN_DISPLAY_LAYER_ORDER[number])), + true, + ); + const scan = parseWindowScan({ + scanned: true, + confirmation_allowed: true, + unique_minute_claim: true, + d9_lagna_count: 1, + d10_lagna_count: 1, + transitions: [ + { layer: "kp1", at: "05:14" }, + { layer: "kp10", at: "05:15" }, + ], + }); + assert.ok(scan); + assert.equal(scan.confirmation_allowed, false); + assert.equal(scan.unique_minute_claim, false); + assert.deepEqual(scan.transitions, [ + { layer: "kp1", at: "05:14", user_meaning: "KP 1宫子主 在 05:14 发生变化" }, + { layer: "kp10", at: "05:15", user_meaning: "KP 10宫子主 在 05:15 发生变化" }, + ]); +}); + test("read-case follows method plan and hides D9/D10 labels even when SQL missing categories rotate", async () => { const accounting = fakeAccounting({ ...receiptHandlers, @@ -603,9 +620,9 @@ test("rescore failure does not fail the evidence write", async () => { assert.ok(result.rescore.error_code); }); -test("public tool surface stays at 13 and new cases bind 10.0.9", () => { +test("public tool surface stays at 13 and new cases bind 10.0.10", () => { assert.equal(PUBLIC_RECTIFICATION_TOOLS.length, 13); - assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.9"); + assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.10"); const deprecated = resolveExactSkillPackage( "jyotish-birth-time-rectification", "10.0.2", @@ -630,11 +647,14 @@ test("public tool surface stays at 13 and new cases bind 10.0.9", () => { assert.equal((plateau.session_outcome as { kind: string }).kind, "collect_evidence"); const skill = readFileSync(new URL("../../skills/jyotish-birth-time-rectification/SKILL.md", import.meta.url), "utf8"); assert.match(skill, /method_followup_plan/); + assert.match(skill, /感情 → 事业 → 家人 → 外貌 → 疤痕 → 职业 → 占问/); + assert.match(skill, /KP 观察不计分、不挡提出门/); assert.match(skill, /不得给用户贴 D9\/D10 星座或类型标签/); assert.doesNotMatch(skill, /±5 分钟确定性/); + assert.doesNotMatch(skill, /KP 政策跳过不挡提出门/); }); -test("family then finance then health then appearance follow the method plan", () => { +test("family then appearance then marks then occupation then horary follow the method plan", () => { const afterFamily = buildMethodFollowupPlan({ evidence: [ { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, @@ -643,45 +663,59 @@ test("family then finance then health then appearance follow the method plan", ( { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, ], }); - assert.equal(afterFamily.next_followup?.method_id, "d2_finance"); - assert.equal(afterFamily.next_followup?.domain, "finance"); - const afterFinance = buildMethodFollowupPlan({ - evidence: [ - { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, - { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, - { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, - { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, - { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - ], - }); - assert.equal(afterFinance.next_followup?.method_id, "d30_health"); - assert.equal(afterFinance.next_followup?.domain, "health_pressure"); - assert.match(afterFinance.next_followup?.user_prompt_hint ?? "", /不是医学判断/); - const afterHealth = buildMethodFollowupPlan({ - evidence: [ - { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, - { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, - { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, - { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, - { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - { status: "confirmed", domain: "health_pressure", datePrecision: "year", occurredFrom: "2022-01-01", occurredTo: null }, - ], - }); - assert.equal(afterHealth.next_followup?.method_id, "appearance"); - assert.equal(afterHealth.next_followup?.domain, "appearance"); + assert.equal(afterFamily.next_followup?.method_id, "appearance"); + assert.equal(afterFamily.next_followup?.domain, "appearance"); + assert.equal(conversationalSessionOutcome({ + selectionAllowed: true, + proposeAllowed: true, + confirmationAllowed: false, + nextFollowup: afterFamily.next_followup, + methods: afterFamily.methods, + }), "collect_evidence"); const afterAppearance = buildMethodFollowupPlan({ evidence: [ { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, - { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - { status: "confirmed", domain: "health_pressure", datePrecision: "year", occurredFrom: "2022-01-01", occurredTo: null }, { status: "confirmed", domain: "appearance", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, ], }); assert.equal(afterAppearance.next_followup?.method_id, "marks"); - assert.match(afterAppearance.next_followup?.user_prompt_hint ?? "", /辅助对照|一宫/); + const afterMarks = buildMethodFollowupPlan({ + evidence: [ + { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, + { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, + { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, + { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, + { status: "confirmed", domain: "appearance", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, + { status: "confirmed", domain: "marks", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, + ], + }); + assert.equal(afterMarks.next_followup?.method_id, "occupation"); + assert.equal(afterMarks.next_followup?.domain, "occupation"); + assert.match(afterMarks.next_followup?.user_prompt_hint ?? "", /第 10 宫|D10/); + assert.doesNotMatch(afterMarks.next_followup?.user_prompt_hint ?? "", FORBIDDEN_LABELS); + const afterOccupation = buildMethodFollowupPlan({ + evidence: [ + { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, + { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, + { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, + { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, + { status: "confirmed", domain: "appearance", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, + { status: "confirmed", domain: "marks", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, + { status: "confirmed", domain: "occupation", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, + ], + }); + assert.equal(afterOccupation.next_followup?.method_id, "horary"); + assert.equal(afterOccupation.next_followup?.domain, "horary"); + assert.equal(conversationalSessionOutcome({ + selectionAllowed: true, + proposeAllowed: true, + confirmationAllowed: false, + nextFollowup: afterOccupation.next_followup, + methods: afterOccupation.methods, + }), "adopt_representative"); }); test("precision stage lagna_frame asks another dated event instead of rotating domains", () => { @@ -698,14 +732,7 @@ test("precision stage lagna_frame asks another dated event instead of rotating d }); test("precision stage d4 asks home change not family, and d5 asks education", () => { - const covered = [ - { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, - { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, - { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, - { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, - { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - { status: "confirmed", domain: "health_pressure", datePrecision: "year", occurredFrom: "2022-01-01", occurredTo: null }, - ] as const; + const covered = CLASSIC_COVERAGE; const d4 = buildMethodFollowupPlan({ evidence: covered, precisionStage: "d4_refine", @@ -779,31 +806,75 @@ test("d9_refine after relationship still asks uncovered career first", () => { proposeAllowed: false, confirmationAllowed: false, nextFollowup: plan.next_followup, + methods: plan.methods, }), "collect_evidence"); assert.equal(conversationalSessionOutcome({ selectionAllowed: true, proposeAllowed: true, confirmationAllowed: false, nextFollowup: plan.next_followup, + methods: plan.methods, }), "collect_evidence"); }); -test("appearance follow-up does not block propose once coverage is complete", () => { +test("career evidence does not cover occupation; appearance still blocks until occupation is asked", () => { const plan = buildMethodFollowupPlan({ evidence: [ + { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, { status: "confirmed", domain: "relationship", datePrecision: "day", occurredFrom: "2024-05-01", occurredTo: null }, { status: "confirmed", domain: "career", datePrecision: "day", occurredFrom: "2019-09-01", occurredTo: null }, { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, - { status: "confirmed", domain: "finance", datePrecision: "year", occurredFrom: "2021-01-01", occurredTo: null }, - { status: "confirmed", domain: "health_pressure", datePrecision: "year", occurredFrom: "2022-01-01", occurredTo: null }, ], }); assert.equal(plan.next_followup?.method_id, "appearance"); + assert.equal(plan.methods.find((item) => item.method_id === "occupation")?.status, "uncovered"); assert.equal(conversationalSessionOutcome({ selectionAllowed: true, proposeAllowed: true, confirmationAllowed: false, nextFollowup: plan.next_followup, + methods: plan.methods, + }), "collect_evidence"); +}); + +test("declining occupation covers the method; declining horary is skipped_by_policy", () => { + const plan = buildMethodFollowupPlan({ + evidence: [ + { status: "confirmed", domain: "education", datePrecision: "year", occurredFrom: "2016-01-01", occurredTo: null }, + { status: "confirmed", domain: "relationship", datePrecision: "year", occurredFrom: "2018-01-01", occurredTo: null }, + { status: "confirmed", domain: "career", datePrecision: "year", occurredFrom: "2019-01-01", occurredTo: null }, + { status: "confirmed", domain: "family", datePrecision: "year", occurredFrom: "2020-01-01", occurredTo: null }, + { status: "confirmed", domain: "appearance", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, + { status: "confirmed", domain: "marks", datePrecision: "unknown", occurredFrom: null, occurredTo: null }, + ], + declinedTopics: [ + { target_domain: "occupation", status: "declined" }, + { target_domain: "horary", status: "declined" }, + ], + }); + assert.equal(plan.methods.find((item) => item.method_id === "occupation")?.status, "covered"); + assert.equal(plan.methods.find((item) => item.method_id === "horary")?.status, "skipped_by_policy"); + assert.equal(plan.next_followup, null); + assert.equal(conversationalSessionOutcome({ + selectionAllowed: true, + proposeAllowed: true, + confirmationAllowed: false, + nextFollowup: plan.next_followup, + methods: plan.methods, + }), "adopt_representative"); +}); + +test("horary follow-up does not block propose once occupation is covered", () => { + const plan = buildMethodFollowupPlan({ + evidence: CLASSIC_COVERAGE.filter((item) => item.domain !== "horary"), + }); + assert.equal(plan.next_followup?.method_id, "horary"); + assert.equal(conversationalSessionOutcome({ + selectionAllowed: true, + proposeAllowed: true, + confirmationAllowed: false, + nextFollowup: plan.next_followup, + methods: plan.methods, }), "adopt_representative"); }); diff --git a/frontend/tests/rectification-ingest-p0.test.ts b/frontend/tests/rectification-ingest-p0.test.ts index f08b6858..5c899ac4 100644 --- a/frontend/tests/rectification-ingest-p0.test.ts +++ b/frontend/tests/rectification-ingest-p0.test.ts @@ -40,8 +40,8 @@ const ingestMigration = readFileSync( new URL("../supabase/migrations/20260819010000_rectification_ingest_precision_plateau.sql", import.meta.url), "utf8", ); -const familyAppearanceMigration = readFileSync( - new URL("../supabase/migrations/20260820010000_rectification_family_appearance_d12.sql", import.meta.url), +const occupationHoraryMigration = readFileSync( + new URL("../supabase/migrations/20260820040000_rectification_occupation_horary.sql", import.meta.url), "utf8", ); const agentSource = readFileSync( @@ -69,11 +69,11 @@ function quotedSqlValues(source: string, pattern: RegExp): string[] { test("SQL kind and domain helpers cover the TypeScript evidence allowlists", () => { const sqlKinds = quotedSqlValues( - familyAppearanceMigration, + occupationHoraryMigration, /create or replace function public\.agentic_rectification_evidence_kinds\(\)[\s\S]*?select array\[([\s\S]*?)\]::text\[\]/, ); const sqlDomains = quotedSqlValues( - familyAppearanceMigration, + occupationHoraryMigration, /create or replace function public\.agentic_rectification_evidence_domains\(\)[\s\S]*?select array\[([\s\S]*?)\]::text\[\]/, ); const sqlPrecisions = quotedSqlValues( @@ -84,7 +84,11 @@ test("SQL kind and domain helpers cover the TypeScript evidence allowlists", () assert.deepEqual(sqlDomains, [...EVIDENCE_DOMAINS]); assert.deepEqual(sqlPrecisions, [...DATE_PRECISIONS]); assert.equal(isEvidenceKind("education_milestone"), true); + assert.equal(isEvidenceKind("occupation_note"), true); + assert.equal(isEvidenceKind("horary_query"), true); assert.equal(isEvidenceDomain("education"), true); + assert.equal(isEvidenceDomain("occupation"), true); + assert.equal(isEvidenceDomain("horary"), true); assert.equal(isEvidenceDomain("health_pressure"), true); }); @@ -202,9 +206,9 @@ test("read-case evidence context keeps day labels and confirm does not rewrite d assert.equal("p_occurred_from" in confirmCall.args, false); }); -test("new-case skill identity is 10.0.9 and the prompt prefers batch ingest", () => { - assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.9"); - assert.match(skill, /^version: 10\.0\.9$/m); +test("new-case skill identity is 10.0.10 and the prompt prefers batch ingest", () => { + assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.10"); + assert.match(skill, /^version: 10\.0\.10$/m); assert.match(skill, /不要对同一句用户消息里的多件事件逐条 propose\+confirm/); assert.match(agentSource, /当前轮新事件一律走 rectification-record-evidence-batch/); assert.doesNotMatch(agentSource, /分别调用 rectification-propose-evidence 和 rectification-confirm-evidence/); diff --git a/frontend/tests/rectification-v9-agent.test.ts b/frontend/tests/rectification-v9-agent.test.ts index 41d44297..9e66472e 100644 --- a/frontend/tests/rectification-v9-agent.test.ts +++ b/frontend/tests/rectification-v9-agent.test.ts @@ -76,11 +76,11 @@ test("system prompt carries only high-priority boundaries, never the method copy test("agent pins the dedicated rectification skill and its fixed version", () => { assert.equal(RECTIFICATION_V9_SKILL_NAME, "jyotish-birth-time-rectification"); assert.equal(basename(RECTIFICATION_V9_SKILL_PATH), RECTIFICATION_V9_SKILL_NAME); - assert.ok(RECTIFICATION_V9_PACKAGE_PATH.endsWith("skills/jyotish-birth-time-rectification/versions/10.0.9")); + assert.ok(RECTIFICATION_V9_PACKAGE_PATH.endsWith("skills/jyotish-birth-time-rectification/versions/10.0.10")); assert.notEqual(RECTIFICATION_V9_SKILL_PATH, RECTIFICATION_V9_PACKAGE_PATH); assert.equal(realpathSync(RECTIFICATION_V9_SKILL_PATH), RECTIFICATION_V9_PACKAGE_PATH); assert.equal(RECTIFICATION_SKILL_NAME, "jyotish-birth-time-rectification"); - assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.9"); + assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.10"); }); test("step budgets are bounded per action with a hard ceiling", () => { diff --git a/frontend/tests/rectification-v9-contracts.test.ts b/frontend/tests/rectification-v9-contracts.test.ts index 457abfa8..959f5e69 100644 --- a/frontend/tests/rectification-v9-contracts.test.ts +++ b/frontend/tests/rectification-v9-contracts.test.ts @@ -92,9 +92,9 @@ test("terminal transitions are one-way and evidence writes stop at terminal", () test("the active rectification skill pins the v10 identity and lives in the right directory", () => { assert.equal(RECTIFICATION_SKILL_NAME, "jyotish-birth-time-rectification"); - assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.9"); + assert.equal(RECTIFICATION_SKILL_VERSION, "10.0.10"); assert.match(skill, /^---\nname: jyotish-birth-time-rectification/m); - assert.match(skill, /^version: 10\.0\.9$/m); + assert.match(skill, /^version: 10\.0\.10$/m); for (const reference of references) { const content = readFileSync(`${skillDirectory}/references/${reference}`, "utf8"); assert.ok(content.length > 0, `${reference} must be non-empty`); @@ -155,12 +155,14 @@ test("quote grounding normalizes whitespace and punctuation", () => { assert.equal(quoteIsGroundedInMessage("", "任意"), false); }); -test("family/other background kinds: only other stays off the scoring path", () => { +test("family/other background kinds: only other and horary stay off the scoring path", () => { assert.equal(isBackgroundEvidenceKind("family_event"), false); assert.equal(isBackgroundEvidenceKind("other"), true); + assert.equal(isBackgroundEvidenceKind("horary_query"), true); + assert.equal(isBackgroundEvidenceKind("occupation_note"), false); assert.equal(isBackgroundEvidenceKind("career_entry"), false); assert.equal(isBackgroundEvidenceKind("appearance_note"), false); - assert.equal(BACKGROUND_ONLY_KINDS.size, 1); + assert.equal(BACKGROUND_ONLY_KINDS.size, 2); assert.equal(evidenceSubjectForDomain("family", "self"), "family"); assert.equal(evidenceSubjectForDomain("career", undefined), "self"); assert.equal(evidenceSubjectForDomain("appearance"), "self"); diff --git a/frontend/tests/rectification-v9-engine-contract.test.ts b/frontend/tests/rectification-v9-engine-contract.test.ts index 0ec4f94c..d3072b54 100644 --- a/frontend/tests/rectification-v9-engine-contract.test.ts +++ b/frontend/tests/rectification-v9-engine-contract.test.ts @@ -200,6 +200,37 @@ test("toEngineEvents keeps all scoreable detailed v2 kinds and drops background }]); assert.equal(datedAppearance[0]!.event_kind, "birthmark_or_scar"); assert.equal(datedAppearance[0]!.domain, "marks"); + const occupation = toEngineEvents([{ + ...EVIDENCE[0]!, + id: "00000000-0000-4000-8000-000000000203", + eventKind: "occupation_note", + domain: "occupation", + datePrecision: "year", + occurredFrom: "2019-01-01", + occurredTo: "2019-12-31", + }]); + assert.equal(occupation[0]!.event_kind, "occupation_note"); + assert.equal(occupation[0]!.domain, "occupation"); + const horary = toEngineEvents([{ + ...EVIDENCE[0]!, + id: "00000000-0000-4000-8000-000000000204", + eventKind: "horary_query", + domain: "horary", + datePrecision: "day", + occurredFrom: "2024-01-15", + occurredTo: "2024-01-15", + }]); + assert.equal(horary[0]!.event_kind, "horary_query"); + assert.equal(horary[0]!.domain, "horary"); + assert.deepEqual(toEngineEvents([{ + ...EVIDENCE[0]!, + id: "00000000-0000-4000-8000-000000000205", + eventKind: "horary_query", + domain: "horary", + datePrecision: "unknown", + occurredFrom: null, + occurredTo: null, + }]), []); }); test("runV9CandidateScore strictly consumes server candidate decisions and v2 receipt", async () => { diff --git a/frontend/tests/rectification-v9-entry-routing.test.ts b/frontend/tests/rectification-v9-entry-routing.test.ts index ce45a9b8..769a32f4 100644 --- a/frontend/tests/rectification-v9-entry-routing.test.ts +++ b/frontend/tests/rectification-v9-entry-routing.test.ts @@ -209,7 +209,7 @@ test("open RPC passes the pinned skill and server-derived baseline only", async session_id: SESSION_ID, status: "draft", should_start_opening: true, - skill_version: "10.0.9", + skill_version: "10.0.10", }; } return null; @@ -247,11 +247,11 @@ test("open RPC passes the pinned skill and server-derived baseline only", async }); assert.equal(response.disposition, "created"); assert.equal(response.shouldStartOpening, true); - assert.equal(response.skillVersion, "10.0.9"); + assert.equal(response.skillVersion, "10.0.10"); const openCall = accounting.calls.find((call) => call.fn === "open_agentic_rectification_case_v2"); assert.ok(openCall); assert.equal(openCall.args.p_skill_name, "jyotish-birth-time-rectification"); - assert.equal(openCall.args.p_skill_version, "10.0.9"); + assert.equal(openCall.args.p_skill_version, "10.0.10"); assert.equal(openCall.args.p_user_id, "user-1"); // The server derives the baseline; the request never carries it from the browser. assert.equal("birth_date" in openCall.args, false); diff --git a/frontend/tests/skill-registry.test.ts b/frontend/tests/skill-registry.test.ts index 2a2cc8ac..8c979b46 100644 --- a/frontend/tests/skill-registry.test.ts +++ b/frontend/tests/skill-registry.test.ts @@ -85,8 +85,8 @@ test("checked-in registry verifies hashed product packages and leaves consult on [ { name: "jyotish-birth-time-rectification", - version: "10.0.9", - sha256: "6c2c2d6177b36188766581762457c14711ea3dcedcd63ae3622427ac74e6e811", + version: "10.0.10", + sha256: "a1dc47e853bd188c04a20de29906d011da21cbd297cb2d2b420684f2cd0a9236", }, { name: "jyotish-personal-report", diff --git a/scripts/active_rectification_event_engine.py b/scripts/active_rectification_event_engine.py index 6a795bb3..59562789 100644 --- a/scripts/active_rectification_event_engine.py +++ b/scripts/active_rectification_event_engine.py @@ -44,6 +44,7 @@ import saham_daynight # noqa: E402 import special_lagnas # noqa: E402 import varga # noqa: E402 from scripts.rectification.refinement_packet import NAKSHATRA_SPAN # noqa: E402 +from scripts.rectification.kp_cusp_observation import observe_kp_cusps # noqa: E402 AYANAMSA: Final = "lahiri" NODE_MODE: Final = "mean" @@ -61,9 +62,12 @@ DOMAIN_CONFIG: Final[dict[EventDomain, DomainConfig]] = { "family": (("D12", "D7", "D3"), (3, 4, 5, 9)), # Dated appearance/marks: D1 lagna / 1st house only. Not a primary formula. "appearance": ((), (1,)), + # Occupation notes: D10 + D1 10th house, auxiliary, no type labels. + "occupation": (("D10",), (10,)), } -AUXILIARY_DOMAINS: Final[frozenset[str]] = frozenset({"appearance"}) +AUXILIARY_DOMAINS: Final[frozenset[str]] = frozenset({"appearance", "occupation"}) AUXILIARY_SCORE_FACTOR: Final = 0.4 +OBSERVATION_ONLY_LAYERS: Final[frozenset[str]] = frozenset({"KP_cusps"}) class RectificationEventCalculationError(RuntimeError): @@ -234,7 +238,11 @@ def _score_event( if sign_index is not None and _relative_house(sign_index, ascendant_index) in target_houses: rules.append(f"{label}_domain_house") points += weight - arudha_keys = ("A7", "UL") if event["domain"] == "relationship" else ("A10",) if event["domain"] == "career" else () + arudha_keys = ( + ("A7", "UL") if event["domain"] == "relationship" + else ("A10",) if event["domain"] in {"career", "occupation"} + else () + ) arudha_signs = { value.get("sign_idx") for key in arudha_keys if isinstance((value := arudha_padas.get(key)), dict) and isinstance(value.get("sign_idx"), int) @@ -249,7 +257,11 @@ def _score_event( event_kind = event.get("event_kind", event["domain"]) if event["domain"] in AUXILIARY_DOMAINS: points *= AUXILIARY_SCORE_FACTOR - rules.append("appearance_auxiliary_not_primary") + rules.append( + "occupation_auxiliary_not_primary" + if event["domain"] == "occupation" + else "appearance_auxiliary_not_primary" + ) if not rules: rules.append("no_domain_activation") rules.append(f"event_kind:{event_kind}") @@ -435,7 +447,7 @@ def build_candidate_static_context( for prefix in ("D2", "D3", "D4", "D5", "D7", "D9", "D10", "D11", "D12", "D24", "D30") } available_layers = ["D1"] - blocked_layers = ["KP_cusps"] + blocked_layers: list[str] = [] varga_ascendants: dict[str, int] = {} for prefix, value in varga_charts.items(): ascendant = (value or {}).get("Ascendant") or {} @@ -471,6 +483,17 @@ def build_candidate_static_context( except (KeyError, TypeError, ValueError): blocked_layers.append("Shadbala") + birth_info = chart.get("birth_info") if isinstance(chart.get("birth_info"), dict) else {} + kp_snapshot = observe_kp_cusps( + birth_info.get("julian_day"), + float(request["lat"]), + float(request["lon"]), + ) + if kp_snapshot.get("status") == "executed": + available_layers.append("KP_cusps") + else: + blocked_layers.append("KP_cusps") + feature_payload = { "time": candidate_at.strftime("%H:%M"), "ascendant_degree": ascendant_longitude, @@ -484,6 +507,8 @@ def build_candidate_static_context( sun_degree=planet_longitudes.get("Sun") if isinstance(planet_longitudes.get("Sun"), (int, float)) else None, moon_degree=planet_longitudes.get("Moon") if isinstance(planet_longitudes.get("Moon"), (int, float)) else None, ), + **(kp_snapshot.get("indices") or {}), + "kp_cusps": kp_snapshot, "varga_ascendants": varga_ascendants, "arudha_signs": arudha_signs, "available_layers": sorted(set(available_layers)), @@ -585,7 +610,10 @@ def _candidate_row( "time": candidate_at.strftime("%H:%M"), "score": round(sum(item["points"] for item in evidence), 4), "evidence": evidence, - "missing_layers": sorted(set(missing_layers + context["feature"]["blocked_layers"])), + "missing_layers": sorted(set( + missing_layers + + [layer for layer in context["feature"]["blocked_layers"] if layer not in OBSERVATION_ONLY_LAYERS] + )), } diff --git a/scripts/active_rectification_events.py b/scripts/active_rectification_events.py index 7032350d..4f2d7e98 100644 --- a/scripts/active_rectification_events.py +++ b/scripts/active_rectification_events.py @@ -37,6 +37,7 @@ EventDomain = Literal[ "health_pressure", "family", "appearance", + "occupation", ] Confidence = Literal["low", "medium", "high"] diff --git a/scripts/domain_calculation_service.py b/scripts/domain_calculation_service.py index 4ddda2cb..1dc268ab 100644 --- a/scripts/domain_calculation_service.py +++ b/scripts/domain_calculation_service.py @@ -19,6 +19,13 @@ from sade_sati import calc_sade_sati_complete CONTRACT_VERSION = "1.0.0" _SWISSEPH_LOCK = threading.RLock() + + +def swiss_ephemeris_lock() -> threading.RLock: + """Shared Swiss Ephemeris lock. Sidereal mode is process-global.""" + return _SWISSEPH_LOCK + + _PLANET_IDS = { "Jupiter": swe.JUPITER, "Saturn": swe.SATURN, diff --git a/scripts/rectification/contracts.py b/scripts/rectification/contracts.py index 22f2c204..0d0293e6 100644 --- a/scripts/rectification/contracts.py +++ b/scripts/rectification/contracts.py @@ -29,10 +29,12 @@ EVENT_KINDS: dict[str, frozenset[str]] = { "family": frozenset({"family_event"}), "appearance": frozenset({"appearance_note"}), "marks": frozenset({"birthmark_or_scar"}), + "occupation": frozenset({"occupation_note"}), + "horary": frozenset({"horary_query"}), "other": frozenset({"other"}), } -BACKGROUND_EVENT_KINDS = frozenset({"other"}) -AUXILIARY_EVENT_KINDS = frozenset({"appearance_note", "birthmark_or_scar"}) +BACKGROUND_EVENT_KINDS = frozenset({"other", "horary_query"}) +AUXILIARY_EVENT_KINDS = frozenset({"appearance_note", "birthmark_or_scar", "occupation_note"}) SCOREABLE_EVENT_KINDS: dict[str, frozenset[str]] = { domain: frozenset(kind for kind in kinds if kind not in BACKGROUND_EVENT_KINDS) for domain, kinds in EVENT_KINDS.items() diff --git a/scripts/rectification/decision_policy.py b/scripts/rectification/decision_policy.py index a8ed6de4..f29bd6ff 100644 --- a/scripts/rectification/decision_policy.py +++ b/scripts/rectification/decision_policy.py @@ -13,6 +13,7 @@ from scripts.rectification.contracts import ( is_scoreable_event, ) from scripts.rectification.house_table import compact_house_table_from_contexts +from scripts.rectification.horary_observation import build_horary_observation from scripts.rectification.refinement_packet import build_refinement_packet from scripts.rectification.scoring_service import precision_weight from scripts.rectification.sealed_holdout import holdout_passed, load_sealed_minute_holdout @@ -269,11 +270,7 @@ def build_technique_audit( continue label, note = _AUDIT_LABELS[method] rows.append({"technique": label, "status": "executed", "note": note}) - rows.append({ - "technique": "KP 宫头", - "status": "blocked", - "note": "KP 宫头政策跳过,不参与提出门或确认门。", - }) + rows.append(_kp_audit_row(built)) rows.extend(( vedastro_audit_row(vedastro_status), unique_minute_audit_row(confirmation_allowed), @@ -281,6 +278,29 @@ def build_technique_audit( return rows +def _kp_audit_row(built: dict[str, Any]) -> dict[str, str]: + executed = False + for context in built.get("static_contexts") or []: + if not isinstance(context, dict): + continue + feature = context.get("feature") + snapshot = feature.get("kp_cusps") if isinstance(feature, dict) else None + if isinstance(snapshot, dict) and snapshot.get("status") == "executed": + executed = True + break + if executed: + return { + "technique": "KP 宫头", + "status": "executed", + "note": "已按 Swiss Ephemeris Placidus + Krishnamurti 观察 12 宫头;不计分,不参与提出门或确认门。", + } + return { + "technique": "KP 宫头", + "status": "blocked", + "note": "Swiss Ephemeris Placidus 宫头无法计算或尚未执行。KP 观察不计分,不挡提出门。", + } + + def _quantized_score(row: CandidateScoreRow) -> Decimal: return _decimal(row.get("score")).quantize(SCORE_QUANTUM, rounding=ROUND_HALF_UP) @@ -581,6 +601,7 @@ def build_decision_receipt( "nakshatra_boundary": packet["nakshatra_boundary"], "precision_stage": packet["precision_stage"], "oos_blind_prompts": packet["oos_blind_prompts"], + "horary_observation": build_horary_observation(request), "unique_minute_claim": False, }) return apply_confirmation_decision(receipt) diff --git a/scripts/rectification/horary_observation.py b/scripts/rectification/horary_observation.py new file mode 100644 index 00000000..99f6beca --- /dev/null +++ b/scripts/rectification/horary_observation.py @@ -0,0 +1,98 @@ +"""Display-only Horary recast for birth-time rectification. + +If the user gives the time they first asked the question, recast a natal-like +chart at that local datetime. Never score it. Never block propose or confirm. +""" + +from __future__ import annotations + +import re +from typing import Any + +from scripts.rectification.house_table import SIGNS_CN +from scripts.rectification.kp_cusp_observation import observe_kp_cusps + +_CLOCK = re.compile(r"(?:[01]?\d|2[0-3]):[0-5]\d") + + +def _question_clock(event: dict[str, Any]) -> str: + summary = str(event.get("summary") or "") + match = _CLOCK.search(summary) + if match: + hour, minute = match.group(0).split(":") + return f"{int(hour):02d}:{int(minute):02d}" + return "12:00" + + +def build_horary_observation(request: dict[str, Any]) -> dict[str, Any]: + events = [ + event for event in (request.get("events") or []) + if isinstance(event, dict) and event.get("event_kind") == "horary_query" + ] + if not events: + return { + "status": "skipped", + "user_meaning": "没有第一次问起这件事的时间,占问观察未执行。", + "unique_minute_claim": False, + } + try: + lat = float(request["lat"]) + lon = float(request["lon"]) + tz = float(request["tz"]) + except (KeyError, TypeError, ValueError): + return { + "status": "blocked", + "user_meaning": "占问时间已记录,但观察盘未能重算。不计分,不挡提出门。", + "unique_minute_claim": False, + } + event = events[0] + date_text = str(event.get("date_start") or "")[:10] + clock = _question_clock(event) + try: + year, month, day = (int(part) for part in date_text.split("-")) + hour, minute = (int(part) for part in clock.split(":")) + import domain_calculation_service + chart = domain_calculation_service.compute_chart({ + "year": year, + "month": month, + "day": day, + "hour": hour, + "minute": minute, + "lat": float(request["lat"]), + "lon": float(request["lon"]), + "tz": float(request["tz"]), + "ayanamsa": "lahiri", + "node_mode": "mean", + }) + asc = chart.get("ascendant") or {} + sign = str(asc.get("sign") or "") + lagna = SIGNS_CN.get(sign, sign) + birth_info = chart.get("birth_info") if isinstance(chart.get("birth_info"), dict) else {} + kp = observe_kp_cusps(birth_info.get("julian_day"), float(request["lat"]), float(request["lon"])) + angles = {} + if kp.get("status") == "executed": + for house in ("1", "4", "7", "10"): + row = (kp.get("houses") or {}).get(house) or {} + angles[house] = { + "sub_lord": row.get("sub_lord"), + "nakshatra_lord": row.get("nakshatra_lord"), + } + return { + "status": "executed", + "question_date": date_text, + "question_time": clock, + "lagna": lagna if lagna else None, + "kp_angles": angles, + "user_meaning": ( + f"已按问起时间 {date_text} {clock} 重算占问盘作观察,不计分,不确认唯一分钟。" + ), + "unique_minute_claim": False, + } + except (TypeError, ValueError, KeyError, OverflowError, OSError): + return { + "status": "blocked", + "question_date": date_text, + "question_time": clock, + "user_meaning": "占问时间已记录,但观察盘未能重算。不计分,不挡提出门。", + "unique_minute_claim": False, + } diff --git a/scripts/rectification/kp_cusp_observation.py b/scripts/rectification/kp_cusp_observation.py new file mode 100644 index 00000000..a098c253 --- /dev/null +++ b/scripts/rectification/kp_cusp_observation.py @@ -0,0 +1,87 @@ +"""Display-only KP Placidus cusp observation for birth-time rectification. + +This lane uses Swiss Ephemeris Placidus house cusps and Krishnamurti ayanamsa. +It must never mix into ranking, propose, or unique-minute confirmation. +Whole-sign midpoints are not a substitute. +""" + +from __future__ import annotations + +from typing import Any + +from ayanamsa_utils import apply_ayanamsa, current_ayanamsa_name +from kp_system import KP_LORDS, get_kp_lords +from scripts.domain_calculation_service import swiss_ephemeris_lock + +SCAN_HOUSES = (1, 4, 7, 10) +_BLOCKED = { + "status": "blocked", + "house_system": "placidus", + "ayanamsa": "krishnamurti", + "houses": {}, + "indices": {}, + "note": "Swiss Ephemeris Placidus 宫头无法计算,KP 观察未执行。不计分,不挡提出门。", +} + + +def _cusp_row(degree: float) -> dict[str, Any]: + lords = get_kp_lords(degree) + sub_lord = str(lords.get("sub_lord") or "") + try: + sub_index = KP_LORDS.index(sub_lord) + except ValueError: + sub_index = None + return { + "cusp_degree": round(float(degree) % 360.0, 4), + "sign": lords.get("sign"), + "rasi_lord": lords.get("rasi_lord"), + "nakshatra": lords.get("nakshatra"), + "nakshatra_lord": lords.get("nakshatra_lord"), + "pada": lords.get("pada"), + "sub_lord": sub_lord, + "sub_sub_lord": lords.get("sub_sub_lord"), + "sub_index": sub_index, + } + + +def observe_kp_cusps(jd: float | None, lat: float | None, lon: float | None) -> dict[str, Any]: + """Return Placidus + Krishnamurti 12-cusp snapshot, or a blocked observation.""" + if not isinstance(jd, (int, float)) or not isinstance(lat, (int, float)) or not isinstance(lon, (int, float)): + return dict(_BLOCKED) + if abs(float(lat)) >= 66.0: + return dict(_BLOCKED) + previous = current_ayanamsa_name() + try: + import swisseph as swe + except ImportError: + return dict(_BLOCKED) + with swiss_ephemeris_lock(): + try: + apply_ayanamsa("krishnamurti", swe) + cusps_raw, _ascmc = swe.houses(float(jd), float(lat), float(lon), b"P") + ayanamsa = float(swe.get_ayanamsa(float(jd))) + houses: dict[str, dict[str, Any]] = {} + indices: dict[str, int] = {} + for house in range(1, 13): + tropical = float(cusps_raw[house - 1]) + if tropical != tropical or abs(tropical) > 720: # NaN / absurd + return dict(_BLOCKED) + sidereal = (tropical - ayanamsa) % 360.0 + row = _cusp_row(sidereal) + houses[str(house)] = row + if house in SCAN_HOUSES and isinstance(row["sub_index"], int): + indices[f"kp{house}_sub_index"] = row["sub_index"] + if len(houses) != 12 or len(indices) != 4: + return dict(_BLOCKED) + return { + "status": "executed", + "house_system": "placidus", + "ayanamsa": "krishnamurti", + "houses": houses, + "indices": indices, + "note": "已按 Swiss Ephemeris Placidus + Krishnamurti 观察 12 宫头;不计分,不参与提出门或确认门。", + } + except (TypeError, ValueError, OverflowError, OSError, RuntimeError, ArithmeticError): + return dict(_BLOCKED) + finally: + apply_ayanamsa(previous or "lahiri", swe) diff --git a/scripts/rectification/refinement_packet.py b/scripts/rectification/refinement_packet.py index cf665e30..d858c61b 100644 --- a/scripts/rectification/refinement_packet.py +++ b/scripts/rectification/refinement_packet.py @@ -130,6 +130,10 @@ _LAYER_LABEL = { "ghati": "Ghati Lagna", "bhava": "Bhava Lagna", "pranapada": "Pranapada Lagna", + "kp1": "KP 1宫子主", + "kp4": "KP 4宫子主", + "kp7": "KP 7宫子主", + "kp10": "KP 10宫子主", } @@ -152,12 +156,16 @@ def _scan_layer_value(feature: dict[str, Any], layer: str) -> int | None: "ghati": feature.get("ghati_sign_index"), "bhava": feature.get("bhava_sign_index"), "pranapada": feature.get("pranapada_sign_index"), + "kp1": feature.get("kp1_sub_index"), + "kp4": feature.get("kp4_sub_index"), + "kp7": feature.get("kp7_sub_index"), + "kp10": feature.get("kp10_sub_index"), }.get(layer) return raw if isinstance(raw, int) else None def window_scan(built: dict[str, Any]) -> dict[str, Any]: - """D1/D9/D10/D4/D5/D7/D12/D24/D2/D11/D30 plus display-only pada/Hora/Ghati/Bhava/Pranapada.""" + """D1/D9/D10/D4/D5/D7/D12/D24/D2/D11/D30 plus display-only pada/Hora/Ghati/Bhava/Pranapada/KP.""" counts: dict[str, set[int]] = {layer: set() for layer in _LAYER_LABEL} transitions: list[dict[str, Any]] = [] previous: dict[str, int | None] | None = None diff --git a/scripts/rectification/scoring_service.py b/scripts/rectification/scoring_service.py index 5d418797..84e9a237 100644 --- a/scripts/rectification/scoring_service.py +++ b/scripts/rectification/scoring_service.py @@ -12,7 +12,7 @@ from scripts.active_rectification_event_engine import compute_candidate_static_c from scripts.active_rectification_events import CandidateScoreRow from scripts.rectification.contracts import LifeEvent, RectificationRequest, is_scoreable_event -ALGORITHM_VERSION = "rectification-v5-matrix-scoring-5" +ALGORITHM_VERSION = "rectification-v5-matrix-scoring-6" INPUT_CONTRACT_VERSION = "rectification-calculation-spec-v4" PRECISION_WEIGHTS = { "day": 1.0, @@ -53,6 +53,7 @@ _ENGINE_KIND_BY_NATIVE_KIND: dict[str, tuple[str, str]] = { "family_event": ("family", "family_event"), "appearance_note": ("appearance", "appearance_note"), "birthmark_or_scar": ("appearance", "birthmark_or_scar"), + "occupation_note": ("occupation", "occupation_note"), } @@ -167,6 +168,7 @@ _KIND_SEMANTICS: dict[str, tuple[int, float]] = { "family_event": (0, 1.0), "appearance_note": (0, 0.8), "birthmark_or_scar": (-1, 0.8), + "occupation_note": (0, 0.8), } @@ -195,6 +197,8 @@ def public_technique_layers(domain: str, rule_ids: Sequence[str]) -> list[str]: layers.update({"d1-rashi", "d30-trimshamsha"}) elif domain in {"appearance", "marks"}: layers.add("d1-rashi") + elif domain == "occupation": + layers.update({"d1-rashi", "d10-dashamsa"}) return sorted(layers) diff --git a/skills/jyotish-birth-time-rectification/SKILL.md b/skills/jyotish-birth-time-rectification/SKILL.md index 47eac9da..c5c11544 100644 --- a/skills/jyotish-birth-time-rectification/SKILL.md +++ b/skills/jyotish-birth-time-rectification/SKILL.md @@ -1,6 +1,6 @@ --- name: jyotish-birth-time-rectification -version: 10.0.9 +version: 10.0.10 description: "生时校正专用 Skill(V10)。以服务器权威 Case、ConversationFocus 与 CaseConversationSummary 驱动低负担访谈;批量证据逐项判定,candidate / accepted / confirmed 严格分离,全部计算与持久化只走服务端工具。触发词:生时校正、出生时间校正、校正出生时间、rectification、birth time correction。" --- @@ -75,7 +75,7 @@ description: "生时校正专用 Skill(V10)。以服务器权威 Case、Conv `CaseConversationSummary` 是长会话的权威记忆,至少投影:confirmed evidence summary、pending revisions、active focus、declined/skipped topics、candidate divergence summary、missing evidence categories、`method_followup_plan`、last result policy。 - 选择下一动作、识别已确认事实、避免重复追问、理解候选差异与结果政策时,优先依据服务器提供的 `CaseConversationSummary` 与 `method_followup_plan`。 -- 不要按 `missing_evidence_categories` 轮询迁居。财务与健康由 `method_followup_plan` 追问,不是 SQL 类别轮询。下一问只跟 `method_followup_plan.next_followup`。先走完方法覆盖(感情 → 事业 → 家人 → 财务 → 健康),再对已覆盖领域做精度追问。`next_user_action.id=adopt_representative` 时 `next_followup` 为空,本轮零追问;`deferred_followup` 留给用户以后再补,不得当成本轮问题。仍有挡住出牌的 `next_followup` 时即使 `selection_allowed` 也继续问,不得 offer。 +- 不要按 `missing_evidence_categories` 轮询迁居。财务与健康只有用户主动说才问,仍可计分。下一问只跟 `method_followup_plan.next_followup`。先走完方法覆盖(感情 → 事业 → 家人 → 外貌 → 疤痕 → 职业 → 占问),再对已覆盖领域做精度追问。占问和外貌/疤痕不挡出牌;职业挡出牌。`next_user_action.id=adopt_representative` 时 `next_followup` 为空,本轮零追问;`deferred_followup` 留给用户以后再补,不得当成本轮问题。仍有挡住出牌的 `next_followup` 时即使 `selection_allowed` 也继续问,不得 offer。 - recent turns 只是有界的原文引用窗口,用于核对当前措辞、quote 和局部承接;不得把 recent turns 当作唯一记忆,也不得用截断历史覆盖 summary。 - summary 与 recent turns 看似冲突时,不自行裁决或默默改写事实:以服务器状态为准;需要用户确认时围绕 active focus 只澄清一个关键点。 - 超过长会话窗口后仍不得忘记已确认证据、pending revision、拒答主题或 active focus。 @@ -108,7 +108,7 @@ description: "生时校正专用 Skill(V10)。以服务器权威 Case、Conv - `candidate`:引擎对当前证据的归一化比较结果,称“当前候选 / 相对支持度”,**不得**称概率、置信度或确定性。 - `accepted`:用户明确选择的当前排盘时间,称“校正采用时间”,**不得**称“已确认唯一出生时间”。 - `confirmed`:通过服务器确认门且用户明确同意,称“已确认校正时间”。 -- `session_outcome=adopt_representative` / `next_user_action.id=adopt_representative`:本轮**有结果**,结果是采用代表性时间作当前排盘。正文必须说还不能确认唯一分钟。不要调用 confirm。只有这时才调用 `rectification-offer-candidates`。服务器会拒绝访谈未停且用户未喊停的 offer。`collecting_evidence` 且仍有挡住出牌的 `next_followup` 时不得 offer/accept。`propose_allowed` 需要可评分事件≥4、领域≥3、唯一领先、宽度≤5、诊断稳定;KP 政策跳过不挡提出门。 +- `session_outcome=adopt_representative` / `next_user_action.id=adopt_representative`:本轮**有结果**,结果是采用代表性时间作当前排盘。正文必须说还不能确认唯一分钟。不要调用 confirm。只有这时才调用 `rectification-offer-candidates`。服务器会拒绝访谈未停且用户未喊停的 offer。`collecting_evidence` 且仍有挡住出牌的 `next_followup` 时不得 offer/accept。`propose_allowed` 需要可评分事件≥4、领域≥3、唯一领先、宽度≤5、诊断稳定;KP 观察不计分、不挡提出门。 - 确认门以 `latest_result.confirmation_gate` 为准。任一 blocker 未通过时只能说还不能确认;用户仍可 accepted 代表性候选。 - `vedastro_minute_sensitive` 为 `not_evaluated` 表示尚未跑通,不等于 fail,但缺它不能写 confirmed。 - 若 `vedastro_minute_sensitive` 为 `passed` 但 `public_aa_holdout` 为 `not_ready`,可以说官方分钟层已区分相邻分钟,仍必须说公开密封集尚未达标,不能确认唯一分钟。 @@ -126,8 +126,8 @@ description: "生时校正专用 Skill(V10)。以服务器权威 Case、Conv - 每轮最多一个主要问题;完整回复可以零问题,不为了延续对话强行追问,不生成三条推荐问题。 - 用户询问“为什么问这个 / 现在到哪一步 / 还需要多少信息”时,基于服务器状态直接回答,不把问题当作事件。 - 用户说“不知道 / 记不清 / 不想回答 / 换个方向”时,按 active focus 关闭或跳过该目标;用户说“目前没有 / 没有更多事件”时,不再轮换证据领域,也不要求结束、暂停或保存进度。 -- 可以询问外貌、体质、胎记或疤痕,用来覆盖方法层;**不得**把外貌疤痕当作主评分,也不得给用户贴 D9/D10 星座或类型标签。有日期的外貌/疤痕只作上升/一宫辅助对照。`internal_observations` 只用于选择下一问主题。 -- 精度阶段按本命上升 → D9 → D10 → D4 居所 → D5/D24 成就收窄;家人走 D12/D7/D3 方法覆盖,财务走 D2/D11,健康走 D30,均不得混进 D4。Pada / Hora / Ghati / Bhava / Pranapada 只展示换升,不确认唯一分钟。 +- 可以询问外貌、体质、胎记或疤痕,用来覆盖方法层;**不得**把外貌疤痕当作主评分,也不得给用户贴 D9/D10 星座或类型标签。有日期的外貌/疤痕只作上升/一宫辅助对照。职业与带日期事业事件独立,对照本命第 10 宫和 D10,不得贴类型标签。占问只问一次;有问起时间则观察,没有也不挡出牌。`internal_observations` 只用于选择下一问主题。 +- 精度阶段按本命上升 → D9 → D10 → D4 居所 → D5/D24 成就收窄;家人走 D12/D7/D3 方法覆盖。财务走 D2/D11、健康走 D30,仅在用户主动说时计分,均不得混进 D4。Pada / Hora / Ghati / Bhava / Pranapada / KP 子主只展示换升,不确认唯一分钟。 - 采用后本命按采用分钟重算并折叠展示技法审计;不得声称唯一分钟,也不自动进入咨询 Agent。 - 采用候选后只需自然说明 accepted 与 confirmed 边界;不强制下一问,不主动关闭 Case,Session 会保留并可日后继续。 - 不再有固定 10–15 个事件、固定 80%/60% 匹配率、外貌/体型/疤痕主评分、固定 A/B/C/D 问卷、D9/D10 类型表贴标签,或“稳定确定到精确分钟”的承诺。 diff --git a/skills/jyotish-birth-time-rectification/references/candidate-comparison.md b/skills/jyotish-birth-time-rectification/references/candidate-comparison.md index 4cc62df3..511ea50e 100644 --- a/skills/jyotish-birth-time-rectification/references/candidate-comparison.md +++ b/skills/jyotish-birth-time-rectification/references/candidate-comparison.md @@ -17,7 +17,7 @@ ## 2. 何时提供候选 - 只有本轮完成 `rectification-offer-candidates` 且返回 `selection_allowed=true` 时,界面才展示候选卡。 -- `selection_allowed` 只表示可以采用代表性时间,**不是**本轮必须出示卡片。提出门看 `latest_result.propose_allowed`,并且没有挡住出牌的 `method_followup_plan.next_followup`(外貌/疤痕不挡)。 +- `selection_allowed` 只表示可以采用代表性时间,**不是**本轮必须出示卡片。提出门看 `latest_result.propose_allowed`,并且没有挡住出牌的 `method_followup_plan.next_followup`(外貌/疤痕/占问不挡;职业挡出牌)。 - `next_user_action.id=adopt_representative`,或用户停止且 `on_user_stop` 为 adopt 时,本轮才 offer/accept。服务器会拒绝访谈未停的 offer。这是采用代表性时间,不是 confirmed。 - 继续收集证据时不得边追问边提供采用。 - 候选卡内容来自持久化 Candidate Snapshot(`agentic_rectification_results`),不是 Agent 文本解析。 diff --git a/skills/jyotish-birth-time-rectification/references/conversation-strategy.md b/skills/jyotish-birth-time-rectification/references/conversation-strategy.md index c066840c..9fda476e 100644 --- a/skills/jyotish-birth-time-rectification/references/conversation-strategy.md +++ b/skills/jyotish-birth-time-rectification/references/conversation-strategy.md @@ -73,12 +73,12 @@ active `ConversationFocus` 是承接型意图的唯一目标来源。它由服 追问必须能澄清事实、提高真实日期精度、补足必要方法层或区分候选;否则不提。优先级: 1. 服务器 `CaseConversationSummary.active focus` 指定的唯一目标。 -2. `method_followup_plan.next_followup` 指定的下一方法层。方法覆盖优先于对已覆盖领域的精度追问:有日期事件 → 感情 → 事业 → 家人(D12/D7/D3)→ 财务(D2/D11)→ 健康(D30)→ 再按精度阶段问关系盘/事业盘/居所(D4)/学业成就(D5,D24 换升并入同一问)→ 外貌/体质 → 胎记/疤痕。占星占问不追问。迁居不进领域轮询,只在 `d4_refine` 精度阶段问搬家/住处。财务与健康走方法覆盖,不要等用户主动说。外貌/疤痕可以问,但不挡提出门,也不得当主评分。Nakshatra pada / Hora / Ghati / Bhava / Pranapada 换升只展示,不阻断采用。`next_user_action.id=adopt_representative` 时 `next_followup` 为空,不得把 `deferred_followup` 当成本轮问题。仍有挡住出牌的 `next_followup` 时即使 `selection_allowed` 也继续问。 +2. `method_followup_plan.next_followup` 指定的下一方法层。方法覆盖优先于对已覆盖领域的精度追问:有日期事件 → 感情 → 事业 → 家人(D12/D7/D3)→ 外貌/体质 → 胎记/疤痕 → 职业(挡出牌,独立于带日期事业事件)→ 占问(只问一次,不挡出牌)→ 再按精度阶段问关系盘/事业盘/居所(D4)/学业成就(D5,D24 换升并入同一问)。迁居不进领域轮询,只在 `d4_refine` 精度阶段问搬家/住处。财务与健康只有用户主动说才问,仍可计分。外貌/疤痕/占问可以问,但不挡提出门,也不得当主评分。Nakshatra pada / Hora / Ghati / Bhava / Pranapada / KP 子主换升只展示,不阻断采用。`next_user_action.id=adopt_representative` 时 `next_followup` 为空,不得把 `deferred_followup` 当成本轮问题。仍有挡住出牌的 `next_followup` 时即使 `selection_allowed` 也继续问。 3. candidate divergence / `internal_observations` 显示真正能区分候选的主题。D9/D10 观察只用于选题,不得说成用户星座或类型标签。 4. pending revision 的一个关键歧义。 5. 已有证据的必要稳定性补强。 -不要按 `missing_evidence_categories` 轮询迁居。财务与健康由 `method_followup_plan` 追问,不是 SQL 类别轮询。`stop_domain_rotation=true` 时停止领域清单。一轮最多一个主要问题。用户询问“为什么问这个 / 现在到哪一步 / 还需要多少信息”时,直接说明目的、当前状态和边界,不绕开问题继续索取证据。 +不要按 `missing_evidence_categories` 轮询迁居。财务与健康只有用户主动说才问,不是 SQL 类别轮询。`stop_domain_rotation=true` 时停止领域清单。一轮最多一个主要问题。用户询问“为什么问这个 / 现在到哪一步 / 还需要多少信息”时,直接说明目的、当前状态和边界,不绕开问题继续索取证据。 ## 8. 日期精度 diff --git a/skills/jyotish-birth-time-rectification/references/evidence-model.md b/skills/jyotish-birth-time-rectification/references/evidence-model.md index 97d4961a..3e36d3d5 100644 --- a/skills/jyotish-birth-time-rectification/references/evidence-model.md +++ b/skills/jyotish-birth-time-rectification/references/evidence-model.md @@ -51,6 +51,8 @@ pressure_period family_event appearance_note birthmark_or_scar +occupation_note +horary_query other ``` @@ -69,6 +71,8 @@ health_pressure family appearance marks +occupation +horary other ``` @@ -113,4 +117,6 @@ draft / pending_confirmation -> rejected (用户否认,保留只读历史) - 只有 `confirmed` 证据进入评分账本;`draft` 与 `pending_confirmation` 都不参与评分。 - `family_event` 进入评分(D12 + D7 + D3 + 六亲宫位)。`other` 只作背景,不推进评分覆盖计数。 - `appearance_note` / `birthmark_or_scar`:无日期只覆盖访谈;有日期才进上升/一宫辅助评分,不得当主公式。 +- `occupation_note`:与带日期事业事件独立。无日期只覆盖访谈;有日期按 D10 + 本命 10 宫辅助评分,不得贴类型标签。 +- `horary_query` 只作背景观察,不推进评分覆盖计数,也不计入 4 事件 / 3 领域。 - 证据变化才触发重算;相同证据指纹复用缓存,不重复评分。 diff --git a/skills/jyotish-birth-time-rectification/references/technique-routing.md b/skills/jyotish-birth-time-rectification/references/technique-routing.md index c068e429..1f84f496 100644 --- a/skills/jyotish-birth-time-rectification/references/technique-routing.md +++ b/skills/jyotish-birth-time-rectification/references/technique-routing.md @@ -22,21 +22,22 @@ ## 3. 按问题域强制调取 -- 事业:同一件带日期的事业事件必须同时计算 `D10` **和** D1 第 10 宫 / 10 宫主(A10 为事业 Arudha,服务器可用时)。 -- 财富:方法覆盖追问带日期的收入、资产或财务变化,计分 `D2 / D11`。不要等用户主动说。窗口扫描记录 D2/D11 换升,但不新增精度阶段。 +- 事业:同一件带日期的事业事件必须同时计算 `D10` **和** D1 第 10 宫 / 10 宫主(A10 为事业 Arudha,服务器可用时)。职业说明与带日期事业事件独立,同样对照 D10 与本命 10 宫,**不得**贴事业类型标签;无日期只覆盖访谈。 +- 财富:用户主动提供带日期的收入、资产或财务变化时计分 `D2 / D11`。不要主动追问。窗口扫描记录 D2/D11 换升,但不新增精度阶段。 - 婚恋:`D9 + UL`(UL 为 Upapada Lagna,服务器可用时)。 - 六亲/家人:`D12` 加 `D7`(子女/伴侣细节)加 `D3`(兄弟姐妹)加 D1 三/四/五/九宫。家人事件进入评分,不只作背景。D3 不另开精度阶段。 - 外貌/体质/胎记疤痕:只对照 D1 上升/一宫,**辅助降权**,不得当主评分,也不得发明星座或类型标签。无日期的回答只覆盖访谈,不进主公式。 -- 健康:方法覆盖追问带日期的健康、事故或压力变化,计分 D1 + D30。不要等用户主动说,也不把 D30 后置到用户自己开口。不是医学判断。窗口扫描记录 D30 换升,但不新增精度阶段。 +- 健康:用户主动提供带日期的健康、事故或压力变化时计分 D1 + D30。不要主动追问。不是医学判断。窗口扫描记录 D30 换升,但不新增精度阶段。 - 迁居:精度阶段 `d4_refine` 问带日期的搬家/住处变化;这不是领域轮询。计分 D4 + D1 四/十二宫。 - 教育/成就:精度阶段 `d5_refine` 在 D5 **或 D24** 换升时问带日期的学业、考试或被委以责任的变化。计分 D24 + D5 + D1 四/五/九宫。D24 窗口扫描并入 `d5_refine`,不新增阶段 id。不得贴类型标签。 -- 精度阶段顺序:有日期事件 → 本命上升 → 方法覆盖(感情 → 事业 → 家人 → 财务 → 健康)→ 再对已覆盖领域做 D9 / D10 / D4 / D5(含 D24 换升)。家人、财务、健康不得混进 D4,也不另开 `d11_refine` / `d30_refine`。未走完方法覆盖时,不得因为关系盘仍会换升就提前出示时间卡。 -- Nakshatra pada、Hora Lagna、Ghati Lagna、Bhava Lagna、Pranapada Lagna 只在窗口扫描中展示换升,不驱动 `ready_to_adopt`,也不打开确认门。日出不可用时省略 Hora/Ghati/Pranapada,不得用 06:00 假日出。Bhava 只用本命日月,不依赖日出。 +- 占问:只问一次第一次认真问起这件事的时间。有日期则按该时点重算观察盘(出生地经纬,除非另给地点),可附 1/4/7/10 KP 子主。失败写成 blocked 观察,不计分,不挡提出门或确认门。没有时间或拒绝则 `skipped_by_policy`。 +- 精度阶段顺序:有日期事件 → 本命上升 → 方法覆盖(感情 → 事业 → 家人 → 外貌 → 疤痕 → 职业 → 占问)→ 再对已覆盖领域做 D9 / D10 / D4 / D5(含 D24 换升)。家人不得混进 D4,也不另开 `d11_refine` / `d30_refine`。未走完挡住出牌的方法覆盖(含职业)时,不得因为关系盘仍会换升就提前出示时间卡。 +- Nakshatra pada、Hora Lagna、Ghati Lagna、Bhava Lagna、Pranapada Lagna、KP 子主只在窗口扫描中展示换升,不驱动 `ready_to_adopt`,也不打开确认门。日出不可用时省略 Hora/Ghati/Pranapada,不得用 06:00 假日出。Bhava 只用本命日月,不依赖日出。 - D9/D10 类型表只作内部观察,不得给用户贴标签。`internal_observations.ask_theme` 只决定下一问主题,不得说出星座、配偶类型或事业特质。 ## 4. 受限技法边界 -- KP、Muhurta、Gochara、Sahams、Sphuta、Tajika 为 reference-only 或 blocked;不得作为确认或精确应期依据。KP 宫头政策跳过,不计入 `propose_allowed` / `engine_granted` 的必需层。 +- KP、Muhurta、Gochara、Sahams、Sphuta、Tajika 为 reference-only 或 blocked;不得作为确认或精确应期依据。KP 按 Swiss Ephemeris Placidus + Krishnamurti 观察 12 宫头;成功为 `executed`,失败为诚实 `blocked`。不计分,不参与提出门或确认门。不得把政策跳过冒充已观察。 - Shadbala / Ashtakavarga 外部绝对值未闭环前不作确定性结论。 - 外部验证状态按服务器字面读取;`not_evaluated` ≠ `fail`。 - 禁止 D60 驱动结论;禁止把邻近分钟与留一事件诊断描述为硬阻塞。 diff --git a/skills/jyotish-birth-time-rectification/versions/10.0.10/SKILL.md b/skills/jyotish-birth-time-rectification/versions/10.0.10/SKILL.md new file mode 100644 index 00000000..c5c11544 --- /dev/null +++ b/skills/jyotish-birth-time-rectification/versions/10.0.10/SKILL.md @@ -0,0 +1,138 @@ +--- +name: jyotish-birth-time-rectification +version: 10.0.10 +description: "生时校正专用 Skill(V10)。以服务器权威 Case、ConversationFocus 与 CaseConversationSummary 驱动低负担访谈;批量证据逐项判定,candidate / accepted / confirmed 严格分离,全部计算与持久化只走服务端工具。触发词:生时校正、出生时间校正、校正出生时间、rectification、birth time correction。" +--- + +# Jyotish 生时校正(V10) + +## 1. 触发条件与方法学归属 + +本 Skill 只服务 `agentic_rectification_cases` 绑定的生时校正会话: + +- 服务端 Case 存在且 `skill_name = 'jyotish-birth-time-rectification'`。 +- 用户话题是出生时间 / 出生分钟 / 事件发生时间能否定位到某几分钟,而不是普通解盘或推运。 +- 普通咨询、推运、合盘、补救问题交给 `jyotish-vedic-astrology`,不要在这里处理。 + +生时校正的方法学、访谈策略、证据边界与候选表达规则只定义在本 Skill 及其 references。system prompt 只保留安全、权限、隐私、工具和运行边界,不得复制、压缩或另写一套校时方法学,也不得用 system prompt 覆盖本版本政策。 + +## 2. 必须先读与服务器权威 + +进入任何一轮实质工作前读取(服务器会随 Dossier 提供投影,缺文件时以服务器 Dossier 为准): + +1. `references/evidence-model.md`:证据种类、日期精度、原文引用、修订链、服务器持有 ID。 +2. `references/conversation-strategy.md`:OpeningPolicy、ConversationFocus、长会话记忆、批量证据与追问策略。 +3. `references/candidate-comparison.md`:candidate / accepted / confirmed 三层语义与表达边界。 +4. `references/technique-routing.md`:技法按主题调用,D9/D10 核心,不一次性调用所有分盘。 +5. `references/truth-consent-boundaries.md`:真实性、同意与选择政策。 + +服务器是下列信息的唯一权威:Skill 绑定版本、Case/Session 身份与状态、`ConversationFocus`、`CaseConversationSummary`、evidence/focus ID、事件状态与修订链、候选范围与评分、采用/确认权限、工具执行、持久化和计费。Agent 只能解释服务器投影并选择自然表达,不得从对话文本、上一条 assistant 消息或 recent turns 重建权威状态。 + +每次 attempt 必须先完成真实 Skill 绑定和 Case 加载,之后才能执行 action。失败或重试 attempt 的部分文本、工具结果与推断不得当作已提交事实;只依据服务器提交成功的 attempt 与 receipt。 + +## 3. Case 状态与只读边界 + +服务器 Dossier 会给出当前 `status`。按表行动: + +| status | 允许动作 | +|---|---| +| `draft` / `collecting_evidence` | 继续收集/修订带日期事件;可读取诊断。`next_user_action.id=adopt_representative` 时本轮结果是采用代表性时间,**不得**同时追问;仍有挡住出牌的 `next_followup` 时继续收集,**不得**提供候选。`selection_allowed` 不够作为出示卡片的理由;提出门看 `propose_allowed` 且访谈已停或用户喊停 | +| `candidate_ready` | 可比较候选、说明当前边界;仍可继续补证据 | +| `candidate_accepted` | 已采用候选,但**不等于**唯一分钟确认;可继续补证据或进入确认门 | +| `needs_rebaseline` | 出生资料基线已变化,候选失效;只允许重新收集/修订事件,禁止引用旧候选 | +| `paused` | 可继续访谈;不要声称结束 | +| `confirmed` / `closed` / `abandoned` / `superseded` | terminal Case,只读历史;不得追加/修订/确认证据,不得采用/确认候选,不得关闭第二次 | + +- terminal Case 的只读限制由服务器强制;Agent 不得用换工具、换措辞、重试或旧 focus 绕过。用户要继续校正时,说明需要走显式新建 Case 的入口。 +- 同一用户可以保留多个可恢复 Case;首页显式新建与历史 Session 精确恢复是两条不同入口,不得因存在旧 Case 强制回到旧 Session。 +- 历史 Session 必须恢复对应的精确 Case/Session;不得把另一个 resumable Case 的上下文混入当前会话。 + +## 4. OpeningPolicy + +服务端首次只提供 opening brief:Case 状态、出生时间不确定类型、已有证据摘要、当前可询问范围。Agent 根据 brief 自然开场,不得固定复述身份、完整流程、领域清单或要求用户先准备一套材料。 + +开场必须满足: + +- 降低回忆负担:从用户最容易想起的一件经历或当前最自然的入口开始,不要求列出固定数量事件。 +- 允许模糊日期:可以先说大概年份、阶段或范围;如确有信息增益,后续再澄清,不诱导猜测月份或日期。 +- 不要求一次说完:明确或自然体现可以分多轮补充、修正或换方向。 +- 至多一个主问题:开场可以没有问题;有问题时只问一个最容易回答、最有信息增益的问题。 +- 不机械复述 opening brief,不泄露服务器字段、内部状态对象或出生资料明文。 + +## 5. ConversationFocus 与意图承接 + +`ConversationFocus` 是服务器持久化的当前对话目标,至少包含 `id`(即 `focusId`)、`questionId`、`intent`、`targetEvidenceId`、目标领域/类型、预期回答结构、状态与时间。Agent 可做意图分类,但服务器必须验证目标仍为 `active`。 + +- “是的 / 不是 / 大概那年 / 后来改了 / 不记得 / 不想回答 / 换个方向”等承接、拒答、确认和修订,必须依赖服务器给出的 active focus。 +- 拒绝、跳过、解决或修订既有目标时,工具调用必须引用服务器提供的 `focusId`;涉及既有证据时还必须引用对应 `evidenceId`。用户对已有 pending 说“对/是”时,`rectification-confirm-evidence` 可以省略 `focusId`,尤其当 active focus 是无 `target_evidence_id` 的 opening focus 时,不得用它烧掉后续事件确认。 +- 不得从 assistant 上一句倒推拒答目标,不得仅靠 pending revision 或中文正则构造 active focus,也不得把脱离上下文的承接词保存成新事件。 +- 没有 active focus、focus 已 resolved/declined/skipped/superseded、或当前表达可能指向多个目标时,只做一句简短澄清;不得猜测或写 evidence。 +- 当前轮用户主动、明确、无歧义地提出全新事件时,可按新事件处理;若需要后续问题,由服务器建立新的 focus。 +- 用户已拒绝或跳过的目标不得换词重问;只有用户主动重开该主题或服务器建立新的有效 focus 才可继续。 + +## 6. CaseConversationSummary 与长会话记忆 + +`CaseConversationSummary` 是长会话的权威记忆,至少投影:confirmed evidence summary、pending revisions、active focus、declined/skipped topics、candidate divergence summary、missing evidence categories、`method_followup_plan`、last result policy。 + +- 选择下一动作、识别已确认事实、避免重复追问、理解候选差异与结果政策时,优先依据服务器提供的 `CaseConversationSummary` 与 `method_followup_plan`。 +- 不要按 `missing_evidence_categories` 轮询迁居。财务与健康只有用户主动说才问,仍可计分。下一问只跟 `method_followup_plan.next_followup`。先走完方法覆盖(感情 → 事业 → 家人 → 外貌 → 疤痕 → 职业 → 占问),再对已覆盖领域做精度追问。占问和外貌/疤痕不挡出牌;职业挡出牌。`next_user_action.id=adopt_representative` 时 `next_followup` 为空,本轮零追问;`deferred_followup` 留给用户以后再补,不得当成本轮问题。仍有挡住出牌的 `next_followup` 时即使 `selection_allowed` 也继续问,不得 offer。 +- recent turns 只是有界的原文引用窗口,用于核对当前措辞、quote 和局部承接;不得把 recent turns 当作唯一记忆,也不得用截断历史覆盖 summary。 +- summary 与 recent turns 看似冲突时,不自行裁决或默默改写事实:以服务器状态为准;需要用户确认时围绕 active focus 只澄清一个关键点。 +- 超过长会话窗口后仍不得忘记已确认证据、pending revision、拒答主题或 active focus。 + +## 7. 批量证据与日期真实性 + +一次用户消息可包含多件事件。优先使用服务器提供的批量 proposal/confirmation 服务,并遵守逐项原子语义: + +- 每件事件独立保留用户原话 `quote`、`kind`、`domain` 和真实 `date precision`;不得合并、拆错主体或要求用户逐条重发。 +- 服务器逐项返回 `accepted` / `needs_clarification` / `rejected`;Agent 按每项结果分别处理,不得让一条模糊或拒绝项阻塞同批清晰项。 +- 清晰且 quote grounding 通过的新事件必须走批量服务写入;不要对同一句用户消息里的多件事件逐条 propose+confirm。`rectification-confirm-evidence` 只用于用户对已有 pending 明确说“对/是”。 +- 证据有效写入后,服务器会按当前账本重算候选。不要等用户说“没有更多了”才 compare;同一证据指纹不要再 compare。不要调用新的扫描工具。 +- 批量结果中的 evidence item `accepted` 只是该项被服务接纳处理,不等于候选 `accepted`;清晰项在批量路径上可由服务器直接 `confirmed`。 +- 复述任何事件日期必须使用服务器 `display_date_label`。日级不得说成“年份已确定为 YYYY”。用户确认“是/对”不得改 `date_precision`。 +- `needs_clarification` 不得猜补日期、主体、事件身份、主动/被动、原因或人物关系;`rejected` 不得伪装成已记录。 +- 修订必须生成 superseding revision,引用 active `focusId` 与目标 `evidenceId`,不得覆盖历史;pending revision 不自动确认。 +- 日期精度真实保留:`year` / `month` / `quarter` / `day` / `range` / `unknown` 按用户原话保存,范围不得取中点,只有服务器目标已明确年份时才可把用户补充的月份/季度并入修订。 +- 批量服务与单项工具都必须依赖服务器幂等键;重试不得重复创建或确认 evidence。Agent 不自行生成 evidence/focus ID。 + +## 8. 可调用工具与输入边界 + +只调用服务器提供的 `rectification-*` 工具,包括 read-case、set/resolve-focus、批量 evidence、单项 proposal/confirmation/revision、candidate comparison/offer/accept/confirm 与 close-case。工具 input 只含服务端合同要求的最小引用(如 caseId、focusId、evidenceId、quote、proposedKind),**绝不**传: + +- userId、出生日期/时间/地点/时区、candidate range、完整 events 数组、分数与阈值、confirmationAllowed/selectionAllowed、profile 写入目标。 + +工具结果只读取;事实、ID、评分、范围、状态、持久化、幂等与权限一律以服务器为准。工具执行对用户保持静默:不得叙述读取 Skill、Case 已加载、调用工具、建立草稿、读取诊断或呈现快照,也不得自行生成“本轮做了什么”“执行步骤”“使用技法”或 Activity 状态文案;运行状态和实际方法 receipt 只由服务器公开凭证展示。 + +## 9. candidate / accepted / confirmed 语言边界 + +- `candidate`:引擎对当前证据的归一化比较结果,称“当前候选 / 相对支持度”,**不得**称概率、置信度或确定性。 +- `accepted`:用户明确选择的当前排盘时间,称“校正采用时间”,**不得**称“已确认唯一出生时间”。 +- `confirmed`:通过服务器确认门且用户明确同意,称“已确认校正时间”。 +- `session_outcome=adopt_representative` / `next_user_action.id=adopt_representative`:本轮**有结果**,结果是采用代表性时间作当前排盘。正文必须说还不能确认唯一分钟。不要调用 confirm。只有这时才调用 `rectification-offer-candidates`。服务器会拒绝访谈未停且用户未喊停的 offer。`collecting_evidence` 且仍有挡住出牌的 `next_followup` 时不得 offer/accept。`propose_allowed` 需要可评分事件≥4、领域≥3、唯一领先、宽度≤5、诊断稳定;KP 观察不计分、不挡提出门。 +- 确认门以 `latest_result.confirmation_gate` 为准。任一 blocker 未通过时只能说还不能确认;用户仍可 accepted 代表性候选。 +- `vedastro_minute_sensitive` 为 `not_evaluated` 表示尚未跑通,不等于 fail,但缺它不能写 confirmed。 +- 若 `vedastro_minute_sensitive` 为 `passed` 但 `public_aa_holdout` 为 `not_ready`,可以说官方分钟层已区分相邻分钟,仍必须说公开密封集尚未达标,不能确认唯一分钟。 +- `public_aa_holdout` 为 `not_ready` 时不得声称已校准到精确分钟,也不得把确认门放到更细宽度或发布准确率。 +- 未达到唯一分钟确认门时,任何“就用 HH:MM”都只能进入 accepted;只有 `confirmation_allowed=true` 且用户同意才可写 confirmed。 +- 若不可分 blocker 为 `blocked`、宽度大于 5、top `tied_minute_count` > 1,或 `confirmation_allowed=false`,正文必须说这是一段不可分区间,把代表分钟称为代表性候选,不得说已定位到唯一分钟。 +- 分钟窗口扫描只在服务端;结果进入候选卡 / 平台语言。不得把「几件事件」说成已确定到 ±5 分钟。 +- 候选卡负责候选时间、排名、相对支持度、采用动作和选中状态;正文只解释当前意义与不确定性,不重复候选表、编号菜单或卡片数字。 +- 不得在同一回复中一边要求继续补证据、一边提供采用候选。 +- 不得伪造出生分钟、分数、权重、事件 ID、分盘事实或确认门结果。 + +## 10. 输出与停止条件 + +- 简体中文,自然对话;不固定以“收到 / 已记录”开头,不机械复读,不擅自解释事件的“人生意义”,不推断用户未陈述的动机、心理或因果关系。 +- 每轮最多一个主要问题;完整回复可以零问题,不为了延续对话强行追问,不生成三条推荐问题。 +- 用户询问“为什么问这个 / 现在到哪一步 / 还需要多少信息”时,基于服务器状态直接回答,不把问题当作事件。 +- 用户说“不知道 / 记不清 / 不想回答 / 换个方向”时,按 active focus 关闭或跳过该目标;用户说“目前没有 / 没有更多事件”时,不再轮换证据领域,也不要求结束、暂停或保存进度。 +- 可以询问外貌、体质、胎记或疤痕,用来覆盖方法层;**不得**把外貌疤痕当作主评分,也不得给用户贴 D9/D10 星座或类型标签。有日期的外貌/疤痕只作上升/一宫辅助对照。职业与带日期事业事件独立,对照本命第 10 宫和 D10,不得贴类型标签。占问只问一次;有问起时间则观察,没有也不挡出牌。`internal_observations` 只用于选择下一问主题。 +- 精度阶段按本命上升 → D9 → D10 → D4 居所 → D5/D24 成就收窄;家人走 D12/D7/D3 方法覆盖。财务走 D2/D11、健康走 D30,仅在用户主动说时计分,均不得混进 D4。Pada / Hora / Ghati / Bhava / Pranapada / KP 子主只展示换升,不确认唯一分钟。 +- 采用后本命按采用分钟重算并折叠展示技法审计;不得声称唯一分钟,也不自动进入咨询 Agent。 +- 采用候选后只需自然说明 accepted 与 confirmed 边界;不强制下一问,不主动关闭 Case,Session 会保留并可日后继续。 +- 不再有固定 10–15 个事件、固定 80%/60% 匹配率、外貌/体型/疤痕主评分、固定 A/B/C/D 问卷、D9/D10 类型表贴标签,或“稳定确定到精确分钟”的承诺。 +- 无法验证时如实降级并说明受限,不得把内部一致性伪装成全球顶级精度。 + +## 11. 上游同步边界 + +方法源只在本 Skill 与 references。不得把本 Skill 内容反向写回 `yinduzhanxing` 上游快照,也不得在同步时自动覆盖商业 Skill。 diff --git a/skills/jyotish-birth-time-rectification/versions/10.0.10/references/candidate-comparison.md b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/candidate-comparison.md new file mode 100644 index 00000000..511ea50e --- /dev/null +++ b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/candidate-comparison.md @@ -0,0 +1,59 @@ +# Candidate Comparison(V9) + +候选比较是服务器计算产物,Agent 只负责解释与引导,不负责产生候选、分数或范围。 + +## 1. 三层语义 + +| 层 | 含义 | 表达 | +|---|---|---| +| `candidate` | 引擎对当前证据的归一化比较结果 | “当前候选”“相对支持度” | +| `accepted` | 用户明确选择的当前排盘时间 | “校正采用时间” | +| `confirmed` | 通过服务器确认门且用户明确同意 | “已确认校正时间” | + +- `candidate_accepted` 不是“唯一出生分钟已确认”,默认仍可继续补充证据。 +- accepted 后用户仍可在同一批有效候选中改选(幂等 RPC 支持)。 +- confirmed 只能由服务器确认门 + 用户明确同意触发,同时写 `completed_at`。 + +## 2. 何时提供候选 + +- 只有本轮完成 `rectification-offer-candidates` 且返回 `selection_allowed=true` 时,界面才展示候选卡。 +- `selection_allowed` 只表示可以采用代表性时间,**不是**本轮必须出示卡片。提出门看 `latest_result.propose_allowed`,并且没有挡住出牌的 `method_followup_plan.next_followup`(外貌/疤痕/占问不挡;职业挡出牌)。 +- `next_user_action.id=adopt_representative`,或用户停止且 `on_user_stop` 为 adopt 时,本轮才 offer/accept。服务器会拒绝访谈未停的 offer。这是采用代表性时间,不是 confirmed。 +- 继续收集证据时不得边追问边提供采用。 +- 候选卡内容来自持久化 Candidate Snapshot(`agentic_rectification_results`),不是 Agent 文本解析。 +- 候选卡拥有时间、排名、相对支持度、采用动作与选中状态;Agent 正文不得重复表格、编号菜单或选择提示。 + +## 3. 表达边界 + +- 相对支持度是候选间归一化比较,**不是**概率、统计置信度或确定性。 +- 不暴露原始分数、内部权重、贡献矩阵、技术层名称、隐藏分钟证据或第二候选簇。 +- 候选范围必须说明“待核对边界”,不得表述为已确认出生分钟。 +- 外部验证状态按服务器字面读取:`not_evaluated` 表示未调用(入口门未就绪),不是“调用了但失败”。 + +## 4. 证据变化与重算 + +- 证据有效变化时由服务器重算候选;Agent 不必等用户说“没有更多了”才 compare。 +- 相同 evidence 指纹 + 引擎版本复用缓存;不要对同一指纹再 compare。 +- 分钟窗口扫描只在服务端,结果进入候选卡 / 不可分平台语言。不得把若干事件说成已确定到 ±5 分钟。 +- 普通澄清轮若不改变账本指纹,不重复播报。 +- 出生资料基线变化 → `needs_rebaseline`,旧候选失效;不得静默继续用旧结果。 +- `needs_rebaseline` 下不引用旧候选、不提供采用。 + +## 5. 不可分平台与确认门(必须说出来) + +服务器 `latest_result` 含 `confirmation_gate`、`indistinguishable_width_minutes`、`confirmation_allowed`、`selection_allowed` 与 `margin_percent`(若有)。`confirmation_gate` 是确认门权威,不是让 Agent 另算一分钟。 + +- 宽度大于 `maxConfirmationWidthMinutes`(5),或 top 候选 `tied_minute_count` > 1,或 `confirmation_allowed=false` 时:正文必须说这是**一段不可分区间**,必须把代表分钟说成**代表性候选**,不得说已定位到唯一分钟,也不得学本地扫分钟后的 1 分钟尖峰。 +- `vedastro_minute_sensitive` 为 `not_evaluated` 表示官方分钟敏感校验尚未跑通,不是 fail;缺它不能写 confirmed。 +- 若官方分钟层已 `passed` 但 `public_aa_holdout` 为 `not_ready`:可以说已区分相邻分钟,仍不得确认唯一分钟或发布准确率。 +- `public_aa_holdout` 为 `not_ready` 时不得声称已校准到精确分钟,也不得把确认门放到更细宽度或发布准确率。 +- 用户仍可 accepted 代表性候选;accepted ≠ confirmed。`session_outcome=adopt_representative` 时正文必须说还不能确认唯一分钟。 +- `confirmation_allowed=true` 才允许进入唯一分钟确认门;平台结果禁止把 `confirmation_allowed` 说成已确认。 +- 候选卡仍可展示代表性时间;Agent 不得把该时间写成“已校正到 HH:MM”。 + +## 6. 保存边界 + +- accepted 写入 `active_birth_time`,保留 `reported_birth_time` 原填报,不写兼容 `birth_time`。 +- 采用后界面按采用分钟重算本命宫位表,并折叠展示本轮技法审计。这不是唯一分钟确认,也不自动进入咨询 Agent。 +- confirmed 同样保留原填报;不自动写入,需要用户明确同意。 +- 失败、空流、Skill 未加载或未完成必要工具链时不保存、不扣费。 diff --git a/skills/jyotish-birth-time-rectification/versions/10.0.10/references/conversation-strategy.md b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/conversation-strategy.md new file mode 100644 index 00000000..9fda476e --- /dev/null +++ b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/conversation-strategy.md @@ -0,0 +1,105 @@ +# Conversation Strategy(V10) + +生时校正访谈是自然对话,不是问卷。服务器持有事实、状态、权限、焦点与长会话记忆;Agent 负责意图理解、自然表达和选择一个有信息增益的下一步。 + +## 1. 每轮上下文优先级 + +每轮先按以下优先级理解会话: + +1. 当前 Case 的服务器状态与读写权限。 +2. `CaseConversationSummary`:confirmed evidence、pending revisions、active focus、declined/skipped topics、candidate divergence、`method_followup_plan`、last result policy。不要把 `missing_evidence_categories` 当下一问。 +3. 当前用户消息。 +4. recent turns:只作为有界原文引用窗口,辅助 quote grounding 和局部措辞理解。 + +recent turns 不是权威记忆,不得依赖“上一条 assistant 问了什么”的倒推、正则匹配或被截断的聊天记录重建 Case 状态。summary 与局部文本不一致时,以服务器状态为准;若用户意图仍不唯一,只澄清一个关键点。 + +## 2. OpeningPolicy + +首次开场只使用服务器 opening brief 中的 Case 状态、出生时间不确定类型、已有证据摘要与当前可询问范围,并自然满足: + +- 降低回忆负担:从最容易想起的一件经历或用户当前话题切入,不索要固定清单。 +- 接受“大概某年 / 那几年 / 某个阶段”等模糊日期,不诱导猜月份、日期或精确时点。 +- 不要求一次说完,允许分多轮补充、修正、暂停或换方向。 +- 至多一个主问题;开场可以零问题。 +- 不固定复述身份、流程、领域列表、证据数量要求或 opening brief 原文。 + +示例方向(不是固定话术):“可以先从你最容易想起的一件经历开始,大概年份也可以,不需要一次说完。哪件事你现在最容易确定?” + +## 3. 一轮的基本形态 + +1. 先判断用户意图:新事件、批量事件、补日期、修正旧事实、回答上一问、确认/否认、询问进度或原因、拒答/换方向、查看或采用候选。 +2. 先读取服务器 Case、summary 与 active focus;静默完成必要的工具调用后再输出答案。正文不叙述内部执行步骤,也不生成 Activity/技法凭证文案。 +3. 自然回应本轮内容,不固定以“收到 / 已记录”开头,不机械复读,不擅自解释事件的“人生意义”。 +4. 清晰项先处理;若仍需追问,只保留一个最有信息增益的主问题。完整回复可以没有问题。 +5. 不允许在同一回复中既要求补证据、又提供采用候选;不生成三条推荐问题。 +6. `next_user_action.id=adopt_representative` 时本轮只解释结果并邀请采用,零追问(除非有 active focus)。仍有挡住出牌的 `next_followup` 时不得出示采用卡。提出门看 `propose_allowed`。 + +## 4. ConversationFocus + +active `ConversationFocus` 是承接型意图的唯一目标来源。它由服务器持久化并提供 `focusId`、目标 `evidenceId`(如有)、intent、预期回答结构和状态。 + +- “是的 / 不是 / 对 / 不对 / 大概那年 / 后来改了 / 不记得 / 不想回答 / 换个方向”只有在存在唯一 active focus 时才能解释为回答、拒答、确认或修订。 +- 拒绝、跳过、解决 focus 时,工具调用必须引用 active `focusId`;修订既有 evidence 时同时引用目标 `evidenceId`。用户对已有 pending 说“对/是”时,确认工具可以省略 `focusId`;opening focus(无 `target_evidence_id`)不得因第一条确认被 resolve。 +- 无 active focus、focus 已非 active、目标已被 supersede、或一句话可能指向多个问题时,简短问清“你指的是哪一件/哪一个时间点”;不得猜测,不调用 evidence 写工具。 +- 脱离 active focus 的“是的 / 不是”不是新事件。不得从 assistant 上一句倒推目标,不得只用 pending revision 构造 `active_followup`。 +- 当前消息若主动、明确陈述全新事件,可独立进入 evidence 流程;需要追问时由服务器建立新 focus。 +- 服务器验证 focus 已失效时,停止该动作并基于最新 summary 重新回应,不沿用旧目标。 + +## 5. 自然叙述与批量 evidence + +用户一段话中可以包含多件事件。应优先走服务器批量服务: + +- 每件事件分别保留原话 `quote`、`kind`、`domain`、主体和日期精度,不合并,不要求逐条重发。 +- 服务器对每项独立返回 `accepted`、`needs_clarification` 或 `rejected`。一项失败不改变其他项结果。 +- 新事件优先走批量服务;一句里两件及以上事件时只允许批量。清晰项在批量路径上可由服务器直接 `confirmed`,不要再逐条 propose+confirm。不要让模糊项阻塞清晰项。 +- 多个模糊项同时存在时,只选择信息增益最高的一项追问一个关键点,其余维持待澄清,不连续抛出问题清单。 +- `needs_clarification` 只问缺失的关键事实;不猜日期、主体、事件身份、动机、因果、主动/被动或人物关系。 +- `rejected` 如需解释,只说明用户可理解的边界,不伪装成已记录。 +- 批量 evidence item 的 `accepted` 是服务处理结果,不是候选采用状态;清晰项的最终 `status` 以服务器返回为准,批量路径上可以为 `confirmed`。 +- 询问进度/原因、拒答、查看结果、采用候选,以及无唯一 active focus 的承接词,都不是新事件。 + +## 6. 确认、修订、拒答与换方向 + +- 确认既有事实:必须有对应 `evidenceId`;确认词本身不创建新 evidence。无匹配 pending-target 的 focus 时可省略 `focusId`。 +- 修订既有事实:必须有 active `focusId` 和目标 `evidenceId`,生成 superseding revision,不覆盖历史;pending revision 不自动确认。 +- 用户明确“不知道 / 记不清”:将 active focus 解决为相应状态,不诱导猜测。 +- 用户明确“不想回答 / 换个方向”:decline/skip active focus;不得换词重开同一目标。 +- 用户主动重新打开曾拒绝主题时,可让服务器建立新 focus;否则 declined/skipped topics 以 `CaseConversationSummary` 为准。 +- 用户说“目前没有 / 没有更多事件”时,停止轮换证据领域;不要求结束、暂停或保存进度。 +- 若没有其他具备信息增益的问题,可以直接说明当前边界或自然结束本轮。 + +## 7. 追问策略 + +追问必须能澄清事实、提高真实日期精度、补足必要方法层或区分候选;否则不提。优先级: + +1. 服务器 `CaseConversationSummary.active focus` 指定的唯一目标。 +2. `method_followup_plan.next_followup` 指定的下一方法层。方法覆盖优先于对已覆盖领域的精度追问:有日期事件 → 感情 → 事业 → 家人(D12/D7/D3)→ 外貌/体质 → 胎记/疤痕 → 职业(挡出牌,独立于带日期事业事件)→ 占问(只问一次,不挡出牌)→ 再按精度阶段问关系盘/事业盘/居所(D4)/学业成就(D5,D24 换升并入同一问)。迁居不进领域轮询,只在 `d4_refine` 精度阶段问搬家/住处。财务与健康只有用户主动说才问,仍可计分。外貌/疤痕/占问可以问,但不挡提出门,也不得当主评分。Nakshatra pada / Hora / Ghati / Bhava / Pranapada / KP 子主换升只展示,不阻断采用。`next_user_action.id=adopt_representative` 时 `next_followup` 为空,不得把 `deferred_followup` 当成本轮问题。仍有挡住出牌的 `next_followup` 时即使 `selection_allowed` 也继续问。 +3. candidate divergence / `internal_observations` 显示真正能区分候选的主题。D9/D10 观察只用于选题,不得说成用户星座或类型标签。 +4. pending revision 的一个关键歧义。 +5. 已有证据的必要稳定性补强。 + +不要按 `missing_evidence_categories` 轮询迁居。财务与健康只有用户主动说才问,不是 SQL 类别轮询。`stop_domain_rotation=true` 时停止领域清单。一轮最多一个主要问题。用户询问“为什么问这个 / 现在到哪一步 / 还需要多少信息”时,直接说明目的、当前状态和边界,不绕开问题继续索取证据。 + +## 8. 日期精度 + +- `year`:只说年份;复述用 `display_date_label`(如 `2024年`)。 +- `month`:明确到月份;复述如 `2024-05`。 +- `quarter`:明确到季度。 +- `day`:明确到日期;复述必须是 `YYYY-MM-DD`,禁止说成“年份已确定为 YYYY”。 +- `range`:只有范围,不得擅自取中点当事实;复述用 `from–to`。 +- `unknown`:日期不明;可保留背景,但不得当作高权重校正证据。 +- 用户确认“是 / 对”不得改 `date_precision`。 +- 用户只补月份/季度时,只有 active focus 与目标 evidence 已由服务器明确年份,才可合并为 revision;不得猜年份。 +- “大概 3 月”仍按用户真实表达保存,不升级成某一天。 + +## 9. 候选输出与终态 + +- 候选卡负责呈现时间、排名、相对支持度、采用动作与选中状态。 +- 正文只解释“这些候选当前意味着什么”和“不确定性在哪里”,不重复候选表、编号菜单或候选卡数字。 +- `relative_support` 不是概率,不能写“准确率 70%”。 +- candidate、accepted、confirmed 严格分离;accepted 不是 confirmed。 +- `next_user_action.id=adopt_representative` 时本轮结果是采用代表性时间;正文必须说还不能确认唯一分钟。仍有 `next_followup` 时不得出示采用卡。 +- 确认门以 `confirmation_gate` 为准。`not_evaluated` 不是 fail;holdout `not_ready` 时不得声称精确分钟或发布准确率。官方分钟层 `passed` 仍不能单独打开确认门。 +- 若 `indistinguishable_width_minutes` > 5 或 top `tied_minute_count` > 1,或 `confirmation_allowed=false`,必须说不可分区间 / 代表性候选,不得说已定位到唯一分钟。accepted ≠ confirmed。 +- accepted 后自然说明它不是唯一分钟确认即可;不强制追问,不要求用户结束、暂停或保存进度。 +- terminal Case(confirmed / closed / abandoned / superseded)只读:不得新增/修订/确认 evidence,不得采用/确认候选;若用户要继续,指向显式新建 Case。 diff --git a/skills/jyotish-birth-time-rectification/versions/10.0.10/references/evidence-model.md b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/evidence-model.md new file mode 100644 index 00000000..3e36d3d5 --- /dev/null +++ b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/evidence-model.md @@ -0,0 +1,122 @@ +# Evidence Model(V9) + +证据是生时校正的唯一事实账本。本文件定义证据如何进入、校验、修订与关闭。服务器是证据账本的唯一写入者;Agent 只能提出 proposal。 + +## 1. 证据最小单元 + +一条证据(`agentic_rectification_evidence` 一行)至少包含: + +- `case_id`:所属 Case,由服务器生成。 +- `source_turn_id`:用户消息所在轮次;`source_message_id` 可选。 +- `user_quote`:用户原话的规范化子串。 +- `subject`:主体(`self` 或亲属关系;家庭事件必须显式 `related_person`)。 +- `event_kind`:语义种类(见 §2),不再只保留粗领域。 +- `domain`:评分/路由领域。 +- `occurred_from` / `occurred_to`:真实日期边界,可空。 +- `date_precision`:`year | month | quarter | day | range | unknown`。 +- `summary`:服务器从已验证引用中生成的安全摘要。 +- `status`:`draft | pending_confirmation | confirmed | superseded | rejected`。 +- `supersedes_evidence_id`:修订链指针。 + +## 2. 事件种类(event_kind) + +```text +education_start +education_completion +education_interruption +education_change +education_milestone +career_entry +career_change +promotion +career_pressure +career_exit +business_start +relationship_start +relationship_commitment +relationship_separation +relationship_end +relationship_change +relocation +foreign_move +return +home_change +finance_gain +finance_loss +income_change +asset_change +finance_change +self_health_event +pressure_period +family_event +appearance_note +birthmark_or_scar +occupation_note +horary_query +other +``` + +语义不折叠:`career_entry / career_pressure / career_exit` 不同;`relationship_start / relationship_commitment / relationship_separation` 不同;不得把“开始关系”与“关系变化”混成同一事件。`education_milestone`、`relationship_end`、`return`、`home_change`、`health_pressure` 等与 TypeScript `EVIDENCE_KINDS` / `EVIDENCE_DOMAINS` 对齐,不得再因枚举缺口导致写入失败。 + +领域(`domain`): + +```text +education +career +relationship +relocation +finance +health +health_pressure +family +appearance +marks +occupation +horary +other +``` + +## 3. 日期精度 + +- 用户只给年份 → `date_precision = 'year'`,`occurred_from = YYYY-01-01`(边界),不得诱导编造月份。 +- 用户给年月 → `month`;给季度 → `quarter`;给年月日 → `day`;给区间 → `range`。 +- 相对表达(“刚毕业那年”)必须由服务器结合权威当前时间解析,Agent 不得自行假设年份。 +- 跨午夜、未知时间不伪造具体分钟;`unknown` 精度允许保留。 +- 服务器投影只读字段 `display_date_label`:日级用 `YYYY-MM-DD`,月级用 `YYYY-MM`,年级用 `YYYY年`,range 用 `from–to`。复述必须用该标签;禁止把日级格式化成“年份已确定为 YYYY”。用户确认“是/对”不得改 `date_precision`。更粗的修订若 quote 并没有更粗的日期表达,服务器拒绝 `precision_downgrade`。 + +## 4. 原文引用(quote grounding) + +- `user_quote` 必须能在对应 `source_turn.user_message` 中找到规范化匹配(去空白、去标点后子串命中)。 +- 服务器确认路径必须校验:引用来自本轮用户消息、kind 属于枚举、日期与原文一致。 +- 模型不得凭空补充月份、日期、原因、主动/被动、人物关系。 + +## 5. 修订链(append-only) + +- 事实变化 = 新增 superseding row,旧行标记 `superseded`,永不覆盖/删除。 +- 合法修订:日期更正、日期补全(如“2016 年 + 9 月”合并为 `2016-09`)、事件重分类(同身份)。 +- 非法修订:跨事件覆盖既有 ID(如把“大学入学”改成“搬家”);服务器拒绝并降级为新的 pending proposal。 +- 证据 ID 只能由服务器生成;模型不得提供或覆盖。 + +## 6. 状态迁移 + +```text +draft -> confirmed (当前轮明确事件:proposal 通过原文绑定后,同轮走服务器确认路径) +draft -> pending_confirmation (事实模糊、冲突或需要用户补充) +pending_confirmation -> confirmed (用户明确确认 + 服务器确认路径) +pending_confirmation -> superseded(用户更正,产生修订) +confirmed -> superseded (后续修订使旧事实失效) +draft / pending_confirmation -> rejected (用户否认,保留只读历史) +``` + +- Agent 只能先产生 `draft`;`confirmed` 只能由服务器确认路径产生。服务器确认路径不等于必须额外等待一轮用户回复。 +- 终态 Case(confirmed/closed/abandoned/superseded)禁止新增或修订证据。 +- 同一请求重放不得重复写证据(幂等键 = case + source_turn + quote + kind + summary)。 + +## 7. 评分输入边界 + +- 只有 `confirmed` 证据进入评分账本;`draft` 与 `pending_confirmation` 都不参与评分。 +- `family_event` 进入评分(D12 + D7 + D3 + 六亲宫位)。`other` 只作背景,不推进评分覆盖计数。 +- `appearance_note` / `birthmark_or_scar`:无日期只覆盖访谈;有日期才进上升/一宫辅助评分,不得当主公式。 +- `occupation_note`:与带日期事业事件独立。无日期只覆盖访谈;有日期按 D10 + 本命 10 宫辅助评分,不得贴类型标签。 +- `horary_query` 只作背景观察,不推进评分覆盖计数,也不计入 4 事件 / 3 领域。 +- 证据变化才触发重算;相同证据指纹复用缓存,不重复评分。 diff --git a/skills/jyotish-birth-time-rectification/versions/10.0.10/references/technique-routing.md b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/technique-routing.md new file mode 100644 index 00000000..1f84f496 --- /dev/null +++ b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/technique-routing.md @@ -0,0 +1,50 @@ +# Technique Routing(V9) + +生时校正是“有日期事件 + Dasha 为主要证据”的校准任务,分盘按主题调用,不一次性调用所有分盘。所有计算只能通过服务端工具;本文件只决定读哪些技法证据,不复制任何引擎实现。 + +## 1. 主证据 + +- 有明确日期(年月级或更精确)的人生事件 + 对应 Dasha 边界是主要证据。 +- 事件原文是用户原话;日期精度按用户真实提供保留。 +- 不把“支持某技法”误当作已完成独立验证;内部一致性不得伪装成全球顶级精度。 + +## 2. 分盘调用层级 + +| 层级 | 分盘 | 用途 | +|---|---|---| +| 核心 | D1(本命) | 全局框架 | +| 核心辅助 | D9、D10 | 关系与事业的主要主题 | +| 主题 | D2/D11(财富)、D3(兄弟姐妹)、D7(子女/伴侣细节)、D12(父母)、D24(教育)、D4(居所/不动产)、D5(成就)、D30(健康压力) | 按主题补充 | +| 仅参考 | D60 | 只作参考,不驱动结论 | + +- 同一轮最多调用 2–3 个相关分盘;D9/D10 之外的分盘必须由当前主题驱动。 +- 未执行、不可用或仅供参考的技法不得显示为已执行。 + +## 3. 按问题域强制调取 + +- 事业:同一件带日期的事业事件必须同时计算 `D10` **和** D1 第 10 宫 / 10 宫主(A10 为事业 Arudha,服务器可用时)。职业说明与带日期事业事件独立,同样对照 D10 与本命 10 宫,**不得**贴事业类型标签;无日期只覆盖访谈。 +- 财富:用户主动提供带日期的收入、资产或财务变化时计分 `D2 / D11`。不要主动追问。窗口扫描记录 D2/D11 换升,但不新增精度阶段。 +- 婚恋:`D9 + UL`(UL 为 Upapada Lagna,服务器可用时)。 +- 六亲/家人:`D12` 加 `D7`(子女/伴侣细节)加 `D3`(兄弟姐妹)加 D1 三/四/五/九宫。家人事件进入评分,不只作背景。D3 不另开精度阶段。 +- 外貌/体质/胎记疤痕:只对照 D1 上升/一宫,**辅助降权**,不得当主评分,也不得发明星座或类型标签。无日期的回答只覆盖访谈,不进主公式。 +- 健康:用户主动提供带日期的健康、事故或压力变化时计分 D1 + D30。不要主动追问。不是医学判断。窗口扫描记录 D30 换升,但不新增精度阶段。 +- 迁居:精度阶段 `d4_refine` 问带日期的搬家/住处变化;这不是领域轮询。计分 D4 + D1 四/十二宫。 +- 教育/成就:精度阶段 `d5_refine` 在 D5 **或 D24** 换升时问带日期的学业、考试或被委以责任的变化。计分 D24 + D5 + D1 四/五/九宫。D24 窗口扫描并入 `d5_refine`,不新增阶段 id。不得贴类型标签。 +- 占问:只问一次第一次认真问起这件事的时间。有日期则按该时点重算观察盘(出生地经纬,除非另给地点),可附 1/4/7/10 KP 子主。失败写成 blocked 观察,不计分,不挡提出门或确认门。没有时间或拒绝则 `skipped_by_policy`。 +- 精度阶段顺序:有日期事件 → 本命上升 → 方法覆盖(感情 → 事业 → 家人 → 外貌 → 疤痕 → 职业 → 占问)→ 再对已覆盖领域做 D9 / D10 / D4 / D5(含 D24 换升)。家人不得混进 D4,也不另开 `d11_refine` / `d30_refine`。未走完挡住出牌的方法覆盖(含职业)时,不得因为关系盘仍会换升就提前出示时间卡。 +- Nakshatra pada、Hora Lagna、Ghati Lagna、Bhava Lagna、Pranapada Lagna、KP 子主只在窗口扫描中展示换升,不驱动 `ready_to_adopt`,也不打开确认门。日出不可用时省略 Hora/Ghati/Pranapada,不得用 06:00 假日出。Bhava 只用本命日月,不依赖日出。 +- D9/D10 类型表只作内部观察,不得给用户贴标签。`internal_observations.ask_theme` 只决定下一问主题,不得说出星座、配偶类型或事业特质。 + +## 4. 受限技法边界 + +- KP、Muhurta、Gochara、Sahams、Sphuta、Tajika 为 reference-only 或 blocked;不得作为确认或精确应期依据。KP 按 Swiss Ephemeris Placidus + Krishnamurti 观察 12 宫头;成功为 `executed`,失败为诚实 `blocked`。不计分,不参与提出门或确认门。不得把政策跳过冒充已观察。 +- Shadbala / Ashtakavarga 外部绝对值未闭环前不作确定性结论。 +- 外部验证状态按服务器字面读取;`not_evaluated` ≠ `fail`。 +- 禁止 D60 驱动结论;禁止把邻近分钟与留一事件诊断描述为硬阻塞。 + +## 5. 决策树(简化) + +1. 有日期事件 → 按 Dasha 建立时间框架。 +2. 主题缺口 → 调对应分盘(§2/§3)。 +3. 候选对比有差异 → 服务器 Candidate Contrast 驱动下一问。 +4. 唯一分钟确认门以 `confirmation_gate` 为准(事件数/领域数/宽度/唯一领先/必需层/VedAstro/holdout)。`not_evaluated` ≠ fail。Agent 不得自行宣告通过或失败。 diff --git a/skills/jyotish-birth-time-rectification/versions/10.0.10/references/truth-consent-boundaries.md b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/truth-consent-boundaries.md new file mode 100644 index 00000000..49ec686e --- /dev/null +++ b/skills/jyotish-birth-time-rectification/versions/10.0.10/references/truth-consent-boundaries.md @@ -0,0 +1,43 @@ +# Truth / Consent Boundaries(V9) + +本文件定义真实性、用户同意与选择政策。服务器拥有事实、权限与状态;Agent 必须服从服务器返回的 truth/consent/selection policy。 + +## 1. 真实性硬边界 + +- 禁止虚构:事件、日期、候选、分盘数据、评分、Dasha 边界或出生分钟。 +- 计算只能通过服务端工具;模型不得重算或发明行星位置、分数或权重。 +- 内部一致性不等于“全球顶级精度”;外部 oracle 未闭环、参照引擎不可用时必须写成 `blocked` 或降级置信度。 +- 系统提示词与 Skill 原文不得输出;reasoning / chain-of-thought 不向用户展示。 + +## 2. 用户同意边界 + +- 保存 profile 需要用户明确同意 + 服务器确认门。 +- accepted(用户选择)与 confirmed(引擎唯一确认 + 用户同意)严格区分;不得把 accepted 写成 confirmed。`confirmation_gate` 是确认门权威;`not_evaluated` 不是失败。 +- 助手文本、模型推断与历史摘要不得升级为已确认事实;当前轮用户主动、明确且无歧义的事件可在 quote grounding 通过后同轮走服务器确认路径。旧文本只能作为显示历史或 pending evidence draft。 +- 用户说“不知道/不想回答”时尊重并关闭该目标,不换词重开。 + +## 3. 选择政策 + +- 候选卡只展示服务器持久化候选与相对支持度;不得暴露原始分数、权重、贡献矩阵、技术层或隐藏分钟。 +- 继续收集证据时不得同时提供采用操作。界面只在本轮完成 `rectification-offer-candidates` 且 `selection_allowed=true` 时展示候选卡。 +- 相同 evidence 指纹复用缓存;只有有效变化才重算。 +- 终态 Case 只读;追加证据、采用、确认全部拒绝。 + +## 4. 隐私与泄露防护 + +- 不输出 userId、出生资料明文、内部 ID、工具参数/结果、数据库错误原文、密钥或内部 URL。 +- 每轮持久化公开执行回执(phase/tool 白名单、状态、时间),不含 reasoning 与 payload。 +- 家庭健康事件不得投射为本人生成评分证据;亲属主体必须显式标记。 + +## 5. 受限技法降级 + +| 状态 | 表达 | +|---|---| +| `blocked` | 明确写 blocked,不得包装成通过 | +| `partial` | 说明部分边界,降级置信度 | +| `reference_only` | 只作参考,不驱动结论 | +| `not_evaluated`(外部验证) | 未调用,不等于失败 | + +## 6. 功能吉凶层(高严谨模式) + +进入高严谨模式(事业/财富/婚恋/应期/技法可靠性)时,除自然吉凶星外必须叠加当前 Lagna 下的 Functional Benefic/Malefic 判定;自然与功能属性冲突时必须说明冲突来源并降级或标记 blocked。未完成该判定不得声称高严谨解读完成。 diff --git a/skills/skill-package-registry.json b/skills/skill-package-registry.json index 04bf6625..59ee7c81 100644 --- a/skills/skill-package-registry.json +++ b/skills/skill-package-registry.json @@ -87,6 +87,14 @@ "sha256": "6c2c2d6177b36188766581762457c14711ea3dcedcd63ae3622427ac74e6e811", "sourceCommit": null, "packagePath": "skills/jyotish-birth-time-rectification/versions/10.0.9", + "status": "deprecated" + }, + { + "name": "jyotish-birth-time-rectification", + "version": "10.0.10", + "sha256": "a1dc47e853bd188c04a20de29906d011da21cbd297cb2d2b420684f2cd0a9236", + "sourceCommit": null, + "packagePath": "skills/jyotish-birth-time-rectification/versions/10.0.10", "status": "active" }, { diff --git a/tests/test_rectification_family_appearance_scoring.py b/tests/test_rectification_family_appearance_scoring.py index d0a6d204..68ee3b7f 100644 --- a/tests/test_rectification_family_appearance_scoring.py +++ b/tests/test_rectification_family_appearance_scoring.py @@ -198,5 +198,57 @@ def test_family_event_engine_rows_include_d12_and_are_not_skipped() -> None: assert "d2-hora" in finance_layers and "d11-labhamsha" in finance_layers health_layers = public_technique_layers("health_pressure", ["vim_md_domain_house"]) assert "d30-trimshamsha" in health_layers + occupation_layers = public_technique_layers("occupation", ["vim_md_domain_house"]) + assert "d1-rashi" in occupation_layers and "d10-dashamsa" in occupation_layers assert all("D10" in context["feature"]["available_layers"] for context in contexts) assert all("D5" in context["feature"]["available_layers"] for context in contexts) + + +def test_occupation_is_auxiliary_tenth_house_independent_of_career() -> None: + prefixes, houses = DOMAIN_CONFIG["occupation"] + assert prefixes == ("D10",) + assert houses == (10,) + assert "occupation" in AUXILIARY_DOMAINS + event = { + "id": "00000000-0000-4000-8000-000000000005", + "domain": "occupation", + "event_kind": "occupation_note", + "date_start": "2019-01-01", + "date_end": "2019-12-31", + "precision": "year", + "summary": "长期工作", + } + assert is_scoreable_event(event) is True + assert is_primary_scoreable_event(event) is False + scored = _score_event( + candidate_time="05:13", + event={ + "id": event["id"], + "domain": "occupation", + "event_kind": "occupation_note", + "date": "2019-01-01", + "precision": "year", + }, + natal_chart={"ascendant": {"lon": 10.0, "sign": "Aries"}, "planets": {"Sun": {"house": 10, "lon": 12.0}}}, + varga_charts=[{"Ascendant": {"sign_idx": 0}, "Sun": {"sign_idx": 9}}], + vimshottari=("Sun", "Moon", "Mars"), + narayana=(None, None), + arudha_padas={}, + ) + assert "occupation_auxiliary_not_primary" in scored["rule_ids"] + career = _score_event( + candidate_time="05:13", + event={ + "id": "00000000-0000-4000-8000-000000000006", + "domain": "career", + "event_kind": "career_entry", + "date": "2019-01-01", + "precision": "year", + }, + natal_chart={"ascendant": {"lon": 10.0, "sign": "Aries"}, "planets": {"Sun": {"house": 10, "lon": 12.0}}}, + varga_charts=[{"Ascendant": {"sign_idx": 0}, "Sun": {"sign_idx": 9}}], + vimshottari=("Sun", "Moon", "Mars"), + narayana=(None, None), + arudha_padas={}, + ) + assert scored["points"] < career["points"] diff --git a/tests/test_rectification_horary_observation.py b/tests/test_rectification_horary_observation.py new file mode 100644 index 00000000..d64a8ed0 --- /dev/null +++ b/tests/test_rectification_horary_observation.py @@ -0,0 +1,64 @@ +from __future__ import annotations + +from scripts.rectification.horary_observation import build_horary_observation + + +def _request(**overrides): + body = { + "birth_date": "1993-04-17", + "start_time": "14:29", + "end_time": "14:30", + "lat": 36.683333, + "lon": 114.35, + "tz": 8.0, + "events": [], + } + body.update(overrides) + return body + + +def test_horary_without_query_is_skipped() -> None: + result = build_horary_observation(_request(events=[{ + "id": "00000000-0000-4000-8000-000000000001", + "domain": "career", + "event_kind": "career_entry", + "date_start": "2019-07-01", + "date_end": "2019-07-01", + "precision": "day", + }])) + assert result["status"] == "skipped" + assert result["unique_minute_claim"] is False + + +def test_dated_horary_query_is_observation_only() -> None: + result = build_horary_observation(_request(events=[{ + "id": "00000000-0000-4000-8000-000000000002", + "domain": "horary", + "event_kind": "horary_query", + "date_start": "2024-01-15", + "date_end": "2024-01-15", + "precision": "day", + "summary": "第一次问起是 14:30", + }])) + assert result["status"] in {"executed", "blocked"} + assert result["unique_minute_claim"] is False + assert "不计分" in result["user_meaning"] + if result["status"] == "executed": + assert result["question_date"] == "2024-01-15" + assert result["question_time"] == "14:30" + assert result.get("lagna") + + +def test_horary_without_coordinates_is_blocked_not_a_gate_fail() -> None: + result = build_horary_observation({ + "events": [{ + "id": "00000000-0000-4000-8000-000000000003", + "domain": "horary", + "event_kind": "horary_query", + "date_start": "2024-01-15", + "date_end": "2024-01-15", + "precision": "day", + }], + }) + assert result["status"] == "blocked" + assert result["unique_minute_claim"] is False diff --git a/tests/test_rectification_kp_cusp_observation.py b/tests/test_rectification_kp_cusp_observation.py new file mode 100644 index 00000000..bac89526 --- /dev/null +++ b/tests/test_rectification_kp_cusp_observation.py @@ -0,0 +1,181 @@ +from __future__ import annotations + +from datetime import datetime + +from kp_system import KP_LORDS +from scripts.active_rectification_event_engine import ( + build_candidate_static_context, + compute_event_candidate_rows, +) +from scripts.rectification.decision_policy import ( + build_candidate_decisions, + build_decision_receipt, + build_technique_audit, +) +from scripts.rectification.kp_cusp_observation import observe_kp_cusps +from scripts.rectification.refinement_packet import window_scan + + +def _request() -> dict: + return { + "birth_date": "1993-04-17", + "start_time": "14:29", + "end_time": "14:30", + "lat": 36.683333, + "lon": 114.35, + "tz": 8.0, + "events": [{ + "id": "5cb071d6-6d99-46be-85dc-a9bf59ef6ac5", + "domain": "career", + "date": "2019-07-01", + "precision": "day", + }], + } + + +def _score_request() -> dict: + return { + "events": [ + { + "id": "00000000-0000-4000-8000-000000000001", + "domain": "career", + "summary": "入职", + "event_kind": "career_entry", + "precision": "day", + "date_start": "2016-09-15", + "date_end": "2016-09-15", + }, + { + "id": "00000000-0000-4000-8000-000000000002", + "domain": "relationship", + "summary": "开始一段关系", + "event_kind": "relationship_start", + "precision": "day", + "date_start": "2018-03-01", + "date_end": "2018-03-01", + }, + { + "id": "00000000-0000-4000-8000-000000000003", + "domain": "education", + "summary": "毕业", + "event_kind": "education_completion", + "precision": "day", + "date_start": "2015-06-01", + "date_end": "2015-06-01", + }, + { + "id": "00000000-0000-4000-8000-000000000004", + "domain": "family", + "summary": "家人变化", + "event_kind": "family_event", + "precision": "day", + "date_start": "2020-01-01", + "date_end": "2020-01-01", + }, + ] + } + + +def _diagnostics() -> dict: + return { + "leave_one_event_out_retention_rate": 1, + "leave_one_domain_out_retention_rate": 1, + "date_sensitivity_retention_rate": 1, + "primary_secondary_margin_percent": 50, + } + + +def test_observe_kp_cusps_uses_placidus_not_equal_houses() -> None: + context = build_candidate_static_context(_request(), datetime(1993, 4, 17, 14, 29)) + feature = context["feature"] + snapshot = feature["kp_cusps"] + natal_houses = context["chart"]["houses"] + assert snapshot["status"] == "executed" + assert snapshot["house_system"] == "placidus" + assert snapshot["ayanamsa"] == "krishnamurti" + assert len(snapshot["houses"]) == 12 + tenth = snapshot["houses"]["10"] + equal_tenth = float(natal_houses["house_10"]["cusp_degree"]) + assert abs(float(tenth["cusp_degree"]) - equal_tenth) > 0.05 + assert tenth["sub_lord"] in KP_LORDS + assert isinstance(feature["kp1_sub_index"], int) + assert 0 <= feature["kp1_sub_index"] <= 8 + assert "KP_cusps" not in feature["blocked_layers"] + assert "KP_cusps" in feature["available_layers"] + + +def test_kp_observation_is_absent_from_scoring_missing_layers() -> None: + request = _request() + context = build_candidate_static_context(request, datetime(1993, 4, 17, 14, 29)) + rows = compute_event_candidate_rows(request, static_contexts=[context]) + assert rows + assert "KP_cusps" not in rows[0]["missing_layers"] + assert context["feature"]["kp_cusps"]["status"] == "executed" + + +def test_window_scan_emits_kp_sub_lord_changes_without_confirmation() -> None: + scan = window_scan({ + "static_contexts": [ + {"feature": {"time": "05:13", "kp1_sub_index": 1, "kp4_sub_index": 2, "kp7_sub_index": 3, "kp10_sub_index": 4}}, + {"feature": {"time": "05:14", "kp1_sub_index": 2, "kp4_sub_index": 2, "kp7_sub_index": 3, "kp10_sub_index": 4}}, + ] + }) + meanings = [item["user_meaning"] for item in scan["transitions"]] + assert "KP 1宫子主 在 05:14 发生变化" in meanings + assert "KP 4宫子主 在 05:14 发生变化" not in meanings + encoded = str(scan) + assert "白羊" not in encoded + assert "Aries" not in encoded + assert scan["confirmation_allowed"] is False + assert scan["unique_minute_claim"] is False + + +def test_technique_audit_kp_executed_when_snapshot_present() -> None: + rows = build_technique_audit( + { + "matrix": {}, + "static_contexts": [{ + "feature": { + "time": "05:13", + "kp_cusps": {"status": "executed", "house_system": "placidus", "ayanamsa": "krishnamurti"}, + } + }], + }, + house_table={"time": "05:13", "lagna": "金牛座"}, + ) + kp = next(row for row in rows if row["technique"] == "KP 宫头") + assert kp["status"] == "executed" + assert "政策跳过" not in kp["note"] + assert "不计分" in kp["note"] + + +def test_technique_audit_kp_blocked_is_honest_and_does_not_fail_propose() -> None: + rows = build_technique_audit({"matrix": {}, "static_contexts": []}, house_table=None) + kp = next(row for row in rows if row["technique"] == "KP 宫头") + assert kp["status"] == "blocked" + assert "政策跳过" not in kp["note"] + decisions = build_candidate_decisions( + [{"time": "05:13", "score": 20, "evidence": [], "missing_layers": []}, + {"time": "05:14", "score": 8, "evidence": [], "missing_layers": []}], + result_id="00000000-0000-4000-8000-000000000099", + ) + receipt = build_decision_receipt( + _score_request(), + decisions, + {"missing_layers": [], "matrix": {}, "static_contexts": [{"feature": {"time": "05:13", "kp_cusps": {"status": "blocked"}}}]}, + _diagnostics(), + ) + assert receipt["gates"]["required_layers"]["passed"] is True + assert receipt["propose_allowed"] is True + audit = next(row for row in receipt["technique_audit_table"] if row["technique"] == "KP 宫头") + assert audit["status"] == "blocked" + assert "政策跳过" not in audit["note"] + + +def test_observe_kp_cusps_blocks_without_inventing_whole_sign_proxy() -> None: + snapshot = observe_kp_cusps(None, 36.6, 114.3) + assert snapshot["status"] == "blocked" + assert snapshot["houses"] == {} + polar = observe_kp_cusps(2451545.0, 80.0, 0.0) + assert polar["status"] == "blocked" + assert polar["houses"] == {} diff --git a/tests/test_rectification_v5_services.py b/tests/test_rectification_v5_services.py index d124424a..afe4349e 100644 --- a/tests/test_rectification_v5_services.py +++ b/tests/test_rectification_v5_services.py @@ -78,6 +78,8 @@ class RectificationV5ServicesTest(unittest.TestCase): "family": ("family_event",), "appearance": ("appearance_note",), "marks": ("birthmark_or_scar",), + "occupation": ("occupation_note",), + "horary": ("horary_query",), "other": ("other",), } @@ -117,6 +119,7 @@ class RectificationV5ServicesTest(unittest.TestCase): body = request() body["events"] = [ event(2, "other", "other", precision="year"), + event(3, "horary", "horary_query", precision="day"), ] normalized = normalize_rectification_request(body, today=date(2026, 7, 28))