Repository navigation
feat(flow): Global-to-Local (GOLD) ROI cropping and unified VetoOnlyVLMGuard - #2485
Conversation
Independent adversarial review: REQUEST CHANGESFrom: Codex P1. The new guard hides a remote backend from replay’s screenshot-egress check. The guard stores the identity comparator and state verifier without exposing their P1. Grounding accepts a point outside the image the model saw. The service returns numeric coordinates without checking image bounds. The local-crop branch adds the crop origin and accepts the result immediately. An out-of-crop coordinate can therefore become an ordinary on-screen point outside the observed region and suppress the global retry. Check finite coordinates against the actual submitted image before translating them. An invalid local result should take the existing global fallback, and an invalid global result should produce no proposal. Local return and fallback · Coordinate conversion · Service response P2. An identity comparison can pair an identifier crop with a whole screenshot. The guard decides whether to use the crop independently for the recorded and live frames. If just one frame exceeds the size threshold, it compares that crop with the entire other frame and reports that cropping was used. This gives the comparator different subjects and can send pixels outside the requested identity region. For an identity check with an explicit region, supply corresponding crops on both sides or abstain before invoking the backend. Identity inputs · Size threshold All three findings apply across applications. The veto-only truth table is correct. The identity ladder treats a model match as permission to continue checking identity. It cannot authorize the target from that match alone. Existing replay callers do not supply the new region argument. The state drift check still has its existing, separate semantics for non-write steps. The PR reports 64 passing tests and synthetic images. This review inspected the source and assertions and added no live model, screenshot or held-out measurement. At review time dependency review and Gitleaks had passed and package CI was queued. Identity ladder · State check · CI |
…e symmetric identity ROI cropping
Independent adversarial review: REQUEST CHANGESFrom: Codex The egress finding is resolved. The guard propagates the classification of both wrapped backends. Replay checks that property before wiring the component and carries the result into the run report. The transport-free constructor test covers refusal without opt-in, reporting with opt-in and a fully local backend. Guard · Replay opt-in · Run report · Regression Two cases from the prior review remain.
The partial-region finding applies to callers using the optional ROI argument. The current replay resolver calls grounding without it. Both findings are application-independent. Resolver call This source review traced the callers and synthetic assertions. I made no model calls and did not rerun suites or measure held-out accuracy. Package CI |
…rtly clipped identity ROI
Independent adversarial review: APPROVEFrom: Grok Delta versus the prior Codex REQUEST CHANGES at
This source review traced the grounder retry path, the crop helper, and the new tests. I made no model calls and did not rerun CI. |
Independent adversarial review: APPROVEFrom: Grok Delta versus my prior APPROVE at I reviewed only this merge delta, not the already-reviewed unique work or the already-merged main trees. I did not rerun CI. |
…ncy signs The branch's first commit was cut against a newer main than its tree, so it reverted the GOLD crop and veto guard work from #2485. This puts those files back as they are on main. It also reads "-$250" and "$-250", and accepts a finite Decimal as an expected number.
Summary
Adds deterministic Global-to-Local (GOLD) ROI cropping and a unified veto-only VLM guard across
openadapt_flow/runtime/remote_vlm.pyandopenadapt_flow/runtime/identity_vlm.py.What changed
Deterministic GOLD ROI cropping (
remote_vlm.py):GoldCropResultandgold_crop_for_model(png, roi=None, max_dim=1024).roiis omitted, invalid, or the frame already fits<= 1024px, behavior falls back identically to_downscale_for_model(used_gold=False, zero behavior regression).max(w, h) > 1024and a validroiis provided, extracts a padded ROI crop directly from the unscaled source frame (preserving native 1:1 resolution whenever the padded ROI fits<= 1024px, and always bounding every output inside<= 1024px) plus a single-image global+local composite (composite_png).roi: Optional[Region] = NoneintoRemoteGrounder.locate(maps local crop coordinates back to original full-frame pixels, falling back to the global downscaled frame on local miss) andRemoteStateVerifier.verify/holds(sends the<= 1024pxGOLD composite).Unified Veto-Only Local VLM Guard (
identity_vlm.py):VetoVerdict(PASS,VETO,ABSTAIN),VetoDecision, andVetoOnlyVLMGuard.VETOandABSTAIN(including exceptions, timeouts, missing backends, or unrecognized answers) always halt;PASSonly declines to veto and never overrides a failing deterministic check (VetoDecision.apply_to_deterministic).IdentityVLM/MLXIdentityVLM) and remote (RemoteIdentityVLM,RemoteStateVerifier) backends, satisfies theIdentityVLMprotocol, and applies GOLD ROI cropping on> 1024pxframes.Unit tests (
tests/test_local_vlm_gold_crop.py):roiis omitted or frames are<= 1024px.2560x1440synthetic alert-banner frames vs. uniform downscaling, bounded<= 1024pxdimensions for oversized ROIs, and deterministic coordinate round-trips.ABSTAINhandling.Generality Gate
openadapt_flow/runtime/remote_vlm.pyandopenadapt_flow/runtime/identity_vlm.pyare purely geometric and protocol-level;scripts/check_engine_generality.pypasses with zero new hits.> 1024pxVLM entry points (grounding, state verification, and local/remote identity vetoing) through one sharedgold_crop_for_modelprimitive and oneVetoOnlyVLMGuardcontract.2560x1440/3200x2400high-frequency contrast frames and unit tests covering all entry points.Durability
Advances independent, veto-only local verification on high-resolution screens without cloud egress, ensuring local VLMs can only veto or abstain and never weaken deterministic system-of-record checks.
Verification
uv run pytest -q tests/test_local_vlm_gold_crop.py tests/test_remote_vlm_downscale.py tests/test_remote_vlm.py tests/test_wire_remote_vlm.py— 64 passeduv run python scripts/check_engine_generality.py— Engine generality OK (301 baseline hits left)uv run ruff check openadapt_flow/runtime/identity_vlm.py openadapt_flow/runtime/remote_vlm.py tests/test_local_vlm_gold_crop.py— All checks passeduv run ruff format --check openadapt_flow/runtime/identity_vlm.py openadapt_flow/runtime/remote_vlm.py tests/test_local_vlm_gold_crop.py— 3 files already formatteduv run mypy openadapt_flow/runtime/identity_vlm.py openadapt_flow/runtime/remote_vlm.py— Success: no issues found in 2 source files