Skip to content

feat(flow): learn per-request bookkeeping from read-only requests - #2413

Merged
abrichr merged 11 commits into
mainfrom
fix/learn-bookkeeping-read-probe
Nov 23, 2026
Merged

abrichr merged 11 commits into
mainfrom
fix/learn-bookkeeping-read-probe

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

Summary

On apps OpenAdapt had never seen, the largest cause of false stops was per-request bookkeeping on the acting user's own rows. Examples are the user's last-login time and the API token's last-used time. The whole-database frame saw those rows move on every write and refuted every correct write. learn (#1679) can excuse such rows, but only from writes a shadow can check, and then only with a person's approval. On apps whose requests name their target in the URL, it learned nothing (second retest: 0 excuses on every app).

openadapt-flow learn probe learns the same moves without a write and without a person:

  1. Under one contract's whole-database frame, it reads the database, sends only GET and HEAD requests as the agent, and reads again, three times. No write is sent.
  2. It proposes with the learner's existing rules (learn.propose). It admits only a changed row of the acting user (actor_row), with the exact columns. It never admits a column named by a probe query string, a parameter or the contract. A changed move seen in one read-only round is enough, because no round carried a task.
  3. It writes the excuses into each contract's frame.learned with source: read_only_probe, the new field this PR adds. Receipts name the source.

It does not admit:

  • Added rows, such as a first-login row. Their excuse names columns, not values, so it would also cover a row the agent adds for itself. They are listed under needs_approval for learn approve.
  • Other users' rows, and rows no user owns, such as background-worker settings. They stay a stop and are listed.
  • Anything without a derivable users table. The users table is derived from the manifest: the table that the columns bound to an actor parameter reference by foreign key. Without one, nothing is learned.
  • Contracts that already have frame.learned. They are refused, so a person reconciles them.
  • Updates or found checks with no version source. Another user's edit that the agent's stale save reverts leaves nothing changed, so before this change only the bookkeeping move stopped it. The replay showed these lost updates passing without this rule, and stopped with it.

No app name appears in engine code. The per-app knowledge is the probe's output, written as contract data.

