Skip to content

refactor(flow): move the replayer's settling and interstitial handling to a mixin, unchanged - #2462

Merged
abrichr merged 6 commits into
mainfrom
refactor/replayer-settling-interstitials
Nov 22, 2026
Merged

abrichr merged 6 commits into
mainfrom
refactor/replayer-settling-interstitials

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

This is step E4 of the approved monorepo refactor plan (openadapt-internal#277, track E). It moves code only. It is stacked on E3 (#2459, approved); only the last changes are new.

What moves. Four methods move unchanged to the SettlingAndInterstitials mixin in openadapt_flow/runtime/replay/settling.py, generated by scripts/extract_mixin.py:

  • _settle_seeded
  • _interstitial_declaration_mutation
  • _resettle_after_interstitial
  • _handle_interstitials

replayer.py keeps every import it had. It goes from 19,229 to 18,693 lines, and its budget is lowered to match.

One test patch is added. verify_moved_code.py flagged one test patch to retarget. test_replayer.py::test_closed_loop_scroll_ocr_ambiguity_continues_but_click_halts patches openadapt_flow.runtime.replayer.resolve, but the moved interstitial handling now reads resolve from runtime/replay/settling.py. The test keeps its original patch and adds the same patch for openadapt_flow.runtime.replay.settling.resolve, so every resolver call is still scripted. The test passed before and passes after.

Checks.

  • verify_moved_code.py against E3: 4 moved units, no edits, and no patch left to retarget.
  • Strict mypy passes across the stack.
  • These pass, 2,504 tests in all: test_import_surface.py, test_import_layers.py, test_fresh_imports.py, the generality test, test_replayer.py, and the interstitial, settle and dialog tests. Two browser-timing cases failed on a first run under machine load and passed when rerun.

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: 98ebfac

Unique versus approved #2459 (4d5b2e75): _settle_seeded, _interstitial_declaration_mutation, _resettle_after_interstitial, and _handle_interstitials move AST-identical into SettlingAndInterstitials. Replayer inherits QualificationFaultInjection, AssetsHealingAndEvidence, SettlingAndInterstitials and no longer defines those four 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 19229→18693, which matches the file.

The one test edit keeps the original openadapt_flow.runtime.replayer.resolve patch and adds the same scripted resolver on openadapt_flow.runtime.replay.settling.resolve, which is the binding interstitial handling now uses. That is the only test that scripts resolve through openadapt_flow.runtime.replayer. Other tests import resolve from runtime.resolver and do not drive interstitial handling through the replayer binding. I did not merge.

Residual: replayer.py keeps unused imports (ExitStack, watch_effects / EffectWatchReport, and part of the interruptions import) under # noqa: F401 after the move. That does not change behavior.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: 98ebfac

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a871eb3

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Codex
Reviewed-Head: a871eb3

I compared this head with main at dee96b87 and with Grok’s previously approved 98ebfac6. The merge preserved the reviewed mixin, host module and resolver test. All four methods match their definitions on main by Python syntax tree. Their referenced runtime globals resolve to the same built-ins or import sources. A fresh interpreter imported the exact head and confirmed the mixin’s position in the method resolution order. The scripted resolver test patches the lookup in each module that calls it.

The move is application-independent. The same settling and interstitial methods continue to handle all targets, including refusal before delivery. This review checked source and runtime bindings. It adds no live-application or held-out qualification.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: a871eb3

Cross-vendor review: the PR is protected and authored by Claude. Codex could not run because its local config failed to load, so Gemini (gemini-3.1-pro-preview) reviewed the diff against main (merge base dee96b870), the full runtime/replay/settling.py at head, and the Replayer class header.

What was checked:

  • Moved code is unchanged. _settle_seeded, _interstitial_declaration_mutation, _resettle_after_interstitial and _handle_interstitials have the same AST at the merge base replayer.py and in settling.py.
  • Name bindings. Every module-level name the moved code uses (resolve, watch_effects, class_texts, dismiss_label, whole_interruption_error, _frame_viewport, timed_span and the others) is imported in settling.py from the same module as before. The only names without a module-level definition are a nested def (_record_watch) and an except-handler variable.
  • Test patches. test_closed_loop_scroll_ocr_ambiguity_continues_but_click_halts keeps its replayer.resolve patch and adds the matching replay.settling.resolve patch. No other test patches a name on the replayer module that the moved code now reads from settling.py. _DIALOG_WAIT_S and identity_mod are not affected.
  • MRO. _SettlingAndInterstitialsHost exists only under TYPE_CHECKING. At runtime the mixin's base is object, and Replayer inherits it without shadowing another method.
  • Safety. No halt, ambiguity refusal, interstitial declaration or fail-closed branch is removed or weakened. The PR body's claims match the code and the test change.
  • Since Grok's review. Grok approved 98ebfac6 with no blockers. Between that head and a871eb37, the only change is a merge of origin/main after refactor(flow): move the replayer's asset, healing and step-evidence helpers to a mixin, unchanged #2459 landed. settling.py and test_replayer.py are unchanged.

Blockers: none.

Note: some flow CI jobs were still pending when this review was written.

# Conflicts:
#	packages/flow/docs/design/DECOMPOSITION.md
@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: ff88907

Delta versus Codex and Gemini APPROVE at a871eb37f939d219bb93b6bd9325a5b2a68a2d9a (request 7082843835). No prior Grok verdict at this head. I compared the unique tree to that head and to current origin/main (876f3f53). I did not merge, tag, publish, or dispatch.

The mixin is unchanged: runtime/replay/settling.py and tests/test_replayer.py are byte-identical to the last approved head. SettlingAndInterstitials's four moved methods (_settle_seeded, _interstitial_declaration_mutation, _resettle_after_interstitial, _handle_interstitials) are AST-identical to Replayer on current main. They are no longer defined on the PR's Replayer, and the mixins do not overlap.

The only unique-file edits from the main merge are:

  • replayer.py now calls save_settled_report(run_dir, report) at the same site as current main, instead of report.save / return report.
  • DECOMPOSITION.md keeps main's __main__.py budget 14237 and this PR's exact replayer.py budget 18693, which matches the file.

No package version, changelog, or lock change. This does not auto-publish. Residual from the earlier review still holds: unused imports kept under # noqa: F401 after the move. __main__.py is 14241 lines against a 14237 budget on main itself; this PR does not touch that file.

protected-safety-review is red pending a fresh unedited stamp. I did not merge.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: be0da6a

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Gemini
Reviewed-Head: be0da6a

Verified the merge with origin/main (efdf76c9ada14660a91be5c01a72d0e937adbae9):

  • packages/flow/openadapt_flow/runtime/replay/settling.py, packages/flow/tests/test_replayer.py, and packages/flow/docs/design/DECOMPOSITION.md are byte-identical to the previously approved head ff889072cdf8e46d3fc939dc769bf70e2420ada9.
  • All four moved methods (_handle_interstitials, _interstitial_declaration_mutation, _resettle_after_interstitial, _settle_seeded) on SettlingAndInterstitials are AST-identical to Replayer on origin/main (efdf76c9) and removed from Replayer in replayer.py.
  • Generality & durability: pure structural refactor of application-independent replayer settling/interstitial logic with no behavioral change; no new live-app qualification claimed.

@abrichr
abrichr merged commit bbeb538 into main Nov 22, 2026
57 of 58 checks passed
@abrichr
abrichr deleted the refactor/replayer-settling-interstitials branch November 22, 2026 22:21
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