Skip to content

Map candidate spans to ra_ap_syntax nodes and extract AST feature vectors (7.3.1) - #238

Merged
leynos merged 76 commits into
mainfrom
7-3-1-map-candidate-spans-and-extract-ast-feature-vectors
Jul 23, 2026
Merged

Map candidate spans to ra_ap_syntax nodes and extract AST feature vectors (7.3.1)#238
leynos merged 76 commits into
mainfrom
7-3-1-map-candidate-spans-and-extract-ast-feature-vectors

Conversation

@lodyai

@lodyai lodyai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR completes roadmap item 7.3.1 — "Map candidate spans to
ra_ap_syntax nodes and extract AST feature vectors"
for clone detector Pass
B, first half.

It includes the execution plan and the implementation of the pure AST building
blocks that item 7.3.2 (Type-3 scoring + SARIF Run 1) will consume:

  • a whitaker_clones_core::ast module that maps a candidate byte span to the
    smallest covering ra_ap_syntax node;
  • a parser-agnostic lowered IR (NormalisedTree / NormalisedNode);
  • deterministic AST feature extraction, including node-kind histograms,
    production bigram/trigram multisets, and canonical Merkle subtree hashes;
  • parser schema versioning so cache users can fail closed across parser bumps;
  • property, snapshot, BDD, Kani, and Verus coverage for the new AST path.

Scoring, SARIF Run 1 updates, latency metrics, and feature-vector emission
metrics remain out of scope for this PR and belong to 7.3.2.

Prerequisite: Stage 0 toolchain bump (nightly-2026-05-28)

The branch includes a Stage 0 bump from nightly-2025-09-18 (rustc 1.92) to
nightly-2026-05-28 (rustc ≥ 1.95). This unblocks the current
ra_ap_syntax snapshot without a backwards dependency bisect and updates the
suite for Dylint 6 / newer rustc APIs.

Key design decisions

  • Lowered owned IR (NormalisedTree) keeps parser imports confined to one
    adapter file, with a boundary guard test enforcing that containment.
  • Count-substrate histogram stores exact (KindId, depth) integer counts
    and applies depth weighting in pure feature-vector logic.
  • Opaque AstHash, typed AstError, and PARSER_SCHEMA_VERSION provide a
    stable, forward-compatible surface for 7.3.2.
  • Verification per ADR-003 includes a Verus accumulation lemma and bounded
    Kani covering-node harnesses.

Validation

  • make check-fmt
  • make test
  • make typecheck
  • make lint

References

@sourcery-ai sourcery-ai Bot 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.

Sorry @LodyAI[bot], you have reached your weekly rate limit of 2500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 16 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 74e828ca-8ab3-4770-a124-2ac43be41a9c

📥 Commits

Reviewing files that changed from the base of the PR and between 9cbd7c8 and 8e7c8f7.

📒 Files selected for processing (7)
  • crates/no_unwrap_or_else_panic/examples/fail_unwrap_in_hand_written_test_companion.rs
  • crates/no_unwrap_or_else_panic/examples/fail_unwrap_in_hand_written_test_companion.stderr
  • crates/no_unwrap_or_else_panic/src/lib_ui_tests.rs
  • docs/developers-guide.md
  • docs/execplans/7-3-1-map-candidate-spans-and-extract-ast-feature-vectors.md
  • src/hir/mod.rs
  • tests/workflows/test_cargo_locked_makefile.py

Walkthrough

This PR adds parser-independent AST lowering, deterministic feature extraction and hashing, verification harnesses, expanded lint test-context detection, pinned tooling, Cargo lock-mode propagation, documentation updates, and refreshed installer fixtures.

Changes

AST extraction, validation, and build integration

