fix(paste): preserve newer clipboard updates #835
<!-- clawsweeper-pr-ack:opened item=835 -->
🦞👀
ClawSweeper picked this up.
Pull request received. I will update this pull request when review starts.
<!-- clawsweeper-review-progress:start -->
ClawSweeper review complete
ClawSweeper finished reviewing this revision. The review result is being finalized.
View the workflow run.
<!-- clawsweeper-review-progress:end -->
PR Summary
<!-- CURSOR_SUMMARY -->
Medium Risk
Changes shared clipboard mutation, permission gating, and paste failure semantics across CLI, MCP, and AutomationKit—high user impact but bounded by extensive tests and explicit refusal when ownership cannot be proven.
Overview
Paste with an explicit payload no longer uses unconditional save/restore slots. CLI and MCP paste now go through a shared ownership-aware temporary clipboard transaction that snapshots complete prior pasteboard state, tracks the generation claimed by the write, and runs one-shot cleanup only while that generation is still owned. If the user or another app copies newer contents during the operation (including identical bytes), cleanup preserves that update instead of restoring the pre-paste clipboard.
AutomationKit adds ClipboardTemporaryWriteProviding / OwnedClipboardTemporaryWriteTransaction, generation checks on native ClipboardService writes, and macOS 15.4+ refusal when the general pasteboard is not silently readable. Legacy clipboard providers without the capability refuse before reads, focus, or input. Failure paths expose clipboard_cleanup_status (restored, preserved_newer_contents, not_needed) in CLI JSON, MCP metadata, and human messages; hotkey refusals after a real clipboard claim stay retry-unsafe without inventing Cmd+V dispatch counts or target receipts.
Tests consolidate on ScriptedClipboardService with new ownership suites; docs and changelog describe the updated cleanup contract.
<sup>Reviewed by Cursor Bugbot for commit 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>
<!-- /CURSOR_SUMMARY -->
Codex review: needs maintainer review before merge. _Reviewed September 26, 2026, 8:06 PM ET / September 27, 2026, 00:06 UTC (Revision 2)._
ClawSweeper review
What this changes
The branch changes CLI and MCP payload paste to use a shared clipboard ownership transaction that preserves newer copies during cleanup and reports the cleanup outcome.
Merge readiness
✅ Ready for maintainer review
Keep this PR open. Current main still restores the clipboard without checking for a newer copy, and the final head addresses that gap. The prior compatibility concern has an explicit maintainer decision and migration guidance; no separate blocking defect is established by this review.
Priority: P1
Reviewed head: 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf
Review scores
| Measure | Result | What it means |
|---|---|---|
| Overall readiness | 🐚 platinum hermit (4/6) | The shared implementation has focused native and adapter coverage, a documented upgrade boundary, and no supported blocking finding on the final head. |
| Proof confidence | 🐚 platinum hermit (4/6) | Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes. |
| Patch quality | 🐚 platinum hermit (4/6) | No actionable review findings were identified. |
Verification
| Check | Result | Evidence |
|---|---|---|
| Real behavior | Not applicable | Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes. |
| Evidence reviewed | 8 items | Current main still has the reported failure path: The CLI's previous cleanup restores the saved clipboard after paste without comparing clipboard generations. MCP has the same unconditional restore path.<br>Shared ownership check: The introduced transaction records the native write claim, checks the generation before cleanup, and returns preservedNewerContents when another write supersedes it.<br>Native final-effect coverage: Tests use unique native NSPasteboards to check ordered restoration, lazy and unreadable representations, and preservation of a newer claim with identical payload bytes. The reported focused native suite passed; this review did not execute it. |
| Findings | None | None. |
| Security | None | None. |
How this fits together
Peekaboo's CLI and MCP paste commands put a temporary payload on the macOS clipboard before sending paste input. The shared AutomationKit clipboard service snapshots the previous contents and handles cleanup after input settles.
flowchart LR
A[CLI or MCP paste request] --> B[Temporary clipboard provider]
B --> C[Snapshot prior items]
C --> D[Write payload and record generation]
D --> E[Send paste input]
E --> F{Generation still owned?}
F -->|Yes| G[Restore prior items]
F -->|No| H[Preserve newer copy]
Before merge
None.
<details>
<summary><strong>Agent review details</strong></summary>
Security
None.
Review metrics
| Metric | Value | Why it matters |
|---|---|---|
| Code delta | production +648/-183; tests +1259/-298 | The substantial shared implementation is accompanied by native clipboard and CLI/MCP regression coverage. |
Technical review
Best possible solution:
Use the shared ownership-aware transaction for automatic payload paste and retain clear permission and custom-provider migration guidance.
Do we have a high-confidence way to reproduce the issue?
Yes. Current-main source unconditionally restores or clears the clipboard after paste; a newer copy made during the settle interval is therefore overwritten. The PR reports failing old-path cases, but this read-only review did not run them.
Is this the best way to solve the issue?
Yes. A generation check in the shared clipboard owner covers both command paths and preserves an observed newer claim; the intentional refusal cases have migration and permission guidance.
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning high; reviewed against 30fc7316fd34.
Labels
Label changes:
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. Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes.rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.Label justifications:
P1: Automatic paste can overwrite a user's newer clipboard copy on current main.merge-risk: 🚨 compatibility: The accepted safety boundary makes legacy custom providers and General-clipboard readers without silent-read permission refuse automatic payload paste.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. Not applicable: The collaborator-authored PR is exempt from the contributor proof gate. The changed production ClipboardService is exercised through unique native NSPasteboards: a second clipboard handle makes a newer claim, and the test observes that cleanup preserves it. General-clipboard UI input is outside the claimed coverage; no stored-data contract changes.Evidence
What I checked:
Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift:246, 30fc7316fd34)Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardTemporaryWrite.swift:169, 73e1c2fdedd5)Core/PeekabooAutomationKit/Tests/PeekabooAutomationKitTests/ClipboardTemporaryWriteTests.swift:358, 73e1c2fdedd5)Apps/CLI/Tests/CLIAutomationTests/PasteClipboardOwnershipTests.swift:11, 73e1c2fdedd5)docs/commands/paste.md:68, 73e1c2fdedd5)Likely related people:
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 re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.@clawsweeper review to request a fresh review only.@clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.@clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.History
<details>
<summary>Review history (1 earlier review cycle)</summary>
<!-- clawsweeper-review-history v=1 total=1 -->
</details>
</details>
<!-- clawsweeper-verdict:needs-human item=835 sha=73e1c2fdedd5cda3c839d7b52462986f0a5c76bf confidence=high updated_at=2026-09-27T00:04:31Z reviewed_at=2026-09-27T00:06:24.983Z lease_owner=github-run-36281325741-1 lease_comment_id=5851122116 source_revision=21d164a46dcf2e81ead43c4abb983bf0b37f8800626079604a34930bf0578277 live_verification=absent -->
<!-- clawsweeper-review-state:ready item=835 sha=73e1c2fdedd5cda3c839d7b52462986f0a5c76bf v=1 -->
<!-- clawsweeper-review-version item=835 reviewed_at=2026-09-27T00:06:24.983Z sha=73e1c2fdedd5cda3c839d7b52462986f0a5c76bf source_revision=21d164a46dcf2e81ead43c4abb983bf0b37f8800626079604a34930bf0578277 lease_owner=github-run-36281325741-1 lease_comment_id=5851122116 v=1 -->
<!-- clawsweeper-review item=835 -->
Snapshot refuses common clipboard types
High Severity
<!-- DESCRIPTION START -->temporarySnapshotItems throws snapshotUnavailable if any declared type returns nil data, so payload paste is refused whenever the current clipboard has promised, converted, or marker types. The existing snapshotRepresentations path already skips those unreadables and still saves the readable items. Finder files, Safari/Chrome copies, and transient markers commonly include such types, so peekaboo paste "text" can fail before writing even though a complete readable snapshot was available.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: c09449d0-fee0-4364-ac62-f74faa484941 -->
<!-- LOCATIONS START
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardService.swift#L276-L298
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmY5ZGQwYTA4LWUyZDMtNDZlNy1iNzcxLTc1Y2E5NzJkZjM2NSIsImVuY3J5cHRpb25LZXkiOiJ0TUtOaGRsb095d1VSNW1ya2MtRjNFSERHMnJKMW9EZExPU2tfdmw2MEJrIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmY5ZGQwYTA4LWUyZDMtNDZlNy1iNzcxLTc1Y2E5NzJkZjM2NSIsImVuY3J5cHRpb25LZXkiOiJ0TUtOaGRsb095d1VSNW1ya2MtRjNFSERHMnJKMW9EZExPU2tfdmw2MEJrIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByTnVtYmVyIjo4MzUsImNvbW1pdFNoYSI6IjY5OTg2NjMyNDg1MDNiYzU2ZTU5Yzg1ODY5NDllM2FhZjFhYTVjNTMiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit 6998663248503bc56e59c8586949e3aaf1aa5c53. Configure here.</sup>
<!-- BUGBOT_REVIEW -->
<!-- BUGBOT_REVIEW_STALE -->
Stale Bugbot comment from a previous run.
Maintainer decision: the ownership capability is an intentional compatibility boundary for automatic temporary-payload paste. A ClipboardServiceProtocol-only provider cannot prove it still owns the clipboard, so retaining the old unconditional restore fallback would retain the data-loss bug. The built-in ClipboardService supports the capability; the command documentation now includes forwarding/migration guidance for wrappers and the required transaction contract for custom backends. Plain background text, current-clipboard paste, and explicit manual clipboard commands retain their existing paths. Foreground authority does not bypass the ownership check.
The unreadable-representation finding was checked against the SDK contract and real private pasteboards. Nil is not generically an empty marker: it can represent an unfulfilled promise or a stale item. Skipping it would silently discard a representation; synthesizing empty bytes would change it. The new native tests demonstrate successful lazy-data restoration, refusal of an unresolved promised representation without changing the original ownership/readable companion, and preservation of actual zero-length marker data. The deliberate completeness refusal is retained and documented. No unsafe skip/fallback was added.
That inspection also identified a separate no-interruption requirement: programmatic General-clipboard reads can request permission on macOS 15.4+. The updated owner checks accessBehavior before snapshot access and requires alwaysAllow; default/ask/deny refuse, even for an empty General board or foreground paste. Named boards and manual commands are unchanged. Documentation explains the deliberate permission setup, older-OS availability, and check/read race limit. It does not promise that an application at default is already listed in Settings or automatically trigger an alert to create that entry.
Final focused proof: 32 native/policy Kit cases, 96 Core/MCP tests, and 64 CLI tests passed. Permission refusal retains its canonical reason, zero mutation, safe retry, and zero input delivery in both adapters. Final scoped lint/format/docs and isolated review pass. Fresh hosted checks for 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf are required before merge; predecessor CI is not the landing gate.
Permission check runs after focus
Medium Severity
<!-- DESCRIPTION START -->
The new silent-read preflight only runs inside prepareTemporaryWrite, after CLI/MCP foreground focus. On macOS 15.4+ the common default policy now refuses with permission_denied after the user's focused app has already changed, even though that refusal claims no clipboard mutation and is treated as retry-safe.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: fec05d94-fd36-4d1e-9a3c-ac1ffd2fc998 -->
<!-- LOCATIONS START
Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/System/ClipboardService.swift#L250-L256
Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift#L110-L238
Core/PeekabooCore/Sources/PeekabooAgentRuntime/MCP/Tools/PasteTool.swift#L201-L555
LOCATIONS END -->
<details>
<summary>Additional Locations (2)</summary>
Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift#L110-L238Core/PeekabooCore/Sources/PeekabooAgentRuntime/MCP/Tools/PasteTool.swift#L201-L555</details>
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmU0NjhkY2ZjLTY1NGMtNDBjNS04OTk4LTA0NzUyNGVhOTZmMCIsImVuY3J5cHRpb25LZXkiOiJ5ZnRWYURlQUxjMkNJVWp3SWw3cEhybmQ3eHMzckpTUmlPdzJHTVVpZ1NZIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a> <a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmU0NjhkY2ZjLTY1NGMtNDBjNS04OTk4LTA0NzUyNGVhOTZmMCIsImVuY3J5cHRpb25LZXkiOiJ5ZnRWYURlQUxjMkNJVWp3SWw3cEhybmQ3eHMzckpTUmlPdzJHTVVpZ1NZIiwiYnJhbmNoIjoiY29kZXgvY2xpcGJvYXJkLW93bmVyc2hpcCIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByTnVtYmVyIjo4MzUsImNvbW1pdFNoYSI6IjczZTFjMmZkZWRkNWNkYTNjODM5ZDdiNTI0NjI5ODZmMGE1Yzc2YmYiLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-web-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-web-light.png"><img alt="Fix in Web" width="99" height="28" src="https://cursor.com/assets/images/fix-in-web-dark.png"></picture></a></div>
<sup>Reviewed by Cursor Bugbot for commit 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Configure here.</sup>
<!-- BUGBOT_REVIEW -->
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
<!-- BUGBOT_FIX_ALL -->
<a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTo3Y2FmODM2Ny1mMDhhLTRhZjItOWQzZS1jOWY2MWExYTE4OGQiLCJlbmNyeXB0aW9uS2V5IjoiT1E0eURWT25sSEhqNDRzM2w3eldUY2hHel8wU0daTE1XQUxFekhZMHRJQSIsImJyYW5jaCI6ImNvZGV4L2NsaXBib2FyZC1vd25lcnNoaXAiLCJyZXBvT3duZXIiOiJvcGVuY2xhdyIsInJlcG9OYW1lIjoiUGVla2Fib28iLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" target="_blank" rel="noopener noreferrer"><picture><source media="(prefers-color-scheme: dark)" srcset="https://cursor.com/assets/images/fix-in-cursor-dark.png"><source media="(prefers-color-scheme: light)" srcset="https://cursor.com/assets/images/fix-in-cursor-light.png"><img alt="Fix All in Cursor" width="115" height="28" src="https://cursor.com/assets/images/fix-in-cursor-dark.png"></picture></a>
<!-- /BUGBOT_FIX_ALL -->
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_BEGIN -->
<sup>❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.</sup>
<!-- BUGBOT_AUTOFIX_REVIEW_FOOTNOTE_END -->
<sup>Reviewed by Cursor Bugbot for commit 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Configure here.</sup>
The ordering observation is correct for explicitly requested foreground setup, but the claimed retry-safe final result is not. The new permission test uses a background fixture; its zero-mutation/retry-safe expectation does not describe the foreground path.
On this head, CLI focus is recorded before preparation, and every transaction error passes through preservingPasteSequence / CommandActionSequenceAccumulator.preservingFailure. Prior dispatched focus plus a permission refusal is composed into an indeterminate, retry-unsafe result with the focus count/receipt retained. The observation-invalidation guard also checks that prior dispatch before allowing no-effect cleanup. See the CLI composition and the shared accumulator.
MCP likewise keeps setupFocusResult, composes the preparation failure through preservingFailure, and makes the canonical aggregate authoritative when projecting metadata. It does not return the raw retry-safe permission leaf after dispatched focus. MCP composition.
Earlier permission checking before an explicitly authorized foreground focus is a possible UX improvement, not the reported lost-effect/retry-safety defect. Default background calls do not perform that focus. Existing shared accumulator and paste composition tests cover retention of prior focus; no additional capability API or unconditional failure rewrite is justified here. A targetless foreground request or confirmed no-change focus can correctly remain retry-safe because there was no preceding mutation.
Landed as f86135fda2da36428c4959a1f3c78901414c4c76. Its tree exactly matches reviewed candidate 73e1c2fdedd5cda3c839d7b52462986f0a5c76bf; main is synchronized. This closes the owned PR queue, not the broader computer-use parity goal.
Final focused proof ran actual builds through the checkout-local workspace wrapper with ambient/live/input automation disabled: swift test --package-path Core/PeekabooAutomationKit for the clipboard temporary-write/write-request suites (32 XCTest cases); swift test --package-path Core/PeekabooCore for the six clipboard, paste, target, and outcome suite selectors (96 tests); and swift test --package-path Apps/CLI -Xswiftc -DPEEKABOO_SKIP_AUTOMATION for the six paste/clipboard/admission selectors (64 tests). All used locked resolution, two build jobs, and serial execution. The native cases use unique private pasteboards; no test drops unresolved representations. Final scoped format/lint, 28 docs/guidance tests, and isolated review passed.
Every final-head product workflow passed on attempt 1: macOS, supplemental/full-safe, and CodeQL. No final-head workflow retry was needed. Both inline review questions are resolved with the documented compatibility decision and existing foreground-effect composition. The separate automated reviewer did not publish a fresh final-head verdict; that is not represented as a clean review. The required isolated review covered the final candidate.
One actual signed CLI/native check used this candidate with compatible GUI source 316bbccd. It sent exactly one background RTF paste to a freshly observed visible test field. The result correctly remained dispatched-unverified and retry-unsafe; no insertion was observed, so this was not a successful end-to-end paste. Clipboard cleanup reported restored, and independent aggregate fingerprints matched before/after. A source-blind audit retained the delivery failure and stricter evidence limits around full ordered fingerprint coverage/generation fencing; no clipboard corruption was observed. Accepted fixture values and the Controls tab were preserved, and the private recovery snapshot was removed. Bounded activation observers are not keyboard/cursor isolation proof. No release, installation, or independent-engine parity is implied.
steipete
Summary
Automatic CLI/MCP paste cleanup previously restored or cleared the clipboard unconditionally. If the user or another application copied something while paste was settling, cleanup overwrote that newer content. The per-user paste lock only serializes Peekaboo clients; it does not own other applications' clipboard writes.
Use one shared temporary-write owner in AutomationKit. It captures the generation returned by the native declaration before payload writes can fail, materializes complete ordered prior items, and performs one-shot cancellation-independent cleanup only while the observed generation is still owned. A superseding copy is preserved even when its bytes are identical. Explicit manual clipboard save/restore, current-clipboard paste, and clipboard-free background text retain their existing paths.
Expose cleanup status separately from input delivery. A hotkey refusal after a real temporary clipboard claim remains retry-unsafe without inventing a Cmd+V dispatch, receiver target, or exact combined mutation count. Existing dispatched partial outcomes retain their counts and evidence. Providers without ownership-aware temporary-write support now refuse before clipboard access or foreground setup instead of silently using unsafe restoration.
On macOS 15.4+, automatic General-clipboard snapshots also require native
alwaysAllowread access before inspecting contents.default,ask, andalwaysDenyrefuse with a canonical permission reason instead of deliberately triggering an alert. Foreground mode is not an exception. Named pasteboards/manual commands are unchanged; older systems do not expose this preflight.CLI/MCP share the production ownership state machine and an in-memory test fixture; several duplicate mocks are removed. Command help, documentation, and the Unreleased changelog describe the changed cleanup contract, including custom-provider migration.
Verification
6998663, full AutomationKit passed: 1,808 Swift Testing tests plus 280 XCTest cases, with ambient and input automation disabled.NSPasteboard has no atomic compare-and-swap. Adjacent generation checks and native writes cannot exclude every cross-process race; this change preserves observed newer ownership rather than claiming universal race freedom. Native snapshots preserve materialized representations, not the original lazy provider identity. This is not a general-clipboard end-to-end or full input-isolation certification.
Merged as
f86135fda2da36428c4959a1f3c78901414c4c76with the identical tree of final candidate73e1c2fdedd5cda3c839d7b52462986f0a5c76bf. Final-head macOS, supplemental/full-safe, and CodeQL all passed on attempt 1.The separate signed native check is deliberately qualified: one background RTF dispatch remained unverified and produced no observed insertion. Clipboard cleanup reported restoration and independent aggregate fingerprints matched; the source-blind audit did not accept the complete ordered/generation-fenced measurement contract from those receipts alone. Fixture values were preserved. This is not a successful full paste workflow or full input-isolation proof.