test(metric): migrate the captured admission fixture past the query-schema change

25 registry tests refused with METRIC_CONTEXT_STALE before reaching the behaviour
they assert.  The raise site is metric_admission.py:110 (_validate_context), not
metric_authority_context.py:43: admission requires the graph's stored query dict
to equal the current schema's own model_dump and its stored
query_model_fingerprint to equal the hash of that dump.

Root cause, measured: commit c805513e (a WIP Stage-1 checkpoint) added
MetricDescriptor.expression_sha256: str | None = None.  query_model_fingerprint
is defined as the hash of DashboardQueryModel.model_dump(mode="json"), so an
additive optional field silently changed the identity of every query model, and
the captured admitted_v2_actual_docker fixture - last written by bcc69f4b, before
that commit - no longer reproduces it.  Re-serializing its query inserts exactly
five null expression_sha256 values; no src/ code reads that field.

The fixture is migrated by scripts/full_flow_v2/migrate_admission_fixture.py,
which is committed with it.  It adds only the missing keys in place and
re-derives the digest chain from the fixture's own bytes with the production
definition of each digest: query_model_fingerprint (15 sites),
reference_digest (6), catalog_digest (9), selection_digest (5), binding_digest
(4), authority_digest (2), metric_expected_entry_sha256, revision_hash (4) and
plan_hash.  It proves each method against the pristine captured body before
using it, refuses any captured value that disagrees with the current schema, and
re-validates every self-hashed body through its own model.  entry_digest and the
publication, release and retained schema bytes are unchanged, which is what
shows the captured evidence itself did not move.

This is a migration, not a re-capture, and the fixture now says so in a
_migration_note; a genuine re-capture is
scripts/full_flow_v2/extract_admission_fixture.py run against a stack built from
current code.  No production code was touched and no assertion was relaxed: the
fail-closed context, reference-source and digest checks all still refuse stale
bytes.

Clearing the staleness also unmasked a stale test call in the same group:
build_transport_factory no longer accepts metadata= or mutating= (neither is read
by the factory), so those two keywords are dropped from the call.

registry: 69 failed+errors -> 41, 937 passed, 0 errors, 0 new failures
(28 fixed: 25 METRIC_CONTEXT_STALE incl. 6 setup errors, plus the 3
frozen_plan/dispatch cases from the previous commit).
This commit is contained in:
2026-10-09 19:36:48 +03:00
parent 95e1ae4bf0
commit a32d4cc694
3 changed files with 402 additions and 60 deletions

View File

