Skip to content

refactor(flow): move the replayer's module-level helpers to runtime/replay/_shared.py, re-exported unchanged - #2455

Merged
abrichr merged 2 commits into
mainfrom
refactor/replayer-module-helpers
Nov 21, 2026
Merged

abrichr merged 2 commits into
mainfrom
refactor/replayer-module-helpers

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

This is step E1 of the approved monorepo refactor plan (openadapt-internal#277, track E; see DECOMPOSITION.md section 4.4 step 1). It moves code only.

Everything between runtime/replayer.py's imports and class Replayer moves unchanged to the new openadapt_flow/runtime/replay/_shared.py. That is 51 names: tuned constants, _GraphStepContext, _ProgramHalt, EgressNotPermitted, _NotActionableError, _WebFormApprovalView, and the module functions (effect_field_checks, effect_endpoint_scope, identity_read_contradicts, better_identity_read, _uniform_page_scale, _scroll_target_positioned and others).

replayer.py re-exports all 51 names and keeps every import it had; the ones it no longer uses are marked noqa. So from openadapt_flow.runtime.replayer import X still works for every X, and a patch of openadapt_flow.runtime.replayer.<name> still reaches the methods that stayed in that module.

Line counts: replayer.py goes from 20,090 to 19,654 lines (−436), and its budget is lowered to match. _shared.py is 543 lines, replay/__init__.py 5.

Proof it is a pure move:

  • Moved code: scripts/verify_moved_code.py --base origin/main reports 60 moved units, no edited or new bodies, and no test patch to retarget.
  • Type checks: strict mypy (the safety-path flags) passes on replayer.py and runtime/replay/. The strict step now lists openadapt_flow/runtime/replay/. CODEOWNERS and the safety-coverage include already cover runtime/replay/.
  • Tests: test_import_surface.py (the 61 pinned replayer names and 278 Replayer methods), test_import_layers.py, test_fresh_imports.py and tests/golden_runs pass, 2,233 tests in all.
  • Lint and release checks: ruff and the release-consistency check are clean.
  • Full suite: a full flow run is in progress. I'll post the comparison with the base as a comment.

Collisions: I checked with git merge-tree against every open PR that touches replayer.py (#2412, #2363, #2291, #2368) and against the receipts and CLI stack (#2394, #2410, #2411, #2426, #2414, #2415, #2428, #2437). replayer.py merges cleanly with all of them. The only new conflict is in the DECOMPOSITION.md budget table, for #2363 and #2423: both raise an adjacent budget row, which #2430 forbids anyway.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 0d3e558

Unique work versus main: 51 module-level helpers move from runtime/replayer.py to runtime/replay/_shared.py, and replayer.py re-exports them.

I compared those 51 definitions to the pre-move replayer.py; their ASTs are identical, and replayer.py imports exactly those 51 names from _shared. The Replayer class stays in replayer.py. The packages workflow now includes openadapt_flow/runtime/replay/, and the replayer.py line budget is lowered (20090 → 19654), not raised. I do not see a behavior change.

No merge from me.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

New head a9cf6254 fixes the CI failures.

  • Lint and shard 3/4 (generality): scripts/generality_baseline.json moves its mockmed entry from runtime/replayer.py to runtime/replay/_shared.py. The hit is the moved comment that cites MockMed evidence for PC_STRUCTURAL_TEMPLATE_THRESHOLD. The count is unchanged at 1, and the 301 hits left are the same.
  • Shard 3/4 (test_choice_backend): a Playwright timing assertion, 751 ms measured against >= 800. It is unrelated to this move and should pass on a rerun.
  • Local checks: check_engine_generality.py, ruff, the format check, the Python 3.10 syntax check and release consistency all pass.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: a9cf625

Re-review at the current head (moved since 0d3e558cc, prior APPROVE 7062312572). The unique commit a9cf62542 only moves the check_engine_generality.py baseline entry with the already-moved comment.

The single mockmed hit is still the MockMed evidence comment at runtime/replay/_shared.py:205 (PC_STRUCTURAL_TEMPLATE_THRESHOLD); runtime/replayer.py has none. The baseline path changes from runtime/replayer.py to runtime/replay/_shared.py, and the count stays 1. No runtime code changed. That is the right fix for the generality check after the E1 move.

No merge from me.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Local full flow suite at 0d3e558c (Python 3.12, -n 4): 24,573 passed, 114 failed, 4 errors. The only commit since then, a9cf6254, is the generality-baseline JSON.

  • Failures: every one except a single test also fails on base 12713d970 in this environment. They need the missing mcp extra, a working CDP or Playwright browser, or the capture recorder.
  • The exception: one test_injection_paths.py case hung under machine load, the same way it did on the B1 run, and was stopped. Run alone, the whole test_compile_agent_blocks_an_obeyed_injection set passes on both this branch and base (6 passed, 56 s each).

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

From: Claude
Reviewed-Head: a9cf625

@abrichr
abrichr merged commit 596cd17 into main Nov 21, 2026
61 of 63 checks passed
@abrichr
abrichr deleted the refactor/replayer-module-helpers branch November 21, 2026 13:39
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