Skip to content

Implement deferred manual settlement requests - #110

Merged
thomhurst merged 2 commits into
mainfrom
issue-10-manual-settlement
Nov 1, 2026
Merged

thomhurst merged 2 commits into
mainfrom
issue-10-manual-settlement

Conversation

@thomhurst

@thomhurst thomhurst commented Nov 1, 2026 •

Copy link
Copy Markdown
Owner

Handlers can now request Complete(), Retry(delay), or DeadLetter(reason) through context.Features.GetRequired<ISettlementFeature>(). The pooled feature queues one outcome per attempt and applies it only after successful handling and scope disposal. Exceptions override requests; cancellation, disposal, send-flush, and fallback errors prevent successful settlement.

Manual retries use the exact requested delay and the existing native redelivery / scheduled-copy / durable-scheduler capability order. Completion flushes buffered direct sends; retry and dead-letter requests discard them. Batch handlers resolve requests per item, and mixed completing/non-completing outcomes with shared buffered sends fail explicitly because those sends cannot be attributed safely. Native operations remain transport-owned.

The PR records precedence in D11, updates the documentation site and implementation status, and covers pool reuse, concurrency, failure history, telemetry, native in-memory settlement, and batch outcomes. Rebased onto the newly merged batch implementation in #99.

Validation:

  • Release build: zero warnings and errors.
  • Full Release suite: 551 passed, zero failed or skipped.
  • Windows x64 Native AOT publish and smoke executable passed, including manual completion.
  • npm ci and npm run build passed. The unchanged 27 dependency audit findings are already tracked by Address documentation dependency audit vulnerabilities #101.
  • BenchmarkDotNet: all 18 batch dry-run cases passed. Four single-message ShortRun cases compare automatic and manual completion, with and without a buffered send. All report the same 432 B from the existing scoped DI work; manual completion adds 0 B. Timing is diagnostic only and does not establish the native-client throughput budget.

Per-message cost: one pooled feature registration and optional-request checks on the common path; no additional steady-state allocations. Retry/dead-letter metadata and durable copies run only when requested.

Evidence for head 688dcadf53bb778819c0bbb0d53bf6eeeb50d317: C:/git/Relayer-evidence/pr-110/688dcadf53bb778819c0bbb0d53bf6eeeb50d317/. The archive contains raw logs and reports, benchmark inputs/generated files and binaries, test binaries, the Native AOT executable, a source snapshot, and inventory.json with SHA-256 hashes. All 864 files were verified when copied. Local evidence follows the repository's seven-inactive-day retention policy.

Closes #10

@coderabbitai

coderabbitai Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f2badbcc-f349-4ded-9381-95fcf9bf1103
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@github-actions

github-actions Bot commented Nov 1, 2026

Copy link
Copy Markdown

Review of #110: deferred manual settlement requests

I read the source diff in src/Relayer, the benchmarks, docs and the tests. I did not build or run the tests.

Correctness. Precedence holds on every path I traced:

  • A handler or middleware exception clears the request (Settlement.Clear()) before the failure policy runs.
  • Scope-disposal, cancellation, flush and fallback errors propagate before any request is applied.
  • Retry and DeadLetter clear the send buffer. Complete flushes first and applies only afterwards.
  • In batches, redirected items are counted separately from failed ones. Mixed redirected and completing items with shared buffered sends fail the whole attempt explicitly rather than guessing attribution.
  • Disposition.Redeliver already rejects negative delays, and ResolveRedelivery guards against DateTimeOffset overflow.
  • CopyAsync now drops any prior header whose key a replacement header carries. This also covers the new DeadLetterReason.
  • Only one request is allowed per attempt, and it is rejected outside the handling window via CanRequestSettlement.

Performance. The per-message cost is one Features.Set (a linear scan over a few entries, 0 B) and one null check on Request. PendingSettlement is allocated once per pooled context. The list and array allocations in SettlementHeaders occur only on a manual retry or dead-letter. The new benchmarks cover the Complete path. This is acceptable under D18.

Docs and tests. D11, design.md, the failure-handling guide, the roadmap and the home page status are updated together. Tests cover precedence, batch per-item outcomes, retry-clearing and buffered-send discard.

Non-blocking notes

  1. When a consumer has no FailurePipeline, ConsumePipeline.ValidateSettlement is a no-op. Retry(delay) is then accepted and passed to the adapter as a bare Disposition.Redeliver with no headers. This contradicts D11's "unsupported runtime delays fail at the request call". Either say in D11 and the guide that this validation needs the failure pipeline, or add a capability check for this path.
  2. ApplyFailureDisposition is a silent no-op when _receive is null. That is fine for direct contexts, but a test pinning the behaviour would protect it.

No actionable issues found.

@thomhurst

Copy link
Copy Markdown
Owner Author

Claude review #110 (comment) is CLEAR for 688dcad. Disposition of its non-blocking notes:

  1. Capability validation: the manual-settlement guide already scopes runtime capability resolution to the executable FailurePipeline and explicitly states that the lower-level ConsumeFailureDelegate composer owns capability validation, durability, and fallbacks. Keeping the low-level native path is deliberate, including for the in-memory hosted consumer; no extra capability abstraction or review-only push is needed.
  2. Direct contexts: ApplyFailureDisposition's no-receive behavior is unchanged. Direct-context composition has no native disposition target, and the new manual-completion benchmark exercises that path. The suggested additional test is non-blocking coverage for that existing contract; no code change.

@thomhurst

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T14:31:18.703292Z 688dcad Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 688dcadf53

ℹ️ 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".

@thomhurst

Copy link
Copy Markdown
Owner Author

Both required reviewers have positive verdicts for head 688dcad. All review surfaces were re-read; there are no inline findings, unresolved threads, or outstanding review-body findings. Claude's non-blocking notes have already been dispositioned above.

Before promotion, I reverified the complete archive inventory and all 864 SHA-256 hashes against the retained originals, including a fresh Git archive of the measured commit. Evidence remains at C:/git/Relayer-evidence/pr-110/688dcadf53bb778819c0bbb0d53bf6eeeb50d317/; verification is recorded in C:/git/Relayer-evidence/pr-110/promotion-evidence-verification.log. The existing seven-inactive-day retention policy applies.

@thomhurst
thomhurst marked this pull request as ready for review November 1, 2026 14:29
@thomhurst
thomhurst enabled auto-merge (squash) November 1, 2026 14:29
@thomhurst
thomhurst merged commit 5064264 into main Nov 1, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Manual settlement through ISettlementFeature

1 participant