Skip to content

Concept relationship layer: wikilink edges in rolegraph #605

@AlexMikhalev

Description

@AlexMikhalev

Summary

Add concept-to-concept edges to the rolegraph, derived from [[wikilinks]] extracted by the Obsidian parser (#604). Currently the thesaurus is flat (synonym -> concept). Wikilinks enable a second layer: concept -> related concept.

Current State

Thesaurus (flat):
  "context management" -> concept("context engineering")
  "semantic scope"     -> concept("context engineering")

Proposed State

Thesaurus (flat, unchanged):
  "context management" -> concept("context engineering")

Relationships (new):
  concept("context engineering") --Related--> concept("knowledge graph")
  concept("context engineering") --Related--> concept("ontology")
  concept("knowledge graph")     --ParentChild--> concept("context engineering")  // from folder hierarchy

Edge Types

pub enum EdgeType {
    Related,      // from [[wikilinks]]
    ParentChild,  // from folder hierarchy (subfolder = child)
    SeeAlso,      // future: explicit "see also::" directive
}

pub struct ConceptEdge {
    pub from: NormalizedTermValue,
    pub to: NormalizedTermValue,
    pub edge_type: EdgeType,
    pub weight: f64,  // default 1.0, can be boosted by frequency
}

Integration with RoleGraph

terraphim_rolegraph already supports node/edge relationships. Feed ConceptEdge data into the existing graph structure so that:

  1. Search ranking: when searching for "context engineering", results mentioning related concepts ("knowledge graph", "ontology") get a relevance boost
  2. Graph traversal: terraphim_agent ASCII graph visualization shows concept neighborhoods
  3. Autocomplete: typing "context" could suggest both synonyms AND related concepts

Implementation

  1. Extend MarkdownDirectivesParseResult to include Vec<ConceptEdge> (Obsidian format parser: aliases, wikilinks, and tags extraction #604 provides related_concepts)
  2. In build_thesaurus_from_haystack(), after building the flat thesaurus, construct edges from related_concepts
  3. Feed edges into RoleGraph::new() alongside the thesaurus
  4. Boost search results that match related concepts (configurable weight, default 0.3x of direct match)

Affected Crates

  • terraphim_rolegraph (primary -- accept and store concept edges)
  • terraphim_automata (pass edges from parser output)
  • terraphim_types (ConceptEdge, EdgeType types)
  • terraphim_service (use edges for search ranking boost)

Dependencies

Estimated Effort

~1 day

Part of

Epic #603

Metadata

Metadata

Assignees

No one assigned

    Labels

    architectureArchitecture and design decisionsenhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions