Skip to content

Preserve Module subclass identity in included_modules - #326

Merged
284km merged 14 commits into
mainfrom
codex-rails1-included-module-identity
Nov 27, 2026
Merged

284km merged 14 commits into
mainfrom
codex-rails1-included-module-identity

Conversation

@284km

@284km 284km commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner

Module#included_modules returned an internal backing module for a Module-subclass instance. Return the original instance so ActiveModel recognizes its existing validator module and avoids adding another copy. Corpus955 covers identity, ordinary modules and nested/prepend controls.

Merged current main29016cb8 and the #317 prerequisite with its no-hook optimization. Measured runtime 17f4f9586b93745c6a56daf41d18cd21a34906fd; comparison runtime d0336e573a7040a3768ab5816925b83c09a13fb9 already includes #317, so the identity change is isolated. Ordinary O2, Mere9dec2ff6 / mgz661a01d8. Clean Ruby4.0.10 via tools/ref_ruby.sh, revision a704b7cd95a42cc0cf5f307137bf3aac0285b915, Prism1.8.2, no extra gems.

  • Corpus --both: 1012/1012, hash ON/OFF.
  • VM corpus (-j 1 fresh full replay): 1012 VM / 0 fallback / 0 differences.
  • Source gates, bracket check and default record hygiene pass. Explicit changed-record hygiene also passes.
  • Corpus955 matches reference stdout/stderr/status on evaluator and VM.

Related test_module selection, all modes COMPLETE with no lost passing case; no whole-file acceptance is claimed:

Mode Tests Assertions Failures Errors Skips
reference 4 13 0 0 0
before-evaluator 4 13 0 0 0
after-evaluator 4 13 0 0 0
before-vm 4 13 0 0 0
after-vm 4 13 0 0 0

Targeted Rails files, all sides COMPLETE without bounds events:

Component Mode MATCH RED MISSING BOTH UNCF EXTRA
activemodel before-evaluator-1 9 1 0 0 0 0
activesupport before-evaluator-1 174 0 0 0 0 0
activemodel after-evaluator-1 10 0 0 0 0 0
activesupport after-evaluator-1 174 0 0 0 0 0
activemodel before-vm 9 1 0 0 0 0
activesupport before-vm 174 0 0 0 0 0
activemodel after-vm 10 0 0 0 0 0
activesupport after-vm 174 0 0 0 0 0

Max RSS, KiB, three alternating full-file evaluator pairs, seed12345, 600s / 2GiB per family, jobs2, MT_CPU=0:

File Comparison samples Candidate samples Median change
activemodel/test/cases/validations/acceptance_validation_test.rb 278304 / 254064 / 276688 256752 / 257760 / 258096 -6.84%
activesupport/test/core_ext/time_with_zone_test.rb 384032 / 381312 / 387520 389536 / 375840 / 375056 -2.13%

The initial four-worker VM replay stalled in reference Ruby on the FIFO in corpus498. Its owner terminated only that reference process; the initial 1011 VM / 0 fallback / 1 FAIL result remains in the record. The isolated reference/evaluator/VM program matches, and a fresh complete VM replay with -j 1 passes. The successful corpus --both and Rails measurements use the same unchanged runtime.

RSS varies; no stable memory improvement is claimed. Native extensions explicitly reused from runtime63213030 / binary c7800ad2; measured and installing binary digests are separate in the record. These are targeted files, not a new full-component run.

Evidence: railstest/framework/records/activemodel-included-module-identity.json and loop/2026-11-27-codex-rails1-included-module-identity.md. Historical acceptance remains pinned to its original record commit. #317 must land first.

Final head 4f3ad87f6af485c641665a10268bc70e3e48e2c9 incorporates #317 head 095b6b1f after acceptance. The diff from the measured runtime contains only the four Markdown/JSON records; all runtime/build inputs and the measured binary remain unchanged.

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Reviewed exact head c6875b61bdb42cac86e15a988313b9e3d916473b against main 8e7572369f099d78b818f98f9791107786a7c57f, including the clean prospective integration tree b2fee3b614e71599cc3ef7bdb2d4292212423606. No new actionable finding.

Using the existing backing-module-to-instance mapping keeps included_modules consistent with ancestor and method-owner reflection. Corpus 955 usefully covers overridden equality and duplicate-validator avoidance, alongside ordinary and nested module controls. The inherited dispatch changes are the already-reviewed #317 dependency; its current head remains unmerged.

