Skip to content

Recover accepted Ripper call prefixes before missing block ends - #414

Merged
284km merged 16 commits into
mainfrom
codex-rails1-ripper-incomplete-commands
Dec 1, 2026
Merged

284km merged 16 commits into
mainfrom
codex-rails1-ripper-incomplete-commands

Conversation

@284km

@284km 284km commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Action View loses render dependencies in incomplete ERB snippets because Ripper emits no accepted call header before the missing end. Recover the accepted prefix for that error family, keeping the failed parse and its diagnostics. Restore callback error? state and reject parser reentry as Ruby 4.0.10 does.

Fixes #339. Addressed P2/Major #4736736761 from head 32039d67: fail closed before visiting recovered prefixes containing an unsupported command/do-block argument. Corpus 1026 adds the rejected suffix and its parenthesized-inner control. A 56-source matrix reports 55 matches and one pre-existing difference on each hosted Prism version (1.8 / 2.1) and on all 8 native engine/index/GC configurations. It has no new regression, false render or exception.

The isolated Rails lock selects Prism 2.1.0; both its ErrorRecoveryNode and bundled Prism 1.8.2 MissingNode remain incomplete. Corpus 1026 covers the accepted headers, opaque callback values, nested/prefix/body cases and repeated rescued reentry. A bare argument-less fcall is deferred until its block is complete, as Ruby requires. Ordinary recursive helper methods avoid a self-referential traversal closure.

Runtime f55995a0140a5aa9c15611235a93f6dc1c6cf34b, main baseline 9d1c0f32. Local validation:

  • 1040/1040 corpus programs match ruby, with the hash index ON and OFF
  • vm_corpus: 1040 programs -- 1040 on the VM, 0 on the evaluator (fell back), 0 FAIL, 0 against the list of fallbacks
  • All source gates, StrBuf source/emitted-C checks and default/explicit record hygiene pass.
  • ActionView dependency tracker: 79 MATCH / 1 RED → 80 MATCH / 0 RED on evaluator and VM; all other categories zero, all file sides COMPLETE. No framework expectation changed.
  • Official Ripper: test_sexp (58 tests / 98 assertions) and test_scanner_events (64 / 631) pass on both builds/engines. test_ripper retains 4 internal 10-second leak-test timeouts and test_parser_events 2, identical to main on each engine; their REPORT_MISMATCH states are not PASS. Outer 600 s / 2 GiB limits were not reached. Full identities and states are retained.
  • Large AS JSON: 158 MATCH/zero other categories in all 12 observations. Fresh native install for each exact binary; packaged Nokogiri libraries; seed 12345, jobs 2, normal GC, 600 s / 2 GiB bounds.
Engine Before RSS samples KiB After RSS samples KiB Median change
evaluator [1503872, 1586272, 1613408] [1626368, 1447872, 1608944] +1.43%
vm [1268352, 1286928, 1274624] [1249344, 1264624, 1287072] -0.78%

Parse instruction counts, before→after (net per parse including loop and explicit GC):

  • valid, evaluator: 579,551,265→580,440,964 (+0.15%).
  • valid, vm: 578,163,650→580,479,594 (+0.40%).
  • missing_end, evaluator: 467,715,001→1,229,015,014 (+162.77%).
  • missing_end, vm: 469,290,211→1,225,119,711 (+161.06%).

The error path now performs accepted-prefix work. This does not claim complete invalid-source Ripper parity. Full raw case identities, sample variation and execution states are retained in railstest/framework/records/actionview-ripper-incomplete-prefix.json and the loop note.

Reference: tools/ref_ruby.sh, clean Ruby 4.0.10 revision a704b7cd95a42cc0cf5f307137bf3aac0285b915, Prism 1.8.2, zero extras. Effective default Gem paths: 46 default + 38 exact bundled specs (manifest checked); isolated installer audit: 46 default only. Compiler 9dec2ff6, mgz 661a01d8. Owner merge waits for automated review of the exact head.

@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 32039d674829888d9b93149afdffc818cf768f11 against current main f0f372e7dc00967ae881f599eae68758648a9148 in isolated checkouts. The accepted-prefix walk fixes the original layout-call case, preserves opaque callback values, and correctly retains the active reentry guard after rescued recursive attempts. One P2 / Major issue remains: the new recovery can dispatch calls after a syntax rejection that native Ripper has already encountered (inline).

Independent validation on macOS arm64:

  • Fresh ordinary O2 builds of both revisions using pinned Mere 9dec2ff687a08433247dbdb7729bc19c8522e538 and mgz 661a01d8bb68f5acd68e3192bd47f081d179c436. Clean Ruby 4.0.10 selected through tools/ref_ruby.sh, revision a704b7cd95a42cc0cf5f307137bf3aac0285b915, Prism 1.8.2, 38 bundled nondefault gems and no extras.
  • All 11 existing Ripper corpus fixtures match the reference on base/head, evaluator/VM, and Hash index on/off: 88/88 control comparisons. New corpus 1026 matches on all four head combinations; its four main comparisons differ as expected for the behavior being repaired.
  • Complete upstream test_sexp.rb (58 tests / 98 assertions) and test_scanner_events.rb (64 / 631) pass on reference and both revisions/engines, with zero failures/errors/skips. These focused runs used a 120-second process timeout; they are not a resource-acceptance measurement.
  • A 1,377-input exploratory matrix produces identical output through the head's native evaluator and its Ruby-loaded adapter, with no exceptions. This is exploratory coverage, not a claim of reference parity. The new rejected-suffix callback is separately reproduced in all four head engine/index combinations; both main and native Ruby omit that callback. Parenthesizing the inner call and the original missing-layout-block case are retained as controls.
  • Regenerating the entire embedded Prism/Ripper source produces a byte-identical m_prism_lib.mere. GC roots against freshly emitted C, duplicate/dead-definition checks, StrBuf source/emitted-C checks, and diff whitespace checks pass.

I did not independently rerun the full corpus, all upstream Ripper files, Rails suites, Linux checks, or RSS acceptance. The PR's published test_ripper/test_parser_events REPORT_MISMATCH observations remain failures/incomplete acceptance, not passes. The published framework record retains every previous passing identity and the one dependency-tracker improvement, but that is supplied evidence rather than an independent Rails rerun.

No merge attempted. Hosted core CI still has executing jobs and queued coverage, so the queue-only exception does not apply. Current main CI run 46362164472 failed its complete Module gate: 195 tests / 1234 assertions, 0 failures and 2 timeout errors (test_iclass_memory_leak, test_complemented_method_entry_memory_leak), with no outer limit event. All 25 jobs of that run were inspected. The recorded global merge holds remain active; this review does not establish a repair or waive those failures. Already-reviewed #410 also has executing corpus/CRuby work, the other open PRs are drafts, and merelang/mere has no open PRs.

Event is COMMENT because the authenticated account owns this PR; the P2 finding requires a fix before merge.

Comment thread lib/ripper_ext.rb Resolved

@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.

Follow-up review of exact head 8b69a3178098ab8ec51b30e28a748c107fbb7f08 against current main f0f372e7dc00967ae881f599eae68758648a9148. The earlier P2 / Major finding in discussion #4736736761 is fixed: recovery now stops before visiting the unsupported command/do-block argument. The rejected suffix no longer dispatches render, while the parenthesized-inner control and original incomplete layout call still dispatch it. No new actionable findings.

Independent validation on macOS arm64:

  • Fresh ordinary O2 head build with pinned Mere 9dec2ff6 and mgz 661a01d8; Ruby 4.0.10 revision a704b7cd95 / Prism 1.8.2 selected through tools/ref_ruby.sh with no extra reference gems. Main's previously built O2 binary was reused after comparing all 2,888 tracked files against fetched current main, plus the pinned mgz checkout and build mode; no differences were found.
  • All 11 existing Ripper corpus fixtures match Ruby on main/head, evaluator/VM, and Hash index on/off: 88/88 controls. Updated corpus 1026 matches on all four ordinary head configurations and all four additional GC-stress-32 configurations. Its four main differences are expected for the functionality being repaired.
  • The original three-case reproduction matches Ruby on all four head engine/index combinations; the old head still reproduces the erroneous callback and main still lacks the intended recovery controls.
  • Original upstream test_sexp.rb (58 tests / 98 assertions) and test_scanner_events.rb (64 / 631), archived from the pinned Ruby commit, pass on reference/main/head and both native engines: zero failures, errors or skips. These use 120-second process timeouts and are focused correctness checks, not resource acceptance.
  • An exploratory 1,596-source Ruby-loaded-adapter suffix matrix introduces no new false render relative to current main and loses no previously matching render observation. Eight pre-existing false-render cases remain outside this recovery path. A separate 1,377-source adapter matrix loses no previously matching complete observation. This does not establish full invalid-source parity.
  • Embedded Prism/Ripper regeneration is byte-identical; freshly emitted-C GC-root accounting, duplicate/dead-definition checks, StrBuf source/emitted-C checks and diff whitespace checks pass.

I did not independently rerun the complete corpus, Rails suites, Linux validation or RSS acceptance. The supplied expanded Rails/Ripper/resource records remain supplied evidence; their test_ripper / test_parser_events REPORT_MISMATCH states are not passes.

No merge attempted. The hosted Linux build is still executing, macOS/reference jobs are queued, and downstream coverage is incomplete, so the unassigned-runner exception does not apply. All 25 jobs of latest main CI 46362164472 were inspected: build-linux failed the complete Module gate (195 tests / 1,234 assertions, zero failures, two internal timeout errors in test_iclass_memory_leak and test_complemented_method_entry_memory_leak; no outer limit event in the retained result). The recorded hold_all_merges / new_failure_review_required flags remain active. Already-reviewed #410 and #415 were also considered and retain executing/incomplete CI; the other open mere-ruby PRs are drafts, and merelang/mere has no open PRs. This review neither attributes the main failures to this change nor clears the holds.

COMMENT because the authenticated account owns this PR. The prior code finding is addressed; merge acceptance remains pending.

@284km
284km merged commit 84a6899 into main Dec 1, 2026
40 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.

Ripper drops command callbacks before an unterminated do block

1 participant