Layer / File(s) Summary
AST contracts, lowering, features, and hashing
crates/whitaker_clones_core/src/ast/*, crates/whitaker_clones_core/src/hashing.rs
Add validated spans, normalized trees, typed errors, bounded parser lowering, deterministic feature vectors, production multisets, and canonical hashes.
AST validation, parser-pin tests, and proof wiring
crates/whitaker_clones_core/tests/*, verus/*, scripts/run-kani.sh, scripts/run-verus.sh
Add unit, snapshot, property, boundary, behaviour, build-script, Kani, and Verus coverage.
Parser pin and build integration
Cargo.toml, crates/whitaker_clones_core/build*
Pin ra_ap_syntax, export its version for schema hashing, and validate exact pins.

Lint diagnostics and test-context recognition

Layer / File(s) Summary
Lint diagnostics and test-context recognition
crates/rustc_lint/src/lib.rs, crates/*/src/driver*, src/hir/mod.rs, crates/no_unwrap_or_else_panic/*
Re-export DiagDecorator, recognize owner and ancestor test functions, support anchored integration-test roots, and add aliased harness regression fixtures.

Documentation and fixtures

Layer / File(s) Summary
Design and developer documentation
docs/*
Document AST boundaries, proof workflows, parser maintenance, roadmap completion, clone-detector contracts, and toolchain guidance.
Installer manifest fixture refresh
installer/src/artefact/*, installer/tests/*
Update manifest examples and test fixtures to the 2026-05-28T00:00:00Z timestamp.

CI and repository tooling

Layer / File(s) Summary
Pinned CI and Cargo invocations
.github/workflows/ci.yml, tests/workflows/*, Makefile
Pin checkout and uv versions, verify workflow contracts, and thread the overridable CARGO_LOCKED option through Cargo commands.

Possibly related issues

Possibly related PRs

Suggested reviewers: codescene-access, codescene-delta-analysis

Poem

Trees take shape where parsers meet,
Hashes hum in hex complete.
Proofs march on, locks hold tight,
Lints find test paths in the light,
CI pins each moving part.

🚥 Pre-merge checks | ✅ 17 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Developer Documentation ⚠️ Warning ExecPlan is stale: it says no users-guide change is needed, yet docs/users-guide.md now has the new AST feature extraction section. Revise the ExecPlan Decision Log/retrospective to match the shipped docs and note the users-guide update, or remove the stale claim.
Observability ⚠️ Warning lower_span has tracing and decision-point logs, but the new AST path explicitly defers latency/feature-vector metrics to 7.3.2, leaving no runtime performance observability. Add bounded-cardinality metrics for lower_span outcomes and latency (success, parse-recovery warning, budget rejection, unparsable span), and keep the existing span fields in traces.
Performance And Resource Use ❓ Inconclusive placeholder Need code evidence before deciding.
✅ Passed checks (17 passed)
Check name Status Explanation
Title check ✅ Passed The title matches the main PR scope and includes the roadmap item reference 7.3.1.
Description check ✅ Passed The description stays on-topic and describes the same AST feature-extraction work.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Testing (Overall) ✅ Passed PASS: the new AST, build, workflow, and no_unwrap behaviours are covered by direct unit, integration, property, BDD, and contract tests that fail on plausible regressions.
User-Facing Documentation ✅ Passed PASS: Document the clone-detector AST substrate in docs/users-guide.md, including lower_span, feature vectors, schema-versioned hashes, and parser fallback.
Module-Level Documentation ✅ Passed PASS: Every touched Rust and Python module begins with a module docstring, and the AST root also documents its adapter/domain boundary.
Testing (Unit And Behavioural) ✅ Passed PASS: unit tests cover edge cases and invariants, and behavioural tests exercise real boundaries via BDD lowering, temp Cargo workspaces, Makefile invocations, and workflow config.
Testing (Property / Proof) ✅ Passed PASS: ast/tests.rs adds proptest/order-invariance coverage, ast/kani.rs adds bounded proofs, and verus/clone_detector_ast_features.rs proves accumulator invariants by induction.
Testing (Compile-Time / Ui) ✅ Passed PASS: build.rs is exercised by isolated Cargo-workspace tests that assert exact-pin accept/reject behaviour, and AST output uses focused JSON snapshots.
Unit Architecture ✅ Passed Pure AST helpers stay side-effect free, fallibility is explicit via AstResult/AstError, and build-time fs/env access is confined to build_support/build.rs.
Domain Architecture ✅ Passed PASS: ra_ap_syntax stays confined to ast/lowering.rs; domain modules are parser-agnostic and show no std::fs/env/path access under src/ast.
Security And Privacy ✅ Passed Approve: keep the change set limited to synthetic AST/tests/docs; logging skips file_text and error variants stay numeric-only, with no secrets found.
Concurrency And State ✅ Passed PASS: The only mutability is a private Cell inside LoweringLimits, owned per lower_span call; no locks, async tasks, globals, or shared caches were added.
Architectural Complexity And Maintainability ✅ Passed The new abstractions are domain-specific, immediately consumed by tests/docs, and the only shared helper is build-time-only for build.rs/tests.
Rust Compiler Lint Integrity ✅ Passed No new allow/expect suppressions appear in the touched Rust files, and the clone() calls are cheap SyntaxNode handle copies or test-owned snapshots.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 7-3-1-map-candidate-spans-and-extract-ast-feature-vectors

Comment @coderabbitai help to get the list of available commands.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

@leynos leynos changed the title Add ExecPlan: map candidate spans to ra_ap_syntax nodes and extract AST feature vectors (7.3.1) Map candidate spans to ra_ap_syntax nodes and extract AST feature vectors (7.3.1) Jun 17, 2026
@leynos

leynos commented Jun 17, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/whitaker_clones_core/tests/ast_feature_extraction_behaviour.rs

Comment on file

//! Behaviour-driven coverage for AST feature extraction.

❌ New issue: String Heavy Function Arguments
In this module, 40.0% of all arguments to its 16 functions are strings. The threshold for string arguments is 39.0%

@leynos

leynos commented Jun 17, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/whitaker_clones_core/src/ast/kani.rs

Comment on lines +37 to +56

fn bounded_tree(
    root_kind: KindId,
    left_branch_kind: KindId,
    right_branch_kind: KindId,
    left_leaf_kind: KindId,
    right_leaf_kind: KindId,
    left_first: bool,
) -> NormalisedTree {
    let left_leaf = leaf(left_leaf_kind, LeafClass::Ident);
    let right_leaf = leaf(right_leaf_kind, LeafClass::Literal);
    let left_branch = branch(left_branch_kind, vec![left_leaf]);
    let right_branch = branch(right_branch_kind, vec![right_leaf]);
    let children = if left_first {
        vec![left_branch, right_branch]
    } else {
        vec![right_branch, left_branch]
    };

    NormalisedTree::new(branch(root_kind, children), ast_span())
}

❌ New issue: Excess Number of Function Arguments
bounded_tree has 6 arguments, max arguments = 4

@leynos

leynos commented Jun 17, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Please suggest a fix for this issue and supply a prompt for an AI coding agent to enable it to apply the fix. Include the file and symbol names indicated in the issue at the head of your response.

crates/no_expect_outside_tests/src/driver/mod.rs

Comment on lines +181 to +187

    let owner_hir_id: hir::HirId = expr.hir_id.owner.into();
    if has_test_like_hir_attributes(cx.tcx.hir_attrs(owner_hir_id), additional_test_attributes)
        || is_harness_marked_test_function(owner_hir_id, harness_marked_test_functions)
    {
        return true;
    }

❌ New issue: Complex Method
is_likely_test_function has a cyclomatic complexity of 9, threshold = 9

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@coderabbitai

This comment was marked as resolved.

@pandalump
pandalump marked this pull request as ready for review June 23, 2026 19:54
@coderabbitai coderabbitai Bot added the Roadmap label Jun 23, 2026
@leynos

leynos commented Jul 5, 2026

Copy link
Copy Markdown
Owner

@coderabbitai Have the following failed checks now been resolved?

If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures.

Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. (Treat documentation and validation coverage as in scope).

❌ Failed checks (2 errors, 4 warnings)

Check name Status Explanation Resolution
Testing (Overall) ❌ Error BDD scenario implementations are vacuous stubs that contain no test logic. Three scenarios parse fixtures but execute empty bodies (let _ = world;), relying entirely on step functions. Step functio... Add test bodies to BDD scenarios: invoke step functions (given_source, when_candidate_span_is_lowered, then_lowered_root_kind_is) to exercise the actual feature-file assertions rather than ignoring the world fixture.
Unit Architecture ❌ Error Changes introduce query-side logging (lower_span emits warnings), redundant parameter validation (ByteSpan already validated but re-validated), and hard-coded parser dependencies without injected... Extract logging to command boundary; accept pre-validated ByteSpan parameter directly; inject parser abstraction or document hard-coded dependency rationale.
Developer Documentation ⚠️ Warning Roadmap item 7.3.1 is marked completed with [x], but the PR description explicitly states it remains a DRAFT awaiting approval and "no implementation is included". This creates a contradiction: eit... Correct the contradiction: either untick the roadmap item [7.3.1] if the work is incomplete and awaiting approval, or update the PR description to accurately reflect that the complete implementation has been delivered and is ready for re...
Testing (Unit And Behavioural) ⚠️ Warning BDD scenario functions in ast_feature_extraction_behaviour.rs are empty stubs (let _ = world;) that never invoke step functions, violating the requirement that behavioural tests exercise the functi... Implement scenario function bodies to execute the step functions: invoke given_* steps to set up test data, when_* steps to trigger the action, and then_* steps to assert expected outcomes, ensuring each scenario actually tests the speci...
Observability ⚠️ Warning The AST feature extraction pipeline (lower_span, feature extraction, hashing) introduces operational behaviour but provides insufficient observability. Only one warn! logged when parser recovery er... Add #[instrument] to lower_span and key feature extraction functions; log errors (not just parser recovery); add debug span selection logs; emit metrics for parse errors and feature vector latency once integrated by 7.3.2.
Performance And Resource Use ⚠️ Warning The select_covering_node function (lowering.rs:62) collects all descendants of the parse tree into a Vec without documented bounds, creating a quadratic scenario if the candidate span selects a l... Document the upstream min_nodes constraint in code comments, add an optional runtime bounds check or assertion in select_covering_node, and add a test case with a large candidate span to verify acceptable performance under realistic...

@leynos

leynos commented Jul 5, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 5, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

@coderabbitai

This comment was marked as resolved.

@lodyai
lodyai Bot force-pushed the 7-3-1-map-candidate-spans-and-extract-ast-feature-vectors branch from 80d7ba8 to 841b378 Compare July 5, 2026 00:16
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as resolved.

@lodyai
lodyai Bot force-pushed the 7-3-1-map-candidate-spans-and-extract-ast-feature-vectors branch from 3df2f6b to 42d9ece Compare July 14, 2026 01:28
codescene-access[bot]

This comment was marked as outdated.

coderabbitai[bot]

This comment was marked as resolved.

coderabbitai[bot]

This comment was marked as resolved.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

leynos pushed a commit that referenced this pull request Jul 23, 2026
Resolve the remaining PR #238 testing, user-facing documentation, and
in-scope AST observability findings.

- lowering.rs: emit `tracing::error!` before every `TreeTooDeep` /
  `TreeTooLarge` return in both `validate_covering_node_budget` (covering-
  node selection) and `LoweringLimits::lower`, with distinct messages that
  name the failing phase. Each log carries the requested-span `start`/`end`
  (the `ByteSpan` is now threaded into `validate_covering_node_budget`),
  plus `depth`+`limit` for depth breaches and the observed `node_count`+
  `limit` for node breaches. The typed errors and the `lower_span`
  `#[tracing::instrument]` fields are unchanged; no metrics/timing/global
  state is introduced (deferred to the 7.3.2 consumer boundary).
- lowering_tests.rs: add a focused test asserting the selection budget
  surfaces `TreeTooDeep`/`TreeTooLarge`; the existing lowering-path budget
  tests are retained.
- users-guide.md: add a top-level "Clone Detection: AST Feature
  Extraction" section describing the Pass B substrate — `lower_span`,
  deterministic feature vectors (kind counts, `2^63 >> depth` weighting
  zero beyond depth 63, production bigrams/trigrams, opaque hex canonical
  hash), `PARSER_SCHEMA_VERSION`-versioned hashes, the default `parser`
  feature and its `AstError::ParserUnavailable` fallback, and the 7.3.2
  deferral of scoring/SARIF. The `rstest_helper_should_be_fixture` section
  is untouched.
- artefact packaging: delete the inert `when_filename_inspected` step and
  its Gherkin `When` line; the scenario now runs Given -> Then directly and
  `then_filename_matches_artefact_name` still asserts against
  `ArtefactName::filename()`.

Validated: cargo test -p whitaker_clones_core ast; cargo test -p
whitaker-installer --test behaviour_artefact_packaging; make markdownlint;
cargo clippy -p whitaker_clones_core --tests -- -D warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
codescene-access[bot]

This comment was marked as outdated.

Resolve the remaining PR #238 testing, user-facing documentation, and
in-scope AST observability findings.

- lowering.rs: emit `tracing::error!` before every `TreeTooDeep` /
  `TreeTooLarge` return in both `validate_covering_node_budget` (covering-
  node selection) and `LoweringLimits::lower`, with distinct messages that
  name the failing phase. Each log carries the requested-span `start`/`end`
  (the `ByteSpan` is now threaded into `validate_covering_node_budget`),
  plus `depth`+`limit` for depth breaches and the observed `node_count`+
  `limit` for node breaches. The typed errors and the `lower_span`
  `#[tracing::instrument]` fields are unchanged; no metrics/timing/global
  state is introduced (deferred to the 7.3.2 consumer boundary).
- lowering_tests.rs: add a focused test asserting the selection budget
  surfaces `TreeTooDeep`/`TreeTooLarge`; the existing lowering-path budget
  tests are retained.
- users-guide.md: add a top-level "Clone Detection: AST Feature
  Extraction" section describing the Pass B substrate — `lower_span`,
  deterministic feature vectors (kind counts, `2^63 >> depth` weighting
  zero beyond depth 63, production bigrams/trigrams, opaque hex canonical
  hash), `PARSER_SCHEMA_VERSION`-versioned hashes, the default `parser`
  feature and its `AstError::ParserUnavailable` fallback, and the 7.3.2
  deferral of scoring/SARIF. The `rstest_helper_should_be_fixture` section
  is untouched.
- artefact packaging: delete the inert `when_filename_inspected` step and
  its Gherkin `When` line; the scenario now runs Given -> Then directly and
  `then_filename_matches_artefact_name` still asserts against
  `ArtefactName::filename()`.

Validated: cargo test -p whitaker_clones_core ast; cargo test -p
whitaker-installer --test behaviour_artefact_packaging; make markdownlint;
cargo clippy -p whitaker_clones_core --tests -- -D warnings.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@leynos
leynos force-pushed the 7-3-1-map-candidate-spans-and-extract-ast-feature-vectors branch from 3519d7b to 9cbd7c8 Compare July 23, 2026 10:14
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@leynos

leynos commented Jul 23, 2026

Copy link
Copy Markdown
Owner

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/workflows/test_cargo_locked_makefile.py`:
- Around line 234-241: Update the private helper _has_locked_flag to use a
single-line docstring summarizing its behavior; move the tokenization rationale
to a regular comment only if it needs to be retained, while preserving the
exact-token matching logic.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0c7fa06c-3fb5-4714-afbb-07175145a519

📥 Commits

Reviewing files that changed from the base of the PR and between 3e66ec0 and 9cbd7c8.

📒 Files selected for processing (9)
  • crates/whitaker_clones_core/src/ast/features.rs
  • crates/whitaker_clones_core/src/ast/lowering.rs
  • crates/whitaker_clones_core/src/ast/lowering_tests.rs
  • crates/whitaker_clones_core/src/hashing.rs
  • docs/execplans/7-3-1-map-candidate-spans-and-extract-ast-feature-vectors.md
  • docs/users-guide.md
  • installer/tests/behaviour_artefact_packaging.rs
  • installer/tests/features/artefact_packaging.feature
  • tests/workflows/test_cargo_locked_makefile.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/rstest-bdd (auto-detected)
💤 Files with no reviewable changes (2)
  • installer/tests/features/artefact_packaging.feature
  • installer/tests/behaviour_artefact_packaging.rs

Comment thread tests/workflows/test_cargo_locked_makefile.py
@leynos

leynos commented Jul 23, 2026

Copy link
Copy Markdown
Owner

@coderabbitai resume

@coderabbitai

coderabbitai Bot commented Jul 23, 2026

Copy link
Copy Markdown
✅ Action performed

Reviews resumed.

Fix a false-positive in the shared rstest companion-module detection that
`no_unwrap_or_else_panic`, `no_expect_outside_tests`, and
`rstest_helper_should_be_fixture` all consume through
`collect_rstest_companion_test_functions`.

`module_has_inner_harness_descriptor_pairs` treated any same-named sibling
module carrying the `fn`/`const` harness-descriptor pair as an rstest
companion, exempting the same-named parent function from the lints. But
`rustc --test` synthesizes that same-name, same-span `const` descriptor for
*every* `#[test]` function, so a handwritten `mod foo { extern crate test as
t; #[test] fn bar() {} }` next to an ordinary `fn foo` has the identical HIR
shape and wrongly exempted `fn foo`.

The distinguishing rstest/rustc invariant is expansion provenance: rstest
emits the companion module through its attribute proc-macro, so the module
item comes from macro expansion, whereas a handwritten module sits at the
crate's root syntax context. `module_qualifies_as_rstest_companion_module`
now trusts the harness-pair heuristic only when
`module_item.span.from_expansion()` holds. The explicit
`RSTEST_HARNESS_DESCRIPTOR` marker remains ungated (no handwritten module
emits it), so descriptor-based regression fixtures still qualify. Genuine
`#[rstest]` recognition is unaffected: real expansions are from macro
expansion and still match.

- Replace the `pass_unwrap_in_rstest_aliased_test_crate` fixture (which
  asserted the handwritten aliased-test-crate shape was exempt) with the
  negative `fail_unwrap_in_hand_written_test_companion`, which reaches the
  harness-pair/adjacency path yet asserts the lint fires on the parent.
- Keep `fail_unwrap_in_aliased_test_crate_non_companion` (aliased import
  without a descriptor pair) as a distinct negative.
- Document the two-tier evidence rule and the expansion-provenance invariant
  in the developer guide's test-context ancestry section.

Validation (pinned nightly-2026-05-28):
- cargo nextest run -p no_unwrap_or_else_panic --features dylint-driver: 25/25
- cargo nextest run -p rstest_helper_should_be_fixture --features dylint-driver: 16/16
- no_expect_outside_tests UI: 7 pre-existing environmental E0658 failures,
  identical on the base revision (crate excluded from `make test`)
- make check-fmt, make lint, make test (1576), make markdownlint: pass

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
codescene-access[bot]

This comment was marked as outdated.

Summarize the helper in a one-line docstring matching its sibling
`_is_lock_relevant_invocation`, and keep the tokenization rationale as a
regular comment on the return. Exact-token matching logic is unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
codescene-access[bot]

This comment was marked as outdated.

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/execplans/7-3-1-map-candidate-spans-and-extract-ast-feature-vectors.md`:
- Around line 83-88: Update the bounded per-candidate cost description to
clarify that 7.3.1 avoids indiscriminate full-file lowering, while allowing a
candidate spanning the source to select SOURCE_FILE and intentionally lower the
complete file via lower_span. Preserve the existing explanation of bounded
subtree selection and AST node/depth budgets.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: f2093962-56fb-463b-9c02-0ab8708719f0

📥 Commits

Reviewing files that changed from the base of the PR and between 3e66ec0 and 9cbd7c8.

📒 Files selected for processing (9)
  • crates/whitaker_clones_core/src/ast/features.rs
  • crates/whitaker_clones_core/src/ast/lowering.rs
  • crates/whitaker_clones_core/src/ast/lowering_tests.rs
  • crates/whitaker_clones_core/src/hashing.rs
  • docs/execplans/7-3-1-map-candidate-spans-and-extract-ast-feature-vectors.md
  • docs/users-guide.md
  • installer/tests/behaviour_artefact_packaging.rs
  • installer/tests/features/artefact_packaging.feature
  • tests/workflows/test_cargo_locked_makefile.py
🔗 Linked repositories identified

CodeRabbit considers these linked repositories for cross-repo context during reviews:

  • leynos/rstest-bdd (auto-detected)
💤 Files with no reviewable changes (2)
  • installer/tests/features/artefact_packaging.feature
  • installer/tests/behaviour_artefact_packaging.rs

The "does not lower whole files" claim was inaccurate: a candidate whose
span covers the source legitimately selects `SOURCE_FILE` and lowers the
complete file through `lower_span` (see `whole_file_span_selects_source_file`).
Reword to say 7.3.1 avoids *indiscriminate* full-file lowering while allowing
that intentional case, preserving the bounded-selection and node/depth budget
explanation.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access Bot 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.

No quality gates enabled for this code.

@leynos
leynos merged commit 4e8a8ab into main Jul 23, 2026
9 checks passed
@leynos
leynos deleted the 7-3-1-map-candidate-spans-and-extract-ast-feature-vectors branch July 23, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants