Architecture

Surface, models, and security

HTTP ingest and read verbs, integrations, model hooks, and security properties.

How to call Spectron, how models plug in, and how security properties attach to stored state.

Two ingest families and one read family over a unified graph (same reconciler, same retrieval stack):

VerbPurpose
POST /api/v1/{ctx}/factsText or triples, with infer: "full" \| "triples" \| "preview" \| "none".
POST /api/v1/{ctx}/facts/batchBulk conversation ingest (messages: [{ role, content, ts }, …]). Idempotent with Idempotency-Key.
POST /api/v1/{ctx}/documentsByte ingest into the multi-modal pipeline (async).
POST /api/v1/{ctx}/queryUnified read over facts and passages. Accepts optional labels, lens (scope paths to read within), and scope_view (strict, merged, or crossTeam) to control how broadly results are folded within what the caller is already allowed to see.
POST /api/v1/{ctx}/chatRecall + LLM synthesis; SSE when streaming.

POST /api/v1/{ctx}/context and the MCP recall / context tools accept the same read parameters as /query.

Trace listing: GET /api/v1/{ctx}/traces and GET /api/v1/{ctx}/traces/{id}. See Traces and memory evolution and REST API.

  • Generated SDKs – Python (surrealdb-spectron) and TypeScript (@surrealdb/spectron), both produced from Spectron’s OpenAPI specification so types track the server surface.

  • MCP over HTTP – tools wrapping the same handlers; shared API-KEY auth. See MCP server.

  • Harness adapters – LangChain, Claude Code hook, OpenAI Agents, Vercel AI SDK, n8n – flush conversations into /facts/batch.

LLMs and embedders appear in five pipeline roles – each configurable per Context and per call, with model and cost recorded on traces:

  1. Extraction – turns and chunks → entities, attributes, relations.

  2. Embedding – vectors for entities, attributes, chunks.

  3. Reconciliation – optional disambiguation when signals conflict.

  4. Synthesis/chat and /reflect generation.

  5. Elaboration / consolidation – background passes.

Spectron supports OpenAI-compatible endpoints plus first-class Anthropic and Google clients. The embedding model at write time must match read time within a Context (or schedule re-embed).

  • EncryptionIn transit: terminate TLS at your reverse proxy or load balancer (typical deployments run Spectron on HTTP behind the proxy). At rest: configure encryption on your SurrealDB storage backend and object-store bucket (for example KMS on S3 or GCS); Spectron inherits whatever those backends provide.

  • Graph-resident audit – writes emit decision_trace; reads emit retrieval_trace; /chat and /reflect emit response_trace. Together these record which caller asked what, against which scope, with which key, and which records were considered or returned.

  • Operational audit events – alongside the trace graph, Spectron emits structured audit events for reads, destructive operations (forget), scope changes, background jobs, and denied authorisation attempts so refused access is on the record even when no trace record is written.

  • Prompt-injection handling – ingest-time scanning on uploads and batched turns; spectron fsck --check injection for sweeps.

  • Right to be forgottenforget soft-deletes or purges per policy; supersession history optional for audit.

Operators can derive:

  • Cost – tokens, model, latency from response_trace.

  • Cache hit rate – responses with reused_from set (tier 2 — fewer tokens spent).

  • Contradiction rateuncertainty records per volume of writes, by source kind.

  • Source distribution – attributes by source.kind over time.

  • Supersession churndecision_trace.superseded per entity.

  • Retrieval quality – candidate sizes and per-signal agreement from retrieval_trace.

See Self-hosting observability for more details.

Was this page helpful?