# Interface AI Computer-Use Automation A compact production-oriented vertical slice for learning a browser workflow with a real LLM, compiling it into a typed capability, and replaying it deterministically without any model dependency. This repository is the complete submission for Interface AI's **Assignment A — Computer-Use Automation System**. The required design write-up is in [`REPORT.md`](REPORT.md), and the checked-in run evidence is indexed in [`evidence/README.md`](evidence/README.md). The demo targets a deliberately awkward, server-rendered credit-union application. It demonstrates parameterized replay, artifact-defined outputs, business outcomes, bounded recovery, policy enforcement, same-session human handoff, evidence redaction, artifact approval/integrity, and multi-run reliability reporting. ## Architecture ```text goal + input -> LLM discovery -> typed trace -> deterministic compiler | v caller <- structured result <- zero-LLM replay <- approved artifact | | policy ControlLease <-> human operator ``` Playwright is isolated behind `SurfaceAdapter`. The replay package imports neither the discovery package nor an LLM SDK. ## Setup Requires Python 3.10+, Chromium, and an Anthropic key only for live discovery. ```bash python3 -m venv .venv source .venv/bin/activate pip install -e '.[dev]' playwright install chromium cp .env.example .env # Edit .env and set ANTHROPIC_API_KEY. ``` `ANTHROPIC_MODEL` and `BROWSER_EXECUTABLE` are optional overrides. `.env` is ignored. Never commit a real model key. ## Offline replay demo Replay requires no model or API key. This command starts the local target and executes the checked-in artifact for success, not-found, and permission-denied: ```bash .venv/bin/pytest tests/test_replay_e2e.py -s ``` Expected result: Alice's balance is returned for `12345`, while `00000` returns `MEMBER_NOT_FOUND` and `ADMIN01` returns `PERMISSION_DENIED`—neither is reported as an automation crash. ## Live discovery and complete evidence demo This is the exact end-to-end path: start the mock app, run the real Anthropic observe/decide/act loop, compile and approve the resulting artifact, replay it with new input, exercise two business outcomes, perform same-context human handoff, and run five stability replays. ```bash .venv/bin/python scripts/generate_evidence.py ``` Outputs are written to `evidence/`: - `01_discovery_success`: redacted model trace, draft artifact, approved artifact - `02_replay_different_input`: successful replay using a different member - `03_replay_unknown_member`: `MEMBER_NOT_FOUND` - `04_replay_permission_denied`: `PERMISSION_DENIED` - `05_same_session_handoff`: intervention, lease transfer, human action, resume - `06_multi_run_stability`: five-run reliability report - `07_replay_transient_recovery`: real postcondition failure and bounded retry ## Exact discover → replay CLI demo The two production paths can also be invoked separately. Start the local target in one terminal: ```bash source .venv/bin/activate flask --app src.target.legacy_app run --port 5001 ``` Run real LLM discovery in a second terminal. This accepts the goal and target as separate inputs, saves the redacted trace, compiles the artifact, and explicitly approves it for unattended replay: ```bash source .venv/bin/activate capability-engine discover \ --goal "Look up member 12345 and extract member_name and savings_balance" \ --target "http://localhost:5001/member/search" \ --inputs '{"member_id":"12345"}' \ --outputs '{"member_name":{"type":"string","description":"Member name","sensitive":true},"savings_balance":{"type":"string","description":"Savings balance","sensitive":true}}' \ --artifact-id member-savings-balance-v1 \ --name "Member savings balance" \ --target-app legacy-cu-core \ --artifact-out capabilities/member-savings-balance.json \ --approve ``` Replay that exact artifact with different input. This command never imports or calls the LLM client: ```bash capability-engine replay \ --artifact capabilities/member-savings-balance.json \ --inputs '{"member_id":"67890"}' \ --evidence-dir evidence/cli_replay ``` ## Development checks ```bash .venv/bin/pytest .venv/bin/ruff check src tests scripts ``` Tests cover CLI contracts, compiler parameterization, output contracts, policy, redaction, approval integrity, reliability aggregation, bounded recovery, same-surface handoff, and browser E2E behavior. ## Submission verification Before publishing, run: ```bash .venv/bin/pytest .venv/bin/ruff check src tests scripts git status --short --ignored ``` Only source, tests, documentation, and redacted evidence should be tracked. `.env`, virtual environments, caches, bytecode, coverage output, packaging metadata, and OS files are ignored. ## Safety defaults Actions and domains are allowlisted. High-risk actions are blocked or require a human confirmation. Discovery inputs use symbolic tokens in prompts/traces. Sensitive JSON fields are redacted, configured page regions are masked in screenshots, DOM snapshots are sanitized, and accessibility evidence is withheld when sensitive selectors are present. Production raw evidence would additionally require encrypted storage, access controls, and retention policies.