fix(paste): preserve observations after no-effect refusals #800
<!-- clawsweeper-pr-ack:opened item=800 -->
🦞👀
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 paste failure paths around snapshot invalidation and interaction-mutation tracking; mistakes could leave stale observations or clear another command’s mutation barrier, though guards and a large contract test suite target those edges.
Overview
Paste no longer always invalidates implicit observations when the command fails after entering its mutation wrapper. On canonical no-dispatch refusals that match JSON error-envelope semantics (refused, no dispatch, retry-safe, no mutation dispatched)—and only when no clipboard write was attempted and no focus/input was recorded—the command skips InteractionObservationInvalidator and may cancel its own fresh uncommitted mutation mark without touching another operation’s durable barrier.
A PasteClipboardMutation flag is set before clipboard.set so partial or attempted writes still force conservative invalidation. Stronger envelope evidence, prior focus, partial clipboard failures, and unclassified input errors keep the old invalidate-on-error behavior.
Adds PasteObservationInvalidationTests, wires them into macOS CI and the paste safety Node policy, and documents the rule in paste command docs and changelogs. Test fixtures for background paste are slightly widened for reuse.
<sup>Reviewed by Cursor Bugbot for commit 2415afab92ccee9dd9d044f3ed9bc4e25892b091. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>
<!-- /CURSOR_SUMMARY -->
Wrapped refusals still drop observations
Medium Severity
<!-- DESCRIPTION START -->
The new skip path only treats a raw DesktopActionFailure as a no-effect refusal. Targeting failures inside the wrapper are thrown as PreDispatchActionError, which already carries a canonical pre-dispatch refusal. JSON still reports retry_safe and no dispatch, but implicit observations are discarded.
<!-- DESCRIPTION END -->
<!-- BUGBOT_BUG_ID: 73c2731a-e474-4d0a-a229-fedcebb3cf22 -->
<!-- LOCATIONS START
Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift#L874-L880
LOCATIONS END -->
<div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRmODE0YThlLWU4YjMtNDRhOS1iYzVlLWQ2MzhiYmU0ZjI2ZiIsImVuY3J5cHRpb25LZXkiOiJrcldsZXpoeWVoSy1JMER1WUtHX3hCTU1uTm5zMXRSLXM1UlFuMThIdUFnIiwiYnJhbmNoIjoiY29kZXgvcGFzdGUtemVyby1lZmZlY3Qtb2JzZXJ2YXRpb25zIiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJvdmlkZXIiOiJnaXRodWIifX0" 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=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmRmODE0YThlLWU4YjMtNDRhOS1iYzVlLWQ2MzhiYmU0ZjI2ZiIsImVuY3J5cHRpb25LZXkiOiJrcldsZXpoeWVoSy1JMER1WUtHX3hCTU1uTm5zMXRSLXM1UlFuMThIdUFnIiwiYnJhbmNoIjoiY29kZXgvcGFzdGUtemVyby1lZmZlY3Qtb2JzZXJ2YXRpb25zIiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJOdW1iZXIiOjgwMCwiY29tbWl0U2hhIjoiMWQ1NmMwOTY1MTdiMmIyYmEwZDgwNjk3NTU2MTcyZWZkZDA1ZWM0YiIsInByb3ZpZGVyIjoiZ2l0aHViIn19" 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 1d56c096517b2b2ba0d80697556172efdd05ec4b. 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=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aToxOTI4MTYzZC1mMGQ4LTRkNGQtYTEyMS0yZWYxNzA3YTllZmIiLCJlbmNyeXB0aW9uS2V5IjoiYllqd0VONFk0N1g1WVY4TjgwZ2Y3cklpVWYzdUQtYjIyclFmQTl1a0RpNCIsImJyYW5jaCI6ImNvZGV4L3Bhc3RlLXplcm8tZWZmZWN0LW9ic2VydmF0aW9ucyIsInJlcG9Pd25lciI6Im9wZW5jbGF3IiwicmVwb05hbWUiOiJQZWVrYWJvbyIsInByb3ZpZGVyIjoiZ2l0aHViIn19" 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 1d56c096517b2b2ba0d80697556172efdd05ec4b. Configure here.</sup>
Codex review: needs changes before merge. _Reviewed September 24, 2026, 7:04 PM ET / 23:04 UTC._
ClawSweeper review
What this changes
The branch makes paste retain implicit UI observations after verified no-effect refusals, adds clipboard-attempt tracking and regression tests, and updates CI and documentation.
Merge readiness
⛔ Needs changes before merge - 2 items remain
Current main still discards the latest observation after an admitted, no-effect paste refusal. This PR addresses that behavior, but its new guard misses wrapped targeting refusals that report the same retry-safe, no-dispatch outcome.
Priority: P2
Reviewed head: 1d56c096517b2b2ba0d80697556172efdd05ec4b
Review scores
| Measure | Result | What it means |
|---|---|---|
| Overall readiness | 🦐 gold shrimp (3/6) | The repair is focused and well covered for direct refusals, but the wrapped-refusal gap prevents a merge-ready rating. |
| Proof confidence | 🌊 off-meta tidepool | Not applicable: The COLLABORATOR-authored PR is exempt from the contributor proof gate. Its fixtures call production PasteCommand with injected services and assert JSON and latest-observation results after the patch, but do not show native paste or the outer CLI runtime; no stored-data format changes. |
| Patch quality | 🦐 gold shrimp (3/6) | 1 actionable review finding remain. |
Verification
| Check | Result | Evidence |
|---|---|---|
| Real behavior | Not applicable | Not applicable: The COLLABORATOR-authored PR is exempt from the contributor proof gate. Its fixtures call production PasteCommand with injected services and assert JSON and latest-observation results after the patch, but do not show native paste or the outer CLI runtime; no stored-data format changes. |
| Evidence reviewed | 10 items | Current main still invalidates on every admitted failure: The paste helper on current main calls observation invalidation unconditionally in its catch path, so the central behavior remains unfixed there.<br>Introduced guard excludes wrapped refusals: The new skip path accepts only an error cast directly to DesktopActionFailure; other errors fall through to invalidation.<br>Target resolution reaches the guard with a wrapper: Admitted clipboard paste calls preDispatchBackgroundTarget inside the helper; that function converts target errors to PreDispatchActionError before clipboard access or input dispatch. |
| Findings | 1 actionable finding | [P2] Recognize wrapped pre-dispatch refusals before invalidating |
| Security | None | None. |
How this fits together
The Peekaboo CLI paste command sends direct background text or uses a serialized clipboard and Cmd+V transaction. Focus, clipboard, and input outcomes determine whether later commands may use the latest UI observation.
flowchart LR
A[Paste request] --> B[Choose delivery route]
B --> C[Focus, clipboard, and input]
C --> D[Record action outcome]
D --> E{No effect refusal?}
E -->|Yes| F[Keep latest observation]
E -->|No| G[Invalidate latest observation]
Before merge
preDispatchBackgroundTarget, which wraps a targeting failure in PreDispatchActionError before any input. Its embedded failure is a canonical no-dispatch refusal, but this new direct cast fails and the fallback discards implicit latest while JSON reports retry-safe and no dispatch. Inspect the embedded failure for this guard and add a targeting-refusal regression.Findings
Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift:877<details>
<summary><strong>Agent review details</strong></summary>
Security
None.
Review metrics
| Metric | Value | Why it matters |
|---|---|---|
| Production and test LOC | production +38 net, tests +460 net | The production growth is scoped to refusal handling; most added code checks its behavior and CI selection. |
Technical review
Best possible solution:
Use the canonical failure embedded in either a direct action error or its pre-dispatch wrapper when deciding observation retention, while preserving the existing focus, clipboard, and foreign-barrier guards.
Do we have a high-confidence way to reproduce the issue?
Yes, at source level: an admitted paste can return a canonical no-dispatch refusal while current main invalidates the latest observation. The PR reports a baseline failure and branch success in injected command tests; this read-only review did not execute them.
Is this the best way to solve the issue?
No, the guard is appropriately narrow but incomplete: it does not inspect the canonical failure inside PreDispatchActionError. A focused wrapped-targeting regression would verify the repair.
Full review comments:
Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift:877An admitted current-clipboard paste can reach
preDispatchBackgroundTarget, which wraps a targeting failure in PreDispatchActionError before any input. Its embedded failure is a canonical no-dispatch refusal, but this new direct cast fails and the fallback discards implicit latest while JSON reports retry-safe and no dispatch. Inspect the embedded failure for this guard and add a targeting-refusal regression.Confidence: 0.93
Overall correctness: patch is incorrect
Overall confidence: 0.9
AGENTS.md: found and applied where relevant.
Codex review notes: model internal, reasoning high; reviewed against b7e2896cd4c5.
Labels
Label changes:
P2: This is a bounded CLI observation-state fix with a concrete remaining path, without evidence of an emergency or broad outage.rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The COLLABORATOR-authored PR is exempt from the contributor proof gate. Its fixtures call production PasteCommand with injected services and assert JSON and latest-observation results after the patch, but do not show native paste or the outer CLI runtime; no stored-data format changes.Label justifications:
P2: This is a bounded CLI observation-state fix with a concrete remaining path, without evidence of an emergency or broad outage.rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🌊 off-meta tidepool and patch quality is 🦐 gold shrimp.status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Not applicable: The COLLABORATOR-authored PR is exempt from the contributor proof gate. Its fixtures call production PasteCommand with injected services and assert JSON and latest-observation results after the patch, but do not show native paste or the outer CLI runtime; no stored-data format changes.Evidence
Acceptance criteria:
What I checked:
Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift:718, b7e2896cd4c5)Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift:877, 1d56c096517b)Apps/CLI/Sources/PeekabooCLI/Commands/Interaction/PasteCommand.swift:842, 1d56c096517b)Apps/CLI/Sources/PeekabooCLI/CLI/Output/JSONOutput.swift:204, 1d56c096517b)Apps/CLI/Tests/CLIAutomationTests/PasteObservationInvalidationTests.swift:27, 1d56c096517b)Likely related people:
Rank-up moves
Optional improvements that raise the rating; they are not merge blockers.
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.</details>
<!-- clawsweeper-verdict:needs-changes item=800 sha=1d56c096517b2b2ba0d80697556172efdd05ec4b confidence=high updated_at=2026-09-24T23:01:34Z reviewed_at=2026-09-24T23:04:38.273Z lease_owner=github-run-36070515318-1 lease_comment_id=5823639647 source_revision=8e599013f23f4cefa9823b6a5a18b0d77a823e680ae38de1c24a18f48389a093 live_verification=absent -->
<!-- clawsweeper-action:fix-required item=800 sha=1d56c096517b2b2ba0d80697556172efdd05ec4b confidence=high updated_at=2026-09-24T23:01:34Z reviewed_at=2026-09-24T23:04:38.273Z lease_owner=github-run-36070515318-1 lease_comment_id=5823639647 source_revision=8e599013f23f4cefa9823b6a5a18b0d77a823e680ae38de1c24a18f48389a093 live_verification=absent finding=review-feedback -->
<!-- clawsweeper-review-state:needs-changes item=800 sha=1d56c096517b2b2ba0d80697556172efdd05ec4b v=1 -->
<!-- clawsweeper-review-version item=800 reviewed_at=2026-09-24T23:04:38.273Z sha=1d56c096517b2b2ba0d80697556172efdd05ec4b source_revision=8e599013f23f4cefa9823b6a5a18b0d77a823e680ae38de1c24a18f48389a093 lease_owner=github-run-36070515318-1 lease_comment_id=5823639647 v=1 -->
<!-- clawsweeper-review item=800 -->
Addressed in 2415afab92ccee9dd9d044f3ed9bc4e25892b091. The guard now reuses the same effective error-envelope projection as JSON output, rather than inspecting only the raw error type. It requires both the canonical outcome and effective retry/dispatch fields to agree, so stronger aggregate outcomes or scalar overrides cannot be erased by unwrapping a refused leaf.
The real admitted missing-app path reproduces the original gap: APP_NOT_FOUND, safe/no-dispatch metadata and zero clipboard/focus/input calls, but three failed observation-preservation assertions. That case now passes, alongside raw/wrapped partial clipboard writes, unknown errors, stronger-envelope controls and other owners' barriers: 17 focused cases total. Full-candidate Autoreview is clear at its recorded scope. Fresh exact-head hosted CI and review remain required before landing.
ClawSweeper status: review started.
I am starting a fresh review of this pull request: fix(paste): preserve observations after no-effect refusals This is item 1/1 in the current shard. Shard 0/1.
This temporary status tracks the active review worker. The completed review will appear in the durable ClawSweeper review comment.
Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.
<!-- clawsweeper-review-status:started item=800 sha=2415afab92ccee9dd9d044f3ed9bc4e25892b091 started_at=2026-09-24T23:16:29.298Z lease_expires_at=2026-09-24T23:18:59.825Z owner=github-run-36071822162-1 v=1 -->
<!-- clawsweeper-review-lease item=800 -->
Landed as 17fbebde4e81c96ae14bead5c36b24961a3dd49d after all exact-head CI and review gates passed. The merged tree exactly matches the tested current-main integration, dd20e0bcb9db4705a3d5076942c47e594a922ede.
This PR preserves the latest UI observation when paste proves it refused without effects. The previous path discarded it even while reporting retry-safe/no-dispatch. The guard now reuses the same effective outcome projection as JSON output, including wrapped target-resolution failures, so stronger aggregate evidence cannot be lost.
The safety boundary stays conservative: attempted clipboard writes, prior focus, uncertain input, and other owners' barriers still prevent preservation or mark cancellation. This is a separate observation-lifecycle fix, not a regression attributed to the earlier admission-deadline work.
Proof: 17 focused in-process CLI cases passed (15 observation cases and two existing admission/recovery controls), including the actual command's execution path and captured JSON for the missing-target wrapper regression. The fixtures use owned snapshot/mutation storage and fake clipboard/focus/input services; process-global runtime configuration is not claimed fully isolated. Node policy and supplemental workflow contracts, docs lint, scoped formatting/strict lint, and complete-candidate P0 Autoreview passed. The actual current-main integration additionally passed 26 graph/policy contracts; its owned Swift source is unchanged.
Fresh automated review of head2415afab completed with no findings in workflow run36071822162, artifact10838742757. That result exists as a workflow artifact; a public review comment was not posted. Bugbot passed and its earlier wrapper-refusal thread is resolved. Native app/clipboard testing and full computer-use parity are not claimed by this PR.
Exact-head macOS CI, CodeQL, and supplemental validation all passed, including full-safe. No code-check rerun was required for this head. Main is synchronized locally; this is a source landing, not a release or deployed-binary claim.
steipete
What this fixes
Paste previously invalidated implicit observations for every failure after entering its body. A canonical refusal before input could therefore report
retry_safe: true,mutation_dispatched: false, and no fresh-observation requirement while still discarding the implicit latest snapshot. Explicit mutation-lease eligibility was not consumed; the mismatch caused unnecessary observation loss.This is a separate follow-up to the landed admission-deadline fixes in #793 and #794, not a regression caused by their shared error mapper.
Change
Paste now skips its invalidator only when a canonical refusal proves no dispatch, the recorded prefix has no mutation, and no clipboard write was attempted. It uses the same effective error-envelope projection as JSON output, including wrapped targeting refusals, while honoring stronger aggregate outcomes and retry/dispatch overrides. A sticky clipboard flag is set before the write because a throwing write can partially mutate the pasteboard.
Skipping invalidation and canceling a tracker mark are separate decisions. Paste cancels only its own fresh, unchanged, unsaturated mark with no protected observation/failure state. It never cancels a durable lease. Existing or interleaved owners retain their boundaries and barriers. Prior focus, partial clipboard writes, uncertain input, and other noncanonical failures retain conservative invalidation and existing retry semantics.
The same owner handles clipboard-backed paste and direct background text. No gate, snapshot-store, public CLI option, or Bridge protocol change is added. The helper lives in a scoped extension rather than growing the command's already-large main type.
Behavioral proof
The baseline reproduced the mismatch with the actual CLI command and captured JSON: one declaration over three controlled prefixes ran; only the no-effect case failed its latest-snapshot and watermark assertions. Clipboard-change and focus-prefix controls passed. Explicit mutation leases and historical reads remained available.
Review exposed a second missing case: the actual admitted current-clipboard path wrapped a missing-target refusal in
PreDispatchActionError. It reportedAPP_NOT_FOUND, safe retry and no dispatch without reading or writing the clipboard, focusing, or sending input, but still lost implicit latest. Three preservation assertions reproduced that gap before the projection repair.The repaired source passes 15 observation cases covering raw and wrapped refusals, clipboard write/restoration, prior focus, raw and wrapped partial clipboard writes, unclassified input failure, stronger envelope outcomes/scalar overrides, three foreign-owner/barrier states, and background-text refusal. The two existing clipboard admission/recovery cases also pass: eight declarations in two suites, 17 cases total. Complete-PR Autoreview is scoped-clean on the repaired candidate; an earlier stalled review was terminated without a verdict and is not counted as proof.
Snapshot and mutation storage is owned by the fixtures. Tests use a real in-memory snapshot manager and temporary watermark store with fake clipboard, focus, and input services. Runtime construction and logger resets are serialized; this is not a claim that every process-global runtime setting is isolated. The tests assert captured JSON, implicit latest, explicit lease eligibility, input counters, clipboard restoration, and caller-owned barrier cleanup. This does not claim a native-app paste or live clipboard demonstration.
CI runs the named isolated suite with automation actions disabled and nonempty proof guards. The shared Node policy verifies its filter and isolation. Node policy checks (15), supplemental-workflow contracts (16), docs lint, scoped SwiftFormat/strict SwiftLint, and independent Autoreview at the requested P0 threshold pass.