stemedb/ai-lookup/features/branching.md
jordan a776744889 Initial project setup with Claude Code monorepo structure
- Rust workspace with stemedb-core crate
- Full .claude/ configuration (agents, skills, commands, guides)
- ai-lookup/ for token-efficient fact storage
- Quality gates: clippy, fmt, jscpd duplication detection
- Pre-commit hook with 5-phase quality checks
- CLAUDE.md router and CODING_GUIDELINES.md standards

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 10:56:26 -07:00

1.5 KiB

Branching ("Fork Reality")

Last Updated: 2025-01-31 Confidence: Medium (planned feature)

Summary

Branching allows agents to create hypothetical scenarios without polluting the main knowledge graph. Think "What if inflation hits 5%?" - simulate effects without committing to reality.

Key Facts:

  • Implemented via Overlay Graphs
  • Branch = lightweight index (Map<Hash, Assertion>)
  • Writes go to branch, reads check branch first then global
  • Merge commits branch assertions to global WAL
  • Copy-on-write semantics

File Pointer: crates/stemedb-core/src/branch.rs (planned, Phase 3)

How It Works

Global DAG:                    Branch "recession-2025":
[A1] -> [A2] -> [A3]          [A4-hypothetical]
                                    |
                              "inflation = 5%"

Write to Branch

// Assertions stored in branch's ephemeral index, not Global DAG
branch.put(hypothetical_assertion)?;

Read from Branch

// Check branch index first, fall back to global
let value = branch.get(hash)
    .or_else(|| global.get(hash))?;

Merge Branch

// Commit hypotheticals to global if they become real
global.merge(branch)?;  // Appends branch assertions to WAL

Use Cases

  1. Scenario Analysis: "What if competitor launches?"
  2. Planning: "What if we expand to Europe?"
  3. Backtesting: "What if we knew X earlier?"