Skip to content

fix(imessage): preserve accepted attachment delivery custody - #117238

Merged
steipete merged 1 commit into
mainfrom
codex/qa400-imessage-outbound-attachment-delivery
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/qa400-imessage-outbound-attachment-delivery

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

iMessage's ordinary outbound owner passed UUID-bearing OpenClaw media-store paths directly to its native one-shot CLI and JSON-RPC transports. The native Swift provider copies the source basename into the recipient-visible attachment, exposing names such as quarterly-report---UUID.pdf instead of quarterly-report.pdf, including threaded fallback and voice notes.

The same owner accepted attachments before attempting separate captions, but did not report accepted provider facts through either real outbound adapter before the later caption send. A failed caption consequently discarded the accepted provider receipt, misrepresented visible content, and could replay an already-delivered attachment from the durable SQLite queue.

Why This Change Was Made

Refactor both native attachment transports through one private, owner-local original-filename lifecycle. Reuse the existing public SDK filename extractor and identity-safe private temporary workspace; copy the canonical stored bytes under the original basename only for the awaited native provider call, preserving the source and reliably removing the private alias on success, failure, and retry.

Publish one typed, canonical accepted-attachment result through the actual primary message adapter and attached-results adapter before attempting the caption. The result carries the original provider receipt, provider message IDs, empty visible text, visibility, and reply metadata. Durability/custody failures propagate their exact original error and prevent a second provider send. Only an actual later caption failure becomes the existing canonical partial-delivery error, retaining the accepted receipt and correctly reporting empty visible text.

User Impact

Recipients see the intended iMessage document and voice attachment filename on both native transports and threaded retries. If an attachment arrives but its caption fails, OpenClaw preserves the actual accepted provider identity and does not silently replay the attachment. If accepted-delivery custody cannot be recorded, the caption is never sent and the original persistence failure remains diagnosable.

Evidence

  • Immutable reviewed commit 005287aaf182329959f0914ade85ae1a78f35874, tree 0fa79906380de1664bb6ff1473fb6f30934966ce, sole parent 618f3298c7dc00a41549e4dec41d8412f651624b; exactly six existing iMessage plugin/owner test files.
  • Current authoritative main 947886e7649ca0172f7e0f643c35f9e6283ebe5b leaves all iMessage, outbound delivery, channel lifecycle, message, and Plugin SDK owner paths unchanged; exact clean synthetic merge tree 88141b928e63e0f21fad329084a7c97bc1ac25a1.
  • Authentic frozen-production baseline reproduces leaked document/voice filenames, native failure cleanup, RPC threaded/unthreaded names, and lost accepted receipts. A separate genuine baseline runs the actual registered iMessage plugin, native provider callback, core durable producer, and SQLite queue: accepted attachment followed by caption failure fails and loses authoritative delivery custody.
  • Corrected real SQLite-backed integration tests prove both accepted-attachment/caption-failure receipt preservation with no recovery replay and rejected accepted-delivery custody with no caption provider call. Focused native-owner tests independently prove canonical accepted progress, preserved original error, and truthful empty-content partial delivery.
  • Full hosted iMessage owner suite: 919/919 tests across 52 files. Hosted production extension typecheck, extension-test typecheck, type-aware lint, formatting, and diff gates all passed on then-authoritative runner main 4fb19fb8c586b2d7801d1c512a4ac21e4d826505 while the local checkout HEAD remained frozen at 4751365ee66a0820549702c93f175fc9acc2dadc; all six final 005287aaf182329959f0914ade85ae1a78f35874 source blobs were individually hash-verified, and current 947886e7649ca0172f7e0f643c35f9e6283ebe5b leaves every affected owner and caller unchanged. The durable integration tests use the canonical mediaAccess.localRoots owner contract.
  • One authorized Blacksmith Testbox lease tbx_01kyxvzs7z16rmgp37pv7yc5mm: https://github.com/openclaw/openclaw/actions/runs/30685502142. The final timing JSON reports exitCode: 0; the lease was explicitly stopped before the final immutable commit, and direct independent status confirmed completed.
  • Pinned native imsg Swift commit e22dfad8e54ef5ae9ef8b64a3db05f0ce25cd52c, MessageSender.swift:122-146, confirms the source basename is user-visible and provider copying completes before return. Direct inspection of installed @openclaw/fs-safe confirms private copy permissions and guaranteed post-send cleanup.
  • Genuine full-branch Codex gpt-5.6-sol high-reasoning autoreview through P0/P1/P2/P3: zero findings, confidence 0.97. Four fresh independently hostile exact-commit reviewers separately inspected both adapter seams, actual durable SQLite custody and replay, native Swift/provider copy lifetime, reply/thread/voice behavior, and dependency contracts.
  • Production delta +114/-21 = +93 lines, limited to three existing iMessage owner files. The growth expresses the single shared native filename lifetime and typed, canonical, custody-first receipt propagation through both existing adapter seams; no new owner, fallback, public SDK/config surface, dependency, storage, schema, auth, or provider routing is introduced.

