frontier-runner 0.2.1__tar.gz → 0.2.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/CHANGELOG.md +7 -0
  2. {frontier_runner-0.2.1/frontier_runner.egg-info → frontier_runner-0.2.2}/PKG-INFO +4 -4
  3. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/README.md +3 -3
  4. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/__init__.py +1 -1
  5. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cli.py +218 -32
  6. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/comment.py +46 -14
  7. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/compare.py +13 -2
  8. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/execute.py +392 -3
  9. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/filter_v1.py +372 -38
  10. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/frontier.py +10 -4
  11. frontier_runner-0.2.2/frontier/mutation.py +373 -0
  12. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/saas.py +1 -1
  13. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/progress.py +37 -4
  14. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/proof.py +179 -43
  15. frontier_runner-0.2.2/frontier/repair.py +394 -0
  16. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/snapshot.py +52 -1
  17. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/validation.py +8 -3
  18. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/warehouse.py +147 -0
  19. {frontier_runner-0.2.1 → frontier_runner-0.2.2/frontier_runner.egg-info}/PKG-INFO +4 -4
  20. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier_runner.egg-info/SOURCES.txt +2 -0
  21. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/pyproject.toml +1 -1
  22. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/LICENSE +0 -0
  23. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/MANIFEST.in +0 -0
  24. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/__main__.py +0 -0
  25. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/adapters/__init__.py +0 -0
  26. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/adapters/base.py +0 -0
  27. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/adapters/bigquery.py +0 -0
  28. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/adapters/databricks.py +0 -0
  29. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/adapters/postgres.py +0 -0
  30. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/adapters/redshift.py +0 -0
  31. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/adapters/snowflake.py +0 -0
  32. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/api.py +0 -0
  33. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/artifacts.py +0 -0
  34. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/__init__.py +0 -0
  35. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/config.py +0 -0
  36. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/consume.py +0 -0
  37. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/normalize.py +0 -0
  38. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/prove.py +0 -0
  39. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/route.py +0 -0
  40. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/store.py +0 -0
  41. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/streams.py +0 -0
  42. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/cdc/upload.py +0 -0
  43. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/certification.py +0 -0
  44. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/config.py +0 -0
  45. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/credentials.py +0 -0
  46. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/dbt_artifacts.py +0 -0
  47. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/environment.py +0 -0
  48. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/errors.py +0 -0
  49. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/github.py +0 -0
  50. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/hashing.py +0 -0
  51. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/impact.py +0 -0
  52. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/local_config.py +0 -0
  53. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/__init__.py +0 -0
  54. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/commands.py +0 -0
  55. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/constants.py +0 -0
  56. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/demo.py +0 -0
  57. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/detect.py +0 -0
  58. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/discover.py +0 -0
  59. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/doctor.py +0 -0
  60. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/github.py +0 -0
  61. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/gitignore.py +0 -0
  62. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/hashkey.py +0 -0
  63. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/permissions.py +0 -0
  64. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/prompt.py +0 -0
  65. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/routes.py +0 -0
  66. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/onboard/versions.py +0 -0
  67. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/semantic.py +0 -0
  68. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/snowflake.py +0 -0
  69. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/snowflake_sql.py +0 -0
  70. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier/sql_fingerprint.py +0 -0
  71. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier_runner.egg-info/dependency_links.txt +0 -0
  72. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier_runner.egg-info/entry_points.txt +0 -0
  73. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier_runner.egg-info/requires.txt +0 -0
  74. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/frontier_runner.egg-info/top_level.txt +0 -0
  75. {frontier_runner-0.2.1 → frontier_runner-0.2.2}/setup.cfg +0 -0
@@ -5,6 +5,12 @@ All notable changes to frontier-runner are documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.2.2] — 2026-09-22
9
+
10
+ - Disposable repair validation is the authoritative repaired-vs-head check. The unchanged materialized mart versus head comparison is an expected pre-repair difference and no longer fails the run.
11
+ - `assert_repaired_equals_reference`, mismatch counts, targeted-repair safety, GitHub comments, and run detail now follow `repairValidation`. Production apply remains not requested unless explicitly applied.
12
+ - Mart baseline, candidate certification, disposable repair, production apply, economics, and execution stay independent dimensions. `NOT_EVALUATED` economics does not fail a correct assessment.
13
+
8
14
  ## [0.2.1] — 2026-09-22
9
15
 
10
16
  - Made filter-v1 eligibility and the RowCover candidate compiler authoritative for `compare` and `prove`. Ineligible plans stay `UNCERTIFIED` and are not reported as safe for targeted repair.
@@ -94,6 +100,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
94
100
  - SaaS commands resolve stored keychain credentials through one shared
95
101
  resolver instead of requiring `FRONTIER_API_KEY` in the environment.
96
102
 
