#307 生时用途扫描补齐缺失生产器 #321
@@ -1,5 +1,9 @@
|
||||
# 印度占星 Skill 更新日志
|
||||
|
||||
## 2026-11-17 · 用途扫描补齐分盘行星、宫主和其他计算层
|
||||
|
||||
- 离线扫描新增必要层的原生取数与边界回执。Skill 版本沿用(BUG-1953)。
|
||||
|
||||
## 2026-11-17 · 报告标示出生时间变化与自选情景
|
||||
|
||||
- 个人报告、年运和合盘的正文顶部及 Markdown 导出显示相关说明。生成中出生资料变化时提示点数已返还。占星 Skill 版本沿用(BUG-1959)。
|
||||
|
||||
@@ -26262,6 +26262,17 @@
|
||||
- 关联记录:#306、#301、BUG-1936、BUG-1872。
|
||||
- 修复版本:`codex/rect-self-choice-nearest-minute-20261117`,待独立验收。
|
||||
|
||||
## BUG-1953 | 生时用途扫描缺少宫主、分盘行星和其他层的生产器
|
||||
|
||||
- 状态:fixed-pending-verify,待独立验收。
|
||||
- 首次发现 / 最近更新:2026-11-17 / 2026-11-17。
|
||||
- 触发与现象:离线用途扫描请求宫主、分盘行星或其他计算层时,缺原生生产器和边界。分盘上升通过覆盖也无法说明同一分盘的行星位置保持稳定。
|
||||
- 根因:现有适配器只生产上升、月亮、Arudha 和部分运限,其他必要层在政策中有名字但没有计算实现。
|
||||
- 修复:逐层复用原生计算,核对换座、月相和征象星排序,依据各层已证实的依赖判断覆盖。度数尊贵与年度盘保留采样回执,Shadbala 标为方法待定。窗口输出带全区间或采样点的范围类型。
|
||||
- 验证与防复发:真实合成范围逐秒对照、几何反例、月相、分盘与征象星变化、跨日、分段接缝、多个范围与多个计算口径。记录见 [#307 进度](tasks/PROGRESS-rect-purpose-layers-20261117.md)。
|
||||
- 关联记录:#307、#304、BUG-1932、BUG-1938、BUG-1962。
|
||||
- 修复版本:`codex/rect-purpose-layers-20261117`。
|
||||
|
||||
## BUG-1954 | 占星师 2026-11-17 对问答数据口径的裁定落地:D2 不再给十二宫行,三个辅助点参与,汇合段补状态
|
||||
|
||||
- 状态:fixed-pending-verify(未推送)。
|
||||
|
||||
@@ -37,3 +37,13 @@ Narayana 与 Arudha 共用换座分段。检查相邻探针时用行星在该段
|
||||
另以 `vimshottari_date` 的范围起点为中心延展到前后各 30 分钟,设为事业、婚恋、财富的月粒度输入。A7、A10、UL、Vimshottari、Narayana 均由抽样变为有依据的覆盖。Vimshottari 的已知边界从 17 个增至 24 个。引擎计算 277 次,预算上限 4000。对同一范围另外做了 3601 次逐秒对照,五层边界均与 CLI 一致,本机耗时约 31 秒。缺生产器的层仍显示原有缺口,合并用途仍需缩小范围。
|
||||
|
||||
`test_native_coverage_matches_per_second_oracle` 对 Arudha 四层、Vimshottari 和 Narayana 分别做原生秒级对照,各取四分钟合成范围。每类至少有一条真实签名边界,两种搜索的边界逐秒一致。A1 在这项直接测试中验证,现有 CLI 用途政策不请求该层。
|
||||
|
||||
## #307 新增层的覆盖依据
|
||||
|
||||
- 宫主取出生盘的十二宫,宫主落宫、九曜落座、星座相位、八分点和两类 Yoga 取原生计算结果。这些当前选用的输出只跟随上升或行星换座。先列出可能变化的秒,两边都取数,再查每段的中点。
|
||||
- D9、D10、D2、D11 的九曜落座按各自行星黄经分段。上升与行星有各自的变化时刻。逆行跨零度时也检查分界两边,候选分界只有读回结果确实变化才留下。
|
||||
- 功能性吉凶沿用现行档案。PVR 表对部分上升的月亮另用盈亏,因此除上升换座,还检查日月距角在零度和一百八十度的两处变化。
|
||||
- 七征象星按原生座内度数排序。换座先切段,度数范围重叠时继续细分,直到能排除名次变化或逐秒读到变化。
|
||||
- 行运采用年度服务已有的慢行星整宫关系,从本命上升和月亮数宫。覆盖只评价出生范围怎样改变整宫投影,使用的天空轨迹沿用年度服务的日尺度搜索。该服务的精确合相及相位命中会使用本命度数。
|
||||
- 金星和木星的本命尊贵有座内度数门槛。年度上升则随太阳返照时刻变化。这两层当前给分钟采样及已发现变化的秒级位置。
|
||||
- Shadbala 保留方法待定。预测窗内的运限只有达到完整区间覆盖时,才有全区间包络。其他回执仅给各采样点的范围。
|
||||
|
||||
@@ -18,9 +18,9 @@
|
||||
| 分盘上升 | 调用现有 `find_lines` 的度数求界,传所需分盘及同一候选缓存。长范围分成不超过 239 分钟的计算段。分界归新段的首个秒级样本,前一秒仍属于前段。普通纬度内检查角度前进和分界两侧,高纬与异常角运动降为采样。 |
|
||||
| 上升星宿、月亮星座和星宿 | 以原生黄经和等分角度求界,两侧按原生结果核对。 |
|
||||
| Arudha | 分钟网格发现后在相邻样本间二分到秒。保留实际最大采样间隔。未排除网格内重复换段时为 `sampled_only`。 |
|
||||
| Vimshottari 与 Narayana | 复用出生时刻大运及 Rath 来源版周期。年使用大运,月增加小运,日增加 Vimshottari 的 PD,Narayana 复用已有 MD/AD。180 秒内逐秒核对,较宽范围按分钟和变化附近二分并标明仅采样。保留原始起止和父段身份。可能窗口并集保留间隙,候选交集只在有完整覆盖且真正相交时给出。 |
|
||||
| Vimshottari 与 Narayana | 复用出生时刻大运及 Rath 来源版周期。年使用大运,月增加小运,日增加 Vimshottari 的 PD,Narayana 复用已有 MD/AD。180 秒内逐秒核对,较宽范围按分钟和变化附近二分并标明仅采样。保留原始起止和父段身份。可能窗口并集保留间隙,候选交集只在有完整覆盖且真正相交时给出。Vimshottari 边界的漂移量取决于出生时月亮的运动和当时所在星宿的大运年数。漂移由引擎重算。 |
|
||||
|
||||
扫描结果区分 `policy_covered`、`sampled_only`、`incomplete`。后两态不会产生 `scope_ready`。没有边界依据时,首尾一致只说明两个观测点一致。所有回执的分辨率只保证到秒。未知用途、原生缺层、方法未决或计算失败均保留限制。现有路线的专用宫主、行运或其他未接方法仍会阻止全用途通过。
|
||||
扫描结果区分 `policy_covered`、`sampled_only`、`incomplete`。后两态不会产生 `scope_ready`。没有边界依据时,首尾一致只说明两个观测点一致。所有回执的分辨率只保证到秒。未知用途、原生缺层、方法未决或计算失败均保留限制。现有用途政策引用的必要层若仍缺相应生产器,会阻止全用途通过。
|
||||
|
||||
候选分组模块的导入路径为 `scripts.active_rectification_candidates`。用同名包承载原移植,保留 scripts 根目录的现有文件数门禁。
|
||||
|
||||
@@ -29,3 +29,9 @@
|
||||
- 结构稳定例,20 分钟内 D1、D9 上升及月亮星宿保持一致,得到 `scope_ready`。同批次记录 D60 等非用途输出的观测差异。
|
||||
- 跨 D9 例,20 秒内首个换座样本在区间内第 10 秒,前一秒与该秒的原生分盘结果不同,得到 `needs_refinement`。
|
||||
- 应期日期例,同一 Vimshottari 大运的起始在相邻两天之间移动,跨过问题内固定日期,得到 `needs_refinement`。Vimshottari 本层逐秒覆盖,现有路线的其他缺层使总体保持 `sampled_only`。用途结论保留原生证据。
|
||||
|
||||
## 分盘行星与应期窗口(#307)
|
||||
|
||||
分盘上升与分盘里的行星分别计算边界。D9、D10、D2、D11 的行星层检查九曜各自跨分段的秒,顺行与逆行都可能换座。上升在整段内稳定时,分盘行星仍可能变动。遇到行星运动方向无法核实或段内取数不一致,回执降为抽样。
|
||||
|
||||
只有完整覆盖才给出全区间包络并判断共同窗口。其余结果标为各采样点的范围,供查看已经观察到的起止和并集。
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# #307 用途扫描缺失层
|
||||
|
||||
- [任务书](TASK-rect-purpose-layers-20261117.md)。分支 `codex/rect-purpose-layers-20261117`。以 `08d44d6ce` 的 `origin/staging` 开工,合入规划方已有的任务书提交。
|
||||
- 本轮新增的层供离线政策调用。现有路由的用途政策继续使用原表。下一步的断言分组与时间粒度由 BUG-1962 处理。
|
||||
|
||||
## 生产器和覆盖
|
||||
|
||||
| 层 | 代码依据 → 实际输入 | 覆盖方法 | 合成输入回执 | 反例测试 |
|
||||
| --- | --- | --- | --- | --- |
|
||||
| `house_lords` | `jyotish_engine.compute_chart_data` → D1 上升 | 上升换座、段中点 | `policy_covered`,`depends_on_signs_only` | `test_change_without_a_matching_geometric_cut_never_gets_coverage[house_lords]` |
|
||||
| `lord_placements` | `compute_chart_data` 的宫主和行星宫位 → D1 上升、宫主星座 | 取两类换座的并集 | `policy_covered`,`depends_on_signs_only` | 同一参数化测试的 `lord_placements` |
|
||||
| `planet_signs` | `compute_chart_data` 行星落座 → 九曜原始黄经 | 核对换座及区段读值 | `policy_covered`,`depends_on_signs_only` | 同一参数化测试的 `planet_signs` |
|
||||
| `planet_vargas:D9` | `chart_choice.boundaries.varga_sign` → 九曜黄经与 D9 口径 | 顺逆向分段秒级二分,核对结果变化 | `policy_covered`,`varga_sign_from_planet_longitude` | `test_retrograde_planet_varga_detects_wrap_in_reverse_direction`。另见同一参数化反例 |
|
||||
| `planet_vargas:D10` | 同上 → 九曜黄经与 D10 口径 | 顺逆向分段及秒级对照 | `policy_covered`,`varga_sign_from_planet_longitude` | 同一参数化反例的 `planet_vargas:D10` |
|
||||
| `planet_vargas:D2` | 同上 → 九曜黄经与 D2 口径 | 候选分界须有实际落座变化 | `policy_covered`,`varga_sign_from_planet_longitude` | 同一参数化反例的 `planet_vargas:D2` |
|
||||
| `planet_vargas:D11` | 同上 → 九曜黄经与 D11 口径 | 顺逆向分段及秒级对照 | `policy_covered`,`varga_sign_from_planet_longitude` | 同一参数化反例的 `planet_vargas:D11` |
|
||||
| `functional_roles` | `functional_benefics.derive_functional_benefic_malefic` → 档案、D1 上升、PVR 月相 | 上升换座和日月距角过零或一百八十度 | `policy_covered`,`functional_roles_from_lagna_and_paksha` | 同一参数化反例的 `functional_roles` |
|
||||
| `venus_jupiter` | `compute_chart_data` 的尊贵输出 → D1 上升、落座、座内度数 | 本尊区间含度数门槛,分钟网格发现变化后定位到秒 | `sampled_only`,`dignity_depends_on_in_sign_degree` | 同一参数化反例的 `venus_jupiter` |
|
||||
| `aspects` | `jaimini._rasi_drishti` → D1 星座 | 换座加段内验证 | `policy_covered`,`depends_on_signs_only` | 同一参数化反例的 `aspects` |
|
||||
| `chara_karakas` | `jaimini.calc_chara_karaka_7` → 七曜座内度数 | 换座切段,重叠的度数范围递归细分 | `policy_covered`,`karaka_order_from_in_sign_degrees` | `test_karaka_finds_and_separates_two_rank_changes_between_minute_samples` |
|
||||
| `ashtakavarga` | `ashtakavarga.calc_ashtakavarga` → 七曜星座与 D1 上升 | 换座及段中点,只投影 BAV、SAV 宫分 | `policy_covered`,`depends_on_signs_only` | 同一参数化反例的 `ashtakavarga` |
|
||||
| `wealth_yogas` | `yogas_doshas.calc_dhana_yogas` → 星座、整宫位置和宫主 | 换座及段中点,保留命中项和组合 | `policy_covered`,`depends_on_signs_only` | 同一参数化反例的 `wealth_yogas` |
|
||||
| `raj_yogas` | `yogas_doshas.calc_raj_yogas` → 星座、整宫位置和宫主 | 换座及段中点,检测器查看星座相对位置 | `policy_covered`,`depends_on_signs_only` | 同一参数化反例的 `raj_yogas` |
|
||||
| `transit_relations` | `annual_service.package._slow_transits`、`_house` → 预测窗慢行星入座、本命上升和月亮座 | 复用慢行星天空轨迹,只比较两组整宫关系 | `policy_covered`,`transit_relations_from_natal_lagna_moon` | 同一参数化反例的 `transit_relations` |
|
||||
| `annual_chart` | `solar_return.find_solar_return_ut`、`_muntha_from_natal_ascendant` → 本命太阳求解口径、出生年、地点和上升 | 分钟网格发现变化再二分,分钟内是否存在往返仍待核 | `sampled_only`,`solar_return_ascendant_between_samples_unproven` | 同一参数化反例的 `annual_chart` |
|
||||
| `strength_shadbala` | 方法待核 | 固定回执 | `incomplete`,`method_unresolved`,`shadbala_pending_review` | `test_shadbala_is_explicitly_unavailable_without_invoking_strength_calculation` |
|
||||
|
||||
## 验证
|
||||
|
||||
- 隔离 Linux 容器中的 Python 快速门(`--profile quick --skip-frontend-runtime`)通过。仓库隐私标记测试 62 项通过。
|
||||
- 新增与既有定向套件合计 113 项通过,另有 26 个子测试通过。16 个生产层的四分钟真实合成范围逐秒对照均与各自回执一致。ESLint 零错误,63 条既有警告。
|
||||
- 预检的 Python、外部引擎适配器与 Gitea 远端可见性通过。Windows 碎片扫描及定向预检分别在既有 90 秒、45 秒预算内超时。
|
||||
- `test_offline_cli_input_runs_all_layers_within_the_candidate_budget` 由 CLI 入口读 ±30 分钟、月粒度的合成 JSON。测试在构造 scope 后指定上表全部层,复用同一候选缓存。实测计算 259 次,预算 4000,未耗尽。各层回执见上表。
|
||||
- 年度服务的精确合相和精确相位读取本命上升及九曜的原始黄经,见 `annual_service.package._natal_chart` 和 `NATAL_POINTS`。本次行运层输出慢行星相对上升或月亮的整宫关系。出生范围覆盖只评价该宫位投影,天空轨迹沿用年度服务的日尺度搜索。时间回执区分 `sampled_points_range` 与 `full_interval_envelope`。只有完整区间覆盖可判定共同窗口。
|
||||
@@ -7,6 +7,7 @@
|
||||
- 被环境或依赖挡住的事项写进根目录 `BLOCKED.md`;Bug 事实写进 `docs/BUG_HISTORY.md`;两者不在这里重复。
|
||||
- 纯文档改动不触发 staging 门禁(见 `deploy/gated-paths.txt`)。
|
||||
|
||||
- [用途扫描缺失层(#307)](PROGRESS-rect-purpose-layers-20261117.md) — 原生计算、分钟网格和逐秒边界对照。
|
||||
- [报告出生输入标示(#313)](PROGRESS-rect-artifact-marking-20261117.md) — 详情、Markdown 导出、合盘写入复核及返还。
|
||||
- [旧聊天出生依据过期(#314)](PROGRESS-rect-stale-chat-evidence-20261117.md) — 历史上下文、摘要与聊天分隔。
|
||||
- [生时纠正用户自选情景(#312)](PROGRESS-rect-self-choice-scenario-20261117.md) — 换座列表、保存重放校验及聊天口径。
|
||||
|
||||
@@ -0,0 +1,94 @@
|
||||
# 生时纠正用途扫描:补齐缺生产器的层(2026-11-17,Claude)
|
||||
|
||||
Bug 编号:BUG-1953(#307)。关联 BUG-1932(#297)、BUG-1938(#304)。后续 BUG-1962(用途政策 v2,排队)。
|
||||
|
||||
## 背景
|
||||
|
||||
#297 的用途扫描对事业、钱财、婚恋给不出「够用」,因为问题路由要求的一批层没有生产器,一律 `blocked`。#304 已经用算法性质给 Arudha、Vimshottari、Narayana 补了覆盖依据。
|
||||
|
||||
占星师 11-17 裁定:各用途所需层以仓内已有清单(`references/technique_registry.json` 的 routes、`scripts/consultation_plan_contract.py` 的 `required_layers`)为起点,再补上实际参与断言的层:分盘里的行星位置、功能性吉凶星、宫主与尊贵、相位、Yoga、力量与 Ashtakavarga、Jaimini 征象星、行运、年度盘。只列进清单不算执行;某层算不了时只限制依赖它的断言。
|
||||
|
||||
**本单只做生产器和覆盖判定**(每层「在这个出生时间范围内会不会变、在哪一秒变」)。用途政策(哪个用途要哪些层、按断言分组、时间粒度怎么判)留给 BUG-1962,本单不改 `scope._policy`,只让新层可以被政策引用。
|
||||
|
||||
## 一、要补的层
|
||||
|
||||
每层在 `scripts/rectification_purpose_gate/native.py` 的 `compute` 里给出输出值,在 `providers.py` 里给出边界提供器。层名固定如下(政策引用用这些名字):
|
||||
|
||||
| 层名 | 输出值 | 出生时间通过什么影响它 |
|
||||
|---|---|---|
|
||||
| `house_lords` | 12 个宫的宫主(D1) | 只随 D1 上升星座变 |
|
||||
| `lord_placements` | 12 个宫主各自落在 D1 的哪一宫 | D1 上升星座、宫主所在星座 |
|
||||
| `planet_signs` | 九曜在 D1 的星座 | 各行星换座时刻 |
|
||||
| `planet_vargas:D9` / `:D10` / `:D2` / `:D11` | 九曜在该分盘的星座 | 各行星在该分盘的换座时刻(月亮最快) |
|
||||
| `functional_roles` | 现行功能性吉凶星档案下各星的角色 | 先读 `scripts/functional_benefics.py`:至少依赖上升星座;PVR 档案还依赖月相(日月距角),把实际输入全部列出 |
|
||||
| `venus_jupiter` | 金星、木星的 D1 宫位与星座、尊贵级别 | 上升星座、两星换座 |
|
||||
| `aspects` | D1 星座相位(Rasi drishti)关系表 | 只随星座变 |
|
||||
| `chara_karakas` | 七/八征象星分配(AK…DK,含 AmK、DK) | 各行星**星座内度数的先后顺序**,月亮最快;用 `scripts/jaimini.py` 的现有函数,按仓内默认的 7 或 8 征象星设置 |
|
||||
| `ashtakavarga` | BAV 与 SAV 各宫分数 | 先读 `scripts/ashtakavarga.py::calc_ashtakavarga` 确认只用星座位置 |
|
||||
| `wealth_yogas` / `raj_yogas` | 命中的 Yoga 名单 | 用现有检测器;先读它依赖什么(星座、宫位、宫主,还是度数、燃烧、合相容许度) |
|
||||
| `transit_relations` | 本次预测窗内行运相对本命的关系(从上升、从月亮数宫;若现有行运模块还用本命度数,一并列出) | 本命上升星座、月亮星座(及模块实际用到的本命度数) |
|
||||
| `annual_chart` | 预测窗内每个年度盘的年度上升星座与 Muntha 星座 | 先读现有年度盘模块(`scripts/annual_tajika_pack.py` / `solar_return.py` / `muntha.py`):年度盘时刻取决于本命太阳度数,出生时间差 1 小时太阳约差 2.5 角分,年度上升可能整座改变 |
|
||||
| `strength_shadbala` | 不计算 | 见第三节 |
|
||||
|
||||
产出值一律复用仓内现有计算函数,不新写占星算法。现有函数需要的输入从 `_chart` 已算出的结果里取,不重复排盘。
|
||||
|
||||
## 二、覆盖依据
|
||||
|
||||
和 #304 一样:只有能从代码证明「这层只在某些时刻会变」的,才给 `policy_covered`,并写 `basis`;证明不了的给 `sampled_only`,不硬套。
|
||||
|
||||
1. **只随星座变的层**(`house_lords`、`lord_placements`、`planet_signs`、`venus_jupiter`、`aspects`、`ashtakavarga` 若确认只用星座):边界只能出现在上升或行星换座时刻。复用 #304 的 `_sign_layout_factory`(上升 + 九曜换座枚举),在每个候选时刻前后一秒取值,变了的才记为边界;每段中点抽查。`basis` 写 `depends_on_signs_only`。
|
||||
2. **分盘行星位置**(`planet_vargas:*`):每颗行星在分盘的换座时刻 = 该行星黄经跨过 `30°/n` 整数倍的时刻。按 `_sector_provider` 的办法求(分钟网格找跨界、二分到秒),逆行两个方向都认。`basis` 写 `varga_sign_from_planet_longitude`。
|
||||
3. **功能性吉凶**:若代码确认只依赖上升星座(和月相),边界 = 上升换座 ∪ 日月距角跨 0°/180° 的时刻(后者按 2 的办法求)。`basis` 写 `functional_roles_from_lagna_and_paksha`。代码依赖更多时降为 `sampled_only` 并在 PROGRESS 写明。
|
||||
4. **征象星**:分配只随「星座内度数的大小顺序」变。边界 = 任意两颗参与排序的行星星座内度数相等的时刻(月亮与其他星最常见)。用分钟网格看排序是否改变、二分到秒;相邻网格点之间各行星度数变化区间若会交叉,加密网格。证明成立给 `policy_covered`,`basis` 写 `karaka_order_from_in_sign_degrees`;否则 `sampled_only`。
|
||||
5. **Yoga**:检测器只用星座/宫位/宫主时按第 1 条;用到度数或容许度的,`sampled_only`,`reason` 写具体依赖。
|
||||
6. **行运关系**:行运本身与出生时间无关。若代码确认它对出生时间的依赖只有本命上升星座和月亮星座(和列明的本命度数),这层的边界 = 这些量的边界(复用现有上升、月亮星座提供器)。`basis` 写 `transit_relations_from_natal_lagna_moon`。
|
||||
7. **年度盘**:没有解析边界的,`sampled_only`;用分钟网格发现变化后二分到秒,回执写明「网格发现 + 二分」,不声称排除了分钟内的往返变化。
|
||||
|
||||
所有提供器沿用 #297 的回执格式和 `_receipt` 的降级规则,不放宽。
|
||||
|
||||
## 三、力量层(Shadbala)
|
||||
|
||||
占星师 11-17:网站本地 Shadbala 在她验收前只能作「方法待核」的参考,不得用于校时排除或确定性判断。同时 BUG-1961(另一窗口)在隐藏没有出处的强弱档位。
|
||||
|
||||
本单:`strength_shadbala` 层不计算,回执固定为 `state = incomplete`、`reason = method_unresolved`、`method_id = shadbala_pending_review`。政策引用它时,只会限制依赖它的断言(BUG-1962 处理分组)。**不改** `scripts/` 下任何 Shadbala 计算文件。
|
||||
|
||||
## 四、扫描器与已知缺陷的修正
|
||||
|
||||
占星师对 BUG-1932 的三处意见,本单一并处理:
|
||||
|
||||
1. 文档里「出生时间差 1 分钟,Vimshottari 边界约移动 3.8 天」这句通用比例删掉(`docs/research/rect-purpose-scan-20261116.md` 和相关 PROGRESS 中出现的地方),改成「漂移量取决于出生时月亮的运动和所在星宿的大运年数,由引擎重算,不用常数」。代码里若有用这个常数做容差的,改为不用。
|
||||
2. 分盘上升的边界不等于分盘的全部输出边界——本单的 `planet_vargas:*` 就是为此补的;在 `docs/research/rect-purpose-scan-20261116.md` 末尾追加一段说明这一点和现在的覆盖范围。
|
||||
3. 采样点之间的最早最晚不等于全区间包络:检查 `timing.py::period_envelopes`,确认只有在该层 `policy_covered` 时才把结果称为包络、否则只叫「各采样点的范围」;补一条测试锁住。另补测试:240 分钟分段的接缝处、跨午夜的范围、多段范围、不同岁差/交点参数分支,各一条,确认没有漏检。
|
||||
|
||||
## 五、测试
|
||||
|
||||
新文件 `tests/test_rectification_purpose_layers.py`:
|
||||
|
||||
- 每个新层:一条确定性假函数的反例(星座没变但值变了 → 不给覆盖;排序在两网格点之间交叉 → 被检出);一条真实引擎的逐秒对照(4 分钟合成范围,每类至少有一条真实边界,提供器的边界与逐秒扫描完全一致)。
|
||||
- 月亮在 D9/D10 的分盘换座、月亮与另一星度数交叉改变 DK/AmK、月相跨 180° 改变功能角色,各至少一条真实引擎用例(找不到合适的合成时刻就写明在 PROGRESS,不要伪造)。
|
||||
- `strength_shadbala` 回执固定为方法待定。
|
||||
- 第四节第 3 条的四条扫描器测试。
|
||||
- `tests/test_rectification_purpose_scan.py`、`test_rectification_purpose_binding.py`、`test_rectification_purpose_coverage.py`、`test_active_rectification_candidates.py`、`test_rectification_purpose_gate.py` 照旧通过,不删改旧断言。
|
||||
|
||||
命令行核对:用 `python -m scripts.rectification_purpose_gate --input <json>` 跑一个 ±30 分钟、月粒度、把本单全部新层列为所需层的合成输入(测试里直接改 `scope["policy"]["required_layers"]`,不改政策),把各层状态、`basis`、计算次数写进 PROGRESS;计算次数不超过默认预算 4000,超过就写明并说明原因。
|
||||
|
||||
## 六、不做的事
|
||||
|
||||
- 不改 `scope._policy` 和用途政策表(BUG-1962)。
|
||||
- 不接任何生产入口(API、页面、聊天都不导入新代码)。
|
||||
- 不改 `scripts/chart_choice/`、`frontend/`、`scripts/report_render/`、`references/`。
|
||||
- 不改任何现有占星计算函数的结果;发现现有函数有错,写进 PROGRESS,不在本单修。
|
||||
- 不计算、不使用 Shadbala。
|
||||
|
||||
## 七、文档
|
||||
|
||||
- `docs/BUG_HISTORY.md` 在 BUG-1953 一节记录(没有就新增;只在自己那一节内编辑;不写姓名、出生资料、邮箱、ID)。
|
||||
- `CHANGELOG.md` 一行;`docs/tasks/PROGRESS-rect-purpose-layers-20261117.md`:每层一行,写「代码依据(文件和函数)→ 依赖的输入 → 覆盖方法 → 状态 → 反例测试名」。
|
||||
- `docs/research/rect-purpose-coverage-20261117.md` 末尾追加新层的覆盖依据,用普通话写,会转给占星师审。
|
||||
|
||||
## 验收
|
||||
|
||||
- `PATH=<venv>/bin:$PATH python scripts/run_quality_gate.py --profile quick --skip-frontend-runtime` 通过;
|
||||
- 新测试全部通过,每个新层至少一条反例和一条逐秒对照;
|
||||
- `cd frontend && npx eslint .` 0 错误(本单不应有前端改动);
|
||||
- 没有任何生产入口导入 `scripts/rectification_purpose_gate`(验收时会 grep);diff 不含第六节列出的路径。
|
||||
@@ -79,7 +79,7 @@ def scan_scope(scope_request: dict, compute_at, boundary_providers: dict) -> dic
|
||||
1. **分盘上升换座**:复用 `scripts/chart_choice/boundaries.py::find_lines`(它已按度数求解精确时刻)。所需分盘不在 `TRACKED_DIVISIONS` 里的(如 D3、D7、D11),用同一求解方法扩展,可以给 `find_lines` 传 `divisions` 参数,不要改它的默认值。
|
||||
2. **D1 上升、上升星宿、月亮星座与星宿**:同样按度数求解,不靠分钟网格。
|
||||
3. **Arudha(A1、A7、A10、UL)**:没有解析边界,用分钟网格发现变化后在相邻两点间二分到秒级,回执里写明「网格发现 + 二分」,最大未检查间隔写实际值。
|
||||
4. **大运边界**:对用途的预测窗,取范围内各候选时刻下相关 Vimshottari(到政策要求的层级)和 Narayana 周期的起止日期,给出每条边界的最早、最晚、并集、交集。提醒:出生时间差 1 分钟,Vimshottari 边界约移动 3.8 天,范围越宽包络越宽,这是预期结果,不是错误。
|
||||
4. **大运边界**:对用途的预测窗,取范围内各候选时刻下相关 Vimshottari(到政策要求的层级)和 Narayana 周期的起止日期,给出每条边界的最早、最晚、并集、交集。Vimshottari 边界的漂移量取决于出生时月亮的运动和当时所在星宿的大运年数。漂移由引擎重算。
|
||||
|
||||
判定规则:
|
||||
|
||||
|
||||
@@ -0,0 +1,202 @@
|
||||
"""Native projections for the optional offline purpose layers."""
|
||||
|
||||
from datetime import timezone
|
||||
from functools import cache
|
||||
|
||||
from scripts.chart_choice import boundaries
|
||||
|
||||
# Use the same engines as the native chart adapter.
|
||||
import ashtakavarga
|
||||
import domain_calculation_service
|
||||
import functional_benefics
|
||||
import jaimini
|
||||
import solar_return
|
||||
import yogas_doshas
|
||||
|
||||
from scripts.annual_service import package as annual
|
||||
|
||||
from .scope import profile_clock
|
||||
|
||||
GRAHAS = ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu")
|
||||
PLANET_VARGAS = {f"planet_vargas:D{division}": division for division in (9, 10, 2, 11)}
|
||||
SIGN_LAYERS = frozenset({
|
||||
"house_lords", "lord_placements", "planet_signs", "aspects", "ashtakavarga",
|
||||
"wealth_yogas", "raj_yogas",
|
||||
})
|
||||
LAYER_NAMES = SIGN_LAYERS | PLANET_VARGAS.keys() | {
|
||||
"functional_roles", "venus_jupiter", "chara_karakas", "transit_relations",
|
||||
"annual_chart", "strength_shadbala",
|
||||
}
|
||||
|
||||
|
||||
def _functional_roles(asc_sign, planets, profile):
|
||||
paksha = functional_benefics.moon_paksha_from_planets(planets)
|
||||
result = functional_benefics.derive_functional_benefic_malefic(
|
||||
asc_sign, functional_profile=profile, moon_paksha=paksha,
|
||||
)
|
||||
if result["status"] != "used" or result["blocked_planets"]:
|
||||
return None
|
||||
return {
|
||||
"profile": result["profile"],
|
||||
"benefics": result["functional_benefics"],
|
||||
"malefics": result["functional_malefics"],
|
||||
"neutrals": result["functional_neutrals"],
|
||||
"yogakarakas": result["yogakarakas"],
|
||||
}
|
||||
|
||||
|
||||
def _ashtakavarga(planet_rows, asc_index):
|
||||
result = ashtakavarga.calc_ashtakavarga(planet_rows, asc_index)
|
||||
return {
|
||||
"bav": {
|
||||
name: [house["sav_score"] for house in ashtakavarga._map_to_houses_values(row["bindus"], asc_index).values()]
|
||||
for name, row in result["bav"].items()
|
||||
},
|
||||
"sav": [row["sav_score"] for row in result["house_scores"].values()],
|
||||
}
|
||||
|
||||
|
||||
def _yogas(detector, planet_rows, house_lords):
|
||||
houses = {f"H{i}_Lord": lord for i, lord in house_lords.items()}
|
||||
matches = detector(planet_rows, houses)["yogas"]
|
||||
return {"matches": [
|
||||
{"name": name, "subtype": subtype, "combination": combination}
|
||||
for name, subtype, combination in sorted({
|
||||
(row["type"], row.get("subtype", ""), row.get("combination", "")) for row in matches
|
||||
})
|
||||
]}
|
||||
|
||||
|
||||
def _transit_sky(forecast, ayanamsa, node_mode):
|
||||
start, end = forecast
|
||||
# Only the portions of the annual transit producer that are common to every natal chart.
|
||||
# Its exact conjunction and aspect queries need natal longitudes and are separate outputs.
|
||||
ctx = annual._Context({
|
||||
"birth": {"year": start.year, "month": start.month, "day": start.day,
|
||||
"hour": start.hour, "minute": start.minute, "tz": 0},
|
||||
"observation_date": start.date(), "ayanamsa": ayanamsa, "node_mode": node_mode,
|
||||
})
|
||||
snapshot = annual._slow_transits(ctx, {
|
||||
"status": "computed", "lagna_sign_idx": 0, "moon_sign_idx": 0, "longitudes": {},
|
||||
}, start, end)
|
||||
return [
|
||||
(body, start.isoformat(), annual.SIGNS.index(row["sign"]))
|
||||
for body, row in snapshot["positions_at_range_start"].items()
|
||||
] + [
|
||||
(row["body"], row["instant"]["utc"], annual.SIGNS.index(row["to_sign"]))
|
||||
for row in snapshot["events"] if row["kind"] == "ingress"
|
||||
]
|
||||
|
||||
|
||||
def _annual_charts(at, profile, asc_index, forecast):
|
||||
start, end = forecast
|
||||
birth_year = profile_clock(at, profile).year
|
||||
if start < at:
|
||||
return None
|
||||
with domain_calculation_service.swiss_ephemeris_lock():
|
||||
jd = solar_return._datetime_to_jd_ut(at)
|
||||
# Match calc_solar_return_chart's solver-frame Sun instead of rerunning the natal chart.
|
||||
target = solar_return._get_sun_lon_jd(jd, ayanamsa_name=profile["ayanamsa"])
|
||||
if target is None:
|
||||
return None
|
||||
returns = []
|
||||
for year in range(max(birth_year, start.year - 1), end.year + 1):
|
||||
solar = solar_return.find_solar_return_ut(jd, target, year, ayanamsa_name=profile["ayanamsa"])
|
||||
if solar.get("method") != "swisseph_newton":
|
||||
return None
|
||||
instant = solar["dt_ut"].replace(tzinfo=timezone.utc)
|
||||
if instant < end:
|
||||
returns.append((instant, year))
|
||||
active = [row for row in returns if row[0] <= start]
|
||||
relevant = active[-1:] + [row for row in returns if start < row[0]]
|
||||
charts = []
|
||||
for instant, year in relevant:
|
||||
request = boundaries.ChartRequest(instant.date().isoformat(), profile["lat"], profile["lon"], 0,
|
||||
profile["ayanamsa"], profile["node_mode"])
|
||||
asc = boundaries.ascendant_longitude(request, instant)
|
||||
muntha = solar_return._muntha_from_natal_ascendant(asc_index, year - birth_year)
|
||||
charts.append({"year": year, "ascendant_sign": boundaries.varga_sign(asc, 1),
|
||||
"muntha_sign": muntha["muntha_sign_idx"]})
|
||||
return {"charts": charts} if charts else None
|
||||
|
||||
|
||||
def native_layer_values(required, forecast):
|
||||
layers = LAYER_NAMES.intersection(required)
|
||||
|
||||
@cache
|
||||
def sky(ayanamsa, node_mode):
|
||||
return _transit_sky(forecast, ayanamsa, node_mode)
|
||||
|
||||
def compute(at, profile, chart, asc, planets, ref, output):
|
||||
values = {}
|
||||
if not layers:
|
||||
return values
|
||||
asc_index = boundaries.varga_sign(asc, 1)
|
||||
asc_sign = chart["ascendant"]["sign"]
|
||||
planet_rows = chart["planets"]
|
||||
has_grahas = all(name in planets and planet_rows[name].get("sign") in annual.SIGNS for name in GRAHAS)
|
||||
house_lords = {str(i): chart["houses"].get(f"house_{i}", {}).get("lord") for i in range(1, 13)}
|
||||
has_lords = all(house_lords.values())
|
||||
for layer in sorted(layers):
|
||||
if layer == "house_lords":
|
||||
value, method, dependencies = (house_lords if has_lords else None, "native_d1_house_lords", ["lagna_sign"])
|
||||
elif layer == "lord_placements":
|
||||
value = {i: planet_rows.get(lord, {}).get("house") for i, lord in house_lords.items()}
|
||||
value, method, dependencies = (
|
||||
value if has_lords and all(value.values()) else None, "native_d1_lord_placements",
|
||||
["lagna_sign", "planet_signs"],
|
||||
)
|
||||
elif layer == "planet_signs":
|
||||
value = {name: planet_rows[name]["sign"] for name in GRAHAS} if has_grahas else None
|
||||
method, dependencies = "native_d1_planet_signs", ["planet_longitudes"]
|
||||
elif layer in PLANET_VARGAS:
|
||||
value = {name: boundaries.varga_sign(planets[name], PLANET_VARGAS[layer])
|
||||
for name in GRAHAS} if has_grahas else None
|
||||
method, dependencies = "native_divisional_planet_signs", ["planet_longitudes", "varga_mode"]
|
||||
elif layer == "functional_roles":
|
||||
profile_id = profile.get("functional_profile", functional_benefics.DEFAULT_FUNCTIONAL_PROFILE)
|
||||
value = _functional_roles(asc_sign, planets, profile_id)
|
||||
method, dependencies = "native_functional_roles", ["lagna_sign", "moon_paksha", "functional_profile"]
|
||||
elif layer == "venus_jupiter":
|
||||
value = {
|
||||
name: {key: planet_rows[name][key] for key in ("sign", "house", "status")}
|
||||
for name in ("Venus", "Jupiter")
|
||||
} if has_grahas else None
|
||||
method, dependencies = "native_d1_venus_jupiter", ["lagna_sign", "planet_signs", "planet_degrees_in_sign"]
|
||||
elif layer == "aspects":
|
||||
value = {
|
||||
name: [target for target in range(12)
|
||||
if jaimini._rasi_drishti(boundaries.varga_sign(planets[name], 1), target)]
|
||||
for name in GRAHAS
|
||||
} if has_grahas else None
|
||||
method, dependencies = "native_jaimini_rasi_drishti", ["planet_signs"]
|
||||
elif layer == "chara_karakas":
|
||||
degrees = {name: planets[name] % 30 for name in GRAHAS[:7]} if has_grahas else {}
|
||||
table = jaimini.calc_chara_karaka_7(degrees)["karaka_table"] if degrees else {}
|
||||
value = {role: row["planet"] for role, row in table.items()} or None
|
||||
method, dependencies = "native_chara_karakas_7", ["seven_planet_degrees_in_sign"]
|
||||
elif layer == "ashtakavarga":
|
||||
value = _ashtakavarga(planet_rows, asc_index) if has_grahas else None
|
||||
method, dependencies = "native_ashtakavarga_bav_sav", ["lagna_sign", "planet_signs"]
|
||||
elif layer in ("wealth_yogas", "raj_yogas"):
|
||||
detector = yogas_doshas.calc_dhana_yogas if layer == "wealth_yogas" else yogas_doshas.calc_raj_yogas
|
||||
value = _yogas(detector, planet_rows, house_lords) if has_lords and has_grahas else None
|
||||
method, dependencies = detector.__name__, ["lagna_sign", "planet_signs", "house_lords"]
|
||||
elif layer == "transit_relations":
|
||||
value = {"whole_sign_relations": [
|
||||
{"body": body, "at": instant, "sign": sign, "from_lagna": annual._house(sign, asc_index),
|
||||
"from_moon": annual._house(sign, boundaries.varga_sign(planets["Moon"], 1))}
|
||||
for body, instant, sign in sky(profile["ayanamsa"], profile["node_mode"])
|
||||
]} if forecast and "Moon" in planets else None
|
||||
method, dependencies = "native_whole_sign_slow_transits", ["lagna_sign", "moon_sign", "forecast_window"]
|
||||
elif layer == "annual_chart":
|
||||
value = _annual_charts(at, profile, asc_index, forecast) if forecast else None
|
||||
method, dependencies = (
|
||||
"native_solar_return_and_muntha", ["candidate_at", "natal_sun_longitude", "lagna_sign", "forecast_window", "profile"],
|
||||
)
|
||||
else:
|
||||
value, method, dependencies = None, "shadbala_pending_review", []
|
||||
values[layer] = output(value, method, ref, dependencies)
|
||||
return values
|
||||
|
||||
return compute
|
||||
@@ -15,6 +15,7 @@ import dasha_analyzer
|
||||
import domain_calculation_service
|
||||
import jaimini
|
||||
|
||||
from .layer_values import native_layer_values
|
||||
from .scope import fingerprint, profile_clock, stamp
|
||||
|
||||
NATIVE_METHOD_VERSION = "purpose-native-v1"
|
||||
@@ -135,6 +136,7 @@ def native_scope_compute(scope: dict):
|
||||
required = policy["required_layers"]
|
||||
forecast_data = scope["purpose_scope"]["forecast_window"]
|
||||
forecast = _window(forecast_data) if forecast_data is not None else None
|
||||
layer_values = native_layer_values(required, forecast)
|
||||
|
||||
def compute(at: datetime, branch: str) -> dict:
|
||||
at = stamp(at)
|
||||
@@ -178,6 +180,7 @@ def native_scope_compute(scope: dict):
|
||||
outputs[layer] = _vimshottari(at, moon, forecast, policy["vimshottari_depth"], ref)
|
||||
elif layer == "Narayana" and forecast:
|
||||
outputs[layer] = _narayana(at, int(asc // 30), planets, forecast, policy["narayana_depth"], ref)
|
||||
outputs.update(layer_values(at, profile, chart, asc, planets, ref, _output))
|
||||
return {
|
||||
**packet, "outputs": outputs,
|
||||
"raw": {"ascendant_longitude": asc, "moon_longitude": moon, "planet_longitudes": planets,
|
||||
|
||||
@@ -11,6 +11,7 @@ from scripts.active_rectification_candidates import MAX_WINDOW_MINUTES
|
||||
from scripts.chart_choice.boundaries import ChartRequest, find_lines
|
||||
from scripts.dasha_common import VIMSHOTTARI_YEARS
|
||||
|
||||
from .layer_values import GRAHAS, PLANET_VARGAS, SIGN_LAYERS
|
||||
from .native import ANGLE_DIMENSIONS, ARUDHAS, division_of
|
||||
from .scan import BoundaryMethodUnavailable
|
||||
from .scope import SECOND, range_limits, stamp
|
||||
@@ -19,7 +20,6 @@ from .timing import TIMING_OUTPUTS, output_periods, period_signature
|
||||
MINUTE = timedelta(minutes=1)
|
||||
CHUNK = timedelta(minutes=MAX_WINDOW_MINUTES - 1)
|
||||
TIMING_EXACT_SECONDS = 180
|
||||
GRAHAS = ("Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn", "Rahu", "Ketu")
|
||||
DATE_ROUNDING = timedelta(microseconds=2)
|
||||
|
||||
|
||||
@@ -202,7 +202,7 @@ def _planet_direction(rows, name):
|
||||
return all(_longitude_delta(a, b) * speeds[0] > 0 for a, b in pairwise(values))
|
||||
|
||||
|
||||
def _sign_layout_factory(profiles):
|
||||
def _sign_layout_factory(profiles, planets=GRAHAS):
|
||||
@cache
|
||||
def layout(start, end, branch, sample):
|
||||
profile = profiles[branch]
|
||||
@@ -226,14 +226,14 @@ def _sign_layout_factory(profiles):
|
||||
asc_values = [asc(at) for at in probes]
|
||||
if not all(_ascending_enough(a, b) for a, b in pairwise(asc_values)):
|
||||
return grid, [], False
|
||||
if not all(_planet_direction(rows, name) for name in GRAHAS):
|
||||
if not all(_planet_direction(rows, name) for name in planets):
|
||||
return grid, [], False
|
||||
|
||||
req = ChartRequest(start.date().isoformat(), profile["lat"], profile["lon"], 0,
|
||||
profile["ayanamsa"], profile["node_mode"])
|
||||
cuts = {line.at for left, right in pairwise(_grid(start, end, CHUNK))
|
||||
for line in find_lines(req, left, right, (1,), longitude_at=asc)}
|
||||
for name in GRAHAS:
|
||||
for name in planets:
|
||||
def sign(at):
|
||||
return int(_planet_longitude(row(at), name) // 30)
|
||||
|
||||
@@ -242,7 +242,7 @@ def _sign_layout_factory(profiles):
|
||||
return grid, [], False
|
||||
|
||||
checked = [observed[at] for at in sorted(observed)]
|
||||
bounded = all(_planet_direction(checked, name) for name in GRAHAS)
|
||||
bounded = all(_planet_direction(checked, name) for name in planets)
|
||||
return grid, sorted(cuts), bounded
|
||||
|
||||
return layout
|
||||
@@ -253,29 +253,177 @@ def _executed_output(sample, at, branch, layer):
|
||||
return output if output and output["status"] == "executed" else None
|
||||
|
||||
|
||||
def _arudha_provider(layer, sign_layout):
|
||||
def _layer_reader(sample, branch, layer):
|
||||
def value(at):
|
||||
output = _executed_output(sample, at, branch, layer)
|
||||
return output["value"] if output else None
|
||||
|
||||
return value
|
||||
|
||||
|
||||
def _constant(points, value):
|
||||
expected = value(points[0])
|
||||
return expected is not None and all(value(at) == expected for at in points[1:])
|
||||
|
||||
|
||||
def _partition_provider(layer, layout, basis, method="sign_change_enumeration"):
|
||||
def provider(item, sample):
|
||||
start, end = range_limits(item)
|
||||
branch = item["branch_id"]
|
||||
|
||||
def value(at):
|
||||
output = _executed_output(sample, at, branch, layer)
|
||||
return output["value"] if output else None
|
||||
|
||||
grid, candidates, bounded = sign_layout(start, end, branch, sample)
|
||||
if bounded:
|
||||
segments = [set(map(value, points)) for points in _segment_probes(start, end, candidates, grid)]
|
||||
bounded = all(len(values) == 1 and None not in values for values in segments)
|
||||
if bounded:
|
||||
value = _layer_reader(sample, branch, layer)
|
||||
grid, candidates, bounded = layout(start, end, branch, sample)
|
||||
if bounded and all(_constant(points, value)
|
||||
for points in _segment_probes(start, end, candidates, grid)):
|
||||
cuts = [at for at in candidates if value(at - SECOND) != value(at)]
|
||||
return _details("sign_change_enumeration", grid, cuts, bounded=True,
|
||||
basis="arudha_depends_on_signs_only")
|
||||
return _details("minute_grid_then_second_bisection", grid, _discover_changes(grid, value),
|
||||
return _details(method, grid, cuts, bounded=True, basis=basis)
|
||||
probes = sorted(set(_with_midpoints(grid)) | set(candidates))
|
||||
return _details("minute_grid_then_second_bisection", probes, _discover_changes(probes, value),
|
||||
bounded=False, reason="scan_incomplete")
|
||||
|
||||
return provider
|
||||
|
||||
|
||||
def _arudha_provider(layer, sign_layout):
|
||||
return _partition_provider(layer, sign_layout, "arudha_depends_on_signs_only")
|
||||
|
||||
|
||||
def _planet_varga_layout(division):
|
||||
def layout(start, end, branch, sample):
|
||||
grid = list(_grid(start, end, MINUTE))
|
||||
probes = _with_midpoints(grid)
|
||||
rows = {at: sample(at, branch) for at in probes}
|
||||
try:
|
||||
if not all(_planet_direction(list(rows.values()), name) for name in GRAHAS):
|
||||
return grid, [], False
|
||||
cuts = set()
|
||||
for name in GRAHAS:
|
||||
def sector(at):
|
||||
if at not in rows:
|
||||
rows[at] = sample(at, branch)
|
||||
longitude = _planet_longitude(rows[at], name)
|
||||
# The existing varga engine indexes equal parts separately within each sign.
|
||||
sign = int(longitude // 30)
|
||||
return sign * division + int((longitude - sign * 30) / (30 / division))
|
||||
|
||||
cuts.update(_discover_changes(probes, sector))
|
||||
checked = [rows[at] for at in sorted(rows)]
|
||||
bounded = all(_planet_direction(checked, name) for name in GRAHAS)
|
||||
except BoundaryMethodUnavailable:
|
||||
return grid, [], False
|
||||
return grid, sorted(cuts), bounded
|
||||
|
||||
return layout
|
||||
|
||||
|
||||
def _functional_layout(lagna_layout):
|
||||
def layout(start, end, branch, sample):
|
||||
grid, lagna_cuts, lagna_bounded = lagna_layout(start, end, branch, sample)
|
||||
probes = _with_midpoints(grid)
|
||||
|
||||
def elongation(at):
|
||||
row = sample(at, branch)
|
||||
return (_planet_longitude(row, "Moon") - _planet_longitude(row, "Sun")) % 360
|
||||
|
||||
try:
|
||||
speeds = [(sample(at, branch).get("raw") or {}).get("planet_speeds", {}) for at in probes]
|
||||
forward = all(
|
||||
all(isinstance(value, (int, float)) and isfinite(value) for value in pair)
|
||||
and pair[0] > pair[1]
|
||||
for pair in ((row.get("Moon"), row.get("Sun")) for row in speeds)
|
||||
) and all(0 < _longitude_delta(elongation(left), elongation(right)) < 2
|
||||
for left, right in pairwise(probes))
|
||||
cuts = _discover_changes(probes, lambda at: int(elongation(at) // 180))
|
||||
except BoundaryMethodUnavailable:
|
||||
return grid, lagna_cuts, False
|
||||
return grid, sorted(set(lagna_cuts) | set(cuts)), lagna_bounded and forward
|
||||
|
||||
return layout
|
||||
|
||||
|
||||
def _karaka_ranges_separate(before, after):
|
||||
spans = sorted(
|
||||
sorted((_planet_longitude(before, name) % 30, _planet_longitude(after, name) % 30))
|
||||
for name in GRAHAS[:7]
|
||||
)
|
||||
return all(left[1] < right[0] for left, right in pairwise(spans))
|
||||
|
||||
|
||||
def _karaka_provider(sign_layout):
|
||||
def provider(item, sample):
|
||||
start, end = range_limits(item)
|
||||
branch = item["branch_id"]
|
||||
value = _layer_reader(sample, branch, "chara_karakas")
|
||||
grid, sign_cuts, bounded = sign_layout(start, end, branch, sample)
|
||||
checked = {}
|
||||
|
||||
def row(at):
|
||||
if at not in checked:
|
||||
checked[at] = sample(at, branch)
|
||||
return checked[at]
|
||||
|
||||
cuts = set()
|
||||
|
||||
def search(left, right):
|
||||
first, last = value(left), value(right)
|
||||
if first is None or last is None:
|
||||
return False
|
||||
before, after = row(left), row(right)
|
||||
if right - left <= SECOND:
|
||||
if first != last:
|
||||
cuts.add(right)
|
||||
return True
|
||||
mid = _midpoint(left, right)
|
||||
if _karaka_ranges_separate(before, after):
|
||||
row(mid)
|
||||
return first == last == value(mid)
|
||||
left_checked = search(left, mid)
|
||||
right_checked = search(mid, right)
|
||||
return left_checked and right_checked
|
||||
|
||||
if bounded:
|
||||
try:
|
||||
for points in _segment_probes(start, end, sign_cuts, grid):
|
||||
if len(points) == 1 and value(points[0]) is None:
|
||||
bounded = False
|
||||
for left, right in pairwise(points):
|
||||
if not search(left, right):
|
||||
bounded = False
|
||||
segment_rows = [checked[at] for at in sorted(checked) if points[0] <= at <= points[-1]]
|
||||
if not segment_rows:
|
||||
segment_rows = [row(points[0])]
|
||||
if not all(_planet_direction(segment_rows, name) for name in GRAHAS[:7]):
|
||||
bounded = False
|
||||
except BoundaryMethodUnavailable:
|
||||
bounded = False
|
||||
if bounded:
|
||||
cuts.update(at for at in sign_cuts if value(at - SECOND) != value(at))
|
||||
return _details("degree_range_refinement_to_second", sorted(set(grid) | checked.keys()), sorted(cuts),
|
||||
bounded=True, basis="karaka_order_from_in_sign_degrees")
|
||||
probes = sorted(set(grid) | checked.keys() | set(sign_cuts))
|
||||
cuts.update(_discover_changes(probes, value))
|
||||
return _details("degree_range_refinement_to_second", probes, sorted(cuts), bounded=False,
|
||||
reason="degree_order_unresolved")
|
||||
|
||||
return provider
|
||||
|
||||
|
||||
def _sampled_layer(layer, reason):
|
||||
def provider(item, sample):
|
||||
start, end = range_limits(item)
|
||||
points = list(_grid(start, end, MINUTE))
|
||||
value = _layer_reader(sample, item["branch_id"], layer)
|
||||
return _details("minute_grid_then_second_bisection", points, _discover_changes(points, value),
|
||||
bounded=False, reason=reason)
|
||||
|
||||
return provider
|
||||
|
||||
|
||||
def _shadbala_pending(item, sample):
|
||||
start, end = range_limits(item)
|
||||
return {**_details("shadbala_pending_review", [start, end], [], bounded=False, reason="method_unresolved"),
|
||||
"state": "incomplete"}
|
||||
|
||||
|
||||
def _degree_order_fixed(rows):
|
||||
# Narayana's strength and dual-lord rules compare unrounded degrees,
|
||||
# with Ketu measured from the far end of its sign.
|
||||
@@ -432,6 +580,9 @@ def native_boundary_providers(scope: dict) -> dict:
|
||||
profiles = scope["profiles"]
|
||||
purpose = scope["purpose_scope"]
|
||||
sign_layout = _sign_layout_factory(profiles)
|
||||
lagna_layout = _sign_layout_factory(profiles, ())
|
||||
lagna_moon_layout = _sign_layout_factory(profiles, ("Moon",))
|
||||
classical_planet_layout = _sign_layout_factory(profiles, GRAHAS[:7])
|
||||
moon_layout = _sector_provider("moon_nakshatra", profiles)
|
||||
providers = {}
|
||||
for layer in scope["policy"]["required_layers"]:
|
||||
@@ -442,6 +593,25 @@ def native_boundary_providers(scope: dict) -> dict:
|
||||
providers[layer] = moon_layout if layer == "moon_nakshatra" else _sector_provider(layer, profiles)
|
||||
elif layer in ARUDHAS:
|
||||
providers[layer] = _arudha_provider(layer, sign_layout)
|
||||
elif layer in SIGN_LAYERS:
|
||||
layout = lagna_layout if layer == "house_lords" else sign_layout
|
||||
providers[layer] = _partition_provider(layer, layout, "depends_on_signs_only")
|
||||
elif layer in PLANET_VARGAS:
|
||||
providers[layer] = _partition_provider(layer, _planet_varga_layout(PLANET_VARGAS[layer]),
|
||||
"varga_sign_from_planet_longitude", "planet_degree_crossing")
|
||||
elif layer == "functional_roles":
|
||||
providers[layer] = _partition_provider(layer, _functional_layout(lagna_layout),
|
||||
"functional_roles_from_lagna_and_paksha", "lagna_and_paksha_crossing")
|
||||
elif layer == "venus_jupiter":
|
||||
providers[layer] = _sampled_layer(layer, "dignity_depends_on_in_sign_degree")
|
||||
elif layer == "chara_karakas":
|
||||
providers[layer] = _karaka_provider(classical_planet_layout)
|
||||
elif layer == "transit_relations" and purpose["forecast_window"] is not None:
|
||||
providers[layer] = _partition_provider(layer, lagna_moon_layout, "transit_relations_from_natal_lagna_moon")
|
||||
elif layer == "annual_chart" and purpose["forecast_window"] is not None:
|
||||
providers[layer] = _sampled_layer(layer, "solar_return_ascendant_between_samples_unproven")
|
||||
elif layer == "strength_shadbala":
|
||||
providers[layer] = _shadbala_pending
|
||||
elif layer in TIMING_OUTPUTS and purpose["forecast_window"] is not None:
|
||||
providers[layer] = _timing_provider(layer, purpose["forecast_window"], purpose["granularity"],
|
||||
sign_layout, moon_layout)
|
||||
|
||||
@@ -59,7 +59,7 @@ def _union(windows: list[tuple]) -> list[dict]:
|
||||
|
||||
|
||||
def period_envelopes(candidates: list[dict], layer: str, policy_covered: bool) -> list[dict]:
|
||||
"""Keep each observed native window; an empty intersection stays null."""
|
||||
"""Return interval envelopes for proved coverage, and sampled ranges otherwise."""
|
||||
periods = {}
|
||||
for candidate in candidates:
|
||||
output = candidate["outputs"].get(layer)
|
||||
@@ -77,6 +77,7 @@ def period_envelopes(candidates: list[dict], layer: str, policy_covered: bool) -
|
||||
common = _window(max(starts), min(ends)) if complete and max(starts) < min(ends) else None
|
||||
envelopes.append({
|
||||
"period_id": key, "coverage": "all_candidates" if complete else "observed_candidates_only",
|
||||
"scope": "full_interval_envelope" if complete else "sampled_points_range",
|
||||
"earliest_start": min(starts).isoformat(), "latest_start": max(starts).isoformat(),
|
||||
"earliest_end": min(ends).isoformat(), "latest_end": max(ends).isoformat(),
|
||||
"possible_windows": _union(windows), "common_window": common,
|
||||
|
||||
@@ -0,0 +1,274 @@
|
||||
"""Offline purpose-layer projections, real edge scans, and conservative counterexamples."""
|
||||
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from functools import cache
|
||||
from itertools import pairwise
|
||||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from scripts.rectification_purpose_gate import __main__ as cli
|
||||
from scripts.rectification_purpose_gate.layer_values import GRAHAS, LAYER_NAMES
|
||||
from scripts.rectification_purpose_gate.native import native_scope_compute
|
||||
from scripts.rectification_purpose_gate.providers import CHUNK, native_boundary_providers
|
||||
from scripts.rectification_purpose_gate.scan import scan_scope
|
||||
from scripts.rectification_purpose_gate.scope import SECOND, build_scope_request, range_limits, stamp
|
||||
from scripts.rectification_purpose_gate.timing import period_envelopes
|
||||
|
||||
START = datetime(2000, 1, 1, tzinfo=timezone.utc)
|
||||
BRANCH = "synthetic"
|
||||
FIXTURE = Path(__file__).with_name("fixtures") / "rectification_purpose_scan_20261116.json"
|
||||
SAMPLED = {"venus_jupiter", "annual_chart"}
|
||||
ASC_EDGE = "2000-01-01T01:37:25+00:00"
|
||||
SKY_EDGE = "2000-01-02T06:12:39+00:00"
|
||||
EDGES = {
|
||||
"house_lords": ASC_EDGE,
|
||||
"lord_placements": ASC_EDGE,
|
||||
"planet_signs": SKY_EDGE,
|
||||
"planet_vargas:D2": "2000-01-01T00:13:32+00:00",
|
||||
"planet_vargas:D9": "2000-01-01T03:32:03+00:00",
|
||||
"planet_vargas:D10": "2000-01-01T00:13:32+00:00",
|
||||
"planet_vargas:D11": "2000-01-01T02:55:56+00:00",
|
||||
"functional_roles": "2000-01-21T04:40:27+00:00",
|
||||
"venus_jupiter": ASC_EDGE,
|
||||
"aspects": SKY_EDGE,
|
||||
"chara_karakas": "2000-01-01T05:33:59+00:00",
|
||||
"ashtakavarga": ASC_EDGE,
|
||||
"wealth_yogas": ASC_EDGE,
|
||||
"raj_yogas": ASC_EDGE,
|
||||
"transit_relations": ASC_EDGE,
|
||||
"annual_chart": "2000-01-01T00:23:22+00:00",
|
||||
}
|
||||
|
||||
|
||||
def _packet(start, end, *, lon=None):
|
||||
packet = json.loads(FIXTURE.read_text(encoding="utf-8"))["vimshottari_date"]["input"]
|
||||
packet["question"].update(
|
||||
granularity="month", forecast_start="2026-01-01T00:00:00+00:00",
|
||||
forecast_end="2027-01-01T00:00:00+00:00", target_boundaries=[],
|
||||
)
|
||||
packet["remaining_ranges"] = [{"start": start.isoformat(), "end": end.isoformat()}]
|
||||
if lon is not None:
|
||||
packet["profiles"]["branches"][BRANCH]["lon"] = lon
|
||||
return packet
|
||||
|
||||
|
||||
def _scope(packet, layers):
|
||||
scope = build_scope_request(packet["question"], packet["original_input"], packet["remaining_ranges"],
|
||||
packet["profiles"], packet["evaluated_at"])
|
||||
# Isolate these producers without changing the question routing policy.
|
||||
scope["policy"]["required_layers"] = sorted(layers)
|
||||
return scope
|
||||
|
||||
|
||||
def _second_edges(sample, item, layer):
|
||||
start, end = range_limits(item)
|
||||
branch = item["branch_id"]
|
||||
points = [start + SECOND * count for count in range(int((end - start) / SECOND) + 1)]
|
||||
values = [sample(at, branch)["outputs"][layer]["value"] for at in points]
|
||||
assert all(value is not None for value in values)
|
||||
return [at for at, (before, after) in zip(points[1:], pairwise(values)) if before != after]
|
||||
|
||||
|
||||
@pytest.mark.parametrize("layer,edge", EDGES.items())
|
||||
def test_real_edges_match_every_second(layer, edge):
|
||||
at = stamp(edge)
|
||||
packet = _packet(at - 120 * SECOND, at + 120 * SECOND, lon=-45 if layer == "functional_roles" else None)
|
||||
scope = _scope(packet, [layer])
|
||||
sample = cache(native_scope_compute(scope))
|
||||
item = scope["plausible_ranges"][0]
|
||||
details = native_boundary_providers(scope)[layer](item, sample)
|
||||
assert details["state"] == ("sampled_only" if layer in SAMPLED else "policy_covered"), details
|
||||
assert details["boundaries"] == _second_edges(sample, item, layer)
|
||||
assert at in details["boundaries"]
|
||||
before, after = sample(at - SECOND, BRANCH), sample(at, BRANCH)
|
||||
left, right = [row["outputs"][layer]["value"] for row in (before, after)]
|
||||
if layer in {"planet_vargas:D9", "planet_vargas:D10"}:
|
||||
assert left["Moon"] != right["Moon"]
|
||||
if layer == "functional_roles":
|
||||
raw = [row["raw"] for row in (before, after)]
|
||||
assert int(raw[0]["ascendant_longitude"] // 30) == int(raw[1]["ascendant_longitude"] // 30)
|
||||
phase = [int(((r["planet_longitudes"]["Moon"] - r["planet_longitudes"]["Sun"]) % 360) // 180) for r in raw]
|
||||
assert phase == [0, 1]
|
||||
assert "Moon" in left["malefics"] and "Moon" in right["neutrals"]
|
||||
if layer == "chara_karakas":
|
||||
assert any(left[role] != right[role] and "Moon" in (left[role], right[role])
|
||||
for role in ("Darakaraka", "Amatyakaraka"))
|
||||
if layer == "annual_chart":
|
||||
assert [row["ascendant_sign"] for row in left["charts"]] != [row["ascendant_sign"] for row in right["charts"]]
|
||||
|
||||
|
||||
def _mock_value(value, layer):
|
||||
return {"status": "executed", "value": value, "method_id": "synthetic", "result_ref": f"test:{layer}"}
|
||||
|
||||
|
||||
def _fake(layer, value, *, geometry=None, ascendant=lambda _: 15):
|
||||
def sample(at, branch):
|
||||
tick = int((at - START) / SECOND)
|
||||
lons = {name: index * 30 + 1 + index * 1.6 for index, name in enumerate(GRAHAS)}
|
||||
speeds = dict.fromkeys(GRAHAS, 0.0)
|
||||
lons["Moon"] += tick * 0.0002
|
||||
speeds["Moon"] = 17.28
|
||||
if geometry:
|
||||
geometry(tick, lons, speeds)
|
||||
asc = ascendant(tick)
|
||||
return {"candidate_at": at.isoformat(), "branch_id": branch, "profile": {},
|
||||
"outputs": {layer: _mock_value(value(tick, lons, asc), layer)},
|
||||
"raw": {"ascendant_longitude": asc, "moon_longitude": lons["Moon"],
|
||||
"planet_longitudes": lons, "planet_speeds": speeds}}
|
||||
|
||||
return cache(sample)
|
||||
|
||||
|
||||
@pytest.mark.parametrize("layer", sorted(LAYER_NAMES - {"strength_shadbala"}))
|
||||
def test_change_without_a_matching_geometric_cut_never_gets_coverage(layer):
|
||||
scope = _scope(_packet(START, START + 120 * SECOND), [layer])
|
||||
sample = _fake(layer, lambda tick, *_: {"value": "before" if tick < 30 else "after"})
|
||||
receipt = native_boundary_providers(scope)[layer](scope["plausible_ranges"][0], sample)
|
||||
assert receipt["state"] == "sampled_only"
|
||||
assert "basis" not in receipt
|
||||
assert receipt["boundaries"] == [START + 30 * SECOND]
|
||||
|
||||
|
||||
def test_karaka_finds_and_separates_two_rank_changes_between_minute_samples():
|
||||
layer = "chara_karakas"
|
||||
scope = _scope(_packet(START, START + 60 * SECOND), [layer])
|
||||
|
||||
def geometry(tick, lons, speeds):
|
||||
lons.update(Moon=33.9 + tick / 240, Sun=4.0, Mars=64.06)
|
||||
speeds["Moon"] = 360
|
||||
|
||||
sample = _fake(layer, lambda tick, lons, asc: sorted(GRAHAS[:7], key=lambda name: lons[name] % 30, reverse=True),
|
||||
geometry=geometry)
|
||||
item = scope["plausible_ranges"][0]
|
||||
details = native_boundary_providers(scope)[layer](item, sample)
|
||||
assert details["state"] == "policy_covered"
|
||||
assert details["boundaries"] == _second_edges(sample, item, layer)
|
||||
assert len(details["boundaries"]) == 2
|
||||
assert all(START < edge < START + 60 * SECOND for edge in details["boundaries"])
|
||||
|
||||
|
||||
def test_retrograde_planet_varga_detects_wrap_in_reverse_direction():
|
||||
layer = "planet_vargas:D9"
|
||||
scope = _scope(_packet(START, START + 60 * SECOND), [layer])
|
||||
|
||||
def geometry(tick, lons, speeds):
|
||||
lons["Rahu"] = (0.025 - tick / 1000) % 360
|
||||
speeds["Rahu"] = -86.4
|
||||
|
||||
sample = _fake(layer, lambda tick, lons, asc: {"Rahu": int(lons["Rahu"] // 30)}, geometry=geometry)
|
||||
item = scope["plausible_ranges"][0]
|
||||
details = native_boundary_providers(scope)[layer](item, sample)
|
||||
assert details["state"] == "policy_covered"
|
||||
assert details["boundaries"] == _second_edges(sample, item, layer) == [START + 26 * SECOND]
|
||||
|
||||
|
||||
def test_shadbala_is_explicitly_unavailable_without_invoking_strength_calculation(monkeypatch):
|
||||
import shadbala
|
||||
|
||||
def unexpected_strength(*args, **kwargs):
|
||||
pytest.fail("The offline purpose scan must never compute Shadbala")
|
||||
|
||||
monkeypatch.setattr(shadbala, "calc_shadbala", unexpected_strength)
|
||||
layer = "strength_shadbala"
|
||||
scope = _scope(_packet(START, START + 60 * SECOND), [layer])
|
||||
compute = native_scope_compute(scope)
|
||||
output = compute(START, BRANCH)["outputs"][layer]
|
||||
assert (output["status"], output["value"], output["method_id"]) == ("blocked", None, "shadbala_pending_review")
|
||||
assessment = scan_scope(scope, compute, native_boundary_providers(scope))
|
||||
receipt = assessment["per_layer_scan_receipts"][0]
|
||||
assert (receipt["state"], receipt["reason"], receipt["method_id"], receipt["boundary_times"]) == (
|
||||
"incomplete", "method_unresolved", "shadbala_pending_review", [],
|
||||
)
|
||||
|
||||
|
||||
def test_scan_deduplicates_boundary_on_the_240_minute_chunk_seam():
|
||||
layer = "D1"
|
||||
scope = _scope(_packet(START, START + timedelta(minutes=240)), [layer])
|
||||
seam = int(CHUNK / SECOND)
|
||||
sample = _fake(layer, lambda tick, lons, asc: int(asc // 30), ascendant=lambda tick: 30 + (tick - seam) / 6000)
|
||||
item = scope["plausible_ranges"][0]
|
||||
details = native_boundary_providers(scope)[layer](item, sample)
|
||||
assert details["boundaries"] == [START + CHUNK]
|
||||
assert details["state"] == "policy_covered"
|
||||
|
||||
|
||||
def test_midnight_range_keeps_the_exact_boundary():
|
||||
layer = "D1"
|
||||
scope = _scope(_packet(START - 4 * SECOND, START + 4 * SECOND), [layer])
|
||||
sample = _fake(layer, lambda tick, lons, asc: int(asc // 30), ascendant=lambda tick: 30 + tick / 6000)
|
||||
item = scope["plausible_ranges"][0]
|
||||
assert native_boundary_providers(scope)[layer](item, sample)["boundaries"] == [START]
|
||||
|
||||
|
||||
def test_disjoint_ranges_do_not_compose_a_bridge_or_duplicate_boundaries():
|
||||
layer = "D1"
|
||||
packet = _packet(START - 4 * SECOND, START + 4 * SECOND)
|
||||
packet["remaining_ranges"].append({"start": (START + 14 * SECOND).isoformat(),
|
||||
"end": (START + 28 * SECOND).isoformat()})
|
||||
scope = _scope(packet, [layer])
|
||||
sample = _fake(layer, lambda tick, lons, asc: int(asc // 30),
|
||||
ascendant=lambda tick: 30 + tick / 6000 if tick < 14 else 60 + (tick - 20) / 6000)
|
||||
bound_profile = scope["profiles"][BRANCH]
|
||||
|
||||
def bound_sample(at, branch):
|
||||
return {**sample(at, branch), "profile": bound_profile}
|
||||
|
||||
result = scan_scope(scope, bound_sample, native_boundary_providers(scope))
|
||||
receipts = result["per_layer_scan_receipts"]
|
||||
assert [r["boundary_times"] for r in receipts] == [[START.isoformat()], [(START + 20 * SECOND).isoformat()]]
|
||||
assert all(r["state"] == "policy_covered" for r in receipts)
|
||||
assert all(not START + 4 * SECOND < stamp(row["candidate_at"]) < START + 14 * SECOND
|
||||
for row in result["candidates"])
|
||||
|
||||
|
||||
def test_ayanamsa_and_node_branches_compare_independently():
|
||||
layer = "planet_signs"
|
||||
at = stamp(SKY_EDGE)
|
||||
packet = _packet(at - 120 * SECOND, at + 120 * SECOND)
|
||||
branches = packet["profiles"]["branches"]
|
||||
branches["alternate"] = {**branches[BRANCH], "ayanamsa": "raman", "node_mode": "true"}
|
||||
bounds = packet["remaining_ranges"][0]
|
||||
packet["remaining_ranges"] = [{**bounds, "branch_id": branch} for branch in branches]
|
||||
scope = _scope(packet, [layer])
|
||||
sample = cache(native_scope_compute(scope))
|
||||
provider = native_boundary_providers(scope)[layer]
|
||||
for item in scope["plausible_ranges"]:
|
||||
details = provider(item, sample)
|
||||
assert details["boundaries"] == _second_edges(sample, item, layer)
|
||||
assert sample(at, BRANCH)["raw"]["planet_longitudes"]["Rahu"] != sample(at, "alternate")["raw"]["planet_longitudes"]["Rahu"]
|
||||
|
||||
|
||||
def test_incomplete_timing_returns_sample_ranges_rather_than_a_full_envelope():
|
||||
layer = "Vimshottari"
|
||||
row = {"period_id": "md", "start": START.isoformat(), "end": (START + 60 * SECOND).isoformat()}
|
||||
output = {**_mock_value("native_periods", layer), "periods": [row]}
|
||||
candidates = [{"candidate_id": "test", "branch_id": BRANCH, "outputs": {layer: output}}]
|
||||
partial, = period_envelopes(candidates, layer, False)
|
||||
assert partial["scope"] == "sampled_points_range" and partial["common_window"] is None
|
||||
complete, = period_envelopes(candidates, layer, True)
|
||||
assert complete["scope"] == "full_interval_envelope" and complete["common_window"] is not None
|
||||
|
||||
|
||||
def test_offline_cli_input_runs_all_layers_within_the_candidate_budget(tmp_path, monkeypatch, capsys):
|
||||
packet_path = tmp_path / "synthetic.json"
|
||||
packet_path.write_text(json.dumps(_packet(START - 1800 * SECOND, START + 1800 * SECOND)), encoding="utf-8")
|
||||
|
||||
def with_layers(*args):
|
||||
scope = build_scope_request(*args)
|
||||
scope["policy"]["required_layers"] = sorted(LAYER_NAMES)
|
||||
return scope
|
||||
|
||||
monkeypatch.setattr(cli, "build_scope_request", with_layers)
|
||||
monkeypatch.setattr(sys, "argv", ["rectification_purpose_gate", "--input", str(packet_path)])
|
||||
assert cli.main() == 0
|
||||
result = json.loads(capsys.readouterr().out)["purpose_assessment"]
|
||||
assert result["budget"]["candidates_computed"] <= result["budget"]["candidate_limit"] == 4000
|
||||
assert not result["budget"]["exhausted"]
|
||||
receipts = {r["layer"]: r for r in result["per_layer_scan_receipts"]}
|
||||
assert receipts.keys() == LAYER_NAMES
|
||||
assert {layer for layer, r in receipts.items() if r["state"] == "sampled_only"} == SAMPLED
|
||||
assert receipts["strength_shadbala"]["state"] == "incomplete"
|
||||
assert all(r["basis"] for layer, r in receipts.items() if layer not in SAMPLED | {"strength_shadbala"})
|
||||
Reference in New Issue
Block a user