Repository navigation
fix(analysis): credit direct field constant boundaries - #1511
Conversation
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
WalkthroughRust equality-boundary analysis now credits eligible direct field assignments from same-file constants and bounded offsets, rejects unsafe or ambiguous cases, and reports ChangesField Assignment Evidence
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant TestModule
participant ValueEnv
participant EvidenceAnalysis
participant EvidenceRecord
TestModule->>ValueEnv: provide direct field assignment
ValueEnv->>EvidenceAnalysis: return observed value or unresolved status
EvidenceAnalysis->>EvidenceRecord: emit evidence limitation category
EvidenceRecord->>EvidenceRecord: map category to repair route
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
crates/ripr/src/analysis/test_grip_evidence.rs (1)
407-517: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider extracting the shared call/argument iteration between
observed_value_facts_for_testandfield_assignment_value_unresolved_for_test.Both functions build the same
ValueEnv, iterateindexed.test.callsfiltered bycall.name == owner_name, resolvecall_arguments, and apply the same operand-projection logic. This duplication will grow as more field-assignment-style checks are added; a shared helper that yields(call, projected_arg)pairs for a givenowner_name/selection would reduce the surface to keep in sync.🤖 Prompt for 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. In `@crates/ripr/src/analysis/test_grip_evidence.rs` around lines 407 - 517, Extract the duplicated call/argument traversal from observed_value_facts_for_test and field_assignment_value_unresolved_for_test into a shared helper that builds projected (call, argument) pairs for the selected owner_name and ObservedArgumentSelection, including filtering calls, resolving call_arguments, and applying projections. Update both functions to use this helper while preserving their existing value-resolution and unresolved-check behavior.crates/ripr/src/analysis/value_resolution.rs (1)
262-282: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick winStale struct-literal fallback when a field assignment is invalidated (not just unresolved).
field_assignment_atreturnsNoneboth when no candidate assignment exists and when a candidate exists but is invalidated (Line 341-343). Inresolve_identifier_or_literal_at, thatNoneis indistinguishable from "never assigned", so execution falls through to thestruct_field_bindingslookup (Lines 283-298) and can resurface the original struct-literal value even though a later direct assignment was invalidated by a mutable borrow.Concretely, for:
let mut file = File { body_model_version: 0, .. }; file.body_model_version = SUPPORTED_VERSION; // credited, then invalidated below mutate(&mut file); lower(&file);
field_assignment_atreturnsNone(invalidated) at the call site, soresolve_identifier_or_literal_atfalls back to the struct literal and resolvesfile.body_model_versionto"0"— a stale value — instead of failing closed. This makesobservednon-empty, which in turn makesactivate_evidence'sfield_assignment_value_unresolvedflag false (Lines 254-259 in test_grip_evidence.rs), producing "Observed 1 concrete activation value(s)…" instead of the intended "Field assignment value is unresolved…" summary. This appears to directly contradict the new testgiven_mutable_borrow_after_field_assignment_then_stale_value_is_not_creditedintest_grip_evidence/tests.rs(Lines 10194-10239), which asserts neither outcome should occur.The fix must short-circuit whenever any candidate assignment is found for the object/field before the call — regardless of invalidation state — rather than only when a value was resolved.
🐛 Proposed fix: never fall through once a candidate assignment exists
if let Some((object, field)) = field_projection(expr) - && let Some(assignment) = self.field_assignment_at(object, field, call_position) + && let Some((local_binding, assignment)) = + self.field_assignment_candidate_at(object, field, call_position) { - return assignment - .values - .iter() - .cloned() - .map(|value| (value, ValueContext::FunctionArgument)) - .collect(); + return if self.field_assignment_is_invalidated(object, local_binding, call_position) { + Vec::new() + } else { + assignment + .values + .iter() + .cloned() + .map(|value| (value, ValueContext::FunctionArgument)) + .collect() + }; }
field_assignment_atthen becomes unused at this call site; either remove it or repurpose it consistently withfield_assignment_value_unresolved_at_call.Also applies to: 333-345
🤖 Prompt for 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. In `@crates/ripr/src/analysis/value_resolution.rs` around lines 262 - 282, Prevent stale struct-literal fallback when a field assignment was invalidated. Update resolve_identifier_or_literal_at to detect whether any prior assignment candidate exists for the object/field, and return without resolving a value whenever such a candidate exists but cannot produce a valid assignment; do not fall through to struct_field_bindings. Reuse or replace field_assignment_at consistently with field_assignment_value_unresolved_at_call, removing the now-unused helper if appropriate.
🤖 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 `@crates/ripr/src/analysis/value_resolution.rs`:
- Around line 210-231: Update field_assignment_is_invalidated call sites in
field_assignment_at and field_assignment_value_unresolved_at_call to begin the
invalidation window at the selected assignment’s source position rather than
local_binding. Use the assignment position already available on the assignment
record, preserving the existing call_position end bound and invalidation checks.
---
Outside diff comments:
In `@crates/ripr/src/analysis/test_grip_evidence.rs`:
- Around line 407-517: Extract the duplicated call/argument traversal from
observed_value_facts_for_test and field_assignment_value_unresolved_for_test
into a shared helper that builds projected (call, argument) pairs for the
selected owner_name and ObservedArgumentSelection, including filtering calls,
resolving call_arguments, and applying projections. Update both functions to use
this helper while preserving their existing value-resolution and
unresolved-check behavior.
In `@crates/ripr/src/analysis/value_resolution.rs`:
- Around line 262-282: Prevent stale struct-literal fallback when a field
assignment was invalidated. Update resolve_identifier_or_literal_at to detect
whether any prior assignment candidate exists for the object/field, and return
without resolving a value whenever such a candidate exists but cannot produce a
valid assignment; do not fall through to struct_field_bindings. Reuse or replace
field_assignment_at consistently with field_assignment_value_unresolved_at_call,
removing the now-unused helper if appropriate.
🪄 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
Run ID: 11094f07-be69-43cd-9f56-1c0b9657c4db
📒 Files selected for processing (11)
.ripr/traceability.tomlCHANGELOG.mdcrates/ripr/src/analysis/test_grip_evidence.rscrates/ripr/src/analysis/test_grip_evidence/tests.rscrates/ripr/src/analysis/value_resolution.rscrates/ripr/src/analysis/value_resolution/tests.rscrates/ripr/src/output/evidence_record.rsdocs/CAPABILITY_MATRIX.mddocs/OUTPUT_SCHEMA.mddocs/specs/RIPR-SPEC-0001-static-exposure-loop.mddocs/specs/RIPR-SPEC-0021-evidence-record.md
|
Addressed the current review findings in f424977. Invalidation is now anchored to the selected assignment position, so a pre-assignment mutable borrow does not deny a later exact value. Once a candidate field assignment exists, an invalidated or unresolved assignment returns no value and cannot fall through to stale struct-literal evidence. Added both internal-state regressions plus a real source-shape ordering regression. Focused proof: value_resolution 31/31, mutable_borrow 3/3, test_grip_evidence 216/216, cargo fmt --check, cargo check -p ripr --all-targets, and git diff --check. The suggested duplicated-traversal extraction is valid maintainability follow-up but is intentionally outside this correctness correction. |
Summary
field = CONST,CONST - 1, andCONST + 1evidence for safe equality-boundary observationsfield_assignment_value_unresolvedlimitationSwarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal: none
Spec:
RIPR-SPEC-0001,RIPR-SPEC-0021ADR: none
Plan item:
analysis/field-constant-observationActive goal:
rust-one-shot-evidence-to-repairIssue: #1423
Scope
Scope Classification
Production delta:
Evidence/support delta:
Single acceptance criterion:
Non-goals:
Support-tier Impact
docs/status/SUPPORT_TIERS.mdClaim/proof notes:
Policy Impact
Ledger or exception notes:
Proof
Result, failures, or skipped proof:
cargo xtask goldens checkproduced no diagnostic before the 20-minute local timeout and left no orphaned process. A fresh protected current-head result is required before merge.Ripr Rust Small Result; that result is not used as proof for the corrective commit.Claim Boundary
Rollback
Spec-Test-Code Traceability
RIPR-SPEC-0001,RIPR-SPEC-0021analysis::value_resolution::tests,analysis::test_grip_evidence::tests,output::evidence_recordnormalization testsanalysis/value_resolution.rs,analysis/test_grip_evidence.rs,output/evidence_record.rsStatic Language Check
killed,survived,untested,proven, andadequate.CI Economics
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.Gates
cargo fmt --checkcargo check --workspace --all-targetscargo test --workspacecargo clippy --workspace --all-targets -- -D warningscargo doc --workspace --no-depscargo package -p ripr --listcargo publish -p ripr --dry-runcargo xtask check-static-languagecargo xtask check-doc-artifactscargo xtask check-support-tierscargo xtask check-no-panic-familycargo xtask check-allow-attributescargo xtask check-local-contextcargo xtask check-file-policycargo xtask check-executable-filescargo xtask check-workflowscargo xtask check-spec-formatcargo xtask check-spec-numberingcargo xtask check-fixture-contractscargo xtask check-generatedcargo xtask check-badge-diff-policycargo xtask check-generated-cleancargo xtask check-dependenciescargo xtask check-process-policycargo xtask check-network-policyExtension changes: none.