Skip to content

fix: keep Gateway responsive while admitting outbound messages - #153076

Merged
steipete merged 6 commits into
mainfrom
codex/outbound-enqueue-main-carry
Sep 20, 2026
Merged

steipete merged 6 commits into
mainfrom
codex/outbound-enqueue-main-carry

Conversation

@steipete

@steipete steipete commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: unrelated Gateway requests can stall while an outbound message waits for durable queue storage.

User Impact

Other Gateway work stays responsive during enqueue. An unconfirmed publication result retains message/media custody for recovery and stops an independent live send; existing fallback rules apply only when nonpublication is known.

Why This Change Was Made

Run enqueue through the existing shared-state worker while preserving atomic publication, deduplication, preparation checks, and original transaction boundaries. Recovery owns the terminal audit result when custody is retained, and a complete result survives later worker cleanup.

Media preparation, stage creation/cancellation/pruning, preparation checkpoints, and other queue writes retain their existing host work. The final provider-authority fence remains synchronous immediately next to transport. Schemas and public APIs are unchanged.

Evidence

  • Composed with actual landed main 044f78eeae1a17af03ef07415641a98ead48830d, including the canonical cleanup-fixture isolation repair in #153286. CI run 35480651177 exposed that inherited failure on the prior successor. The Enqueue feature patch is unchanged; exact-head CI run 35481632662 passed on bbc8792e922f3e1b5b63be9428800fcdc12c2145.
  • The qualified predecessor passed 291 functional/restart cases and 1,810 routing/planner cases, the normal production build, and the complete selected changed-file gate, including all typechecks, unused-export scans, type-aware lint, and storage/schema/pairing guards. Independent review found no actionable P0–P2 issues. Those results are retained for the unchanged feature.
  • The current main composition additionally passed 27 cases across five enqueue, cleanup, and read-only-owner files, the maintained runtime build, and core typechecking. Cron, ACK, enqueue, Upload, and agent cleanup retain the shared worker dispatcher. The one-shot native cleanup fixture consumes its arm only after the actual enqueue commits; delivery and cleanup assertions are unchanged.
  • Plain Node 24.21.0 against the current maintained build exercised ten enqueue commands, three ACKs, and three actual Gateway Upload commits. Each round shared one canonical actor. All eight calibrated caller-data SQLite counters and all eight separately calibrated exact-control counters were zero within the measured calls. Six pending rows and three upload blobs reopened correctly, three acknowledged rows/media artifacts were removed, six stage/preparation records were consumed, and synthetic state was cleaned up. All 77 source/build bindings were reverified afterward.
  • In that single busy-host sample, cold enqueue calls took 2,315–4,502 ms, warm/staged calls 5.9–83.3 ms, ACKs 4.8–78.5 ms, and Upload commits 3.5–44.7 ms. The largest interval-plus-tail event-loop gap was 45.6 ms. Imports, media/preparation setup, readback, and close/cleanup are excluded; these figures are not a systemwide SQL-free or production-latency claim.

@clawsweeper

clawsweeper Bot commented Sep 19, 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. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime agents Agent runtime and tooling size: XL maintainer Maintainer-authored PR labels Sep 19, 2026
@clawsweeper clawsweeper Bot added 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. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 19, 2026
@clawsweeper

clawsweeper Bot commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 19, 2026, 10:06 PM ET / September 20, 2026, 02:06 UTC (Revision 9).

ClawSweeper review

What this changes

Moves outbound message enqueue writes to the shared database worker so storage waits do not block unrelated Gateway work, while preserving message and media recovery.

Merge readiness

✅ Ready for maintainer review

This PR remains useful: current main and the latest release still enqueue synchronously. The reviewed patch preserves queue ownership and recovery semantics, with no blocking defect found.

Priority: P2
Reviewed head: bbc8792e922f3e1b5b63be9428800fcdc12c2145

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, well-supported repair with meaningful recovery coverage and no blocking finding.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The captured Node 24.21.0 runtime observations exercise worker-backed enqueue in the maintained build and report successful durable readback, stage consumption, cleanup, and continued event-loop progress; inspected fault tests supplement this evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured Node 24.21.0 runtime observations exercise worker-backed enqueue in the maintained build and report successful durable readback, stage consumption, cleanup, and continued event-loop progress; inspected fault tests supplement this evidence.
Evidence reviewed 10 items Pinned introduction and review continuity: Reviewed the introduced delta from 044f78e to bbc8792. The preceding completed review covers this same head and contains no findings. The supplied stale test merge was not used to infer removal of current-main behavior.
Current main still needs the change: Current main's enqueue entrypoints call synchronous queue insertion and namespace transaction helpers directly; they do not dispatch enqueue through the shared worker.
Latest-release comparison: The published v2026.9.5 source also uses synchronous enqueue helpers, so the requested worker-backed behavior is not already shipped there.
Findings None None.
Security None None.

How this fits together

