Skip to content

parsers/ + config/: E-class dedup, including one byte-for-byte 55-line clone #231

Description

@nikolay-e

Second half of the shelved 2026-08-20 cleanliness batch. Same rule as #230: one
commit per item, corpus per commit, because the corpus is their only real net.

Highest confidence-per-line item in the whole audit.
parsers/config_parser.rs:54-108 fragment_json is a byte-for-byte copy of
split_at_top_level_pattern (:110-163) sitting six lines below it, differing
only in that it spells JSON_TOP_LEVEL_KEY where the generic takes pattern.
Diffed line by line: 55-58 = 111-114, 60-66 = 116-121, 68-70 = 123-125,
72-102 = 127-157 (31 lines identical), 104-107 = 159-162. It reduces to one
call. Then fragment_yaml/fragment_toml/fragment_json are three 3-line
wrappers with one call site each — inline them into the match at :37-42.
−63 on a 193-line file. Found independently by two agents.

item Δ
tree_sitter_strategy.rs:30-778 LANG_CONFIGS — 749 lines, 76 entries, 39 unique shapes (cpp's 8 node types re-typed for 10 extensions, bash x4, six languages x3). extension: &str -> extensions: &[&str]; first-occurrence order preserved so find_lang_config is unchanged −346
the 7-parameter walker: try_container_split/handle_definition_node/extract_definitions/recurse_children thread the same 7 values — 47 declaration lines + 84 argument lines. A struct Walk<'a> makes every call one line −110
LANGUAGE_CACHE (:941-1068) — 39 of its 128 lines are blank separators; de-blanking is free −78
config_parser.rs clone (above) −63
smaller: shared make_fragment, a children() iterator, decorated_definition_kind/unwrap_decorated sharing one loop, file_extension_lower defined 3x −114
config/weights.rs:182-366 LANG_WEIGHTS — 18 entries as 10-line struct literals while the same file already uses EdgeWeightConfig::new(0.50, 0.70) one-liners for 130+ entries 160 lines above −159
config/edge_weights.rs — 14x (struct + impl Default + Lazy) -> const −100

Two traps, both established by the adversarial round, both cheap to trip.

  1. config/ -> const is only safe for edge_weights.rs and weights.rs.
    Eight other config modules read env vars inside the initializer; turning
    those into consts silently removes a documented Tier-3 override, and one of
    them is cited in CHANGELOG.md:196 behind a published measurement. The "4
    dead env knobs" from the first-round audit fall in this category and should
    not be deleted.
  2. Deriving LANG_CONFIGS extensions from languages.rs:EXTENSION_TO_LANGUAGE
    is Q-class
    , not a bigger win: it newly routes .php3/.php4/.php5/.php7/.phps
    to php and .bst/.dtx to latex. NODE_TYPE_KEYWORDS (:780-900) is already
    the right shape — leave it.

Also do not touch config/category_weights.rs in this pass: its 10 all-1.0
fields look like dead identity code, but paper/v2 names that surface as its
highest-leverage open item, so deleting it removes a declared research lever
rather than dead weight.

Protocol: ANALYSIS_code_cleanliness_refactoring.md §3, §5, R2.2 rows 10-11,
29-30, and R3 for the env-in-initializer refutation.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions