From e0b6bec875ec0e05c5f82fa1e41b8b581ab5f59d Mon Sep 17 00:00:00 2001 From: busya Date: Fri, 9 Oct 2026 21:30:18 +0300 Subject: [PATCH] fix(fixtures): align the baseline graph and pin with the current contracts Follow-up to a5969af3, which gave the catalog entry the native_result the contract requires. Two consequences had to be carried through. 1. The declared pin now carries that native_result. resolve_baseline_pin returns it for the metric entry, so the fixture's own baseline_pin - which the resolver oracle in test_baseline_resolver.py is built from - must declare the same block; otherwise the oracle asserted a pin the resolver could never produce. The migration script syncs it from the entry revision rather than duplicating it. 2. _GRAPH_WITH_REF no longer carries an unbound compare_to_baseline step. A graph holds its baseline references declaratively in `baselines`, and that is what graph_has_baseline_refs reads (baseline_resolver.py:60-63) and what needs_pin consults - the step is not the reference. A v1 graph may not carry that step at all: runner_plan.py:144-150 refuses the shape as UNBOUND_BASELINE_GRAPH before the resolver runs, which is why two start_run tests in this file read as a regex mismatch rather than as the refusal they target. The step becomes a literal assertion, so the derived plan stays non-empty (an empty plan would mark a walked run passed without executing anything) while the resolver still sees a graph with baseline refs and no explicit selector. The test's own assertion graph_has_baseline_refs(...) is True keeps holding. Measured with the Molecular CoT digest: the NATIVE_RESULT_CATALOG_INVALID EXPLORE records that dominated this suite are gone, and nothing replaced them. execution 3 failed / 411 passed -> 414 passed; registry 12 failed / 968 passed; scenario 414 passed. No production code touched. --- .../execution/test_baseline_resolver.py | 8 +- scripts/migrate_catalog_native_result.py | 26 +++++- .../fixtures/production-contract-refresh.json | 84 ++++++++++++++++++- 3 files changed, 114 insertions(+), 4 deletions(-) diff --git a/backend/tests/services/dashboard_testing/execution/test_baseline_resolver.py b/backend/tests/services/dashboard_testing/execution/test_baseline_resolver.py index 407d66943..4c7d89b64 100644 --- a/backend/tests/services/dashboard_testing/execution/test_baseline_resolver.py +++ b/backend/tests/services/dashboard_testing/execution/test_baseline_resolver.py @@ -62,10 +62,16 @@ for _entry in EXPECTED_PIN["entries"]: _entry["reference_source"] = deepcopy(_REFERENCE_SOURCE) _SCENARIO = "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaa1" _REVISION = "bbbbbbbb-bbbb-4bbb-8bbb-bbbbbbbbbbb1" +# A graph carries its baseline references declaratively in `baselines`, which is what +# graph_has_baseline_refs reads (baseline_resolver.py:60-63) and what needs_pin consults. The step +# is not the reference, and a v1 graph may not carry an unbound compare_to_baseline step at all: +# runner_plan.py:144-150 refuses that shape as UNBOUND_BASELINE_GRAPH before the resolver is +# reached. It is therefore a literal assertion, which keeps the derived plan non-empty while the +# resolver still sees a graph with baseline refs and no explicit selector. _GRAPH_WITH_REF = { "action_registry_version": ACTION_REGISTRY_VERSION, "action_registry_hash": action_registry_fingerprint(), - "steps": [{"logical_step_id": "cmp", "tool": "assertion", "action": "compare_to_baseline"}], + "steps": [{"logical_step_id": "assert-044", "tool": "assertion", "action": "structural_assert"}], "dependencies": [], "baselines": {"revenue_sum": {"reference": "ss-prod-visual"}}, } diff --git a/scripts/migrate_catalog_native_result.py b/scripts/migrate_catalog_native_result.py index 3ad4a4391..677c6eccc 100644 --- a/scripts/migrate_catalog_native_result.py +++ b/scripts/migrate_catalog_native_result.py @@ -59,6 +59,20 @@ PATH = Path(__file__).resolve().parents[0] / ".." / "specs" / "044-dashboard-sce TABLE_INDEX = 1 +def sync_pin_native_result(data: dict) -> int: + """The pin declares what resolution returns; the metric entry now carries a native_result.""" + by_baseline = {wrapper["baseline_id"]: wrapper["entry"] + for wrapper in data["catalog_revision"]["entry_revisions"]} + synced = 0 + for pin_entry in data["baseline_pin"].get("entries", []): + entry = by_baseline.get(pin_entry.get("baseline_id")) + block = (entry or {}).get("native_result") + if block is not None and pin_entry.get("native_result") != block: + pin_entry["native_result"] = json.loads(json.dumps(block)) + synced += 1 + return synced + + def canonical_holders(data: dict, entry: dict): """Every canonical table the fixture repeats: the entry's own and both comparison sides.""" yield entry["expected"]["canonical"] @@ -101,8 +115,16 @@ def main() -> int: revision = data["catalog_revision"] wrapper = revision["entry_revisions"][TABLE_INDEX] entry = wrapper["entry"] - if "native_result" in entry and "canonical" not in entry.get("expected", {}): - raise SystemExit("fixture already carries a native_result block; nothing to migrate") + already = "native_result" in entry and "canonical" not in entry.get("expected", {}) + if already: + # Idempotent second half: the declared pin must return what the resolver now produces from + # this entry, which includes the native_result block the pin oracle did not carry before. + synced = sync_pin_native_result(data) + print(f"entry already migrated; pin entries synced: {synced}") + if "--write" in sys.argv: + PATH.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8") + print(f"written: {PATH}") + return 0 entry.setdefault("dataset_id", 4) canonical = entry["expected"]["canonical"] diff --git a/specs/044-dashboard-scenario-execution/fixtures/production-contract-refresh.json b/specs/044-dashboard-scenario-execution/fixtures/production-contract-refresh.json index 1958ae212..50f2e34e2 100644 --- a/specs/044-dashboard-scenario-execution/fixtures/production-contract-refresh.json +++ b/specs/044-dashboard-scenario-execution/fixtures/production-contract-refresh.json @@ -32,7 +32,89 @@ "source_response_hash": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", "expected_image_sha256": null, "capture_artifact_id": "77777777-7777-4777-8777-777777777778", - "capture_profile_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "capture_profile_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", + "native_result": { + "schema_version": 1, + "authority_record": { + "schema_version": 1, + "descriptor": { + "schema_version": 1, + "canonicalization_version": 1, + "query_semantics_sha256": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc", + "chart_id": 34, + "dataset_id": 4, + "selected_metric": "revenue_by_region", + "columns": [ + { + "name": "region", + "generic_type_code": 1, + "nullable": false + }, + { + "name": "revenue_by_region", + "generic_type_code": 0, + "nullable": false + }, + { + "name": "orders", + "generic_type_code": 0, + "nullable": false + } + ], + "native_request": { + "content_ref": "draft:77777777-7777-4777-8777-777777777778:329f97a0db2cc20f1ea65811a6b75dca1626991e140dedc77e37fcfa6d4f9f97", + "sha256": "329f97a0db2cc20f1ea65811a6b75dca1626991e140dedc77e37fcfa6d4f9f97" + }, + "kind": "table", + "scope": "native_query_result", + "key_columns": [ + "region" + ] + }, + "descriptor_sha256": "54d2485d152bc4e9c89e65a0b2eaf16de98149843bd17a5fd844cb6a749e5c46", + "result_identity_sha256": "565a3bb6cd83fe2f4c348ae84c47221bd122fa0cc85d5de3ae32d1cd6f6acec9", + "capture_artifact_id": "77777777-7777-4777-8777-777777777778", + "capture_content_ref": "draft:77777777-7777-4777-8777-777777777778:eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "source_response_hash": "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", + "canonical_value_digest": "cbd92b356fb8329dd2ae67dbc4c8a426fe4c716d5284ebc5925c8a0419eef422", + "context_sha256": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" + }, + "authority_record_sha256": "aad3cdeba98c5566f4be68210447da59cab1a9580e79e5eccc5656f6689f2d53", + "policy_snapshot": { + "schema_version": 1, + "result_identity_sha256": "565a3bb6cd83fe2f4c348ae84c47221bd122fa0cc85d5de3ae32d1cd6f6acec9", + "comparison_policy": { + "type": "row_set", + "amount": null, + "ratio": null, + "min": null, + "max": null, + "min_inclusive": true, + "max_inclusive": true, + "keys": [ + "region" + ], + "order_sensitive": false, + "allow_extra_rows": false, + "per_column": { + "revenue_by_region": { + "type": "exact", + "amount": null, + "ratio": null, + "min": null, + "max": null, + "min_inclusive": true, + "max_inclusive": true, + "keys": null, + "order_sensitive": true, + "allow_extra_rows": false, + "per_column": null + } + } + } + }, + "policy_sha256": "88808f5139bbf0c5a5b4f2f9c042f1bcd90a8c2d5c56dbd1b1788f055bfbf66f" + } } ] },