@agent-blueprint-protocol/verifier 0.8.3 → 1.0.0-rc.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.
Files changed (123) hide show
  1. package/CHANGELOG.md +137 -0
  2. package/LICENSE +1 -1
  3. package/NOTICE +2 -2
  4. package/README.md +164 -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/kit/cli.mjs +1 -4
  21. package/dist/release-history.json +1 -0
  22. package/dist/release-metadata.json +1 -1
  23. package/dist/spec/FOUNDATION-TRANSITION.md +67 -0
  24. package/dist/spec/IPR.md +27 -0
  25. package/dist/spec/LICENSE +190 -0
  26. package/dist/spec/NOTICE +4 -0
  27. package/dist/spec/README.md +47 -0
  28. package/dist/spec/conformance/base64url-decode.schema.json +176 -0
  29. package/dist/spec/conformance/blueprint-decode.schema.json +280 -0
  30. package/dist/spec/conformance/bounds-new.schema.json +302 -0
  31. package/dist/spec/conformance/bounds_algebra-intersect.schema.json +457 -0
  32. package/dist/spec/conformance/canonicalization-encode.schema.json +280 -0
  33. package/dist/spec/conformance/case-file.schema.json +122 -0
  34. package/dist/spec/conformance/certified-results.json +1 -0
  35. package/dist/spec/conformance/claim.schema.json +52 -0
  36. package/dist/spec/conformance/compatibility-verify.schema.json +262 -0
  37. package/dist/spec/conformance/deployment-decode.schema.json +322 -0
  38. package/dist/spec/conformance/digest-tagged.schema.json +200 -0
  39. package/dist/spec/conformance/evidence.schema.json +249 -0
  40. package/dist/spec/conformance/execution.md +80 -0
  41. package/dist/spec/conformance/extension-resolve.schema.json +264 -0
  42. package/dist/spec/conformance/federation-decode.schema.json +318 -0
  43. package/dist/spec/conformance/federation-verify_commitment.schema.json +342 -0
  44. package/dist/spec/conformance/index.schema.json +102 -0
  45. package/dist/spec/conformance/json-decode.schema.json +287 -0
  46. package/dist/spec/conformance/negotiation-negotiate.schema.json +264 -0
  47. package/dist/spec/conformance/portability-scan.schema.json +188 -0
  48. package/dist/spec/conformance/predicate.schema.json +201 -0
  49. package/dist/spec/conformance/reconcile.schema.json +287 -0
  50. package/dist/spec/conformance/runner.md +182 -0
  51. package/dist/spec/conformance/schema-validate_instance.schema.json +206 -0
  52. package/dist/spec/conformance/signature-verify.schema.json +224 -0
  53. package/dist/spec/conformance/support.schema.json +72 -0
  54. package/dist/spec/errata.md +13 -0
  55. package/dist/spec/grammar/blueprint.cddl +92 -0
  56. package/dist/spec/grammar/deployment.cddl +125 -0
  57. package/dist/spec/grammar/derived/blueprint.schema.json +340 -0
  58. package/dist/spec/grammar/derived/deployment.schema.json +496 -0
  59. package/dist/spec/grammar/derived/taskenvelope.schema.json +244 -0
  60. package/dist/spec/grammar/taskenvelope.cddl +77 -0
  61. package/dist/spec/protocol.md +1238 -0
  62. package/dist/spec/registry/OPERATIONS.md +69 -0
  63. package/dist/spec/registry/registry.json +68 -0
  64. package/dist/verifier/b64url.d.ts +6 -2
  65. package/dist/verifier/b64url.js +7 -1
  66. package/dist/verifier/blueprint.d.ts +12 -16
  67. package/dist/verifier/blueprint.js +40 -112
  68. package/dist/verifier/bounds.d.ts +1 -1
  69. package/dist/verifier/bounds.js +2 -2
  70. package/dist/verifier/bounds_algebra.d.ts +9 -0
  71. package/dist/verifier/bounds_algebra.js +10 -7
  72. package/dist/verifier/canonical.d.ts +1 -1
  73. package/dist/verifier/canonical.js +41 -8
  74. package/dist/verifier/cli.js +97 -45
  75. package/dist/verifier/compatibility.js +5 -7
  76. package/dist/verifier/corpus.d.ts +1 -1
  77. package/dist/verifier/corpus.js +10 -2
  78. package/dist/verifier/decode.js +24 -6
  79. package/dist/verifier/deployment.d.ts +20 -3
  80. package/dist/verifier/deployment.js +48 -10
  81. package/dist/verifier/digest.d.ts +12 -0
  82. package/dist/verifier/digest.js +17 -3
  83. package/dist/verifier/errors.d.ts +2 -0
  84. package/dist/verifier/errors.js +1 -0
  85. package/dist/verifier/execution.d.ts +13 -0
  86. package/dist/verifier/execution.js +82 -0
  87. package/dist/verifier/extension.js +4 -4
  88. package/dist/verifier/facade.d.ts +325 -0
  89. package/dist/verifier/facade.js +78 -0
  90. package/dist/verifier/federation.d.ts +2 -2
  91. package/dist/verifier/federation.js +26 -79
  92. package/dist/verifier/harness.d.ts +16 -0
  93. package/dist/verifier/harness.js +201 -0
  94. package/dist/verifier/index.d.ts +3 -0
  95. package/dist/verifier/index.js +2 -0
  96. package/dist/verifier/mapping.d.ts +139 -0
  97. package/dist/verifier/mapping.js +1 -0
  98. package/dist/verifier/negotiation.d.ts +2 -1
  99. package/dist/verifier/negotiation.js +12 -3
  100. package/dist/verifier/plain.d.ts +4 -0
  101. package/dist/verifier/plain.js +38 -0
  102. package/dist/verifier/portability.d.ts +1 -1
  103. package/dist/verifier/portability.js +19 -6
  104. package/dist/verifier/predicate.d.ts +7 -0
  105. package/dist/verifier/predicate.js +63 -7
  106. package/dist/verifier/reconcile.d.ts +37 -0
  107. package/dist/verifier/reconcile.js +115 -0
  108. package/dist/verifier/registry.js +10 -1
  109. package/dist/verifier/registry_engine.d.ts +3 -0
  110. package/dist/verifier/registry_engine.js +37 -20
  111. package/dist/verifier/report.d.ts +8 -0
  112. package/dist/verifier/report.js +9 -2
  113. package/dist/verifier/results.d.ts +3 -0
  114. package/dist/verifier/results.js +13 -0
  115. package/dist/verifier/run_corpus.js +4 -80
  116. package/dist/verifier/runner.d.ts +6 -0
  117. package/dist/verifier/runner.js +123 -17
  118. package/dist/verifier/schema.js +14 -55
  119. package/dist/verifier/signature.d.ts +19 -8
  120. package/dist/verifier/signature.js +51 -29
  121. package/dist/verifier/value.d.ts +9 -2
  122. package/dist/verifier/value.js +81 -11
  123. package/package.json +17 -12
