@agent-blueprint-protocol/verifier 0.8.4 → 1.0.0-rc.2

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.
Files changed (107) hide show
  1. package/CHANGELOG.md +139 -0
  2. package/LICENSE +1 -1
  3. package/NOTICE +2 -2
  4. package/README.md +143 -255
  5. package/dist/corpus/cases/blueprint-decode.json +1 -1
  6. package/dist/corpus/cases/bounds-new.json +1 -1
  7. package/dist/corpus/cases/bounds_algebra-intersect.json +1 -1
  8. package/dist/corpus/cases/canonicalization-encode.json +1 -1
  9. package/dist/corpus/cases/deployment-decode.json +1 -1
  10. package/dist/corpus/cases/extension-resolve.json +1 -1
  11. package/dist/corpus/cases/federation-decode.json +1 -1
  12. package/dist/corpus/cases/federation-verify_commitment.json +1 -1
  13. package/dist/corpus/cases/json-decode.json +1 -1
  14. package/dist/corpus/cases/negotiation-negotiate.json +1 -1
  15. package/dist/corpus/cases/predicate.json +1 -0
  16. package/dist/corpus/cases/reconcile.json +1 -0
  17. package/dist/corpus/cases/schema-validate_instance.json +1 -1
  18. package/dist/corpus/cases/signature-verify.json +1 -1
  19. package/dist/corpus/index.json +1 -1
  20. package/dist/release-history.json +1 -0
  21. package/dist/release-metadata.json +1 -1
  22. package/dist/spec/FOUNDATION-TRANSITION.md +67 -0
  23. package/dist/spec/IPR.md +27 -0
  24. package/dist/spec/LICENSE +190 -0
  25. package/dist/spec/NOTICE +4 -0
  26. package/dist/spec/README.md +47 -0
  27. package/dist/spec/conformance/base64url-decode.schema.json +176 -0
  28. package/dist/spec/conformance/blueprint-decode.schema.json +280 -0
  29. package/dist/spec/conformance/bounds-new.schema.json +302 -0
  30. package/dist/spec/conformance/bounds_algebra-intersect.schema.json +457 -0
  31. package/dist/spec/conformance/canonicalization-encode.schema.json +280 -0
  32. package/dist/spec/conformance/case-file.schema.json +122 -0
  33. package/dist/spec/conformance/certified-results.json +1 -0
  34. package/dist/spec/conformance/claim.schema.json +52 -0
  35. package/dist/spec/conformance/compatibility-verify.schema.json +262 -0
  36. package/dist/spec/conformance/deployment-decode.schema.json +322 -0
  37. package/dist/spec/conformance/digest-tagged.schema.json +200 -0
  38. package/dist/spec/conformance/evidence.schema.json +249 -0
  39. package/dist/spec/conformance/execution.md +80 -0
  40. package/dist/spec/conformance/extension-resolve.schema.json +264 -0
  41. package/dist/spec/conformance/federation-decode.schema.json +318 -0
  42. package/dist/spec/conformance/federation-verify_commitment.schema.json +342 -0
  43. package/dist/spec/conformance/index.schema.json +102 -0
  44. package/dist/spec/conformance/json-decode.schema.json +287 -0
  45. package/dist/spec/conformance/negotiation-negotiate.schema.json +264 -0
  46. package/dist/spec/conformance/portability-scan.schema.json +188 -0
  47. package/dist/spec/conformance/predicate.schema.json +201 -0
  48. package/dist/spec/conformance/reconcile.schema.json +287 -0
  49. package/dist/spec/conformance/runner.md +185 -0
  50. package/dist/spec/conformance/schema-validate_instance.schema.json +206 -0
  51. package/dist/spec/conformance/signature-verify.schema.json +224 -0
  52. package/dist/spec/conformance/support.schema.json +72 -0
  53. package/dist/spec/errata.md +13 -0
  54. package/dist/spec/grammar/blueprint.cddl +92 -0
  55. package/dist/spec/grammar/deployment.cddl +125 -0
  56. package/dist/spec/grammar/derived/blueprint.schema.json +340 -0
  57. package/dist/spec/grammar/derived/deployment.schema.json +496 -0
  58. package/dist/spec/grammar/derived/taskenvelope.schema.json +244 -0
  59. package/dist/spec/grammar/taskenvelope.cddl +77 -0
  60. package/dist/spec/protocol.md +1237 -0
  61. package/dist/spec/registry/OPERATIONS.md +78 -0
  62. package/dist/spec/registry/registry.json +23 -0
  63. package/dist/verifier/b64url.js +1 -1
  64. package/dist/verifier/blueprint.d.ts +2 -15
  65. package/dist/verifier/blueprint.js +21 -107
  66. package/dist/verifier/bounds_algebra.d.ts +9 -0
  67. package/dist/verifier/bounds_algebra.js +6 -6
  68. package/dist/verifier/cli.js +14 -31
  69. package/dist/verifier/corpus.d.ts +1 -1
  70. package/dist/verifier/corpus.js +5 -1
  71. package/dist/verifier/decode.js +15 -3
  72. package/dist/verifier/deployment.d.ts +8 -0
  73. package/dist/verifier/deployment.js +17 -2
  74. package/dist/verifier/digest.js +1 -1
  75. package/dist/verifier/errors.d.ts +2 -0
  76. package/dist/verifier/errors.js +1 -0
  77. package/dist/verifier/execution.d.ts +13 -0
  78. package/dist/verifier/execution.js +82 -0
  79. package/dist/verifier/facade.d.ts +311 -0
  80. package/dist/verifier/facade.js +78 -0
  81. package/dist/verifier/federation.d.ts +2 -2
  82. package/dist/verifier/federation.js +10 -7
  83. package/dist/verifier/harness.d.ts +16 -0
  84. package/dist/verifier/harness.js +201 -0
  85. package/dist/verifier/index.d.ts +3 -0
  86. package/dist/verifier/index.js +2 -0
  87. package/dist/verifier/mapping.d.ts +139 -0
  88. package/dist/verifier/mapping.js +1 -0
  89. package/dist/verifier/negotiation.d.ts +2 -1
  90. package/dist/verifier/negotiation.js +6 -3
  91. package/dist/verifier/plain.d.ts +4 -0
  92. package/dist/verifier/plain.js +38 -0
  93. package/dist/verifier/predicate.d.ts +7 -0
  94. package/dist/verifier/predicate.js +60 -1
  95. package/dist/verifier/reconcile.d.ts +37 -0
  96. package/dist/verifier/reconcile.js +115 -0
  97. package/dist/verifier/registry.js +9 -51
  98. package/dist/verifier/registry_engine.d.ts +3 -0
  99. package/dist/verifier/registry_engine.js +8 -8
  100. package/dist/verifier/results.d.ts +3 -0
  101. package/dist/verifier/results.js +13 -0
  102. package/dist/verifier/runner.d.ts +2 -0
  103. package/dist/verifier/runner.js +115 -16
  104. package/dist/verifier/signature.d.ts +17 -6
  105. package/dist/verifier/signature.js +41 -25
  106. package/package.json +17 -12
  107. package/dist/corpus/schemas/estate-contract.schema.json +0 -1
@@ -1,6 +1,6 @@
1
1
  // Domain-separated SHA-256 digests — the mirror of AgentBlueprintProtocol.Digest:
2
2
  // preimage `separator || 0x00 || jcs_bytes` under the registered separator
3
- // (base §8.2), tagged wire form "sha-256:<43-char unpadded base64url>".
3
+ // (protocol §5), tagged wire form "sha-256:<43-char unpadded base64url>".
4
4
  import { createHash } from "node:crypto";
5
5
  import * as b64 from "./b64url.js";
6
6
  export const SEPARATORS = {
@@ -0,0 +1,2 @@
1
+ /** Closed denial vocabulary, including the decoder ceiling family. */
2
+ export type ErrorCode = "attestation_malformed" | "audience_mismatch" | "base64url_invalid" | "base64url_padded" | "binding_attestation_stale" | "binding_descriptor_mismatch" | "binding_incomplete" | "bound_source_missing" | "bound_unit_mismatch" | "bound_unknown" | "bound_value_invalid" | "ceiling:bytes" | "ceiling:depth" | "ceiling:items" | "ceiling:key" | "ceiling:members" | "ceiling:nodes" | "ceiling:number_lexeme" | "ceiling:string" | "compatibility_duplicate_entry" | "compatibility_entry_missing" | "compatibility_identity_inexact" | "corpus_applicability_incomplete" | "corpus_case_id_duplicate" | "corpus_case_invalid" | "corpus_count_mismatch" | "corpus_empty" | "corpus_file_set_mismatch" | "corpus_hash_mismatch" | "corpus_index_invalid" | "deployment_digest_mismatch" | "digest_algorithm_unsupported" | "digest_encoding_invalid" | "digest_mismatch" | "duplicate_member" | "extension_criticality_conflict" | "extension_duplicate" | "extension_namespace_invalid" | "extension_payload_forbidden" | "extension_retired" | "extension_schema_digest_mismatch" | "extension_schema_unavailable" | "extension_unknown_critical" | "federation_mapping_conflict" | "federation_state_unmappable" | "federation_terminal_conflict" | "forbidden_portable_value" | "integer_magnitude" | "invalid_cardinality" | "invalid_constraint" | "invalid_encoding" | "invalid_number" | "invalid_syntax" | "invalid_type" | "lifecycle_state_invalid" | "missing_ceiling" | "missing_required_field" | "no_authoritative_recovery" | "non_canonical_bytes" | "nonportable_content" | "number_not_double_expressible" | "predicate_nodes_exceeded" | "predicate_op_unknown" | "predicate_path_unresolved" | "protected_bound_clamp_denied" | "protocol_revision_unsupported" | "required_core_field_not_digest_covered" | "required_core_field_unsupported" | "schema_complexity_exceeded" | "schema_dialect_unknown" | "schema_invalid_shape" | "schema_keyword_not_allowed" | "schema_keyword_value_invalid" | "schema_ref_cycle" | "schema_ref_unresolvable" | "signature_algorithm_unsupported" | "signature_key_unsupported" | "signature_malformed" | "signature_not_verified" | "trailing_bytes" | "unknown_bound" | "unknown_member";
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { Readable } from 'node:stream';
2
+ import { type LoadedCorpus } from './corpus.ts';
3
+ export declare const LINE_LIMIT = 5000000;
4
+ export declare class ExecutionFailure extends Error {
5
+ outcome: string;
6
+ constructor(outcome: string);
7
+ }
8
+ export declare function lines(stream: Readable): {
9
+ next: (timeout: number) => Promise<unknown>;
10
+ end: () => void;
11
+ };
12
+ export declare function handshake(corpus: LoadedCorpus): Record<string, unknown>;
13
+ export declare function serve(corpus: LoadedCorpus): Promise<number>;
@@ -0,0 +1,82 @@
1
+ import { decode } from './decode.js';
2
+ import { plain } from './plain.js';
3
+ import { canonical } from './results.js';
4
+ import { memberString } from './corpus.js';
5
+ import { project } from './runner.js';
6
+ export const LINE_LIMIT = 5_000_000;
7
+ export class ExecutionFailure extends Error {
8
+ outcome;
9
+ constructor(outcome) { super(outcome); this.outcome = outcome; }
10
+ }
11
+ export function lines(stream) {
12
+ const queue = [];
13
+ let pending = null, buffer = Buffer.alloc(0), ended = false;
14
+ const push = (x) => { if (pending) {
15
+ const resolve = pending;
16
+ pending = null;
17
+ resolve(x);
18
+ }
19
+ else
20
+ queue.push(x); };
21
+ stream.on('data', (chunk) => {
22
+ buffer = Buffer.concat([buffer, chunk]);
23
+ for (;;) {
24
+ const index = buffer.indexOf(10);
25
+ if (index < 0)
26
+ break;
27
+ const row = buffer.subarray(0, index);
28
+ buffer = buffer.subarray(index + 1);
29
+ if (row.length + 1 > LINE_LIMIT) {
30
+ push(new ExecutionFailure('oversized_line'));
31
+ stream.pause();
32
+ return;
33
+ }
34
+ const value = decode(row);
35
+ push(value.ok ? plain(value.v) : new ExecutionFailure('malformed_line'));
36
+ }
37
+ if (buffer.length >= LINE_LIMIT) {
38
+ push(new ExecutionFailure('oversized_line'));
39
+ stream.pause();
40
+ }
41
+ });
42
+ const end = () => { if (ended)
43
+ return; ended = true; if (buffer.length)
44
+ push(new ExecutionFailure('malformed_line')); push(null); };
45
+ stream.on('end', end);
46
+ stream.on('error', () => push(new ExecutionFailure('early_exit')));
47
+ return { end, next: async (timeout) => {
48
+ let timer;
49
+ const item = queue.length ? queue.shift() : ended ? null : await new Promise(resolve => { pending = resolve; timer = setTimeout(() => { pending = null; resolve(new ExecutionFailure('response_timeout')); }, timeout); });
50
+ if (timer)
51
+ clearTimeout(timer);
52
+ if (item instanceof Error)
53
+ throw item;
54
+ return item;
55
+ } };
56
+ }
57
+ export function handshake(corpus) {
58
+ return { protocol: 'agent-blueprint-protocol-conformance-execution', version: 1, corpus_digest: corpus.identity, registry_digest: memberString(corpus.index, 'registry_digest') };
59
+ }
60
+ export async function serve(corpus) {
61
+ const reader = lines(process.stdin), hello = handshake(corpus);
62
+ try {
63
+ if (canonical(await reader.next(30_000)) !== canonical(hello))
64
+ return 2;
65
+ process.stdout.write(canonical(hello) + '\n');
66
+ for (;;) {
67
+ const request = await reader.next(30_000);
68
+ if (request === null)
69
+ return 0;
70
+ if (!request || Object.keys(request).sort().join(',') !== 'id,input,surface' || typeof request.id !== 'string' || typeof request.surface !== 'string' || !request.input || typeof request.input !== 'object' || Array.isArray(request.input))
71
+ return 2;
72
+ const input = decode(canonical(request.input));
73
+ if (!input.ok)
74
+ return 2;
75
+ const row = { id: request.id, surface: request.surface, input: input.v, expected: { t: 'obj', v: [] } };
76
+ process.stdout.write(canonical({ id: request.id, result: project(row, corpus.data, corpus.raws) }) + '\n');
77
+ }
78
+ }
79
+ catch {
80
+ return 2;
81
+ }
82
+ }
@@ -0,0 +1,311 @@
1
+ import type { ErrorCode } from './errors.ts';
2
+ /** Known output identifiers; future values remain valid strings throughout 1.x. */
3
+ export declare const KNOWN_NOTICES: Readonly<{
4
+ readonly clamp_applied: 'clamp_applied';
5
+ readonly extension_deprecated: 'extension_deprecated';
6
+ readonly extension_retired: 'extension_retired';
7
+ readonly extension_unknown_optional_retained: 'extension_unknown_optional_retained';
8
+ }>;
9
+ export type KnownNotice = typeof KNOWN_NOTICES[keyof typeof KNOWN_NOTICES];
10
+ export type Notice = KnownNotice | (string & {});
11
+ /** Known evidence surfaces, never an exhaustive proof checklist. */
12
+ export declare const KNOWN_EVIDENCE_SURFACES: Readonly<{
13
+ readonly canonical: 'canonical';
14
+ readonly digest: 'digest';
15
+ readonly negotiation: 'negotiation';
16
+ readonly structure: 'structure';
17
+ readonly portability: 'portability';
18
+ readonly signatures: 'signatures';
19
+ readonly extensions: 'extensions';
20
+ readonly bind: 'bind';
21
+ readonly bounds: 'bounds';
22
+ readonly compatibility: 'compatibility';
23
+ readonly tenancy: 'tenancy';
24
+ readonly live_policy: 'live_policy';
25
+ readonly authority: 'authority';
26
+ readonly effect_ownership: 'effect_ownership';
27
+ readonly execution: 'execution';
28
+ readonly billing: 'billing';
29
+ readonly evaluation_truth: 'evaluation_truth';
30
+ readonly signature_created_at: 'signature_created_at';
31
+ readonly lifecycle_state: 'lifecycle_state';
32
+ readonly binding_descriptors: 'binding_descriptors';
33
+ readonly binding_staleness: 'binding_staleness';
34
+ }>;
35
+ export type KnownEvidenceSurface = typeof KNOWN_EVIDENCE_SURFACES[keyof typeof KNOWN_EVIDENCE_SURFACES];
36
+ export type EvidenceSurface = KnownEvidenceSurface | (string & {});
37
+ /** Known binding check kinds; unknown kinds establish no familiar check. */
38
+ export declare const KNOWN_EVIDENCE_CHECK_KINDS: Readonly<{
39
+ readonly release_binding: 'release_binding';
40
+ readonly binding_completeness: 'binding_completeness';
41
+ readonly effect_recovery: 'effect_recovery';
42
+ readonly binding_descriptors: 'binding_descriptors';
43
+ readonly binding_staleness: 'binding_staleness';
44
+ }>;
45
+ export type KnownEvidenceCheckKind = typeof KNOWN_EVIDENCE_CHECK_KINDS[keyof typeof KNOWN_EVIDENCE_CHECK_KINDS];
46
+ export type EvidenceCheckKind = KnownEvidenceCheckKind | (string & {});
47
+ /** Known returned signature identifiers; verification inputs retain their strict types. */
48
+ export declare const KNOWN_SIGNATURE_ALGORITHMS: Readonly<{
49
+ readonly ed25519: 'Ed25519';
50
+ }>;
51
+ export type KnownSignatureAlgorithm = typeof KNOWN_SIGNATURE_ALGORITHMS[keyof typeof KNOWN_SIGNATURE_ALGORITHMS];
52
+ export type SignatureAlgorithm = KnownSignatureAlgorithm | (string & {});
53
+ export declare const KNOWN_SIGNATURE_PURPOSES: Readonly<{
54
+ readonly blueprint: 'blueprint';
55
+ readonly deployment: 'deployment';
56
+ readonly federation_envelope: 'federation-envelope';
57
+ }>;
58
+ export type KnownSignaturePurpose = typeof KNOWN_SIGNATURE_PURPOSES[keyof typeof KNOWN_SIGNATURE_PURPOSES];
59
+ export type SignaturePurpose = KnownSignaturePurpose | (string & {});
60
+ /** A JSON value without runtime-specific types. */
61
+ export type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
62
+ readonly [key: string]: JsonValue;
63
+ };
64
+ /** A closed denial and its value-free member path. */
65
+ export interface ProtocolError {
66
+ readonly code: ErrorCode;
67
+ readonly subject: readonly (string | number)[];
68
+ }
69
+ /** Every public operation returns a success value or a typed denial. */
70
+ export type Result<T> = {
71
+ readonly ok: true;
72
+ readonly value: T;
73
+ } | {
74
+ readonly ok: false;
75
+ readonly error: ProtocolError;
76
+ };
77
+ /** Tighten-only decoder ceilings; omission uses the protocol maximum. */
78
+ export interface Bounds {
79
+ readonly bytes?: number;
80
+ readonly depth?: number;
81
+ readonly members?: number;
82
+ readonly items?: number;
83
+ readonly nodes?: number;
84
+ readonly string?: number;
85
+ readonly key?: number;
86
+ readonly number_lexeme?: number;
87
+ }
88
+ /** Names of the eight tighten-only decoder ceilings. */
89
+ export type CeilingKey = keyof Bounds;
90
+ /** Decode options. */
91
+ export interface DecodeOptions {
92
+ readonly bounds?: Bounds;
93
+ }
94
+ /** A read-only artifact view; canonical bytes and digest identify its value. */
95
+ export interface Artifact {
96
+ readonly kind: 'blueprint' | 'deployment' | 'federation';
97
+ readonly value: {
98
+ readonly [key: string]: JsonValue;
99
+ };
100
+ readonly canonicalBytes: Uint8Array;
101
+ readonly contentDigest: string | null;
102
+ }
103
+ /** A decoded Blueprint Core. */
104
+ export type Blueprint = Artifact & {
105
+ readonly kind: 'blueprint';
106
+ readonly contentDigest: string;
107
+ };
108
+ /** A decoded Deployment Manifest. */
109
+ export type Deployment = Artifact & {
110
+ readonly kind: 'deployment';
111
+ readonly contentDigest: string;
112
+ };
113
+ /** A decoded federation TaskEnvelope. */
114
+ export type FederationEnvelope = Artifact & {
115
+ readonly kind: 'federation';
116
+ };
117
+ /** Raw Ed25519 public key supplied by the caller. */
118
+ export interface PublicKey {
119
+ readonly keyId: string;
120
+ readonly algorithm: 'ed25519';
121
+ readonly key: Uint8Array;
122
+ }
123
+ /** Negotiation support with host registrations and held schema documents. Compiled entries preserve their criticality and schema pins. */
124
+ export interface Support {
125
+ readonly revisions: ReadonlySet<number>;
126
+ readonly coreFields: ReadonlySet<string>;
127
+ readonly registry: Readonly<Record<string, {
128
+ readonly owner: string;
129
+ readonly criticality: 'critical' | 'optional';
130
+ readonly state: 'reserved' | 'active' | 'deprecated' | 'retired';
131
+ readonly schemaDigest: string | null;
132
+ readonly a2aUri: string | null;
133
+ readonly promotedAtRevision: number | null;
134
+ }>>;
135
+ readonly schemas: Readonly<Record<string, JsonValue>>;
136
+ }
137
+ /** An ordinal classification and its retained regulatory markers. */
138
+ export interface Classification {
139
+ readonly ordinal: 'public' | 'internal' | 'confidential' | 'restricted';
140
+ readonly markers: readonly ('pci' | 'phi')[];
141
+ }
142
+ /** An integer count of millionths of one unit of the named ISO 4217 currency. */
143
+ export interface Cost {
144
+ readonly amount: number;
145
+ readonly currency: string;
146
+ }
147
+ /** The closed operational and protected bound vocabulary. */
148
+ export interface BoundSet {
149
+ readonly max_attempts?: number;
150
+ readonly max_concurrency?: number;
151
+ readonly max_cost?: Cost;
152
+ readonly max_depth?: number;
153
+ readonly max_descendants?: number;
154
+ readonly max_elapsed_ms?: number;
155
+ readonly max_fan_out?: number;
156
+ readonly max_tokens?: number;
157
+ readonly classification_ceiling?: Classification;
158
+ readonly disclosure_ceiling?: 'none' | 'summary' | 'detail' | 'full';
159
+ readonly effect_impact_ceiling?: 'ordinary' | 'money' | 'authority' | 'secret';
160
+ readonly authority_trait?: 'none' | 'local_policy' | 'external_authority_required';
161
+ readonly approval_trait?: 'none' | 'human_required' | 'separated_human_required';
162
+ }
163
+ /** Three bound sources and the protected narrowing posture. */
164
+ export interface Sources {
165
+ readonly blueprint: BoundSet;
166
+ readonly deployment: BoundSet;
167
+ readonly host: BoundSet;
168
+ readonly protectedClamp?: 'deny' | 'acknowledge';
169
+ }
170
+ /** Descriptor and freshness observations; null leaves a check unverified. */
171
+ export interface Observations {
172
+ readonly now: string | null;
173
+ readonly maxAttestationAgeMs: number | null;
174
+ readonly observed: Readonly<Record<string, string>>;
175
+ }
176
+ /** Exact observed build identities. */
177
+ export interface Observed {
178
+ readonly identities: readonly {
179
+ readonly kind: string;
180
+ readonly name: string;
181
+ readonly version: string;
182
+ readonly digest: string;
183
+ }[];
184
+ }
185
+ /** The inputs for the eight-stage non-authorizing import pass. */
186
+ export interface Inputs {
187
+ readonly hostBounds: BoundSet;
188
+ readonly support: Support;
189
+ readonly keys: readonly PublicKey[];
190
+ readonly protectedClamp: 'deny' | 'acknowledge';
191
+ readonly observations: Observations;
192
+ }
193
+ /** Receiving context for existing federation receipt verification. */
194
+ /** Verified signed attributes, including the digest and purpose. */
195
+ export interface SignedAttributes {
196
+ readonly algorithm: SignatureAlgorithm;
197
+ readonly contentDigest: string;
198
+ readonly createdAt: string;
199
+ readonly keyId: string;
200
+ readonly purpose: SignaturePurpose;
201
+ }
202
+ /** Negotiated extension facts. */
203
+ export interface Negotiated {
204
+ readonly protocolRevision: number;
205
+ readonly criticalExtensions: readonly string[];
206
+ readonly quarantinedExtensions: readonly string[];
207
+ readonly optionalRetained: readonly string[];
208
+ readonly notices: readonly Notice[];
209
+ }
210
+ /** A clamp records the requested and effective values and narrowing source. */
211
+ export interface Clamp {
212
+ readonly field: keyof BoundSet;
213
+ readonly class: 'operational' | 'protected';
214
+ readonly unit: 'count' | 'millisecond' | 'token' | 'money' | 'ordinal';
215
+ readonly requested: JsonValue;
216
+ readonly effective: JsonValue;
217
+ readonly source: 'deployment' | 'host';
218
+ readonly acknowledged: boolean;
219
+ }
220
+ /** Pointwise effective bounds and their clamp evidence. */
221
+ export interface Intersection {
222
+ readonly effective: BoundSet;
223
+ readonly clamps: readonly Clamp[];
224
+ }
225
+ /** One performed or explicitly unverified check. */
226
+ export interface Check {
227
+ readonly surface: EvidenceSurface;
228
+ readonly subject: readonly (string | number)[];
229
+ readonly verified: boolean;
230
+ readonly detail: JsonValue;
231
+ }
232
+ /** Typed import evidence; its unverified surfaces never form an empty set. */
233
+ export interface Evidence {
234
+ readonly protocol_revision: number | null;
235
+ readonly blueprint_digest: string | null;
236
+ readonly deployment_digest: string | null;
237
+ readonly checks: readonly Check[];
238
+ readonly effective_bounds: BoundSet | null;
239
+ readonly clamps: readonly Clamp[];
240
+ readonly optional_extensions_retained: readonly string[];
241
+ readonly not_verified: readonly EvidenceSurface[];
242
+ }
243
+ /** One transport mapping row, returned as inert data. */
244
+ export interface MappingRow {
245
+ readonly index: number;
246
+ readonly logical_field: string;
247
+ readonly a2a_location: string;
248
+ readonly mcp_location: string;
249
+ readonly verdict: 'native' | 'partial' | 'extension';
250
+ }
251
+ /** An integrity-checked, in-memory corpus handle. */
252
+ export interface Corpus {
253
+ readonly identity: string;
254
+ readonly totalCases: number;
255
+ }
256
+ /** A per-case verdict agreement. */
257
+ export interface CaseResult {
258
+ readonly caseId: string;
259
+ readonly agree: boolean;
260
+ }
261
+ /** An aggregate conformance summary. */
262
+ export interface Report {
263
+ readonly format: 'agent-blueprint-protocol-conformance-report';
264
+ readonly corpus_digest: string;
265
+ readonly total: number;
266
+ readonly agreed: number;
267
+ readonly disagreed: number;
268
+ readonly agreement: boolean;
269
+ readonly exit_status: 0 | 1;
270
+ }
271
+ /** An identity-free, per-case results document. */
272
+ export interface ResultsDocument {
273
+ readonly format: 'agent-blueprint-protocol-conformance-results';
274
+ readonly corpus_digest: string;
275
+ readonly registry_digest: string;
276
+ readonly results: readonly {
277
+ readonly id: string;
278
+ readonly surface: string;
279
+ readonly result: Readonly<Record<string, JsonValue>>;
280
+ }[];
281
+ }
282
+ /** Decode canonical Blueprint bytes under optional tightened ceilings. */
283
+ export declare function decodeBlueprint(input: Uint8Array | string, options?: DecodeOptions): Result<Blueprint>;
284
+ /** Decode canonical Deployment bytes under optional tightened ceilings. */
285
+ export declare function decodeDeployment(input: Uint8Array | string, options?: DecodeOptions): Result<Deployment>;
286
+ /** Decode a canonical federation TaskEnvelope. */
287
+ export declare function decodeFederationEnvelope(input: Uint8Array | string, options?: DecodeOptions): Result<FederationEnvelope>;
288
+ /** Encode an artifact view's value as canonical UTF-8 bytes. */
289
+ export declare function canonicalBytes(value: Artifact): Result<Uint8Array>;
290
+ /** Negotiate revision, required fields, and extensions. */
291
+ export declare function negotiate(value: Blueprint | Deployment, options: Support): Result<Negotiated>;
292
+ /** Intersect three total bound sources and record every narrowing. */
293
+ export declare function intersect(options: Sources): Result<Intersection>;
294
+ /** Verify exact observed build identities against a Deployment. */
295
+ export declare function verifyCompatibility(value: Deployment, observed: Observed): Result<Evidence>;
296
+ /** Run the eight-stage import pass and return non-authorizing evidence. */
297
+ export declare function reconcile(blueprint: Blueprint, deployment: Deployment, options: Inputs): Result<Evidence>;
298
+ /** Return the 23 transport mapping rows as data. */
299
+ export declare function federationMapping(): Result<readonly MappingRow[]>;
300
+ /** Verify a detached signature and return the verified attributes. */
301
+ export declare function verifySignature(entry: JsonValue, keys: readonly PublicKey[]): Result<SignedAttributes>;
302
+ /** Load and integrity-check a corpus from a path-to-bytes map. */
303
+ export declare function loadCorpus(files: ReadonlyMap<string, Uint8Array>, options?: {
304
+ readonly priorCensus?: boolean;
305
+ }): Result<Corpus>;
306
+ /** Execute every loaded corpus case. */
307
+ export declare function runCorpus(value: Corpus): Result<readonly (readonly CaseResult[])[]>;
308
+ /** Build the unchanged aggregate report from a corpus run. */
309
+ export declare function buildReport(value: Corpus, results: readonly (readonly CaseResult[])[]): Result<Report>;
310
+ /** Build canonical, identity-free per-case results from the implementation. */
311
+ export declare function buildResultsDocument(value: Corpus): Result<ResultsDocument>;
@@ -0,0 +1,78 @@
1
+ import * as bp from './blueprint.js';
2
+ import * as dep from './deployment.js';
3
+ import * as fed from './federation.js';
4
+ import * as neg from './negotiation.js';
5
+ import * as alg from './bounds_algebra.js';
6
+ import * as sig from './signature.js';
7
+ import * as compat from './compatibility.js';
8
+ import * as imports from './reconcile.js';
9
+ import * as corpus from './corpus.js';
10
+ import * as runner from './runner.js';
11
+ import * as report from './report.js';
12
+ import { resultsDocument, canonical } from './results.js';
13
+ import { tagged, plain, jsonValue } from './plain.js';
14
+ import { rows } from './mapping.js';
15
+ import { toTagged } from './digest.js';
16
+ /** Known output identifiers; future values remain valid strings throughout 1.x. */
17
+ export const KNOWN_NOTICES = Object.freeze({ clamp_applied: 'clamp_applied', extension_deprecated: 'extension_deprecated', extension_retired: 'extension_retired', extension_unknown_optional_retained: 'extension_unknown_optional_retained' });
18
+ /** Known evidence surfaces, never an exhaustive proof checklist. */
19
+ export const KNOWN_EVIDENCE_SURFACES = Object.freeze({ canonical: 'canonical', digest: 'digest', negotiation: 'negotiation', structure: 'structure', portability: 'portability', signatures: 'signatures', extensions: 'extensions', bind: 'bind', bounds: 'bounds', compatibility: 'compatibility', tenancy: 'tenancy', live_policy: 'live_policy', authority: 'authority', effect_ownership: 'effect_ownership', execution: 'execution', billing: 'billing', evaluation_truth: 'evaluation_truth', signature_created_at: 'signature_created_at', lifecycle_state: 'lifecycle_state', binding_descriptors: 'binding_descriptors', binding_staleness: 'binding_staleness' });
20
+ /** Known binding check kinds; unknown kinds establish no familiar check. */
21
+ export const KNOWN_EVIDENCE_CHECK_KINDS = Object.freeze({ release_binding: 'release_binding', binding_completeness: 'binding_completeness', effect_recovery: 'effect_recovery', binding_descriptors: 'binding_descriptors', binding_staleness: 'binding_staleness' });
22
+ /** Known returned signature identifiers; verification inputs retain their strict types. */
23
+ export const KNOWN_SIGNATURE_ALGORITHMS = Object.freeze({ ed25519: 'Ed25519' });
24
+ export const KNOWN_SIGNATURE_PURPOSES = Object.freeze({ blueprint: 'blueprint', deployment: 'deployment', federation_envelope: 'federation-envelope' });
25
+ const handles = new WeakMap();
26
+ function guarded(f) { try {
27
+ const r = f();
28
+ return r?.ok === false ? { ok: false, error: { code: r.e, subject: r.subject ?? [] } } : { ok: true, value: (r?.ok === true && Object.hasOwn(r, 'v') ? r.v : r) };
29
+ }
30
+ catch {
31
+ return { ok: false, error: { code: 'invalid_type', subject: [] } };
32
+ } }
33
+ function bytes(input) { if (typeof input === 'string')
34
+ return input; if (input instanceof Uint8Array)
35
+ return Buffer.from(input); throw new TypeError(); }
36
+ function support(s) { return { revisions: new Set(s.revisions), coreFields: new Set(s.coreFields), registry: { ...s.registry }, schemas: Object.fromEntries(Object.entries(s.schemas).map(([k, v]) => [k, tagged(v)])) }; }
37
+ function artifact(kind, result, mod) { if (!result.ok)
38
+ return result; const encoded = mod.canonicalBytes(result.v); if (!encoded.ok)
39
+ return encoded; return { ok: true, v: { kind, value: plain(result.v.value), canonicalBytes: Buffer.from(encoded.v), contentDigest: kind === 'federation' ? null : mod.contentDigest(result.v) } }; }
40
+ /** Decode canonical Blueprint bytes under optional tightened ceilings. */
41
+ export function decodeBlueprint(input, options = {}) { return guarded(() => artifact('blueprint', bp.decode(bytes(input), options.bounds), bp)); }
42
+ /** Decode canonical Deployment bytes under optional tightened ceilings. */
43
+ export function decodeDeployment(input, options = {}) { return guarded(() => artifact('deployment', dep.decode(bytes(input), options.bounds), dep)); }
44
+ /** Decode a canonical federation TaskEnvelope. */
45
+ export function decodeFederationEnvelope(input, options = {}) { return guarded(() => artifact('federation', fed.decode(bytes(input), options.bounds), fed)); }
46
+ /** Encode an artifact view's value as canonical UTF-8 bytes. */
47
+ export function canonicalBytes(value) { return guarded(() => Buffer.from(canonical(value.value))); }
48
+ /** Negotiate revision, required fields, and extensions. */
49
+ export function negotiate(value, options) { return guarded(() => neg.negotiate(tagged(value.value), support(options))); }
50
+ /** Intersect three total bound sources and record every narrowing. */
51
+ export function intersect(options) { return guarded(() => { const r = alg.intersect(options.blueprint, options.deployment, options.host, options.protectedClamp ?? 'deny'); return r.ok ? { ok: true, v: { effective: r.v.effective, clamps: r.v.clamps.map(c => ({ field: c.field, class: c.cls, unit: c.cls === 'protected' ? 'ordinal' : c.field === 'max_cost' ? 'money' : c.field === 'max_elapsed_ms' ? 'millisecond' : c.field === 'max_tokens' ? 'token' : 'count', requested: jsonValue(c.requested), effective: jsonValue(c.effective), source: c.source, acknowledged: c.acknowledged })) } } : r; }); }
52
+ /** Verify exact observed build identities against a Deployment. */
53
+ export function verifyCompatibility(value, observed) {
54
+ return guarded(() => {
55
+ const result = compat.verify({ value: tagged(value.value) }, observed);
56
+ if (!result.ok)
57
+ return result;
58
+ const entries = value.value.build_identities;
59
+ return { ok: true, v: { protocol_revision: value.value.protocol_revision, blueprint_digest: null, deployment_digest: null, effective_bounds: null, clamps: [], optional_extensions_retained: [], checks: entries.map((entry, index) => ({ surface: 'compatibility', subject: ['build_identities', index], verified: true, detail: entry.digest })), not_verified: ['tenancy', 'live_policy', 'authority', 'effect_ownership', 'execution', 'billing', 'evaluation_truth'] } };
60
+ });
61
+ }
62
+ /** Run the eight-stage import pass and return non-authorizing evidence. */
63
+ export function reconcile(blueprint, deployment, options) { return guarded(() => { if (options.observations.now !== null && dep.parseTimestamp(options.observations.now) === null)
64
+ return { ok: false, e: "invalid_type" }; return imports.reconcile({ value: tagged(blueprint.value) }, { value: tagged(deployment.value) }, { ...options, hostBounds: options.hostBounds, support: support(options.support), keys: options.keys.map(key => ({ keyId: key.keyId, key: key.algorithm === 'ed25519' ? key.key : new Uint8Array() })), observations: options.observations }); }); }
65
+ /** Return the 23 transport mapping rows as data. */
66
+ export function federationMapping() { return guarded(() => rows.map(row => ({ ...row }))); }
67
+ /** Verify a detached signature and return the verified attributes. */
68
+ export function verifySignature(entry, keys) { return guarded(() => { const r = sig.verify(tagged(entry), keys.map(key => ({ keyId: key.keyId, key: key.algorithm === 'ed25519' ? key.key : new Uint8Array() }))); return r.ok ? { ok: true, v: { ...r.v, contentDigest: toTagged(r.v.contentDigest) } } : r; }); }
69
+ /** Load and integrity-check a corpus from a path-to-bytes map. */
70
+ export function loadCorpus(files, options = {}) { return guarded(() => { const r = (options.priorCensus ? corpus.loadPriorCensus : corpus.load)(new Map([...files].map(([k, v]) => { if (!(v instanceof Uint8Array))
71
+ throw new TypeError(); return [k, Buffer.from(v)]; }))); if (!r.ok)
72
+ return r; const handle = { identity: r.v.identity, totalCases: r.v.caseIds.size }; handles.set(handle, r.v); return { ok: true, v: handle }; }); }
73
+ /** Execute every loaded corpus case. */
74
+ export function runCorpus(value) { return guarded(() => runner.run(handles.get(value))); }
75
+ /** Build the unchanged aggregate report from a corpus run. */
76
+ export function buildReport(value, results) { return guarded(() => { const r = report.toBytes(value.identity, results); return typeof r === 'string' ? JSON.parse(r) : r; }); }
77
+ /** Build canonical, identity-free per-case results from the implementation. */
78
+ export function buildResultsDocument(value) { return guarded(() => resultsDocument(handles.get(value))); }
@@ -16,8 +16,8 @@ export interface Context {
16
16
  subject?: unknown;
17
17
  audience?: unknown;
18
18
  issuerKeySets: Record<string, signature.PublicKey[]> | null;
19
- createdAfter?: string;
20
- createdBefore?: string;
19
+ createdAfter?: unknown;
20
+ createdBefore?: unknown;
21
21
  priorReceipts: PriorReceipt[];
22
22
  }
