Skip to content

fix(reply): report settled delivery outcomes once - #124773

Merged
steipete merged 22 commits into
mainfrom
steipete/settled-dispatch-receipt
Aug 17, 2026
Merged

steipete merged 22 commits into
mainfrom
steipete/settled-dispatch-receipt

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where reply delivery visibility was inferred from queued admissions and then repaired in several downstream layers. Cancelled, explicitly non-visible, pre-send failed, and ambiguous post-send outcomes could therefore be collapsed or reconstructed inconsistently.

Why This Change Was Made

The reply dispatcher now publishes one settled receipt after its delivery chain drains. Each reply kind records delivered, deliveredNotVisible, cancelled, failedBeforeSend, and failedAfterSend, plus the terminal anyVisibleDelivered fact. Channel turns and fallback decisions consume that receipt directly; the old subtraction and multi-signal count reconstruction paths are removed.

The deprecated inbound-reply-dispatch Plugin SDK shim retains its existing count-shaped contract by deriving legacy fields from the receipt at that compatibility boundary only.

User Impact

Reply visibility, no-visible-reply fallback behavior, status reactions, and delivery logs now use transport settlement facts instead of queue admission guesses. Explicitly non-visible sends no longer need lifecycle subtraction, while post-send ambiguity remains conservatively distinguishable from failures proven to occur before I/O.

Evidence

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: msteams Channel integration: msteams channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: zalo Channel integration: zalo gateway Gateway runtime agents Agent runtime and tooling channel: feishu Channel integration: feishu size: L maintainer Maintainer-authored PR labels Aug 16, 2026
@steipete
steipete marked this pull request as ready for review August 16, 2026 19:25
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: found issues before merge. Reviewed August 17, 2026, 9:26 AM ET / 13:26 UTC.

ClawSweeper review

What this changes

The PR makes settled receipts canonical for reply delivery while also changing configuration health reporting and several migration/session utilities.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 4 items remain

Keep open: the latest head fixes the earlier admission-counter concern, but it also introduces a P1 remote-configuration health-reporting regression outside the stated reply-delivery work.

Priority: P1
Reviewed head: d10dacd8105412116ae37e302395f60f3642fde0
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The reply compatibility repair has targeted source and test coverage, but a P1 configuration regression and mixed scope prevent merge readiness.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR is not subject to the external-contributor real-behavior-proof gate; its supplied focused Testbox evidence remains useful supplemental validation.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR is not subject to the external-contributor real-behavior-proof gate; its supplied focused Testbox evidence remains useful supplemental validation.
Evidence reviewed 7 items Settled receipt owner: The dispatcher waits for queued work, records distinct settled outcomes, and publishes a receipt while preserving the admission-time counter API.
Prior counter blocker addressed: The current compatibility test asserts queued counts remain 1 before and after delivery settlement while cancelled and post-send failure facts remain in the receipt.
SDK compatibility boundary: The deprecated inbound-reply shim converts settled receipt outcomes back to legacy delivered and failure counts at its compatibility boundary.
Findings 1 actionable finding [P1] Preserve failed health-check reporting
Security None None.

How this fits together

Reply dispatch queues agent output through channel transports, then reports settled visibility and failure facts to channel fallbacks, reactions, logs, and compatibility consumers. Separately, the configuration wizard probes a gateway and tells an operator whether its health check completed.

flowchart LR
  A[Agent reply payload] --> B[Reply dispatcher]
  B --> C[Channel transport]
  C --> D[Settled delivery receipt]
  D --> E[Fallbacks and channel status]
  D --> F[Legacy SDK projection]
  G[Configure remote gateway] --> H[Reachability and health result]
  H --> I[Operator-facing setup status]
Loading

Decision needed

Question Recommendation
Should the unrelated configuration, migration, and session changes remain in this reply-delivery PR after the health-reporting regression is fixed? Split to focused changes: Keep the settled-receipt repair here and move unrelated configuration and migration work to separately reviewed PRs.

Why: Those changes alter setup and migration behavior outside the stated delivery invariant, so only maintainers can decide whether they share one merge and release-risk boundary.

