fix(ayanamsa): pin Lahiri on reference sets and add a user setting

Product default stays Raman. Public-case revalidation and fixture dashas now pass --ayanamsa lahiri; profiles store the four selectable values.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-03 16:33:46 +08:00
co-authored by Cursor
parent 58cae371bb
commit b6a70aa7df
44 changed files with 425 additions and 30 deletions
+16
View File
@@ -7872,3 +7872,19 @@
- 相关记录:BUG-416、BUG-431、BUG-498
- 复发自:BUG-431
- 修复版本:待发布
## BUG-511 | 公开案例复验因默认岁差改 Raman 而失败,标签与计算不一致
- 状态:resolved
- 首次发现:2026-09-03
- 最近更新:2026-09-03
- 影响面:`tests/run_real_case_revalidation.py`、`scripts/jyotish_api_server.py` 岁差回执、账户 `profiles.ayanamsa`、咨询/报告/校正/每日星语请求口径
- 用户现象:发布门真实案例复验 `valid=false`,gated 通过率掉到门槛以下。同一张虚构盘在旧生产与当前默认下 Moon nakshatra / 首段大运不同。回执上的岁差名有时写成 Lahiri 或 Raman,与该次实际计算不是同一套。
- 触发条件:`80102459` 把引擎默认改成 Raman 后,参考集调用没有显式锁定 Lahiri;VedAstro `ayanamsa_policy` 与部分回执字段仍写死字面量。
- 根因:参考集对照依赖「默认值恰好是 Lahiri」;产品默认改为 Raman 后口径漂移。三处标签用字面量兜底,不读该次请求实际岁差。账户没有用户可选岁差。
- 修复:参考集与夹具大运显式 `--ayanamsa lahiri`。API 回执与 VedAstro 对照改用该次请求实际岁差。`profiles.ayanamsa` 默认 `raman`,设置里可选四个值;咨询、报告、校正、星盘库、每日星语走 `resolveAyanamsa`。`DEFAULT_AYANAMSA_NAME` 本轮不改。
- 验证:夹具大运日期不变;前端 `resolveAyanamsa`、账户 PATCH 四值校验、咨询 toolInput 带 profile 岁差、校正快照带岁差但不进 fingerprint;`npm run test:db` 跑迁移。公开案例复验命令见本轮 PROGRESS。
- 防复发:参考集与外部对照必须显式传岁差,不得依赖默认值。回执只显示实际名。岁差不进校正 `baselineFingerprint`,不重算历史报告。
- 相关记录:无
- 复发自:无
- 修复版本:待发布
@@ -0,0 +1,72 @@
# PROGRESS · 仓库整备(2026-09-03)
工作树:`/Users/jesse/Downloads/Copse/astrology/.worktrees/repo-hygiene-20260903`
分支:`codex/repo-hygiene-20260903`
基线:开工后快进到 `origin/staging` @ `58cae371`(含 BUG-510 与上游同步任务书)。任务书:`docs/tasks/TASK-repo-hygiene-20260903.md`。
未碰 `main`。未改 `DEFAULT_AYANAMSA_NAME`(保持 `raman`)。未改校正打分/阈值/golden。未改 `page.tsx`(仍 2041 行)。`scripts/jyotish_api_server.py` 仍 11120 行(与 rebase 后 HEAD 相同)。
BUG 编号:开工时 `docs/BUG_HISTORY.md` 最大号是 **BUG-510**。本轮岁差记 **BUG-511**。
| 任务 | 状态 | 说明 |
| --- | --- | --- |
| 0 岁差设置 + 参考集锁口径 | 待验收 | 本提交。产品 staging 实测仍欠 |
| 1 发布门本地可复现 | 未开始 | 任务 0 先推 |
| 2 注册表白名单 | 未开始 | |
| 3 仓库地址 | 未开始 | |
| 4 早期日志搬家 | 未开始 | |
| 5 远端分支清理 | 未开始 | |
## 环境备忘
- 本 worktree **没有** `.venv`。预检与 Python 测试用主仓 `/Users/jesse/Downloads/Copse/astrology/yinduzhanxing/.venv`(`mcp` 1.28.1,`hypothesis` 已装)。
- 任务书写把迁移放进 `frontend/db/migrations/`。实际 `frontend/scripts/db-migrate.mjs` 会跑 `frontend/db/migrations` **和** `frontend/supabase/migrations`。账户资料列修复历来放 supabase(`account-api` 还断言同类 SQL 不在 `db/migrations`)。本轮唯一迁移是 `frontend/supabase/migrations/20260903010000_profile_ayanamsa.sql`,避免两个目录同名撞车。
- 产品文案里的「账户与出生资料」在现界面是 **星盘资料** 里的本人编辑表,不是 `个人资料`(MVP 合同禁止在那里放出生 UI)。岁差单选加在本人星盘表单,未改 `page.tsx`。
- `npm run test:db` 与 `npx tsx --test tests/rectification-*.test.ts` 不可并行:默认 `JYOTISHA_POSTGRES_MAX_FIXTURES=2`,抢槽时前几个库测会报泛化 `database migration failed`。隔离重跑后绿。
## 任务 0
### 0.a 参考集锁口径
- `tests/run_real_case_revalidation.py`:`REFERENCE_AYANAMSA = "lahiri"`,引擎 argv `--ayanamsa lahiri`,报告 `reference_ayanamsa`。
- `scripts/local_accuracy_report.py` 同口径。
- 夹具大运:`base` 加 `--ayanamsa lahiri`。三栏:原值=依赖默认;新值=显式 lahiri;原因=夹具日期是 Lahiri 口径。期望日期未改。
### 0.b 标签与计算一致
- `scripts/jyotish_api_server.py` 经 `_request_ayanamsa` / `DEFAULT_AYANAMSA_NAME` / `ayanamsa_display_name`,不再写死 `'lahiri'` / `'Raman'`。
- `_request_ayanamsa` 也读 `ayanamsa_policy`,VedAstro 对照与该次请求同口径。
- `DEFAULT_AYANAMSA_NAME` 仍是 `'raman'`。
- 验收 grep(`scripts/jyotish_api_server.py` + `frontend/src`,排除 test):只剩 `frontend/src/lib/ayanamsa.ts` 选项/默认,以及 `personal-report-generation.ts` 的 `SAFE_AYANAMSA` 显示映射。
### 0.c 用户设置
- `frontend/src/lib/ayanamsa.ts`:`resolveAyanamsa`,默认 `raman`。
- 迁移:`profiles.ayanamsa text not null default 'raman'` + 四值 check + `grant update (ayanamsa)` 给 `authenticated`。
- 咨询、声明窗口、报告 worker、每日星语、合盘、校正 v9 引擎请求、生时评估 scan 均传实际岁差。
- 校正 `V9BaselineSnapshot` 新写入带 `ayanamsa`;**不进** `baselineFingerprint`。
- 岁差不进 `declarationFields` / `concurrencyFields`,改设置不 409、不清确认。
### 偏离
- 迁移目录:supabase,原因见环境备忘。
- UI 位置:星盘资料本人编辑,不是不存在的「账户与出生资料」面板。
### 命令摘要
| 命令 | 结果 |
| --- | --- |
| `python tests/run_real_case_revalidation.py` | `valid: true`,`reference_ayanamsa: lahiri`,gated **66/66**,`pass_rate: 1.0` |
| `pytest …test_fixture_dasha_timeline…` + `test_api_server_growth_contract.py` | 4 passed;夹具日期未改;API 行数 11120 |
| `scripts/user_invocation_acceptance_check.py` | `status: pass`,`checks.user_invocation_tests: true`,`external_adapter_status: complete`(本机 PyJHora 可用) |
| `npx tsc --noEmit` | 0 错 |
| `npx eslint .` | 0 error,73 既有 warning |
| 前端聚焦:ayanamsa / account-api / consultation-route-service / server-owned-birth-profile / global-birth-profile-routes / settings-mvp / rectification-v9-case-service / consultation-workflow-request / consultation-birth-accuracy / consultation-agentic-runtime / personal-report-api / rectification-v9-engine-contract | fail=0 |
| `npm run test:db`(`--test-concurrency=1`,单独跑) | **34 pass / 0 fail** |
| `npx tsx --test tests/rectification-*.test.ts` 隔离重跑库测 | ingest P0 + v9-database **10 pass / 0 fail**;未改 scorer/golden |
| `wc -l frontend/src/app/page.tsx` | 2041,与 HEAD 相同 |
产品负责人 staging 实测(虚构盘 2000-01-01 12:00 UTC 0/0:Lahiri=Swati,Raman=Vishakha)仍欠。部署 SHA 待合入 staging 后补。
## 任务 1–5
尚未开始。
+1 -1
View File
@@ -91,7 +91,7 @@
| 任务书 | 进度 | 主题 | 状态 | 落点 |
| --- | --- | --- | --- | --- |
| `TASK-repo-hygiene-20260903.md` | — | 岁差默认 Raman + 用户设置可选、参考集锁口径(P0,单独先推)、发布门本地可复现、注册表白名单、仓库地址、早期日志搬家、远端分支清理 | 待领取 | 分支 `codex/repo-hygiene-20260903` |
| `TASK-repo-hygiene-20260903.md` | `PROGRESS-repo-hygiene-20260903.md` | 岁差默认 Raman + 用户设置可选、参考集锁口径(P0,单独先推)、发布门本地可复现、注册表白名单、仓库地址、早期日志搬家、远端分支清理 | 执行中 | 分支 `codex/repo-hygiene-20260903` |
### 上游同步与能力接入