Skip to content

fix(flow): quickstart writes its run summary through the sealed set (fixes #2682) - #2683

Merged
abrichr merged 3 commits into
mainfrom
claude/quickstart-at-rest
Nov 25, 2026
Merged

abrichr merged 3 commits into
mainfrom
claude/quickstart-at-rest

Conversation

@abrichr

@abrichr abrichr commented Nov 25, 2026

Copy link
Copy Markdown
Member

Fixes #2682.

Problem

With encryption at rest on (the default since Flow 4.0.0), openadapt quickstart exits 1 on a fresh machine. write_receipt wrote run-summary.json, run-summary.md and run-summary.png with plain file writes into the encrypted run folder, outside its sealed index. seal_run then refused the folder with report_unreadable. Released openadapt 1.24.0 with Flow 4.0.0 from PyPI is affected. I reproduced it in a clean venv with an empty HOME.

Fix

  • openadapt_flow.receipt.write_receipt writes all three summary files through sealed_set.write_bytes. The PNG is rendered to memory first. Outside a sealed folder this is a plain write, as before.
  • The run inventory in sealed_set.py names run-summary.json, .md and .png as structural (allow-listed plaintext). They sit next to their pre-3.5 names, receipt.md and receipt.png, which were already listed. The summary is the allow-listed receipt projection (outcomes, counts, digests, no record text). phi_at_rest.md already documented it as plaintext beside an encrypted run. The inventory just never picked up the Flow 3.5 rename.
  • Fail-closed is unchanged. seal_run, _adoptable and _reconcile_run_files are untouched, and any other plaintext file in a run folder still makes it refuse (tested).
  • The same bug exists in the OpenEMR quickstart, in the halted run: screen.png from the driver's Session.screenshot and quickstart-readback.json were written directly into run-broken. Both now go through the set. The read-back file names a synthetic patient, so it is sealed as a normal run file.

Why the summary stays plaintext instead of being encrypted: __main__ prints the PNG path as the "Shareable receipt", demo_proof and the lifecycle script read it, and keyless readers (read_run_summary, seal_publish) expect it as plaintext. Encrypting it would break those readers and would contradict the documented receipt design.

Known limit: for a run set, _reconcile_run_files re-records the hash of plain-codec files on open. An edit to the summary after sealing is therefore not caught at open, as is already the case for the other receipt files. This PR does not change that.

Tests

  • packages/flow/tests/test_run_summary_sealed.py (browserless): seals a run, calls write_receipt, then checks that open_set plus verify_all succeed, that every file on disk is in the index, that a keyless read_run_summary works, that a later write to the run works, and that an unlisted plaintext file still makes the run refuse. Without the fix, the first two tests fail with the exact holds run-summary.json in plaintext error.
  • packages/flow/tests/test_quickstart_encrypted.py: the real quickstart in a hidden browser, with encryption forced on in any lane, an empty HOME and no seal home. It asserts that every run checked and was sealed (seal.json exists), and that every sealed folder's on-disk files are in its index. Without the fix it fails the same way.
  • The launcher's opt-in test_real_quickstart allows run-summary.png as plaintext and gains the same index check.

CI: these live in packages/flow/tests outside e2e/. The flow default at rest and flow core unit lanes both install the in-tree launcher and a Playwright browser, so they run on every Flow-touching PR and on main. The quickstart test is skipped only if the launcher or Playwright is missing. Before this change, the launcher's quickstart tests used a fake engine with OPENADAPT_FLOW_PLAINTEXT_AT_REST set, and the one real encrypted test was opt-in and never enabled.

Local results:

  • 13 Flow files (sealed set, at-rest default, receipts, tutorial, OpenEMR driver, the new tests): 290 passed in the plaintext lane; 286 passed and 4 skipped (existing skips) with OPENADAPT_TEST_DEFAULT_AT_REST=1.
  • Launcher: tests/test_quickstart.py, test_quickstart_openemr.py and test_quickstart_lifecycle.py with OPENADAPT_REAL_QUICKSTART=1: 147 passed, 1 skipped (the Docker OpenEMR run).
  • Manual: from source with an empty HOME, openadapt quickstart exits 0. Every sealed folder (recording, bundle, run-1, run-broken) opens, and every file in it is indexed. The same holds for openadapt-flow tutorial --break-it and for a rerun beside a crashed 4.0.0 output folder.
  • Not run: the OpenEMR quickstart end to end (needs Docker).

Release metadata

  • Flow: an entry under Unreleased, with no version bump. Flow's Unreleased already holds features (gui.attestations, hub pages, repeating structures), so the next Flow release is a minor (4.1.0), not 4.0.1. release_plan also builds main's tip, so a patch-only 4.0.1 can't be cut from main. The fix ships with the next release PR. Since released 4.0.0 is broken out of the box, that release should go out soon.
  • Launcher: openadapt/quickstart/openemr.py changed, so the launcher CHANGELOG gets an Unreleased entry, with no version bump. The MockMed quickstart fix needs no launcher change; it arrives with the new Flow. When the launcher is next released, raise its Flow floor to the fixed version so pip install openadapt gets it.

…ixes #2682)

write_receipt wrote run-summary.json/.md/.png with plain file writes into
an encrypted run folder, outside its sealed index, so seal_run refused the
run and openadapt quickstart exited 1 under the default at-rest mode.

Write the summary through the run's sealed set and name the three files in
the run inventory as allow-listed plaintext, next to their pre-3.5 receipt.*
names. Any other plaintext file still makes the run refuse. The OpenEMR
quickstart's halted-run screenshot and read-back file go through the set too.

Tests: a browserless sealed-run regression, and an encrypted empty-HOME
quickstart that checks every sealed folder's files are in its index.
@abrichr

abrichr commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 3831aa3

Author declaration. This fixes #2682: write_receipt now writes run-summary.json, .md and .png through the run's sealed set, and the run inventory names those three files as allow-listed plaintext, next to their pre-3.5 receipt.* names. seal_run and the reconcile step are unchanged, so any other plaintext file in a run folder still makes it refuse. The OpenEMR quickstart's halted-run screenshot and read-back file also go through the set. New tests: a browserless sealed-run regression, and an encrypted empty-HOME quickstart that checks every sealed folder's files are in its index. Both run in the Flow CI lanes, and both fail without the fix. No version bump: Flow's Unreleased already holds features, so this ships in the next Flow release. The OpenEMR quickstart was not run end to end (needs Docker).

@abrichr

abrichr commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 3831aa3

Scope: the full diff against main a1370c7f (the PR's merge base): receipt.write_receipt, the run inventory in sealed_set.py, the OpenEMR quickstart writers (openadapt/quickstart/openemr.py, benchmark/openemr_local/quickstart.py), phi_at_rest.md, the two new Flow tests and the launcher quickstart test.

What I checked

  • The bug is real in the released packages. In a fresh venv with openadapt==1.24.0 and openadapt-flow==4.0.0 from PyPI and an empty HOME, openadapt quickstart exits 1 with LocalSealError: report_unreadable from seal_runs. Anyone who runs pip install openadapt and then the quickstart hits this today.
  • The fix works end to end at this head. From source with an empty HOME and encryption at rest on by default, openadapt quickstart exits 0. recording, bundle, run-1 and run-broken are all sealed, every file on disk in each of them is in its index, and run-summary.json, .md and .png are indexed with codec plain. REPORT.md and report.json are on disk only as .enc. openadapt verify run-1 reports a valid offline Seal over run-1/report.json.
  • The new tests fail without the fix. I put main's receipt.py and sealed_set.py back and kept the new tests. 3 of the 4 fail (both sealed-summary tests and the encrypted quickstart). With the PR's sources, all 4 pass, with no skips on this box.
  • Fail-closed is kept. In a copy of the sealed run-1, I added a plaintext notes.txt. open_set refused it with holds notes.txt in plaintext, outside its sealed index.
  • The plaintext allow-list is safe. RunReceipt is extra="forbid" and holds only outcomes, counts, digests and versions, so listing run-summary.* as structural adds no record text to plaintext. That is the same treatment receipt.md and receipt.png already get.
  • Other writers. I looked for direct writes under openadapt/quickstart, tutorial.py and demo_proof.py. crop_png decrypts in memory. everyday.py writes verify.yaml/task.json into a task folder, not a sealed run. The OpenEMR screen.png and quickstart-readback.json now go through the set, and their run folder exists at that point. I found no other writer into a sealed run folder on the quickstart path.

Non-blocking

  • As the PR says, a later edit to run-summary.json is not detected when the set is opened: I changed steps_ok in a copy of the sealed run and open_set still opened it. The signed receipt (seal.json) covers report.json, not the summary, so verification is not affected. This was already true of the other plain receipt files.

Tests (exact head, Linux, py3.12, fresh venv, launcher, types and flow [dev] editable)

  • 14 Flow files (at-rest default, at-rest round 3, attended at rest, encryption at rest, sealed at rest, run receipt, write receipt, handoff receipts, break-it CLI, tutorial run params, quickstart lifecycle, OpenEMR quickstart driver, and the two new files): 301 passed in the plaintext lane. With OPENADAPT_TEST_DEFAULT_AT_REST=1: 290 passed, 10 skipped and 1 failed, test_tutorial_run_params::test_a_run_with_a_new_note_is_checked_against_that_note (bundle/workflow.json not found). That test fails the same way on main a1370c7f in that lane, so this PR did not cause it.
  • Launcher tests/test_quickstart.py and tests/test_quickstart_openemr.py: 124 passed, 2 skipped and 3 failed. The 3 are terminal-view rendering tests that expect ANSI escapes, and they fail the same way on main on this box. The cause is the terminal environment here, not this PR.
  • ruff check and ruff format --check on the 7 changed Python files: clean.

Generality gate: the repo AGENTS.md has no generality-gate section, so I applied the three-point gate. 1. No per-app code: pass. The fix is in the shared receipt writer and the run inventory. The two OpenEMR edits route existing writes through the same set API. 2. Fix the class: pass. Every write_receipt caller (quickstart, tutorial, --receipt) now goes through the set, and I swept for other plaintext writers. 3. Held-out evidence: the real quickstart in a hidden browser with encryption on, plus the released-package repro above.

Not run: the OpenEMR quickstart end to end (needs Docker), and the full Flow suite.

CI at this head (when I posted): 5 passed, 22 pending and 19 skipped. None had failed. The packages / flow lanes that run the new encrypted quickstart test were still pending, so they should be green before merge.

Release decisions still required: released Flow 4.0.0 with launcher 1.24.0 crashes on first run, so a Flow release with this fix should go out soon. The next launcher release should also raise its Flow floor to that version. Both need the release owner. I did not push to this branch.

# Conflicts:
#	packages/flow/CHANGELOG.md
@abrichr
abrichr enabled auto-merge (squash) November 25, 2026 12:41
@abrichr

abrichr commented Nov 25, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: f18be52

This is a re-review after the merge from main. My APPROVE at 3831aa32 (review) does not carry over by itself, so I checked the new head.

What changed

Checked at this head

  • End to end, empty HOME, encryption at rest on by default: openadapt quickstart exits 0. recording, bundle, run-1 and run-broken each open with open_set and verify_all(), and none has a file on disk outside its index. run-1/run-summary.json is in the index. REPORT.md and report.json are on disk only as .enc. openadapt verify on run-1 reports a valid offline Seal over run-1/report.json (1 of 1 verified).
  • The new tests still fail without the fix: I put main 1d344298's receipt.py and sealed_set.py back and kept the new tests. 3 of 4 failed. With the PR's sources, all 4 pass.
  • Fail-closed: a copy of sealed run-1 with a plaintext notes.txt added is refused (holds notes.txt in plaintext, outside its sealed index).

Tests (exact head, Linux, py3.12, editable launcher and Flow)

  • Flow at-rest and receipt files (at-rest default, at-rest round 3, attended at rest, encryption at rest, run receipt, sealed at rest, write receipt, and the two new files): 260 passed.
  • Launcher tests/test_quickstart.py: 96 passed, 1 skipped. With this box's NO_COLOR=1 / FORCE_COLOR=0 set, 3 terminal-view tests fail the same way on main 1d344298. With those variables unset, all pass.
  • ruff check and ruff format --check on the 7 changed Python files: clean.

Generality gate: unchanged from my earlier review. The fix is in the shared receipt writer and run inventory, with no per-app code. Every write_receipt caller goes through the set. Held-out evidence is the real quickstart run above.

Not run: the OpenEMR quickstart end to end (needs Docker), and the full Flow suite.

CI at this head (when I posted): 10 pending and 2 skipped. None had failed or passed yet, so they need to finish green before merge.

Release decisions still required: released Flow 4.0.0 with launcher 1.24.0 still crashes on first run. A Flow release with this fix, and a launcher Flow-floor bump after it, need the release owner. I did not push to this branch.

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.

openadapt quickstart exits 1 with default encryption at rest: run summary written in plaintext into the sealed run

1 participant