Skip to content

fix(glr): certify Python clean-tie election across mixed GSS stacks - #1026

Merged
odvcencio merged 4 commits into
mainfrom
codex/compact-grammar-certification-python-20260902
Sep 2, 2026
Merged

fix(glr): certify Python clean-tie election across mixed GSS stacks#1026
odvcencio merged 4 commits into
mainfrom
codex/compact-grammar-certification-python-20260902

Conversation

@odvcencio

Copy link
Copy Markdown
Owner

Summary

Fix compact acceptance for Python clean ties that arrive as a flat stack and a packed graph stack.

  • Preflight mixed representations before promotion. Preserve status, shift, state, byte, clean-zero, and materializing-shape gates.
  • Use the incoming packed stack as the physical merge receiver when it matches C's version-head ownership. Keep the incumbent as the logical survivor.
  • Preserve both producer paths, sticky error history, diagnostic version identity, and topology telemetry. A rejected shape consumes no staging nodes.
  • Enable C raw-subtree ordering for the exact Python grammar blob on clean, non-recovery ties.
  • Make the former Python interpolation rewrite an observed counted no-op. The producer now emits the C-owned choice.
  • Retire the two family-D Python divergences and record exact route digests.

The support lane in PR #1025 merged before this branch.

Smallest falsifiers

  • x, y, z = 1, 2, 3 versus the C oracle.
  • f"{x, y}" versus the C oracle.
  • f"{*xs,}" versus the C oracle.
  • Additional with-target, except-target, star-target, call-argument, parenthesized-tuple, and conversion-format controls.

The old Python paths selected pattern_list for these producer ties. C selects expression_list.

Proof

Focused Docker tests pass for mixed flat/GSS merges, logical version ownership, distinct-shape rejection, sticky error inheritance, topology receipts, and the C comparator.

The generated Python corpus from the pinned grammar source passes the A3 sweep: 3 real files plus 30 constructed files, 33 accepted, and zero divergences.

The Python route receipt reports exact C digests for raw, production, compact, and incremental trees. Scanner reuse remains true. Compact counters report one routed parse and zero fallbacks for all three blocker witnesses.

