@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
package/revocation.d.ts
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import type { ProtocolEnvelope, SignatureVerificationMaterial } from './protocol';
|
|
2
|
-
import type { RedisLikeClient } from './redisClient';
|
|
3
|
-
/**
|
|
4
|
-
* A shared key-revocation list consulted on the verification hot path.
|
|
5
|
-
*
|
|
6
|
-
* `RollingKeyring` enforces revocation in-process; a `RevocationStore` makes a
|
|
7
|
-
* revocation effective fleet-wide: revoke a `(sender, keyId)` on one node and
|
|
8
|
-
* every node that consults the same store rejects it.
|
|
9
|
-
*/
|
|
10
|
-
export interface RevocationStore {
|
|
11
|
-
isRevoked(sender: string, keyId: string, nowMs?: number): boolean | Promise<boolean>;
|
|
12
|
-
revoke(sender: string, keyId: string, options?: {
|
|
13
|
-
untilMs?: number;
|
|
14
|
-
}): void | Promise<void>;
|
|
15
|
-
}
|
|
16
|
-
/** Single-process revocation list (tests, local dev, single-node deployments). */
|
|
17
|
-
export declare class InMemoryRevocationStore implements RevocationStore {
|
|
18
|
-
/** keyId map value: revoked-until timestamp, or `Infinity` for permanent. */
|
|
19
|
-
private readonly revoked;
|
|
20
|
-
private readonly now;
|
|
21
|
-
constructor(options?: {
|
|
22
|
-
now?: () => number;
|
|
23
|
-
});
|
|
24
|
-
private makeKey;
|
|
25
|
-
isRevoked(sender: string, keyId: string, nowMs?: number): boolean;
|
|
26
|
-
revoke(sender: string, keyId: string, options?: {
|
|
27
|
-
untilMs?: number;
|
|
28
|
-
}): void;
|
|
29
|
-
}
|
|
30
|
-
/** Behavior when the Redis client throws while checking revocation. */
|
|
31
|
-
export type RevocationErrorBehavior = 'reject' | 'allow';
|
|
32
|
-
export interface RedisRevocationStoreOptions {
|
|
33
|
-
/** Key namespace in Redis. Default `aip:revoked:`. */
|
|
34
|
-
keyPrefix?: string;
|
|
35
|
-
/**
|
|
36
|
-
* Behavior when the Redis client throws.
|
|
37
|
-
* - `reject` (default): fail closed — treat the key as revoked. A revoked key
|
|
38
|
-
* is a compromised key; never accept on uncertainty.
|
|
39
|
-
* - `allow`: treat the key as not revoked (favor availability).
|
|
40
|
-
*/
|
|
41
|
-
errorBehavior?: RevocationErrorBehavior;
|
|
42
|
-
/** Local cache freshness window in ms for `isRevoked` reads. Default 5000. */
|
|
43
|
-
cacheTtlMs?: number;
|
|
44
|
-
/** Observability hook fired whenever a Redis error forces degraded handling. */
|
|
45
|
-
onDegraded?: (error: unknown, context: {
|
|
46
|
-
sender: string;
|
|
47
|
-
keyId: string;
|
|
48
|
-
}) => void;
|
|
49
|
-
/** Clock override (testing). */
|
|
50
|
-
now?: () => number;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Creates a Redis-backed {@link RevocationStore}.
|
|
54
|
-
*
|
|
55
|
-
* Reads are served from a short-lived local cache so the verification hot path
|
|
56
|
-
* does not hit Redis on every message; known revocations therefore keep
|
|
57
|
-
* enforcing even through a brief Redis outage.
|
|
58
|
-
*/
|
|
59
|
-
export declare function createRedisRevocationStore(client: Pick<RedisLikeClient, 'set' | 'get' | 'del'>, options?: RedisRevocationStoreOptions): RevocationStore;
|
|
60
|
-
type SignatureResolver = (signature: NonNullable<ProtocolEnvelope['signature']>, sender: string) => SignatureVerificationMaterial | undefined | Promise<SignatureVerificationMaterial | undefined>;
|
|
61
|
-
/**
|
|
62
|
-
* Wraps a signature resolver so that a revoked `(sender, keyId)` resolves to no
|
|
63
|
-
* material — which makes signature verification fail and the envelope is rejected.
|
|
64
|
-
*
|
|
65
|
-
* Compose over `createKeyringSignatureResolver` (or any resolver) and pass the
|
|
66
|
-
* result as the transport `signatureResolver`.
|
|
67
|
-
*/
|
|
68
|
-
export declare function withRevocationCheck(resolver: SignatureResolver, store: RevocationStore, options?: {
|
|
69
|
-
nowMsProvider?: () => number;
|
|
70
|
-
}): SignatureResolver;
|
|
71
|
-
export {};
|
package/runtimePolicy.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
export interface RuntimePolicy {
|
|
2
|
-
version: string;
|
|
3
|
-
name: string;
|
|
4
|
-
status: string;
|
|
5
|
-
owner?: string;
|
|
6
|
-
updated_at?: string;
|
|
7
|
-
hard_invariants?: Record<string, unknown>;
|
|
8
|
-
slo_defaults?: Record<string, unknown>;
|
|
9
|
-
mode_selection?: Record<string, unknown>;
|
|
10
|
-
guardrails?: Record<string, unknown>;
|
|
11
|
-
tuning?: Record<string, unknown>;
|
|
12
|
-
adaptive_flow?: Record<string, unknown>;
|
|
13
|
-
benchmark_policy?: Record<string, unknown>;
|
|
14
|
-
runtime_decision_tree?: unknown[];
|
|
15
|
-
operator_handoff_required_fields?: string[];
|
|
16
|
-
[key: string]: unknown;
|
|
17
|
-
}
|
|
18
|
-
export interface LoadRuntimePolicyOptions {
|
|
19
|
-
path?: string;
|
|
20
|
-
readTextFile?: (filePath: string) => Promise<string>;
|
|
21
|
-
}
|
|
22
|
-
export declare function validateRuntimePolicy(value: unknown): RuntimePolicy;
|
|
23
|
-
export declare function parseRuntimePolicyJson(jsonText: string): RuntimePolicy;
|
|
24
|
-
export declare function loadRuntimePolicy(options?: LoadRuntimePolicyOptions): Promise<RuntimePolicy>;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type BootstrapRuntimePolicyEnforcerOptions, type PolicyEnforcer } from './policyEnforcer';
|
|
2
|
-
import type { RuntimePolicy } from './runtimePolicy';
|
|
3
|
-
export interface RuntimePolicySnapshot {
|
|
4
|
-
policy: RuntimePolicy;
|
|
5
|
-
enforcer: PolicyEnforcer;
|
|
6
|
-
loadedAtMs: number;
|
|
7
|
-
}
|
|
8
|
-
export declare class RuntimePolicyManager {
|
|
9
|
-
private snapshot;
|
|
10
|
-
private readonly options;
|
|
11
|
-
constructor(options?: BootstrapRuntimePolicyEnforcerOptions);
|
|
12
|
-
loadInitial(): Promise<RuntimePolicySnapshot>;
|
|
13
|
-
current(): RuntimePolicySnapshot;
|
|
14
|
-
refresh(): Promise<RuntimePolicySnapshot>;
|
|
15
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import type { RuntimeMode } from './policyEnforcer';
|
|
2
|
-
export type RuntimeEnvironment = 'dev' | 'staging' | 'prod';
|
|
3
|
-
export interface RuntimeTuningPreset {
|
|
4
|
-
environment: RuntimeEnvironment;
|
|
5
|
-
mode: RuntimeMode;
|
|
6
|
-
poolSize: number;
|
|
7
|
-
batchSize: number;
|
|
8
|
-
inflightCap: number;
|
|
9
|
-
retryMaxAttempts: number;
|
|
10
|
-
}
|
|
11
|
-
export declare function getRuntimeTuningPreset(environment: RuntimeEnvironment): RuntimeTuningPreset;
|