Skip to content

Test native IR invariants and harden append-fold helper contract - #9370

Merged
youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:upgrade-native-ir-invariants-20261025
Oct 26, 2026
Merged

youknowone merged 1 commit into
RustPython:mainfrom
youknowdot:upgrade-native-ir-invariants-20261025

Conversation

@youknowdot

Copy link
Copy Markdown
Contributor

Summary

  • Add three direct native-IR invariant tests from the Python 3.15 upgrade: raw constant-pool representation, malformed append-sequence rejection, and vacated instruction-slot metadata reuse.
  • Harden the private constant-sequence folding helper to reject terminal ListAppend/SetAdd depths other than one, preserving the existing helper structure.
  • Existing production callers already require depth one: this is defensive helper-contract hardening, not a newly fixed reachable interpreter bug. All pre-existing tests and comments are preserved.

The tests construct IR directly; no Python-source behavior tests were added. The raw frozenset vector and inactive instruction-storage assertions are not observable through Python-level equality. The unchanged negative test includes ListAppend 2; the symmetric SetAdd guard has no dedicated depth-two assertion.

Validation

  • cargo check --locked --offline -p rustpython-codegen --tests
  • cargo clippy --locked --offline -p rustpython-codegen --tests -- -D warnings
  • cargo test --locked --offline -p rustpython-codegen --lib --no-run --message-format=json
  • Three exact native selectors, single-threaded: constant_append_sequences_fold_for_iteration_and_membership, constant_append_sequences_require_unaliased_matching_constant_elements, redundant_nop_compaction_clears_vacated_instruction_metadata — 3 passed, 0 failed, 0 ignored.

Only those three native tests executed under bounded guards; no Python/parser/VM/lifecycle payload execution. Full workspace, C-API and canonical Python suites were not run for this slice.

AI-assisted; disclosed in the commit trailer.

Retain direct IR coverage for constant-pool representations, malformed
append-sequence rejection, and vacated instruction-slot metadata reuse.
Reject non-unit terminal append depths at the private folding helper.
Existing production callers already require depth one; this is defensive
contract hardening, not a newly fixed reachable interpreter bug.

Preserve the existing helper structure and all pre-existing tests. The
three added native tests are unchanged from the Python 3.15 upgrade work.

Validation: codegen check and strict Clippy with --tests, a --lib --no-run
build, and exactly three bounded native IR tests (one pass, zero ignored
each). No Python, parser, VM or lifecycle payload was executed. The
symmetric SetAdd guard has no dedicated depth-two assertion.

Assisted-by: OpenAI Codex:model version unavailable
@coderabbitai

coderabbitai Bot commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Caution

Review failed

The pull request is closed.

Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@youknowone
youknowone marked this pull request as ready for review October 26, 2026 01:12
@youknowone
youknowone merged commit 9710aa5 into RustPython:main Oct 26, 2026
29 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T01:13:48.020182Z
We couldn’t complete this review. Comment @codex review to try again.
da4cbaf Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

youknowdot added a commit to youknowdot/RustPython that referenced this pull request Oct 26, 2026
Restore main warning matching and unused opcode override tooling. Keep the exact native IR tests and minimal helper guard from RustPython#9370 while pruning equivalent folding refactors. Remove only the newly added frozendict Rust/Python wrapper, preserving its Python suite and all runtime fixtures.

Validated this exact tree with fresh codegen test-target and selected threaded VM library checks and strict Clippy. No test bodies, interpreter runtime or metadata generators executed.

Assisted-by: OpenAI Codex:model version unavailable
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.

2 participants