Skip to content

fix(imessage): surface recovery cursor startup failures - #175442

Merged
steipete merged 3 commits into
mainfrom
deslop/z20-41-imessage-cursor-20261015
Oct 17, 2026
Merged

steipete merged 3 commits into
mainfrom
deslop/z20-41-imessage-cursor-20261015

Conversation

@steipete

@steipete steipete commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes missed iMessages being skipped after a saved recovery-cursor read fails: the error was treated as a first start, so the watcher could subscribe from the latest database row instead of saved progress.

User Impact

For normal downtime recovery, an unreadable recovery cursor now stops account startup visibly. Resolving the state-store read error and restarting resumes saved progress. Legitimately absent cursors retain first-start behavior. Explicit compatibility catchup retains its own replay cursor and no longer reads the unused normal recovery cursor.

Why This Change Was Made

Remove two catch-to-null startup wrappers and let the existing account-start error owner report failures. Skip normal recovery-cursor loading when compatibility catchup owns replay. Remove the migration-disable option that becomes test-only, preserving migration, database-scoping and rewind assertions and moving compatibility coverage to registered account startup.

Ordinary advance/rewind best-effort writes, original migration ordering, GUID deduplication, replay bounds, persisted shapes and shutdown remain unchanged. The recovery feature and incident-backed stale-backlog fence from #91335 remain intact.

Best-effort tradeoffs accepted

  • A current or legacy recovery-cursor read failure no longer starts a watcher with fabricated empty progress. Startup fails visibly until the store is readable. Missing entries still mean no cursor; silent read failure was not a recovery contract.
  • Account-only legacy adoption errors now propagate instead of being converted to empty progress. The original consume-before-adoption ordering is unchanged. A pre-existing migration atomicity gap remains: consuming a legacy entry before a later failed adoption write can lose that cursor. This PR does not claim retry-safe adoption. An attempted read/write/cleanup handoff was parked because a complete repair needs an atomic storage operation, not another non-atomic cleanup chain.
  • Compatibility catchup does not inspect the unused recovery cursor; its own replay and persistence owner remains authoritative. No config, schema, namespace, protocol, dependency or storage-policy changes.

Production delta: 35 added / 46 deleted, 11 net lines removed. Tests/support/routing add 107 lines and remove 32 (75 net added); documentation adds two lines. This is a silent-failure bug fix.

Evidence

  • Registered account-start regressions cover current/legacy read failure against saved row 4990 and synthetic Messages watermark 5000: startup must reject before probe/watch, then resume from 4990 when reads recover. A compatibility-start regression requires catchup to work when its unused normal recovery cursor is unavailable. Existing first-start, database-fallback, bounded persisted catchup, migration/scoping and rewind assertions remain.
  • Local negative control stopped before assertions when focused Vitest expanded into the prohibited broad shared compiled-worker build (exit 130). No failing-before or passing-after local runtime claim; repaired-head hosted CI must run the native database-worker suite. No equivalent cold local build retry.
  • Five-file formatting and whitespace checks pass. Targeted touched-graph typecheck exited 2 only on unchanged transitive missing local parse5 and split MCP packages, with cascading implicit-any diagnostics; no iMessage diagnostic. No dependency reconciliation/compiler retry. Extension lint requires the prohibited local declaration build and remains a hosted gate.
  • Final narrow mandatory suppression guard: 13 passed / 1 failed (111.85 seconds Vitest, 151.13 seconds wrapper), solely two unchanged directives in the MCP lifecycle fixture introduced by refactor: migrate MCP servers and peripheral clients to v2 #175366 (97 observed vs 95 allowed). No new suppressions or baseline edits. Independent full-delta P0–P2 review found no accepted/actionable findings (0.93 confidence); the repair is signed.
  • First-head exact CI was green; hosted P2 correctly identified compatibility-mode loading of an unused cursor. Prior-head CI is not repaired-head proof. The broader pre-existing migration defect is recorded above, not hidden by passing read regressions.
  • Repaired head 04b1796 passed all new registered recovery/bypass regressions and cursor persistence. Run 39029218638 failed its extension bundle on seven owned fixture prerequisites, not inherited failures: four approval-poll cases ran in a thread pool despite host-owned state writes, and three watch-retry cases intentionally installed an unrelated failing state store. The fixture-only followup routes the existing approval-poll suite through the established fork/database-worker lane and uses the existing healthy isolated state runtime for retry tests. Every assertion, retry bound and timer remains unchanged. Independent fixture-delta P0–P2 review is clean (0.96); all other selected CI jobs on 04b were successful. New exact-head CI remains required; no green reruns or failure relabeling.
  • No live Messages account, native provider, operator state or credentials used. Runtime attempts use isolated home/state/config/XDG directories. No new production import edges; no runtime cycle can be introduced by this patch.

Exact final head 5a4201353ec2b6815dbca183945be35d9d3cab92: CI39030132886 succeeded, including the extension bundle, retained runtime siblings, production/test types, lint and guards. All133 check-runs enumerated; auxiliary metadata cancellations have successful same-head successors. No failed or unfinished check and all three required security/dependency/CI statuses successful. The earlier hosted compatibility finding is fixed by skipping normal cursor loading whenever compatibility catchup owns replay.

