Skip to content

fix(flow): keep ir within its import-time budget (main is red) - #2466

Merged
abrichr merged 1 commit into
mainfrom
claude/flow-ir-import-budget
Nov 21, 2026
Merged

abrichr merged 1 commit into
mainfrom
claude/flow-ir-import-budget

Conversation

@abrichr

@abrichr abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member

Main is red. tests/test_import_direction.py::test_import_time_budget fails on origin/main (de6c0bb6):

  • openadapt_flow.ir loads 45 modules against a budget of 44.
  • openadapt_flow.receipt loads 46 against 45.

Cause. The merge order. #2427 set the budgets from a tree without F1 (#2454). F1 split qualification.py into a package, so openadapt_flow.qualification.models is now one more module on ir's import path. Comparing sys.modules before and after shows that module is the only addition. Budgets never rise, so this PR takes one module back out.

Fix. runtime/effects/ui_readback.py used launch_rendering_ready in a single method, when it opens a browser. Importing ir loaded _browser_readiness only because of that one import. It is now imported inside that method, the way taskgen, qualify, rl_env and browser_teach already import it.

  • ui_readback.launch_rendering_ready still resolves, through a module __getattr__, and it is the same object as before.
  • Nothing else changes.

Verified.

  • test_import_direction.py passes again: ir loads 44 modules and receipt 45, both exactly at budget.
  • These also pass, 2,425 tests in all:
    • test_import_layers.py: its diagnostics are unchanged apart from one line-number shift, and debt rows don't depend on line numbers.
    • test_fresh_imports.py
    • test_consumer_import_surface.py
    • the ui_readback tests
  • mypy, ruff, the generality check and the size ratchet are clean.

@abrichr

abrichr commented Nov 21, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: APPROVE

From: Grok
Reviewed-Head: bad29d5

Scope: packages/flow/openadapt_flow/runtime/effects/ui_readback.py (+13/-1). The module-level launch_rendering_ready import moves inside _PlaywrightSession's launch path, and a module __getattr__ keeps ui_readback.launch_rendering_ready resolvable.

Question asked: does any caller rely on _browser_readiness being loaded as a side effect of importing ui_readback? No, based on a repo-wide grep at this head:

  • No code or test imports launch_rendering_ready from ui_readback, and none patches ui_readback.launch_rendering_ready. A patch there would now be bypassed by the local import, but there is none to bypass.
  • Every other user (agent/browser_teach.py, qualify/session.py, taskgen/runner.py, rl_env/environment.py, validation/*, _browser_setup.py, copilot_runtime.py, __main__.py, and others) imports from openadapt_flow._browser_readiness directly, mostly with the same local-import pattern this PR uses.
  • openadapt_flow/__init__.py already exposes _browser_readiness lazily through its own __getattr__, so attribute access on the package doesn't depend on load order.
  • tests/test_browser_fixture_source.py puts a foreign openadapt_flow._browser_readiness into sys.modules. It passes (18/18) at this head.

Exact-head evidence (Linux x86_64, uv sync --extra dev in packages/flow):

  • test_import_direction.py passes 12/12 at the head. Control: with ui_readback.py reverted to base de6c0bb6, both test_import_time_budget[openadapt_flow.ir] and [openadapt_flow.receipt] fail. This PR fixes both, not just ir, and raises no budget.
  • Probe: importing ui_readback leaves openadapt_flow._browser_readiness out of sys.modules. from ...ui_readback import launch_rendering_ready returns the same object as _browser_readiness.launch_rendering_ready. An unknown attribute still raises AttributeError.
  • Targeted suites: test_ui_readback_*, test_desktop_readback, test_ui_read_checks, test_effect_plugin_options, test_verifier_null_review, and test_import_direction give 351 passed. test_ui_readback_benchmark.py (5 tests) errors on this box because of local key-directory permissions. In a clean HOME it fails 4/5 (test_summary_counts: 5 == 3) identically on base and head, so this PR doesn't cause it. It is still a pre-existing local failure, and CI will decide.

Mutants: restoring the top-level import is killed by the budget tests (the control above). Deleting __getattr__ was not run; by grep, no test or caller references the re-export, so it would survive.

Generality gate: a generic lazy import with no app-, site- or task-specific logic, and no change to verdict, readback or launch arguments.

P3 (non-blocking): nothing pins the ui_readback.launch_rendering_ready re-export. Either add a one-line test, or drop the __getattr__ if nothing outside the repo needs it.

CI at review time: 11 pass, 14 pending, 21 skipping. protected-safety-review / Evaluate protected-path evidence failed only with "expected exactly one current exact-head independent review", so it needs a rerun after this comment. Merge, as stated, belongs to the coordinator once CI is green.

@abrichr
abrichr merged commit 694bd53 into main Nov 21, 2026
89 of 95 checks passed
@abrichr
abrichr deleted the claude/flow-ir-import-budget branch November 21, 2026 14:43
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