Repository navigation
feat(receipts): the post-save screen check earns VERIFIED, with basis post_save_screen - #2849
Conversation
…t and an older SHOWN one
…cs and capability row
…heck, kernel floor and redaction, wrap integrity
…d, step-bound checks, kernel verifier and mint rules, wrap outcome
… verifier total, ignore unkeyed Flow screen checks
…ve_screen from it The runtime now observes, after each save on a backend that can read the page, what a careful person checks: every value the run typed for the save read in a field (bound to its label, alone on a line, or in a labelled cell), the form no longer holding the values, and no new error (error regions, aria-invalid, or failure words on new lines). Counts and flags only go into report.json (StepResult.post_save_screen, ReadbackSave.screen_check, both omitted when unset), and the run receipt earns post_save_screen from them. MockMed's patient record view now shows each saved encounter's fields with labels (Type: ... | Note: ...), as a real EMR's record view does; the banner is unchanged.
…eld; real-run proof The compiler marks the after-frame line where the saved value is bound to the label it was typed under as the read-back field (effect_mining.mark_labelled_field), so a same-screen check reads the record's field instead of a banner. The on-screen verifier compares only the value bound to a marked field's label (ReadbackField.label, omitted when unset). A save whose post-save screen check read every field no longer lists field_values as unchecked on its receipt line. benchmark/post_save_screen holds a real headless MockMed run compiled without database access: its receipt is VERIFIED with basis post_save_screen (Python and JS verifiers), the regulated profile refuses it, and per-fault screen checks.
…d edits, stricter field reads - Page view: per-element exclusion of status regions, on-screen text only, table headers respect column spans, editable controls keyed by element path; a frame that is shown but can't be read means no check. - Check: every intended value read under its label in one record that is new since the save; a still-showing form (even cleared) has not left edit mode; any visible error region or invalid control is an error. - Intended values are the edits the run delivered since its last executed save (not the workflow definition), so guards, loops and graph runs count what ran. - Compiler: labels from this save's steps only; the label starts a line or follows a separator and the value ends there; the effect value is bound to the run input; long labels are skipped. - Verifier: a labelled field needs the strict matcher's label binding. - Receipt: screen checks come from each write's own result; a repeated step earns nothing; checks on stronger-tier saves are ignored. - A missing openadapt_types.evidence means no check, never a failure.
…abel-bound reads keep their kind - Receipt: the saves that need a screen check are rebuilt from the write results, not the summary; checks on saves read at level 3 or 4 are ignored (including for fields_not_read). - Page view: one visible-text reader for lines, cells and dd (status text, controls and unselected options left out; covered or off-screen text left out; <br> and blocks start lines, not source newlines); tables with row spans give no pairs; off-screen frames are skipped; controls keyed by id, name or label when they have one. - Check: a value shown under its label before the save, in any form, is not new; failure words are looked for in table and dl cells and outside the saved values. - Edits: a select or a resumed run makes the next save's edits unknown (no check); only a successful save starts a new list. - Verifier: a labelled read keeps the field's value_kind and date order. - Compiler: a line with the label twice is not marked; the effect value is bound to the run input after the different-path pass.
…e-word value stripping, rendered spacing - Receipt: the run's level is its weakest write's, from the write results. - Error scan: a saved value is left out only as whole words. - Page view: whitespace between inline elements is kept, hidden elements don't break lines, a status cell is left out, a one-row table's cells are lines, and a named control's key includes its form. - Check: only a record that already showed every intended value counts as shown before, so a value shared with an older record still reads. - A save made by a choice gets no check; an ambiguous labelled date stays ambiguous; the compiler counts a repeated label on the raw line.
…d_record) After a complete post-save screen check, when reloading the page can't repeat the save (the save loaded no new document, or the new address has no query string), the runtime loads the same page fresh in a new tab of the same session and reads every typed value again. All shown: the check is marked reopened and the save counts as level 2, so the receipt names reopened_record. One missing (the browser showed a value the server didn't keep): the run stops at that save. MockMed's record view now loads saved encounters from the server on a fresh page load (fault backend only), the way a real record view does, so the reopen reads what was stored. Its partial and optimistic faults, which looked complete right after the save, are now caught on reopen.
- File-size budgets: the page reading moves to backends/page_view.py (no change to playwright_backend.py); the edit tracker, the before/after page views and the reopen halt live in the effects mixin and runtime/post_save_screen.py; replayer.py gains one call line and ir.py two one-line fields (plain dicts, omitted when unset). PostSaveScreenEvidence moves to runtime/post_save_screen.py. - Verdict-folds ratchet: evidence-only handlers hand back NOT_CHECKED; the receipt rebuilds its saves through summarize_report; wrap_receipt_word uses verify-run's classify(). - run_proof.py disables argument abbreviations; public artifact inventory lists the new evidence files; shard durations cover the new test files; seal-view size snapshot updated. - Tests reading MockMed's encounter row follow the labelled text: the e2e banner OCR check scores adjacent line pairs (OCR splits the banner), and the chaos check expects 'Type: Triage'.
Independent adversarial review: REQUEST CHANGESFrom: Grok I reviewed this exact head. I am not approving, and I will not merge or push. Blocker
Related fail-closed gap
What holds
Generality gate
Tests I ran
CI at this headCI is red, for two reasons this branch does not yet address:
The review-verdict check is red because this is the first Grok/Codex review of this head. I am not merging. The PR already says it is held until after the Dec 1 launch and needs the coordinator's sign-off. Limitations, not blockersThe PR already lists several honest gaps (a server-dropped value that the page still shows until reopen, identical older records, selects making a save uncheckable, the shared matcher's |
…ncounter row Taken from CI run 46580234507's flow-golden-runs artifact (Linux). The only differences are the encounter row text, now 'Type: Triage | Note: <note>' (was 'Triage — <note>'), and the final screenshot's hash that shows it.
Independent adversarial review: REQUEST CHANGESFrom: Grok I reviewed this exact head. I am not approving, and I will not merge or push. This is a re-review. Since Blocker
Related fail-closed gap
What holds
Generality gate
Tests I ran
CI at this headFinished package checks I can see are green, including Limitations, not blockersThe PR already lists several honest gaps (a server-dropped value that the page still shows until reopen, identical older records, selects making a save uncheckable, the shared matcher's |
…ved flags are None - with_reopen: the reopened page's own check replaces the post-save one (marked reopened), so the receipt carries what the reopen saw; it earns reopened_record only by the ScreenCheck.complete rule (every value read and matched, form closed, no error, not banner-only). The reopen gate uses the same rule. - observe: a view that doesn't report editable controls or error signals gives left_edit_mode / error_shown None, never closed / no error. - Tests: a reopen that still shows the editable form, a banner-only reopen, a reopen that reads fewer fields, the reopen's own flags, unobserved flags.
Independent adversarial review: APPROVEFrom: Grok I reviewed this exact head. I am not merging or pushing. This is a re-review of the REQUEST CHANGES I posted at The earlier blockers
Fail-closed paths I re-checked
Value matching (
|
What kind of change does this PR introduce?
Feature (receipt vocabulary), with tests and docs. Touches openadapt-types, openadapt-flow, openadapt-kernel, the launcher (
openadapt.wrap,openadapt receipt verify) and seal-view.Summary
OpenAdapt checks a save the way a careful person checks their own work. The post-save screen check is the baseline, so it now earns
VERIFIED, with the evidence named in the basis. Stronger evidence is a stronger basis on the same word, not a better word.post_save_screenis level 1.reopened_recordis level 2, the same check after the acting session reopened the record.post_save_screen_basis()hands these bases out, from a per-saveScreenCheck. The check must show that every intended value was read on the screen field by field and matched, the form left edit mode, no error is shown, and the save was not signalled only by a banner or toast.None) earns no basis, and the word isRECORDED. The receipt listsfields_not_readwhen a value was not read.separate_session,fresh_reload,system_api,activity_log,db_frameandowned_connectionkeep their levels on the sameVERIFIEDword.outcome_wordandbuild_evidence_scopenow defaultminimumtosame_screen.Regulatedpassesseparate_session, so a screen check is notVERIFIEDunder it; a test covers both profiles throughverified_tier_floor.SHOWNis retired. No producer writes it. Older blocks that saySHOWNstill validate at levels 1 and 2 without a basis. They verify in Python and JS (a signed vector covers it), andopenadapt receipt verifylabels the word as the older format.not_covered. It still always lists server-side async and outbound effects.One word per path
evidence_basis.evidence_scope_for_run)screen_checksand earns the basis only from one complete check per save. The tier alone never earns it, because other evidence also lands at tier 4.verify-runread_proves_deltanow uses the newINDEPENDENT_LEVELS(3 and 4), so its behaviour is unchanged even thoughVERIFIED_LEVELSnow lists levels 1 to 4.post_save_screenchannel that applies the same rule toproof.screen_check.ReadBackProof.is_valid()refuses an incomplete check. A channel the bridge does not know no longer counts as a level 3fresh_reloadread; it is not checked (fail closed).openadapt.wrapwrap_receipt_word()takes the word from the Contract'sverify-runreceipt, bound by digest. A declaredchecked_howalone isRECORDED. Signed bytes are unchanged.effect_location,txScreenCheck, so it isRECORDEDwhere it used to beSHOWN.fresh_reload, which it was missing.viewer.htmlis rebuilt at 261,870 of the 262,144-byte budget.| Flow runtime (new) | After each save on a backend that can read the page (the browser), it records a post-save screen check in
report.json(StepResult.post_save_screen,ReadbackSave.screen_check; counts and flags only, omitted when unset). The run receipt earnspost_save_screenfrom it. |Flow runtime: the post-save screen check
runtime/post_save_screen.pycompares the page right before the save with the settled page after it, before any read-back navigates away.Intended values. What the run typed or chose for this save: type and select steps since the previous save, run inputs resolved, secret inputs left out.
Field read. A value bound to its label (
Note: <value>), alone on a line, or in a labelled table cell ordd, judged by the shared strict matcher (openadapt_types.evidence), which is unchanged. Text in a banner, toast or status region (rolealert/status/log,aria-live, or an id or class naming a banner, toast, alert, notice, flash or snackbar) is not a field read. A match must be new: the value shows in more places after the save than before it.Left edit mode. No visible editable control still holds an intended value.
Error shown. An error region appeared or changed, a control became
aria-invalid, or a new line carries a failure word. The region andaria-invalidsignals work in any language; the word list is only an extra signal.Reopened (level 2). When the post-save check is complete and reloading the page can't repeat the save, the runtime reopens the record. Reloading counts as safe when the save loaded no new document, or when the new address has no query string. The reopen is a fresh GET load of the same page in a new tab of the same session.
reopened, the save counts as level 2, and the receipt namesreopened_record.Backends that can't read the page (desktop, Citrix, RDP) record no check, so their screen-checked runs stay
RECORDED. Where reloading isn't safe, the check stays at level 1.What it still can't see:
Compiler and verifier: read the field, not the banner
A same-screen read-back mined from the demonstration's stable region landed on MockMed's "Encounter saved — " banner, and the verifier rightly refused banner text as not the field.
effect_mining.mark_labelled_field): it now marks the one after-frame line where the saved value is bound to the label it was typed under, as aReadbackFieldwith that label. On web recordings the field is read from page structure.ReadbackField.label, omitted when unset).MockMed was changed, and why
MockMed's patient record view now shows each saved encounter's fields with labels:
Type: Triage | Note: <note>, where it used to showTriage — <note>./api/db), as a real record view does. Before, MockMed kept them only in the page, so a reopened record showed nothing.tests/test_mockmed.pyandbenchmark/ui_readback/gui_harness.py.mockmed_*golden baselines pin the old row text, the final screenshots, and report bytes (which now include the screen check). They are Linux results regenerated in CI, so they will be refreshed from this PR's CI artifact.Real-run proof (in-house)
packages/flow/benchmark/post_save_screen/(README, script and results) covers one real headless run on MockMed. The program was compiled without database access, as a customer with no database gets it, and ran with only the on-screen verifier under thestandardprofile.reopened_record, levelreopened. The post-save check read 1 of 1 fields and matched it, the form closed, no error appeared, and the record showed the note again after reopening.openadapt receipt verifyand the JS verifier both accept it.?fault=partial(the server stores the encounter without its note; the page still shows it): the run halts at the save, because the reopened record shows 0 of 1 saved values.?fault=timeout: the run halts.probe-views.json: shows the check after the save and after the reopen for each fault.partialandoptimisticlook complete right after the save and are caught on reopen.timeoutsees the error and the open form, andsessionreads nothing.The script stands in for the reviewing person twice, and says so:
permissivepolicy, because the strict packs need a database effect and an idempotency key (Strict policy packs can't be met by a customer without database access #2859).Not yet shown on a held-out app. MockMed motivated this work, so this is in-house evidence. A run on an app that didn't motivate it, such as OpenEMR's encounter view, hasn't been done. Public wording should wait for it.
Tests
Shared cases:
packages/types/tests/vectors/screen-check/cases.jsonholds ten cases, run through the types ladder, Flow run receipts, the kernel bridge andopenadapt.wrap(tests/test_post_save_screen_parity.py).Signed
record/run/v1vectors, checked by the Python, kernel and JS verifiers:valid-evidence-scope-post-save-screen(accepted)older-evidence-scope-shown(accepted)evidence-scope-screen-with-unread-fields(refused)evidence-scope-screen-with-unchecked-write(refused)Runtime check:
packages/flow/tests/test_post_save_screen_runtime.py.Labelled-field read-back:
test_labelled_field_readback.py.Policy floor:
test_post_save_screen.py.Schema fixtures:
ir.json,deployment.jsonandruntime.effects.effect.jsonregenerated with the locked pydantic.ir.jsonanddeployment.jsonwere already stale on main.Local results:
receipt verify, wrap)The 12 Flow failures also fail on clean main locally or pass when run alone:
runtime_validation,dialog_row_identity, the handoff tests andbrowser_attach.Docs
THREAT_MODEL.md: a new section, "The baseline: check like a careful operator". The post-save screen check is part of layer 1, and record, wire and undo checks are upgrades. It also states what the screen check can't see.RECEIPTS.md,READBACK_LADDER.mdandEFFECT_LOCATION.mdto the runtime check and its limits.CAPABILITIES.mdandllms-full.txt. Repo policy and CI forbid it in a PR;refresh-generated.ymldoes it after merge.Generality
aria-*attributes and counts. MockMed is a test app.openadapt_types.check_level(copied into the standalone kernel), with shared vectors for every path.Independent review
I ran
codex execwith paid API keys stripped.After round 6 I stopped iterating. Each hardening pass on crafted HTML opened a new crafted case, as earlier review loops have done.
Stated limits (also in the docs):
;rule. The shared matcher treats;as a field separator, soNote: green; awaiting reviewreads asgreen. This is unchanged on purpose.Known gaps left from round 6, rare on honest pages:
resume_from, starts with an empty edit list.Pre-existing, not changed here:
fresh_reloaddefault: fixed separately in fix(kernel): never sign a non-DOM read-back as a reload when no reload ran #2854; siblings in Kernel: other paths sign a fresh_reload proof without a proven fresh read #2857.readbackblock: Run receipt keeps VERIFIED for a report with writes but no readback block #2855.Release order
feat, so 0.25.0).>=0.25.0,<0.26.0.With types 0.24.x, Flow fails closed: there is no screen basis. Older verifiers refuse receipts that carry the new bases as malformed, so verifiers should upgrade first.
Checklist
Notes
Held until after the Dec 1 launch. Do not merge before the coordinator signs off.