Skip to content

feat(conformance): python emit-compile-run #1039#1099

Merged
TSavo merged 1 commit into
mainfrom
1039-python-conformance
May 17, 2026
Merged

feat(conformance): python emit-compile-run #1039#1099
TSavo merged 1 commit into
mainfrom
1039-python-conformance

Conversation

@TSavo
Copy link
Copy Markdown
Owner

@TSavo TSavo commented May 17, 2026

Closes the Python side of #1039. 5 fixtures (hello_world, recursive factorial, arithmetic, control flow, transported concept citation comment). CI slow lane runs LiftKit → BindKit → LowerKit → py_compile → python3 + behavior assertion. Refusal paths for target-compile-failure + target-behavior-divergence both verified.

43 python realize tests pass, 39 python lift tests pass, 2 cargo slow-lane conformance tests pass.

🤖 Generated with Claude Code

Summary by CodeRabbit

Release Notes

  • Tests

    • Added comprehensive conformance test suite validating Python code generation, compilation, and runtime behavior across multiple test scenarios.
    • Extended CI pipeline with additional slow-lane validation for Python conformance.
  • New Features

    • Enhanced language support for conditionals, function calls, and recursive functions in Python code processing.

Review Change Stack

Adds 5 Python fixtures (hello_world, recursive factorial, arithmetic,
control flow, transported concept citation comment) under
implementations/python/conformance/fixtures, plus a CI slow lane that
runs real LiftKit → BindKit → LowerKit, invokes py_compile then python3,
and asserts behavior equivalence to the original source.

Refusal paths verified: target-compile-failure and target-behavior-divergence
both emit CompositionRefusalMemento with the expected failure_kind.

Extended Python lift/realize support for leaf-only returns, `pass` as
concept:skip, ternary conditionals, and call callee slots — surfaced
naturally by the fixtures.

43 python realize tests pass, 39 python lift tests pass, 2 cargo slow-lane
conformance tests pass. Pre-existing bug-zoo TypeScript red on local
default lane is sandbox-environmental (tsx unavailable), task #70 not
introduced by this PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 17, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8494c017-42ec-466f-9af8-78f772ef9af5

📥 Commits

Reviewing files that changed from the base of the PR and between ec2f329 and 519cd52.

📒 Files selected for processing (16)
  • .github/workflows/ci.yml
  • implementations/python/conformance/fixtures/arithmetic/expected.json
  • implementations/python/conformance/fixtures/arithmetic/original.py
  • implementations/python/conformance/fixtures/control_flow/expected.json
  • implementations/python/conformance/fixtures/control_flow/original.py
  • implementations/python/conformance/fixtures/hello_world/expected.json
  • implementations/python/conformance/fixtures/hello_world/original.py
  • implementations/python/conformance/fixtures/recursive_function/expected.json
  • implementations/python/conformance/fixtures/recursive_function/original.py
  • implementations/python/conformance/fixtures/transported_op_via_concept_citation_comment/expected.json
  • implementations/python/conformance/fixtures/transported_op_via_concept_citation_comment/original.py
  • implementations/python/provekit-lift-python-source/src/provekit_lift_python_source/bind_lifter.py
  • implementations/python/provekit-lift-python-source/tests/test_bind_lifter.py
  • implementations/python/provekit-realize-python-core/src/provekit_realize_python_core/realizer.py
  • implementations/python/provekit-realize-python-core/tests/test_emit_compile_run_conformance.py
  • implementations/rust/provekit-cli/tests/python_emit_compile_run_conformance.rs

Walkthrough

This PR extends the Python lift and realize subsystems to support pass statements, ternary expressions, and explicit call handling, introduces five conformance fixtures demonstrating basic language constructs, and adds comprehensive Python and Rust test suites validating the lift→emit→compile→run pipeline end-to-end via fixture-driven expected outputs.

Changes

Python Conformance Testing

