Skip to content

fix: distinguish unresolved delivery failures from delivery history - #207897

Merged
daniel-lxs merged 3 commits into
mainfrom
openclaw/delivery-health-dead-letter-count-d59f36
Nov 29, 2026
Merged

daniel-lxs merged 3 commits into
mainfrom
openclaw/delivery-health-dead-letter-count-d59f36

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #112313

What Problem This Solves

A failed delivery can leave a receipt so OpenClaw does not send the same message twice. That receipt keeps the delivery queue warning on even when no work remains. When a new failure appears, the warning can still show the age of the old receipt.

User Impact

openclaw health, status --deep, and status --all show past failures that are not queued for retry as history. The dead-letter warning counts only unresolved failures and reports their oldest age. Inbound dead letters and ingress pressure remain visible. No configuration, migration, purge, or replay is needed.

Why This Change Was Made

The queue already records which failures are permanent or bounded duplicate-send receipts. The health read uses those two states; a missing or unfamiliar state still warns. Existing JSON totals and timestamps keep their meaning. A new CLI reading an older Gateway still warns on the undifferentiated total; third-party clients that reject unknown snapshot fields need the updated schema. Nothing changes delivery, settlement, retention, or the one-time warning when session recovery abandons a delivery.

This preserves the privacy and duplicate-prevention decisions in #123642 and the failed-range search in #164131. The count reads the recovery state of each failed row; it does not read message bodies, scan pending or completed deliveries, add an index, or rebuild a database.

Evidence

I used an isolated Gateway and an operator.read credential on Crabbox AWS, with synthetic deliveries and no live Telegram traffic.

Scenario Main Fixed
Only the retained send guard Warning; nothing to retry History only
One newer inbound event failed Warning showed 51s, the guard’s age; the event was 12–16s old Warning showed only the inbound event at 19s; the guard stayed in history
Resubmitted the event and restarted Still warned No queue warning; the receipt still blocked another send with the same ID

status --deep showed history as INFO and status --all as plain detail. Three regression suites failed on main; 66 focused tests passed on the behavioral fix. The terminal captures compare 15a54eaa5479 and 03fa7bf8dc03; the final lint cleanup did not change the SQL or displayed text.

Read cost: The AWS benchmark found one indexed search before and after, with and without planner statistics. With 100,000 completed rows, the warm median after ANALYZE went from 0.021 to 0.044 ms with 100 failures, and from 9.55 to 86.88 ms with 100,000 failures. These are query times on a cache miss, not health RPC latency. Reading each failed row’s recovery state avoids a database migration. Idle reads reuse the cached aggregate.

AWS CLI verification on bbce2eb92f82 passed touched-file lint (zero warnings/errors), formatting, focused regressions, the query-plan assertion, and core types. The read-only CLI showed the new failure at 19s, not the receipt at 43–49s. After resubmission and restart, only history remained. The preparation receipt records the patch and exact Git tree. Commit b7f68b66d8e8 has the same Git tree as that AWS run.

Full CI found that TypeScript could not prove the test had captured a query before inspecting it. 5847f0cdd677 changes only sqlite-query-plan.test.ts, leaving the production tree and CLI captures unchanged. On Crabbox AWS, the previously failing core-test-state-logging type graph and the failed-range query-plan test both passed with that test fix.

Terminal comparison

Before

Before: a retained guard keeps the warning on

After

After: only the new inbound failure warns

What changed

Before, annotated: the guard alone raises a warning

After, annotated: the guard alone is history

Co-authored-by: daniel-lxs [email protected]

Worked on by

Work sessions

Linked for team reference; these sessions aren’t public.

🦞 Made with OpenClaw

roboclaw-bot and others added 2 commits November 29, 2026 02:01
Keep duplicate-send receipts visible without making them a standing warning. Report unresolved failures and their own age without changing retention or replay.

Co-authored-by: daniel-lxs <[email protected]>
Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: d962dcf0-197a-4fbc-b27c-735d5c8bfc1e
@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui gateway Gateway runtime commands Command implementations size: S labels Nov 29, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 29, 2026
@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

