Skip to content

Knowledge Graph

The Knowledge Graph is the backbone of RaiSE’s context system. It merges everything — memory patterns, governance documents, skills metadata, work tracking, and discovered components — into a single graph of connected concepts.

A directed graph where:

  • Nodes are concepts — patterns, principles, requirements, skills, stories, components, modules
  • Edges are relationships — “learned from”, “governed by”, “depends on”, “constrained by”

When you run rai memory build, the CLI traverses all project sources and assembles this graph. When you query with rai memory query or rai memory context, you’re searching this graph.

TypeID PatternSourceExample
PatternPAT-*, BASE-*Memory JSONL files”Use fixtures for database tests”
CalibrationCAL-*Calibration recordsStory S3.5: M size, 45 min actual
SessionSES-*Session history”Implemented auth module”
Principle§NConstitution”Simple heuristics over complex ML”
RequirementRF-*PRD”Marketing website with craftsman tone”
GuardrailGR-*Guardrails”MUST: No vanity metrics as goals”
Skill/nameSKILL.md files/rai-story-plan — decompose into tasks
StoryS*.*Work trackingS8.6: Docs Getting Started
EpicE*Epic scopesE8: Website v1 + Docs
Componentcomp-*Discovery scanSessionManager class
Modulemod-*Discovery analysismod-memory — memory subsystem
DecisionADR-*Architecture decisionsADR-019: Unified context graph

Edges express how concepts relate:

EdgeMeaningExample
learned_fromPattern came from this sessionPAT-042 → SES-015
governed_byRequirement implements a principleRF-01 → §2
implementsStory implements a requirementS8.6 → RF-05
part_ofStory belongs to an epicS8.6 → E8
depends_onModule depends on anothermod-session → mod-memory
belongs_toModule belongs to a domainmod-memory → bc-core
constrained_byDomain is constrained by a guardrailbc-core → GR-015
applies_toPattern applies to a skillPAT-001 → /rai-story-implement
Terminal window
rai memory build

This merges all sources:

  1. Governance: principles, requirements, guardrails from governance/
  2. Memory: patterns, calibration, sessions from .raise/rai/memory/
  3. Work: epic and story scopes from work/epics/
  4. Skills: metadata from .claude/skills/*/SKILL.md
  5. Components: discovered code from work/discovery/

The output is .raise/rai/memory/index.json.

Find concepts by content:

Terminal window
rai memory query "testing patterns"

Find a specific concept by ID:

Terminal window
rai memory query "PAT-001" --strategy concept_lookup

Get the full architectural context for a module — its domain, layer, constraints, and dependencies:

Terminal window
rai memory context mod-memory

This returns:

  • Bounded context: which domain the module belongs to
  • Layer: its position in the architecture (leaf, domain, integration, orchestration)
  • Constraints: applicable guardrails (MUST and SHOULD)
  • Dependencies: what it depends on and what depends on it

Check the graph for structural issues:

Terminal window
rai memory validate

This detects cycles in dependency relationships, invalid edge types, and dangling references.

The graph structure enables contextual queries — not just “find this keyword” but “show me everything related to this module, including the rules that constrain it and the patterns learned while building it.”

When your AI partner runs rai session start --context, the CLI assembles a context bundle by traversing this graph. The result is a compressed view of everything relevant to your current work — not a dump of all files, but a curated selection of the most important nodes and their relationships.