Skip to content

refactor(gateway): reuse completed conversation delivery projection - #131107

Merged
steipete merged 1 commit into
mainfrom
codex/cleanup-conversation-delivery-20260827
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/cleanup-conversation-delivery-20260827

Conversation

@steipete

@steipete steipete commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Completed conversation-send retries duplicated the canonical delivery-result projection, while their tests used copied in-memory stores instead of the real conversation storage owner. That left two internal interpretations of the same durable operation and made the tests less representative of production persistence.

Why This Change Was Made

The Gateway send path now reuses resultFromExistingOperation, the canonical completed-delivery projection. Completed retries still validate current route eligibility before replay, retain persisted operation metadata, and bypass fresh delivery-store resolution and transport; fresh sends keep their existing current-conversation projection and delivery behavior. Test setup now uses the canonical SQLite-backed store through one shared helper.

User Impact

No user-visible behavior, schema, protocol, configuration, or public API changes. This is an internal behavior-preserving consolidation of completed delivery replay and its tests.

Evidence

  • Strengthened owner baseline on unchanged production: 35/35 passed.
  • Final owner suite: 35/35 passed; sibling conversation contracts: 85 passed.
  • Complete changed-file gate: exit 0 after the explicit status case was corrected; all routed types, lint, format, dead-code scans, and guards passed.
  • Exact-head CI passed on attempt 2. Attempt 1's only independent failure was two unchanged browser-server harness cases that received ECONNREFUSED during startup before their route assertions; the unchanged failed-only retry passed. The startup cause was not reproduced or proven. Named follow-up: improve deterministic browser test-server startup diagnostics and lifecycle proof without extending its existing retry window.
  • Isolated P0 autoreview: no findings, 0.95 confidence.
  • Production LOC: +34/-72 (net -38). Tests/support: +290/-294 (net -4). Total: net -42.
  • Both completed retries and fresh sends resolve and authorize the current route; completed retries preserve persisted metadata while bypassing fresh delivery-store resolution and transport.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 27, 2026 18:13
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: L maintainer Maintainer-authored PR labels Aug 27, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 2:19 PM ET / 18:19 UTC.

ClawSweeper review

What this changes

The PR reuses the outbound delivery owner’s completed-operation projection for Gateway conversation-send retries and replaces copied in-memory test state with the canonical SQLite-backed store helper.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open for normal maintainer handling: the introduced consolidation preserves Gateway route checks and delegates completed-status interpretation to the outbound delivery owner; no actionable defect was found. Exact-head CI is still incomplete.

Priority: P3
Reviewed head: 8623e41dbccaf70301ff9243ceb979b45f0c3b81

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, net-negative refactor with meaningful persisted-owner coverage and no identified correctness or security concern.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored internal refactor is exempt from the external contributor proof gate; the PR body records focused owner-suite evidence.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored internal refactor is exempt from the external contributor proof gate; the PR body records focused owner-suite evidence.
Evidence reviewed 6 items Shared owner projection: The outbound delivery owner maps every durable terminal state, including rejection, and is already used before new delivery and recovery handling.
Gateway preserves authorization boundary: The send path resolves and validates the current conversation route before it projects a completed stored operation, then returns the operation’s persisted address metadata.
Owner-boundary coverage: The SQLite-backed helper and table-driven replay test cover completed statuses, stored metadata, route reassignment, and the no-transport replay invariant.
Findings None None.
Security None None.

Live Verification

Command: pnpm openclaw --help

Result: PASS (completed)

$ node scripts/run-node.mjs --help
[openclaw] Building TypeScript (dist is stale: missing_build_stamp - build stamp missing).
[openclaw] Building bundled plugin assets.
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 107.45 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[tsdown-build] invocation 1/2 finished in 0.7s
node_modules/playwright-core/lib/coreBundle.js (65821:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65821:29 ]
       │
 65821 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/playwright-core/lib/coreBundle.js (65828:28) [EVAL] Use of direct ˋevalˋ function is strongly discouraged as it poses security risks and may cause
issues with minification.
       ╭─[ node_modules/playwright-core/lib/coreBundle.js:65828:29 ]
       │
 65828 │               const value = eval(ˋ(${expr})ˋ);
       │                             ──┬─
       │                               ╰─── Use of direct ˋevalˋ here.
       │
       │ Help: Consider using indirect eval. For more information, check the documentation: https://rolldown.rs/guide/troubleshooting#avoiding-direct-eval
───────╯

node_modules/web-tree-sitter/web-tree-sitter.js (2343:30) [EVAL] Use of direct ˋevalˋ fu
… output truncated …
ct and manage anonymous usage telemetry
  terminal             Open a local terminal UI (alias for tui --local)
  transcripts *        Inspect stored transcripts
  triage               Collect sanitized diagnostics and prepare an agent debugging handoff
  tui                  Open a terminal UI connected to the Gateway
  uninstall            Uninstall the gateway service + local data (CLI remains)
  update *             Update OpenClaw and inspect update channel status
  users *              Manage durable user profiles and email aliases
  webhooks *           Webhook helpers and integrations
  worker               Run the restricted cloud worker runtime
  worktrees *          Create, inspect, restore, and clean up managed worktrees

