把独立年度方法参考算进结果指纹,标准版不再白算这一章。

跑了修复单点名的测试、两次真算 PyJHora,以及 200 张英文扫描。

Co-Authored-By: Grok (agent loop)
This commit is contained in:
jesse-ux
2026-10-23 23:55:06 +08:00
co-authored by Grok (agent loop)
parent 683bd2fbc3
commit c899e36509
12 changed files with 161 additions and 27 deletions
+7 -16
View File
@@ -2341,20 +2341,6 @@ def _attach_pyjhora_annual_method_reference(packet: dict, args):
return attach_pyjhora_annual_method_reference(packet, args)
def _bind_result_without_annual_method_reference(packet: dict, profile: dict) -> dict:
"""Keep the new chapter out of result_hash. The chart result itself is unchanged."""
worksheets = packet.get("worksheets") if isinstance(packet, dict) else None
timing = worksheets.get("timing_and_predictive_systems") if isinstance(worksheets, dict) else None
detached = None
if isinstance(timing, dict) and "pyjhora_annual_method_reference" in timing:
detached = timing.pop("pyjhora_annual_method_reference")
try:
return bind_result_to_profile(packet, profile)
finally:
if isinstance(timing, dict) and detached is not None:
timing["pyjhora_annual_method_reference"] = detached
def _uncertainty_minutes_from_args(args):
explicit = getattr(args, 'uncertainty_minutes', None)
if explicit not in (None, ''):
@@ -18101,12 +18087,17 @@ def build_professional_report_reference_packet(
full_reading: dict,
args,
selected_pack_ids: list[str] | None = None,
*,
include_annual_method_reference: bool = True,
) -> dict:
"""Build the public, non-writer professional reference packet for CLI and API."""
packet = build_pl9_style_export_packet(full_reading, include_raw=True)
packet = attach_calculation_profile(packet, args)
packet = _attach_annual_tajika_pack(packet, args)
packet = _attach_pyjhora_annual_method_reference(packet, args)
# The flag is decided by the API after it knows the edition. Attach before
# bind_result_to_profile so this chapter stays inside result_hash.
if include_annual_method_reference:
packet = _attach_pyjhora_annual_method_reference(packet, args)
packet = _attach_report_governance_contracts(packet, args)
packet = _attach_base_charts_pack(packet)
packet = _attach_visual_chart_pack(packet, args)
@@ -18124,7 +18115,7 @@ def build_professional_report_reference_packet(
and isinstance(profile.get('input_hash'), str)
and len(profile['input_hash']) == 64
):
delivered = _bind_result_without_annual_method_reference(delivered, profile)
delivered = bind_result_to_profile(delivered, profile)
if isinstance(delivered, dict) and delivered.get('selected_report_scope') == 'full':
evaluate_full_report = _try_attr_import('full_report_quality_gate', 'evaluate_full_report')
if evaluate_full_report is None:
+1
View File
@@ -245,6 +245,7 @@ def _assemble_professional_report_reference(
full_reading,
_export_args(birth),
packs,
include_annual_method_reference=edition == FULL_DATA_EDITION,
)
except ValueError as exc:
raise ProfessionalReportReferenceInputError(str(exc)) from exc
@@ -85,6 +85,26 @@ def reset_reference_cache() -> None:
_CACHE.clear()
def mask_report_fingerprint_lines(markdown: str) -> str:
"""Blank the report-id and result-fingerprint lines before a byte compare.
Including this chapter changes ``result_hash``, so those two identity lines
move. Everything else, after the chapter itself is stripped, must not.
"""
output: list[str] = []
for line in (markdown or "").splitlines(keepends=True):
body = line.rstrip("\r\n")
ending = line[len(body):]
stripped = body.strip()
if stripped.startswith("- 报告 ID: `") and stripped.endswith("`"):
output.append(f"- 报告 ID: `FINGERPRINT`{ending}")
elif stripped.startswith("- 计算结果摘要: `") and stripped.endswith("`"):
output.append(f"- 计算结果摘要: `FINGERPRINT`{ending}")
else:
output.append(line)
return "".join(output)
def strip_annual_method_chapter(markdown: str) -> str:
"""Drop this chapter so older full-text checks still see the previous report."""
lines = (markdown or "").splitlines(keepends=True)