@cotal-ai/core 0.12.0 → 0.13.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 (152) hide show
  1. package/dist/acls.d.ts +31 -7
  2. package/dist/acls.d.ts.map +1 -1
  3. package/dist/acls.js +105 -17
  4. package/dist/acls.js.map +1 -1
  5. package/dist/agent-file.js +1 -1
  6. package/dist/agent-file.js.map +1 -1
  7. package/dist/auth-provider.d.ts +8 -0
  8. package/dist/auth-provider.d.ts.map +1 -1
  9. package/dist/auth-provider.js.map +1 -1
  10. package/dist/backup.d.ts.map +1 -1
  11. package/dist/backup.js +6 -4
  12. package/dist/backup.js.map +1 -1
  13. package/dist/broker-floor.d.ts +34 -0
  14. package/dist/broker-floor.d.ts.map +1 -0
  15. package/dist/broker-floor.js +39 -0
  16. package/dist/broker-floor.js.map +1 -0
  17. package/dist/canonical.d.ts +24 -0
  18. package/dist/canonical.d.ts.map +1 -0
  19. package/dist/canonical.js +159 -0
  20. package/dist/canonical.js.map +1 -0
  21. package/dist/connector.d.ts +4 -0
  22. package/dist/connector.d.ts.map +1 -1
  23. package/dist/endpoint-action.d.ts +424 -0
  24. package/dist/endpoint-action.d.ts.map +1 -0
  25. package/dist/endpoint-action.js +910 -0
  26. package/dist/endpoint-action.js.map +1 -0
  27. package/dist/endpoint-binding.d.ts +344 -0
  28. package/dist/endpoint-binding.d.ts.map +1 -0
  29. package/dist/endpoint-binding.js +753 -0
  30. package/dist/endpoint-binding.js.map +1 -0
  31. package/dist/endpoint-checkpoint.d.ts +292 -0
  32. package/dist/endpoint-checkpoint.d.ts.map +1 -0
  33. package/dist/endpoint-checkpoint.js +818 -0
  34. package/dist/endpoint-checkpoint.js.map +1 -0
  35. package/dist/endpoint-cluster.d.ts +95 -0
  36. package/dist/endpoint-cluster.d.ts.map +1 -0
  37. package/dist/endpoint-cluster.js +194 -0
  38. package/dist/endpoint-cluster.js.map +1 -0
  39. package/dist/endpoint-contract-store.d.ts +90 -0
  40. package/dist/endpoint-contract-store.d.ts.map +1 -0
  41. package/dist/endpoint-contract-store.js +348 -0
  42. package/dist/endpoint-contract-store.js.map +1 -0
  43. package/dist/endpoint-envelope.d.ts +165 -0
  44. package/dist/endpoint-envelope.d.ts.map +1 -0
  45. package/dist/endpoint-envelope.js +346 -0
  46. package/dist/endpoint-envelope.js.map +1 -0
  47. package/dist/endpoint-grants.d.ts +123 -0
  48. package/dist/endpoint-grants.d.ts.map +1 -0
  49. package/dist/endpoint-grants.js +215 -0
  50. package/dist/endpoint-grants.js.map +1 -0
  51. package/dist/endpoint-guard.d.ts +222 -0
  52. package/dist/endpoint-guard.d.ts.map +1 -0
  53. package/dist/endpoint-guard.js +468 -0
  54. package/dist/endpoint-guard.js.map +1 -0
  55. package/dist/endpoint-handle.d.ts +176 -0
  56. package/dist/endpoint-handle.d.ts.map +1 -0
  57. package/dist/endpoint-handle.js +608 -0
  58. package/dist/endpoint-handle.js.map +1 -0
  59. package/dist/endpoint-journal.d.ts +225 -0
  60. package/dist/endpoint-journal.d.ts.map +1 -0
  61. package/dist/endpoint-journal.js +431 -0
  62. package/dist/endpoint-journal.js.map +1 -0
  63. package/dist/endpoint-receipt.d.ts +225 -0
  64. package/dist/endpoint-receipt.d.ts.map +1 -0
  65. package/dist/endpoint-receipt.js +417 -0
  66. package/dist/endpoint-receipt.js.map +1 -0
  67. package/dist/endpoint-records.d.ts +243 -0
  68. package/dist/endpoint-records.d.ts.map +1 -0
  69. package/dist/endpoint-records.js +591 -0
  70. package/dist/endpoint-records.js.map +1 -0
  71. package/dist/endpoint-serve.d.ts +176 -0
  72. package/dist/endpoint-serve.d.ts.map +1 -0
  73. package/dist/endpoint-serve.js +446 -0
  74. package/dist/endpoint-serve.js.map +1 -0
  75. package/dist/endpoint-service.d.ts +518 -0
  76. package/dist/endpoint-service.d.ts.map +1 -0
  77. package/dist/endpoint-service.js +973 -0
  78. package/dist/endpoint-service.js.map +1 -0
  79. package/dist/endpoint-session.d.ts +398 -0
  80. package/dist/endpoint-session.d.ts.map +1 -0
  81. package/dist/endpoint-session.js +834 -0
  82. package/dist/endpoint-session.js.map +1 -0
  83. package/dist/endpoint-signing.d.ts +105 -0
  84. package/dist/endpoint-signing.d.ts.map +1 -0
  85. package/dist/endpoint-signing.js +190 -0
  86. package/dist/endpoint-signing.js.map +1 -0
  87. package/dist/endpoint-subjects.d.ts +222 -0
  88. package/dist/endpoint-subjects.d.ts.map +1 -0
  89. package/dist/endpoint-subjects.js +381 -0
  90. package/dist/endpoint-subjects.js.map +1 -0
  91. package/dist/endpoint-supervisor.d.ts +19 -0
  92. package/dist/endpoint-supervisor.d.ts.map +1 -0
  93. package/dist/endpoint-supervisor.js +12 -0
  94. package/dist/endpoint-supervisor.js.map +1 -0
  95. package/dist/endpoint-traits.d.ts +225 -0
  96. package/dist/endpoint-traits.d.ts.map +1 -0
  97. package/dist/endpoint-traits.js +469 -0
  98. package/dist/endpoint-traits.js.map +1 -0
  99. package/dist/endpoint-verbs.d.ts +277 -0
  100. package/dist/endpoint-verbs.d.ts.map +1 -0
  101. package/dist/endpoint-verbs.js +576 -0
  102. package/dist/endpoint-verbs.js.map +1 -0
  103. package/dist/endpoint-virtual.d.ts +308 -0
  104. package/dist/endpoint-virtual.d.ts.map +1 -0
  105. package/dist/endpoint-virtual.js +440 -0
  106. package/dist/endpoint-virtual.js.map +1 -0
  107. package/dist/endpoint-work.d.ts +304 -0
  108. package/dist/endpoint-work.d.ts.map +1 -0
  109. package/dist/endpoint-work.js +728 -0
  110. package/dist/endpoint-work.js.map +1 -0
  111. package/dist/endpoint.d.ts +66 -22
  112. package/dist/endpoint.d.ts.map +1 -1
  113. package/dist/endpoint.js +289 -89
  114. package/dist/endpoint.js.map +1 -1
  115. package/dist/evict.d.ts +95 -32
  116. package/dist/evict.d.ts.map +1 -1
  117. package/dist/evict.js +193 -3
  118. package/dist/evict.js.map +1 -1
  119. package/dist/index.d.ts +25 -0
  120. package/dist/index.d.ts.map +1 -1
  121. package/dist/index.js +25 -0
  122. package/dist/index.js.map +1 -1
  123. package/dist/lease.d.ts +4 -0
  124. package/dist/lease.d.ts.map +1 -1
  125. package/dist/lease.js.map +1 -1
  126. package/dist/members.d.ts +4 -4
  127. package/dist/members.d.ts.map +1 -1
  128. package/dist/members.js +12 -12
  129. package/dist/members.js.map +1 -1
  130. package/dist/provision.d.ts +70 -18
  131. package/dist/provision.d.ts.map +1 -1
  132. package/dist/provision.js +194 -33
  133. package/dist/provision.js.map +1 -1
  134. package/dist/safe-pattern.d.ts +33 -0
  135. package/dist/safe-pattern.d.ts.map +1 -0
  136. package/dist/safe-pattern.js +486 -0
  137. package/dist/safe-pattern.js.map +1 -0
  138. package/dist/schema-profile.d.ts +93 -0
  139. package/dist/schema-profile.d.ts.map +1 -0
  140. package/dist/schema-profile.js +284 -0
  141. package/dist/schema-profile.js.map +1 -0
  142. package/dist/streams.d.ts +13 -8
  143. package/dist/streams.d.ts.map +1 -1
  144. package/dist/streams.js +35 -18
  145. package/dist/streams.js.map +1 -1
  146. package/dist/subjects.d.ts +100 -40
  147. package/dist/subjects.d.ts.map +1 -1
  148. package/dist/subjects.js +136 -60
  149. package/dist/subjects.js.map +1 -1
  150. package/dist/types.d.ts +9 -0
  151. package/dist/types.d.ts.map +1 -1
  152. package/package.json +3 -1