Examples:
  openclaw onboard
    Run guided setup for a local Gateway, workspace, auth, and channels.
  openclaw setup
    Create the baseline config, workspace, and session folders.
  openclaw configure
    Change models, Gateway, channels, plugins, skills, and health checks.
  openclaw status
    Check Gateway, channel, model, and recent-session status.
  openclaw doctor --fix
    Repair common config, service, plugin, and channel problems.
  openclaw channels add
    Add or update a chat channel account with guided prompts.
  openclaw channels status
    See connected messaging accounts and login state.
  openclaw --dev gateway
    Run a dev Gateway (isolated state/config) on ws://127.0.0.1:19001.
  openclaw gateway run --force
    Start the Gateway and replace anything bound to its port.
  openclaw models status
    Show model/provider auth health before running agents.
  openclaw plugins list
    Inspect enabled, disabled, and installed plugins.
  openclaw agent --to +15555550123 --message "Run summary" --deliver
    Run one agent turn through the Gateway and optionally deliver the reply.
  openclaw message send --channel telegram --target @mychat --message "Hi"
    Send via your Telegram bot.

Docs: docs.openclaw.ai/cli

Assertions:

  • PASS expect_output: Usage: openclaw

How this fits together

Gateway conversation sends resolve a registered address, validate current route ownership, then either replay a durable completed operation or dispatch through the outbound delivery owner. The persisted delivery record is the canonical replay source.

flowchart LR
  A[Gateway send request] --> B[Conversation registry]
  B --> C[Route ownership check]
  C --> D[Durable delivery operation]
  D --> E{Already completed?}
  E -->|Yes| F[Shared result projection]
  E -->|No| G[Outbound delivery owner]
  F --> H[Gateway response]
  G --> H
Loading

Before merge

  • Resolve merge risk (P1) - Exact-head CI remains queued or in progress; merge readiness should wait for those checks to finish successfully.
Agent review details

Security

None.

PR surface

Source +13, Tests -55. Total -42 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 85 72 +13
Tests 2 239 294 -55
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 324 366 -42

Review metrics

Metric Value Why it matters
Production versus test LOC production +34/-72 (net -38); tests/support +290/-294 (net -4) The refactor removes a duplicate production projection while moving test setup to the durable storage owner.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep one shared completed-delivery interpreter in the outbound owner while retaining Gateway’s current-route eligibility check and persisted-store replay coverage.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep one shared completed-delivery interpreter in the outbound owner while retaining Gateway’s current-route eligibility check and persisted-store replay coverage.

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

Not applicable: this is an internal behavior-preserving refactor, not a report of a user-observable failure. The changed tests exercise persisted delivery records, but were not run in this read-only review.

Is this the best way to solve the issue?

Yes. The patch deletes the send-only duplicate and reuses the existing outbound owner without collapsing the turn path’s separate correlated-reply projection.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P3: This is a behavior-preserving internal Gateway cleanup with no reported user-visible change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor is exempt from the external contributor proof gate; the PR body records focused owner-suite evidence.

Label justifications:

  • P3: This is a behavior-preserving internal Gateway cleanup with no reported user-visible change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This maintainer-authored internal refactor is exempt from the external contributor proof gate; the PR body records focused owner-suite evidence.

Evidence

What I checked:

  • Shared owner projection: The outbound delivery owner maps every durable terminal state, including rejection, and is already used before new delivery and recovery handling. (src/infra/outbound/conversation-delivery.ts:104, 8623e41dbcca)
  • Gateway preserves authorization boundary: The send path resolves and validates the current conversation route before it projects a completed stored operation, then returns the operation’s persisted address metadata. (src/gateway/conversation-send.ts:66, 8623e41dbcca)
  • Owner-boundary coverage: The SQLite-backed helper and table-driven replay test cover completed statuses, stored metadata, route reassignment, and the no-transport replay invariant. (src/gateway/conversation-send.test.ts:68, 8623e41dbcca)
  • Sibling behavior remains distinct: Conversation turns keep their reply-specific completed projection because they additionally own correlated-reply semantics; they continue to share the outbound send owner. (src/gateway/conversation-turn.ts:61, 8623e41dbcca)
  • History provenance: Blame shows the pre-existing Gateway send and outbound projection behavior originates in the current baseline commit, while this PR only replaces the duplicate local projection with that existing owner helper. (src/gateway/conversation-send.ts:79, 5e193d50ad8b)
  • Introduced-surface check: Verified introduction and test-merge metadata limit the merged change to the five reviewed Gateway/outbound files; current base changes do not modify this surface. (src/gateway/conversation-send.ts:80, 8623e41dbcca)

Likely related people:

  • openclaw-mantis[bot]: Current baseline lines for both the Gateway send flow and outbound completed-operation projection blame to the baseline commit. (role: introduced baseline behavior; confidence: high; commits: 5e193d50ad8b; files: src/gateway/conversation-send.ts, src/infra/outbound/conversation-delivery.ts)
  • Peter Steinberger: Feature history records several contributions on these delivery files, including the reviewed consolidation. (role: recent area contributor; confidence: medium; commits: 8623e41dbcca; files: src/gateway/conversation-send.ts, src/infra/outbound/conversation-delivery.ts)

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.

@steipete
steipete merged commit c1c6e97 into main Aug 27, 2026
432 of 434 checks passed
@steipete
steipete deleted the codex/cleanup-conversation-delivery-20260827 branch August 27, 2026 18:46
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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