← Back to Pull requests

fix(bridge): verify typed native value readbacks #815

Merged
steipete merged 25 files (2145 lines) on Sep 25, 2026 20:29 UTC
View on GitHub
steipete steipete commented on Sep 25, 2026 17:52 UTC
Author

Summary

A native value mutation can be verified successfully and then rejected by Bridge because the observed presentation is not an exact copy of the requested text. For example, a slider can read back 57.99999999999999 after a request for 58. Selected-only controls also use AXSelected, whereas the previous Bridge rule required AXSetValue.

Keep coercion and comparison in the native automation owner, and carry a typed witness from the exact observation that verified the mutation. Bridge uses those shared rules while still checking the target, action, presentation, anchor, canonical outcome, and signed receipt. Text stays literal and integer-typed readbacks retain exact precision; there is no generic numeric-string relaxation. The service no longer performs a second read to construct a potentially different reported value.

The optional witness is negotiated through an authenticated client offer and projected out before signing for older clients. The host captures the historical presentation from the same raw observation and restores it only for non-offering clients, after validating the original typed request and rendering. Missing witnesses retain the existing strict legacy contract; malformed or inconsistent witnesses are rejected. Raw and receiptless response projections remain compatible. This adds no input route, activation, mutation replay, protocol-version bump, or dependency change.

Compatibility review found a real edge: the old native formatter renders boxed numeric 0/1 as false/true. The repair preserves those successful old-client Boolean requests without treating arbitrary text as numeric. The reported native 58.0 example already rendered as 58 on the old path; separate raw Swift/Float and signed-zero forms are covered too.

The new signing boundary must not inherit lossy native conversions that the old exact Bridge check happened to mask. Boolean readbacks now require actual Boolean or exact numeric 0/1; fractional values are not truncated. Integer-control string coercion keeps its fast integer path and uses bounded exact decimal/scientific conversion instead of passing through Double. Fractional tails, underflow-to-zero, overflow, malformed forms, and undocumented hexadecimal fallback are refused before writing. Literal text and floating-point control semantics remain separate.