Independent validation:

  • Fresh ordinary O2 builds of the exact head, current main, and prospective integration, with pinned Mere 9dec2ff687a08433247dbdb7729bc19c8522e538 and mgz 661a01d8bb68f5acd68e3192bd47f081d179c436. No runtime binary reuse. The exact head's generated C SHA-256 also matches the attached runtime record.
  • Corpus 942–944 and 955, eleven existing Module/reflection/native-super/sender cases, and an additional identity probe: head 64/64 and integration 64/64 comparisons match clean Ruby 4.0.10 (revision a704b7cd95a42cc0cf5f307137bf3aac0285b915, Prism 1.8.2), checking stdout, stderr and exit status across evaluator/VM and hash index ON/OFF with tight GC. Main passes all 44 existing-case comparisons and reproduces the differences in the four new files and identity probe. The probe also covers inherited inclusion, extension, class/module dup and clone, returned-array mutation, and identity after GC.
  • All eight source gates pass on head and integration; generated-C bracket depth is 155/1024 on both. Explicit hygiene for the four added records and diff whitespace checks pass.
  • Audited the attached Rails record's equal before/after file inventories and source hashes, per-case results, and six bounded RSS replays. These remain author-provided measurements; I did not rerun Rails, the full corpus/unit suite, or platform/resource acceptance.

Hosted CI is not all passing: unittest-harness and both runtime-load-path jobs fail because their corpus fixtures do not supply the new sh_cls_var statistics. The same failure is present in main's hosted load-path run and independently reproduces on current main and this prospective integration (two failures in each load-path run and both harness subcases). The exact PR head passes those focused harness controls and all six local load-path tests. The relevant fixture/check code has no net integration delta, so these failures are retained as baseline evidence rather than attributed to this diff.

Linux build is still executing; macOS build/reference and other coverage remain queued or incomplete. Current main CI 45775704307 is pending and its jobs endpoint returns an empty inventory. The recorded hold_all_merges / new_failure_review_required remains active for already-reviewed PRs as well. No merge or queue exception is taken; #317 must also land first. COMMENT because this is the authenticated user's own PR.

@284km

284km commented Nov 26, 2026 •

Copy link
Copy Markdown
Owner Author

The separate CI fixture follow-up #334 is now merged on main as d4414ac2 (reviewed head 8a29f72d, measured code f4751983). It changes only the two Python fixtures and their validation records. The reported missing-statistics fixture failure is addressed; no Module identity runtime change was needed for it.

Three alternating pairs pass after the fixture fix: harness 21/0 and load-path 8/0; unchanged main reproduces 21/2 and 6/2. Extra controls verify that missing or oversized statistics rows stop before reference corpus execution. Real corpus --both is 973/973; VM 973 / 0 fallback / 0 differences; all nine current source gates, bracket check and explicit record hygiene pass. Code and records were pushed together once. The follow-up review found no issue.

The #317 prerequisite and the recorded merge hold remain separate; this comment does not request a merge exception.

@284km

284km commented Nov 26, 2026

Copy link
Copy Markdown
Owner Author

Checked the later completed corpus job at reviewed head c6875b61. Its failure is the existing VM-stream issue #323: 830_for_splat_targets.rb has stack_max 6 versus Ruby 5. It is not a new Module identity finding.

The preceding stages pass: corpus 977/977 with hash index ON/OFF; VM 977 / 0 fallback / 0 failures; vm_check 246/246; snippet comparison 460/0. Whole-file ISeq comparison reports 976 same / 1 different / 0 errors, with that one known metadata difference. This hosted merge-cohort count is separate from the exact-head local 970-program acceptance in the description.

Both review bodies and inline comments have been checked again; no actionable review finding remains. This PR is already Ready for review. The #317 dependency and the owner’s recorded merge hold remain in effect.

@284km

284km commented Nov 27, 2026

Copy link
Copy Markdown
Owner Author

Updated head: 4f3ad87f6af485c641665a10268bc70e3e48e2c9.

Merged main 29016cb8 and #317's no-hook optimization, then completed fresh local acceptance: corpus --both 1012/1012; full VM replay 1012 VM / 0 fallback / 0 differences; source gates plus default/explicit record hygiene pass. All four selected Module cases (13 assertions) pass on reference and both before/after engines.

