Skip to main content
@rubric-app/core exports four classes that compose into a complete adapter: TokenStore, BundlePoller, Evaluator, and AuditSink. Each runs independently; you wire them together at boot. If you’re using Claude Code, the Claude Code adapter wires these for you and you don’t need this page.

TokenStore

JWT-SVID identity store. Exchanges your enrollment token for a 60-minute signed identity at boot and refreshes it before expiry.
bootstrapTokenStore performs the initial enrollment and starts the refresh loop. Call tokenStore.stop() on shutdown.

BundlePoller

Pulls your policy bundle from Rubric every 30 seconds (configurable). Calls onUpdate(bundle) whenever the content hash changes.
The poller rejects bundles whose bundleVersion is lower than the cached one or whose builtAt is meaningfully older than the cached builtAt. Inspect poller.lastPullAt and poller.lastBundleChangeAt to detect stuck or rolled-back states.

Evaluator

Synchronous, in-process policy evaluator. Takes an EvaluationRequest and returns an EvaluationResult in well under 1ms.
Full API surface in Evaluator.

AuditSink

Batched, retried shipper for audit events. enqueue() is synchronous and never blocks; a background flush task ships events to Rubric.
The default queue cap is 10,000 events. When full, new events are dropped and droppedQueueFull increments. Wire this to your monitoring so you can alarm on silent drops. Call audit.stop(drainTimeoutMs) on shutdown to flush remaining events synchronously up to the deadline.

Composing them into an adapter

A complete adapter is just these four pieces wired together. See the Claude Code adapter source on GitHub for a working example.