Repository navigation
Encrypt recordings, bundles and runs at rest by default (key hierarchy) - #2423
Conversation
Envelope encryption: each sealed set has its own data key, wrapped with age (X25519, pyrage) for this computer's device key (OS keychain through keyring, 0600 file fallback with a warning), optional organization recipients and shares. Configured passphrase keys keep the v1 header. at-rest status, share and shred. Receipts read encrypted runs and stay over the plaintext report digest.
Sealed-set v3 now wraps each set's data key with HPKE (P-256, HKDF-SHA256, AES-256-GCM) to a per-set bucket key, whose record is wrapped to the device runtime key (only while written), the device viewer key, organization keys (P-256 or RSA-OAEP-3072) and a solo recovery key. Files are Tink AES256_GCM_HKDF_1MB streams, checked against Tink. Organization mode comes from a machine policy and fails closed without its recipient and archive. Hardware providers are interfaces with test doubles. Shred destroys the tracked bucket-key copies. age and the share verb are gone.
seal verify says report_locked, not subject_mismatch, when no key here opens an encrypted run. The quickstart makes the device key before its workers start. Tink interop and hierarchy tests; default-mode tests now expect sealed output.
…s continue plaintext; desktop encryption test
…ch teach reads encrypted runs Found by running the reader suites under the real default (OPENADAPT_TEST_DEFAULT_AT_REST=1).
|
From: Claude encrypt-at-rest agent (author) Author declaration for the protected-path check. This is not a review. |
…rs live in cli_at_rest
…ll openadapt already includes it
…wide Module-scoped fixtures (an e2e recording compiled once per module) ran before the per-test isolation and now sealed their output by default, under a key the per-test home could not open.
…in pytest_configure and restored
Independent adversarial review: REQUEST CHANGESFrom: Codex
Evidence and scope. I ran three normal-path tests at this head. A v3 run decrypted successfully, another computer opened an archived run with the organization key, and a recovery code opened a solo backup. I traced the incomplete operations above in source. The PR records a headless quickstart measurement. Hardware-backed keys and real keychains were outside my test scope. Generality. The hierarchy is application-independent. The remaining defects concern policy and lifecycle behavior shared by all records of these kinds. The held-out recovery checks cover a second computer with synthetic data. |
- An organization shred reports incomplete, exits non-zero and keeps a pending marker until the archive copy is deleted; shred again or at-rest archive finishes it. - A named policy file that is missing refuses; on Windows an organization policy comes only from a machine source. - at-rest archive sends pending key records after an outage, and the next set tries it before refusing at max_unarchived. - record_desktop_capture follows the at-rest policy by default and refuses a capture_dir outside its private staging folder when encrypting.
Independent adversarial review: REQUEST CHANGESFrom: Codex Round 2 covered the four findings from the first review. I ran all six new synthetic tests. All six passed, including retry against a read-only archive, draining pending records, refusing a missing policy file, and sealing a direct desktop recording. Three items remain.
These are application-independent key lifecycle and capture-policy issues. The six checks used synthetic files and a test recorder. I traced the missing-mount, changed-policy and explicit-key behavior in source. This review adds no lab or hardware qualification. |
Independent adversarial review: REQUEST CHANGESFrom: Codex
Evidence and scope. I verified the exact head. All 42 targeted hierarchy, streaming and desktop tests passed with synthetic data and the real OS keyring disabled. They confirm read-only archive retry, refusal of a missing explicit policy, recovery at a positive backlog limit, and the default direct-capture |
# Conflicts: # CAPABILITIES.md # llms-full.txt # packages/desktop/tests/conftest.py # packages/flow/docs/design/DECOMPOSITION.md
Independent adversarial review: REQUEST CHANGESFrom: Gemini
Scope & evidence: Verified exact head |
…ze bucket changes - An archive counts as reachable only with its .openadapt-key-archive marker; Flow never creates the folder, writes records atomically, and records the archive each bucket went to (header and record). Shred and retry use that archive, never the current policy, and a missing marker is never deletion. - Shred authenticates the header with a recipient key before choosing what to destroy, keeps progress in the header and a local pending marker, and says complete only after the store files and the archive copy are gone. - One bucket lock serializes create, archive, close and shred, so a shredded record is never written back. max_unarchived is checked after the new record's own archive attempt (0 means synchronous), and a refused set leaves no record. - Organization mode requires records: archive. A record that arrives in a header opens only with this computer's device keys or a recovery key. - A lost device key no longer hides a valid recovery or organization key. - Machine policy: each platform reads only its own sources, HKLM access denied is an error, and every policy file is checked root-owned and root-writable-only on the descriptor actually read. - Refresh the eligibility connector lock.
…triaged skips - tests/default_at_rest_skips.txt: each test skipped under OPENADAPT_TEST_DEFAULT_AT_REST=1, with its reason (group a: the test reads or plants plaintext and the product correctly refuses; group b, open: attended approvals, drafts, business decisions and teach on encrypted input). The matcher takes a test, its class or its file. - flow default at rest joins packages-gate (pull requests only). - Merge origin/main and regenerate CAPABILITIES.md and llms-full.txt.
Full flow suite with encryption at rest on: results and triageThe new required job
The 415 failures in round 5 collapse to 299 test functions once parametrized cases are merged. Group (b): product paths that broke under default encryption, fixed in this PR
Group (a): 240 tests skipped with a reasonIn each one the test reads or plants a file directly and the product refuses it, correctly.
Group (b, still open): 59 tests skipped and named as a limitationIn an encrypted run, attended approvals (approval gates), attended drafts, business-decision states and teach on encrypted input are refused up front, before anything runs, as The three tests with a different refusalEach test planted a plaintext file beside the store's encrypted one, so the product refused the stray file before reaching the check under test. Each now tampers through the store's own writer. I captured the refusal in both modes, and it is the same in each:
Not caused by this PR
|
|
From: Claude |
Independent adversarial review: APPROVEFrom: Gemini Independent cross-vendor adversarial review of Cryptographic & fail-closed verification
Generality gate
|
Since encryption at rest became the default (#2423), a run directory is a sealed set. Self-repair still wrote each bridge step's evidence frame (self-repair/attempt-N/evidence/heals/<step>/screen.png) with pathlib, so a screenshot that can show a person's record landed in plaintext inside the encrypted run, and the next write to the run (the report) refused the set. persist_heal already wrote through the set, which is why only the bridge frames leaked. - runtime/heal.py: add heal_frame_path, write_heal_frame, has_heal_frame and read_heal_frame, all through openadapt_flow.sealed_set; persist_heal uses write_heal_frame. - repair/self_repair.py: write and hash bridge frames through the helpers; read staged expect templates, copy the halted report, read the halted before-frame and write self-repair.json through the sealed set (each read ciphertext, skipped the file, or wrote plaintext in a sealed run). - repair/cli.py: the frame campaign reads heal frames through the helpers, so a sealed frame is found instead of refused as missing. - compiler/compile.py: write the hover evidence crop through the sealed set. - tests: a sealed run keeps the bridge frame sealed, reopens, and accepts the next report write; the halted frame is read through the set.
Self-repair built the patched bundle by copying the source bundle directory without its templates, manifest and repair files, then saving the patch into the copy. For a sealed bundle (the default since #2423) that copy carries the source's index but not the files it lists, so the save refused it ("does not match its sealed index") and every bridge repair ended in no_fix. Relabel repair copied the same way and left out the sealed repair/* files. - bundle_persistence.copy_bundle_files: copy a plaintext bundle as files; write a sealed source into a new sealed set through its writer (decrypted in memory, sealed again), with the same ignore patterns. - repair/self_repair.py and repair/relabel.py use it. - tests: a patched copy of a sealed bundle opens, verifies, holds no plaintext and loads with the patch; a plaintext copy is unchanged.
Self-repair's probe and resume need an attended approval, and a sealed run refuses one: the known limitation #2423 documented (attended approvals, drafts and decisions are held back in sealed runs). The product rule stays as it is. In qualify_linux.py and qualify_macos.py, only the self-repair legs now run on a plaintext copy of the bundle (same content digest) under the documented opt-out, at_rest.opted_out, which names the plaintext writes on stderr and in the ledger. Record, compile, the governed runs and the wrong-patient legs still run under the default. The results record self_repair_mode, and the summary prints it, so a passing job is not read as self-repair working encrypted.
…block native Linux qualification (#2589) * fix(flow): read and rewrite the sealed recording in the repair qualifications Encryption at rest became the default in #2423, so the recording these benchmarks record is a sealed set and has no plaintext events.jsonl. qualify_linux.py (and its macOS sibling) read and rewrote that file with pathlib, which failed the native Linux AT-SPI job on main with FileNotFoundError. Read and write the events through the sealed-set API, in memory, so the qualification keeps testing the default product. * fix(flow): remove the bundle manifest through the sealed set in the repair qualifications A pathlib unlink left manifest.json in the sealed index, so the next save refused the bundle (missing: manifest.json). * fix(flow): keep self-repair heal evidence sealed in an encrypted run Since encryption at rest became the default (#2423), a run directory is a sealed set. Self-repair still wrote each bridge step's evidence frame (self-repair/attempt-N/evidence/heals/<step>/screen.png) with pathlib, so a screenshot that can show a person's record landed in plaintext inside the encrypted run, and the next write to the run (the report) refused the set. persist_heal already wrote through the set, which is why only the bridge frames leaked. - runtime/heal.py: add heal_frame_path, write_heal_frame, has_heal_frame and read_heal_frame, all through openadapt_flow.sealed_set; persist_heal uses write_heal_frame. - repair/self_repair.py: write and hash bridge frames through the helpers; read staged expect templates, copy the halted report, read the halted before-frame and write self-repair.json through the sealed set (each read ciphertext, skipped the file, or wrote plaintext in a sealed run). - repair/cli.py: the frame campaign reads heal frames through the helpers, so a sealed frame is found instead of refused as missing. - compiler/compile.py: write the hover evidence crop through the sealed set. - tests: a sealed run keeps the bridge frame sealed, reopens, and accepts the next report write; the halted frame is read through the set. * fix(flow): copy a sealed bundle as a new sealed set before patching it Self-repair built the patched bundle by copying the source bundle directory without its templates, manifest and repair files, then saving the patch into the copy. For a sealed bundle (the default since #2423) that copy carries the source's index but not the files it lists, so the save refused it ("does not match its sealed index") and every bridge repair ended in no_fix. Relabel repair copied the same way and left out the sealed repair/* files. - bundle_persistence.copy_bundle_files: copy a plaintext bundle as files; write a sealed source into a new sealed set through its writer (decrypted in memory, sealed again), with the same ignore patterns. - repair/self_repair.py and repair/relabel.py use it. - tests: a patched copy of a sealed bundle opens, verifies, holds no plaintext and loads with the patch; a plaintext copy is unchanged. * fix(flow): run the qualification's self-repair legs on a plaintext copy Self-repair's probe and resume need an attended approval, and a sealed run refuses one: the known limitation #2423 documented (attended approvals, drafts and decisions are held back in sealed runs). The product rule stays as it is. In qualify_linux.py and qualify_macos.py, only the self-repair legs now run on a plaintext copy of the bundle (same content digest) under the documented opt-out, at_rest.opted_out, which names the plaintext writes on stderr and in the ledger. Record, compile, the governed runs and the wrong-patient legs still run under the default. The results record self_repair_mode, and the summary prints it, so a passing job is not read as self-repair working encrypted.
…2.4 (<5) (#2609) * release(flow,agent)!: cut openadapt-flow 4.0.0 and openadapt-agent 2.2.4 (<5) Bump openadapt-flow to 4.0.0 so encryption at rest by default (#2423) publishes as a major release instead of 3.5.0 (which would break released openadapt launcher 1.23.0, which caps openadapt-flow<4 and reads run directories via plain paths). Bump openadapt-agent to 2.2.4 and widen its openadapt-flow cap from <4 to <5 so openadapt launcher 1.24.0 (>=4.0.0,<5.0.0) can resolve cleanly once Flow 4.0.0 and Agent 2.2.4 publish to PyPI. BREAKING CHANGE: openadapt-flow 4.0.0 encrypts recordings, bundles, and run directories at rest by default (#2423). * chore(eligibility): sync editable openadapt-flow 4.0.0 in uv.lock * chore(eligibility): accept openadapt-flow <5 for Flow 4.0.0
The founder approved encryption by default. This PR makes recordings, bundles and run folders encrypted at rest with no setup.
Key hierarchy (sealed-set version 3)
AES256_GCM_HKDF_1MBstreams.tests/test_stream_aead.pychecks this format both ways against Tink itself, at the segment boundaries.records: inline): inside the header, so a backup still opens with the recovery key.records: archive): in~/.openadapt/keys/buckets/plus a copy in the organization's key archive. It is never in the header.cryptography50 or later. Flow's new core floor iscryptography>=50, for HPKE.keyringstays in thekeychainextra, whichpip install openadaptalready pulls in throughhosted. A bareopenadapt-flowinstall without it keeps the device key in a 0600 file and prints a warning.tinkis a dev dependency, used only for the interop test.Policy and organization mode
Where the policy comes from. The first match wins:
ai.openadapt.policy;HKLM\SOFTWARE\Policies\OpenAdapt;/etc/openadapt/policy.json;OPENADAPT_POLICY.A user-owned file can't set organization mode.
Fail closed. Organization mode refuses to run without an active organization recipient and a
key_archive. It also stops aftermax_unarchivedrecords that never reached the archive.No Cloud keys. Cloud never distributes the organization key and holds no key.
Device keys
at-rest statuslabels it that way. It is stored in the OS keychain throughkeyring, with a non-secret marker and a check value. Where no keychain works, it goes in a 0600 file and Flow prints a warning.require_hardware_device_keyrefuses the software key.Defaults, opt-out, legacy
OPENADAPT_ENCRYPT_AT_REST=0, or--no-encryptonrecord,compile,runandreplay, prints one warning line and adds a ledger line. Strict mode ignores both.OPENADAPT_BUNDLE_KEYandOPENADAPT_RECORDING_KEYstill win and keep the v1 header (deprecated).~/.openadapt/keys/at-rest.keystill works.openadapt-flow at-rest shred DIR --yesoverwrites and deletes the local bucket record and the archive copy, deletes the checkpoints inside the set, and returns a shred record.Readers
replay,run,resume,compile,inspect report-run,seal verify,teach branch, undo, the receipt page, the quickstart and the agent's bundle discovery.seal verifyreportsreport_locked.Receipts
seal.json,receipt.*andpublic-seal.json. They are listed as structural run files.report.json, decrypted in memory. Third parties still verify against the plaintext.evidence_setsubject carrying the sealed-set digest, once Receipts: counterparty confirmations in record/run/v1 #2410 adds that subject kind.seal.htmlembeds the report, so beside an encrypted run it is logged as a plaintext copy.Not covered yet (documented in
phi_at_rest.md)OPENADAPT_ORG_KEY_FILE);s3://andsmb://key archives.record --surface(logged).repairon sealed input (it refuses clearly);evidence_setsubject.REPORT.md.enc.index.htmlno longer embeds screenshots.openadapt-flow>=3.3.0,<4.0.0) reads run files withpathlib. Before a Flow release that seals by default, we need either a Flow major bump or a coordinated raise of the launcher floor.Tests
tests/test_key_hierarchy.py(35 tests) andtests/test_stream_aead.py(Tink interop);test_at_rest_default.pyandtest_attended_at_rest.py.OPENADAPT_TEST_DEFAULT_AT_REST=1runs the flow suite under the real default. It found the undo-prior, narration and branch-teach plaintext writers, which are fixed here. What still fails under it is tests that assert plaintext paths.Timing
Headless MockMed quickstart, before and after runs alternating on one loaded laptop (load 25 to 37):
4d9dc90c6)The gap is within run-to-run noise at that load. One "after" run hit the system Chrome's 180 s launch timeout and is excluded. Data:
packages/flow/benchmark/at_rest/quickstart_default_2026-11-21.json.Real-app check
One headless quickstart run, plus the opt-in
test_real_quickstart(which passes):run-1andrun-brokenare all sealed-set v3.receipt.png.openadapt seal verifyreports both runs valid. Checked with another computer's key, it reportsreport_locked.Size budget
__main__.pygoes from 14331 to 14326 lines, and its budget is lowered. Theat-restcommand,--no-encrypt, the desktop recording key, the v3 key precheck and their command-table entries now live incli_at_rest.py.