# governed-computer-use — computer-use capabilities with a model-risk lifecycle An LLM **discovers** a back-office flow in a legacy banking UI once. Code **records** it as a typed, versioned artifact, **replays** it deterministically with no model in the loop, **escalates** to a human who takes over the *same* live session, and governs every capability the way a bank governs a model: draft → validated → approved → suspended / retired. - **[REPORT.md](REPORT.md)**: design write-up (architecture, schema, determinism, multi-tenant, handoff, safety, cuts) - **[evidence/](evidence/README.md)**: real runs (LLM discovery, harvesting, validation, replays, handoff, second tenant) - **[docs/decisions/](docs/decisions)**: ADR 0001–0009 · **[docs/findings-from-real-runs.md](docs/findings-from-real-runs.md)**: F1–F11, what broke and how it was fixed The target is *LegacyCore*, a fictional core-banking app included here (frames, layout tables, no element IDs), with two tenants and injectable faults. All data is fictional. ## Setup (macOS / Linux, Python 3.10+) ```bash python3 -m venv .venv && source .venv/bin/activate pip install -r requirements.txt python -m playwright install chromium cp .env.example .env # demo operator credentials are prefilled; an API key is only needed for discovery/harvest/overlay-draft ``` ## 5-minute demo: the production path (no API key needed) The repo ships the approved capability (`artifacts/reverse_fee.v0.3.2.yaml`) and Globex's approved overlay. ```bash # Terminal 1 python -m target_app --tenant acme --port 5001 # Terminal 2 ACME="--artifact artifacts/reverse_fee.v0.3.2.yaml --policy policies/acme.yaml --tenant acme --base-url http://127.0.0.1:5001" FEE="--input account_suffix=D10 --input fee_date=2026-09-12 --input reason_code=COURTESY" python -m cua replay $ACME $FEE --input member_id=100234 --input fee_amount=30.00 # SUCCESS FR-104312 python -m cua replay $ACME $FEE --input member_id=100239 --input fee_amount=30.00 # BUSINESS_OUTCOME ACCOUNT_ON_HOLD (hold type redacted) python -m cua replay $ACME $FEE --input member_id=100236 --input fee_amount=39.00 --interactive # over $35 authority: you approve as supervisor python -m cua replay $ACME $FEE --input member_id=100245 --input fee_amount=30.00 # two identical fees: FAILED AMBIGUOUS_TARGET (never guesses) ``` Restart the app to reset its data. Faults can be injected, e.g. `--faults broadcast,slow=1.5`, `--faults record_locked=1`, `--faults app_error`. **Human handoff:** start the app with `--faults password_notice`, add `--handoff --operator --headed` to a replay, clear the unknown notice in the browser and press **Return control** (details below). **Second tenant:** `python -m target_app --tenant globex --port 5002`, then replay with `--overlay overlays/reverse_fee/globex.yaml --policy policies/globex.yaml --tenant globex --base-url http://127.0.0.1:5002`. ## Discovery (real LLM run, needs `ANTHROPIC_API_KEY` in `.env`) ```bash python -m target_app --tenant acme --port 5001 # terminal 1 python -m cua discover --spec specs/reverse_fee.spec.yaml --policy policies/acme.yaml \ --tenant acme --base-url http://127.0.0.1:5001 --app-version 4.2.1 --headed --slow-mo 300 ``` When the agent reaches **Post** (a money-moving step) it pauses for your approval (ADR 0005). Output goes to `runs//`: a redacted event log, blurred screenshots, the recorded draft artifact and review notes. `evidence/01-discovery` is such a run. ## Full lifecycle (how the shipped artifacts were produced) The recorded artifact is a **draft**. It becomes production-ready the way a model does at a bank: ```bash A=runs//reverse_fee.draft.yaml # or evidence/01-discovery/reverse_fee.draft.yaml COMMON="--policy policies/acme.yaml --tenant acme --base-url http://127.0.0.1:5001" # 1) Outcome harvesting: replay the draft against the scenario matrix; an LLM PROPOSES how to # handle each unknown screen, code validates the proposal, YOU approve each one in the terminal. python -m cua harvest --artifact $A $COMMON --scenarios specs/reverse_fee.scenarios.yaml --out artifacts/reverse_fee.v0.2.0.yaml # 2) Validation: run all scenarios N times; 100% pass promotes draft -> validated, report written python -m cua validate --artifact artifacts/reverse_fee.v0.2.0.yaml $COMMON --scenarios specs/reverse_fee.scenarios.yaml --repeats 3 # 2b) Reviewer edits, if needed (audited; new patch version; back to draft -> re-validate) python -m cua review --artifact artifacts/reverse_fee.v0.3.0.yaml --by \ --reason "" --certify-not-applied --remove-screen # 3) Approval (human sign-off; sets annual re-validation date) python -m cua approve --artifact artifacts/reverse_fee.v0.2.0.yaml --by --role model_risk_validator # 4) Production path: deterministic replay, no LLM python -m cua replay --artifact artifacts/reverse_fee.v0.2.0.yaml $COMMON \ --input member_id=100234 --input account_suffix=D10 --input fee_date=2026-09-12 \ --input fee_amount=30.00 --input reason_code=COURTESY ``` Add `--interactive` to `replay` to approve policy escalations (e.g. member 100235 / 100236) in the terminal. Restart the target app between runs that post a reversal. ## Human handoff (same live session) ```bash # Terminal 1: an interruption no artifact has seen python -m target_app --tenant acme --port 5001 --faults password_notice # Terminal 2: replay with handoff enabled (headed so you can take over) python -m cua replay --artifact artifacts/reverse_fee.v0.3.1.yaml --policy policies/acme.yaml \ --tenant acme --base-url http://127.0.0.1:5001 --handoff --operator --headed \ --input member_id=100234 --input account_suffix=D10 --input fee_date=2026-09-12 \ --input fee_amount=30.00 --input reason_code=COURTESY ``` The banner turns green when you hold control: clear the notice in the page, then press **Return control** — replay re-syncs by screen and finishes. While the banner is red the automation holds the lease and your clicks are blocked (use **Request takeover**). ## A second tenant (Globex): overlay drafted by the LLM, approved per tenant Globex runs the same LegacyCore product (4.3.0) with different captions, labels, reason codes and column order. The approved Acme capability fails safely there (`UNEXPECTED_SCREEN`, nothing posted). Instead of re-discovering, we draft a **tenant overlay** (ADR 0009): ```bash # 0. one-time, non-material change (F10): code proves 0.3.2 is render-equivalent to 0.3.1 python -m cua review --artifact artifacts/reverse_fee.v0.3.1.yaml --templatize-fingerprints \ --by MAK --reason "fingerprint captions become tenant vocabulary (F10)" # 1. Globex test app (second terminal) python -m target_app --tenant globex --port 5002 # 2. the model proposes Globex wording for each gap, code verifies it on the live screen, you approve python -m cua overlay-draft --artifact artifacts/reverse_fee.v0.3.2.yaml --policy policies/globex.yaml \ --tenant globex --base-url http://127.0.0.1:5002 --tenant-from Acme --app-version 4.3.0 # 2b. if the draft report lists OPEN GAPS (e.g. a reason code with no equivalent), decide each one: # declare it unsupported (requests with it are rejected up front) — approval is blocked until you do python -m cua overlay-edit --artifact artifacts/reverse_fee.v0.3.2.yaml --overlay overlays/reverse_fee/globex.yaml \ --unsupported reason_code:SERVICE_DISRUPTION --by MAK --reason "Globex offers no service-disruption reason code" # 3. validate on Globex's own scenario matrix, then approve for Globex only python -m cua validate --artifact artifacts/reverse_fee.v0.3.2.yaml --overlay overlays/reverse_fee/globex.yaml \ --policy policies/globex.yaml --tenant globex --base-url http://127.0.0.1:5002 \ --scenarios specs/reverse_fee.scenarios.yaml --repeats 3 python -m cua approve --artifact artifacts/reverse_fee.v0.3.2.yaml --overlay overlays/reverse_fee/globex.yaml \ --by MAK --role model_risk_validator # 4. production replay on Globex (effective version 0.3.2+globex.1) python -m cua replay --artifact artifacts/reverse_fee.v0.3.2.yaml --overlay overlays/reverse_fee/globex.yaml \ --policy policies/globex.yaml --tenant globex --base-url http://127.0.0.1:5002 \ --input member_id=100234 --input account_suffix=D10 --input fee_date=2026-09-12 \ --input fee_amount=30.00 --input reason_code=COURTESY ``` The overlay can change only wording (`vocab`, code-list texts), never steps, screens, outcomes or risk; it is pinned to the base's version and content hash, and can never be more trusted than its base. ## Tests ```bash python -m pytest -q # 75 tests, ~13 min; real browser + real app; the model is scripted for determinism ``` ## Repository map | Path | What | |---|---| | `target_app/` | LegacyCore: Flask app, tenants (acme 4.2.1, globex 4.3.0), seed members, fault injection | | `cua/surface/` | Playwright surface: accessibility snapshot, layout labels, table context, verified screenshot blur | | `cua/discovery/` | Discovery agent (LLM tools, human gate), recorder (derives the artifact) | | `cua/replay/` | Deterministic engine: classify, locate, act, recover, gate, result contract | | `cua/harvest.py`, `cua/overlay.py` | LLM-proposes / code-verifies / human-approves loops for outcomes and tenant overlays | | `cua/lifecycle.py`, `cua/registry.py` | Validation, approval, audited changes (materiality), circuit breaker | | `cua/handoff.py` | Control lease, in-page input lock, human action recording | | `cua/safety/` | Redaction, allowlist guard, authority policy | | `cua/schema/` | Capability, overlay, policy and result schemas | | `artifacts/`, `overlays/`, `policies/`, `specs/` | Capability versions, tenant overlays, tenant policies, task spec and scenario matrix |