Layered request flow, agent runtime, retrieval backends, and shared infrastructure
/v1/run passes through five enforcement layers before any retrieval or generation work happens. The agent runtime then routes retrieval across pgvector, Bedrock KB, or Vertex AI Search — picked per-corpus from a single config field. Stateful infrastructure (Postgres, Redis, ARQ workers) is shared across the platform with envelope-encrypted secrets and a tamper-evident audit log.Tenant boundary
Non-bypassable tenant scoping. The principal's tenant_id is checked against every resource's tenant_id.
↳ TENANT_MISMATCH — request rejected before any policy runs.
Kill switches / maintenance gates
Per-feature kill switches and maintenance windows take precedence over RBAC and ABAC.
↳ FEATURE_DISABLED or MAINTENANCE_MODE — short-circuit denial.
RBAC role gate
Endpoint-level role check. The role matrix in README pins minimum role per route.
↳ ROLE_INSUFFICIENT — denied with the required role surfaced.
Document ACL evaluation
Explicit grants (read / write / admin) for the principal. Expired grants are ignored. Owner = automatic admin.
↳ ACL_DENIED — no matching grant or only expired grants found.
ABAC policy evaluation
Deny-first then allow-then. Higher priority wins. Conditions evaluated against principal, resource labels, and request context.
↳ POLICY_DENIED — surfaced with the matching policy name.
Default deny
If no allow policy matched, the configurable default is applied (default deny in production).
↳ DEFAULT_DENY — terminal step; flag controls behavior.
Rate limit
Redis · token-bucketPer-key + per-tenant dual enforcement with stable 429 schema, retry hints, and audit events for throttling and degraded mode.
Auth
API key + SSO/SCIMHashed API key storage; OIDC SSO with PKCE + state/nonce replay protection; SCIM 2.0 token-authenticated provisioning.
RBAC
reader / editor / adminRole gate on every protected endpoint. Admin role does not bypass document ACLs unless AUTHZ_ADMIN_BYPASS_DOCUMENT_ACL=true.
ABAC
policy enginePriority-aware deny-first / allow-then policies with simulation API and DSL conditions (eq, time_between, var).
Doc ACL
creator-owner defaultPer-document grants (read / write / admin) with expiring grants ignored. Default-deny posture configurable.
LangGraph agent
/v1/run · SSEState graph orchestrates retrieval → generation → optional TTS. Request_id tracing on every event; reconnect-safe sequence numbers.
Retrieval router
per-corpus providerEach corpus picks its retrieval provider in corpora.provider_config_json. Empty config normalizes to local pgvector.
Generator
Gemini · Vertex AIPluggable LLM provider with deterministic fake-LLM path for tests. Timeout + cancellation handling for streaming paths.
PostgreSQL + pgvector
local defaultCosine retrieval with similarity scoring, deterministic ordering, embedding-dimension invariants, race-safe upserts.
AWS Bedrock KB
managedKnowledge Base id + region selectable per corpus. Bedrock adapter mock-tested in CI without live creds.
GCP Vertex AI Search
Discovery EngineDiscovery Engine datastores wired through the same router. Vertex adapter mock-tested with config-error mapping.
PostgreSQL
system of recordTenants, corpora, documents, chunks, audit log, compliance evidence, encrypted blobs, retention runs — all here. Alembic-migrated.
Redis
rate limits · idempotency · ARQToken-bucket rate limit state, idempotency conflict detection, and ARQ job queues for async ingestion + notifications.
ARQ Workers
ingestion · notifications · evaluatorThree durable worker pools — ingestion (chunk + embed + persist), notification delivery, operability evaluator.
KMS / Keyring
envelope encryptionTenant key registry + encrypted blob store. Pluggable KMS providers; resumable re-encryption jobs with telemetry.