Repository navigation
feat(flow): hardware-tiered local model router and PrePostSubmitVisualVeto - #2536
Merged
Merged
Conversation
Member
Author
Independent adversarial review: APPROVEFrom: Grok Cross-vendor review of this Gemini-authored PR. I did not write these changes. The unique tree is three new files ( Safety and routing
No per-app names in the new engine module. No CI or safety weakening. Residuals (not blockers of this PR's own content)
No merge from this review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a domain-agnostic hardware-tiered local model policy/router and a pre/post-submit visual veto guard under
openadapt_flow/models/(__init__.py,runtime.py), building directly on the GOLD ROI cropping andVetoOnlyVLMGuardprimitives from #2485.What changed
Hardware-Tiered Local Model Policy & Router (
openadapt_flow/models/runtime.py):DETERMINISTIC_ONLY): Zero-model fast path; default whenever deterministic API/DB/SQL/DOM authority covers the check (prefer_deterministic=True).LOCAL_ACCELERATED/LAN_APPLIANCE): Routes to local Apple Silicon MLX / CUDA acceleration (zero egress) or an explicitly opted-in LAN GPU appliance (allow_lan_appliance=True, strictMAY_EGRESS = Truepropagation).CPU_LIGHTWEIGHT): Allows lightweight ONNX locate-only grounding on CPU-only hosts and explicitly refuses interactive 4B+ VLM calls (CpuVlmRefusedErrorwhenrequire_vlm=True, or a fail-closed abstaining guard whenrequire_vlm=False) unlessallow_slow_cpu_vlm=Trueis opted in for offline/async jobs.detect_hardware_capabilitiesprobes host capabilities viaimportlib.util.find_specwithout importing heavy ML stacks.Pre/Post-Submit Visual Veto (
PrePostSubmitVisualVeto):VetoOnlyVLMGuardwith GOLD ROI cropping (<= 1024pxbudget) forcheck_pre_submit(identity + optional state) andcheck_post_submit(state verification).VETOandABSTAINalways halt (allowed=False);PASSnever overrides a failing deterministic check (deterministic_passed=False).MAY_EGRESScleanly intocomponent_may_egress/Replayeropt-in enforcement.Unit tests (
packages/flow/tests/test_tiered_local_model_runtime.py):MAY_EGRESSpropagation intoReplayer, GOLD-cropped pre/post-submit veto truth tables, combined identity+state vetoes, and partly clipped ROI abstention.Generality Gate
openadapt_flow/models/is purely hardware-capability and protocol-level;scripts/check_engine_generality.pypasses with zero new hits.>1024pxframes covering all tiers and veto truth tables.Durability
Advances independent, accountable, hardware-aware local verification: deterministic system-of-record checks remain primary, visual models stay strictly veto-only, egress requires explicit opt-in, and CPU-only runners fail closed instead of stalling interactively.
Verification
uv run pytest -q tests/test_tiered_local_model_runtime.py tests/test_local_vlm_gold_crop.py tests/test_remote_vlm.py— 78 passeduv run python scripts/check_engine_generality.py— Engine generality OK (199 baseline hits left)python3 scripts/check_file_size_ratchet.py— passed (exit 0)uv run ruff check openadapt_flow/models/__init__.py openadapt_flow/models/runtime.py tests/test_tiered_local_model_runtime.py— All checks passeduv run ruff format --check openadapt_flow/models/__init__.py openadapt_flow/models/runtime.py tests/test_tiered_local_model_runtime.py— 3 files already formatteduv run mypy openadapt_flow/models/__init__.py openadapt_flow/models/runtime.py— Success: no issues found in 2 source files