Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
8ac01cb
feat(flow): one verdict kernel, a fail-open harness and a fold ratchet
abrichr Nov 21, 2026
f6d8d0d
fix(flow): close the gaps a review found in the verdict kernel and ha…
abrichr Nov 21, 2026
2d9b7e0
fix(flow): second review round on the verdict kernel and harness
abrichr Nov 21, 2026
ff07a95
Merge remote-tracking branch 'origin/main' into claude/fail-open-general
abrichr Nov 21, 2026
9b6956b
Merge remote-tracking branch 'origin/main' into claude/fail-open-general
abrichr Nov 22, 2026
f77c4cb
fix(flow): settle the positive controls, verify-run folds and receipt…
abrichr Nov 22, 2026
f34a1ec
fix(flow): close the log-call hole in the swallow check; state the pr…
abrichr Nov 22, 2026
c151226
fix(flow): close the four ratchet and observed gaps Gemini found
abrichr Nov 22, 2026
7a5f6e4
docs(flow): record how the fold baseline was measured and why unread-…
abrichr Nov 22, 2026
1e1f79c
feat(flow): links, tabs and menu items as steps; the commit point is …
abrichr Nov 22, 2026
c6d6cb1
docs(flow): record gui.steps in CAPABILITIES, the changelog and the f…
abrichr Nov 22, 2026
f72b015
fix(flow): take no step on a backend that cannot count writes; refute…
abrichr Nov 22, 2026
847be95
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 22, 2026
10ed817
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 23, 2026
93dc3a9
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 23, 2026
f250b48
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 23, 2026
3f85d83
Merge remote-tracking branch 'origin/claude/fail-open-general' into HEAD
abrichr Nov 23, 2026
0158fe7
fix(gui): count only 2xx/3xx same-origin write responses and refute 4…
abrichr Nov 23, 2026
0ff9b43
fix(gui): match each commit write's outcome to the demo
abrichr Nov 23, 2026
a1e1d8b
fix(gui): key redirects by path and query, with minted ids replaced
abrichr Nov 23, 2026
c33290c
Merge remote-tracking branch 'origin/main' into HEAD
abrichr Nov 24, 2026
97dc0cb
test(gui): serve synthetic test apps on loopback HTTP so 302 redirect…
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
7 changes: 6 additions & 1 deletion CAPABILITIES.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| Steps drawn as links, tabs or menu items, and the commit point learned from the demonstration: a step's role (commit, navigate, in place) comes from the writes the backend counted, never its words; a commit holds only on exactly the demonstrated writes, and a backend that cannot count writes never attempts one | On main ([#2499](https://github.com/OpenAdaptAI/OpenAdapt/pull/2499)) | Synthetic: a web form, an EMR-like chart, a SaaS settings page (headless Chromium) and a spreadsheet-like grid with no browser | `openadapt_flow.gui.steps`, `packages/flow/tests/gui` |
2 changes: 1 addition & 1 deletion capabilities/CAPABILITIES.md.sha256
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5828c214b5d23d77e08c7a6feb1f7e58b220467ca05894d87d2fddc6bd91f96f
6df073cac92b3e1998b04f9e83520994614d253611d8f1f6597499ba8746651e
6 changes: 6 additions & 0 deletions packages/flow/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@

### Features

- Links, tabs and menu items can be steps (`openadapt_flow.gui.steps`). Each
demonstrated click gets its role from what the backend counted: a commit
when it wrote, a navigation when the screen changed with no write. A live
commit holds only on exactly the demonstrated writes. `openadapt_flow.gui`
is a neutral view of a screen (role, name, state, containers) with adapters
for a browser page, an accessibility tree and a `form_tx` snapshot.
- One verdict kernel, `openadapt_flow.verdict`, for every check that turns
evidence into held, refuted or not checked. It fixes the obligations from
the plan first, settles results against them, and never passes an empty
Expand Down
2 changes: 2 additions & 0 deletions packages/flow/docs/FAIL_CLOSED.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,8 @@ Done:
- [x] `receipt_record._tally_lines` (C2 C3): fix: a line check nobody listed
keeps the run from VERIFIED and counts as not checked.
- [x] `tx/wire_tap.relay_redirect_location` (C6): registered after #2470.
- [x] `gui.steps.judge_step` (C3 C5): new. A commit holds only on exactly
the demonstrated writes; an unlisted step role is not checked.

