Repository navigation
fix(flow): quickstart writes its run summary through the sealed set (fixes #2682) - #2683
Conversation
…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.
|
From: Claude Author declaration. This fixes #2682: |
Independent adversarial review: APPROVEFrom: Grok Scope: the full diff against What I checked
Non-blocking
Tests (exact head, Linux, py3.12, fresh venv, launcher, types and flow
|
# Conflicts: # packages/flow/CHANGELOG.md
Independent adversarial review: APPROVEFrom: Grok This is a re-review after the merge from What changed
Checked at this head
Tests (exact head, Linux, py3.12, editable launcher and Flow)
Generality gate: unchanged from my earlier review. The fix is in the shared receipt writer and run inventory, with no per-app code. Every 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. |
Fixes #2682.
Problem
With encryption at rest on (the default since Flow 4.0.0),
openadapt quickstartexits 1 on a fresh machine.write_receiptwroterun-summary.json,run-summary.mdandrun-summary.pngwith plain file writes into the encrypted run folder, outside its sealed index.seal_runthen refused the folder withreport_unreadable. Released openadapt 1.24.0 with Flow 4.0.0 from PyPI is affected. I reproduced it in a clean venv with an emptyHOME.Fix
openadapt_flow.receipt.write_receiptwrites all three summary files throughsealed_set.write_bytes. The PNG is rendered to memory first. Outside a sealed folder this is a plain write, as before.sealed_set.pynamesrun-summary.json,.mdand.pngas structural (allow-listed plaintext). They sit next to their pre-3.5 names,receipt.mdandreceipt.png, which were already listed. The summary is the allow-listed receipt projection (outcomes, counts, digests, no record text).phi_at_rest.mdalready documented it as plaintext beside an encrypted run. The inventory just never picked up the Flow 3.5 rename.seal_run,_adoptableand_reconcile_run_filesare untouched, and any other plaintext file in a run folder still makes it refuse (tested).screen.pngfrom the driver'sSession.screenshotandquickstart-readback.jsonwere written directly intorun-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_proofand 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_filesre-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, callswrite_receipt, then checks thatopen_setplusverify_allsucceed, that every file on disk is in the index, that a keylessread_run_summaryworks, 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 exactholds run-summary.json in plaintexterror.packages/flow/tests/test_quickstart_encrypted.py: the real quickstart in a hidden browser, with encryption forced on in any lane, an emptyHOMEand no seal home. It asserts that every run checked and was sealed (seal.jsonexists), and that every sealed folder's on-disk files are in its index. Without the fix it fails the same way.test_real_quickstartallowsrun-summary.pngas plaintext and gains the same index check.CI: these live in
packages/flow/testsoutsidee2e/. Theflow default at restandflow core unitlanes 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 withOPENADAPT_FLOW_PLAINTEXT_AT_RESTset, and the one real encrypted test was opt-in and never enabled.Local results:
OPENADAPT_TEST_DEFAULT_AT_REST=1.tests/test_quickstart.py,test_quickstart_openemr.pyandtest_quickstart_lifecycle.pywithOPENADAPT_REAL_QUICKSTART=1: 147 passed, 1 skipped (the Docker OpenEMR run).HOME,openadapt quickstartexits 0. Every sealed folder (recording,bundle,run-1,run-broken) opens, and every file in it is indexed. The same holds foropenadapt-flow tutorial --break-itand for a rerun beside a crashed 4.0.0 output folder.Release metadata
gui.attestations, hub pages, repeating structures), so the next Flow release is a minor (4.1.0), not 4.0.1.release_planalso 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.openadapt/quickstart/openemr.pychanged, 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 sopip install openadaptgets it.