Graph Agent Protocol (GAP): Unifying Typed Discovery, Batched Federation, and Zero-Trust Governance for AI Agents

Duy Đức Nguyễn · Infinite Agent Labs · office@infiniteagentlabs.com · ORCID: 0009-0009-4741-5637
Reference Release v0.1.0-rc.1 · November 16, 2026 · Apache-2.0 · Code & Artifacts: https://github.com/vnknowledge2014/GraphProtocol
Abstract. AI agents increasingly invoke REST/OpenAPI APIs, SQL stores, GraphQL subgraphs, gRPC endpoints, CLI utilities, codebases, Model Context Protocol (MCP) tool servers, peer Agent2Agent (A2A) workers, and interactive AG-UI interfaces. Current deployments fragment this plane across flat JSON-RPC catalogs (MCP), opaque peer task endpoints (A2A), and ad-hoc frontend streams, causing O(N) prompt schema inflation (203,421 tokens at N=1,000), client-orchestrated N+1 join round-trips, unpinned descriptions vulnerable to rug pulls, and hot-path latency from neural routing. We introduce Graph Agent Protocol (GAP), a strongly typed GraphQL-profile gateway built across three separated planes: (1) a Zero-ML deterministic execution plane with Cedar policy checks, tenant-keyed planning, batched DataLoader joins, and wait-free immutable snapshots backed by a pure-Rust persistent AVL OrdMap; (2) a three-level progressive discovery plane unifying MCP 2026-07-28 (651 tokens constant), A2A v1.0, and AG-UI v1.0 (/ag-ui SSE + interrupts) alongside multi-provider System-1 routers (@receptron/laya, Jev, gemini-decision-1) and automatic deterministic fallback (INV-17); and (3) a zero-trust control plane enforcing propose-not-activate ingestion, SHA-256 description-hash drift freezes, DNS-pinned SSRF egress guards, OS sandboxing, and BLAKE3 hash chains over dual-stack HTTP/2 + HTTP/3 (QUIC RFC 9114, 0-RTT disabled). Implemented across 32 layered Rust crates with zero RUSTSEC advisories, GAP cuts cross-branch token usage at N=1,000 by 99.0% uncached (93.5% cached) and code-graph context by 119.3x–208.7x, boots its 28.1 MB bit-identical binary in 1055.0 ms at 9.32 MiB idle RSS, sustains 1,063.6 req/s over TCP (11.54 ms p95) and 5,013.1 req/s over persistent multiplexed QUIC (2.36 ms p95) with zero errors, and recovers from OS SIGKILL in 28.86 ms.
AI Agent Hosts & Dual-Stack Transport Ingress (L4) MCP 2026-07-28 (651 tok) | GAP-QL (/graphql + SSE) | A2A v1.0 Tasks | AG-UI v1.0 (/ag-ui SSE & Interrupts) | CLI Wire Edge: HTTP/1.1 + HTTP/2 TCP (Alt-Svc) · HTTP/3 QUIC UDP (RFC 9114, TLS 1.3 ALPN h3, 0-RTT disabled) · gRPC · stdio Plane 1: Deterministic Hot Execution Plane (Zero ML · INV-01 / INV-02 / INV-04) AuthN + Cedar Default-Deny Policy Scopes & Cost Caps GAP-QL Planner ArcSwap + AVL OrdMap Tenant PlanCache Batch Executor DataLoader Join O(1) P2C LB + Breaker Security Guard EgressGuard SSRF OS Sandbox & T2 Tag Native Graph Connector (NGC) Adapters + Durable Multi-Tenant State OpenAPI | GraphQL | gRPC | SQL (SQLite/PostgreSQL) | Sandboxed CLI | Code Graph (tree-sitter) ContextStore (SQLite WAL/FTS5 + opt. SurrealDB) · TaskStore Leases · BLAKE3 Audit Chain Plane 2: Calibrated Discovery __metaGraph (L0) -> __search (L1) -> __type (L2) BM25 + HNSW Hybrid + Visibility Bitset (INV-05) Opt. S1 (Laya, Jev, Gemini Dec. 1) + Fallback (INV-17) Plane 3: Zero-Trust Control Plane Propose-Not-Activate + T0 / T1 / T2 Trust Tiers SHA-256 Desc-Hash Pin -> Drift Freeze (SEC-082) Wait-Free ArcSwap Publish + Auto-Rollback Core Architectural Guarantees & Verified Runtime Invariants 1. Wait-Free Snapshot Atomicity (INV-01, INV-02): Each request pins one Arc<Snapshot> backed by pure-Rust persistent AVL OrdMap. 2. Multi-Tenant & Supply-Chain Hygiene (INV-09, ADR-002): TenantId in all keys; zero unsafe outside S1; zero RUSTSEC advisories. 3. Rug-Pull & Replay Defense (INV-08, OPS-005): Drift freezes mutations; T2 output in <gap:untrusted>; HTTP/3 0-RTT disabled. 4. Strict Layering (ARC-002): L0..L6 acyclic crate DAG ensures zero ML runtime crates reach execution, transport, or authz.
Figure 1: Three-plane zero-trust architecture of Graph Agent Protocol (GAP). Plane 1 runs typed GraphQL planning, Cedar authorization, and batched joins with zero ML models (ARC-002, INV-01, INV-04) behind dual-stack HTTP/1.1+HTTP/2 TCP and HTTP/3 QUIC transport (OPS-005). Plane 2 performs visibility-filtered progressive disclosure; Plane 3 governs proposal verification, rug-pull drift pinning, and lock-free snapshot swaps.

1. Introduction & Threat Model

Production AI agents must discover, authorize, compose, and audit operations across heterogeneous backends. Anthropic's Model Context Protocol (MCP) [1] standardizes vertical tool invocation over JSON-RPC, whereas Google's Agent2Agent (A2A) protocol [2] standardizes horizontal multi-agent delegation via Agent Cards and asynchronous task lifecycles. Operating multi-tenant gateways exposes four structural weaknesses that flat catalogs and point-to-point RPC do not solve together:

  1. Prompt Context Explosion & N+1 Waterfalls: Flat MCP exports grow linearly to 203,421 tokens at N=1,000 before reasoning begins, forcing models to issue sequential multi-turn round-trips to join cross-backend entities.
  2. Semantic Rug Pulls & Spoofed Hints: Security audits [3,4,5] show unpinned tool descriptors permit hidden prompt injection and post-approval behavioral shifts.
  3. Hot-Path Neural Entanglement: Invoking ML tool classifiers on every request adds tens of milliseconds and mixes probabilistic inference with security-critical authorization.
  4. Protocol Silos Without Typed Federation: Treating SQL tables, REST APIs, CLI binaries, and code ASTs as unrelated untyped tools forces the LLM to act as query planner and join engine.

GAP enforces a simple engineering rule: use deterministic compilers, typed graphs, and formal policy engines wherever structure exists, and confine probabilistic retrieval strictly to bounded, calibrated intent discovery (ARC-002).

2. Three-Plane Architecture & Invariants

As Figure 1 shows, GAP assigns every downstream backend (branch) an explicit trust tier: T0 (Ed25519-signed internal manifest; signature mismatch downgrades fail-closed to T2), T1 (admin-approved and pinned via cryptographic spec_hash and desc_hash), and T2 (untrusted external branches whose text outputs are length-capped, scrubbed, and wrapped inside escaped <gap:untrusted> envelopes, with CLI/stdio blocked without OS sandboxing).

To prevent architectural erosion, 20 normative invariants (INV-01..INV-20) are enforced continuously via static crate layering checks (tools/check_layers.py) and strict spec traceability (tools/spec_trace.py --strict):

3. Protocol Design & Dual-Stack Transport

3.1 GAP-QL & Three-Level Progressive Disclosure

GAP-QL is a strict GraphQL profile parsed by apollo-compiler with zero custom grammar keywords [9]. Capabilities—__metaGraph (L0 branch summaries), __search (L1 hybrid BM25+HNSW candidates), __type (L2 exact SDL hydration), @sideEffect, @requiresScope, and @join—live purely as standard types and directives. Behind MCP 2026-07-28, the five-tool facade (gap_search, gap_describe, gap_query, gap_mutate, gap_task) holds tools/list invariant at 651 tokens.

