Skip to content

test(architecture): ratchet feature-code reaches past the resolution catalogue - #333

Merged
Hessesian merged 2 commits into
mainfrom
chore/architecture-ratchet
Oct 20, 2026
Merged

Hessesian merged 2 commits into
mainfrom
chore/architecture-ratchet

Conversation

@Hessesian

Copy link
Copy Markdown
Owner

Why

Review of #329 showed an agent reusing every primitive named in AGENTS.md and reinventing most of the ones that are not: about 340 lines of line-text parsing next to an existing CST walker, direct indexer.definitions reads, and copies of named_arg_label and param_names_from_sig. The catalogue exists, but nothing an agent reads by default names it, and nothing fails when feature code reaches around it.

What

  • tests/architecture_ratchet.rs scans src/features, src/semantic_tokens and src/inlay_hints.rs (production files, non-comment lines) for literal reaches into resolver::infer* and the raw index maps, and compares each count with a baseline taken from main today. Any drift fails: more means a new bypass, fewer means the baseline must be lowered in the same change. The failure message lists every site.
  • AGENTS.md: Key Files entries for CstQuery, NodeExt and StrExt, phrased as the question each answers, plus one Code Quality rule stating what the test enforces.
  • docs/agent-reference.md §12: a private helper needed by a second feature moves next to its input type; an almost-right primitive gets its return type widened rather than a sibling.

Baselines

Pattern Count
resolver::infer:: 7
resolver::infer_lines:: 0
infer_variable_type 2
infer_type_in_lines 0
.definitions. / .jar_definitions. 0 / 0
.files. / .jar_files. 2 / 2
.live_lines 2
.extension_by_receiver 1

Limits

The scan is literal text. A reach spelled through a re-export (use crate::resolver::{infer_variable_type_raw} is caught by name, other re-exports are not) or split across lines escapes it. The durable fix is to make resolver::infer private once its count reaches zero; the file header says so.

Verification

  • cargo test: 2103 passed, 0 failed.
  • cargo clippy --all-targets -- -D warnings: clean.
  • Confirmed the test fails: appending an indexer.definitions.get(..) call to a feature file reports .definitions.: baseline 0, found 1 with the file and line.

No behaviour change. #329 as currently written will fail this test once it is rebased.

🤖 Generated with Claude Code

…catalogue

Feature code keeps growing private resolvers because the catalogue
(`CstQuery`, `NodeExt`, `StrExt`) is not named anywhere an agent reads
by default, and nothing stops a reach into `resolver::infer` or the raw
index maps.

- tests/architecture_ratchet.rs counts those reaches in src/features,
  src/semantic_tokens and src/inlay_hints.rs against today's baselines
  and fails on any drift, so a count can only go down.
- AGENTS.md names `CstQuery`, `NodeExt` and `StrExt` by the question
  each answers, and states the rule the test enforces.
- docs/agent-reference.md §12 gains the relocation rule and
  "extend, don't fork".

No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Aggregate counts allow replacement bypasses, and missing scan roots can silently reduce coverage.

2 open findings
What changed in this PR

Adds an architecture ratchet preventing feature code from bypassing resolution APIs.

Changes:

  • Scans feature sources for raw resolver/index access.
  • Documents preferred resolution primitives and extension practices.
File Description
tests/​architecture_ratchet.rs Adds bypass-count enforcement.
AGENTS.md Adds architectural guidance.
docs/​agent-reference.md Documents reuse and extension patterns.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/architecture_ratchet.rs Resolved
Comment thread tests/architecture_ratchet.rs Resolved
…ears

Review feedback on #333:
- A total per pattern let one removed bypass pay for a new one elsewhere.
  Baselines are now per file, so a reach in a new file fails even when
  another file dropped one. A swap inside a single file still passes;
  the header says so.
- A renamed or deleted feature root was skipped silently. Each root in
  FEATURE_ROOTS must now exist.
- Paths are reported relative to the crate root with '/' separators, so
  the baselines hold on Windows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hessesian
Hessesian merged commit 697340d into main Oct 20, 2026
4 checks passed
@Hessesian
Hessesian deleted the chore/architecture-ratchet branch October 20, 2026 08:00
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.

2 participants