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
@@ -22,11 +22,11 @@ def execute_consultation_workflow(body: dict[str, Any], *, surface: str = "api")
|
||||
|
||||
|
||||
def build_runtime_evidence_helpers(chart: dict[str, Any]) -> dict[str, Any]:
|
||||
from jyotish_api_server import JyotishAPIHandler
|
||||
from offline_compute_mixins import VedastroEvidenceMixin
|
||||
|
||||
handler = JyotishAPIHandler.__new__(JyotishAPIHandler)
|
||||
helper = VedastroEvidenceMixin()
|
||||
return {
|
||||
"vedastro_official": handler._high_rigor_vedastro_official_summary(chart),
|
||||
"vedastro_archive_manifest": handler._compute_vedastro_gateway_archives(),
|
||||
"interpretation_coverage": handler._interpretation_source_runtime_coverage(chart),
|
||||
"vedastro_official": helper._high_rigor_vedastro_official_summary(chart),
|
||||
"vedastro_archive_manifest": helper._compute_vedastro_gateway_archives(),
|
||||
"interpretation_coverage": helper._interpretation_source_runtime_coverage(chart),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user