23
23
  export type CodecResult = {
@@ -399,11 +399,11 @@ export function toMcpState(spelling) {
399
399
  // ---- carriers: the placement laws, per transport ----------------------------------------
400
400
  // The A2A-side carrier key: the registry entry's a2a_uri.
401
401
  export function a2aCarrierKey() {
402
- return compiledEntry("com.example/federation").a2a_uri;
402
+ return compiledEntry("io.github.baselabs/federation").a2a_uri;
403
403
  }
404
404
  // The MCP-side carrier key: the registry namespace.
405
405
  export function mcpCarrierKey() {
406
- return "com.example/federation";
406
+ return "io.github.baselabs/federation";
407
407
  }
408
408
  export function fromA2aCarrier(carrier) {
409
409
  if (!isValue(carrier) || carrier.t !== "obj")
@@ -417,7 +417,7 @@ export function fromA2aCarrier(carrier) {
417
417
  const logical = fromA2aState(stateRaw.v);
418
418
  if (!logical.ok)
419
419
  return logical;
420
- const body = carrierBody(carrier.v, "metadata", a2aCarrierKey());
420
+ const body = carrierBody(carrier.v, "metadata", [a2aCarrierKey(), "https://example.com/extensions/federation"]);
421
421
  if (!body.ok)
422
422
  return body;
423
423
  const placed = noDoublePlacement(body.v);
@@ -438,7 +438,7 @@ export function fromMcpCarrier(carrier) {
438
438
  const logical = fromMcpState(stateRaw.v);
439
439
  if (!logical.ok)
440
440
  return logical;
441
- const body = carrierBody(carrier.v, "_meta", mcpCarrierKey());
441
+ const body = carrierBody(carrier.v, "_meta", [mcpCarrierKey(), "com.example/federation"]);
442
442
  if (!body.ok)
443
443
  return body;
444
444
  const placed = noDoublePlacement(body.v);
@@ -463,15 +463,18 @@ function carrierState(members) {
463
463
  return { ok: false, e: "invalid_type" };
464
464
  return carrierString(found.v, "state");
465
465
  }
466
- function carrierBody(members, envelopeMember, key) {
466
+ function carrierBody(members, envelopeMember, keys) {
467
467
  const found = keyfind(members, envelopeMember);
468
468
  if (found === null)
469
469
  return { ok: false, e: "missing_required_field" };
470
470
  if (found.t !== "obj")
471
471
  return { ok: false, e: "invalid_type" };
472
- const inner = keyfind(found.v, key);
473
- if (inner === null)
472
+ const entries = found.v.filter(([key]) => keys.includes(key));
473
+ if (entries.length === 0)
474
474
  return { ok: false, e: "missing_required_field" };
475
+ if (entries.length > 1)
476
+ return { ok: false, e: "federation_mapping_conflict" };
477
+ const inner = entries[0][1];
475
478
  if (inner.t !== "obj")
476
479
  return { ok: false, e: "invalid_type" };
477
480
  return { ok: true, v: inner.v };
@@ -0,0 +1,16 @@
1
+ export declare const OUTCOMES: {
2
+ readonly handshake_mismatch: 10;
3
+ readonly duplicate_id: 11;
4
+ readonly missing_response: 12;
5
+ readonly extra_response: 13;
6
+ readonly reordered_response: 14;
7
+ readonly malformed_line: 15;
8
+ readonly oversized_line: 16;
9
+ readonly response_timeout: 17;
10
+ readonly early_exit: 18;
11
+ readonly disagreement: 19;
12
+ };
13
+ export declare function documentDigest(bytes: string): string;
14
+ export declare function runHarness(args: string[], readCorpus: (path: string) => Map<string, Buffer>, metadata: {
15
+ corpus_digest: string;
16
+ }): Promise<number>;