Concepts Copy

The Memory Graph

A high-performance, deterministic knowledge graph linking files, code symbols, team decisions, and operational policies with sub-300ms recall.

BetterContext abandons flat vector stores in favor of an active, multi-relational knowledge graph. Nodes represent grounded facts and code constructs, while edges capture functional, architectural, and causal dependencies.

FRAME 01 · STRUCTURAL CODE AST & SPECIFICATION ENTITIES 01 · Code AST Functions & Classes Database Schemas Interface Contracts Tree-sitter Symbols CODE AST 02 · Specs & ADRs Markdown Doc Pages OpenAPI / gRPC DDL Architecture Records Operational Runbooks SPECS/ADR WEIGHT & DECAY FRAME 02 · TEMPORAL CONFIDENCE HALF-LIFE DECAY ENGINE Decay & Weight Engine w(t) = w0 · 2^(-Δt/t_half) Bitemporal Dual Clock Active Node Reinforce Anti-Entropy Pruning t_half Continuous Half-Life Decay • Recent commits maintain confidence ≥ 0.95 • Unreferenced documentation decays to zero • Prevents Citing Stale/Deprecated Code ACTIVATE FRAME 03 · OPERATIONAL ACTIVITY & GOVERNANCE INVARIANTS 03 · Events Git Commits & Tags Release Post-Mortems PR Review Threads Deployment Traces EVENTS 04 · Policy & Rules Negative Constraints Compliance Guardrails Security Invariants Data Residency Rules POLICIES Exponential Half-Life Anti-Entropy Pruning

Node & Entity Ontology

The graph is populated with four distinct node classes:

Confidence Half-Life Decay

Information in engineering organizations changes rapidly. Code is refactored, APIs are deprecated, and team ownership shifts. Static vector databases treat a document written 3 years ago with the same authority as one committed 10 minutes ago.

BetterContext applies a continuous exponential decay model to edge weights:

Decay Formula: w(t) = w_0 · 2^(-Δt / t_half)
• Active nodes reinforced by recent commits, agent citations, or human verification maintain high confidence (0.95+).
• Orphaned or unreferenced documentation decays in relevance, preventing agents from citing stale or misleading patterns.

Traversing the Graph via Python SDK

from bettercontext import BetterContextClient

client = BetterContextClient()

# Inspect neighbors and dependencies of a specific service
node = client.graph.get_node(id="auth-middleware-v2")
print(f"Node Type: {node.type}")
print(f"Confidence Score: {node.confidence}")

# List inbound and outbound dependencies
for edge in node.edges:
    print(f"-> {edge.relation} -> {edge.target_node.title} (Weight: {edge.weight})")

Next Steps

Was this page helpful?

Powered By BetterContext