Skip to content

fix(post): execute pending-review inline delivery transaction - #831

Merged
EffortlessSteven merged 7 commits into
mainfrom
codex/issue827-pending-review
Aug 4, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
codex/issue827-pending-review

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

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:

  • 13 github_delivery tests;
  • post-submission terminal-state regression test;
  • 751 ub-review binary tests;
  • 8 CLI posting tests;
  • Clippy with -D warnings;
  • workspace docs;
  • cargo xtask policy-check;
  • artifact verifier self-test, including cleaned-up-transaction rejection;
  • git diff --check.

Hosted run 30960210780 passed at exact head 5254115287b57ccb85e47116529bf03abbbb9fb0: gate outcome pass, artifact verifier passed, and hosted RIPR reported new_unsuppressed=0 with 284 exact 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.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Summary by CodeRabbit

  • New Features

    • Added bounded GitHub pull-request review delivery with inline comments and suggestions.
    • Reviews verify the pull-request head and planned comments before submission.
    • Delivery records include transaction status, receipts, and cleanup results when submission fails.
  • Bug Fixes

    • Improved handling of mismatched, missing, duplicate, or unexpected review comments.
    • Failed submissions now attempt cleanup and report whether cleanup succeeded.
    • Added validation for delivery records and receipt consistency.
  • Tests

    • Expanded coverage for successful deliveries, validation failures, submission errors, and artifact verification.

Walkthrough

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

Changes

GitHub delivery transaction

Layer / File(s) Summary
Delivery transaction contract
src/delivery_transaction.rs
The transaction exposes planned identities and lifecycle state. It records post-submission failures and validates terminal transitions.
GitHub delivery adapter
src/github_delivery.rs, src/main.rs, src/review_text.rs
The adapter creates pending reviews, reconciles returned comments, rechecks the pull-request head, submits valid reviews, persists receipts, and cleans up on failure.
Verification and workflow coverage
scripts/verify-bun-review-artifacts.py, tests/cli.rs, tests/common/mod.rs, .ripr/suppressions.toml
The verifier checks delivery artifacts and secret markers. Tests cover successful delivery, reconciliation failures, submission failures, and cleanup outcomes. Suppressions document the related transport probes.

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
Loading

Possibly related issues

  • Issue 827 — Directly covers the pending-review delivery lifecycle implemented here.
  • Issue 765 — Defines the broader transactional inline-review delivery flow.
  • Issue 828 — Depends on this transaction substrate for reply delivery and retry behavior.

Possibly related PRs

Suggested labels: enhancement, codex

Poem

A rabbit checks each review claim,
Then binds the head before the name.
Comments match, and receipts stay,
Pending work submits the safe way.
If failure comes, cleanup runs.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR adds 1,090 RIPR suppressions, although #827 forbids broad suppressions and the description states that none were added. Remove the unrelated suppressions or provide narrow, issue-linked justification for each one, then correct the Policy receipts section.
Description check ⚠️ Warning The description explains scope and verification well but omits the required Policy receipts and CI budget sections. Add the template sections for Policy receipts and CI budget, including the .ripr suppression receipt and the planned CI cost band.
✅ Passed checks (3 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation covers the #827 pending-review lifecycle, exact reconciliation, head revalidation, artifact persistence, cleanup, and failure handling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly identifies the main change: executing pending-review inline delivery transactions for post.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/issue827-pending-review

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot added codex enhancement New feature or request labels Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/github_delivery.rs Outdated
let mut transaction = DeliveryTransaction::new(expected_head.clone(), planned.clone())?;

let pending_payload = serde_json::json!({
"event": "PENDING",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread src/github_delivery.rs Outdated
Comment on lines +119 to +120
"PUT",
&format!("{review_url}/{created_review_id}"),

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread src/github_delivery.rs Outdated

fn write_transaction(out: &Path, transaction: &DeliveryTransaction) -> Result<()> {
let value = serde_json::to_value(transaction)?;
write_json(&out.join("review/delivery-transaction.json"), &value)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@coderabbitai coderabbitai 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.

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

📥 Commits

Reviewing files that changed from the base of the PR and between bf15a07 and 822b8ff.

📒 Files selected for processing (7)
  • scripts/verify-bun-review-artifacts.py
  • src/delivery_transaction.rs
  • src/github_delivery.rs
  • src/main.rs
  • src/review_text.rs
  • tests/cli.rs
  • tests/common/mod.rs

Comment on lines +8437 to +8443
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.
"""

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.

📐 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

Comment thread scripts/verify-bun-review-artifacts.py Resolved
Comment thread scripts/verify-bun-review-artifacts.py Resolved
Comment thread src/github_delivery.rs Resolved
Comment thread src/github_delivery.rs Resolved
Comment thread src/github_delivery.rs Resolved
Comment thread src/github_delivery.rs Outdated
Comment on lines +445 to +450
let text = format!("{error:#}").to_ascii_lowercase();
if text.contains("receipt") {
DeliveryFailureStage::ReceiptPersistence
} else if text.contains("head changed") {
DeliveryFailureStage::HeadRevalidation
} else {

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.

🗄️ 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.

Comment thread src/github_delivery.rs Resolved
Comment thread tests/cli.rs Resolved
Comment thread tests/common/mod.rs
Comment on lines +322 to +330
} 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"}),
)
}

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.

🎯 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

codecov Bot commented Aug 4, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.60000% with 34 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/github_delivery.rs 96.46% 33 Missing ⚠️
src/delivery_transaction.rs 98.36% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai 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.

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 win

Add a self-test for the new receipts_persisted requirement.

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 value

Use test-scoped reasons for the PR #827 exposure suppressions.

The new entries apply one boilerplate RIPR false-positive reason across many distinct probes in github_delivery.rs, review_text.rs, and common/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

📥 Commits

Reviewing files that changed from the base of the PR and between 822b8ff and 7d01c1a.

📒 Files selected for processing (6)
  • .ripr/suppressions.toml
  • scripts/verify-bun-review-artifacts.py
  • src/delivery_transaction.rs
  • src/github_delivery.rs
  • tests/cli.rs
  • tests/common/mod.rs

Comment on lines +480 to +499
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(())
}

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.

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

Suggested change
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.

Comment thread src/github_delivery.rs
Comment on lines +325 to +337
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
)
})?;

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.

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

Suggested change
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.

Comment thread src/github_delivery.rs Resolved
Comment thread tests/common/mod.rs
Comment on lines +337 to 348
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)

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.

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

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

Labels

codex enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant