HydraScope
Live Agent Context Layer (Skills, 64 MCP Tool Definitions, Resolved Entities, and Multi-Hop AST/ADR Lineage) Built on Self-Hosted HydraDB (v0.4.0)
Launch Live Demo (https://hydrascope.krusch.dev) · Watch Loom Walkthrough (4m 45s) · Read Architecture Write-Up (krusch.dev) · Read Ontology Triad Paper (krusch.dev)

Most agent stacks preload dozens of MCP tool schemas into every prompt window (12,000+ tokens before Turn 1) or bolt on a flat cosine vector store that retrieves deprecated v1 tools, misses mandatory post-check tools that share zero vocabulary with the user prompt, and repeats entity-lookup round-trips on every run.
I built HydraScope on the open-source HydraDB (v0.4.0) graph engine (hydra-db/hydradb) as a live, self-sharpening context store for AI agents. HydraScope stores an agent's Skills, MCP Tool Definitions, Resolved Entities, and Code/ADR Lineage in HydraDB, traverses only the structural subgraph each task requires, and writes newly resolved entity aliases and co-executed tool paths back into HydraDB after every run.
Architecture: How HydraDB Powers the Context Layer
flowchart LR
P["Agent Task Prompt"] --> G["Pre-Flight Ontology Gate (0 LLM Tokens)"]
G -->|"Ungrounded subsystem"| B["Block Hallucination Trap"]
G -->|"Grounded"| H["HydraDB v0.4.0 OpenCypher Traversal"]
H --> S["Skills -> Active MCP Tools -> Mandatory Post-Checks"]
H --> E["Resolved Entities (:RESOLVED_TO) + 2-Hop AST & Active ADRs (:SUPERSEDES)"]
S & E --> C["Compact Agent Slice (~520-721 Tokens)"]
C --> W["Post-Run Writeback: MERGE Resolved Entities & Tool Shortcuts into HydraDB"]
W --> H
Why Plain Vector Stores and Tool Preloading Fail Here
- Zero-Lexical-Overlap Tool & Code Dependencies: Refunding a disputed Stripe invoice (
stripe_v2_idempotent_refund) requires running double-entry cent conservation (ledger_verify_cent_conservation) and appending an HMAC receipt (audit_append_signed_receipt). In 1024d embedding space (snowflake-arctic-embed2), those mandatory post-check tools score < 0.20 cosine similarity to "partner invoice refund" and are missed 100% of the time. HydraDB walks (Skill)-[:IMPACTS*1..2]->(McpTool) deterministically.
- Temporal Supersession Poisoning (
:SUPERSEDES): Deprecated tools (stripe_v1_legacy_charge_refund) and retired Architecture Decision Records (ADR-003: SHA-1 webhook check) often share more surface keywords with user prompts than their v2 replacements (ADR-014: HMAC-SHA256), causing vector stores to inject retired rules at rank #1. HydraScope traverses :SUPERSEDES edges to block retired tools/ADRs at HEAD while supporting exact asOf historical time-travel replay.
- Continual Entity & Path Compression Across Runs: A flat vector store has no structural memory of entities resolved on prior turns (
"Acme Logistics" -> acct_partner_99281), forcing repeated lookup tool round-trips. HydraScope persists :RESOLVED_TO entity nodes and compressed tool chains into HydraDB via OpenCypher MERGE, collapsing multi-turn fan-out chains into a single pass.
- Zero-Token Pre-Flight Answerability Shield: When asked about subsystems absent from the architecture (
Kafka, Kubernetes), vector stores still return top-k neighbors (cosine ~0.50), tempting the model to fabricate configurations. HydraScope grounds domain nouns against the HydraDB ontology first and halts ungrounded traps at 0 tokens.
Measured Benchmarks, Baselines, and Continual Learning
All benchmarks are reproducible via npm run continual, npm run bench, and npm run load against self-hosted ghcr.io/hydra-db/hydradb:0.4.0 and real 1024d snowflake-arctic-embed2 dense embeddings (with a deterministic 256d hashed n-gram cosine fallback when running offline).
1. Track 2 Agent Context Layer: 64 MCP Tools + Continual Learning (Epoch 1 -> Epoch 4)
Workload: 8 MCP servers (stripe, ledger, redis, pagerduty, vault, postgres, github, audit = 64 tool schemas totaling 12,412 preload tokens) across multi-turn operational tasks with recurring organization/cluster entities and retired v1 tool traps.
| Context Strategy |
Tool Recall |
Tool Precision |
Tool F1 |
Single-Turn Ready |
Deprecated Tool Poison |
Mean Round-Trips |
Mean Prompt Tokens |
| Baseline 1: Preload All 64 MCP Tools |
100.0% |
4.7% |
9.0% |
0.0% |
100.0% |
2.50 |
12,412 |
Baseline 2: Dense 1024d Vector Top-5 |
33.3% |
20.0% |
25.0% |
0.0% |
100.0% |
5.00 |
1,132 |
| HydraScope Epoch 1 (Cold Graph) |
100.0% |
75.0% |
85.7% |
0.0% |
0.0% |
2.50 |
883 |
| HydraScope Epoch 2 (+Resolved Partner) |
100.0% |
87.5% |
93.3% |
50.0% |
0.0% |
1.75 |
802 |
| HydraScope Epoch 3 (+Resolved Cluster) |
100.0% |
93.8% |
96.8% |
75.0% |
0.0% |
1.38 |
761 |
| HydraScope Epoch 4 (Converged Graph) |
100.0% |
100.0% |
100.0% |
100.0% |
0.0% |
1.00 |
721 (-94.2%) |
2. Multi-Hop Code AST + Temporal ADR Suite (8 Scenarios)
| Retrieval Arm |
Scenario Pass Rate |
Critical Multi-Hop Recall |
Temporal Poisoning |
Trap Block Rate |
Mean Prompt Tokens |
| Full-Repo Stuffing |
50.0% (4/8) |
100.0% |
100.0% |
0.0% |
4,813 |
Dense 1024d Vector Top-K (k=4) |
12.5% (1/8) |
77.8% |
100.0% |
0.0% |
1,257 |
HydraScope Structural Graph (hydradb:0.4.0) |
100.0% (8/8) |
100.0% |
0.0% |
100.0% |
520 (-89.2%) |
3. Self-Hosted hydradb:0.4.0 Concurrent OpenCypher Load Test
- Workload:
64 concurrent mixed OpenCypher multi-hop MATCH traversals and 1-hop MERGE mutations across 8 parallel workers on ghcr.io/hydra-db/hydradb:0.4.0.
- Measured Result:
64 / 64 (100%) succeeded, ~409 ops/sec, P50 = 11.7ms, P95 = 40.6ms, P99 = 58.7ms, verified via monotonic sgk:1:... read-epoch bookmarks.
How I Use HydraDB & @hydradb/selfgraph Across My Daily Stack
Across my local multi-node Linux workstation and GPU servers, my coding agents and background SRE daemon coordinate 8 MCP servers (40+ tools) and dozens of active repositories. Preloading every tool schema burned 10k+ tokens before Turn 1, while 1024d cosine vector search repeatedly surfaced retired ADRs or missed mandatory 2-hop verification tools that shared zero keywords with my prompt. Running self-hosted hydradb:0.4.0 together with @hydradb/selfgraph (src/connectors/selfgraph-store.js) solved three concrete bottlenecks across my stack:
- IDE & Fleet Coding Context (
hydrascope-mcp on HydraDBStore + KuzuStore): My global IDE MCP config mounts hydrascope-mcp against self-hosted hydradb:0.4.0 (supporting HydraDBStore over Bolt :7687 as well as embedded KuzuStore for zero-daemon local CLI/worktree sessions). Personalized PageRank (strategy: "ppr") walks Skill -> McpTool -> CodeSymbol -> AdrRule subgraphs inside a 520-750 token budget at $0 LLM extraction cost, contradiction: "supersede" (max_count: 1 on ACTIVE_RULE_FOR and RESOLVED_TO) retires outdated rules automatically on write while keeping asOf / knownAt history queryable, and SelfGraph.readiness() + graph.diff(since, until) audit orphan symbols and recent graph mutations after repository compiles.
- Bi-Temporal Personal Knowledge Graph in
krusch-companion: In my daily local-first personal assistant, flat SQLite notes and vector chunks struggled whenever single-valued facts changed over time (who works where, current primary contractor/vendor, current address) or when voice notes created duplicate contact mentions ("M. Chen" vs "Maya Chen"). Embedding @hydradb/selfgraph (KuzuStore alongside companion.db, zero extra daemon or GPU VRAM overhead) gave me automatic max_count: 1 supersession on WORKS_AT, LIVES_IN, and PRIMARY_VENDOR_FOR, owner-certified ground-truth relations (relations.certify so background note re-ingestion never overwrites verified facts), and reversible entity merges (entities.unmerge).
- CLI, HTTP, MCP & Upstream Contributions: You can run
npm run selfgraph -- "Update per-item partner fee rounding in calculatePartnerFee", hit GET /api/selfgraph/status or POST /api/selfgraph/retrieve (live on https://hydrascope.krusch.dev), or pass engine: "selfgraph" to hydrascope_traverse_context over stdio MCP. Dogfooding SelfGraph against real ontologies in both repos surfaced subtle cross-SDK edge cases around multi-endpoint max_count supersession, schema alias canonicalization, known_at provenance, and explicit stopword/single-character entity terms in check_answerable, which I fixed and contributed back upstream across 9 PRs (#149, #156, #157, #167, #179, #180, #208, #215, and #243).
4-Axis Brick Ontology Bridge & The Common Ground · HydraScope · DEADBOLT Triad
HydraScope serves as Pillar 2 of the Common Ground · HydraScope · DEADBOLT Ontology Triad, bridging organizational context from MIT-licensed 0xANUSHKA/common-ground-8090, sealed multi-stack blueprints from @krusch/toolkit (brick-exchange