Skip to content

fv(diff): Kani proofs for hunk-body line mapping (#13681) - #13765

Merged
EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-zlw2o0
Nov 8, 2026
Merged

EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-zlw2o0

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Requested by Steven Zimmerman · project thread

Summary

  • Extracts the pure coordinate step (hunk_step) and header-count accounting (hunk_account) that ParserState::consume_hunk_line / account_hunk_line already did inline. Behavior is unchanged: the same refusal at a zero side, the same overflow close, the same +S,0 anchor (fix(diff): removed-line new_side_line is one low in a zero-new-count hunk (+S,0), found by the #12918 differential #13098) and +0,0 → line 1 (check: deletion-only diff reports its finding at line 0 (./src/lib.rs:0) #11486).
  • Adds three Kani harnesses in analysis/diff/parse/hunk_kani.rs (beside the existing header proofs):
    1. hunk_step_records_the_cursor_line_and_never_line_zero: over all usize coordinates, a body line records exactly the cursor line and advances that side by one, is refused iff its side is 0, exhausts iff its counter is usize::MAX; no recorded line or anchor is 0.
    2. hunk_body_maps_each_line_to_its_exact_coordinate: feeding back the core's own next_*, a consistent 3-line body maps each line to start plus the preceding lines (starts over all of usize short of exhaustion).
    3. hunk_account_settles_exactly_when_body_matches_header: a 0–4 line body against any stated counts settles at (0,0) iff its own counts equal the header's (over- and under-delivery both fail to settle).
  • Expected values in each harness are independent arithmetic, not parser output. How the state machine records a malformed hunk around these functions (record_malformed_hunk, end-of-hunk settlement) is covered by ordinary parser tests, not these proofs.

Decision (documented on #13681): harnesses that drove the whole ParserState (map, PathBuf keys, line text) got no CBMC verdict in 25 minutes, three attempts. Per RIPR-SPEC-0371 ("a smaller pure core is proved"), the proofs target the extracted core; the 306 existing analysis::diff tests keep covering how the state machine uses it.

Swarm / Source Boundary

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

Source-of-truth Links

Proposal: none
Spec: RIPR-SPEC-0371 (Kani lane; harness rules unchanged)
ADR: none
Plan item: #12109 internal-assurance track; related #12904
Governing issue or accepted claim: #13681
Acceptance delta (one sentence): Kani now proves the diff parser's hunk-body coordinate mapping and its remaining-count accounting against the hunk header, which previously had no proofs.

Candidate Relationships

Candidate branch: claude/project-thread-zlw2o0
Stack parent or prerequisite PR: none
Proposed replacement of PR: none

Local evidence

  • Head 182ac16e (doc/changelog only since b21627b8): cargo kani (0.68.0) — 3 new + 2 existing hunk harnesses VERIFIED (0.5s / 3.1s / 1.3s; existing 69s, 9s); 11/11 cover! SATISFIED. cargo xtask precommit: exit 0.
  • Head b21627b8: cargo test -p ripr --lib analysis::diff: 306 passed. Negative control: mutating production (context step not advancing new; accounting saturating instead of checked) makes all 3 new harnesses FAILED. Restored.
  • Independent review: CLEAN, two non-blocking findings fixed — see comment.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UNUoLVPtDQ1Bdq3NszjhqS

Extract the pure coordinate step (hunk_step) and header-count accounting
(hunk_account) that ParserState::consume_hunk_line and account_hunk_line
already performed inline, with unchanged behavior, and prove them with
three Kani harnesses: every body line records exactly the cursor line and
never line 0 (all usize coordinates, including exhaustion); a consistent
body maps each line to start plus preceding lines; and accounting settles
exactly when the body agrees with the header counts.

Driving the full parser state through CBMC produced no verdict in 25
minutes, so per RIPR-SPEC-0371 the smaller pure core is proved and the
existing parser tests cover its use.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVPtDQ1Bdq3NszjhqS
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@EffortlessSteven EffortlessSteven self-assigned this Nov 8, 2026
@coderabbitai

coderabbitai Bot commented Nov 8, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

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).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 25 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 152 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 38fffebe-45ff-4b5e-958c-1660a51f9899
Commits

Reviewing files that changed from the base of the PR and between 5d5951b and 586daf8.

Files selected for processing: 3

  • changelog.d/13681-kani-proofs-for-hunk-body-line-mapping.md
  • crates/ripr/src/analysis/diff/parse.rs
  • crates/ripr/src/analysis/diff/parse/hunk_kani.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

…13681)

Review follow-up: the module doc now names the body harnesses and says
the surrounding state machine is covered by ordinary tests, and the
changelog claims only the remaining-count accounting, not malformed-hunk
recording.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVPtDQ1Bdq3NszjhqS

Copy link
Copy Markdown
Member Author

Independent review (fresh-context subagent, no stake), head b21627b8: CLEAN, two non-blocking findings, both fixed in 182ac16e.

Inspected: the full diff, the surrounding consume_hunk_line / account_hunk_line / advance_quarantined_line / note_unheadered_gitlink / mark_section_body_seen, source_line_text, and the harness rules in RIPR-SPEC-0371.

  • Behavior preservation: a line-by-line comparison found no change.
    • The zero-side refusal stays at the same point.
    • Coordinates cannot move between computing step and using it, because every branch that calls advance_quarantined_line returns first.
    • The \ No newline path, empty-line context, &raw[1..] slicing (the first byte is ASCII) and the +S,0 / +0,0 anchors are all unchanged.
  • Proof adequacy: the expected values come from independent arithmetic, not restated from the implementation. The domains are stated, and every harness has a reachable cover!.
  • Finding 1 (fixed): the hunk_kani.rs module doc still described header proofs only. It now names the body harnesses and says the surrounding state machine is covered by ordinary tests.
  • Finding 2 (fixed): the changelog said the proofs cover "when it counts a hunk as malformed". It now claims only the remaining-count accounting. The proofs do not cover record_malformed_hunk.

The reviewer's own cargo test run was OOM-killed, an infrastructure failure. My run on b21627b8 passed 306 analysis::diff tests. The source is unchanged since then: 182ac16e touches doc comments and the changelog only.

Kani rerun on 182ac16e (kani-verifier 0.68.0, local): Complete - 5 successfully verified harnesses, 0 failures. That covers the 3 new and 2 existing hunk harnesses, with 11/11 cover! SATISFIED. cargo xtask precommit on 182ac16e: exit 0.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review November 8, 2026 15:43
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@devin-ai-integration devin-ai-integration 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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY

Subject: head 182ac16e546a180556da2e06f336d7cb767e2ad2.

Independent review by a fresh-context reviewer with no stake in the change. Full record: #13765 (comment).

  • Verdict: CLEAN on b21627b8.
  • Both non-blocking findings (module doc scope, changelog overclaim) are fixed in 182ac16e, which touches doc comments and the changelog only.
  • Behavior preservation of consume_hunk_line / account_hunk_line was checked line by line.
  • The harness oracles are independent of the implementation, the domains are stated, and every cover is reachable.

Local evidence on 182ac16e:

  • cargo kani 0.68.0: 5/5 hunk harnesses VERIFIED, 11/11 covers SATISFIED.
  • cargo xtask precommit: exit 0.

Missing until CI completes: hosted Ripr Rust Small Result and the advisory Kani lane. This is not REVIEW_READY for merge.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for head 182ac16

This supersedes my previous review. Its closing sentence was meant only as a scope note, and that note follows here.

The independent fresh-context review found the source clean; record: #13765 (comment). Both of its non-blocking findings are fixed on this head.

Local Kani on this head: 5/5 hunk harnesses VERIFIED, 11/11 covers satisfied. Precommit: exit 0.

Hosted Ripr Rust Small Result and the advisory Kani lane are still to run. The final merge judgment follows their results.


Generated by Claude Code

@github-actions

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

ripr static exposure check

Commit 586daf88c89e · run · advisory, static evidence only (not a mutation run).

#ripr agent static-advisory base=5d5951b19a273c2261cf79fd604b0038545b424f findings=137 gaps=15 infection_unknown=3 no_static_path=3 reachable_unrevealed=15 static_unknown=36 weakly_exposed=80
analysis=incomplete|outcome=partial_with_limitations
limitation=language_scope_unsupported|reason=proof_harness_not_evaluated: lines changed inside a function carrying a proof-ha…|recovery=proof_harness_not_evaluated: a changed proof harness (`#[kani::proof]` or `#[kani::proof_for_contract]`) is verification source, so ripr produced no production probe for it and does not evaluate it. Run the verifier for the changed harness; this is not a coverage claim.
+1 more analysis limitations; `--format json` lists all
reachable_unrevealed|crates/ripr/src/analysis/diff/parse/hunk_kani.rs:64|match kani::any::<u8>() % 3|missing=No statically established oracle: assertion execution or macro binding is unesta…|test=t1|id=probe:crates_ripr_src_analysis_diff_parse_hunk_kani.rs:match_arm:a96cb1a2
weakly_exposed|crates/ripr/src/analysis/diff/parse.rs:247|match raw.as_bytes().first()|missing=No strong discriminator was detected|test=t1|id=probe:crates_ripr_src_analysis_diff_parse.rs:match_arm:f09fd9a0
weakly_exposed|crates/ripr/src/analysis/diff/parse.rs:248|Some(b'+') =>|missing=No strong discriminator was detected|test=t1|id=probe:crates_ripr_src_analysis_diff_parse.rs:match_arm:45b4e560
weakly_exposed|crates/ripr/src/analysis/diff/parse.rs:248|Some(Self::Added)|missing=No strong discriminator was detected|test=t2|id=probe:crates_ripr_src_analysis_diff_parse.rs:return_value:3f583e5d
weakly_exposed|crates/ripr/src/analysis/diff/parse.rs:249|Some(b'-') =>|missing=No strong discriminator was detected|test=t1|id=probe:crates_ripr_src_analysis_diff_parse.rs:match_arm:f76366d1
weakly_exposed|crates/ripr/src/analysis/diff/parse.rs:249|Some(Self::Removed)|missing=No strong discriminator was detected|test=t2|id=probe:crates_ripr_src_analysis_diff_parse.rs:return_value:7cf4fc7a
t1=crates/ripr/src/analysis/classify/owner_pin/tests.rs:4188 a_bare_call_through_any_other_binding_of_the_name_is_not_a_pin exact_value `assert_eq!(weight_admitted(control).len(), 1);` miss=no_call_path
t2=crates/ripr/tests/cross_crate_reach.rs:645 a_bare_call_after_a_use_of_a_renamed_dependency_is_noticed relational_check `if !check.contains(NOTICED) { return Err(format!("renamed + imported must read n…` miss=weak_assertion
+9 more gaps not shown; `--format json` lists all
limits=infection_unknown:3,no_static_path:3,reachable_unrevealed:8,static_unknown:36,weakly_exposed:72
next=ripr explain --root . --base 5d5951b19a273c2261cf79fd604b0038545b424f --committed --mode draft --format agent probe:crates_ripr_src_analysis_diff_parse_hunk_kani.rs:match_arm:a96cb1a2
verify=refused|outcome=partial_with_limitations|findings=137|exposed=0|reason=analysis_incomplete,gaps_remain

Took 84s.

Copy link
Copy Markdown
Member Author

The Rust-only feature lane failure on head 182ac16e (run 42496576364) does not come from this PR.

cli_reference_matches_the_binary fails with "docs/CLI_REFERENCE.md is stale". This PR touches neither the CLI nor that doc. The test and doc came from #13655 and #13731 on main, and qualification runs the merge composition with current main, so the composed tree goes stale as soon as the CLI help changes.

The existing main-health fix is #13778 ("rebless CLI reference for repair/continue --json"). I am not duplicating it here. Once it lands I will re-apply merge-ready on this head to re-qualify against the healed main.


Generated by Claude Code

Copy link
Copy Markdown
Member Author

Update on the Rust-only feature lane / cli_reference_matches_the_binary failures (runs 42500784263, 42505990840).

Each failed run composed this head with a main whose docs/CLI_REFERENCE.md lagged a CLI help change (#13793, #13813). The fixes for those (#13778, #13811) landed later.

I checked current main (98fdf65b) locally with cargo test -p ripr --no-default-features --features lang-rust --test cli_reference_doc: 2 passed. So the lane is green on current main without anything from this PR. I re-applied merge-ready so the candidate re-qualifies against that main. The diff is unchanged.


Generated by Claude Code

Refresh the integration basis: the hosted merge ref was composing with a
stale main (3c84be7) that predates the CLI reference reblesses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UNUoLVPtDQ1Bdq3NszjhqS

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

SOURCE_REVIEW_READY for head 586daf8

This head is a clean merge of current main (5d5951b) into the previously reviewed head 182ac16, with no conflicts. Its diff against main is the same three files, byte for byte: parse.rs, hunk_kani.rs and the changelog fragment. The source and oracle review recorded for 182ac16 still applies unchanged; only the integration basis moved.

Why the merge: the hosted merge ref kept composing with an old main (3c84be7) that predates the CLI reference reblesses #13778 and #13811, so cli_reference_matches_the_binary kept reporting a stale doc in the Rust-only lane.

Local check on this head: cargo test -p ripr --lib analysis::diff passed 313 tests.


Generated by Claude Code

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

REVIEW_READY for head 586daf8

Final merge judgment for this head.

  • Source and oracle review: independent, clean. Both findings were fixed in 182ac16. The diff since then is unchanged; 586daf8 only merges current main into it, with no conflicts.
  • Hosted checks on this head all pass: Ripr Rust Small Result (gates and four test shards), Rust-only feature lane, the Kani lane, the Windows gate, cargo-deny, security, the Python journeys and the paste lanes.
  • There are no review threads. The only bot output is CodeRabbit and Gemini quota notices plus the advisory ripr comment, so no review findings are pending.

Merging as a squash pinned to this head.


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants