@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,346 @@
1
+ import { rawDigest, isContractDigest, isWellFormedUnicode } from "./canonical.js";
2
+ import { assertCommandToken, assertIdToken, assertLifecycleToken, endpointToken } from "./endpoint-subjects.js";
3
+ import { SCHEMA_PROFILE } from "./schema-profile.js";
4
+ /** The envelope schema version — independent of the wire `protocolVersion`; starts at its own
5
+ * v1 inside the v0.4 revision. Other values are rejected (`unsupported-version`). */
6
+ export const EP_ENVELOPE_V = 1;
7
+ // ---- structured errors (§13.3 error catalog) ------------------------------------------------
8
+ /** The §13.3 error catalog. Extensions add codes only under reverse-DNS; any code (catalog or
9
+ * extension) is one token of at most 64 bytes. */
10
+ export const EP_ERROR_CODES = Object.freeze([
11
+ "bad-request", "unsupported-version", "op-mismatch", "class-mismatch", "target-mismatch",
12
+ "sender-mismatch", "unauthenticated", "permission-denied", "not-found", "already-exists",
13
+ "conflict", "contract-mismatch", "contract-invalid", "failed-precondition",
14
+ "deadline-exceeded", "cancelled", "expired", "unavailable", "unimplemented",
15
+ "resource-exhausted", "internal",
16
+ ]);
17
+ const EP_ERROR_SET = new Set(EP_ERROR_CODES);
18
+ const LABEL = "[a-z0-9]([a-z0-9-]*[a-z0-9])?";
19
+ /** Reverse-DNS extension token: three or more DNS-shaped labels (`com.acme.throttled`). */
20
+ const EXTENSION_CODE = new RegExp(`^${LABEL}(\\.${LABEL}){2,}$`);
21
+ /** True iff `code` is a catalog token or a reverse-DNS extension token within the 64-byte bound. */
22
+ export function isEpErrorCode(code) {
23
+ if (typeof code !== "string" || Buffer.byteLength(code, "utf8") > 64)
24
+ return false;
25
+ return EP_ERROR_SET.has(code) || EXTENSION_CODE.test(code);
26
+ }
27
+ /** A consuming-boundary rejection: the catalog code plus a human message. Boundaries convert it
28
+ * to an `EndpointReply` error via {@link EpEnvelopeError.toEpError} (or, on reply-less planes,
29
+ * to the §13.4 decision/quarantine fact carrying the same code). */
30
+ export class EpEnvelopeError extends Error {
31
+ code;
32
+ details;
33
+ constructor(code, message, details) {
34
+ super(message);
35
+ this.code = code;
36
+ this.details = details;
37
+ this.name = "EpEnvelopeError";
38
+ }
39
+ toEpError() {
40
+ return { code: this.code, message: this.message, ...(this.details ? { details: this.details } : {}) };
41
+ }
42
+ }
43
+ function fail(code, message) {
44
+ throw new EpEnvelopeError(code, message);
45
+ }
46
+ // ---- signed-artifact binding (§13.3/§13.7) --------------------------------------------------
47
+ /** `authDigest`: `sha256:<hex>` over the UTF-8 bytes of the `auth` slot EXACTLY as carried. The
48
+ * slot is already a canonical signed artifact, so it is digested as bytes, never
49
+ * re-canonicalized; absent from the §13.4 fingerprint iff `auth` is absent. A malformed-UTF-16
50
+ * slot is refused (`bad-request`): a lone surrogate has no UTF-8 encoding, so its "digest"
51
+ * would be over a substituted value and two distinct slots could share one fingerprint. */
52
+ export function authDigest(auth) {
53
+ if (typeof auth !== "string" || !isWellFormedUnicode(auth))
54
+ throw new EpEnvelopeError("bad-request", "auth slot is not a well-formed Unicode string");
55
+ return rawDigest(auth);
56
+ }
57
+ // ---- consuming-boundary validators ----------------------------------------------------------
58
+ function asRecord(v, what) {
59
+ if (v === null || typeof v !== "object" || Array.isArray(v))
60
+ fail("bad-request", `${what} is not a JSON object`);
61
+ return v;
62
+ }
63
+ function asString(v, what) {
64
+ if (typeof v !== "string" || v.length === 0)
65
+ fail("bad-request", `${what} is not a non-empty string`);
66
+ return v;
67
+ }
68
+ /** Wire integers are I-JSON interoperable: non-negative safe integers (§13.7). */
69
+ function asWireInt(v, what) {
70
+ if (typeof v !== "number" || !Number.isSafeInteger(v) || v < 0)
71
+ fail("bad-request", `${what} is not a non-negative integer within the I-JSON range`);
72
+ return v;
73
+ }
74
+ /** Rewrap a grammar validator's plain throw as the catalog code the boundary owes. */
75
+ function grammar(fn) {
76
+ try {
77
+ return fn();
78
+ }
79
+ catch (e) {
80
+ fail("bad-request", e.message);
81
+ }
82
+ }
83
+ /** W3C `traceparent`: version, 32-hex trace-id, 16-hex parent-id, 2-hex flags. Version `00` is
84
+ * EXACTLY this 55-character form — no extension tail. A higher version may carry additional
85
+ * printable-ASCII fields after the flags (the W3C forward-compatibility rule), bounded to a
86
+ * finite profile size so nothing unbounded is retained for propagation. Version `ff` and
87
+ * all-zero ids are invalid per the spec. */
88
+ const TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-[0-9a-f]{2}(-[\x21-\x7e]+)?$/;
89
+ const MAX_TRACEPARENT_BYTES = 256;
90
+ const CORRELATION_BYTE_BOUNDS = { tracestate: 512, baggage: 8192 };
91
+ /** Correlation is validated, never trusted opaque (§13.3 "per W3C Trace Context"): these fields
92
+ * are PROPAGATED downstream (calls, events, facts, receipts), so an unvalidated value becomes
93
+ * header injection or amplification wherever they are re-emitted. `traceparent` is checked
94
+ * against the W3C grammar; `tracestate`/`baggage` stay content-opaque but are bounded to the
95
+ * W3C size limits and refused any control character (no CR/LF crosses the boundary). */
96
+ function pickCorrelation(v) {
97
+ if (v === undefined)
98
+ return undefined;
99
+ const o = asRecord(v, "correlation");
100
+ const out = {};
101
+ if (o.traceparent !== undefined) {
102
+ const tp = asString(o.traceparent, "correlation.traceparent");
103
+ if (Buffer.byteLength(tp, "utf8") > MAX_TRACEPARENT_BYTES)
104
+ fail("bad-request", `correlation.traceparent exceeds ${MAX_TRACEPARENT_BYTES} bytes`);
105
+ const m = TRACEPARENT.exec(tp);
106
+ if (!m || m[1] === "ff" || /^0+$/.test(m[2]) || /^0+$/.test(m[3]))
107
+ fail("bad-request", "correlation.traceparent is not a valid W3C Trace Context traceparent");
108
+ if (m[1] === "00" && m[4] !== undefined)
109
+ fail("bad-request", "correlation.traceparent version 00 is exactly 55 characters; it carries no extension fields");
110
+ out.traceparent = tp;
111
+ }
112
+ for (const k of ["tracestate", "baggage"]) {
113
+ if (o[k] === undefined)
114
+ continue;
115
+ const s = asString(o[k], `correlation.${k}`);
116
+ if (Buffer.byteLength(s, "utf8") > CORRELATION_BYTE_BOUNDS[k])
117
+ fail("bad-request", `correlation.${k} exceeds ${CORRELATION_BYTE_BOUNDS[k]} bytes`);
118
+ // eslint-disable-next-line no-control-regex
119
+ if (/[\x00-\x1f\x7f]/.test(s))
120
+ fail("bad-request", `correlation.${k} carries a control character`);
121
+ out[k] = s;
122
+ }
123
+ return out;
124
+ }
125
+ /** Validate the version discriminant first: any `v !== 1` is `unsupported-version`, before any
126
+ * other field is looked at, so version skew never masquerades as a shape error. */
127
+ function assertVersion(o, what) {
128
+ if (o.v !== EP_ENVELOPE_V)
129
+ fail("unsupported-version", `${what} envelope version ${JSON.stringify(o.v)} is not ${EP_ENVELOPE_V}`);
130
+ }
131
+ /** Shape-validate an incoming request envelope (the pre-subject half of the consuming boundary;
132
+ * {@link checkRequestSubjectAgreement} is the other half). Throws {@link EpEnvelopeError} with
133
+ * the exact catalog code; returns a picked copy with exactly the §13.3 fields. */
134
+ export function parseEndpointRequest(raw) {
135
+ const o = asRecord(raw, "request");
136
+ assertVersion(o, "request");
137
+ const id = grammar(() => assertIdToken(asString(o.id, "id"), "id"));
138
+ const op = asRecord(o.op, "op");
139
+ const endpoint = asString(op.endpoint, "op.endpoint");
140
+ grammar(() => endpointToken(endpoint));
141
+ const command = grammar(() => assertCommandToken(asString(op.command, "op.command")));
142
+ const digests = {};
143
+ for (const k of ["inputDigest", "outputDigest"]) {
144
+ const d = op[k];
145
+ if (d === undefined) {
146
+ if (command !== "describe")
147
+ fail("contract-mismatch", `op.${k} is required on every command except describe (a payload-free side pins the void schema digest)`);
148
+ continue;
149
+ }
150
+ if (typeof d !== "string" || !isContractDigest(d))
151
+ fail("bad-request", `op.${k} is not a sha256:<hex> digest`);
152
+ digests[k] = d;
153
+ }
154
+ const cls = o.class;
155
+ if (cls !== "ephemeral" && cls !== "journal")
156
+ fail("bad-request", `class ${JSON.stringify(cls)} is not "ephemeral" | "journal" (record is a state contract, never a request class)`);
157
+ if (typeof o.replyExpected !== "boolean")
158
+ fail("bad-request", "replyExpected is not a boolean");
159
+ const replyExpected = o.replyExpected;
160
+ if (cls === "journal" && replyExpected)
161
+ fail("bad-request", "a journal-class submission sets replyExpected: false; the decision is observed on the caller's decision subtree (SPEC 13.4)");
162
+ let deadlineMs;
163
+ if (o.deadlineMs !== undefined) {
164
+ deadlineMs = asWireInt(o.deadlineMs, "deadlineMs");
165
+ if (deadlineMs === 0)
166
+ fail("bad-request", "deadlineMs must be a positive budget, never zero");
167
+ }
168
+ else if (replyExpected || cls === "journal") {
169
+ fail("bad-request", `deadlineMs is required for ${replyExpected ? "a call" : "a journal-class submission (the decision deadline)"}`);
170
+ }
171
+ const goalId = o.goalId === undefined ? undefined : grammar(() => assertIdToken(asString(o.goalId, "goalId"), "goalId"));
172
+ let target;
173
+ if (o.target !== undefined) {
174
+ const t = asRecord(o.target, "target");
175
+ target = {
176
+ owner: asString(t.owner, "target.owner"),
177
+ actor: asString(t.actor, "target.actor"),
178
+ lifecycleUid: grammar(() => assertLifecycleToken(asString(t.lifecycleUid, "target.lifecycleUid"), "target.lifecycleUid")),
179
+ ...(t.mappingRevision !== undefined ? { mappingRevision: asWireInt(t.mappingRevision, "target.mappingRevision") } : {}),
180
+ };
181
+ }
182
+ // §13.7: explicit `null` is a VALID canonical-void payload and must reach the command's own
183
+ // schema validator, so only non-null args are shape-gated here.
184
+ const args = o.args === undefined || o.args === null ? o.args : asRecord(o.args, "args");
185
+ const f = asRecord(o.from, "from");
186
+ const from = {
187
+ id: asString(f.id, "from.id"),
188
+ name: asString(f.name, "from.name"),
189
+ ...(f.role !== undefined ? { role: asString(f.role, "from.role") } : {}),
190
+ };
191
+ const auth = o.auth === undefined ? undefined : asString(o.auth, "auth");
192
+ if (auth !== undefined && !isWellFormedUnicode(auth))
193
+ fail("bad-request", "auth slot is not well-formed Unicode (a lone surrogate has no UTF-8 encoding, so it cannot be digested as carried)");
194
+ const correlation = pickCorrelation(o.correlation);
195
+ return {
196
+ v: EP_ENVELOPE_V, id, op: { endpoint, command, ...digests }, class: cls, replyExpected,
197
+ ...(goalId !== undefined ? { goalId } : {}),
198
+ ...(target !== undefined ? { target } : {}),
199
+ ...(args !== undefined ? { args } : {}),
200
+ from,
201
+ ...(deadlineMs !== undefined ? { deadlineMs } : {}),
202
+ ...(correlation !== undefined ? { correlation } : {}),
203
+ ...(auth !== undefined ? { auth } : {}),
204
+ };
205
+ }
206
+ /** The body↔subject agreement half of the consuming boundary (§13.3): `op` MUST agree with the
207
+ * subject (`op-mismatch`); the body target is ABSENT for `self`/untargeted forms (a supplied
208
+ * one is `target-mismatch`, never ignored) and REQUIRED with a subject-equal owner (and, in
209
+ * `handle` mode, subject-equal actor + lifecycleUid) for the targeted forms; `from.id` MUST
210
+ * equal the subject sender principal (`sender-mismatch`). Currency of `target.actor`/
211
+ * `target.lifecycleUid` against the live mapping is the handler's fresh-read (`expired`),
212
+ * deliberately not checkable here. */
213
+ export function checkRequestSubjectAgreement(env, subject) {
214
+ if (env.op.endpoint !== subject.endpoint)
215
+ fail("op-mismatch", `op.endpoint "${env.op.endpoint}" does not agree with the subject endpoint "${subject.endpoint}"`);
216
+ if (env.op.command !== subject.command)
217
+ fail("op-mismatch", `op.command "${env.op.command}" does not agree with the subject command "${subject.command}"`);
218
+ // §13.3: deadlineMs is a MUST for call, SCATTER, and journal submissions. Call and journal
219
+ // are enforced at parse time; scatter is only knowable here, where the route is in hand.
220
+ if (subject.route === "all" && env.deadlineMs === undefined)
221
+ fail("bad-request", "deadlineMs is required on the scatter rail (SPEC 13.3: MUST for call/scatter and journal submissions)");
222
+ const t = subject.target;
223
+ if (!t || t.mode === "self") {
224
+ if (env.target !== undefined)
225
+ fail("target-mismatch", `a body target on ${t ? `a "self"-mode` : "an untargeted"} request is target-mismatch, never ignored (SPEC 13.3)`);
226
+ }
227
+ else {
228
+ if (!env.target)
229
+ fail("target-mismatch", `the "${t.mode}" form requires a body target (SPEC 13.3)`);
230
+ if (env.target.owner !== t.tOwner)
231
+ fail("target-mismatch", `target.owner "${env.target.owner}" does not equal the subject target owner "${t.tOwner}"`);
232
+ if (t.mode === "handle" && (env.target.actor !== t.tActor || env.target.lifecycleUid !== t.tUid))
233
+ fail("target-mismatch", "in handle mode the body target actor and lifecycleUid must equal the subject redemption triple");
234
+ }
235
+ const sender = `${subject.caller.owner}.${subject.caller.actor}`;
236
+ if (env.from.id !== sender)
237
+ fail("sender-mismatch", `from.id "${env.from.id}" does not equal the subject sender principal "${sender}"`);
238
+ }
239
+ /** The contract-class agreement check (`class-mismatch`): the envelope's declared class MUST
240
+ * equal the command's contract class. Split out because it needs the contract in hand. */
241
+ export function assertClassMatches(env, declaredClass) {
242
+ if (env.class !== declaredClass)
243
+ fail("class-mismatch", `class "${env.class}" does not equal the command's contract class "${declaredClass}"`);
244
+ }
245
+ function pickError(v) {
246
+ const e = asRecord(v, "error");
247
+ const code = asString(e.code, "error.code");
248
+ if (!isEpErrorCode(code))
249
+ fail("bad-request", `error.code ${JSON.stringify(code)} is neither a catalog token nor a reverse-DNS extension token within 64 bytes`);
250
+ const message = typeof e.message === "string" ? e.message : fail("bad-request", "error.message is not a string");
251
+ let details;
252
+ if (e.details !== undefined) {
253
+ if (!Array.isArray(e.details))
254
+ fail("bad-request", "error.details is not an array");
255
+ details = e.details.map((d, i) => {
256
+ const o = asRecord(d, `error.details[${i}]`);
257
+ const kind = asString(o.kind, `error.details[${i}].kind`);
258
+ if (!EXTENSION_CODE.test(kind))
259
+ fail("bad-request", `error.details[${i}].kind "${kind}" is not reverse-DNS namespaced`);
260
+ return o;
261
+ });
262
+ }
263
+ return { code, message, ...(details ? { details } : {}) };
264
+ }
265
+ /** Shape-validate a reply at the caller's consuming boundary. `data` is schema-validated by the
266
+ * caller against its PINNED output digest (§13.7), not here. */
267
+ export function parseEndpointReply(raw) {
268
+ const o = asRecord(raw, "reply");
269
+ assertVersion(o, "reply");
270
+ const id = grammar(() => assertIdToken(asString(o.id, "id"), "id"));
271
+ if (typeof o.ok !== "boolean")
272
+ fail("bad-request", "ok is not a boolean");
273
+ if (o.ok && o.error !== undefined)
274
+ fail("bad-request", "an ok reply must not carry an error");
275
+ if (!o.ok && o.data !== undefined)
276
+ fail("bad-request", "a failed reply must not carry data");
277
+ const error = o.ok ? undefined : pickError(o.error);
278
+ const receipt = o.receipt === undefined ? undefined : asString(o.receipt, "receipt");
279
+ return {
280
+ v: EP_ENVELOPE_V, id, ok: o.ok,
281
+ ...(o.ok && o.data !== undefined ? { data: o.data } : {}),
282
+ ...(error ? { error } : {}),
283
+ ...(receipt !== undefined ? { receipt } : {}),
284
+ };
285
+ }
286
+ /** Shape-validate an event at its consuming boundary (§13.3: every plane is runtime-validated).
287
+ * The publishing instance and epoch come from the SUBJECT; payload claims are display data. */
288
+ export function parseEndpointEvent(raw) {
289
+ const o = asRecord(raw, "event");
290
+ assertVersion(o, "event");
291
+ const topic = asString(o.topic, "topic");
292
+ if (Buffer.byteLength(topic, "utf8") > 256)
293
+ fail("bad-request", "topic exceeds 256 bytes");
294
+ const ts = asWireInt(o.ts, "ts");
295
+ if (!("data" in o))
296
+ fail("bad-request", "event carries no data field");
297
+ const correlation = pickCorrelation(o.correlation);
298
+ return { v: EP_ENVELOPE_V, topic, ts, data: o.data, ...(correlation !== undefined ? { correlation } : {}) };
299
+ }
300
+ // ---- invocation-time contract validation (§13.7, distinct from registration time) -----------
301
+ /** Validate `args` against the command's compiled input schema BEFORE any effect: failure is the
302
+ * invocation-time `bad-request` (registration-time violations are `contract-invalid`,
303
+ * {@link import("./schema-profile.js").ContractInvalidError}). Against the void schema the
304
+ * payload is absent or `null` (§13.7), so `undefined` args validate as `null` here and only
305
+ * here; an explicit `null` passes through unchanged, and it is the SCHEMA (an object-typed
306
+ * input contract) that rejects null for non-void commands. The §13.8 validation budget is the
307
+ * PROFILE's fixed 10ms, read internally so no caller
308
+ * can tune it away, and is enforced post-hoc, fail-loud as `bad-request` (the spec's
309
+ * over-budget code for validate time, distinct from compile's `contract-invalid`). Post-hoc
310
+ * measurement classifies, it cannot preempt — the pre-emptive defense is the registration-time
311
+ * bounded-pattern gate (schema-profile), which keeps the exponential backtracking class out of
312
+ * registered contracts in the first place. */
313
+ export function assertArgsValid(validate, args) {
314
+ const value = args === undefined ? null : args;
315
+ const started = Date.now();
316
+ const okValid = validate(value);
317
+ const elapsed = Date.now() - started;
318
+ if (elapsed > SCHEMA_PROFILE.validateBudgetMs)
319
+ fail("bad-request", `args validation took ${elapsed}ms (budget ${SCHEMA_PROFILE.validateBudgetMs}ms; over budget is bad-request, SPEC 13.8)`);
320
+ if (!okValid) {
321
+ const first = validate.errors?.[0];
322
+ fail("bad-request", `args do not validate against the input schema${first ? `: ${first.instancePath || "/"} ${first.message ?? ""}` : ""}`);
323
+ }
324
+ return value;
325
+ }
326
+ /** Validate an output payload against the command's compiled output schema at EITHER §13.7
327
+ * boundary — the responder's, before the success publish, or the caller's, on the consumed
328
+ * reply — the symmetric budgeted half of {@link assertArgsValid}, under the SAME fixed
329
+ * §13.8 `validateBudgetMs` (read internally, never caller-tunable). Both failure classes are
330
+ * structured `internal`: an invalid output is a responder bug (§13.3/§13.7) whichever side
331
+ * detects it, and an over-budget output validation is the same bug class, never the caller's
332
+ * `bad-request`. A void output is `undefined`, validated as `null` against the void schema,
333
+ * mirroring the args side. */
334
+ export function assertOutputValid(validate, data) {
335
+ const value = data === undefined ? null : data;
336
+ const started = Date.now();
337
+ const okValid = validate(value);
338
+ const elapsed = Date.now() - started;
339
+ if (elapsed > SCHEMA_PROFILE.validateBudgetMs)
340
+ fail("internal", `output validation took ${elapsed}ms (budget ${SCHEMA_PROFILE.validateBudgetMs}ms; an over-budget output validation is a responder bug, SPEC 13.7/13.8)`);
341
+ if (!okValid) {
342
+ const first = validate.errors?.[0];
343
+ fail("internal", `output does not validate against the pinned output schema; an invalid reply is a responder bug, never success (SPEC 13.7)${first ? `: ${first.instancePath || "/"} ${first.message ?? ""}` : ""}`);
344
+ }
345
+ }
346
+ //# sourceMappingURL=endpoint-envelope.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-envelope.js","sourceRoot":"","sources":["../src/endpoint-envelope.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAwB,MAAM,wBAAwB,CAAC;AACtI,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAGrD;sFACsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC;AAE/B,gGAAgG;AAEhG;mDACmD;AACnD,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IA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ChC,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,OAAO,CAAC;IACrC,IAAI,OAAO,GAAG,cAAc,CAAC,gBAAgB;QAC3C,IAAI,CAAC,UAAU,EAAE,0BAA0B,OAAO,cAAc,cAAc,CAAC,gBAAgB,0EAA0E,CAAC,CAAC;IAC7K,IAAI,CAAC,OAAO,EAAE,CAAC;QACb,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,UAAU,EAAE,4HAA4H,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,YAAY,IAAI,GAAG,IAAI,KAAK,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACvN,CAAC;AACH,CAAC"}
@@ -0,0 +1,123 @@
1
+ import { type EpCaller, type EpTarget } from "./endpoint-subjects.js";
2
+ /** A minted request capability: one endpoint command a caller may invoke, on the named rails.
3
+ * `routes` defaults to `["one"]`; `instanceId` additionally pins the instance form to exactly
4
+ * that instance. A TARGETED capability carries its authorization mode with the target tokens
5
+ * LITERAL as minted (§13.2): `owner`/`child` pin the caller's own owner; `any`/`ledger` may pin
6
+ * `"*"` (mintable only under operator/admin policy — enforced by the minting authority, not
7
+ * here); `handle` pins the full redemption triple and is never a standing capability (the
8
+ * standing rollup {@link epCallerGrantRows} refuses it; only the §13.6 redemption path builds
9
+ * handle rows, through {@link epRequestGrantRows} directly). */
10
+ export interface EpCapability {
11
+ endpoint: string;
12
+ command: string;
13
+ routes?: ("one" | "all")[];
14
+ instanceId?: string;
15
+ target?: EpTarget;
16
+ /** Also grant the matching journal-submission append row (`epj`, §13.9 matrix). */
17
+ journal?: boolean;
18
+ }
19
+ /** Request-publish rows for one capability (§13.9 "Request publish"): per route,
20
+ * `ep.{one,all}.<endpoint>.<command>[.<mode>[.<target…>]].<cO>.<cA>.<cUid>.*` and the
21
+ * instance-pinned form when `instanceId` is set. The nonce is the only wildcard token. */
22
+ export declare function epRequestGrantRows(space: string, cap: EpCapability, caller: EpCaller): string[];
23
+ /** Journal-submission append row (§13.9 "Journal submission append"): the same authz/target
24
+ * block as the request forms, caller-pinned, no nonce. Explicitly untrusted input (§13.4). */
25
+ export declare function epJournalGrantRow(space: string, cap: EpCapability, caller: EpCaller): string;
26
+ /** The caller's reply-rail read row (§13.9 "Reply subscribe"): its own rail only, exact arity. */
27
+ export declare function epCallerReplyGrantRow(space: string, caller: EpCaller): string;
28
+ /** Per-goal live progress read row (§13.9 "Live event progress", reserved `goal` topic):
29
+ * `epe.<endpoint>.*.*.goal.<cO>.<cA>.<cUid>.>` — the caller identity in the subject gives
30
+ * mint-time read containment; delivered on the caller's own core subscription only. */
31
+ export declare function epGoalProgressGrantRow(space: string, endpoint: string, caller: EpCaller): string;
32
+ /** All caller-side rows for a capability set: request-publish (+ optional journal) into
33
+ * `pub.allow`, the reply rail into `sub.allow`. This is the STANDING rollup (`permissionsFor`
34
+ * mints long-lived credentials from it), so a `handle`-mode capability is refused here:
35
+ * handle rows are redemption-minted only (§13.2/§13.6), built by the redemption path through
36
+ * {@link epRequestGrantRows} directly. Deliberately NOT included: `epe` event
37
+ * subtrees beyond the per-goal row — read grants are minted per read capability by the
38
+ * granting authority (Appendix B), not implied by an invoke capability. */
39
+ export declare function epCallerGrantRows(space: string, caps: EpCapability[], caller: EpCaller): {
40
+ pub: string[];
41
+ sub: string[];
42
+ };
43
+ /** The delivery endpoint's baseline command names (Appendix B: "durable join/leave/list").
44
+ * All four command vocabularies below are RUNTIME-frozen (TS `as const` is type-level only)
45
+ * and the capability builders consult PRIVATE module-load snapshots, never these live
46
+ * exports: a post-import `push("attach")` here would otherwise widen every subsequently
47
+ * minted agent grant (the afa715b identity-vs-integrity class, executed repro). */
48
+ export declare const BASELINE_DELIVERY_ENDPOINT = "delivery";
49
+ export declare const BASELINE_DELIVERY_COMMANDS: readonly ["join", "leave", "list"];
50
+ /** The manager endpoint's self-lifecycle baseline (the v0.3 self-service tier serves exactly
51
+ * no-name self stop) and the spawn-capability owner-mode lifecycle set. */
52
+ export declare const BASELINE_LIFECYCLE_ENDPOINT = "manager";
53
+ export declare const BASELINE_SELF_LIFECYCLE_COMMANDS: readonly ["stop"];
54
+ /** `spawn` is CREATION: a virgin spawn has no target lifecycle UID or current mapping yet, so it
55
+ * CANNOT ride owner mode (§13.2 owner mode resolves a body `{owner, actor, lifecycleUid}` against
56
+ * the CURRENT mapping — there is nothing to resolve for a not-yet-existing child). It is minted
57
+ * UNTARGETED; the child-owner ceiling is the authenticated caller's own owner, carried by the
58
+ * pinned caller triple. `despawn` (terminal) and `attach` (interactive) act on an EXISTING agent,
59
+ * so they ride owner mode. Owner-mode `stop` is DELIBERATELY ABSENT: on the v0.3 surface a named
60
+ * stop and a despawn both free-slot + deprovision, so an owner-mode `stop` would be a wire synonym
61
+ * of `despawn` (distsys) — one owner-mode terminal command keeps the vocabulary single. Self-`stop`
62
+ * stays in the BASELINE (the v0.3 self-service tier's only op); it is the lighter self-halt. */
63
+ export declare const SPAWN_CREATE_COMMANDS: readonly ["spawn"];
64
+ export declare const SPAWN_OWNER_LIFECYCLE_COMMANDS: readonly ["despawn", "attach"];
65
+ /** `describe` on ALL endpoints (Appendix B / §13.9 "describe by default"): the ONE
66
+ * subject-wildcard request form in the caller grammar,
67
+ * `ep.one.*.describe.<cO>.<cA>.<cUid>.*` — the endpoint token is the wildcard, the command is
68
+ * the literal reserved `describe`, and the caller triple stays pinned. DELIBERATELY not an
69
+ * {@link EpCapability} (whose endpoint is a validated literal): a wildcard-endpoint capability
70
+ * would generalize to arbitrary commands, and the baseline is the only place the wildcard form
71
+ * is normative. Untargeted only — describe is constructed untargeted on every serve
72
+ * (§13.7), so no authz/target block ever appears in the row. */
73
+ export declare function epDescribeAllGrantRow(space: string, caller: EpCaller): string;
74
+ /** The baseline {@link EpCapability} set every agent holds (Appendix B) beyond the wildcard
75
+ * describe row: delivery join/leave/list (untargeted) + self-mode lifecycle. */
76
+ export declare function baselineCallerCapabilities(): EpCapability[];
77
+ /** The `spawn` capability's addition (Appendix B): the manager endpoint's lifecycle commands.
78
+ * `spawn` (creation) is UNTARGETED — a virgin child has no lifecycle UID to resolve against the
79
+ * current mapping, so an owner-mode row would be un-invokable under the verb grammar (§13.2). The
80
+ * three that act on an existing agent ride owner mode, target owner pinned to the CALLER's own
81
+ * (§13.2: an owner-mode standing mint never names a foreign owner). */
82
+ export declare function spawnCallerCapabilities(callerOwner: string): EpCapability[];
83
+ /** All BASELINE caller rows (Appendix B): the wildcard describe form + the baseline capability
84
+ * rollup into `pub.allow`, and the caller's reply rail into `sub.allow` — ALWAYS present (the
85
+ * baseline implies the reply read even when no per-capability rows are minted). */
86
+ export declare function epBaselineGrantRows(space: string, caller: EpCaller): {
87
+ pub: string[];
88
+ sub: string[];
89
+ };
90
+ /** One registered command's serve-subscribe rows (§13.9 "Serve subscribe"), per registered
91
+ * command and never a cross-command `>`:
92
+ * - class rail: `"ep.one.<endpoint>.<command>.> <queue>"` — QUEUE-QUALIFIED ONLY (the NATS
93
+ * `subject queue` grant form): no credential can plain-subscribe the class rail, which is
94
+ * what keeps per-request nonces visible only to the queue-selected instance;
95
+ * - scatter rail: `ep.all.<endpoint>.<command>.>` plain;
96
+ * - instance rail: `ep.inst.<endpoint>.<instanceId>.<command>.>` exact.
97
+ * The epoch is deliberately absent from serve subscriptions (§13.1's barrier is the fence). */
98
+ export declare function epServeSubscribeRows(space: string, endpoint: string, instanceId: string, command: string): string[];
99
+ /** A serving instance's egress rows (§13.9 matrix): reply publish (attribution-pinned instance
100
+ * triple + epoch), events, timer SCHEDULE requests (never `.armed`/`.fire`), and the epoch-pinned
101
+ * record-write ingress. Every row pins the instance's own identity and epoch. */
102
+ export declare function epServePublishRows(space: string, endpoint: string, instanceId: string, epoch: number): string[];
103
+ /** All serve-credential subject-space rows for an instance. `ephemeralCommands` is the
104
+ * RAIL-SERVED (ephemeral) subset only — journal commands stay in the credential's descriptor
105
+ * surface but ride `epj` submissions, never the §13.2 request rails, so they take no rail
106
+ * subscribe row here (their effects/pool durable binds ride the §13.12 stream binding). The
107
+ * reserved `describe` is DERIVED here — every endpoint serves it (§13.7), so this ONE assembly
108
+ * seam emits its rails for every serve credential (even a journal-only endpoint, whose
109
+ * `ephemeralCommands` is empty) and an explicit `describe` refuses (mirroring
110
+ * {@link import("./endpoint-serve.js").serveEndpoint}'s construction rule: there is no custom
111
+ * describe). The subscribe side also carries the instance's OWN epoch-pinned timer FIRE row
112
+ * (§13.9 "Timer fire consume": `ept.<e>.<i>.<epoch>.*.fire` — consume only; the publish side
113
+ * stays `.schedule`-only, no credential publishes `.armed`/`.fire`). */
114
+ export declare function epServeGrantRows(space: string, serve: {
115
+ endpoint: string;
116
+ instanceId: string;
117
+ epoch: number;
118
+ ephemeralCommands: string[];
119
+ }): {
120
+ pub: string[];
121
+ sub: string[];
122
+ };
123
+ //# sourceMappingURL=endpoint-grants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-grants.d.ts","sourceRoot":"","sources":["../src/endpoint-grants.ts"],"names":[],"mappings":"AAYA,OAAO,EAEL,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAE7B,MAAM,wBAAwB,CAAC;AAEhC;;;;;;;iEAOiE;AACjE,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,CAAC,KAAK,GAAG,KAAK,CAAC,EAAE,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,QAAQ,CAAC;IAClB,mFAAmF;IACnF,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAwBD;;2FAE2F;AAC3F,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,GAAG,MAAM,EAAE,CAS/F;A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