refactor(api): 抽出 offline compute mixins,关掉 2/4 处 handler 伪造
spike 闸门(任务书 §5.2)结果为红,按 §6.3 退回 A 方案。 spike:115 个闭包方法整体移入 ConsultationComputeMixin 后, tests/test_api_server_security.py 一字不改跑出 1 failed / 128 passed。 test_chart_async_job_executes_in_background 挂在 monkeypatch.setattr(jyotish_api_server, '_write_async_job_record', ...): 调用方法随 mixin 搬走后从新模块 globals 解析,补丁落在旧模块绑定上不生效。 已实证把同一 fake 打到 mixin 模块即恢复原行为,故为落点问题而非搬坏。 循环 import 不是障碍(移动集不引用 JyotishAPIHandler)。 退回 A 的实际交付:新建 scripts/offline_compute_mixins.py, 收 BadRequest、3 个模块级助手,以及 RequestParamMixin / VedastroEvidenceMixin / SynastryMixin 共 7 个方法(300 行), JyotishAPIHandler 通过继承保留全部方法,HTTP 侧零变化。 consultation_workflow_service.build_runtime_evidence_helpers 与 local_accuracy_report 改为直接实例化 mixin,不再伪造 handler。 11 个搬走的定义经 SHA-256 逐个比对与搬走前字节级相同; jyotish_api_server.py 的 diff 为 11 行插入 / 378 行删除,无重排。 scripts 侧 __new__ 4 → 2(剩 2 处都在咨询工作流链上); 类方法 225 → 218;行数 11,291 → 10,924。 合同测试收紧基线并新增 scripts 侧专门断言与反向 import 断言; 两次反向验证(加回 __new__ / 加类方法)均正确变红。 新增 tests/test_offline_compute_mixins.py 覆盖此前零覆盖的 MCP 路径, 并加入 CORE_PYTEST_TARGETS。 tests/test_api_server_security.py 一字未改,129 passed。 快速门 pytest 段 798 passed / 1 skipped / 0 failed。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JUei7K13cYxLHE3Axe4A45
This commit is contained in:
co-authored by
Claude Opus 5
parent
30f9e0943f
commit
5582091851
@@ -75,6 +75,9 @@ CORE_PYTEST_TARGETS = [
|
||||
"tests/test_birth_time_journey_contract.py",
|
||||
# Freeze scripts/jyotish_api_server.py growth; new features must be modules.
|
||||
"tests/test_api_server_growth_contract.py",
|
||||
# Pins the two closed __new__ forgeries: MCP/report scripts must keep reaching the
|
||||
# compute mixins without constructing an HTTP handler (TASK-api-server-backdoor-close).
|
||||
"tests/test_offline_compute_mixins.py",
|
||||
# Foreground VedAstro snapshot cache + join cancel (BUG-727 / BUG-728).
|
||||
"tests/test_vedastro_snapshot_cache.py",
|
||||
# Native seven-governors adapter and the three read-only chart endpoints.
|
||||
|
||||
Reference in New Issue
Block a user