ActiveModel acceptance validation improves 9 MATCH / 1 RED → 10 MATCH / 0 RED on evaluator and VM; the complete TimeWithZone file stays 174 MATCH / 0 RED. All files COMPLETE, no bounds events. Three fixed-seed RSS pairs for both files and their variation are recorded.

The initial four-worker VM run stalled in the reference Ruby FIFO case498. Only that owned reference process was terminated, and its failed replay is retained separately. The isolated reference/evaluator/VM program matches; the fresh complete VM replay passes with -j 1.

Measured runtime 17f4f958 has unchanged runtime/build inputs in the final head: the later #317 update adds only Markdown/JSON records. Code/main integration and records were pushed together once. Ready/MERGEABLE; the inline-comment endpoint is currently empty. This exact head still needs the review bot, and #317 must land first. No merge-hold exception is requested.

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Re-reviewed updated head 4f3ad87 against freshly fetched main b9ca06d, including the previous review, follow-ups, inherited #317 changes and new records. No new actionable finding. The original-instance mapping still provides the intended identity/equality behavior, and the no-backing hook fast path sets its flag at both backing creation and copying.

Independent Darwin arm64 validation:

  • Corpus 942–944/955 and 11 neighboring Module/reflection/sender/native-super files: 60/60 comparisons match clean Ruby 4.0.10 in stdout/stderr/status across evaluator/strict VM and hash index ON/OFF with tight GC.
  • An additional probe using module_eval to define methods matches in all 4 configurations: included-hook receiver identity, inherited inclusion, returned-array mutation, Module-subclass dup/clone, extension, GC lifetime and ordinary hooks before/after backing creation. The initial probe instead defined the method inside the Module-subclass new block and failed. A separate minimal control reproduces that existing constructor-block method-definition gap on current main and head, both engines; the initial failure is retained and excluded from passing totals, not attributed to this PR.
  • Unchanged upstream test_module selection (module_subclass_initialize, included_modules_with_prepend, ancestors, included_modules): reference, main evaluator/VM and head evaluator/VM each pass 4 tests / 13 assertions, no skips or lost passing case. This is selected-case acceptance, not whole-file acceptance.
  • The earlier fixture failure is addressed: harness 21/21 and load-path 8/8 pass locally. Hosted unittest-harness now also passes. Nine source gates, fresh generated-C bracket depth 155/1024 and diff whitespace pass.
  • Reused the recorded O2 binary 0f51e0123391f18e2a9cd3b3148d49fec425c910a0b953b989ba1a26dc9a0ba6 after comparing 685 tracked runtime/build inputs against the clean build checkout and verifying imported pinned mgz inputs. The measured runtime 17f4f95 differs from this head only in four Markdown/JSON records. Fresh emission using clean pinned Mere 9dec2ff6 reproduces the recorded C digest. Current-main control inputs were independently compared against all 687 corresponding runtime/build files. No fresh runtime compilation is claimed.

Audited the refreshed Rails records: matching before/after file and case inventories, COMPLETE results, original 600-second/2-GiB family bounds, and explicitly separate native-install provenance. The initial FIFO VM replay failure is retained separately from its successful serial replay. These full-sweep/Rails/RSS results remain author-provided evidence; I did not rerun full suites or resource/platform acceptance.

The prospective merge is source-clean (tree 4fd04e9c4003078a952adaca21d755fdf9aff9f2); no integration binary was tested. No merge: prerequisite #317 remains open, build-linux is executing the C API comparison, macOS build/reference jobs are unassigned with zero steps, and downstream coverage is incomplete. Main CI 45916943242 is pending with an empty job inventory. The recorded all-merge/new-failure-review hold also applies to already-reviewed candidates and remains active; these conditions are not covered by the queue exception. COMMENT because the authenticated account owns this PR.

@284km 284km left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Review of 4f3ad87f. No Critical/Major/Minor findings. mod_vclasses now returns the Module-subclass instance itself (mod_inst_self) instead of its internal backing class, so included_modules shows the identity ActiveModel compares against. The fresh current-main corpus (1012/1012, VM 0 fallback) is posted, and #317, which this sits on, is merged first. The review bot reviewed this head with no findings, and the test merge with current main is clean.

@284km
284km merged commit 7850d07 into main Nov 27, 2026
14 of 20 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