Skip to content

refactor(flow): move the replayer's API-tier and web-form spans to a mixin, unchanged - #2469

Open
abrichr wants to merge 19 commits into
mainfrom
claude/replayer-api-tier
Open

abrichr wants to merge 19 commits into
mainfrom
claude/replayer-api-tier

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

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

What moves. The replayer's API-tier and web-form-span methods move unchanged into the ApiTier mixin in openadapt_flow/runtime/replay/api_tier.py. There are 12:

  • Web-form spans: _web_form_span_at, _web_form_surface_refusal, _governed_web_form_refusal, _run_web_form_span, _web_form_approval_view
  • Request binding: _lookup_capability_refusal, _url_path_targets_param, _api_request_pointer_value, _api_request_pointer_field_path
  • API delivery outcomes: _api_identity_refusal, _verify_uncertain_api_delivery, _set_api_unavailable_refusal

What stays in replayer.py. _actuator_for and _try_api_tier stay, because they pass self to functions typed Replayer (actuator_for, arm_first_local_delivery).

replayer.py keeps every import it had. It goes from 15,872 to 15,125 lines, and its budget is lowered to match. Across E1–E8, replayer.py has gone from 20,090 to 15,125 lines (−4,965).

Checks:

  • verify_moved_code.py against E7 finds 12 moved units, no edits, and no patch to retarget. Against main before E1, the whole stack is 154 moved units with no edits.
  • Strict mypy passes across the stack, and project mypy passes on 772 files.
  • The local full flow suite on this head (E1–E8 together) matches base. The one exception is a test_injection_paths case that hangs under machine load and passes when run alone.
  • These pass, 2,656 tests in all: test_import_surface.py, test_import_layers.py, test_fresh_imports.py, the generality test, test_replayer.py, and the api-tier, web-form, api-step, lookup-capability and api-request tests.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: 8b1f7c0

Unique versus approved #2467 (132b24c0): 12 methods move AST-identical into ApiTier. _actuator_for and _try_api_tier stay on Replayer, unchanged, as claimed. Replayer inherits QualificationFaultInjection, AssetsHealingAndEvidence, SettlingAndInterstitials, EffectChecks, Confirming, ConsequentialDelivery, ApiTier and no longer defines those 12 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 15872→15125, 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 urlsplit). 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: 992daca

I am correcting my original approval. This head inherits a public API regression from #2463. Calling typing.get_type_hints(Replayer.recheck_deferred_readback) raises NameError for Workflow. The new defining module, runtime/replay/effects.py, imports Workflow, Mapping and RuntimeParamScalar only under TYPE_CHECKING. The E5 and E8 trees have the identical effects.py blob (be4cf631). The E5 reviewer confirmed that the call resolved all six annotations on its parent and raised after the move in Python 3.12. Reproduction and expected behavior

Bring the E5 correction forward through E8, including the focused test for the public method. The E8-specific delta still preserves all 12 moved method bodies, signatures and decorators, has no override collisions, and leaves _actuator_for and _try_api_tier on Replayer. The inherited defect affects runtime inspection across applications. My check compared exact source blobs and the parent’s recorded reproduction. I did not rerun the suite or exercise a held-out application.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Codex
Reviewed-Head: 992daca

The head changed after Grok's approval at 8b1f7c04 (merges from main and the E4–E7 branches). Codex reviewed the new head, looking only for correctness and safety blockers. It found none.

What Codex checked:

  • The E8 change (d701e07f6..992daca91) moves exactly 12 methods into ApiTier, unchanged. scripts/verify_moved_code.py --base d701e07f6 reports 12 moved units and exits 0. Against origin/main it reports 81 moved units and exits 0.
  • _actuator_for and _try_api_tier stay in replayer.py.
  • api_tier.py imports every module global that the moved methods read at runtime. Names used only in annotations sit under TYPE_CHECKING.
  • No test patches openadapt_flow.runtime.replayer.X for a symbol that E8 moved, so no test passes without exercising the moved code.
  • No method is defined in two runtime mixins. _ApiTierHost does not appear in the runtime MRO.
  • Refusals, approval gates, identity checks and uncertain-delivery verification are unchanged. Nothing fails open.
  • replayer.py is 15,125 lines, which matches its lowered budget in DECOMPOSITION.md. The compatibility imports stay under noqa.
  • Since 8b1f7c04, the only change to E8's files is documentation. The merges from main add no runtime problem.
  • Grok's earlier review raised no blockers. Its note about unused noqa: F401 imports does not change behavior.

Codex could not run pytest in its read-only sandbox because no temp directory was writable. git diff --check passed.

No blockers.

# 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: 1d78c6b

Review only. I am not merging this PR. This is a delta stamp versus the previously reviewed head 992daca914d26432eadc47cdfbd0481bdc961612.

The only new commit is a merge of current main. The unique tree versus main is the same mixin move (ApiTier and the stacked settling/effects/confirming/delivery files). replayer.py is still 15,125 lines, matching the ratchet row this PR keeps. The merge correctly kept main's __main__.py budget of 14,237 (the previous unique tree still carried 14,331 against an older base). The unique replayer.py hunks are unchanged aside from shift of surrounding line numbers.

I approve this head. I am not merging it.

@abrichr

abrichr commented Nov 22, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Gemini
Reviewed-Head: 1d78c6b

Independent cross-vendor review of claude/replayer-api-tier against origin/main.

Blocking finding (P1 — missed in prior delta stamp)

  • Carries #2463's unfixed get_type_hints NameError into main. This PR targets main and ships the same packages/flow/openadapt_flow/runtime/replay/effects.py (lines 41–56, 251–259) where Workflow, Mapping, and RuntimeParamScalar are imported only under if TYPE_CHECKING:. Merging this branch to main would cause typing.get_type_hints(Replayer.recheck_deferred_readback) to raise NameError: name 'Workflow' is not defined (breaking runtime introspection that works on origin/main).
  • 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 / #2467 stack).

Verified non-blocking checks

  • All 12 ApiTier methods (plus the stacked 23 ConsequentialDelivery, 20 Confirming, 22 EffectChecks, and 4 SettlingAndInterstitials methods) are AST-identical to origin/main Replayer, with zero leftovers and zero cross-mixin overlaps. ApiTier exposes no public methods.
  • replayer.py is 15,125 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