Skip to content

fix(verify): admit a fresh view only from fetches the runtime observed - #2892

Open
abrichr wants to merge 1 commit into
fix/write-intent-obligations-fresh-viewfrom
fix/fresh-view-runtime-observed
Open

abrichr wants to merge 1 commit into
fix/write-intent-obligations-fresh-viewfrom
fix/fresh-view-runtime-observed

Conversation

@abrichr

@abrichr abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member

Stacked on #2877.

Bug

With #2877, a verifier marks its read-back as a fresh view by putting fresh_view in its own result: a list of fetches, or a session id. Nothing checked that those fetches happened. A verifier that invented {"kind": "separate_session", "session": "x"} next to a matching read-back still got VERIFIED.

Change

  • The runtime times its own checks. SimplexTransducer wraps each check it runs (Rung 2, Rung 3, the reopen executor) and records the window (start, end) and the result for that run. The runtime takes those times itself.
  • A new fetch_observer= parameter. It is on SimplexTransducer and openadapt.wrap, and follows the FetchObserver protocol: fetches_between(start, end) -> [ObservedFetch(method, url, status, at, from_cache, session)] plus agent_session. The runtime asks it only about the window of the check that produced the read-back being judged.
  • What counts as a fresh view. evaluate_save_evidence now builds the fresh view only from those observed fetches:
    • at least one GET answered 2xx and not served from a cache;
    • a fetch from a session other than agent_session makes it a separate session;
    • a fresh_view key in the result is ignored.
  • When no save verifies:
    • there is no observer;
    • the observer saw no read in the window;
    • the read-back came from a frame carried in an observation, which no timed check produced;
    • the observer raises. The exception propagates and nothing is admitted.
  • fresh_view_of is removed (it read the caller's dict). It is replaced by fresh_view_from_observed.
  • What this does not prove. The observer is still supplied by the integrator, for example from the browser's network events. The guarantee is that a verifier's own return value can no longer vouch for freshness, and the runtime decides when to look.

Tests

  • New in tests/test_transducer_fresh_view.py:
    • a fabricated fresh view, refused with and without an observer;
    • a read outside the check window, refused;
    • a 304, a POST and a cached response, each refused;
    • a separate session detected from the observed session.
  • Entry points. The entry-point matrix now crosses no fresh view, a fabricated fresh view, a fresh mismatch, a fresh wrong record and a fresh match. Only a fresh match from a check the runtime ran verifies. The two observation-carried frame entries never verify.
  • Results:
    • tests/test_transducer_fresh_view.py: 78 passed.
    • The transducer, obligation, fact-ledger, v3-runtime, wrap and fail-closed test files: 276 passed, 31 xfailed.
    • check_verdict_folds.py and check_engine_generality.py: clean.
  • Capability row. The row in capabilities/10-computer-use-agents/0105-… is updated.

Generality gate

  1. No per-app code in the engine. Observed fetches are a data shape; the engine names no app.
  2. Fix the class, not the instance. This is the remaining sibling of "VERIFIED without real evidence" in fix(verify): require only written values, and a fresh view of the saved record, to verify a save #2877: caller-asserted freshness. Every timed entry point goes through the same observed-fetch check, and the parametrized matrix covers all of them.
  3. Held-out evidence. Not yet shown with this rule. The held-out run for fix(verify): require only written values, and a fresh view of the saved record, to verify a save #2877 used caller-reported fetches.

A verifier could make a save VERIFIED by putting a well-formed fresh_view
(a fetch list or a session id) in its own result next to a matching
read-back. The runtime now times each check it runs (Rung 2, Rung 3, the
reopen executor) and asks the fetch observer attached at wrap time
(fetch_observer=) which server reads it saw in that window. Only a GET
answered 2xx and not from a cache counts; one from another session is a
separate-session read. A fresh_view in a result is ignored, a frame carried
in an observation has no timed check, and with no observer no save verifies.
@abrichr

abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 444e40c

This closes the gap I flagged on #2877: a verifier can no longer vouch for freshness by putting a well-formed fresh_view next to a matching read-back. evaluate_save_evidence now builds the view only from fetches the runtime's fetch_observer reported for the timed check that produced that result. A fresh_view key in the result is ignored. With no observer, or with a result that was not produced by a check the runtime timed (an observation-carried frame), nothing is admitted.

What I checked

I read openadapt/transducer_fresh_view.py, the _timed_check / _observed_fetches / _admit_save_evidence path in SimplexTransducer, the last-check retarget in transducer_v3_runtime.py when a verifier result is copied, and the fetch_observer= pass-through on openadapt.wrap. Entry points I followed all go through the same admit path or the _mark_verified / _emit_receipt backstops: Rung 2 and Rung 3 at DONE and mid-run reconcile, the reopen executor, verification frames, the obligation read-back, and step-cap finalize.

fresh_view_from_observed only keeps GETs with a 2xx status, a non-empty URL, and from_cache false. A 304, a POST, and a cached response are refused. A fetch whose session is set and differs from agent_session is a separate_session; otherwise it is a server_reload. If the observer raises, the exception propagates and nothing is admitted.

Against this worktree on Python 3.12:

  • python packages/flow/scripts/check_verdict_folds.py: "Verdict folds OK (2615 baseline folds left)"
  • python packages/flow/scripts/check_engine_generality.py: "Engine generality OK (7 baseline hits left)". Observed fetches are a data shape; the engine names no application.
  • tests/test_transducer_fresh_view.py: 78 passed, including a fabricated fresh_view (with and without an observer), a read outside the check window, 304 / POST / cached refusals, a separate session detected from the observed session, and the entry-point matrix. Only a fresh match from a check the runtime ran verifies; the two observation-carried frame entries never do.
  • The related transducer, obligation, fact-ledger, v3-runtime, wrap and fail-closed files: 303 passed, except tests/test_transducer_fail_closed.py::test_rollback_all_keeps_git_worktree_file, which also fails at the fix(verify): require only written values, and a fresh view of the saved record, to verify a save #2877 parent on this machine (the test is not in this PR's unique diff). I am treating that as inherited and unrelated.

CI at this head

review-verdict is red, as expected, until this comment lands. packages-gate, smoke, launcher / run-ci, gitleaks, dependency-review, install-weight and the manifest/link jobs are green. Most packages / flow * jobs were skipped because this PR is stacked on #2877 and the unique diff is in the root openadapt/ package, not packages/flow; the tests above were run locally on this SHA.

Limitations, not merge blockers

The observer is still trusted computing base, as the PR states. Two engine-side consequences of that:

  • _observed_fetches does not re-filter the observer's list by ObservedFetch.at against the timed window. A sloppy fetches_between that returns older reads would still admit them. The window test in this PR relies on the test observer to filter.
  • from_cache defaults to False, so an observer that omits the cache flag treats a cached response as fresh.

The runtime also does not bind the observed GET to the record or to the read-back text: any non-cached 2xx GET in the check window is enough, including an unrelated poll or a fetch whose body was ignored. That is weaker than "this read-back came from that fetch," and it is the remaining gap in this class. The capability row is honest that the integrator supplies the observer and that held-out tasks were shown under #2877's caller-reported fetches, not yet rerun with this rule.

This PR is stacked on #2877, which still conflicts with main and has no check runs at 61760e606252. I am not merging or pushing. A release decision, if any, still sits with the maintainer after #2877 is conflict-free and green and this head is rechecked on that merge.

This branch has not been deployed

No deployments
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