The outbound delivery queue stores prepared messages and staged media before channel transport sends them. Its publication result determines whether live delivery proceeds, cleanup runs, or recovery retains responsibility.

flowchart TD
  A[Prepared outbound message] --> B[Host captures payload and media]
  B --> C[Shared database worker]
  C --> D[Atomic queue publication]
  D --> E{Publication outcome}
  E -->|Confirmed| F[Live channel delivery]
  E -->|Uncertain| G[Retain custody for recovery]
  E -->|Confirmed rollback| H[Cleanup and existing fallback]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +131, Tests +725, Docs +16. Total +872 across 32 files.

View PR surface stats
Area Files Added Removed Net
Source 9 249 118 +131
Tests 22 876 151 +725
Docs 1 16 0 +16
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 32 1141 269 +872

Review metrics

Metric Value Why it matters
Production versus validation growth Production +131 net lines; tests, support, and test routing +725 net lines Production growth implements worker dispatch and publication-outcome handling; most added code protects failure and recovery behavior.

Technical review

Best possible solution:

Keep enqueue on the canonical shared worker while preserving atomic custody, confirmed-rollback fallback, and the existing final transport-authority checks.

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

Yes, from source: current-main enqueue executes synchronous SQLite writes, making writer contention a concrete responsiveness regression scenario. This review did not execute that scenario.

Is this the best way to solve the issue?

Yes. Reusing the shared worker and existing transaction kernels is a focused repair, and the supplied runtime observations and fault coverage support the publication and recovery behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This addresses bounded Gateway responsiveness degradation during durable outbound enqueue waits.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured Node 24.21.0 runtime observations exercise worker-backed enqueue in the maintained build and report successful durable readback, stage consumption, cleanup, and continued event-loop progress; inspected fault tests supplement this evidence.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured Node 24.21.0 runtime observations exercise worker-backed enqueue in the maintained build and report successful durable readback, stage consumption, cleanup, and continued event-loop progress; inspected fault tests supplement this evidence.

Evidence

What I checked:

  • Pinned introduction and review continuity: Reviewed the introduced delta from 044f78e to bbc8792. The preceding completed review covers this same head and contains no findings. The supplied stale test merge was not used to infer removal of current-main behavior. (bbc8792e922f)
  • Current main still needs the change: Current main's enqueue entrypoints call synchronous queue insertion and namespace transaction helpers directly; they do not dispatch enqueue through the shared worker. (src/infra/outbound/delivery-queue-storage.ts:163, 26505c528b50)
  • Latest-release comparison: The published v2026.9.5 source also uses synchronous enqueue helpers, so the requested worker-backed behavior is not already shipped there. (src/infra/outbound/delivery-queue-storage.ts:161, ec9c1a13db89)
  • Publication and cleanup classification: Enqueue captures canonical JSON and state before awaiting the worker. An entered operation without an authoritative result retains custody; a returned rollback result preserves ordinary cleanup and fallback. The worker reuses existing namespace conflict, exact preparation comparison, and atomic stage-consumption kernels. (src/infra/outbound/delivery-queue-storage.ts:163, bbc8792e922f)
  • Focused fault coverage: Inspected tests exercise a lost committed reply, retained media and exactly-once recovery, serialization rejection, confirmed native rollback, and coordinator cleanup failure after commit. These tests use the actual queue/worker boundary with a mocked channel sender; they were not executed during this read-only review. (src/infra/outbound/deliver.enqueue-worker.integration.test.ts:100, bbc8792e922f)
  • Supplied production-runtime observations: The captured PR body reports Node 24.21.0 exercising ten enqueue commands, three acknowledgments, and three Gateway Upload commits against the maintained build. It records zero calibrated caller-thread SQLite counters during measured calls, reopened queue rows and upload blobs, consumed stages, removed acknowledged artifacts, and a largest measured event-loop gap of 45.6 ms. These are bounded reported runtime observations, not an independently repeated production benchmark. (bbc8792e922f)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • galiniliev: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (8 earlier review cycles)
  • reviewed 2026-09-19T17:58:01.730Z sha 179d295 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-19T19:25:14.589Z sha 9121361 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-19T19:49:22.040Z sha 82eccbc :: needs maintainer review before merge. :: none
  • reviewed 2026-09-19T20:06:07.410Z sha a4438c5 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-19T20:30:18.004Z sha a4438c5 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T01:16:37.272Z sha 5d73274 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T01:26:01.845Z sha 5d73274 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-20T01:39:42.976Z sha bbc8792 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 9e7a575 into main Sep 20, 2026
223 checks passed
@steipete
steipete deleted the codex/outbound-enqueue-main-carry branch September 20, 2026 02:15
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 20, 2026
…law#153076)

* fix: keep Gateway responsive while admitting outbound messages

* test: run durable delivery flows with the host database broker

* test: complete durable delivery test routing

* test: include WhatsApp in the database-worker batch expectation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR 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: XL 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.

1 participant