The forest splat witness remains a known forest-only difference (pattern_list versus C's expression_list). The compact gate does not certify forest output, and dispatch.python remains live.

Verification commands

bash cgo_harness/docker/run_parity_in_docker.sh --repo-root /home/draco/work/gts-compact-grammar-certification-python-20260902 --no-build --label core-post-rebase-gates -- 'go test . -run "TestTryGSSMainMergeResultMixed|TestA3ArmNoOpConfirmationPythonConfirms|TestAdmissionCandidateCertifiedAcceptanceFrontiers" -count=1 && go test . -tags gts_workcount -run "TestDiagnosticTopologyMixed|TestDiagnosticTopologyReceipt(RecordsChildElection|NodeAllocationRefreshesReusedPointer|PreservesEntriesPrefixAcrossPromotionAndCopy|SeparatesMutatedEntriesCopiesBeforePromotion)$" -count=1 && go test ./grammars -run "^TestBuiltinCompactAcceptanceProfilesRequireExactBlobIdentity$" -count=1'

bash cgo_harness/docker/run_parity_in_docker.sh --repo-root /home/draco/work/gts-compact-grammar-certification-python-20260902 --no-build --label python-final-certification -- 'cd /workspace/cgo_harness && go test . -tags "cgo treesitter_c_parity" -run "^TestPython(DispatchBlockerReceipt(Document|Routes)|SchedulerAction(LoadBearingCOracleParity|KnownGapCOracleParity|NeutralSubpassCOracleParity)|A3CompactCertificationFullCorpusSweep)$" -count=1 -v'

bash cgo_harness/docker/run_parity_in_docker.sh --repo-root /home/draco/work/gts-compact-grammar-certification-python-20260902 --no-build --label core-package-correctness-final -- 'go test . -count=1'

No performance changes are included.

- Merge a flat stack with an already-packed GSS stack in tryGSSMainMergeResult. The incoming stack can supply the physical graph receiver while the incumbent keeps the logical survivor slot, byte offset, and version.
- Check a mixed pair against the existing status, shift, state, byte-offset, clean-zero, and distinct-shape gates before it stages. Rejected pairs keep the flat survivor unchanged and consume no GSS scratch nodes.
- Certify the structural election for Python's exact blob, so the producer elects expression_list for assignment-right and f-string tuples the way the C reference does.
- Reduce normalizePythonInterpolationPatterns to a counted no-op. The producer now owns the choice, so a post-build rewrite would undo it.
- Retire the two family-D Python known divergences, flip the arm no-op confirmation, and update the blocker-receipt digests and the 2026-09-02 PARTIAL-GO section in docs/root-normalization-retirement.md.
- Drop meson from the certified acceptance-frontier candidates. Its compact tree intentionally differs from Go's historical tree and stays covered by the locked-C parity test.
- Add unit tests and diagnostic topology receipt tests for mixed merges, distinct-shape rejection, sticky error inheritance, and scratch-budget bounds.

Buckley-Change-Hash: sha256:59e05a80ccabbd9fc163998be0042d4d552ee8ece1c6bc7b3cbfb40263fa4f5b
Buckley-Change-Stats: files=14 insertions=697 deletions=209 binaries=0
- Add Language.CompactMixedGSSMergeCertified. A mixed boundary merge in tryGSSMainMergeResult now runs only for a certified grammar artifact, so uncertified grammars keep one stack representation instead of adopting C's physical receiver ownership.
- Certify python for the mixed merge in its exact built-in runtime profile, and require the flag there under the locked blob hash.
- Restore the meson case in TestAdmissionCandidateCertifiedAcceptanceFrontiers. The narrower gate makes its compact tree match the historical production tree again.
- Keep a nil language on the current merge route so profiles without a language object behave as before.

Buckley-Change-Hash: sha256:4124c9fa9104c3f55ae6ff281ab1117e07c13d19f7104c9a56732906eafcf816
Buckley-Change-Stats: files=5 insertions=21 deletions=7 binaries=0
- Set CompactMixedGSSMergeCertified on the Language fixture in TestTryGSSMainMergeResultMixedDistinctShapesRejectWithoutMutation.
- Match the language flags that the mixed GSS merge path checks before it selects the compact representation.
- Keep the assertions unchanged: the distinct-shape check must still reject the merge and must not mutate the inputs.

Buckley-Change-Hash: sha256:9c5cd648647a5b5fc413177375bf539015089e20fffa69e6d8b31cfe2b804433
Buckley-Change-Stats: files=1 insertions=4 deletions=1 binaries=0
- Count certified flat/GSS representation joins in MergeEventCensusCounts. The C runtime has no version merge for these joins, so they no longer share the lane's Successes counter.
- Record the attempt in tryGSSMainMergeResult before the remaining gate checks, and record the success on the merged-path side. This separates representation joins from ordinary main merges.
- Stop recording a distinct-shapes refusal for that rejection branch, because the census now classifies that event on its own.
- Report RefuseNoGSSHead and RefuseNoGSSHeadOne for each mixed attempt, so the packed-head baseline stays a gate observation.
- Add the matching no-op hooks for the disabled census build tag.
- Sum the new counters in the cgo_harness census totals and print them in the totals line.
- Update the test to cover both new counters, and refresh the pinned baselines: python sources 26 to 30, and the constructed-source denominator 104 to 108.

Buckley-Change-Hash: sha256:d92b1482343939da9cc2ffa58b50dcd9b4e0d0e08d647945f77d6a1b062afe13
Buckley-Change-Stats: files=5 insertions=50 deletions=13 binaries=0
@odvcencio
odvcencio merged commit 106508e into main Sep 2, 2026
50 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant