- engineering-docs → archive/2026-03-29-engineering-docs (63/63 tasks complete) - phase-2-production-ready → archive/2026-03-29-phase-2-production-ready (89/89 tasks complete) - openspec/specs/ synced with all Phase 1 + Phase 2 + engineering-docs capabilities (22 specs total) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1.2 KiB
1.2 KiB
Spec: OPA Policy Engine Integration
Status: Pending CEO approval Workstream: 5 of 8
Scope
- New
OpaMiddlewarereplacing static scope check inauth.ts @openpolicyagent/opa-wasmintegration (embedded Wasm, no sidecar)policies/authz.rego— main allow/deny policypolicies/data/scopes.json— scope to permission mapping- SIGHUP handler to hot-reload policies without restart
- New env var:
POLICY_DIR(default:./policies)
Policy interface
input = {
"method": "GET",
"path": "/api/v1/agents",
"scopes": ["agents:read"],
"agentId": "uuid"
}
output = {
"allow": true | false,
"reason": "string" // populated when allow=false
}
Acceptance Criteria
- All existing scope checks replaced by OPA evaluation
- Policy files hot-reloadable on SIGHUP (no restart required)
- OPA Wasm loaded at startup — fail-fast if
POLICY_DIRinvalid allow=falseresponses return403withreasonin error body- Existing test suite passes unchanged (OPA evaluates same rules as before)
- New unit tests for OPA middleware: allow/deny cases, missing scope, invalid input
POLICY_DIRenv var documented indocs/devops/environment-variables.md