Skip to content

refactor(flow): move the replayer's consequential-delivery checks to a mixin, unchanged - #2467

Open
abrichr wants to merge 16 commits into
mainfrom
claude/replayer-consequential-delivery
Open

abrichr wants to merge 16 commits into
mainfrom
claude/replayer-consequential-delivery

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

This is step E7 of the approved monorepo refactor plan (openadapt-internal#277, track E). It moves code only. Stacked on E6 (#2465, approved). Only the last changes are new.

What moves. The replayer's consequential-delivery checks move unchanged into the ConsequentialDelivery mixin in openadapt_flow/runtime/replay/delivery.py. That covers 23 methods in five groups:

  • Consequence and identity contracts: _step_is_consequential, _step_requires_remote_identity_binding, _step_requires_remote_guarded_actuation, _selection_contract_error, _step_has_identity_contract, _unbound_submit_refusal, _step_needs_consequential_revalidation
  • Atomic identity: _requires_atomic_identity_pointer, _requires_atomic_identity_keyboard, _typed_remote_receipt_required, _local_atomic_capability_error
  • Guarded revalidation: _cancel_guarded_coordinate, _cancel_guarded_keyboard, _guarded_keyboard_revalidation, _guarded_type_pointer_revalidation, _guarded_click_pointer_revalidation, _revalidation_frame_capture, _revalidate_consequential_actuation
  • Delivery: _deliver_backend_call, _regions_intersect, _translate_recorded_region
  • Fresh actuation: _fresh_actuation_identity_regions, _fresh_actuation_authorization_refusal

Kept in replayer.py: _fresh_actuation_event and _delivery_authorization_refusal. They pass self to functions typed Replayer (fresh_actuation_event, arm_first_local_delivery). Moving them would mean editing those signatures, which a pure move should not do. They move once those functions take a protocol.

replayer.py keeps every import it had. It goes from 16,830 to 15,872 lines, and its budget is lowered to match.

Checks:

  • verify_moved_code.py against E6: 23 moved units, no edits, and no test patch to retarget.
  • Strict mypy passes across the stack.
  • On the E8 stack top, project mypy passes on 772 files. The local full flow suite also matches base, apart from one test_injection_paths case that hangs under machine load and passes alone.
  • These pass, 2,651 tests: test_import_surface.py, test_import_layers.py, test_fresh_imports.py, the generality test, test_replayer.py, and the consequential, delivery, guarded, remote-identity, actuation and atomic tests. One case failed on the first run and passed on the rerun.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 132b24c

Unique versus approved #2465 (c06b3145): 23 methods move AST-identical into ConsequentialDelivery. _fresh_actuation_event and _delivery_authorization_refusal stay on Replayer, unchanged, as claimed. Replayer inherits QualificationFaultInjection, AssetsHealingAndEvidence, SettlingAndInterstitials, EffectChecks, Confirming, ConsequentialDelivery and no longer defines those 23 methods; the mixins do not overlap. The host stub is TYPE_CHECKING only and covers every self method and attribute the mixin uses; the runtime mixin base is object. The size-ratchet budget for replayer.py is lowered 16830→15872, which matches the file. No unique test edits. I did not merge.

Residual: replayer.py keeps unused imports under # noqa: F401 after the move (including runtime.authorization). 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: d701e07

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 E7. The test should resolve the method through Replayer and check the annotation types. This fix applies across all application targets. My comparison of the 23 moved consequential-delivery 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: Codex
Reviewed-Head: d701e07

Codex reviewed the change this PR adds on top of E6 (#2465, head 9e7406e15), in a read-only checkout of this head. It looked for correctness and safety blockers only. No blockers.

What it checked:

  • All 23 listed methods in ConsequentialDelivery (runtime/replay/delivery.py) match the bodies removed from replayer.py, including the staticmethod, classmethod and timed_span decorators.
  • In the runtime MRO, every moved name resolves to ConsequentialDelivery, and nothing shadows it. _fresh_actuation_event and _delivery_authorization_refusal stay in replayer.py.
  • delivery.py imports every module-level name the moved code uses. F821 and strict mypy pass. No test monkeypatches a module global that the moved code no longer reads.
  • replayer.py is exactly 15,872 lines, and the size-ratchet check passes.
  • verify_moved_code.py reports exactly 23 moved units, with no edited or missing bodies.
  • No safety check is removed and nothing fails open. This is a pure move.

Earlier review: Grok approved at 132b24c0c with no blockers. The reviewed files have not changed since that head, so its approval and its residual note (unused imports kept under noqa: F401) still hold.

Not covered: Codex did not run pytest, because the read-only sandbox has no writable temp directory. Test evidence comes from CI, which was still pending when this review ran.

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

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Grok
Reviewed-Head: 408c618

Delta versus Codex APPROVE at d701e07f6a3b338652510a5587fa8a1e258cb948 and earlier Grok APPROVE at 132b24c0cf07b80ca1ad7f6e885304809dc38abd (request 7082890171). No prior Grok verdict at this head. I did not merge.

P1 — Merging this branch to main would ship #2463's get_type_hints regression

delivery.py, confirming.py, effects.py, settling.py, and tests/test_replayer.py are byte-identical to the last Codex-approved head. The 23 ConsequentialDelivery methods, 20 Confirming methods, 22 EffectChecks methods, and 4 SettlingAndInterstitials methods are AST-identical to Replayer on current main, with no leftover definitions and no cross-mixin name collisions.

The only unique-file edits from the main merge are save_settled_report in replayer.py and the __main__.py budget alignment to 14237. replayer.py is exactly 15872 lines, matching its ratchet budget.

This PR still includes runtime/replay/effects.py with Workflow, Mapping, and RuntimeParamScalar imported only under TYPE_CHECKING. It targets main, so a merge would move Replayer.recheck_deferred_readback into that module and break typing.get_type_hints (NameError: name 'Workflow' is not defined). That is the same P1 as #2463; it was not fixed here.

Please carry the runtime imports and the Replayer-mediated get_type_hints regression into this branch before it lands, even if #2463 is meant to merge first. I will not approve this head until that ships with the branch.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: 408c618

Independent cross-vendor review of claude/replayer-consequential-delivery against origin/main.

Blocking finding (P1)

  • Carries #2463's unfixed get_type_hints NameError into main. Because this PR targets main and includes packages/flow/openadapt_flow/runtime/replay/effects.py (lines 41–56, 251–259), Workflow, Mapping, and RuntimeParamScalar are still imported only under if TYPE_CHECKING:, so typing.get_type_hints(Replayer.recheck_deferred_readback) raises NameError: name 'Workflow' is not defined.
  • Required fix: Carry the runtime imports (Mapping, Workflow, RuntimeParamScalar) in effects.py and the get_type_hints(Replayer.recheck_deferred_readback) regression test (or rebase onto the fixed #2463 once it lands).

Verified non-blocking checks

  • All 23 ConsequentialDelivery, 20 Confirming, 22 EffectChecks, and 4 SettlingAndInterstitials methods are AST-identical to origin/main Replayer, with zero leftovers and zero overlaps. No other moved methods are public.
  • replayer.py is 15,872 lines, matching DECOMPOSITION.md.
  • Generality / durability: pure runtime decomposition refactor; no per-app code.
  • Note: packages / flow core unit (shard 1/4) is currently blocked by stale packages/flow/tests/fixtures/cli_surface.json on main.

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