Measured (replay of the first-contact retest's graded cases)

Measured in openadapt-internal evidence/false-stops-2026-11. Each case was judged by the frozen verifier, by main and by this branch, and scored with the retest's own score.py. Agent cases were replayed from their recorded transcripts, with no model calls.

The cases were judged by the frozen verifier, main and this branch (the merged head of this PR and #2377, plus the lost-update rule) on the same writes. The apps are anonymized here; the private report names them.

App Correct writes stopped: frozen / main / this branch In-scope harms stopped: frozen / main / this branch
A: last-login bookkeeping 77/77, 77/77, 36/77 26/26, 26/26, 26/26 (exact reason 21, 21, 22)
B: token last-used bookkeeping 46/46, 46/46, 34/46 (replayed agent writes; full app 67/67 to 26/67 before the lost-update rule) its 2 planted lost updates and 1 agent lost update: still stopped (they passed before the rule)
C: no per-request bookkeeping 29/69, 69/69, 29/69 29/29 each
D: first-login row (an added row, held for approval) unchanged unchanged
Held-out E and F 19/137, 103/137, 19/137 35/46, 38/46, 35/46

The main column is worse than frozen on C, E and F. That comes from the recheck defect #2377 fixes: every recheck of a write begun without a ledger is held UNCERTAIN. Without the bookkeeping refutation, one out-of-scope late duplicate on A now passes. The old setup allow-lists its own record table, so the recheck can't see the duplicate. This is a pre-existing gap that the bookkeeping refutation used to hide; it is reported, not fixed here.

Tests

tests/test_learn_probe.py runs on SQLite, and on MariaDB and PostgreSQL when given. It covers:

  • a correct write passes once the probe has learned the bookkeeping;
  • seven harms on top of the learned bookkeeping all stay stops: another user's last-login, another column of the actor's row, another user's token, a property row for another user, an extra property row for the actor, and a token deletion;
  • a row no user owns and a colleague's concurrent move are never learned;
  • a column the probe's query names is never learned;
  • an added row stays a stop until a person approves it;
  • the read-only method check;
  • refusing to overwrite frame.learned;
  • deriving the users table from a manifest.

Locally, test_learn_probe, test_learned_excuses, test_verifier_recheck, test_verifier_api, test_verifier_snapshot_api, test_frame_owner_attribution, test_continuous_learning and test_verifier_finality gave 327 passed, 68 skipped. Ruff and mypy pass on the new module.

A companion PR, #2377, fixes two recheck false stops found by the same replay.

openadapt-flow learn probe reads the whole-database frame, sends only GET
and HEAD requests as the agent, and reads again. A changed row of the
acting user that moved (a last-login or token-use time) becomes a
frame.learned excuse with source read_only_probe, with no approval. Added
rows, rows of other users and rows no user owns are not admitted.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: 53910b3

P1. The probe can learn an unrelated edit to the acting user's row. The before/after window records the row owner and the changed columns. Another session can change an ordinary field on that same row during one probe round. One observation qualifies for automatic application, and the verifier will then excuse future changes with that column set. The existing concurrency test changes a different user's row. Keep same-owner changes with uncertain provenance pending approval. Auto-apply only where the evidence ties the change to the read request. A synthetic same-owner concurrent edit should stay a stop while ordinary request bookkeeping still qualifies. Probe and proposal · Runtime matching

P1. A mixed contract can receive an excuse while an existing target has no version coverage. The eligibility test counts only record_written effects. A contract that creates a record and checks an existing record with field_equals qualifies as create-only. The alternative check accepts any frame.versions, even when its target_surface covers only one of two write surfaces. Both cases can lift the bookkeeping stop on a stale save to the uncovered target. Check each write target against the surfaces the version judge actually covers. Add mixed-target controls with and without coverage of the existing record. Eligibility test · Version judge

I reviewed the current source, test assertions and recorded CI. The Flow lint job reports missing annotations for kept and held. Unit shard 2 fails the backend-parity and standalone CLI inventory checks. I did not rerun those jobs. Mypy · Unit shard

Generality and evidence

  1. The implementation adds application-independent engine code.
  2. Request attribution and version coverage must hold for every affected target before the verifier can automatically excuse a change.
  3. The PR reports paired replay on held-out apps for the combined tree with fix(flow): two rechecks that held correct writes UNCERTAIN #2377. Its listed controls leave the same-owner concurrent edit and mixed-target cases above unmeasured.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: 53910b3

Gemini (gemini-3.1-pro-preview) reviewed the diff, the PR body, runtime/effects/learned.py and the version judge in verify_run.py. This is a fallback: the local Codex CLI could not run (config and model mismatch). The head is unchanged since the earlier Codex review, and every blocker from that review is still open.

  1. Not fixed: a concurrent edit to the acting user's own row is learned. learn_probe.propose calls _learn.propose(..., k=1, ...) (learn_probe.py line 207), so one move seen in one probe window is applied automatically. Another session can change an ordinary column of the actor's row during that window, and the probe will learn it as an excuse. The concurrency test only covers a different user's row.
  2. Not fixed: a mixed contract can get an excuse without version coverage. _sees_its_own_harm (line 294) looks only at record_written effects. A contract that creates one record and checks an existing record with field_equals therefore counts as create-only. The function also accepts any frame.versions without checking that its target_surface covers every write surface.
  3. Not fixed: CI is red. kept, held = [], [] (line 209) has no type annotations, and the flow core lint job (mypy) still fails on it. Unit shard 2 (backend parity and the standalone CLI inventory) also still fails.

…eside an update the versions don't cover

Review blockers on #2413:
- A move must show in every read-only round (at least two), so a one-off
  edit to the acting user's own row during one round is not excused.
- _sees_its_own_harm judged only record_written effects. Now every
  effect counts: create-only means every effect is a count_new_only
  record_written (or a zero-count guard); otherwise frame.versions must
  cover each other effect on its target_surface.
- Annotate the kept/held lists (mypy).
- learn probe takes --base-url for read-only HTTP requests: record why in
  BACKEND_PARITY.md's URL flags table.
- Rename learn_probe.add_parser to register_parser so the parser
  constructor inventory doesn't read the call as an argparse constructor.
@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 9397a64

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: 9397a64

P1. A repeated change to the actor’s row still becomes an automatic excuse without evidence of who made it. The learner now requires the same column set in each of at least two distinct rounds. That fixes the one-round case. Each round still records a before/after difference and the row owner. A background writer updating the actor’s row throughout the rounds produces the same evidence as request bookkeeping. The verifier will then excuse future changes to those columns on that actor’s row. Keep candidates with only this timing evidence pending human approval. Automatic application needs an existing source that attributes the change to the request. Probe evidence · Proposal filter · Runtime match

P1. An unscoped version read can still miss a write target on a second surface. The new guard correctly refuses a mixed create/update with no versions and an update outside an explicitly named version surface. When target_surface is unset, it accepts every combination of surfaces. The version judge receives the target’s textual ID and deduplicates on that ID alone. Distinct records on two surfaces can have the same local ID, so the second record’s version check is skipped. Keep the automatic excuse disabled on such multi-surface contracts unless the version source distinguishes every target. This can be enforced in probe eligibility. Eligibility · Target collection · Version deduplication

I checked the type annotations, the backend-parity entry and both ends of the parser registration rename. Those changes address the earlier CI findings in source. The author reports 173 targeted tests passing. GitHub CI was still pending at review time. This was a source review of the two updated commits. The changes are application-independent. I have no new held-out runtime result for the two remaining cases. GitHub CI

abrichr added a commit that referenced this pull request Nov 21, 2026
learn_probe._sees_its_own_harm now takes both: every effect must create,
or frame.versions / a bound frame.row_versions must cover every other
effect's surface. A derived row_versions is written only when the
resulting contract passes that check. Docs describe the binding and the
one-table read.
# Conflicts:
#	CAPABILITIES.md
#	llms-full.txt
… for unscoped versions

Codex review blockers on #2413.

fail-open class: correlation-as-attribution. A change to the acting user's
row in every read-only round was taken as the request's bookkeeping, but a
background writer produces the same evidence. Each round now has a control
window of the same length that sends nothing. A move that shows there, or
any move when control windows are missing, goes under needs_approval
instead of becoming an automatic excuse.

fail-open class: ambiguous-subject-binding. With frame.versions and no
target_surface, a contract whose other effects span several surfaces was
eligible, though the version judge tells targets apart by local id alone.
Such a contract now gets no automatic excuse.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: 83138c0

Gemini cross-vendor review of the delta that answers Codex's two blockers (control windows; unscoped versions over several surfaces), and of the full PR diff vs main. Summary of Gemini's output:

  1. Blocker: packages/flow/openadapt_flow/learn_probe.py propose (around line 268). A control window whose frame read fails, for example on a database connection error, gives an episode with has_database: False and no moves. propose only checks that a control episode exists for each round (len(controls) < len(eps)), so a failed control window adds nothing to the background set. A background writer that moves a row during that window is then missed, and the move becomes an automatic excuse (fail-open). Every control window must also have read the database, for example not all(c.get("has_database") for c in controls).

Checked:

  • Background-writer attribution through the control windows.
  • Matching control moves against excuses by table and columns, including the empty-columns fallback.
  • Edge cases for empty control windows, which is where the issue above was found.
  • Unscoped version reads over several surfaces, now correctly restricted to one surface.
  • Test coverage for the new logic.

…und move

Gemini review blocker on #2413 (fail-open class: absent-evidence-as-success).
A control window whose frame was not read listed no moves, so a background
writer during it could still become an automatic excuse. Every control
window must have read the database (frame held or refuted); otherwise the
probe's excuses wait under needs_approval.
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: c274d55

Gemini cross-vendor review of the two delta commits since Codex's review at 9397a64:

  • 83138c0 adds control windows and restricts unscoped versions to one surface.
  • c274d55 makes an unreadable control window count as no evidence.

The review also covers the full PR diff vs main. Summary of Gemini's output; it reported no findings.

  • Background writers: a control window of the same length follows each request window. A move seen in a control window sends the excuse to needs_approval.
  • Failed or partial reads: every control window must have read the database (has_database) with its frame held or refuted. Otherwise the excuses default to needs_approval.
  • Ambiguous subject binding: with an unscoped version read (target_surface unset), _sees_its_own_harm requires every other effect to be on one surface.
  • Added rows: still go to needs_approval, because their excuses name columns, not values.
  • Other users' rows: the relation is derived from the schema's foreign keys (users_for_actor_params), so only the acting user's rows are excused.
  • Tests: test_a_background_writer_on_the_actors_row_is_not_excused, test_an_unreadable_control_window_excuses_nothing_automatically and test_unscoped_versions_over_two_surfaces_do_not_cover_updates cover these cases.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: c274d55

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 9117e38

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 9117e38

Verified clean merge with origin/main (24034b59d72ea4c05960b4e729d9aea72a771b06) over the previously approved head c274d556aad313eab70ebdcba45c3699656e5e65:

  • Only packages/flow/docs/BACKEND_PARITY.md conflicted (two adjacent rows: openadapt-flow learn probe and openadapt-flow wrap-dispatch); preserved both and regenerated llms-full.txt via scripts/build_llms_full.py.
  • Regenerated packages/flow/tests/fixtures/cli_surface.json (OPENADAPT_WRITE_CLI_SURFACE=1) for the newly added openadapt-flow learn probe subcommand and updated openadapt-flow learn --help.
  • All PR code and test files (openadapt_flow/learn.py, openadapt_flow/learn_probe.py, openadapt_flow/runtime/effects/frame.py, openadapt_flow/runtime/effects/learned.py, tests/test_learn_probe.py) merged cleanly without conflict.
  • Targeted pytest: tests/test_learn_probe.py (26 passed, 43 skipped opt-in live) and tests/test_cli_surface.py (3 passed, 1 skipped).
  • Generality & durability: general read-only probe for learning per-request bookkeeping tables across apps, fail-closed on unreadable control windows, no per-app engine code.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 2144dc5

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 2144dc5

Delta over 9117e38ef3aeda3a5093817205aa3ae243c62b44:

  • Ran scripts/build_command_map.py and scripts/build_llms_full.py (2 lines updated in CAPABILITIES.md and llms-full.txt) to include openadapt-flow learn probe in the generated command map.
  • Verified tests/test_capabilities_map.py: 2 passed in 2.38s. No code or behavior change.

@abrichr
abrichr merged commit 49cdd76 into main Nov 23, 2026
57 of 58 checks passed
@abrichr
abrichr deleted the fix/learn-bookkeeping-read-probe branch November 23, 2026 02:45
abrichr added a commit that referenced this pull request Nov 23, 2026
…urces

- new_artifact_key moves to sealed_set (at_rest must not import upward).
- A type ignore for the unfinished-run resume key, as on the creation path.
- The checkpoint lifecycle test checks the refusal when the key is used.
- CAPABILITIES.md rows now come from capabilities/: the two at-rest rows
  move into their sources, and the learn-probe row from #2413 gets one.
abrichr added a commit that referenced this pull request Nov 23, 2026
…lt (#2423)

* flow: encrypt recordings, bundles and runs at rest by default (WIP)

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.

* flow: key hierarchy per the evidence-encryption memo

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.

* flow: report a locked encrypted run clearly; tests for the key hierarchy

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.

* flow: sealed bundles never yield plaintext runs; legacy plaintext runs continue plaintext; desktop encryption test

* benchmark: quickstart timing with everything encrypted by default

* flow: refuse passphrase rewrap of v3 sets; mypy fixes

* flow: keep __main__ growth small; RFC 9180 derivation vector; no internal references

* flow: encrypt undo prior state and narration inside sealed sets; branch teach reads encrypted runs

Found by running the reader suites under the real default
(OPENADAPT_TEST_DEFAULT_AT_REST=1).

* docs: link the capability row to #2423

* flow: open key records with the binary-safe opener (Windows descriptor contract)

* flow: register the quickstart timing data in the public artifact inventory

* flow: keep __main__.py from growing; at-rest command tables and helpers live in cli_at_rest

* flow: keyring stays in the keychain extra (install weight); pip install openadapt already includes it

* tests: set the synthetic-data opt-out and the file key store session-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.

* cli: route at-rest under the setup task in both task tables

* flow: at-rest subcommands refuse abbreviations; session test env set in pytest_configure and restored

* flow: address the Codex review of #2423

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

* flow: bind key records to their archive, authenticate shreds, serialize 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.

* flow: keep run state, exports and recorders inside the at-rest policy

- Durable checkpoints (and rollback state) in a version 3 run use a key
  derived from the run's data key, whoever constructs the store, so a shred
  reaches them in backups too. A store without a key encrypts by default,
  and a downgraded run still sets its checkpoint key.
- --no-encrypt lasts for one command: the environment is restored however
  the command ends.
- Recorder and InteractiveRecorder default to the at-rest policy; an
  explicit encryption_key=None is refused in strict mode and ledgered
  otherwise. Direct desktop capture applies strict mode, the ledger and the
  organization policy before the recorder starts, and a plaintext staging
  folder that survives cleanup is an error, not a success.
- report-run --receipt writes records.json only inside an encrypted run (or
  under the recorded opt-out).
- local-seal verify reads an encrypted run's report in memory and is
  sealed-ready (and strict-safe on plaintext runs).
- api.replay reads the report through the sealed set.
- Hosted success reporting parses the bytes it decrypted; the client run id
  of an encrypted run is a structural file in its sealed index.
- Retention planning refuses a passphrase check on a version 3 run, where
  the passphrase plays no part.

* docs: archive marker, archive-only organization mode, shred authentication and run-keyed checkpoints

Move the encryption-at-rest changelog section to Unreleased: v3.4.0 shipped
without it.

* Regenerate the flow CLI surface snapshot (at-rest commands, --no-encrypt) and llms-full.txt

* test(flow): the records.json receipt test writes outside a run under the opt-out

* flow: seal rollback records in encrypted runs, bind solo sets to their device

- rollback writes its compensated marker and difference files through the
  run's sealed set when the run is encrypted (the default), and
  was_compensated reads the marker there; a run whose state can't be read is
  never treated as resumable.
- A key record carried in a header opens silently only with this computer's
  device key. A set that only the recovery code opens (which anyone who read
  recovery.pub.json could make) is refused until the person restores it:
  `openadapt-flow at-rest restore DIR --yes` rewraps it to this device and
  re-stamps the header, or OPENADAPT_RECOVERY_RESTORE=1 reads backups in place.
- CI: flow core unit shard 1 also runs the rollback, checkpoint and key
  suites with OPENADAPT_TEST_DEFAULT_AT_REST=1.
- Regenerate the CLI surface snapshot (at-rest restore) and llms-full.txt.

* fix(flow): use open_binary in key_hierarchy and satisfy mypy

* flow: durable resume and authority proofs work in encrypted runs

- DurableAuthority digests report.json through the run's sealed set (the
  bytes the continuation fenced), so prove_executor_outcome and the terminal
  check no longer fail on every encrypted run.
- A run cut off before its writer finalized (a crash or a killed leg) can be
  carried on: the next writer authenticates the header and adopts each file
  only if it authenticates under the set's key at its own path.
- CheckpointStore resolves the run's key when it is used, so a store made
  before its run became an encrypted set uses the run's key.
- was_compensated checks the marker's presence in either form without
  opening the set (the previous push treated an unfinalized run as
  compensated and refused its resume).
- The attended reject path rewrites the report through the sealed set.
- CI: the default-mode step also runs the durable and authority suites that
  pass in that mode.

* flow: an atomic report replace that keeps an encrypted run sealed (attended reject)

* flow: keep at_rest below sealed_set, fix mypy, keep capability row sources

- new_artifact_key moves to sealed_set (at_rest must not import upward).
- A type ignore for the unfinished-run resume key, as on the creation path.
- The checkpoint lifecycle test checks the refusal when the key is used.
- CAPABILITIES.md rows now come from capabilities/: the two at-rest rows
  move into their sources, and the learn-probe row from #2413 gets one.

* ci: a temporary informational job running the whole flow suite with encryption at rest on (#2423)

* test(flow): tamper durable state through the stores' own writers, so the intended refusal is checked in either mode

* flow: authoring, runtime validation and agent teach read and write encrypted recordings and runs

- AuthoringSession reads and stamps the recording's events.jsonl and
  meta.json, and writes admit.json, through the sealed set (the recorder
  seals by default).
- Runtime validation reads the run report in memory.
- Agent-teach evidence reads the sealed report and frames; writing that
  plaintext evidence folder is logged by default and refused in strict mode.
- Tests: under OPENADAPT_TEST_DEFAULT_AT_REST=1, one at-rest home per
  session (per worker), outside the tests' own directories.

* flow: distill and agent-teach candidates stay encrypted; default-mode test isolation

- distill_recording reads an encrypted recording in memory and writes the
  distilled recording encrypted (authoring compile distills by default).
- The agent-teach repair candidate is written through the sealed set.
- Tests: the default-mode skip list (tests/default_at_rest_skips.txt), and
  the sealed lock directory outside the tests' own directories.

* docs: drop the duplicate learn-probe row source (#2573 added it on main)

* flow: receipts and handoff follow-ups for encrypted runs; JIT drafts plaintext by design, ledgered

- Run receipts are written for encrypted runs (the default): receipt.json
  stays a structural file of the set, the private openings, card and
  follow-ups are sealed in it, and receipts and follow-ups serialize on a
  lock of their own (sealed_set.side_lock). Verification and the handoff
  list read them through the set.
- The JIT compile agent's capture (recording, draft bundle, signed records)
  is plaintext by design: named on stderr and in the ledger, refused in
  strict mode before recording, with the opt-out held for that capture only.
- distill: a type fix for mypy.
- Tests: the default-mode session home resolves symlinks.

* flow: more readers of encrypted runs and bundles (default-mode triage)

- The JIT capture's plaintext opt-out stack exists from construction, so a
  capture closed without entering still cleans up.
- verify_integrity hashes an encrypted bundle's assets in memory.
- The variant router reads the child run's report through the sealed set.
- The console shows an encrypted run's pending escalation.
- The approver-root pin (a key fingerprint, key directory and roster head,
  written before the run) is a structural file of a run set.

* ci: the default-at-rest suite is required on pull requests, with its 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.

* test(flow): track tests/default_at_rest_skips.txt (*.txt is ignored)

* ci: the default-at-rest shards leave the wall-clock bound to flow core unit
abrichr added a commit that referenced this pull request Nov 24, 2026
…arget (#2457)

* feat(flow): learn per-request bookkeeping from read-only requests

openadapt-flow learn probe reads the whole-database frame, sends only GET
and HEAD requests as the agent, and reads again. A changed row of the
acting user that moved (a last-login or token-use time) becomes a
frame.learned excuse with source read_only_probe, with no approval. Added
rows, rows of other users and rows no user owns are not admitted.

* fix(flow): no probe excuse for an update that can't see a lost update; capability row

* feat(flow): row versions held from the baseline count who saved the target

On PostgreSQL, a read-only REPEATABLE READ snapshot opened at the baseline
still sees the row version that was current then. Its xmax names the
transaction that replaced it; the current row's xmin names the last
writer. Equal: one transaction wrote the target in the window. Different:
two or more, which is a lost update. frame.row_versions turns this on per
contract, and learn probe now writes it beside a bookkeeping excuse on an
update or found check whose generated read it can trace to one table.
MySQL and MariaDB targets get no source: a last-saved marker reads the same
after one save as after two.

* fix(flow): row versions: a shared-lock xmax is not one writer; probe needs a one-table read

* fix(flow): row versions never vouch for a target created in the window; mypy and format

* docs: capability row for row versions; refresh llms-full

* fix(flow): a probe excuses only a move every round shows; no excuse beside an update the versions don't cover

Review blockers on #2413:
- A move must show in every read-only round (at least two), so a one-off
  edit to the acting user's own row during one round is not excused.
- _sees_its_own_harm judged only record_written effects. Now every
  effect counts: create-only means every effect is a count_new_only
  record_written (or a zero-count guard); otherwise frame.versions must
  cover each other effect on its target_surface.
- Annotate the kept/held lists (mypy).
- learn probe takes --base-url for read-only HTTP requests: record why in
  BACKEND_PARITY.md's URL flags table.
- Rename learn_probe.add_parser to register_parser so the parser
  constructor inventory doesn't read the call as an argparse constructor.

* docs(flow): learn probe excuses only moves every round shows

* fix(flow): row versions bound to the target's own table; only no-such-multixact means a plain xid; one-table reads only

Review blockers on #2457:
- frame.row_versions is judged only when its table and key_column are the
  table and column the target_surface's read takes the target_field from,
  over the frame's own connection (row_versions.binding_problem). A decoy
  table with the same key now leaves the frame not checked
  (unbound_source) instead of vouching for a target it never held.
- _multixact_updater_other_than treats only PostgreSQL's "MultiXactId N
  has not been created yet" / "does no longer exist" as a plain xid. Any
  other error is raised, so the judge reports not checked.
- detect_row_versions (now row_versions.single_table_read) accepts one
  SELECT over one table and rejects UNION, INTERSECT, EXCEPT, JOIN,
  LATERAL, WITH, subqueries and a second statement.

* fix(learn): attribute probe excuses with control windows; one surface for unscoped versions

Codex review blockers on #2413.

fail-open class: correlation-as-attribution. A change to the acting user's
row in every read-only round was taken as the request's bookkeeping, but a
background writer produces the same evidence. Each round now has a control
window of the same length that sends nothing. A move that shows there, or
any move when control windows are missing, goes under needs_approval
instead of becoming an automatic excuse.

fail-open class: ambiguous-subject-binding. With frame.versions and no
target_surface, a contract whose other effects span several surfaces was
eligible, though the version judge tells targets apart by local id alone.
Such a contract now gets no automatic excuse.

* fix(row-versions): bind the key projection exactly; refuse duplicate keys and expired multixacts

Codex review blockers on #2457.

fail-open class: ambiguous-subject-binding. The projection matcher found
the key column anywhere in the select list, so a computed identity ending
with that column qualified while returning a different value than the
lookup column. The select item must now be exactly t.<column> or
CAST(t.<column> AS TEXT). When a key maps to more than one physical row in
the baseline or current read, the target is not_checked instead of one
version silently replacing the other.

fail-open class: absent-evidence-as-success. PostgreSQL also says "does no
longer exist" for a multixact older than its retained range, whose members
are gone. Only "has not been created yet" now means a plain xid; an expired
lookup leaves the target not_checked.

* fix(learn): an unreadable control window is no evidence of no background move

Gemini review blocker on #2413 (fail-open class: absent-evidence-as-success).
A control window whose frame was not read listed no moves, so a background
writer during it could still become an automatic excuse. Every control
window must have read the database (frame held or refuted); otherwise the
probe's excuses wait under needs_approval.

* test(flow): regenerate cli_surface.json for learn probe

* docs: refresh command map and llms-full.txt for learn probe
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