Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
a0fc255
test(flow): report the native field read's refusal when the approval …
abrichr Nov 30, 2026
036937b
test(flow): a windowless grid cell's value refuses the native field p…
abrichr Nov 30, 2026
9bb59cb
fix(flow): bind a screen fault to the engine's own capture of the sig…
abrichr Nov 30, 2026
405dc5e
fix(flow): read a windowless, read-only control's UIA value into the …
abrichr Nov 30, 2026
72123f5
fix(flow): record a stale-identity fault receipt on the engine's plai…
abrichr Nov 30, 2026
9df0f13
fix(flow): read windowlessness from the raw UIA element, and report w…
abrichr Nov 30, 2026
efa5734
test(flow): stage the Windows stale-identity fault as a click-through…
abrichr Nov 30, 2026
035e63f
test(flow): a stale-identity surface shows another record in the reco…
abrichr Nov 30, 2026
7e05595
fix(flow): bind a windowless grid cell with no RuntimeId by its struc…
abrichr Nov 30, 2026
f05e0ce
test(flow): report which windowless value read stage fails
abrichr Nov 30, 2026
4b05d94
fix(flow): read a windowless value through GetPattern when the contro…
abrichr Nov 30, 2026
41431aa
fix(flow): admit an editable-flagged windowless grid cell, header or …
abrichr Nov 30, 2026
b05c973
Merge remote-tracking branch 'origin/fix/native-value-guard-bracket' …
abrichr Nov 30, 2026
a2047e6
fix(flow): read windowless provider probes through an explicit not-ch…
abrichr Nov 30, 2026
8b2ea9c
test(flow): every windowless probe maps a provider error to the refus…
abrichr Nov 30, 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
8 changes: 8 additions & 0 deletions packages/flow/docs/APPROVAL_MODES.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,14 @@ openadapt-flow item-approval decline RUN_DIR ... --reason wrong_values
is gone, another of the app's windows reaches outside that frame, or a
monitor sits left of or above the primary one (the window's frame and the
screenshot's pixels would then be offset), it reads the whole screen.
Each text box, label and button that has its own window is read by its
value, proved complete by two independent sources. A control drawn by its
parent, with no window of its own (a grid cell or column header, a title
bar), can't be proved that way. When it is read-only and not a password
field, its UI Automation value is read twice, must match, and enters the
digest as its own kind; the screen text there is still read too. Any
other control without a proof stops the item. See
[Limits](LIMITS.md#windows-approval-controls-without-their-own-window).
Elsewhere it reads the words on the screen. An API step prepares its
request again instead; a request whose digest changed stops the item
before the save, and the GUI steps don't run in its place.
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 @@ -25,6 +25,38 @@ are part of the qualification boundary, so this does not qualify arbitrary
fresh workers. A script-hosted application's own code is covered by its
declared version, not the host executable's hash.

## Windows approval: controls without their own window

Before a save, an approval on Windows reads the app window to check that
nothing changed while the person decided. A text box or label with its own
window is read through two independent sources that must agree, so a value
cut short by the app's accessibility provider stops the item. A control drawn
by its parent, such as a grid cell, a grid column header or the title bar,
has no second source. Its UI Automation value is read twice and must match,
and the screen text over it is still read. If the provider cuts that value
short, a change in the hidden part that also leaves the visible text the same
is not detected. Some providers give such a control no RuntimeId at all
(WinForms grid cells and column headers). That control is then bound by its
path: each element up to an ancestor that has a RuntimeId, by type, position
and index among its siblings, read again before and after each of the two
reads. If a provider swaps in another element with the same type, position
and index, the check reads it as the same control; a changed value still
shows in the two reads or in the screen text. A scroll or resize between the
reads stops the item. A grid or list cell, a header or the title bar is
included even when its provider reports it as editable (WinForms does so
for a read-only grid); a text box never is. These values are used only for
that check: they are never complete values, read-back evidence or the basis
of a VERIFIED result. Read-back, not the approval check, verifies what a
save wrote. An
editable control, a password field, a control whose password status is
unknown, or one whose two reads differ still stops the item.

A native Windows stale-identity fault covers the whole screen, so the
keyboard lease that checks the target refuses and the save halts. The fault
receipt then binds to the engine's own plain screenshot, and only when its
SHA-256 equals the frame the fault driver signed. Otherwise no receipt is
recorded and the campaign rejects the case.

## Validated on

Every published result used synthetic patients, claims and records.
Expand Down
39 changes: 33 additions & 6 deletions packages/flow/openadapt_flow/approval_mode/form_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,17 @@
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.
- A control with no window of its own (a grid cell or column header, a
title bar) has no second source to prove its value complete. When it is
read-only and not a password field, its UI Automation value, read twice
and equal, enters the digest as ``uia_only_unverified``; its pixels are
never painted out, so OCR still reads them, and the read is never a
complete value. Limit: a provider that truncates the value could hide a
suffix that changes while OCR sees nothing change either. A control whose
provider gives no RuntimeId (WinForms grid cells and headers) is bound by
its structural path up to an ancestor that has one, and reads as
``uia_only_structural``; a provider that swaps in another element with
the same type, bounds and index reads as the same control.

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 @@ -37,7 +48,12 @@
import re
from typing import Any, Optional, Sequence

from openadapt_flow.approval_mode.window_fields import valid_form_field
from openadapt_flow.approval_mode.window_fields import (
UIA_ONLY_STRUCTURAL,
UIA_ONLY_UNVERIFIED,
UNMASKED_KINDS,
valid_form_field,
)

#: (kind, "sha256:<hex>")
FormState = tuple[str, str]
Expand Down Expand Up @@ -209,11 +225,12 @@ def window_fields_state(
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.
# State, container, unverified 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
if kind in UNMASKED_KINDS or not text
else _clamp((fx - x0, fy - y0, fw, fh), w, h)
)
if inside is not None:
Expand All @@ -226,9 +243,19 @@ def window_fields_state(
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}
# A read that includes an unverified (windowless) value is its own kind,
# so its digest never equals one from a read that proved every value.
# The weakest binding in the read names it: a structural-path value,
# then a RuntimeId-bound one, then a read that proved every value.
kinds = {row[0] for row in rows}
kind = (
"window_fields_uia_only_structural"
if UIA_ONLY_STRUCTURAL in kinds
else "window_fields_uia_only_unverified"
if UIA_ONLY_UNVERIFIED in kinds
else "window_fields"
)
return _digest(kind, {"window": list(window), "fields": rows, "words": words})


def capture_form_state(
Expand Down
13 changes: 12 additions & 1 deletion packages/flow/openadapt_flow/approval_mode/item_approval.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,20 @@ class ItemApprovalRequest(BaseModel):
#: 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.
#: ``window_fields_uia_only_unverified`` is that read when it includes a
#: windowless control's unverified UIA value (never equal to a fully
#: proved read); ``window_fields_uia_only_structural`` when one of those
#: values is bound by its structural path (no RuntimeId).
#: ``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", "window_fields", "api_request"]
form_state_kind: Literal[
"dom",
"screen_text",
"window_fields",
"window_fields_uia_only_unverified",
"window_fields_uia_only_structural",
"api_request",
]
form_state_sha256: str = Field(pattern=PREFIXED_SHA256_PATTERN)
created_at: str
expires_at: str
Expand Down
22 changes: 19 additions & 3 deletions packages/flow/openadapt_flow/approval_mode/window_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,21 @@
FIELD_KEYS = frozenset(
{"kind", "rect", "text", "state", "value_proof", "value_identity"}
)
FIELD_KINDS = frozenset({"title_bar", "edit", "value", "text", "state"})
#: A windowless, read-only control's UIA value read twice (no second source).
#: It enters the approval digest only, never masks pixels, and never counts
#: as a complete value or as read-back evidence.
UIA_ONLY_UNVERIFIED = "uia_only_unverified"
#: The same read for a control whose provider gives no RuntimeId (WinForms
#: grid cells and headers), bound by its structural path instead. Weaker
#: than a RuntimeId binding: a same-type, same-bounds, same-index swap reads
#: as the same control. Digest only, never masked, never complete.
UIA_ONLY_STRUCTURAL = "uia_only_structural"
UNVERIFIED_KINDS = frozenset({UIA_ONLY_UNVERIFIED, UIA_ONLY_STRUCTURAL})
FIELD_KINDS = frozenset({"title_bar", "edit", "value", "text", "state"}) | (
UNVERIFIED_KINDS
)
#: Kinds whose rectangle is never painted out of the OCR read.
UNMASKED_KINDS = frozenset({"state", "value"}) | UNVERIFIED_KINDS
FIELD_STATES = frozenset({None, "on", "off", "indeterminate", "selected", "unselected"})

# The host checks the format it understands, independently of the deployed
Expand Down Expand Up @@ -64,7 +78,9 @@ def valid_form_field(field: Any, *, pid: int | None = None) -> bool:

``text`` without a value proof is the established visible-label channel;
value-backed cells must carry a proof. Containers and empty values enter
the digest but leave their pixels visible. A proof is observation metadata,
the digest but leave their pixels visible. ``uia_only_unverified`` (a
windowless control's value) and ``uia_only_structural`` never
carry a proof, never mask, and are never complete values. A proof is observation metadata,
not a signature or caller-provided authorization.
"""
try:
Expand All @@ -83,7 +99,7 @@ def valid_form_field(field: Any, *, pid: int | None = None) -> bool:
or rect[2] <= 0
or rect[3] <= 0
or (kind in {"edit", "value"} and (proof is None or state is not None))
or (kind in {"title_bar", "state"} and proof is not None)
or (kind in {"title_bar", "state"} | UNVERIFIED_KINDS and proof is not None)
or (kind == "state" and (text != "" or state is None))
):
return False
Expand Down
Loading