Skip to content

fix(flow): keep repair evidence sealed under encryption at rest - #2589

Merged
abrichr merged 5 commits into
mainfrom
claude/fix-native-linux-at-rest
Nov 23, 2026
Merged

abrichr merged 5 commits into
mainfrom
claude/fix-native-linux-at-rest

Conversation

@abrichr

@abrichr abrichr commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Symptom

On main push runs, the packages.yml job "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):

FileNotFoundError: [Errno 2] No such file or directory: '/tmp/oa-linux-atspi-.../record/recording/events.jsonl'

Main stays red whenever flow changes. The openadapt-types 0.24.2 publish (#2540) is also blocked, because release_plan.py needs a green packages.yml push 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.py makes is now a sealed set, so it has no plaintext events.jsonl. After recording, the script reads that file with pathlib and rewrites it to stamp the banner's identifier_region on each click. That read fails. qualify_macos.py has the same code.

Fix

Both scripts now read and rewrite the events with openadapt_flow.sealed_set.read_text and write_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 through compile_recording, Workflow.save/load, ReplayTarget and repair.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 PYTHONPATH set to this worktree:

  • A scratch smoke script under the real default (no plaintext opt-out, file key store, isolated at-rest home). It records with Recorder on a fake backend, checks that the recording is sealed and has no plaintext events.jsonl, does this PR's read and rewrite, compiles, saves and loads the bundle, checks that every click anchor carries the stamped identifier_region, and then mirrors the rest of _record: unlink manifest.json with pathlib, re-save, load and evaluate_policy.
  • ruff check and ruff format --check on benchmark/repair_every_backend/.
  • mypy on 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 a workflow_dispatch of packages.yml on 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:

openadapt_flow/repair/self_repair.py, in _finish: report.save(report_dir)
openadapt_flow/sealed_set.py, _reconcile_run_files
SealedSetError: .../repair-with-record-check/item holds self-repair/attempt-1/evidence/heals/step_000_bridge_1/screen.png in plaintext, outside its sealed index

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 moved persist_heal (the replaced-target heal) to the sealed-set helpers, but missed this second writer two screens away. That is why only *_bridge_N frames 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: new 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. The bridge frame is stored as given, because frame_sha256 is 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:
    • The staged expect templates were listed with iterdir and read raw, which gave the sealed file names and ciphertext.
    • The copy of the halted report was skipped silently, because report.json is not a plain file in a sealed run. That dropped its evidence reference.
    • The halted step's before-frame was read raw, so it was always missing.
    • self-repair.json was 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.py still writes its evidence folder in plaintext. That is deliberate and already logged through at_rest.unsealed_write, or refused in strict mode. Self-repair on a plaintext bundle under the default still writes a plaintext patched bundle at self-repair/attempt-N/bundle inside the sealed run.

Checks for c352ba7: OPENADAPT_TEST_DEFAULT_AT_REST=1 pytest -p no:xdist tests/test_heal_evidence_sealed.py passed (3 tests). ruff check and ruff format --check on the changed files are clean. mypy on 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 with tests/test_self_repair_bridge.py under OPENADAPT_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.

  • New 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.py and repair/relabel.py both use it. Relabel had the same copy, which left out the sealed repair/* files.
  • Tests: a patched copy of a sealed bundle opens, verifies, holds no plaintext, and loads with the patch. A plaintext copy is unchanged.

Why #2423 missed these: the end-to-end self-repair tests (test_self_repair_bridge.py and others) are in tests/nightly_only.txt. The default-at-rest CI lane runs with OPENADAPT_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_unsupported admits only the exact DryRunGate (#2190), and self-repair's probe and resume use _ProbeGate. I tried admitting _ProbeGate in a local scratch patch only, not committed. The person-approval request then fails: ItemApprovalStore writes item-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:

  1. Seal the item-approval store, which also means the portal and Desktop readers.
  2. Keep self-repair's approval request outside the sealed run directory.
  3. Run self-repair's legs in plaintext with the logged downgrade.

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.py and tests/test_self_repair_after_crop.py: 4 passed in plaintext mode. Under the default they still fail at the gate above.
  • ruff and mypy are clean on the changed files.
  • All runs were direct and single-process, because the load stayed above 200.

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/preparation changed, and _ProbeGate is not admitted.

In qualify_linux.py and qualify_macos.py, only the self-repair legs (_repair, which includes the fault probe) run on a plaintext copy of the bundle:

  • The copy is decrypted in memory and saved under the same content digest, which the script checks.
  • The legs run under the product's documented opt-out, at_rest.opted_out, which names the plaintext writes on stderr and in the ledger.
  • Record, compile, the governed run and the wrong-patient and look-alike legs still run under the default (encrypted).

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 --check and py_compile pass on benchmark/repair_every_backend/. tests/test_heal_evidence_sealed.py passes (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

  • Make self-repair work under the default: either seal the item-approval store (including its portal and Desktop readers), or keep self-repair's approval request outside the sealed run. Until then, the attended gate refusal in runtime/preparation.sealed_run_unsupported stands.
  • Use copy_bundle_files for the partial sealed copy in compiler/probing.py (around line 281).
  • Add a self-repair end-to-end test lane under the default. Today these tests are in tests/nightly_only.txt, and the default-at-rest lane runs with OPENADAPT_TEST_LANE=fast.
  • Fix the same pathlib reads of sealed files in benchmark/macos_native/qualify_calibre.py and benchmark/multi_surface_record/qualify_linux_cross_window.py.

Same pattern elsewhere (not changed here)

  • compiler/probing.py (around line 281) copies a sealed source with copytree(ignore=templates) and then saves. It looks like the same broken partial-index copy; copy_bundle_files fits it.

  • benchmark/macos_native/qualify_calibre.py reads and rewrites recording/events.jsonl with pathlib in the same way.

  • benchmark/multi_surface_record/qualify_linux_cross_window.py reads events.jsonl, the run's report.json and the bundle's workflow.json with pathlib.

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.

…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.
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 84df590

Author declaration. I wrote this change. It routes the repair qualifications' events.jsonl read and rewrite through openadapt_flow.sealed_set, because recordings are sealed by default since #2423.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 84df590

Independent cross-vendor review of claude/fix-native-linux-at-rest against origin/main.

What was verified

  • No plaintext opt-out; fail-closed sealed-set I/O: Replaces raw events_path.read_text() / events_path.write_text() with openadapt_flow.sealed_set.read_text() / sealed_set.write_text() so recordings encrypted at rest by default (#2423) are read and rewritten in memory through the sealed-set API and remain sealed on disk.
  • Fixes both siblings in benchmark/repair_every_backend/: Covers both qualify_linux.py and qualify_macos.py (the only two files in that directory reading/writing events.jsonl).
  • Generality / durability: Benchmark qualification harness fix only; zero per-app engine code; preserves default at-rest encryption without workarounds. Approve for merge on green CI.

…epair qualifications

A pathlib unlink left manifest.json in the sealed index, so the next
save refused the bundle (missing: manifest.json).
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 646afe3

I ran the real "flow native Linux" step locally at this head, and it still fails. The sealed-set read/rewrite and the manifest.json unlink are correct now, but the run reaches self-repair and crashes there. The cause is engine code, not these scripts. Merging this alone will not turn main green or unblock the types publish.

What I ran

Setup: Linux box (Debian 13), Xvfb, openbox, at-spi2-core 2.56, GTK3 and Python 3.12. Installed with scripts/ci/locked_install.py --lock 'packages/flow[dev,linux]' --editable packages/types --editable packages/flow, matching the CI step. HOME was isolated, so the product default applies: at rest on, a fresh file key store, no plaintext opt-out. The command is the job's own xvfb-run … dbus-run-session … openbox … python benchmark/repair_every_backend/qualify_linux.py.

Tree Result
main d82ccc96 (control) exit 1 after about 8 s: FileNotFoundError …/record/recording/events.jsonl. This reproduces main's failure.
84df590c (previous head) exit 1 after about 8 s: SealedSetError …/record/bundle does not match its sealed index (missing: manifest.json) at qualify_linux.py:208-209. Fixed at this head.
646afe36 (this head) exit 1 after 21.9 s: SealedSetError: …/repair-with-record-check/item holds self-repair/attempt-1/evidence/heals/step_000_bridge_1/screen.png in plaintext, outside its sealed index

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 qualify_linux.py:341 → repair.run → self_repair.py:836 run → self_repair.py:2479 _finish → ir.py:6764 report.save → sealed_set.write_bytes resume → SealedSet.open refuses.

Findings

  • P1, engine: packages/flow/openadapt_flow/repair/self_repair.py:1290-1292. When self-repair inserts a bridge step, it writes the halted screen with plain pathlib: (frame_dir / "screen.png").write_bytes(screen). That file lands inside a sealed run directory. There are two effects:

    • Screen pixels sit on disk in plaintext under the at-rest default.
    • The next sealed write into the run refuses the set, so every bridge-step repair fails.

    self_repair.py:1420 reads the file back with pathlib too.

  • P1, still failing after a probe fix. As a local probe only (nothing pushed), I routed lines 1292 and 1420 through sealed_set.write_bytes and read_bytes. The script then exits 1 with 10 of 16 checks ok. The repair_with_record_check stage reports "the proposal could not be applied (SealedSetError)", and repair_resumed, repair_resume_verified, repair_exactly_one_new_row, click_admitted_on_atspi_identity, repair_fault_probe_stopped_before_save and one_person_decision are BAD. So more of the repair or patch path writes outside the sealed index. This needs a scoped engine fix, with a unit test that runs self-repair's bridge path at rest. A test like that would also catch this without the GTK job.

  • P3, ruff format --check: both scripts would be reformatted (the new events = [...] comprehension). CI doesn't format-check benchmark/repair_every_backend, so this isn't blocking.

  • P3, mypy: 4 dict-item errors in qualify_linux.py:197-198 and qualify_macos.py:240-241. They're on lines this PR doesn't touch.

Tests run (at this head unless noted)

  • qualify_linux.py, the real CI step, as in the table above.
  • pytest tests/test_compile_identifier_crop.py tests/test_artifact_reads.py (at 84df590c; the new commit changes only the two benchmark scripts): 63 passed in 51.9 s.
  • ruff check benchmark/repair_every_backend/: passed.

Generality gate

Pass for this diff: it changes two benchmark harnesses and no engine code, with no app-specific logic in openadapt_flow. The engine fix it needs is generic too: self-repair evidence writes must go through the sealed-set helpers for every backend.

Not run

  • qualify_macos.py, which needs macOS and real apps. It has the same _record change and calls the same repair.run, so it should hit the same engine failure.
  • The rest of the Linux job (qualify_linux_atspi.py).
  • The latent copies Claude listed (qualify_calibre.py, qualify_linux_cross_window.py).

CI at review time

Dispatch 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 Analyze (python, javascript-typescript) pending. The packages PR run hadn't reported yet.

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.
@abrichr abrichr changed the title fix(flow): read and rewrite the sealed recording in the repair qualifications fix(flow): keep repair evidence sealed under encryption at rest Nov 23, 2026
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: c352ba7

What changed since 646afe3:

  • The scope grew to include a product privacy fix. Self-repair wrote each bridge step's evidence frame (self-repair/attempt-N/evidence/heals/<step>/screen.png) with pathlib. Inside a run that is sealed by default, that put a screenshot in plaintext, and the next report write refused the run (CI run 45254655799).
  • runtime/heal.py has new heal-frame helpers (heal_frame_path, write_heal_frame, has_heal_frame, read_heal_frame) that go through sealed_set. persist_heal uses them.
  • repair/self_repair.py writes and hashes the bridge frame through the helpers. It also now uses the sealed set for these:
    • reading the staged expect templates
    • copying the halted report
    • reading the halted before-frame
    • writing self-repair.json
  • repair/cli.py: the frame campaign reads frames through the helpers.
  • compiler/compile.py: the hover evidence crop is written through the sealed set.
  • New tests/test_heal_evidence_sealed.py (3 tests) passes under OPENADAPT_TEST_DEFAULT_AT_REST=1. ruff and mypy are clean on the changed files. The machine load stayed above 35 (185 to 296), so the checks ran directly, single-process, and not through the cpu-slots guard.
  • None of the touched paths is in .github/agent-safety-manifest.json.
  • The packages.yml dispatch on this head is run 45260140733.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: c352ba7

Independent cross-vendor review of claude/fix-native-linux-at-rest against origin/main.

What was verified

  • Sealed-set heal evidence & self-repair I/O (runtime/heal.py, repair/self_repair.py, repair/cli.py, compiler/compile.py):
    • write_heal_frame, has_heal_frame, and read_heal_frame centralize heal screenshot I/O through openadapt_flow.sealed_set, preventing plaintext PNG leaks inside encrypted run directories.
    • self_repair.py routes bridge frames, staged templates (_sealed.list_files / _sealed.read_bytes), evidence_dir / "report.json", work / "self-repair.json", and _before_frame() (catching only OSError so tampered sealed sets still refuse) through sealed_set.
    • compiler/compile.py routes _hover_evidence crops through _sealed.write_bytes, and both qualify_linux.py and qualify_macos.py route events.jsonl + manifest.json unlink through sealed_set.
  • Sibling audit across openadapt_flow/repair/: Audited all writers in repair/ (agent_teach.py, registration.py, dialog_identity.py, hold.py, lifecycle.py, readmission.py, auto_repair.py, standard_change.py). No other plaintext writes remain inside a sealed run directory (agent_teach.py writes to a separate external evidence directory guarded by at_rest.unsealed_write).
  • Tests (tests/test_heal_evidence_sealed.py): Verifies default-at-rest sealing, zero plaintext PNGs, _assert_ciphertext_only, subsequent report.json write acceptance, plain-run compatibility, and _before_frame sealed decryption.
  • Generality & Durability: Zero per-app engine code; fixes the class of unsealed evidence writes across repair/heal/compile/qualify; directly preserves on-premises PHI encryption at rest. Held-out / live Linux AT-SPI Xvfb workflow_dispatch run (45260140733) is currently queued on c352ba7c. Approve for merge on green CI.

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.
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 3ec46af

What changed since c352ba7:

  • New bundle_persistence.copy_bundle_files. Self-repair and relabel used to build the patched bundle with copytree(ignore=...). For a sealed source, that copied the index without the files it lists, so the save was refused: "does not match its sealed index". The repair half of dispatch 45260140733 failed this way, and it reproduces locally. A sealed source is now written into a new sealed set through its writer. A plaintext source is copied as before.
  • repair/self_repair.py and repair/relabel.py use the new helper.
  • tests/test_heal_evidence_sealed.py has 2 new tests: a sealed copy opens, verifies, holds no plaintext and loads the patch; a plaintext copy is unchanged.
  • Checks:
    • tests/test_heal_evidence_sealed.py passes (5 tests, default mode).
    • tests/test_repair_relabel.py passes (10 tests) in both modes.
    • The self-repair bridge and after-crop tests pass in plaintext mode (4 tests).
    • ruff and mypy are clean.
  • Still blocked: under the default, the probe is refused by sealed_run_unsupported, because _ProbeGate is not the exact DryRunGate from feat: check prefilled workflows without application input #2190. Past that, ItemApprovalStore writes its approval frame in plaintext inside the sealed run. Both are policy decisions, not missed writers, so this PR does not change them. The PR body lists three options.
  • No touched path is in .github/agent-safety-manifest.json.
  • The packages.yml dispatch on this head is run 45262952933. It is expected to fail at the probe gate.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 3ec46af

Delta review versus previously Gemini-approved head c352ba7c506d634303f01af7cde02608277bf1b4.

What was verified

  • bundle_persistence.copy_bundle_files(): Cleanly handles both plaintext (shutil.copytree) and sealed sources (decrypts in memory via _sealed.open_set(source), fails closed with SealedSetKeyError if output_bundle_key() is missing, and writes a fresh sealed set via _sealed.writing(destination, "bundle", passphrase) with per-component fnmatch filtering so ignored files never leave stale index entries or plaintext on disk).
  • Fixes both siblings: Updated both repair/self_repair.py and repair/relabel.py to call copy_bundle_files().
  • Tests (tests/test_heal_evidence_sealed.py): Adds test_a_patched_copy_of_a_sealed_bundle_is_a_sealed_set_that_opens (verifies excluded manifest.json/templates/, _assert_ciphertext_only, patched.save(encrypt=True), verify_all(), and Workflow.load) plus test_a_plain_bundle_copy_is_a_plain_file_copy.
  • CI status: workflow_dispatch run 45262952933 (flow native Linux (AT-SPI, Xvfb)) is currently queued on 3ec46af7. Approve for merge once CI is green.

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.
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 32a7698

What changed since 3ec46af:

  • benchmark/repair_every_backend/qualify_linux.py and qualify_macos.py: only the self-repair legs (_repair, including the fault probe) run on a plaintext copy of the bundle, with the same content digest, under at_rest.opted_out. Record, compile, the governed run and the wrong-patient and look-alike legs stay under the default. The results record self_repair_mode: "plaintext (known limitation: attended approvals are refused in sealed runs, #2423)", and the summary prints it.
  • Product code is unchanged since 3ec46af. Nothing in runtime/preparation changed, and _ProbeGate is not admitted. The heal-frame, copy_bundle_files, relabel and hover-crop fixes stay.
  • Checks: ruff, ruff format --check and py_compile pass on the scripts. tests/test_heal_evidence_sealed.py passes (5 tests, default mode). A scratch smoke test of the scoped opt-out passed.
  • packages.yml dispatch 45264633441, job "flow native Linux (AT-SPI, Xvfb)" 138008791947: success, with all checks passing and a VERIFIED resume.
  • No touched path is in .github/agent-safety-manifest.json.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 32a7698

Delta review versus previously Gemini-approved head 3ec46af7e4b28de2d2458445a6b85d32537e9a6b.

What was verified

  • Product policy untouched: Zero changes to product code since 3ec46af7 — all 7 encryption-at-rest fixes (runtime/heal.py, repair/self_repair.py, repair/cli.py, repair/relabel.py, bundle_persistence.py, compiler/compile.py, tests/test_heal_evidence_sealed.py) and fail-closed product defaults remain intact.
  • Scoped, honestly labelled benchmark opt-out (qualify_linux.py, qualify_macos.py): Record, compile, and all governed runs stay under the encryption-at-rest default. Only the self-repair legs run inside _self_repair_legs() under at_rest.opted_out(...), verifying copy.manifest.content_digest == source.manifest.content_digest and explicitly recording self_repair_mode: "plaintext (known limitation: attended approvals are refused in sealed runs, #2423)" in both the results JSON and stdout logs.
  • Live Linux AT-SPI verification: workflow_dispatch 45264633441 (flow native Linux (AT-SPI, Xvfb), job 138008791947) confirmed conclusion: success on exact head 32a76987. Approve for merge on green required CI.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 32a7698

My earlier blocker (at 646afe3: self-repair wrote a plaintext screen.png into an encrypted run) is fixed. I see no new blocker at this head.

What I checked

  • Plaintext opt-out stays in the qualification. _self_repair_legs lives only in benchmark/repair_every_backend/qualify_macos.py (and qualify_linux.py imports it). It wraps only the three self-repair legs. Record, compile, the governed clean run and the other-patient and look-alike legs still run under the default, before the block starts. at_rest.opted_out restores both env vars in finally, and main() also restores the whole environment. No product code or default changed. Probe: inside the block the copy is plaintext and the env is set. After the block, or after an exception inside it, both vars are gone. The sealed source bundle is byte-for-byte unchanged and holds no plaintext PNG. The copy is decrypted in memory and saved to <work>/repair-bundle (a temp folder that is deleted unless --keep). It is checked to have the same content digest.
  • Honest labelling. self_repair_mode is written to the results JSON and printed above the checks. The opt-out names itself on stderr and in the ledger. passed is still all(checks), and no check was changed or dropped.
  • Sealed writes and copy_bundle_files. Heal frames, staged templates, self-repair.json, the halted report copy, the campaign frame reads, the compiler hover crop and relabel now all go through the sealed set. Probes on a sealed source: swapped files, an added file and a wrong key each refuse, and no plaintext lands in the destination. ignore drops exactly the matching paths, and the new set passes verify_all. _before_frame catches only OSError. SealedSetError and SealedSetKeyError are ValueErrors, so a tampered frame still refuses rather than reading as "no frame".
  • Remaining plaintext writers. In the self-repair path, the approval store still writes its frame in plaintext through at_rest.unsealed_write. That path is refused up front in a sealed run (sealed_run_unsupported). Under OPENADAPT_TEST_DEFAULT_AT_REST=1, the 9 self-repair and auto-repair tests that fail locally now fail only with that documented refusal ("Nothing was executed"). At the merge-base, 3 of those same 9 tests showed the plaintext heals/.../screen.png leak.
  • Generality gate (AGENTS.md: engine code stays application-agnostic). Pass. The engine changes are generic sealed-set I/O helpers (write_heal_frame, read_heal_frame, has_heal_frame, copy_bundle_files), with no app names or app-specific branches. The fix covers the whole class: every self-repair evidence writer and both bundle-copy sites, not just the one file. App-specific code exists only in the benchmark qualification. The evidence is the real AT-SPI/GTK qualification run, plus unit tests.

Non-blocking (P3)

  • If a plaintext bundle runs in a default sealed run, copy_bundle_files falls back to copytree into the sealed run folder. The next write to that run then refuses the set. This fails closed, the code before this PR did the same, and the data is the bundle's own plaintext. A follow-up could seal the copy whenever the destination is inside a sealed set.
  • _self_repair_legs checks that the digests match but does not check that the copy is really plaintext. My probe confirmed it is.

Tests at this head (fresh worktree, Python 3.12, packages/flow[dev])

  • Repair, heal, sealed-set, at-rest and qualification-evidence suites: 552 passed, 0 failed.
  • tests/test_heal_evidence_sealed.py plus 6 extra probes of my own (not committed): 11 passed.
  • The same set under OPENADAPT_TEST_DEFAULT_AT_REST=1: 399 passed, 36 skipped, 9 failed. The same 9 fail at the merge-base too, and at this head they fail only on the documented sealed-run refusal described above. CI's default-at-rest shards pass.

CI

  • The dispatched Packages run for this head is 45264633441. Its job flow native Linux (AT-SPI, Xvfb) passed: linux atspi: PASSED with all 18 checks ok, including repair_resumed, repair_resume_verified, repair_exactly_one_new_row, click_admitted_on_atspi_identity, repair_fault_probe_stopped_before_save and one_person_decision. The log says the self-repair legs ran in plaintext. The run as a whole ended cancelled, as the run for the previous head did.
  • PR checks when I posted: 32 pass, 23 skipping, packages-gate pending, none failing.

Not run

  • The macOS qualification (no Mac runner here).
  • The full flow suite (I ran the focused suites above).

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.

1 participant