Copy the full-data packet once per report, not once per domain (issue #122, BUG-1471)
read_full_data_domain deep-copied the shared worksheets on every call; a long report reads five domains twice, so ten copies for read-only use. The shared part is now copied once (full_data_domain_base) and reused for every domain's facts and their leaf check; each domain's facts are still copied out so domains share no objects. Long reports byte-identical on four fictional charts; with #121, -24–29% end to end. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DbBXoz1Qk3y9buDv1mkmTu
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
f8fa4d66ef
commit
3eeb898071
@@ -14,9 +14,11 @@ from typing import Any
|
||||
try:
|
||||
from scripts.consult_card_domain_facts import assert_fact_leaves, build_consult_card_facts, dig
|
||||
from scripts.consult_full_data_cache import _attach_graha_drishti
|
||||
from scripts.pl9_full_data_export import full_data_domain_base
|
||||
except ModuleNotFoundError: # pragma: no cover - direct scripts/ execution path
|
||||
from consult_card_domain_facts import assert_fact_leaves, build_consult_card_facts, dig
|
||||
from consult_full_data_cache import _attach_graha_drishti
|
||||
from pl9_full_data_export import full_data_domain_base
|
||||
|
||||
READING_FACTS_SCHEMA = "report-reading-facts-v1"
|
||||
READING_DOMAINS = ("general", "career", "wealth", "marriage", "health")
|
||||
@@ -87,10 +89,12 @@ def build_report_reading_facts(
|
||||
) -> dict[str, Any]:
|
||||
"""Compact, packet-sourced facts for the reading. Raises on any non-packet leaf."""
|
||||
working = _attach_graha_drishti(copy.deepcopy(packet), full_reading)
|
||||
raw = build_consult_card_facts(working, list(READING_DOMAINS), minute_confirmed=minute_confirmed)
|
||||
# One detached copy of the packet serves every domain's facts and their leaf check (issue #122).
|
||||
base = full_data_domain_base(working)
|
||||
raw = build_consult_card_facts(working, list(READING_DOMAINS), minute_confirmed=minute_confirmed, base=base)
|
||||
rows = {row["domain"]: row for row in raw["domains"]}
|
||||
for row in rows.values():
|
||||
assert_fact_leaves(working, row)
|
||||
assert_fact_leaves(working, row, base=base)
|
||||
general = rows["general"]
|
||||
planets = {}
|
||||
for name, record in general["planets"].items():
|
||||
|
||||
Reference in New Issue
Block a user