@@ -0,0 +1,325 @@
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 and digest-pinned schema documents. */
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
+ export interface Context {
195
+ readonly keys: readonly PublicKey[];
196
+ readonly issuer?: string | null;
197
+ readonly subject?: string | null;
198
+ readonly audience?: string | null;
199
+ readonly issuerKeySets?: Readonly<Record<string, readonly PublicKey[]>> | null;
200
+ readonly createdAfter?: string | null;
201
+ readonly createdBefore?: string | null;
202
+ readonly priorReceipts: readonly {
203
+ readonly taskIdentity: string;
204
+ readonly terminalState: string;
205
+ readonly terminalCommitment: string;
206
+ }[];
207
+ }
208
+ /** Verified signed attributes, including the digest and purpose. */
209
+ export interface SignedAttributes {
210
+ readonly algorithm: SignatureAlgorithm;
211
+ readonly contentDigest: string;
212
+ readonly createdAt: string;
213
+ readonly keyId: string;
214
+ readonly purpose: SignaturePurpose;
215
+ }
216
+ /** Negotiated extension facts. */
217
+ export interface Negotiated {
218
+ readonly protocolRevision: number;
219
+ readonly criticalExtensions: readonly string[];
220
+ readonly quarantinedExtensions: readonly string[];
221
+ readonly optionalRetained: readonly string[];
222
+ readonly notices: readonly Notice[];
223
+ }
224
+ /** A clamp records the requested and effective values and narrowing source. */
225
+ export interface Clamp {
226
+ readonly field: keyof BoundSet;
227
+ readonly class: 'operational' | 'protected';
228
+ readonly unit: 'count' | 'millisecond' | 'token' | 'money' | 'ordinal';
229
+ readonly requested: JsonValue;
230
+ readonly effective: JsonValue;
231
+ readonly source: 'deployment' | 'host';
232
+ readonly acknowledged: boolean;
233
+ }
234
+ /** Pointwise effective bounds and their clamp evidence. */
235
+ export interface Intersection {
236
+ readonly effective: BoundSet;
237
+ readonly clamps: readonly Clamp[];
238
+ }
239
+ /** One performed or explicitly unverified check. */
240
+ export interface Check {
241
+ readonly surface: EvidenceSurface;
242
+ readonly subject: readonly (string | number)[];
243
+ readonly verified: boolean;
244
+ readonly detail: JsonValue;
245
+ }
246
+ /** Typed import evidence; its unverified surfaces never form an empty set. */
247
+ export interface Evidence {
248
+ readonly protocol_revision: number | null;
249
+ readonly blueprint_digest: string | null;
250
+ readonly deployment_digest: string | null;
251
+ readonly checks: readonly Check[];
252
+ readonly effective_bounds: BoundSet | null;
253
+ readonly clamps: readonly Clamp[];
254
+ readonly optional_extensions_retained: readonly string[];
255
+ readonly not_verified: readonly EvidenceSurface[];
256
+ }
257
+ /** One transport mapping row, returned as inert data. */
258
+ export interface MappingRow {
259
+ readonly index: number;
260
+ readonly logical_field: string;
261
+ readonly a2a_location: string;
262
+ readonly mcp_location: string;
263
+ readonly verdict: 'native' | 'partial' | 'extension';
264
+ }
265
+ /** An integrity-checked, in-memory corpus handle. */
266
+ export interface Corpus {
267
+ readonly identity: string;
268
+ readonly totalCases: number;
269
+ }
270
+ /** A per-case verdict agreement. */
271
+ export interface CaseResult {
272
+ readonly caseId: string;
273
+ readonly agree: boolean;
274
+ }
275
+ /** An aggregate conformance summary. */
276
+ export interface Report {
277
+ readonly format: 'agent-blueprint-protocol-conformance-report';
278
+ readonly corpus_digest: string;
279
+ readonly total: number;
280
+ readonly agreed: number;
281
+ readonly disagreed: number;
282
+ readonly agreement: boolean;
283
+ readonly exit_status: 0 | 1;
284
+ }
285
+ /** An identity-free, per-case results document. */
286
+ export interface ResultsDocument {
287
+ readonly format: 'agent-blueprint-protocol-conformance-results';
288
+ readonly corpus_digest: string;
289
+ readonly registry_digest: string;
290
+ readonly results: readonly {
291
+ readonly id: string;
292
+ readonly surface: string;
293
+ readonly result: Readonly<Record<string, JsonValue>>;
294
+ }[];
295
+ }
296
+ /** Decode canonical Blueprint bytes under optional tightened ceilings. */
297
+ export declare function decodeBlueprint(input: Uint8Array | string, options?: DecodeOptions): Result<Blueprint>;
298
+ /** Decode canonical Deployment bytes under optional tightened ceilings. */
299
+ export declare function decodeDeployment(input: Uint8Array | string, options?: DecodeOptions): Result<Deployment>;
300
+ /** Decode a canonical federation TaskEnvelope. */
301
+ export declare function decodeFederationEnvelope(input: Uint8Array | string, options?: DecodeOptions): Result<FederationEnvelope>;
302
+ /** Encode an artifact view's value as canonical UTF-8 bytes. */
303
+ export declare function canonicalBytes(value: Artifact): Result<Uint8Array>;
304
+ /** Negotiate revision, required fields, and extensions. */
305
+ export declare function negotiate(value: Blueprint | Deployment, options: Support): Result<Negotiated>;
306
+ /** Intersect three total bound sources and record every narrowing. */
307
+ export declare function intersect(options: Sources): Result<Intersection>;
308
+ /** Verify exact observed build identities against a Deployment. */
309
+ export declare function verifyCompatibility(value: Deployment, observed: Observed): Result<Evidence>;
310
+ /** Run the eight-stage import pass and return non-authorizing evidence. */
311
+ export declare function reconcile(blueprint: Blueprint, deployment: Deployment, options: Inputs): Result<Evidence>;
312
+ /** Return the 23 transport mapping rows as data. */
313
+ export declare function federationMapping(): Result<readonly MappingRow[]>;
314
+ /** Verify a detached signature and return the verified attributes. */
315
+ export declare function verifySignature(entry: JsonValue, keys: readonly PublicKey[]): Result<SignedAttributes>;
316
+ /** Load and integrity-check a corpus from a path-to-bytes map. */
317
+ export declare function loadCorpus(files: ReadonlyMap<string, Uint8Array>, options?: {
318
+ readonly priorCensus?: boolean;
319
+ }): Result<Corpus>;
320
+ /** Execute every loaded corpus case. */
321
+ export declare function runCorpus(value: Corpus): Result<readonly (readonly CaseResult[])[]>;
322
+ /** Build the unchanged aggregate report from a corpus run. */
323
+ export declare function buildReport(value: Corpus, results: readonly (readonly CaseResult[])[]): Result<Report>;
324
+ /** Build canonical, identity-free per-case results from the implementation. */
325
+ 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 = {
@@ -1,11 +1,5 @@
1
- // The federation profile — the mirror of AgentBlueprintProtocol.Federation:
2
- // the 23-member TaskEnvelope decoded through the registry engine (carrier-key
3
- // placement laws, R1-R4 root hooks), the lossy-aware A2A/MCP state codecs
4
- // (federation_state_unmappable, never a silent degrade), the bounded
5
- // from_value reconstruction path, and verify_commitment's numbered steps
6
- // (terminal members → JWS verify → binding → commitment recompute → context
7
- // compare → prior-receipt conflict → signed freshness).
8
- import { MAXIMA as CEILINGS, coerce as coerceBounds, maximum as maxBounds } from "./bounds.js";
1
+ import { isValue } from "./value.js";
2
+ import { coerce as coerceBounds, maximum as maxBounds } from "./bounds.js";
9
3
  import * as blueprint from "./blueprint.js";
10
4
  import * as canonical from "./canonical.js";
11
5
  import * as digest from "./digest.js";
@@ -250,7 +244,7 @@ export function decode(bytes, bounds) {
250
244
  // already-decoded value, with the decoder's ceilings re-imposed (a hostile
251
245
  // carrier body cannot buy unbounded work the decode lane would have refused).
252
246
  export function fromValue(value) {
253
- if (value.t !== "obj")
247
+ if (!value || value.t !== "obj")
254
248
  return { ok: false, e: "invalid_type" };
255
249
  const bounded = boundedShape(value);
256
250
  if (!bounded.ok)
@@ -268,69 +262,15 @@ function normalizeBounds(bounds) {
268
262
  return { ok: true, v: maxBounds() };
269
263
  return coerceBounds(bounds);
270
264
  }
265
+ // ---- the bounded shape walk (from_value's decoder-parity gate) ----------------------
271
266
  function boundedShape(value) {
272
- return shapeWalk(value, { members: 0, items: 0, nodes: 0, string: 0, depth: 0 });
273
- }
274
- function shapeWalk(value, acc) {
275
- const entry = ceiling(acc);
276
- if (!entry.ok)
277
- return entry;
278
- switch (value.t) {
279
- case "obj": {
280
- const bumped = bump(acc, { members: value.v.length, nodes: 1, depth: 1 });
281
- return walkShapeMembers(value.v, bumped);
282
- }
283
- case "arr": {
284
- const bumped = bump(acc, { items: value.v.length, nodes: 1, depth: 1 });
285
- return walkShapeItems(value.v, bumped);
286
- }
287
- case "str": {
288
- const bumped = bump(acc, { nodes: 1, string: Buffer.byteLength(value.v, "utf8"), depth: 1 });
289
- return ceiling(bumped);
290
- }
291
- default:
292
- return ceiling(bump(acc, { nodes: 1 }));
293
- }
294
- }
295
- function walkShapeMembers(members, acc) {
296
- for (const [, value] of members) {
297
- const result = shapeWalk(value, acc);
298
- if (!result.ok)
299
- return result;
300
- }
301
- return { ok: true };
302
- }
303
- function walkShapeItems(items, acc) {
304
- for (const item of items) {
305
- const result = shapeWalk(item, acc);
306
- if (!result.ok)
307
- return result;
308
- }
309
- return { ok: true };
310
- }
311
- function bump(acc, adds) {
312
- const out = { ...acc };
313
- for (const [key, add] of Object.entries(adds)) {
314
- out[key] += add;
315
- }
316
- return out;
317
- }
318
- function ceiling(acc) {
319
- const checks = [
320
- ["members", CEILINGS.members, "members"],
321
- ["items", CEILINGS.items, "items"],
322
- ["nodes", CEILINGS.nodes, "nodes"],
323
- ["string", CEILINGS.string, "string"],
324
- ["depth", CEILINGS.depth, "depth"],
325
- ];
326
- for (const [key, max, name] of checks) {
327
- if (acc[key] > max)
328
- return { ok: false, e: `ceiling:${name}` };
329
- }
330
- return { ok: true };
267
+ const result = canonical.encode(value);
268
+ return result.ok ? { ok: true } : result;
331
269
  }
332
270
  // ---- canonical bytes ------------------------------------------------------------------
333
271
  export function canonicalBytes(envelope) {
272
+ if (!envelope || typeof envelope !== "object")
273
+ return { ok: false, e: "invalid_type" };
334
274
  return canonical.encode(envelope.value);
335
275
  }
336
276
  // ---- the federation portability pass (mode map + R4) ----------------------------------
@@ -459,14 +399,14 @@ export function toMcpState(spelling) {
459
399
  // ---- carriers: the placement laws, per transport ----------------------------------------
460
400
  // The A2A-side carrier key: the registry entry's a2a_uri.
461
401
  export function a2aCarrierKey() {
462
- return compiledEntry("com.example/federation").a2a_uri;
402
+ return compiledEntry("io.github.baselabs/federation").a2a_uri;
463
403
  }
464
404
  // The MCP-side carrier key: the registry namespace.
465
405
  export function mcpCarrierKey() {
466
- return "com.example/federation";
406
+ return "io.github.baselabs/federation";
467
407
  }
468
408
  export function fromA2aCarrier(carrier) {
469
- if (carrier.t !== "obj")
409
+ if (!isValue(carrier) || carrier.t !== "obj")
470
410
  return { ok: false, e: "invalid_type" };
471
411
  const id = carrierString(carrier.v, "id");
472
412
  if (!id.ok)
@@ -477,7 +417,7 @@ export function fromA2aCarrier(carrier) {
477
417
  const logical = fromA2aState(stateRaw.v);
478
418
  if (!logical.ok)
479
419
  return logical;
480
- const body = carrierBody(carrier.v, "metadata", a2aCarrierKey());
420
+ const body = carrierBody(carrier.v, "metadata", [a2aCarrierKey(), "https://example.com/extensions/federation"]);
481
421
  if (!body.ok)
482
422
  return body;
483
423
  const placed = noDoublePlacement(body.v);
@@ -487,7 +427,7 @@ export function fromA2aCarrier(carrier) {
487
427
  return rebuilt.ok ? { ok: true, v: { decoded: true } } : rebuilt;
488
428
  }
489
429
  export function fromMcpCarrier(carrier) {
490
- if (carrier.t !== "obj")
430
+ if (!isValue(carrier) || carrier.t !== "obj")
491
431
  return { ok: false, e: "invalid_type" };
492
432
  const id = carrierString(carrier.v, "taskId");
493
433
  if (!id.ok)
@@ -498,7 +438,7 @@ export function fromMcpCarrier(carrier) {
498
438
  const logical = fromMcpState(stateRaw.v);
499
439
  if (!logical.ok)
500
440
  return logical;
501
- const body = carrierBody(carrier.v, "_meta", mcpCarrierKey());
441
+ const body = carrierBody(carrier.v, "_meta", [mcpCarrierKey(), "com.example/federation"]);
502
442
  if (!body.ok)
503
443
  return body;
504
444
  const placed = noDoublePlacement(body.v);
@@ -523,15 +463,18 @@ function carrierState(members) {
523
463
  return { ok: false, e: "invalid_type" };
524
464
  return carrierString(found.v, "state");
525
465
  }
526
- function carrierBody(members, envelopeMember, key) {
466
+ function carrierBody(members, envelopeMember, keys) {
527
467
  const found = keyfind(members, envelopeMember);
528
468
  if (found === null)
529
469
  return { ok: false, e: "missing_required_field" };
530
470
  if (found.t !== "obj")
531
471
  return { ok: false, e: "invalid_type" };
532
- const inner = keyfind(found.v, key);
533
- if (inner === null)
472
+ const entries = found.v.filter(([key]) => keys.includes(key));
473
+ if (entries.length === 0)
534
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];
535
478
  if (inner.t !== "obj")
536
479
  return { ok: false, e: "invalid_type" };
537
480
  return { ok: true, v: inner.v };
@@ -558,7 +501,7 @@ function rebuild(id, logical, body) {
558
501
  // The Terminal Commitment: the domain-separated digest over exactly the
559
502
  // seven named components.
560
503
  export function terminalCommitment(envelope) {
561
- if (envelope.value.t !== "obj")
504
+ if (!envelope || !isValue(envelope.value) || envelope.value.t !== "obj")
562
505
  return { ok: false, e: "invalid_type" };
563
506
  const members = new Map(envelope.value.v);
564
507
  const taskOk = stringMember(members, "task_identity");
@@ -591,7 +534,7 @@ export function terminalCommitment(envelope) {
591
534
  return { ok: true, v: digest.hash("federation_envelope", Buffer.from(jcs.v, "utf8")) };
592
535
  }
593
536
  export function verifyCommitment(envelope, context) {
594
- if (envelope.value.t !== "obj")
537
+ if (!envelope || !isValue(envelope.value) || envelope.value.t !== "obj")
595
538
  return { ok: false, e: "invalid_type" };
596
539
  const members = new Map(envelope.value.v);
597
540
  const taskOk = stringMember(members, "task_identity");
@@ -606,6 +549,10 @@ export function verifyCommitment(envelope, context) {
606
549
  const signatureEntry = receiptFetch(receipt.v, "signature");
607
550
  if (!signatureEntry.ok)
608
551
  return signatureEntry;
552
+ if (!context || typeof context !== "object" || !Array.isArray(context.keys) ||
553
+ (context.issuerKeySets != null && (typeof context.issuerKeySets !== "object" || Array.isArray(context.issuerKeySets) || Object.values(context.issuerKeySets).some((keys) => !Array.isArray(keys)))) ||
554
+ (!Array.isArray(context.priorReceipts) || context.priorReceipts.some((receipt) => !receipt || typeof receipt !== "object")))
555
+ return { ok: false, e: "invalid_type" };
609
556
  const pool = resolvePool(members, context);
610
557
  if (!pool.ok)
611
558
  return pool;
@@ -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>;