@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,69 @@
1
+ # Registry operations process
2
+
3
+ How namespaces enter and leave the compiled extension registry. The
4
+ registry is governance-canonical in `registry.json` (this directory);
5
+ the compiled counterparts (Elixir module and TypeScript verifier) are
6
+ hand-mirrored and bound by the registry-equality gate.
7
+
8
+ ## Qualification
9
+
10
+ A registration request MUST provide: the namespace (reverse-DNS-plus-
11
+ path, not parseable as a network endpoint), an owner, the declared
12
+ criticality, and, for critical namespaces, a schema document whose JCS
13
+ digest is pinned. A request SHOULD state the A2A declaration URI.
14
+ Example-class identities are the norm until a product is public.
15
+
16
+ ## Registration steps
17
+
18
+ 1. The owner submits the entry (and, for critical entries, the schema
19
+ document) as a change to `registry.json` and implements it in both
20
+ language packages.
21
+ 2. The registry-equality check, corpus checks, and CI checks must pass.
22
+ Corpus verification fails when cases were generated for a different
23
+ registry state.
24
+ 3. The change lands with a CHANGELOG entry and an ADR record when it
25
+ sets a precedent (the product-extension registration is the
26
+ recorded example).
27
+
28
+ ## Lifecycle
29
+
30
+ `reserved` → `active` → `deprecated` → `retired`. Promotion to a
31
+ critical declaration requires a protocol revision increment (the
32
+ digest-covered evolution rule); demotion does not. A retired namespace
33
+ is never reused. Deprecated entries retain verifiable artifacts with a
34
+ typed notice.
35
+
36
+ ## Decision rights
37
+
38
+ The registry steward accepts registrations; the two-consumer
39
+ rule governs promotion into shared surfaces: a member or helper earns
40
+ a shared seat only when two independently verified consumers use it.
41
+ The registry carries published facts, never authority.
42
+
43
+ ## MCP metadata registrations
44
+
45
+ A namespace carried as an MCP `_meta` key follows the grammar in
46
+ [MCP revision 2026-07-28](https://modelcontextprotocol.io/specification/2026-07-28/basic#_meta).
47
+ This registry requires at least two prefix labels. Each begins with a
48
+ lowercase letter, ends with a lowercase letter or digit, and permits
49
+ lowercase letters, digits, and hyphens inside. The nonempty name begins and
50
+ ends with a lowercase letter or digit; its interior also permits lowercase
51
+ letters, digits, hyphens, underscores, and dots. These lowercase and
52
+ two-label restrictions are stricter than the MCP grammar. A prefix whose second label is `mcp` or `modelcontextprotocol` is
53
+ reserved. The registry equality gate checks registrations; artifact
54
+ decoding retains its revision 1 namespace grammar.
55
+
56
+ ## Federation namespace
57
+
58
+ `io.github.baselabs/federation` is active and critical, with A2A URI
59
+ `https://baselabs.github.io/agent_blueprint_protocol/extensions/federation`.
60
+ It retains the schema pin of `com.example/federation`. Producers SHOULD
61
+ use the active namespace; both are supported. The deprecated spelling
62
+ emits `extension_deprecated` and is never retired in the 1.x line.
63
+
64
+ ## Review and disputes
65
+
66
+ The maintainer evaluates namespace control, public owner identity, grammar,
67
+ criticality, schema digest reproducibility, compatibility, and test coverage.
68
+ Requests are reviewed on a best-effort basis, in the order received. An applicant can request reconsideration in the same public discussion. Unresolved disputes go to the registry steward with the evidence and requested change.
69
+ A dispute does not change a released registry entry.
@@ -0,0 +1,68 @@
1
+ {
2
+ "format": "agent-blueprint-protocol-registry",
3
+ "entries": [
4
+ {
5
+ "a2a_uri": "https://example.com/extensions/commerce-graph",
6
+ "criticality": "critical",
7
+ "namespace": "com.example.commerce/graph",
8
+ "owner": "ExampleCommerce",
9
+ "promoted_at_revision": null,
10
+ "schema_digest": null,
11
+ "state": "active"
12
+ },
13
+ {
14
+ "a2a_uri": "https://example.com/extensions/commerce-classification-labels",
15
+ "criticality": "optional",
16
+ "namespace": "com.example.commerce/classification-labels",
17
+ "owner": "ExampleCommerce",
18
+ "promoted_at_revision": null,
19
+ "schema_digest": null,
20
+ "state": "active"
21
+ },
22
+ {
23
+ "a2a_uri": "https://example.com/extensions/commerce-rubric-assertion",
24
+ "criticality": "optional",
25
+ "namespace": "com.example.commerce/rubric-assertion",
26
+ "owner": "ExampleCommerce",
27
+ "promoted_at_revision": null,
28
+ "schema_digest": null,
29
+ "state": "active"
30
+ },
31
+ {
32
+ "a2a_uri": "https://example.com/extensions/platform-estate",
33
+ "criticality": "optional",
34
+ "namespace": "com.example.platform/estate",
35
+ "owner": "ExamplePlatform",
36
+ "promoted_at_revision": null,
37
+ "schema_digest": null,
38
+ "state": "deprecated"
39
+ },
40
+ {
41
+ "a2a_uri": "https://example.com/extensions/platform-estate-contract",
42
+ "criticality": "critical",
43
+ "namespace": "com.example.platform/estate-contract",
44
+ "owner": "ExamplePlatform",
45
+ "promoted_at_revision": null,
46
+ "schema_digest": "sha-256:s_ToZWwxrhhd4vVxAyUh2Q6Gddston4tBSLHTLvCQAw",
47
+ "state": "active"
48
+ },
49
+ {
50
+ "a2a_uri": "https://example.com/extensions/federation",
51
+ "criticality": "critical",
52
+ "namespace": "com.example/federation",
53
+ "owner": "Agent Blueprint Protocol",
54
+ "promoted_at_revision": null,
55
+ "schema_digest": "sha-256:NgfEJT8JXJqRMpQS5TVBQDrk97-PzUtbgnRgWc8Dki0",
56
+ "state": "deprecated"
57
+ },
58
+ {
59
+ "a2a_uri": "https://baselabs.github.io/agent_blueprint_protocol/extensions/federation",
60
+ "criticality": "critical",
61
+ "namespace": "io.github.baselabs/federation",
62
+ "owner": "Agent Blueprint Protocol",
63
+ "promoted_at_revision": null,
64
+ "schema_digest": "sha-256:NgfEJT8JXJqRMpQS5TVBQDrk97-PzUtbgnRgWc8Dki0",
65
+ "state": "active"
66
+ }
67
+ ]
68
+ }
@@ -1,5 +1,9 @@
1
1
  export declare function encode(data: Buffer): string;
2
- export type StrictErr = "base64url_padded" | "base64url_invalid";
2
+ export declare function encode(data: unknown): string | {
3
+ ok: false;
4
+ e: string;
5
+ };
6
+ export type StrictErr = "base64url_padded" | "base64url_invalid" | "invalid_type";
3
7
  export declare function decodeStrict(input: string): {
4
8
  ok: true;
5
9
  v: Buffer;
@@ -12,5 +16,5 @@ export declare function decodeLenient(input: string): {
12
16
  v: Buffer;
13
17
  } | {
14
18
  ok: false;
15
- e: "lenient_invalid";
19
+ e: "lenient_invalid" | "invalid_type";
16
20
  };
@@ -12,9 +12,13 @@
12
12
  // invalid characters.
13
13
  const ALPHABET = /^[A-Za-z0-9_-]*$/;
14
14
  export function encode(data) {
15
+ if (!Buffer.isBuffer(data))
16
+ return { ok: false, e: "invalid_type" };
15
17
  return data.toString("base64url");
16
18
  }
17
19
  export function decodeStrict(input) {
20
+ if (typeof input !== "string")
21
+ return { ok: false, e: "invalid_type" };
18
22
  if (input.includes("="))
19
23
  return { ok: false, e: "base64url_padded" };
20
24
  if (!ALPHABET.test(input))
@@ -26,8 +30,10 @@ export function decodeStrict(input) {
26
30
  return { ok: false, e: "base64url_invalid" };
27
31
  return { ok: true, v: decoded };
28
32
  }
29
- const LENIENT = /^[A-Za-z0-9_-]+={0,2}$/;
33
+ const LENIENT = /^(?:[A-Za-z0-9_-]+={0,2})?$/;
30
34
  export function decodeLenient(input) {
35
+ if (typeof input !== "string")
36
+ return { ok: false, e: "invalid_type" };
31
37
  if (!LENIENT.test(input))
32
38
  return { ok: false, e: "lenient_invalid" };
33
39
  if (input.length % 4 === 1)
@@ -1,5 +1,4 @@
1
1
  import type { Bounds } from "./bounds.ts";
2
- import * as digest from "./digest.ts";
3
2
  import { type Spec } from "./registry_engine.ts";
4
3
  import type { Value } from "./value.ts";
5
4
  export interface Blueprint {
@@ -28,8 +27,14 @@ export declare function fromValue(value: Value, opts?: {
28
27
  ok: false;
29
28
  e: string;
30
29
  };
31
- export declare function toValue(blueprint: Blueprint): Value;
32
- export declare function digestInput(blueprint: Blueprint): Value;
30
+ export declare function toValue(blueprint: Blueprint): Value | {
31
+ ok: false;
32
+ e: string;
33
+ };
34
+ export declare function digestInput(blueprint: Blueprint): Value | {
35
+ ok: false;
36
+ e: string;
37
+ };
33
38
  export declare function canonicalBytes(blueprint: Blueprint): {
34
39
  ok: true;
35
40
  v: string;
@@ -37,20 +42,11 @@ export declare function canonicalBytes(blueprint: Blueprint): {
37
42
  ok: false;
38
43
  e: string;
39
44
  };
40
- export declare function contentDigest(blueprint: Blueprint): string;
41
- export declare function verifyContentDigest(blueprint: Blueprint): VResult;
42
- export interface SignatureAttributes {
43
- contentDigest: digest.Digest;
44
- createdAt: string;
45
- keyId: string;
46
- purpose: "blueprint" | "deployment" | "federation-envelope";
47
- }
48
- export declare function signatureAttributes(entry: Value): {
49
- ok: true;
50
- v: SignatureAttributes;
51
- } | {
45
+ export declare function contentDigest(blueprint: Blueprint): string | {
52
46
  ok: false;
53
47
  e: string;
54
48
  };
49
+ export declare function verifyContentDigest(blueprint: Blueprint): VResult;
50
+ export declare function scan(value: Value, authoredNs: Set<string>): VResult;
51
+ export { attributes as signatureAttributes } from "./signature.ts";
55
52
  export declare function validZFormDate(stamped: string): boolean;
56
- export {};
@@ -1,10 +1,10 @@
1
+ import { isValue } from "./value.js";
1
2
  // The Blueprint artifact — the mirror of AgentBlueprintProtocol.Blueprint:
2
3
  // canonical verify → the 18-member registry table → the portability scan →
3
4
  // the content-digest comparison, over the digest-covered members minus the
4
- // evidence trio. Also hosts the Signature.attributes twin (the TS signature
5
- // twin keeps its parts parser private; the artifact tables need the
6
- // attributes projection for the purpose checks).
7
- import * as b64 from "./b64url.js";
5
+ // evidence trio. The artifact tables share the signature parser for
6
+ // attributes and purpose checks.
7
+ import { attributes as signatureAttributes } from "./signature.js";
8
8
  import { coerce as coerceBounds, maximum as maxBounds } from "./bounds.js";
9
9
  import * as canonical from "./canonical.js";
10
10
  import * as digest from "./digest.js";
@@ -70,7 +70,7 @@ const SEGMENT = /^[a-z0-9][a-z0-9._-]*$/;
70
70
  const Z_FORM = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/;
71
71
  const CURRENCY = /^[A-Z]{3}$/;
72
72
  const enumSet = (values) => new Set(values);
73
- // ---- the 18-member table (base §6): data for the generic engine ---------------
73
+ // ---- the 18-member table (protocol §2): data for the generic engine ---------------
74
74
  function portElement() {
75
75
  return {
76
76
  kind: {
@@ -183,6 +183,7 @@ export function table() {
183
183
  field("signatures", { array: { kind: "custom", check: checkSignatureEntry } }, {
184
184
  required: false,
185
185
  maxItems: CEILING_SIGNATURES,
186
+ check: checkSignatureIds,
186
187
  }),
187
188
  field("attestations", { array: { kind: "any" } }, {
188
189
  required: false,
@@ -215,7 +216,14 @@ export function decode(bytes, bounds) {
215
216
  return { ok: true, v: { value } };
216
217
  }
217
218
  export function fromValue(value, opts = {}) {
219
+ if (opts === null || typeof opts !== "object" || Array.isArray(opts))
220
+ return { ok: false, e: "invalid_type" };
218
221
  const validated = opts.authoredExtensions ?? [];
222
+ if (!Array.isArray(validated) || validated.some((ns) => typeof ns !== "string"))
223
+ return { ok: false, e: "invalid_type" };
224
+ const shaped = canonical.encode(value);
225
+ if (!shaped.ok)
226
+ return shaped;
219
227
  if (validated.length > 0) {
220
228
  if (value.t !== "obj")
221
229
  return { ok: false, e: "invalid_type" };
@@ -232,25 +240,31 @@ export function fromValue(value, opts = {}) {
232
240
  return { ok: true, v: { value } };
233
241
  }
234
242
  export function toValue(blueprint) {
235
- return blueprint.value;
243
+ return blueprint && isValue(blueprint.value) ? blueprint.value : { ok: false, e: "invalid_type" };
236
244
  }
237
245
  // ---- digest surface ----------------------------------------------------------------
238
246
  export function digestInput(blueprint) {
247
+ if (!blueprint || !isValue(blueprint.value))
248
+ return { ok: false, e: "invalid_type" };
239
249
  if (blueprint.value.t !== "obj")
240
250
  return blueprint.value;
241
251
  return { t: "obj", v: blueprint.value.v.filter(([name]) => !EVIDENCE_MEMBERS.includes(name)) };
242
252
  }
243
253
  export function canonicalBytes(blueprint) {
254
+ if (!blueprint || typeof blueprint !== "object")
255
+ return { ok: false, e: "invalid_type" };
244
256
  return canonical.encode(blueprint.value);
245
257
  }
246
258
  // The honest content digest over the covered members' canonical bytes.
247
259
  export function contentDigest(blueprint) {
248
260
  const jcs = canonical.encode(digestInput(blueprint));
249
261
  if (!jcs.ok)
250
- throw new Error("blueprint digest input must encode");
262
+ return jcs;
251
263
  return digest.toTagged(digest.hash("blueprint_content", Buffer.from(jcs.v, "utf8")));
252
264
  }
253
265
  export function verifyContentDigest(blueprint) {
266
+ if (!blueprint || !isValue(blueprint.value))
267
+ return { ok: false, e: "invalid_type" };
254
268
  const members = blueprint.value.t === "obj" ? blueprint.value.v : [];
255
269
  const declared = keyfind(members, "content_digest");
256
270
  if (declared === null || declared.t !== "str")
@@ -315,10 +329,20 @@ function checkSchemaDocument(value) {
315
329
  // The purpose is the artifact's fact: the envelope parses AND must be
316
330
  // "blueprint" here — a deployment-purpose signature riding a Blueprint is a
317
331
  // wrong-position entry, denied as a table constraint.
332
+ function checkSignatureIds(value) {
333
+ if (value.t !== "arr")
334
+ return { ok: false, e: "invalid_type" };
335
+ const ids = value.v.flatMap((entry) => {
336
+ const attrs = entry?.t === "obj" ? keyfind(entry.v, "signed_attributes") : null;
337
+ const id = attrs?.t === "obj" ? keyfind(attrs.v, "key_id") : null;
338
+ return id?.t === "str" ? [id.v] : [];
339
+ });
340
+ return new Set(ids).size === ids.length ? { ok: true } : { ok: false, e: "invalid_constraint" };
341
+ }
318
342
  function checkSignatureEntry(entry) {
319
343
  const attrs = signatureAttributes(entry);
320
344
  if (!attrs.ok)
321
- return { ok: false, e: attrs.e };
345
+ return attrs;
322
346
  return attrs.v.purpose === "blueprint" ? { ok: true } : { ok: false, e: "invalid_constraint" };
323
347
  }
324
348
  // The attestation kind registry is empty BY DESIGN; a non-empty array denies.
@@ -523,7 +547,9 @@ function memberArray(members, name) {
523
547
  return found !== undefined && found.t === "arr" ? found.v : [];
524
548
  }
525
549
  // ---- the portability scan -----------------------------------------------------------
526
- function scan(value, authoredNs) {
550
+ export function scan(value, authoredNs) {
551
+ if (!isValue(value) || value.t !== "obj" || !(authoredNs instanceof Set) || [...authoredNs].some(ns => typeof ns !== "string"))
552
+ return { ok: false, e: "invalid_type" };
527
553
  if (value.t !== "obj")
528
554
  return { ok: false, e: "invalid_type" };
529
555
  const members = value.v;
@@ -564,11 +590,7 @@ function predicateOperands(members) {
564
590
  const predicateValue = keyfind(assertion.v, "predicate");
565
591
  if (predicateValue === null || predicateValue.t !== "obj")
566
592
  continue;
567
- for (const operandName of ["value", "values"]) {
568
- const operand = keyfind(predicateValue.v, operandName);
569
- if (operand !== null)
570
- out.push(operand);
571
- }
593
+ out.push(predicateValue);
572
594
  }
573
595
  return out;
574
596
  }
@@ -680,106 +702,12 @@ function memberListOf(members, name) {
680
702
  const found = keyfind(members, name);
681
703
  return found !== null && found.t === "arr" ? found.v : [];
682
704
  }
683
- const PURPOSES = new Set(["blueprint", "deployment", "federation-envelope"]);
684
- const ENTRY_MEMBERS = ["protected", "signature", "signed_attributes"];
685
- const HEADER_MEMBERS = ["alg", "b64", "crit", "kid"];
686
- const ATTR_MEMBERS = ["algorithm", "content_digest", "created_at", "key_id", "purpose"];
687
- function malformed() {
688
- return { ok: false, e: "signature_malformed" };
689
- }
690
- export function signatureAttributes(entry) {
691
- if (entry.t !== "obj")
692
- return malformed();
693
- const entryPairs = entry.v;
694
- const entryNames = entryPairs.map(([name]) => name).sort();
695
- if (entryNames.length !== 3 ||
696
- entryNames.join("\u0000") !== ENTRY_MEMBERS.join("\u0000")) {
697
- return malformed();
698
- }
699
- const header = keyfind(entryPairs, "protected");
700
- const attrs = keyfind(entryPairs, "signed_attributes");
701
- const signatureBody = keyfind(entryPairs, "signature");
702
- // Header: exactly {alg, b64, crit, kid}; the one algorithm-unsupported
703
- // denial fires only when alg is a string naming another algorithm.
704
- if (header.t !== "obj")
705
- return malformed();
706
- const headerNames = header.v.map(([name]) => name).sort();
707
- if (headerNames.length !== 4 || headerNames.join("\u0000") !== HEADER_MEMBERS.join("\u0000")) {
708
- return malformed();
709
- }
710
- const alg = keyfind(header.v, "alg");
711
- if (alg.t === "str" && alg.v !== "EdDSA") {
712
- return { ok: false, e: "signature_algorithm_unsupported" };
713
- }
714
- if (alg.t !== "str")
715
- return malformed();
716
- const b64Flag = keyfind(header.v, "b64");
717
- if (b64Flag.t !== "bool" || b64Flag.v !== false)
718
- return malformed();
719
- const crit = keyfind(header.v, "crit");
720
- if (crit.t !== "arr" ||
721
- crit.v.length !== 1 ||
722
- crit.v[0].t !== "str" ||
723
- crit.v[0].v !== "b64") {
724
- return malformed();
725
- }
726
- const kid = keyfind(header.v, "kid");
727
- if (kid.t !== "str" || kid.v === "")
728
- return malformed();
729
- // Attributes: exactly the five closed members.
730
- if (attrs.t !== "obj")
731
- return malformed();
732
- const attrNames = attrs.v.map(([name]) => name).sort();
733
- if (attrNames.length !== 5 || attrNames.join("\u0000") !== ATTR_MEMBERS.join("\u0000")) {
734
- return malformed();
735
- }
736
- const algorithm = keyfind(attrs.v, "algorithm");
737
- if (algorithm.t === "str" && algorithm.v !== "Ed25519") {
738
- return { ok: false, e: "signature_algorithm_unsupported" };
739
- }
740
- if (algorithm.t !== "str")
741
- return malformed();
742
- const contentDigest = keyfind(attrs.v, "content_digest");
743
- if (contentDigest.t !== "str" || !digest.fromTagged(contentDigest.v).ok)
744
- return malformed();
745
- const createdAt = keyfind(attrs.v, "created_at");
746
- if (createdAt.t !== "str" || !Z_FORM.test(createdAt.v) || !validZFormDate(createdAt.v)) {
747
- return malformed();
748
- }
749
- const keyId = keyfind(attrs.v, "key_id");
750
- if (keyId.t !== "str" || keyId.v === "" || keyId.v.includes("."))
751
- return malformed();
752
- const purpose = keyfind(attrs.v, "purpose");
753
- if (purpose.t !== "str" || !PURPOSES.has(purpose.v))
754
- return malformed();
755
- if (kid.v !== keyId.v)
756
- return malformed();
757
- if (signatureBody.t !== "str")
758
- return malformed();
759
- const decodedSignature = b64.decodeStrict(signatureBody.v);
760
- if (!decodedSignature.ok || decodedSignature.v.length !== 64)
761
- return malformed();
762
- // canonical_input: both halves must re-encode (invalid UTF-8 in a
763
- // hand-built entry denies malformed).
764
- const headerJson = canonical.encode(header);
765
- const attrsJson = canonical.encode(attrs);
766
- if (!headerJson.ok || !attrsJson.ok)
767
- return malformed();
768
- const parsedDigest = digest.fromTagged(contentDigest.v);
769
- if (!parsedDigest.ok)
770
- return malformed();
771
- return {
772
- ok: true,
773
- v: {
774
- contentDigest: parsedDigest.v,
775
- createdAt: createdAt.v,
776
- keyId: keyId.v,
777
- purpose: purpose.v,
778
- },
779
- };
780
- }
705
+ // Artifact tables and receipt checks use the signature module's parser.
706
+ export { attributes as signatureAttributes } from "./signature.js";
781
707
  // DateTime.from_iso8601's field validation for the Z whole-second form.
782
708
  export function validZFormDate(stamped) {
709
+ if (typeof stamped !== "string")
710
+ return false;
783
711
  const year = Number(stamped.slice(0, 4));
784
712
  const month = Number(stamped.slice(5, 7));
785
713
  const day = Number(stamped.slice(8, 10));
@@ -8,7 +8,7 @@ export interface Bounds {
8
8
  key: number;
9
9
  number_lexeme: number;
10
10
  }
11
- export declare const MAXIMA: Bounds;
11
+ export declare const MAXIMA: Readonly<Bounds>;
12
12
  export declare function maximum(): Bounds;
13
13
  export declare function coerce(overrides: unknown): {
14
14
  ok: true;
@@ -2,7 +2,7 @@
2
2
  // profile maxima and the tighten-only override rule (unknown key denies
3
3
  // `unknown_bound`; a non-positive, non-integer, or super-maximum value denies
4
4
  // `ceiling:<field>`).
5
- export const MAXIMA = {
5
+ export const MAXIMA = Object.freeze({
6
6
  bytes: 5_000_000,
7
7
  depth: 64,
8
8
  members: 1_000,
@@ -11,7 +11,7 @@ export const MAXIMA = {
11
11
  string: 100_000,
12
12
  key: 1_000,
13
13
  number_lexeme: 64,
14
- };
14
+ });
15
15
  const FIELDS = Object.keys(MAXIMA);
16
16
  export function maximum() {
17
17
  return { ...MAXIMA };
@@ -23,5 +23,14 @@ export declare function intersect(blueprint: Record<string, unknown>, deployment
23
23
  } | {
24
24
  ok: false;
25
25
  e: string;
26
+ subject?: (string | number)[];
27
+ };
28
+ export declare function buildSet(raw: Record<string, unknown>): {
29
+ ok: true;
30
+ v: Record<string, BoundValue>;
31
+ } | {
32
+ ok: false;
33
+ e: string;
34
+ subject?: (string | number)[];
26
35
  };
27
36
  export {};
@@ -77,7 +77,7 @@ export function intersect(blueprint, deployment, host, posture) {
77
77
  return cost.currency;
78
78
  });
79
79
  if (new Set(currencies).size !== 1) {
80
- return { ok: false, e: "bound_unit_mismatch" };
80
+ return { ok: false, e: "bound_unit_mismatch", subject: ["max_cost"] };
81
81
  }
82
82
  return compose(sources, posture);
83
83
  }
@@ -86,14 +86,16 @@ export function intersect(blueprint, deployment, host, posture) {
86
86
  // The TS runner passes corpus bound-set objects through verbatim (the Elixir
87
87
  // runner pre-filters unknown member names to :invalid_type at add_bound_entry;
88
88
  // here that delegated filter runs first, then BoundSet.new's value checks).
89
- function buildSet(raw) {
89
+ export function buildSet(raw) {
90
+ if (!isPlainObject(raw))
91
+ return { ok: false, e: "invalid_type" };
90
92
  const out = {};
91
93
  for (const [name, value] of Object.entries(raw)) {
92
94
  if (!Object.hasOwn(TABLE, name))
93
95
  return { ok: false, e: "invalid_type" };
94
96
  const built = buildBound(name, value);
95
97
  if (!built.ok)
96
- return built;
98
+ return { ...built, subject: [name] };
97
99
  out[name] = built.v;
98
100
  }
99
101
  return { ok: true, v: out };
@@ -146,7 +148,8 @@ function buildBound(name, raw) {
146
148
  return { ok: false, e: "bound_value_invalid" };
147
149
  }
148
150
  function isPlainObject(value) {
149
- return typeof value === "object" && value !== null && !Array.isArray(value);
151
+ return typeof value === "object" && value !== null &&
152
+ (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
150
153
  }
151
154
  // ---- totality ----------------------------------------------------------------------
152
155
  function totalOf(sources) {
@@ -156,7 +159,7 @@ function totalOf(sources) {
156
159
  const expected = new Set(NAMES);
157
160
  const extra = [...present].filter((name) => !expected.has(name));
158
161
  if (extra.length > 0)
159
- return { ok: false, e: "bound_unknown" };
162
+ return { ok: false, e: "bound_unknown", subject: ["bound_set"] };
160
163
  if (present.size === expected.size && NAMES.every((n) => present.has(n))) {
161
164
  // re-validate present values (bypassed-set parity)
162
165
  for (const name of NAMES) {
@@ -174,7 +177,7 @@ function totalOf(sources) {
174
177
  return rebuilt;
175
178
  }
176
179
  else {
177
- return { ok: false, e: TABLE[name].cls === "operational" ? "missing_ceiling" : "bound_source_missing" };
180
+ return { ok: false, e: TABLE[name].cls === "operational" ? "missing_ceiling" : "bound_source_missing", subject: [name] };
178
181
  }
179
182
  }
180
183
  }
@@ -199,7 +202,7 @@ function compose(sources, posture) {
199
202
  continue;
200
203
  }
201
204
  if (def.cls === "protected" && posture === "deny") {
202
- return { ok: false, e: "protected_bound_clamp_denied" };
205
+ return { ok: false, e: "protected_bound_clamp_denied", subject: [name] };
203
206
  }
204
207
  clamps.push({
205
208
  field: name,
@@ -1,6 +1,6 @@
1
1
  import type { Bounds } from "./bounds.ts";
2
2
  import type { Value } from "./value.ts";
3
- export declare function encode(value: Value, bounds?: Bounds | Record<string, unknown>): {
3
+ export declare function encode(value: unknown, bounds?: Bounds | Record<string, unknown>): {
4
4
  ok: true;
5
5
  v: string;
6
6
  } | {