@clawsweeper

clawsweeper Bot commented Oct 17, 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 channel: imessage Channel integration: imessage size: S labels Oct 17, 2026
@steipete
steipete marked this pull request as ready for review October 17, 2026 11:02
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-17T11:36:53.768417Z 04b1796 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e38aec936f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

return null;
const store = openRecoveryCursorStore();
const key = recoveryCursorStoreKey(accountId, dbIdentity);
const value = await store.lookup(key);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Skip recovery cursor reads while legacy catchup owns replay

With channels.imessage.catchup.enabled: true, monitor-provider.ts:300-311 discards this recovery cursor and the compatibility catchup store owns replay, but this newly uncaught lookup now aborts account startup when only the imessage.recovery-cursor entry is corrupt or otherwise unreadable. That turns irrelevant state damage into a channel outage for a documented retained configuration; skip loading this cursor in catchup mode, or preserve best-effort handling there while keeping fail-closed behavior for normal recovery.

AGENTS.md reference: AGENTS.md:L19-L19

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Propagate recovery-cursor startup failures and bypass the unused normal cursor when compatibility catchup owns replay.

Example: Saved progress is row 4990, the Messages watermark is 5000, and reading saved progress fails.

  • Before: Startup can treat the failure as missing progress and subscribe from row 5000, skipping missed messages.
  • After: Startup rejects before subscribing; once reads recover, it subscribes from saved row 4990.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch is source-supported and resolves the prior finding, while upgrade compatibility remains unproven and exact-head validation is incomplete.
Proof confidence 🦐 gold shrimp (3/6) Ordinary contributor proof is exempt for this maintainer-authored PR, but the non-waivable upgrade gate remains insufficient: provide a redacted latest-stable upgrade trace preserving saved cursor and catchup settings, showing unreadable normal recovery state stopping startup and recovery resuming from saved progress.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Messages received during downtime can be skipped when a saved recovery-cursor read fails.
Reason: The change distinguishes unavailable progress from absent progress, and its maintainer author explicitly accepts the resulting startup behavior.

Merge readiness

⛔ Blocked before merge - 1 item remains

This PR fixes a current silent-recovery failure, and the earlier compatibility-catchup finding is resolved; no new actionable code findings were identified.

Priority: P2
Reviewed head: 5a4201353ec2b6815dbca183945be35d9d3cab92

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence does not show a latest-stable upgrade preserving saved cursors and catchup settings through read failure and recovery, or a negative control reaching the intended regression assertion.
Agent review details

How this fits together

The iMessage monitor loads persisted account-and-database recovery progress before starting the imsg watcher, then journals inbound rows through durable ingress before advancing progress.

flowchart TD
  A[Account startup] --> B[Replay mode]
  B --> C[Normal recovery cursor]
  B --> D[Compatibility catchup cursor]
  C --> E[imsg watcher]
  D --> E
  E --> F[Durable ingress]
  F --> G[Agent dispatch]
Loading

Technical review

Best possible solution:

Retain the focused startup-error propagation and compatibility-catchup bypass while preserving the existing replay and persistence owners.

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

Current-main source shows a failed cursor read returning null and startup choosing the Messages watermark; the added registered-startup regressions encode that path, but no reproduction was executed during this read-only review.

Is this the best way to solve the issue?

Removing the catch-to-null behavior fixes the incorrect first-start classification at its owner without changing replay limits, deduplication, stored shapes, or ordinary best-effort writes.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Recovery reads and legacy adoption changes intended behavior with a stated reason (fc6400e: Always-on recovery preserved downtime progress and suppressed stale backlog; later database scoping preserved progress across upgrades without carrying another database's high-water.)
  • Compatibility catchup selection keeps the original intent (fc6400e: Explicit catchup retains its own cursor and replay path; the PR now avoids loading normal recovery state that this mode does not consume.)
  • Test fixture prerequisites and worker routing keeps the original intent (4152c53: State-backed monitor tests use process-based database-worker execution; retry coverage requires a healthy state store before reaching RPC startup.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 4152c53 adds extensions/imessage/src/monitor/recovery-cursor.ts:97 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 4152c53bdac1; files: extensions/imessage/src/monitor/recovery-cursor.ts)
  • Omar Shahine: Raw commit fc6400e adds extensions/imessage/src/monitor/recovery-cursor.ts:36 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: fc6400ede389; files: extensions/imessage/src/monitor/recovery-cursor.ts)

PR surface

Source -11, Tests +75, Docs +2. Total +66 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 35 46 -11
Tests 4 107 32 +75
Docs 1 2 0 +2
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 144 78 +66

Labels

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status no longer selects a status label.