103
+ [0.2.2]: https://github.com/jadsamara/frontier-runner/compare/v0.2.1...v0.2.2
97
104
  [0.2.1]: https://github.com/jadsamara/frontier-runner/compare/v0.2.0...v0.2.1
98
105
  [0.2.0]: https://github.com/jadsamara/frontier-runner/compare/v0.1.3...v0.2.0
99
106
  [0.1.3]: https://github.com/jadsamara/frontier-runner/compare/v0.1.2...v0.1.3
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: frontier-runner
3
- Version: 0.2.1
3
+ Version: 0.2.2
4
4
  Summary: Customer-side Frontier CLI for dbt + Snowflake or BigQuery + GitHub impact assessments.
5
5
  Author: Frontier
6
6
  License: MIT License
@@ -92,7 +92,7 @@ Until the package is on PyPI, install the GitHub Release wheel for a version
92
92
  tag. You do not need a commit SHA:
93
93
 
94
94
  ```bash
95
- pipx install \ "frontier-runner[snowflake] @ https://github.com/jadsamara/frontier-runner/releases/download/v0.2.1/frontier_runner-0.2.1-py3-none-any.whl"
95
+ pipx install \ "frontier-runner[snowflake] @ https://github.com/jadsamara/frontier-runner/releases/download/v0.2.2/frontier_runner-0.2.2-py3-none-any.whl"
96
96
  pipx inject frontier-runner "snowflake-connector-python>=3.12,<4"
97
97
  ```
98
98
 
@@ -222,9 +222,9 @@ workflow uses `FRONTIER_BLOCKING=false` unless you pass `--blocking`.
222
222
  Pin an immutable released version:
223
223
 
224
224
  ```bash
225
- pip install "frontier-runner[snowflake]==0.2.1"
225
+ pip install "frontier-runner[snowflake]==0.2.2"
226
226
  # or
227
- pip install "frontier-runner[bigquery]==0.2.1"
227
+ pip install "frontier-runner[bigquery]==0.2.2"
228
228
  ```
229
229
 
230
230
  Until PyPI trusted publishing is reviewed and live, install the GitHub Release
@@ -34,7 +34,7 @@ Until the package is on PyPI, install the GitHub Release wheel for a version
34
34
  tag. You do not need a commit SHA:
35
35
 
36
36
  ```bash
37
- pipx install \ "frontier-runner[snowflake] @ https://github.com/jadsamara/frontier-runner/releases/download/v0.2.1/frontier_runner-0.2.1-py3-none-any.whl"
37
+ pipx install \ "frontier-runner[snowflake] @ https://github.com/jadsamara/frontier-runner/releases/download/v0.2.2/frontier_runner-0.2.2-py3-none-any.whl"
38
38
  pipx inject frontier-runner "snowflake-connector-python>=3.12,<4"
39
39
  ```
40
40
 
@@ -164,9 +164,9 @@ workflow uses `FRONTIER_BLOCKING=false` unless you pass `--blocking`.
164
164
  Pin an immutable released version:
165
165
 
166
166
  ```bash
167
- pip install "frontier-runner[snowflake]==0.2.1"
167
+ pip install "frontier-runner[snowflake]==0.2.2"
168
168
  # or
169
- pip install "frontier-runner[bigquery]==0.2.1"
169
+ pip install "frontier-runner[bigquery]==0.2.2"
170
170
  ```
171
171
 
172
172
  Until PyPI trusted publishing is reviewed and live, install the GitHub Release
@@ -1,3 +1,3 @@
1
1
  """Customer-side Frontier runner."""
2
2
 
3
- __version__ = "0.2.1"
3
+ __version__ = "0.2.2"
@@ -106,6 +106,9 @@ from frontier.proof import (
106
106
  failed_execution_sql_change_proof,
107
107
  resolve_deleted_order,
108
108
  sql_change_proof_validation_results,
109
+ finalize_sql_change_assessment,
110
+ repair_summary_metrics,
111
+ targeted_repair_status_line,
109
112
  )