Verification

  • Authoritative regression: the native witness accepted the rounded readback while the original Bridge binding rejected it; the same test passes with the repair.

  • Native setter tests: 32 declarations / 90 expanded cases, including a 15-shape raw-observation matrix, exact Boolean readbacks, exact integer boundaries/scientific notation, literal text, idempotence, nonfinite values, and unavailable readback.

  • Bridge contracts: 20 tests across binding and wire suites, including signed roundtrips, tampering, missing/malformed witnesses, old-decoder digest compatibility, forged legacy presentation, validation before projection, and rejection of lossy Boolean/integer results.

  • The compatibility regression first failed in the unchanged projection path while the other eight binding tests passed; the corrected projection and unchanged exact legacy binder now pass together.

  • Boolean and exact-integer regressions reproduced false native/signed acceptance before the shared policy repair, then passed without changing result-trust checks.

  • A production Bridge host/client test uses a private Unix socket, real handshakes and signing/receipt verification, and injected synthetic automation/permissions. Three valid observations produced verified signed receipts. All three invalid observations reached the injected provider, raised DesktopActionFailure, and left no retained or archived receipt. Own-process identity was supplied explicitly; trust checks were not weakened. This does not test real AX effects, default TCC grants, separate-process isolation, or live desktop parity.

  • Final-source strict SwiftLint and SwiftFormat pass all 21 changed/new Swift files; documentation lint, YAML parsing, and whitespace checks pass. The final complete-candidate isolated Codex autoreview is scoped-clean with no actionable P0–P2 findings.

  • Dedicated hosted selections require both native and Bridge suites and nonzero test counts.

  • Proof is inert: synthetic elements, codecs, and the production host/client signing path under injected services; no live desktop input was posted. A signed matching CLI/GUI native canary remains part of subsequent deployment qualification, not a claim made by this PR.
  • Updates Bridge and set-value documentation plus the Unreleased changelog. No release publication.

    Final receipt proof and compatibility decision

    Captured output from the final 003eee48f2c07e53f3b75f28023361ee962d3a1e local run is below (build chatter and unrelated suite output omitted; test lines unchanged). The production host/client test checks three positive signed receipts with validateIntegrity() and the negotiated attestation, then exercises the three rejected observations shown here. The rejected calls reach the injected provider; none produces a retained or archived receipt. Positive receipts are asserted, not printed individually.

    ◇ Suite PeekabooBridgeSetValueHostClientTests started.
    ◇ Test "production signing accepts exact readbacks and never attests lossy coercion" started.
    Synthetic value rejection: DesktopActionFailure
    Synthetic rejected value receipt: retained=false, archived=false
    Synthetic value rejection: DesktopActionFailure
    Synthetic rejected value receipt: retained=false, archived=false
    Synthetic value rejection: DesktopActionFailure
    Synthetic rejected value receipt: retained=false, archived=false
    ✔ Test "production signing accepts exact readbacks and never attests lossy coercion" passed after 0.049 seconds.
    ✔ Suite PeekabooBridgeSetValueHostClientTests passed after 0.050 seconds.
    ✔ Test run with 1 test in 1 suite passed after 0.050 seconds.
    

    The exact-head test defines the observed cases: valid numeric Boolean 0/1 and rounded slider 57.99999999999999 for 58; rejected Boolean 0.5/1.5 and integer text 1.0000000000000001 observed as 1. This is production transport/handshake/signing/receipt proof with synthetic automation and permissions, not live AX, default TCC, or separate-process isolation proof. The final-head Core CI job also passed and runs this same required suite with nonzero-test guards.

    Maintainer decision for this repair: accept the documented exact decimal/scientific integer-input contract. Baseline docs, CLI help, and MCP schema do not promise hexadecimal strings; their acceptance arose incidentally from the lossy Double fallback. Keeping that fallback would preserve the precision defect, while adding a second radix parser would add complexity without an identified documented consumer contract. This intentionally narrows integer-control string input; it is not claimed to be transparent to every external integration. Upgrade affected calls by supplying an exact in-range decimal integer (for example 16 instead of 0x10), or a typed integer through the SDK/MCP. Literal text and floating-point controls retain their distinct semantics. Rejection happens before the write, and existing stored receipts/absent-witness exact matching remain supported.

    Diff: 2145 lines (+1974 / -171) across 25 files Reviewer: steipete Review duration: 156m
    All Vouch review confidence checks passed
    Residual risk 0.14 = Change Risk (0.86) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.86 · 2145 lines diff across 25 files
    0.86
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.91 · 5 substantive comment(s)
    0.91
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    83%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.400
    Self Review self_review
    0.140
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    14 items
    clawsweeper[bot] clawsweeper[bot] commented on Sep 25, 2026 17:52 UTC
    Bot

    <!-- clawsweeper-pr-ack:opened item=815 -->
    🦞👀
    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 -->

    cursor[bot] cursor[bot] commented on Sep 25, 2026 17:52 UTC
    Bot

    PR Summary

    <!-- CURSOR_SUMMARY -->
    Medium Risk
    Changes signed Bridge set-value receipt binding and native mutation verification semantics; malformed witnesses are rejected, but regressions could affect remote value mutations and retry safety.

    Overview
    Fixes cases where native accessibility set-value succeeded but Bridge rejected the result because newValue had to exactly match the request (e.g. slider readback 57.99999999999999 vs requested 58).

    Native automation now attaches an optional ElementValueVerification witness (resolved kind, tagged readback, legacy presentation) on value and selected-only mutations, with shared coercion/comparison in ElementValueMutationSemantics. Bridge binds signed setValue responses to that witness when clients negotiate setValueVerification (protocol ≥1.37); without it, exact-string binding remains. Responses are validated before legacy projection strips the witness and restores historical presentation for old decoders.

    Coercion is tightened: integer strings use exact decimal/scientific parsing (no lossy Double), fractional Boolean readbacks fail verification, and text fields stay literal. CI adds native and Bridge contract suites; docs and changelog describe the behavior.

    <sup>Reviewed by Cursor Bugbot for commit 003eee48f2c07e53f3b75f28023361ee962d3a1e. Bugbot is set up for automated code reviews on this repo. Configure here.</sup>
    <!-- /CURSOR_SUMMARY -->

    cursor[bot] cursor[bot] commented on code on Sep 25, 2026 18:00 UTC
    Code Review
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/Core/Protocols/ElementValueVerification.swift:1
    @@ -0,0 +1,246 @@
    +import Foundation
    +
    +/// The comparison selected from the resolved native element, not inferred from a caller's text.
    +public enum ElementValueKind: String, Codable, Equatable, Sendable {
    +    case bool
    +    case int
    +    case double
    +    case string
    +}
    +
    +/// A tagged native scalar. Unlike an untagged JSON number, this preserves integer versus floating readback.
    +public enum ElementValueReadback: Equatable, Sendable, Codable {
    +    case bool(Bool)
    +    case int(Int)
    +    case double(Double)
    +    case string(String)
    +
    +    public var kind: ElementValueKind {
    +        switch self {
    +        case .bool: .bool
    +        case .int: .int
    +        case .double: .double
    +        case .string: .string
    +        }
    +    }
    +
    +    public var displayString: String {
    +        switch self {
    +        case let .bool(value): String(value)
    +        case let .int(value): String(value)
    +        case let .double(value):
    +            // The display must remain stable when signed JSON canonicalizes integral numbers and negative zero.
    +            Int(exactly: value).map(String.init) ?? String(value)

    Legacy readback contract rejects integral doubles

    Medium Severity

    <!-- DESCRIPTION START -->
    ElementValueReadback.displayString renders an integral double as an integer string, and the host now copies that into newValue. After projectingSetValueVerification drops the witness, Bridge still requires newValue to equal the request's own displayString, so a literal "58.0" request fails even when the native readback was exactly 58.0. The write can succeed on the host while an older or receiptless client rejects the signed result.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: e97bcf63-72bf-474d-8212-c9390656544c -->

    <!-- LOCATIONS START
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/Core/Protocols/ElementValueVerification.swift#L30-L33
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/UIAutomationService+ElementActions.swift#L86-L88
    Core/PeekabooCore/Sources/PeekabooBridge/PeekabooBridgeOperationResultContracts.swift#L760-L763
    LOCATIONS END -->
    <details>
    <summary>Additional Locations (2)</summary>

  • Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/UIAutomationService+ElementActions.swift#L86-L88

  • Core/PeekabooCore/Sources/PeekabooBridge/PeekabooBridgeOperationResultContracts.swift#L760-L763
  • </details>

    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmVhNTMwYjEzLWMxODctNGYyMC05YzQxLWY2MDc1YzE5MGY0MiIsImVuY3J5cHRpb25LZXkiOiJOWVZUdG9MVDc0WnhZN3oweU9Dd2hfbVo5UTZWYWRsSXpmYWpwVm9uY1d3IiwiYnJhbmNoIjoiY29kZXgvc2V0LXZhbHVlLXJlYWRiYWNrLXdpdG5lc3MiLCJyZXBvT3duZXIiOiJvcGVuY2xhdyIsInJlcG9OYW1lIjoiUGVla2Fib28iLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" 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>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmVhNTMwYjEzLWMxODctNGYyMC05YzQxLWY2MDc1YzE5MGY0MiIsImVuY3J5cHRpb25LZXkiOiJOWVZUdG9MVDc0WnhZN3oweU9Dd2hfbVo5UTZWYWRsSXpmYWpwVm9uY1d3IiwiYnJhbmNoIjoiY29kZXgvc2V0LXZhbHVlLXJlYWRiYWNrLXdpdG5lc3MiLCJyZXBvT3duZXIiOiJvcGVuY2xhdyIsInJlcG9OYW1lIjoiUGVla2Fib28iLCJwck51bWJlciI6ODE1LCJjb21taXRTaGEiOiIzOWRjNDc3YmFlMzgyOGU2M2M0MmRkNzZiZTVjMjg5ZmRkMWQ2ZjU2IiwicHJvdmlkZXIiOiJnaXRodWIifX0" 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 39dc477bae3828e63c42dd76be5c289fdd1d6f56. Configure here.</sup>

    cursor[bot] cursor[bot] commented on Sep 25, 2026 18:00 UTC
    Reviewer

    <!-- BUGBOT_REVIEW -->
    <!-- BUGBOT_REVIEW_STALE -->
    Stale Bugbot comment from a previous run.

    clawsweeper[bot] clawsweeper[bot] commented on Sep 25, 2026 18:33 UTC
    Bot

    Codex review: needs maintainer review before merge. _Reviewed September 25, 2026, 4:04 PM ET / 20:04 UTC (Revision 5)._

    ClawSweeper review

    What this changes

    The branch carries typed native set-value readbacks through Bridge signed results, preserves older clients’ response format, and adds regression tests, CI coverage, and documentation.

    Merge readiness

    ✅ Ready for maintainer review

    Keep open. Current main still rejects a rounded value that native automation can verify. The current PR head has production-path receipt proof, and the earlier Boolean-readback finding has been addressed. No remaining actionable defect was established.

    Priority: P2
    Reviewed head: 003eee48f2c07e53f3b75f28023361ee962d3a1e

    Review scores

    | Measure | Result | What it means |
    |---|---|---|
    | Overall readiness | 🦞 diamond lobster (5/6) | The patch has focused boundary checks, compatibility coverage, and an exact-head production transport trace; its native desktop qualification remains outside the supplied proof. |
    | Proof confidence | 🦞 diamond lobster (5/6) | Sufficient (terminal): The exact-head terminal trace exercises a real Bridge host and client over a private socket with injected automation: valid readbacks yield checked signed receipts, while three invalid readbacks fail without a retained or archived receipt. Native tests supplement that transport proof; live Accessibility and default permissions were not exercised. Existing-style receipt and old-decoder digest tests support stored-result compatibility. |
    | Patch quality | 🦞 diamond lobster (5/6) | No actionable review findings were identified. |

    Verification

    | Check | Result | Evidence |
    |---|---|---|
    | Real behavior | Verified | Sufficient (terminal): The exact-head terminal trace exercises a real Bridge host and client over a private socket with injected automation: valid readbacks yield checked signed receipts, while three invalid readbacks fail without a retained or archived receipt. Native tests supplement that transport proof; live Accessibility and default permissions were not exercised. Existing-style receipt and old-decoder digest tests support stored-result compatibility. |
    | Evidence reviewed | 7 items | Current-main gap: Fetched main still requires an exact set-value presentation and has no typed witness file; its native setter already permits floating-point readbacks within tolerance.<br>Native verification: The setter captures the readback from the write and constructs the witness from that observation; postvalidation uses the same witness rather than taking another read.<br>Signed-result boundary: Bridge binds a present witness to the original request, action, target, and displayed readback; absent witnesses retain exact legacy matching. The host validates before removing a witness for non-offering clients and before signing. |
    | Findings | None | None. |
    | Security | None | None. |

    How this fits together

    Peekaboo’s CLI and MCP set-value requests reach a macOS Accessibility element through native automation, sometimes via Bridge. Bridge checks the host’s result before reporting the write as verified and issuing a signed receipt.

    flowchart LR
      A[CLI or MCP value request] --> B[Bridge client]
      B --> C[Authenticated session and capability]
      C --> D[Bridge host]
      D --> E[Native Accessibility setter]
      E --> F[Typed readback check]
      F --> G[Signed result or legacy response]
    

    Before merge

    None.

    <details>
    <summary><strong>Agent review details</strong></summary>

    Security

    None.

    Review metrics

    | Metric | Value | Why it matters |
    |---|---|---|
    | Swift source and test growth | production +315 net lines, tests +1446 net lines | The production growth implements a shared witness and comparison policy; most added lines cover native, wire, and host/client behavior. |

    Technical review

    Best possible solution:

    Keep native coercion and readback comparison in one policy, let capable Bridge clients use the typed witness, and preserve exact legacy response binding.

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

    Yes, from source: native verification allows a slider request for 58 to read back 57.99999999999999, while current main’s Bridge binder requires an exact presentation. I did not execute a live desktop reproduction.

    Is this the best way to solve the issue?

    Yes. The shared native comparison and typed witness repair that mismatch without applying numeric-string tolerance to literal text, while legacy projection preserves older clients’ exact contract.

    AGENTS.md: found and applied where relevant.

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

    Labels

    Label changes:

    No label changes.

    Label justifications:

  • P2: This repairs a bounded Bridge set-value failure without evidence of a broader runtime outage.

  • merge-risk: 🚨 compatibility: Integer-control hexadecimal strings that incidentally worked before will be refused; the collaborator explicitly accepted and documented that upgrade change.

  • merge-risk: 🚨 security-boundary: Typed evidence now participates in deciding whether a remote result receives a signed success receipt, a boundary covered by negative receipt and tampering tests.

  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.

  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head terminal trace exercises a real Bridge host and client over a private socket with injected automation: valid readbacks yield checked signed receipts, while three invalid readbacks fail without a retained or archived receipt. Native tests supplement that transport proof; live Accessibility and default permissions were not exercised. Existing-style receipt and old-decoder digest tests support stored-result compatibility.

  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head terminal trace exercises a real Bridge host and client over a private socket with injected automation: valid readbacks yield checked signed receipts, while three invalid readbacks fail without a retained or archived receipt. Native tests supplement that transport proof; live Accessibility and default permissions were not exercised. Existing-style receipt and old-decoder digest tests support stored-result compatibility.
  • Evidence

    What I checked:

  • Current-main gap: Fetched main still requires an exact set-value presentation and has no typed witness file; its native setter already permits floating-point readbacks within tolerance. (Core/PeekabooCore/Sources/PeekabooBridge/PeekabooBridgeOperationResultContracts.swift:760, b1d3bb62a366)

  • Native verification: The setter captures the readback from the write and constructs the witness from that observation; postvalidation uses the same witness rather than taking another read. (Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/ActionInputDriver.swift:458, 003eee48f2c0)

  • Signed-result boundary: Bridge binds a present witness to the original request, action, target, and displayed readback; absent witnesses retain exact legacy matching. The host validates before removing a witness for non-offering clients and before signing. (Core/PeekabooCore/Sources/PeekabooBridge/PeekabooBridgeOperationResultContracts.swift:760, 003eee48f2c0)

  • Production-path proof: The PR body supplies terminal output for the exact-head test using a real Bridge host, client, socket, handshake, signing, and receipt path with injected automation. Three invalid observations reached the provider, returned DesktopActionFailure, and produced no retained or archived receipt; the test source checks three positive signed receipts. The proof does not claim live Accessibility or default permission behavior. (Core/PeekabooCore/Tests/PeekabooTests/PeekabooBridgeSetValueHostClientTests.swift:67, 003eee48f2c0)

  • Stored-receipt compatibility: Wire tests validate an existing-style receipt without a witness and confirm that a non-offering client can reconstruct the signed response digest after projection. Receipt bundles decode canonical response bytes and verify their hash. (Core/PeekabooCore/Tests/PeekabooBridgeTests/PeekabooBridgeSetValueVerificationWireTests.swift:112, 003eee48f2c0)

  • Accepted compatibility change: In the PR discussion, the collaborator explicitly accepted rejecting previously incidental hexadecimal integer strings and documented decimal or typed-integer inputs as the upgrade path. See https://github.com/openclaw/Peekaboo/pull/815#issuecomment-5838627895. (docs/commands/set-value.md:28, 003eee48f2c0)
  • Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • 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.
  • History

    <details>
    <summary>Review history (4 earlier review cycles)</summary>

    <!-- clawsweeper-review-history v=1 total=4 -->

  • reviewed 2026-09-25T18:32:41.764Z sha 9dada4c1b4f6fcf02b2cb5618c26fa593cc57574 :: needs real behavior proof before merge. :: [P1] Reject fractional readbacks before signing Boolean success

  • reviewed 2026-09-25T18:49:00.066Z sha 9dada4c1b4f6fcf02b2cb5618c26fa593cc57574 :: needs real behavior proof before merge. :: [P1] Reject fractional readbacks before signing Boolean success

  • reviewed 2026-09-25T19:33:06.351Z sha 003eee48f2c07e53f3b75f28023361ee962d3a1e :: needs real behavior proof before merge. :: none

  • reviewed 2026-09-25T19:58:26.182Z sha 003eee48f2c07e53f3b75f28023361ee962d3a1e :: needs maintainer review before merge. :: none
  • </details>

    </details>

    <!-- clawsweeper-verdict:needs-human item=815 sha=003eee48f2c07e53f3b75f28023361ee962d3a1e confidence=high updated_at=2026-09-25T20:02:55Z reviewed_at=2026-09-25T20:04:42.763Z lease_owner=github-run-36183268958-1 lease_comment_id=5838674230 source_revision=5acbd5189a6a884b7e9ef78a98db624665177f5405bde598ee01594a42d7eebf live_verification=absent -->
    <!-- clawsweeper-review-state:ready item=815 sha=003eee48f2c07e53f3b75f28023361ee962d3a1e v=1 -->

    <!-- clawsweeper-review-version item=815 reviewed_at=2026-09-25T20:04:42.763Z sha=003eee48f2c07e53f3b75f28023361ee962d3a1e source_revision=5acbd5189a6a884b7e9ef78a98db624665177f5405bde598ee01594a42d7eebf lease_owner=github-run-36183268958-1 lease_comment_id=5838674230 v=1 -->

    <!-- clawsweeper-review item=815 -->

    cursor[bot] cursor[bot] commented on Sep 25, 2026 18:34 UTC
    Reviewer

    <!-- 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=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9BTExfSU5fQ1VSU09SIiwiZGF0YSI6eyJyZWRpc0tleSI6ImJ1Z2JvdC1tdWx0aTo4MWM1YmEwZi01ZTBhLTQ2N2ItYTk0NC00ZTI2YTI3YjM0YTciLCJlbmNyeXB0aW9uS2V5IjoidDhHQTRkTlZCdHBITGkyS3FzSGhURFhPa0ltdkRMNXMwaVdsQU5zS1RfUSIsImJyYW5jaCI6ImNvZGV4L3NldC12YWx1ZS1yZWFkYmFjay13aXRuZXNzIiwicmVwb093bmVyIjoib3BlbmNsYXciLCJyZXBvTmFtZSI6IlBlZWthYm9vIiwicHJvdmlkZXIiOiJnaXRodWIifX0" 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 9dada4c1b4f6fcf02b2cb5618c26fa593cc57574. Configure here.</sup>

    cursor[bot] cursor[bot] commented on code on Sep 25, 2026 18:34 UTC
    Code Review
    Core/PeekabooCore/Sources/PeekabooBridge/PeekabooBridgeResponse+SetValueVerification.swift:1
    @@ -0,0 +1,30 @@
    +import PeekabooAutomationKit
    +
    +extension PeekabooBridgeResponse {
    +    /// Old receivers drop unknown result fields before reconstructing the signed response digest.
    +    func projectingSetValueVerification(offered: Bool, request: PeekabooBridgeRequest) throws -> Self {
    +        switch self {
    +        case let .elementActionResult(result):
    +            var newValue = result.newValue
    +            if case .setValue = request.unwrappedOperationRequest, let witness = result.valueVerification {
    +                // Validate before stripping: otherwise a forged legacy spelling could bypass typed request binding.
    +                let plan = PeekabooBridgeOperationResultSemantics.requestPlan(for: request, vocabulary: .current)
    +                try plan.validateBoundTypedResponse(self, outcome: nil)
    +                newValue = witness.legacyPresentation
    +            }
    +            guard !offered else { return self }
    +            return .elementActionResult(.init(
    +                target: result.target,
    +                actionName: result.actionName,
    +                anchorPoint: result.anchorPoint,
    +                oldValue: result.oldValue,
    +                newValue: newValue))

    Zero-one values break old clients

    High Severity

    <!-- DESCRIPTION START -->
    Legacy projection replaces newValue with legacyPresentation from describe(), and that helper’s Bool-first NSNumber cast turns native 0 and 1 into false/true. Older clients still require an exact match to the requested display string, so attested set-value of 0 or 1 fails after the write already succeeded.
    <!-- DESCRIPTION END -->

    <!-- BUGBOT_BUG_ID: f41ecde6-5387-41cc-a887-4b6820cb0358 -->

    <!-- LOCATIONS START
    Core/PeekabooCore/Sources/PeekabooBridge/PeekabooBridgeResponse+SetValueVerification.swift#L7-L21
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/Core/Protocols/ElementValueVerification.swift#L188-L198
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/ActionInputDriver.swift#L451-L476
    LOCATIONS END -->
    <details>
    <summary>Additional Locations (2)</summary>

  • Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/Core/Protocols/ElementValueVerification.swift#L188-L198

  • Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/ActionInputDriver.swift#L451-L476
  • </details>

    <div><a href="https://cursor.com/open?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9DVVJTT1IiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmE1NDA4OTU0LTA3NTctNDlhOS1iYWVmLTQ5NjEyZDQwOWFiMyIsImVuY3J5cHRpb25LZXkiOiJsQlNlb3FtOVQ5VFQwc1RVdTc3UHZHR1hDRXVLai00M0o0SG8xZ3hMcmdZIiwiYnJhbmNoIjoiY29kZXgvc2V0LXZhbHVlLXJlYWRiYWNrLXdpdG5lc3MiLCJyZXBvT3duZXIiOiJvcGVuY2xhdyIsInJlcG9OYW1lIjoiUGVla2Fib28iLCJwcm92aWRlciI6ImdpdGh1YiJ9fQ" 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>&nbsp;<a href="https://cursor.com/agents?link=eyJ2ZXJzaW9uIjoxLCJ0eXBlIjoiQlVHQk9UX0ZJWF9JTl9XRUIiLCJkYXRhIjp7InJlZGlzS2V5IjoiYnVnYm90OmE1NDA4OTU0LTA3NTctNDlhOS1iYWVmLTQ5NjEyZDQwOWFiMyIsImVuY3J5cHRpb25LZXkiOiJsQlNlb3FtOVQ5VFQwc1RVdTc3UHZHR1hDRXVLai00M0o0SG8xZ3hMcmdZIiwiYnJhbmNoIjoiY29kZXgvc2V0LXZhbHVlLXJlYWRiYWNrLXdpdG5lc3MiLCJyZXBvT3duZXIiOiJvcGVuY2xhdyIsInJlcG9OYW1lIjoiUGVla2Fib28iLCJwck51bWJlciI6ODE1LCJjb21taXRTaGEiOiI5ZGFkYTRjMWI0ZjZmY2YwMmIyY2I1NjE4YzI2ZmE1OTNjYzU3NTc0IiwicHJvdmlkZXIiOiJnaXRodWIifX0" 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 9dada4c1b4f6fcf02b2cb5618c26fa593cc57574. Configure here.</sup>

    steipete steipete commented on code on Sep 25, 2026 18:38 UTC
    Code Review
    Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/Core/Protocols/ElementValueVerification.swift:1
    @@ -0,0 +1,246 @@
    +import Foundation
    +
    +/// The comparison selected from the resolved native element, not inferred from a caller's text.
    +public enum ElementValueKind: String, Codable, Equatable, Sendable {
    +    case bool
    +    case int
    +    case double
    +    case string
    +}
    +
    +/// A tagged native scalar. Unlike an untagged JSON number, this preserves integer versus floating readback.
    +public enum ElementValueReadback: Equatable, Sendable, Codable {
    +    case bool(Bool)
    +    case int(Int)
    +    case double(Double)
    +    case string(String)
    +
    +    public var kind: ElementValueKind {
    +        switch self {
    +        case .bool: .bool
    +        case .int: .int
    +        case .double: .double
    +        case .string: .string
    +        }
    +    }
    +
    +    public var displayString: String {
    +        switch self {
    +        case let .bool(value): String(value)
    +        case let .int(value): String(value)
    +        case let .double(value):
    +            // The display must remain stable when signed JSON canonicalizes integral numbers and negative zero.
    +            Int(exactly: value).map(String.init) ?? String(value)

    Checked against the actual native baseline and addressed the compatibility class in 9dada4c1b4f6fcf02b2cb5618c26fa593cc57574. Native AX values are boxed CFNumbers/NSNumbers. The old safeValueDescription checks Bool, then Int, before Double, so native NSNumber(58.0) already rendered as "58" on e3463aba4; the literal numeric-control request "58.0" was already rejected by the old exact binder. Text-field strings remain literal on both paths.

    There was a real related regression for native numeric 0/1 and Boolean requests. The repair captures legacyPresentation from the same raw observation, validates it and the original typed request before projection, then restores it only for non-offering clients. Raw Swift Double/Float spellings and signed zero are also covered. The native suite passes 26 declarations/55 cases and the Bridge suites pass 18 tests, including the previously failing compatibility case and signed old-decoder byte checks. No request text is copied into the observed value.

    Baseline formatter: https://github.com/openclaw/Peekaboo/blob/e3463aba4f221974e8df2385266368e12c1ee020/Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/UIAutomationService%2BElementActions.swift#L396

    steipete steipete commented on code on Sep 25, 2026 18:38 UTC
    Code Review
    Core/PeekabooCore/Sources/PeekabooBridge/PeekabooBridgeResponse+SetValueVerification.swift:1
    @@ -0,0 +1,30 @@
    +import PeekabooAutomationKit
    +
    +extension PeekabooBridgeResponse {
    +    /// Old receivers drop unknown result fields before reconstructing the signed response digest.
    +    func projectingSetValueVerification(offered: Bool, request: PeekabooBridgeRequest) throws -> Self {
    +        switch self {
    +        case let .elementActionResult(result):
    +            var newValue = result.newValue
    +            if case .setValue = request.unwrappedOperationRequest, let witness = result.valueVerification {
    +                // Validate before stripping: otherwise a forged legacy spelling could bypass typed request binding.
    +                let plan = PeekabooBridgeOperationResultSemantics.requestPlan(for: request, vocabulary: .current)
    +                try plan.validateBoundTypedResponse(self, outcome: nil)
    +                newValue = witness.legacyPresentation
    +            }
    +            guard !offered else { return self }
    +            return .elementActionResult(.init(
    +                target: result.target,
    +                actionName: result.actionName,
    +                anchorPoint: result.anchorPoint,
    +                oldValue: result.oldValue,
    +                newValue: newValue))

    This exact non-offering-client behavior is pre-existing, not introduced by the repair. On e3463aba4, the default native value reader already used the same Bool-first formatter: native numeric 0/1 rendered as "false"/"true". Consequently, the old exact binder rejected numeric requests whose display strings were "0"/"1", while Boolean false/true requests could succeed.

    The current projection intentionally preserves that old contract. Normalizing the old-client result to 0/1 would break those previously successful Boolean requests. Current offering clients use the attested typed readback and accept the native numeric verification; non-offering clients retain exact legacy matching. The new regression first failed for the native Boolean requests and now passes, and separate tests reject fabricated legacy rendering or attempts to bypass typed request validation before stripping.

    The baseline formatter was moved unchanged into the shared helper; it was not newly introduced here: https://github.com/openclaw/Peekaboo/blob/e3463aba4f221974e8df2385266368e12c1ee020/Core/PeekabooAutomationKit/Sources/PeekabooAutomationKit/Services/UI/UIAutomationService%2BElementActions.swift#L396

    steipete steipete commented on Sep 25, 2026 19:05 UTC
    Author

    Accepted the fractional-Boolean finding. This was inherited native behavior, but the old Bridge exact-string check rejected the resulting presentation; the new typed witness must not promote that mismatch into signed success. The fix belongs in the shared native comparison owner: actual Boolean or exact numeric 0/1 only, with no truncation or tolerance for Boolean readbacks.

    Regression tests now reproduce the native and signed failures before the fix. The same audit found lossy integer-string fallback through Double (for example, a large decimal integer rounding to its neighbor), which is being replaced with bounded exact decimal/scientific integer conversion. Literal text and floating-point control semantics remain separate.

    This PR remains held until those repairs pass native, signed-wire, and an inert production host/client signing-path harness, followed by full-candidate review and fresh exact-head CI. The harness uses synthetic automation and a private local socket; it does not claim live desktop or all-app parity. The unrelated hosted library filesystem failure is also preserved, and assertions will not be weakened for that failure.

    steipete steipete commented on Sep 25, 2026 19:52 UTC
    Author

    The final-head PR body now includes the captured production host/client output and a link to the passing exact-head Core CI job. All three injected invalid observations produced DesktopActionFailure with retained=false, archived=false; the same passing test checks all three allowed signed receipts and their attestation/integrity. The source/transport proof is explicitly synthetic, not live AX or default TCC qualification.

    Maintainer decision: accept the documented exact decimal/scientific integer-input restriction. Baseline docs/help/schema do not promise hexadecimal input. The previous floating-point fallback could round hexadecimal integers as well, so it should not be retained as a compatibility path. Callers using hexadecimal strings for integer-resolved controls must supply an exact decimal equivalent or a typed integer without converting through floating point. This is an intentional upgrade change, not a claim of universal external-client compatibility.

    No production or test source changed after the reviewed 003eee48f2c07e53f3b75f28023361ee962d3a1e head.

    @clawsweeper re-review

    clawsweeper[bot] clawsweeper[bot] commented on Sep 25, 2026 19:55 UTC
    Bot

    <!-- clawsweeper-command-ack:5838627895 -->
    <!-- clawsweeper-command-status:815:re_review:command-5838627895-muhdrkwo-c5b2b5aa82a17ca7eff7ac2fd398be9686572dacbacda834857b40b967354b56 -->
    🦞👀
    Exact review queued.

    <!-- clawsweeper-command-progress:start -->
    Re-review progress:

  • State: Complete

  • Detail: The durable review result and its route handoff completed.

  • Run: https://github.com/openclaw/clawsweeper/actions/runs/36184167536

  • Updated: 2026-09-25T20:10:51.903Z

  • <!-- clawsweeper-command-progress:end -->

    steipete steipete commented on Sep 25, 2026 20:29 UTC
    Author

    Landed as 4f584990748f7e46687b396d1ec382af2af0ff81 after verifying the exact reviewed head 003eee48f2c07e53f3b75f28023361ee962d3a1e and its merge tree. Visible main was pulled without recursing into submodules; the landed tree exactly matches the locally tested combined tree below.

    Native verification and signed Bridge binding now share one scalar comparison owner and the same typed observation. This removes the redundant post-verification AX read and fixes rounded numeric or selected-only observations being rejected merely because their rendered text/action differed. Authenticated capability negotiation and validated old-client projection preserve the existing witness-free receipt contract.

    Review also caught a real inherited truncation hazard: fractional numeric readbacks could masquerade as Boolean success. That is now exact Boolean or numeric 0/1 only. Integer string coercion no longer passes through lossy floating point. The intentional exact decimal/scientific contract and hexadecimal migration guidance are documented in this PR.

    Verification at the final head:

  • Native setter suite: 32 declarations / 90 expanded cases, including pre-write rejection, exact integer boundaries, Boolean readbacks, text, and legacy presentation.

  • Model/wire contracts: 20 tests, covering signing, tampering, request binding, and older-decoder compatibility.

  • Production Bridge host/client harness: the real socket, handshake, signing and receipt verification path, using synthetic automation/permissions and explicit own-process identity. Three valid observations produce verified signed receipts; all three invalid observations reach the injected provider and fail with no retained/archived receipt. Captured output is in the PR body.

  • Strict style checks across 21 Swift files, docs/YAML/whitespace checks, and complete-candidate isolated Codex autoreview passed without actionable P0-P2 findings.

  • Exact-head macOS build/tests, supplemental/full-safe, and CodeQL all passed.
  • The earlier superseded-head library failure showed widespread hosted filesystem EIO writes, including unchanged tests and later manifests; it was not established to be disk-full. No assertions were weakened for it. The final-head replacement passed. This does not claim live AX effects, default GUI trust/TCC, separate-process isolation, or full desktop parity. The Unreleased changelog and command/Bridge documentation are included; no release publication.

    An additional local combined-tree pass with #814 tested tree 3d980d51f2ce2d541135f6564ede7cd0ed03e3c6: 37 declarations / 40 expanded cases passed. All committed submodules, all 14 resolved dependency revisions, and the cache's source paths were verified. The second command reused the artifacts built by the first. These commands ran from the task-owned combined worktree with /bin/bash and login disabled:

    set -o pipefail
    PEEKABOO_INCLUDE_AUTOMATION_TESTS=false PEEKABOO_INCLUDE_AMBIENT_STATE_TESTS=false PEEKABOO_RUN_INPUT_AUTOMATION_TESTS=false RUN_AUTOMATION_READ=false RUN_LOCAL_TESTS=false INTEGRATION_TESTS=0 swift test --package-path Core/PeekabooCore --scratch-path /private/tmp/peekaboo-current-performance-cleanup/Core/PeekabooCore/.build --skip-update --disable-automatic-resolution --no-parallel --jobs 4 --filter '^PeekabooBridgeTests[.](PeekabooBridgeSetValueVerificationTests|PeekabooBridgeSetValueVerificationWireTests)/|^PeekabooTests[.]PeekabooBridgeSetValueHostClientTests/' 2>&1 | tee /private/tmp/peekaboo-combined-814-815.MUUCdT-bridge.log
    
    PEEKABOO_INCLUDE_AUTOMATION_TESTS=false PEEKABOO_INCLUDE_AMBIENT_STATE_TESTS=false PEEKABOO_RUN_INPUT_AUTOMATION_TESTS=false RUN_AUTOMATION_READ=false RUN_LOCAL_TESTS=false INTEGRATION_TESTS=0 swift test --package-path Core/PeekabooCore --scratch-path /private/tmp/peekaboo-current-performance-cleanup/Core/PeekabooCore/.build --skip-build --disable-automatic-resolution --no-parallel --filter 'Explicit false mutation dispatch survives failed result summarization|Capture and image traces classify only focus-capable requests as mutations|Native capture success receipt reaches execution trace through the real agent bridge|Trace allowlists audit fields and omits all content-bearing values|Trace replaces arbitrary field names with stable ordinals at every object depth|SnapshotInvalidationMetadataTests|Browser tool legacy client refuses connect and mapped mutation without outcomes|Browser tool namespaces provider metadata and strips reserved semantic claims|Browser tool rejects mutation result without canonical outcome|Browser tool allows outcome-free result from read-only provider call|Legacy browser reads cannot promote provider metadata claims|UI element double zero has stable canonical bytes|Bridge JSON double zero has stable canonical bytes recursively|setValue semantic planning follows canonical numeric values without coercing strings' 2>&1 | tee /private/tmp/peekaboo-combined-814-815.MUUCdT-trace-provider-canonical.log
    

    Reviewers
    Assignees
    steipete steipete
    Labels
    risk: low confidence: 83.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 85.5% (HIGH) · Higher = larger blast radius
    85.5%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 83.8% · Lower = rushed or shallow review
    83.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 13.8% · Safe to merge
    13.8%