Documentation Index
Fetch the complete documentation index at: https://docs.oktolabs.ai/llms.txt
Use this file to discover all available pages before exploring further.
Knowledge Graph consolidation
Consolidation is the only path that writes to a Pulse Knowledge Graph. Seven MCP tools compose into a single transactional flow:commit, which atomically writes all candidates plus an audit row plus an outbox event. A content-hash check on begin short-circuits no-op replays. Sessions expire after 1 hour (kg_session_ttl_seconds).
Each primitive is gated by its own dotted-string flag in the granular permission registry: kg.session.begin, kg.session.add_node, kg.session.add_edge, kg.session.get_similar, kg.session.propose, kg.session.commit, kg.session.abort. The meaningful gate is kg.session.commit — presets sometimes grant everything except commit for dry-run-only roles. Cognitive agents typically receive the full set. User-facing dashboards typically receive none. See overview for the full preset model.
Source: okto-pulse-core/src/okto_pulse/core/mcp/kg_tools.py:register_kg_tools. Citations below reference 80-pulse-feature-inventory.md:503–515.
The transactional flow
1. okto_pulse_kg_begin_consolidation
Open a session for a board. Pulse computes a content_hash over the artifact you are consolidating (a spec, a card validation record, a decision artifact); if a previous commit produced the same hash, the call returns nothing_changed: true and you can skip the rest.
nothing_changed: true, abort and exit:
2. okto_pulse_kg_add_node_candidate
Add a node candidate to the open session. Stays in-memory until commit. Call once per node you want to materialize.
attributes map is type-specific — Decision accepts rationale/confidence, Constraint accepts severity/scope, etc. Unknown keys are dropped on commit with a warning in the audit row.
3. okto_pulse_kg_add_edge_candidate
Add an edge candidate connecting two candidates (or one candidate and one existing node by node_id).
4. okto_pulse_kg_get_similar_nodes
Before reconciling, ask the graph what existing nodes look like a given candidate. Used to decide whether to UPDATE an existing node, SUPERSEDE it, or add a fresh one. HNSW vector search if the candidate type has an index, else title-prefix fallback.
5. okto_pulse_kg_propose_reconciliation
Compute reconciliation hints for every candidate in the session. The hints are advisory — commit will use them by default but you can override per candidate.
| Hint | Meaning |
|---|---|
ADD | Insert as a new node. |
UPDATE | Update an existing node (target_node) in place. Used for refining attributes. |
SUPERSEDE | Insert as new + add supersedes edge to target_node. The old node is preserved. |
NOOP | Already present and unchanged — drop on commit. |
6. okto_pulse_kg_commit_consolidation
Atomically write all candidates. Pulse runs four side-effects in one transaction:
- Embed each new node (sentence-transformers, 384-dim).
- Apply node and edge candidates per their hint (or per
agent_overrides). - Append a row to the audit table with the full session payload + hash.
- Emit an outbox event for downstream consumers.
committable: false state. Either retry commit or call abort.
7. okto_pulse_kg_abort_consolidation
Drop an in-flight session without writing anything. No compensating delete is needed because nothing was persisted yet.
nothing_changedis detected afteradd_*is already in flight.- Reconciliation surfaces a contradiction the agent isn’t allowed to introduce.
- Session TTL is about to expire and you can’t finish the work.
End-to-end example
A cognitive agent finishes a spec evaluation and wants to record the resultingDecision and a supersedes edge to the previous decision on the same topic.
abort) is only reached on the unhappy path.
Idempotency and replay safety
Two layers protect the graph from duplicate writes:- Content hash on
begin. Re-consolidating the same(source_type, source_id, source_version)with no actual change returnsnothing_changed: trueand never enters a session. Replays are safe. NOOPreconciliation hint. Even when a session is opened, candidates whose existing nodes already match are taggedNOOPand skipped on commit.
Permissions and audit trail
Every consolidation produces an audit row containing the session id, content hash, all candidates, all reconciliation hints, all overrides, and the agent identity from the API key. The audit row is the system-of-record — query the graph to see what the state is, query the audit table to see how it got there. The 6 deterministic edge types (derives_from, mentions, violates, implements, tests, belongs_to) are written exclusively by the Layer 1 worker, not via MCP. This keeps cognitive agents out of structural-graph mutations and makes the deterministic skeleton machine-checkable.
Common errors
| Error | Cause | Fix |
|---|---|---|
403 reserved_edge_type | Agent tried to add derives_from / mentions / violates / implements / tests / belongs_to via MCP. | Use one of the 5 cognitive edge types, or let the Layer 1 worker write the relationship. |
409 session_expired | Session exceeded kg_session_ttl_seconds (default 3600). | Re-open with begin_consolidation. |
409 commit_conflict | Another session committed first and the candidate now collides. | Re-run propose_reconciliation and re-commit. |
422 unknown_attribute | Attribute key not in the type’s schema. | Drop the unknown key, or extend the type’s schema. |
429 rate_limit | Too many consolidations per minute for this agent. | Back off and retry. |
Next steps
Queries
Read tools that surface what’s in the graph after consolidation.
Health & migration
Operate the consolidation queue, dead-letter recovery, and decay tick.