RepairConcepts

⚠️ DANGER: This tool can PERMANENTLY DAMAGE your [[knowledge-graph]] if used incorrectly! Repairs [[graph]] corruption by replacing [[concept]] variants with canonical form in source [[markdown]] files. Fixes the source of truth rather than just the database. Use this to consolidate [[concept]] families while preserving semantic meaning.

🛡️ SEMANTIC VALIDATION: Automatically blocks unsafe consolidations by checking semantic similarity between concepts using [[vector-embeddings]]. Only proceeds if ALL variants have similarity >= minSemanticSimilarity threshold (default 0.7).

When to Use This Tool

Key Features

Parameters

ParameterTypeRequiredDescriptionExample
conceptsToReplacestringYesComma/semicolon-separated list of concept variants to replace”tools,Tools,TOOLS”
canonicalConceptstringYes*The canonical concept to use (*empty string for WikiLink removal)“tool”
folderstringNoSubfolder under memory root to process (default: all memory)“research/ai”
dryRunboolNoALWAYS START WITH TRUE! Preview changes without modifying files (default: true)true
createWikiLinksboolNoCreate [[WikiLinks]] from plain text instead of replacing existing (default: false)false
minSemanticSimilaritydoubleNoMinimum similarity threshold (0.0-1.0) for safe consolidation (default: 0.7)0.7

Usage Examples

Safe: Plural Consolidation (ALWAYS START HERE)

{
  "conceptsToReplace": "tools,Tools,TOOLS",
  "canonicalConcept": "tool",
  "dryRun": true
}

⚠️ First run with dryRun=true to preview changes. This is SAFE - just plural standardization.

After Dry Run: Apply the Changes

{
  "conceptsToReplace": "tools,Tools,TOOLS",
  "canonicalConcept": "tool",
  "dryRun": false
}

Only run with dryRun=false AFTER reviewing the dry run output and confirming safety.

Safe: Case Normalization

{
  "conceptsToReplace": "mcp,Mcp,MCP",
  "canonicalConcept": "MCP",
  "dryRun": true
}

Standardizes casing - semantic validation will pass as these are identical concepts.

{
  "conceptsToReplace": "machine learning,neural network",
  "canonicalConcept": "Machine Learning",
  "createWikiLinks": true,
  "dryRun": true
}

Converts plain text “machine learning” → [[Machine Learning]] for graph integration.

Scoped Repair (Specific Folder)

{
  "conceptsToReplace": "agents,Agents",
  "canonicalConcept": "agent",
  "folder": "research/ai",
  "dryRun": true
}

Limits changes to research/ai subfolder - useful for targeted cleanup.

{
  "conceptsToReplace": "test-coverage,coverage",
  "canonicalConcept": "coverage",
  "minSemanticSimilarity": 0.0,
  "dryRun": true
}

⚠️ Setting minSemanticSimilarity=0.0 disables safety checks - only use if you understand the risk.

Critical Warnings

⚠️ NEVER CONSOLIDATE THESE PATTERNS

  1. Class Names → Generic Concepts

  2. Specific Types → Generic Categories

  3. File Paths → Concepts

  4. Compound Concepts → Base Terms

✅ SAFE CONSOLIDATION PATTERNS

  1. Plurals → Singular

  2. Case Variations → Standard Case

  3. Typos → Correct Spelling

Semantic Validation Explained

How It Works

  1. Generates [[vector-embeddings]] for canonical concept
  2. Generates embeddings for each variant to replace
  3. Calculates cosine similarity between canonical and each variant
  4. Blocks operation if ANY variant falls below threshold

Similarity Thresholds

Example Validation Output

=== SEMANTIC VALIDATION ===
Checking semantic similarity with threshold 0.70...

WARNING: Unsafe consolidation detected! The following concepts are semantically dissimilar:
  - coding-agent: similarity 0.623
  - deployment-agent: similarity 0.589

This would destroy semantic meaning. Review concepts manually or increase similarity threshold.

Dangerous Operations

{
  "conceptsToReplace": "deprecated-concept",
  "canonicalConcept": "",
  "dryRun": true
}

⚠️ Empty canonicalConcept removes [[brackets]] entirely, breaking graph connections. Only use for de-linking obsolete concepts.

Bypassing Semantic Validation

{
  "minSemanticSimilarity": 0.0
}

🚨 Disables safety checks - you can destroy semantic meaning. Only use if semantic validation is preventing a consolidation you’ve manually verified as safe.

Common Patterns

Standard Repair Workflow

  1. Analyze First: Run AnalyzeConceptCorruption to understand variants
  2. Dry Run: Run RepairConcepts with dryRun=true
  3. Review Output: Check what would be changed
  4. Verify Safety: Ensure semantic validation passed
  5. Apply Changes: Run with dryRun=false
  6. Sync Graph: Run Sync tool to rebuild knowledge graph

Incremental Cleanup

Process concept families one at a time rather than bulk operations:

# Step 1: Fix "tool" family
RepairConcepts conceptsToReplace='tools,Tools' canonicalConcept='tool' dryRun=true

# Step 2: Fix "agent" family
RepairConcepts conceptsToReplace='agents,Agents' canonicalConcept='agent' dryRun=true

# Step 3: Fix "test" family
RepairConcepts conceptsToReplace='tests,Tests' canonicalConcept='test' dryRun=true

Folder-Scoped Repairs

Test repairs on small subfolders before processing entire memory:

{
  "conceptsToReplace": "experimental,Experimental",
  "canonicalConcept": "experiment",
  "folder": "research/experiments",
  "dryRun": true
}

Troubleshooting

Error: “WARNING: Unsafe consolidation detected!”

Cause: Semantic similarity validation failed - variants are not semantically equivalent Solution: Review the similarity scores. If consolidation is truly safe, either:

  1. Reconsider if these concepts should remain distinct (usually the right answer)
  2. Set minSemanticSimilarity=0.0 to override (only if manually verified safe)

Cause: Set createWikiLinks=true with empty canonicalConcept Solution: Choose one mode: create WikiLinks OR remove them, not both

Result: “Files scanned: 0”

Cause: Folder parameter points to non-existent directory Solution: Verify folder path relative to memory root, or omit for full memory scan

Semantic Validation Warning But Operation Seems Safe

Cause: Embeddings don’t capture context (e.g., “tests” vs “test” may have lower similarity than expected) Solution: Review specific use cases, then override with minSemanticSimilarity=0.0 if truly safe

Changes Not Reflected in Graph

Cause: Forgot to run Sync after applying repairs Solution: Always run Sync tool after RepairConcepts to rebuild knowledge graph

Output Structure

Dry Run Output

=== SEMANTIC VALIDATION ===
Checking semantic similarity with threshold 0.70...
All variants passed semantic validation.

Scanning 245 markdown files...
Looking for variants: tools, Tools, TOOLS
Will replace with: [[tool]] (normalized: tool)

Would modify: research/machine-learning/transformers.md
  [[tools]] → [[tool]]
  [[Tools]] → [[tool]]
Would modify: projects/2024/ai-infrastructure.md
  [[TOOLS]] → [[tool]]

=== SUMMARY ===
Files scanned: 245
Files to modify: 2
Total replacements: 3

This was a DRY RUN. To apply changes, run with dryRun=false

After applying changes, run 'sync' to rebuild the graph with clean concepts.

Actual Run Output

✓ Modified: research/machine-learning/transformers.md
  [[tools]] → [[tool]]
  [[Tools]] → [[tool]]
✓ Modified: projects/2024/ai-infrastructure.md
  [[TOOLS]] → [[tool]]

=== SUMMARY ===
Files scanned: 245
Files modified: 2
Total replacements: 3

✓ Changes applied successfully!
Run 'sync' to rebuild the graph with the cleaned concepts.

Example Repair Session

Step 1: Analyze the Problem

{
  "conceptFamily": "tool"
}

Output shows: [[tool]] (245x), [[tools]] (89x), [[Tools]] (12x), [[VectorTools.cs]] (18x)

Step 2: Plan Safe Repairs

✅ Safe to merge: [[tools]], [[Tools]] → [[tool]] 🚨 DO NOT merge: [[VectorTools.cs]] (file path)

Step 3: Dry Run

{
  "conceptsToReplace": "tools,Tools",
  "canonicalConcept": "tool",
  "dryRun": true
}

Step 4: Review Semantic Validation

=== SEMANTIC VALIDATION ===
All variants passed semantic validation.
  - tools: similarity 0.983
  - Tools: similarity 0.983

Step 5: Review Changes

Would modify: 15 files
Total replacements: 101

Step 6: Apply Repairs

{
  "conceptsToReplace": "tools,Tools",
  "canonicalConcept": "tool",
  "dryRun": false
}

Step 7: Rebuild Graph

{
  "tool": "Sync"
}

Ma Protocol Compliance

RepairConcepts follows Maenifold’s Ma Protocol principles:

This tool embodies Ma Protocol’s principle of preserving space through careful action - the semantic validation ensures you don’t collapse important conceptual distinctions in your [[knowledge-graph]].