Skip to content

repsel: one safety gate and one write walker for both numeric proofs, plus the #7770 super-chain test and bench numbers - #7788

Merged
proggeramlug merged 3 commits into
mainfrom
repsel/7770-followup-shared-gate
Aug 11, 2026
Merged

repsel: one safety gate and one write walker for both numeric proofs, plus the #7770 super-chain test and bench numbers#7788
proggeramlug merged 3 commits into
mainfrom
repsel/7770-followup-shared-gate

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 10, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #7774 (merged as 2e5bf44). These two commits were pushed to the PR branch but were not in the rebase that got merged, so they are absent from main; the branch was deleted on merge, so this restores them. No behavior change — a consolidation, a coverage gap, and two efficiency items, all from the code review of #7774.

1. One safety gate, not two (the load-bearing one)

prove_group_numeric_fields had grown its own copy of the 'cand loop's entire Pass-3 obligation set: ThisFlowAnalysis construction, ctor_chain_safe, prototype_is_stable, field/method name-ambiguity, per-method method_safe. That verdict is what licenses a bare unchecked load double, so the two copies silently drifting is a miscompile, not a missed optimization — and nothing diffed them against each other.

Extracted as chain_this_flow_verdict, now the single implementation both callers use. Tightening an obligation is a one-place change again.

2. The super-chain resolution path had no test at group scope

prove_numeric_fields resolves a parent constructor's parameters through super(...) argument lists under the caller's already-resolved environment. #7774 made that path reachable through the group MEET (multiple provenance news) for the first time, and every fixture in the new test file had extends: None — so a wrong index or an unresolved caller env there would have granted an unsound claim with zero red tests.

super_chain_params_resolve_under_the_group_meet covers both directions: all-numeric push sites prove the derived and the inherited field; one string at the super-feeding position drops exactly z group-wide while x survives.

3. One write walker, not three

collect_numeric_by_construction_locals had a hand-rolled full Stmt-tree write collector nearly identical to not_bigint_locals::collect_writes — the "two traversals that must agree, drifting by one Stmt variant" bug class that ptr_shape_elements.rs's own doc warns this file cannot afford. Generalized collect_writes to record a no-init Let as None (fine for the non-BigInt fixpoint, fatal for the numeric one) and deleted the duplicate.

4. Two efficiency items

  • The group proof ran its full this-flow walk before discovering the class has no raw-f64-declared field anywhere on the chain (proven arrays of string/object-only records paid for a moot proof). Now bails first.
  • group_members() rebuilt its map twice per collector run — once for the numeric proof, once for the pre-existing group-integrity pass. Computed once, passed to both.

5. The perf numbers for #7770

The merged fragment stops before the bench results. Restores them: on the pinned quiet mini (interleaved arms, best-of-15, two independent runs, outputs byte-verified against Node before timing) the issue's read loop goes 101/102 ms → 91/90 ms, while batch.ts, suite/04_array_read and suite/09_method_calls are unchanged. Includes the trap worth recording — benchmarking this needs the array and its read loop in ONE function, because an array crossing a function boundary is the #7766 shape #7770 does not address (both arms keep all 4 js_number_coerce sites, and the "no regression" is vacuous).

Validation

Rebased onto current main (after #7771 and #7765, which touch neighbouring element-shape code): cargo test -p perry-codegen --lib 850/850 green, cargo fmt --check and the 2000-line file-size gate clean.

Summary by CodeRabbit

  • Performance

    • Improved numeric-field optimization, with an estimated 10–12% target-loop improvement in applicable cases.
    • Reduced unnecessary analysis while preserving byte-identical output where expected.
  • Bug Fixes

    • Correctly handles uninitialized local bindings and values passed through superclass constructors.
    • Prevents invalid numeric promotion when incompatible values, such as strings, are introduced.
  • Tests & Documentation

    • Added coverage for inherited constructors, numeric fields, validation behavior, and benchmark results.

Ralph Küpper added 3 commits August 10, 2026 19:49
… proofs; super-chain group tests

Review findings on PR #7774: extract chain_this_flow_verdict so the 'cand
loop and prove_group_numeric_fields share the single Pass-3 obligation set
(the gate licenses a bare unchecked load double — two drifting copies would
be a miscompile); generalize not_bigint_locals::collect_writes to record
no-init Lets as None and reuse it for the numeric-by-construction fixpoint
(third hand-rolled walker deleted); bail out of the group proof before the
this-flow walk when no chain field is raw-f64-declared; build the
group-members map once per region. New red tests for the super()-argument
resolution path under the group meet, both directions.
@coderabbitai

coderabbitai Bot commented Aug 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 748f02a7-0bf7-4064-8bbd-3f88d02ce469

📥 Commits

Reviewing files that changed from the base of the PR and between 762d10f and 5852fa2.

📒 Files selected for processing (6)
  • changelog.d/7774-element-group-numeric-proof.md
  • changelog.d/7788-shared-this-flow-gate.md
  • crates/perry-codegen/src/collectors/not_bigint_locals.rs
  • crates/perry-codegen/src/collectors/ptr_shape.rs
  • crates/perry-codegen/src/collectors/ptr_shape_group_numeric_tests.rs
  • crates/perry-codegen/src/collectors/ptr_shape_numeric.rs

📝 Walkthrough

Walkthrough

The PR centralizes this-flow and write analysis, reuses element-group membership, improves group-wide numeric proofing, and adds super(...) inheritance coverage.

Changes

Element-group numeric proof

Layer / File(s) Summary
Shared group and flow analysis
crates/perry-codegen/src/collectors/ptr_shape.rs
Element-group membership is cached and reused. Constructor, prototype, method-resolution, and this-flow checks use chain_this_flow_verdict.
Group numeric proof and write tracking
crates/perry-codegen/src/collectors/ptr_shape_numeric.rs, crates/perry-codegen/src/collectors/not_bigint_locals.rs
Group proofing uses explicit membership and skips groups without raw-f64 candidates. Numeric-local analysis reuses collect_writes, which now records uninitialized let bindings as None.
Inheritance validation and benchmark record
crates/perry-codegen/src/collectors/ptr_shape_group_numeric_tests.rs, changelog.d/*.md
Tests cover numeric fields flowing through super(...). Changelogs record validation results, benchmark data, and unchanged cases.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the shared safety gate, write walker, super-chain test, and benchmark updates.
Description check ✅ Passed The description clearly covers the changes, related issue, validation commands, benchmark results, and no-behavior-change intent.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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 repsel/7770-followup-shared-gate

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.

@proggeramlug
proggeramlug merged commit 98b6341 into main Aug 11, 2026
1 of 18 checks passed
@proggeramlug
proggeramlug deleted the repsel/7770-followup-shared-gate branch August 11, 2026 05:23
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