@steipete
steipete marked this pull request as ready for review August 1, 2026 05:34
@openclaw-barnacle openclaw-barnacle Bot added channel: imessage Channel integration: imessage size: L maintainer Maintainer-authored PR labels Aug 1, 2026
@clawsweeper clawsweeper Bot added 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. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 1:39 AM ET / 05:39 UTC.

ClawSweeper review

What this changes

The PR makes iMessage attachment sends preserve recipient-visible original filenames and retain accepted attachment receipts when a later caption send fails.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for protected maintainer review. The patch is a coherent owner-local repair: it preserves the original attachment basename only for the native send lifetime and records accepted attachment delivery before a later caption can fail; no discrete source-level defect was found in the proposed change.

Priority: P1
Reviewed head: 005287aaf182329959f0914ade85ae1a78f35874
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, owner-local repair with strong durable-delivery coverage and no supported correctness finding; protected maintainer review remains the merge gate.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (linked_artifact): The PR body provides a linked completed Testbox run and describes a registered-plugin, SQLite-backed durable-delivery harness that exercises accepted attachment, caption failure, and replay prevention; redact any private device or endpoint details in any follow-up native proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (linked_artifact): The PR body provides a linked completed Testbox run and describes a registered-plugin, SQLite-backed durable-delivery harness that exercises accepted attachment, caption failure, and replay prevention; redact any private device or endpoint details in any follow-up native proof.
Evidence reviewed 7 items Attachment filename ownership: The new private workspace helper copies a UUID-suffixed media-store path under the extracted original filename only while the awaited native provider call is running, preserving the canonical source file and cleaning up the alias afterward.
Custody precedes caption: For attachment-plus-caption sends, the adapter awaits the accepted attachment delivery callback before starting the caption; callback failure therefore prevents a second provider send, while a caption failure becomes a partial-delivery error containing the accepted receipt.
Shared partial-delivery contract: The shared channel contract explicitly preserves provider-visible delivery facts when a later native operation fails, matching the PR's use of the partial-delivery error rather than treating the accepted attachment as unsent.
Findings None None.
Security None None.

How this fits together

The iMessage plugin converts a rendered outbound payload into native attachment and caption sends, then reports delivery facts to the shared durable message system. Those facts determine the receipt retained for retries and whether an already-visible attachment may be replayed.

flowchart LR
  A[Outbound payload] --> B[iMessage message adapter]
  B --> C[Native attachment transport]
  C --> D[Accepted delivery receipt]
  D --> E[Durable delivery custody]
  E --> F[Caption transport]
  F --> G[Final or partial delivery result]
Loading

Decision needed

Question Recommendation
Does the maintainer intend to approve the protected iMessage delivery-custody ordering after the remaining required checks finish on this head? Approve the custody-first repair: After the remaining required checks complete, merge the patch with accepted attachment delivery recorded before any caption attempt.

Why: The patch changes outbound message custody and retry semantics in a maintainer-labeled channel surface; source and focused integration evidence support the implementation, but the protected label requires an explicit human merge decision.

Before merge

  • Resolve merge risk (P1) - This changes the ordering by which an accepted attachment becomes durable relative to a later caption send; an incorrect callback bridge could affect retry classification or duplicate prevention, so protected maintainer review should confirm the intended custody boundary on the exact head.
Agent review details

Security

None.

PR surface

Source +93, Tests +366. Total +459 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 114 21 +93
Tests 3 371 5 +366
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 485 26 +459

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Approve after protected review (recommended)
    Merge after required checks finish and a maintainer confirms that recording accepted attachment delivery before the caption is the intended retry boundary.
  2. Pause for native-path confirmation
    Hold the PR for a focused macOS native transport confirmation if maintainers require direct provider evidence in addition to the durable-plugin harness.

Technical review

Best possible solution:

