Skip to content

refactor(checker): consolidate hardcoded name lists into the semantic registry - #160

Merged
sims1253 merged 4 commits into
mainfrom
cleanup/05-name-lists
Sep 2, 2026
Merged

sims1253 merged 4 commits into
mainfrom
cleanup/05-name-lists

Conversation

@sims1253

@sims1253 sims1253 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Cleanup sprint, PR 5 of 7 (stacks on #159). Addresses the in-repo half of #49/#41. Net +174 lines (+208/−34) — the one PR in this sprint that grows the tree, deliberately: the semantic_lists registry pattern mandates per-list claim docs, registry entries, and coherence tests (~15-20 lines per list × 5), and that guard rail is the point. The call-site literals it deletes were only ~15 lines. If you'd rather keep the tree shrinking and drop the registry overhead, rejecting this PR alone is coherent — the analysis it produced for #49/#41 survives in the issue comments either way.

What

Five hardcoded name lists move into the registry, each with a coherence test:

  • S3_MATH_GENERICS (27) / S3_SUMMARY_GENERICS (7) — replace the match arm in s3_group_generic; name sets verified programmatically identical (34/34, order-preserving). mean stays a documented special case: it is a plain S3 generic (mean.bar catches mean(z); Summary.bar does not), so it cannot join the Summary list.
  • GROUP_GENERICS (Ops/Math/Summary/matrixOps) — replaces the predicate duplicated in collect.rs and infer/index.rs.
  • S7_OBJECT_CONSTRUCTORS — replaces the lib.rs match; also fixes its doc, which described a deleted promise-capture helper (match.call/sys.call) instead of S7 constructors.
  • QUOTING_FORMS (~/expression/vars) — replaces the duplicated list in infer_call and is_aliasable_function.

Coherence details worth review: acosh/asinh/atanh exist in the vendored base stub only as ambient functions, so the agreement-test helper now also consults globals.ambient_functions/globals.s3_generics (no current entry's outcome changes; module doc updated to match). The R oracle for quoting forms runs live (~/expression verified; vars when ggplot2 is installed); the S7 oracle mirrors the shiny skip pattern.

What was deliberately NOT migrated (the real #49 finding)

expression_has_list_origin (3 names) and is_numeric_truthiness_idiom (5 names) are not blocked on typeshed plumbing — both are already Checker methods. They're blocked on semantics: the stubs cover 60 functions returning list and 7 returning integer-1 (the hardcoded five plus Position and nobs). Consulting stub return modes would change real behavior — if (nobs(fit)) would stop firing RY003; strsplit() results would gain list-origin marking feeding has_list_origin consumers. Each list needs a deliberate widen-or-stay decision with fixture coverage, not a mechanical swap. Full analysis posted to #49/#41.

No vendored stub data was touched. Refs #49, refs #41 (does not close either — the remainder needs r-typeshed data and/or semantic decisions).

Gates

cargo test --workspace (969 pass, 19/19 semantic-list coherence), clippy -D warnings, fmt; snapshots byte-identical. Independently reviewed: set/order fidelity, mean byte-identical, ambient-widening impact, doc accuracy all verified programmatically.

… config

Behavior-preserving deduplication, net -155 lines.

Checker inference: one find_arg behind infer_rep/infer_seq; one
conservative_element_type for the three $/[[ fallbacks; one
emit_not_callable and one infer_args_for_diagnostics for the repeated
RY070 emit/args-walk tails; a total join_all shared by the five
return-collection folds (seeds from the first element: join is
opaque-absorbing); json_rtype_scalar made pub(crate) with the
json_rtype_to_rtype_shallow wrapper deleted; json_length_to_length for
the JsonLength->Length mapping; insert_loop_carried_bindings returns ();
the always-true post-saturating_add length guard unwrapped; the seq
variant of the arg finder rebuilt on find_arg; the caller-side
debug_assert moved into build_data_frame_schema; HigherOrderCall
destructured away.

Checker top level: run_passes shared by check/check_with_scope;
CallerVisibleSignature wraps Vec<UserParam> instead of mirroring it;
insert_parameter_default delegates to insert and re-applies its marker
sets; EnvironmentProfile machinery inlined into top_level_scope;
resolves_to_base_lenient/resolves_to_base share one impl behind a
guard flag; BASE_DATABASE_PACKAGES names the standard-package list
once; equality-aware Project setters share set_if_changed; the concise
and full writers share write_concise_header and OutputFormat::is_human.

Every hand-rolled rsplit_once("::") bare-name expression now goes
through semantic_lists::bare_name, and the Arith operator arm lists use
BinOpKind::is_arithmetic.

CLI/workspace/config: watch mode shares rescan/sync_stamps; CheckResult
shares counts(); the clap default reuses ry-config's
DEFAULT_OUTPUT_FORMAT; workspace_context inlined at its two callers;
the local serialized_cache layer deleted in favor of the process-wide
stamped cache in serialized_inventory; load_base_cached's race dance
reduced to get/set/get; IndexConfig drops its redundant per-field serde
default functions.
@coderabbitai

coderabbitai Bot commented Sep 2, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Team

Run ID: 764289ea-5fe2-40c4-a716-d31e42655629

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No critical issues — one minor suggestion inline, one informational note below.

Reviewed changes

Reviewed all 8 files of the diff at 0a7fac7 — five hardcoded name lists consolidated into the semantic_lists registry, plus registry entries, claim docs, and coherence tests.

  • Registry migration of five lists: S3_MATH_GENERICS (27), S3_SUMMARY_GENERICS (7), GROUP_GENERICS, S7_OBJECT_CONSTRUCTORS, and QUOTING_FORMS move into crates/ry-checker/src/semantic_lists.rs with per-list claim docs and registry entries; call sites in collect.rs, higher_order.rs, infer/call.rs, infer/index.rs, and infer/mod.rs now read the constants via is_group_generic/is_quoting_form/direct contains.
  • Coherence-test widening: base_typeshed_names/rlang_typeshed_names also consult globals.ambient_functions and globals.s3_generics, plus two new R-oracle tests (S7 constructors, quoting forms) that genuinely fail when R rejects the probed names.
  • Doc corrections: the stale promise-capture doc on is_callable_object_constructor is rewritten to match its S7 behavior, and generic_argument_may_dispatch now documents why mean stays a special case.

Verification done in this run: all five lists checked byte- and order-identical against the removed literals; vendor base.json membership claims confirmed (24 Math members in functions plus acosh/asinh/atanh ambient-only, all 7 Summary in functions, all 4 group names in globals.s3_generics, mean absent from s3_generics); worktree-wide grep finds zero leftover inline copies; cargo test -p ry-checker --test semantic_lists 19/19 locally; cargo clippy -p ry-checker --all-targets -- -D warnings clean.

ℹ️ The registry's no-escape guarantee misses pub(crate) const lists — NSE_SYMBOL_FNS is unregistered and unaccounted

The PR's migrated and deliberately-not-migrated accounting omits NSE_SYMBOL_FNS (crates/ry-checker/src/infer/index.rs:604), a 25-member hardcoded semantic name list that drives is_nse_symbol_fn. It is neither registered nor visible to no_unregistered_hardcoded_lists, because scan_file only matches lines whose trimmed text starts with const — pub(crate) const NSE_SYMBOL_FNS: &[&str] slips through. If that prefix were fixed, the test would immediately fail until this list is registered or given a documented exclusion, so the registry's "every hardcoded list" claim currently overstates what the guard enforces. Mergeable as-is if this list is planned for a later PR in the sprint — worth one accounting line either way.

Technical details
# NSE_SYMBOL_FNS escapes the semantic-lists registry

## Affected sites
- crates/ry-checker/src/infer/index.rs:604 — `pub(crate) const NSE_SYMBOL_FNS: &[&str]` (25 members: ggplot2/rlang/tidyselect/base/data.table NSE names), consulted by `is_nse_symbol_fn`; not in `semantic_lists::registry()` and not in `known_non_semantic`.
- crates/ry-checker/tests/semantic_lists.rs:334 — `scan_file` uses `trimmed.strip_prefix("const ")`, so any `pub const` / `pub(crate) const` slice outside `semantic_lists.rs` is invisible to `no_unregistered_hardcoded_lists`. A worktree grep confirms `NSE_SYMBOL_FNS` is the only such escape today (`BASE_DATABASE_PACKAGES` is private `const` and allow-listed).

## Required outcome
- The PR body's migrated/not-migrated accounting mentions `NSE_SYMBOL_FNS` (register it, exclude it with a justification, or name the sprint PR that will), and/or the scan strips an optional `pub(crate)`/`pub` prefix so the guard matches the module doc's "every hardcoded list" claim. Note: fixing the scan alone turns the test red until the list is registered or excluded.

## Open questions for the human
- Is `NSE_SYMBOL_FNS` scheduled for PR 6/7 of this sprint? If yes, a one-line note in the PR description is sufficient for this PR.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

@sims1253

sims1253 commented Sep 2, 2026

Copy link
Copy Markdown
Owner Author

Addressed the S7 export-list finding in 6272a44: the coherence probe now checks getNamespaceExports("S7") (what S7::name call syntax actually resolves through) instead of namespace membership, matching the claim wording. Skip gates unchanged; CI's oracle job (with S7 installed) exercises the new probe.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found — the follow-up cleanly addresses the prior review's oracle feedback.

Reviewed changes

Reviewed the delta since the prior pullfrog review at 0a7fac7 — one commit tightening the S7 coherence oracle in crates/ry-checker/tests/semantic_lists.rs.

  • Tightened the S7 oracle to pin the export claim: s7_object_constructors_match_r_oracle now checks membership in getNamespaceExports("S7") instead of namespace-level exists(..., where = asNamespace("S7")), so the assertion matches the claim doc ("exported by the S7 package") and the S7::<name> call syntax the production matcher actually keys on. The prior suggestion was applied verbatim, plus a comment explaining the export-list rationale.

Verification done in this run: full-diff TOC coverage across all 8 files; cargo test -p ry-checker --test semantic_lists 19/19 pass locally including the updated S7 oracle; the prior inline thread is resolved as addressed.

Pullfrog  | View workflow run | Using openai-compatible/glm-5.3 | 𝕏

@sims1253
sims1253 changed the base branch from cleanup/04-dedupe to main September 2, 2026 10:07
@sims1253
sims1253 merged commit 942d7ae into main Sep 2, 2026
16 checks passed
@sims1253
sims1253 deleted the cleanup/05-name-lists branch September 2, 2026 10:19
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