Spec-19-Adapter-ABI
What this spec defines
The stable adapter contract for code that bridges Stigmem into agent runtimes, tools, and platform hooks. Adapter behavior and failure contracts; protocol-wide conformance vectors belong to their owning component specs.
Extraction status
This file contains the ADR-010 prose extraction for the adapter ABI.
Legacy version labels from archived source material are normalized
to the current v0.9.0a1 protocol line here. Historical wording
remains available in spec/archive/evolution/ and
spec/EVOLUTION.md.
Adapter archetypes
Adapters SHOULD clearly document which archetype they implement.
Environment contract
Adapters MUST honor these environment variables:
STIGMEM_URLSTIGMEM_API_KEYSTIGMEM_SOURCE_ENTITYsource on write operations. Default is adapter-specific.Process-mode adapters MUST exit non-zero if STIGMEM_URL is absent. Middleware adapters MUST skip Stigmem operations and MUST NOT change the host process exit code.
Boot handshake
Adapters SHOULD probe the node at startup:
GET /.well-known/stigmem
The response must advertise node version, node id, node URL, auth mode, and federation capability. Missing or malformed required fields SHOULD be treated as a failed probe.
Process-mode adapters SHOULD log a probe failure and allow individual tool calls to fail with adapter-level errors. Middleware adapters MUST return an empty boot context and continue.
BootContext
Middleware adapters that inject Stigmem context return:
BootContext {
facts: Fact[]
summary: string
}
BootContext is always returned. On total failure, it MUST be:
BootContext { facts: [], summary: "" }
Context pull
Middleware adapters MAY pull context during boot. All context queries are non-fatal. A failed or empty query MUST NOT abort startup.
Common context pulls include:
Confident user/agent facts
Above an adapter-defined confidence threshold.
Project constraints
Pending handoffs
Targeting STIGMEM_SOURCE_ENTITY.
Recent escalations
Adapters SHOULD filter pulled facts to relevant namespaces to avoid injecting unbounded or noisy context.
Write surfaces
Adapters may assert lifecycle, handoff, decision, or escalation facts. Write operations MUST use fire-and-forget semantics:
No host crash
Write failures MUST NOT crash the host process.
Log warning
Write failures SHOULD be logged at warning level.
Lifecycle confidence=1.0
Lifecycle and intent-routing facts SHOULD use confidence=1.0.
Local heartbeats
Activity/heartbeat facts MUST remain local unless a component spec explicitly says otherwise.
Paperclip-style lifecycle facts use the paperclip: namespace
registered by Spec-16-Namespace-Registry. Intent and delegation
facts use the intent: namespace.
Context injection format
Adapters that inject facts into an agent prompt SHOULD group facts by relation namespace and render a concise Markdown summary:
## Stigmem context - {user_entity}
### {namespace}
- **{relation}** on `{entity}`: {value_str}[ _(confidence: {confidence:.2f})_]
Rendering rules:
Omit empty blocks
Omit the entire context block when no facts were retrieved.
Verbatim identifiers
Preserve relation and entity strings verbatim.
Null rendering
Render null values as (null).
Confidence threshold
Include confidence only when below 1.0.
Ordering
Descending confidence, then descending HLC where available.
Adapters that handle prompt injection risks SHOULD layer additional sanitizer or structural-channel controls; those controls are outside this ABI.
Error handling contract
The crash-forbidden invariant applies to middleware adapters.
A Stigmem node failure MUST NOT crash the host agent process.
STIGMEM_URL absentBootContext.Adapter-specific conformance
Adapters that write lifecycle or intent facts SHOULD include integration tests that verify:
- Expected relations appear in the fact store after lifecycle events.
- Client-side validation rejects facts with wrong scope or too-low confidence, or the node response is handled without crashing.
- Node unavailability does not crash middleware-mode hosts.
Out of scope
This spec does not define:
Protocol-wide conformance vectors
Adapter package layout
Plugin lifecycle APIs
Sanitizer requirements
Prompt-injection.
Adapter relation inventories
Beyond registered namespace examples.