diff --git a/docs/audits/REALISM_AUDIT.md b/docs/audits/REALISM_AUDIT.md index ca32dd6d79..1247cb06f3 100644 --- a/docs/audits/REALISM_AUDIT.md +++ b/docs/audits/REALISM_AUDIT.md @@ -2,6 +2,11 @@ Date: 2026-10-20. Code: `origin/main` at `0669c4b1f`. +Status re-checked on 2026-11-30 against `origin/main` at `89f19e272`, by reading +the code; no tests were run for the re-check. The Fails column now shows each +row's current state. Ranks 13, 14, 16, 18, 19, 20 and 22 remain open or partly +open, each with its own issue (#2807 to #2813). + ## Why this audit A sign-in spike found that window-scoped recording re-finds its target window @@ -41,22 +46,22 @@ Paths are relative to `packages/flow/openadapt_flow/` unless they start with | 4 | Read-back values | A non-exact read-back match means the expected value is present. `compare_value(..., exact=False)` is a substring test (`runtime/effects/readback_values.py:214`), used for every on-screen check (`runtime/effects/onscreen.py:603-610`). | The expected amount is 250 and the screen shows "$1,250.00". The expected quantity is 5 and the screen shows "Qty 15". A credit "$100.00 CR" reads as 100.00. Each confirms the write. | `test_onscreen_verifier.py` confirms embedded labels and never tests a neighbouring number. | OPEN, reproduced → **fixed** ([#1747](https://github.com/OpenAdaptAI/OpenAdapt/pull/1747)) | H × H | [`test_realism_readback_values.py`](../../packages/flow/tests/test_realism_readback_values.py) (Hypothesis over integers and formats; passes). Issue [#1472](https://github.com/OpenAdaptAI/OpenAdapt/issues/1472) | | 5 | Teach: parameter inference | A value typed whole in one step is the parameter, even if the same value also appears inside longer text in another step (`jit/lift.py`). | The agent types the patient's name into its field and into a note. The note keeps the demonstrated name on every later run. The record check passes because the literal is constant. | `tests/test_jit.py` asserted the old behaviour. | OPEN → **fixed** | H × H | Hypothesis property in [`test_jit.py`](../../packages/flow/tests/test_jit.py) (fix PR [#1465](https://github.com/OpenAdaptAI/OpenAdapt/pull/1465)) | | 6 | Effect checks: baselines | A record's identity is its raw `id`, or `str()` of each field (`runtime/effects/effect.py` `stable_id`). The baseline is stored with `model_dump(mode="json")` (`verify_run.py:709`). | Postgres, MSSQL and Oracle return UUID, Decimal and datetime values. After the JSON round trip they no longer compare equal, so every existing row counts as new. `count_new_only` then confirms a write that never happened. | `test_verify_run*.py` and `test_effect_sql.py` use SQLite ints and strings. | OPEN → **fixed** ([#1482](https://github.com/OpenAdaptAI/OpenAdapt/pull/1482)) | M × H | Hypothesis round trip in `tests/test_stable_id_json_baseline.py` | -| 7 | Teach: canaries | Canary values are different from run 1's. Nothing checks it (`compile_agent/pipeline.py:1010-1041`). | A canary run with run 1's values passes even when the program types a constant, which makes canaries blind to ranks 5 and 8. | Every test happens to use different values. | OPEN | H × H | Property test: admitting with canary values equal to run 1's must refuse. Issue [#1473](https://github.com/OpenAdaptAI/OpenAdapt/issues/1473). | -| 8 | Teach: parameter inference | A value typed whole exactly once belongs to the field it was typed in, with no record-field check. Record binding matches any field whose value equals the input (`jit/lift.py:164-171`, `record_sor.py:272-291`). | `quantity="1"` is set with a stepper, and "1" is typed into refills. Refills becomes the quantity parameter. | Synthetic workflows with long, unique values. | OPEN after the write | M × H | Hypothesis workflows with short values that collide. Issue [#1474](https://github.com/OpenAdaptAI/OpenAdapt/issues/1474). | +| 7 | Teach: canaries | Canary values are different from run 1's. Nothing checks it (`compile_agent/pipeline.py:1010-1041`). | A canary run with run 1's values passes even when the program types a constant, which makes canaries blind to ranks 5 and 8. | Every test happens to use different values. | OPEN → **fixed** ([#1465](https://github.com/OpenAdaptAI/OpenAdapt/pull/1465), [#2661](https://github.com/OpenAdaptAI/OpenAdapt/pull/2661)) | H × H | Property test: admitting with canary values equal to run 1's must refuse. Pinned by `test_compile_agent_canary_values.py::test_a_canary_with_run1_values_is_refused`. Issue [#1473](https://github.com/OpenAdaptAI/OpenAdapt/issues/1473) (closed). | +| 8 | Teach: parameter inference | A value typed whole exactly once belongs to the field it was typed in, with no record-field check. Record binding matches any field whose value equals the input (`jit/lift.py:164-171`, `record_sor.py:272-291`). | `quantity="1"` is set with a stepper, and "1" is typed into refills. Refills becomes the quantity parameter. | Synthetic workflows with long, unique values. | OPEN after the write → **fixed** ([#1754](https://github.com/OpenAdaptAI/OpenAdapt/pull/1754)) | M × H | Hypothesis workflows with short values that collide. Pinned by `test_jit.py::test_lift_needs_a_named_field_for_a_short_value_two_fields_hold` and `test_record_sor.py::test_short_values_and_bare_numerics_not_bound_by_value_alone`. Issue [#1474](https://github.com/OpenAdaptAI/OpenAdapt/issues/1474) (closed). | | 9 | Read-back values | A fuzzy text match whose longest common run covers 90% of the value confirms it (`runtime/effects/onscreen.py:262-277`). | "follow-up scheduled for 2026-10-29" confirms "…2026-10-21". "john smithson" confirms "John Smith". | No test with a difference at the end. | OPEN, reproduced → **fixed** ([#1747](https://github.com/OpenAdaptAI/OpenAdapt/pull/1747)) | M × M-H | [`test_realism_readback_values.py`](../../packages/flow/tests/test_realism_readback_values.py) (passes; `value_matches` is whole-field). Issue [#1472](https://github.com/OpenAdaptAI/OpenAdapt/issues/1472) | -| 10 | UI read-back | A "not found" page proves a record is absent. The browser read-back returns before its identity check (`runtime/effects/ui_readback.py:1089-1104`). The desktop read-back already guards this (`desktop_readback.py:1310`). | A void or delete workflow is verified by absence, but a wrong URL, an access-denied page or a filtered list also shows "not found". | `test_ui_readback_verifier.py` has no such case. | OPEN | M × H | Port the desktop test. Issue [#1475](https://github.com/OpenAdaptAI/OpenAdapt/issues/1475). | +| 10 | UI read-back | A "not found" page proves a record is absent. The browser read-back returns before its identity check (`runtime/effects/ui_readback.py:1089-1104`). The desktop read-back already guards this (`desktop_readback.py:1310`). | A void or delete workflow is verified by absence, but a wrong URL, an access-denied page or a filtered list also shows "not found". | `test_ui_readback_verifier.py` has no such case. | OPEN → **fixed in effect** ([#1515](https://github.com/OpenAdaptAI/OpenAdapt/pull/1515)): an empty page never confirms, and absence claims are removed | M × H | Port the desktop test. Pinned by `test_ui_readback_verifier.py::test_a_search_that_finds_nothing_never_confirms`. Issue [#1475](https://github.com/OpenAdaptAI/OpenAdapt/issues/1475) (closed). | | 11 | Effect checks: paging | The first page of a FHIR or REST search holds every match (`runtime/effects/fhir.py:245`, `rest.py:100-150`). | Servers page at 20 to 50 results. A duplicate on page 2 still confirms `expected_count=1`. | `test_effect_fhir.py` has no paging. | OPEN → **fixed** ([#1538](https://github.com/OpenAdaptAI/OpenAdapt/pull/1538)) | M × H | [`test_effect_paging.py`](../../packages/flow/tests/test_effect_paging.py) (fake FHIR/REST pages; passes). Issue [#1476](https://github.com/OpenAdaptAI/OpenAdapt/issues/1476). | | 12 | Capture: several windows | When several windows match, the largest is the target (`packages/capture/openadapt_capture/window_capture.py:2050`, `window_capture_linux.py:553`). macOS raises `WindowCaptureAmbiguousError` instead. | Two browser or EMR windows are open on different patients. The bigger one is recorded. | `test_window_capture_linux.py::test_resolver_binds_process_and_root_pixel_coordinates` asserted that the largest wins. | OPEN → **fixed** | M × H | [`test_realism_capture.py`](../../packages/capture/tests/test_realism_capture.py) (fix PR [#1468](https://github.com/OpenAdaptAI/OpenAdapt/pull/1468)). Issue [#1477](https://github.com/OpenAdaptAI/OpenAdapt/issues/1477) | -| 13 | Replay: typed-input check | Typing into a field produces the field's old value plus the typed text, and that counts as landed (`runtime/replayer.py:16545-16555`). Nothing clears the field first. | A search box keeps its last query, or a restored draft fills the field. The step saves "SmithJones". | No test with a prefilled field. In a real browser, the click's region check halts this case today. | CLOSED in the tested shape; OPEN when the fill arrives after the click check | M × H | [`test_realism_browser.py`](../../packages/flow/tests/test_realism_browser.py) `::test_a_field_autofilled_on_focus_never_saves_a_concatenation` (passes; pins the halt) | -| 14 | Replay: browser dialogs | A dialog the recording never saw is auto-dismissed by Playwright and not reported (`backends/playwright_backend.py:1137-1140, 3200-3232`). | A `confirm()` before Save returns false, so the save silently doesn't happen. | `test_multi_surface_dialog.py` covers recorded dialogs only. | CLOSED when the step has a visible postcondition (tested); OPEN when it has none | H × M | [`test_realism_browser.py`](../../packages/flow/tests/test_realism_browser.py) `::test_an_unrecorded_confirm_dialog_never_ends_in_success` (passes; pins the halt) | -| 15 | Replay: pixel typed-input check | OCR read-back of a typed value passes at 80% of the value, and any pixel change passes for values under 4 characters (`runtime/replayer.py:16598-16604`, `runtime/identity.py:631-638`). | Keystrokes are dropped over RDP or Citrix, or sent to a guest with a different keyboard layout. MRN `12345678901` arrives as `123456789xy`. | Synthetic OCR fakes. | OPEN | M × H | Fake OCR read-back that is wrong in the last 2 characters must halt. Issue [#1478](https://github.com/OpenAdaptAI/OpenAdapt/issues/1478). | -| 16 | Replay: retry after no change | When a field shows no change, the replayer re-clicks, selects all and retypes. The first delivery may have gone to another window (`runtime/replayer.py:16670-16760`). Windows-agent typing has no foreground check (`backends/win_agent/server.py:419-458`). | A notification steals focus. The patient name lands in a chat box, the retry fills the right field, and the step passes. | Fake backends never change focus. | OPEN | M × H | Fake desktop backend that moves focus on the first keystroke must halt. Issue [#1478](https://github.com/OpenAdaptAI/OpenAdapt/issues/1478). | -| 17 | Replay: occlusion | A structurally present but covered or off-viewport element returns the same value as a missing element, so resolution falls through to the pixel rungs (`backends/playwright_backend.py:2027-2048`, `runtime/resolver.py:767`). | A chat bubble or sticky banner covers the button's centre, and the template click lands on the overlay. | `test_structural_rung.py` has no partial occlusion. | OPEN | M × M-H | Real page with a fixed overlay on the button's centre. Issue [#1479](https://github.com/OpenAdaptAI/OpenAdapt/issues/1479). | -| 18 | Durable: deliveries outside a fence | A first, customer-local leg writes its checkpoint after delivery. A crash in between leaves no pause, so the only path is a fresh run from step 0. The local CLI builds no idempotency ledger. | The process is killed after Save. The re-run repeats every save. | Crashes are simulated with monkeypatch; no test kills a real process. | OPEN | M × H | Subprocess killed with SIGKILL at a random write, then re-run. Issue [#1480](https://github.com/OpenAdaptAI/OpenAdapt/issues/1480). | -| 19 | Capture: clocks | Input events use `time.time()`, and frames use a `perf_counter` offset (`input_observer/*.py`, `recorder.py:2030`). | An NTP step, or sleep and wake on macOS, makes action timestamps drift from frame timestamps. | The observer tests inject a fake clock. | OPEN (alignment) | M × M | Monkeypatch `time.time` to jump mid-recording. Not filed yet. | -| 20 | Capture: Windows | `IsWindowVisible` means the window is on screen. The region grab is what the window shows (`window_capture.py:2004, 2075-2096`). | A minimized window, or one on another virtual desktop. A toast or overlay over the window is recorded as the target's pixels. | No unit tests for the Windows resolver or grab. | OPEN | M × H | A resolver over injected Win32 attributes. Issue [#1477](https://github.com/OpenAdaptAI/OpenAdapt/issues/1477). | -| 21 | Capture: title binding | The title selector re-matches every frame. Linux, macOS and remote-display replay also re-find by exact title. | Chrome, LibreOffice and EMR windows retitle per record. | Static-title fakes. | CLOSED (stops) | H × L | Owned by the window-identity session. | -| 22 | Replay: settle timeout | Outside production profiles, a page that never settles proceeds with the latest frame (`vision/settle.py:304-313`). | Long-poll or server-sent-event requests keep the page "busy" forever. | `test_page_settle.py` covers a blocked settle, not the proceed path. | OPEN (demo profile only) | H × M | Real page with an open EventSource. Not filed yet. | +| 13 | Replay: typed-input check | Typing into a field produces the field's old value plus the typed text, and that counts as landed (`runtime/replayer.py:16545-16555`). Nothing clears the field first. | A search box keeps its last query, or a restored draft fills the field. The step saves "SmithJones". | No test with a prefilled field. In a real browser, the click's region check halts this case today. | CLOSED in the tested shape; **OPEN** when the fill arrives after the click check (`runtime/replay/confirming.py:508`) | M × H | [`test_realism_browser.py`](../../packages/flow/tests/test_realism_browser.py) `::test_a_field_autofilled_on_focus_never_saves_a_concatenation` (passes; pins the halt) Issue [#2807](https://github.com/OpenAdaptAI/OpenAdapt/issues/2807). | +| 14 | Replay: browser dialogs | A dialog the recording never saw is auto-dismissed by Playwright and not reported (`backends/playwright_backend.py:1137-1140, 3200-3232`). | A `confirm()` before Save returns false, so the save silently doesn't happen. | `test_multi_surface_dialog.py` covers recorded dialogs only. | **Partly fixed** ([#2295](https://github.com/OpenAdaptAI/OpenAdapt/pull/2295)): the `dialog_unexpected` halt is armed only for interactive recordings; OPEN elsewhere when the step has no postcondition | H × M | [`test_realism_browser.py`](../../packages/flow/tests/test_realism_browser.py) `::test_an_unrecorded_confirm_dialog_never_ends_in_success` (passes; pins the halt) Issue [#2808](https://github.com/OpenAdaptAI/OpenAdapt/issues/2808). | +| 15 | Replay: pixel typed-input check | OCR read-back of a typed value passes at 80% of the value, and any pixel change passes for values under 4 characters (`runtime/replayer.py:16598-16604`, `runtime/identity.py:631-638`). | Keystrokes are dropped over RDP or Citrix, or sent to a guest with a different keyboard layout. MRN `12345678901` arrives as `123456789xy`. | Synthetic OCR fakes. | OPEN → **fixed** ([#1831](https://github.com/OpenAdaptAI/OpenAdapt/pull/1831)): a changed field must read back the full value | M × H | Fake OCR read-back that is wrong in the last 2 characters must halt. Pinned by `test_replayer.py::test_typed_input_requires_the_exact_ocr_value`. Issue [#1478](https://github.com/OpenAdaptAI/OpenAdapt/issues/1478) (closed). | +| 16 | Replay: retry after no change | When a field shows no change, the replayer re-clicks, selects all and retypes. The first delivery may have gone to another window (`runtime/replayer.py:16670-16760`). Windows-agent typing has no foreground check (`backends/win_agent/server.py:419-458`). | A notification steals focus. The patient name lands in a chat box, the retry fills the right field, and the step passes. | Fake backends never change focus. | **Partly fixed** ([#1831](https://github.com/OpenAdaptAI/OpenAdapt/pull/1831)): no retry outside the browser, so the record stays right; a stray Windows delivery is not prevented, and the focus guard has no real caller | M × H | Fake desktop backend that moves focus on the first keystroke must halt. Issue [#2809](https://github.com/OpenAdaptAI/OpenAdapt/issues/2809). | +| 17 | Replay: occlusion | A structurally present but covered or off-viewport element returns the same value as a missing element, so resolution falls through to the pixel rungs (`backends/playwright_backend.py:2027-2048`, `runtime/resolver.py:767`). | A chat bubble or sticky banner covers the button's centre, and the template click lands on the overlay. | `test_structural_rung.py` has no partial occlusion. | OPEN → **fixed** ([#1756](https://github.com/OpenAdaptAI/OpenAdapt/pull/1756)) | M × M-H | Real page with a fixed overlay on the button's centre. Pinned by `test_playwright_occlusion_refusal.py::test_covered_element_never_falls_through_to_template_rung`. Issue [#1479](https://github.com/OpenAdaptAI/OpenAdapt/issues/1479) (closed). | +| 18 | Durable: deliveries outside a fence | A first, customer-local leg writes its checkpoint after delivery. A crash in between leaves no pause, so the only path is a fresh run from step 0. The local CLI builds no idempotency ledger. | The process is killed after Save. The re-run repeats every save. | Crashes are simulated with monkeypatch; no test kills a real process. | **Partly fixed** ([#2209](https://github.com/OpenAdaptAI/OpenAdapt/pull/2209)): durable runs pause before a first local write; still no SIGKILL test, and local runs have no idempotency ledger | M × H | Subprocess killed with SIGKILL at a random write, then re-run. Issue [#2810](https://github.com/OpenAdaptAI/OpenAdapt/issues/2810). | +| 19 | Capture: clocks | Input events use `time.time()`, and frames use a `perf_counter` offset (`input_observer/*.py`, `recorder.py:2030`). | An NTP step, or sleep and wake on macOS, makes action timestamps drift from frame timestamps. | The observer tests inject a fake clock. | OPEN (alignment) | M × M | Monkeypatch `time.time` to jump mid-recording. Issue [#2811](https://github.com/OpenAdaptAI/OpenAdapt/issues/2811). | +| 20 | Capture: Windows | `IsWindowVisible` means the window is on screen. The region grab is what the window shows (`window_capture.py:2004, 2075-2096`). | A minimized window, or one on another virtual desktop. A toast or overlay over the window is recorded as the target's pixels. | No unit tests for the Windows resolver or grab. | **Partly fixed**: minimized and cloaked windows are skipped; overlays are still recorded as the window's pixels | M × H | A resolver over injected Win32 attributes. Issue [#2812](https://github.com/OpenAdaptAI/OpenAdapt/issues/2812). | +| 21 | Capture: title binding | The title selector re-matches every frame. Linux, macOS and remote-display replay also re-find by exact title. | Chrome, LibreOffice and EMR windows retitle per record. | Static-title fakes. | CLOSED (stops) → **fixed** ([#1468](https://github.com/OpenAdaptAI/OpenAdapt/pull/1468)): the window id is pinned after the first match | H × L | Owned by the window-identity session. Pinned by `test_window_capture.py::TestPinnedWindowIdentity::test_title_change_keeps_capturing_the_same_window`. | +| 22 | Replay: settle timeout | Outside production profiles, a page that never settles proceeds with the latest frame (`vision/settle.py:304-313`). | Long-poll or server-sent-event requests keep the page "busy" forever. | `test_page_settle.py` covers a blocked settle, not the proceed path. | OPEN (unprofiled and Demo runs only) | H × M | Real page with an open EventSource. Issue [#2813](https://github.com/OpenAdaptAI/OpenAdapt/issues/2813). | ### Lower-ranked gaps worth knowing @@ -76,7 +81,8 @@ Paths are relative to `packages/flow/openadapt_flow/` unless they start with are read. Windows low-level hooks can be removed without notice, and a macOS permission revoked mid-recording is not detected. - **Durable runs on macOS:** `fsync` without `F_FULLFSYNC` is not durable - across power loss. + across power loss. Still true on 2026-11-30: nothing under `packages/` uses + `F_FULLFSYNC`. ## Open items @@ -86,7 +92,8 @@ Not audited in depth in this pass, and left open: systems (their tests use fake clients only); - autofill, password-manager and permission UI on attached real-profile browsers; - crash and resume under a real process kill (issue #1480); -- every gap above whose status still reads OPEN, each tracked by its issue. +- every gap above whose status still reads OPEN or partly fixed, each tracked + by its issue. ## What already fails closed, and was checked @@ -117,7 +124,9 @@ with that session rather than changed here. so the browser tests here run on every flow change. - Several browser test modules call `pytest.skip` when Chromium fails to launch. In CI that skip should be a failure, or a broken browser install - silently drops those tests. + silently drops those tests. Still true on 2026-11-30: 33 flow test files + skip this way, and CI checks skips only in the critical, golden and on-prem + junit files (`.github/workflows/packages.yml`). - The macOS, Windows, Linux, RDP and Citrix replay backends are tested only against fake clients. None of the fakes change focus, titles, keyboard layout or codec noise. A realistic test for those needs a real OS runner.