3.2 Three-Axis Facades, Native Connectors & Dual-Stack HTTP/2 + HTTP/3

Six reference Native Graph Connectors (OpenAPI, GraphQL, gRPC, SQL, sandboxed CLI, tree-sitter Code) translate heterogeneous protocols into Describe, BatchQuery, and Mutate frames. At L4, gap-transport serves /graphql, /graphql/stream, /mcp (MCP 2026-07-28), A2A v1.0, and /ag-ui (AG-UI v1.0 SSE + human approval interrupts, spotlighted via <gap:untrusted>, ADR-027) over HTTP/1.1+HTTP/2 TCP (Alt-Svc: h3) and HTTP/3 QUIC (RFC 9114, 0-RTT disabled, OPS-005). Optional System-1 routing (ADR-028) unifies Candle, @receptron/laya, Jev, and gemini-decision-1 (0 output tokens, up to 1,000 parallel heads) under INV-17 baseline fallback.

4. Zero-Trust Governance & Snapshot Control

All changes enter via sandboxed gap-ingest extraction, CISG injection linting, and admin-approved Proposal records rather than auto-mutating live routing. DriftMonitor hashes sanitized upstream descriptions and immediately freezes tampered branches to BranchStatus::Drift while planners continue serving pinned baselines (SEC-082).

Outbound HTTP passes through EgressGuard, which pins resolved DNS sockets once, blocks loopback/RFC 1918/metadata IPs (169.254.169.254) and obfuscated numeric/IPv6-mapped forms across redirects. Subprocesses run inside Linux Bubblewrap or macOS Seatbelt sandboxes with SHA-256 binary allowlists. Snapshots publish off-thread via SnapshotHandle with automatic 60 s error-spike rollback and BLAKE3 chained audit logs.

Direct-MCP Schema (O(N): 1,904 -> 203,421) GAP 5-Tool Facade (constant O(1): 651) 1001,00010,000100,000Gate G-F1 Ceiling<= 1,200 tokens (O(1)) 1,904651N = 10(2 branches)10,066651N = 50(5 branches)40,586651N = 200(20 branches)203,421651N = 1000(100 branches) MCP tools/list Tokens (log10)
Figure 2: Static MCP tools/list token scaling (GQL-022 estimator). Publishing flat tool catalogs explodes to 203,421 tokens at N=1,000 tools across 100 branches, whereas GAP's five-tool progressive facade remains fixed at 651 tokens (46% below Gate G-F1's 1,200-token ceiling).
Table 1: Reproducible GAP-Bench end-to-end comparison across catalog scales (N), uncached vs. 0.10x warm-prefix cached regimes, and agent turn counts (100% task success across all cells; ratio < 1.000x denotes GAP token savings).
SuiteNDirect Unc.GAP Unc.Ratio (U)Direct Cac.GAP Cac.Ratio (C)Turns D → G
api_lookup102,041.65,823.02.852x547.24,691.98.575x1.0 → 2.0
cross_branch_join108,891.88,517.90.958x2,200.57,383.73.355x4.0 → 2.0
api_lookup5010,205.55,859.50.574x2,385.24,728.01.982x1.0 → 2.0
cross_branch_join5041,539.88,547.90.206x6,740.77,413.71.100x4.0 → 2.0
api_lookup20040,724.35,865.50.144x9,251.24,734.90.512x1.0 → 2.0
cross_branch_join200163,619.88,547.90.052x23,717.47,413.70.313x4.0 → 2.0
api_lookup1000203,559.55,878.00.029x45,889.14,747.00.103x1.0 → 2.0
cross_branch_join1000814,959.88,547.90.010x114,294.47,413.70.065x4.0 → 2.0
code_graph24141,681.31,187.40.008x137,810.4660.40.005x11.0 → 1.0
Uncached Token Ratio (GAP / Direct) Cached Token Ratio (0.10x Warm Prefix) < 1.0x = GAP Saves Tokens 0.01x0.1x1.0x (Parity)10.0x 2.85x8.57xAPIN=100.958x3.36xJoinN=100.574x1.98xAPIN=500.206x1.10xJoinN=500.144x0.512xAPIN=2000.052x0.313xJoinN=2000.0289x0.103xAPIN=10000.0105x0.065xJoinN=10000.0084x0.0048xCodeN=24 Direct-MCP Favored (> 1.0x at small N) GAP Favored (< 1.0x · up to 209x win) GAP / Direct Token Ratio (log10)
Figure 3: Crossover regime law plotting GAP / Direct-MCP prompt token ratio on a log scale. Below 1.0x (mint region), batched federation and progressive disclosure cut tokens by 95.3x–208.7x; above 1.0x (rose region), tiny cached catalogs (N≤50) still favor Direct-MCP.

5. Rust Implementation & Formal Traceability

GAP is built in Rust Edition 2024 (rustc 1.98.1) across 32 crates (L0–L6, including gap-agui and multi-provider gap-s1), forbidding unsafe everywhere outside optional gap-s1 and denying unwrap, expect, and panic in non-test paths. BSL dependencies remain strictly behind optional store-surreal. To eliminate every unmaintained/unsound third-party crate from the supply chain, snapshot maps use an owned zero-unsafe AVL OrdMap and PEM parsing uses rustls-pki-types directly, achieving 0 errors across cargo deny check advisories bans licenses sources (ignore = []).

Verification passes end-to-end across 362 specification requirements (89 MUST, 0 uncovered across 2,515 markers), 135/136 offline/loopback conformance checks, 365 1,024-case proptests, 10 fuzz targets (34 corpora), chaos, soak, and upgrade/backup drills.

6. Experimental Evaluation & Crossover Analysis

Across Table 1 and Figure 3, GAP-Bench demonstrates both massive wins and honest boundaries (ADR-017, ADR-021): at N=1,000, GAP cuts cross-branch join tokens by 99.0% uncached (93.5% cached) and halves turns (4.0 → 2.0); on code_graph (24 symbols), typed graph walks reduce turns from 11.0 to 1.0 for 119.32x uncached and 208.68x cached savings. Conversely, on tiny flat catalogs (N=10 cached: 547.2 vs. 4,691.9 tokens), single-turn Direct-MCP stays smaller, and conditional X-1 wire columnarization yielded <20% suite reduction and remains deferred.

Table 2 isolates RouteBench discovery routing: un-finetuned Candle weights score only 14.29% debiased top-1 at 73.85 ms p95, whereas GAP's deterministic lexical+structural baseline achieves 95.24% test / 97.22% held-out top-1 in 0.887 ms, justifying fail-safe BASELINE_FALLBACK under Gate G-S1.

Table 2: RouteBench comparison (ntest=48, nheld=72; 1,000 bootstrap resamples), lock-free micro-primitives (m3-baseline.json), and live bit-identical dual-stack HTTP/2 + HTTP/3 QUIC verification drills (bench/results/ga_local/report.json).
Benchmark / Drill ComponentMetric 1Metric 2Latency / ThroughputArtifact Source
baseline (BM25+Struct)Test Top-1: 95.24%Held Top-1: 97.22%0.887 ms p95s1_comparison.json
s1_forward (laya-candle:f32)Test Top-1: 7.14%ECE15: 0.044542.34 ms p95s1_comparison.json
s1_debiased (Laya + PMI)Test Top-1: 14.29%ECE15: 0.030373.85 ms p95s1_comparison.json
Lock-Free Balance / RCUArcSwap load: 15 nsGuard / CAS / P2C: 42 / 44 / 94 nsStore p99 @256r: 59 µsm3-baseline.json
gap serve (TCP HTTP/1.1+2)Cold start: 1055.0 msIdle / Peak RSS: 9.32 / 16.30 MiB1,063.6 req/s (11.54 ms p95, 0 err)ga_local/report.json
HTTP/3 QUIC (8 mux conns)TLS 1.3 ALPN h30-RTT: Disabled · Alt-Svc5,013.1 req/s (2.36 ms p95, 0 err)ga_local/report.json
Binary Parity & CrashSize: 28,084,064 BDouble SHA-256: IdenticalSIGKILL recover: 28.86 msga_local/report.json
Lock-Free RCU / Balance (ns) Deterministic Route & HTTP/2 + HTTP/3 Load (ms) Lifecycle (ms) Un-finetuned S1 (ms) 10 ns100 ns1 µs10 µs100 µs1 ms10 ms100 ms1 s ArcSwap::load (M0)15 nsIn-Flight RAII Guard42 nsEWMA Update (CAS)44 nsP2C N=2 Select94 nsBaseline Route p950.887 ms (95.2% top-1)HTTP/3 QUIC Mixed p952.36 ms (5,013 req/s, 8 conn)HTTP/2 TCP Mixed p9511.54 ms (1,064 req/s, urllib)SIGKILL Recover /readyz28.86 msLaya S1 Debiased p9573.9 ms (14.3% top-1)Cold Start /readyz1055 ms (9.3 MiB RSS) Measured Latency Spectrum (log10 nanoseconds · Release & Offline Drills)
Figure 4: Multi-scale latency spectrum across lock-free RCU/balance primitives (15–94 ns), deterministic baseline discovery (0.887 ms), live multiplexed HTTP/3 QUIC (2.36 ms p95) and HTTP/2 TCP (11.54 ms p95) mixed loads, and OS SIGKILL recovery (28.86 ms).

7. Related Work & Limitations

Retriever-assisted tool routers such as Gorilla [7] and ToolLLM [8] expand API coverage yet omit deterministic Cedar authorization [10], conformal abstention [11], and cross-backend DataLoader joins. Recent MCP security audits [3,4,5] and A2A security analyses [6] catalog poisoning and rug pulls; GAP neutralizes these via propose-not-activate ingestion, desc_hash pinning, EgressGuard, and sandboxing. GraphQL MCP servers [12] pioneered progressive GraphQL discovery, which GAP extends across arbitrary non-GraphQL backends over HTTP/2 and QUIC.

Multi-day cloud soak runs (72 h), 24 h libFuzzer sweeps, live frontier LLM sweeps, and Linux OIDC signing remain CI/cloud release gates rather than local macOS drills; locally all HTTP/2 (short-lived Python urllib clients to subprocesses) and HTTP/3 (persistent QUIC streams to in-process fixtures) benchmarks measure distinct transport topologies reported transparently above.

8. Conclusion

GAP reconciles MCP usability, A2A horizontal tasks, dual-stack HTTP/2 and HTTP/3 QUIC performance, and enterprise zero-trust security in one verified Rust gateway. All specifications, conformance tests, reproducible benchmarks, and Apache-2.0 source artifacts are openly published for verification and reuse.

References

  1. Anthropic. Model Context Protocol (MCP) Specification (incl. 2026-07-28 revision). https://modelcontextprotocol.io, 2024–2026.
  2. Google LLC and A2A Contributors. Agent2Agent (A2A) Protocol Specification. https://a2a-protocol.org, 2025.
  3. H. Song et al. Beyond the Protocol: Unveiling Attack Vectors in the Model Context Protocol Ecosystem. arXiv:2506.02040, 2025.
  4. Z. Wang et al. MCPTox: A Benchmark for Tool Poisoning Attack on Real-World MCP Servers. arXiv:2508.14925, 2025.
  5. arXiv:2512.06556 Authors. Semantic Attacks on Tool-Augmented LLMs: Securing MCP Against Descriptor Manipulation, 2025.
  6. arXiv:2504.16902 Authors. Building a Secure Agentic AI Application Leveraging A2A Protocol, 2025.
  7. S. G. Patil et al. Gorilla: Large Language Model Connected with Massive APIs. arXiv:2305.15334 (NeurIPS), 2023.
  8. Y. Qin et al. ToolLLM: Facilitating LLMs to Master 16000+ Real-world APIs. arXiv:2307.16789 (ICLR), 2023.
  9. O. Hartig and J. Pérez. Semantics and Complexity of GraphQL. In Proc. WWW '18, 2018.
  10. J. W. Cutler et al. Cedar: A New Language for Expressive, Fast, Safe, and Analyzable Authorization. Proc. ACM Program. Lang. (OOPSLA), 2024.
  11. A. N. Angelopoulos and S. Bates. A Gentle Introduction to Conformal Prediction. arXiv:2107.07511, 2021.
  12. Apollo GraphQL and Grafbase Engineering. Progressive Schema Disclosure Patterns in GraphQL MCP Servers, 2025.