Skip to content

Knowledge Graph

The knowledge graph stores scoped entities, aspects, grouped claim values, dependencies, proposals, and assertions. Dreaming derives this state from evidence through audited operations, and explicit ontology operations can also change it. Structured remember payloads are kept as evidence. They are not applied to the graph.

This page is the implementation reference. For the model behind it, see Knowledge Architecture. For routes, see the knowledge and ontology API.

The base schema comes from migration 019-knowledge-structure.ts and later migrations in platform/core/src/migrations/.

Top-level graph nodes. Main fields:

  • id, name, canonical_name, entity_type, agent_id, description
  • mentions
  • pinned, pinned_at
  • status (active or archived), archived_at, archived_by, archive_reason
  • proposal_id, proposal_evidence
  • last_synthesized_at
  • timestamps

ENTITY_TYPES in platform/core/src/types.ts lists the valid types. It covers people, projects, systems, tools, concepts, skills, tasks, sources, artifacts, agents, policies, actions, workflows, events, object types, interfaces, observations, claim slots, claim values, and unknown.

Entity lists filter to the agent and to active rows, then sort pinned entities first:

ORDER BY e.pinned DESC, e.pinned_at DESC, e.mentions DESC, e.updated_at DESC, e.name ASC

Named dimensions under an entity. Main fields: id, entity_id, agent_id, name, canonical_name, weight, status, archive fields, proposal fields, and timestamps.

Aspects are unique on (entity_id, canonical_name).

Values under an aspect. Main fields:

  • id, aspect_id, agent_id, memory_id
  • kind: attribute, claim, or constraint
  • content, normalized_content
  • group_key, claim_key
  • confidence, importance
  • status: active, superseded, or deleted
  • superseded_by
  • version, version_root_id, previous_attribute_id
  • archive fields, source provenance fields, proposal fields, timestamps

group_key and claim_key give each value its navigation path and its update identity:

entity -> aspect -> group_key -> claim_key -> attribute versions

A missing group_key is treated as general. Versions and replacement are scoped to one claim slot: the same aspect, kind, group, and claim key.

Directed edges between entities. Main fields: id, source_entity_id, target_entity_id, agent_id, aspect_id, dependency_type, strength, confidence, reason, status, archive fields, source provenance fields, proposal fields, and timestamps.

DEPENDENCY_TYPES in platform/core/src/types.ts lists the valid types. A related_to edge must have a non-empty reason; database triggers from migration 050 enforce this.

Migration 050 also adds entity_dependency_history. Triggers write a row for each dependency insert, update, and delete.

The retention worker runs a bounded compactor over this table. It removes both rows of a rebuild pair: a trigger-written deleted event and the next event for the same dependency, when that event is a trigger-written created event with the same timestamp, source, target, agent, dependency type, and reason. Rows with no reason never match, because the comparison is an SQL equality. Every other history row is kept.

Task lifecycle metadata keyed by entity_id: agent_id, status, expires_at, retention_until, completed_at, and updated_at.

Pending proposals and the audit record of applied operations. Main fields:

  • operation, payload
  • status: pending, applied, rejected, or failed
  • confidence, rationale, evidence, risk
  • source provenance
  • created_by, applied_by, rejected_by
  • result, timestamps

Attributed statements that do not become current truth. Main fields:

  • subject_entity_id, optional claim_attribute_id
  • predicate: claims, believes, observed, decided, prefers, denies, or questions
  • content, speaker, asserted_at, confidence, evidence
  • source provenance
  • status: active, archived, or superseded
  • supersedes_assertion_id, archive fields, timestamps

Assertions are written by the assertion endpoints and, when write_assertions is set, by POST /api/ontology/extract. They do not pass through the operation handlers below and do not write ontology_proposals rows.

A derived audit ledger, not a truth layer. Each row is agent-scoped and links two active, non-constraint claim values in the same entity, aspect, group, and claim slot. It snapshots both values, their confidence, source provenance, and proposal evidence, so a source purge can resolve the row without losing the record of what conflicted.

The detector is a bounded lexical check (negation_mismatch and supported antonym pairs). A row stays active while both values stay active and still match. Supersession, archival, replacement, or source deletion marks it resolved. The ledger never ranks sources, picks a winner, bypasses proposal review, or adds a contradicts edge to the graph.

Dreaming is the only automatic semantic writer. It applies its changes as operation batches through the same handlers that explicit edits use, so every change leaves an applied ontology_proposals row.

