fix(rectification): split D4/D5 stages and recast after adopt
Keep family on D12+D7 instead of mixing it into D4, score D5 on education, and show a natal recast plus technique audit after adopt without unique-minute claims. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -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.4";
|
||||
export const RECTIFICATION_SKILL_VERSION = "10.0.5";
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
* 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
|
||||
* 4. Relatives — confirmed family evidence (D12 + 六亲 houses)
|
||||
* 4. Relatives — confirmed family evidence (D12 + D7 + 六亲 houses)
|
||||
* 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 — folded into method 3 (D10 + D1 10th)
|
||||
@@ -45,9 +45,9 @@ export type MethodCoverage = Readonly<{
|
||||
}>;
|
||||
|
||||
export type MethodFollowup = Readonly<{
|
||||
method_id: "dasha_events" | "d9_relationship" | "d10_career" | "relatives" | "appearance" | "marks" | "active_focus" | "nakshatra_boundary" | "oos_blind";
|
||||
method_id: "dasha_events" | "d9_relationship" | "d10_career" | "d4_home" | "d5_education" | "relatives" | "appearance" | "marks" | "active_focus" | "nakshatra_boundary" | "oos_blind";
|
||||
intent: string;
|
||||
ask_theme: "dated_event" | "relationship_style" | "career_style" | "family_event" | "appearance" | "marks" | "active_focus" | "nakshatra_trait" | "oos_blind";
|
||||
ask_theme: "dated_event" | "relationship_style" | "career_style" | "home_change" | "education_style" | "family_event" | "appearance" | "marks" | "active_focus" | "nakshatra_trait" | "oos_blind";
|
||||
domain: string | null;
|
||||
kind_hint: string | null;
|
||||
user_prompt_hint: string;
|
||||
@@ -322,14 +322,24 @@ export function buildMethodFollowupPlan(input: {
|
||||
user_prompt_hint: "事业盘仍会换升。可以再补一件记得大概时间的工作变化;同一件事会同时对照本命第 10 宫和 D10,不要描述类型标签。",
|
||||
source: "precision_stage",
|
||||
});
|
||||
} else if (stage === "theme_refine" && !declined.has("family")) {
|
||||
} else if ((stage === "d4_refine" || stage === "theme_refine") && !declined.has("relocation")) {
|
||||
next = followup({
|
||||
method_id: "relatives",
|
||||
method_id: "d4_home",
|
||||
intent: "distinguish_candidates",
|
||||
ask_theme: "family_event",
|
||||
domain: "family",
|
||||
kind_hint: "family_event",
|
||||
user_prompt_hint: "若还想继续收窄,可以再补一件记得大概时间的家人变化;也可以先采用代表性时间。",
|
||||
ask_theme: "home_change",
|
||||
domain: "relocation",
|
||||
kind_hint: "home_change",
|
||||
user_prompt_hint: "居所盘仍会换升。可以再补一件记得大概时间的搬家或住处变化。",
|
||||
source: "precision_stage",
|
||||
});
|
||||
} else if (stage === "d5_refine" && !declined.has("education")) {
|
||||
next = followup({
|
||||
method_id: "d5_education",
|
||||
intent: "distinguish_candidates",
|
||||
ask_theme: "education_style",
|
||||
domain: "education",
|
||||
kind_hint: "education_milestone",
|
||||
user_prompt_hint: "成就盘仍会换升。可以再补一件记得大概时间的学业、考试或被委以责任的变化;同一件事会对照本命五宫和 D5,不要贴类型标签。",
|
||||
source: "precision_stage",
|
||||
});
|
||||
} else if (!relationshipCovered && !declined.has("relationship")) {
|
||||
@@ -359,7 +369,7 @@ export function buildMethodFollowupPlan(input: {
|
||||
ask_theme: "family_event",
|
||||
domain: "family",
|
||||
kind_hint: "family_event",
|
||||
user_prompt_hint: "可以先说一段记得大概时间的家人相关变化。",
|
||||
user_prompt_hint: "可以先说一段记得大概时间的家人相关变化。同一件事会对照 D12 父母盘和 D7 子女盘。",
|
||||
source: "method_coverage",
|
||||
});
|
||||
} else if (!appearanceCovered && !declined.has("appearance")) {
|
||||
@@ -385,6 +395,9 @@ export function buildMethodFollowupPlan(input: {
|
||||
} else {
|
||||
const d9 = input.observations?.find((item) => item.layer === "d9");
|
||||
const d10 = input.observations?.find((item) => item.layer === "d10");
|
||||
const d4 = input.observations?.find((item) => item.layer === "d4");
|
||||
const d5 = input.observations?.find((item) => item.layer === "d5");
|
||||
const d7 = input.observations?.find((item) => item.layer === "d7");
|
||||
const d12 = input.observations?.find((item) => item.layer === "d12");
|
||||
if (d9?.candidates_differ && !declined.has("relationship")) {
|
||||
next = followup({
|
||||
@@ -406,14 +419,34 @@ export function buildMethodFollowupPlan(input: {
|
||||
user_prompt_hint: "当前候选在事业主题上仍分不开,可以再补一件记得大概时间的工作变化;不要描述类型标签。同一件事会同时对照本命第 10 宫和 D10。",
|
||||
source: "varga_observation",
|
||||
});
|
||||
} else if (d12?.candidates_differ && !declined.has("family")) {
|
||||
} else if (d4?.candidates_differ && !declined.has("relocation")) {
|
||||
next = followup({
|
||||
method_id: "d4_home",
|
||||
intent: "distinguish_candidates",
|
||||
ask_theme: "home_change",
|
||||
domain: "relocation",
|
||||
kind_hint: "home_change",
|
||||
user_prompt_hint: "当前候选在居所主题上仍分不开,可以再补一件记得大概时间的搬家或住处变化。",
|
||||
source: "varga_observation",
|
||||
});
|
||||
} else if (d5?.candidates_differ && !declined.has("education")) {
|
||||
next = followup({
|
||||
method_id: "d5_education",
|
||||
intent: "distinguish_candidates",
|
||||
ask_theme: "education_style",
|
||||
domain: "education",
|
||||
kind_hint: "education_milestone",
|
||||
user_prompt_hint: "当前候选在学业或成就主题上仍分不开,可以再补一件记得大概时间的学业、考试或被委以责任的变化;不要贴类型标签。",
|
||||
source: "varga_observation",
|
||||
});
|
||||
} else if ((d12?.candidates_differ || d7?.candidates_differ) && !declined.has("family")) {
|
||||
next = followup({
|
||||
method_id: "relatives",
|
||||
intent: "distinguish_candidates",
|
||||
ask_theme: "family_event",
|
||||
domain: "family",
|
||||
kind_hint: "family_event",
|
||||
user_prompt_hint: "当前候选在家人主题上仍分不开,可以再补一件记得大概时间的家人变化。",
|
||||
user_prompt_hint: "当前候选在家人主题上仍分不开,可以再补一件记得大概时间的家人变化。同一件事会对照 D12 和 D7。",
|
||||
source: "varga_observation",
|
||||
});
|
||||
} else if (input.nakshatraBoundary?.near_boundary) {
|
||||
|
||||
@@ -53,6 +53,8 @@ export const PUBLIC_RECTIFICATION_METHODS = [
|
||||
"d1-rashi",
|
||||
"d2-hora",
|
||||
"d4-chaturthamsha",
|
||||
"d5-panchamsha",
|
||||
"d7-saptamsha",
|
||||
"d9-navamsa",
|
||||
"d10-dashamsa",
|
||||
"d11-labhamsha",
|
||||
|
||||
@@ -13,10 +13,12 @@ const LAYER_LABEL: Record<WindowScanLayer, string> = {
|
||||
d9: "D9",
|
||||
d10: "D10",
|
||||
d4: "D4",
|
||||
d5: "D5",
|
||||
d7: "D7",
|
||||
d12: "D12",
|
||||
};
|
||||
|
||||
export type WindowScanLayer = "d1" | "d9" | "d10" | "d4" | "d12";
|
||||
export type WindowScanLayer = "d1" | "d9" | "d10" | "d4" | "d5" | "d7" | "d12";
|
||||
|
||||
export type WindowScanTransition = Readonly<{
|
||||
layer: WindowScanLayer;
|
||||
@@ -68,6 +70,8 @@ export type PrecisionStageId =
|
||||
| "lagna_frame"
|
||||
| "d9_refine"
|
||||
| "d10_refine"
|
||||
| "d4_refine"
|
||||
| "d5_refine"
|
||||
| "theme_refine"
|
||||
| "ready_to_adopt";
|
||||
|
||||
@@ -113,7 +117,7 @@ export function parseWindowScanTransitions(value: unknown): readonly WindowScanT
|
||||
const at = asTime(row?.at);
|
||||
if (
|
||||
!row
|
||||
|| (layer !== "d1" && layer !== "d9" && layer !== "d10" && layer !== "d4" && layer !== "d12")
|
||||
|| (layer !== "d1" && layer !== "d9" && layer !== "d10" && layer !== "d4" && layer !== "d5" && layer !== "d7" && layer !== "d12")
|
||||
|| !at
|
||||
) continue;
|
||||
const key = `${layer}:${at}`;
|
||||
@@ -252,6 +256,8 @@ export function parsePrecisionStage(value: unknown): PrecisionStage | null {
|
||||
&& current !== "lagna_frame"
|
||||
&& current !== "d9_refine"
|
||||
&& current !== "d10_refine"
|
||||
&& current !== "d4_refine"
|
||||
&& current !== "d5_refine"
|
||||
&& current !== "theme_refine"
|
||||
&& current !== "ready_to_adopt"
|
||||
)
|
||||
|
||||
@@ -19,19 +19,23 @@ export type WindowScan = Readonly<{
|
||||
d9_lagna_count: number;
|
||||
d10_lagna_count: number;
|
||||
d4_lagna_count: number;
|
||||
d5_lagna_count: number;
|
||||
d7_lagna_count: number;
|
||||
d12_lagna_count: number;
|
||||
d1_candidates_differ: boolean;
|
||||
d9_candidates_differ: boolean;
|
||||
d10_candidates_differ: boolean;
|
||||
d4_candidates_differ: boolean;
|
||||
d5_candidates_differ: boolean;
|
||||
d7_candidates_differ: boolean;
|
||||
d12_candidates_differ: boolean;
|
||||
transitions: readonly WindowScanTransition[];
|
||||
}>;
|
||||
|
||||
export type InternalVargaObservation = Readonly<{
|
||||
layer: "d9" | "d10" | "d12";
|
||||
layer: "d9" | "d10" | "d4" | "d5" | "d7" | "d12";
|
||||
candidates_differ: boolean;
|
||||
ask_theme: "relationship_style" | "career_style" | "family_event" | null;
|
||||
ask_theme: "relationship_style" | "career_style" | "home_change" | "education_style" | "family_event" | null;
|
||||
}>;
|
||||
|
||||
function asRecord(value: unknown): Readonly<Record<string, unknown>> | null {
|
||||
@@ -65,11 +69,15 @@ export function parseWindowScan(value: unknown): WindowScan | null {
|
||||
if (d9Count === null || d10Count === null) return null;
|
||||
const d1Count = optionalCount(row.d1_lagna_count);
|
||||
const d4Count = optionalCount(row.d4_lagna_count);
|
||||
const d5Count = optionalCount(row.d5_lagna_count);
|
||||
const d7Count = optionalCount(row.d7_lagna_count);
|
||||
const d12Count = optionalCount(row.d12_lagna_count);
|
||||
const d9Differ = row.d9_candidates_differ === true || d9Count > 1;
|
||||
const d10Differ = row.d10_candidates_differ === true || d10Count > 1;
|
||||
const d1Differ = row.d1_candidates_differ === true || d1Count > 1;
|
||||
const d4Differ = row.d4_candidates_differ === true || d4Count > 1;
|
||||
const d5Differ = row.d5_candidates_differ === true || d5Count > 1;
|
||||
const d7Differ = row.d7_candidates_differ === true || d7Count > 1;
|
||||
const d12Differ = row.d12_candidates_differ === true || d12Count > 1;
|
||||
return {
|
||||
scanned: true,
|
||||
@@ -79,11 +87,15 @@ export function parseWindowScan(value: unknown): WindowScan | null {
|
||||
d9_lagna_count: d9Count,
|
||||
d10_lagna_count: d10Count,
|
||||
d4_lagna_count: d4Count,
|
||||
d5_lagna_count: d5Count,
|
||||
d7_lagna_count: d7Count,
|
||||
d12_lagna_count: d12Count,
|
||||
d1_candidates_differ: d1Differ,
|
||||
d9_candidates_differ: d9Differ,
|
||||
d10_candidates_differ: d10Differ,
|
||||
d4_candidates_differ: d4Differ,
|
||||
d5_candidates_differ: d5Differ,
|
||||
d7_candidates_differ: d7Differ,
|
||||
d12_candidates_differ: d12Differ,
|
||||
transitions: parseWindowScanTransitions(row.transitions),
|
||||
};
|
||||
@@ -110,6 +122,21 @@ export function internalObservationsFromWindowScan(
|
||||
candidates_differ: scan.d10_candidates_differ,
|
||||
ask_theme: scan.d10_candidates_differ ? "career_style" : null,
|
||||
},
|
||||
{
|
||||
layer: "d4",
|
||||
candidates_differ: scan.d4_candidates_differ,
|
||||
ask_theme: scan.d4_candidates_differ ? "home_change" : null,
|
||||
},
|
||||
{
|
||||
layer: "d5",
|
||||
candidates_differ: scan.d5_candidates_differ,
|
||||
ask_theme: scan.d5_candidates_differ ? "education_style" : null,
|
||||
},
|
||||
{
|
||||
layer: "d7",
|
||||
candidates_differ: scan.d7_candidates_differ,
|
||||
ask_theme: scan.d7_candidates_differ ? "family_event" : null,
|
||||
},
|
||||
{
|
||||
layer: "d12",
|
||||
candidates_differ: scan.d12_candidates_differ,
|
||||
|
||||
@@ -12,6 +12,8 @@ import {
|
||||
refinementFromDecisionReceipt,
|
||||
} from "./rectification-agentic/v9/refinement-packet";
|
||||
import { parseWindowScan } from "./rectification-agentic/v9/varga-observations";
|
||||
import type { TechniqueAuditRow } from "./consultation-agent-events";
|
||||
import { normalizeTechniqueAuditRows } from "./consultation-technique-audit";
|
||||
|
||||
export type RectificationCandidate = Readonly<{
|
||||
candidateId: string;
|
||||
@@ -33,6 +35,14 @@ export type RectificationHouseTable = Readonly<{
|
||||
houses: readonly RectificationHouseRow[];
|
||||
}>;
|
||||
|
||||
export type RectificationNatalRecast = Readonly<{
|
||||
time: string;
|
||||
lagna: string;
|
||||
user_meaning: string;
|
||||
unique_minute_claim: false;
|
||||
confirmation_allowed: false;
|
||||
}>;
|
||||
|
||||
export type RectificationCandidateResult = Readonly<{
|
||||
resultId: string;
|
||||
candidates: readonly RectificationCandidate[];
|
||||
@@ -43,6 +53,9 @@ export type RectificationCandidateResult = Readonly<{
|
||||
selectedTime: string | null;
|
||||
selectionKind: string | null;
|
||||
houseTable: RectificationHouseTable | null;
|
||||
houseTablesByTime: Readonly<Record<string, RectificationHouseTable>>;
|
||||
natalRecast: RectificationNatalRecast | null;
|
||||
techniqueAudit: readonly TechniqueAuditRow[];
|
||||
windowTransitions: readonly WindowScanTransition[];
|
||||
eventDashaLedger: readonly EventDashaLedgerRow[];
|
||||
dashaAgreement: DashaAgreement | null;
|
||||
@@ -102,11 +115,68 @@ export function parseRectificationHouseTable(value: unknown): RectificationHouse
|
||||
return { time: tableTime, lagna, houses };
|
||||
}
|
||||
|
||||
function houseTableFromSnapshot(snapshot: Record<string, unknown>): RectificationHouseTable | null {
|
||||
return parseRectificationHouseTable(snapshot.houseTable)
|
||||
?? parseRectificationHouseTable(snapshot.house_table)
|
||||
?? parseRectificationHouseTable(record(snapshot.decisionReceipt)?.house_table)
|
||||
?? parseRectificationHouseTable(record(snapshot.decision_receipt)?.house_table);
|
||||
function houseTablesByTimeFromSnapshot(
|
||||
snapshot: Record<string, unknown>,
|
||||
receipt: Record<string, unknown> | null,
|
||||
): Record<string, RectificationHouseTable> {
|
||||
const raw = record(snapshot.houseTablesByTime)
|
||||
?? record(snapshot.house_tables_by_time)
|
||||
?? record(receipt?.house_tables_by_time);
|
||||
const tables: Record<string, RectificationHouseTable> = {};
|
||||
if (!raw) return tables;
|
||||
for (const [key, value] of Object.entries(raw)) {
|
||||
const clock = time(key);
|
||||
const table = parseRectificationHouseTable(value);
|
||||
if (!clock || !table) continue;
|
||||
tables[clock] = table;
|
||||
}
|
||||
return tables;
|
||||
}
|
||||
|
||||
function natalRecastFromSnapshot(
|
||||
snapshot: Record<string, unknown>,
|
||||
receipt: Record<string, unknown> | null,
|
||||
table: RectificationHouseTable | null,
|
||||
): RectificationNatalRecast | null {
|
||||
const raw = record(snapshot.natalRecast) ?? record(snapshot.natal_recast) ?? record(receipt?.natal_recast);
|
||||
const recastTime = table?.time ?? time(raw?.time);
|
||||
const lagna = table?.lagna || (typeof raw?.lagna === "string" ? raw.lagna.trim() : "") || "";
|
||||
if (!recastTime || !lagna || deniedHouseTable.test(lagna)) return null;
|
||||
const meaning = natalRecastMeaning({ time: recastTime, lagna })
|
||||
?? (typeof raw?.user_meaning === "string" && raw.user_meaning.trim() && !deniedHouseTable.test(raw.user_meaning)
|
||||
? raw.user_meaning.trim().slice(0, 220)
|
||||
: null);
|
||||
if (!meaning) return null;
|
||||
return {
|
||||
time: recastTime,
|
||||
lagna,
|
||||
user_meaning: meaning,
|
||||
unique_minute_claim: false,
|
||||
confirmation_allowed: false,
|
||||
};
|
||||
}
|
||||
|
||||
export function natalRecastMeaning(table: Pick<RectificationHouseTable, "time" | "lagna"> | null): string | null {
|
||||
if (!table) return null;
|
||||
return `本命宫位已按 ${table.time} 重算(上升 ${table.lagna})。下面是本轮实际执行的技法,不能当作唯一分钟确认。`;
|
||||
}
|
||||
|
||||
export function workingRectificationHouseTable(
|
||||
result: Pick<RectificationCandidateResult, "selectedTime" | "representativeTime" | "houseTable" | "houseTablesByTime">,
|
||||
): RectificationHouseTable | null {
|
||||
const wanted = result.selectedTime ?? result.representativeTime;
|
||||
if (wanted && result.houseTablesByTime[wanted]) return result.houseTablesByTime[wanted];
|
||||
return result.houseTable;
|
||||
}
|
||||
|
||||
function techniqueAuditFromSnapshot(
|
||||
snapshot: Record<string, unknown>,
|
||||
receipt: Record<string, unknown> | null,
|
||||
): readonly TechniqueAuditRow[] {
|
||||
return normalizeTechniqueAuditRows(snapshot.techniqueAudit)
|
||||
?? normalizeTechniqueAuditRows(snapshot.technique_audit_table)
|
||||
?? normalizeTechniqueAuditRows(receipt?.technique_audit_table)
|
||||
?? [];
|
||||
}
|
||||
|
||||
function receiptFromSnapshot(snapshot: Record<string, unknown>): Record<string, unknown> | null {
|
||||
@@ -139,6 +209,15 @@ export function parseRectificationCandidateResult(value: unknown): Rectification
|
||||
const receipt = receiptFromSnapshot(snapshot);
|
||||
const refinement = refinementFromDecisionReceipt(receipt);
|
||||
const windowScan = parseWindowScan(receipt?.window_scan) ?? parseWindowScan(snapshot.window_scan);
|
||||
const selectedTime = time(snapshot.selectedTime);
|
||||
const representativeTime = time(snapshot.representativeTime);
|
||||
const houseTablesByTime = houseTablesByTimeFromSnapshot(snapshot, receipt);
|
||||
const fallbackHouseTable = parseRectificationHouseTable(snapshot.houseTable)
|
||||
?? parseRectificationHouseTable(snapshot.house_table)
|
||||
?? parseRectificationHouseTable(receipt?.house_table);
|
||||
const houseTable = (selectedTime && houseTablesByTime[selectedTime])
|
||||
?? (representativeTime && houseTablesByTime[representativeTime])
|
||||
?? fallbackHouseTable;
|
||||
|
||||
return {
|
||||
resultId: snapshot.resultId,
|
||||
@@ -148,10 +227,13 @@ export function parseRectificationCandidateResult(value: unknown): Rectification
|
||||
: "low",
|
||||
selectionAllowed: snapshot.selectionAllowed === true,
|
||||
confirmationAllowed: snapshot.confirmationAllowed === true,
|
||||
representativeTime: time(snapshot.representativeTime),
|
||||
selectedTime: time(snapshot.selectedTime),
|
||||
representativeTime,
|
||||
selectedTime,
|
||||
selectionKind: text(snapshot.selectionKind),
|
||||
houseTable: houseTableFromSnapshot(snapshot),
|
||||
houseTable,
|
||||
houseTablesByTime,
|
||||
natalRecast: natalRecastFromSnapshot(snapshot, receipt, houseTable),
|
||||
techniqueAudit: techniqueAuditFromSnapshot(snapshot, receipt),
|
||||
windowTransitions: windowScan?.transitions ?? parseWindowScanTransitions(snapshot.window_scan),
|
||||
eventDashaLedger: refinement.event_dasha_ledger,
|
||||
dashaAgreement: refinement.dasha_agreement,
|
||||
|
||||
@@ -4,6 +4,8 @@ export const PUBLIC_RECTIFICATION_METHOD_LABELS: Readonly<Record<PublicRectifica
|
||||
"d1-rashi": "D1 本命盘",
|
||||
"d2-hora": "D2 财帛分盘",
|
||||
"d4-chaturthamsha": "D4 迁移分盘",
|
||||
"d5-panchamsha": "D5 成就分盘",
|
||||
"d7-saptamsha": "D7 子女分盘",
|
||||
"d9-navamsa": "D9 婚姻分盘",
|
||||
"d10-dashamsa": "D10 事业分盘",
|
||||
"d11-labhamsha": "D11 收益分盘",
|
||||
|
||||
Reference in New Issue
Block a user