Repository navigation
fix(proof): bind receipt replanning to current head - #837
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary by CodeRabbit
WalkthroughProof receipt validation now scopes terminalization, portfolio selection, seeded requests, and receipt checks to the current diff head. Focused proof planning records budget status for all candidates. v2 normalization preserves Cargo passthrough arguments. ChangesProof receipt handling
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Diff
participant ProofBroker
participant ProofPlanner
participant Receipts
Diff->>ProofBroker: provide current diff.head
ProofBroker->>Receipts: filter receipts by head
ProofBroker->>ProofPlanner: pass current-head portfolio evidence
ProofPlanner->>Receipts: terminalize requests by ID and head
Receipts-->>ProofPlanner: current-head receipt status
Possibly related issues
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 2
🤖 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 `@src/proof/broker.rs`:
- Around line 1000-1023: Update has_unreceipted_proof_request_tasks to call
current_head_receipts once, bind the resulting collection, and pass it by
slice/reference to both unreceipted_focused_test_tasks and
unreceipted_focused_build_tasks instead of recomputing and cloning the same
receipts.
In `@src/proof/planner.rs`:
- Around line 1690-1728: Extend
terminalization_does_not_use_receipt_from_another_head with a stale-only
scenario before the final call that moves request and receipt: invoke
terminalize_proof_requests using only the previous-head receipt, then assert the
request status is deferred rather than satisfied. Preserve the existing
assertions for the current-head receipt case.
🪄 Autofix
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: 0f6bf3c1-7590-4056-94b6-c3bdaf5f51eb
📒 Files selected for processing (3)
src/main.rssrc/proof/broker.rssrc/proof/planner.rs
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 (1)
src/proof/tasks.rs (1)
720-723: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winCompare the command specifications.
These assertions only confirm that both tasks have command specifications. The task identity does not contain Cargo passthrough arguments. The test can pass if one path removes
-- --nocapture.Compare the
head.argvandbase_plus_tests.argvvalues from both command specifications.Proposed test assertion
- assert_eq!( - from_v1[0].command_specs.is_some(), - from_v2[0].command_specs.is_some() - ); + assert_eq!( + from_v1[0].command_specs.as_ref().map(|specs| { + (&specs.head.argv, &specs.base_plus_tests.argv) + }), + from_v2[0].command_specs.as_ref().map(|specs| { + (&specs.head.argv, &specs.base_plus_tests.argv) + }), + "v1 and v2 command specifications must preserve Cargo passthrough arguments" + );🤖 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 `@src/proof/tasks.rs` around lines 720 - 723, Strengthen the task comparison assertion by comparing the actual command arguments rather than only command_specs presence: when command specifications exist, compare both head.argv and base_plus_tests.argv between from_v1[0] and from_v2[0]. Preserve the existing option-presence check while ensuring Cargo passthrough arguments such as --nocapture cannot be omitted unnoticed.
♻️ Duplicate comments (1)
src/proof/planner.rs (1)
1725-1734: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winAdd stale-only behavior assertions.
Both tests include a current-head receipt. That receipt makes the final result successful. Add a stale-only invocation before the mixed-receipt invocation.
src/proof/planner.rs#L1725-L1734: terminalize with onlyreceiptand assertdeferred.src/proof/broker.rs#L1504-L1518: select with onlystale_receiptand assert the task remains selected instead of answered.🤖 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 `@src/proof/planner.rs` around lines 1725 - 1734, Add stale-only assertions before the existing mixed-receipt checks: in src/proof/planner.rs lines 1725-1734, invoke terminalization with only receipt and assert the result is deferred; in src/proof/broker.rs lines 1504-1518, invoke selection with only stale_receipt and assert the task remains selected rather than answered. Preserve the existing mixed current-head receipt assertions afterward.
🤖 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 `@src/proof/planner.rs`:
- Around line 1725-1734: The new unit tests are located in child-module tests
blocks instead of the designated root test module. Move the head-aware
terminalization assertions from src/proof/planner.rs lines 1725-1734, the
head-aware portfolio assertions from src/proof/broker.rs lines 1504-1518, and
the current-head filtering, candidate-merging, and seeded-request tests from
src/proof/broker.rs lines 1574-1695 into the mod tests block at the bottom of
src/main.rs, preserving their coverage and required imports or helpers.
---
Outside diff comments:
In `@src/proof/tasks.rs`:
- Around line 720-723: Strengthen the task comparison assertion by comparing the
actual command arguments rather than only command_specs presence: when command
specifications exist, compare both head.argv and base_plus_tests.argv between
from_v1[0] and from_v2[0]. Preserve the existing option-presence check while
ensuring Cargo passthrough arguments such as --nocapture cannot be omitted
unnoticed.
---
Duplicate comments:
In `@src/proof/planner.rs`:
- Around line 1725-1734: Add stale-only assertions before the existing
mixed-receipt checks: in src/proof/planner.rs lines 1725-1734, invoke
terminalization with only receipt and assert the result is deferred; in
src/proof/broker.rs lines 1504-1518, invoke selection with only stale_receipt
and assert the task remains selected rather than answered. Preserve the existing
mixed current-head receipt assertions afterward.
🪄 Autofix
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: 23da2af7-7069-4b1c-9c50-13c752ca9889
📒 Files selected for processing (4)
src/main.rssrc/proof/broker.rssrc/proof/planner.rssrc/proof/tasks.rs
| assert!(receipt_matches_request_on_head( | ||
| ¤t_receipt, | ||
| "request-current-head", | ||
| "current-head", | ||
| )); | ||
| assert!(!receipt_matches_request_on_head( | ||
| &receipt, | ||
| "request-current-head", | ||
| "current-head", | ||
| )); |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Move the new unit tests to src/main.rs.
These assertions are in child-module mod tests blocks. Move unit-test coverage to the mod tests block at the bottom of src/main.rs.
src/proof/planner.rs#L1725-L1734: move the head-aware terminalization test assertions tosrc/main.rs.src/proof/broker.rs#L1504-L1518: move the head-aware portfolio test assertions tosrc/main.rs.src/proof/broker.rs#L1574-L1695: move the current-head filtering, candidate-merging, and seeded-request unit tests tosrc/main.rs.
As per coding guidelines, “Integration tests live in tests/cli.rs; unit tests in the mod tests at the bottom of src/main.rs.”
📍 Affects 2 files
src/proof/planner.rs#L1725-L1734(this comment)src/proof/broker.rs#L1504-L1518src/proof/broker.rs#L1574-L1695
🤖 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 `@src/proof/planner.rs` around lines 1725 - 1734, The new unit tests are
located in child-module tests blocks instead of the designated root test module.
Move the head-aware terminalization assertions from src/proof/planner.rs lines
1725-1734, the head-aware portfolio assertions from src/proof/broker.rs lines
1504-1518, and the current-head filtering, candidate-merging, and seeded-request
tests from src/proof/broker.rs lines 1574-1695 into the mod tests block at the
bottom of src/main.rs, preserving their coverage and required imports or
helpers.
Source: Coding guidelines
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 (1)
src/proof/tasks.rs (1)
760-797: 📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy liftMove the added unit tests to
src/main.rs.The added tests are unit tests. Put them in the
mod testsat the bottom ofsrc/main.rs, as required by the repository test layout.As per coding guidelines, “Integration tests live in
tests/cli.rs; unit tests in themod testsat the bottom ofsrc/main.rs.”Also applies to: 800-1075
🤖 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 `@src/proof/tasks.rs` around lines 760 - 797, Move the newly added unit tests out of `src/proof/tasks.rs` and into the `mod tests` block at the bottom of `src/main.rs`, following the repository’s test layout. Keep the existing assertions and coverage unchanged, and preserve the helper symbols they exercise such as `focused_test_candidates_from_requests`, `focused_test_candidates_from_v2`, and `v2_focused_test_request` by relocating the test code rather than rewriting it.Source: Coding guidelines
♻️ Duplicate comments (1)
src/proof/planner.rs (1)
1735-1749: 📐 Maintainability & Code Quality | 🟠 MajorKeep the new head-scoped regression tests in the root test module.
Move the containing tests and their new assertions to
src/main.rs:
src/proof/planner.rs#L1735-L1749: moveterminalization_does_not_use_receipt_from_another_head.src/proof/broker.rs#L1520-L1530: moveportfolio_does_not_reuse_receipt_from_another_head.As per coding guidelines, “Integration tests live in
tests/cli.rs; unit tests in themod testsat the bottom ofsrc/main.rs.”🤖 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 `@src/proof/planner.rs` around lines 1735 - 1749, The head-scoped regression test terminalization_does_not_use_receipt_from_another_head, including its new assertions, should be moved from src/proof/planner.rs#L1735-L1749 into the mod tests section of src/main.rs. Also move portfolio_does_not_reuse_receipt_from_another_head from src/proof/broker.rs#L1520-L1530 into the same root test module, preserving both tests’ behavior and assertions.Source: Coding guidelines
🤖 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 `@src/proof/tasks.rs`:
- Around line 132-145: Update the planning flow around
focused_test_tasks_from_diff so budget-rejected candidates do not prevent later
candidates from being evaluated. Continue scanning candidate_tasks after a
rejection, and ensure later candidates that satisfy the remaining caps are added
to plans with the appropriate candidate_plan_status instead of being marked
deferred_by_budget solely because an earlier candidate failed.
---
Outside diff comments:
In `@src/proof/tasks.rs`:
- Around line 760-797: Move the newly added unit tests out of
`src/proof/tasks.rs` and into the `mod tests` block at the bottom of
`src/main.rs`, following the repository’s test layout. Keep the existing
assertions and coverage unchanged, and preserve the helper symbols they exercise
such as `focused_test_candidates_from_requests`,
`focused_test_candidates_from_v2`, and `v2_focused_test_request` by relocating
the test code rather than rewriting it.
---
Duplicate comments:
In `@src/proof/planner.rs`:
- Around line 1735-1749: The head-scoped regression test
terminalization_does_not_use_receipt_from_another_head, including its new
assertions, should be moved from src/proof/planner.rs#L1735-L1749 into the mod
tests section of src/main.rs. Also move
portfolio_does_not_reuse_receipt_from_another_head from
src/proof/broker.rs#L1520-L1530 into the same root test module, preserving both
tests’ behavior and assertions.
🪄 Autofix
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: 618006be-8e1d-4a71-ab03-a9a7ae2001e9
📒 Files selected for processing (3)
src/proof/broker.rssrc/proof/planner.rssrc/proof/tasks.rs
| let planned_ids = focused_test_tasks_from_diff(diff, proof_requests, budget) | ||
| .into_iter() | ||
| .map(|task| task.id) | ||
| .collect::<BTreeSet<_>>(); | ||
| let candidate_tasks = focused_test_candidates_from_diff(diff, proof_requests); | ||
| let mut plans = Vec::with_capacity(candidate_tasks.len()); | ||
| for task in candidate_tasks { | ||
| let status = candidate_plan_status(planned_ids.contains(&task.id)); | ||
| plans.extend(std::iter::once(focused_proof_plan_for_task( | ||
| task, | ||
| budget, | ||
| status, | ||
| "candidate recorded for portfolio accounting; execution is budget-gated".to_owned(), | ||
| ))); |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Continue after a candidate exceeds a budget cap.
focused_test_tasks_from_diff stops at its first rejected candidate. This function then marks every later candidate as deferred_by_budget.
With one selected file, a candidate for a second file can fail max_focused_test_files, while a later candidate for the selected file can still fit all caps. Keep scanning after a rejection so the later candidate can be planned.
Proposed fix
if !focused_proof_budget_allows_next(
tasks.len(),
&files,
&task.file,
estimated_seconds,
task_timeout_sec,
task.mode.command_count(),
budget,
) {
- return tasks;
+ continue;
}🤖 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 `@src/proof/tasks.rs` around lines 132 - 145, Update the planning flow around
focused_test_tasks_from_diff so budget-rejected candidates do not prevent later
candidates from being evaluated. Continue scanning candidate_tasks after a
rejection, and ensure later candidates that satisfy the remaining caps are added
to plans with the appropriate candidate_plan_status instead of being marked
deferred_by_budget solely because an earlier candidate failed.
Summary
Bind receipt-driven proof replanning and terminalization to the exact reviewed head.
The current broker already replans after focused receipts and shares equivalent request evidence. Before this repair, receipt reuse was keyed by task/request identity alone, so a receipt from an earlier PR head could incorrectly satisfy current-head work or prevent its execution.
Scope
No new proof command family, GitHub posting, gate-authority change, threshold change, suppression, or unrelated compiler work is included.
Proof
The hosted exact-head gate and RIPR remain required before merge.