Contributing
How to work in the AISOC in-a-box monorepo: layout, contracts, connectors, and
the verification culture the project actually runs on. AI-assisted PRs must
also follow ../../AGENTS.md>AGENTS.md in the repo root.
Monorepo structure
Four planes with hard ownership boundaries (spec §5 is the path authority):
proto/ the wire contract (tunnel + service), additive-only
packages/ shared-schemas (generated), ecs-mapping, ui-kit
apps/ CLOUD plane — portal, control-plane-api,
agent-orchestrator, tunnel-gateway, billing
edge/ THE BOX — edge-agent, os-image, config, policies, helm
services/ long-running non-apps (alert-ingest, audit-chain-writer)
spec/ compat shims for the §3 artifacts (canonical home:
apps/agent-orchestrator/; hash parity is checked by
tools/spec-verify)
deploy/ reference stacks (compose Phase-0), tailnet-only exposure
docs/ spec/ (normative), developer/ (this tree)
docs-site/ marketing + rendered docs (build.py -> dist/)
tools/ spec-verify harness, soc-box-doctor, release-cli
Import rules (CI-enforced by tools/spec-verify --deps):
apps/*may not importedge/*.edge/*may import onlypackages/shared-schemasand its own tree.- Cross-boundary traffic is defined only by
proto/+packages/shared-schemas/json/. If it isn't in the contract, it doesn't cross the tunnel.
Contracts first
Any change that touches a boundary goes through the contract, in this order:
- Edit
proto/or the JSON-Schema source of truth inpackages/shared-schemas/. - Regenerate pydantic + zod models (
packages/shared-schemas/codegen/). buf breaking+openapi-diffmust pass — additive changes only for anything the Box speaks. A breaking wire change needs an ADR and a major tunnel version; assume "no".- API surface changes update
docs/spec§4.5 first, then re-runpython3 docs/developer/api/generate_openapi.pyand commit the generatedopenapi.yaml/openapi.jsonwith the PR. Never hand-edit the generated files.
Adding a connector
Connectors run on the edge (secrets never leave the box) and are catalogued by templates in the cloud. A connector is three pieces:
1. Template (cloud) — a row in connector_templates (GET /v1/connector-templates): type id, display, required scopes, wizard steps,
auth mode (oauth_device_code | admin_consent | api_key | cross_account_iam),
and the ECS source namespace it maps into (logs-<ns>.<type>-<tenant>-*).
2. Collector (edge) — edge/edge-agent/internal/connectors/<type>/:
- Implements the collector interface:
Auth(ctx, sealedCreds),Poll(ctx, cursor) (events, nextCursor),Test(ctx) TestResult. - Credentials arrive sealed with the tenant KMS key and are never returned by any GET path; store runtime secrets in the agent's memory only, re-sealing refresh tokens at rest.
- Emit ECS-normalized events into the Vector pipeline (the collector does not talk to ES or the cloud directly — Vector owns indexing and the alert fan-out).
- Respect the staleness budget: consecutive-failure counters and error classes
(
auth | scope | rate | network | schema) surface via connector runs; >3 failures auto-opens an ops case. - Idempotent polling: cursors persisted atomically with the batch they follow;
a crash between fetch and index must not duplicate events (ECS
event.originalhash dedupe at the sink).
3. Mapping + redaction (packages) — extend packages/ecs-mapping/ with the
field map and any redaction-profile includes for new PII-bearing fields. The
GDPR-standard profile must apply to your events before they are
egress-eligible; a source that can't be redacted can only be edge-local, and
that must be stated in the PR.
Checklist a reviewer will run your connector through:
- no raw secrets in logs, errors, or
TestResult -
soc-readerES user can't read your index without the tenant grant - alert metadata path carries
context_pointers, not raw events - run with network disabled at first poll → clean retry, no token leak
- unit tests against recorded (sanitized) provider fixtures
Testing culture
The project's rule: if a claim can't be executed, it isn't done.
| Tier | What | How |
|---|---|---|
| Spec snippets | every code/config block in docs/spec |
tools/spec-verify (tomlcheck, esql-lint, opa check, py_compile) in spec-verify.yml |
| §3 logic | triage logic, validator, audit chain | python3 -m unittest test_triage_logic |
| HITL policy | decision-table rows r1–r18 | opa test policies/*.rego |
| Contracts | proto/schema/OpenAPI compat | buf breaking, openapi-diff |
| Tenancy | cross-tenant reads ⇒ ∅ | integration suite iterates every analyst route from the OpenAPI list — a new route cannot skip the check |
| Acceptance gates | G1 isolation (1.A8/1.A9/1.A10), G2 HITL + audit chain (2.A3/2.A4/2.A6/2.A7) | tests.integration.test_g1_tenant_isolation / test_g2_hitl_audit; the live halves run against the reference stack in gate-suite.yml on every PR (§6 task 5), the in-process halves (chain tamper, OPA axes) run anywhere |
| Sovereignty | port-scan finds nothing; egress = tunnel + allowlist | pilot-verify runbook (G1 gate) |
Run the fast local gates before pushing; the merge queue runs everything.
Dev loop with the reference stack
cd deploy/compose && ./up.sh
# iterate; orchestrator code lives in deploy/compose/cloud/orchestrator for Phase-0,
# migrating to apps/agent-orchestrator as Phase 1 lands
curl -s http://127.0.0.1:8117/healthz | python3 -m json.tool
# docs site rebuild (when markdown or theme changed):
cd ../../docs-site && npm install && PUPPETEER_EXECUTABLE_PATH=... python3 build.py
Never expose any stack port beyond 127.0.0.1; tailnet publishing happens only
through tailscale-serve.sh.
Commit + PR conventions
- Conventional commits:
feat:,fix:,refactor:,test:,docs:,chore:. - One logical change per commit; reference the issue id in the message.
- Docs that describe behavior you changed are part of the change — spec §4.5 first, generated artifacts re-run and committed.
- CI red because a contract check fired is a good outcome; suppress the check only with a written reason in the PR.
Legal and licensing rails
- Elastic components run as customer-managed artifacts pulled at deploy time; this repo never redistributes Elastic-licensed binaries or images. Elastic Basic tier only on both ES tiers — a PR that needs a paid feature must carry a free-tier fallback or die.
- No AGPL components in the proprietary cloud plane. Vector is used as an
unmodified binary (MPL-2.0) and inventoried in
NOTICE. - Third-party notices regenerate via
just legal; never hand-editNOTICE.