Skip to content

refactor: collapse duplicated helpers across checker, cli, workspace, config - #159

Merged
sims1253 merged 2 commits into
mainfrom
cleanup/04-dedupe
Sep 2, 2026
Merged

sims1253 merged 2 commits into
mainfrom
cleanup/04-dedupe

Conversation

@sims1253

@sims1253 sims1253 commented Sep 2, 2026

Copy link
Copy Markdown
Owner

Cleanup sprint, PR 4 of 7 (stacks on #157). Net −105 lines (24 files, +454/−559). ~34 dedupes, each independently verified behavior-preserving — zero snapshot changes across the corpus, oracle, and vendor suites (the strongest local signal for a no-behavior claim in this repo).

The dedupes (highlights)

  • find_arg (named-arg-wins-else-positional) replaces twin closures in infer_rep/infer_seq; conservative_element_type replaces a 3× fallback; emit_not_callable replaces a 3× RY070 emit; infer_args_for_diagnostics folds the 7 byte-identical arg-infer loops (the ~12 genuinely-different loops were left alone).
  • join_all replaces 5 seed-from-first folds — the naive fold(unknown(), join) would have been wrong (RType::join is opaque-absorbing); caught during implementation.
  • check/check_with_scope share a run_passes prologue; CallerVisibleParameter (a field-for-field mirror of UserParam, both pub(crate)) is deleted; resolves_to_base_lenient = resolves_to_base_impl(..., false); BinOpKind::is_arithmetic / OutputFormat::is_human / semantic_lists::bare_name replace 2/4/9 inline copies respectively.
  • CLI watch mode: 3× mtime-stamping and 2× discovery loops → rescan/sync_stamps; error/warning counting computed once; DEFAULT_CHECK_OUTPUT_FORMAT reuses ry_config's constant; IndexConfig's triple-stated defaults reduced to the Default impl.

Deliberately NOT done (verification said no)

  • dataset_cache in ry-workspace was kept: the claim "the global cache makes it redundant" is false — it aggregates whole data/ directories, which the per-file global cache cannot key. Deleting it would be a real perf regression.
  • The Narrowing::None => {} arm is unreachable but removing it would need a _ arm — no net win.
  • The SERIALIZED_BINDINGS_UNENUMERABLE defensive branch stays: the marker IS still produced (unstubbed attached packages), pinned by a test.

Caught in review, fixed before push

The first version delegated insert_parameter_default to Scope::insert, which additionally clears lexical_functions/list_origin_bindings markers — a real behavior delta reachable via build_function_signature's captured-scope walk. Fixed by preserving both markers (mirroring insert_narrowed's style), with a Scope-level regression test proven to fail against the broken version. The other 14 equivalence claims were independently verified.

Gates

cargo test --workspace (967 pass), clippy -D warnings, fmt — green; snapshots byte-identical.

… 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: 2a091f7e-6f6a-40ad-851c-13d45c7d34d0

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 new issues found.

Reviewed changes — every dedupe in this PR hand-verified as behavior-preserving against the code it replaced; the local gates agree.

  • bare_name / join_all / find_arg / conservative_element_type — each extracted helper is byte-equivalent to every inline copy it replaces; the remaining rsplit_once("::") sites all consume the package side too, so the dedupe boundary is drawn correctly.
  • emit_not_callable + infer_args_for_diagnostics — 3× RY070 emit and 7 byte-identical arg-infer loops collapsed; the distinct "cannot call a value of mode" RY070 is correctly left inline.
  • Scope::insert_parameter_default — the trickiest seam. Delegating to insert alone would clear lexical_functions/list_origin_bindings markers the old code preserved; the save/restore wrapper restores exactly the old marker semantics, and the new parameter_default_preserves_lexical_and_list_origin_markers test is a genuine pin (it fails against the un-restored delegation).
  • run_passes prologue — parse-error emission moved after collect+fixpoint in check_with_scope; both passes run in discarding mode so they emit nothing, leaving RY000 ordering unchanged.
  • serialized_cache removal (ry-workspace) — sound: serialized_inventory carries its own global mtime-stamped cache, so the per-resolution map was redundant (and dataset_cache, which aggregates whole data/ dirs, is rightly kept).
  • seed_caller_visible_signature — *current = previous.clone() additionally copies name, but the pre-existing guard bails on any name mismatch, so a stale param name can never be installed.
  • CLI watch/config — rescan(…, report=false) preserves the old silent poll behavior; IndexConfig's container-level #[serde(default)] + Default impl (same constants) cover the removed per-field serde defaults; config::DEFAULT_OUTPUT_FORMAT is "full", identical to the deleted CLI constant.
  • Gates — cargo test --workspace: 967 passed / 0 failed across 43 targets; cargo clippy --workspace --all-targets -- -D warnings: clean.

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

@sims1253
sims1253 changed the base branch from cleanup/01-dead-code to main September 2, 2026 09:16
@sims1253
sims1253 merged commit 6337a39 into main Sep 2, 2026
16 checks passed
@sims1253
sims1253 deleted the cleanup/04-dedupe 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