@7h3/protocol 0.4.0 → 0.5.1
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/README.md +6 -323
- package/agentAdapter.d.ts +26 -0
- package/auditLog.d.ts +54 -0
- package/capability.d.ts +67 -0
- package/cborCodec.d.ts +34 -0
- package/conformanceVectors.d.ts +20 -0
- package/encryption.d.ts +85 -0
- package/envelopeCbor.d.ts +33 -0
- package/frameworkAdapters.d.ts +72 -0
- package/gateway.d.ts +53 -0
- package/grpcBinding.d.ts +29 -0
- package/httpBinding.d.ts +50 -0
- package/index.d.ts +39 -0
- package/index.js +3662 -0
- package/keyInfra.d.ts +64 -0
- package/keyRegistry.d.ts +9 -0
- package/keyRotation.d.ts +20 -0
- package/mcpGateway.d.ts +37 -0
- package/mcpTransports.d.ts +62 -0
- package/mcpWrapper.d.ts +83 -0
- package/otel.d.ts +65 -0
- package/package.json +13 -79
- package/policyEnforcer.d.ts +50 -0
- package/policyTelemetryFeedback.d.ts +11 -0
- package/protocol.d.ts +66 -0
- package/protocolAgent.d.ts +58 -0
- package/protocolBinary.d.ts +8 -0
- package/protocolCapabilities.d.ts +24 -0
- package/protocolReplay.d.ts +35 -0
- package/protocolTransport.d.ts +73 -0
- package/queueBinding.d.ts +43 -0
- package/rateLimiter.d.ts +18 -0
- package/{src/redisClient.ts → redisClient.d.ts} +25 -75
- package/replayStores.d.ts +98 -0
- package/revocation.d.ts +71 -0
- package/routePolicy.d.ts +30 -0
- package/runtimePolicy.d.ts +24 -0
- package/runtimePolicyManager.d.ts +15 -0
- package/runtimePolicyPresets.d.ts +11 -0
- package/signedResponse.d.ts +21 -0
- package/stream.d.ts +59 -0
- package/telemetry.d.ts +79 -0
- package/webhookBinding.d.ts +30 -0
- package/wsBinding.d.ts +52 -0
- package/.dockerignore +0 -19
- package/.github/dependabot.yml +0 -32
- package/.github/workflows/ci.yml +0 -31
- package/.github/workflows/publish.yml +0 -59
- package/.github/workflows/scorecard.yml +0 -37
- package/7h3.example.yaml +0 -125
- package/CHANGELOG.md +0 -92
- package/CONTRIBUTING.md +0 -82
- package/Dockerfile +0 -73
- package/GOVERNANCE.md +0 -62
- package/SECURITY.md +0 -70
- package/bench-results/replay-cache-full-1777891033256.json +0 -10
- package/bench-results/replay-cache-full-1777896317488.json +0 -10
- package/bench-results/replay-cache-full-1777900993184.json +0 -10
- package/bench-results/replay-cache-full-1777901019285.json +0 -10
- package/bench-results/replay-cache-quick-1777870170126.json +0 -10
- package/bench-results/signature-profiles-quick-1775875160079.json +0 -85
- package/bench-results/signature-profiles-quick-1775983539716.json +0 -85
- package/bench-results/signature-profiles-quick-1776237913190.json +0 -85
- package/bench-results/wire-codecs-full-1777891019803.json +0 -93
- package/bench-results/wire-codecs-full-1777896260964.json +0 -93
- package/bench-results/wire-codecs-full-1777901004247.json +0 -93
- package/bench-results/wire-codecs-quick-1775972879056.json +0 -93
- package/bench-results/wire-codecs-quick-1775983541111.json +0 -93
- package/bench-results/wire-codecs-quick-1776237914299.json +0 -93
- package/bench-results/wire-codecs-quick-1777841285236.json +0 -93
- package/bench-results/wire-codecs-quick-1777841321772.json +0 -93
- package/bench-results/wire-codecs-quick-1777841330408.json +0 -93
- package/bench-results/wire-codecs-quick-1777852886082.json +0 -93
- package/bench-results/wire-codecs-quick-1777852988773.json +0 -93
- package/bench-results/wire-codecs-quick-1777870188095.json +0 -93
- package/bench-results/wire-codecs-quick-1777870263918.json +0 -93
- package/bench-results/wire-codecs-quick-1777870455034.json +0 -93
- package/bench-results/wire-codecs-quick-1778816163081.json +0 -93
- package/bench-results/wire-codecs-quick-1778843936130.json +0 -93
- package/bin/7h3.ts +0 -385
- package/conformance/7h3_v0_1.json +0 -77
- package/conformance/7h3_v0_1_binary.json +0 -20
- package/conformance/aip_v0_1_binary.json +0 -20
- package/docker-compose.yaml +0 -77
- package/docs/ADOPTION_PLAN.md +0 -120
- package/docs/AGENTS.md +0 -77
- package/docs/AIP_RFC_v0.1.md +0 -97
- package/docs/AI_DECISION_CARD.md +0 -122
- package/docs/AI_RUNTIME_POLICY.json +0 -126
- package/docs/AI_RUNTIME_POLICY.yaml +0 -110
- package/docs/BACKPRESSURE_TUNING.md +0 -65
- package/docs/BENCHMARK_CLAIM_MATRIX.md +0 -42
- package/docs/BENCHMARK_REPORT_TEMPLATE.md +0 -169
- package/docs/BINARY_CODEC_BENCH.md +0 -23
- package/docs/CLEAN_CLONE_RUNBOOK.md +0 -36
- package/docs/CLOCK_SKEW_POLICY.md +0 -30
- package/docs/DISTRIBUTED_REPLAY.md +0 -142
- package/docs/FUZZ_CAMPAIGN.md +0 -121
- package/docs/GATEWAY.md +0 -195
- package/docs/KEY_MANAGEMENT_POLICY.md +0 -53
- package/docs/KEY_REVOCATION.md +0 -69
- package/docs/MCP_WRAPPER.md +0 -159
- package/docs/MIGRATION_GUIDE.md +0 -40
- package/docs/OPERATORS.md +0 -184
- package/docs/PERF_REGRESSION_POLICY.md +0 -34
- package/docs/PROJECT_EXAMINATION_2026-05-31.md +0 -219
- package/docs/RELEASE_BENCHMARK_REPORT_2026-05-15.md +0 -135
- package/docs/RELEASE_GATE.md +0 -25
- package/docs/RELEASE_NOTES_v0.1.0.md +0 -54
- package/docs/SECURITY_REVIEW_2026-06-05.md +0 -165
- package/docs/TELEMETRY.md +0 -41
- package/docs/THREAT_MODEL.md +0 -89
- package/docs/VERSIONING_POLICY.md +0 -30
- package/docs/assets/banner.png +0 -0
- package/eslint.config.js +0 -15
- package/fuzz/ts/harness-decode.ts +0 -136
- package/fuzz/ts/harness-verify.ts +0 -121
- package/fuzz/ts/run.ts +0 -35
- package/mcp-server/README.md +0 -38
- package/mcp-server/package-lock.json +0 -1187
- package/mcp-server/package.json +0 -35
- package/mcp-server/src/index.ts +0 -236
- package/mcp-server/tsconfig.json +0 -14
- package/scripts/aip-framework-quickstart.ts +0 -110
- package/scripts/aip-mcp-gateway.ts +0 -38
- package/scripts/aip-mcp-wrap-demo.ts +0 -72
- package/scripts/aip-quickstart.ts +0 -60
- package/scripts/bench-diff.ts +0 -118
- package/scripts/bench-protocol-e2e.ts +0 -937
- package/scripts/bench-protocol-openloop.ts +0 -1397
- package/scripts/bench-replay-cache.ts +0 -76
- package/scripts/bench-signature-profiles.ts +0 -180
- package/scripts/bench-wire-codecs.ts +0 -161
- package/scripts/build-binary-conformance.ts +0 -36
- package/scripts/build-release-dashboard.ts +0 -175
- package/scripts/canary-rollout.ts +0 -38
- package/scripts/mcpGatewayCli.test.ts +0 -116
- package/scripts/prepare-aip-package.ts +0 -88
- package/scripts/regen-conformance-sigs.ts +0 -18
- package/scripts/release-gate.ts +0 -19
- package/scripts/validate-runtime-policy.ts +0 -18
- package/sdk/browser/index.test.ts +0 -162
- package/sdk/browser/index.ts +0 -257
- package/sdk/browser/package.json +0 -13
- package/sdk/go/go.mod +0 -3
- package/sdk/go/http.go +0 -135
- package/sdk/go/protocol.go +0 -324
- package/sdk/go/protocol_test.go +0 -334
- package/sdk/go/webhook.go +0 -136
- package/sdk/python/README.md +0 -18
- package/sdk/python/protocol_7h3/__init__.py +0 -46
- package/sdk/python/protocol_7h3/http.py +0 -212
- package/sdk/python/protocol_7h3/keys.py +0 -149
- package/sdk/python/protocol_7h3/protocol.py +0 -525
- package/sdk/python/protocol_7h3/queue.py +0 -118
- package/sdk/python/protocol_7h3/webhook.py +0 -116
- package/sdk/python/pyproject.toml +0 -40
- package/sdk/python/tests/test_conformance.py +0 -110
- package/sdk/python/tests/test_http.py +0 -305
- package/sdk/python/tests/test_keys.py +0 -417
- package/sdk/python/tests/test_queue.py +0 -120
- package/sdk/python/tests/test_webhook.py +0 -345
- package/sdk/rust/Cargo.lock +0 -371
- package/sdk/rust/Cargo.toml +0 -25
- package/sdk/rust/README.md +0 -31
- package/sdk/rust/fuzz/Cargo.toml +0 -29
- package/sdk/rust/fuzz/fuzz_targets/fuzz_canonicalize.rs +0 -46
- package/sdk/rust/fuzz/fuzz_targets/fuzz_decode.rs +0 -11
- package/sdk/rust/src/bin/aip_mcp_gateway.rs +0 -59
- package/sdk/rust/src/http.rs +0 -145
- package/sdk/rust/src/keys.rs +0 -161
- package/sdk/rust/src/lib.rs +0 -688
- package/sdk/rust/src/queue.rs +0 -79
- package/sdk/rust/src/webhook.rs +0 -86
- package/sdk/rust/tests/conformance.rs +0 -148
- package/sdk/rust/tests/gateway.rs +0 -130
- package/sdk/rust/tests/http_webhook_queue.rs +0 -201
- package/sdk/rust/tests/keys.rs +0 -189
- package/src/agentAdapter.test.ts +0 -48
- package/src/agentAdapter.ts +0 -56
- package/src/auditLog.test.ts +0 -145
- package/src/auditLog.ts +0 -147
- package/src/conformance.test.ts +0 -136
- package/src/conformanceVectors.ts +0 -99
- package/src/frameworkAdapters.test.ts +0 -290
- package/src/frameworkAdapters.ts +0 -261
- package/src/gateway.test.ts +0 -343
- package/src/gateway.ts +0 -171
- package/src/grpcBinding.test.ts +0 -211
- package/src/grpcBinding.ts +0 -103
- package/src/httpBinding.test.ts +0 -376
- package/src/httpBinding.ts +0 -163
- package/src/index.ts +0 -32
- package/src/keyInfra.test.ts +0 -278
- package/src/keyInfra.ts +0 -228
- package/src/keyRegistry.ts +0 -59
- package/src/keyRotation.test.ts +0 -78
- package/src/keyRotation.ts +0 -72
- package/src/mcpGateway.test.ts +0 -129
- package/src/mcpGateway.ts +0 -250
- package/src/mcpTransports.test.ts +0 -92
- package/src/mcpTransports.ts +0 -169
- package/src/mcpWrapper.test.ts +0 -179
- package/src/mcpWrapper.ts +0 -206
- package/src/policyEnforcer.test.ts +0 -99
- package/src/policyEnforcer.ts +0 -169
- package/src/policyTelemetryFeedback.test.ts +0 -25
- package/src/policyTelemetryFeedback.ts +0 -38
- package/src/protocol.bench.ts +0 -37
- package/src/protocol.test.ts +0 -155
- package/src/protocol.ts +0 -413
- package/src/protocolAgent.test.ts +0 -105
- package/src/protocolAgent.ts +0 -169
- package/src/protocolBinary.test.ts +0 -165
- package/src/protocolBinary.ts +0 -312
- package/src/protocolCapabilities.ts +0 -70
- package/src/protocolFuzz.advanced.test.ts +0 -235
- package/src/protocolFuzz.test.ts +0 -111
- package/src/protocolNegative.test.ts +0 -97
- package/src/protocolReplay.test.ts +0 -71
- package/src/protocolReplay.ts +0 -194
- package/src/protocolTransport.test.ts +0 -556
- package/src/protocolTransport.ts +0 -483
- package/src/queueBinding.test.ts +0 -130
- package/src/queueBinding.ts +0 -102
- package/src/rateLimiter.test.ts +0 -96
- package/src/rateLimiter.ts +0 -46
- package/src/redisIntegration.test.ts +0 -134
- package/src/replayStores.test.ts +0 -141
- package/src/replayStores.ts +0 -82
- package/src/revocation.test.ts +0 -98
- package/src/revocation.ts +0 -0
- package/src/routePolicy.test.ts +0 -87
- package/src/routePolicy.ts +0 -72
- package/src/runtimePolicy.test.ts +0 -49
- package/src/runtimePolicy.ts +0 -81
- package/src/runtimePolicyManager.test.ts +0 -29
- package/src/runtimePolicyManager.ts +0 -50
- package/src/runtimePolicyPresets.ts +0 -43
- package/src/signedResponse.test.ts +0 -111
- package/src/signedResponse.ts +0 -83
- package/src/webhookBinding.test.ts +0 -144
- package/src/webhookBinding.ts +0 -115
- package/src/wsBinding.test.ts +0 -221
- package/src/wsBinding.ts +0 -100
- package/tsconfig.json +0 -15
- package/tsconfig.lib.json +0 -23
- package/vite.lib.config.ts +0 -16
|
@@ -1,34 +0,0 @@
|
|
|
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.
|
|
@@ -1,219 +0,0 @@
|
|
|
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/
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
# Release Benchmark Report (2026-05-15)
|
|
2
|
-
|
|
3
|
-
## 1) Metadata
|
|
4
|
-
|
|
5
|
-
- Report ID: `gluv-release-bench-2026-05-15`
|
|
6
|
-
- Date/Time (UTC): 2026-05-15 (updated 2026-05-18)
|
|
7
|
-
- Branch/Commit: `bbcd960` (Fix inFlight counter leak in HTTP batch bench server handler)
|
|
8
|
-
- Runtime: Node.js `v24.10.0`
|
|
9
|
-
- Machine: local benchmark host (same environment used for prior release-gate runs)
|
|
10
|
-
|
|
11
|
-
## 2) Scope
|
|
12
|
-
|
|
13
|
-
- Profile: `full` (segmented mode-by-mode to avoid timeout)
|
|
14
|
-
- Modes tested:
|
|
15
|
-
- `ws`, `ws-batch`, `ws-binary`, `ws-binary-batch`
|
|
16
|
-
- `http-binary`
|
|
17
|
-
- `http-batch` (concurrency 10 lanes complete; concurrency 100 unstable/timeout)
|
|
18
|
-
- `http-binary-batch` (concurrency 10 lanes complete; concurrency 100 incomplete)
|
|
19
|
-
- Payload sizes: `256`, `1024`, `4096` bytes
|
|
20
|
-
- Concurrency levels targeted: `10`, `100`
|
|
21
|
-
|
|
22
|
-
## 3) Security Configuration Matrix
|
|
23
|
-
|
|
24
|
-
| Check | Full Secure Protocol |
|
|
25
|
-
|---|---:|
|
|
26
|
-
| Signature verification | enabled |
|
|
27
|
-
| Canonicalization | enabled |
|
|
28
|
-
| Replay defense | enabled |
|
|
29
|
-
| TTL/clock-skew enforcement | enabled |
|
|
30
|
-
| Policy checks/guardrails | enabled |
|
|
31
|
-
|
|
32
|
-
Notes:
|
|
33
|
-
- Guardrail for unsafe plain `http` high-concurrency was enforced.
|
|
34
|
-
- No benchmark run in this report used invariant-bypass settings.
|
|
35
|
-
|
|
36
|
-
## 4) Commands Executed (Representative)
|
|
37
|
-
|
|
38
|
-
```bash
|
|
39
|
-
npx tsx scripts/bench-protocol-openloop.ts --profile full --ci --adaptive --p99-threshold 250 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8 --modes ws
|
|
40
|
-
npx tsx scripts/bench-protocol-openloop.ts --profile full --ci --adaptive --p99-threshold 250 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8 --modes ws-batch
|
|
41
|
-
npx tsx scripts/bench-protocol-openloop.ts --profile full --ci --adaptive --p99-threshold 250 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8 --modes ws-binary
|
|
42
|
-
npx tsx scripts/bench-protocol-openloop.ts --profile full --ci --adaptive --p99-threshold 250 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8 --modes ws-binary-batch
|
|
43
|
-
npx tsx scripts/bench-protocol-openloop.ts --profile full --ci --adaptive --p99-threshold 250 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8 --modes http-binary
|
|
44
|
-
npx tsx scripts/bench-protocol-openloop.ts --profile full --adaptive --p99-threshold 250 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8 --modes http-batch --payloads 256,1024,4096 --concurrency 10
|
|
45
|
-
npx tsx scripts/bench-protocol-openloop.ts --profile full --adaptive --p99-threshold 250 --drop-threshold-pct 2 --adaptive-max-doublings 6 --adaptive-binary-steps 8 --modes http-binary-batch --payloads 256,1024,4096 --concurrency 10
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
## 5) Results Summary (Best observed per lane)
|
|
49
|
-
|
|
50
|
-
### Full Secure Protocol (authoritative)
|
|
51
|
-
|
|
52
|
-
| Mode | Payload | Concurrency | Ops/s | Drop % | p99 ms | Sustainable |
|
|
53
|
-
|---|---:|---:|---:|---:|---:|---|
|
|
54
|
-
| ws | 256 | 100 | 6548.375 | 0.000 | 49.669 | yes |
|
|
55
|
-
| ws | 1024 | 100 | 5887.500 | 0.000 | 53.772 | yes |
|
|
56
|
-
| ws | 4096 | 100 | 3887.500 | 0.000 | 66.011 | yes |
|
|
57
|
-
| ws-batch | 256 | 100 | 7649.000 | 0.000 | 30.971 | yes |
|
|
58
|
-
| ws-batch | 1024 | 100 | 6749.500 | 0.000 | 37.306 | yes |
|
|
59
|
-
| ws-batch | 4096 | 100 | 3850.000 | 0.000 | 49.455 | yes |
|
|
60
|
-
| ws-binary | 256 | 100 | 7261.000 | 0.000 | 53.193 | yes |
|
|
61
|
-
| ws-binary | 1024 | 100 | 5087.375 | 0.000 | 73.307 | yes |
|
|
62
|
-
| ws-binary | 4096 | 100 | 3662.500 | 0.000 | 77.854 | yes |
|
|
63
|
-
| ws-binary-batch | 256 | 100 | 5750.000 | 0.000 | 36.134 | yes |
|
|
64
|
-
| ws-binary-batch | 1024 | 100 | 6499.000 | 0.000 | 35.508 | yes |
|
|
65
|
-
| ws-binary-batch | 4096 | 100 | 4246.000 | 0.000 | 63.565 | yes |
|
|
66
|
-
| http-binary | 256 | 100 | 2699.875 | 0.000 | 129.755 | yes |
|
|
67
|
-
| http-binary | 1024 | 100 | 2385.000 | 0.000 | 119.438 | yes |
|
|
68
|
-
| http-binary | 4096 | 100 | 11993.750 | 0.000 | 17.647 | yes |
|
|
69
|
-
| http-batch | 256 | 10 | 399.125 | 1.359 | 0.867 | yes |
|
|
70
|
-
| http-batch | 1024 | 10 | 291.625 | 1.686 | 0.939 | yes |
|
|
71
|
-
| http-batch | 4096 | 10 | 320.500 | 1.536 | 1.259 | yes |
|
|
72
|
-
| http-binary-batch | 256 | 10 | 276.000 | 1.779 | 0.979 | yes |
|
|
73
|
-
| http-binary-batch | 1024 | 10 | 260.000 | 1.887 | 0.983 | yes |
|
|
74
|
-
| http-binary-batch | 4096 | 10 | 447.500 | 1.214 | 1.260 | yes |
|
|
75
|
-
|
|
76
|
-
### Updated results after bug fix (2026-05-18, commit `bbcd960`)
|
|
77
|
-
|
|
78
|
-
Root cause identified and fixed: the `inFlight` counter in the HTTP batch bench server handler was never decremented for batch requests, causing it to accumulate until the server began 503-ing all traffic. Fix: added `finally { this.inFlight -= 1 }` to the batch path.
|
|
79
|
-
|
|
80
|
-
| Mode | Payload | Concurrency | Ops/s | Drop % | p99 ms | Sustainable |
|
|
81
|
-
|---|---:|---:|---:|---:|---:|---|
|
|
82
|
-
| http-batch | 256 | 100 | 34940.000 | 0.000 | 7.877 | yes |
|
|
83
|
-
| http-batch | 1024 | 100 | 21460.000 | 0.000 | 11.470 | yes |
|
|
84
|
-
| http-batch | 4096 | 100 | 17886.667 | 0.000 | 13.683 | yes |
|
|
85
|
-
| http-binary-batch | 256 | 100 | 28238.000 | 0.000 | 8.551 | yes |
|
|
86
|
-
| http-binary-batch | 1024 | 100 | 19056.000 | 0.000 | 22.214 | yes |
|
|
87
|
-
| http-binary-batch | 4096 | 100 | 11096.000 | 0.000 | 20.675 | yes |
|
|
88
|
-
|
|
89
|
-
Evidence: `dist/bench/protocol-openloop.quick.2026-05-18T09-23-51-852Z.json`
|
|
90
|
-
|
|
91
|
-
## 6) SLO Gate Status
|
|
92
|
-
|
|
93
|
-
Defined gates used in this closure cycle:
|
|
94
|
-
|
|
95
|
-
- Interactive lanes: `p99 <= 25ms`, `drop <= 2%`
|
|
96
|
-
- High-throughput lanes: `p99 <= 250ms`, `drop <= 2%`
|
|
97
|
-
|
|
98
|
-
Current status:
|
|
99
|
-
|
|
100
|
-
- WS lanes (`ws*`): PASS on completed lanes.
|
|
101
|
-
- `http-binary`: PASS on completed lanes.
|
|
102
|
-
- `http-batch` and `http-binary-batch`: PASS at concurrency `100` after `bbcd960` bug fix (0% drop, all p99 within gate).
|
|
103
|
-
|
|
104
|
-
Overall decision: `GO (all lanes pass SLO gates as of 2026-05-18)`
|
|
105
|
-
|
|
106
|
-
## 7) Reliability Hardening Applied During Benchmarking
|
|
107
|
-
|
|
108
|
-
- Added HTTP/2 server stream `error` handling in bench harness.
|
|
109
|
-
- Added HTTP/2 client session `error` handling in bench harness.
|
|
110
|
-
- These are benchmark resilience fixes and do not alter protocol invariants.
|
|
111
|
-
|
|
112
|
-
## 8) Evidence Artifacts
|
|
113
|
-
|
|
114
|
-
- `dist/bench/protocol-openloop.full.2026-05-15T08-33-35-118Z.json`
|
|
115
|
-
- `dist/bench/protocol-openloop.full.2026-05-15T08-48-39-773Z.json`
|
|
116
|
-
- `dist/bench/protocol-openloop.full.2026-05-15T09-03-28-317Z.json`
|
|
117
|
-
- `dist/bench/protocol-openloop.full.2026-05-15T09-18-35-320Z.json`
|
|
118
|
-
- `dist/bench/protocol-openloop.full.2026-05-15T09-33-32-306Z.json`
|
|
119
|
-
- `dist/bench/protocol-openloop.full.2026-05-15T10-48-40-452Z.json`
|
|
120
|
-
- `dist/bench/protocol-openloop.full.2026-05-15T11-18-47-746Z.json`
|
|
121
|
-
|
|
122
|
-
## 9) Security Review Checklist
|
|
123
|
-
|
|
124
|
-
- [x] Signature verification enabled
|
|
125
|
-
- [x] Replay defense enabled
|
|
126
|
-
- [x] TTL/clock-skew checks enabled
|
|
127
|
-
- [x] Canonicalization enabled
|
|
128
|
-
- [x] Policy validation run (`npm run policy:validate`)
|
|
129
|
-
- [x] Release gate re-run after harness changes (`npm run release:gate`)
|
|
130
|
-
|
|
131
|
-
## 10) Next Actions for Full Closure
|
|
132
|
-
|
|
133
|
-
- ~~Rework HTTP batch transport path before re-qualification at concurrency `100`.~~ Resolved by `bbcd960`.
|
|
134
|
-
- All transport modes qualified. No further bench gate blockers.
|
|
135
|
-
- Proceed with `@7h3/protocol` publish from `dist/npm-aip/` via release automation.
|
package/docs/RELEASE_GATE.md
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
# GLUV Release Gate
|
|
2
|
-
|
|
3
|
-
Run this gate before publishing protocol performance claims or changing transport defaults.
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
npm run release:gate
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
The gate runs tests, AIP build, lint, wire benchmarks, and adaptive open-loop CI checks. For release candidates, also run:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
npm run bench:wire:full
|
|
13
|
-
npm run bench:replay:full
|
|
14
|
-
npm run bench:openloop:full
|
|
15
|
-
npm run conformance:binary
|
|
16
|
-
npm run conformance:python
|
|
17
|
-
npm run conformance:rust
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
## Rollout Rules
|
|
21
|
-
|
|
22
|
-
- Compact JSON remains the default wire format for `aip/0.1` compatibility.
|
|
23
|
-
- Binary wire and binary WebSocket modes are opt-in until negotiated through `CAPS`.
|
|
24
|
-
- Signature verification, replay defense, TTL validation, and canonicalization must stay enabled in all benchmark claims.
|
|
25
|
-
- README performance numbers must come from fresh benchmark artifacts committed or attached to the release.
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# v0.1.0 — First public release
|
|
2
|
-
|
|
3
|
-
> **The signing-and-replay layer your agent protocol forgot.**
|
|
4
|
-
|
|
5
|
-
MCP sends JSON-RPC unsigned. A2A signs the identity card, not the traffic.
|
|
6
|
-
`@7h3/protocol` puts a signed, TTL-bounded, replay-checked AIP envelope around every message — without touching your handler.
|
|
7
|
-
|
|
8
|
-
## What's included
|
|
9
|
-
|
|
10
|
-
**Core AIP (`aip/0.1`)**
|
|
11
|
-
Real WebCrypto HMAC-SHA256 + Ed25519 over a deterministic canonical form. Byte-identical signatures in TypeScript, Python, and Rust via a shared conformance fixture.
|
|
12
|
-
|
|
13
|
-
**Distributed replay protection**
|
|
14
|
-
Redis-backed `SET NX PX` atomic reserve. Client-agnostic (`RedisLikeClient`) — works with ioredis, node-redis, or any adapter. Graceful degradation to local store on Redis outage; `onDegraded` hook for observability.
|
|
15
|
-
|
|
16
|
-
**Fleet-wide key revocation**
|
|
17
|
-
Cached reads, fail-closed default. Wraps any `SignatureResolver` — one line to add revocation to an existing verify path.
|
|
18
|
-
|
|
19
|
-
**MCP hardening wrapper**
|
|
20
|
-
Drop `wrapMcpServer` around your handler. Add `wrapMcpClient` on the caller. Four threat bindings enforced out of the box:
|
|
21
|
-
|
|
22
|
-
| Binding | Defends against |
|
|
23
|
-
|---|---|
|
|
24
|
-
| Recipient | Cross-server replay |
|
|
25
|
-
| Sender | Response spoofing |
|
|
26
|
-
| Correlation | Response substitution |
|
|
27
|
-
| Replay (default on) | Duplicate execution |
|
|
28
|
-
|
|
29
|
-
**Transport adapters**
|
|
30
|
-
`serveMcpOverStdio` + `createHttpMcpHandler` — real transports, no new npm deps.
|
|
31
|
-
|
|
32
|
-
## Install
|
|
33
|
-
|
|
34
|
-
```bash
|
|
35
|
-
npm install @7h3/protocol
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
## Quick demo
|
|
39
|
-
|
|
40
|
-
```bash
|
|
41
|
-
git clone https://github.com/IceMasterT/7h3-protocol-aip
|
|
42
|
-
cd 7h3-protocol-aip && npm install
|
|
43
|
-
npm run aip:mcp:wrap # proves tamper + replay rejection
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Honest caveats
|
|
47
|
-
|
|
48
|
-
- No independent security audit yet — reproductions and findings welcome.
|
|
49
|
-
- Distributed stores require a Redis (or equivalent) control plane; operators own HA and clock sync.
|
|
50
|
-
- Wire version `aip/0.1` is stable; the TypeScript API is pre-1.0 (minor version may bring breaking changes).
|
|
51
|
-
|
|
52
|
-
## License
|
|
53
|
-
|
|
54
|
-
MIT.
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# Internal Security Review — AIP v0.1.2
|
|
2
|
-
|
|
3
|
-
**Date:** 2026-06-05
|
|
4
|
-
**Reviewer:** Claude Code (AI-assisted internal review)
|
|
5
|
-
**Scope:** `@7h3/protocol` v0.1.2 — TypeScript sources, Python SDK, Rust SDK
|
|
6
|
-
**Status:** ⚠️ NOT an independent third-party audit. This review was performed by the same AI assistant that co-developed parts of the codebase. It is published for transparency; it does not substitute for an independent cryptographic audit.
|
|
7
|
-
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
## Summary
|
|
11
|
-
|
|
12
|
-
The core cryptographic choices are sound: WebCrypto primitives for both HMAC-SHA256 and Ed25519, constant-time verification, algorithm-confusion guards, and fail-closed revocation. Two real bugs were found and fixed in this review pass. No signature-forgery or authentication-bypass paths were identified.
|
|
13
|
-
|
|
14
|
-
| Finding | Severity | Status |
|
|
15
|
-
|---|---|---|
|
|
16
|
-
| Replay key collision via unescaped `\|` separator | Medium | **Fixed** — `encodeURIComponent` applied |
|
|
17
|
-
| Empty nonce not rejected by `validateEnvelope` | Low | **Fixed** — error diagnostic added |
|
|
18
|
-
| Rust cargo-fuzz targets uncompiled (README overclaim) | Low | **Corrected in README** |
|
|
19
|
-
| `recipient: null` vs `undefined` — cross-language parity gap | Low | Documented accepted risk |
|
|
20
|
-
| Revocation key space-separator (minor variant of #1) | Low | Documented accepted risk |
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## Finding 1 — Replay Key Collision (Medium, Fixed)
|
|
25
|
-
|
|
26
|
-
**File:** `src/protocolReplay.ts` — `InMemoryReplayCache.makeKey` and `DistributedReplayCache.makeKey`
|
|
27
|
-
|
|
28
|
-
**Before:**
|
|
29
|
-
```ts
|
|
30
|
-
return `${envelope.header.sender}|${envelope.header.messageId}|${envelope.header.nonce}`
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**Problem:** The `|` separator is unescaped. A sender named `"a|b"` with messageId `"c"` produces the same composite key as sender `"a"` with messageId `"b|c"`. If an attacker controls their own agent ID and can observe or predict a target agent's messageId, they can send a message first that "claims" the target's replay key, causing the legitimate message to be rejected as a replay.
|
|
34
|
-
|
|
35
|
-
**Security impact:** This is a **false-rejection DoS**, not a forgery or auth bypass. Signatures still cover the full, unencoded field values — an attacker cannot craft a message that validates under a victim's key. The worst they can achieve is having a legitimate message silently dropped.
|
|
36
|
-
|
|
37
|
-
**Fix applied:**
|
|
38
|
-
```ts
|
|
39
|
-
return `${encodeURIComponent(envelope.header.sender)}|${encodeURIComponent(envelope.header.messageId)}|${encodeURIComponent(envelope.header.nonce)}`
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
`encodeURIComponent` maps `|` → `%7C`, making cross-boundary collisions impossible. For typical agent IDs containing only word characters and hyphens, the output is byte-identical to the old format — no Redis key migration required for standard deployments.
|
|
43
|
-
|
|
44
|
-
**Note on deployed keys:** If your Redis instance already contains replay keys with agent IDs containing `|`, `%`, or other URI-reserved characters, those keys will have a different format after this fix. Existing entries will expire naturally via their TTL; no manual migration is needed.
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## Finding 2 — Empty Nonce Not Validated (Low, Fixed)
|
|
49
|
-
|
|
50
|
-
**File:** `src/protocol.ts` — `validateEnvelope`
|
|
51
|
-
|
|
52
|
-
**Problem:** `validateEnvelope` checked `messageId`, `sender`, `ttlMs`, `timestampMs`, and `content` but did not validate `nonce`. A missing or empty nonce produces a replay key of the form `sender||messageId`. While this doesn't defeat replay protection outright (the composite key still covers sender + messageId), it eliminates the entropy contribution of the nonce and allows any two messages with identical sender + messageId to collide in the replay cache, regardless of time.
|
|
53
|
-
|
|
54
|
-
**Fix applied:** Added `if (!nonce.trim()) diagnostics.push({ level: 'error', message: 'Missing nonce — replay protection requires a unique nonce per message' })`.
|
|
55
|
-
|
|
56
|
-
---
|
|
57
|
-
|
|
58
|
-
## Finding 3 — Rust cargo-fuzz Targets Uncompiled (Low, Corrected)
|
|
59
|
-
|
|
60
|
-
**File:** `sdk/rust/fuzz/`, `README.md` status table
|
|
61
|
-
|
|
62
|
-
**Problem:** `cargo-fuzz` is not installed in the development environment. The Rust fuzz targets (`fuzz_decode.rs`, `fuzz_canonicalize.rs`) were authored and reviewed but have never been compiled or run. The prior README entry claimed "✅ cargo-fuzz targets" without this qualification.
|
|
63
|
-
|
|
64
|
-
**Correction:** The README status now reads: "TypeScript harnesses run clean (50k/20k rounds); Rust targets authored, not yet executed (`cargo-fuzz` not installed)."
|
|
65
|
-
|
|
66
|
-
The targets themselves look structurally correct:
|
|
67
|
-
- `fuzz_decode`: feeds arbitrary bytes through `decode_envelope` under a no-panic invariant — correct
|
|
68
|
-
- `fuzz_canonicalize`: constructs `ProtocolEnvelope` from fuzz bytes, asserts `canonicalize_envelope` is idempotent — correct
|
|
69
|
-
|
|
70
|
-
To run:
|
|
71
|
-
```bash
|
|
72
|
-
rustup toolchain install nightly
|
|
73
|
-
cargo install cargo-fuzz
|
|
74
|
-
cargo +nightly fuzz run fuzz_decode --manifest-path sdk/rust/fuzz/Cargo.toml
|
|
75
|
-
cargo +nightly fuzz run fuzz_canonicalize --manifest-path sdk/rust/fuzz/Cargo.toml
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
---
|
|
79
|
-
|
|
80
|
-
## Finding 4 — `recipient: null` vs Absent (Low, Accepted Risk)
|
|
81
|
-
|
|
82
|
-
**File:** `src/protocol.ts` — `serializeHeaderCanonical`
|
|
83
|
-
|
|
84
|
-
```ts
|
|
85
|
-
if (header.recipient !== undefined) {
|
|
86
|
-
parts.push(`"recipient":${JSON.stringify(header.recipient)}`)
|
|
87
|
-
}
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
If a JSON message arrives with `"recipient": null`, JavaScript parses this as `null`, which passes the `!== undefined` check. `JSON.stringify(null)` produces `"null"`, so the canonical form includes `"recipient":null` — different from a message where `recipient` is absent entirely.
|
|
91
|
-
|
|
92
|
-
In the TypeScript type system, `ProtocolHeader.recipient` is typed as `string | undefined`. A `null` value is a type violation but not rejected at runtime.
|
|
93
|
-
|
|
94
|
-
**Cross-language risk:** The Rust SDK uses `Option<String>` for `recipient`, which serializes `None` as absent (the field is skipped). If a TS caller writes `recipient: null` and the Rust verifier receives it, the canonical forms diverge → signature mismatch.
|
|
95
|
-
|
|
96
|
-
**Status:** Accepted risk. The correct mitigation is to normalise `null` → `undefined` in the wire decoder. This is tracked as a future improvement. In practice, `null` recipients do not appear in protocol-generated envelopes (`createEnvelope` leaves `recipient` undefined when not supplied).
|
|
97
|
-
|
|
98
|
-
---
|
|
99
|
-
|
|
100
|
-
## Finding 5 — Revocation Key Space Separator (Low, Accepted Risk)
|
|
101
|
-
|
|
102
|
-
**File:** `src/revocation.ts` — `InMemoryRevocationStore.makeKey` and `createRedisRevocationStore`
|
|
103
|
-
|
|
104
|
-
The revocation key format `"${sender} ${keyId}"` uses a space as separator. If a sender ID contains a space (e.g., `"agent one"`) and a keyId starts with something that continues the pattern, a collision is theoretically possible. However:
|
|
105
|
-
|
|
106
|
-
1. Key IDs in practice are short tokens like `"k1"`, `"prod-key-2026"` — not containing spaces
|
|
107
|
-
2. Agent IDs with spaces are unusual enough to warrant operator documentation
|
|
108
|
-
3. The collision would cause a revocation miss (treating a non-revoked key as revoked, or vice versa) — not an auth bypass
|
|
109
|
-
|
|
110
|
-
**Status:** Accepted risk. Documented in this review. Consider changing to `${encodeURIComponent(sender)}:${encodeURIComponent(keyId)}` in a future patch.
|
|
111
|
-
|
|
112
|
-
---
|
|
113
|
-
|
|
114
|
-
## Positive Findings
|
|
115
|
-
|
|
116
|
-
### Constant-time HMAC verification
|
|
117
|
-
|
|
118
|
-
`hmacVerify` delegates to `crypto.subtle.verify` (WebCrypto), which is specified to run in constant time. There is no string `===` comparison of signature bytes anywhere on the verify hot path.
|
|
119
|
-
|
|
120
|
-
### Algorithm confusion rejected
|
|
121
|
-
|
|
122
|
-
`verifyEnvelopeSignature` checks `signature.alg !== material.alg` before dispatching. An envelope signed with Ed25519 cannot be verified with HMAC material and vice versa — the check is at the dispatch level, before any cryptographic operation.
|
|
123
|
-
|
|
124
|
-
`verifyEnvelopeHmac` checks `envelope.signature.alg !== 'HS256'` explicitly before calling `hmacVerify`. Same for `verifyEnvelopeEd25519` / `'ED25519'`. Downgrade attacks via algorithm confusion are blocked at two independent points.
|
|
125
|
-
|
|
126
|
-
### Revocation fail-closed
|
|
127
|
-
|
|
128
|
-
`createRedisRevocationStore` defaults to `errorBehavior: 'reject'`. A Redis outage causes the store to treat the key as revoked. Cached stale-revoked entries serve during brief outages without allowing a previously-revoked key through.
|
|
129
|
-
|
|
130
|
-
### MCP wrapper — all four bindings present
|
|
131
|
-
|
|
132
|
-
Code review confirms all four claimed bindings in `src/mcpWrapper.ts`:
|
|
133
|
-
|
|
134
|
-
| Binding | Code location | Enforcement |
|
|
135
|
-
|---|---|---|
|
|
136
|
-
| Recipient | line 120: `envelope.header.recipient !== options.selfAgentId` | Returns 32600 error; handler does not run |
|
|
137
|
-
| Sender | line 176: `received.envelope.header.sender !== options.peerAgentId` | Throws; response discarded |
|
|
138
|
-
| Correlation | line 181: `body.correlationId !== decodeOptions.expectCorrelationId` | Throws; response discarded |
|
|
139
|
-
| Replay | `InMemoryReplayCache` injected by default in `wrapMcpServer` | Replay → `consume()` returns `{ok: false}` |
|
|
140
|
-
|
|
141
|
-
### Cross-language parity (within tested scope)
|
|
142
|
-
|
|
143
|
-
The three conformance vectors in `conformance/aip_v0_1.json` produce byte-identical signatures in TypeScript, Python, and Rust. The canonicalization format is simple string concatenation with fixed key order; there is no runtime type ambiguity within the tested input set.
|
|
144
|
-
|
|
145
|
-
**Caveat:** Three vectors are a narrow coverage set. Cross-language divergence on edge cases (very large integers, Unicode normalization, `NaN`/`Infinity` in numeric fields) is not covered by the current conformance suite.
|
|
146
|
-
|
|
147
|
-
---
|
|
148
|
-
|
|
149
|
-
## Scope Not Covered
|
|
150
|
-
|
|
151
|
-
| Area | Reason not covered |
|
|
152
|
-
|---|---|
|
|
153
|
-
| WebCrypto Ed25519 implementation | Browser/Node built-in; outside reviewable scope |
|
|
154
|
-
| Binary wire format (protocolBinary.ts) | Not reviewed in this pass — fuzz coverage via `protocolFuzz.advanced.test.ts` exists |
|
|
155
|
-
| Framework adapters (LangChain, LlamaIndex) | Translation adapters; lower security surface |
|
|
156
|
-
| Policy enforcer | Logic review only; not cryptographic |
|
|
157
|
-
| Python pure-Ed25519 implementation | Correctness verified against conformance vector; not audited for side channels |
|
|
158
|
-
|
|
159
|
-
---
|
|
160
|
-
|
|
161
|
-
## Conclusion
|
|
162
|
-
|
|
163
|
-
The cryptographic architecture is well-chosen: standard primitives, no custom crypto, constant-time comparison, fail-closed defaults. The two bugs fixed in this review (replay key collision, empty nonce) were low-to-medium severity and have been patched. No authentication bypass, signature forgery, or replay-protection bypass paths were found.
|
|
164
|
-
|
|
165
|
-
**This review does not substitute for an independent third-party audit by a qualified cryptographer.** The parsing, canonicalization, and replay-cache logic remain unaudited by an external reviewer. Treat accordingly for high-stakes deployments.
|