Before merge

  • Preserve failed health-check reporting (P1) - waitForGatewayReachable resolves { ok: false } on deadline, but this call discards that result. The subsequent health-command error is caught and the function still returns true, so the caller reports “health check completed” for an unreachable or failed remote gateway; the focused failed-health test was removed in this patch. Preserve the failed outcome (or throw on !ok) and restore that regression coverage.
  • Resolve merge risk (P1) - The branch mixes reply-delivery work with configuration-wizard and migration changes; its classified production delta is positive despite being a bug-fix PR.
  • Resolve merge risk (P1) - The local checkout could not retrieve current main, so the broader receipt refactor still needs an exact-head, main-aware maintainer review after CI completes.

Findings

  • [P1] Preserve failed health-check reporting — src/commands/configure.wizard.ts:167-172
Agent review details

Security

None.

PR surface

Source +295, Tests +376. Total +671 across 71 files.

View PR surface stats
Area Files Added Removed Net
Source 42 934 639 +295
Tests 29 739 363 +376
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 71 1673 1002 +671

Review metrics

Metric Value Why it matters
Production versus test delta production +69 after excluding a 28/27 type-only move; tests/test support +446 The bug-fix branch has net production growth and includes setup and migration behavior beyond the stated delivery repair.

Stored data model

Persistent data-model change detected: serialized state: src/config/sessions/session-prompt-types.ts, serialized state: src/config/sessions/types.ts, unknown-data-model-change: src/config/sessions/types.ts, vector/embedding metadata: src/auto-reply/reply/dispatch-from-config.transcript.ts. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Merge-risk options

Maintainer options:

  1. Repair the health outcome and split scope (recommended)
    Restore failure reporting when the gateway probe or health command fails, reinstate focused coverage, and isolate unrelated setup and migration changes before merge.
  2. Accept a combined compatibility review
    Maintainers may retain the broader branch only after explicitly reviewing its configuration and migration behavior independently of reply delivery.

Technical review

Best possible solution:

Restore the three-state health outcome and its failed-health regression coverage, then separate unrelated configuration, migration, and session changes from the reply-delivery repair unless maintainers explicitly retain them together.

Do we have a high-confidence way to reproduce the issue?

Yes, by source: waitForGatewayReachable resolves ok: false, while the changed wizard discards that result and returns true after a failed health command. This was not executed because the review checkout is read-only.

Is this the best way to solve the issue?

No. The receipt design now preserves the prior admission-count contract, but the branch must restore failed-health reporting and narrow or explicitly justify unrelated setup and migration changes.

Full review comments:

  • [P1] Preserve failed health-check reporting — src/commands/configure.wizard.ts:167-172
    waitForGatewayReachable resolves { ok: false } on deadline, but this call discards that result. The subsequent health-command error is caught and the function still returns true, so the caller reports “health check completed” for an unreachable or failed remote gateway; the focused failed-health test was removed in this patch. Preserve the failed outcome (or throw on !ok) and restore that regression coverage.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against bc277fa09554.

Labels

Label justifications:

  • P1: A remote gateway that cannot be reached can be reported as having completed its health check during configuration.
  • merge-risk: 🚨 compatibility: The branch changes deprecated Plugin SDK delivery projections and configuration/migration behavior used by existing setups.
  • merge-risk: 🚨 message-delivery: Settled receipts now drive delivery visibility, fallback, and channel status decisions across multiple transports.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: This maintainer-authored PR is not subject to the external-contributor real-behavior-proof gate; its supplied focused Testbox evidence remains useful supplemental validation.

Evidence

What I checked:

