Skip to main content

Communication Framework

Actors

EXTERNAL                          ARCAN CORE                           EXTERNAL
──────── ────────── ────────
Human (CLI) ──→ HTTPS Server
Human (API client) ──→ │
SDK (Go/TS/Python) ──→ ├── Middleware Stack
CI/CD pipeline ──→ │ (guardian layer)
K8s service account ──→ │
├── Handlers
│ (business logic)

├── Store ──→ SQLite / PostgreSQL

├── Crypto ──→ KMS (AWS/GCP/Azure)

├── Engine Registry
│ ├── KV (built-in)
│ └── Plugin Runtime ─host fn─→ Connection Mgr ──→ External System
│ (sandboxed) (SQL, HTTP)

├── Audit Dispatcher ──→ Webhook Sink ──→ SIEM
│ ──→ Syslog Sink ──→ Log Aggregator
│ ──→ Store (async)

├── Reaper (background)

└── Registry Client ──→ registry.getarcan.dev

Communication Paths

Path 1: Client to Core (HTTPS)

┌──────────┐         ┌──────────────────┐
│ Client │──HTTPS──→ HTTPS Listener │ TLS required in ALL modes
└──────────┘ └────────┬─────────┘

┌────────▼─────────┐
│ Request ID MW │ Assigns/extracts X-Request-Id
├──────────────────┤
│ Rate Limit MW │ Guards: per-IP and per-token limits
├──────────────────┤
│ Auth MW │ Guardian #1: validates token, sets UserID
├──────────────────┤
│ Policy MW │ Guardian #2: evaluates RBAC permissions
├──────────────────┤
│ Logging MW │ Observer: structured request/response log
└────────┬─────────┘

┌────────▼─────────┐
│ Handler │ Guardian #3: ResolveRealm (tenant boundary)
└──────────────────┘

Path 2: Handler to Store (Go function call)

Handler calls store methods directly. Store enforces realm scoping on every query. Handlers can only access data within the resolved realm.

Path 3: Handler to Engine to Plugin Runtime to External System

┌──────────┐       ┌──────────┐       ┌─────────────┐       ┌───────────────┐       ┌────────────┐
│ Handler │─call─→│ Registry │─call─→│ Plugin │─host ─→│ Connection │─proto─→│ External │
│ │ │ │ │ Runtime │ fn │ Manager │ │ System │
│ │ │ │ │ (sandboxed) │ │ (SQL, HTTP) │ │ (PG, AWS) │
└──────────┘ └──────────┘ └─────────────┘ └───────────────┘ └────────────┘

The plugin code runs sandboxed inside the core process. It calls ctx.SQL() or ctx.HTTP(). These are host functions implemented by the core. The core's connection manager holds the actual database connections and HTTP clients. Root credentials never leave the core -- the plugin never sees them.

Path 4: Handler to Audit Dispatcher (Go channel, async)

Fire-and-forget via buffered channel. Uses context.Background(), not request context. Each sink (webhook, syslog, store) runs in its own goroutine.

Path 5: Core to Registry Service (HTTPS)

Registry client downloads packages and verifies signatures. No write access to registry from the core. Activation tokens sent for enterprise downloads.

The Six Guardians

#GuardianLocationWhat It GuardsFailure Mode
1Auth Middlewareinternal/middleware/auth.goIdentity -- is this a valid user?401 Unauthorized
2Policy Middlewareinternal/middleware/policy.goAuthorization -- can this user do this action?403 Forbidden
3ResolveRealminternal/handler/realm_resolve.goTenant boundary -- which realm?404 Not Found
4Plugin Runtimeinternal/plugin/runtime.goSandbox -- plugin can only call declared host functions501/502
5Signature Verifierinternal/plugin/signature.goSupply chain -- is this package authentic?Plugin not loaded
6Store Layerinternal/store/*/Data boundary -- queries scoped to realmNo cross-realm leaks

Rule: No request path bypasses all six guardians. Every data-modifying operation passes through at least guardians 1, 2, 3, and 6. Engine operations add 4 and 5.

Entitlement Chain

Human/Client

├── Authenticates with token
│ Guardian: Auth Middleware
│ Grants: identity (user_id, auth_method)

├── Authorized by RBAC policy
│ Guardian: Policy Middleware
│ Grants: capabilities (secrets:read, leases:create, etc.)

├── Scoped to realm
│ Guardian: ResolveRealm
│ Grants: realm_id (data boundary)

├── Request reaches handler
│ Guardian: Handler validation
│ Grants: validated input → store/engine call

├── Handler calls store
│ Guardian: Store layer (realm scoping)
│ Grants: CRUD within realm

├── Handler calls engine registry
│ Guardian: Plugin runtime (sandbox + capabilities)
│ Grants: only declared host functions available

└── Plugin calls host function (ctx.SQL, ctx.HTTP)
Guardian: Connection Manager
Grants: connection to configured external system only
Root credentials held by core, never exposed to plugin

SYSTEM ACTORS (no human identity):
├── Reaper: system-level, all realms, cleanup only
└── Audit dispatcher: append-only, fire-and-forget

Communication Rights Matrix

FromToProtocolAuthEntitlementGuardian
ClientHTTPS ServerHTTPS (TLS always)Bearer tokenIdentityAuth MW
Auth MWStoreGo callSystemToken lookupTrusted path
Policy MWStoreGo callSystemRole/binding lookupTrusted path
HandlerStoreGo callAuthorizedCRUD within realmStore scoping
HandlerEngine RegistryGo callAuthorizedEngine lookupRegistry
HandlerAudit DispatcherGo channelAuthorizedEmit eventsDispatcher
RegistryPlugin RuntimeGo callAuthorizedSandboxed executionRuntime sandbox
PluginConnection MgrHost functionDeclared capabilitySQL/HTTP to external systemConnection Mgr
PluginStore (plugin_data)Host functionDeclared capabilityScoped to engine_id + realm_idStore scoping
PluginAuditHost functionDeclared capabilityEmit events (tagged with plugin name)Dispatcher
ReaperStoreGo callSystemCleanup expired dataTrusted path
ReaperEngine RegistryGo callSystemRevoke expired leasesRuntime sandbox
Registry ClientRegistry APIHTTPSNone / activation tokenDownload + verifySignature verifier
Audit DispatcherWebhook SinkHTTPSHMAC signatureDeliver eventsSink retry
Audit DispatcherSyslog SinkTCP/UDPNetwork trustDeliver eventsSink retry