Repository navigation
perf(flow): a checkpoint store derives its at-rest key once per run (28 s -> 3.5 s quickstart) - #2375
Conversation
#2341 removed the process-wide derived-key cache, so every sealed checkpoint read ran scrypt again: 131 derivations and 28 s for the MockMed quickstart run, against 3.5 s on Flow 3.3.0. A CheckpointStore is a caller-owned handle; it now keeps the keys it derived from its explicit key (crypto.ContainerKeys, keyed by salt and work factors, no passphrase copy or verifier, dropped when the key changes) for its own lifetime. Every read still authenticates with AES-GCM. No module-level state.
Independent adversarial review: APPROVEFrom: Grok This is a caller-owned handle, not a return of the process-wide cache #2341 removed.
I am not merging: the public OpenAdapt merge HOLD stands until the privacy-floor PR merges. Logged on openadapt-internal#211. |
Independent adversarial review: APPROVEFrom: Grok The only change since the APPROVE at The changelog still amends the #2341 bullet under dated 3.4.0. The heading now matches main: I am not merging in this pass. #2371 has landed, but the coordinator's merge order still waits on the packages-gate run and then the Flow floor PR before later Flow PRs go in. Logged on openadapt-internal#211. |
Independent adversarial review: APPROVEFrom: Grok Delta re-review after my APPROVE at First-parent commits since that head: a merge of current main, then What I ran
Review only; I am not merging. |
….1.4 Keep OpenAdaptAI#2375's amendment of the OpenAdaptAI#2341 note and this branch's notes side by side, note the Flow merges since (OpenAdaptAI#2383, OpenAdaptAI#2439, OpenAdaptAI#2451, OpenAdaptAI#2454-OpenAdaptAI#2456, OpenAdaptAI#2459), and relock packages/flow on openadapt-privacy 1.1.4 (was 1.0.0).
This changes a control approved in #2341. #2341 removed the process-wide derived-key cache on purpose and accepted the extra KDF work. On the quickstart, that cost is large. Every sealed checkpoint read runs scrypt again: one headless MockMed run makes 131 derivations, about 20 of its 28-29 s. On Flow 3.3.0 the same run takes 3.5 s.
The change.
crypto.ContainerKeysis a derived-key handle owned by one caller, and aCheckpointStorecreates one for its own lifetime. Keys are stored by (salt, n, r, p).rebindkeeps only a reference to the key object the store already holds, and drops every key when that object changes.test_repeated_payload_operations_do_not_use_a_global_cacheis unchanged.Tests. The three tests that pinned per-operation counts now pin the new property:
559 crypto, at-rest, durable and sealed tests pass locally.
Bisect (first-parent, from
openadapt-flow-v3.3.0to maind10f0a2b). Each figure is one headless MockMed run (record_tutorial,compile_recording, thenrun_tutorial_workflow, as inopenadapt.quickstart.engine.FlowEngine). Runs used a CPU slot at load 9-15.c6748ab1cd93fa43e7(parent of #2341)95cc7878b(#2341)d10f0a2bA cProfile of main shows
Scrypt.derive×131 = 19.98 s. The derivations come throughCheckpointStore._read_json→decrypt_bytes, mostly fromcontinuation_state_digestandcheckpoints()rescans in_sync_authorityandupdate_audit_evidence. All 117 read derivations are on the single store created atruntime/replayer.py:1966.The #2341 bullet in the v3.4.0 changelog is amended, not given a new Unreleased entry. This must ship in the same release as #2341: Flow 3.4.0 is not out yet, and without this change it would ship 8x slower.
docs/phi_at_rest.mdis updated, andllms-full.txtis regenerated.Merge order: after #2371 (privacy 1.1.4 and the Flow hold), before the Flow privacy-floor PR.