fix(report): bind v2 chart cap to CHART_IDS.length

Five-theme personal_full assembled nine charts after health vargas landed, but the document schema still capped at six. Bind the count to the enum, align JSON/Python contracts, and log final-parse paths without values.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Jesse_Chen
2026-09-04 21:33:27 +08:00
co-authored by Cursor
parent d2955c6280
commit 6119469069
13 changed files with 279 additions and 21 deletions
+19
View File
@@ -316,3 +316,22 @@ def test_validator_accepts_synthetic_producer_output() -> None:
}
document["provenance"]["evidenceHash"] = compute_evidence_hash(document)
assert validate_report_document(document).valid
def test_v2_accepts_full_chart_ids_set() -> None:
from scripts.personal_report_contract import CHART_IDS
document = load_report_document(str(ROOT / "tests" / "fixtures" / "personal_report_document.v2.json"))
template = document["charts"][0]
present = {chart["id"] for chart in document["charts"]}
for chart_id in CHART_IDS:
if chart_id in present:
continue
extra = json.loads(json.dumps(template))
extra["id"] = chart_id
extra["title"] = f"{chart_id} 分盘"
document["charts"].append(extra)
assert len(document["charts"]) == len(CHART_IDS)
document["provenance"]["evidenceHash"] = compute_evidence_hash(document)
result = validate_report_document(document)
assert result.valid, result.errors