Skip to main content

Knowledge Graph consolidation

Consolidation is the only path that writes to a Pulse Knowledge Graph. Seven MCP tools compose into a single transactional flow:
The session is in-memory until 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.
When 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.
Embeddings are computed on commit, not on add. The 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).
Cognitive agents may only add 5 edge types: supersedes, contradicts, depends_on, relates_to, validates.The remaining 6 (derives_from, mentions, violates, implements, tests, belongs_to) are reserved for the Layer 1 deterministic worker. Attempts to add them via MCP return a 403 reserved_edge_type error.

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 semantics:

6. okto_pulse_kg_commit_consolidation

Atomically write all candidates. Pulse runs four side-effects in one transaction:
  1. Embed each new node (sentence-transformers, 384-dim).
  2. Apply node and edge candidates per their hint (or per agent_overrides).
  3. Append a row to the audit table with the full session payload + hash.
  4. Emit an outbox event for downstream consumers.
If commit fails (lock conflict, schema violation, embedder timeout), nothing lands and the session enters a 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.
Use abort when:
  • nothing_changed is detected after add_* 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 resulting Decision and a supersedes edge to the previous decision on the same topic.
That’s the full happy path. Six tool calls. The seventh (abort) is only reached on the unhappy path.

Idempotency and replay safety

Two layers protect the graph from duplicate writes:
  1. Content hash on begin. Re-consolidating the same (source_type, source_id, source_version) with no actual change returns nothing_changed: true and never enters a session. Replays are safe.
  2. NOOP reconciliation hint. Even when a session is opened, candidates whose existing nodes already match are tagged NOOP and skipped on commit.
The combination means an agent can safely call the consolidation flow on every spec evaluation without worrying about bloating the graph with duplicates.

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


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.
Last modified on May 8, 2026