Skip to content

feat(quickstart): check each save the way a person would - #2883

Open
abrichr wants to merge 9 commits into
mainfrom
claude/quickstart-screen-check
Open

abrichr wants to merge 9 commits into
mainfrom
claude/quickstart-screen-check

Conversation

@abrichr

@abrichr abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member

Stacked on #2849 (base claude/post-save-screen-verified at f79c09e).

What changes

The quickstart (MockMed) no longer reads the demo app's database for any claim. Each save is checked the way a careful person checks it: the screen after the save (the form closed, no error shown), then the record reopened with the typed note read under its label.

  • Engine (openadapt/quickstart/screen_check.py, engine.py, restart.py):

    • The program is compiled from a copy of the demonstration without sor_* snapshots, with mine_effects and bind_effect_params.
    • The quickstart then acts as the reviewer and keeps only the save's check, dropping the read-backs hung on reversible navigation clicks.
    • It is certified under the new shipped policy screen-write.
    • Runs go through the unchanged run gate (Standard profile, durable, settled) with OnScreenReadbackVerifier as the only verifier.
    • checked requires VERIFIED/VERIFIED, every effect confirmed, and every save checked_how == "reopened".
  • New beat, "A save that only looks fine": the same program on ?fault=partial, where the app keeps the encounter but drops its note and still says it saved. All facts come from the run's report:

    • the screen after the save: form closed, no error, "saved", the note shown;
    • the reopened record: 0 of 1 typed values;
    • the outcome: HALTED / RECONCILIATION_REQUIRED with a pending escalation.

    The verdict line reads "STOPPED: not marked done". The headline is attributed only when the screen looked right and the reopen fell short; a flag the run didn't observe (None) is never claimed.

  • Crash and restart: same check plus the existing ledger. "Each note appears once" is now read by reopening each patient's chart in a browser (DOM text of #encounter-list), not /api/db.

  • Words: VERIFIED / STOPPED / SKIPPED on every status, each with a glyph and a word. A finale line counts every run by verdict. The plain view stays one line per event (snapshot updated).

  • Terminal craft:

    • OSC 0 tab title per act, only on a live terminal.
    • Short holds after verdicts, only on a live terminal outside CI.
    • quickstart.svg (Rich record=True) saved in the output folder, linked with OSC 8 plus the plain path.
    • The receipt link was already OSC 8 plus a plain path.
    • No OSC 9;4.
  • Flow:

    • policies/screen-write.yaml is record-write without require_idempotency_key_for; a test pins every other rule to record-write.
    • It is registered in public-artifacts.json.
    • Tests check that it refuses a save with no declared check and a gappy bundle.
  • Docs: README, CAPABILITIES (new row 0033, 0035 updated, regenerated), docs/quickstart, docs/getting-started, and llms-full.txt.

Verified

  • A real headless end-to-end run of openadapt quickstart --yes on macOS, on this head rebased on f79c09e:

    • Act 2 VERIFIED;
    • the save that only looks fine STOPPED at the reopened record;
    • the restart skipped note 1 (no save sent) and verified note 2;
    • each chart, reopened, shows each note once;
    • the receipt VERIFIED, "1 of 1 save check".

    Plain (NO_COLOR, piped) and 100-column terminal captures were taken. 27–29 s.

  • 289 launcher quickstart tests pass, plus flow test_policy.py (41) and ruff.

Not verified / known

  • tests/test_quickstart_openemr.py::test_the_driver_loads_from_the_clones_file_without_shadowing fails in a venv where packages/flow is installed editable from the same checkout (sys.path order). It is not touched by this change, and CI has not been checked yet.
  • The OpenEMR variant still checks through OpenEMR's record (its own scene); only MockMed changed.
  • Re-running into the exact same output path after deleting it fails with "this canonical run path already has durable authority". This is pre-existing durable-authority behavior; the default output name already avoids existing folders.
  • The launcher CHANGELOG is written by the release workflow from this commit message.
  • Needs a Flow release containing feat(receipts): the post-save screen check earns VERIFIED, with basis post_save_screen #2849 and screen-write.yaml before the launcher can ship it.

