Skip to content

fix(rust): an uncalled owner cannot be exposed through same-file tests - #3947

Merged
EffortlessSteven merged 4 commits into
mainfrom
claude/language-quality-kairya-rust-proximity
Sep 24, 2026
Merged

EffortlessSteven merged 4 commits into
mainfrom
claude/language-quality-kairya-rust-proximity

Conversation

@claude

@claude claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Requested by Steven · project thread

Summary

Before: a Rust function that nothing calls, changed from (cents + 50) / 100 to (cents + 49) / 100, was reported exposed with confidence 1.00 and "Related tests appear to reach untested_rounding: discount_applies_at_100, …". Those tests call a different function in the same file. This is the most trust-damaging result from the language walkthrough, because exposed tells a reviewer they need not look.

After: the same change is weakly_exposed (0.66), and the reach line says "No test is seen calling untested_rounding; tests share only its file or a name token: discount_applies_at_100, discount_small_unchanged". Those tests remain listed as the likely place to add one.

How: reach_evidence returned yes for any relation, including same_test_file and weak_token_substring, and classify could return Exposed without checking reach. Reach is now weak/low confidence when every owner-anchored relation is proximity-only (same_test_file, same_module, weak_token_substring), and Exposed also requires reach yes.

Swarm / Source Boundary

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge, dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Spec: RIPR-SPEC-0001 (rule added under Classifications)
Issue: none filed; found in the language-quality walkthrough for 0.11

Scope Classification

  • One production behavior

Single acceptance criterion:

  • A changed owner that is linked to tests only by file, module or name-token proximity is never exposed.

Non-goals (separate findings from the same walkthrough):

  • Numeric literals such as 100 count as matching probe tokens in reveal (extract/text.rs:22), so they can still credit a discriminator for a test that really does call the owner.
  • "Related test" ordering is by name, not relation strength (related_tests.rs:463).
  • The repo-scoped grip path (test_grip_evidence.rs) has its own reach and is unchanged here.

Decisions (overrule on review)

  • weak, not no. Considered making proximity-only reach no (no_static_path). That drops the test file as the suggested place to add a test, and Python and TypeScript already treat heuristic-only links as weak (weakly_exposed). So weak keeps the three languages on one rule: proximity is weak, and it is never exposed.
  • owner_named_test stays anchored. A test whose name contains the owner's name but whose call was not captured (for example, called through a macro) is more likely to reach the owner than a file neighbour. Demoting it too would move many more results with less evidence that they are wrong.
  • The macro case moves. given_three_character_probe_token_in_test_name_when_owner_is_not_called_then_test_is_related pinned reach yes for a test matched only by the token vat in its name. It now pins weak and not-exposed. The test stays related.

Support-tier Impact

  • none

Policy Impact

  • none

Proof

cargo test -p ripr --lib                   # 5298 passed after the one test update above
cargo test -p ripr --test cli_smoke        # 207 passed
cargo xtask goldens check                  # pass
cargo xtask check-fixture-contracts        # pass
cargo xtask precommit                      # pass
cargo clippy -p ripr --all-targets -- -D warnings   # pass
  • The new unit tests fail on main by construction, because main's reach_evidence always returns yes for a non-empty relation list:
    • given_only_proximity_relations_when_building_reach_evidence_then_reach_is_weak
    • classify_does_not_emit_exposed_when_reach_is_weak
  • Control: given_one_calling_test_among_proximity_relations_when_building_reach_evidence_then_reach_is_yes.
  • New fixture rust_uncalled_owner_same_file_tests: main's binary reports exposed 1.0/reach yes; this branch reports weakly_exposed 0.66/reach weak.
  • Reblessed, where the only relation is weak_token_substring: assertion_shaped_control_production_caller and rust_constructor_field_observation. Class is unchanged in both (propagation_unknown), reach goes from yes to weak, and one confidence moves from 0.66 to 0.63.
  • Walkthrough repo pricing: only the uncalled owner's finding changed. The other nine findings are identical.

Not run: cargo xtask dogfood, other integration test binaries, Windows. CI covers them.

Claim Boundary

May claim: diff-scoped Rust findings no longer report exposed from proximity-only relations. Must not claim: repo-scoped seam grip uses the same rule.

Rollback

Revert the commit; the goldens and the fixture revert with it.

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code or tests.

🤖 Generated with Claude Code

https://claude.ai/code/session_018QP9k41E538Xgytw8QCSfM


Generated by Claude Code

A Rust function that no test calls was reported `exposed` with confidence
1.00 when the file's inline test module held strong tests for a different
function: every test in the same file counted as related, reach was `yes`
for any relation, and the classifier's `exposed` branch never checked reach.

- Reach is `weak` (low confidence) when every owner-anchored relation is
  file or name proximity only (same_test_file, same_module,
  weak_token_substring). Those tests stay listed as the likely place to add
  a test.
- `exposed` now also requires reach `yes`.

New fixture rust_uncalled_owner_same_file_tests (main: exposed 1.00, now
weakly_exposed 0.66 with a reach summary saying no test calls the owner).
Two goldens reblessed where the only relation is weak_token_substring:
reach yes->weak, class unchanged. RIPR-SPEC-0001 states the rule.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018QP9k41E538Xgytw8QCSfM
@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: bf7fb1be-4d2c-4b86-ac9d-617312700d9e

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.

