fix(codemod): preserve lazy formatted assertion messages

Merged
MA
4h ago
+129-1

Delivered and verified — 2026-12-06

Merged normally as 54ddc5cdb36a9e1d7edfb4b9e7af8cd1a25be337. Native post-merge CI and both Release validations completed successfully.

Parents: bf99f474d64afdc7a36c1c5e2996e04a8b39b933 and f144eed542f7796e86acd79436a9f7152c1ef305. The integrated tree, fb22efb1fc562e7de7ec5f93f5aa6eed1125d84d, is identical to the qualified PR preview.

Causal proof and native receipts

StageExact revisionNative jobResult
Regression-only RED6c693de1; preview 627067e11461382377471 failed, 892 passed / 47.23s / 0 warnings
Fixed PRf144eed5; preview 6847d1ef1461391981292,625 passed / 100.64s / 0 warnings
Integrated push54ddc5cd1461407086282,625 passed / 101.98s / 0 warnings
Exact Release candidate54ddc5cd1461407540172,625 passed / 97.03s / 0 warnings
Final Release validation54ddc5cd1461418561252,625 passed / 126.49s / 0 warnings

The original physical consumer passed during RED. The transformed consumer evaluated each formatted message on success and again on failure, producing (1, 2, text). The literal control stayed correct. With only the production classification changed, those same regression bytes pass the independent (0, 1, text) oracle before reaching the golden comparison.

The new ordinary test and all three physical probes passed in each successful execution above. Every listed successful job passed native setup, Ruff and Pyrefly with zero errors. No near-limit tests were reported. The ordinary 2-second budget, existing markers and gates remained unchanged; optional FULL was skipped.

Review and artifact integrity

The exact authored head passed Cubic check 146139214762 (two reviews, zero issues in four files), Semgrep check 146139184542 and Sonar check 146139853107 (zero new issues, zero accepted issues, zero hotspots). There were no review threads at merge preflight.

  • Push artifact 15995319183: SHA-256 1215bf2288e62d7c83ad7c47000fdfc3575904dd57bc154c3331b415c7361c9b.
  • Final Release artifact 15996220015: SHA-256 ffdf77de434267567cbf65dc2b62467459e4200ab53f1408f2041592acefcf56.

Both artifacts were downloaded and their digests checked. Native check receipts preserve the integrated commit/tree before and after, a clean working tree and return code zero. Test totals and runtime warnings are established by the respective job logs; these success artifacts do not contain test JUnit.

Release and remaining integration findings

Release run 47668127075 completed successfully at 15:45:16Z. The plan was bump=none, current=next=0.12.3, releasable=False. Tag/build/publish were skipped; no package version was published. Docs was not triggered for this change.

The integration Sonar check 146141884353 remains failed on Security Rating C. Its analysis of 54ddc5cd retains the same four pre-existing OPEN findings: AaHDJM8o__TgKab75PGM, AaHDJM8o__TgKab75PGN, AaHDJM8o__TgKab75PGO, and AaFW-IYcx7x0cPygmn5y. The post-merge query returned zero newly created open issues. No finding was accepted, suppressed or closed to qualify this PR.

Earlier diagnostic receipts are retained below as history.


Current validation receipt — 2026-12-06

Root cause reproduced by native CI; the reviewed correction is now published. GREEN is pending.

  • RED head 6c693de15f1c6ea6a337bc42b33ce6f1047a42bd, tree 667240b8e3ef1823451a6d6ff9c38657b3a9acc1.
  • Native RED run 47667337804, job 146138237747: 1 failed, 892 passed in 47.23s; 0 runtime warnings; no near-limit test.
  • The original physical module passed its oracle. The transformed execution failed at driver line 39, before the golden comparison. Both f and F observed (1, 2, "failure: recorded detail") instead of (0, 1, ...). The literal control retained (0, 0, "literal message").
  • Fixed head f144eed542f7796e86acd79436a9f7152c1ef305, tree fb22efb1fc562e7de7ec5f93f5aa6eed1125d84d.
  • Production changes exactly one line: STRING_MESSAGE excludes f/F, routing formatted messages to the existing lazy rejection branch.
  • All three regression blobs are unchanged from RED: 721a1b482cc0171988b164989aad79a85f5fe17b, 6727eb8e2aa255735d8b07b12e4ad4cfe4a5e449, and 57c7dedafdd6bde0ceb25b7e4d36b1a1a2df281f.
  • The final diff is exactly four files: one production line and the three regression files. No markers, thresholds, timeouts, gates, or optional FULL changes.

The initial diagnostic stage below is retained as history.


Problem

The assertion codemod currently classifies formatted string messages as constants. It can rewrite assert condition, f"...{detail()}..." into a matcher call with an eagerly evaluated msg= argument. A passing assertion then evaluates a message that Python would leave untouched.

The existing guide already requires dynamic messages to remain lazy. Python 3.13 documents the same contract:

Regression and intended change

One ordinary test executes a physical consumer through runpy.run_path, before and after the public u.Infra.rewrite_test_assertions API. Three probes cover lower-case f, upper-case F, and a constant literal control. Both passing and failing conditions are exercised.

The independent runtime oracle requires zero formatted-message evaluations after success, exactly one after failure, and the original failure text. The transformed runtime oracle runs before the golden comparison.

The reviewed implementation change removes only f/F from STRING_MESSAGE. Formatted messages then use the existing conditional rejection path. Plain and raw/unicode constant messages retain their existing handling. The string masker, binding logic, and walrus regression remain unchanged.

Native validation status

Diagnostic RED stage — production is still unchanged. Do not merge this stage.

  • Base: bf99f474d64afdc7a36c1c5e2996e04a8b39b933.
  • Regression-only head: 6c693de15f1c6ea6a337bc42b33ce6f1047a42bd.
  • Tree: 667240b8e3ef1823451a6d6ff9c38657b3a9acc1.
  • Exactly three new test/fixture files; independently reviewed.
  • No local project runtime or gates were executed.
  • Runtime failure, subsequent fix, and successful standard CI are not yet confirmed.

After the native RED receipt, publish the one-line production correction with these regression bytes unchanged. Require standard CI and reviews on the final head, then verify the integrated commit. Keep optional FULL, markers, thresholds, timeouts, and gate policies unchanged.