Skip to content

fix(classify): count a boundary literal as infection only when it feeds the owner - #3983

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

EffortlessSteven merged 3 commits into
mainfrom
claude/language-quality-kairya-rust-infection

Conversation

@claude

@claude claude Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Steven · project thread

Summary

Before: in a two-crate workspace, a new function fragile_fee (weight_grams > 2_000) that no test calls was reported exposed (warning, confidence 1.00), with infection yes: Detected test input literal matching changed boundary: 2000. The only 2000 in the tests is the expected value in assert_eq!(tax_bps("EU"), 2000), which is an oracle on a different function.

After: fragile_fee is weakly_exposed (confidence 0.92), with infection weak: Related tests contain the changed boundary literal [2000] only outside the changed owner's inputs (for example as an expected value); no test input at the changed boundary was detected. A test that passes the boundary value to the owner, directly or through let x = 50; owner(x), is still credited.

How: predicate infection in analysis/classify/infection.rs now reads activation::owner_input_values instead of every literal in the related tests. That set holds owner-call arguments, table rows and builder arguments, never assertion arguments. It reuses the activation authority rather than adding a parallel rule. A bare-identifier argument resolves through a new strict entry in the shared let scan, value_resolution::test_let_bound_literal. That entry refuses mut and shadowed bindings and accepts only numbers or booleans.

Found in the onboarding thread's new-user re-walk (F15-13, infection half).

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, which states the rule.
Issue: none filed. The re-walk evidence is F15-13.

Scope Classification

  • One production behavior

Single acceptance criterion:

  • A boundary-matching literal counts as infection evidence only when it is an input of the changed owner.

Non-goals:

Support-tier Impact

  • none

Policy Impact

  • none. This is an exposed-to-weakly_exposed demotion that fails closed.

Proof

At 4c0ba96:

cargo test -p ripr --lib                            # 5310 passed
cargo xtask goldens check                           # pass
cargo xtask fixtures / check-fixture-contracts      # pass
cargo clippy -p ripr --all-targets -- -D warnings   # pass
cargo xtask precommit                               # exit 0

New tests:

  • predicate_infection_ignores_boundary_literal_used_only_as_expected_value is the negative case: the literal is used only as an expected value.
  • predicate_infection_credits_the_same_literal_when_it_is_an_owner_input is its positive control.
  • predicate_infection_credits_table_row_inputs_but_not_enum_variants.
  • let_bound_owner_argument_is_an_owner_input checks that a let-bound argument is credited.
  • let_bound_owner_argument_fails_closed_on_mut_shadowed_or_computed_bindings covers mut, shadowed, computed and string bindings.
  • owner_input_values_exclude_assertion_expected_values.

New fixture infection_expected_value_literal: fragile_fee is weakly_exposed, and bulky_fee (let volume = 50;) stays exposed.

On the re-walk ws repo the summary goes from 1 exposed, 1 weak to 0 exposed, 2 weak. The pricing and pricing-lit output is unchanged.

Not established:

Claim Boundary

May claim: an expected-value literal no longer earns infection yes. Must not claim: infection evidence is data-flow precise.

Rollback

Revert the commit. The fixture and spec text revert with it.

Spec-Test-Code Traceability

  • Spec: RIPR-SPEC-0001
  • Tests: analysis/classify/infection.rs, analysis/classify/activation.rs, analysis/value_resolution.rs
  • Code: same files
  • Fixture: fixtures/infection_expected_value_literal/

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

@claude
claude Bot requested a review from EffortlessSteven September 23, 2026 11:25
@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: 6369054b-8229-4420-92ac-0fdaeb3b9258

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 one test-proof clarification before upstream.

Verification questions

  • Confirm new unit tests in activation.rs (let_bound_owner_argument_is_an_owner_input, let_bound_owner_argument_fails_closed_on_mut_shadowed_or_computed_bindings, owner_input_values_exclude_assertion_expected_values) and infection.rs are positive/negative controls that prove red/green separation. Without cargo-test receipt this is unverified in this lane.

Refuted

  • The new test_let_bound_literal returns the wrong literal when the let RHS contains multiple scalar tokens (e.g. let pair = (10, 20);) and a tuple-typed owner takes one element; refuted because: RHS through extract_let_bindings keeps the raw textual RHS; subsequent scalar_values would still extract both 10 and 20, but the call site filters down to a single-element match and owner_call_parameter_values already iterates per index. Tuples are an unsupported corner and the let_bound_owner_argument_fails_closed_on_mut_shadowed_or_computed_bindings test does not assert tuple behavior, so this is an unforced concern.

Parked follow-ups

  • Seam-path let rule in value_resolution remains permissive per PR body; only the new strict check-path entry fails closed.
  • Adjacent #3982 (named-constant cache generations) is not exercised here; author notes seam-path let rule is still permissive and the strict entry covers check-path only — sibling seam cache is not invalidated by this PR.
  • owner_argument_values filter scalar_values(value) == [value] plus strip-quotes guard is redundant for numeric/boolean inputs since strip_comments_and_strings already strips string contents and extract_let_bindings only keeps literals; the only values that survive are already scalar. Mild duplication of guard logic.
  • Strict let scan test_let_bound_literal rejects mut, multi-let (shadow), and computed RHS, but still returns raw RHS for numeric bool; string RHS filtered later in owner_argument_values.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.
  • cargo-test receipt is scheduled-late (not yet landed); this lane cannot independently verify the new unit tests pass without it.

