@7h3/protocol 0.1.2 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +19 -0
- package/.github/dependabot.yml +32 -0
- package/.github/workflows/ci.yml +31 -0
- package/.github/workflows/publish.yml +59 -0
- package/.github/workflows/scorecard.yml +37 -0
- package/7h3.example.yaml +125 -0
- package/CHANGELOG.md +92 -0
- package/CONTRIBUTING.md +82 -0
- package/Dockerfile +73 -0
- package/GOVERNANCE.md +62 -0
- package/README.md +323 -6
- package/SECURITY.md +70 -0
- package/bench-results/replay-cache-full-1777891033256.json +10 -0
- package/bench-results/replay-cache-full-1777896317488.json +10 -0
- package/bench-results/replay-cache-full-1777900993184.json +10 -0
- package/bench-results/replay-cache-full-1777901019285.json +10 -0
- package/bench-results/replay-cache-quick-1777870170126.json +10 -0
- package/bench-results/signature-profiles-quick-1775875160079.json +85 -0
- package/bench-results/signature-profiles-quick-1775983539716.json +85 -0
- package/bench-results/signature-profiles-quick-1776237913190.json +85 -0
- package/bench-results/wire-codecs-full-1777891019803.json +93 -0
- package/bench-results/wire-codecs-full-1777896260964.json +93 -0
- package/bench-results/wire-codecs-full-1777901004247.json +93 -0
- package/bench-results/wire-codecs-quick-1775972879056.json +93 -0
- package/bench-results/wire-codecs-quick-1775983541111.json +93 -0
- package/bench-results/wire-codecs-quick-1776237914299.json +93 -0
- package/bench-results/wire-codecs-quick-1777841285236.json +93 -0
- package/bench-results/wire-codecs-quick-1777841321772.json +93 -0
- package/bench-results/wire-codecs-quick-1777841330408.json +93 -0
- package/bench-results/wire-codecs-quick-1777852886082.json +93 -0
- package/bench-results/wire-codecs-quick-1777852988773.json +93 -0
- package/bench-results/wire-codecs-quick-1777870188095.json +93 -0
- package/bench-results/wire-codecs-quick-1777870263918.json +93 -0
- package/bench-results/wire-codecs-quick-1777870455034.json +93 -0
- package/bench-results/wire-codecs-quick-1778816163081.json +93 -0
- package/bench-results/wire-codecs-quick-1778843936130.json +93 -0
- package/bin/7h3.ts +385 -0
- package/conformance/7h3_v0_1.json +77 -0
- package/conformance/7h3_v0_1_binary.json +20 -0
- package/conformance/aip_v0_1_binary.json +20 -0
- package/docker-compose.yaml +77 -0
- package/docs/ADOPTION_PLAN.md +120 -0
- package/docs/AGENTS.md +77 -0
- package/docs/AIP_RFC_v0.1.md +97 -0
- package/docs/AI_DECISION_CARD.md +122 -0
- package/docs/AI_RUNTIME_POLICY.json +126 -0
- package/docs/AI_RUNTIME_POLICY.yaml +110 -0
- package/docs/BACKPRESSURE_TUNING.md +65 -0
- package/docs/BENCHMARK_CLAIM_MATRIX.md +42 -0
- package/docs/BENCHMARK_REPORT_TEMPLATE.md +169 -0
- package/docs/BINARY_CODEC_BENCH.md +23 -0
- package/docs/CLEAN_CLONE_RUNBOOK.md +36 -0
- package/docs/CLOCK_SKEW_POLICY.md +30 -0
- package/docs/DISTRIBUTED_REPLAY.md +142 -0
- package/docs/FUZZ_CAMPAIGN.md +121 -0
- package/docs/GATEWAY.md +195 -0
- package/docs/KEY_MANAGEMENT_POLICY.md +53 -0
- package/docs/KEY_REVOCATION.md +69 -0
- package/docs/MCP_WRAPPER.md +159 -0
- package/docs/MIGRATION_GUIDE.md +40 -0
- package/docs/OPERATORS.md +184 -0
- package/docs/PERF_REGRESSION_POLICY.md +34 -0
- package/docs/PROJECT_EXAMINATION_2026-05-31.md +219 -0
- package/docs/RELEASE_BENCHMARK_REPORT_2026-05-15.md +135 -0
- package/docs/RELEASE_GATE.md +25 -0
- package/docs/RELEASE_NOTES_v0.1.0.md +54 -0
- package/docs/SECURITY_REVIEW_2026-06-05.md +165 -0
- package/docs/TELEMETRY.md +41 -0
- package/docs/THREAT_MODEL.md +89 -0
- package/docs/VERSIONING_POLICY.md +30 -0
- package/docs/assets/banner.png +0 -0
- package/eslint.config.js +15 -0
- package/fuzz/ts/harness-decode.ts +136 -0
- package/fuzz/ts/harness-verify.ts +121 -0
- package/fuzz/ts/run.ts +35 -0
- package/mcp-server/README.md +38 -0
- package/mcp-server/package-lock.json +1187 -0
- package/mcp-server/package.json +35 -0
- package/mcp-server/src/index.ts +236 -0
- package/mcp-server/tsconfig.json +14 -0
- package/package.json +79 -13
- package/scripts/aip-framework-quickstart.ts +110 -0
- package/scripts/aip-mcp-gateway.ts +38 -0
- package/scripts/aip-mcp-wrap-demo.ts +72 -0
- package/scripts/aip-quickstart.ts +60 -0
- package/scripts/bench-diff.ts +118 -0
- package/scripts/bench-protocol-e2e.ts +937 -0
- package/scripts/bench-protocol-openloop.ts +1397 -0
- package/scripts/bench-replay-cache.ts +76 -0
- package/scripts/bench-signature-profiles.ts +180 -0
- package/scripts/bench-wire-codecs.ts +161 -0
- package/scripts/build-binary-conformance.ts +36 -0
- package/scripts/build-release-dashboard.ts +175 -0
- package/scripts/canary-rollout.ts +38 -0
- package/scripts/mcpGatewayCli.test.ts +116 -0
- package/scripts/prepare-aip-package.ts +88 -0
- package/scripts/regen-conformance-sigs.ts +18 -0
- package/scripts/release-gate.ts +19 -0
- package/scripts/validate-runtime-policy.ts +18 -0
- package/sdk/browser/index.test.ts +162 -0
- package/sdk/browser/index.ts +257 -0
- package/sdk/browser/package.json +13 -0
- package/sdk/go/go.mod +3 -0
- package/sdk/go/http.go +135 -0
- package/sdk/go/protocol.go +324 -0
- package/sdk/go/protocol_test.go +334 -0
- package/sdk/go/webhook.go +136 -0
- package/sdk/python/README.md +18 -0
- package/sdk/python/protocol_7h3/__init__.py +46 -0
- package/sdk/python/protocol_7h3/http.py +212 -0
- package/sdk/python/protocol_7h3/keys.py +149 -0
- package/sdk/python/protocol_7h3/protocol.py +525 -0
- package/sdk/python/protocol_7h3/queue.py +118 -0
- package/sdk/python/protocol_7h3/webhook.py +116 -0
- package/sdk/python/pyproject.toml +40 -0
- package/sdk/python/tests/test_conformance.py +110 -0
- package/sdk/python/tests/test_http.py +305 -0
- package/sdk/python/tests/test_keys.py +417 -0
- package/sdk/python/tests/test_queue.py +120 -0
- package/sdk/python/tests/test_webhook.py +345 -0
- package/sdk/rust/Cargo.lock +371 -0
- package/sdk/rust/Cargo.toml +25 -0
- package/sdk/rust/README.md +31 -0
- package/sdk/rust/fuzz/Cargo.toml +29 -0
- package/sdk/rust/fuzz/fuzz_targets/fuzz_canonicalize.rs +46 -0
- package/sdk/rust/fuzz/fuzz_targets/fuzz_decode.rs +11 -0
- package/sdk/rust/src/bin/aip_mcp_gateway.rs +59 -0
- package/sdk/rust/src/http.rs +145 -0
- package/sdk/rust/src/keys.rs +161 -0
- package/sdk/rust/src/lib.rs +688 -0
- package/sdk/rust/src/queue.rs +79 -0
- package/sdk/rust/src/webhook.rs +86 -0
- package/sdk/rust/tests/conformance.rs +148 -0
- package/sdk/rust/tests/gateway.rs +130 -0
- package/sdk/rust/tests/http_webhook_queue.rs +201 -0
- package/sdk/rust/tests/keys.rs +189 -0
- package/src/agentAdapter.test.ts +48 -0
- package/src/agentAdapter.ts +56 -0
- package/src/auditLog.test.ts +145 -0
- package/src/auditLog.ts +147 -0
- package/src/conformance.test.ts +136 -0
- package/src/conformanceVectors.ts +99 -0
- package/src/frameworkAdapters.test.ts +290 -0
- package/src/frameworkAdapters.ts +261 -0
- package/src/gateway.test.ts +343 -0
- package/src/gateway.ts +171 -0
- package/src/grpcBinding.test.ts +211 -0
- package/src/grpcBinding.ts +103 -0
- package/src/httpBinding.test.ts +376 -0
- package/src/httpBinding.ts +163 -0
- package/src/index.ts +32 -0
- package/src/keyInfra.test.ts +278 -0
- package/src/keyInfra.ts +228 -0
- package/src/keyRegistry.ts +59 -0
- package/src/keyRotation.test.ts +78 -0
- package/src/keyRotation.ts +72 -0
- package/src/mcpGateway.test.ts +129 -0
- package/src/mcpGateway.ts +250 -0
- package/src/mcpTransports.test.ts +92 -0
- package/src/mcpTransports.ts +169 -0
- package/src/mcpWrapper.test.ts +179 -0
- package/src/mcpWrapper.ts +206 -0
- package/src/policyEnforcer.test.ts +99 -0
- package/src/policyEnforcer.ts +169 -0
- package/src/policyTelemetryFeedback.test.ts +25 -0
- package/src/policyTelemetryFeedback.ts +38 -0
- package/src/protocol.bench.ts +37 -0
- package/src/protocol.test.ts +155 -0
- package/src/protocol.ts +413 -0
- package/src/protocolAgent.test.ts +105 -0
- package/src/protocolAgent.ts +169 -0
- package/src/protocolBinary.test.ts +165 -0
- package/src/protocolBinary.ts +312 -0
- package/src/protocolCapabilities.ts +70 -0
- package/src/protocolFuzz.advanced.test.ts +235 -0
- package/src/protocolFuzz.test.ts +111 -0
- package/src/protocolNegative.test.ts +97 -0
- package/src/protocolReplay.test.ts +71 -0
- package/src/protocolReplay.ts +194 -0
- package/src/protocolTransport.test.ts +556 -0
- package/src/protocolTransport.ts +483 -0
- package/src/queueBinding.test.ts +130 -0
- package/src/queueBinding.ts +102 -0
- package/src/rateLimiter.test.ts +96 -0
- package/src/rateLimiter.ts +46 -0
- package/src/redisClient.ts +140 -0
- package/src/redisIntegration.test.ts +134 -0
- package/src/replayStores.test.ts +141 -0
- package/src/replayStores.ts +82 -0
- package/src/revocation.test.ts +98 -0
- package/src/revocation.ts +0 -0
- package/src/routePolicy.test.ts +87 -0
- package/src/routePolicy.ts +72 -0
- package/src/runtimePolicy.test.ts +49 -0
- package/src/runtimePolicy.ts +81 -0
- package/src/runtimePolicyManager.test.ts +29 -0
- package/src/runtimePolicyManager.ts +50 -0
- package/src/runtimePolicyPresets.ts +43 -0
- package/src/signedResponse.test.ts +111 -0
- package/src/signedResponse.ts +83 -0
- package/src/webhookBinding.test.ts +144 -0
- package/src/webhookBinding.ts +115 -0
- package/src/wsBinding.test.ts +221 -0
- package/src/wsBinding.ts +100 -0
- package/tsconfig.json +15 -0
- package/tsconfig.lib.json +23 -0
- package/vite.lib.config.ts +16 -0
- package/agentAdapter.d.ts +0 -26
- package/conformanceVectors.d.ts +0 -20
- package/frameworkAdapters.d.ts +0 -72
- package/index.d.ts +0 -20
- package/index.js +0 -1702
- package/keyRotation.d.ts +0 -20
- package/mcpGateway.d.ts +0 -37
- package/mcpTransports.d.ts +0 -62
- package/mcpWrapper.d.ts +0 -83
- package/policyEnforcer.d.ts +0 -50
- package/policyTelemetryFeedback.d.ts +0 -11
- package/protocol.d.ts +0 -66
- package/protocolAgent.d.ts +0 -58
- package/protocolBinary.d.ts +0 -8
- package/protocolCapabilities.d.ts +0 -24
- package/protocolReplay.d.ts +0 -35
- package/protocolTransport.d.ts +0 -73
- package/redisClient.d.ts +0 -49
- package/replayStores.d.ts +0 -32
- package/revocation.d.ts +0 -71
- package/runtimePolicy.d.ts +0 -24
- package/runtimePolicyManager.d.ts +0 -15
- package/runtimePolicyPresets.d.ts +0 -11
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
# MCP Hardening Wrapper
|
|
2
|
+
|
|
3
|
+
MCP messages are plain JSON-RPC 2.0 with no signature and no replay protection.
|
|
4
|
+
This wrapper puts a signed AIP envelope around every MCP message on the wire —
|
|
5
|
+
authenticating it, TTL-bounding it, and replay-checking it — **without changing
|
|
6
|
+
your MCP handler**. Your handler still receives plain JSON-RPC `{ method, params }`
|
|
7
|
+
and returns plain results; AIP lives entirely on the wire.
|
|
8
|
+
|
|
9
|
+
Source: `src/mcpWrapper.ts`. Runnable demo: `npm run aip:mcp:wrap`.
|
|
10
|
+
|
|
11
|
+
## Threat coverage
|
|
12
|
+
|
|
13
|
+
| Threat | Covered by |
|
|
14
|
+
|---|---|
|
|
15
|
+
| Message tampering (params/method altered in flight) | Canonical signature over the envelope (HS256 / Ed25519) |
|
|
16
|
+
| Replay / duplicate execution | `(sender, messageId, nonce)` replay cache + TTL; **on by default** (`InMemoryReplayCache` if none supplied) |
|
|
17
|
+
| Cross-server relay (valid envelope for server A replayed to server B) | **Recipient binding** — the server runs the handler only when `recipient === selfAgentId` |
|
|
18
|
+
| Response spoofing (another valid signer answers) | **Sender binding** — the client accepts a response only when `sender === peerAgentId` (peerAgentId is required) |
|
|
19
|
+
| Response substitution (a valid response to request A returned for request B) | **Correlation binding** — the client requires `correlationId === the request's messageId` |
|
|
20
|
+
| Compromised key still in use | Compose `withRevocationCheck` into `receive.signatureResolver` |
|
|
21
|
+
|
|
22
|
+
`encodeRequest` returns `{ raw, messageId }`; pass `messageId` to `decodeResponse(raw, { expectCorrelationId })` to enforce the correlation binding (`wrapMcpClient` does this for you).
|
|
23
|
+
|
|
24
|
+
## Server side — wrap an existing handler
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
import { wrapMcpServer, signEnvelopeHmac } from '@7h3/protocol'
|
|
28
|
+
import { DistributedReplayCache, createRedisReplayStore } from '@7h3/protocol'
|
|
29
|
+
|
|
30
|
+
// Your existing MCP handler — unchanged, AIP-unaware.
|
|
31
|
+
async function myMcpServer(request) {
|
|
32
|
+
if (request.method === 'tools/call') return { jsonrpc: '2.0', id: request.id, result: runTool(request.params) }
|
|
33
|
+
return { jsonrpc: '2.0', id: request.id, error: { code: -32601, message: 'Method not found' } }
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const secured = wrapMcpServer(myMcpServer, {
|
|
37
|
+
selfAgentId: 'agent.mcp-server',
|
|
38
|
+
sign: (e) => signEnvelopeHmac(e, process.env.AIP_SECRET!, 'server-k1'),
|
|
39
|
+
receive: {
|
|
40
|
+
secretResolver: async () => process.env.AIP_SECRET!,
|
|
41
|
+
replayCache: new DistributedReplayCache(createRedisReplayStore(redisLikeClient)), // fleet-wide replay
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
// `secured(rawWireEnvelope) => Promise<rawWireEnvelope>` — drop it into your stdio/HTTP transport read loop.
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## HMAC vs Ed25519
|
|
49
|
+
|
|
50
|
+
| | HMAC (HS256) | Ed25519 |
|
|
51
|
+
|---|---|---|
|
|
52
|
+
| Secret model | Shared secret — both sides can sign and verify | Keypair — only you can sign; peers verify with your public key |
|
|
53
|
+
| Peer compromise | A compromised peer can forge messages | A compromised peer cannot forge your messages |
|
|
54
|
+
| Key distribution | One secret distributed to all trusted peers | Public key is safe to publish; private key never leaves the signer |
|
|
55
|
+
| When to use | Dev, testing, fully trusted internal infra | Production, multi-tenant, or any boundary where you do not control both sides |
|
|
56
|
+
|
|
57
|
+
**Use HMAC when** you own both sides of the wire (same team, same trusted cluster) and want the simplest possible setup.
|
|
58
|
+
|
|
59
|
+
**Use Ed25519 in production.** If a worker/peer node is compromised, the attacker gains verify capability only — they cannot impersonate the signer.
|
|
60
|
+
|
|
61
|
+
Ed25519 server example (replace the HMAC `sign`/`receive` block above):
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { wrapMcpServer, signEnvelopeEd25519 } from '@7h3/protocol'
|
|
65
|
+
|
|
66
|
+
// Generate keys once: npx @7h3/protocol-mcp → aip_generate_keypair
|
|
67
|
+
// Set AIP_PRIVATE_KEY (server) and distribute AIP_CLIENT_PUBLIC_KEY (client's pubkey)
|
|
68
|
+
|
|
69
|
+
const secured = wrapMcpServer(myMcpServer, {
|
|
70
|
+
selfAgentId: 'agent.mcp-server',
|
|
71
|
+
sign: (e) => signEnvelopeEd25519(e, process.env.AIP_PRIVATE_KEY!, 'k1'),
|
|
72
|
+
receive: {
|
|
73
|
+
signatureResolver: async (sig) =>
|
|
74
|
+
sig.alg === 'ED25519'
|
|
75
|
+
? { alg: 'ED25519' as const, publicKey: process.env.AIP_CLIENT_PUBLIC_KEY! }
|
|
76
|
+
: undefined,
|
|
77
|
+
},
|
|
78
|
+
})
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Client side — sign requests, verify responses
|
|
82
|
+
|
|
83
|
+
```ts
|
|
84
|
+
import { wrapMcpClient, signEnvelopeHmac } from '@7h3/protocol'
|
|
85
|
+
|
|
86
|
+
const call = wrapMcpClient(transport.send /* (raw) => Promise<raw> */, {
|
|
87
|
+
selfAgentId: 'agent.mcp-client',
|
|
88
|
+
peerAgentId: 'agent.mcp-server',
|
|
89
|
+
sign: (e) => signEnvelopeHmac(e, process.env.AIP_SECRET!, 'client-k1'),
|
|
90
|
+
receive: { secretResolver: async () => process.env.AIP_SECRET! },
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
const result = await call({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'planner' } })
|
|
94
|
+
// throws if the server response signature does not verify
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`createMcpClientCodec(options)` exposes `encodeRequest` / `decodeResponse` directly
|
|
98
|
+
when you manage the transport send yourself. `encodeRequest` returns
|
|
99
|
+
`{ raw, messageId }`; pass that `messageId` as `decodeResponse(raw, { expectCorrelationId })`
|
|
100
|
+
to bind each response to its request. `peerAgentId` is required so responses can be
|
|
101
|
+
bound to the expected sender.
|
|
102
|
+
|
|
103
|
+
## Composes with the rest of the stack
|
|
104
|
+
|
|
105
|
+
The `receive` field is a full `ReceiveEnvelopeOptions`, so the wrapper inherits
|
|
106
|
+
everything the transport pipeline offers:
|
|
107
|
+
|
|
108
|
+
- **Fleet-wide replay** — pass a `DistributedReplayCache(createRedisReplayStore(...))`.
|
|
109
|
+
- **Key revocation** — set `receive.signatureResolver = withRevocationCheck(resolver, revocationStore)`.
|
|
110
|
+
- **Ed25519** — sign with `signEnvelopeEd25519` and resolve material via `signatureResolver`.
|
|
111
|
+
- **Clock skew / TTL / telemetry** — `maxClockSkewMs`, `telemetry`, etc.
|
|
112
|
+
|
|
113
|
+
## Transports
|
|
114
|
+
|
|
115
|
+
The wrapper is transport-agnostic (it operates on wire envelopes). Two adapters
|
|
116
|
+
connect it to real transports; both keep the handler on plain JSON-RPC.
|
|
117
|
+
|
|
118
|
+
### stdio (newline-delimited)
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
import { wrapMcpServer, serveMcpOverStdio, createStdioMcpClient, wrapMcpClient } from '@7h3/protocol'
|
|
122
|
+
|
|
123
|
+
// server process: read envelopes from stdin, write replies to stdout
|
|
124
|
+
serveMcpOverStdio(wrapMcpServer(myMcpServer, serverOpts)) // defaults to process.stdin/stdout
|
|
125
|
+
|
|
126
|
+
// client process: spawn the server and talk to it
|
|
127
|
+
const stdio = createStdioMcpClient({ input: child.stdout, output: child.stdin })
|
|
128
|
+
const call = wrapMcpClient(stdio.send, clientOpts)
|
|
129
|
+
const result = await call({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'planner' } })
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Stdio frames one envelope per line, so it supports the `json` and `compact` wire
|
|
133
|
+
formats. For `binary`, use HTTP.
|
|
134
|
+
|
|
135
|
+
### HTTP
|
|
136
|
+
|
|
137
|
+
```ts
|
|
138
|
+
import http from 'node:http'
|
|
139
|
+
import { wrapMcpServer, createHttpMcpHandler, createHttpMcpClient, wrapMcpClient } from '@7h3/protocol'
|
|
140
|
+
|
|
141
|
+
// server: any node:http-compatible host
|
|
142
|
+
http.createServer(createHttpMcpHandler(wrapMcpServer(myMcpServer, serverOpts))).listen(8787)
|
|
143
|
+
|
|
144
|
+
// client: POSTs each request envelope, returns the reply envelope (global fetch)
|
|
145
|
+
const httpClient = createHttpMcpClient({ url: 'http://localhost:8787' })
|
|
146
|
+
const call = wrapMcpClient(httpClient.send, clientOpts)
|
|
147
|
+
const result = await call({ jsonrpc: '2.0', id: 1, method: 'tools/call', params: { name: 'planner' } })
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Pass `{ binary: true }` to both `createHttpMcpHandler` and `createHttpMcpClient`
|
|
151
|
+
to use the `binary` wire format over HTTP.
|
|
152
|
+
|
|
153
|
+
## Notes
|
|
154
|
+
|
|
155
|
+
- Both peers must be wrapped: the on-wire message is an AIP envelope, not plain
|
|
156
|
+
JSON-RPC. For interop with un-wrapped MCP peers, terminate AIP at a gateway.
|
|
157
|
+
- `wireFormat` defaults to `compact`; use `binary` for the highest-throughput lanes.
|
|
158
|
+
- Verification failures and replays come back as signed JSON-RPC errors
|
|
159
|
+
(`-32600`), so the client still gets an authenticated, well-formed response.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# AIP Migration Guide
|
|
2
|
+
|
|
3
|
+
## Import path migration (JS/TS)
|
|
4
|
+
|
|
5
|
+
Use the stable package subpath export:
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
import { createAipAgentAdapter, receiveEnvelope } from '@7h3/protocol'
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Avoid repo-relative imports in consumer apps.
|
|
12
|
+
|
|
13
|
+
## Signature profile migration
|
|
14
|
+
|
|
15
|
+
### HS256 to ED25519
|
|
16
|
+
|
|
17
|
+
1. Generate/provision ED25519 key pairs.
|
|
18
|
+
2. Keep HS256 verification active during overlap window.
|
|
19
|
+
3. Start signing outbound envelopes with ED25519.
|
|
20
|
+
4. Monitor verify failures by algorithm.
|
|
21
|
+
5. Revoke/decommission HS256 keys after migration window.
|
|
22
|
+
|
|
23
|
+
## Replay cache migration
|
|
24
|
+
|
|
25
|
+
### Single-node to distributed
|
|
26
|
+
|
|
27
|
+
1. Replace `InMemoryReplayCache` with `DistributedReplayCache`.
|
|
28
|
+
2. Implement atomic reserve in shared store (for example Redis `SET NX PX`).
|
|
29
|
+
3. Roll out gradually and monitor replay reject metrics.
|
|
30
|
+
|
|
31
|
+
## Clock skew migration
|
|
32
|
+
|
|
33
|
+
1. Start with default `maxClockSkewMs` (30s).
|
|
34
|
+
2. Tighten to lower values in synchronized environments.
|
|
35
|
+
3. Monitor `rejected_clock_skew` telemetry for false-positive tuning.
|
|
36
|
+
|
|
37
|
+
## Rollback guidance
|
|
38
|
+
|
|
39
|
+
- Keep prior verification profiles and key material during rollout.
|
|
40
|
+
- Do not remove old verifiers until telemetry confirms stable traffic.
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
# GLUV Operators Guide
|
|
2
|
+
|
|
3
|
+
This guide is for SRE, platform, and performance teams operating GLUV-backed workloads in production.
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 1) Operational objectives
|
|
8
|
+
|
|
9
|
+
Primary objectives:
|
|
10
|
+
|
|
11
|
+
1. Maintain low drop-rate under declared load profiles
|
|
12
|
+
2. Maintain p99 latency SLO
|
|
13
|
+
3. Preserve signature/replay guarantees under stress
|
|
14
|
+
4. Detect and stop regressions before release
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## 2) SLO model
|
|
19
|
+
|
|
20
|
+
Define SLOs per traffic class (example baseline):
|
|
21
|
+
|
|
22
|
+
- **Availability:** protocol receive path success ≥ 99.9%
|
|
23
|
+
- **Drop rate:** `dropPct <= 0.1%` (or 0% for critical lanes)
|
|
24
|
+
- **Latency:** p99 <= 20ms (adjust by payload and transport class)
|
|
25
|
+
- **Integrity:** 100% signature verification and replay checks on ingress
|
|
26
|
+
|
|
27
|
+
Important: “no drop” means **within declared operating envelope**. Any system can be overloaded if offered load exceeds capacity.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 3) Transport selection matrix
|
|
32
|
+
|
|
33
|
+
Use this default selection policy:
|
|
34
|
+
|
|
35
|
+
| Workload | Recommended Mode | Why |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| High-throughput lane | `http-binary-batch` or `ws-binary-batch` | best throughput and lowest overhead |
|
|
38
|
+
| Balanced latency/compatibility | `ws-batch` | low framing overhead and stable p99 |
|
|
39
|
+
| Low/medium compatibility lane | `http` | simplest interoperability |
|
|
40
|
+
| Stress testing only | `http` + `--allow-unsafe-http` | intentional overload characterization |
|
|
41
|
+
|
|
42
|
+
Guardrail behavior in benchmark harness blocks unsafe plain HTTP at high concurrency unless explicitly overridden.
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
## 4) Benchmark discipline
|
|
47
|
+
|
|
48
|
+
### Sustainable benchmarks (default)
|
|
49
|
+
|
|
50
|
+
Use adaptive benchmark commands for release confidence:
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
npm run bench:openloop:quick
|
|
54
|
+
npm run bench:openloop:full
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
These discover sustainable operating rates using threshold gates.
|
|
58
|
+
|
|
59
|
+
### Stress benchmarks (explicit overload)
|
|
60
|
+
|
|
61
|
+
Use only for capacity ceiling exploration:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
npm run bench:openloop:stress:quick
|
|
65
|
+
npm run bench:openloop:stress:full
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
Do not use stress runs alone as production readiness criteria.
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 5) Core runbook commands
|
|
73
|
+
|
|
74
|
+
### Quality and release gates
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
npm run lint
|
|
78
|
+
npm run test
|
|
79
|
+
npm run build
|
|
80
|
+
npm run release:gate
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Conformance gates
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm run conformance:python
|
|
87
|
+
npm run conformance:rust
|
|
88
|
+
npm run conformance:binary
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Benchmark analysis
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm run bench:diff -- --baseline <baseline.json> --candidate <candidate.json>
|
|
95
|
+
npm run release:dashboard
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 6) Incident runbook
|
|
101
|
+
|
|
102
|
+
### Symptom: high drop rate
|
|
103
|
+
|
|
104
|
+
1. Confirm mode and benchmark class (adaptive vs stress)
|
|
105
|
+
2. Check if plain HTTP is being used at high concurrency
|
|
106
|
+
3. Switch to binary batch mode for hot lanes
|
|
107
|
+
4. Inspect overload/retry behavior and queue pressure
|
|
108
|
+
5. Reduce offered rate or widen worker capacity
|
|
109
|
+
|
|
110
|
+
### Symptom: p99 latency spike
|
|
111
|
+
|
|
112
|
+
1. Compare payload size distribution against baseline
|
|
113
|
+
2. Check in-flight cap / batch-size adaptation behavior
|
|
114
|
+
3. Verify no regression in signature profile or canonicalization path
|
|
115
|
+
4. Re-run adaptive benchmark for sustainable envelope
|
|
116
|
+
|
|
117
|
+
### Symptom: signature failures
|
|
118
|
+
|
|
119
|
+
1. Validate key resolver outputs and key IDs
|
|
120
|
+
2. Verify canonicalization parity across runtime boundaries
|
|
121
|
+
3. Check clock skew / TTL policy window
|
|
122
|
+
|
|
123
|
+
### Symptom: replay rejections
|
|
124
|
+
|
|
125
|
+
1. Verify message uniqueness (`messageId`, `nonce`)
|
|
126
|
+
2. Validate replay cache window sizing
|
|
127
|
+
3. Confirm producer retry semantics are idempotent
|
|
128
|
+
|
|
129
|
+
---
|
|
130
|
+
|
|
131
|
+
## 7) Tuning matrix (starting points)
|
|
132
|
+
|
|
133
|
+
| Setting | Low Traffic | Medium Traffic | High Traffic |
|
|
134
|
+
|---|---:|---:|---:|
|
|
135
|
+
| Batch size | 4–8 | 8–32 | 32–64 |
|
|
136
|
+
| In-flight cap | 16–64 | 64–256 | 256–1024 |
|
|
137
|
+
| Retry backoff | 1–2ms | 2–8ms | 4–16ms |
|
|
138
|
+
| Preferred mode | `http`/`ws` | `ws-batch` | `http-binary-batch` / `ws-binary-batch` |
|
|
139
|
+
|
|
140
|
+
Treat this as a starting policy; tune from measured p99/drop under adaptive runs.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
## 8) Security and reliability invariants
|
|
145
|
+
|
|
146
|
+
Never disable these in production:
|
|
147
|
+
|
|
148
|
+
- signature verification
|
|
149
|
+
- canonicalization checks
|
|
150
|
+
- replay defense
|
|
151
|
+
- TTL and clock-skew enforcement
|
|
152
|
+
|
|
153
|
+
Any performance optimization must preserve these invariants.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## 9) Release acceptance checklist
|
|
158
|
+
|
|
159
|
+
Release candidate is acceptable when:
|
|
160
|
+
|
|
161
|
+
1. `release:gate` passes
|
|
162
|
+
2. conformance suites pass (TS/Python/Rust/binary)
|
|
163
|
+
3. adaptive benchmarks satisfy target SLO thresholds
|
|
164
|
+
4. no critical regression in benchmark diff vs baseline
|
|
165
|
+
5. rollback plan and threshold alerts are prepared
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## 10) Recommended rollout strategy
|
|
170
|
+
|
|
171
|
+
1. Canary 5%
|
|
172
|
+
2. Observe drop/p99/signature/replay counters
|
|
173
|
+
3. Expand 25% → 50% → 100%
|
|
174
|
+
4. Auto-rollback if drop or p99 breaches thresholds for sustained window
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## 11) Documentation map
|
|
179
|
+
|
|
180
|
+
- Protocol technical guide: `README.md`
|
|
181
|
+
- Executive brief: `README_EXECUTIVE.md`
|
|
182
|
+
- Performance policy: `PERF_REGRESSION_POLICY.md`
|
|
183
|
+
- Backpressure notes: `BACKPRESSURE_TUNING.md`
|
|
184
|
+
- Release hardening: `RELEASE_GATE.md`
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# 7h3 Protocol AIP Performance Regression Policy
|
|
2
|
+
|
|
3
|
+
## Purpose
|
|
4
|
+
|
|
5
|
+
Prevent unreviewed regressions in throughput and tail latency.
|
|
6
|
+
|
|
7
|
+
## CI gate
|
|
8
|
+
|
|
9
|
+
- CI must run adaptive open-loop performance gate:
|
|
10
|
+
- `npm run bench:openloop:adaptive:ci`
|
|
11
|
+
- Fail build if p99 or drop-rate exceeds configured thresholds.
|
|
12
|
+
|
|
13
|
+
## Release gate
|
|
14
|
+
|
|
15
|
+
For release candidates:
|
|
16
|
+
|
|
17
|
+
1. Run baseline and candidate benchmark suites using `full` profiles.
|
|
18
|
+
2. Compare with `npm run bench:diff -- --baseline <...> --candidate <...>`.
|
|
19
|
+
3. Block release if either condition is met without explicit waiver:
|
|
20
|
+
- throughput regression beyond accepted threshold
|
|
21
|
+
- p99 regression beyond accepted threshold
|
|
22
|
+
|
|
23
|
+
## Waiver process
|
|
24
|
+
|
|
25
|
+
- Waiver requires:
|
|
26
|
+
- documented reason
|
|
27
|
+
- owner
|
|
28
|
+
- rollback plan
|
|
29
|
+
- follow-up due date
|
|
30
|
+
|
|
31
|
+
## Reporting
|
|
32
|
+
|
|
33
|
+
- Attach benchmark artifacts and diff report to release PR.
|
|
34
|
+
- Record claim context with hardware profile and command set.
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# @7h3/protocol — Independent Examination (updated 2026-06-01)
|
|
2
|
+
|
|
3
|
+
**Original examination:** 2026-05-31 · **Updated:** 2026-06-01 (post-extraction, post-publish)
|
|
4
|
+
**Reviewer stance:** Independent audit — claims split into **Verified** (ran it / read the code) vs **Asserted** (repo says so, unverified).
|
|
5
|
+
**Repo:** `github.com/IceMasterT/7h3-protocol-aip` · local `/media/artiq/DATA/7h3-protocol`
|
|
6
|
+
**Package:** `@7h3/protocol@0.1.0` · live on npm · MIT
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 0) TL;DR
|
|
11
|
+
|
|
12
|
+
AIP is a **cryptographic hardening envelope for MCP and A2A traffic** — per-message signing, TTL-bounding, and replay-checking that those protocols don't provide natively. It is now extracted, published, and public. The engineering is real. The market gap is real and publicly acknowledged. The first meaningful risk is adoption, not implementation.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## 1) What shipped
|
|
17
|
+
|
|
18
|
+
### Core protocol (`aip/0.1`)
|
|
19
|
+
- `protocol.ts` — envelope model, deterministic canonicalization (fixed key order), HMAC-SHA256 / Ed25519 signing and verification over real WebCrypto. Key handles LRU-cached.
|
|
20
|
+
- `protocolTransport.ts` — wire encode/decode (`json` / `compact` / `binary`), full receive pipeline (validate → canonicalize → verify → replay-check), batch/session transport with bounded-concurrency and telemetry hooks.
|
|
21
|
+
- `protocolBinary.ts` — MessagePack binary wire codec (highest-throughput lane).
|
|
22
|
+
- `protocolReplay.ts` — `InMemoryReplayCache` (`(sender, messageId, nonce)` uniqueness window + TTL); `DistributedReplayCache` wrapping any `DistributedReplayStore`.
|
|
23
|
+
- `keyRotation.ts`, `protocolCapabilities.ts`, `protocolAgent.ts` — key lifecycle, capability negotiation, agent identity.
|
|
24
|
+
- `runtimePolicy*.ts` + `policyEnforcer.ts` + `policyTelemetryFeedback.ts` — declarative transport/retry/safety policy with telemetry-driven feedback.
|
|
25
|
+
- `mcpGateway.ts`, `frameworkAdapters.ts`, `agentAdapter.ts` — JSON-RPC gateway runtime, LangChain/LlamaIndex/JSON-RPC bridges.
|
|
26
|
+
|
|
27
|
+
### Distributed stores (production gap — now closed)
|
|
28
|
+
- `redisClient.ts` — `RedisLikeClient` interface (client-agnostic; no Redis npm dep) + `InMemoryRedisLikeClient` reference impl.
|
|
29
|
+
- `replayStores.ts` — `createRedisReplayStore`: atomic `SET NX PX` reserve, `reserveMany` batch pipeline, `errorBehavior: 'fallback' | 'reject' | 'allow'`, `onDegraded` observability hook. Default: degrade-to-local, never silent.
|
|
30
|
+
- `revocation.ts` — `InMemoryRevocationStore`; `createRedisRevocationStore` (cached reads, **fail-closed default**); `withRevocationCheck` wraps any `SignatureResolver` — one line to add fleet-wide revocation to any verify path.
|
|
31
|
+
|
|
32
|
+
### MCP hardening wrapper (production gap — now closed)
|
|
33
|
+
- `mcpWrapper.ts` — `wrapMcpServer` / `wrapMcpClient` / `createMcpClientCodec`. Wire message is a signed AIP envelope carrying JSON-RPC in `body.content`; handler receives plain JSON-RPC (zero app changes).
|
|
34
|
+
- **Recipient binding** — server rejects envelopes not addressed to `selfAgentId` (cross-server relay defense).
|
|
35
|
+
- **Sender binding** — client accepts responses only when `sender === peerAgentId` (response-spoof defense).
|
|
36
|
+
- **Correlation binding** — client enforces `correlationId === request messageId` (response-substitution defense).
|
|
37
|
+
- **Replay on by default** — `InMemoryReplayCache` injected if none supplied.
|
|
38
|
+
- `mcpTransports.ts` — `serveMcpOverStdio` / `createStdioMcpClient` (newline-delimited, in-order sequential chain); `createHttpMcpHandler` / `createHttpMcpClient` (`node:http` + global `fetch`, `binary` mode). No new runtime dependencies.
|
|
39
|
+
|
|
40
|
+
### Polyglot parity
|
|
41
|
+
- Python SDK (`sdk/python`, `from aip7h3 import …`)
|
|
42
|
+
- Rust SDK + gateway (`sdk/rust`, `use aip7h3::…`)
|
|
43
|
+
- Shared conformance fixtures (`conformance/aip_v0_1.json`) drive byte-identical signature verification across all three runtimes.
|
|
44
|
+
|
|
45
|
+
### Governance scaffolding
|
|
46
|
+
`docs/`: THREAT_MODEL, KEY_MANAGEMENT_POLICY, CLOCK_SKEW_POLICY, DISTRIBUTED_REPLAY, KEY_REVOCATION, MCP_WRAPPER, TELEMETRY, PERF_REGRESSION_POLICY, VERSIONING_POLICY, MIGRATION_GUIDE, RELEASE_GATE. Benchmark harnesses, release dashboard generator, canary planner.
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
50
|
+
## 2) Auditor's ledger
|
|
51
|
+
|
|
52
|
+
### ✅ Verified (ran it / read the code)
|
|
53
|
+
|
|
54
|
+
**123 tests pass across 22 files in ~924ms.** (`npx vitest run`, 2026-06-01). Real coverage: envelope conformance, negative/malformed corpus, fuzz/property tests, replay cache (in-memory + distributed + batch), key rotation, transport, binary codec, gateway, policy, revocation, MCP wrapper (round-trip, tamper-reject, replay-reject, recipient/sender/correlation binding), stdio transport (PassThrough streams), HTTP transport (real `http.Server` on ephemeral port).
|
|
55
|
+
|
|
56
|
+
**Real cryptography.** `protocol.ts` uses `crypto.subtle` — genuine HMAC-SHA256 and Ed25519 (PKCS8/SPKI import, base64url encoding). Not hand-rolled.
|
|
57
|
+
|
|
58
|
+
**Deterministic canonicalization is real.** Fixed key order (not recursive sort), explicit `body`-then-`header` layout. This is what makes cross-language parity *provable*, not just asserted.
|
|
59
|
+
|
|
60
|
+
**Genuine tri-language parity.** Python `unittest` and Rust `cargo test` both driven by the same JSON fixture set. Signatures verified against the same known vectors in all three runtimes.
|
|
61
|
+
|
|
62
|
+
**Redis stores work.** Live-Redis integration test (`redisIntegration.test.ts`): replay reserve via `SET NX PX` and revocation round-trip both confirmed against a real server. Test auto-skips if no server present — no false passes.
|
|
63
|
+
|
|
64
|
+
**Infinite-recursion bug in fallback chain caught by TDD before shipping.** `createRedisReplayStore` with default `errorBehavior:'fallback'` initially created a fallback store that also tried to create its own fallback. Fixed by passing `{ errorBehavior: 'reject' }` to the inner store. The test suite caught this before it shipped.
|
|
65
|
+
|
|
66
|
+
**MCP wrapper security bindings all independently tested.** Each binding (recipient, sender, correlation, replay-default) has its own test that verifies rejection of the specific attack it defends against.
|
|
67
|
+
|
|
68
|
+
**Honest threat model.** Lists remaining open risks (see §6). That candor is a credibility asset.
|
|
69
|
+
|
|
70
|
+
**Published and public.** `@7h3/protocol@0.1.0` on npm. `github.com/IceMasterT/7h3-protocol-aip` public. 12 GitHub topics set.
|
|
71
|
+
|
|
72
|
+
### ⚠️ Asserted (treat as marketing until independently reproduced)
|
|
73
|
+
|
|
74
|
+
- Benchmark numbers are from one dev machine with no external methodology audit. Read them as "comfortably adequate," not headline performance.
|
|
75
|
+
- Python and Rust SDKs share the conformance fixture but the Python Ed25519 path requires the `cryptography` package (skipped if absent). Rust integration is straightforward but has not been published to crates.io.
|
|
76
|
+
- No third-party security audit. For a cryptographic protocol, a formal audit or at minimum an external reproduction of conformance vectors is the credibility step this hasn't cleared yet.
|
|
77
|
+
|
|
78
|
+
> Precedent from this workspace: a self-reported "95/100" on a separate project was independently re-scored to ~22. The discipline here is better (green suite, shared fixtures, honest risk listing), but the rule stands — believe the test run; discount self-graded readiness claims.
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 3) Architecture
|
|
83
|
+
|
|
84
|
+
### Receive pipeline (core)
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
wire bytes ──▶ decode (json | compact | binary)
|
|
88
|
+
──▶ validate envelope shape + policy (version, ids, ttl, clock-skew)
|
|
89
|
+
──▶ canonicalize (fixed key order, body→header layout)
|
|
90
|
+
──▶ verify signature (HS256 | Ed25519) via key/secret resolver
|
|
91
|
+
└──▶ withRevocationCheck (optional, wraps resolver)
|
|
92
|
+
──▶ replay-cache check (sender, messageId, nonce) + TTL window
|
|
93
|
+
└──▶ InMemoryReplayCache (single-node)
|
|
94
|
+
└──▶ DistributedReplayCache → RedisReplayStore (fleet-wide)
|
|
95
|
+
──▶ accept ──▶ app handler
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### MCP wrapper pipeline
|
|
99
|
+
|
|
100
|
+
```
|
|
101
|
+
JSON-RPC request
|
|
102
|
+
──▶ createEnvelope (sender=client, recipient=server, content=json-rpc)
|
|
103
|
+
──▶ signEnvelope
|
|
104
|
+
──▶ [transport: stdio newline / HTTP POST]
|
|
105
|
+
──▶ wrapMcpServer receives WireEnvelope
|
|
106
|
+
──▶ receiveEnvelope (full pipeline above)
|
|
107
|
+
──▶ recipient binding check (recipient === selfAgentId)
|
|
108
|
+
──▶ handler(plain json-rpc) ←─ zero app changes
|
|
109
|
+
──▶ signEnvelope(response, correlationId=request.messageId)
|
|
110
|
+
──▶ [transport]
|
|
111
|
+
──▶ wrapMcpClient decodeResponse
|
|
112
|
+
──▶ sender binding (sender === peerAgentId)
|
|
113
|
+
──▶ correlation binding (correlationId === request.messageId)
|
|
114
|
+
──▶ returns plain JSON-RPC response
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
**Envelope structure:** `header{version, messageId, timestampMs, ttlMs, sender, recipient?, nonce}` + `body{intent, content, capability?, correlationId?}` + optional `signature{alg, keyId, value}`.
|
|
118
|
+
**Intents:** `PING / PONG / CAPS / TASK / RESULT / ERROR` — a deliberately minimal verb set.
|
|
119
|
+
|
|
120
|
+
This is a textbook-correct message-security design: validate → canonicalize → verify → replay → accept. Nothing exotic, everything in the right order.
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## 4) Performance — honest read
|
|
125
|
+
|
|
126
|
+
Quick-profile benchmarks (single dev machine, 2026-05-31):
|
|
127
|
+
|
|
128
|
+
| Metric | Value | Interpretation |
|
|
129
|
+
|---|---|---|
|
|
130
|
+
| Canonicalization | ~1.07M ops/s | Near-zero overhead |
|
|
131
|
+
| Compact codec (encode+decode) | ~0.98M ops/s | Near-zero overhead |
|
|
132
|
+
| Sign + verify (HMAC-SHA256) | ~38.3k ops/s | **Binding ceiling** |
|
|
133
|
+
| In-process E2E | ~50k ops/s, p99 ~4.7ms (c=100) | Protocol overhead only |
|
|
134
|
+
| Open-loop adaptive HTTP | ~10.2k ops/s, p99 ~13.4ms, 0% drop | Transport-bound, not protocol-bound |
|
|
135
|
+
|
|
136
|
+
The crypto sign+verify path (~38k/s/core) is the binding constraint. ~10k/s sustained over HTTP is honest and production-adequate for an agent control plane. This is not a "millions of messages/second" story, and the repo doesn't claim it — it explicitly distinguishes adaptive/sustainable throughput from firehose stress numbers. Market as **"predictable, signed, replay-safe throughput,"** never as raw speed.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## 5) Best use case
|
|
141
|
+
|
|
142
|
+
**Lead with:** a drop-in cryptographic trust layer for MCP-mediated tool calls and multi-agent traffic — especially any flow where tool calls trigger real side effects (writes, payments, actions).
|
|
143
|
+
|
|
144
|
+
AIP is at its best when:
|
|
145
|
+
- 2+ agents or services are exchanging messages,
|
|
146
|
+
- tool calls cause side effects that must not be replayed or tampered with,
|
|
147
|
+
- you need tamper-evidence, replay-safety, and an audit trail,
|
|
148
|
+
- you run a polyglot stack (TS orchestrator + Rust gateway + Python workers) and need signatures to match across all three.
|
|
149
|
+
|
|
150
|
+
**Runnable entry point:** `npm run aip:mcp:wrap` — demonstrates tampered and replayed requests rejected in under 30 seconds.
|
|
151
|
+
|
|
152
|
+
**Where not to use it:** single-process prototypes, no trust boundary, exploratory prompt UX. The repo says this itself.
|
|
153
|
+
|
|
154
|
+
---
|
|
155
|
+
|
|
156
|
+
## 6) Market positioning
|
|
157
|
+
|
|
158
|
+
The competitive landscape (verified 2026-05-31) strongly favors a **complement-not-compete** posture:
|
|
159
|
+
|
|
160
|
+
- **MCP** (Anthropic): JSON-RPC messages sent unsigned, no replay protection. Open issues requesting per-message signing. Community spec **MCPS** proposes a signing + nonce envelope as a backward-compatible layer. ~8.5% of MCP servers use OAuth.
|
|
161
|
+
- **A2A** (Google, v1.2): Signed Agent Cards authenticate the identity card for domain verification — **not** per-message task traffic.
|
|
162
|
+
|
|
163
|
+
AIP implements exactly the missing layer for both. The gap is not a niche opinion — it's in NSA guidance, in public GitHub issues, and in active community proposals. The positioning writes itself:
|
|
164
|
+
|
|
165
|
+
> **"The signing-and-replay layer your agent protocol forgot."**
|
|
166
|
+
> Sign, TTL-bound, and replay-protect every MCP/A2A message — with byte-identical verification across TypeScript, Python, and Rust.
|
|
167
|
+
|
|
168
|
+
Do **not** position AIP as a competing agent protocol. Position it as the hardening envelope / trust middleware those protocols lack natively. The moat is "works today, polyglot, already tested, MIT."
|
|
169
|
+
|
|
170
|
+
**Standardization risk:** MCPS or MCP itself may standardize this natively. That is the primary time-sensitivity argument. AIP's edge is "running in prod now," not "only possible solution."
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 7) Shipped state vs original plan
|
|
175
|
+
|
|
176
|
+
The original examination identified four blockers and five execution steps. Current status:
|
|
177
|
+
|
|
178
|
+
| Item | Status |
|
|
179
|
+
|---|---|
|
|
180
|
+
| Protocol never published / `private:true` / version `0.0.0` | ✅ `@7h3/protocol@0.1.0` live on npm |
|
|
181
|
+
| Esolang-branded name buries the protocol | ✅ Extracted to `7h3-protocol-aip`; npm `@7h3/protocol` |
|
|
182
|
+
| In-memory replay cache insufficient for multi-node | ✅ `createRedisReplayStore` — atomic `SET NX PX`, batch pipeline, graceful degradation |
|
|
183
|
+
| No revocation/expiry enforcement layer | ✅ `createRedisRevocationStore` + `withRevocationCheck` — fail-closed, cached |
|
|
184
|
+
| No MCP integration artifact | ✅ `wrapMcpServer` / `wrapMcpClient` + stdio + HTTP transport adapters |
|
|
185
|
+
| Repo public and discoverable | ✅ Public, 12 topics, GitHub release v0.1.0 |
|
|
186
|
+
|
|
187
|
+
**What the original plan identified as gaps that were then built before launch — not retrofitted.** That sequence (design → TDD → ship) is why the shipped state is consistent.
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## 8) Open risks (carry forward)
|
|
192
|
+
|
|
193
|
+
- **Adoption is the only live risk.** An unadopted protocol's value is ~0 regardless of implementation quality. First real users matter more than a seventh benchmark run. The MCP wrapper is the fastest path to "I protected my MCP server this afternoon."
|
|
194
|
+
- **No independent security audit.** For a signing protocol, a third-party crypto review is the credential that converts skeptics. Particularly: the canonicalization algorithm (fixed-key-order scheme) and the nonce/TTL window assumptions deserve an external read.
|
|
195
|
+
- **No formal fuzz campaign** on parser boundaries (wire decode, envelope validation). Reproducible fuzz corpus welcome.
|
|
196
|
+
- **Distributed stores require an available Redis control plane.** Operators own HA and clock synchronization. Documented in `docs/DISTRIBUTED_REPLAY.md`; runtime degradation is observable via `onDegraded` hook.
|
|
197
|
+
- **Wire version `aip/0.1` is frozen.** Any break to the envelope schema, canonicalization algorithm, or intent vocabulary is a major version bump. The TypeScript API is pre-1.0 — minor version may bring breaking changes.
|
|
198
|
+
- **Python and Rust packages not yet published** (PyPI, crates.io). Polyglot claim is verifiable via the shared conformance fixture, but `pip install` and `cargo add` don't work yet.
|
|
199
|
+
- **Standardization race.** MCPS or MCP native signing could absorb the niche. Speed of community adoption is the hedge.
|
|
200
|
+
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
## 9) Bottom line
|
|
204
|
+
|
|
205
|
+
The engineering shipped clean: 123 tests green, real cryptography, genuine tri-language parity, four MCP security bindings all independently tested, distributed stores with graceful degradation, and a live-Redis integration test confirming the round-trip. The original examination's two core diagnoses — *mis-packaged* and *mis-positioned* — have both been addressed. The protocol is now a real, installable, documented, public artifact with honest caveats.
|
|
206
|
+
|
|
207
|
+
The question is no longer "is this good enough to release?" It is "can it earn enough adoption that the standardization window doesn't close first?" That is a distribution and community problem, not an engineering problem. The MCP wrapper is the lever: it gives any developer a same-afternoon path from "interesting" to "running in my stack."
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
### Sources (competitive landscape, verified 2026-05-31)
|
|
212
|
+
|
|
213
|
+
- MCP lacks per-message auth/integrity: https://github.com/google/mcp/issues/32
|
|
214
|
+
- State of MCP Security 2026 (unsigned messages, no replay, MCPS proposal): https://nimblebrain.ai/blog/state-of-mcp-security-2026/
|
|
215
|
+
- MCP Security Checklist 2026: https://www.networkintelligence.ai/blogs/model-context-protocol-mcp-security-checklist/
|
|
216
|
+
- NSA MCP security guidance: https://www.nsa.gov/Portals/75/documents/Cybersecurity/CSI_MCP_SECURITY.pdf
|
|
217
|
+
- "MCP is dead, long live MCPS" (per-message signing + nonce replay envelope): https://dev.to/razashariff/mcp-is-dead-long-live-mcps-5ddp
|
|
218
|
+
- A2A Signed Agent Cards (card-level, not per-message): https://cloud.google.com/blog/products/ai-machine-learning/agent2agent-protocol-is-getting-an-upgrade
|
|
219
|
+
- A2A protocol overview: https://a2a-protocol.org/latest/
|