110
113
  from frontier.warehouse import (
111
114
  FakeWarehouse,
@@ -245,6 +248,8 @@ def _write_failed_prove_run(
245
248
  manifest,
246
249
  phase: str,
247
250
  code: str,
251
+ snapshot=None,
252
+ warehouse=None,
248
253
  ) -> Path | None:
249
254
  """Overwrite frontier-run.json with this invocation's failed assessment."""
250
255
  output = Path(args.output) if getattr(args, "output", None) else _target_dir(_project_dir(args)) / RUN_FILE_NAME
@@ -255,10 +260,13 @@ def _write_failed_prove_run(
255
260
  text = str(error)
256
261
  if isinstance(error, ConfigError) and ENVIRONMENT_MISMATCH in text:
257
262
  code_name = ENVIRONMENT_MISMATCH
263
+ query_id = getattr(warehouse, "last_query_id", None)
264
+ if query_id and str(query_id) not in reason:
265
+ reason = f"warehouse job: {query_id}; {reason}"[:512]
258
266
  result = FrontierResult(
259
- full_entity_count=1,
260
- frontier_entity_count=1,
261
- percent_rows_avoided=0.0,
267
+ full_entity_count=None,
268
+ frontier_entity_count=None,
269
+ percent_rows_avoided=None,
262
270
  change_events=[],
263
271
  affected_entities=[],
264
272
  frontier_sql="",
@@ -270,6 +278,10 @@ def _write_failed_prove_run(
270
278
  failure_reason=reason[:512],
271
279
  proof_status="EXECUTION_FAILED",
272
280
  execution_reasons=(f"{code_name}: {reason}",),
281
+ source_snapshot=snapshot,
282
+ targeted_query_id=str(query_id) if query_id else None,
283
+ sql_change_candidate_count=None,
284
+ confirmed_count=None,
273
285
  )
274
286
  comparison = dict(sql_comparison) if sql_comparison else None
275
287
  if comparison is not None:
@@ -283,6 +295,20 @@ def _write_failed_prove_run(
283
295
  message=f"{phase_name}: {code_name}: {reason[:400]}",
284
296
  )
285
297
  ]
298
+ extra_metrics = {
299
+ "fullEntityCount": None,
300
+ "frontierEntityCount": None,
301
+ "percentRowsAvoided": None,
302
+ "sqlChangeCandidateCount": None,
303
+ "confirmedFrontierCount": None,
304
+ "confirmedEntityCount": None,
305
+ "missedEntityCount": None,
306
+ "missingFrontierEntities": None,
307
+ "extraFrontierEntities": None,
308
+ "candidateFrontierCount": None,
309
+ "changedSourceRowCount": None,
310
+ "sourcePopulationCount": None,
311
+ }
286
312
  try:
287
313
  path = _emit_run(
288
314
  args,
@@ -290,6 +316,7 @@ def _write_failed_prove_run(
290
316
  manifest=manifest,
291
317
  result=result,
292
318
  validations=validations,
319
+ extra_metrics=extra_metrics,
293
320
  sql_comparison=comparison,
294
321
  )
295
322
  print(f"Wrote failed assessment to {path}", flush=True)
@@ -816,6 +843,11 @@ def _stamp_sql_comparison(args: argparse.Namespace, comparison: dict[str, Any] |
816
843
  execution_failed = bool(getattr(result, "execution_failed", False))
817
844
  eligible = eligibility.get("eligible") is True
818
845
  snapshot = getattr(result, "source_snapshot", None)
846
+ failure_phase = str(getattr(result, "failure_phase", "") or "")
847
+ validation_attempted = execution_failed and any(
848
+ token in failure_phase.lower()
849
+ for token in ("warehouse execution", "impact", "confirm", "materializ", "snapshot")
850
+ )
819
851
  static_certified = filter_v1_sql_certified(
820
852
  eligible=eligible,
821
853
  compiled=compiled,
@@ -844,13 +876,18 @@ def _stamp_sql_comparison(args: argparse.Namespace, comparison: dict[str, Any] |
844
876
  full_comparison_bytes=getattr(result, "full_comparison_bytes_scanned", None),
845
877
  warehouse_credits=getattr(result, "warehouse_credits", None),
846
878
  candidates_confirmed=confirmed,
847
- confirmation_failed=getattr(result, "failure_phase", None) == "CONFIRMED",
879
+ confirmation_failed=validation_attempted or getattr(result, "failure_phase", None) == "CONFIRMED",
848
880
  full_reference_validated=bool(getattr(result, "full_reference_validated", False)),
849
881
  full_reference_failed=getattr(result, "failure_phase", None) == "FULL_REFERENCE",
850
882
  failure_phase=getattr(result, "failure_phase", None) if execution_failed else None,
851
883
  failure_code=getattr(result, "failure_code", None) if execution_failed else None,
852
884
  failure_reason=getattr(result, "failure_reason", None) if execution_failed else None,
853
885
  )
886
+ query_id = getattr(result, "targeted_query_id", None)
887
+ if query_id:
888
+ execution = dict(dimensions.get("execution") or {})
889
+ execution["warehouseQueryId"] = str(query_id)[:128]
890
+ dimensions["execution"] = execution
854
891
  enrich_certification_record(
855
892
  dimensions,
856
893
  eligibility=eligibility,
@@ -858,6 +895,38 @@ def _stamp_sql_comparison(args: argparse.Namespace, comparison: dict[str, Any] |
858
895
  candidate_fingerprint=eligibility.get("candidateFingerprint"),
859
896
  execution_failed=execution_failed,
860
897
  )
898
+ from frontier.repair import baseline_boundary_from, economics_from_jobs, empty_production_apply
899
+
900
+ mart = getattr(result, "mart_baseline", None)
901
+ repair = getattr(result, "repair_validation", None)
902
+ production = getattr(result, "production_apply", None) or empty_production_apply()
903
+ if mart:
904
+ dimensions["martBaseline"] = mart
905
+ if repair:
906
+ dimensions["repairValidation"] = repair
907
+ dimensions["productionApply"] = production
908
+ dimensions["baselineBoundary"] = baseline_boundary_from(
909
+ mart_baseline=mart,
910
+ repair_validation=repair,
911
+ certification_status=(dimensions.get("certification") or {}).get("status"),
912
+ validation_status=(dimensions.get("validation") or {}).get("status"),
913
+ snapshot=snapshot,
914
+ cleanup_ok=(repair or {}).get("disposableResourcesCleaned"),
915
+ execution_failed=execution_failed,
916
+ )
917
+ jobs = getattr(result, "job_metrics", None)
918
+ if jobs:
919
+ dimensions["economics"] = {
920
+ **(dimensions.get("economics") or {}),
921
+ **economics_from_jobs(
922
+ jobs,
923
+ phase_timings=getattr(result, "phase_timings", None),
924
+ warehouse_credits=getattr(result, "warehouse_credits", None),
925
+ full_bytes=getattr(result, "full_comparison_bytes_scanned", None),
926
+ full_elapsed_ms=getattr(result, "full_comparison_elapsed_ms", None),
927
+ include_full_reference=bool(getattr(result, "full_reference_validated", False)),
928
+ ),
929
+ }
861
930
  stamped.update(dimensions)
862
931
  if (stamped.get("economics") or {}).get("decision") == FULL_REBUILD_RECOMMENDED:
863
932
  stamped["fullRebuildRecommended"] = True
@@ -959,10 +1028,34 @@ def _print_assessment_dimensions(comparison: dict[str, Any] | None) -> None:
959
1028
  )
960
1029
  boundary = comparison.get("baselineBoundary") or {}
961
1030
  if boundary:
1031
+ mart = comparison.get("martBaseline") or {}
1032
+ repair = comparison.get("repairValidation") or {}
1033
+ production = comparison.get("productionApply") or {}
1034
+ print(
1035
+ "Candidate set: "
1036
+ + str((comparison.get("certification") or {}).get("status") or "UNCERTIFIED")
1037
+ )
1038
+ print(
1039
+ "Existing mart baseline: "
1040
+ + str(mart.get("status") or "NOT_RUN")
1041
+ )
1042
+ print(
1043
+ "Disposable repair: "
1044
+ + str(repair.get("status") or "NOT_RUN")
1045
+ )
1046
+ if boundary.get("safeInPlaceProductionRepair"):
1047
+ print("Targeted repair procedure: validated at this snapshot")
1048
+ else:
1049
+ print("Targeted repair procedure: not certified")
1050
+ print(
1051
+ "Production repair: "
1052
+ + ("not applied" if (production.get("status") or "NOT_REQUESTED") in {"NOT_REQUESTED", "NOT_RUN"} else str(production.get("status")))
1053
+ )
1054
+ economics = comparison.get("economics") or {}
1055
+ if economics.get("measurementBasis"):
962
1056
  print(
963
- "Baseline: this assessment compares two SQL versions at one pinned source snapshot; "
964
- "the existing materialized dbt mart is not that snapshot; "
965
- "in-place production repair is not certified."
1057
+ f"Economics basis: {economics.get('measurementBasis')} "
1058
+ f"({economics.get('reason') or 'no monetary savings claimed from bytes alone'})"
966
1059
  )
967
1060
 
968
1061
 
@@ -997,7 +1090,12 @@ def _emit_run(
997
1090
  include_entity_ids = args.include_entity_ids or config.upload.include_entity_ids
998
1091
  hash_entity_ids = args.hash_entity_ids or config.upload.hash_entity_ids
999
1092
  send_raw_ids = include_entity_ids and not hash_entity_ids
1000
- hash_key = None if send_raw_ids else entity_hash_key_from_env()
1093
+ has_entity_ids = bool(
1094
+ getattr(result, "change_events", ()) or getattr(result, "affected_entities", ())
1095
+ )
1096
+ hash_key = None
1097
+ if not send_raw_ids and has_entity_ids:
1098
+ hash_key = entity_hash_key_from_env()
1001
1099
  details = frontier_result_to_dict(
1002
1100
  result,
1003
1101
  config=config,
@@ -1026,6 +1124,7 @@ def _emit_run(
1026
1124
  sql_check = sql_change_narrow_frontier_result(sql_comparison)
1027
1125
  if sql_check is not None:
1028
1126
  validations.append(sql_check)
1127
+ payload_validations = [item for item in validations if item.status != "skipped"]
1029
1128
  payload = build_ingest_payload(
1030
1129
  external_run_id=run_id,
1031
1130
  project=config.project,
@@ -1047,9 +1146,9 @@ def _emit_run(
1047
1146
  "differenceCount": item.difference_count,
1048
1147
  **({"message": item.message} if item.message else {}),
1049
1148
  }
1050
- for item in validations
1149
+ for item in payload_validations
1051
1150
  ],
1052
- evidence_level=evidence_level(validations),
1151
+ evidence_level=evidence_level(payload_validations),
1053
1152
  status=overall_status(validations),
1054
1153
  git=github_source(),
1055
1154
  entity_ids_hashed=not send_raw_ids,
@@ -1236,9 +1335,9 @@ def cmd_record_failure(args: argparse.Namespace) -> int:
1236
1335
  entity_key=config.model.key,
1237
1336
  grain=config.model.grain,
1238
1337
  metrics={
1239
- "fullEntityCount": 1,
1240
- "frontierEntityCount": 0,
1241
- "percentRowsAvoided": 100.0,
1338
+ "fullEntityCount": None,
1339
+ "frontierEntityCount": None,
1340
+ "percentRowsAvoided": None,
1242
1341
  },
1243
1342
  change_events=[
1244
1343
  {
@@ -1381,7 +1480,17 @@ def cmd_prove(args: argparse.Namespace) -> int:
1381
1480
  duration_ms=elapsed_ms(started),
1382
1481
  status=failure_status(error),
1383
1482
  )
1384
- raise
1483
+ _write_failed_prove_run(
1484
+ args,
1485
+ config=config,
1486
+ run_id=run_id,
1487
+ error=error,
1488
+ sql_comparison=sql_comparison,
1489
+ manifest=manifest,
1490
+ phase="canonical predicate selection",
1491
+ code="EXECUTION_FAILED",
1492
+ )
1493
+ _reraise_prove_failure(error, phase="canonical predicate selection", code="EXECUTION_FAILED")
1385
1494
  log_step(
1386
1495
  "canonical predicate selection completed",
1387
1496
  duration_ms=elapsed_ms(started),
@@ -1398,6 +1507,7 @@ def cmd_prove(args: argparse.Namespace) -> int:
1398
1507
  sql_change_queries = selected_queries if persist else ()
1399
1508
  sql_proof = None
1400
1509
  proof = None
1510
+ skip_proof_metrics = False
1401
1511
  warehouse: WarehouseAdapter | None = None
1402
1512
  base_sql, after_sql = _proof_sql_pair(
1403
1513
  args,
@@ -1878,6 +1988,41 @@ def cmd_prove(args: argparse.Namespace) -> int:
1878
1988
  )
1879
1989
  if source_snapshot is not None:
1880
1990
  result.source_snapshot = source_snapshot
1991
+ if isolated is not None:
1992
+ result.job_metrics = list(isolated.job_metrics)
1993
+ result.phase_timings = dict(isolated.phase_timings)
1994
+ target = str(manifest.find_model(config.model.name).relation or "")
1995
+ if target and base_sql:
1996
+ isolated.verify_mart_baseline(target_relation=target, old_sql=base_sql)
1997
+ result.mart_baseline = isolated.mart_baseline
1998
+ from frontier.certification import CONTRACT_CERTIFIED, SQL_CERTIFIED, certification_status, filter_v1_sql_certified
1999
+
2000
+ eligibility = (sql_comparison or {}).get("staticEligibility") or {}
2001
+ for row in (sql_comparison or {}).get("modified") or []:
2002
+ row_eligibility = row.get("staticEligibility") or {}
2003
+ if row_eligibility.get("eligible") or row_eligibility.get("compiled"):
2004
+ eligibility = {**eligibility, **row_eligibility}
2005
+ break
2006
+ compiled = bool(eligibility.get("compiled"))
2007
+ static_certified = filter_v1_sql_certified(
2008
+ eligible=eligibility.get("eligible") is True,
2009
+ compiled=compiled,
2010
+ confirmed=result.proof_status == "CONFIRMED",
2011
+ execution_failed=bool(result.execution_failed),
2012
+ )
2013
+ cert_status, _ = certification_status(
2014
+ source_snapshot or isolated.snapshot,
2015
+ static_certified=static_certified,
2016
+ )
2017
+ if target and after_sql:
2018
+ isolated.validate_disposable_repair(
2019
+ target_relation=target,
2020
+ new_sql=after_sql,
2021
+ certified=cert_status in {SQL_CERTIFIED, CONTRACT_CERTIFIED},
2022
+ confirmed=result.proof_status == "CONFIRMED",
2023
+ )
2024
+ result.repair_validation = isolated.repair_validation
2025
+ result.production_apply = {"status": "NOT_REQUESTED"}
1881
2026
  if discovered_candidates is not None:
1882
2027
  result.changed_source_row_count = discovered_source_rows
1883
2028
  if result.sql_change_candidate_count is None:
@@ -1987,6 +2132,7 @@ def cmd_prove(args: argparse.Namespace) -> int:
1987
2132
  full_entity_count=result.full_entity_count,
1988
2133
  changed_source_row_count=discovered_source_rows,
1989
2134
  source_snapshot=source_snapshot,
2135
+ skip_legacy_repair_mismatch=True,
1990
2136
  )
1991
2137
  except Exception as error:
1992
2138
  log_step(
@@ -2061,6 +2207,8 @@ def cmd_prove(args: argparse.Namespace) -> int:
2061
2207
  manifest=manifest,
2062
2208
  phase="warehouse execution",
2063
2209
  code="EXECUTION_FAILED",
2210
+ snapshot=source_snapshot,
2211
+ warehouse=warehouse,
2064
2212
  )
2065
2213
  _reraise_prove_failure(error, phase="warehouse execution", code="EXECUTION_FAILED")
2066
2214
  finally:
@@ -2074,6 +2222,14 @@ def cmd_prove(args: argparse.Namespace) -> int:
2074
2222
  if warehouse is not None:
2075
2223
  warehouse.close()
2076
2224
 
2225
+ if sql_proof is not None:
2226
+ sql_proof, validations = finalize_sql_change_assessment(
2227
+ sql_proof,
2228
+ getattr(result, "repair_validation", None),
2229
+ validations,
2230
+ include_repair_assertion=not skip_proof_metrics,
2231
+ )
2232
+
2077
2233
  sql_comparison = _stamp_sql_comparison(
2078
2234
  args,
2079
2235
  _apply_rebuild_to_comparison(sql_comparison, result, validations),
@@ -2086,13 +2242,21 @@ def cmd_prove(args: argparse.Namespace) -> int:
2086
2242
  }
2087
2243
  if not rebuild_recommended and not result.full_rebuild_required:
2088
2244
  extra_metrics["testDurationMs"] = assessed.test_duration_ms
2089
- extra_metrics.update(
2090
- {
2091
- "missingFrontierEntities": assessed.missing_frontier_entities,
2092
- "extraFrontierEntities": assessed.extra_frontier_entities,
2093
- "mismatchedFinalRows": assessed.mismatched_final_rows,
2094
- }
2095
- )
2245
+ if sql_proof is not None:
2246
+ extra_metrics.update(
2247
+ repair_summary_metrics(
2248
+ sql_proof,
2249
+ getattr(result, "repair_validation", None),
2250
+ )
2251
+ )
2252
+ else:
2253
+ extra_metrics.update(
2254
+ {
2255
+ "missingFrontierEntities": assessed.missing_frontier_entities,
2256
+ "extraFrontierEntities": assessed.extra_frontier_entities,
2257
+ "mismatchedFinalRows": assessed.mismatched_final_rows,
2258
+ }
2259
+ )
2096
2260
  if sql_proof is not None:
2097
2261
  frontier_for_metrics = min(
2098
2262
  sql_proof.candidate_frontier_count,
@@ -2193,9 +2357,22 @@ def cmd_prove(args: argparse.Namespace) -> int:
2193
2357
  print("Row count: Not measured")
2194
2358
  else:
2195
2359
  print(f"Row count: {sql_proof.before_entity_count} → {sql_proof.after_entity_count}")
2196
- print(
2197
- f"Targeted repair: {'skipped' if rebuild_recommended or result.full_rebuild_required or getattr(result, 'execution_failed', False) else ('safe' if sql_proof.targeted_repair_safe else 'not safe')}"
2360
+ repair_status = (
2361
+ (getattr(result, "repair_validation", None) or {}).get("status")
2362
+ or ((sql_comparison or {}).get("repairValidation") or {}).get("status")
2363
+ or "NOT_RUN"
2364
+ )
2365
+ repair_line = targeted_repair_status_line(
2366
+ repair_status=str(repair_status),
2367
+ proof=sql_proof,
2368
+ skipped=bool(
2369
+ rebuild_recommended
2370
+ or result.full_rebuild_required
2371
+ or getattr(result, "execution_failed", False)
2372
+ ),
2198
2373
  )
2374
+ if repair_line:
2375
+ print(repair_line)
2199
2376
  print(
2200
2377
  f"Targeted validation: {(sql_comparison or {}).get('targetedValidation') or ('NOT_RUN' if result.full_rebuild_required else 'PASSED')}"
2201
2378
  )
@@ -2205,15 +2382,22 @@ def cmd_prove(args: argparse.Namespace) -> int:
2205
2382
  print("Full backfill: recommended")
2206
2383
  else:
2207
2384
  print("Full backfill: not required")
2208
- print(
2209
- f"Missing frontier entities: {_format_measured(None if result.full_rebuild_required else assessed.missing_frontier_entities)}"
2210
- )
2211
- print(
2212
- f"Extra frontier entities: {_format_measured(None if result.full_rebuild_required else assessed.extra_frontier_entities)}"
2213
- )
2214
- print(
2215
- f"Mismatched final rows: {_format_measured(None if result.full_rebuild_required else assessed.mismatched_final_rows)}"
2216
- )
2385
+ repair_payload = getattr(result, "repair_validation", None) or {}
2386
+ repair_status = repair_payload.get("status") or "NOT_RUN"
2387
+ if repair_status in {"SUCCEEDED", "FAILED"}:
2388
+ print(f"Missing repaired entities: {_format_measured(repair_payload.get('missingRows'))}")
2389
+ print(f"Extra repaired entities: {_format_measured(repair_payload.get('extraRows'))}")
2390
+ print(f"Mismatched repaired rows: {_format_measured(repair_payload.get('mismatchedRows'))}")
2391
+ else:
2392
+ print(
2393
+ f"Missing frontier entities: {_format_measured(None if result.full_rebuild_required else assessed.missing_frontier_entities)}"
2394
+ )
2395
+ print(
2396
+ f"Extra frontier entities: {_format_measured(None if result.full_rebuild_required else assessed.extra_frontier_entities)}"
2397
+ )
2398
+ print(
2399
+ f"Mismatched final rows: {_format_measured(None if result.full_rebuild_required else assessed.mismatched_final_rows)}"
2400
+ )
2217
2401
  if result.full_rebuild_required:
2218
2402
  print("Test duration: Not measured")
2219
2403
  else:
@@ -2231,6 +2415,8 @@ def cmd_prove(args: argparse.Namespace) -> int:
2231
2415
  "Assessment failed; wrote diagnostics for upload.",
2232
2416
  file=sys.stderr,
2233
2417
  )
2418
+ else:
2419
+ print("Assessment passed; wrote results for upload.")
2234
2420
  return 0
2235
2421
 
2236
2422
 
@@ -35,7 +35,7 @@ def _format_measured(value: Any) -> str:
35
35
  return _format_count(int(value))
36
36
 
37
37
 
38
- def _pluralize(noun: str, count: int) -> str:
38
+ def _pluralize(noun: str, count: int | None) -> str:
39
39
  if count == 1:
40
40
  return noun
41
41
  if noun.endswith("s"):
@@ -77,8 +77,10 @@ def format_pr_comment(payload: dict[str, Any], *, run_url: str) -> str:
77
77
  model_name = str(model.get("name") or "unknown")
78
78
  entity_type = str(model.get("entityType") or "entity")
79
79
  metrics = payload.get("metrics") or {}
80
- full_count = int(metrics.get("fullEntityCount") or 0)
81
- frontier_count = int(metrics.get("frontierEntityCount") or 0)
80
+ full_raw = metrics.get("fullEntityCount")
81
+ frontier_raw = metrics.get("frontierEntityCount")
82
+ full_count = int(full_raw) if full_raw is not None else None
83
+ frontier_count = int(frontier_raw) if frontier_raw is not None else None
82
84
  percent = metrics.get("percentRowsAvoided")
83
85
  percent_text = f"{percent}%" if percent is not None else "n/a"
84
86
  events = payload.get("changeEvents") or []
@@ -114,9 +116,12 @@ def format_pr_comment(payload: dict[str, Any], *, run_url: str) -> str:
114
116
  after_count = metrics.get("afterEntityCount")
115
117
  recommended = bool(comparison.get("fullRebuildRecommended"))
116
118
  full_rebuild = bool(comparison.get("fullRebuildRequired") or comparison.get("narrowFrontierSafe") is False)
119
+ repair = comparison.get("repairValidation") or {}
120
+ repair_status = repair.get("status") or "NOT_RUN"
117
121
  targeted_safe = (
118
122
  int(metrics.get("mismatchedFinalRows") or 0) == 0
119
123
  and int(metrics.get("missingFrontierEntities") or 0) == 0
124
+ and metrics.get("mismatchedFinalRows") is not None
120
125
  and not full_rebuild
121
126
  and not recommended
122
127
  )
@@ -163,9 +168,18 @@ def format_pr_comment(payload: dict[str, Any], *, run_url: str) -> str:
163
168
  lines.append(
164
169
  f"Row count: {_format_count(int(before_count))} → {_format_count(int(after_count))}"
165
170
  )
166
- lines.append(
167
- f"Targeted repair: {'skipped' if recommended or full_rebuild else ('safe' if targeted_safe else 'not safe')}"
168
- )
171
+ if recommended or full_rebuild:
172
+ lines.append("Targeted repair: skipped")
173
+ elif repair_status == "SUCCEEDED":
174
+ pass
175
+ elif repair_status == "FAILED":
176
+ lines.append("Targeted repair procedure: failed")
177
+ elif targeted_safe:
178
+ lines.append("Targeted repair: safe")
179
+ elif metrics.get("mismatchedFinalRows") is None and repair_status == "NOT_RUN":
180
+ pass
181
+ else:
182
+ lines.append("Targeted repair: not safe")
169
183
  targeted_validation = comparison.get("targetedValidation")
170
184
  if targeted_validation:
171
185
  lines.append(f"Targeted validation: {targeted_validation}")
@@ -181,12 +195,12 @@ def format_pr_comment(payload: dict[str, Any], *, run_url: str) -> str:
181
195
  lines.append(f"Changed source events: {len(events)}")
182
196
  lines.append(
183
197
  f"Affected {_pluralize(entity_type, frontier_count)}: "
184
- f"{_format_count(frontier_count)} of {_format_count(full_count)}"
198
+ f"{_format_measured(frontier_count)} of {_format_measured(full_count)}"
185
199
  )
186
200
  else:
187
201
  lines.append(
188
202
  f"Affected {_pluralize(entity_type, frontier_count)}: "
189
- f"{_format_count(frontier_count)} of {_format_count(full_count)}"
203
+ f"{_format_measured(frontier_count)} of {_format_measured(full_count)}"
190
204
  )
191
205
  lines.extend(
192
206
  [
@@ -201,9 +215,9 @@ def format_pr_comment(payload: dict[str, Any], *, run_url: str) -> str:
201
215
  if event_count is not None or sql_count is not None or union_count is not None:
202
216
  lines.append(
203
217
  "Candidate keys: "
204
- f"{_format_count(int(event_count or 0))} event, "
205
- f"{_format_count(int(sql_count or 0))} SQL-change, "
206
- f"{_format_count(int(union_count or 0))} union"
218
+ f"{_format_measured(event_count)} event, "
219
+ f"{_format_measured(sql_count)} SQL-change, "
220
+ f"{_format_measured(union_count)} union"
207
221
  )
208
222
  comparison = payload.get("sqlComparison") or {}
209
223
  if comparison:
@@ -313,10 +327,28 @@ def format_pr_comment(payload: dict[str, Any], *, run_url: str) -> str:
313
327
  if execution.get("status"):
314
328
  lines.append(f"Execution: {execution.get('status')}")
315
329
  if comparison.get("baselineBoundary"):
330
+ mart = comparison.get("martBaseline") or {}
331
+ repair = comparison.get("repairValidation") or {}
332
+ production = comparison.get("productionApply") or {}
333
+ cert = (comparison.get("certification") or {}).get("status") or "UNCERTIFIED"
334
+ lines.append(f"Candidate set certified: {'yes' if cert in {'SQL_CERTIFIED', 'CONTRACT_CERTIFIED'} else 'no'} ({cert})")
335
+ lines.append(f"Existing mart baseline: {mart.get('status') or 'NOT_RUN'}")
336
+ lines.append(f"Disposable repair validated: {repair.get('status') or 'NOT_RUN'}")
337
+ apply_status = production.get("status") or "NOT_REQUESTED"
338
+ lines.append(
339
+ "Production repair not applied"
340
+ if apply_status in {"NOT_REQUESTED", "NOT_RUN"}
341
+ else f"Production apply: {apply_status}"
342
+ )
343
+ if (comparison.get("baselineBoundary") or {}).get("safeInPlaceProductionRepair"):
344
+ lines.append(
345
+ "Repair procedure validated at the pinned snapshot. Production was not modified."
346
+ )
347
+ economics = comparison.get("economics") or {}
348
+ if economics.get("measurementBasis"):
316
349
  lines.append(
317
- "Baseline: two SQL versions at one pinned source snapshot; "
318
- "the existing materialized dbt mart is not that snapshot; "
319
- "in-place production repair is not certified."
350
+ f"Economics basis: {economics.get('measurementBasis')}"
351
+ + (f" — {economics.get('reason')}" if economics.get("reason") else " — bytes are not billed cost")
320
352
  )
321
353
  if comparison.get("failurePhase") or comparison.get("failureCode"):
322
354
  lines.append(
@@ -541,11 +541,22 @@ def format_compare_report(comparison: dict[str, Any]) -> str:
541
541
  "legacy impact SQL is not evidence that repair is safe",
542
542
  ]
543
543
  )
544
- elif safe is not None:
544
+ elif eligibility.get("eligible") is True:
545
545
  lines.extend(
546
546
  [
547
547
  "",
548
- f"Narrow frontier safe: {'yes' if safe and (not eligibility or certified) else 'no'}",
548
+ "certification: pending warehouse execution",
549
+ "narrow frontier decision: not yet established",
550
+ ]
551
+ )
552
+ if certified:
553
+ lines.append("candidate SQL: compiled")
554
+ elif safe is False:
555
+ lines.extend(
556
+ [
557
+ "",
558
+ "Narrow frontier safe: no — filter-v1 certification rejected this plan; "
559
+ "legacy impact SQL is not evidence that repair is safe",
549
560
  ]
550
561
  )
551
562
  if comparison.get("fullRebuildRequired"):