@claude

claude Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor Author

Disposition for review 5290508943. No code change was needed. The review asked for proof that the new tests separate red from green. I ran two mutants on head 4c0ba96, each on its own:

Mutant Unit tests (classify::) Golden
M1: owner_argument_values stops resolving let-bound arguments let_bound_owner_argument_is_an_owner_input fails (363 pass, 1 fail) infection_expected_value_literal drifts to 0 exposed / 2 weak
M2: infection credits any test literal, the pre-fix behaviour predicate_infection_ignores_boundary_literal_used_only_as_expected_value and predicate_infection_credits_table_row_inputs_but_not_enum_variants fail (362 pass, 2 fail) the same fixture drifts to 2 exposed / 0 weak

Unmutated, 364/364 pass and the golden holds at 1 exposed / 1 weak. let_bound_owner_argument_fails_closed_on_mut_shadowed_or_computed_bindings and owner_input_values_exclude_assertion_expected_values still pass under both mutants. That is expected: they are negative controls against over-crediting, and neither mutant over-credits in the shapes they cover.

Parked items:


Generated by Claude Code

@EffortlessSteven
EffortlessSteven force-pushed the claude/language-quality-kairya-rust-infection branch from 4c0ba96 to aab1b47 Compare September 24, 2026 11:03
# Conflicts:
#	crates/ripr/src/analysis/classify/infection.rs
#	crates/ripr/src/analysis/value_resolution.rs
#	docs/specs/RIPR-SPEC-0001-static-exposure-loop.md
… main's base-field removal

Main's fixture harness no longer injects the synthetic base field into
check.json (compare main's own boundary_named_constant golden). The drift
was formatting_only: summary, counts and findings are unchanged (1 exposed,
1 weakly_exposed with the oracle-only infection-weak message intact).
Blessed with the RIPR-SPEC-0001 reason recorded in the fixture's golden
CHANGELOG as entry (2).
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 24, 2026 17:21
@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

  • fixtures/infection_expected_value_literal/expected/human.txt:1 — Golden only renders the weakly_exposed block and lists '1 lower-priority finding(s) omitted'. The CHANGELOG admits two pending regenerates (initial fixture + post-main-harness format fix). The second regenerate's blessed human.txt must include the exposed bulky_fee block in some form (or explicitly pin the hidden count to 1) so a future fixture harness regression that drops the second finding is caught.

Verification questions

  • Confirm strict entry test_let_bound_literal refuses 'mut' and shadows, but its extract_let_bindings(body).remove(ident) runs on raw body while the existence check runs on strip_comments_and_strings(body). A let inside a commented-out block survives the check; the remove then returns None regardless because the live bindings map is empty. Net is correct (None), but the asymmetry between the two passes is a small smell.

Refuted

  • owner_argument_values might let a string RHS leak a numeric owner input (let amount = "10"; score(amount)); refuted because: filter strips leading '"' and \''; scalar_values on the trimmed RHS does not return a number. Negative control test asserts owner_input_values is empty for that body.
  • Tuple-typed owner argument (let pair = (10,20); owner(pair)) would over-credit both literals; refuted because: owner_argument_values can yield [10,20] but owner_call_parameter_values takes .next() per index and per-parameter filtering keeps a single slot; tuple is not asserted in the strict test but the seam scan's permissive shape is not the check path.

Parked follow-ups

  • test_let_bound_literal strict entry fails closed on mut/shadow/computed/string but does NOT assert tuple behavior; reviewer thread already refuted the multi-scalar-RHS concern as unforced, but no test pins it.
  • Seam-path let scan in value_resolution remains permissive per PR body; cache generations not bumped, conflicts with #3984 parked, named-constant follow-up #3984 owns seam bump.
  • Seam-path let rule in value_resolution remains permissive; this PR only adds a strict check-path entry. Author explicitly parks it; warm-cache could still mask a future classification change in named-constant seam usage.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven
EffortlessSteven merged commit f114542 into main Sep 24, 2026
24 of 25 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/language-quality-kairya-rust-infection branch September 24, 2026 18:04
@EffortlessSteven

Copy link
Copy Markdown
Member

Review — head aab1b47 (rebased onto current main)

Surfaces. crates/ripr/src/analysis/classify/* infection counting, RIPR-SPEC-0001 spec doc, traceability.

What this PR does. Counts a boundary literal as infection only when it feeds the changed owner — a same-file literal used by an unrelated path no longer inflates infection evidence for the owner under change.

Stimulus/oracle. Classifier tests pin both directions: literal feeding the owner counts; literal on a sibling path does not. Keeps evidence-promotion honesty (no credit without the feed edge).

Validation. Ripr Rust Small Result: SUCCESS on aab1b47. Clean squash-rebase.

Disposition: REVIEW_READY.

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