Skip to content

feat(flow): Multi-LoRA veto registry, zero-PHI calibration collector, and shared BYOC HTTP server - #2576

Open
abrichr wants to merge 3 commits into
mainfrom
gemini/multi-lora-veto-registry
Open

abrichr wants to merge 3 commits into
mainfrom
gemini/multi-lora-veto-registry

Conversation

@abrichr

@abrichr abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member

Summary

Implements the Multi-LoRA visual veto registry + Mitigation #1 (Online False-Pause Calibration Flywheel) + Mitigation #4 (Shared BYOC Multi-LoRA Veto HTTP Server for zero-GPU VA/clinic laptops) in packages/flow/openadapt_flow/:

  • multi_lora_veto.py: Declarative AppAdapterRegistry + MultiLoraVetoRouter hot-swapping compact per-app LoRA adapters by (tenant_id, app_id, workflow_id, domain) with strict BYOC tenant isolation, per-adapter temperature calibration, fail-closed ABSTAIN -> HALT_ESCALATE, and deduplicated Exception Inbox QLoRA JSONL export.
  • calibration_collector.py (Mitigation pip install -r requirements (There is no requirements file in the repo) #1): Value-free / zero-PHI CalibrationCollector & record_operator_override(...) logging SHA-256 screenshot hashes, allowlisted structural metadata (with PII pattern guards), and verdict labels into tenant-scoped JSONL queues for overnight per-app LoRA calibration. Enforces fail-closed tenant isolation on writes and reads.
  • byoc_veto_server.py (Mitigation Modify record.py to accept a command line description of the task that is being performed #4): Lightweight stdlib ThreadingHTTPServer (POST /v1/verify, GET /healthz) + post_verify_request(...) client routing zero-GPU laptop checks to a single customer-VPC GPU running MultiLoraVetoRouter. Enforces constant-time tenant-key auth (401/403), serialized GPU hot-swap lock, strict ABSTAIN -> HALT_ESCALATE, and fail-closed 503 on backend errors.

Verification

  • pytest tests/test_multi_lora_veto.py tests/test_calibration_collector.py tests/test_byoc_veto_server.py -q: 13 passed
  • ruff check & ruff format --check: clean
  • mypy on all 3 source modules: Success: no issues found
  • python3 scripts/check_source_boundary.py: OK: no boundary violations
  • gitleaks protect --staged --redact: no leaks found
  • packages/types/ untouched.

@abrichr

abrichr commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Independent adversarial review: REQUEST CHANGES

From: Claude
Reviewed-Head: 9cc95c3

I read all six files at this head, and Gemini's note on openadapt-internal #211 (comment 7092819494). None of these files is imported anywhere else in the repo, so nothing runs today. The findings below are about what the modules will do once someone wires them in.

P1: the agent can pick its own lenient adapter and get ALLOW

ByocVerifyPayload.requested_adapter_id is set by the caller. AppAdapterRegistry.resolve() returns it straight away through get(). get() only checks BYOC tenant ownership, and MultiLoraVetoRouter.evaluate() never checks that spec.app_id / workflow_id match request.app_id. app_id, workflow_id and domain are also set by the caller, so it can also steer the request to the fallback chain or the cold-start default.

Scenario: the registry holds public adapter app-a (threshold 0.5) and public adapter app-b (threshold 0.99). An agent running workflow A posts {"app_id": "app-a", "requested_adapter_id": "app-b", ...} with a valid tenant key. The router scores with app-b's threshold and temperature. A fault probability of 0.9 returns ALLOW instead of VETO. The thing being checked chooses its own checker. Fix: the server should choose the adapter from server-side bindings (tenant key mapped to allowed app/workflow), reject requested_adapter_id unless it equals the resolved spec, and reject any spec whose app_id does not match the request.

P1: form values leave the machine in plaintext, and "zero-PHI" is not true for this PR as a whole

  • VetoInferenceRequest.expected_fields: dict[str, str] holds the values being entered, which are patient or claim data. post_verify_request() sends them to a remote server, and vllm_request_payload() forwards them to the model. The server only makes sense on a customer-VPC GPU reached from other laptops (module docstring). That means binding beyond 127.0.0.1, but it is a plain http:// stdlib server with no TLS. So the field values and the bearer tenant key cross the network in cleartext.
  • export_inbox_training_jsonl() writes expected_fields and the free-text reviewer_note into training JSONL. That is PHI in a training file.
  • A 422 response returns exc.errors(). Pydantic includes the input value there, so bad requests echo field values back.

The PR title and the collector docstring say "zero-PHI", but only calibration_collector.py is value-free. Either take values out of the wire and export formats (send per-field hashes or match booleans), or drop the zero-PHI claim and require TLS plus an explicit opt-in for remote use.

P1: the remote check cannot see the screen

The server receives only pre_submit_image_sha256 and post_submit_image_sha256. A visual model cannot judge a SHA-256 digest. So any real LoraBackend.score() behind this API either returns a verdict without looking at the screen (an ALLOW that means nothing), or it needs the screenshots sent too, which brings PHI onto the wire. The tests only pass because _StubLoraBackend returns preset logits. Please state which design is meant before this merges as a "veto".

P2: fail-closed on the client side depends on a caller that doesn't exist

The server side is fail-closed: auth, size, JSON, schema and backend errors all return HALT_ESCALATE, and abstain is forced to HALT_ESCALATE. The client is not. post_verify_request() raises HTTPError on 4xx/5xx and URLError or a timeout when the server is down, so the HALT_ESCALATE body never reaches the caller as a VetoOutcome. If a future caller catches the error and goes on, that is fail-open. Have the client turn every error into VetoOutcome(decision=HALT_ESCALATE), and add a test with the server stopped.

P2: registry integrity hash is never checked

AdapterSpec.sha256 is required and its format is checked, but nothing compares it to the adapter bytes. adapter_uri accepts any string (a path, http://, ollama://). There is no loader in this PR, so there is no pickle or code loading today. But the field implies an integrity guarantee the code does not give. Any backend that loads adapters must check the sha256 before load, read only safetensors (no torch.load or pickle), and accept URIs only under an allowlisted root. Until then, mark sha256 as unenforced in the docstring.

P2: other items

  • GET /healthz is unauthenticated and returns active_adapter_id and request counts. For a BYOC adapter, that leaks another tenant's adapter id and activity on a shared server.
  • Calibration collector: it writes only to a local JSONL under queue_root, sends nothing over the network, and is not wired in, so today it is off. When it gets wired in, it must be opt-in with an explicit consent setting that defaults off. Also, step_id allows :/ and 128 characters, adapter_id is not validated at all, and app and workflow slugs are free text. Any of these can carry a record id (for example patient/12345). Screenshot hashes are also stable identifiers for screens that contain PHI. The email, SSN and phone regexes cover only structural_metadata string values.
  • Claims: the collector docstring says calibration drives "unseen false-veto rates down after 10-25 real runs". No measurement supports this, so remove it. I found no other made-up metrics. The tests use all-same-digit hashes and stub logits, and they do not claim real model results.
  • Generality: the engine code names no apps. Adapters are declarative data (from_yaml uses yaml.safe_load). Good.
  • Protected paths: none of the six files matches any of the 48 path patterns in .github/agent-safety-manifest.json, so the protected-path evidence rule does not apply here. A cross-vendor review is still worth having for a module named "veto".
  • CI: checks were still pending when I reviewed. Please confirm that the flow test job picks up the three new test files.

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