Repository navigation
fix(flow): keep repair evidence sealed under encryption at rest - #2589
Conversation
…ications 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.
Independent adversarial review: APPROVEFrom: Gemini Independent cross-vendor review of What was verified
|
…epair qualifications A pathlib unlink left manifest.json in the sealed index, so the next save refused the bundle (missing: manifest.json).
Independent adversarial review: REQUEST CHANGESFrom: Grok I ran the real "flow native Linux" step locally at this head, and it still fails. The sealed-set read/rewrite and the What I ranSetup: Linux box (Debian 13), Xvfb, openbox, at-spi2-core 2.56, GTK3 and Python 3.12. Installed with
At this head, recording, sealed read and rewrite, compile, sealed save and load, the policy check and the governed runs all get past their earlier failures. The crash comes later, at Findings
Tests run (at this head unless noted)
Generality gatePass for this diff: it changes two benchmark harnesses and no engine code, with no app-specific logic in Not run
CI at review timeDispatch run 45254655799 at this head was still queued, so its "flow native Linux" result isn't known yet. I expect it to fail as above. The PR checks at this head had just started: 6 pass, 1 skipping, and CodeQL Grok makes no merge or release decision. Types 0.24.2 stays blocked until the GTK job is green on a main push. |
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.
|
From: Claude What changed since 646afe3:
|
Independent adversarial review: APPROVEFrom: Gemini Independent cross-vendor review of What was verified
|
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.
|
From: Claude What changed since c352ba7:
|
Independent adversarial review: APPROVEFrom: Gemini Delta review versus previously Gemini-approved head What was verified
|
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.
|
From: Claude What changed since 3ec46af:
|
Independent adversarial review: APPROVEFrom: Gemini Delta review versus previously Gemini-approved head What was verified
|
Independent adversarial review: APPROVEFrom: Grok My earlier blocker (at 646afe3: self-repair wrote a plaintext What I checked
Non-blocking (P3)
Tests at this head (fresh worktree, Python 3.12,
CI
Not run
|
#2592) * docs(types): date the 0.24.2 release and note why it published late * docs(verify): date the 0.2.1 release and note why it published late
Symptom
On main push runs, the
packages.ymljob "flow native Linux (AT-SPI, Xvfb)" fails in the step "Record, compile, run and repair on a GTK3 app with SQLite" (for example run 45198283097 at 21e200a, job 137842240925, and run 45204335746 at 2ea7480):Main stays red whenever flow changes. The openadapt-types 0.24.2 publish (#2540) is also blocked, because
release_plan.pyneeds a greenpackages.ymlpush run for that commit.Cause
#2423 made encryption at rest the default for recordings, bundles and runs. The recording that
benchmark/repair_every_backend/qualify_linux.pymakes is now a sealed set, so it has no plaintextevents.jsonl. After recording, the script reads that file withpathliband rewrites it to stamp the banner'sidentifier_regionon each click. That read fails.qualify_macos.pyhas the same code.Fix
Both scripts now read and rewrite the events with
openadapt_flow.sealed_set.read_textandwrite_text. These are the same helpers the product uses for sealed recordings: they decrypt in memory and reseal the file in place. A plaintext recording still works. Nothing sets the plaintext opt-out, so the qualification keeps testing the default product. The rest of each script already goes throughcompile_recording,Workflow.save/load,ReplayTargetandrepair.run, which read sealed sets. The only plaintext file the scripts write is their own results JSON.Checks
Not run locally. The checks need machine load under 15, and during a 30-minute wait it stayed between 34 and 264, so I stopped the queue. These are the checks still to run, on macOS, in the flow venv, with
PYTHONPATHset to this worktree:Recorderon a fake backend, checks that the recording is sealed and has no plaintextevents.jsonl, does this PR's read and rewrite, compiles, saves and loads the bundle, checks that every click anchor carries the stampedidentifier_region, and then mirrors the rest of_record: unlinkmanifest.jsonwith pathlib, re-save, load andevaluate_policy.ruff checkandruff format --checkonbenchmark/repair_every_backend/.mypyon the two scripts.pytest tests/test_compile_identifier_crop.py tests/test_artifact_reads.py.Not run locally: the GTK3, Xvfb and AT-SPI job itself (it needs Linux and a display) and the macOS script (it drives real apps). The job also does not run on pull requests or in the merge queue: its condition is
needs.scope.outputs.flow == 'true' && github.event_name != 'pull_request' && github.event_name != 'merge_group'. So it runs on the main push after this merges, or on aworkflow_dispatchofpackages.ymlon this branch.Scope grew: a privacy fix in self-repair (c352ba7)
With the recording fix in, the next dispatch (run 45254655799) got as far as the repair and failed inside product code:
This is a privacy regression, not only a test failure. Under the encryption-at-rest default, a run directory is a sealed set. Self-repair wrote the screenshot each new bridge step was taken from with
pathlib, so a frame that can show a person's record was written unencrypted inside the encrypted run. The sealed-set check then correctly refused the whole run on the next write. The bridge writer was added on 2026-10-18 (1cfb6e8), before the default. #2423 movedpersist_heal(the replaced-target heal) to the sealed-set helpers, but missed this second writer two screens away. That is why only*_bridge_Nframes leaked. No self-repair bridge test runs against a sealed run, so nothing caught it.Fix, in one place rather than at each call site:
runtime/heal.py: newheal_frame_path,write_heal_frame,has_heal_frameandread_heal_frame, all throughopenadapt_flow.sealed_set.persist_healuseswrite_heal_frame. The bridge frame is stored as given, becauseframe_sha256is taken over these bytes.repair/self_repair.py: bridge frames are written and hashed through the helpers. These sibling reads and writes in the same function did not work in a sealed run, and now go through the set:iterdirand read raw, which gave the sealed file names and ciphertext.report.jsonis not a plain file in a sealed run. That dropped its evidence reference.self-repair.jsonwas written as plaintext.repair/cli.py: the frame campaign (used by self-repair) reads heal frames through the helpers. Before, a sealed frame was refused as "no evidence frame".compiler/compile.py: the hover evidence crop is written through the sealed set. It is the same class of bug, found while sweeping.tests/test_heal_evidence_sealed.py: in a sealed run under the default mode, writing a bridge frame leaves no plaintext PNG on disk, the set reopens, the next report write is accepted, and the frame reads back. The halted frame is read through the set. A scratch script reproduces the exact CI refusal with the old writer.Not changed, flagged:
repair/agent_teach.pystill writes its evidence folder in plaintext. That is deliberate and already logged throughat_rest.unsealed_write, or refused in strict mode. Self-repair on a plaintext bundle under the default still writes a plaintext patched bundle atself-repair/attempt-N/bundleinside the sealed run.Checks for c352ba7:
OPENADAPT_TEST_DEFAULT_AT_REST=1 pytest -p no:xdist tests/test_heal_evidence_sealed.pypassed (3 tests).ruff checkandruff format --checkon the changed files are clean.mypyon the four changed modules is clean. The load stayed between 185 and 296, so the cpu-slots guard (load under 35) timed out after 15 minutes. These ran directly, single-process, and the wider repair suites did not run locally.Round 3: patched copy of a sealed bundle (3ec46af)
Dispatch 45260140733 at c352ba7 no longer crashed. Its repair half ended
no_fix: "the proposal could not be applied (SealedSetError)". The same failure reproduces locally withtests/test_self_repair_bridge.pyunderOPENADAPT_TEST_DEFAULT_AT_REST=1. The message is.../self-repair/attempt-1/bundle does not match its sealed index (missing: manifest.json, templates/...).Self-repair built the patched bundle with
shutil.copytree(..., ignore=("repair", "manifest.json", "templates")). For a sealed source, that copies the index but not the files it lists, so the save into the copy is refused. My earlier note in this PR, that a sealed bundle there "is a nested sealed set and is fine", was wrong.bundle_persistence.copy_bundle_files: a plaintext source is copied as files. A sealed source is written into a new sealed set through its writer, decrypted in memory and sealed again, with the same ignore patterns.repair/self_repair.pyandrepair/relabel.pyboth use it. Relabel had the same copy, which left out the sealedrepair/*files.Why #2423 missed these: the end-to-end self-repair tests (
test_self_repair_bridge.pyand others) are intests/nightly_only.txt. The default-at-rest CI lane runs withOPENADAPT_TEST_LANE=fast, so it never runs them under the default.Blocker found (resolved for the qualification in round 4)
With the copy fixed, the patch applies and step 1 of the bridge is admitted. The probe then refuses to start, in
first_local_runtime.run_with_output: "a sealed run keeps an approval gate (attended approvals) outside the sealed set, so it is held back".runtime/preparation.sealed_run_unsupportedadmits only the exactDryRunGate(#2190), and self-repair's probe and resume use_ProbeGate. I tried admitting_ProbeGatein a local scratch patch only, not committed. The person-approval request then fails:ItemApprovalStorewritesitem-approval/<request>.png(the frame shown to the approver) in plaintext inside the sealed run. That store is a deliberate, logged plaintext exception (at_rest.unsealed_write("approval requests and frames")), and the run's sealed set correctly refuses it. So self-repair cannot finish under the default until one of these is chosen:Each choice changes fail-closed or at-rest policy, so this PR doesn't make it.
Checks for 3ec46af:
tests/test_heal_evidence_sealed.py: 5 passed under the default.tests/test_repair_relabel.py: 10 passed in both modes.tests/test_self_repair_bridge.pyandtests/test_self_repair_after_crop.py: 4 passed in plaintext mode. Under the default they still fail at the gate above.Round 4: self-repair legs scoped to plaintext in the qualification (32a7698)
The coordinator chose option 3, applied only to the qualification scripts. Product policy is unchanged. A sealed run refusing an attended approval gate is the known limitation #2423 documented: attended approvals, drafts and decisions are held back in sealed runs. Self-repair's probe and resume need a person's decision, so they fall under it. Nothing in
runtime/preparationchanged, and_ProbeGateis not admitted.In
qualify_linux.pyandqualify_macos.py, only the self-repair legs (_repair, which includes the fault probe) run on a plaintext copy of the bundle:at_rest.opted_out, which names the plaintext writes on stderr and in the ledger.The results JSON records
"self_repair_mode": "plaintext (known limitation: attended approvals are refused in sealed runs, #2423)", and the script prints the same line. A green job does not mean self-repair works encrypted.Result: packages.yml dispatch 45264633441, job "flow native Linux (AT-SPI, Xvfb)" 138008791947, success. Every check passed. The repair ran halt, propose, patch (
admitted by element_and_record_check), probe (stopped before the save), replay and fault campaigns, one person's approval, and a VERIFIED resume.Checks for 32a7698:
ruff check,ruff format --checkandpy_compilepass onbenchmark/repair_every_backend/.tests/test_heal_evidence_sealed.pypasses (5 tests, default mode). A scratch smoke test of the scoped legs showed encryption off inside the block, a plaintext copy, and the default restored after the block.Follow-ups
runtime/preparation.sealed_run_unsupportedstands.copy_bundle_filesfor the partial sealed copy incompiler/probing.py(around line 281).tests/nightly_only.txt, and the default-at-rest lane runs withOPENADAPT_TEST_LANE=fast.pathlibreads of sealed files inbenchmark/macos_native/qualify_calibre.pyandbenchmark/multi_surface_record/qualify_linux_cross_window.py.Same pattern elsewhere (not changed here)
compiler/probing.py(around line 281) copies a sealed source withcopytree(ignore=templates)and then saves. It looks like the same broken partial-index copy;copy_bundle_filesfits it.benchmark/macos_native/qualify_calibre.pyreads and rewritesrecording/events.jsonlwithpathlibin the same way.benchmark/multi_surface_record/qualify_linux_cross_window.pyreadsevents.jsonl, the run'sreport.jsonand the bundle'sworkflow.jsonwithpathlib.Neither is in a CI job that runs on main pushes, so neither keeps main red. Both will fail the same way under the default the next time someone runs them.