@github-actions github-actions 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.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • cargo-test receipt listed as receipt-absent in UB packet (always-on base); non-blocking because unit/control tests are demonstrated via diff construction and the claim is provable from changed source + goldens + --doc-hidden review posture. Pending late phase will produce a real receipt before gate.

Refuted

  • No resizable-buffer/ArrayBuffer/TypedArray/detach/transfer/stale-length concerns in this Rust analyzer diff; the ub-active-view surface is absent.
  • New unit tests would not be red on main because reach_evidence currently returns Yes regardless — so adding the assertion is not actually red; refuted because: reach_evidence returns Yes only after the proximity_only branch is added; on main all non-SeamCalleeCall relations still map to Yes, making given_only_proximity_relations assert Weak fail on main. Decision-level test also fails on main because classify required only discriminate&infect&propagate. Both are genuinely red-on-main.
  • Other RIPR stages (infect, observe, discriminate, propagate) can independently produce Exposed from same_test_file proximity alone, requiring a parallel gate in decision.rs; refuted because: Decision.rs's new conjunction gates Exposed on all four stages being Yes. Inspecting reach.rs and the changed fixtures, infect/observe/discriminate/propagate only flip to Yes when the related test body contains observable evidence (assertion argument values, exact-value oracles, propagation witnesses). same_test_file alone does not produce that evidence; the fixture's neighbour tests provide strong assertions that legitimately satisfy those stages. The reach gate is sufficient.
  • A name-token matched test (WeakTokenSubstring) could be attacker-influenced (e.g., test name contains owner substring) and let proximity reach evade detection, enabling false-negative Exposed classifications in downstream tooling that consumes reach.state; refuted because: WeakTokenSubstring derives from static tokenization of source identifiers authored in the same repo; the threat model for ripr output is trusted-repo advisory, not adversarial input. Reach is gated by owner_anchored non-empty, and the control test pins reach=Yes when DirectOwnerCall co-occurs with proximity relations. No untrusted taint path into the reach summary.

Parked follow-ups

  • Sibling reach helper test_grip_evidence.rs is referenced in PR body as unchanged and out-of-scope; PR explicitly limits claim to diff-scoped Rust findings, not repo-scoped seam grip.
  • Residual risk: the spec says 'helper chain' but reach.rs proximity-only only treats SameTestFile/SameModule/WeakTokenSubstring as proximity; if a future helper-chain RelationReason is added and inadvertently included in is_proximity_only, an indirect call could be downgraded to Weak and hide real reach. Not exploitable today, watch on additions.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

…_file_tests patch

The Rust gates run git diff --check on the PR range, and the single-space
blank context lines in diff.patch read as trailing whitespace. The hunk now
carries only the three non-blank lines around the change; the golden moves
only by input_identity.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018QP9k41E538Xgytw8QCSfM
# Conflicts:
#	fixtures/assertion_shaped_control_production_caller/expected/CHANGELOG.md
#	fixtures/rust_constructor_field_observation/expected/CHANGELOG.md
…anded None-default base envelope

RIPR-SPEC-0084 (landed on main since the branch was cut) changed the
--diff fixture envelope: the top-level base field is omitted and
base_revision records null. The new fixture authored on this branch
predates that contract. Findings, reach, classes and confidences are
unchanged; drift was formatting-only (110 lines, semantic findings
byte-identical).

Merge resolution note: kept main's landed RIPR-SPEC-0084 rebless
entries and renumbered this branch's RIPR-SPEC-0001 entries per fixture
to keep pending headings unique (MD024).
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 24, 2026 10:44
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@github-actions github-actions 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.

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • The PR is a Rust static-analysis behavior change (reach/classify gating + goldens). It does not touch resizable buffers, active views, ArrayBuffer/TypedArray resize/detach/transfer, or any JS/JS-style stale-length surface. Lane is out of scope.

Refuted

  • A separate gate in classify() duplicates the proximity check that is now centralized in reach_evidence.; refuted because: reach_evidence returns StageState::Weak when proximity_only holds, and classify() only gates on that scalar; there is no second proximity pass and no RelationReason branching in classify(). The previous reach-Yes behavior was a single missing guard, not duplicated logic.
  • The new Weak branch could be reached with owner_anchored empty and silently downgrade a real reach=Yes path to Weak.; refuted because: Branch is gated by !owner_anchored.is_empty(); the existing owner_anchored-empty summary path still runs and returns Yes as before. No code path was removed or weakened.

Parked follow-ups

  • reach.rs::reach_evidence is the single builder for owner reach; a non-empty SeamCalleeCall relation defers to the existing Yes branch even when only weak tokens are present, so the token vat case stays Weak.
  • Park rather than broaden: same_test_file/same_module proximity should remain Weak (not No), matching Python/TypeScript heuristic rule per PR decisions.
  • The two parked candidates (candidate-0004-99a52d8e3ef9 and candidate-0007-3c6f31b6f8bd) belong outside the current PR scope.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven
EffortlessSteven merged commit cf1e4ff into main Sep 24, 2026
24 of 25 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/language-quality-kairya-rust-proximity branch September 24, 2026 12:34
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