Skip to content

Graph

The graph and its primitives — objects, relations, patches, views, and events. The graph is a projection of the event log; mutations go through events. For the conceptual model see concepts/graph.

Event-sourced graph. The log is truth; objects/relations are projection.

relations(source=None, target=None, type=None)

Return relations filtered by source, target, and/or type.

v1.0.4 #1: the canonical filter API on Graph. Decomposes the v0 get_relations(object_id=, direction=) axis into separate source and target slots so the call reads the way users already write it (matches docs/concepts/graph.md). Filter kwargs compose by AND; calling with no kwargs returns every relation. Graph.get_relations(object_id=, type=, direction=) stays as a backward-compatible alias.

objects(type=None, where=None)

Return objects matching type and/or where.

v1.0.3 #1: the canonical query API on Graph, mirroring View.objects(type=...) so call sites read the same inside and outside behaviors. Graph.query(object_type=...) is kept as a backward-compatible alias.

query(object_type=None, where=None)

Backward-compatible alias for :meth:objects. v1.0.3 #1.

New code should use graph.objects(type=...) — the kwarg type matches :meth:View.objects so the call reads the same in and out of behaviors.

attach_store(store)

Wire an EventStore as the durability sink. Idempotent on the same store. Calling with a different store after events exist is an error — events would be persisted in two places and you'd lose history.

emit(event)

Append to log, project, persist (if attached), notify. CONTRACT #2.

patch_object(target, updates, *, actor='system', caused_by=None, frame_id=None, rationale=None, evidence=None, llm_request_event_id=None, tool_request_event_ids=None)

Auto-apply shortcut: build patch, version-check, emit applied/rejected.

Primitives

Read-only scoped slice of the graph, handed to behaviors as ctx.view.

Behaviors never query the live graph: they declare what they want via decorator metadata (view= specs like include_types or around) and the runtime builds the View before invocation (CONTRACT #11). A View is a point-in-time snapshot — filter it with :meth:objects / :meth:relations / :meth:events, but nothing done to it mutates the graph; mutations go through the context's propose/patch surface and land as events.

Diffs