Skip to content

refactor(flow): move the replayer's action confirmation to a mixin, unchanged - #2465

Merged
abrichr merged 17 commits into
mainfrom
claude/replayer-confirming
Nov 24, 2026
Merged

abrichr merged 17 commits into
mainfrom
claude/replayer-confirming

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

Step E6 of the approved monorepo refactor plan (openadapt-internal#277, track E). This is a move only. Stacked on E5 (#2463, approved); only the last changes are new.

What moves. The replayer's checks that confirm an action landed move unchanged into the Confirming mixin in openadapt_flow/runtime/replay/confirming.py. That is 20 methods:

  • Step gates and predicates: _apply_step_gates, _predicate_holds
  • Typed input: _field_region, _ocr_squashed, _readable_chars, _text_value_at, _typed_input_landed, _verify_typed_input
  • Selected option: _verify_selected_option, _selection_region_compatible, _selection_target_continuous
  • Structural state: _structural_state, _structural_changed
  • Postconditions: _check_postconditions, _note_page_scale, _drift_oracle_rescue, _expected_state_text, _scaled_region_match, _dom_text_visible, _postcondition_template

replayer.py keeps every import it had. It goes from 17,872 to 16,830 lines (−1,042), and its budget is lowered to match.

Checks.

  • verify_moved_code.py against E5: 20 moved units, no edits, and no test patch to retarget.
  • Strict mypy passes across the stack.
  • These tests pass, 2,479 in all: test_import_surface.py, test_import_layers.py, test_fresh_imports.py, the generality test, test_replayer.py, and the typed-input, selected-option, postcondition, step-guard, predicate and text-value tests.

The branch uses the claude/ prefix, so protected-safety-review needs no separate author declaration.

Collisions. No open PR edits these methods.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: c06b314

Unique versus approved #2463 (469d4010): 20 methods move AST-identical into Confirming (step gates, typed input, selected option, structural state, and postconditions). Replayer inherits QualificationFaultInjection, AssetsHealingAndEvidence, SettlingAndInterstitials, EffectChecks, Confirming and no longer defines those 20 methods; the mixins do not overlap. The host stub is TYPE_CHECKING only; the runtime mixin base is object. The size-ratchet budget for replayer.py is lowered 17872→16830, which matches the file. No unique test edits. I did not merge.

Residual: replayer.py keeps unused imports under # noqa: F401 after the move. That does not change behavior.

@abrichr

abrichr commented Nov 21, 2026 •

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Codex
Reviewed-Head: 9e7406e

This replaces my earlier approval. It missed an inherited regression in the public Replayer.recheck_deferred_readback method. This PR targets main, so it would ship that regression.

I checked method resolution and the defining module at this exact head. Replayer inherits the implementation from EffectChecks. Its annotations reference Workflow, Mapping and RuntimeParamScalar, all three imported only under TYPE_CHECKING. The defining effects.py is byte-identical to E5, where a fresh Python 3.12 interpreter raised NameError on typing.get_type_hints(Replayer.recheck_deferred_readback). The same call resolved on E4. E5 reproduction

Please carry E5’s runtime import fix and public API regression test into E6. The test should resolve the method through Replayer and check the annotation types. This fix applies across all application targets. My comparison of the 20 moved confirming methods still stands. I checked the inherited defect at source level and did not run a held-out application.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 9e7406e

Cross-vendor review by gemini-3.1-pro-preview. Codex was tried first and failed: the local CLI could not load its config, and with that worked around, it rejected every model for this account. The head moved from c06b3145 (Grok's APPROVE) to 9e7406e1 through merges only. The only runtime change those merges bring in is in runtime/effects/ui_readback.py, which none of the moved methods use. The other change is a test in tests/test_file_size_ratchet.py.

What was checked, against E5 head 05be872c for the part unique to this PR:

  1. AST identity. All 20 methods in Confirming (runtime/replay/confirming.py) match the Replayer originals exactly, and none is still defined on Replayer.
  2. Name resolution. Every module-level name the moved code uses resolves in confirming.py from the same source module as before. No TYPE_CHECKING-only name is used outside annotations, so no rare path can raise NameError.
  3. Test patches. Tests patch replayer globals in four places: identity_mod.* and time.sleep patch shared module objects, so they still apply. resolve, _DIALOG_WAIT_S and READBACK_DEADLINE_MARGIN_S are not used by the moved code. Replayer._typed_input_landed is patched on the class, which still takes precedence over the mixin. No safety test passes vacuously.
  4. MRO. Replayer(QualificationFaultInjection, AssetsHealingAndEvidence, SettlingAndInterstitials, EffectChecks, Confirming), and no method name is defined in two of these classes.
  5. Safety. No postcondition, typed-input, selected-option or step-gate check is removed or weakened, and nothing fails open.
  6. PR claims. replayer.py is 16,830 lines and its budget row in DECOMPOSITION.md is 16830. The original imports are kept, the now-unused ones under # noqa: F401.

Prior blockers: none. Grok's note about the noqa: F401 imports is not a blocker.

Blockers: none. CI was still pending when this was posted.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

@codex review

Review rules for this repository:

  • Blockers are only: correctness bugs; fail-open paths (a check that passes when it should fail, missing or truncated evidence treated as success, an unbound subject, a permissive default, an unsafe URL or redirect); security problems; secrets; broken tests; and claims the code does not back up.
  • Everything else, including pre-existing code this diff does not change, goes under "Out of scope (follow-up)".
  • If an earlier review exists, review only the changes since it, and say whether each earlier blocker is fixed.
  • End with exactly one line: VERDICT: APPROVE or VERDICT: REQUEST CHANGES.

# Conflicts:
#	packages/flow/docs/design/DECOMPOSITION.md
#	packages/flow/openadapt_flow/runtime/replayer.py
@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: 75f36c2

Independent cross-vendor review of claude/replayer-confirming after merging origin/main (4519814c7).

Blocking finding (P1)

  • Carries #2463's unfixed get_type_hints NameError into main. This PR targets main and ships packages/flow/openadapt_flow/runtime/replay/effects.py where Mapping, Workflow, and RuntimeParamScalar are imported only under if TYPE_CHECKING: (lines 42–53), while the public method recheck_deferred_readback (lines 251–259) uses all three in its annotations under from __future__ import annotations. Merging this head to main would cause typing.get_type_hints(Replayer.recheck_deferred_readback) to raise NameError: name 'Workflow' is not defined (same P1 blocking #2463, #2467, and #2469).
  • Required fix: Import Mapping, Workflow, and RuntimeParamScalar at runtime in effects.py and add a focused regression test calling typing.get_type_hints(Replayer.recheck_deferred_readback) (or rebase onto the fixed #2463).

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: cc3bb18

Independent cross-vendor review of claude/replayer-confirming after resolving the prior P1 and syncing with origin/main (c6e175016).

What was verified

  • effects.py get_type_hints P1 fixed (cc3bb1876): Mapping, Workflow, RuntimeParamScalar (along with Literal, Region, RunReport, Step, QualificationFaultGate, Effect, EffectVerifier, PipelinedReadback, ReadbackPipeline) are now imported at runtime in packages/flow/openadapt_flow/runtime/replay/effects.py instead of under if TYPE_CHECKING:, so typing.get_type_hints(Replayer.recheck_deferred_readback) resolves cleanly.
  • Clean origin/main merge (574a1b40f): PR is MERGEABLE with all moved EffectChecks and Confirming methods preserved intact. Approve for merge on green CI.

# Conflicts:
#	packages/flow/openadapt_flow/runtime/replayer.py
# Conflicts:
#	packages/flow/docs/design/DECOMPOSITION.md
#	packages/flow/openadapt_flow/runtime/replay/effects.py
#	packages/flow/openadapt_flow/runtime/replayer.py
@abrichr

abrichr commented Nov 24, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: 7a789fe

Verified

  • Clean 3-file mixin extraction (packages/flow/openadapt_flow/runtime/replay/confirming.py +1206, packages/flow/openadapt_flow/runtime/replayer.py +6/-1044, packages/flow/docs/design/DECOMPOSITION.md budget lowered 17872 -> 16820) merged cleanly onto origin/main after #2463.
  • Confirmed #2497's fail-closed _drift_oracle_rescue semantics are preserved intact in confirming.py:1081-1120 (a model "yes" records a hint in result.postcondition_drift_rescues and still unconditionally returns every pc in survivors, never clearing a failed postcondition).
  • Pure structural refactor with no per-app engine code and no behavioral regressions.

@abrichr
abrichr merged commit 698f063 into main Nov 24, 2026
53 checks passed
@abrichr
abrichr deleted the claude/replayer-confirming branch November 24, 2026 06:49
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