Likely related people:

  • steipete: Current-line blame attributes the restored admission counter and compatibility projection to this head's final commit. (role: current implementation contributor; confidence: high; commits: d10dacd81054; files: src/auto-reply/reply/reply-dispatcher.ts, src/plugin-sdk/inbound-reply-dispatch.ts, src/commands/configure.wizard.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Restore the remote health failure outcome and regression test.
  • Split or obtain explicit maintainer approval for the unrelated configuration and migration changes.
  • Rerun exact-head checks after the correction.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (21 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-17T04:46:47.669Z sha 6d50503 :: needs changes before merge. :: [P1] Preserve the shipped ReplyDispatcher counter API
  • reviewed 2026-08-17T05:14:23.461Z sha 0ff3ff6 :: found issues before merge. :: [P1] Preserve the shipped ReplyDispatcher counter API | [P1] Retain conservative visibility for legacy dispatchers
  • reviewed 2026-08-17T05:21:21.464Z sha 0ff3ff6 :: found issues before merge. :: [P1] Preserve legacy inbound dispatch projections | [P1] Accept void custom dispatcher barriers | [P1] Reconcile failed Slack stream delivery before visibility
  • reviewed 2026-08-17T06:54:12.946Z sha 171bcc4 :: found issues before merge. :: [P1] Preserve count-shaped channel-inbound projections | [P1] Retain admission semantics for getQueuedCounts
  • reviewed 2026-08-17T08:58:49.697Z sha 4e60e05 :: found issues before merge. :: [P1] Retain admission semantics for getQueuedCounts
  • reviewed 2026-08-17T09:04:59.004Z sha 4e60e05 :: needs changes before merge. :: [P1] Preserve admission semantics for getQueuedCounts
  • reviewed 2026-08-17T10:23:52.256Z sha 4e60e05 :: needs changes before merge. :: [P1] Preserve admission semantics for getQueuedCounts
  • reviewed 2026-08-17T13:04:16.023Z sha dd2bfa6 :: needs changes before merge. :: [P1] Preserve admission semantics for getQueuedCounts

@clawsweeper clawsweeper Bot added merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 16, 2026
@steipete steipete self-assigned this Aug 16, 2026
@openclaw-barnacle openclaw-barnacle Bot added channel: matrix Channel integration: matrix extensions: qa-lab labels Aug 16, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Aug 17, 2026
@steipete
steipete force-pushed the steipete/settled-dispatch-receipt branch from 36e45bf to dd2bfa6 Compare August 17, 2026 12:38
@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@steipete

Copy link
Copy Markdown
Contributor Author

Maintainer adjudication of the latest P1 (configure.wizard.ts:167-172, failed gateway health reporting): skipped as out of scope for this PR. That file is not among this PR's 71 changed files, and the concern (health-command failure visibility during the configure wizard) belongs to the setup/wizard owner and its silent-failure invariant — unrelated to dispatch-receipt settlement. It is filed as a dedicated follow-up task rather than absorbed into an already seven-round delivery-accounting PR.

All previous actionable findings from this review series are addressed on the current head: seal race (idle-barrier finalizations + fake-timer regression), Matrix receipt consumption, channel-message facade legacy projections, shipped counter API restored as receipt-derived projections, legacy-dispatcher admission-conservative visibility with capability detection, and getQueuedCounts admission semantics restored (d10dacd).

@steipete
steipete merged commit eb38d5e into main Aug 17, 2026
218 checks passed
@steipete
steipete deleted the steipete/settled-dispatch-receipt branch August 17, 2026 13:38
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 18, 2026
* refactor(reply): publish settled dispatch receipts

* refactor(reply): isolate dispatch outcome accounting

* refactor(discord): infer settled dispatch result

* test(reply): model settled dispatch receipts

* test(reply): type settled receipt fixtures

* test(telegram): declare settled final receipt

* test(telegram): adapt legacy dispatch fixtures

* fix(reply): complete settled receipt compatibility

* test(channels): keep delivery suite within lint budget

* test(channels): reuse settled count fixture

* test(channels): consolidate receipt assertions

* test(channels): extract delivery receipt fixtures

* fix(qa): recover stopped clients after config restart

* fix(reply): settle deferred delivery receipts

* test(channels): share delivery turn fixtures

* fix(channels): preserve non-visible reconciliation

* fix(reply): preserve settled receipt compatibility

* refactor(reply): make settled receipts canonical

* refactor(reply): absorb settlement at dispatcher boundary

* test(matrix): prove settled receipt precedence

* refactor(sessions): extract prompt snapshot types

* fix(reply): restore queued admission counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: feishu Channel integration: feishu channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: signal Channel integration: signal channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: zalo Channel integration: zalo gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: XL status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant