|
| 1 | +# Airlock Protocol — CLAUDE.md |
| 2 | + |
| 3 | +## What is this project? |
| 4 | +Airlock Protocol — "DMARC for AI Agents". An open trust verification protocol for autonomous AI agents. |
| 5 | +Ed25519 cryptography, DID identifiers, 5-phase verification, live registry at api.airlock.ing. |
| 6 | + |
| 7 | +## Tech Stack |
| 8 | +- **Language:** Python 3.11+ |
| 9 | +- **Framework:** FastAPI + Uvicorn |
| 10 | +- **Orchestration:** LangGraph |
| 11 | +- **Crypto:** PyNaCl (Ed25519) |
| 12 | +- **DB:** LanceDB (vector), optional Redis |
| 13 | +- **LLM:** LiteLLM (multi-provider) |
| 14 | +- **Tests:** pytest + pytest-asyncio + hypothesis |
| 15 | + |
| 16 | +## Running Tests |
| 17 | +```bash |
| 18 | +pytest # run all tests |
| 19 | +pytest tests/ -x # stop on first failure |
| 20 | +pytest tests/test_crypto.py # single file |
| 21 | +pytest -k "test_verify" # by name pattern |
| 22 | +pytest --cov=airlock # with coverage |
| 23 | +``` |
| 24 | + |
| 25 | +## Running the Gateway |
| 26 | +```bash |
| 27 | +uvicorn airlock.gateway.app:create_app --factory --port 8000 --reload |
| 28 | +``` |
| 29 | + |
| 30 | +## Project Structure |
| 31 | +``` |
| 32 | +airlock/ |
| 33 | + a2a/ — Agent-to-Agent adapter |
| 34 | + audit/ — Audit trail |
| 35 | + crypto/ — Keys, signing, verifiable credentials |
| 36 | + engine/ — Orchestrator, event bus, state machine |
| 37 | + gateway/ — FastAPI routes and handlers |
| 38 | + integrations/ — Anthropic, LangChain, OpenAI SDKs |
| 39 | + registry/ — Agent registry and store |
| 40 | + reputation/ — Trust scoring and decay |
| 41 | + schemas/ — Pydantic models |
| 42 | + sdk/ — Client SDK and middleware |
| 43 | + semantic/ — Challenge evaluation + rule engine |
| 44 | +tests/ — 27 test files, 198+ tests |
| 45 | +``` |
| 46 | + |
| 47 | +## Conventions |
| 48 | +- **Type hints:** Always use type hints. MyPy strict mode is enabled. |
| 49 | +- **Linting:** Ruff. Run `ruff check .` before committing. |
| 50 | +- **Async:** Use async/await for all I/O operations. pytest-asyncio with `asyncio_mode = "auto"`. |
| 51 | +- **Pydantic:** Use Pydantic v2 models for all data schemas. No raw dicts for structured data. |
| 52 | +- **Error handling:** All API errors must return structured JSON with `error`, `detail`, and `status_code` fields. |
| 53 | +- **Tests:** Every new feature needs tests. Use `fakeredis` for Redis tests, `asgi-lifespan` for gateway tests. |
| 54 | +- **Imports:** Use absolute imports (`from airlock.crypto.keys import ...`), never relative. |
| 55 | +- **No print():** Use `logging` module. Never print() in library code. |
| 56 | +- **DID format:** Always validate DID strings match `did:key:z6Mk...` pattern before processing. |
| 57 | +- **Secrets:** Never log or expose private keys, challenge secrets, or JWT tokens. |
| 58 | + |
| 59 | +## Common Mistakes to Avoid |
| 60 | +- Don't use `json.dumps()` for Pydantic models — use `model.model_dump_json()` |
| 61 | +- Don't forget `await` on async functions — this causes silent failures |
| 62 | +- Don't hardcode ports — use config.py |
| 63 | +- Don't skip input validation on DID strings — always validate format |
| 64 | +- Don't use `datetime.now()` — use `datetime.utcnow()` or `datetime.now(UTC)` for consistency |
| 65 | +- Don't create test files outside of `tests/` directory |
| 66 | +- Don't import from `airlock.gateway` in core modules — gateway depends on core, not the reverse |
| 67 | + |
| 68 | +## Architecture Rules |
| 69 | +- Gateway layer → Engine layer → Crypto/Registry/Reputation layers |
| 70 | +- No circular dependencies between modules |
| 71 | +- All events go through the EventBus — no direct cross-module calls |
| 72 | +- Orchestrator uses LangGraph state machine — don't bypass the graph |
0 commit comments