Remember writes evidence only. Ingest adds only mechanical source-topology entities and containment links, never aspects or claim values. POST /api/memory/remember keeps a structured payload as evidence metadata on a newly saved memory and returns structured_applied: false; a deduplicated remember keeps no new payload and its response omits that field.

The retired txPersistStructured and txPersistEntities closures and the inline LLM extraction chain were removed in the Dreaming cutover. The only write helper left in platform/daemon/src/ontology/graph/transactions.ts is txDecrementEntityMentions. The retention worker uses it to lower mention counts after a memory purge. Retention never deletes entities. An entity with zero mentions keeps its pin, aspects, values, aliases, dependencies, and assertions.

Source: platform/daemon/src/ontology/proposals/proposals.ts

Operations that can be applied or proposed:

  • entities: create_entity, rename_entity, archive_entity, merge_entities
  • aspects: create_aspect, rename_aspect, archive_aspect, merge_aspects
  • claim values: add_claim_value, set_claim_value, supersede_claim_value, archive_claim_value, restore_claim_version
  • links: create_link, update_link, archive_link
  • policy and interface objects: create_policy, create_action_type, create_interface, attach_interface

pin_entity, unpin_entity, create_entity_alias, and archive_entity_alias use the same apply path from the pin and alias routes.

Each operation runs in one of three modes:

  • dry run: apply inside a transaction, return the result, then roll back;
  • apply: change the graph and write an applied proposal row in the same transaction;
  • propose: write a pending proposal and change nothing else.

Dry run and propose cannot be combined. A batch takes up to 500 operations and applies them in one transaction; one failure rolls back the whole batch. In a dry-run batch, failures are collected per operation instead.

  • add_claim_value adds an active value to a slot. It does not replace other active values in that slot. If the same normalized value is already active there, it returns that row instead of adding a duplicate.
  • set_claim_value makes the new value the current version of the slot and marks the slot’s other active values superseded. If an active value in the slot has newer evidence time than the incoming value, the incoming value is stored as superseded by that newer value instead.
  • supersede_claim_value explicitly supersedes values selected by attribute_id or old_value. With new_value, it writes the replacement through set_claim_value.

Maintenance does not run a supersession sweep.

Some operations refuse with 409 unless the payload sets force: true:

  • set_claim_value when the slot holds an active constraint;
  • archive_claim_value on a constraint;
  • archive_aspect when the aspect has active constraints;
  • archive_entity on a pinned entity.

The operation routes pass write caps from memory.pipelineV2.traversal.maxWriteAspectsPerEntity (default 20) and maxWriteAttributesPerAspect (default 50). When caps are passed, these fail with 409:

  • create_aspect, or add_claim_value that names a new aspect, when the entity already has the maximum active aspects;
  • add_claim_value, or set_claim_value on a slot with no earlier versions, when the aspect already has the maximum active values.

Source: platform/daemon/src/recall/graph/traversal.ts

Traversal picks focal entities, walks a bounded subgraph, and returns memory IDs and structure for recall. Automatic recall runs it only when both memory.pipelineV2.graph.enabled and memory.pipelineV2.traversal.enabled are true. An explicit POST /api/knowledge/expand call runs traversal regardless of those two flags.

resolveFocalEntities uses the first source that returns entities:

  1. checkpoint entity IDs, when supplied;
  2. otherwise, project entities whose names match tokens from the project path (up to 5);
  3. otherwise, query-token matches through entities_fts, with a LIKE fallback (up to 20).

Pinned entities are then merged in, unless the caller disables them. The final set is capped at 200 entities. A session key does not resolve entities. It only sets the reported source to session_key when nothing else matched.

For the focal entities, traversal:

  1. collects active constraint values, ordered by importance and de-duplicated by entity and content;
  2. takes up to maxAspectsPerEntity aspects per entity, ordered by weight DESC, or only aspects whose canonical name matches aspectFilter when one is set;
  3. collects memory_id values from active values in those aspects, ordered by importance, up to maxAttributesPerAspect per aspect;
  4. if the memory budget is not full, adds memories from memory_entity_mentions;
  5. if time and budget remain, follows outgoing dependencies from the focal set and runs steps 1 to 4 for target entities not yet visited.

All steps share one memory budget, maxTraversalPaths.

Dependencies qualify when both of these hold (a missing confidence counts as 0.7):

confidence * strength >= minDependencyStrength
confidence >= minConfidence

