AISOCin‑a‑box

Getting Started

Run the whole AISOC in-a-box reference stack on one machine in about ten minutes: the edge Box (Vector + Elasticsearch), the cloud control plane (the control-plane API — FastAPI, PostgreSQL with RLS, OPA HITL gate, hash-chained audit — and the agent orchestrator — the LangGraph triage runtime), the minimal portal — and this docs site.

Hard rule of the reference deploy: every host binding is 127.0.0.1. The only exposure point is tailscale serve, which puts the portal and the docs on your tailnet and nowhere else.

Prerequisites

  • Docker with the docker compose plugin
  • bash, openssl (for one-off secret generation)
  • Optional, for tailnet access: tailscale ≥ 1.60 logged in to your tailnet
  • Optional, for rebuilding this site: Node.js ≥ 20 and a Chrome binary for mermaid SVG rendering

1. Bring up the stack

# clone from the Gitea origin on the tailnet (see `git remote -v` in your rig):
git clone http://lukeserver.tailb90ec0.ts.net:3000/luke/aisocinabox.git
cd aisocinabox/deploy/compose
./up.sh

up.sh copies .env.example → .env with fresh secrets on first run, pulls images (Elastic images are pulled as customer-managed artifacts — the repo redistributes no Elastic license), builds the orchestrator and portal, and starts everything with 127.0.0.1 bindings:

Service Loopback port What
control-plane API 8117 REST control plane (/healthz, cases, approvals, ES|QL, fleet, audit mirror) — RLS-bound
agent-orchestrator 8130 triage graph + OPA gate + audit chains (/healthz, /v1/status/{id}, /v1/audit/{t}/chain)
opa 8118 HITL policy decisions (§3.3)
portal 8119 web shell
docs-site 8121 this site (marketing + architecture + developer docs + API console)
vector webhook 8120 edge ingest (edr_webhook)
vector metrics 9590 Vector self-observability (Prometheus)
elasticsearch 9200 edge log store
postgres 54330 control-plane ledger (RLS)

Sanity check (the thin :8117/healthz is liveness; the rich health — OPA bundle sha, pg: true, per-tenant audit-chain verification — is on the orchestrator at :8130):

curl -s http://127.0.0.1:8130/healthz | python3 -m json.tool

You should see "status": "ok", the OPA bundle sha, pg: true, and the audit-chain verification state.

2. First API call

The reference stack exposes a small, real slice of the §4.5 contract. Push an AlertMetadataPush-shaped alert and watch the triage graph run. The body is the alert's fields at top level (a nested "alert" wrapper silently loses the ecs block); the reference stack authenticates by header — the edge presents the tenant credential, not a user session:

curl -s -X POST http://127.0.0.1:8117/api/alerts/ingest \
  -H 'Content-Type: application/json' \
  -H 'X-Tenant-Id: tnt_acme_01' \
  -H 'X-Actor-Subject: edge-agent' \
  -d '{
    "edge_id": "edge-ref-0001",
    "local_alert_id": "getting-started-0001",
    "trigger": {"type": "edr_rule", "rule_id": "T1489-ransomware-staging",
                "severity": "high"},
    "ecs": {"event": {"kind": "alert", "category": ["intrusion"],
                      "original": "HIGHBLAST"},
             "user": {"name": "svc-backup"},
             "host": {"hostname": "WS-ACME-0421"},
             "process": {"name": "vssadmin.exe",
                         "parent": {"name": "powershell.exe"}}},
    "asset": {"criticality": "high"}
  }' | python3 -m json.tool

The response is {alert_id, case_id, triage} — the run view is nested under triage. A high-blast-radius host_isolate proposal suspends at the HITL gate (triage.state = "awaiting_approval", with triage.interrupt carrying the request_id). It is synchronous: a run can take up to ~180 s. Re-pushing the same local_alert_id is a no-op ("deduped": true).

Resolve the suspended proposal through the approval ledger — not the orchestrator's raw resume (the ledger writes the accountability row, then resumes the graph, then re-syncs the PG case state). First find the approval id, then decide:

# find the pending approval id (analyst headers):
curl -s http://127.0.0.1:8117/api/approvals \
  -H 'X-Tenant-Id: tnt_acme_01' -H 'X-Actor-Subject: analyst:m.reyes' \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["items"][0]["id"])'

# approve (mfa_verified must be literally true — D-V1; justification mandatory):
curl -s -X POST http://127.0.0.1:8117/api/approvals/<approval_id>/decision \
  -H 'Content-Type: application/json' \
  -H 'X-Tenant-Id: tnt_acme_01' \
  -H 'X-Actor-Subject: analyst:m.reyes' \
  -d '{"decision": "approve",
       "justification": "verified credential abuse on WS-ACME-0421",
       "mfa_verified": true}'

An approve lands the PG case as contained with the action executed; a deny lands it as escalated. (The same two buttons exist on the portal's case page, which calls this same endpoint.)

Then watch it all land in the tamper-evident ledger — the chain lives on the orchestrator, and its events use event_type:

curl -s http://127.0.0.1:8130/v1/audit/tnt_acme_01/chain | \
  python3 -c 'import json,sys; d=json.load(sys.stdin); print(d["verification"]); [print(e["seq"], e["event_type"]) for e in d["events"][-6:]]'

verification is {ok, count, head_hash} — the chain re-verified on read. A cross-tenant read (/v1/audit/tnt_globex_02 shows that tenant's chain only) and cross-tenant case reads return structurally empty / 404-identical — RLS plus writer binding, not an application if (multi-tenancy.md).

1.5 Tenant provisioning + edge simulator (the developer onboarding flow)

The Phase E flow is sign up → get tenant → configure edge sim → see first alert, all by API. A platform admin provisions a tenant in one call:

curl -s -X POST http://127.0.0.1:8117/api/tenants/provision \
  -H 'content-type: application/json' \
  -H 'x-actor-subject: platform:ops' \
  -d '{"name": "Dev Onboarding Co", "admin_email": "[email protected]"}'

The response is everything a new tenant needs, exactly once:

{
  "id": "tnt_dev_onboarding_co",
  "status": "active",
  "admin_user": {"subject": "it:dev", "roles": ["client_it", "concierge_lead"]},
  "edge":       {"id": "edge-dev_onboarding_co-01"},
  "api_key":    {"key": "sk_tnt_…", "note": "shown once — only its hash is stored"}
}

One transaction creates the tenant registry row, the admin user (so the developer can mint the rest of their team via /api/users), and the reference edge row; the bearer key is the tenant credential (§1.2.4) — a SHA-256 hash lives in PG, the secret never does. Additional keys: POST/GET/DELETE /api/tenants/{id}/keys[/key_id] (tenant users:manage).

Then point the edge simulator at the stack with that key and watch alerts flow edge → tunnel → triage → case → portal:

python3 edge/edge-sim/edge_sim.py --api http://127.0.0.1:8117 \
    --tenant tnt_dev_onboarding_co --api-key 'sk_tnt_…' \
    --count 10 --seed 7 --high-blast 2 --format json

Two of the ten suspend at the HITL gate (hitl_interrupts: 2) — approve one in the portal or via /api/approvals/{id}/decision and read the case's audit trail. Full simulator reference: Edge Box Simulator.

3. The portal demo flow

http://127.0.0.1:8119/       # login — reference credential:
                             #   sub:  analyst:m.reyes
                             #   pass: soc-demo-analyst
                             # (unless PORTAL_ANALYST_SUB/PASS is set in .env)
http://127.0.0.1:8119/seed   # 3 synthetic alerts through the REAL path:
                             # POST -> Vector edr_webhook -> ES, then
                             # AlertMetadataPush -> /api/alerts/ingest -> triage graph

One benign alert runs the autonomous lane; two host_isolate proposals suspend at the HITL gate for Approve/Deny in the case page. Note: restarting the portal container rotates the session cookie — log in again.

4. Expose the portal + docs on your tailnet

./tailscale-serve.sh

The script registers two tailnet-only serve routes — portal on :4443, docs on :4444 — and refuses to hijack a port already in tailscale serve status (pick another with SOC_TAILNET_SERVE_PORT / SOC_DOCS_SERVE_PORT). From any tailnet device (including your phone):

  • portal: https://<hostname>.<tailnet>.ts.net:4443
  • docs: https://<hostname>.<tailnet>.ts.net:4444

No public ingress, ever. That is decision D2 running, not described.

5. Rebuild this docs site

# from the repo root:
npm --prefix docs-site install            # marked + mermaid-cli (build-only)
PUPPETEER_EXECUTABLE_PATH=/path/to/chrome python3 docs-site/build.py

The build auto-compiles every docs/developer/**/*.md (including the API reference + interactive console) into docs-site/dist/; the four interactive diagram sets inline from docs-site/assets/diagrams/ via ```diagram fences (a fence with no matching asset fails the build loudly). The compose docs-site service serves dist/ — it reports unhealthy until a build exists, so build first boot, then docker compose up -d docs-site. The API reference regenerates from the spec §4.5 via python3 docs/developer/api/generate_openapi.py.

6. Stop

./down.sh          # stops + removes serve routes
./down.sh -v       # ...and drops all data volumes

Next