Repository navigation
improve(health): surface dead-lettered delivery queue entries - #99842
vincentkoc merged 3 commits into
Conversation
Deliveries that exhaust retries are moved to the failed status in the SQLite delivery queue for diagnostics, but no health surface ever read them back: openclaw health stayed all-green while messages sat dead-lettered, visible only in gateway logs. Add a per-queue failed count accessor and report dead-lettered entries in the health snapshot (JSON field plus a warning line), following the existing plugin and context-engine health section pattern. Observer-only: no retry, purge, or behavior change.
Add getHealthSnapshot coverage against an isolated state dir, an openclaw health text-output test for the warning line, exact oldest-failure timestamp assertions via fake timers, and a debug log when the delivery-queue health read fails.
|
Codex review: needs maintainer review before merge. Reviewed July 4, 2026, 2:40 AM ET / 06:40 UTC. Summary PR surface: Source +104, Tests +212. Total +316 across 8 files. Reproducibility: yes. source-reproducible. Current main persists failed delivery queue rows with Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Next step before merge
Security Review detailsBest possible solution: Land the additive read-only health diagnostic after ordinary maintainer review and CI, keeping enqueue, retry, purge, and recovery behavior unchanged. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible. Current main persists failed delivery queue rows with Is this the best way to solve the issue? Yes. Reusing the existing SQLite queue state and shared health snapshot is the narrow maintainable path, and the latest commit now covers the cached gateway response path that normal AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cafbd745c1b1. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +104, Tests +212. Total +316 across 8 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
|
The gateway health handler can serve a cached snapshot for up to a refresh interval, so a delivery dead-lettered after the cache was filled stayed hidden from openclaw health. Recompute the delivery queue summary in mergeCachedHealthRuntimeState alongside the existing context-engine and model-pricing live merges, and cover the cached handler path with a regression test.
…aw#99842) * improve(health): surface dead-lettered delivery queue entries Deliveries that exhaust retries are moved to the failed status in the SQLite delivery queue for diagnostics, but no health surface ever read them back: openclaw health stayed all-green while messages sat dead-lettered, visible only in gateway logs. Add a per-queue failed count accessor and report dead-lettered entries in the health snapshot (JSON field plus a warning line), following the existing plugin and context-engine health section pattern. Observer-only: no retry, purge, or behavior change. * test(health): cover snapshot and CLI dead-letter reporting Add getHealthSnapshot coverage against an isolated state dir, an openclaw health text-output test for the warning line, exact oldest-failure timestamp assertions via fake timers, and a debug log when the delivery-queue health read fails. * fix(health): recompute dead-letter counts for cached gateway responses The gateway health handler can serve a cached snapshot for up to a refresh interval, so a delivery dead-lettered after the cache was filled stayed hidden from openclaw health. Recompute the delivery queue summary in mergeCachedHealthRuntimeState alongside the existing context-engine and model-pricing live merges, and cover the cached handler path with a regression test.
Prompt request: Make
openclaw healthreport deliveries that were dead-lettered by the durable delivery queue, so silent message loss becomes visible, while keeping the queue's enqueue, retry, and recovery behavior unchanged.Proof target: Show that dead-lettered entries surface in the health snapshot (JSON field and warning line) and that a queue with only pending entries reports nothing.
What Problem This Solves
Resolves a problem where messages that permanently fail delivery are invisible to operators. When a delivery exhausts its retries, the durable delivery queue moves the entry to a
failedstatus that is retained for diagnostics — but nothing ever reads those rows back:openclaw healthstays all-green, and the only trace is a gateway log line at the moment it happened. An operator whose channel had an outage has no way to notice that messages were dropped.Why This Change Was Made
The SQLite delivery queue already persists dead-lettered entries with a
failed_attimestamp; the gap is purely read-side. This change adds a per-queue failed-count accessor to the storage layer and reports dead-lettered entries fromgetHealthSnapshot, the builder shared by the gateway health state and theopenclaw healthcommand. It follows the existing plugin and context-engine health section pattern: thedeliveryQueuesfield is omitted when nothing is dead-lettered, a storage read failure degrades to omitting the section rather than failing health, and the text renderer adds one warning line. Because the gateway health handler can serve a cached snapshot for up to a refresh interval, the cached-response merge path recomputes the delivery queue summary the same way it already refreshes context-engine and model-pricing state, so a delivery that dead-letters right after the cache fills is still reported. Observer-only — no retry, purge, or queue behavior change.User Impact
Operators now see dead-lettered deliveries in
openclaw health: a JSONdeliveryQueues.failedentry per queue (count plus oldest failure timestamp) and a text line such asDelivery queue: warning (dead-lettered entries — outbound: 2; oldest 2h ago). Healthy systems see no new output.Evidence
Real-runtime capture using the production storage layer with no mocks (isolated
OPENCLAW_STATE_DIR; three outbound deliveries enqueued viaupsertDeliveryQueueEntry, two dead-lettered viamoveDeliveryQueueEntryToFailed, then the realgetHealthSnapshot):Before (main):
After (this PR):
The still-pending third delivery does not appear — only dead-lettered entries are reported.
Focused tests:
src/infra/delivery-queue-sqlite.test.ts— an empty queue returns no counts; dead-lettered entries are counted per queue with exact oldest-failure timestamps (fake timers) while pending entries stay excluded.src/commands/health.snapshot.test.ts— the built health snapshot omits the field for a clean queue and reports the dead-lettered entry against an isolated state dir.src/commands/health.test.ts—openclaw healthrenders the warning line from a gateway summary, and the formatter returns null when nothing is dead-lettered.src/gateway/server-methods/server-methods.test.ts— a cached gateway health response reports a delivery dead-lettered after the cache was filled. The new assertions fail without the change.