Skip to content

fix(transducer): step-cap VERIFIED needs a Rung 2 or Rung 3 pass and every required fact - #2900

Open
abrichr wants to merge 1 commit into
mainfrom
fix/transducer-step-cap-no-unproven-verify
Open

abrichr wants to merge 1 commit into
mainfrom
fix/transducer-step-cap-no-unproven-verify

Conversation

@abrichr

@abrichr abrichr commented Dec 1, 2026

Copy link
Copy Markdown
Member

Problem

In a HealthAdminBench run (N=135, wrapped arm), 38 episodes hit the step cap without DONE and finalize_on_step_cap settled them as VERIFIED. None of the 38 passed the official grader. Normal DONE episodes looked much better (VCR 5, SER 20).

That run used 1574d5f53. Where the 38 came from:

Source of the step-cap VERIFIED Count Status on main
verified_commit_hold ("Commit N was verified at step K and no state-changing action ran since") 31 Already removed at step cap by e772115
Attached Rung 2 verifier passed 7 Still allowed (see below)

main also added the no-save guard (d9d39f2) and the open-obligations guard (0df6072) after that run. So 31 of the 38 are already fixed on main. This PR does not change the 7 Rung 2 cases.

What this PR changes

finalize_on_step_cap on main still had two ways to return VERIFIED without checking the end state:

  1. A passing verification_frame on the last observation.
  2. All required facts found in the fact ledger. Facts seen earlier in the run do not show what the final state is when the agent stopped mid-task.

Both are removed from the step-cap path. A step-capped receipt is now VERIFIED only when all of these hold:

  • the episode made a save (existing guard),
  • no compiled obligation is open (existing guard),
  • every required_fact_ids entry is proven (new: checked first, and unproven facts settle the receipt without calling any verifier),
  • an attached Rung 3 or Rung 2 verifier passes on the final observation.

Otherwise the receipt is COMPLETED_UNVERIFIED with delivery_uncertain=True. The reason says whether facts were unproven, the verifier did not hold, or no verifier was attached. ReceiptOutcome has no UNCERTAIN member. The existing no-save path (COMPLETED_UNVERIFIED, commit_index=0, delivery_uncertain=True) already covers that case, so I did not add an enum value.

verification_frame is still used on the normal DONE path (simplex_transducer.py). Nothing in openadapt/ relied on it at step cap.

The 7 Rung 2 cases

The benchmark runner attaches its own DOM read-back Rung 2 verifier and passes no required_facts. With this PR, a Rung 2 pass and no required facts still gives VERIFIED, so those 7 would still promote. To fix them, change the runner: pass required_facts in the task, or make its Rung 2 check stricter. That is a separate change.

Tests

New or rewritten in tests/test_transducer_fact_ledger.py:

  • test_step_cap_after_earlier_saves_with_unproven_facts_is_not_verified: the HealthAdminBench shape. Two saves are each verified mid-run, then the step cap hits with one required fact unproven. The test expects COMPLETED_UNVERIFIED, and Rung 2 must not be called at finalize.
  • test_step_cap_facts_proven_without_an_end_state_verifier_are_not_verified
  • test_step_cap_ignores_a_passing_verification_frame_without_a_verifier
  • test_step_cap_verifies_when_rung2_holds_and_all_facts_are_proven (rewritten from test_step_cap_audit_accepts_facts_proven_on_the_final_view, which asserted the old behavior)
  • test_step_cap_verifies_when_rung3_holds_and_all_facts_are_proven

The first three fail on main and pass with this change.

Local results:

  • pytest tests/test_transducer_fact_ledger.py: 29 passed
  • pytest tests/test_openadapt_wrap.py tests/test_simplex_transducer.py tests/test_transducer_*.py tests/test_wrap_command.py tests/test_evidence_pending_callers.py: 609 passed, 31 xfailed
  • Full tests/: 3498 passed. The 31 failures and 8 errors (CLI smoke, quickstart, release artifacts, seal publish, browser fixture) fail the same way on unmodified main in this environment. test_receipt_verify.py and test_wrap_receipt_trust.py cannot be collected here because openadapt_flow.receipt_record is missing.
  • ruff check openadapt/ and ruff format --check openadapt/: clean
  • mypy openadapt/transducer_fact_ledger.py: no new errors in this file

…every required fact

When an agent runs out of steps without declaring DONE, it may have stopped
mid-task. finalize_on_step_cap still had two ways to stamp VERIFIED that do
not check the end state: a passing verification_frame on the last
observation, and required facts the ledger picked up earlier in the run.

Now the step-cap receipt is VERIFIED only when the episode made a save, no
compiled obligation is open, every required fact is proven, and an attached
Rung 3 or Rung 2 verifier passes on the final observation. Unproven facts
settle the receipt as COMPLETED_UNVERIFIED before any verifier runs.
Everything else is COMPLETED_UNVERIFIED with delivery_uncertain set.
@abrichr

abrichr commented Dec 2, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 055be82

This tightens finalize_on_step_cap so a step-capped episode is VERIFIED only after a save, no open compiled obligations, every required_fact_ids entry is proven, and an attached Rung 3 or Rung 2 verifier passes on the final observation. I read the full function at this head. The no-save and open-obligation guards still return first. Unproven required facts now settle COMPLETED_UNVERIFIED before any verifier runs. verification_frame and "all required facts proven" were removed as promotion paths on this function only. _ok is still the strict verifier_passed helper (exact True, or a mapping with verified is True).

Local tests at this exact head. pytest tests/test_transducer_fact_ledger.py: 29 passed. The three new tests, plus a probe that all required facts are proven and Rung 2 returns False, fail on current main (7c30a436) in the ways the PR describes: facts alone promoted to VERIFIED, a passing verification_frame promoted, and unproven facts still consulted Rung 2 and promoted. The same four broader-suite failures I saw here (openadapt_types missing on three simplex tests, and test_rollback_all_keeps_git_worktree_file) also fail on unmodified main in this environment. CI is the authority for the full tests/ suite.

Generality gate. The production diff is only openadapt/transducer_fact_ledger.py. No identifiers were added to packages/flow/openadapt_flow. The new tests use synthetic URLs and fact ids; a public benchmark name appears only in a test docstring.

CI at this head. packages-gate, launcher / run-ci (ubuntu-latest, 3.12) (this runs pytest tests/ -v), and smoke are green. review-verdict is red because there was no review yet. The PR is MERGEABLE. It is one types-release commit behind main (#2897); git merge-tree is clean.

Limitations, not blockers for this PR.

  • With no required_facts and a passing attached Rung 2, the receipt is still VERIFIED. The author states this is the remaining 7 HealthAdminBench step-cap cases and belongs in the runner (pass required_facts, or tighten Rung 2). I confirmed that shape still promotes at this head.
  • A raising verifier still propagates (same on main); it does not fail closed to COMPLETED_UNVERIFIED.
  • finalize_on_step_cap is a public method the caller must invoke. SimplexTransducer.act does not call it when the step budget runs out. The DONE path in _verify_before_done still accepts a passing verification_frame, as the PR says.
  • I did not re-run the N=135 HealthAdminBench job.

A maintainer still has to merge this PR; I will not merge it.

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