Qualifying edges are ordered by confidence * strength. The walk follows one hop only; maxDependencyHops is accepted but not used.

The edge limit is shared across all focal entities: the query returns at most maxBranching times the number of focal entities, so one well-connected entity can use the whole allowance (#2352).

Traversal does not check the archived status of entities, aspects, or dependencies. An archived link is still followed, and archived entities and aspects can still add constraints and memories (#2351).

The result contains memoryIds, memoryScores, memoryPaths, constraints, entityCount, timedOut, activeAspectIds, and focalEntityIds. Recall blends it with its other channels; see How recall ranks candidates.

Settings live under memory.pipelineV2.traversal in agent.yaml:

Key Default Meaning
enabled true Run traversal (also needs graph.enabled)
primary true Use traversal as a primary recall candidate source
maxAspectsPerEntity 20 Aspects read per entity (1 to 100)
maxAttributesPerAspect 50 Memory IDs taken per aspect (1 to 200)
maxDependencyHops 10 Not used by the current one-hop walk
minDependencyStrength 0.3 Minimum confidence * strength
maxBranching 4 Edge allowance per focal entity, pooled (1 to 50)
maxTraversalPaths 50 Total memory ID budget (1 to 500)
minConfidence 0.5 Minimum edge confidence
timeoutMs 500 Deadline in milliseconds (50 to 5000)
boostWeight 0.2 Weight blended into recall scores for traversal hits
constraintBudgetChars 1000 Character budget for constraints injected at session start

Source: platform/daemon/src/ontology/proposals/aspect-feedback.ts

When memory.pipelineV2.graph.enabled and memory.pipelineV2.feedback.enabled are on, maintenance can decay aspect weights. With feedback.decayEnabled, aspects not updated for feedback.staleDays lose feedback.decayRate, down to feedback.minAspectWeight. Decay is off by default (decayEnabled: false, decayRate: 0).

applyFtsOverlapFeedback, which raised aspect weights from keyword-search overlap, is still in the file, but nothing calls it.

Source: platform/daemon/src/ontology/graph/hygiene.ts

The hygiene report is read-only. It lists suspicious entities, duplicate canonical groups, counts of values missing a group key, claim key, or source memory, and safe mention-link candidates where a known entity name appears in an unlinked memory.

Knowledge routes are in platform/daemon/src/http/routes/knowledge-routes.ts and ontology routes in platform/daemon/src/http/routes/ontology-routes.ts. Every route, with parameters and permissions, is documented in the knowledge and ontology API.

signet knowledge reads the graph: entities, entity, tree, aspects, groups, claims, attributes, and hygiene.

signet ontology changes and inspects it:

  • entity, aspect, claim, and link subcommands apply operations;
  • stream apply applies a JSONL operation stream;
  • proposals, proposal, propose, apply, reject, and conflicts work with the proposal queue;
  • assertions and assertion manage epistemic assertions;
  • contradictions, claim-evidence, link-evidence, and explain-claim read audit data;
  • extract and consolidate build proposals from sources.

Operation commands accept --dry-run, --propose, --actor, --reason, and --evidence-file. Both command groups accept --agent and --json. Usage examples are next to each route in the knowledge and ontology API.

getKnowledgeGraphForConstellation in platform/daemon/src/ontology/graph/knowledge-graph.ts builds the bounded payload for the dashboard graph. It reads active entities, aspects, values, dependencies, assertions, pending proposals, and a Dreaming summary. Source document entities are included when an active Dreaming claim cites them. Source folders, skills, and uncited source topology are left out. Limits, defaults, and caching are documented under GET /api/knowledge/constellation.

The dashboard scene draws entities and source documents, aspects, optional groups, claim slots, values, assertions, evidence origins, and memory references. Relationships are typed edges, not nodes. When every value in an aspect is in general, the group is folded into the aspect. An assertion attaches to its linked claim value when that value is shown, and otherwise to its subject entity. Confidence and provenance appear in node details. Pending proposals are in the payload but are not drawn as nodes. For using the view, see Memory graph.

Graph rows belong to one agent (agent_id). Most knowledge routes use the requested agent_id, then the credential’s scoped agent, then default. The constellation route falls back to the configured daemon agent instead.

When token scope enforcement applies, a non-admin credential restricted to one agent cannot request another agent; the route answers 403. Scope is not enforced in local mode or for unauthenticated requests in hybrid mode, and admin credentials can request any agent. The constellation route also offers an all-agents view, which needs admin permission outside local mode.