Next, most bug-prone first:

Expand Down
22 changes: 22 additions & 0 deletions packages/flow/openadapt_flow/gui/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""General GUI mechanisms over one neutral view of a screen.

Programs that fill forms keep meeting the same few interface shapes in every
kind of app: a portal, an EMR chart, a spreadsheet grid, a SaaS settings page.
This package handles each shape once, over :mod:`openadapt_flow.gui.model`
(controls with a role, a name, a state and the containers they sit in), so no
mechanism depends on a browser or names an application:

- :mod:`openadapt_flow.gui.steps`: a link, a tab or a button can be a step,
and the step that commits is the one the demonstration showed writing.

Per-app facts (which control, which words, how many writes) are pack data,
learned from a demonstration or declared by the pack author. The engine holds
no word lists of its own.

Adapters turn a backend's view into a :class:`~openadapt_flow.gui.model.Screen`:
:mod:`openadapt_flow.gui.dom` for a browser page,
:mod:`openadapt_flow.gui.adapters` for an accessibility tree (desktop,
spreadsheet) or a ``form_tx`` snapshot.

Stdlib only, apart from the browser adapter.
"""
222 changes: 222 additions & 0 deletions packages/flow/openadapt_flow/gui/adapters.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
"""Turn other backends' views into a :class:`~openadapt_flow.gui.model.Screen`.

