diff --git a/jevdual/docs/native-row-contract.md b/jevdual/docs/native-row-contract.md index b7901afa..c0f96b3c 100644 --- a/jevdual/docs/native-row-contract.md +++ b/jevdual/docs/native-row-contract.md @@ -51,3 +51,11 @@ This is built and checked offline, not a delivered or live-qualified capability. | Same-token replay | existing operation projection and ordinary consumer; no new dispatch | producer/retained faults stay unknown, presentation faults stay unverified, no second press | These cases run across acknowledged delivery, SDK refusal, pre-input error and lost RPC reply using the production Rust row adapter with simulated AX/input. They do not claim application-effect confirmation or authenticate arbitrary external files. Replay does not independently authenticate every historical file: retained reads use the durable validator, while ordinary replay checks the projected copies. No SDK/AX dispatch code changes are needed for this agreement check. + +## AXWindow NoValue membership + +The held census accepts only AXWindow kAXErrorNoValue (-25212) as a reason to prove membership through AXParent. Each complete held-reference parent chain must remain in the same PID, have reciprocal parent/child membership, and end at the exact window whose native ID was checked. Any explicit non-root AXWindow must equal that window. Unsupported/timeout/other read errors, invalid types, missing parents, cycles, inconsistent aliases and exhausted bounds refuse. The full census still validates every edge/column alias before discovery. Additional chain work is charged to the existing two-second/500000-work budget; the existing 32-parent, 2048-node and 4096-held-reference limits are unchanged. + +This is an observation membership proof, not an optional-attribute shortcut. The actual click recipient still requires its explicit AXWindow, and dispatch repeats the census against held token objects before the existing foreground check and press. No across-command object continuity or atomic app-side final-read/press is promised. The motivating retained trace proves only NoValue on a local AXGroup; parent-chain positives are synthetic until a separately authorized live observation establishes actual topology. + +The offline row-parent dispatch probe mirrors the actual recipient explicit-window preflight before general peer membership. Recipient NoValue/missing/unreadable/foreign values yield zero synthetic presses and ordinary/durable refusal. This strengthens fixture fidelity only: the native CF reads, initial root discovery and real input remain source-assessed rather than executed by that probe. diff --git a/jevdual/docs/notebook/2026-11-17-native-row-parent.md b/jevdual/docs/notebook/2026-11-17-native-row-parent.md new file mode 100644 index 00000000..543b5237 --- /dev/null +++ b/jevdual/docs/notebook/2026-11-17-native-row-parent.md @@ -0,0 +1,36 @@ +# Held-parent membership for row capture + +## RWP1 · prediction · 2026-11-17 12:33 +Hypothesis: the observed AXWindow NoValue refusal can be handled without weakening recipient authority when the existing held-object census proves a complete same-PID reciprocal parent chain to the exact window. NoValue alone is never proof. +Test: preserve the real capture error as a failing native read-policy regression; construct explicitly synthetic direct-window/NoValue-chain positives and foreign-window/PID, Unsupported/timeout/error, missing/unreadable parents, cycle, conflicting alias, incomplete children and budget negatives. Exercise the shared Rust membership algorithm through actual SDK probe and public ordinary/durable CLI, with native error-policy tests and matched generated wheel bindings. Trace/callback and prior row recipient controls remain. Freeze final source for independent Kimi K3.1 Pro, GPT-6.1 Sol, Antigravity Gemini4Hydrogen review before integration/delivery. One live guarded observation only after checked delivery and serialized owner pause, never an action/retry. +Predicts: direct-window positives are unchanged; NoValue qualifies only with complete held-parent proof. All other read errors and contradictory membership refuse with zero press. Existing two-second/2048-node/4096-reference/500000-comparison bounds account additional work; incomplete evidence never creates a row binding. Generated ABI/callback ownership and row/effect rules remain unchanged. +Against: unsafe chain accepted, explicit disagreement ignored, NoValue conflated with Unsupported, budget enlarged/unaccounted, synthetic graph presented as live evidence, or any authority dependency outside this contract. Stop on new scope dependency; preserve failures. +Refs: /Volumes/External SSD/demoApps/demo/films/showcase-2026-11-17/workspace/approved-path-readiness-002/diagnostic-001/{row-trace.json,DIAGNOSIS.md,READ-REFUSAL-SPECIMEN.json}; /Volumes/External SSD/Footwork-native-row-parent-evidence-20261117/BASELINE.json. + +## RWU1 · update · 2026-11-17 13:01 +Observed: RWP1 red boundary retained: native error-policy regression 1 failed/1 passed; shared membership tests 2 failed/2 passed; actual Rust adapter/public CLI 4 failed/25 passed. The four failures are synthetic complete/flattened valid NoValue parent chains in ordinary/durable mode. Initial native command used an incorrect Cargo package name and is preserved as setup failure, not evidence. +Next: implement only exact NoValue held-parent membership, preserve error/alias/budget refusal and existing recipient/evidence contracts. Kimi review route corrected by Thomas to Kimi CLI standard kimi-code/k3.1-pro; resolve current settings at dispatch. +Refs: /Volumes/External SSD/Footwork-native-row-parent-evidence-20261117/{parent-contract-red.txt,native-parent-red-correct-package.txt,public-cli-red.txt,probe-red-build.txt}. + +## RWU2 · update · 2026-11-17 13:12 +Observed: behavior commit 50b46ff1 builds pinned parent1 wheel; 613 affected Python tests, 76 Rust contract tests and 2 native capture-policy tests pass. Initial affected run retained 1 stale version-pin assertion failure/612 passes; corrected test names exact parent1 distribution. Archive, source and wheel-build extraction match all 903 SDK source files; generated ABI and callback ownership modules are byte-identical to trace2. No installed/runtime change or live collection. +Next: freeze exact source and artifacts for three independent council reviews using Kimi CLI standard K3.1 Pro/max, GPT-6.1 Sol/high and Antigravity Gemini4Hydrogen/high; resolve findings before CI/integration/delivery. RWP1 remains open for independent review and separately authorized single live observation. +Refs: /Volumes/External SSD/Footwork-native-row-parent-evidence-20261117/{CHECKPOINT.json,integrated-final.txt,integrated-final-pin.txt,contract-final.txt,native-parent-final.txt,WHEEL-IDENTITY.json,SDK-SOURCE-HASHES.json}. + +## RWP2 · prediction · 2026-11-17 13:37 +Hypothesis: the council probe mismatch is isolated to the offline dispatch adapter omitting the actual recipient explicit-window preflight; native production already refuses that condition. +Test: preserve recipient-local NoValue counterexample through ordinary/durable public CLI before correcting the probe. Include direct recipient and peer-only NoValue positives, recipient Unsupported/timeout/foreign/missing controls, zero-press refusal receipts and durable same-token replay. Rebuild/rebind only the owned probe/package after red tests; compare all production SDK files and callback/ABI bytes to frozen352cbdac. +Predicts: recipient NoValue tests fail on the retained old probe and pass with zero sends after the preflight mirror. Valid peers and direct recipients still dispatch exactly once, unverifiable; no production code changes. +Against: the correction alters production behavior, hides the original positive/negative controls, or still acknowledges a missing/unreadable/foreign recipient window. +Refs: /Volumes/External SSD/Footwork-native-row-parent-evidence-20261117/council-kimi-352cbdac/REVIEW.md; Sol I1 and Gemini F2 on same frozen source. + +## RWU3 · update · 2026-11-17 13:41 +Observed: RWP2 red public-CLI regressions 8 failed/41 passed on retained352cbdac probe; corrected probe 49 passed. Only SDK example row_parent_probe.rs changes, other902SDKfiles identical. Initial append used a doubled path and did not add tests; that prior29-test run is retained separately, not counted as red evidence. The scoped correction mirrors strict actual-recipient window read before general census; production source is unchanged. +Next: rebind package/wheel/probe, run affected checks and obtain fresh council on correction; preserve all original reviews and frozen artifacts. +Refs: /Volumes/External SSD/Footwork-native-row-parent-evidence-20261117/correction-001/{recipient-red.txt,recipient-red-correct-path.txt,recipient-green.txt,PRODUCTION-EQUIVALENCE.json,SDK-CORRECTION.diff}. + +## RWU4 · update · 2026-11-17 13:44 +Resolves: RWP2 = held +Observed: corrected package/probe passes633affectedPython tests (49focused cases), zero skips. Only offline example changes among903SDKfiles; native SDK library, callback and generated contract bytes match352cbdac wheel. Rebuilt CLI binary and wheel RECORD differ and are bound by fresh hashes; no claim of all-binary identity. Production code remains unchanged, so prior76Rust/2native-policy checks are retained evidence, not repeated runs. +Next: fresh council review of the correction and package binding, carrying original findings; no installed or live action until review/check gates clear. +Refs: /Volumes/External SSD/Footwork-native-row-parent-evidence-20261117/correction-001/{integrated-final.txt,WHEEL-IDENTITY.json,PRODUCTION-EQUIVALENCE.json,SDK-CORRECTION.diff}. diff --git a/jevdual/pyproject.toml b/jevdual/pyproject.toml index f7701423..8b990854 100644 --- a/jevdual/pyproject.toml +++ b/jevdual/pyproject.toml @@ -24,7 +24,7 @@ dependencies = [ [project.optional-dependencies] desktop = [ - "cua-driver==0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2", # tests/contract/test_cua_driver_seams.py + "cua-driver==0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2.parent1", # tests/contract/test_cua_driver_seams.py "jeepney==0.9.0 ; sys_platform == 'linux'", # bounded AT-SPI exact-text access "pyobjc-framework-applicationservices>=12 ; sys_platform == 'darwin'", "pyobjc-framework-quartz>=12 ; sys_platform == 'darwin'", diff --git a/jevdual/tests/contract/test_cua_driver_seams.py b/jevdual/tests/contract/test_cua_driver_seams.py index e5553ae7..96e8c7bb 100644 --- a/jevdual/tests/contract/test_cua_driver_seams.py +++ b/jevdual/tests/contract/test_cua_driver_seams.py @@ -17,7 +17,7 @@ cd = pytest.importorskip("cua_driver") -PINNED_VERSION = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2" +PINNED_VERSION = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2.parent1" def _params(cls) -> set[str]: diff --git a/jevdual/tests/test_cua_driver_build.py b/jevdual/tests/test_cua_driver_build.py index 64f1ab86..683d3831 100644 --- a/jevdual/tests/test_cua_driver_build.py +++ b/jevdual/tests/test_cua_driver_build.py @@ -180,7 +180,7 @@ def test_local_native_patch_has_inspectable_hash_bound_provenance(): for name, hashes in foreground['files'].items(): assert hashlib.sha256(source.extractfile(name).read()).hexdigest() == hashes['after'] assert hashes['before'] != hashes['after'] - steps = (('ordinary-helptag', helptag, 2), ('connected-click', connected, 2), ('ref-locate', locate, 3), ('row-recipient', row, 17)) + steps = (('ordinary-helptag', helptag, 2), ('connected-click', connected, 2), ('ref-locate', locate, 3), ('row-recipient', row, 19)) for index, (step, record, count) in enumerate(steps): step_patch = (vendor / f'patches/{step}.patch').read_bytes() assert hashlib.sha256(step_patch).hexdigest() == record['patch_sha256'] diff --git a/jevdual/tests/test_native_row_parent.py b/jevdual/tests/test_native_row_parent.py new file mode 100644 index 00000000..9846f963 --- /dev/null +++ b/jevdual/tests/test_native_row_parent.py @@ -0,0 +1,95 @@ +"""Synthetic held-parent graph through shared Rust capture check and public CLI. + +Only the NoValue error is live-derived. No full Chrome graph was captured. +""" +import pytest + +from tests import test_native_row_sdk_cli as cli +from tests import test_session_scenarios as scenarios +from tests.test_native_row_sdk import PROBE, click_wire, graph_fixture, node, probe + +world = scenarios.world +fw = scenarios.fw +pytestmark = pytest.mark.skipif(not PROBE, reason="requires pinned row_parent_probe") + + +@pytest.mark.parametrize("durable", [False, True]) +@pytest.mark.parametrize("variant", ["complete", "flattened"]) +@pytest.mark.parametrize("fault", ["direct", "no_value", "unsupported", "timeout", "foreign"]) +def test_public_cli_held_parent_contract(world, fw, monkeypatch, tmp_path, durable, variant, fault): + original = cli.probe + def with_membership(data): + return original({**data, "window_faults": {} if fault == "direct" else {"1": fault}}) + monkeypatch.setattr(cli, "probe", with_membership) + _graph, sent = cli.sdk_row_world(world, monkeypatch, variant) + cli.start_row(fw, monkeypatch, tmp_path, durable) + result = fw("do", "click", "section:Task ID=TASK-0::combobox:Open menu", + *(["--token", "parent-contract"] if durable else [])) + if fault in ("direct", "no_value"): + assert result[0] == 0, result + assert sent == [940] + assert cli.last_receipt(fw)["effect"] == "unverifiable" + else: + assert result[0] != 0, result + assert sent == [] + + +@pytest.mark.parametrize("fault", ["foreign", "unsupported", "timeout", "missing_parent", + "cycle", "nonreciprocal", "alias", "wrong_pid", "budget"]) +def test_actual_dispatch_refuses_invalid_membership(fault): + graph = graph_fixture() + data = {"mode": "discover", "graph": graph, "pid": 77, "window_id": 40335, "recipient": 940} + binding = probe(data)["binding"] + assert binding + faults = {"1": "no_value"} + extra = {} + if fault in ("foreign", "unsupported", "timeout"): + faults["1"] = fault + elif fault == "missing_parent": + node(graph, 1)["parent"] = None + elif fault == "cycle": + node(graph, 1)["parent"] = 2 + elif fault == "nonreciprocal": + node(graph, 0)["children"] = [] + elif fault == "alias": + # A conflicting edge outside the proved chain must still fail the full census. + node(graph, 20)["children"].append(940) + elif fault == "wrong_pid": + node(graph, 0)["pid"] = 78 + elif fault == "budget": + extra["membership_budget"] = 1 + answer = probe({"mode": "dispatch", "click": click_wire(), "binding": binding, + "graph": graph, "recipient": 940, "window_faults": faults, **extra}) + assert answer["schema_valid"] + assert answer["presses"] == [] + assert answer["receipt"]["dispatched"] is False + + +@pytest.mark.parametrize("durable", [False, True]) +@pytest.mark.parametrize("variant", ["complete", "flattened"]) +@pytest.mark.parametrize("fault", ["no_value", "unsupported", "timeout", "foreign", "missing"]) +def test_actual_recipient_window_preflight_refuses_before_press( + world, fw, monkeypatch, tmp_path, durable, variant, fault, +): + from jevdual.session_operations import SessionOperations + + original = cli.probe + def fault_at_dispatch(data): + if data.get("mode") == "dispatch": + data = {**data, "window_faults": {"940": fault}} + return original(data) + monkeypatch.setattr(cli, "probe", fault_at_dispatch) + _graph, sent = cli.sdk_row_world(world, monkeypatch, variant) + authority = cli.start_row(fw, monkeypatch, tmp_path, durable) + # Observation succeeds with a direct-window recipient. The independent + # recipient read fails only at dispatch, before the general peer census. + result = fw("do", "click", "section:Task ID=TASK-0::combobox:Open menu", + *(["--token", "recipient-window"] if durable else [])) + assert not sent, result + assert cli.last_receipt(fw)["effect"] == "refused" + if durable: + with SessionOperations(authority) as operations: + status = operations.receipt(operations.status()[-1]) + assert (status["state"], status["disposition"]) == ("final", "not_sent") + fw("do", "click", "section:Task ID=TASK-0::combobox:Open menu", "--token", "recipient-window") + assert not sent diff --git a/jevdual/uv.lock b/jevdual/uv.lock index 400d0cc3..718c479a 100644 --- a/jevdual/uv.lock +++ b/jevdual/uv.lock @@ -731,7 +731,7 @@ wheels = [ [[package]] name = "cua-driver" -version = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2" +version = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2.parent1" source = { directory = "vendor/cua-driver" } [[package]] diff --git a/jevdual/vendor/cua-driver/PROVENANCE.md b/jevdual/vendor/cua-driver/PROVENANCE.md index 634b4115..0402e9c3 100644 --- a/jevdual/vendor/cua-driver/PROVENANCE.md +++ b/jevdual/vendor/cua-driver/PROVENANCE.md @@ -5,7 +5,7 @@ Reference commit: `5486b6246e4c807c0d793216e52df283671d9362` (release `cua-drive Source directory: `libs/cua-driver/python/src/cua_driver`. Python/native version: `0.46.0`. License: upstream MIT (`LICENSE.md`, copied as `LICENSE`). -Footwork distribution version: `0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2`. The published 0.46.0 wheel does not contain the required shutdown cleanup, foreground text focus, passive HelpTag, connected-node click and ref locate patches and cannot satisfy this exact dependency. The upstream Python `__version__` remains `0.46.0`. +Footwork distribution version: `0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2.parent1`. The published 0.46.0 wheel does not contain the required shutdown cleanup, foreground text focus, passive HelpTag, connected-node click and ref locate patches and cannot satisfy this exact dependency. The upstream Python `__version__` remains `0.46.0`. Three Python files remain byte-for-byte from the exact release source. The contract UniFFI module carries the row2 ABI; the SDK UniFFI module preserves exact landed fdbf48f callback ownership/drop hardening after regeneration. __init__.py additionally exports ExpectedRow and RowReceipt. The published macOS wheel has the same files except that its packaging removes the `x-release-please-version` comment from `__init__.py`. Generated records and native library must always be upgraded together. @@ -20,7 +20,7 @@ Three Python files remain byte-for-byte from the exact release source. The contr ## Source archive -`native-source.tar.gz` SHA256: `941c3b35a6d467a14c64a4bfe5a4d6a84a67b032675b893b856cb8dcf256b52a` (6,448,145 bytes). It is the end of a six-step patch chain on the selected release source: cleanup2, focus1, helptag1, connected4, locate10, row4. Each step's manifest under `patches/` binds its base archive, patch, patched archive and changed files by SHA256. The focus1 archive (`804aeb8b2ba5b2b49772250a0435032bd9510835a56a33122d1cab531810cfb2`, 6,403,795 bytes) remains in Git history; `python3 scripts/cua_source_chain.py --base --output ` rebuilds this archive from it and checks every hash. +`native-source.tar.gz` SHA256: `26a6a46dc089553a5505cfe109871e4f21b2638885b702a911cfdaeb3e44b90b` (6,451,272 bytes). It is the end of a six-step patch chain on the selected release source: cleanup2, focus1, helptag1, connected4, locate10, row4. Each step's manifest under `patches/` binds its base archive, patch, patched archive and changed files by SHA256. The focus1 archive (`804aeb8b2ba5b2b49772250a0435032bd9510835a56a33122d1cab531810cfb2`, 6,403,795 bytes) remains in Git history; `python3 scripts/cua_source_chain.py --base --output ` rebuilds this archive from it and checks every hash. The complete upstream release archive has SHA256 `032ce99f2e33154082cf854a1a04213e8a7b9eeae0e524564c7c6adb0ae93112`. The selected, unpatched native archive has SHA256 `257a36f5a793ad66d9c3e276709a7c81b667ed960ca5a3544e2d0ea43678fad1`. diff --git a/jevdual/vendor/cua-driver/build_support.py b/jevdual/vendor/cua-driver/build_support.py index 654fb4b1..6f61a21d 100644 --- a/jevdual/vendor/cua-driver/build_support.py +++ b/jevdual/vendor/cua-driver/build_support.py @@ -10,9 +10,9 @@ import tarfile from pathlib import Path, PurePosixPath -VERSION = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2" +VERSION = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2.parent1" SOURCE_COMMIT = "5486b6246e4c807c0d793216e52df283671d9362" -SOURCE_SHA256 = "941c3b35a6d467a14c64a4bfe5a4d6a84a67b032675b893b856cb8dcf256b52a" +SOURCE_SHA256 = "26a6a46dc089553a5505cfe109871e4f21b2638885b702a911cfdaeb3e44b90b" TOOLCHAIN = "1.97.1" diff --git a/jevdual/vendor/cua-driver/native-source.tar.gz b/jevdual/vendor/cua-driver/native-source.tar.gz index b9427cc2..a0f0b090 100644 Binary files a/jevdual/vendor/cua-driver/native-source.tar.gz and b/jevdual/vendor/cua-driver/native-source.tar.gz differ diff --git a/jevdual/vendor/cua-driver/patches/row-recipient.json b/jevdual/vendor/cua-driver/patches/row-recipient.json index 5aaef5f1..78a6d2d6 100644 --- a/jevdual/vendor/cua-driver/patches/row-recipient.json +++ b/jevdual/vendor/cua-driver/patches/row-recipient.json @@ -1,6 +1,6 @@ { "base_archive_sha256": "5cf6ce6a66b06783d8798a3c90e9a82728266326c80b6beab9ff3efe0080ade9", - "patch_sha256": "256bf7c6088e104badae0280945c0f8940f8c10f0223884e99166c38c022d4cf", + "patch_sha256": "0f30c110fd6ff2e412ba3bd5f0d34d24756deaaa90716263dc06190c10745713", "files": { "libs/cua-driver/rust/crates/cua-driver-contract/examples/row_guard_probe.rs": { "before": null, @@ -13,7 +13,7 @@ }, "libs/cua-driver/rust/crates/cua-driver-contract/src/lib.rs": { "before": "24696d580184ab248114b1294ca1e9d8b568eea88b6137c2d15c7c726d549b3b", - "after": "7b8c2b723a69428148283fd390fc7eefe3ebb3f331cbeaadcfb01d343db3f50d" + "after": "43acecdb48835c512873a57acf7c616292d85f7804dead1072298cf2393ff572" }, "libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs": { "before": "fa9ce6eec69a605bb45142bcad21faf6a0529eed7ad36d4ddd1b81b7d14b6300", @@ -50,7 +50,7 @@ }, "libs/cua-driver/rust/crates/platform-macos/src/ax/row_guard.rs": { "before": null, - "after": "abe7100e3b9ea21f64adc3aa54008b9d110e7ae63afc2fe2ebfe50476a507f9c", + "after": "44f3dd69a68262c4fcf3d480f72278cd8b48fa46d03f871f2837cb488b20782b", "mode": 420 }, "libs/cua-driver/rust/crates/platform-macos/src/ax/snapshot.rs": { @@ -74,6 +74,16 @@ "before": null, "after": "8034c5f399b687fa106a4cf8ed977c0d4ecf53236e6f2f7187a15817452b0e28", "mode": 420 + }, + "libs/cua-driver/rust/crates/cua-driver-contract/src/row_window.rs": { + "before": null, + "after": "cd704024aae00d9794c2d52c9693c7e3bcb54dc0f9554a2e8faccd9da9109265", + "mode": 420 + }, + "libs/cua-driver/rust/crates/cua-driver-contract/examples/row_parent_probe.rs": { + "before": null, + "after": "c87aab038b51396a28038c4df8d1779ec6ff79531e3d2e411bdc4cec09a54e41", + "mode": 420 } }, "added_directories": [ @@ -81,8 +91,8 @@ ], "upstream_commit": "5486b6246e4c807c0d793216e52df283671d9362", "base_version": "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10", - "version": "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2", - "patched_archive_sha256": "941c3b35a6d467a14c64a4bfe5a4d6a84a67b032675b893b856cb8dcf256b52a", + "version": "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2.parent1", + "patched_archive_sha256": "26a6a46dc089553a5505cfe109871e4f21b2638885b702a911cfdaeb3e44b90b", "abi": "ExpectedRow version2 unchanged; optional row_trace_url input and row_trace_json output; callback overlay unchanged", "toolchain": "1.97.1" } diff --git a/jevdual/vendor/cua-driver/patches/row-recipient.patch b/jevdual/vendor/cua-driver/patches/row-recipient.patch index add1bf97..936df805 100644 --- a/jevdual/vendor/cua-driver/patches/row-recipient.patch +++ b/jevdual/vendor/cua-driver/patches/row-recipient.patch @@ -110,6 +110,9 @@ @@ -21,0 +22,2 @@ +pub mod row; +pub use row::ExpectedRow; +@@ -817,0 +820,2 @@ ++ ++pub mod row_window; --- a/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs +++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/outputs.rs @@ -720,0 +721,3 @@ @@ -1022,7 +1025,7 @@ +pub(crate) mod row_trace; --- /dev/null +++ b/libs/cua-driver/rust/crates/platform-macos/src/ax/row_guard.rs -@@ -0,0 +1,454 @@ +@@ -0,0 +1,514 @@ +//! SDK-owned row census and actual-token press. No public raw AX entry point. +use super::bindings::*; +use core_foundation::{ @@ -1036,6 +1039,7 @@ + discover_row_traced, dispatch_row, RowBinding, RowGraph, RowNode, RowReceipt, +}; +use cua_driver_contract::ExpectedRow; ++use cua_driver_contract::row_window::{prove_window_member, WindowMembership, WindowReference}; +use std::collections::{BTreeMap, BTreeSet}; +use std::sync::Arc; +use std::time::{Duration, Instant}; @@ -1193,8 +1197,8 @@ + } else { + self.element(el, "AXParent", false)? + }; -+ if id != root && self.element(el, "AXWindow", false)? != Some(root) { -+ return Err("row peer window mismatch".into()); ++ if id != root { ++ prove_window_member(self, id, root, pid)?; + } + let children = self + .elements( @@ -1272,17 +1276,59 @@ + }) + } +} ++impl WindowMembership for Capture { ++ fn checkpoint(&mut self) -> Result<(), String> { ++ // Charge new membership work to the existing comparison/deadline budget. ++ self.comparisons += 1; ++ if self.comparisons > 500_000 { return Err("row census equality budget".into()); } ++ if Instant::now() > self.deadline { return Err("row census deadline".into()); } ++ Ok(()) ++ } ++ fn pid(&mut self, id: u64) -> Result { ++ let el = self.objects.get(id as usize).ok_or("row held peer absent")?.ptr(); ++ let mut pid = 0; ++ if unsafe { AXUIElementGetPid(el, &mut pid) } != 0 || pid <= 0 { ++ return Err("row peer PID unreadable".into()); ++ } ++ Ok(pid as u32) ++ } ++ fn window(&mut self, id: u64) -> Result { ++ let el = self.objects.get(id as usize).ok_or("row held peer absent")?.ptr(); ++ let key = CFString::new("AXWindow"); ++ let mut value = std::ptr::null(); ++ let error = unsafe { AXUIElementCopyAttributeValue(el, key.as_concrete_TypeRef(), &mut value) }; ++ match read_window_result(error, value)? { ++ Some(value) => self.intern(value.as_CFTypeRef() as AXUIElementRef).map(WindowReference::Direct), ++ None => Ok(WindowReference::NoValue), ++ } ++ } ++ fn parent(&mut self, id: u64) -> Result { ++ let el = self.objects.get(id as usize).ok_or("row held peer absent")?.ptr(); ++ self.element(el, "AXParent", false)?.ok_or("row parent missing".into()) ++ } ++ fn children(&mut self, id: u64) -> Result, String> { ++ let el = self.objects.get(id as usize).ok_or("row held peer absent")?.ptr(); ++ self.elements(el, "AXChildren", false)?.ok_or("row parent children missing".into()) ++ } ++} ++ +fn read(el: AXUIElementRef, key: &str, optional: bool) -> Result, String> { + let key_cf = CFString::new(key); + let mut value = std::ptr::null(); + let error = + unsafe { AXUIElementCopyAttributeValue(el, key_cf.as_concrete_TypeRef(), &mut value) }; -+ super::row_trace::read(key, (error != 0 && !(optional && (error == kAXErrorNoValue || error == kAXErrorAttributeUnsupported))).then_some(error)); ++ read_result(key, error, value, optional, optional) ++} ++fn read_window_result(error: i32, value: CFTypeRef) -> Result, String> { ++ read_result("AXWindow", error, value, true, false) ++} ++fn read_result(key: &str, error: i32, value: CFTypeRef, no_value: bool, unsupported: bool) -> Result, String> { ++ super::row_trace::read(key, (error != 0 && !((no_value && error == kAXErrorNoValue) || (unsupported && error == kAXErrorAttributeUnsupported))).then_some(error)); + if error != 0 { + if !value.is_null() { + unsafe { CFRelease(value) }; + } -+ if optional && (error == kAXErrorNoValue || error == kAXErrorAttributeUnsupported) { ++ if (no_value && error == kAXErrorNoValue) || (unsupported && error == kAXErrorAttributeUnsupported) { + return Ok(None); + } + return Err(format!("{key} unreadable ({error})")); @@ -1477,6 +1523,23 @@ + }, + ) +} ++ ++#[cfg(test)] ++mod window_absence_tests { ++ use super::*; ++ #[test] ++ fn capture_boundary_real_no_value_is_distinct_from_other_errors() { ++ // Exact retained error code; constructed null result, no live AX call. ++ assert!(read_window_result(-25212, std::ptr::null()).unwrap().is_none()); ++ } ++ #[test] ++ fn capture_boundary_other_errors_still_refuse() { ++ for error in [-25205,-25204,-25202] { ++ assert!(read_window_result(error, std::ptr::null()).is_err()); ++ } ++ assert!(read_window_result(0,std::ptr::null()).is_err()); ++ } ++} --- a/libs/cua-driver/rust/crates/platform-macos/src/ax/snapshot.rs +++ b/libs/cua-driver/rust/crates/platform-macos/src/ax/snapshot.rs @@ -9 +9 @@ @@ -1800,3 +1863,461 @@ + serde_json::json!({"schema_valid":true,"receipt":receipt,"presses":presses}) + ); +} +--- /dev/null ++++ b/libs/cua-driver/rust/crates/cua-driver-contract/src/row_window.rs +@@ -0,0 +1,261 @@ ++//! Window membership over SDK-held canonical object identities, never coordinates. ++#[derive(Clone, Copy, Debug, PartialEq, Eq)] ++pub enum WindowReference { ++ Direct(u64), ++ NoValue, ++} ++ ++pub trait WindowMembership { ++ fn checkpoint(&mut self) -> Result<(), String>; ++ fn pid(&mut self, id: u64) -> Result; ++ fn window(&mut self, id: u64) -> Result; ++ fn parent(&mut self, id: u64) -> Result; ++ fn children(&mut self, id: u64) -> Result, String>; ++} ++ ++/// Direct window references keep their original requirement. Only NoValue invokes ++/// the bounded parent proof. IDs denote SDK-held CFEqual-canonical references; ++/// this proves membership within this census, not continuity across commands. ++pub fn prove_window_member( ++ p: &mut P, ++ id: u64, ++ root: u64, ++ pid: u32, ++) -> Result { ++ p.checkpoint()?; ++ if p.pid(id)? != pid { ++ return Err("row peer PID mismatch".into()); ++ } ++ p.checkpoint()?; ++ match p.window(id)? { ++ WindowReference::Direct(window) if window == root => { ++ p.checkpoint()?; ++ return Ok(false); ++ } ++ WindowReference::Direct(_) => return Err("row peer window mismatch".into()), ++ WindowReference::NoValue => {} ++ } ++ let mut current = id; ++ let mut seen = std::collections::BTreeSet::from([id]); ++ // The existing row ancestry contract permits at most 32 parent edges. ++ for _ in 0..32 { ++ p.checkpoint()?; ++ let parent = p.parent(current)?; ++ if !seen.insert(parent) { ++ return Err("row parent cycle".into()); ++ } ++ p.checkpoint()?; ++ if p.pid(parent)? != pid { ++ return Err("row parent PID mismatch".into()); ++ } ++ if parent != root { ++ p.checkpoint()?; ++ match p.window(parent)? { ++ WindowReference::Direct(window) if window != root => { ++ return Err("row parent window mismatch".into()) ++ } ++ WindowReference::Direct(_) | WindowReference::NoValue => {} ++ } ++ } ++ p.checkpoint()?; ++ let children = p.children(parent)?; ++ let mut member = false; ++ for child in children { ++ p.checkpoint()?; ++ member |= child == current; ++ } ++ if !member { ++ return Err("row parent/child mismatch".into()); ++ } ++ p.checkpoint()?; ++ if parent == root { ++ return Ok(true); ++ } ++ current = parent; ++ } ++ Err("row parent depth limit".into()) ++} ++ ++#[cfg(test)] ++mod tests { ++ use super::*; ++ use std::collections::BTreeMap; ++ #[derive(Clone)] ++ struct Node { ++ pid: u32, ++ window: Result, ++ parent: Result, ++ children: Result, String>, ++ } ++ struct Fixture { ++ nodes: BTreeMap, ++ budget: usize, ++ reads: usize, ++ } ++ impl WindowMembership for Fixture { ++ fn checkpoint(&mut self) -> Result<(), String> { ++ if self.budget == 0 { ++ return Err("row census equality budget".into()); ++ } ++ self.budget -= 1; ++ Ok(()) ++ } ++ fn pid(&mut self, id: u64) -> Result { ++ self.reads += 1; ++ self.nodes ++ .get(&id) ++ .map(|n| n.pid) ++ .ok_or("missing peer".into()) ++ } ++ fn window(&mut self, id: u64) -> Result { ++ self.reads += 1; ++ self.nodes.get(&id).ok_or("missing peer")?.window.clone() ++ } ++ fn parent(&mut self, id: u64) -> Result { ++ self.reads += 1; ++ self.nodes.get(&id).ok_or("missing peer")?.parent.clone() ++ } ++ fn children(&mut self, id: u64) -> Result, String> { ++ self.reads += 1; ++ self.nodes.get(&id).ok_or("missing peer")?.children.clone() ++ } ++ } ++ fn fixture() -> Fixture { ++ // Synthetic chain only. The live trace establishes NoValue, not this topology. ++ Fixture { ++ budget: 500000, ++ reads: 0, ++ nodes: [ ++ ( ++ 1, ++ Node { ++ pid: 77, ++ window: Ok(WindowReference::Direct(1)), ++ parent: Err("root".into()), ++ children: Ok(vec![2]), ++ }, ++ ), ++ ( ++ 2, ++ Node { ++ pid: 77, ++ window: Ok(WindowReference::Direct(1)), ++ parent: Ok(1), ++ children: Ok(vec![6]), ++ }, ++ ), ++ ( ++ 6, ++ Node { ++ pid: 77, ++ window: Ok(WindowReference::NoValue), ++ parent: Ok(2), ++ children: Ok(vec![]), ++ }, ++ ), ++ ] ++ .into_iter() ++ .collect(), ++ } ++ } ++ #[test] ++ fn direct_window_unchanged() { ++ let mut f = fixture(); ++ assert_eq!(prove_window_member(&mut f, 2, 1, 77), Ok(false)); ++ assert_eq!(f.reads, 2); ++ } ++ #[test] ++ fn live_error_synthetic_chain_positive() { ++ let mut f = fixture(); ++ assert_eq!(prove_window_member(&mut f, 6, 1, 77), Ok(true)); ++ } ++ #[test] ++ fn multiple_no_value_parents() { ++ let mut f = fixture(); ++ f.nodes.get_mut(&2).unwrap().window = Ok(WindowReference::NoValue); ++ assert_eq!(prove_window_member(&mut f, 6, 1, 77), Ok(true)); ++ } ++ #[test] ++ fn decisive_chain_refusals() { ++ for fault in [ ++ "foreign", ++ "ancestor_foreign", ++ "pid", ++ "root_pid", ++ "missing_parent", ++ "unreadable_parent", ++ "cycle", ++ "nonreciprocal", ++ "children_error", ++ "unsupported", ++ "timeout", ++ "budget", ++ ] { ++ let mut f = fixture(); ++ match fault { ++ "foreign" => f.nodes.get_mut(&6).unwrap().window = Ok(WindowReference::Direct(99)), ++ "ancestor_foreign" => { ++ f.nodes.get_mut(&2).unwrap().window = Ok(WindowReference::Direct(99)) ++ } ++ "pid" => f.nodes.get_mut(&2).unwrap().pid = 78, ++ "root_pid" => f.nodes.get_mut(&1).unwrap().pid = 78, ++ "missing_parent" => f.nodes.get_mut(&6).unwrap().parent = Ok(99), ++ "unreadable_parent" => { ++ f.nodes.get_mut(&6).unwrap().parent = Err("AXParent unreadable".into()) ++ } ++ "cycle" => { ++ f.nodes.get_mut(&2).unwrap().parent = Ok(6); ++ f.nodes.get_mut(&6).unwrap().children = Ok(vec![2]); ++ } ++ "nonreciprocal" => f.nodes.get_mut(&2).unwrap().children = Ok(vec![]), ++ "children_error" => { ++ f.nodes.get_mut(&2).unwrap().children = Err("AXChildren unreadable".into()) ++ } ++ "unsupported" => { ++ f.nodes.get_mut(&6).unwrap().window = Err("AXWindow unreadable (-25205)".into()) ++ } ++ "timeout" => { ++ f.nodes.get_mut(&6).unwrap().window = Err("AXWindow unreadable (-25204)".into()) ++ } ++ "budget" => f.budget = 1, ++ _ => unreachable!(), ++ } ++ assert!(prove_window_member(&mut f, 6, 1, 77).is_err(), "{fault}"); ++ } ++ } ++ #[test] ++ fn existing_ancestry_bound_and_final_work_are_enforced() { ++ for edges in [32, 33] { ++ let mut f = fixture(); ++ f.nodes.clear(); ++ for id in 0..=edges { ++ f.nodes.insert( ++ id, ++ Node { ++ pid: 77, ++ window: Ok(WindowReference::NoValue), ++ parent: if id == 0 { ++ Err("root".into()) ++ } else { ++ Ok(id - 1) ++ }, ++ children: Ok(if id == edges { vec![] } else { vec![id + 1] }), ++ }, ++ ); ++ } ++ assert_eq!( ++ prove_window_member(&mut f, edges, 0, 77).is_ok(), ++ edges == 32 ++ ); ++ } ++ let mut f = fixture(); ++ assert_eq!(prove_window_member(&mut f, 6, 1, 77), Ok(true)); ++ let charged = 500000 - f.budget; ++ let mut f = fixture(); ++ f.budget = charged - 1; ++ assert!(prove_window_member(&mut f, 6, 1, 77).is_err()); ++ let mut f = fixture(); ++ f.budget = charged; ++ assert_eq!(prove_window_member(&mut f, 6, 1, 77), Ok(true)); ++ } ++} +--- /dev/null ++++ b/libs/cua-driver/rust/crates/cua-driver-contract/examples/row_parent_probe.rs +@@ -0,0 +1,191 @@ ++//! Offline AX-provider adapter: production schema and recipient validator, no OS input. ++use cua_driver_contract::row::{ ++ discover_row, discover_row_traced, dispatch_row, RowBinding, RowGraph, ++}; ++use cua_driver_contract::row_window::{prove_window_member, WindowMembership, WindowReference}; ++use cua_driver_contract::{ActionTarget, ClickInput, ToolInput}; ++// Synthetic provider only: no claim that this graph was captured from Chrome. ++struct Membership<'a> { ++ graph: &'a RowGraph, ++ faults: &'a serde_json::Value, ++ budget: usize, ++ window_id: u64, ++} ++impl Membership<'_> { ++ fn node(&self, id: u64) -> Result<&cua_driver_contract::row::RowNode, String> { ++ self.graph ++ .nodes ++ .iter() ++ .find(|n| n.id == id) ++ .ok_or("missing held peer".into()) ++ } ++} ++impl WindowMembership for Membership<'_> { ++ fn checkpoint(&mut self) -> Result<(), String> { ++ if self.budget == 0 { ++ return Err("row census equality budget".into()); ++ } ++ self.budget -= 1; ++ Ok(()) ++ } ++ fn pid(&mut self, id: u64) -> Result { ++ Ok(self.node(id)?.pid) ++ } ++ fn window(&mut self, id: u64) -> Result { ++ match self.faults[id.to_string()].as_str() { ++ Some("no_value") => Ok(WindowReference::NoValue), ++ Some("missing") => Err("recipient window absent".into()), ++ Some("unsupported") => Err("AXWindow unreadable (-25205)".into()), ++ Some("timeout") => Err("AXWindow unreadable (-25204)".into()), ++ Some("foreign") => Ok(WindowReference::Direct(u64::MAX)), ++ _ => { ++ if self.node(id)?.window_id == self.window_id { ++ Ok(WindowReference::Direct(self.graph.root)) ++ } else { ++ Err("row peer window mismatch".into()) ++ } ++ } ++ } ++ } ++ fn parent(&mut self, id: u64) -> Result { ++ self.node(id)?.parent.ok_or("AXParent missing".into()) ++ } ++ fn children(&mut self, id: u64) -> Result, String> { ++ Ok(self.node(id)?.children.clone()) ++ } ++} ++fn capture_membership( ++ input: &serde_json::Value, ++ graph: RowGraph, ++ pid: u32, ++ window_id: u64, ++) -> Result { ++ let mut p = Membership { ++ graph: &graph, ++ faults: &input["window_faults"], ++ budget: input["membership_budget"].as_u64().unwrap_or(500000) as usize, ++ window_id, ++ }; ++ for node in &graph.nodes { ++ if node.id != graph.root { ++ prove_window_member(&mut p, node.id, graph.root, pid)?; ++ } ++ } ++ Ok(graph) ++} ++use std::io::{self, Read}; ++fn main() { ++ let mut text = String::new(); ++ io::stdin().read_to_string(&mut text).unwrap(); ++ let input: serde_json::Value = serde_json::from_str(&text).unwrap(); ++ if input["mode"] == "trace" { ++ let graph: RowGraph = serde_json::from_value(input["graph"].clone()).unwrap(); ++ let pid = input["pid"].as_u64().unwrap() as u32; ++ let window = input["window_id"].as_u64().unwrap(); ++ let recipient = input["recipient"].as_u64().unwrap(); ++ let off = discover_row(&graph, pid, window, recipient); ++ let mut events = Vec::new(); ++ let on = discover_row_traced(&graph, pid, window, recipient, Some(&mut events)); ++ println!( ++ "{}", ++ serde_json::json!({"off": off, "on": on, "keys": events}) ++ ); ++ return; ++ } ++ if input["mode"] == "discover" { ++ let graph: RowGraph = serde_json::from_value(input["graph"].clone()).unwrap(); ++ let result = capture_membership( ++ &input, ++ graph, ++ input["pid"].as_u64().unwrap() as u32, ++ input["window_id"].as_u64().unwrap(), ++ ) ++ .and_then(|graph| { ++ discover_row( ++ &graph, ++ input["pid"].as_u64().unwrap() as u32, ++ input["window_id"].as_u64().unwrap(), ++ input["recipient"].as_u64().unwrap(), ++ ) ++ }); ++ println!( ++ "{}", ++ match result { ++ Ok(binding) => serde_json::json!({"binding":binding}), ++ Err(error) => serde_json::json!({"binding":null,"error":error}), ++ } ++ ); ++ return; ++ } ++ let parsed = serde_json::from_value::(input["click"].clone()) ++ .map_err(|e| e.to_string()) ++ .and_then(|i| { ++ i.validate()?; ++ Ok(i) ++ }); ++ let click = match parsed { ++ Ok(click) => click, ++ Err(error) => { ++ println!( ++ "{}", ++ serde_json::json!({"schema_valid":false,"error":error,"presses":[]}) ++ ); ++ return; ++ } ++ }; ++ if input["mode"] != "dispatch" { ++ println!("{}", serde_json::json!({"schema_valid":true})); ++ return; ++ } ++ let binding: RowBinding = serde_json::from_value(input["binding"].clone()).unwrap(); ++ let graph = ++ serde_json::from_value::(input["graph"].clone()).map_err(|e| e.to_string()); ++ let ActionTarget::Window { pid, window_id } = click.target else { ++ panic!("fixture requires window") ++ }; ++ let recipient = input["recipient"].as_u64().unwrap(); ++ let graph = graph.and_then(|graph| { ++ // Mirror row_guard::press: the actual recipient requires an explicit ++ // window before the more permissive peer-membership census can run. ++ let mut reader = Membership { ++ graph: &graph, ++ faults: &input["window_faults"], ++ budget: 500000, ++ window_id, ++ }; ++ match reader.window(recipient)? { ++ WindowReference::Direct(root) if root == graph.root => {} ++ WindowReference::Direct(_) => return Err("recipient window mismatch".into()), ++ WindowReference::NoValue => return Err("AXWindow unreadable (-25212)".into()), ++ } ++ capture_membership(&input, graph, pid, window_id) ++ }); ++ let mut presses = Vec::new(); ++ let receipt = dispatch_row( ++ graph, ++ &binding, ++ click.expected_row.as_ref(), ++ pid, ++ window_id, ++ recipient, ++ || { ++ if input["admission_error"] == true { ++ Err("fixture focus lost before press".into()) ++ } else { ++ Ok(()) ++ } ++ }, ++ || { ++ presses.push(recipient); ++ if input["press_error"] == true { ++ Err("fixture AXPress response lost".into()) ++ } else { ++ Ok(()) ++ } ++ }, ++ ); ++ println!( ++ "{}", ++ serde_json::json!({"schema_valid":true,"receipt":receipt,"presses":presses}) ++ ); ++} diff --git a/jevdual/vendor/cua-driver/pyproject.toml b/jevdual/vendor/cua-driver/pyproject.toml index 19b46258..6b680d5d 100644 --- a/jevdual/vendor/cua-driver/pyproject.toml +++ b/jevdual/vendor/cua-driver/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "hatchling.build" [project] name = "cua-driver" -version = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2" +version = "0.46.0+footwork.5486b624.cleanup2.focus1.helptag1.connected4.locate10.row4.trace2.parent1" description = "Rust-backed Cua Driver SDK and bundled executable for client applications" readme = "README.md" license = { text = "MIT" }