1. Why None of the Three Pieces Was Complete on Its Own
When you build infrastructure for autonomous coding agents under sprint pressure, you usually attack one failure mode at a time. Across the HydraDB Hackathon and EVOLVE (the 8090 AI Hackathon in Redwood City), three distinct failure modes surfaced in separate projects:
- Cross-Organization Trust & Data Privacy (Common Ground, MIT): Built by Anushka Jogalekar and Connor Hood (
common-ground-theta.vercel.app), Common Ground solved how two portfolio companies or partner teams can share a contract-verified function under scoped grants and rebind local field names without ever uploading private schemas or customer rows. - Intra-Repository Blast Radius & Tamper Governance (DEADBOLT, MIT): Built on my
@krusch/toolkitGolden Bricks, DEADBOLT solved what happens after code enters a repository: running 4-gate fault-injection sandboxes, locking adopted files with.brick-lock.json, and computing 2-hop WebAssembly Tree-sitter caller cones so parallel subagents never step on shared choke points or introduce+1¢SOX rounding drift two imports away. - Structural & Temporal Graph Context (HydraScope on HydraDB v0.4.0): Built on self-hosted HydraDB and inspired by
hydra-db/selfgraph(where I also contributed 8+ maintainer-merged upstream PRs), HydraScope solved why flat keyword and cosine vector stores fail as an agent context layer: replacing prompt bloat and deprecated-rule poisoning with deterministic OpenCypher traversal and temporal:SUPERSEDESlineage.
In Paper #29, I combined the first two pieces into @krusch/toolkit/brick-exchange (Brick #40) and sent a thank-you note to Common Ground's creators crediting their MIT repository. When they wrote back with explicit encouragement to keep iterating on the design, the missing structural link between all three projects became obvious.
Without HydraScope and HydraDB sitting in the middle, even an Ed25519-sealed Brick Exchange still relies on flat text matching to connect builders and agents. Flat text matching breaks in four predictable ways across real multi-stack organizations:
- Runtime Purity Blindness: A brick that passes all four Node 22 sandbox gates while importing
node:fsornode:cryptolooks valid in keyword search, yet immediately breaks acloudflare-edgeWorker isolate or areact-vitebrowser bundle. Conversely, a Python FastAPI squad searching for a webhook verifier needs to know whether an equivalent native brick already exists in Python (krusch_toolkit.security) or whether it needs a typed hexagonal contract adapter (binding_adapter.py). - Opaque Identifier Collisions: Two bricks that both expose a field named
channel_idappear compatible to naive schema or embedding search even when one emits a Slack channel identifier (slack:channel_id) and the downstream brick expects a Discord snowflake (discord:channel_id). - Multi-Hop Composition Blindness: When a team needs to turn a raw signed Stripe webhook into a balanced minor-unit ledger entry, no single brick may span the entire gap, even though
brickAproducesledger_eventandbrickBconsumesledger_eventacross a 2-hop chain. - Version Supersession Poisoning: As security bricks evolve from
@v1to@v2, lexical and vector similarity continue surfacing retired@v1bundles alongside current ones unless explicit:SUPERSEDESedges prune superseded versions before ranking.
2. What HydraDB's Property-Graph Ontology Brings to the Exchange
The word ontology gets overused in AI tooling, often as a dressed-up label for a static JSON taxonomy. What HydraDB v0.4.0 (ghcr.io/hydra-db/hydradb:0.4.0) and SelfGraph bring to HydraScope is concrete and operational: an executable OpenCypher property graph with deterministic vertex addressing, typed multi-hop edge traversal, pre-flight answerability gates, and first-class temporal supersession.
In brick-ontology-bridge.js and @krusch/toolkit/brick-exchange/ontology, five graph capabilities turn isolated bricks into a navigable engineering ontology:
- Deterministic 48-Bit Surrogate OpenCypher Vertices & 10 Typed Relations: Every ontology entity (
brick:<id>@<hash>,stack:*,port:*,channel:*,moe:*, andorg:*) hashes viasurrogateOntologyVertexId(namespace, logicalId)into a collision-resistant IEEE-754 safe integer in[1000, 281474976711655]matching HydraDB's native OpenCypher vertex contract. Edges are strictly allowlisted across ten structural types::TARGETS_STACK,:CONSUMES_PORT,:PRODUCES_PORT,:BRIDGES_CHANNEL,:ROUTES_TO_MODEL,:USES_STACK,:LISTENS_CHANNEL,:REQUIRES_PORT,:SUPERSEDES, and:GOVERNS. Before any vertex touches HydraDB,INV-HS-02scrubs private network literals, file paths, and email addresses. - The Permission-Before-Traversal Invariant: Graph databases become dangerous across organizational boundaries if you traverse the full global graph first and redact unauthorized nodes at the end, because 2-hop path existence can still leak a partner company's private capabilities. Fusing Common Ground's privacy rule directly into
store.planCrossStackComposition({ viewerId, ... })enforces a strict ordering:evaluateVisibilityForBundlefilters the candidate set forviewerIdbeforecompileBrickOntologyGraphmaterializes a single vertex or edge. Unshared bricks never enter the caller's ontology subgraph. - Temporal
:SUPERSEDESLineage & HistoricalasOfReplay: Whenbrick:webhook-hmac@v2declaressupersedes: ["brick:webhook-hmac@v1"], the graph compiler automatically marks@v1withisCurrent: false,retiredAt, andsupersededBy. Live OpenCypher and embedded traversals prune retired bricks by default so coding agents stop adopting deprecated helpers, while passingasOf: "2026-11-01"deterministically reconstructs the exact brick topology that was active on an earlier audit date. - 2-Hop Typed Port Composition Without False Bridges: When a developer or agent requests a workflow spanning
webhook_envelope -> audit_recordontypescript-node, HydraScope traverses both 1-hop direct bricks and 2-hop pipelines (brickA -[:PRODUCES_PORT]-> port:ledger_event -[:CONSUMES_PORT]-> brickB). Crucially, shared canonical ports allow composition while vendor-namespaced opaque identifiers (slack:channel_idvs.discord:channel_id) refuse to bridge. - Unified
:GOVERNSMerging Into Repository AST Graphs: Because HydraScope already compiles polyglot repositories (10 languages via WebAssembly Tree-sitter) into file, symbol, and ADR vertices,mergeOntologyIntoRepoGraph(repoGraph, ontologyGraph)wires:GOVERNSedges directly from adopted ontology bricks into the exact repository symbols and files importingbricks/<id>. An agent querying HydraScope sees, in one unified graph, the upstream Common Ground contract, the HydraDB port and channel invariants, and DEADBOLT's 2-hop caller blast radius inside the repo.
3. Inside the 4-Axis Ontology: Stacks, Ports, Channels & MoE Specialists
To keep ontology metadata practical rather than bureaucratic, normalizeBrickOntologyMetadata infers sensible defaults from existing blueprints while checking four orthogonal axes in under 1 ms:
| Ontology Axis | Canonical Entities in INV-LEGO-36 |
Deterministic Safety or Compatibility Check | Failure Code / Bridge Action |
|---|---|---|---|
| Axis 1: Runtime Stacks ( ONTOLOGY_STACKS) |
node-esm, typescript-node, python-fastapi, react-vite, cloudflare-edge + 40 JS/TS/Py catalog equivalents |
Comment/literal-aware lexer (isWebStandardPureSource) rejects node:* / host bare modules on Edge & Browser stacks; resolves Python krusch_toolkit.* twins |
STACK_RUNTIME_INCOMPATIBLE or bridgeMode: "contract-adapter" (binding_adapter.py) |
| Axis 2: Data Ports ( ONTOLOGY_DATA_PORTS) |
timeseries_window, ledger_event, webhook_envelope, audit_record, identity_claims, document_page + <ns>:<id> |
Maps field-alias synonym rings (ts_ms/recorded_at -> ts; amount_cents -> gross) and isolates vendor ID namespaces |
PORT_NAMESPACE_COLLISION (blocks slack:channel_id -> discord:channel_id) |
| Axis 3: Channels ( ONTOLOGY_CHANNELS) |
webhook:github, webhook:slack, webhook:stripe, workspace:gmail|drive|calendar, mcp:stdio, http:sse, telemetry:timeseries |
Verifies constant-time HMAC + replay-window bricks (@krusch/toolkit/webhooks) on signed webhooks & PII scrubbing on Workspace channels |
CHANNEL_SECURITY_GUARD_MISSING when required verifier brick is absent |
| Axis 4: MoE Specialists ( ONTOLOGY_MOE_PROFILES) |
timeseries-cadence-moe, financial-integer-ledger, cross-stack-schema-adapter, channel-security-normalizer |
Enforces numerical invariants (integer minor units, monotonic timestamps, NaN/Infinity rejection) & routes unmapped adapter repair via cascade.js |
TIMESERIES_INVARIANT_VIOLATION; escalates $0 Tier-0 -> L1 gemma4:e4b -> L2 30B MoE |
Zero-Upload Hexagonal Adapter Synthesis Across JavaScript, TypeScript, and Python
One of Common Ground's sharpest insights at EVOLVE was separating an immutable verified logic file from a recipient-editable local binding so each company maps its own internal column names on its own laptop. Extending that pattern across the 4-axis ontology yielded synthesizeBrickBinding:
- Tier-0 Deterministic Synonym Resolution (
$0.00,<1 ms): When a partner team runskrusch-lego ontology bindagainst a local sample file (for example, rows keyed byrecorded_atandreadinginstead oftsandval, oramount_centsandtenant_idinstead ofgrossandorgId),ONTOLOGY_DATA_PORTSresolves the field map deterministically with zero LLM calls and zero bytes uploaded. - Stack-Native Adapter Generation + Locked Sandbox Proof: For
node-esm,react-vite, andcloudflare-edge, the engine emitsbinding.js; fortypescript-node, it emits strictly typedbinding.ts; and forpython-fastapi, it emits a Python 3.11+ hexagonal contract module (binding_adapter.pywithadapt_inputandadapt_batch) rather than pretending Python executes V8 closures in-process. On JS/TS targets,synthesizeBrickBindingimmediately executes the adapted local sample insidetryBrickLocally's locked Node 22 sandbox before writing the adapter to disk. - Cascade-Routed MoE Escalation Only When Needed: Only when a local payload has unmapped structural mismatches outside the deterministic alias ring does the engine invoke an optional local repair callback routed through
@krusch/toolkit/cascade(stepping from fast localgemma4:e4bup toqwen3-coder-30b-moefor cadence or integer-cent conservation rules), re-verifying every candidate mapping inside the sandbox.
4. Walkthrough: One Cohesive Pipeline From Cross-Org Grant to 2-Hop Repo Merge
Putting all three pillars side by side shows how a real cross-team task flows through the unified stack without hand-offs or copy-pasted glue code:
Step 1 · Common Ground Gate
Team A seals a TypeScript telemetry or Stripe settlement brick (passing all 4 sandbox + fault-injection gates with an Ed25519 signature) and issues a time-bounded Grant to Team B. Unshared orgs see zero vertices.
Step 2 · HydraScope + HydraDB
Team B runs ontology compose for cloudflare-edge or python-fastapi. HydraScope prunes retired :SUPERSEDES bricks, blocks slack != discord port collisions, and synthesizes a local binding adapter at 0 B upload.
Step 3 · DEADBOLT Promotion
Team B vendors the brick with .brick-lock.json, merges :GOVERNS edges into HydraScope's repo AST graph, and runs planAgentFanOut + verifyTwoHopBlastRadius so parallel subagents wire consumers without 2-hop regressions.
# 1. Inspect the 4-axis ontology & JS/TS/Python/React/Edge catalog equivalents
node bin/krusch-lego.js ontology inspect
node bin/krusch-lego.js ontology inspect webhooks --json
# 2. Check runtime purity, channel HMAC guards & port compatibility in <1ms
node bin/krusch-lego.js ontology check ./sealed-brick.json \
--stack cloudflare-edge \
--channel webhook:stripe
# 3. Run permission-pre-filtered 1-hop & 2-hop composition with temporal asOf replay
node bin/krusch-lego.js ontology compose \
--db ./exchange.db \
--viewer partner-eng \
--stack typescript-node \
--channel webhook:stripe \
--ports ledger_event,audit_record
# 4. Synthesize a zero-upload TypeScript or Python 3.11+ hexagonal adapter locally
node bin/krusch-lego.js ontology bind ./sealed-brick.json \
--stack python-fastapi \
--sample ./local-private-rows.json \
--out ./bricks/telemetry-completeness/binding_adapter.py
When self-hosted HydraDB v0.4.0 is online, HydraScope's syncAndQueryBrickOntology syncs these exact vertices and 10 edge types into OpenCypher via idempotent MERGE batches (sustaining 416.4 ops/sec concurrent throughput in HydraScope's load benchmark) while keeping an automatic sub-millisecond embedded BFS fallback (INV-HS-03) whenever an engineer works offline on a laptop.
5. Scope Boundaries, Tradeoffs & Where Simpler Tooling Wins
Uniting a cross-organization grant model, a 4-axis OpenCypher ontology, and a 2-hop AST blast-radius verifier solves real failure modes, yet clear engineering honesty requires naming what this architecture does not claim to do:
- When Embedded SQLite or Plain Monorepos Are Enough: If one team works inside a single Node or Python monorepo with fewer than a dozen shared internal modules, standard workspace packages plus
krusch-lego auditalready enforce boilerplate and security rules in under1 mswithout running a separate graph server. Self-hosted HydraDB v0.4.0 earns its operational footprint when an agent context layer must traverse 64+ MCP tools, multi-repo polyglot AST symbols, temporal ADR supersession chains, and cross-team brick graphs together. - Hexagonal
contract-adapterBoundaries vs. Cross-Language Transpilation: SettingtargetStack: "python-fastapi"on a JavaScript or TypeScript brick intentionally returnsbridgeMode: "contract-adapter"and generates a typed Python 3.11+ input/batch normalizer (binding_adapter.py) around hexagonal JSON/HTTP/MCP boundaries, or points to the native Python twin inkrusch_toolkitviaCROSS_STACK_BRICK_EQUIVALENTS. It does not magically transpile arbitrary JavaScript closures into native Python bytecode. - Curated Ontology Axes vs. Arbitrary Unmodeled Schemas: The built-in synonym rings and port-isolation guards cover six canonical shared ports (
timeseries_window,ledger_event,webhook_envelope,audit_record,identity_claims, anddocument_page) plus explicit<namespace>:<port>scoping. Domain schemas outside those rings require explicitfieldMapdeclarations or sandbox-rechecked local MoE synthesis rather than silent heuristic guessing. - Static 2-Hop &
:GOVERNSHorizons: Both DEADBOLT's 2-hop AST blast-radius cones and HydraScope'smergeOntologyIntoRepoGraphoperate over static import, export, and symbol graphs. Dynamicimport(runtimeExpr)specifiers, reflection, or cross-service queue consumers beyond modeled channel edges still require end-to-end integration tests, and participating organizations retain full responsibility for Ed25519 key rotation, corporate IP/NDA review, and schema governance. - Reference Implementation & Verification Status: Every invariant described in this paper is exercised across
279passing automated tests in three public MIT repositories:test_brick_ontology.jsinside@krusch/toolkit(179/179tests),brick-ontology-bridge.test.jsinsideHydraScope(22/22tests), andbrick-ontology.test.jsinsidekrusch-stack(78/78tests). External multi-company production deployments and independent third-party security audits have not been conducted yet.
6. Run the Full 3-Pillar Ontology Stack Locally
All three repositories ship under the MIT License, crediting Anushka Jogalekar and Connor Hood's MIT-licensed 0xANUSHKA/common-ground-8090 for inspiring the permission-scoped contract-sharing layer and hydra-db/hydradb + hydra-db/selfgraph for the OpenCypher graph and temporal ontology foundations:
# 1. Verify @krusch/toolkit (179/179 tests incl. 4-axis ontology & Brick Exchange)
git clone https://github.com/kruschdev/toolkit.git && cd toolkit
PUPPETEER_SKIP_DOWNLOAD=true npm install && npm test
# 2. Verify HydraScope's OpenCypher ontology bridge & :GOVERNS AST merge (22/22 tests)
git clone https://github.com/kruschdev/HydraScope.git && cd HydraScope
npm install && npm test
# 3. Verify standalone zero-dep parity in krusch-stack (78/78 tests)
git clone https://github.com/kruschdev/krusch-stack.git && cd krusch-stack
npm install && npm test