This PR separates retained failure receipts from unresolved delivery warnings in health and detailed status reports.

Example: One retained outbound receipt remains while a newer inbound Telegram event fails.

  • Before: The warning includes both entries and reports the receipt’s older age.
  • After: The warning shows only the inbound failure at 19 seconds; the outbound receipt appears as history.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, worthwhile diagnostic repair with inspected CLI evidence, distinct regression coverage, and explicitly recorded compatibility and query-cost tradeoffs.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): Inspected terminal captures exercise the queue aggregate through an isolated Gateway and shipped health CLI using synthetic entries, showing receipt-only history, independently aged inbound warnings, and warning removal after resubmission and restart; the final test-only narrowing preserves that production behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Old retained receipts keep health warnings active and obscure the age of newer delivery failures.
Reason: The maintainer-authored direction restores a useful diagnostic distinction across all three CLI surfaces without removing duplicate-send protection.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes misleading delivery warnings still present on main, with no actionable correctness or security findings.

Reviewed head: 5847f0cdd677572104f97a67c3e3b5e4a4f14577

Before merge

None.

Findings

None.

Agent review details

How this fits together

The delivery queue owner aggregates failed SQLite rows into Gateway health snapshots, which CLI health and status render as warnings or informational history.

flowchart LR
  A[Delivery queue rows] --> B[Queue worker aggregate]
  B --> C[Owner health cache]
  C --> D[Gateway health snapshot]
  D --> E[Shared health formatters]
  E --> F[Health and status output]
Loading

Technical review

Best possible solution:

Use the existing queue aggregate and shared formatters to distinguish unresolved failures from retained history while preserving delivery fences.

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

Main’s aggregate and formatter deterministically include retained receipts in warning counts and age, matching the supplied before captures.

Is this the best way to solve the issue?

The change uses existing recovery-state facts and rendering owners, preserves conservative warnings for unknown states, and avoids changing persistence or delivery behavior.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against cb59aaa31064.

Provenance checked

  • Failed-delivery warning severity changes intended behavior with a stated reason (ef1c832: improve(health): surface dead-lettered delivery queue entries #99842 made otherwise invisible dead-lettered deliveries visible to operators; this PR explains why retained terminal receipts now need separate informational reporting.)
  • Payload-free retained delivery receipts keeps the original intent (ad6bc6d: Preserve privacy and duplicate-prevention ownership using minimal receipts while keeping health coarse and read-only.)
  • Failed-range query selection and cached publication keeps the original intent (6f85fa9: Keep failed-delivery diagnostics on a status-first indexed search rather than scanning pending and completed history.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 437ef61 adds src/commands/health-format.ts:288 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 437ef6160e16; files: src/commands/health-format.ts)

PR surface

Source +69, Tests +37, Docs +3. Total +109 across 14 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 8 88 19 +69
Tests 4 52 15 +37
Docs 2 4 1 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 14 144 35 +109

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Snapshot contract 2 optional response fields retainedCount and oldestUnresolvedAt preserve existing totals but require schema updates for strict older consumers.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • merge-risk: 🚨 compatibility: New optional fields enter a closed snapshot object; the maintainer-authored PR explicitly records and accepts the impact on strict older clients.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-29T02:28:56.161Z sha b7f68b6 :: passed. :: none
  • reviewed 2026-11-29T02:47:30.331Z sha b7f68b6 :: passed. :: none

Reviewed November 28, 2026, 10:10 PM ET / November 29, 2026, 03:10 UTC (Revision 3).

@roboclaw-bot
roboclaw-bot marked this pull request as ready for review November 29, 2026 02:41
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

Keep the one-statement assertion and assert that the captured read exists before using its SQL and bound parameters.

Co-authored-by: daniel-lxs <[email protected]>
@daniel-lxs

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Nov 29, 2026
@daniel-lxs
daniel-lxs merged commit 51d75fe into main Nov 29, 2026
138 checks passed
@daniel-lxs
daniel-lxs deleted the openclaw/delivery-health-dead-letter-count-d59f36 branch November 29, 2026 04:03
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 29, 2026
…penclaw#207897)

Show retained duplicate-send receipts as delivery history. Count unresolved failures in the dead-letter warning and report the age of the oldest unresolved failure.

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: d962dcf0-197a-4fbc-b27c-735d5c8bfc1e
vincentkoc added a commit that referenced this pull request Nov 29, 2026
* commit '99b4afc696081eda8aefd8e91250c112f53a8a73': (564 commits)
  test(ios): verify send-at-tap feedback and work grouping (#207913)
  test(agents): reject unsuccessful live replay completions (#207724)
  fix(cron): keep a started cron turn running when its job is edited (#207947)
  improve(ui): put waiting for a free agent under automation timing (#201282)
  chore(ui): refresh control ui locales (#207514)
  fix: distinguish unresolved delivery failures from delivery history (#207897)
  test(doctor): require security check in proxy ordering assertion (#207912)
  fix: keep update rollback tests in sync with shipped workers (#207822)
  test(agents): fix provider header filtering coverage (#207732)
  refactor: remove the bundled GBrain adapter (#207924)
  improve(ui): show optional run limits beside the automation schedule (#201283)
  test(onboarding): inspect recorded output for credential leaks (#207872)
  perf(exec): reduce host memory sampler allocations (#207927)
  test(mcp-relay): isolate the Connected apps fallback locale (#207923)
  fix(acp): deliver bound channel replies to the pending question (#207035)
  fix(cron): keep required reports from going silent when nothing changes (#207044)
  test(sessions): assert participant queue rollback state (#207891)
  perf(gateway): skip session display preparation for transcript recall (#207916)
  test(agents): verify complete bracketed paste payload (#207733)
  test: stop timing out the cron recovery settlement test on slow runners (#207920)
  ...
vincentkoc added a commit that referenced this pull request Nov 29, 2026
* commit '1b246c09b0c1d41ed0f090f07fc50381decba90d': (574 commits)
  fix: stop the manual handoff UI test from hanging after completion (#207945)
  fix: surface favorites and recommended models in picker search (#201450)
  fix: show the saved quota reset when chat skips its only model (#207210)
  fix: avoid reloading unchanged plugins after Gateway boot (#207949)
  fix: keep Task progress double-clicks from changing the window (#207937)
  fix(doctor): continue repairs past retained conflicting exec approvals (#207951)
  test(reply): make account isolation assertion decisive (#207793)
  fix: keep task progress compact when reopening Details (#207943)
  fix(ui): restore the saved reading position after an empty search (#207673)
  fix: remove four Memory Wiki settings that had no effect (#207882)
  test(ios): verify send-at-tap feedback and work grouping (#207913)
  test(agents): reject unsuccessful live replay completions (#207724)
  fix(cron): keep a started cron turn running when its job is edited (#207947)
  improve(ui): put waiting for a free agent under automation timing (#201282)
  chore(ui): refresh control ui locales (#207514)
  fix: distinguish unresolved delivery failures from delivery history (#207897)
  test(doctor): require security check in proxy ordering assertion (#207912)
  fix: keep update rollback tests in sync with shipped workers (#207822)
  test(agents): fix provider header filtering coverage (#207732)
  refactor: remove the bundled GBrain adapter (#207924)
  ...
tideclaw-bot pushed a commit that referenced this pull request Nov 30, 2026
…207897)

Show retained duplicate-send receipts as delivery history. Count unresolved failures in the dead-letter warning and report the age of the oldest unresolved failure.

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: d962dcf0-197a-4fbc-b27c-735d5c8bfc1e

(cherry picked from commit 51d75fe)

Release adaptation: Keep the closed beta snapshot shape and report only unresolved outbound failures.

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime impact:ux-friction User-facing flow adds avoidable confusion or support burden without fully blocking progress. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants