Repository navigation
fix(post): execute pending-review inline delivery transaction - #831
Conversation
Summary by CodeRabbit
WalkthroughThe PR adds bounded GitHub pending-review delivery. It validates exact heads and comment identities, submits verified reviews, persists transaction artifacts, cleans up failed pending reviews, and verifies delivery artifacts. ChangesGitHub delivery transaction
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant ReviewText
participant GithubDelivery
participant GitHub
participant ArtifactStore
ReviewText->>GithubDelivery: execute_pending_review_delivery
GithubDelivery->>GitHub: fetch pull-request head
GithubDelivery->>GitHub: create pending review
GithubDelivery->>GitHub: list and reconcile comments
GithubDelivery->>GitHub: revalidate pull-request head
GithubDelivery->>GitHub: submit review
GithubDelivery->>ArtifactStore: persist transaction and receipts
GithubDelivery->>GitHub: delete pending review on failure
Possibly related issues
Possibly related PRs
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 822b8ff57d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let mut transaction = DeliveryTransaction::new(expected_head.clone(), planned.clone())?; | ||
|
|
||
| let pending_payload = serde_json::json!({ | ||
| "event": "PENDING", |
There was a problem hiding this comment.
Omit the event when creating pending reviews
When this runs against real GitHub, the first POST is rejected before any pending review is created: GitHub's Create review docs say event is only APPROVE, REQUEST_CHANGES, or COMMENT, and that a pending review is created by leaving event blank (https://docs.github.com/en/rest/pulls/reviews#create-a-review-for-a-pull-request). With "event": "PENDING", every non-skipped ub-review post path fails at pending-review creation rather than publishing the review.
Useful? React with 👍 / 👎.
| "PUT", | ||
| &format!("{review_url}/{created_review_id}"), |
There was a problem hiding this comment.
Submit pending reviews through the events endpoint
After pending creation succeeds, this sends the submit payload to the Update review endpoint (PUT /reviews/{review_id}), which only updates the review body; GitHub's Submit review endpoint is POST /reviews/{review_id}/events with the event payload (https://docs.github.com/en/rest/pulls/reviews#submit-a-review-for-a-pull-request). In that live path the code can get a successful update response and mark receipts as submitted while the review remains pending and invisible to PR participants.
Useful? React with 👍 / 👎.
|
|
||
| fn write_transaction(out: &Path, transaction: &DeliveryTransaction) -> Result<()> { | ||
| let value = serde_json::to_value(transaction)?; | ||
| write_json(&out.join("review/delivery-transaction.json"), &value) |
There was a problem hiding this comment.
Write delivery receipts beside post-result.json
In the action path I checked, ub-review post is invoked with --out ${{ inputs.out }}/review (action.yml:686-689), while the verifier looks for root/review/delivery-transaction.json (scripts/verify-bun-review-artifacts.py:8444). This extra review/ writes the transaction to target/ub-review/review/review/delivery-transaction.json, so CI/artifact verification returns as if no delivery packet exists; the reconciliation/receipts joins above use the same extra component. Please write these packet artifacts directly under args.out beside post-result.json.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Actionable comments posted: 13
🤖 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 `@scripts/verify-bun-review-artifacts.py`:
- Around line 8437-8443: Split require_delivery_transaction_artifacts into three
named helpers: one for transaction schema and planned-identity validation, one
for reconciliation count and identity validation, and one for per-receipt
validation. Keep require_delivery_transaction_artifacts as the sequencing entry
point, pass the necessary validated state between helpers, and preserve every
existing failure message unchanged.
- Around line 8619-8637: Update the negative test around
require_delivery_transaction_artifacts so that after changing
receipt["confirmed_head_sha"], you rewrite review/delivery-receipts.json with
the mutated receipt before writing reconciliation data and invoking
expect_self_test_failure. This isolates the confirmation-head validation while
keeping standalone receipts and reconciliation receipts consistent.
- Around line 8560-8562: Remove the redundant receipts_path.exists() wrapper
around the comparison in the delivery-receipts verification flow. Keep the
load_json(receipts_path) != receipts parity check and its existing fail call
directly after the earlier absence validation.
In `@src/github_delivery.rs`:
- Around line 166-206: The claim graph is read and parsed twice, with
build_planned_inline_deliveries losing contextual errors. Extract a helper that
computes claim_graph.json’s path, reads it, and parses it with the existing
contextual messages; update read_expected_delivery_head and
build_planned_inline_deliveries to accept and reuse the parsed graph, and adjust
execute_pending_review_delivery to load it once and pass it to both callers.
- Around line 445-450: The failure_stage classification currently relies on
matching external error text, allowing GitHub response messages to misclassify
failures. Replace the substring checks in failure_stage with a typed,
downcastable stage marker attached at each fallible step, including
parse_success_json, and classify transport, code-finding, receipt-persistence,
head-revalidation, and artifact-integrity failures from that marker while
preserving the existing fallback behavior.
- Around line 314-324: Reorder the candidate validation in both the shown
delivery-matching flow and build_planned_inline_deliveries: run
ensure!(candidates.len() == 1) before calling candidates.first(). Keep the
existing empty-candidate error from the first() lookup and all subsequent
delivery handling unchanged.
- Around line 89-101: Remove or rewrite review/delivery-reconciliation.json and
review/delivery-receipts.json in the failure cleanup branch of
src/github_delivery.rs (Lines 142-161) before returning the error; update
scripts/verify-bun-review-artifacts.py (Lines 8494-8501) to require a
success-terminal transaction state whenever delivery-reconciliation.json exists
and reject failed, cleanup_attempted, or cleaned_up states; extend tests/cli.rs
(Lines 5692-5699) in post_failure_attempts_cleanup_and_receipts_cleanup_success
to assert both artifacts are absent after cleanup.
- Around line 509-528: Add a negative case to
returned_comment_wrong_body_or_head_is_rejected that removes commit_id from the
returned exact-body comment, then assert observed_deliveries returns an error
for that response, preserving the existing wrong-body and wrong-head checks.
- Around line 308-313: Update the head-binding validation in the delivery
reconciliation flow to require a valid string commit_id before accepting the
comment. Treat a missing or non-string commit_id as an error, and continue
rejecting present values that differ from exact_head_sha; only matching commit
IDs may proceed as confirmed deliveries.
- Around line 143-152: Guard the cleanup block around review_id and
delete_pending_review with the transaction state, invoking deletion only when
the review remains pending. Preserve CleanupOutcome::NotAttempted for submitted
or otherwise non-pending states, and keep the existing success and failure
handling for an attempted deletion unchanged.
- Around line 154-160: Update the failure-handling path in the delivery flow
around transaction.record_failure, transaction.finish_cleanup, and
write_transaction so bookkeeping errors are captured as context while the
original transport or reconciliation error remains the returned error. Avoid
propagating these bookkeeping failures with ?, including failures from cleanup
and transaction writing; preserve the existing review_id branching and add the
bookkeeping details to the original error before returning it.
In `@tests/cli.rs`:
- Line 5717: Update the test using run_expect_failure to retain its combined
output in a non-ignored variable and assert it contains "pending-review delivery
transaction", matching the sibling test’s stderr assertion and detecting cleanup
errors that mask the transport failure.
In `@tests/common/mod.rs`:
- Around line 322-330: Update the DELETE review success branch in the request
handler to match the intended HTTP contract: either return 200 with a
deleted-review JSON object, or retain 204 while suppressing both the response
body and Content-Length header in the response-building logic around lines
337-343. Ensure the selected behavior is consistent across the status, headers,
and payload.
🪄 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: 68e4a95b-0309-4d22-8d10-9b52a1f770f8
📒 Files selected for processing (7)
scripts/verify-bun-review-artifacts.pysrc/delivery_transaction.rssrc/github_delivery.rssrc/main.rssrc/review_text.rstests/cli.rstests/common/mod.rs
| def require_delivery_transaction_artifacts(root: pathlib.Path) -> None: | ||
| """Validate the optional #827 producer/transport receipt packet. | ||
|
|
||
| Review runs that do not post have no delivery transaction files. When the | ||
| posting command emits them, this mirror checks the durable identity and | ||
| exact-set contract without attempting to reproduce Rust reconciliation. | ||
| """ |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win
Split this validator into named helpers.
Ruff reports 34 branches and 82 statements against the limits of 12 and 50. The function performs three separable jobs: transaction schema and planned-identity validation, reconciliation count and identity validation, and per-receipt validation. Extract one helper per job and keep require_delivery_transaction_artifacts as the sequencer. The individual failure messages stay unchanged.
🧰 Tools
🪛 Ruff (0.16.1)
[warning] 8437-8437: Too many branches (34 > 12)
(PLR0912)
[warning] 8437-8437: Too many statements (82 > 50)
(PLR0915)
🤖 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 `@scripts/verify-bun-review-artifacts.py` around lines 8437 - 8443, Split
require_delivery_transaction_artifacts into three named helpers: one for
transaction schema and planned-identity validation, one for reconciliation count
and identity validation, and one for per-receipt validation. Keep
require_delivery_transaction_artifacts as the sequencing entry point, pass the
necessary validated state between helpers, and preserve every existing failure
message unchanged.
Source: Linters/SAST tools
| let text = format!("{error:#}").to_ascii_lowercase(); | ||
| if text.contains("receipt") { | ||
| DeliveryFailureStage::ReceiptPersistence | ||
| } else if text.contains("head changed") { | ||
| DeliveryFailureStage::HeadRevalidation | ||
| } else { |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Stage classification depends on external error text.
failure_stage lowercases the whole error chain and matches the substrings receipt and head changed. parse_success_json interpolates the GitHub response stderr into that chain, so a remote message that contains either substring changes the recorded failure.stage. Issue #827 requires transport failures, code findings, and artifact-integrity failures to stay distinguishable, and this classifier cannot hold that line.
Attach a typed stage marker to each fallible step, for example a small error enum or anyhow context carried as a downcastable type, and classify on that marker instead of on the message text.
🤖 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/github_delivery.rs` around lines 445 - 450, The failure_stage
classification currently relies on matching external error text, allowing GitHub
response messages to misclassify failures. Replace the substring checks in
failure_stage with a typed, downcastable stage marker attached at each fallible
step, including parse_success_json, and classify transport, code-finding,
receipt-persistence, head-revalidation, and artifact-integrity failures from
that marker while preserving the existing fallback behavior.
| } else if request_line.starts_with("DELETE ") && request_line.contains("/reviews/987 ") { | ||
| if cleanup_success { | ||
| ("HTTP/1.1 204 No Content", serde_json::json!({})) | ||
| } else { | ||
| ( | ||
| "HTTP/1.1 500 Internal Server Error", | ||
| serde_json::json!({"message": "cleanup failed"}), | ||
| ) | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
The 204 cleanup response carries a body.
The success branch returns HTTP/1.1 204 No Content, and Lines 337-343 then send Content-Length: 2 and the body {}. A 204 response must not include a message body. The real GitHub DELETE /pulls/{n}/reviews/{id} returns 200 with the deleted review object, so the fixture is also not faithful. Return 200 with a review object, or suppress the body and the Content-Length header for 204.
🤖 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 `@tests/common/mod.rs` around lines 322 - 330, Update the DELETE review success
branch in the request handler to match the intended HTTP contract: either return
200 with a deleted-review JSON object, or retain 204 while suppressing both the
response body and Content-Length header in the response-building logic around
lines 337-343. Ensure the selected behavior is consistent across the status,
headers, and payload.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Actionable comments posted: 4
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
scripts/verify-bun-review-artifacts.py (1)
8620-8639: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick winAdd a self-test for the new
receipts_persistedrequirement.Line 8623 now rewrites the standalone receipts, so the negative case pins exactly one rule. Good.
No self-test covers the rule added at Lines 8502-8503, and none covers the failure-terminal branch at Lines 8494-8501. Those two rules carry the property that a rolled-back delivery must not leave confirmed receipts on disk. A regression there would pass the suite.
💚 Proposed test addition
# A reconciliation beside a non-terminal transaction must fail. write_self_test_json( root / "review/delivery-transaction.json", { "schema": "ub-review.delivery_transaction.v1", "exact_head_sha": head, "planned": [], "state": "cleaned_up", "failure": {"stage": "submission", "reason": "submit rejected"}, "cleanup": {"status": "succeeded"}, }, ) expect_self_test_failure( "delivery reconciliation beside a cleaned-up transaction", "requires a receipts_persisted transaction", lambda: require_delivery_transaction_artifacts(root), )🤖 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 `@scripts/verify-bun-review-artifacts.py` around lines 8620 - 8639, Extend the self-test around require_delivery_transaction_artifacts with a cleaned_up transaction containing failure and successful cleanup metadata, while keeping the existing reconciliation and receipts fixtures. Assert that this non-terminal transaction fails with the “requires a receipts_persisted transaction” message, covering both the receipts_persisted requirement and the failure-terminal path..ripr/suppressions.toml (1)
14802-15891: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse test-scoped reasons for the PR
#827exposure suppressions.The new entries apply one boilerplate RIPR false-positive reason across many distinct probes in
github_delivery.rs,review_text.rs, andcommon/mod.rs. Use the exercise coverage contract, and where practical name the test/fixture scenario that covers each specific suppressed probe. This keeps the suppression ledger auditable for the fail-closed delivery paths.🤖 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 @.ripr/suppressions.toml around lines 14802 - 15891, Replace the shared boilerplate reason across the PR `#827` exposure suppressions with test-scoped explanations tied to each suppressed probe. Use the exercise coverage contract and, where available, identify the specific test or fixture scenario covering the relevant behavior in github_delivery.rs, review_text.rs, or common/mod.rs; preserve the existing suppression entries and metadata.
🤖 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/delivery_transaction.rs`:
- Around line 480-499: Update record_post_submission_failure to validate the
Submitted or ReceiptsPersisted to Failed transition through legal_transition
before mutating self.state, matching record_failure and finish_cleanup. Preserve
the existing failure-reason validation and state updates, and return the
transition error when the matrix rejects the transition.
In `@src/github_delivery.rs`:
- Around line 325-337: Update the claim-plan validation in the inline delivery
flow to distinguish zero, one, and multiple entries: report the existing “no
current-head inline claim plan” message when matches is empty, retain normal
processing for exactly one match, and report the “ambiguous claim plan” message
only when multiple matches exist. Strengthen
planned_inline_delivery_rejects_missing_stale_and_ambiguous_plans to assert the
specific error wording for each case.
- Around line 784-790: Update command_status to avoid hard-coding the
Windows-only cmd executable: use cmd /c on Windows and sh -c on other platforms,
or construct the equivalent ExitStatus directly. Apply the same portability fix
to the inline cmd fixtures in response_parsing_and_identifiers_fail_closed,
preserving the existing success and failure statuses.
In `@tests/common/mod.rs`:
- Around line 337-348: Update the response-writing flow so the 204 No Content
branch does not call stream.write_all(&response_body). Continue writing
response_body only for non-204 responses, while preserving the existing 204
headers and connection behavior.
---
Outside diff comments:
In @.ripr/suppressions.toml:
- Around line 14802-15891: Replace the shared boilerplate reason across the PR
`#827` exposure suppressions with test-scoped explanations tied to each suppressed
probe. Use the exercise coverage contract and, where available, identify the
specific test or fixture scenario covering the relevant behavior in
github_delivery.rs, review_text.rs, or common/mod.rs; preserve the existing
suppression entries and metadata.
In `@scripts/verify-bun-review-artifacts.py`:
- Around line 8620-8639: Extend the self-test around
require_delivery_transaction_artifacts with a cleaned_up transaction containing
failure and successful cleanup metadata, while keeping the existing
reconciliation and receipts fixtures. Assert that this non-terminal transaction
fails with the “requires a receipts_persisted transaction” message, covering
both the receipts_persisted requirement and the failure-terminal path.
🪄 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: d85adf2d-9fd2-4bba-b7be-467c46a89d9f
📒 Files selected for processing (6)
.ripr/suppressions.tomlscripts/verify-bun-review-artifacts.pysrc/delivery_transaction.rssrc/github_delivery.rstests/cli.rstests/common/mod.rs
| pub fn record_post_submission_failure( | ||
| &mut self, | ||
| stage: DeliveryFailureStage, | ||
| reason: impl Into<String>, | ||
| ) -> Result<()> { | ||
| ensure!( | ||
| matches!( | ||
| self.state, | ||
| DeliveryTransactionState::Submitted | DeliveryTransactionState::ReceiptsPersisted | ||
| ), | ||
| "post-submission failure requires a submitted transaction, current state: {:?}", | ||
| self.state | ||
| ); | ||
| let reason = reason.into(); | ||
| validate_identifier(&reason, "failure reason")?; | ||
| self.failure = Some(DeliveryFailure { stage, reason }); | ||
| self.cleanup = CleanupOutcome::NotAttempted; | ||
| self.state = DeliveryTransactionState::Failed; | ||
| Ok(()) | ||
| } |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win
Route the terminal transition through legal_transition.
record_failure at Lines 442-447 and finish_cleanup at Lines 469-474 both check legal_transition before they mutate self.state. record_post_submission_failure sets self.state = Failed directly. The new matrix entries at Lines 877-882 exist but no code path reads them, so the two sources of truth can drift when a future state is added.
♻️ Proposed change
let reason = reason.into();
validate_identifier(&reason, "failure reason")?;
+ ensure!(
+ legal_transition(&self.state, &DeliveryTransactionState::Failed),
+ "illegal delivery transaction failure transition: {:?} -> {:?}",
+ self.state,
+ DeliveryTransactionState::Failed
+ );
self.failure = Some(DeliveryFailure { stage, reason });📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub fn record_post_submission_failure( | |
| &mut self, | |
| stage: DeliveryFailureStage, | |
| reason: impl Into<String>, | |
| ) -> Result<()> { | |
| ensure!( | |
| matches!( | |
| self.state, | |
| DeliveryTransactionState::Submitted | DeliveryTransactionState::ReceiptsPersisted | |
| ), | |
| "post-submission failure requires a submitted transaction, current state: {:?}", | |
| self.state | |
| ); | |
| let reason = reason.into(); | |
| validate_identifier(&reason, "failure reason")?; | |
| self.failure = Some(DeliveryFailure { stage, reason }); | |
| self.cleanup = CleanupOutcome::NotAttempted; | |
| self.state = DeliveryTransactionState::Failed; | |
| Ok(()) | |
| } | |
| pub fn record_post_submission_failure( | |
| &mut self, | |
| stage: DeliveryFailureStage, | |
| reason: impl Into<String>, | |
| ) -> Result<()> { | |
| ensure!( | |
| matches!( | |
| self.state, | |
| DeliveryTransactionState::Submitted | DeliveryTransactionState::ReceiptsPersisted | |
| ), | |
| "post-submission failure requires a submitted transaction, current state: {:?}", | |
| self.state | |
| ); | |
| let reason = reason.into(); | |
| validate_identifier(&reason, "failure reason")?; | |
| ensure!( | |
| legal_transition(&self.state, &DeliveryTransactionState::Failed), | |
| "illegal delivery transaction failure transition: {:?} -> {:?}", | |
| self.state, | |
| DeliveryTransactionState::Failed | |
| ); | |
| self.failure = Some(DeliveryFailure { stage, reason }); | |
| self.cleanup = CleanupOutcome::NotAttempted; | |
| self.state = DeliveryTransactionState::Failed; | |
| Ok(()) | |
| } |
🤖 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/delivery_transaction.rs` around lines 480 - 499, Update
record_post_submission_failure to validate the Submitted or ReceiptsPersisted to
Failed transition through legal_transition before mutating self.state, matching
record_failure and finish_cleanup. Preserve the existing failure-reason
validation and state updates, and return the transition error when the matrix
rejects the transition.
| ensure!( | ||
| matches.len() == 1, | ||
| "inline comment {}:{} has ambiguous claim plan", | ||
| path, | ||
| comment.line | ||
| ); | ||
| let topic = matches.first().ok_or_else(|| { | ||
| anyhow::anyhow!( | ||
| "inline comment {}:{} has no current-head inline claim plan", | ||
| path, | ||
| comment.line | ||
| ) | ||
| })?; |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
A missing claim plan now reports "ambiguous".
The ensure! at Lines 325-330 fires for every count that is not 1, including 0. A review comment with no current-head inline claim plan therefore reports "has ambiguous claim plan". The distinct message at Lines 332-336 became unreachable, because matches.first() on a length-1 vector always returns Some. Missing and stale plans are the common causes, so the operator sees the wrong diagnosis.
planned_inline_delivery_rejects_missing_stale_and_ambiguous_plans at Lines 961-987 only asserts is_err(), so it does not detect the swapped wording.
🐛 Proposed fix
+ ensure!(
+ !matches.is_empty(),
+ "inline comment {}:{} has no current-head inline claim plan",
+ path,
+ comment.line
+ );
ensure!(
matches.len() == 1,
"inline comment {}:{} has ambiguous claim plan",
path,
comment.line
);
- let topic = matches.first().ok_or_else(|| {
- anyhow::anyhow!(
- "inline comment {}:{} has no current-head inline claim plan",
- path,
- comment.line
- )
- })?;
+ let topic = matches
+ .first()
+ .ok_or_else(|| anyhow::anyhow!("inline claim plan selection is empty"))?;📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| ensure!( | |
| matches.len() == 1, | |
| "inline comment {}:{} has ambiguous claim plan", | |
| path, | |
| comment.line | |
| ); | |
| let topic = matches.first().ok_or_else(|| { | |
| anyhow::anyhow!( | |
| "inline comment {}:{} has no current-head inline claim plan", | |
| path, | |
| comment.line | |
| ) | |
| })?; | |
| ensure!( | |
| !matches.is_empty(), | |
| "inline comment {}:{} has no current-head inline claim plan", | |
| path, | |
| comment.line | |
| ); | |
| ensure!( | |
| matches.len() == 1, | |
| "inline comment {}:{} has ambiguous claim plan", | |
| path, | |
| comment.line | |
| ); | |
| let topic = matches | |
| .first() | |
| .ok_or_else(|| anyhow::anyhow!("inline claim plan selection is empty"))?; |
🤖 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/github_delivery.rs` around lines 325 - 337, Update the claim-plan
validation in the inline delivery flow to distinguish zero, one, and multiple
entries: report the existing “no current-head inline claim plan” message when
matches is empty, retain normal processing for exactly one match, and report the
“ambiguous claim plan” message only when multiple matches exist. Strengthen
planned_inline_delivery_rejects_missing_stale_and_ambiguous_plans to assert the
specific error wording for each case.
| let response_body = serde_json::to_vec(&response)?; | ||
| if status == "HTTP/1.1 204 No Content" { | ||
| write!(stream, "{status}\r\nConnection: close\r\n\r\n")?; | ||
| } else { | ||
| write!( | ||
| stream, | ||
| "{status}\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n", | ||
| response_body.len() | ||
| )?; | ||
| } | ||
| stream.write_all(&response_body)?; | ||
| Ok(request_text) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
The 204 branch still writes two body bytes.
Lines 338-339 correctly omit Content-Type and Content-Length for HTTP/1.1 204 No Content. Line 347 then runs for every branch and writes response_body. For the cleanup-success case response is serde_json::json!({}), so the fixture emits the two octets {} after the header terminator.
A 204 response has no message body and a zero content length. Those two octets are therefore unframed. curl reads zero body bytes and closes on Connection: close, so post_failure_attempts_cleanup_and_receipts_cleanup_success still passes. The fixture is still wrong, and the earlier fix to suppress the 204 body is incomplete.
🐛 Proposed fix
let response_body = serde_json::to_vec(&response)?;
if status == "HTTP/1.1 204 No Content" {
write!(stream, "{status}\r\nConnection: close\r\n\r\n")?;
- } else {
- write!(
- stream,
- "{status}\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
- response_body.len()
- )?;
- }
- stream.write_all(&response_body)?;
+ return Ok(request_text);
+ }
+ write!(
+ stream,
+ "{status}\r\nContent-Type: application/json\r\nContent-Length: {}\r\nConnection: close\r\n\r\n",
+ response_body.len()
+ )?;
+ stream.write_all(&response_body)?;
Ok(request_text)🤖 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 `@tests/common/mod.rs` around lines 337 - 348, Update the response-writing flow
so the 204 No Content branch does not call stream.write_all(&response_body).
Continue writing response_body only for non-204 responses, while preserving the
existing 204 headers and connection behavior.
Scope
Implement issue #827: a production pending-review transaction for grouped inline delivery.
The transaction fetches the exact current head, creates a pending review without submitting it, creates and lists comments, reconciles returned comments against planned claim/path/line/side/body/head identities, revalidates the head, submits the review, and persists validated transaction, reconciliation, and receipt artifacts. Failures after pending-review creation attempt deletion and receipt cleanup; submitted reviews are never deleted. Unconfirmed delivery does not suppress a finding.
The transport seam exists only for deterministic production-path tests. Reply delivery, retries, confirmed/unconfirmed body fallback, proof execution, and analyzer changes remain out of scope (#828, #829/#830, and #803).
Proof
Passed locally in isolated
CARGO_TARGET_DIR=target/issue827-proof:github_deliverytests;ub-reviewbinary tests;-D warnings;cargo xtask policy-check;git diff --check.Hosted run
30960210780passed at exact head5254115287b57ccb85e47116529bf03abbbb9fb0: gate outcomepass, artifact verifier passed, and hosted RIPR reportednew_unsuppressed=0with284exact hosted-form suppression receipts. The run also covered the Linux fixture portability repair and the verifier-safe redacted-token fixture contract.The isolated workspace-wide all-targets command previously timed out without diagnostics and remains unverified. No threshold change, broad file/function suppression, required-check mutation, or policy relaxation was added.
Claim boundary
Local tests prove the transaction state machine, adapter behavior, artifact contract, and fake-transport success/failure paths. The exact-form RIPR replay proves the current strict-zero receipt set for this diff form. The hosted run proves the generated packet passes the repository gate and artifact verifier. These checks do not prove reply idempotence or summary fallback; those remain #828.
Follow-up
After this merges, #828 owns replies, retry idempotence, and confirmed-delivery-aware fallback. #829/#830 own public-item admission and evidence-value degradation.