diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..c096205 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,38 @@ +# Nothing secret or local may enter a build context. +# +# The Dockerfiles do not COPY .env — but a build context is uploaded to the +# daemon whole, and "the Dockerfile does not reference it" is not the same as +# "it was never sent". Signing keys, database passwords and bearer tokens all +# live in .env. + +.env +.env.* +!.env.example + +.git +.github +.gitignore +.gitattributes + +.venv +venv +__pycache__ +*.pyc +.pytest_cache +*.egg-info + +# Local output, none of which belongs in an image. +backups +evidence +sbom +check + +# The verified wheel is copied in explicitly by path; everything else in +# dist/ is downloaded release assets the image has no use for. +dist/* +!dist/remora-*.whl + +docs +README.md +*.md +!README.md diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 52b6d9a..0287def 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -48,7 +48,7 @@ jobs: pip install -e . - name: Contract, manifest agreement and import boundary - run: python -m pytest tests/compatibility -q + run: python run.py check vertical: name: The product, running @@ -72,11 +72,23 @@ jobs: run: python run.py scenarios - name: End-to-end, security and fault tests + # AAE_REQUIRE_LIVE is set by run.py: a skipped suite fails here + # rather than reporting green for tests that never ran. run: python run.py e2e - name: The signed ToolSpec bundle still verifies run: python run.py check-sign + - name: Inventory what shipped + run: python run.py sbom --out ./sbom + + - name: Publish the SBOM + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 + with: + name: sbom + path: sbom/ + if-no-files-found: error + - name: Diagnostics on failure if: failure() run: | @@ -86,4 +98,4 @@ jobs: - name: Tear down if: always() - run: python run.py down + run: python run.py reset diff --git a/.gitignore b/.gitignore index 3209afc..fc2bd6c 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,6 @@ __pycache__/ .env *.egg-info/ evidence/ +backups/ +sbom/ +toolpacks/work_order/tool_specs.signed.json diff --git a/Makefile b/Makefile deleted file mode 100644 index adb3aa7..0000000 --- a/Makefile +++ /dev/null @@ -1,71 +0,0 @@ -# Assured Agent Execution -# -# Every target delegates to run.py, so there is exactly one implementation. -# That is not tidiness: a shell version and a Python version drift, and the -# first person to notice is a new developer following a walkthrough that no -# longer matches what runs. -# -# `make` is not installed on a default Windows machine. If you do not have it: -# -# python run.py up -# python run.py scenarios -# -# is the same thing, and is what the documentation uses. - -PY ?= python - -.DEFAULT_GOAL := help -.PHONY: help up down build pin env deps sign check-sign verify compat e2e \ - scenarios doctor logs ps clean - -help: ## Show this help - @grep -hE '^[a-z-]+:.*?##' $(MAKEFILE_LIST) \ - | awk 'BEGIN{FS=":.*?## "}{printf " \033[36m%-12s\033[0m %s\n", $$1, $$2}' - -up: ## Verify the pin, generate secrets, sign, build, migrate, start - $(PY) run.py up - -down: ## Stop everything and remove the volumes - $(PY) run.py down - -build: ## Build both images from the verified wheel - $(PY) run.py build - -pin: ## Download and hash-verify the pinned REMORA core artifacts - $(PY) run.py pin - -env: ## Generate this installation's secrets (never overwrites) - $(PY) run.py env - -deps: ## Create the venv and install the SDK from the verified wheel - $(PY) run.py deps - -sign: ## Sign the ToolSpec bundle and pin its digest into .env - $(PY) run.py sign - -check-sign: ## Verify the signed bundle without re-signing it - $(PY) run.py check-sign - -verify: ## Everything: pin, contract tests, end-to-end tests - $(PY) run.py verify - -compat: ## Pinned-core contract tests (no Docker needed) - $(PY) run.py compat - -e2e: ## End-to-end tests against the running stack - $(PY) run.py e2e - -scenarios: ## Run the four decisions against the running stack - $(PY) run.py scenarios - -doctor: ## What is pinned, what is served, what is reachable - $(PY) run.py doctor - -logs: ## Follow the control plane log - $(PY) run.py logs - -ps: ## Show what is running - $(PY) run.py ps - -clean: ## Remove the venv and downloaded artifacts (keeps .env) - $(PY) run.py clean diff --git a/README.md b/README.md index c17627a..3d3e014 100644 --- a/README.md +++ b/README.md @@ -1,194 +1,180 @@ # Assured Agent Execution -**Deterministic governance and controlled execution for probabilistic AI agents** +**Controlled execution for AI-agent tool calls.** -Powered by REMORA. +Powered by [REMORA](https://github.com/darklordVirtual/REMORA-research). -> **Maturity:** `0.1.0-dev`, Gate C vertical. The product installs, runs and -> proves its own claims on one command. It is **not** production-ready: no -> external security review has run against it, the pinned core is a -> deliberate prerelease, and there is no signed image, SBOM or build -> provenance. See [Non-claims](#non-claims). +Assured Agent Execution (AAE) governs how AI agents interact with tools and +operational systems. -A governed proposal receives exactly one of four decisions — **ACCEPT**, -**VERIFY**, **ABSTAIN**, **ESCALATE**. AAE binds authorization to the exact -payload, dispatches through credentials the agent never holds, reads the -effect back on a credential that cannot write it, and exports a tamper-evident -record. +Every proposed tool call receives one of four decisions: -## Install +| Decision | Action | +| --- | --- | +| **ACCEPT** | Execute automatically | +| **VERIFY** | Require approval | +| **ABSTAIN** | Stop | +| **ESCALATE** | Route to a higher authority | -Requires Docker, Python 3.11+, and the GitHub CLI (`gh`, to fetch the pinned -core release). +AAE binds authorization to the exact tool call, separates approval from +execution, verifies selected effects against the system of record, and records +the complete execution lifecycle. + +## Architecture + +```mermaid +flowchart LR + A[AI agent or application] --> B[AAE control plane] + + R[Pinned REMORA core] --> B + T[Signed ToolPack] --> B + I[Authority source] --> B + + B --> D{Decision} + + D -->|ACCEPT| X[Execute] + D -->|VERIFY| V[Required approval] + D -->|ABSTAIN| S[Stop] + D -->|ESCALATE| H[Higher authority] + + V --> X + H --> V + + X --> O[System of record] + O --> P[Read-only effect verification] + + B --> E[Audit and evidence] + P --> E +``` + +## Core capabilities + +* Four-way decision routing +* Exact-payload approval binding +* Separate identities for proposing, approving and executing +* Deployment-controlled ToolSpecs +* Pinned and verified REMORA artifacts +* Read-only postcondition verification +* Replay-resistant execution grants +* Lifecycle and evidence export + +## Quickstart + +### Requirements + +* Docker with Docker Compose +* Python 3.11 or newer +* Authenticated GitHub CLI (`gh`) ```bash git clone https://github.com/darklordVirtual/assured-agent-execution cd assured-agent-execution -python run.py up # verify the pin, generate secrets, sign, build, migrate, start -python run.py scenarios # run the four decisions against what you just started + +python run.py up +python run.py scenarios ``` -`make up` / `make scenarios` do the same thing — the Makefile delegates to -`run.py`, so there is one implementation and it cannot drift from the -documentation. `make` is not installed on a default Windows machine, which is -why the commands above do not need it. +`python run.py up`: + +1. fetches and verifies the pinned REMORA artifacts; +2. creates installation-specific credentials; +3. signs the ToolPack; +4. builds the containers; +5. applies the database migrations; +6. starts the control plane and dashboard. + +The API and dashboard URLs are printed when startup completes. + +## Reference scenarios -There is nothing to fill in first. `python run.py up` generates this -installation's signing keys, database passwords and bearer tokens into `.env`, -so no two installs share a credential — not even two developers on the same -team. It also probes for free host ports rather than hardcoding 8080, and -prints the URLs it chose: +The included work-order ToolPack demonstrates the complete execution flow: +```text +ACCEPT Grounded read executes automatically +VERIFY Production write requires approval +ABSTAIN Unresolved authority stops the request +ESCALATE Destructive action requires senior authority +BINDING Approval cannot be reused for another payload +ROLES An approver cannot execute its own approval ``` - API http://localhost:8088 - Console http://localhost:8089 + +The main governed path is: + +```text +propose → assess → approve → execute → verify effect → record ``` -## What `python run.py scenarios` proves +To try to get past these controls yourself, see +[Attack the demo](docs/tutorials/attack-the-demo.md). + +## REMORA integration +AAE consumes a versioned REMORA release through pinned artifacts: + +* REMORA wheel +* release manifest +* OpenAPI specification +* public SDK contract +* execution lifecycle schema +* ToolSpec schema +* postcondition schema + +The active release is defined in: + +```text +product/core-artifact-lock.json ``` -[PASS] ACCEPT: grounded read under signed WO-1201 - assess → accept (grounded_read_accept) - execute_accepted → execute - replay refused → ReplayRefusedError - -[PASS] VERIFY: close WO-1202 under signed authority - assess → verify (evidence_insufficient) - agent token refused approval (correct) - domain_expert approved → approved - execute → execute - EFFECT_VERIFIED — the system of record shows the approved delta - record_effect → EFFECT_VERIFIED in the chain - -[PASS] ABSTAIN: read under an authority that does not resolve -[PASS] ESCALATE: purge work-order history → required_role=senior_authority -[PASS] BINDING: approve one payload, execute another → binding_refused -[PASS] ROLES: the approver cannot execute + +Every artifact is verified before installation and use. + +## Repository structure + +```text +src/aae/ CLI, configuration, evidence and verification +toolpacks/work_order/ Reference ToolPack +db/workorders/ Example system-of-record schema +console/ Local demonstration dashboard +docker/ Container definitions +product/ Pinned REMORA artifacts and metadata +tests/compatibility/ Core compatibility tests +tests/e2e/ Execution and security tests +docs/ Architecture, security model and operations ``` -Read the VERIFY trace closely, because it is the whole product in six lines: a -production write was held; the agent that proposed it was refused the right to -approve it; the identity the *decision* named — not a generic approver — -released it; the operator executed; and a separate process holding a -`SELECT`-only credential went and looked at the database to confirm the -approved change had actually happened. - -## What each boundary buys - -| Boundary | What it prevents | -|---|---| -| Risk classification lives in `tool_metadata.json`, hashed into REMORA's policy identity | A tool cannot classify itself, and relabelling one invalidates every execution lease issued before the relabel | -| Work-order authority is resolved **server-side** from a file the deployment controls | The agent names which authority it acts under and can never assert that the authority exists or says what it claims | -| ToolSpec bundle signed with a deployment key (`python run.py sign`) | Argument schemas, allowed targets and credential scopes cannot be edited by the thing they constrain — and the **pinned digest** refuses a correctly-signed *older* bundle, because a signature proves authenticity, never currency | -| Approval is bound to the exact tool-call hash | Getting a yes for one payload and executing another — the realistic attack on human-in-the-loop, which is never "bypass the human" | -| `operator` / `reviewer` / `domain_expert` / `senior_authority` / `viewer`, none of them `admin` | One credential that can both approve and execute makes every other control decorative | -| The postcondition reader holds `SELECT` and nothing else | A verifier that could write the state it verifies is reporting on itself | -| `EFFECT_UNOBSERVABLE` / `EFFECT_VERIFIER_FAILED` are non-terminal; only `EFFECT_MISMATCH` is | "We could not look" is not "it was wrong". Collapsing them would close incidents that are still open, or open incidents for actions that succeeded | - -## The dependency direction - -AAE consumes versioned REMORA artifacts. It never installs from -`REMORA-research/master` and never imports `remora.policy`, -`remora.enforcement`, `remora.governance` or `servers`. - -The control plane **is** REMORA's governance API, installed from the pinned -wheel and run as a service. `servers/` and `schemas/` ship inside that wheel, -so running it is *deploying* the core, not importing it — and -`tests/compatibility` enforces that no AAE source file crosses the line. - -This repository pins release -[`core-candidate-2026.08.06.3`](https://github.com/darklordVirtual/REMORA-research/releases/tag/core-candidate-2026.08.06.3), -built from a clean checkout of `aff4edf`: - -| Artifact | Pinned by | -|---|---| -| `remora-0.10.0-py3-none-any.whl` | SHA-256 | -| `core-release-manifest.json` | SHA-256 | -| `openapi.json` | SHA-256 | -| `public_api_v1.json` (36 SDK symbols) | SHA-256 | -| `execution_lifecycle_v1.yaml` | SHA-256 | -| `tool_spec_v1.yaml` | SHA-256 | -| `postcondition_contract_v1.yaml` | SHA-256 | - -`scripts/verify_core_pin.py` downloads them and **refuses on any hash -mismatch** — a pin nobody verifies is a comment, not a control. It also -verifies the copy checked into this tree, because verifying only the download -left the in-tree manifest free to rot, and it did for two pin bumps. - -`tests/compatibility/test_pin_manifest_agreement.py` then compares the -hand-written lock against the release-generated manifest field by field, so -the two cannot disagree silently again. - -One dependency is *not* on the stable namespace and is not hidden: -`toolpacks/work_order/bundle.py` imports nine types from `remora.toolcall.*` -to declare what this deployment's tools mean, because no equivalent exists in -`remora.sdk`. `test_toolpack_authoring_surface.py` pins the exact symbols and -constructor keywords, and its last test asserts `remora.sdk` does not yet -offer them — when that test fails, it is the signal to move the imports. - -## Verify it yourself +## Commands ```bash -python run.py verify # pin + 71 contract tests + 55 end-to-end tests -python run.py check-sign # verify the signed ToolSpec bundle without re-signing -python run.py doctor # what is pinned, what is served, what is reachable +python run.py up # Start the stack +python run.py scenarios # Run the reference scenarios +python run.py doctor # Inspect the deployment +python run.py check-sign # Verify the ToolPack +python run.py check # Contract tests, no Docker required +python run.py verify # Contract and end-to-end tests +python run.py down # Stop the stack +python run.py reset # Stop and remove all volumes ``` -The end-to-end suite includes `tests/e2e/test_toolspec.py`, which takes the -bundle this deployment actually runs and attacks it — widening allowed -targets, rewriting the description an agent reads, escalating credential -scope, reclassifying a destructive tool as routine, presenting a revoked -signer, and presenting a correctly-signed older bundle. Every one is refused. +`backup`, `restore`, `sbom`, `sign` and `reseed` are documented in +[Operations](docs/operations.md). ## Documentation -- [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) — what runs where, and why each - boundary is where it is -- [docs/ONBOARDING.md](docs/ONBOARDING.md) — install, run and verify in 30 - minutes without reading the research repository -- [docs/OPERATIONS.md](docs/OPERATIONS.md) — signing, rotation, evidence - export, and what to do when an effect does not verify - -## Known gaps - -Stated here rather than discovered later. - -- **A fully grounded medium-risk mutation abstains.** It falls through every - rule to `default_safe_abstain`: no review item, no `ResolutionPlan`, no path - an approver could take, for an action a signed work order authorizes. High - risk hits `evidence_insufficient`; ungrounded arguments hit their own rule; - medium-and-grounded matches neither, so declaring a risk tier leaves a tool - *worse off* than leaving it unknown. Raised upstream. -- **`callable_digest` is recorded, not enforced.** `ToolSpecBundle.verify_callable` - exists in REMORA 0.10.0 and nothing calls it at dispatch. AAE computes the - real source digest and a test asserts it matches, so the field is true — but - until core wires the check, a swapped callable is caught by the policy bundle - hash over the module source, not by the spec. -- **HMAC signing is symmetric.** The process that verifies the ToolSpec bundle - holds the key that signs it. "The agent cannot sign its own spec" is only as - strong as the agent's inability to read the control plane's environment. The - frozen contract defers asymmetric signing to v2. -- **Tools run in the control-plane process.** `GovernedToolDispatcher` holds - the callables, so the credential separation that exists is at the *database* - (writer vs reader), not at a process boundary. A credential-isolated worker - needs a remote dispatch boundary REMORA does not yet have. -- **Effect verification covers tools that declare a reader.** A tool without - one reports `EFFECT_UNSUPPORTED`, recorded so the absence is visible — that - is not a verified effect. -- No OIDC, no backup/restore procedure, no external review, no signed image, - no SBOM, no build provenance. +* [Architecture](docs/architecture.md) — components, data flow and boundaries +* [Security model](docs/security-model.md) — what is enforced, and by what +* [Limitations](docs/limitations.md) — known gaps +* [Operations](docs/operations.md) — signing, backup, evidence and upgrades +* [Attack the demo](docs/tutorials/attack-the-demo.md) — try to get past the controls +* [Decision records](docs/adr/) — why the architecture is the way it is ## Non-claims AAE does not claim that agents are always correct, that all tools can be -effect-verified, that safety is guaranteed, or that bypass remains impossible -when agents retain direct tool credentials. +effect-verified, that safety is guaranteed, or that bypass is impossible when +an agent retains direct tool credentials. ## License -Source-available under Business Source License 1.1. Commercial production use -requires separate written terms. See [LICENSING.md](LICENSING.md). +Source-available under the Business Source License 1.1. -The pinned REMORA core is a **separate** Licensed Work under its own copy of -the same license: an AAE license grants nothing in REMORA, and vice versa. A -deployment runs both and needs to be permitted under both. +See [LICENSING.md](LICENSING.md) for permitted use and commercial terms. The +pinned REMORA core is a separate Licensed Work under the same licensor. diff --git a/console/app.py b/console/app.py index 773d7fa..7049e9a 100644 --- a/console/app.py +++ b/console/app.py @@ -7,9 +7,18 @@ about the demonstration surface can change the behaviour of the system being demonstrated. It holds no policy and makes no decisions. -It holds the demo bearer tokens because this is a local product install. A -real deployment puts an identity provider here instead, and the page says so -rather than leaving you to assume otherwise. +It is **read-only**, and holds exactly one credential: the `viewer` token, +whose role grants `read` and nothing else. It cannot propose, approve or +execute, and there is no endpoint here that writes anything. + +That was not true of the first version. It held all five tokens — including +`domain_expert` and `senior_authority` — and exposed an unauthenticated POST +that ran the scenarios, which perform real writes under those roles. A +presentation surface with an approver credential is a high-value target +wearing a low-value label. + +Running the scenarios is a CLI action (`python run.py scenarios`), which is +where a privileged credential belongs. What it shows, and why each panel is on it: @@ -27,8 +36,6 @@ import json import os -import subprocess -import sys from typing import Any import httpx @@ -36,19 +43,19 @@ from fastapi.responses import HTMLResponse, JSONResponse API = os.environ.get("AAE_API_URL", "http://control-plane:8000") -TOKENS = { - "operator": os.environ.get("AAE_TOKEN_AGENT", ""), - "viewer": os.environ.get("AAE_TOKEN_VIEWER", ""), -} +#: One credential, read-only. Anything this console cannot do with `viewer` +#: is something it should not be doing. +VIEWER_TOKEN = os.environ.get("AAE_TOKEN_VIEWER", "") READER_DSN = os.environ.get("AAE_WORKORDER_READER_DSN", "") app = FastAPI(title="AAE Operator Console", docs_url=None, redoc_url=None) -def _get(path: str, role: str = "viewer") -> tuple[int, Any]: +def _get(path: str) -> tuple[int, Any]: try: - response = httpx.get(f"{API}{path}", timeout=15, - headers={"Authorization": f"Bearer {TOKENS[role]}"}) + response = httpx.get( + f"{API}{path}", timeout=15, + headers={"Authorization": f"Bearer {VIEWER_TOKEN}"}) return response.status_code, response.json() except Exception as exc: # noqa: BLE001 return 0, {"error": f"{type(exc).__name__}: {exc}"} @@ -59,7 +66,7 @@ def posture() -> JSONResponse: """Everything that decides whether the activity below means anything.""" status, root = _get("/") _, health = _get("/v1/health") - chain_status, chain = _get("/v1/execution/audit/verify", role="operator") + chain_status, chain = _get("/v1/execution/audit/verify") lock: dict[str, Any] = {} try: @@ -101,7 +108,7 @@ def work_orders() -> JSONResponse: from psycopg.rows import dict_row with psycopg.connect(READER_DSN, row_factory=dict_row, - connect_timeout=5) as conn: + connect_timeout=5, autocommit=True) as conn: conn.read_only = True with conn.cursor() as cur: cur.execute( @@ -125,27 +132,6 @@ def clean(row: dict) -> dict: "events": [clean(r) for r in events]}) -@app.post("/api/scenarios") -def run_scenarios() -> JSONResponse: - """Run the same scenarios `aae scenarios` runs. - - Shells out to the product CLI rather than reimplementing them. A console - with its own copy of the scenarios could show green while the CLI showed - red, and then nobody would know which one described the product. - """ - try: - completed = subprocess.run( - [sys.executable, "-m", "aae.cli", "scenarios"], - capture_output=True, text=True, timeout=180) - except subprocess.TimeoutExpired: - return JSONResponse({"error": "scenario run exceeded 180s"}, - status_code=504) - return JSONResponse({ - "exit_code": completed.returncode, - "output": completed.stdout or completed.stderr, - }) - - _PAGE = """ Assured Agent Execution — Operator Console