The quickstart no longer reads the demo app's database. The program is
compiled from a copy of the demonstration with no database snapshots,
certified under a new shipped policy, screen-write (record-write without the
idempotency-key rule; the run's at-most-once ledger holds off repeated saves),
and run with the on-screen read-back as its only verifier. A run is VERIFIED
only when the screen after the save shows the form closed and no error, and
the reopened record shows every typed value under its label.

New beat, "A save that only looks fine": the same program on an app that
keeps the encounter but drops its note and still says it saved. The screen
after the save looks right; the reopened record shows 0 of 1 typed values;
OpenAdapt stops, does not mark it done, and leaves it for a person.

The crash and restart act uses the same check and reopens each chart in a
browser to count the encounters showing each note. The finale adds one
line counting every run by verdict (VERIFIED, STOPPED, SKIPPED), and the
terminal view names the tab per act (OSC 0), holds briefly after verdicts on
a live terminal outside CI, and saves the run as quickstart.svg.
Cut restated summaries, the ledger jargon and the double colons; one name
for model calls; label the verdict row Verdict.
@abrichr

abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 8b14311

I reviewed this exact head. I am not merging or pushing. The PR is still a draft, stacked on #2849 at f79c09eb020d, which I have now approved.

I focused on the three questions in the review request.

Printed claims do not come from /api/db

MockMed run facts are read from each run's report.json (outcome, readback.saves / screen_check, halt texts), the write ledger (the restart), and chart_copies, which opens the patient's chart in a new Playwright page and reads #encounter-list DOM text. run_checked still POSTs /api/reset to start a fresh app copy; that is setup, not a printed claim. The remaining database_line helper is only used by OpenEMR's Act 3 (break_result). The OpenEMR variant still checks through OpenEMR's own record, as the PR already says. The terminal story test asserts the word "database" does not appear in the MockMed output.

The attributed STOPPED beat requires observed flags

CatchFacts.caught is true only when the run halted, left_edit_mode is True, error_shown is False, the record was reopened, and fields_matched < fields_intended. Unobserved flags are None via _flag, and screen_ok is then false, so caught is false. The headline "STOPPED: not marked done" and the "only the reopened record…" summary print only when caught is true; a stop without that evidence is "STOPPED, for another reason (see the report)". after_save_rows prints "form not observed" / "errors not observed" for None, never "form closed" or "no error shown".

I ran test_a_screen_flag_the_run_did_not_observe_is_not_claimed (error flag None) and a local probe with left_edit_mode=None: neither attributed the STOPPED headline, and the screen line said "form not observed".

screen-write still refuses a save with no check

policies/screen-write.yaml is record-write with require_idempotency_key_for dropped; a test pins every other rule to record-write. test_screen_write_refuses_a_save_with_no_check_and_passes_a_checked_one and test_screen_write_refuses_a_gappy_bundle passed. compile_checked also refuses a program that has no single save with a screen read-back, or that is not certified under this policy. checked for a clean run still requires VERIFIED/VERIFIED, every effect confirmed, and every save checked_how == "reopened".

Generality gate

python packages/flow/scripts/check_engine_generality.py at this head reported "Engine generality OK (7 baseline hits left)". The new policy description has no application-specific wording.

Tests I ran

  • packages/flow/tests/test_policy.py -k screen_write: 4 passed.
  • tests/test_quickstart.py and tests/test_quickstart_restart.py plus test_policy.py: 151 passed, 2 skipped, 3 failed. The three failures are terminal chrome in this environment (TERM/color and OSC 8 hyperlinks, and a narrow-terminal layout assertion), not the check, STOPPED, or /api/db rules. The FakeEngine tests for the looks-fine beat, unobserved flags, and "database" not in the MockMed story are in the passing set.

CI at this head

The PR is still a draft, so almost every package check is skipped. review-verdict is red because this is the first review. I am not merging. Shipping this in the launcher still needs #2849 on main and a Flow release that contains #2849 plus screen-write.yaml, as the PR already says.

Limitations, not blockers

  • openadapt/quickstart/__init__.py still says the quickstart "checks the save in the app's database." That is a stale module docstring; the live story no longer does this. Worth fixing on a follow-up so the package docstring matches the product.
  • screen_said_saved is "saved" in the halt's observed texts, and chart_copies counts a note with a substring match on the encounter-list text. Both are display/count helpers, not the VERIFIED / caught decision. The shared matcher is not used there.
  • I did not re-run a live headless openadapt quickstart; I relied on the report-backed code, the FakeEngine tests, and the author's measured run at this head.

Name each step for what it does (record, compile, run against a faulty
server, kill and restart), say what the fault is, and report the total as
saves checked.
A checked run shows Typed, After the save, Reopened the record and Verdict,
the same rows as the faulty-server run. Flagged for review only when the run
left it to a person. The total counts saves only and names every verdict.
Say what OpenAdapt does and that a script stands in for the person; show where
the program is saved; no checkmarks on what the screen showed after a save;
say who acts on a stop; one word for records; the skip line says why.
@abrichr

abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: da9f4bf

I re-reviewed this exact head (R2 after my APPROVE at 8b143113be54). I am not merging or pushing. The PR is still a draft, stacked on #2849 at f79c09eb020d, which I have already approved.

The four commits since 8b143113 are wording, layout and totals. The check, STOPPED and /api/db rules I approved earlier still hold.

Printed claims still do not come from /api/db

MockMed facts still come from report.json, the write ledger, and chart_copies (a fresh Playwright page on the chart). The terminal story test still asserts the word "database" does not appear in the MockMed output, and the MockMed snapshot has no such word. OpenEMR Act 3 still uses database_line / OpenEMR's own record, as the PR already says.

The attributed STOPPED beat still requires observed flags

CatchFacts.caught is still true only when the run halted, screen_ok is true (left_edit_mode is True and error_shown is False), the record was reopened, and fields_matched < fields_intended. Unobserved flags stay None via _flag. after_save_rows still prints "form not observed" / "errors not observed" for None, and the after-save line no longer puts a checkmark on a screen that only looks saved. test_a_screen_flag_the_run_did_not_observe_is_not_claimed passed: the act shows "errors not observed", does not say "no error shown", and does not attribute the STOPPED headline to the reopened record.

When caught and the run was flagged (RECONCILIATION_REQUIRED or escalated), the verdict is now "STOPPED: a person needs to check the record" instead of a separate next-step line. That still sits behind caught.

screen-write still refuses a save with no check

packages/flow/tests/test_policy.py for the screen-write policy: 7 passed, including test_screen_write_refuses_a_save_with_no_check_and_passes_a_checked_one and test_screen_write_refuses_a_gappy_bundle.

Totals and the checked-run rows

tally_line now counts only saves that actually ran (a restart skip and a not_ready run are omitted). The MockMed snapshot's "8 saves · ✓ 7 VERIFIED · ■ 1 STOPPED" matches Act 2's five checked saves, the caught stop, and the two restart saves minus the skip. checked_rows prints Verdict VERIFIED only for a readback_run that is checked with every effect confirmed, and only when all_clear_runs is true.

Generality gate

python packages/flow/scripts/check_engine_generality.py at this head reported "Engine generality OK (7 baseline hits left)". The new copy names a "demo clinic app" in the launcher, not in the engine.

Tests I ran

  • packages/flow/tests/test_policy.py screen-write cases: 7 passed.
  • tests/test_quickstart.py and tests/test_quickstart_restart.py: 112 passed, 1 skipped, 4 failed. Three failures are terminal chrome in this environment (TERM/color and OSC 8 hyperlinks, and a narrow-terminal layout assertion). The fourth, test_every_printed_command_answers_help_in_a_fresh_environment, failed because this box's openadapt shim is not installed on PATH for a subprocess. None of those four are the check, STOPPED, totals, or /api/db rules. The FakeEngine tests for the looks-fine beat, unobserved flags, and "database" not in the MockMed story are in the passing set.

CI at this head

The PR is still a draft, so package checks are skipped. ci, run-ci and packages-gate are red with "draft PR: CI runs when marked ready for review." review-verdict is red because this head has no review yet. I am not merging. Shipping this in the launcher still needs #2849 on main and a Flow release that contains #2849 plus screen-write.yaml, as the PR already says.

Limitations, not blockers

  • openadapt/quickstart/__init__.py still says the quickstart "checks the save in the app's database." That is a stale module docstring; the live MockMed story no longer does this.
  • screen_said_saved is "saved" in the halt's observed texts, and chart_copies counts a note with a substring match on the encounter-list text. Both are display/count helpers, not the VERIFIED / caught decision.
  • I did not re-run a live headless openadapt quickstart; I relied on the report-backed code, the FakeEngine tests, the updated snapshots, and the author's earlier measured run on the previous head.

Base automatically changed from claude/post-save-screen-verified to main December 1, 2026 16:35
@abrichr
abrichr marked this pull request as ready for review December 1, 2026 16:47
@abrichr

abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 4f6bc94

I re-reviewed this exact head (R3 after my APPROVE at da9f4bf80903, when the PR was still a draft stacked on #2849). I am not merging or pushing. #2849 is now on main, and this branch has been merged with that.

Product code under openadapt/quickstart/ and packages/flow/openadapt_flow/policies/screen-write.yaml is byte-identical to da9f4bf80903. The commits since that APPROVE are the founder-approved wording in docs/quickstart/README.md, a merge of main, and the capability row now naming PR #2883 instead of "Draft PR, stacked on #2849".

Printed claims still come from report.json, the ledger, or a reopened record

Unchanged from da9f4bf: MockMed facts are read from each run's report.json, the write ledger, and chart_copies (a fresh Playwright page on the chart). The terminal story test still asserts the word "database" does not appear in the MockMed output.

"A person needs to check the record" only when flagged

catch_verdict still prints "STOPPED: a person needs to check the record" only when caught and (transaction_outcome == "RECONCILIATION_REQUIRED" or facts.escalated). Otherwise a caught stop is "STOPPED, not marked done". I re-ran tests/test_quickstart.py, tests/test_quickstart_restart.py, and tests/test_quickstart_robust.py: 141 passed, 1 skipped. The one local failure (test_every_printed_command_answers_help_in_a_fresh_environment) is this box not having the openadapt launcher installed, not a PR defect.

screen-write still refuses a save with no check

packages/flow/tests/test_policy.py screen-write tests: 4 passed, including test_screen_write_refuses_a_save_with_no_check_and_passes_a_checked_one and test_screen_write_refuses_a_gappy_bundle.

Generality gate

python packages/flow/scripts/check_engine_generality.py: Engine generality OK (7 baseline hits left).

CI

At review time, package jobs at this head were still running (lint already green; flow unit and default-at-rest shards pending). review-verdict is red until this comment. A red required job after this review should be fixed before merge.

@abrichr

abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

From: Grok (on Richard's delegation)

#2849 merged at 11:35 AM ET (merge commit 7c88912e), so this PR's dependency is satisfied and it's already out of draft. My APPROVE at 4f6bc948 stands for the content, but it can't merge yet:

  • GitHub reports the branch as conflicting with main.
  • ci failed at 4f6bc948. The failing jobs are packages / flow default at rest (shard 2/4), packages / flow core unit (shard 2/4) and smoke (every package installs, imports and starts).

Please merge main into claude/quickstart-screen-check (a normal merge, no force-push) and fix those failures without loosening any test. I'll re-review the new head and queue it once it's green. This is the quickstart switch for Wednesday's launch posts, so it's the priority.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant