Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
6742b1a
fix(approval): read a desktop approval's text fields by value, not by…
abrichr Nov 19, 2026
c4ac87a
ci: run the approval form-fields tests on the Windows runner
abrichr Nov 19, 2026
07200dd
test: drop the OCR-only reproduction, whose result depends on the pla…
abrichr Nov 19, 2026
7504306
fix(approval): read labels, buttons and grid cells by value too; keep…
abrichr Nov 19, 2026
c74f5df
fix(approval): accept the window_fields form-state kind in an approva…
abrichr Nov 19, 2026
571ffdd
docs: approval reads the window's controls by value (#2189); rebuild …
abrichr Nov 19, 2026
4ad70c7
fix(approval): preserve complete evidence for masked controls
abrichr Nov 20, 2026
ed175d9
fix(approval): leave empty and password controls visible
abrichr Nov 20, 2026
cb8a301
Merge remote-tracking branch 'origin/main' into fix/approval-form-fie…
abrichr Nov 20, 2026
2ddc51d
Require independent native extent and UIA agreement for complete values
abrichr Nov 20, 2026
8bd2e9d
Refuse incomplete native values at approval boundaries
abrichr Nov 20, 2026
919c921
Merge remote-tracking branch 'origin/main' into codex/approval-native…
abrichr Nov 20, 2026
b18f733
Exercise native approval completeness and physical evidence on Windows
abrichr Nov 20, 2026
4de5701
Require complete structural values and preserve marker uncertainty
abrichr Nov 20, 2026
f9cac7f
Guard every native value read with current sensitive status
abrichr Nov 20, 2026
7f65509
Check sensitivity after all provider metadata in value guards
abrichr Nov 20, 2026
87d29b3
Negotiate native value reads before guarded previews and probes
abrichr Nov 20, 2026
b476bbf
Require supported raw password status before native text reads
abrichr Nov 20, 2026
f05aabd
Refuse unknown native capabilities and bind complete read deployment
abrichr Nov 20, 2026
b5134fd
Merge commit '614e06c22a7951dbabeb695621e63c43699b5653' into codex/ap…
abrichr Nov 20, 2026
93347ab
Refuse incomplete native visibility, value and state projections
abrichr Nov 20, 2026
b1b6cbd
Report request-local non-content native projection refusals
abrichr Nov 20, 2026
7527440
Bind native read negotiation to independently understood client code
abrichr Nov 20, 2026
4be4b54
fix(verification): isolate complete-value helper annotations
abrichr Nov 20, 2026
a222b03
fix(windows): preserve loader isolation and lookup freshness
abrichr Nov 20, 2026
1a2503d
fix(verification): attribute unavailable raw property observations
abrichr Nov 20, 2026
154ce2c
Merge current main into native approval completeness change
abrichr Nov 20, 2026
546e0b9
Merge current main and test explicit WinForms capability reports
abrichr Nov 21, 2026
e67aac2
Record one guarded UIA availability property in the Windows fixture
abrichr Nov 21, 2026
f79375d
Merge main and reconcile Windows value and keyboard checks
abrichr Nov 21, 2026
f084564
Check the merged native proof contract in the Windows keyboard fixture
abrichr Nov 21, 2026
fb25f6c
Fix agent formatting and record the strict census stop in the native …
abrichr Nov 21, 2026
f35c431
Merge current main and retain both Flow changelog contributions
abrichr Nov 21, 2026
4213908
fix(flow): validate native observations in the host format layer
abrichr Nov 21, 2026
4bba2ce
fix(win-agent): accept Win32 EDIT evidence when a provider does not s…
abrichr Nov 21, 2026
acdb5a8
Merge remote-tracking branch 'origin/fix/approval-form-fields-2189' i…
abrichr Nov 21, 2026
d495cc2
fix(win-agent): bind alternate native evidence to proven provider states
abrichr Nov 21, 2026
3b88e33
test(flow): bind the synthetic UIA sentinel in refusal fixtures
abrichr Nov 21, 2026
9585e76
test(win-agent): distinguish strict census sensitivity refusals in gu…
abrichr Nov 21, 2026
cdf8b20
test(win-agent): report both evidence outcomes for a refused native e…
abrichr Nov 21, 2026
9b07747
style(flow): format native provider and projection tests
abrichr Nov 21, 2026
d7768a1
fix(flow): look up Windows-only ctypes last-error functions at runtime
abrichr Nov 21, 2026
dec6a7f
Merge main into #2291 and retain the unreleased native read changes
abrichr Nov 21, 2026
34f9275
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 23, 2026
5c4e6a5
Merge commit '2ea74802f07bc87bf2abe253b9d6d42a0eded613' into HEAD
abrichr Nov 23, 2026
0da47d7
Merge origin/main and fix strict census structural UIA types (#2291)
abrichr Nov 24, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 26 additions & 2 deletions .github/workflows/desktop-replay.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ on:
- packages/flow/tests/e2e/test_windows_hosted_replay.py
- packages/flow/tests/e2e/test_native_keyboard_lease.py
- packages/flow/tests/e2e/test_windows_hosted_governed.py
- packages/flow/tests/e2e/test_windows_approval_completeness.py
- packages/flow/tests/_approver_keys.py
- packages/flow/tests/conftest.py
- packages/flow/tests/e2e/conftest.py
Expand All @@ -62,6 +63,14 @@ on:
- packages/flow/tests/test_check_it_dry_run_apps.py
- packages/flow/tests/native_apps/check_it_gtk.py
- packages/flow/tests/test_approval_form_window.py
- packages/flow/tests/test_approval_form_fields.py
- packages/flow/tests/test_approval_value_completeness.py
- packages/flow/tests/test_native_value_completeness.py
- packages/flow/tests/test_native_sensitive_reads.py
- packages/flow/tests/test_form_projection_refusal.py
- packages/flow/tests/test_native_value_deployment.py
- packages/flow/tests/test_structural_value_completeness.py
- packages/flow/tests/test_desktop_readback.py
- packages/flow/tests/test_binary_file_descriptors.py
- packages/flow/tests/_binary_descriptor_contract.py
- packages/flow/benchmark/rdp_pool/**
Expand Down Expand Up @@ -121,7 +130,12 @@ jobs:
run: |
mkdir -p runs
pytest -v -rs -p no:cacheprovider tests/test_windows_attempt_ledger.py \
tests/test_approval_form_window.py tests/test_binary_file_descriptors.py --junitxml=runs/windows-guards-junit.xml
tests/test_approval_form_window.py tests/test_approval_form_fields.py \
tests/test_binary_file_descriptors.py tests/test_native_value_completeness.py \
tests/test_native_sensitive_reads.py tests/test_form_projection_refusal.py \
tests/test_approval_value_completeness.py tests/test_native_value_deployment.py \
tests/test_structural_value_completeness.py tests/test_desktop_readback.py \
--junitxml=runs/windows-guards-junit.xml
- name: Native keyboard leases (real input, read-back and planted refusals)
timeout-minutes: 6
env:
Expand Down Expand Up @@ -216,6 +230,14 @@ jobs:
assert result["delivery_receipt"] == case["input_attempts"][-1]["response"]["receipt"]
print(json.dumps({"editable_observation_cases": 8, "runtime_type_cases": 2, "skipped": 0, "rows_unchanged": True}))
PYTHON
- name: Native approval complete values and no-write refusal
env:
OAFLOW_WINDOWS_HOSTED_E2E: "1"
OAFLOW_NATIVE_APPROVAL_EVIDENCE: ${{ runner.temp }}/native-approval-evidence.json
OAFLOW_NATIVE_APPROVAL_SOURCE_HEAD: ${{ github.event.pull_request.head.sha || github.sha }}
run: |
pytest -v -rs -p no:cacheprovider --basetemp="$RUNNER_TEMP/ac" \
tests/e2e/test_windows_approval_completeness.py --junitxml=runs/native-approval-junit.xml
- name: Record, compile and replay, judged from the record
env:
OAFLOW_WINDOWS_HOSTED_E2E: "1"
Expand All @@ -231,7 +253,7 @@ jobs:
import xml.etree.ElementTree as ET
cases = [
case
for name in ("windows-guards", "windows-replay")
for name in ("windows-guards", "native-approval", "windows-replay")
for case in ET.parse(f"runs/{name}-junit.xml").getroot().iter("testcase")
]
skipped = [c for c in cases if c.find("skipped") is not None]
Expand Down Expand Up @@ -269,6 +291,8 @@ jobs:
with:
name: windows-replay-evidence
path: |
${{ runner.temp }}/native-approval-evidence.json
${{ runner.temp }}/native-approval-evidence.frames/*.png
${{ runner.temp }}/windows-replay-evidence.json
${{ runner.temp }}/windows-governed-evidence.json
${{ runner.temp }}/nkl-editable/*.json
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
| Native Windows (UI Automation) | Released | Synthetic (a WinForms test app in a Windows 11 VM, 3 of 3 trials); CI on a GitHub-hosted Windows runner on every change to the Windows path and nightly: record, compile and replay of the WinForms Patient Notes app through the real win_agent, judged from its SQLite record, with a near-identical sibling roster that must not be written, and a non-gating governed run of the same workflow under the Standard profile with a person's signed approval, a hold and a resume, whose resume currently stops before the save on a false form change (fail-closed, nothing written; [#2189](https://github.com/OpenAdaptAI/OpenAdapt/issues/2189)), followed by a gating check that fails the job on any sibling, held or unverified write ([desktop-replay.yml](.github/workflows/desktop-replay.yml)); on a real Windows 11 ARM machine, record, compile and replay of the same kind of WinForms test form with an owned confirm dialog, 3 of 3 trials, each also refusing a target covered by another app's window and one blocked by a modal dialog before any input | [SURFACES.md](packages/flow/docs/SURFACES.md) |
| Native Windows (UI Automation) | Released | Earlier synthetic evidence: a WinForms test app in a Windows 11 VM, 3 of 3 trials; GitHub-hosted CI records, compiles and replays Patient Notes through the real agent with SQLite and sibling-write checks. A historical short-note approval/hold/resume composition completed verified target-only saves ([run44665211915](https://github.com/OpenAdaptAI/OpenAdapt/actions/runs/44665211915)); it does not qualify the new complete-value contract. Current approval/structural work ([#2291](https://github.com/OpenAdaptAI/OpenAdapt/pull/2291)) remains held on current-head native evidence and independently qualified record identity. Its synthetic native observation variant excludes a full Flow save and unsupported virtual cells. Existing safety/no-skip gates remain enabled ([desktop-replay.yml](.github/workflows/desktop-replay.yml)). Earlier Windows 11 ARM evidence: record, compile and replay of a WinForms form with an owned confirm dialog, 3 of 3 trials, plus covered-target/modal refusal before input. | [SURFACES.md](packages/flow/docs/SURFACES.md) |
30 changes: 30 additions & 0 deletions packages/flow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,36 @@

<!-- version list -->

## Unreleased

### Fixes

- Native approval and structural field reads require exact UIA values to agree
with independent native extent/full reads under the same control identity.
Missing, sensitive, incomplete or disagreeing values refuse the observation;
an advertised native approval channel does not fall back to OCR. Empty
complete values remain values. A container cannot hide unread descendants
([#2291](https://github.com/OpenAdaptAI/OpenAdapt/pull/2291)).
- Value reads negotiate independent client/server read-v3 declarations and
require the separate helper proof-v3 contract before any preview or value
getter. Incompatible consumers refuse before provider access; versioned
refusal-parser imports reject mixed local modules. One
current sensitivity guard protects values, previews and capability probes.
Failed/unknown capability probes cannot become caption masks. Structural
previews and unqualified row inventories do not authorize effect checks.
- Unavailable native form projections return a closed request-local refusal
receipt with stage/channel/reason and already-known numeric metadata. A
closed property/guard-phase/result category locates raw-boolean failures;
the first unknown stops later probes. Partial fields, names, values, raw COM
objects and provider exceptions are excluded. No
additional source read, global last-error state, fallback or retry is added.
- Approval form state reads proven values separately from the remaining OCR
pixels, so caret/title-bar display noise need not alter an unchanged field's
value digest ([#2189](https://github.com/OpenAdaptAI/OpenAdapt/issues/2189)).
Current complete-value approval/structural qualification is pending. The
native observation fixture excludes a full Flow save; earlier short-note
governed evidence does not qualify this new source or unbounded values.

## v4.0.0 (2026-11-24)

### Breaking Changes
Expand Down
32 changes: 32 additions & 0 deletions packages/flow/docs/LIMITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -1000,6 +1000,38 @@ What is not:
- Values chosen by clicking (not typing), drag and drop, and WebSocket
traffic are checked only by the write adapter or the read-back, if at all.
- The instruction detector on approval forms is a heuristic display aid.
- On Windows, value-backed approval controls require identity-bound agreement
between exact UI Automation values and independent native extent/full reads.
Missing, sensitive, incomplete or disagreeing values, unknown subtrees and
another visible owned window refuse the advertised native projection; the
whole window is not downgraded to OCR. Visibility is an exact supported raw
property; unknown visibility or required visible bounds/type refuses the
projection. Relevant toggle/selection state has a separate complete/state
observation: unknown, failed or unrepresented composite state refuses before
masking. Known absent state patterns do not establish absent business state.
Empty complete values remain covered. A value-capable control carries its
full-value obligation regardless of type; generic containers stay unmasked.
Password status and value-pattern availability use raw UIA properties with
default values ignored; an unsupported default False is unknown. A named
control is a separate caption channel only when its value-pattern
absence is known; a failed/unknown value probe cannot hide required data in
a caption mask. This does not prove a caption is a record identity.
The remaining unmasked pixels are read by OCR. The projection still trusts
that standard controls render the qualified text inside their rectangles;
custom painting that violates that relationship is not qualified.
Structural field values require the same complete-value contract. Name/MSAA
and clipped previews do not authorize business-value or absence predicates;
unknown markers remain indeterminate. No complete native row-inventory
source is qualified. Structural uniqueness is checked at both observation
endpoints, with fresh fixed-control identity during reads, not continuously
or as authority for a later write. Current complete-value Flow/save and
held-out application qualification remain pending. Unavailable form reads
carry a closed request-local refusal receipt with fixed non-content codes.
For the existing raw boolean probes it names only the property category,
guard/query phase and result category; this does not establish a provider
cause. It collects no extra source data after refusal and never permits
retry. Read-v3 client/server declarations are independent of helper proof-v3;
older incompatible consumers refuse before source getters.
- No live model has been run against these fixtures yet; the live-model test
is off by default because it costs money.

Expand Down
144 changes: 143 additions & 1 deletion packages/flow/openadapt_flow/approval_mode/form_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,14 @@
is read, in reading order and with its frame in the digest, so text
elsewhere on the screen that changes by itself (a clock in a taskbar, a
notification) is not mistaken for an edited form.
- When the backend can also read that window's controls through the
platform's accessibility API (``approval_form_fields``: UI Automation on
Windows), each text field, label, button, list or grid cell and the title
bar is read by its value (with its toggle or selection state) and painted
out of the OCR read, and the rest of the window is still read by OCR. A
caret blinking in a text box, a hovered title-bar button or a selection
highlight that dims when the window loses focus then reads the same every
time, while a changed value changes the digest through either channel.

Only a digest leaves this module. The digest stays in the run directory; it
never enters the report or anything sent to Cloud.
Expand All @@ -29,6 +37,8 @@
import re
from typing import Any, Optional, Sequence

from openadapt_flow.approval_mode.window_fields import valid_form_field

#: (kind, "sha256:<hex>")
FormState = tuple[str, str]
#: x, y, width, height in frame pixels.
Expand Down Expand Up @@ -154,17 +164,87 @@ def screen_text_state(
return _digest("screen_text", {"rows": rows})


def _clamp(region: Region, width: int, height: int) -> Optional[Region]:
x, y, w, h = region
left, top = max(0, x), max(0, y)
right, bottom = min(width, x + w), min(height, y + h)
if right <= left or bottom <= top:
return None
return (left, top, right - left, bottom - top)


def window_fields_state(
vision: Any, frame_png: bytes, window_fields: dict[str, Any]
) -> Optional[FormState]:
"""The window's fields by value, and the rest of it by OCR, or ``None``.

``window_fields`` is a backend's ``approval_form_fields`` answer: the
window's frame and its title bar and text fields, each with its screen
rectangle and text. Every field rectangle is painted out of the window
crop before OCR, so what OCR reads there (a caret, a hovered button)
cannot vary between reads; the field's own value stands in for it. The
frame, each field's kind, rectangle, value and state, and the remaining
words in reading order are all in the digest. ``None`` when nothing was read.
"""

from PIL import Image, ImageDraw

try:
bounds = tuple(int(v) for v in window_fields["bounds"])
fields = list(window_fields["fields"])
with Image.open(io.BytesIO(frame_png)) as image:
window = _clamp(bounds, *image.size) # type: ignore[arg-type]
if window is None:
return None
x0, y0, w, h = window
crop = image.convert("RGB").crop((x0, y0, x0 + w, y0 + h))
draw = ImageDraw.Draw(crop)
rows: list[Any] = []
for field in fields:
if not valid_form_field(field):
return None
kind, text = field["kind"], field["text"]
fx, fy, fw, fh = field["rect"]
state, proof = field["state"], field["value_proof"]
rows.append(
[kind, [fx, fy, fw, fh], text, state, proof, field["value_identity"]]
)
# State, container and empty values leave pixels visible. Only
# complete nonempty leaves or visible labels authorize a mask.
inside = (
None
if kind in {"state", "value"} or not text
else _clamp((fx - x0, fy - y0, fw, fh), w, h)
)
if inside is not None:
ix, iy, iw, ih = inside
draw.rectangle((ix, iy, ix + iw - 1, iy + ih - 1), fill="white")
out = io.BytesIO()
crop.save(out, format="PNG")
words = _words(vision, out.getvalue())
except Exception: # noqa: BLE001 - unreadable is not "unchanged"
return None
if not words and not any(row[2] for row in rows):
return None
return _digest(
"window_fields", {"window": list(window), "fields": rows, "words": words}
)


def capture_form_state(
backend: Any,
vision: Any,
frame_png: Optional[bytes] = None,
regions: Optional[Sequence[Region]] = None,
window_fields: Optional[dict[str, Any]] = None,
) -> Optional[FormState]:
"""The best available field state for this backend, or ``None``.

A backend may provide ``form_state()`` returning JSON-serializable data;
a browser backend is read through its page; any other backend falls back
to the words on the screen, in ``regions`` when they are given.
to the screen: the app window's fields by value and the rest by OCR when
``window_fields`` is given, else the words in ``regions`` (or on the
whole screen).
"""

custom = getattr(backend, "form_state", None)
Expand All @@ -180,6 +260,8 @@ def capture_form_state(
frame_png = backend.screenshot()
except Exception: # noqa: BLE001
return None
if window_fields is not None:
return window_fields_state(vision, frame_png, window_fields)
return screen_text_state(vision, frame_png, regions)


Expand Down Expand Up @@ -229,10 +311,70 @@ def approval_window_regions(
return [(left, top, right - left, bottom - top)]


def approval_window_fields(
backend: Any, save_step: Optional[str], results: Sequence[Any] = ()
) -> Optional[dict[str, Any]]:
"""The backend's ``approval_form_fields`` answer for the approval's
window, or ``None`` (the approval refuses when this channel is required).

The same window :func:`approval_window_regions` names; the save step is
left out and the earlier steps' points name the window on a resumed run.
An unreadable native value never falls back to OCR. Never raises.
"""

fields_of = getattr(backend, "approval_form_fields", None)
if not callable(fields_of):
return None
try:
points = [
(int(prior.resolution.point[0]), int(prior.resolution.point[1]))
for prior in results
if prior.step_id != save_step and prior.resolution is not None
]
answer = fields_of(save_step, points)
except Exception: # noqa: BLE001 - no answer is OCR alone
return None
if not isinstance(answer, dict) or set(answer) != {"bounds", "fields"}:
return None
return answer


def approval_form_state(
backend: Any,
vision: Any,
frame_png: Optional[bytes],
save_step: Optional[str],
results: Sequence[Any] = (),
) -> Optional[FormState]:
"""The approval's form state for ``save_step``, or ``None``.

A backend offering native field reads must return complete evidence;
unavailable values refuse without an OCR downgrade. Backends without
that channel retain their existing DOM or screen read. Different read
channels have different kinds, so a changed channel halts the save.
"""

if callable(getattr(backend, "approval_form_fields", None)):
# Once a native field channel is required, no answer (including a
# legacy/malformed response or a missing complete value) is a refusal.
# OCR cannot establish equality of a hidden or omitted suffix.
if frame_png is None:
return None
fields = approval_window_fields(backend, save_step, results)
if fields is None:
return None
return window_fields_state(vision, frame_png, fields)
regions = approval_window_regions(backend, frame_png, save_step, results)
return capture_form_state(backend, vision, frame_png, regions)


__all__ = [
"FormState",
"approval_form_state",
"approval_window_fields",
"approval_window_regions",
"capture_form_state",
"window_fields_state",
"dom_form_state",
"screen_text_state",
]
6 changes: 4 additions & 2 deletions packages/flow/openadapt_flow/approval_mode/item_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,10 +242,12 @@ class ItemApprovalRequest(BaseModel):
screenshot: str = Field(min_length=1, max_length=256)
screenshot_sha256: str = Field(pattern=_HEX_SHA256)
#: How the field state was read: the page's own form controls, or the
#: text on the screen where the application exposes no form controls.
#: text on the screen where the application exposes no form controls,
#: or (``window_fields``) the app window's controls read by value through
#: the platform's accessibility API with the rest of it read by OCR.
#: ``api_request`` when the save is an API step: the digest is then the
#: exact request, the record and the record check (``api_request``).
form_state_kind: Literal["dom", "screen_text", "api_request"]
form_state_kind: Literal["dom", "screen_text", "window_fields", "api_request"]
form_state_sha256: str = Field(pattern=PREFIXED_SHA256_PATTERN)
created_at: str
expires_at: str
Expand Down
Loading
Loading