Skip to content

fix(ruby): calls without parentheses, ?/! names, and methods owned by their class (#3377) - #3637

Merged
squid-protocol merged 3 commits into
mainfrom
claude/festive-fermat-kojuy7
Sep 25, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
claude/festive-fermat-kojuy7

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner

Closes #3377.

1. Paren-less calls and ?/! names (CALLS_OUT_RUBY)

Ruby used CALLS_OUT_C_STYLE (name(), which finds only a third of Ruby's calls. Idiomatic Ruby writes obj.to_s, xs.each do and puts x, and method names end in ?/!.

The new pattern in _shared_patterns.py takes a name when it:

  • follows a receiver dot: obj.name, obj&.name, "".name, a leading-dot chain line, or Mod::name;
  • is followed by (;
  • ends in ? or ! (a local variable never does, so it is always a call);
  • opens a statement as a command with an argument: puts x, command! "brew".

It never matches a bare word: Ruby can't tell foo the variable from foo the call without a symbol table. It also excludes keywords, modifiers (value if cond), ternaries (ready ? a : b), != and =~, and name?: hash labels. ReDoS tests are included.

detector.py runs it like the C-style family (qualifier capture, and the #3360 nested-declaration check) through QUALIFIED_CALLS_OUT_PATTERNS, instead of an identity check against two patterns.

call_graph_accuracy ruby, against tree-sitter: recall 34.4% → 92.9%, precision 91.5% → 92.7%. Of the 71 remaining misses, 41 are class, require and raise, which the calls_out contract ignores.

2. Ruby methods now belong to their class

Paren-less capture exposed a false resolver edge: brew.rb's bare puts resolved unique to AbstractDownloadStrategy's private def puts.

The root cause is older: no Ruby method was ever attached to its class. The class-scope search looked for a {, found the first hash literal or block, and ended the class there.

Ruby now uses the indentation scoping Python uses, so a class ends at its own end. Crucible ruby methods, compared with tree-sitter's enclosing class:

before after
agree 38 245
no class 208 0
name differs 92 93

The "name differs" rows are naming only: ActiveStorage::Blob vs Blob, and class << self.

Golden masters

  • shell/brew/download_strategy.rb: Popularity Rank / Direct Downstream 1 → 0. The two false puts edges are gone, and so is an older false fetch edge (brew.rb's options.fetch(...) is Hash#fetch).
  • Consequent ripple in network_macro, systemic_bottlenecks and Composition Fit.
  • Nothing else moves.

Other gates

  • call_graph_accuracy baseline regenerated. It also ratchets javascript, php and typescript gains that were already on main but never recorded.
  • Tests: tests/extraction/languages/test_calls_out_ruby_3377.py has 47 tests: call and non-call shapes, splice-level qualifiers, ReDoS, and class ownership. The ownership test fails without the detector change.
  • tree_sitter_accuracy_audit --all --ci: OK (30 languages).
  • Full suite: 11,260 passed.
  • ruff and dead-key audits: no new findings. mypy: none in the touched files.
  • docs/calls_out_rule_contract.md lists Ruby as its own family.

Cross-repo

This PR moves the keyword-rosetta ruby manifest (rosetta-audit: 3 mismatches). All three are real calls the old name( pattern could not see:

  • a.rb probe_safety: value.freeze
  • b.rb probe_telemetry: Rails.logger.info(msg) (logger is a method call)
  • b.rb probe_state: items.pop

This PR carries rosetta:rebless-owed, so it merges first. The companion keyword-rosetta re-bless PR then goes against engine main, updating data/ruby/expected_signals.json per its docs/GATING.md. After it merges, the corpus's bias-history.yml regenerates the bias chart.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q

…d by their class (#3377)

calls_out used CALLS_OUT_C_STYLE (`name(`), which found a third of Ruby's
calls: idiomatic Ruby writes `obj.to_s`, `xs.each do`, `puts x`, and method
names end in `?`/`!`. The new CALLS_OUT_RUBY takes a name when it follows a
receiver dot (`obj.name`, `obj&.name`, a leading-dot chain, `Mod::name`), is
followed by `(`, ends in `?`/`!` (a local variable never does), or opens a
statement as a command with an argument (`puts x`, `command! "brew"`) -- never
a bare word, which Ruby cannot tell from a local variable without a symbol
table. Keywords, modifiers (`value if cond`), ternaries, `!=`/`=~` and
`name?:` hash labels are excluded; ReDoS-tested. detector.py runs it like the
C-style family (qualifiers, #3360 header check) via
QUALIFIED_CALLS_OUT_PATTERNS.

call_graph_accuracy ruby (vs tree-sitter): recall 34.4% -> 92.9%, precision
91.5% -> 92.7%. 41 of the 71 misses left are `class`/`require`/`raise`, which
the contract ignores. Baseline regenerated (it also ratchets javascript, php
and typescript gains already on main).

Paren-less capture exposed a resolver false edge: brew.rb's bare `puts`
resolved `unique` to AbstractDownloadStrategy's private `def puts`. Root
cause: no Ruby method was ever attached to its class. The class-scope search
looked for a `{`, found the first hash literal or block, and ended the class
there (208 of 283 crucible methods classless, 38 agreeing with tree-sitter's
enclosing class). Ruby now uses the indentation scoping Python uses -- a
class ends at its `end` -- and 245 agree, 0 classless; the rest are naming
(`ActiveStorage::Blob` vs `Blob`, `class << self`). The false `puts` edges and
an old false `fetch` edge (brew.rb's `options.fetch`) are gone.

Golden masters: shell/brew/download_strategy.rb Popularity Rank / Direct
Downstream 1 -> 0, plus the network_macro and systemic_bottlenecks ripple and
Composition Fit.

Closes #3377.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
@squid-protocol squid-protocol added the rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge label Sep 25, 2026 — with Claude
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol commented Sep 25, 2026 •

Copy link
Copy Markdown
Owner Author

full-suite-matrix (ubuntu-latest, 3.9) failure: not caused by this PR. The fix is now included, at the author's request (eb24f0e).

What failed: 2 failed and 4 collection errors in tests/cobol_mainframe/test_completeness.py and test_tool_regex_redos.py, all with:

TypeError: unsupported operand type(s) for |: 'types.GenericAlias' and 'NoneType'

Cause: gitgalaxy/tools/cobol_to_cobol/completeness_report.py:44 has def main(argv: list[str] | None = None), and the module had no from __future__ import annotations. Python 3.9 evaluates that annotation at import and fails. It came in with #3505, but the matrix only runs when a PR is labelled, so main never exercised it.

Fix: eb24f0e adds from __future__ import annotations. tests/cobol_mainframe on Python 3.9.23: 481 passed. The OS × Python matrix has been re-dispatched on the new head.


Generated by Claude Code

…nnotations

`def main(argv: list[str] | None = None)` is evaluated at import on Python
3.9, raising TypeError in tests/cobol_mainframe/test_completeness.py and
test_tool_regex_redos.py on every 3.9 matrix cell (since #3505; the matrix
only runs on labelled PRs, so main never exercised it). tests/cobol_mainframe
on Python 3.9.23: 481 passed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q
…nal-contract render

Two Windows-only failures in the Full Suite Gate matrix, present on main
since each landed (the matrix only runs on labelled PRs):

- tests/tools/cross_verify.py `_rel` stripped a `/`-joined root, but on
  Windows `str(Path("/repo"))` is `\repo` and answer paths are `\repo\B.cbl`,
  so no task-B/C/D/E answer ever matched its key (3 test_cross_verify tests).
  Both sides are now compared with `/`.
- tests/signal_contract_audit.py rendered doc links with `Path('..') / doc`,
  i.e. `..\docs\x.md` on Windows, so the committed render always read stale.
  PurePosixPath keeps the link `/` on every OS; the Linux render is unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q

Copy link
Copy Markdown
Owner Author

full-suite-matrix (windows-latest, 3.12) failure: two more pre-existing Windows-only bugs, fixed in 945397e. Neither is related to Ruby. They were exposed because this PR's label ran the OS × Python matrix, which main never runs.

  • tests/cobol_mainframe/test_cross_verify.py (3 tests). cross_verify._rel removed a /-joined root from each answer path. On Windows, str(Path("/repo")) is \repo and answer paths are \repo\B.cbl, so no answer ever matched its key. Both sides are now compared with /. Checked with PureWindowsPath: \repo\B.cbl now resolves to B.cbl.
  • tests/test_signal_contract_sheet.py::test_committed_render_matches_the_module. The render built doc links with Path('..') / doc, which is ..\docs\x.md on Windows, so the committed render always read as stale. It now uses PurePosixPath; the Linux render is byte-identical.

Locally: both test files pass (23 passed), signal_contract_audit --ci is clean, and the ruff gate shows no new findings. The matrix has been re-dispatched on 945397e.


Generated by Claude Code

@squid-protocol
squid-protocol merged commit fee76c5 into main Sep 25, 2026
43 checks passed
@squid-protocol
squid-protocol deleted the claude/festive-fermat-kojuy7 branch September 25, 2026 17:09
squid-protocol added a commit to squid-protocol/keyword-rosetta that referenced this pull request Sep 25, 2026
…alaxy#3377) (#156)

gitgalaxy#3377 gives ruby its own calls_out family (CALLS_OUT_RUBY): a
receiver-dot call needs no parentheses. a.rb probe_safety [] -> [freeze],
b.rb probe_telemetry gains `logger` (`Rails.logger.info`), probe_state gains
`pop`. `freeze` and `pop` are already in docs/calls_out_truth.json's
hand-derived periphery -- the old engine missed them; `logger` is a real
method call and not forbidden. Nothing planted moves.

verify_language.py ruby: PASS (88 assertions); check_calls_out_truth ruby,
na_check, ledger_orphan_check, ledger_issue_check: clean.

Cross-repo: companion of squid-protocol/gitgalaxy#3637 (merges first, labelled
rosetta:rebless-owed); this PR verifies against engine main after it.


Claude-Session: https://claude.ai/code/session_01YAtpBfGGyBGGovitSVaM5Q

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

rosetta:rebless-owed Intentionally moves keyword-rosetta counts; audit warns, corpus re-blesses after merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

#3332 follow-up: ruby calls_out misses paren-less calls and ?/! method names (Level-1 recall 33.7%)

2 participants