Keep the filename alias and accepted-delivery callback inside the iMessage owner, then land the repair after protected maintainer review confirms the custody-before-caption ordering.

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

Yes, from source: current main sends an attachment and then its caption without forwarding accepted attachment progress through the iMessage adapter, while the durable queue relies on that progress to retain custody. The PR adds focused durable-plugin tests for the caption-failure and custody-rejection paths; this read-only review did not execute a live iMessage send.

Is this the best way to solve the issue?

Yes. Recording the provider-accepted receipt at the iMessage owner before attempting the caption is the narrowest fix because that owner has the authoritative native receipt and can stop the second send if custody persistence rejects it; downstream inference would be less reliable.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: The patch addresses an iMessage outbound delivery failure mode that can lose accepted-delivery custody and permit replay of an attachment after a caption failure.
  • add merge-risk: 🚨 message-delivery: The PR deliberately changes when attachment delivery is recorded relative to caption delivery, which directly affects retry and duplicate-prevention behavior.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a linked completed Testbox run and describes a registered-plugin, SQLite-backed durable-delivery harness that exercises accepted attachment, caption failure, and replay prevention; redact any private device or endpoint details in any follow-up native proof.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (linked_artifact): The PR body provides a linked completed Testbox run and describes a registered-plugin, SQLite-backed durable-delivery harness that exercises accepted attachment, caption failure, and replay prevention; redact any private device or endpoint details in any follow-up native proof.

Label justifications:

  • P1: The patch addresses an iMessage outbound delivery failure mode that can lose accepted-delivery custody and permit replay of an attachment after a caption failure.
  • merge-risk: 🚨 message-delivery: The PR deliberately changes when attachment delivery is recorded relative to caption delivery, which directly affects retry and duplicate-prevention behavior.
  • 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 (linked_artifact): The PR body provides a linked completed Testbox run and describes a registered-plugin, SQLite-backed durable-delivery harness that exercises accepted attachment, caption failure, and replay prevention; redact any private device or endpoint details in any follow-up native proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides a linked completed Testbox run and describes a registered-plugin, SQLite-backed durable-delivery harness that exercises accepted attachment, caption failure, and replay prevention; redact any private device or endpoint details in any follow-up native proof.

Evidence

What I checked:

  • Attachment filename ownership: The new private workspace helper copies a UUID-suffixed media-store path under the extracted original filename only while the awaited native provider call is running, preserving the canonical source file and cleaning up the alias afterward. (extensions/imessage/src/send.ts:453, 005287aaf182)
  • Custody precedes caption: For attachment-plus-caption sends, the adapter awaits the accepted attachment delivery callback before starting the caption; callback failure therefore prevents a second provider send, while a caption failure becomes a partial-delivery error containing the accepted receipt. (extensions/imessage/src/send.ts:831, 005287aaf182)
  • Shared partial-delivery contract: The shared channel contract explicitly preserves provider-visible delivery facts when a later native operation fails, matching the PR's use of the partial-delivery error rather than treating the accepted attachment as unsent. (src/channels/turn/delivery-result.ts:20, bcff3a0de3a9)
  • Durable replay coverage: The added integration test drives the registered iMessage plugin through the durable sender and queue drain, asserting that an accepted attachment followed by a caption failure retains the receipt and does not replay the attachment. (extensions/imessage/src/test-plugin.test.ts:405, 005287aaf182)
  • Current-main comparison: Current main commit bcff3a0 has no changes from the PR base on any of the six affected iMessage source and test paths, so the PR still owns this repair rather than duplicating main. (bcff3a0de3a9)
  • Feature-history routing: History sampling shows Peter Steinberger as the dominant contributor across the central iMessage send and adapter files, and the proposed repair commit is authored by the same contributor identity. (extensions/imessage/src/send.ts:831, 005287aaf182)

Likely related people:

  • steipete: The current iMessage send and adapter history is heavily associated with Peter Steinberger, and the proposed commit is authored by that same contributor identity. (role: feature-history owner and recent area contributor; confidence: high; commits: 89394978e0a6, 005287aaf182; files: extensions/imessage/src/send.ts, extensions/imessage/src/channel.ts, extensions/imessage/src/channel.runtime.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 ee320a6 into main Aug 1, 2026
155 of 176 checks passed
@steipete
steipete deleted the codex/qa400-imessage-outbound-attachment-delivery branch August 1, 2026 06:36
@steipete

steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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