@@ -5,7 +5,7 @@
"compiler_version": "038.2.0",
"template_version": "v2",
"scenario_id": "d1-metric-baseline",
"revision_hash": "7c9574458ec12bcf11f2d2d283408d3c3f45b9611a145bd8903e23ea772bae00",
"revision_hash": "aa3ef5036c0a9575b82dafbf81fb2ca12fee26cb790cc26e5b09a916948a1a85",
"parent_revision_hash": null,
"dashboard_context": {
"dashboard_id": 1,
@@ -60,7 +60,8 @@
"expression_type": "SIMPLE",
"label": "total_revenue",
"metric_name": "total_revenue",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
},
{
"aggregate": null,
@@ -69,7 +70,8 @@
"expression_type": "SIMPLE",
"label": "total_orders",
"metric_name": "total_orders",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
}
],
"slice_name": "Revenue by Region",
@@ -97,7 +99,8 @@
"expression_type": "SIMPLE",
"label": "total_revenue",
"metric_name": "total_revenue",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
}
],
"slice_name": "Daily Revenue",
@@ -130,7 +133,8 @@
"expression_type": "SIMPLE",
"label": "total_revenue",
"metric_name": "total_revenue",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
},
{
"aggregate": null,
@@ -142,7 +146,8 @@
"expression_type": "SIMPLE",
"label": "total_orders",
"metric_name": "total_orders",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
}
]
}
@@ -216,7 +221,7 @@
"type": "TIME_GRAIN"
}
],
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"schema_version": 1,
"slug": "sales",
"title": "Sales typed v2 acceptance",
@@ -231,8 +236,8 @@
]
},
"input_fingerprints": {
"baseline_selection": "da4d20201b7b311337dc4ba55aa9491b23f7d3152e24d1fd2a44b4923503cd80",
"query_model": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81"
"baseline_selection": "fbdc8d44b4445c7bc2488f2aa51894f67b9ae06f735b308e1c051c36ca13870e",
"query_model": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b"
},
"parameters": [],
"phases": [
@@ -280,7 +285,7 @@
"dataset_id": 1,
"metric_name": "total_revenue",
"value_type": "decimal",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"normalized_filters": {
"schema_version": 1,
"filters": [
@@ -385,7 +390,7 @@
"dataset_id": 1,
"metric_name": "total_revenue",
"value_type": "decimal",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"normalized_filters": {
"schema_version": 1,
"filters": [
@@ -450,15 +455,15 @@
"entry_digest": "37a02f777b9783867107c828af2febbdb33d8d077cb57efe9a12157193f0c7d7",
"coordinate_hash": "22775e4f5765d44da9fdbf27286c39cfde95fa6176603748af809a11cd77334c",
"catalog_revision_id": "047df297-050f-4cc4-a4f4-52b1bebe7bf4",
"catalog_digest": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"catalog_digest": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"release_id": "7212c87b-4954-4d22-9de7-4c8685258d39",
"release_version": "v0.3.0-docker.v2",
"release_commit_hash": "c60b7b1a3eb07be9c86f3984820e75d78403500e",
"publication_commit_hash": "db09f883181cde36dab54bd67a71f4a4cb4fb5f3",
"reference_digest": "75985d92f0f292d77bedc7a9d954abf6ed070f87be17fe0aad7dc22978a1c04a",
"selection_digest": "da4d20201b7b311337dc4ba55aa9491b23f7d3152e24d1fd2a44b4923503cd80"
"reference_digest": "ada38aa53a4d807ddd39724f27c47239a183fdbf2099da063779d30579c23552",
"selection_digest": "fbdc8d44b4445c7bc2488f2aa51894f67b9ae06f735b308e1c051c36ca13870e"
},
"binding_digest": "a095b9dbd5b7fcfd0500267bb8a8f968519efe8925907bddba30fb9abd36bd47"
"binding_digest": "0f2492aa01e3699b10678f122015382464ff03dc726e7e2a5f658175863b6645"
}
],
"metric_schema_authorities": [
@@ -470,7 +475,7 @@
"chart_id": 2,
"dataset_id": 1,
"result_key": "total_revenue",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"filters_hash": "sha256:2924c64ea208d23eb97107aeec10cd8266b1b59ebfb7984aba67cd6a719fe94f",
"execution_principal_fingerprint": "de291a69497e144d397bcf6444268550b45ed6d257be4bc6cd550b71cce4dc17",
"rls_security_fingerprint": "dafcd49e27dcc265ecc0df09b1e2efd0a35696a84c31403806acbe382ed0f02e",
@@ -478,14 +483,14 @@
"generic_data_type": 0,
"source_response_hash": "sha256:a172aff6c4f2c07ab1888072a781b14b4d09d6f98986cd115e0af416577dfc5c",
"evidence_content_ref": "draft:b6573140-1acd-45ae-be56-5c681c8e826d:a172aff6c4f2c07ab1888072a781b14b4d09d6f98986cd115e0af416577dfc5c",
"authority_digest": "1e43107638b8ef164f377ee037c08ba0228dc9e0c136186e70810b3148c7a26c"
"authority_digest": "d0b0459406bbf00c79083ad6acbb5ef2fb2d17909814c5697c0a6460a8f1fe60"
}
]
},
"plan": {
"scenario_revision_id": "315151ad-b731-4300-9bc4-9ee478cf8359",
"scenario_content_hash": "7c9574458ec12bcf11f2d2d283408d3c3f45b9611a145bd8903e23ea772bae00",
"verification_program_hash": "7c9574458ec12bcf11f2d2d283408d3c3f45b9611a145bd8903e23ea772bae00",
"scenario_content_hash": "aa3ef5036c0a9575b82dafbf81fb2ca12fee26cb790cc26e5b09a916948a1a85",
"verification_program_hash": "aa3ef5036c0a9575b82dafbf81fb2ca12fee26cb790cc26e5b09a916948a1a85",
"action_registry_version": "038.5.0",
"action_registry_hash": "234807c6fc1fbc97436e62223bce7c4375d617949a38e8369c0cf93f85dd8b82",
"decision_policy": {
@@ -584,7 +589,7 @@
"dataset_id": 1,
"metric_name": "total_revenue",
"value_type": "decimal",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"normalized_filters": {
"schema_version": 1,
"filters": [
@@ -698,7 +703,7 @@
"dataset_id": 1,
"metric_name": "total_revenue",
"value_type": "decimal",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"normalized_filters": {
"schema_version": 1,
"filters": [
@@ -763,15 +768,15 @@
"entry_digest": "37a02f777b9783867107c828af2febbdb33d8d077cb57efe9a12157193f0c7d7",
"coordinate_hash": "22775e4f5765d44da9fdbf27286c39cfde95fa6176603748af809a11cd77334c",
"catalog_revision_id": "047df297-050f-4cc4-a4f4-52b1bebe7bf4",
"catalog_digest": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"catalog_digest": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"release_id": "7212c87b-4954-4d22-9de7-4c8685258d39",
"release_version": "v0.3.0-docker.v2",
"release_commit_hash": "c60b7b1a3eb07be9c86f3984820e75d78403500e",
"publication_commit_hash": "db09f883181cde36dab54bd67a71f4a4cb4fb5f3",
"reference_digest": "75985d92f0f292d77bedc7a9d954abf6ed070f87be17fe0aad7dc22978a1c04a",
"selection_digest": "da4d20201b7b311337dc4ba55aa9491b23f7d3152e24d1fd2a44b4923503cd80"
"reference_digest": "ada38aa53a4d807ddd39724f27c47239a183fdbf2099da063779d30579c23552",
"selection_digest": "fbdc8d44b4445c7bc2488f2aa51894f67b9ae06f735b308e1c051c36ca13870e"
},
"binding_digest": "a095b9dbd5b7fcfd0500267bb8a8f968519efe8925907bddba30fb9abd36bd47"
"binding_digest": "0f2492aa01e3699b10678f122015382464ff03dc726e7e2a5f658175863b6645"
},
"metric_expected_entry": {
"baseline_id": "03833feb-06bd-4332-bc05-dc3ca63325f2",
@@ -856,8 +861,8 @@
"dashboard_id": 1,
"environment_id": "full-flow-preprod",
"filters_hash": "sha256:2924c64ea208d23eb97107aeec10cd8266b1b59ebfb7984aba67cd6a719fe94f",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"reference_digest": "75985d92f0f292d77bedc7a9d954abf6ed070f87be17fe0aad7dc22978a1c04a",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"reference_digest": "ada38aa53a4d807ddd39724f27c47239a183fdbf2099da063779d30579c23552",
"resolved_at": "2026-10-01T04:31:17.091018+00:00",
"resolved_native_filters": [
{
@@ -890,7 +895,7 @@
"status": "approved",
"supersedes_revision_id": null
},
"metric_expected_entry_sha256": "4d1ae3ce6e30db8bd90201402ae2775639d55f6939e2b55a82d06520c96b5d12"
"metric_expected_entry_sha256": "e5f397236c176dca7c9ffcf9f83e9ac857ed8da658e7bebf1768bf1cf2563305"
}
],
"metric_graph": {
@@ -898,7 +903,7 @@
"compiler_version": "038.2.0",
"template_version": "v2",
"scenario_id": "d1-metric-baseline",
"revision_hash": "7c9574458ec12bcf11f2d2d283408d3c3f45b9611a145bd8903e23ea772bae00",
"revision_hash": "aa3ef5036c0a9575b82dafbf81fb2ca12fee26cb790cc26e5b09a916948a1a85",
"parent_revision_hash": null,
"dashboard_context": {
"dashboard_id": 1,
@@ -953,7 +958,8 @@
"expression_type": "SIMPLE",
"label": "total_revenue",
"metric_name": "total_revenue",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
},
{
"aggregate": null,
@@ -962,7 +968,8 @@
"expression_type": "SIMPLE",
"label": "total_orders",
"metric_name": "total_orders",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
}
],
"slice_name": "Revenue by Region",
@@ -990,7 +997,8 @@
"expression_type": "SIMPLE",
"label": "total_revenue",
"metric_name": "total_revenue",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
}
],
"slice_name": "Daily Revenue",
@@ -1023,7 +1031,8 @@
"expression_type": "SIMPLE",
"label": "total_revenue",
"metric_name": "total_revenue",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
},
{
"aggregate": null,
@@ -1035,7 +1044,8 @@
"expression_type": "SIMPLE",
"label": "total_orders",
"metric_name": "total_orders",
"sql_expression": null
"sql_expression": null,
"expression_sha256": null
}
]
}
@@ -1109,7 +1119,7 @@
"type": "TIME_GRAIN"
}
],
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"schema_version": 1,
"slug": "sales",
"title": "Sales typed v2 acceptance",
@@ -1124,8 +1134,8 @@
]
},
"input_fingerprints": {
"baseline_selection": "da4d20201b7b311337dc4ba55aa9491b23f7d3152e24d1fd2a44b4923503cd80",
"query_model": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81"
"baseline_selection": "fbdc8d44b4445c7bc2488f2aa51894f67b9ae06f735b308e1c051c36ca13870e",
"query_model": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b"
},
"parameters": [],
"phases": [
@@ -1173,7 +1183,7 @@
"dataset_id": 1,
"metric_name": "total_revenue",
"value_type": "decimal",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"normalized_filters": {
"schema_version": 1,
"filters": [
@@ -1278,7 +1288,7 @@
"dataset_id": 1,
"metric_name": "total_revenue",
"value_type": "decimal",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"normalized_filters": {
"schema_version": 1,
"filters": [
@@ -1343,15 +1353,15 @@
"entry_digest": "37a02f777b9783867107c828af2febbdb33d8d077cb57efe9a12157193f0c7d7",
"coordinate_hash": "22775e4f5765d44da9fdbf27286c39cfde95fa6176603748af809a11cd77334c",
"catalog_revision_id": "047df297-050f-4cc4-a4f4-52b1bebe7bf4",
"catalog_digest": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"catalog_digest": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"release_id": "7212c87b-4954-4d22-9de7-4c8685258d39",
"release_version": "v0.3.0-docker.v2",
"release_commit_hash": "c60b7b1a3eb07be9c86f3984820e75d78403500e",
"publication_commit_hash": "db09f883181cde36dab54bd67a71f4a4cb4fb5f3",
"reference_digest": "75985d92f0f292d77bedc7a9d954abf6ed070f87be17fe0aad7dc22978a1c04a",
"selection_digest": "da4d20201b7b311337dc4ba55aa9491b23f7d3152e24d1fd2a44b4923503cd80"
"reference_digest": "ada38aa53a4d807ddd39724f27c47239a183fdbf2099da063779d30579c23552",
"selection_digest": "fbdc8d44b4445c7bc2488f2aa51894f67b9ae06f735b308e1c051c36ca13870e"
},
"binding_digest": "a095b9dbd5b7fcfd0500267bb8a8f968519efe8925907bddba30fb9abd36bd47"
"binding_digest": "0f2492aa01e3699b10678f122015382464ff03dc726e7e2a5f658175863b6645"
}
],
"metric_schema_authorities": [
@@ -1363,7 +1373,7 @@
"chart_id": 2,
"dataset_id": 1,
"result_key": "total_revenue",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"filters_hash": "sha256:2924c64ea208d23eb97107aeec10cd8266b1b59ebfb7984aba67cd6a719fe94f",
"execution_principal_fingerprint": "de291a69497e144d397bcf6444268550b45ed6d257be4bc6cd550b71cce4dc17",
"rls_security_fingerprint": "dafcd49e27dcc265ecc0df09b1e2efd0a35696a84c31403806acbe382ed0f02e",
@@ -1371,7 +1381,7 @@
"generic_data_type": 0,
"source_response_hash": "sha256:a172aff6c4f2c07ab1888072a781b14b4d09d6f98986cd115e0af416577dfc5c",
"evidence_content_ref": "draft:b6573140-1acd-45ae-be56-5c681c8e826d:a172aff6c4f2c07ab1888072a781b14b4d09d6f98986cd115e0af416577dfc5c",
"authority_digest": "1e43107638b8ef164f377ee037c08ba0228dc9e0c136186e70810b3148c7a26c"
"authority_digest": "d0b0459406bbf00c79083ad6acbb5ef2fb2d17909814c5697c0a6460a8f1fe60"
}
]
},
@@ -1380,12 +1390,12 @@
"baseline_set_id": "full-flow-sales-v2",
"baseline_set_version": "1",
"catalog_revision_id": "047df297-050f-4cc4-a4f4-52b1bebe7bf4",
"catalog_digest": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"catalog_digest": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"release_id": "7212c87b-4954-4d22-9de7-4c8685258d39",
"release_version": "v0.3.0-docker.v2",
"release_commit_hash": "c60b7b1a3eb07be9c86f3984820e75d78403500e",
"publication_commit_hash": "db09f883181cde36dab54bd67a71f4a4cb4fb5f3",
"baseline_family": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"baseline_family": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"entries": [
{
"baseline_id": "03833feb-06bd-4332-bc05-dc3ca63325f2",
@@ -1401,8 +1411,8 @@
"dashboard_id": 1,
"environment_id": "full-flow-preprod",
"filters_hash": "sha256:2924c64ea208d23eb97107aeec10cd8266b1b59ebfb7984aba67cd6a719fe94f",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"reference_digest": "75985d92f0f292d77bedc7a9d954abf6ed070f87be17fe0aad7dc22978a1c04a",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"reference_digest": "ada38aa53a4d807ddd39724f27c47239a183fdbf2099da063779d30579c23552",
"resolved_at": "2026-10-01T04:31:17.091018+00:00",
"resolved_native_filters": [
{
@@ -1435,16 +1445,16 @@
},
"metric_admission_version": 1,
"metric_binding_digests": [
"a095b9dbd5b7fcfd0500267bb8a8f968519efe8925907bddba30fb9abd36bd47"
"0f2492aa01e3699b10678f122015382464ff03dc726e7e2a5f658175863b6645"
],
"plan_hash": "90e0aa2cce82953e3a833b4f25093fc7fc477efeca32078be49e16149979d37a"
"plan_hash": "12647d32a706fe2d4a40cbe3e1f7fecd23a82200083994b072fb8b32a73a3470"
},
"principal_fingerprint": "de291a69497e144d397bcf6444268550b45ed6d257be4bc6cd550b71cce4dc17",
"publication": {
"id": "9cbb3c35-006c-4d7c-9492-7e7424d3f685",
"idempotency_key": "v2-047df297-050f-4cc4-a4f4-52b1bebe7bf4",
"catalog_revision_id": "047df297-050f-4cc4-a4f4-52b1bebe7bf4",
"catalog_digest": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"catalog_digest": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"repository": "admin/baseline-catalogs",
"branch": "main",
"expected_branch_head": "a0224bcf28cb49be8bc058ffaf254fb7c27a01b3",
@@ -1460,12 +1470,12 @@
"baseline_set_id": "full-flow-sales-v2",
"baseline_set_version": "1",
"release_id": "7212c87b-4954-4d22-9de7-4c8685258d39",
"baseline_family": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"catalog_digest": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"baseline_family": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"catalog_digest": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"catalog_revision": {
"actor_id": "cc9e6c64-8d93-4f26-86a5-fcc1b2fc8bfd",
"cas_version": 1,
"catalog_digest": "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd",
"catalog_digest": "220203c8a6aff2cc11ef3553ba0f0752555414ba37589856d12d6aeb17228bc6",
"catalog_id": "6e359a70-e84a-455c-a3d4-bc31cb1afa03",
"catalog_revision_id": "047df297-050f-4cc4-a4f4-52b1bebe7bf4",
"created_at": "2026-10-01T04:31:17.326327+00:00",
@@ -1553,8 +1563,8 @@
"dashboard_id": 1,
"environment_id": "full-flow-preprod",
"filters_hash": "sha256:2924c64ea208d23eb97107aeec10cd8266b1b59ebfb7984aba67cd6a719fe94f",
"query_model_fingerprint": "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81",
"reference_digest": "75985d92f0f292d77bedc7a9d954abf6ed070f87be17fe0aad7dc22978a1c04a",
"query_model_fingerprint": "sha256:692c2ebf35a3105e0585d3ec902f62d674df3c3b1586d1cd2ab2edb249a54c7b",
"reference_digest": "ada38aa53a4d807ddd39724f27c47239a183fdbf2099da063779d30579c23552",
"resolved_at": "2026-10-01T04:31:17.091018+00:00",
"resolved_native_filters": [
{
@@ -1647,5 +1657,6 @@
"content_ref": "draft:b6573140-1acd-45ae-be56-5c681c8e826d:a172aff6c4f2c07ab1888072a781b14b4d09d6f98986cd115e0af416577dfc5c",
"raw_base64": "eyJyZXN1bHQiOiBbeyJjYWNoZV9rZXkiOiAiMzRkNjc2NDAyZGE2MmI2MGViNWUyYjY0Y2UwOGIyOGYiLCAiY2FjaGVkX2R0dG0iOiBudWxsLCAiY2FjaGVfdGltZW91dCI6IDg2NDAwLCAiYXBwbGllZF90ZW1wbGF0ZV9maWx0ZXJzIjogW10sICJhbm5vdGF0aW9uX2RhdGEiOiB7fSwgImVycm9yIjogbnVsbCwgImlzX2NhY2hlZCI6IG51bGwsICJxdWVyeSI6ICJTRUxFQ1QgU1VNKHJldmVudWUpIEFTIHRvdGFsX3JldmVudWUgXG5GUk9NIHB1YmxpYy5zYWxlcyBcbldIRVJFIHJlZ2lvbiBJTiAoJ05vcnRoJykgXG4gTElNSVQgMTAwMDA7XG5cbiIsICJzdGF0dXMiOiAic3VjY2VzcyIsICJzdGFja3RyYWNlIjogbnVsbCwgInJvd2NvdW50IjogMSwgInNxbF9yb3djb3VudCI6IDEsICJmcm9tX2R0dG0iOiBudWxsLCAidG9fZHR0bSI6IG51bGwsICJsYWJlbF9tYXAiOiB7InRvdGFsX3JldmVudWUiOiBbInRvdGFsX3JldmVudWUiXX0sICJjb2xuYW1lcyI6IFsidG90YWxfcmV2ZW51ZSJdLCAiaW5kZXhuYW1lcyI6IFswXSwgImNvbHR5cGVzIjogWzBdLCAiZGF0YSI6IFt7InRvdGFsX3JldmVudWUiOiAxNjM1MC4wMH1dLCAicmVzdWx0X2Zvcm1hdCI6ICJqc29uIiwgImFwcGxpZWRfZmlsdGVycyI6IFt7ImNvbHVtbiI6ICJyZWdpb24ifV0sICJyZWplY3RlZF9maWx0ZXJzIjogW119XX0="
}
]
],
"_migration_note": "Captured from run 986e4c04-e5eb-4baf-876d-1eaf44c4a89b by scripts/full_flow_v2/extract_admission_fixture.py. On 2026-10-09 the query-model schema gained MetricDescriptor.expression_sha256 (commit c805513e), which changes DashboardQueryModel.model_dump and therefore every query_model_fingerprint and every digest derived from it; the five expression_sha256 values were added and the fixture's dependent digests re-derived with the production definitions. The publication, release and retained schema bytes are otherwise the captured ones."
}

View File

@@ -65,8 +65,8 @@ async def test_owned_recipe_inputs_reach_transport_without_changing_registry(db_
assert dashboard_id == 1 and actual_action == action
seen.append(copy.deepcopy(action_input))
factory = build_transport_factory(session_manager=None, session_plan_box=[None], transport=ExternalTransport(),
binding=binding, admission=admission, metadata=admission['metadata'], descriptor=admission['descriptor'],
action=action, mutating=False, action_timeout_seconds=30)
binding=binding, admission=admission, descriptor=admission['descriptor'],
action=action, action_timeout_seconds=30)
await factory()
assert len(seen) == 1
if mutation == 'native':

View File

@@ -0,0 +1,331 @@
# #region Tooling.FullFlowV2AdmissionFixtureMigration [C:3] [TYPE Module] [SEMANTICS test,docker,metric,admission,fixture,schema,migration]
# @BRIEF Add the schema fields a captured admission fixture predates and re-derive its digest chain.
# @RELATION DEPENDS_ON -> [Tooling.FullFlowV2AdmissionFixture]
# @INVARIANT Only keys absent from the captured bytes are added; any captured value that disagrees
# with the current schema aborts the migration instead of being overwritten.
# @INVARIANT Every rewritten digest is produced by the production definition of that digest and the
# body is re-validated through its own model, which re-hashes and refuses on a mismatch.
# @RATIONALE The fixture is captured evidence, so its publication, release and retained schema bytes
# stay byte-identical; only identity claims about the inspected query model move, because
# MetricDescriptor.expression_sha256 (c805513e) changed DashboardQueryModel.model_dump and
# therefore every fingerprint and digest derived from it.
# @REJECTED Rewriting the whole fixture from the production pipeline was rejected: the result would
# satisfy every check by construction and prove nothing about the captured bytes.
# @REJECTED Leaving the fixture stale was rejected: 25 registry tests then refuse with
# METRIC_CONTEXT_STALE before reaching the behaviour they assert.
"""One-off migration of the captured admitted-v2 Docker fixture to the current query-model schema.
Root cause this repairs: commit c805513e (a WIP Stage-1 checkpoint) added
`MetricDescriptor.expression_sha256: str | None = None` to the query-model schema without
migrating anything that binds to the model's serialization. `query_model_fingerprint` is defined
as the hash of `DashboardQueryModel.model_dump(mode="json")`, so every captured graph, binding,
selection, reference source, catalog envelope and plan that was recorded before that commit now
asserts an identity the current serializer does not reproduce. Admission refuses those bytes with
METRIC_CONTEXT_STALE before any test reaches the behaviour it asserts.
What this script does: adds the five missing `expression_sha256` values in place (all null - no src/
code reads that field), then re-derives every digest in the fixture's dependency chain from the
fixture's own bytes using the production definition of each one. Nothing is loosened: the models
re-validate every self-hashed body afterwards, and the admission context conditions are re-checked.
This does NOT restore a genuine capture. It makes one captured snapshot coherent under the current
schema; a true re-capture is scripts/full_flow_v2/extract_admission_fixture.py run against a stack
built from current code. The provenance note written into the fixture says so.
Run with --write to apply; without it the script only reports. It expects a pristine fixture.
"""
from __future__ import annotations
import hashlib
import json
from pathlib import Path
import sys
BACKEND = Path(__file__).resolve().parents[2] / "backend"
sys.path.insert(0, str(BACKEND))
from src.schemas.dashboard_testing import DashboardQueryModel # noqa: E402
from src.services.dashboard_testing.fingerprints import compute_sha256 # noqa: E402
from src.services.dashboard_testing.query_model import _compute_fingerprint # noqa: E402
from src.services.dashboard_testing.reference_source import require_reference_source # noqa: E402
from src.services.dashboard_testing.scenario.canonical import canonical_dump, sha256_hex # noqa: E402
from src.services.dashboard_testing.scenario.metric_binding import PublishedComparisonBinding # noqa: E402
from src.services.dashboard_testing.scenario.metric_result_schema import ( # noqa: E402
MetricResultSchemaAuthority,
)
from src.services.dashboard_testing.scenario.models import DashboardTestScenario # noqa: E402
from src.services.dashboard_testing.scenario.profile_baseline_snapshot import ( # noqa: E402
ProfileBaselineSelection,
)
PATH = BACKEND / "tests/fixtures/dashboard_scenarios/admitted_v2_actual_docker.json"
OLD_FINGERPRINT = "sha256:bfc5ca501dfc040add49d1fcb0853890f3427ad04065bfe702c46d5453638d81"
OLD_REFERENCE = "75985d92f0f292d77bedc7a9d954abf6ed070f87be17fe0aad7dc22978a1c04a"
OLD_CATALOG = "4e3e42393dabf58f493800796863c428b25745e4f4879db0bd6d12147e599bbd"
OLD_SELECTION = "da4d20201b7b311337dc4ba55aa9491b23f7d3152e24d1fd2a44b4923503cd80"
OLD_BINDING = "a095b9dbd5b7fcfd0500267bb8a8f968519efe8925907bddba30fb9abd36bd47"
OLD_AUTHORITY = "1e43107638b8ef164f377ee037c08ba0228dc9e0c136186e70810b3148c7a26c"
OLD_REVISION = "7c9574458ec12bcf11f2d2d283408d3c3f45b9611a145bd8903e23ea772bae00"
OLD_PLAN = "90e0aa2cce82953e3a833b4f25093fc7fc477efeca32078be49e16149979d37a"
OLD_ENTRY_DIGEST = "37a02f777b9783867107c828af2febbdb33d8d077cb57efe9a12157193f0c7d7"
COUNTS = {
"fingerprint": 15,
"reference_digest": 6,
"catalog_digest": 9,
"selection_digest": 5,
"binding_digest": 4,
"authority_digest": 2,
}
MIGRATION_NOTE = (
"Captured from run {run_id} by scripts/full_flow_v2/extract_admission_fixture.py. "
"On 2026-10-09 the query-model schema gained MetricDescriptor.expression_sha256 (commit "
"c805513e), which changes DashboardQueryModel.model_dump and therefore every "
"query_model_fingerprint and every digest derived from it; the five expression_sha256 values "
"were added and the fixture's dependent digests re-derived with the production definitions. "
"The publication, release and retained schema bytes are otherwise the captured ones."
)
def walk(node, path=()):
"""Yield (path_tuple, container, key) for every scalar leaf."""
if isinstance(node, dict):
for key, value in node.items():
if isinstance(value, (dict, list)):
yield from walk(value, path + (key,))
else:
yield path, node, key
elif isinstance(node, list):
for index, value in enumerate(node):
if isinstance(value, (dict, list)):
yield from walk(value, path + (index,))
else:
yield path, node, index
def replace_scalar(data, old, new) -> int:
count = 0
for _, container, key in walk(data):
if container[key] == old:
container[key] = new
count += 1
return count
def add_missing_captured_fields(reference, captured, path=()) -> list[str]:
"""Copy only the keys the current schema adds; refuse any value that disagrees."""
added = []
if isinstance(reference, dict) and isinstance(captured, dict):
for key, value in reference.items():
if key not in captured:
captured[key] = value
added.append(".".join(str(part) for part in path + (key,)))
else:
added += add_missing_captured_fields(value, captured[key], path + (key,))
extra = set(captured) - set(reference)
if extra:
raise SystemExit(f"captured query carries unknown fields at {path}: {sorted(extra)}")
elif isinstance(reference, list) and isinstance(captured, list):
if len(reference) != len(captured):
raise SystemExit(f"captured list length differs at {path}")
for index, (ref, cap) in enumerate(zip(reference, captured)):
added += add_missing_captured_fields(ref, cap, path + (index,))
elif reference != captured:
raise SystemExit(f"captured value differs at {path}: {captured!r} != {reference!r}")
return added
def self_hashed(body: dict, field: str, model_cls=None) -> str:
"""Recompute a self-hashed body with the production definition of its digest field."""
without = {k: v for k, v in body.items() if k != field}
if model_cls is None:
return sha256_hex(canonical_dump(without))
constructed = model_cls.model_construct(**without)
return sha256_hex(canonical_dump(constructed.model_dump(mode="json", exclude={field})))
def reference_digest_of(source: dict) -> str:
"""The definition used by build_reference_source for reference_digest."""
return hashlib.sha256(json.dumps({
"environment_id": source["environment_id"],
"dashboard_id": source["dashboard_id"],
"resolved_native_filters": source["resolved_native_filters"],
"filters_hash": source["filters_hash"],
"query_model_fingerprint": source["query_model_fingerprint"],
}, sort_keys=True, separators=(",", ":"), ensure_ascii=False).encode()).hexdigest()
def catalog_digest_of(data) -> str:
revisions = data["publication"]["envelope"]["catalog_revision"]["entry_revisions"]
return hashlib.sha256(
json.dumps(revisions, sort_keys=True, separators=(",", ":")).encode()
).hexdigest()
def main() -> int:
raw = PATH.read_text(encoding="utf-8")
data = json.loads(raw)
pristine = json.loads(raw)
report: dict[str, object] = {"graph_equals_plan_metric_graph": data["graph"] == data["plan"]["metric_graph"]}
for label, token in (("fingerprint", OLD_FINGERPRINT), ("reference_digest", OLD_REFERENCE),
("catalog_digest", OLD_CATALOG), ("selection_digest", OLD_SELECTION),
("binding_digest", OLD_BINDING), ("authority_digest", OLD_AUTHORITY)):
found = sum(1 for _, c, k in walk(data) if c[k] == token)
report[f"{label}_sites"] = found
if found != COUNTS[label]:
raise SystemExit(f"{label}: expected {COUNTS[label]} sites, found {found}")
if not report["graph_equals_plan_metric_graph"]:
raise SystemExit("graph and plan.metric_graph have already diverged; refusing to guess")
if MIGRATION_NOTE.format(run_id="x")[:20] in raw:
raise SystemExit("fixture already migrated; run against a pristine checkout")
# 0. Prove every digest method against the pristine captured bodies before trusting it.
for label, body, field, expected, model_cls in (
("binding_digest", pristine["graph"]["baseline_bindings"][0], "binding_digest", OLD_BINDING,
PublishedComparisonBinding),
("authority_digest", pristine["graph"]["metric_schema_authorities"][0], "authority_digest",
OLD_AUTHORITY, MetricResultSchemaAuthority),
("selection_digest", pristine["graph"]["baseline_bindings"][0]["selection"], "selection_digest",
OLD_SELECTION, ProfileBaselineSelection),
("reference_digest", pristine["plan"]["baseline_pin"]["entries"][0]["reference_source"],
"reference_digest", OLD_REFERENCE, None),
):
reproduced = (reference_digest_of(body) if label == "reference_digest"
else self_hashed(body, field, model_cls))
if reproduced != expected:
raise SystemExit(f"{label}: method did not reproduce the captured value "
f"({reproduced} != {expected}); refusing to migrate")
if catalog_digest_of(pristine) != OLD_CATALOG:
raise SystemExit("catalog_digest method did not reproduce the captured value")
# 1. The captured query bytes predate MetricDescriptor.expression_sha256.
stored_query = data["graph"]["dashboard_context"]["query"]
model = DashboardQueryModel.model_validate(stored_query)
dumped = model.model_dump(mode="json")
report["fields_added"] = add_missing_captured_fields(dumped, stored_query)
new_fingerprint = _compute_fingerprint({k: v for k, v in dumped.items()
if k != "query_model_fingerprint"})
report["old_fingerprint"] = model.query_model_fingerprint
report["new_fingerprint"] = new_fingerprint
stored_query["query_model_fingerprint"] = new_fingerprint
data["plan"]["metric_graph"]["dashboard_context"]["query"] = json.loads(json.dumps(stored_query))
if stored_query != {**dumped, "query_model_fingerprint": new_fingerprint}:
raise SystemExit("in-place field addition does not reproduce the current-schema dump")
# 2. Identity claims: coordinates, authorities, inputs and captured reference sources.
# Two of the fifteen sites live inside the query dicts re-serialized in step 1.
report["fingerprints_rewritten"] = replace_scalar(data, OLD_FINGERPRINT, new_fingerprint)
# 3. reference_digest is defined over the fingerprint, so every mirror moves with it.
new_reference = reference_digest_of(data["plan"]["baseline_pin"]["entries"][0]["reference_source"])
report["reference_digests_rewritten"] = replace_scalar(data, OLD_REFERENCE, new_reference)
# 4. The catalog digest covers the entry revisions that embed the reference source.
new_catalog = catalog_digest_of(data)
report["catalog_digests_rewritten"] = replace_scalar(data, OLD_CATALOG, new_catalog)
# 5. The selection digest covers the selection body, which now carries new reference/catalog
# digests; input_fingerprints.baseline_selection mirrors the selection digest.
selection = data["graph"]["baseline_bindings"][0]["selection"]
new_selection = self_hashed(selection, "selection_digest", ProfileBaselineSelection)
report["new_selection_digest"] = new_selection
report["selection_digests_rewritten"] = replace_scalar(data, OLD_SELECTION, new_selection)
for inputs in (data["graph"]["input_fingerprints"], data["plan"]["metric_graph"]["input_fingerprints"]):
inputs["baseline_selection"] = new_selection
# 6. Binding and authority digests cover their own bodies.
new_binding = self_hashed(data["graph"]["baseline_bindings"][0], "binding_digest",
PublishedComparisonBinding)
new_authority = self_hashed(data["graph"]["metric_schema_authorities"][0], "authority_digest",
MetricResultSchemaAuthority)
report["new_binding_digest"] = new_binding
report["new_authority_digest"] = new_authority
report["binding_digests_rewritten"] = replace_scalar(data, OLD_BINDING, new_binding)
report["authority_digests_rewritten"] = replace_scalar(data, OLD_AUTHORITY, new_authority)
# 7. The entry digest is unchanged, which is what proves the entry body itself did not move.
if compute_sha256(data["plan"]["steps"][1]["metric_expected_entry"]["entry"]) != OLD_ENTRY_DIGEST:
raise SystemExit("entry_digest moved; the captured entry body should be untouched")
# 8. The pinned expected-entry wrapper is hashed whole.
plan = data["plan"]
wrapper = plan["steps"][1]["metric_expected_entry"]
new_wrapper = compute_sha256(wrapper)
plan["steps"][1]["metric_expected_entry_sha256"] = new_wrapper
report["metric_expected_entry_sha256_rewritten"] = new_wrapper != OLD_ENTRY_DIGEST
# 9. Graph revision hash, its mirrors, and the admitted plan hash.
scenario = DashboardTestScenario.model_validate(data["graph"])
new_revision = hashlib.sha256(scenario.canonical_bytes()).hexdigest()
report["revision_hash_sites"] = replace_scalar(data, OLD_REVISION, new_revision)
body = {k: v for k, v in data["plan"].items() if k != "plan_hash"}
data["plan"]["plan_hash"] = hashlib.sha256(
json.dumps(body, sort_keys=True, separators=(",", ":")).encode()
).hexdigest()
report["old_plan_hash"] = OLD_PLAN
# 10. Re-validate through the production models; this is the proof, not a diff review.
data["_migration_note"] = MIGRATION_NOTE.format(run_id=data["source_run_id"])
final_graph = DashboardTestScenario.model_validate(data["graph"])
final_model = DashboardQueryModel.model_validate(final_graph.dashboard_context["query"])
recomputed = _compute_fingerprint(
final_model.model_dump(mode="json", exclude={"query_model_fingerprint"})
)
for source in (
data["plan"]["steps"][1]["metric_expected_entry"]["reference_source"],
data["plan"]["baseline_pin"]["entries"][0]["reference_source"],
data["publication"]["envelope"]["catalog_revision"]["entry_revisions"][0]["reference_source"],
):
require_reference_source(source)
if reference_digest_of(source) != source["reference_digest"]:
raise SystemExit("a reference_digest does not match its own body after migration")
report["graph_and_plan_equal"] = data["graph"] == data["plan"]["metric_graph"]
report["fingerprint_self_consistent"] = recomputed == final_model.query_model_fingerprint
report["context_bytes_equal"] = (
final_graph.dashboard_context["query"] == final_model.model_dump(mode="json")
)
report["selection_digest_self_consistent"] = (
final_graph.baseline_bindings[0].selection.selection_digest == new_selection
)
report["revision_hash_self_consistent"] = (
hashlib.sha256(final_graph.canonical_bytes()).hexdigest() == final_graph.revision_hash
)
report["catalog_digest_self_consistent"] = catalog_digest_of(data) == new_catalog
report["plan_hash_self_consistent"] = data["plan"]["plan_hash"] == hashlib.sha256(
json.dumps({k: v for k, v in data["plan"].items() if k != "plan_hash"},
sort_keys=True, separators=(",", ":")).encode()
).hexdigest()
report["stale_values_remain"] = any(
token in json.dumps(data, ensure_ascii=False)
for token in (OLD_REFERENCE, OLD_CATALOG, OLD_SELECTION, OLD_BINDING, OLD_AUTHORITY,
OLD_REVISION, OLD_PLAN)
)
for key, value in report.items():
print(f"{key}: {value}")
must_hold = ("graph_and_plan_equal", "fingerprint_self_consistent", "context_bytes_equal",
"selection_digest_self_consistent", "revision_hash_self_consistent",
"catalog_digest_self_consistent", "plan_hash_self_consistent")
failed = [k for k in must_hold if report[k] is not True]
expected_sites = {"fingerprints_rewritten": 13, "reference_digests_rewritten": 6,
"catalog_digests_rewritten": 9, "selection_digests_rewritten": 5,
"binding_digests_rewritten": 4, "authority_digests_rewritten": 2}
wrong = {k: report[k] for k, v in expected_sites.items() if report[k] != v}
if failed or wrong or report["stale_values_remain"]:
raise SystemExit(f"verification failed: {failed or wrong or 'stale values remain'}")
if "--write" in sys.argv:
PATH.write_text(json.dumps(data, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
print(f"written: {PATH}")
else:
print("dry run (pass --write to apply)")
return 0
if __name__ == "__main__":
raise SystemExit(main())
# #endregion Tooling.FullFlowV2AdmissionFixtureMigration