Semantic Triggers
Overview
Semantic triggers flip the database query model: instead of you asking the database for information, the database tells you when something becomes relevant.
You subscribe to a context string. Whenever the decay worker, Hebbian worker, or a new engram store causes an engram to cross the relevance threshold for your context, MuninnDB fires a notification.
Use case: An AI agent monitoring a user's project subscribes to "deployment failures". When a new engram about a failed deploy is stored (by another process, webhook, or agent), the monitoring agent is notified immediately — without polling.
Creating Triggers
sub, err := mem.Subscribe(ctx, &muninn.TriggerRequest{
Context: "production deployment failure",
Threshold: 0.8, // Fire when relevance >= 0.8
Callback: func(e *muninn.TriggerEvent) {
fmt.Printf("Alert! Relevant memory: %s\n", e.Engram.Concept)
},
})
defer sub.Cancel() def on_trigger(event):
print(f"Alert! Relevant memory: {event.engram.concept}")
sub = mem.subscribe(
context="production deployment failure",
threshold=0.8, # Fire when relevance >= 0.8
callback=on_trigger,
)
# Cancel when done
sub.cancel() Delivery Methods
- Callback (Go SDK) — In-process function call. Zero latency.
- WebSocket — Connect via REST to
/v1/ws/triggers/:subscription_id. - SSE — Server-Sent Events at
/v1/sse/triggers/:subscription_id. - Webhook — HTTP POST to a URL when trigger fires.
- MCP stream — Delivered as MCP tool events to the subscribed agent.
Triggers are rate-limited per vault (default 100/minute) to prevent notification storms during bulk imports.