- :func:`screen_from_tree`: an accessibility tree (UI Automation, AX, AT-SPI,
or a spreadsheet's cell grid exported as one). Each node is a mapping with
``role``, ``name`` and optional ``handle``, ``value``, ``checked``,
``disabled``, ``readonly``, ``target``, ``text`` and ``children``. Nodes
whose role is a container role (:data:`CONTAINER_ROLES`) become containers
of the controls under them; a ``dialog`` node also becomes a
:class:`~openadapt_flow.gui.model.Dialog`.
- :func:`screen_from_form_snapshot`: a ``form_tx`` ``FormSnapshot``, read by
attribute so this module does not import ``form_tx``. That snapshot keeps
section and row text, not container handles, so the containers it gives are
named by their text and carry no structure beyond it.

Role names are mapped through :data:`TREE_ROLES`; an unknown role is
``other`` and never acts as a control a mechanism can use.
"""

from __future__ import annotations

from typing import Any, Mapping, Optional

from openadapt_flow.gui.model import ROLES, Container, Control, Dialog, Screen

__all__ = [
"CONTAINER_ROLES",
"TREE_ROLES",
"screen_from_form_snapshot",
"screen_from_tree",
]

#: Accessibility role names from common trees, mapped to :data:`ROLES`.
TREE_ROLES: Mapping[str, str] = {
"edit": "textbox",
"text field": "textbox",
"textfield": "textbox",
"entry": "textbox",
"searchbox": "textbox",
"spinbutton": "textbox",
"check box": "checkbox",
"check_box": "checkbox",
"toggle button": "switch",
"radio button": "radio",
"radiobutton": "radio",
"combo box": "combobox",
"popupbutton": "combobox",
"list": "listbox",
"push button": "button",
"hyperlink": "link",
"tab item": "tab",
"tabitem": "tab",
"page tab": "tab",
"menu item": "menuitem",
"dataitem": "cell",
"data item": "cell",
"gridcell": "cell",
"table cell": "cell",
"static text": "text",
"statictext": "text",
"label": "text",
}

#: Tree roles that hold controls rather than being one, and their kind.
CONTAINER_ROLES: Mapping[str, str] = {
"group": "group",
"grouping": "group",
"pane": "region",
"region": "region",
"section": "region",
"form": "form",
"dialog": "dialog",
"window": "region",
"row": "row",
"dataitem row": "row",
"list item": "item",
"listitem": "item",
"table": "region",
"grid": "region",
"sheet": "region",
}


def _role(raw: object) -> str:
key = " ".join(str(raw or "").split()).casefold()
if key in ROLES:
return key
return TREE_ROLES.get(key, "other")


def screen_from_tree(
root: Mapping[str, Any],
*,
location: str = "",
title: str = "",
complete: bool = True,
) -> Screen:
"""Flatten ``root`` into a :class:`Screen`. A node without ``handle`` gets
its index path (``0/2/1``), which is stable only while the tree is."""

controls: list[Control] = []
dialogs: list[Dialog] = []
texts: list[str] = []

def walk(
node: Mapping[str, Any],
path: str,
boxes: tuple[Container, ...],
dialog: str,
) -> None:
handle = str(node.get("handle") or path)
raw_role = " ".join(str(node.get("role") or "").split()).casefold()
name = str(node.get("name") or "")
kind = CONTAINER_ROLES.get(raw_role)
if node.get("text"):
texts.append(str(node["text"]))
if kind is not None:
box = Container(handle, kind, name, str(node.get("text") or name))
boxes = boxes + (box,)
if kind == "dialog" and raw_role == "dialog":
dialogs.append(Dialog(handle, name, str(node.get("text") or "")))
dialog = handle
else:
role = _role(raw_role)
if role != "other":
checked = node.get("checked")
controls.append(
Control(
handle=handle,
role=role,
name=name,
value=str(node.get("value") or ""),
checked=None if checked is None else bool(checked),
disabled=bool(node.get("disabled")),
readonly=bool(node.get("readonly")),
required=bool(node.get("required")),
containers=boxes,
dialog=dialog,
target=str(node.get("target") or ""),
error=str(node.get("error") or ""),
)
)
for i, child in enumerate(node.get("children") or ()):
walk(child, f"{path}/{i}", boxes, dialog)

walk(root, "0", (), "")
return Screen(
controls=tuple(controls),
dialogs=tuple(dialogs),
location=location,
title=title or str(root.get("name") or ""),
text="\n".join(texts),
complete=complete,
)


def _snapshot_role(ctrl: Any) -> str:
role = _role(getattr(ctrl, "role", ""))
if role != "other":
return role
tag = str(getattr(ctrl, "tag", "")).casefold()
kind = str(getattr(ctrl, "input_type", "")).casefold()
if tag == "a":
return "link"
if tag == "button" or kind in ("submit", "button", "reset", "image"):
return "button"
if tag == "select":
return "combobox"
if kind in ("checkbox", "radio"):
return kind
if tag in ("input", "textarea"):
return "textbox"
return "other"


def screen_from_form_snapshot(snapshot: Any) -> Screen:
"""A ``form_tx`` snapshot as a :class:`Screen`. Containers are the
control's section text and row text, named by that text."""

controls = []
for ctrl in getattr(snapshot, "controls", ()) or ():
if not getattr(ctrl, "visible", True) or getattr(ctrl, "is_secret", False):
continue
boxes: list[Container] = []
section = str(getattr(ctrl, "section_text", "") or "")
if section:
boxes.append(Container(f"section:{section}", "region", section, section))
row = str(getattr(ctrl, "row_text", "") or "")
if row:
boxes.append(Container(f"row:{row}", "row", "", row))
modal = str(getattr(ctrl, "modal_container", "") or "")
checked: Optional[bool] = getattr(ctrl, "checked", None)
controls.append(
Control(
handle=str(getattr(ctrl, "dom_selector")),
role=_snapshot_role(ctrl),
name=str(getattr(ctrl, "label_text", "") or ""),
value=str(getattr(ctrl, "current_value", "") or ""),
checked=checked,
disabled=bool(getattr(ctrl, "disabled", False)),
readonly=bool(getattr(ctrl, "readonly", False)),
required=bool(getattr(ctrl, "required", False)),
containers=tuple(boxes),
dialog=modal,
error=str(getattr(ctrl, "error_text", "") or ""),
)
)
dialogs = tuple(
Dialog(
str(getattr(m, "container_selector", "")),
str(getattr(m, "modal_id", "")),
str(getattr(m, "message_text", "") or ""),
)
for m in getattr(snapshot, "active_modals", ()) or ()
)
return Screen(
controls=tuple(controls),
dialogs=dialogs,
location=str(getattr(snapshot, "url_origin_and_path", "") or ""),
title=str(getattr(snapshot, "title", "") or ""),
text=str(getattr(snapshot, "page_text", "") or ""),
errors=tuple(getattr(snapshot, "banner_errors", ()) or ()),
)
Loading