Repository navigation
test(review): prove integrated Perl replay - #835
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reached
Next review available in: 13 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Summary by CodeRabbit
WalkthroughChangesM1 production replay
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Fixture as Perl LSP fixture
participant Compiler as Production compiler
participant Delivery as Fake delivery API
participant Receipts as Receipt files
Fixture->>Compiler: Build observations and thread context
Compiler->>Delivery: Validate head and submit review requests
Delivery-->>Compiler: Return deterministic responses
Compiler->>Receipts: Persist terminal delivery receipts
Possibly related issues
Possibly related PRs
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 |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 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 `@docs/PRODUCT_STATE.md`:
- Around line 309-311: Reconcile the v0.1.0 release status throughout
PRODUCT_STATE.md: update the section around the tag-cutting guidance and the
statements around lines 259-262 to reflect that v0.1.0 is already shipped and
published, while preserving the remaining release-only proof and v0.1.1
authorization requirements described near Issue `#716`.
In `@src/review_experience.rs`:
- Around line 762-1050: Move the test function
perl_lsp_3627_runs_production_compiler_and_delivery_replay and its required
fixture/helper dependencies out of the source module into tests/cli.rs,
preserving the complete production compiler, delivery API replay, receipt
assertions, and fixed-head silence checks. Keep source-module tests limited to
local unit tests in the existing test modules.
- Around line 984-987: Update the fake-server lifecycle around
spawn_fake_delivery_api and server.join so request-count failures terminate the
server instead of blocking indefinitely: configure the server’s blocking accept
loop with an accept deadline or equivalent timeout, and propagate a timeout
error that includes the requests captured so far. Preserve the existing panic
and handler-error propagation for successful completion.
- Around line 296-314: Update fixture_run_args to pass the explicit
--max-inline-comments value of 2 in the Cli::try_parse_from arguments, ensuring
fixture replays always compile at least the required two comments regardless of
UB_REVIEW_MAX_INLINE_COMMENTS.
🪄 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: cf63af8e-c13a-49d3-8f84-ce59aa70b934
📒 Files selected for processing (5)
.ripr/suppressions.tomldocs/PRODUCT_STATE.mddocs/REVIEW_EXPERIENCE_FIXTURES.mdsrc/github_delivery.rssrc/review_experience.rs
| #[test] | ||
| fn perl_lsp_3627_runs_production_compiler_and_delivery_replay() -> Result<(), String> { | ||
| let fixture = fixture()?; | ||
| let temp = tempfile::tempdir().map_err(|error| error.to_string())?; | ||
| let out = temp.path().join("review"); | ||
| fs::create_dir_all(&out).map_err(|error| error.to_string())?; | ||
|
|
||
| let reply_thread = fixture | ||
| .threads | ||
| .iter() | ||
| .find(|thread| thread.id == "3558771748") | ||
| .ok_or_else(|| "fixture reply thread is missing".to_owned())?; | ||
| let inline_thread = fixture | ||
| .threads | ||
| .iter() | ||
| .find(|thread| thread.id == "3558766480") | ||
| .ok_or_else(|| "fixture inline thread is missing".to_owned())?; | ||
| let mut observations = production_observations(&fixture); | ||
| let reply_observation = observations | ||
| .iter_mut() | ||
| .find(|observation| observation.id == "fixture-parser:later-variable-subscript") | ||
| .ok_or_else(|| "fixture reply observation is missing".to_owned())?; | ||
| reply_observation.status = "refuted".to_owned(); | ||
| reply_observation.evidence = vec!["focused parser proof receipt".to_owned()]; | ||
|
|
||
| let reply_comment = fixture_comment(reply_thread, &reply_thread.body); | ||
| let inline_comment = fixture_comment(inline_thread, &inline_thread.body); | ||
| for observation in &mut observations { | ||
| if observation.line == reply_thread.anchor || observation.line == inline_thread.anchor { | ||
| observation.claim = format!("[fixture] {}", observation.claim); | ||
| } | ||
| } | ||
| let comments = vec![reply_comment, inline_comment]; | ||
| let thread_context = production_thread_context_with_shape( | ||
| &fixture, | ||
| &fixture.buggy_head_sha, | ||
| &fixture.buggy_head_sha, | ||
| None, | ||
| &[inline_thread.id.as_str(), "3558707519"], | ||
| ); | ||
| let initial_graph = build_active_claim_graph( | ||
| &fixture.buggy_head_sha, | ||
| &observations, | ||
| &comments, | ||
| &[], | ||
| &[], | ||
| &[], | ||
| &thread_context, | ||
| ); | ||
| let reply_claim_id = initial_graph | ||
| .topics | ||
| .iter() | ||
| .find(|topic| topic.path.as_deref() == Some(reply_thread.path.as_str())) | ||
| .map(|topic| topic.claim_id.clone()) | ||
| .ok_or_else(|| "reply claim was not produced by the production graph".to_owned())?; | ||
| let proof_receipt = ProofReceipt { | ||
| schema: "ub-review.proof_receipt.v1".to_owned(), | ||
| id: "fixture-focused-parser-proof".to_owned(), | ||
| kind: "focused-test".to_owned(), | ||
| base: fixture.base_sha.clone(), | ||
| head: fixture.buggy_head_sha.clone(), | ||
| test_patch_mode: "none".to_owned(), | ||
| requested_by: vec![reply_claim_id.clone()], | ||
| request_ids: vec![reply_claim_id], | ||
| commands: vec![ProofCommandReceipt { | ||
| side: "head".to_owned(), | ||
| command: fixture.pr_body.focused_command.clone(), | ||
| env: std::collections::BTreeMap::new(), | ||
| status: "passed".to_owned(), | ||
| exit_code: Some(0), | ||
| timed_out: false, | ||
| timeout_sec: 300, | ||
| duration_ms: 1, | ||
| stdout: "focused proof passed".to_owned(), | ||
| stderr: String::new(), | ||
| reason: "fixture proof receipt".to_owned(), | ||
| }], | ||
| result: "passed".to_owned(), | ||
| reason: "focused parser proof changed the reply disposition".to_owned(), | ||
| }; | ||
| let proof_receipts = vec![proof_receipt]; | ||
| let graph = build_active_claim_graph( | ||
| &fixture.buggy_head_sha, | ||
| &observations, | ||
| &comments, | ||
| &[], | ||
| &[], | ||
| &proof_receipts, | ||
| &thread_context, | ||
| ); | ||
| let reply_topic = graph | ||
| .topics | ||
| .iter() | ||
| .find(|topic| topic.path.as_deref() == Some(reply_thread.path.as_str())) | ||
| .ok_or_else(|| "reply topic was not retained".to_owned())?; | ||
| require( | ||
| reply_topic.planned_action == "reply" | ||
| && reply_topic.planned_thread_id.as_deref() == Some(reply_thread.id.as_str()) | ||
| && reply_topic.proof_receipts == vec!["fixture-focused-parser-proof"], | ||
| "production graph did not create an exact proof-backed reply plan", | ||
| )?; | ||
| let inline_topic = graph | ||
| .topics | ||
| .iter() | ||
| .find(|topic| topic.path.as_deref() == Some(inline_thread.path.as_str())) | ||
| .ok_or_else(|| "inline topic was not retained".to_owned())?; | ||
| require( | ||
| inline_topic.planned_action == "inline" && inline_topic.planned_thread_id.is_none(), | ||
| "production graph did not create a novel inline plan", | ||
| )?; | ||
| require( | ||
| graph.topics.len() == fixture.claims.len(), | ||
| format!( | ||
| "production graph collapsed distinct Perl claims: topics={} claims={} ids={:?}", | ||
| graph.topics.len(), | ||
| fixture.claims.len(), | ||
| graph | ||
| .topics | ||
| .iter() | ||
| .map(|topic| { | ||
| format!( | ||
| "{}:{}:{}:{}", | ||
| topic.path.as_deref().unwrap_or("<summary>"), | ||
| topic.anchor.unwrap_or_default(), | ||
| topic.mechanism, | ||
| topic.subject | ||
| ) | ||
| }) | ||
| .collect::<Vec<_>>() | ||
| ), | ||
| )?; | ||
| write_claim_graph(temp.path(), &graph).map_err(|error| error.to_string())?; | ||
|
|
||
| let plan = fixture_plan(&fixture); | ||
| let diff = fixture_diff(&fixture, &fixture.buggy_head_sha); | ||
| let args = fixture_run_args(temp.path(), &out, &fixture.buggy_head_sha)?; | ||
| let body_policy = ReviewBodyPolicy::default(); | ||
| let post_review_on = vec!["pull_request".to_owned()]; | ||
| let surface = compile_review_surface(ReviewCompilerInput { | ||
| shared_context_id: "fixture-context", | ||
| review_body_policy: &body_policy, | ||
| run_pass: RunPass::Manual, | ||
| post_review_on: &post_review_on, | ||
| args: &args, | ||
| plan: &plan, | ||
| diff: &diff, | ||
| model_lanes: &[], | ||
| missing_or_failed_sensor_evidence: &[], | ||
| missing_or_failed_model_evidence: &[], | ||
| inline_comments: &comments, | ||
| summary_only_findings: &[], | ||
| observations: &observations, | ||
| proof_receipts: &proof_receipts, | ||
| suggested_issues: &[], | ||
| final_follow_up_tasks: 0, | ||
| reporter_distillation: Some( | ||
| "The focused receipt changes the disposition; internal lane and queue state stays hidden.", | ||
| ), | ||
| }) | ||
| .map_err(|error| error.to_string())?; | ||
| require( | ||
| surface.should_prepare_github_review && surface.github_review.comments.len() == 2, | ||
| "production compiler did not retain the reply and inline surfaces", | ||
| )?; | ||
| for forbidden in &fixture | ||
| .heads | ||
| .iter() | ||
| .find(|head| head.sha == fixture.buggy_head_sha) | ||
| .ok_or_else(|| "fixture buggy head is missing".to_owned())? | ||
| .forbidden_public_fragments | ||
| { | ||
| require( | ||
| !surface | ||
| .github_review | ||
| .body | ||
| .to_ascii_lowercase() | ||
| .contains(&forbidden.to_ascii_lowercase()), | ||
| format!("forbidden internal text reached compiled body: {forbidden}"), | ||
| )?; | ||
| } | ||
| let reply_index = surface | ||
| .github_review | ||
| .comments | ||
| .iter() | ||
| .position(|comment| comment.line == reply_thread.anchor.unwrap_or_default()) | ||
| .ok_or_else(|| "compiled reply comment is missing".to_owned())?; | ||
| let inline_index = surface | ||
| .github_review | ||
| .comments | ||
| .iter() | ||
| .position(|comment| comment.line == inline_thread.anchor.unwrap_or_default()) | ||
| .ok_or_else(|| "compiled inline comment is missing".to_owned())?; | ||
| let reply_body = | ||
| github_review_post_comment_body(&surface.github_review.comments[reply_index]) | ||
| .map_err(|error| error.to_string())?; | ||
| let (api, server) = spawn_fixture_delivery_api( | ||
| &fixture.buggy_head_sha, | ||
| &reply_thread.id, | ||
| &reply_thread.path, | ||
| reply_thread.anchor.unwrap_or_default(), | ||
| &surface.github_review.comments[inline_index], | ||
| &reply_body, | ||
| ) | ||
| .map_err(|error| error.to_string())?; | ||
| let post_args = PostArgs { | ||
| review_json: out.join("github-review.json"), | ||
| diff_patch: None, | ||
| out: out.clone(), | ||
| github_token: Some("fixture-token".to_owned()), | ||
| repo: Some("owner/repo".to_owned()), | ||
| pull_number: Some(42), | ||
| github_api_url: api, | ||
| fail_on_post_error: true, | ||
| }; | ||
| let payload = github_review_post_payload(&surface.github_review) | ||
| .map_err(|error| error.to_string())?; | ||
| let outcome = execute_pending_review_delivery(&post_args, &surface.github_review, &payload) | ||
| .map_err(|error| error.to_string())?; | ||
| require( | ||
| outcome.response["state"] == "COMMENTED", | ||
| "production delivery did not submit the compiled review", | ||
| )?; | ||
| let requests = server | ||
| .join() | ||
| .map_err(|_| "fixture GitHub server panicked".to_owned())? | ||
| .map_err(|error| error.to_string())?; | ||
| require( | ||
| requests.len() == 7 | ||
| && requests[0].0.starts_with("GET /repos/owner/repo/pulls/42 ") | ||
| && requests[1].0.contains("/pulls/42/comments?") | ||
| && requests[2] | ||
| .0 | ||
| .starts_with("POST /repos/owner/repo/pulls/42/reviews ") | ||
| && requests[3].0.contains("/reviews/987/comments") | ||
| && requests[4] | ||
| .0 | ||
| .starts_with("POST /repos/owner/repo/pulls/42/comments ") | ||
| && requests[5].0.starts_with("GET /repos/owner/repo/pulls/42 ") | ||
| && requests[6].0.contains("/reviews/987/events") | ||
| && !requests[6] | ||
| .1 | ||
| .contains(&surface.github_review.comments[inline_index].body), | ||
| format!("unexpected production delivery request sequence: {requests:?}"), | ||
| )?; | ||
| let transaction: serde_json::Value = serde_json::from_slice( | ||
| &fs::read(out.join("delivery-transaction.json")).map_err(|error| error.to_string())?, | ||
| ) | ||
| .map_err(|error| error.to_string())?; | ||
| require( | ||
| transaction["state"] == "receipts_persisted" | ||
| && out.join("delivery-reconciliation.json").is_file() | ||
| && out.join("delivery-reply-receipts.json").is_file(), | ||
| "production delivery did not leave terminal receipts", | ||
| )?; | ||
|
|
||
| let fixed_args = fixture_run_args(temp.path(), &out, &fixture.fixed_head_sha)?; | ||
| let fixed_diff = fixture_diff(&fixture, &fixture.fixed_head_sha); | ||
| let fixed_plan = Plan { | ||
| head: fixture.fixed_head_sha.clone(), | ||
| ..plan.clone() | ||
| }; | ||
| let fixed_surface = compile_review_surface(ReviewCompilerInput { | ||
| shared_context_id: "fixture-context-fixed", | ||
| review_body_policy: &body_policy, | ||
| run_pass: RunPass::Manual, | ||
| post_review_on: &post_review_on, | ||
| args: &fixed_args, | ||
| plan: &fixed_plan, | ||
| diff: &fixed_diff, | ||
| model_lanes: &[], | ||
| missing_or_failed_sensor_evidence: &[], | ||
| missing_or_failed_model_evidence: &[], | ||
| inline_comments: &[], | ||
| summary_only_findings: &[], | ||
| observations: &[], | ||
| proof_receipts: &[], | ||
| suggested_issues: &[], | ||
| final_follow_up_tasks: 0, | ||
| reporter_distillation: None, | ||
| }) | ||
| .map_err(|error| error.to_string())?; | ||
| require( | ||
| !fixed_surface.should_prepare_github_review | ||
| && fixed_surface.github_review.comments.is_empty() | ||
| && fixed_surface.github_review.body.is_empty(), | ||
| "fixed production head did not remain silent", | ||
| )?; | ||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | 🏗️ Heavy lift
Move the production replay to tests/cli.rs.
This test exercises the integrated production review and delivery path. Keep local helper unit tests in source modules. Move this replay to the required integration-test location.
As per coding guidelines, “Integration tests live in tests/cli.rs; unit tests in the mod tests at the bottom of src/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/review_experience.rs` around lines 762 - 1050, Move the test function
perl_lsp_3627_runs_production_compiler_and_delivery_replay and its required
fixture/helper dependencies out of the source module into tests/cli.rs,
preserving the complete production compiler, delivery API replay, receipt
assertions, and fixed-head silence checks. Keep source-module tests limited to
local unit tests in the existing test modules.
Source: Coding guidelines
| let requests = server | ||
| .join() | ||
| .map_err(|_| "fixture GitHub server panicked".to_owned())? | ||
| .map_err(|error| error.to_string())?; |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Make request-count failures terminate the fake server.
The fake server accepts exactly seven connections. If delivery regresses and sends fewer requests, server.join() blocks forever because spawn_fake_delivery_api uses blocking accept() without an accept deadline. Return a timeout error with the captured requests instead.
🤖 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/review_experience.rs` around lines 984 - 987, Update the fake-server
lifecycle around spawn_fake_delivery_api and server.join so request-count
failures terminate the server instead of blocking indefinitely: configure the
server’s blocking accept loop with an accept deadline or equivalent timeout, and
propagate a timeout error that includes the requests captured so far. Preserve
the existing panic and handler-error propagation for successful completion.
There was a problem hiding this comment.
Confirmed findings
- Fake GitHub server uses blocking accept() with a fixed seven-response queue. If delivery regresses and emits fewer requests, server.join() blocks indefinitely because there is no accept deadline. Add an accept timeout so a regression surfaces as a test failure rather than a hung CI job.
Verification questions
- Confirm pRODUCT_STATE.md lines 161-164 claim pending-review creation, exact comment reconciliation, head revalidation, replies, retry identity, and confirmed GitHub delivery receipts are 'now exercised by the production Perl #3627 replay in #801' — but the replay asserts 7 requests in a specific order; if any of those six behaviors is not asserted, the doc claim overstates coverage.
- Confirm pRODUCT_STATE.md line 138 says 'Transactional inline delivery is complete through merged PRs #831 and #832' but the diff provides no receipt or cross-reference confirming #831/#832 merged; replay test in src/review_experience.rs:762-1050 only proves the integrated path locally, not that those PRs are merged on origin/main.
- Confirm forbidden-fragment check uses case-insensitive substring search on compiled body only (surface.github_review.body), but does not scan compiled comment bodies. Per fixture.heads[*].forbidden_public_fragments meaning is ambiguous: could apply to comments too. Comment bodies are constructed from observation.claim prefixed with '[fixture]' so they would surface anything originating in claims.
- Confirm perl_lsp_3627_runs_production_compiler_and_delivery_replay at src/review_experience.rs:762-1050 violates the documented 'integration tests live in tests/cli.rs' guideline cited in the seeded CodeRabbit comment at line 1050. This test exercises the integrated production compiler + delivery path, not a local unit.
- Confirm github_delivery.rs:1111-1114 re-exports FakeHttpResponse and spawn_fake_delivery_api as pub(crate) for cross-module test reuse. This widens the cfg(test) public surface of a delivery module solely to support one replay test in review_experience::tests.
- Confirm pub(crate) lifting of FakeHttpResponse fields (status/body) and re-export from src/github_delivery.rs module tests widens the fake surface area. The visible fields are now mutable from review_experience tests; any future fixture regression that mutates them mid-handler would not be caught here because the replay's spawned server is single-use.
Proof results
- Focused HEAD proof failed (exit 101):
cargo test --locked --package ub-review --lib review_experience::tests::perl_lsp_3627_runs_production_compiler_and_delivery_replay. This is a current failure, not a red/green witness. - Focused build proof passed:
cargo doc --workspace --no-deps --locked. - Focused build proof passed:
cargo check --workspace --all-targets --locked.
Refuted
- Risk of detached worker leaking requests or losing terminal receipt writes; refuted because: The fake server's JoinHandle is awaited via server.join() before the test reads delivery-transaction.json and checks requests len == 7. The production execute_pending_review_delivery path runs synchronously on the test thread; no spawn-and-detach, no async::spawn, no fire-and-forget. There is no worker handoff to leak.
- Fixture token 'fixture-token' is a hardcoded secret that could leak via logs, crash dumps, or process listings; refuted because: Token is scoped to the in-process fake server bound to 127.0.0.1; never sent to real GitHub; stderr is asserted empty in proof receipt; not embedded in compiled release binary inputs. Acceptable test fixture.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Follow-up for the exact head
Local proof on |
What this does
Adds the #801 integrated M1 replay for the real perl-lsp #3627 review shape. The production claim graph, compiler, proof receipt binding, pending-review transport, reply delivery, confirmed receipts, and fixed-head silence now run together against a local fake GitHub API.
The replay proves distinct claims survive, an exact proof receipt creates a current-head reply plan, a novel surface reaches pending-review delivery, the actual create/list/reconcile/reply/head-recheck/submit sequence completes, confirmed delivery removes the inline body duplicate, terminal receipts are written, and a fixed head stays silent. It does not claim an external perl-lsp run.
The RIPR ledger contains exact owned receipts only for cfg(test) fixture plumbing that the analyzer cannot trace through its production assertions. No production gate threshold or behavior is suppressed.
Verification
Review map
src/review_experience.rs: production graph/compiler/fake-GitHub replay, delivery receipts, body fallback, and fixed-head silence.src/github_delivery.rs: reuses the existing fake delivery server for the integrated fixture..ripr/suppressions.toml: exact test-fixture exposure receipts with ownership and recheck boundary.docs/REVIEW_EXPERIENCE_FIXTURES.md: M1 integration: prove one current-head review surface on the perl-lsp #3627 replay #801 proof boundary.docs/PRODUCT_STATE.md: current M1 and release-state source truth.