Layer / File(s) Summary
Conformance Fixture Definitions
implementations/python/conformance/fixtures/*/original.py, implementations/python/conformance/fixtures/*/expected.json
Five fixture sets define observable Python behavior: hello_world returns a string constant, arithmetic/blend computes (x + y) * z - x, control_flow/abs_value uses conditionals, recursive_function/factorial implements recursion, and transported_op_via_concept_citation_comment demonstrates concept citations. Each includes both reference implementation and expected output cases.
AST Lifting Extensions
implementations/python/provekit-lift-python-source/src/provekit_lift_python_source/bind_lifter.py
ast.Pass nodes map to concept:skip operator shapes; ast.IfExp (ternary) maps to concept:conditional with shaped test/body/else operands; ast.Call now includes the call target as the first operand in the resulting concept:call shape. Block-level leaf tracking enables proper operand binding aggregation for statements without operator shapes.
Bind Lifter Test Updates
implementations/python/provekit-lift-python-source/tests/test_bind_lifter.py
Loop bodies now asserted as nested _gamma_shape("concept:skip") instead of empty shapes; concept:call operand structure expanded to include shaped call target as first argument; while-vs-for discrimination tests updated to match new loop body representation.
Realizer Lowering for Skip and Call
implementations/python/provekit-realize-python-core/src/provekit_realize_python_core/realizer.py
concept:skip with no arguments emits empty TermBody and None-typed expression; concept:call with arguments emits direct Python call when callee is an identifier, with return type from mapped operation; operation return-type inference special-cases both operators.
Python Conformance Test Suite
implementations/python/provekit-realize-python-core/tests/test_emit_compile_run_conformance.py
Fixture-driven validation loads expected outputs from JSON, executes original.py in fresh namespace, applies lift→emit→compile pipeline to stub code, runs emitted module as subprocess, and asserts JSON output equality. Tests fixture registry structure, compile/runtime failure kinds, and concept citation comment emission.
Rust End-to-End Conformance and CI
implementations/rust/provekit-cli/tests/python_emit_compile_run_conformance.rs, .github/workflows/ci.yml
Rust slow-tests suite orchestrates full provekit pipeline (lift→bind→lower via KitRegistry) for each fixture, validates emitted code produces original outputs, and includes fixture enumeration and Python execution harness. CI integration adds slow test to trinity-composition-census job with --nocapture output.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • TSavo/provekit#1074: Extends the same CI slow-lane job that already runs trinity_composition_census by adding the new python_emit_compile_run_conformance Rust test step.
  • TSavo/provekit#1046: Introduces the conformance metadata and refusal failure_kind taxonomy that the main PR's test suite relies on for compile and behavior divergence detection.
  • TSavo/provekit#1034: Implements the transported-op concept-citation comment behavior that the main PR exercises via the transported_op_via_concept_citation_comment fixture and test validation.

Suggested labels

area:conformance, substrate-correctness

Poem

🐰 From fixtures small to pipelines wide,
We lift and lower, test with pride!
Pass statements skip, calls now ring true,
Conformance flows from old to new. ✨

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 1039-python-conformance

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@TSavo TSavo merged commit d45bbd1 into main May 17, 2026
6 of 8 checks passed
TSavo added a commit that referenced this pull request May 17, 2026
…emanticTag ruling

Adds the 2026-05-17 post-#1039 + post-PlatformSemanticTag-ruling snapshot.
Per-kit emit-compile-run conformance shipped across Python (PR #1099),
Java (PR #1100), and C (PR #1101). PlatformSemanticTag schema ruling
locked at docs/plans/2026-05-16-platform-semantic-tag-schema-ruling.md.
Stream A Stages 2-5 implementation work surface enumerated and unblocked
for dispatch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 519cd52c24

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +260 to +261
if isinstance(node, ast.Pass):
return _operator_shape_result("concept:skip", [])
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve leaf return after pass statements

Treating ast.Pass as concept:skip here changes control-flow shaping for blocks like def f(x): pass; return x: _shape_block_with_bindings keeps operator-shaped statements and drops later leaf-only returns when any operator is present, so this function now lifts as just skip and realizes to an implicit None return instead of returning x. This is a behavioral regression introduced by making pass an operator without also preserving a trailing leaf return in mixed blocks.

Useful? React with 👍 / 👎.

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