Label justifications:

  • P2: A focused iMessage recovery fix prevents missed-message skipping after a cursor-store failure.
  • merge-risk: 🚨 compatibility: Existing installations with unreadable recovery state now stop account startup; this tradeoff is explicitly accepted in the maintainer-authored body.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Supply the latest-stable upgrade trace requested in the previous review.

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-10-17T11:19:01.615Z sha e38aec9 :: blocked before merge. :: [P2] Skip unused recovery-cursor loading in compatibility catchup mode
  • reviewed 2026-10-17T11:39:36.627Z sha 04b1796 :: blocked before merge. :: none

Reviewed October 17, 2026, 7:53 AM ET / 11:53 UTC (Revision 3).

@steipete

Copy link
Copy Markdown
Contributor Author

Addressed the compatibility-mode finding in 04b1796: the monitor no longer loads normal recovery state when compatibility catchup owns replay. Added a registered account-start regression requiring catchup startup to succeed when that unused recovery store is unavailable, and removed the now-test-only migration-disable option. Normal recovery still fails visibly on authoritative read failure.

Independent full-delta review found no actionable P0–P2 issues. Prior-head CI is not repaired-head proof; exact repaired-head CI remains the gate. Local runtime proof could not run without the prohibited broad worker build; the body records that gap and the unchanged local dependency/suppression failures. The pre-existing consume-before-adoption migration atomicity gap is explicitly recorded, not claimed fixed.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

The seven runtime failures on 04b1796 are owned fixture integration failures, not inherited CI:

Cases Failure Repair in 5a42013
Four approval-poll ingress cases Newly visible state consume reached the host-only broker from a Vitest thread. Move the existing suite to the established fork/database-worker routing list, like its approval-reaction sibling.
Three watch-subscribe retry cases Fixture deliberately made every state-store open fail, so startup correctly rejected before RPC retries. Use the existing healthy isolated state fixture; preserve all retry/status assertions and timers.

All registered startup read-failure/catchup-bypass regressions and cursor persistence passed on 04b. Production is unchanged by this fixture followup; independent P0–P2 review found no actionable issue. No mocks, skips, timeout increases or expected-failure exemptions were added. Next exact-head CI is required proof; prior green is not reused.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 17, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Exact-head landing evidence

Reviewed signed head: 5a4201353ec2b6815dbca183945be35d9d3cab92.

Exact-head CI39030132886 has completed successfully. Enumerated all133 check-runs with filter=all and pagination: no failed or unfinished check; selected extension bundle, runtime siblings, production/test types, lint, guards, source contracts, package boundaries, docs and channel critical-quality all succeeded. The auxiliary cancellations117388805482(auto-response) and117388759835(PR context and evidence) have completed same-head successes117388760530 and117388805385 respectively; no runtime suite is cancelled or missing. All three dependency/security/ci-gate commit statuses are successful. Live branch rules require zero approving reviews; none of the seven authored paths matches CODEOWNERS. Remote remains OPEN/MERGEABLE at the reviewed head.

Independent full production/test delta review50538 is scoped-clean P0–P2/0.93; fixture-only final delta32016 scoped-clean/0.96. The sole hosted P2 reviewed e38; current monitor-provider explicitly sets recoveryCursorRowid to null when catchupCfg.enabled and never calls loadIMessageRecoveryCursor in that branch. Registered compatibility-start coverage passed hosted CI. Seven owned fixture prerequisite failures on04b were fixed through existing worker routing/healthy runtime, with no assertions, timers, retries, skips or timeouts weakened. They were not attributed to main. No reruns or advancement-only rebase.

Local limitations remain disclosed: cold native runtime proof was stopped before assertions when it required prohibited broad compilation; targeted types found unchanged parse5/MCP dependency gaps, and suppression guard13PASS/1FAIL solely unchanged MCP97vs95. These are not relabeled local passes; exact-head hosted runtime/types/lint/guards now pass. No live Messages account, credentials, operator state or external API proof is claimed.

Production35add46delete=11netremoved; tests/support/routing107add32delete; docs2add. Normal recovery read failures now stop account startup visibly instead of inventing empty progress. Compatibility catchup retains its own owner. Existing consume-before-adoption-write atomicity gap remains unchanged and separately parked; this PR does not claim atomic migration or alter persisted shapes.

Campaign Ending10 authorizes the exact-SHA guarded direct landing fallback after the retained three native pre-intent startup infrastructure failures (Backup36/Canvas37/Google39), plus175442's allocation deadline. Native lock owner d6b39380f5031a418c9c4eeef226cd0ae3963c2f remains preserved; supported lock recovery failed dependency qualification, no shared install/manual ref cleanup. Known task descendants drained; no native merge intent/outcome or uncertain merge write exists. This fallback bypasses broken tooling startup, not CI, reviews, security or enforced policy. Effective token-unset writer steipete and Peter author/committer verified.

@steipete
steipete merged commit c1ec411 into main Oct 17, 2026
143 of 145 checks passed
@steipete
steipete deleted the deslop/z20-41-imessage-cursor-20261015 branch October 17, 2026 11:58
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
)

* fix(imessage): surface recovery cursor startup failures

* fix(imessage): keep compatibility catchup on its own cursor

* test(imessage): qualify state prerequisites for monitor suites
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant