Skip to content

Preserve visibility and metadata for self aliases - #372

Merged
284km merged 1 commit into
mainfrom
codex-misc-self-alias-metadata
Nov 27, 2026
Merged

284km merged 1 commit into
mainfrom
codex-misc-self-alias-metadata

Conversation

@284km

@284km 284km commented Nov 27, 2026

Copy link
Copy Markdown
Owner

Self-aliasing preserves the source method visibility, including private/protected methods and an inherited public visibility override. For an owned identical-name alias, unchanged body/closure/scope metadata is retained while alias-sharing warning state and method_added still run. An explicitly public owned initialize stays public, as in Ruby. Inherited, prepended and builtin sources keep their normal copy path. The original resource timeout remains unresolved; this PR fixes correctness and avoids redundant metadata writes.

Fresh local acceptance uses clean Ruby 4.0.10 through tools/ref_ruby.sh. The two full sweeps use the same freshly built O2 candidate, with hash indexing ON and OFF.

  • sh run_corpus.sh --both: 995/995 PASS, exit 0.
  • MERE_RUBY_VM=1 sh run_corpus.sh --both: 995/995 PASS, exit 0.

Focused corpus 1136 matches the reference on both engines (stdout, stderr and exit status). Related original CRuby selections are run unchanged, one file at a time, against the exact matching main 410c231. Every invocation uses MERE_RUBY_GC_TIGHT=1 and parsed --seed=1. The selected test counts below do not claim whole-file or full-suite passes.

Original selection Ruby 4.0.10 Main evaluator Candidate evaluator Main VM Candidate VM
ruby/test_alias.rb (8 selected) 8 / 19 PASS 8 / 19 PASS 8 / 19 PASS 8 / 19 PASS 8 / 19 PASS
ruby/test_alias.rb (1 selected) 1 / 3 PASS 1 / 0, 0 failures, 1 errors 1 / 0, 0 failures, 1 errors 1 / 0, 0 failures, 1 errors 1 / 0, 0 failures, 1 errors

RSS values below are measured maximum resident set sizes of the test driver from /usr/bin/time -l, in bytes.

Max RSS bytes, same selections Reference Main evaluator Candidate evaluator Main VM Candidate VM
ruby/test_alias.rb (8 selected) 22413312 162807808 163037184 163397632 161333248
ruby/test_alias.rb (1 selected) 22233088 247119872 212910080 233619456 228720640

Cost measurements use three alternating main/candidate O2 pairs, tight GC and parsed --seed=1. Instructions and elapsed seconds are medians; RSS is the maximum of three runs. Elapsed time is diagnostic under shared-machine load.

Workload / engine Instruction change Main / candidate median seconds Main / candidate max RSS bytes
plain / evaluator -0.093% 0.414438 / 0.406449 84000768 / 84131840
owned / evaluator -15.969% 0.139142 / 0.144011 78151680 / 72105984
churn / evaluator +0.009% 0.645945 / 0.615237 86425600 / 86343680
plain / VM -0.147% 0.475936 / 0.418925 85164032 / 85147648
owned / VM -15.880% 0.165496 / 0.139545 78708736 / 73056256
churn / VM -3.134% 0.750932 / 0.650144 92667904 / 88850432

Candidate O2 SHA-256: 61cd87c2324a702c0e4bc351cccce4229f9667166ea977847d7859900354c793. Matching-main control: 410c231. Compiler 9dec2ff6, mgz 661a01d8.

Original ruby/test_alias.rb test_alias_memory_leak is unchanged: 500 x 1000 define/alias/remove operations, original timeout and memory assertions. Reference passes 1 test / 3 assertions; matching main and candidate both time out on evaluator and VM. This is still an open throughput RED, not a leak diagnosis or a claimed resource-test fix. The separate plain/owned/churn 10000-iteration benchmarks are diagnostics, never substitutes for that original case. Corpus 1136 has 10 reference-matched rows including visibility, hooks, Method snapshots, closures, super/prepend, native aliases, public initialize and warning behavior.

Eight source gates (gc_roots, dup_defs, dead_defs, meth_writes, name_spec, rx_caps, ns_names, name_len), generated-C bracket depth, full/explicit completed record_hygiene and staged/unstaged whitespace: PASS. Code/integration and the completed loop record are pushed together. No full unit/Rails suite, reference gem installation or workflow change.

@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 499f6edc3400e6d0e651f5dafdab68bc0ff04f8a against freshly fetched current main 391b560e5f3311f5ec4b0503684ccd1d0bbd7de4. No new actionable finding. Capturing effective visibility before destination mutation fixes the self-alias cases, and the owned-method shortcut retains hooks and warning sharing while preserving closures and Method snapshots. The prospective merge is clean and has only the four intended files; I did not build that integration tree.

Independent validation: fresh ordinary O2 builds of current main and this exact head with pinned Mere 9dec2ff687a08433247dbdb7729bc19c8522e538 and mgz 661a01d8bb68f5acd68e3192bd47f081d179c436; no runtime binary reuse. Against clean Ruby 4.0.10, corpus 1136, twelve existing alias/visibility/reflection cases, and an additional probe give 56/56 exact matches on head, checking stdout, stderr and exit status across evaluator/VM and hash index ON/OFF with tight GC. Main matches all 48 existing-case comparisons and reproduces the visibility failures in the new corpus and probe. The probe also covers singleton visibility, repeated method_added events, frozen-class refusal, prepend, alias original_name, lexical constants and a saved closure after redefinition/GC. All eight source gates pass, generated-C bracket depth is 155/1024, explicit completed-record hygiene passes, and diff whitespace is clean. No tracked AGENTS.md or CLAUDE.md was found in either fetched tree.

Hosted CI is not all passing. Main run 45913249285 and PR run 45914294032 both fail the bundled-network step. Their downloaded network artifacts have identical whole-file inventories and identical failing case tags: TestNetHTTPInRactor#test_get, TestNetHTTPS#test_ractor and TestTimeout#test_ractor (450 cases: 445 MATCH, 3 RED, 2 BOTH). The HTTP failure in both logs reports an un-shareable Proc in Process.__clock_check inside a Ractor, followed by the same Marshal diagnostic. This is retained baseline evidence, not a finding caused by this diff or a claim that the failure is repaired. macOS/reference and downstream coverage remain queued or incomplete.

I did not rerun full corpus, original whole-file Alias/resource acceptance, Rails, instruction benchmarks or full platform acceptance; the original Alias timeout remains explicitly unresolved in this PR's record. No merge: recorded hold_all_merges / new_failure_review_required is active, and actual CI failures mean this is not a queue-only exception. Already-reviewed #317/#326/#355 were also considered; #355 retains an actionable P2 and #326 depends on unmerged #317. COMMENT because this is the authenticated user's own 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 499f6edc. No Critical/Major/Minor findings. The source visibility is now read before the destination flags are cleared, so alias_method :x, :x keeps a private, protected or inherited-public-override visibility. An owned identical-name alias no longer copies its own records onto itself, but still marks the shared definition for redefinition warnings and fires method_added. Inherited, prepended and builtin sources keep the normal alias path. The review bot reviewed this head with no findings, corpus --both 995/995 and the VM corpus are posted, and the test merge with current main is clean.

@284km
284km merged commit b9ca06d into main Nov 27, 2026
11 of 19 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