Repository navigation
feat(flow): learn per-request bookkeeping from read-only requests - #2413
Conversation
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.
Independent adversarial review: REQUEST CHANGESFrom: Codex 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 I reviewed the current source, test assertions and recorded CI. The Flow lint job reports missing annotations for Generality and evidence
|
Independent adversarial review: REQUEST CHANGESFrom: Gemini Gemini (gemini-3.1-pro-preview) reviewed the diff, the PR body,
|
…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.
|
From: Claude |
Independent adversarial review: REQUEST CHANGESFrom: Codex 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 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 |
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.
Independent adversarial review: REQUEST CHANGESFrom: Gemini 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:
Checked:
|
…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.
Independent adversarial review: APPROVEFrom: Gemini Gemini cross-vendor review of the two delta commits since Codex's review at 9397a64:
The review also covers the full PR diff vs main. Summary of Gemini's output; it reported no findings.
|
|
From: Claude |
# Conflicts: # packages/flow/docs/BACKEND_PARITY.md
|
From: Claude |
Independent adversarial review: APPROVEFrom: Gemini Verified clean merge with
|
|
From: Claude |
Independent adversarial review: APPROVEFrom: Gemini Delta over
|
…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.
…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
…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
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 probelearns the same moves without a write and without a person:GETandHEADrequests as the agent, and reads again, three times. No write is sent.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.frame.learnedwithsource: read_only_probe, the new field this PR adds. Receipts name the source.It does not admit:
needs_approvalforlearn approve.frame.learned. They are refused, so a person reconciles them.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, bymainand by this branch, and scored with the retest's ownscore.py. Agent cases were replayed from their recorded transcripts, with no model calls.The cases were judged by the frozen verifier,
mainand 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.The
maincolumn 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.pyruns on SQLite, and on MariaDB and PostgreSQL when given. It covers:frame.learned;Locally,
test_learn_probe,test_learned_excuses,test_verifier_recheck,test_verifier_api,test_verifier_snapshot_api,test_frame_owner_attribution,test_continuous_learningandtest_verifier_finalitygave 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.