@@ -0,0 +1,469 @@
1
+ /**
2
+ * v0.4 governed traits (SPEC §13.7 "Traits", §13.9 "Trait seam", §13.10) — the trait
3
+ * definition and attachment artifacts, their fail-closed verification, and the pre-effect
4
+ * enforcement gate the serve boundary runs for the two traits this revision governs,
5
+ * `ai.cotal.guarded` and `ai.cotal.priced`.
6
+ *
7
+ * The authority model has TWO distinct signatures (§13.7): a trait DEFINITION
8
+ * `{ urn, valueSchema, selector, breakingChanges, authority }` is content-addressed and
9
+ * signed by a key whose anchor's traits-scope covers the urn's reverse-DNS domain (the
10
+ * space-operator key carries `ai.cotal`; a third party registers under its own domain
11
+ * claim); every governed ATTACHMENT is SEPARATELY signed by the definition's NAMED
12
+ * authority over `{ endpoint, command, contractDigest, traitUrn, value }` — so a
13
+ * self-published descriptor cannot strip, forge, or downgrade a governed annotation
14
+ * (the annotation's authority is the attachment, bound to the cluster document's complete
15
+ * closure digest, never the descriptor's own bytes). Removal or downgrade is an authorized
16
+ * contract revision, enforced at the trusted registration write (registerServiceInstance's
17
+ * governed-continuity seam) against the registry's prior spec, so a surviving command cannot
18
+ * drop a governed trait.
19
+ *
20
+ * Core owns exactly the fail-closed verification interfaces (§13.9 trait seam): the guard
21
+ * call and priced-proof hooks are SEAMS — policy engines, token formats, and payment rails
22
+ * are extensions behind them, and the test implementations live in smokes, never here.
23
+ * Non-governed traits are unsigned vocabulary: declared in the cluster document, carried
24
+ * in describe, never gated here.
25
+ */
26
+ import { canonicalJson, contractDigest, isContractDigest } from "./canonical.js";
27
+ import { EpEnvelopeError } from "./endpoint-envelope.js";
28
+ import { ContractInvalidError, compileContract } from "./schema-profile.js";
29
+ import { verifyClusterManifest, isReverseDnsUrn, TRAIT_GUARDED, TRAIT_PRICED, GOVERNED_TRAIT_URNS } from "./endpoint-cluster.js";
30
+ import { runGuardGate } from "./endpoint-guard.js";
31
+ import { assertServeGrantAuthorized } from "./endpoint-service.js";
32
+ import { resolveAnchorForUse, verifyArtifactSignature, assertAnchorScopeCovers, } from "./endpoint-signing.js";
33
+ // The trait vocabulary constants (TRAIT_GUARDED / TRAIT_PRICED / GOVERNED_TRAIT_URNS) are
34
+ // defined in endpoint-cluster.ts, the layer both this module and the trusted registrar depend
35
+ // on, so the registrar pins the canonical governed set structurally without an import cycle
36
+ // (this module imports endpoint-service for the serve-grant seam). Re-exported here: the trait
37
+ // vocabulary remains part of this module's public surface.
38
+ export { TRAIT_GUARDED, TRAIT_PRICED, GOVERNED_TRAIT_URNS };
39
+ /** What a trait definition may attach to (§13.7). */
40
+ export const TRAIT_SELECTORS = Object.freeze(["cluster", "command", "attribute", "event"]);
41
+ const isRec = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
42
+ function deepFreeze(v) {
43
+ if (v !== null && typeof v === "object") {
44
+ for (const child of Object.values(v))
45
+ deepFreeze(child);
46
+ Object.freeze(v);
47
+ }
48
+ return v;
49
+ }
50
+ // Provenance brands (the compiled-contract / serve-grant pattern): the consuming seams check
51
+ // the brand, never structure, so a hand-built artifact that skipped verification can never
52
+ // enter an enforcement path.
53
+ const VERIFIED_DEFINITIONS = new WeakSet();
54
+ const VERIFIED_ATTACHMENTS = new WeakSet();
55
+ function invalid(what) {
56
+ throw new ContractInvalidError(`trait artifact does not validate: ${what}`);
57
+ }
58
+ /** Deep-copy a received artifact into a PRIVATE, deep-frozen snapshot BEFORE any await: the
59
+ * parse, the signature, the value-schema validation, and the brand must all attest the SAME
60
+ * bytes. A parsed artifact that aliases caller-reachable objects (`att.value` ← `raw.value`)
61
+ * can otherwise be mutated DURING the awaited anchor/schema reads AFTER the signature verified
62
+ * — branding a value nobody signed (finding: signed "warden", branded "evil").
63
+ *
64
+ * The snapshot is built through the STRICT RFC 8785 / I-JSON canonical path
65
+ * ({@link canonicalJson}), NOT `JSON.stringify`: `JSON.stringify` is a LENIENT projection that
66
+ * silently DROPS `undefined`/function/symbol object properties and coerces non-finite numbers
67
+ * to `null`, so snapshotting through it would verify the signature over a NORMALIZED artifact
68
+ * rather than the exact received bytes — the same D28 field-dropping class the 2c6d071 fold
69
+ * closed for nested `{keyId}` (finding: an unsigned `value.unsignedExtra: undefined` that
70
+ * refuses against the exact raw would ride once `JSON.stringify` drops it). `canonicalJson`
71
+ * THROWS on any non-interchangeable value (undefined anywhere, non-finite number, lone
72
+ * surrogate), so a non-I-JSON artifact REFUSES here instead of being normalized; and the
73
+ * snapshot's canonical form is byte-identical to what {@link verifyArtifactSignature} checks. */
74
+ function snapshotArtifact(raw, what) {
75
+ let copy;
76
+ try {
77
+ copy = JSON.parse(canonicalJson(raw));
78
+ }
79
+ catch (e) {
80
+ invalid(`${what} is not strict interchangeable JSON (${e?.message ?? String(e)}); a signed artifact must canonicalize exactly, never through a value-dropping projection (SPEC 13.10 D28)`);
81
+ }
82
+ if (!isRec(copy))
83
+ invalid(`${what} is not an object`);
84
+ return deepFreeze(copy);
85
+ }
86
+ /** A closed `{ keyId: <non-empty string> }` object, nothing else (§13.10, D28): the nested
87
+ * signer/authority shapes are part of the signed artifact, so an UNKNOWN nested field must
88
+ * refuse — otherwise it would ride UNSIGNED under a field-dropping projection and the recomputed
89
+ * signature would still verify over the clean version. */
90
+ function assertClosedKeyId(v, what) {
91
+ if (!isRec(v) || typeof v.keyId !== "string" || v.keyId === "")
92
+ invalid(`${what} is not { keyId } (a non-empty string)`);
93
+ const keys = Object.keys(v);
94
+ if (keys.length !== 1 || keys[0] !== "keyId")
95
+ invalid(`${what} carries fields other than keyId (${keys.sort().join(",")}); a nested object is a CLOSED shape so no unsigned field can ride under it (SPEC 13.10 D28)`);
96
+ return { keyId: v.keyId };
97
+ }
98
+ function parseTraitDefinitionShape(raw) {
99
+ const o = isRec(raw) ? raw : invalid("definition is not an object");
100
+ if (o.v !== 1)
101
+ invalid(`definition v ${JSON.stringify(o.v)} is not 1`);
102
+ if (typeof o.urn !== "string" || !isReverseDnsUrn(o.urn))
103
+ invalid(`definition urn ${JSON.stringify(o.urn)} is not a reverse-DNS trait URN`);
104
+ if (typeof o.valueSchema !== "string" || !isContractDigest(o.valueSchema))
105
+ invalid("definition valueSchema is not a sha256 closure digest");
106
+ if (!Array.isArray(o.selector) || o.selector.length === 0)
107
+ invalid("definition selector must be a non-empty array");
108
+ const seen = new Set();
109
+ for (const s of o.selector) {
110
+ if (typeof s !== "string" || !TRAIT_SELECTORS.includes(s))
111
+ invalid(`definition selector entry ${JSON.stringify(s)} is not one of ${TRAIT_SELECTORS.join("|")}`);
112
+ if (seen.has(s))
113
+ invalid(`definition selector lists "${s}" twice`);
114
+ seen.add(s);
115
+ }
116
+ if (typeof o.breakingChanges !== "boolean")
117
+ invalid("definition breakingChanges is not a boolean");
118
+ const authority = assertClosedKeyId(o.authority, "definition authority");
119
+ const signer = assertClosedKeyId(o.signer, "definition signer");
120
+ if (typeof o.sig !== "string")
121
+ invalid("definition sig is absent");
122
+ const keys = Object.keys(o).sort().join(",");
123
+ if (keys !== "authority,breakingChanges,selector,sig,signer,urn,v,valueSchema")
124
+ invalid(`definition carries unknown/missing fields (${keys}); the artifact is a closed discriminated schema (SPEC 13.10)`);
125
+ return {
126
+ v: 1, urn: o.urn, valueSchema: o.valueSchema, selector: [...o.selector],
127
+ breakingChanges: o.breakingChanges, authority, signer, sig: o.sig,
128
+ };
129
+ }
130
+ /**
131
+ * Verify a trait DEFINITION (§13.7/§13.10), fail closed: shape (closed schema), the signer
132
+ * resolved FRESH in the anchor registry (role `traits`, window at verification time — a
133
+ * definition is timeless content, its authority must be live), the signer's traits-scope
134
+ * covering the urn's reverse-DNS domain (this is what makes `ai.cotal.*` operator-only and
135
+ * a third-party urn its registered owner's), and the D28 signature. Returns the frozen,
136
+ * provenance-branded definition; every attachment verifier REQUIRES the brand.
137
+ */
138
+ export async function verifyTraitDefinition(raw, opts) {
139
+ // Snapshot FIRST (before the anchor await): the parse, the signature, and the returned
140
+ // artifact all attest one immutable copy — a caller mutating `raw` mid-verification races
141
+ // nothing (§13.10 D28: the verified bytes ARE the branded bytes).
142
+ const artifact = snapshotArtifact(raw, "trait definition");
143
+ const def = parseTraitDefinitionShape(artifact); // closed schema incl. closed nested {keyId}
144
+ const anchor = await resolveAnchorForUse(opts.resolveAnchor, { keyId: def.signer.keyId, role: "traits", at: opts.now ?? Date.now() });
145
+ assertAnchorScopeCovers(anchor, "traits", def.urn, "trait definition urn");
146
+ // §13.10 D28: verify over the EXACT received artifact as snapshot at entry (minus sig),
147
+ // never a field-dropping reconstruction — the closed nested-shape checks above already
148
+ // guarantee the snapshot and the parsed projection agree, so an unsigned field can neither
149
+ // survive nor change the verified bytes.
150
+ verifyArtifactSignature(artifact, anchor);
151
+ const frozen = deepFreeze(def);
152
+ VERIFIED_DEFINITIONS.add(frozen);
153
+ return frozen;
154
+ }
155
+ /** True iff this exact object came out of {@link verifyTraitDefinition}. */
156
+ export function isVerifiedTraitDefinition(def) {
157
+ return typeof def === "object" && def !== null && VERIFIED_DEFINITIONS.has(def);
158
+ }
159
+ /** The definition's content address (§13.7): the artifact digest over its FULL RFC 8785
160
+ * canonical form, signature included — the value a by-digest reference names. */
161
+ export function traitDefinitionDigest(def) {
162
+ return contractDigest(def);
163
+ }
164
+ function parseTraitAttachmentShape(raw) {
165
+ const o = isRec(raw) ? raw : invalid("attachment is not an object");
166
+ if (o.v !== 1)
167
+ invalid(`attachment v ${JSON.stringify(o.v)} is not 1`);
168
+ for (const f of ["space", "endpoint", "command", "traitUrn"])
169
+ if (typeof o[f] !== "string" || o[f] === "")
170
+ invalid(`attachment ${f} is not a non-empty string`);
171
+ if (typeof o.contractDigest !== "string" || !isContractDigest(o.contractDigest))
172
+ invalid("attachment contractDigest is not a sha256 closure digest");
173
+ if (!("value" in o) || o.value === undefined)
174
+ invalid("attachment value is absent (validate against the definition's value schema, even when void)");
175
+ const signer = assertClosedKeyId(o.signer, "attachment signer");
176
+ if (typeof o.ts !== "number" || !Number.isSafeInteger(o.ts) || o.ts <= 0)
177
+ invalid("attachment ts is not a positive integer timestamp");
178
+ if (typeof o.sig !== "string")
179
+ invalid("attachment sig is absent");
180
+ const keys = Object.keys(o).sort().join(",");
181
+ if (keys !== "command,contractDigest,endpoint,sig,signer,space,traitUrn,ts,v,value")
182
+ invalid(`attachment carries unknown/missing fields (${keys}); the artifact is a closed discriminated schema (SPEC 13.10)`);
183
+ return {
184
+ v: 1, space: o.space, endpoint: o.endpoint, command: o.command,
185
+ contractDigest: o.contractDigest, traitUrn: o.traitUrn, value: o.value,
186
+ signer, ts: o.ts, sig: o.sig,
187
+ };
188
+ }
189
+ /**
190
+ * Verify one governed trait ATTACHMENT against its verified definition and the EXPECTED
191
+ * binding coordinates (§13.7/§13.10), fail closed on every §13-acceptance adversarial class:
192
+ * - substitute: `space`/`endpoint`/`command` must equal the expected target — an attachment
193
+ * signed for one command can never gate (or satisfy) another;
194
+ * - stale digest: `contractDigest` must equal the CURRENT declaring cluster's closure
195
+ * digest — a prior revision's attachment is revision-bound evidence, never carried over;
196
+ * - forge: the signer MUST BE the definition's NAMED authority, resolved fresh (role
197
+ * `traits`, window checked at VERIFICATION time — never the signer-asserted `ts`, which is
198
+ * self-attested and would let an expired predecessor key backdate or a not-yet-valid
199
+ * successor future-date past rotation, §13.10 — revocation immediate), its traits-scope
200
+ * must cover the urn, and the D28 signature must verify over the exact received bytes;
201
+ * - downgrade: within a digest the value is signature-bound; a value the schema rejects
202
+ * fails here, and cross-revision weakening is caught at the trusted registration write
203
+ * (registerServiceInstance's governed-continuity seam), not from a caller-supplied prior;
204
+ * - selector: the definition must admit a `command` target.
205
+ * The `value` is validated against the definition's `valueSchema` bundle, read and compiled
206
+ * through the SAME digest-verified path serve authorization uses.
207
+ */
208
+ export async function verifyTraitAttachment(raw, opts) {
209
+ if (!isVerifiedTraitDefinition(opts.definition))
210
+ throw new EpEnvelopeError("failed-precondition", "the supplied trait definition is not a verified artifact (verifyTraitDefinition); an unverified definition carries no attachment authority (SPEC 13.7)");
211
+ // Snapshot FIRST (before any await): `att.value` below references the snapshot, so a caller
212
+ // mutating `raw.value` during the awaited anchor/schema reads cannot change what gets
213
+ // signature-verified, schema-validated, or branded (finding: signed "warden" branded as
214
+ // "evil" via the alias). The verified bytes ARE the branded bytes (§13.10 D28).
215
+ const artifact = snapshotArtifact(raw, "trait attachment");
216
+ const att = parseTraitAttachmentShape(artifact);
217
+ const def = opts.definition;
218
+ if (att.traitUrn !== def.urn)
219
+ throw new EpEnvelopeError("failed-precondition", `attachment traitUrn "${att.traitUrn}" is not the definition's "${def.urn}"; an attachment verifies only against its own trait's definition (SPEC 13.7)`);
220
+ if (!def.selector.includes("command"))
221
+ throw new EpEnvelopeError("failed-precondition", `trait "${def.urn}" selector [${def.selector.join(", ")}] does not admit a command target; an attachment outside its definition's selector never verifies (SPEC 13.7)`);
222
+ if (att.space !== opts.expect.space)
223
+ throw new EpEnvelopeError("failed-precondition", `attachment space "${att.space}" is not "${opts.expect.space}"; trust roots never merge across spaces (SPEC 13.10)`);
224
+ if (att.endpoint !== opts.expect.endpoint || att.command !== opts.expect.command)
225
+ throw new EpEnvelopeError("failed-precondition", `attachment is bound to ${att.endpoint}/${att.command}, not ${opts.expect.endpoint}/${opts.expect.command}; a substituted attachment never verifies (SPEC 13.7)`);
226
+ if (att.contractDigest !== opts.expect.contractDigest)
227
+ throw new EpEnvelopeError("failed-precondition", `attachment is bound to contractDigest ${att.contractDigest}, not the current declaring closure ${opts.expect.contractDigest}; a stale revision's attachment is evidence for ITS revision only (SPEC 13.10: replaced only by an authorized contract revision)`);
228
+ if (att.signer.keyId !== def.authority.keyId)
229
+ throw new EpEnvelopeError("permission-denied", `attachment is signed by ${att.signer.keyId}, not the definition's named authority ${def.authority.keyId}; attachment authority is the definition's to name (SPEC 13.7)`);
230
+ const anchor = await resolveAnchorForUse(opts.resolveAnchor, { keyId: att.signer.keyId, role: "traits", at: opts.now ?? Date.now() });
231
+ assertAnchorScopeCovers(anchor, "traits", att.traitUrn, "trait attachment urn");
232
+ // §13.10 D28: verify over the EXACT received artifact as snapshot at entry (minus sig),
233
+ // never a reconstruction — and never the caller's still-mutable `raw`.
234
+ verifyArtifactSignature(artifact, anchor);
235
+ // Value-schema validation through the digest-verified two-step read (§13.7): manifest at the
236
+ // closure digest, root at manifest.root, profile-compiled; the compiled closure digest must
237
+ // round-trip to the definition's valueSchema, so no unverified byte enters the validator.
238
+ const readSchema = async (digest, what) => {
239
+ let bytes;
240
+ try {
241
+ bytes = await opts.readArtifact(digest);
242
+ }
243
+ catch (e) {
244
+ throw new EpEnvelopeError("unavailable", `the contract-store read seam failed for the ${what} ${digest}; attachment verification fails closed (SPEC 13.7): ${e?.message ?? String(e)}`);
245
+ }
246
+ if (bytes === undefined)
247
+ throw new EpEnvelopeError("failed-precondition", `the ${what} ${digest} is not readable from the contract store; an unverifiable value schema never verifies an attachment (SPEC 13.7)`);
248
+ return bytes;
249
+ };
250
+ const manifestRaw = await readSchema(def.valueSchema, "trait value-schema manifest");
251
+ const { root } = verifyClusterManifest(def.valueSchema, manifestRaw);
252
+ const rootRaw = await readSchema(root, "trait value-schema document");
253
+ const compiled = compileContract({ root: rootRaw });
254
+ if (compiled.closureDigest !== def.valueSchema)
255
+ throw new EpEnvelopeError("internal", `the compiled value schema's closure digest ${compiled.closureDigest} does not round-trip to the definition's ${def.valueSchema}; a store/manifest inconsistency never verifies (SPEC 13.7)`);
256
+ if (!compiled.validate(att.value)) {
257
+ const first = compiled.validate.errors?.[0];
258
+ throw new EpEnvelopeError("failed-precondition", `attachment value does not validate against trait "${def.urn}"'s value schema${first ? `: ${first.instancePath || "/"} ${first.message ?? ""}` : ""} (SPEC 13.7)`);
259
+ }
260
+ const frozen = deepFreeze(att);
261
+ VERIFIED_ATTACHMENTS.add(frozen);
262
+ return frozen;
263
+ }
264
+ /** True iff this exact object came out of {@link verifyTraitAttachment}. */
265
+ export function isVerifiedTraitAttachment(att) {
266
+ return typeof att === "object" && att !== null && VERIFIED_ATTACHMENTS.has(att);
267
+ }
268
+ const VERIFIED_GOVERNED = new WeakMap();
269
+ /**
270
+ * Verify a serve grant's WHOLE governed surface (§13.7, fail closed, both strip directions):
271
+ * every granted command's DECLARED governed traits must each have exactly one verified
272
+ * attachment bound to that command's declaring closure digest (a declared-but-unattached
273
+ * governed trait is a strip or an unverifiable annotation — refuse before effect), and every
274
+ * supplied attachment must land on a command that DECLARES its trait (an attached-but-
275
+ * undeclared governed trait means the self-published descriptor dropped an authority's
276
+ * annotation — equally a strip). Duplicates, unknown commands, non-governed urns, and
277
+ * missing definitions all refuse. Returns the branded surface, bound to exactly this grant's
278
+ * identity coordinates; {@link assertGovernedSurfaceFor} is the serve-side check.
279
+ *
280
+ * This verifies the CURRENT surface's declaration<->attachment coherence (both strip directions
281
+ * WITHIN a revision). Cross-REVISION governed-continuity (a re-registration may not strip an
282
+ * authority-imposed trait from a surviving command, §13.7) is enforced at the TRUSTED registration
283
+ * write (registerServiceInstance's governed-continuity seam) against the registry's prior
284
+ * spec — NOT here, and NOT from a caller-supplied prior surface, which the owner could forge by
285
+ * claiming "first governance".
286
+ */
287
+ export async function verifyGovernedSurface(args) {
288
+ assertServeGrantAuthorized(args.serve);
289
+ const defs = new Map();
290
+ for (const def of args.definitions) {
291
+ if (!isVerifiedTraitDefinition(def))
292
+ throw new EpEnvelopeError("failed-precondition", "a supplied trait definition is not a verified artifact (verifyTraitDefinition); fail closed (SPEC 13.7)");
293
+ if (!GOVERNED_TRAIT_URNS.includes(def.urn))
294
+ throw new EpEnvelopeError("failed-precondition", `definition "${def.urn}" is not a governed trait; this revision governs exactly ${GOVERNED_TRAIT_URNS.join(" and ")} (SPEC 13.7), and non-governed traits are unsigned vocabulary with no attachment surface`);
295
+ if (defs.has(def.urn))
296
+ throw new EpEnvelopeError("failed-precondition", `two definitions supplied for "${def.urn}"; a governed trait has one definition per verification (SPEC 13.7)`);
297
+ defs.set(def.urn, def);
298
+ }
299
+ // NULL-PROTOTYPE dictionaries at BOTH levels: a command is caller-named text under the
300
+ // `[a-z0-9-]{1,32}` grammar, and "constructor" is a valid token — on a plain `{}` it would
301
+ // resolve the inherited `Object.prototype.constructor` (truthy!), so the attachment would be
302
+ // written onto the GLOBAL `Object` function instead of an own frozen entry: coverage would
303
+ // pass via inherited state, another surface could observe/reuse it, and deleting the global
304
+ // property post-brand would un-govern the command (finding). `Object.create(null)` has no
305
+ // prototype, so every lookup is an own-property read.
306
+ const commands = Object.create(null);
307
+ for (const raw of args.attachments) {
308
+ // Route on minimally-read fields; full verification below binds them all over the signature.
309
+ const o = isRec(raw) ? raw : invalid("attachment is not an object");
310
+ const command = typeof o.command === "string" ? o.command : invalid("attachment command is not a string");
311
+ const urn = typeof o.traitUrn === "string" ? o.traitUrn : invalid("attachment traitUrn is not a string");
312
+ const decl = args.serve.surface[command];
313
+ if (decl === undefined)
314
+ throw new EpEnvelopeError("failed-precondition", `attachment names command "${command}", which is not on the granted registered surface (SPEC 13.7)`);
315
+ if (!GOVERNED_TRAIT_URNS.includes(urn))
316
+ throw new EpEnvelopeError("failed-precondition", `attachment names "${urn}", not a governed trait; this revision governs exactly ${GOVERNED_TRAIT_URNS.join(" and ")} (SPEC 13.7)`);
317
+ if (!decl.traits.includes(urn))
318
+ throw new EpEnvelopeError("failed-precondition", `command "${command}" carries a verified-authority attachment for "${urn}" that its registered declaration does not declare; a self-published descriptor cannot strip a governed annotation (SPEC 13.7)`);
319
+ const def = defs.get(urn);
320
+ if (def === undefined)
321
+ throw new EpEnvelopeError("failed-precondition", `no verified definition supplied for governed trait "${urn}"; an attachment without its definition is unverifiable and refuses (SPEC 13.7)`);
322
+ const att = await verifyTraitAttachment(raw, {
323
+ definition: def,
324
+ expect: { space: args.serve.space, endpoint: args.serve.endpoint, command, contractDigest: decl.clusterDigest },
325
+ resolveAnchor: args.resolveAnchor,
326
+ readArtifact: args.readArtifact,
327
+ ...(args.now !== undefined ? { now: args.now } : {}),
328
+ });
329
+ const per = commands[command] ?? (commands[command] = Object.create(null));
330
+ if (per[urn] !== undefined)
331
+ throw new EpEnvelopeError("failed-precondition", `two attachments supplied for ${command}/${urn}; the governed surface is one attachment per (command, trait) (SPEC 13.7)`);
332
+ per[urn] = att;
333
+ }
334
+ for (const cmd of args.serve.commands) {
335
+ for (const urn of args.serve.surface[cmd].traits) {
336
+ if (!GOVERNED_TRAIT_URNS.includes(urn))
337
+ continue; // vocabulary: unsigned, ungated
338
+ if (commands[cmd]?.[urn] === undefined)
339
+ throw new EpEnvelopeError("failed-precondition", `command "${cmd}" declares governed trait "${urn}" with no verified attachment for the current contract digest; missing, unverifiable, or stale governed attachments refuse before effect (SPEC 13.7)`);
340
+ }
341
+ }
342
+ // Deep-frozen: the attachments are already frozen; this locks the nested records too, so the
343
+ // brand below attests an object no caller can mutate after verification (finding: a frozen Map
344
+ // is still mutable; a frozen plain record is not).
345
+ const surface = deepFreeze({ commands });
346
+ VERIFIED_GOVERNED.set(surface, {
347
+ space: args.serve.space, endpoint: args.serve.endpoint, instanceId: args.serve.instanceId,
348
+ epoch: args.serve.epoch, registrationRevision: args.serve.registrationRevision,
349
+ grantCommands: new Set(args.serve.commands),
350
+ });
351
+ return surface;
352
+ }
353
+ /** Refuse a governed surface that {@link verifyGovernedSurface} did not produce FOR THIS
354
+ * grant: brand first (structure carries no verification), then the identity bond — a
355
+ * surface verified for another instance, epoch, or registration revision never gates this
356
+ * one (a re-registration re-verifies; the fresh grant demands a fresh surface). */
357
+ export function assertGovernedSurfaceFor(surface, serve) {
358
+ const bond = VERIFIED_GOVERNED.get(surface);
359
+ if (bond === undefined)
360
+ throw new Error("the traits surface is not a verified governed surface (verifyGovernedSurface); a structural value carries no verification (SPEC 13.7)");
361
+ if (bond.space !== serve.space || bond.endpoint !== serve.endpoint || bond.instanceId !== serve.instanceId
362
+ || bond.epoch !== serve.epoch || bond.registrationRevision !== serve.registrationRevision)
363
+ throw new Error(`the governed surface was verified for ${bond.endpoint}/${bond.instanceId}@${bond.epoch} rev ${bond.registrationRevision}, not this grant (${serve.endpoint}/${serve.instanceId}@${serve.epoch} rev ${serve.registrationRevision}); a re-registration demands a fresh verification (SPEC 13.7)`);
364
+ }
365
+ // §13.7 downgrade/removal continuity — "removal or downgrade is an AUTHORIZED contract
366
+ // revision" — is enforced at the TRUSTED registration write (registerServiceInstance's
367
+ // governed-continuity seam), against the registry's own prior spec. It is deliberately NOT a
368
+ // serve-side check over two caller-supplied branded surfaces: the owner controls the descriptor,
369
+ // so a caller-supplied "previous" (or a claimed first-governance) is forgeable, whereas the prior
370
+ // registered spec is not. See registerServiceInstance.
371
+ // ---- the pre-effect enforcement gate (§13.9 trait seam) ------------------------------------------
372
+ /** The reference guard/proof seam deadline (§13.8: reference default call deadline 15s;
373
+ * overridable, never removable) when the request carries no tighter budget. A governed gate
374
+ * MUST be bounded — a never-settling seam is timeout→deny, never a hung request. */
375
+ export const REFERENCE_GOVERNED_SEAM_DEADLINE_MS = 15_000;
376
+ /** Race a fail-closed seam against its deadline: a never-settling guard/proof becomes DENY
377
+ * (`permission-denied`) at the bound, so it can never hold the request or `serveEndpoint.stop()`
378
+ * open (§13.6: timeout or unreachable is deny). The seam's own throw is re-raised for the
379
+ * caller to map; only the timeout is synthesized here. */
380
+ async function raceSeam(work, ms, what) {
381
+ let timer;
382
+ try {
383
+ return await Promise.race([
384
+ Promise.resolve(work),
385
+ new Promise((_, reject) => {
386
+ timer = setTimeout(() => reject(new EpEnvelopeError("permission-denied", `${what} did not answer within the ${ms}ms bound; timeout is deny (SPEC 13.6: fail closed, never a hung request)`)), ms);
387
+ }),
388
+ ]);
389
+ }
390
+ finally {
391
+ if (timer !== undefined)
392
+ clearTimeout(timer);
393
+ }
394
+ }
395
+ /**
396
+ * The fail-closed pre-effect gate (§13.7/§13.9): run once per accepted request, AFTER args
397
+ * validation, target currency, and mode authorization, immediately BEFORE the handler — for
398
+ * calls and casts alike (casts have effects too). Guard FIRST, then priced (deliberate: a
399
+ * guard deny must never burn a one-use payment proof). Every anomalous answer refuses:
400
+ * - guarded: THE gate is {@link runGuardGate} — the guard's raw answer is parsed CLOSED and
401
+ * every obligation is VERIFIED (D28 signature, anchor role/scope, validity window,
402
+ * space + request binding) before it can reach a handler; wiring absent, seam throw,
403
+ * timeout, garbled answer, or an unverifiable obligation = DENY (`permission-denied`);
404
+ * `deny` = `permission-denied`; `hold` = `failed-precondition` on THIS rail (hold converts
405
+ * an ACTION to waiting on a guard-owned checkpoint, §13.6 — the ephemeral rail cannot
406
+ * wait; the action composite's own gate, `gateGoalExecution`, routes hold);
407
+ * - priced: absent `auth` slot, seam absent, seam throw, non-boolean or false answer =
408
+ * `permission-denied`; a proof is verified, never assumed.
409
+ * Both gates are BOUNDED by `deadlineMs` (the request budget, or the §13.8 reference
410
+ * default): a never-settling extension becomes deny at the bound, never a hung request.
411
+ * Returns the guard's VERIFIED obligations for the handler context. Receipt emission for
412
+ * priced commands is the §13.10 receipts slice (D9), not gated here.
413
+ */
414
+ export async function assertGovernedPreEffect(args) {
415
+ const governed = args.enforcement.governed.commands[args.command];
416
+ if (governed === undefined)
417
+ return {};
418
+ const seamMs = args.deadlineMs !== undefined && Number.isSafeInteger(args.deadlineMs) && args.deadlineMs > 0
419
+ ? args.deadlineMs : REFERENCE_GOVERNED_SEAM_DEADLINE_MS;
420
+ let obligations;
421
+ const guarded = governed[TRAIT_GUARDED];
422
+ if (guarded !== undefined) {
423
+ const guard = args.enforcement.guard;
424
+ if (guard === undefined)
425
+ throw new EpEnvelopeError("permission-denied", `command "${args.command}" is guarded and this instance wired no guard seam; an unreachable guard is deny (SPEC 13.6: fail closed)`);
426
+ // The VERIFIED trait value names the guard endpoint; an unroutable guard is deny.
427
+ const guardEndpoint = isRec(guarded.value) ? guarded.value.guard : undefined;
428
+ if (typeof guardEndpoint !== "string" || guardEndpoint.length === 0)
429
+ throw new EpEnvelopeError("permission-denied", `command "${args.command}" carries a guarded trait whose value names no guard endpoint; an unroutable guard is deny (SPEC 13.6: fail closed)`);
430
+ // ONE gate: runGuardGate owns the call, the closed parse, and the D28 obligation
431
+ // verification. It throws permission-denied on deny/timeout/garble/unverifiable
432
+ // obligation (fail closed); its only returns are a VERIFIED allow or a VERIFIED hold.
433
+ const verdict = await runGuardGate({
434
+ guardEndpoint,
435
+ request: { endpoint: args.endpoint, command: args.command, id: args.requestId, caller: args.caller },
436
+ callGuard: guard.call,
437
+ deadlineMs: seamMs,
438
+ now: guard.now !== undefined ? guard.now() : Date.now(),
439
+ space: args.space,
440
+ resolveAnchor: guard.resolveAnchor,
441
+ });
442
+ if (verdict.decision === "hold")
443
+ throw new EpEnvelopeError("failed-precondition", `the guard held "${args.command}": hold converts an ACTION to waiting on a guard-owned checkpoint (SPEC 13.6), and the ephemeral rail cannot wait; submit the work as an action, whose gate (gateGoalExecution) routes hold; refusing pre-effect`);
444
+ obligations = verdict.obligations;
445
+ }
446
+ const priced = governed[TRAIT_PRICED];
447
+ if (priced !== undefined) {
448
+ if (args.auth === undefined)
449
+ throw new EpEnvelopeError("permission-denied", `command "${args.command}" is priced and the request carries no auth-slot payment proof; a priced command verifies an independently verifiable proof before effect, never a bare assertion (SPEC 13.10)`);
450
+ const verify = args.enforcement.verifyPaymentProof;
451
+ if (verify === undefined)
452
+ throw new EpEnvelopeError("permission-denied", `command "${args.command}" is priced and this instance wired no proof verifier; an unverifiable proof never effects (SPEC 13.10: fail closed)`);
453
+ let ok;
454
+ try {
455
+ ok = await raceSeam(verify({ endpoint: args.endpoint, command: args.command, caller: args.caller, requestId: args.requestId, proof: args.auth, value: priced.value }), seamMs, `the payment-proof verifier for "${args.command}"`);
456
+ }
457
+ catch (e) {
458
+ if (e instanceof EpEnvelopeError)
459
+ throw e; // the bound's deny, already fail-closed
460
+ throw new EpEnvelopeError("permission-denied", `the payment-proof verifier failed (${e?.message ?? String(e)}); verification fails closed (SPEC 13.10)`);
461
+ }
462
+ if (typeof ok !== "boolean")
463
+ throw new EpEnvelopeError("permission-denied", "the payment-proof verifier returned a non-boolean; a malformed answer fails closed (SPEC 13.10)");
464
+ if (!ok)
465
+ throw new EpEnvelopeError("permission-denied", `the payment proof did not verify for "${args.command}" (SPEC 13.10: valid proof in the slot or reject)`);
466
+ }
467
+ return obligations !== undefined ? { obligations } : {};
468
+ }
469
+ //# sourceMappingURL=endpoint-traits.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-traits.js","sourceRoot":"","sources":["../src/endpoint-traits.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC5E,O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