Repository navigation
refactor(imessage): keep echo and replay storage off the Gateway thread - #149605
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
d159492 to
f9bb473
Compare
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:25 AM ET / 06:25 UTC (Revision 4). ClawSweeper reviewWhat this changesMoves iMessage echo tracking and restart replay bookkeeping to asynchronous storage while retaining atomic cursor writes on supported older hosts. Merge readiness✅ Ready for maintainer review This PR remains useful: current main still performs these iMessage operations synchronously, and the merged worker prerequisite does not complete this caller migration. No actionable introduced defect was found. Priority: P2 Review scores
Verification
How this fits togetherThe iMessage plugin records outgoing messages to suppress reflected echoes and saves the last durably admitted incoming row for restart recovery. These records connect the Messages transport to OpenClaw’s durable inbound queue and agent dispatch. flowchart TD
A[Outgoing message] --> B[Persist provisional echo]
B --> C[Messages transport]
C --> D[Incoming message]
D --> E[Durable admission and replay cursor]
E --> F[Await echo lookup]
F --> G[Suppress echo or dispatch]
B --> H[Plugin state worker]
E --> H
F --> H
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +67, Tests +254, Docs +16. Total +337 across 17 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Keep one cursor decision across supported hosts, with durable admission and failed-send cleanup settled before reporting completion. Do we have a high-confidence way to reproduce the issue? Not applicable as a discrete bug reproduction: source confirms synchronous bookkeeping on current main, but Gateway stalls were not measured during this read-only review. Is this the best way to solve the issue? Yes. Reusing the existing worker API with a shared atomic decision and a published-host fallback preserves the established storage contract without adding another owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 8ca8c40a35d5. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles)
|
Move echo bookkeeping and recovery cursor operations onto the existing async state API, preserving pending-send rollback and durable-ingress ordering. Keep atomic cursor updates for the declared 2026.9.4 host contract when comparison methods are absent; current hosts retain the worker comparison path. Related: #146557
8fd56a4 to
2a069fa
Compare
|
Merged via squash.
|
…ad (openclaw#149605) * refactor(imessage): await echo and recovery cursor storage Move echo bookkeeping and recovery cursor operations onto the existing async state API, preserving pending-send rollback and durable-ingress ordering. Keep atomic cursor updates for the declared 2026.9.4 host contract when comparison methods are absent; current hosts retain the worker comparison path. Related: openclaw#146557 * test(imessage): await recovery cursor behavior fixtures * test(imessage): align send routing with database worker owner
Related: #146557
What Problem This Solves
iMessage echo suppression and restart replay currently perform SQLite bookkeeping on the Gateway thread.
User Impact
Current hosts move that bookkeeping to the existing state worker while preserving echo suppression, replay ordering, and failed-send cleanup. The declared OpenClaw 2026.9.4 peer and plugin API floor remains supported through its existing synchronous atomic updater. There are no configuration, schema, expiration, or retention changes.
Why This Change Was Made
Send, inbound, startup, and durable-ingress callers now await their echo and cursor operations. One pure cursor decision serves worker comparisons and the older host's transactional update callback, preserving monotonic advancement and rewinding only the expected row after a database replacement. The compatibility path is selected only when comparison methods are absent, before any wait; errors from available comparison methods never retry through synchronous storage. Remove that fallback only when the declared host floor excludes hosts without comparison support.
Reply-cache hydration remains with its existing owner because the synchronous action-authorization callback still requires first-read hydration. The affected tests use the existing process-based database-worker lane, await fixture shutdown, and signal request readiness without increasing deadlines.
Evidence
Eight real-SQLite cursor cases cover current and 2026.9.4 API-shaped stores, concurrent maximum advancement, durable rewinds, intervening writes, and modern comparison failures without synchronous fallback. The three older-host cases fail without the compatibility repair.
Eight monitor cases cover startup watermarks, remote replay, downtime recovery, cursor advancement after durable enqueue, and replaced or empty databases.
CI exposed one missed test-helper caller migration. The existing monitor behavior corpus now awaits cursor operations; all 17 selected recovery-cursor cases pass, along with scoped lint and extension-test types. A fresh P0–P2 review of that test-only completion is clean. Production code and the previously qualified rendering inputs are unchanged.
The selected changed-check plan is complete and independent P0–P2 review is clean. A fixture variable-shadowing lint finding was fixed; final lint/typechecks and all remaining planned guards passed. The published 2026.9.4 API and npm peer/plugin API declarations were inspected; version-shaped fixtures use the real SQLite owner, rather than a full historical-host installation.
Supporting predecessor proof is retained: 33 focused storage cases, 28 reply-cache cases, and 13 ingress cases. Cursor coverage is refreshed above. The unchanged rendering corpus passed a paired comparison at 9.005 seconds before migration and 11.034 seconds afterward under its unchanged 30-second deadline; earlier loaded concurrent runs exceeded that deadline. No rendering or full-suite repeat was added for this compatibility-only delta.
Rebase sanity preserved all qualified iMessage production/test file hashes and combined the documentation and worker-test roster with current main, including the landed Discord and ClickClack routes.
Proof uses synthetic state and transport fixtures; live Messages data and real channel sends were outside this validation.
send.test.tsin the ordinary lane. The route contract now checks both send suites in the database-worker lane and an unaffected sibling in the ordinary lane. All 18 selected iMessage routing cases pass, with fresh P0–P2 review clean; production and roster bytes did not change.The final main integration includes the canonical planner-fixture repair (#149726) and Goal read reuse (#149697). All qualified iMessage production/test bytes are unchanged; the worker roster is the exact union with current main. Sixteen cursor/monitor cases passed again with the current frozen dependency install. Fresh CI is attached to the integrated head.