@cotal-ai/core 0.11.6 → 0.13.0

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 (170) 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 +90 -10
  8. package/dist/auth-provider.d.ts.map +1 -1
  9. package/dist/auth-provider.js.map +1 -1
  10. package/dist/backup-config.d.ts +55 -0
  11. package/dist/backup-config.d.ts.map +1 -0
  12. package/dist/backup-config.js +243 -0
  13. package/dist/backup-config.js.map +1 -0
  14. package/dist/backup.d.ts +86 -0
  15. package/dist/backup.d.ts.map +1 -0
  16. package/dist/backup.js +497 -0
  17. package/dist/backup.js.map +1 -0
  18. package/dist/broker-floor.d.ts +34 -0
  19. package/dist/broker-floor.d.ts.map +1 -0
  20. package/dist/broker-floor.js +39 -0
  21. package/dist/broker-floor.js.map +1 -0
  22. package/dist/canonical.d.ts +24 -0
  23. package/dist/canonical.d.ts.map +1 -0
  24. package/dist/canonical.js +159 -0
  25. package/dist/canonical.js.map +1 -0
  26. package/dist/channels.d.ts.map +1 -1
  27. package/dist/channels.js +8 -1
  28. package/dist/channels.js.map +1 -1
  29. package/dist/connector.d.ts +4 -0
  30. package/dist/connector.d.ts.map +1 -1
  31. package/dist/endpoint-action.d.ts +424 -0
  32. package/dist/endpoint-action.d.ts.map +1 -0
  33. package/dist/endpoint-action.js +910 -0
  34. package/dist/endpoint-action.js.map +1 -0
  35. package/dist/endpoint-binding.d.ts +344 -0
  36. package/dist/endpoint-binding.d.ts.map +1 -0
  37. package/dist/endpoint-binding.js +753 -0
  38. package/dist/endpoint-binding.js.map +1 -0
  39. package/dist/endpoint-checkpoint.d.ts +292 -0
  40. package/dist/endpoint-checkpoint.d.ts.map +1 -0
  41. package/dist/endpoint-checkpoint.js +818 -0
  42. package/dist/endpoint-checkpoint.js.map +1 -0
  43. package/dist/endpoint-cluster.d.ts +95 -0
  44. package/dist/endpoint-cluster.d.ts.map +1 -0
  45. package/dist/endpoint-cluster.js +194 -0
  46. package/dist/endpoint-cluster.js.map +1 -0
  47. package/dist/endpoint-contract-store.d.ts +90 -0
  48. package/dist/endpoint-contract-store.d.ts.map +1 -0
  49. package/dist/endpoint-contract-store.js +348 -0
  50. package/dist/endpoint-contract-store.js.map +1 -0
  51. package/dist/endpoint-envelope.d.ts +165 -0
  52. package/dist/endpoint-envelope.d.ts.map +1 -0
  53. package/dist/endpoint-envelope.js +346 -0
  54. package/dist/endpoint-envelope.js.map +1 -0
  55. package/dist/endpoint-grants.d.ts +123 -0
  56. package/dist/endpoint-grants.d.ts.map +1 -0
  57. package/dist/endpoint-grants.js +215 -0
  58. package/dist/endpoint-grants.js.map +1 -0
  59. package/dist/endpoint-guard.d.ts +222 -0
  60. package/dist/endpoint-guard.d.ts.map +1 -0
  61. package/dist/endpoint-guard.js +468 -0
  62. package/dist/endpoint-guard.js.map +1 -0
  63. package/dist/endpoint-handle.d.ts +176 -0
  64. package/dist/endpoint-handle.d.ts.map +1 -0
  65. package/dist/endpoint-handle.js +608 -0
  66. package/dist/endpoint-handle.js.map +1 -0
  67. package/dist/endpoint-journal.d.ts +225 -0
  68. package/dist/endpoint-journal.d.ts.map +1 -0
  69. package/dist/endpoint-journal.js +431 -0
  70. package/dist/endpoint-journal.js.map +1 -0
  71. package/dist/endpoint-receipt.d.ts +225 -0
  72. package/dist/endpoint-receipt.d.ts.map +1 -0
  73. package/dist/endpoint-receipt.js +417 -0
  74. package/dist/endpoint-receipt.js.map +1 -0
  75. package/dist/endpoint-records.d.ts +243 -0
  76. package/dist/endpoint-records.d.ts.map +1 -0
  77. package/dist/endpoint-records.js +591 -0
  78. package/dist/endpoint-records.js.map +1 -0
  79. package/dist/endpoint-serve.d.ts +176 -0
  80. package/dist/endpoint-serve.d.ts.map +1 -0
  81. package/dist/endpoint-serve.js +446 -0
  82. package/dist/endpoint-serve.js.map +1 -0
  83. package/dist/endpoint-service.d.ts +518 -0
  84. package/dist/endpoint-service.d.ts.map +1 -0
  85. package/dist/endpoint-service.js +973 -0
  86. package/dist/endpoint-service.js.map +1 -0
  87. package/dist/endpoint-session.d.ts +398 -0
  88. package/dist/endpoint-session.d.ts.map +1 -0
  89. package/dist/endpoint-session.js +834 -0
  90. package/dist/endpoint-session.js.map +1 -0
  91. package/dist/endpoint-signing.d.ts +105 -0
  92. package/dist/endpoint-signing.d.ts.map +1 -0
  93. package/dist/endpoint-signing.js +190 -0
  94. package/dist/endpoint-signing.js.map +1 -0
  95. package/dist/endpoint-subjects.d.ts +222 -0
  96. package/dist/endpoint-subjects.d.ts.map +1 -0
  97. package/dist/endpoint-subjects.js +381 -0
  98. package/dist/endpoint-subjects.js.map +1 -0
  99. package/dist/endpoint-supervisor.d.ts +19 -0
  100. package/dist/endpoint-supervisor.d.ts.map +1 -0
  101. package/dist/endpoint-supervisor.js +12 -0
  102. package/dist/endpoint-supervisor.js.map +1 -0
  103. package/dist/endpoint-traits.d.ts +225 -0
  104. package/dist/endpoint-traits.d.ts.map +1 -0
  105. package/dist/endpoint-traits.js +469 -0
  106. package/dist/endpoint-traits.js.map +1 -0
  107. package/dist/endpoint-verbs.d.ts +277 -0
  108. package/dist/endpoint-verbs.d.ts.map +1 -0
  109. package/dist/endpoint-verbs.js +576 -0
  110. package/dist/endpoint-verbs.js.map +1 -0
  111. package/dist/endpoint-virtual.d.ts +308 -0
  112. package/dist/endpoint-virtual.d.ts.map +1 -0
  113. package/dist/endpoint-virtual.js +440 -0
  114. package/dist/endpoint-virtual.js.map +1 -0
  115. package/dist/endpoint-work.d.ts +304 -0
  116. package/dist/endpoint-work.d.ts.map +1 -0
  117. package/dist/endpoint-work.js +728 -0
  118. package/dist/endpoint-work.js.map +1 -0
  119. package/dist/endpoint.d.ts +66 -22
  120. package/dist/endpoint.d.ts.map +1 -1
  121. package/dist/endpoint.js +289 -89
  122. package/dist/endpoint.js.map +1 -1
  123. package/dist/evict.d.ts +95 -32
  124. package/dist/evict.d.ts.map +1 -1
  125. package/dist/evict.js +193 -3
  126. package/dist/evict.js.map +1 -1
  127. package/dist/index.d.ts +29 -0
  128. package/dist/index.d.ts.map +1 -1
  129. package/dist/index.js +29 -0
  130. package/dist/index.js.map +1 -1
  131. package/dist/lease.d.ts +4 -0
  132. package/dist/lease.d.ts.map +1 -1
  133. package/dist/lease.js.map +1 -1
  134. package/dist/members.d.ts +4 -4
  135. package/dist/members.d.ts.map +1 -1
  136. package/dist/members.js +12 -12
  137. package/dist/members.js.map +1 -1
  138. package/dist/provision.d.ts +78 -20
  139. package/dist/provision.d.ts.map +1 -1
  140. package/dist/provision.js +214 -37
  141. package/dist/provision.js.map +1 -1
  142. package/dist/runtime.d.ts +3 -0
  143. package/dist/runtime.d.ts.map +1 -1
  144. package/dist/safe-pattern.d.ts +33 -0
  145. package/dist/safe-pattern.d.ts.map +1 -0
  146. package/dist/safe-pattern.js +486 -0
  147. package/dist/safe-pattern.js.map +1 -0
  148. package/dist/schema-profile.d.ts +93 -0
  149. package/dist/schema-profile.d.ts.map +1 -0
  150. package/dist/schema-profile.js +284 -0
  151. package/dist/schema-profile.js.map +1 -0
  152. package/dist/secret-store.d.ts +46 -0
  153. package/dist/secret-store.d.ts.map +1 -0
  154. package/dist/secret-store.js +2 -0
  155. package/dist/secret-store.js.map +1 -0
  156. package/dist/space-auth.d.ts +9 -0
  157. package/dist/space-auth.d.ts.map +1 -0
  158. package/dist/space-auth.js +126 -0
  159. package/dist/space-auth.js.map +1 -0
  160. package/dist/streams.d.ts +14 -10
  161. package/dist/streams.d.ts.map +1 -1
  162. package/dist/streams.js +47 -76
  163. package/dist/streams.js.map +1 -1
  164. package/dist/subjects.d.ts +100 -40
  165. package/dist/subjects.d.ts.map +1 -1
  166. package/dist/subjects.js +136 -60
  167. package/dist/subjects.js.map +1 -1
  168. package/dist/types.d.ts +9 -0
  169. package/dist/types.d.ts.map +1 -1
  170. package/package.json +6 -2
@@ -0,0 +1,468 @@
1
+ /**
2
+ * The GUARD CHECKPOINT (SPEC §13.6): the pre-effect authorization hook. A command carrying the
3
+ * governed `ai.cotal.guarded` trait MUST NOT effect until the guard endpoint named by the
4
+ * verified trait value answered ALLOW (class call). Answers: `allow | deny | hold` plus
5
+ * optional SIGNED obligations (attenuations the endpoint MUST apply; monotonic, §13.10 replay
6
+ * matrix: bound to the goal/request, reusable within it). `hold` converts the action to
7
+ * `waiting` on a checkpoint OWNED BY THE GUARD DECISION (the guard's authenticated responder
8
+ * is the checkpoint holder — only IT can release the hold). Timeout, an unreachable guard, a
9
+ * garbled answer, or an invalid obligation is DENY (fail closed). Ordering is
10
+ * guard-then-effect; side-effecting guards own their own reconciliation.
11
+ *
12
+ * This module is THE guard gate. There is exactly one: {@link runGuardGate} owns the guard
13
+ * call, the closed answer parse, and the D28 obligation verification, and BOTH production
14
+ * rails run through it — the ephemeral serve rail via `assertGovernedPreEffect` (which
15
+ * refuses hold, since an ephemeral request cannot wait) and the action composite via
16
+ * {@link gateGoalExecution} (which ROUTES hold into the checkpoint pause and a guard deny
17
+ * into the shared terminal commit). {@link reconcileGuardHold} is the durable backstop that
18
+ * converges a settled hold whose projection crashed mid-flight. The gate never guesses:
19
+ * every path that is not a well-formed, obligation-valid ALLOW or HOLD is a refusal.
20
+ */
21
+ import { EpEnvelopeError } from "./endpoint-envelope.js";
22
+ import { canonicalJson } from "./canonical.js";
23
+ import { verifyArtifactSignature, resolveAnchorForUse, assertAnchorScopeCovers } from "./endpoint-signing.js";
24
+ import { mintCheckpoint, resumeCheckpoint, readCheckpointSpec, readCheckpointSettle, expireCheckpoint } from "./endpoint-checkpoint.js";
25
+ import { transitionGoal, commitGoalResult, projectGoalTerminal, readGoalSpec, readGoalStatus, readGoalResult, ownerCommitProof, claimGuardClearanceMint, snapshotRef } from "./endpoint-action.js";
26
+ const isRec = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
27
+ /** THIS module is THE gate, so it claims the one-shot clearance mint at load: a guarded goal's
28
+ * edge into `running` opens only with a clearance minted here - by the gate's own allow,
29
+ * release, and reconcile arms, each of which verified the guard's answer or its recorded
30
+ * settlement first. No other module can claim the mint (the second claim throws). */
31
+ const mintGuardClearance = claimGuardClearanceMint();
32
+ /** The gate-VERIFIED obligation sets, branded so the durable HOLD ingress can require that its
33
+ * obligations came from {@link runGuardGate}'s verification (signature, anchor role/scope,
34
+ * windows, request binding) and not from a structurally shaped fake: {@link holdGuardedGoal}
35
+ * is a public composition seam, and an unverified set persisted there would return through
36
+ * release/reconcile under the same trusted type as a verified one. Entries are DEEP-FROZEN at
37
+ * verification, so a branded obligation cannot be mutated away from the bytes its signature
38
+ * verified over. */
39
+ const VERIFIED_OBLIGATIONS = new WeakSet();
40
+ function deepFreeze(v) {
41
+ if (v === null || typeof v !== "object")
42
+ return;
43
+ for (const k of Object.keys(v))
44
+ deepFreeze(v[k]);
45
+ Object.freeze(v);
46
+ }
47
+ function denyClosed(why) {
48
+ throw new EpEnvelopeError("permission-denied", `guard gate DENIES: ${why} (SPEC 13.6: timeout, an unreachable guard, or a garbled answer is deny; the gate fails closed, never open)`);
49
+ }
50
+ function parseObligation(raw, i) {
51
+ if (!isRec(raw))
52
+ denyClosed(`obligation[${i}] is not an object`);
53
+ const o = raw;
54
+ const allowed = new Set(["v", "space", "requestId", "signer", "attenuations", "iat", "exp", "sig"]);
55
+ for (const k of Object.keys(o))
56
+ if (!allowed.has(k))
57
+ denyClosed(`obligation[${i}] carries the unknown field "${k}" (closed schema)`);
58
+ if (o.v !== 1 || typeof o.space !== "string" || o.space.length === 0)
59
+ denyClosed(`obligation[${i}] has no version/space`);
60
+ if (typeof o.requestId !== "string" || o.requestId.length === 0)
61
+ denyClosed(`obligation[${i}] binds no requestId`);
62
+ if (!isRec(o.signer) || typeof o.signer.keyId !== "string")
63
+ denyClosed(`obligation[${i}] names no signer keyId`);
64
+ if (!Array.isArray(o.attenuations) || o.attenuations.length === 0 || !o.attenuations.every(isRec))
65
+ denyClosed(`obligation[${i}] carries no structured attenuations (an obligation that attenuates nothing is garbled)`);
66
+ for (const f of ["iat", "exp"])
67
+ if (typeof o[f] !== "number" || !Number.isSafeInteger(o[f]) || o[f] < 0)
68
+ denyClosed(`obligation[${i}] ${f} is not a non-negative safe integer`);
69
+ if (o.exp <= o.iat)
70
+ denyClosed(`obligation[${i}] exp is not after iat`);
71
+ if (typeof o.sig !== "string" || o.sig.length === 0)
72
+ denyClosed(`obligation[${i}] is unsigned`);
73
+ return o;
74
+ }
75
+ /** Race an await against the REMAINING guard budget: the whole gate (the guard call AND every
76
+ * obligation's anchor resolution) is ONE bounded operation, so a stuck registry after the
77
+ * guard answered cannot hang the gate. Timeout is DENY (SPEC 13.6: fail closed). Races
78
+ * `Promise.resolve(p)` unconditionally (a non-native thenable must not bypass the deadline). */
79
+ async function withGateBudget(p, remainingMs, what) {
80
+ if (remainingMs <= 0)
81
+ throw new EpEnvelopeError("permission-denied", `${what} found the guard budget already exhausted; the gate is one bounded operation and timeout is DENY (SPEC 13.6: fail closed)`);
82
+ let timer;
83
+ const deadline = new Promise((_, reject) => {
84
+ timer = setTimeout(() => reject(new EpEnvelopeError("permission-denied", `${what} did not answer within the remaining ${remainingMs}ms guard budget; timeout is DENY (SPEC 13.6: fail closed)`)), remainingMs);
85
+ });
86
+ try {
87
+ return await Promise.race([Promise.resolve(p), deadline]);
88
+ }
89
+ finally {
90
+ clearTimeout(timer);
91
+ }
92
+ }
93
+ /** Verify one obligation against the trust-anchor registry: D28 signature over the EXACT RAW
94
+ * artifact, `obligations` role, scope covering the GUARDED endpoint, anchor window at `iat`,
95
+ * obligation window at `now`, space + request binding. Any failure denies (fail closed), and
96
+ * the anchor resolution runs within the gate's REMAINING budget. */
97
+ async function verifyObligation(raw, ob, i, opts) {
98
+ if (ob.space !== opts.space)
99
+ denyClosed(`obligation[${i}] is bound to space ${ob.space}, not ${opts.space}`);
100
+ if (ob.requestId !== opts.requestId)
101
+ denyClosed(`obligation[${i}] binds requestId ${ob.requestId}, not this request's ${opts.requestId} (an obligation is bound to its goal/request)`);
102
+ if (opts.now < ob.iat || opts.now > ob.exp)
103
+ denyClosed(`obligation[${i}] is outside its validity window [${ob.iat}, ${ob.exp}] at now ${opts.now}`);
104
+ let anchor;
105
+ try {
106
+ anchor = await withGateBudget(resolveAnchorForUse(opts.resolveAnchor, { keyId: ob.signer.keyId, role: "obligations", at: ob.iat }), opts.remainingMs(), `obligation[${i}]'s anchor resolution`);
107
+ assertAnchorScopeCovers(anchor, "obligations", opts.endpoint, `obligation[${i}] for endpoint`);
108
+ verifyArtifactSignature(raw, anchor);
109
+ }
110
+ catch (e) {
111
+ denyClosed(`obligation[${i}] does not verify (${e.message})`);
112
+ }
113
+ }
114
+ /** Parse the guard endpoint's raw answer body, CLOSED per decision. Anything else denies. */
115
+ function parseGuardAnswer(raw) {
116
+ if (!isRec(raw))
117
+ denyClosed("the guard answered with a non-object body");
118
+ const o = raw;
119
+ const allowed = new Set(["v", "decision", "reason", "token", "holdDeadlineMs", "obligations"]);
120
+ for (const k of Object.keys(o))
121
+ if (!allowed.has(k))
122
+ denyClosed(`the guard answer carries the unknown field "${k}" (closed schema)`);
123
+ if (o.v !== 1)
124
+ denyClosed("the guard answer version is not 1");
125
+ if (o.decision !== "allow" && o.decision !== "deny" && o.decision !== "hold")
126
+ denyClosed(`the guard decision ${JSON.stringify(o.decision)} is not allow|deny|hold`);
127
+ const rawObs = o.obligations === undefined ? [] : o.obligations;
128
+ if (!Array.isArray(rawObs))
129
+ denyClosed("the guard answer obligations is not an array");
130
+ if (o.decision === "deny") {
131
+ if (o.obligations !== undefined || o.token !== undefined || o.holdDeadlineMs !== undefined)
132
+ denyClosed("a deny answer carries allow/hold fields (garbled cross-variant answer)");
133
+ if (o.reason !== undefined && typeof o.reason !== "string")
134
+ denyClosed("the deny reason is not a string");
135
+ return { answer: { decision: "deny", ...(o.reason !== undefined ? { reason: o.reason } : {}) }, rawObligations: [] };
136
+ }
137
+ if (o.reason !== undefined)
138
+ denyClosed(`a ${o.decision} answer carries a deny reason (garbled cross-variant answer)`);
139
+ const obligations = rawObs.map((r, i) => parseObligation(r, i));
140
+ if (o.decision === "allow") {
141
+ if (o.token !== undefined || o.holdDeadlineMs !== undefined)
142
+ denyClosed("an allow answer carries hold fields (garbled cross-variant answer)");
143
+ return { answer: { decision: "allow", obligations }, rawObligations: rawObs };
144
+ }
145
+ if (typeof o.token !== "string" || o.token.length === 0)
146
+ denyClosed("a hold answer names no checkpoint token");
147
+ if (typeof o.holdDeadlineMs !== "number" || !Number.isSafeInteger(o.holdDeadlineMs) || o.holdDeadlineMs <= 0)
148
+ denyClosed("a hold answer has no positive integer holdDeadlineMs (deadlines are mandatory, SPEC 13.6)");
149
+ return { answer: { decision: "hold", token: o.token, holdDeadlineMs: o.holdDeadlineMs, obligations }, rawObligations: rawObs };
150
+ }
151
+ /** Run the §13.6 guard gate for one guarded request: call the guard endpoint (via the injected
152
+ * seam) within `deadlineMs`, and classify FAIL-CLOSED — the ONLY outcomes are a verified
153
+ * ALLOW, a verified HOLD (the caller then wires the pause via {@link holdGuardedGoal}), or a
154
+ * `permission-denied` throw. A timeout, transport failure, garbled answer, cross-variant
155
+ * fields, or an obligation that does not verify (signature, scope, window, request binding)
156
+ * all DENY. Ordering is guard-then-effect: call this BEFORE any effect. */
157
+ export async function runGuardGate(opts) {
158
+ if (typeof opts.guardEndpoint !== "string" || opts.guardEndpoint.length === 0)
159
+ denyClosed("the guarded trait names no guard endpoint");
160
+ if (!Number.isSafeInteger(opts.deadlineMs) || opts.deadlineMs <= 0)
161
+ throw new EpEnvelopeError("failed-precondition", `the guard deadline must be a positive integer; got ${JSON.stringify(opts.deadlineMs)}`);
162
+ if (!Number.isSafeInteger(opts.now) || opts.now < 0)
163
+ throw new EpEnvelopeError("failed-precondition", `now must be a non-negative safe integer; got ${JSON.stringify(opts.now)}`);
164
+ // ONE total gate budget: the guard call and every obligation verification share this clock,
165
+ // so a stuck anchor registry AFTER the guard answered is still a bounded DENY.
166
+ const gateDeadlineAt = Date.now() + opts.deadlineMs;
167
+ const remainingMs = () => gateDeadlineAt - Date.now();
168
+ let called;
169
+ try {
170
+ called = await withGateBudget(opts.callGuard({
171
+ guardEndpoint: opts.guardEndpoint,
172
+ endpoint: opts.request.endpoint,
173
+ ...(opts.request.command !== undefined ? { command: opts.request.command } : {}),
174
+ requestId: opts.request.id,
175
+ caller: opts.request.caller,
176
+ }), remainingMs(), "the guard");
177
+ }
178
+ catch (e) {
179
+ if (e instanceof EpEnvelopeError && e.code === "permission-denied")
180
+ throw e;
181
+ denyClosed(`the guard call failed (${e?.message ?? String(e)})`);
182
+ }
183
+ if (!isRec(called))
184
+ denyClosed("the guard call seam returned no authenticated responder identity");
185
+ // SINGLE-READ the responder BEFORE any touch of the answer (security H3, both vectors): the
186
+ // `responder` PROPERTY itself is read exactly once into a local - an accessor on the seam
187
+ // result could otherwise answer the type-check with the authenticated identity and the
188
+ // capture with an attacker's - and the scalars are then read only from that one object,
189
+ // validated as read locals, and frozen before `called.answer` (whose serialization runs
190
+ // caller getters) is ever evaluated.
191
+ const rawResponder = called.responder;
192
+ if (!isRec(rawResponder))
193
+ denyClosed("the guard call seam returned no authenticated responder identity");
194
+ const responderId = rawResponder.id;
195
+ const responderUid = rawResponder.lifecycleUid;
196
+ if (typeof responderId !== "string" || responderId.length === 0 || typeof responderUid !== "string" || responderUid.length === 0)
197
+ denyClosed("the guard call seam returned no authenticated responder identity");
198
+ const responder = Object.freeze({ id: responderId, lifecycleUid: responderUid });
199
+ // SNAPSHOT the seam's answer to a DETACHED value BEFORE the parse and the anchor awaits: the
200
+ // obligation signatures verify over EXACTLY these bytes, so a caller that mutates the raw
201
+ // answer/obligations during the awaited anchor resolution can never split what was
202
+ // parsed/scoped from what the signature verifies (D28 consuming boundary).
203
+ let answerSnapshot;
204
+ try {
205
+ answerSnapshot = JSON.parse(canonicalJson(called.answer));
206
+ } // throws on non-interchangeable I-JSON; the detached tree is unreachable to the caller
207
+ catch (e) {
208
+ return denyClosed(`the guard answer is not interchangeable JSON (${e.message})`);
209
+ }
210
+ const { answer, rawObligations } = parseGuardAnswer(answerSnapshot);
211
+ if (answer.decision === "deny")
212
+ throw new EpEnvelopeError("permission-denied", `the guard denied this request${answer.reason !== undefined ? `: ${answer.reason}` : ""} (SPEC 13.6: guard-then-effect)`);
213
+ for (let i = 0; i < answer.obligations.length; i++)
214
+ await verifyObligation(rawObligations[i], answer.obligations[i], i, { resolveAnchor: opts.resolveAnchor, now: opts.now, space: opts.space, endpoint: opts.request.endpoint, requestId: opts.request.id, remainingMs });
215
+ // Brand + deep-freeze the VERIFIED set: from here on these exact objects (and only they)
216
+ // prove "verified by THIS gate" at the durable HOLD ingress, and cannot be mutated away
217
+ // from the bytes their signatures verified over.
218
+ for (const ob of answer.obligations) {
219
+ deepFreeze(ob);
220
+ VERIFIED_OBLIGATIONS.add(ob);
221
+ }
222
+ if (answer.decision === "allow")
223
+ return { decision: "allow", obligations: answer.obligations };
224
+ return { decision: "hold", token: answer.token, holdDeadlineMs: answer.holdDeadlineMs, obligations: answer.obligations, responder };
225
+ }
226
+ /** The ACTION composite's guard gate (§13.6): run by the OWNING instance for a guarded goal
227
+ * BEFORE any execution effect — the counterpart of the ephemeral rail's
228
+ * `assertGovernedPreEffect`, with hold ROUTED instead of refused. {@link runGuardGate} does
229
+ * the calling, parsing, and obligation verification; this seam projects the verdict onto the
230
+ * goal:
231
+ * - ALLOW: the goal transitions accepted → running under the owner's construction-bound
232
+ * proof (this projection is the owner's admission to execute) and the VERIFIED
233
+ * obligations return for the executor, which MUST apply them;
234
+ * - HOLD: {@link holdGuardedGoal} mints the guard-holder-bound checkpoint and projects
235
+ * `waiting`;
236
+ * - DENY (or ANY fail-closed gate refusal: timeout, garble, unverifiable obligation): the
237
+ * goal commits terminal `failed` at the shared commit point under the OWNER's
238
+ * construction-bound proof — the owner runs this gate, so the deny predicate is the
239
+ * owner's own refusal to execute, carrying the gate's reason in the terminal payload.
240
+ * Obligations bind to the GOAL id (§13.10: bound to its goal/request, reusable within it). */
241
+ export async function gateGoalExecution(ctx, args) {
242
+ const goal = snapshotRef(args.goal);
243
+ // The gate runs only on a goal whose ACCEPTED record binds THIS guard (SPEC 13.6/13.7): the
244
+ // record's binding is what transitionGoal enforces on the edge into running, so a goal with
245
+ // no recorded binding would pass the gate here yet stay publicly transitionable - an
246
+ // unrecorded guard is unenforceable, and a mismatched one gates against the wrong authority.
247
+ // Both are wiring defects, refused loudly before the guard is consulted.
248
+ const gateSpec = await readGoalSpec(ctx, goal);
249
+ if (gateSpec === undefined)
250
+ throw new EpEnvelopeError("failed-precondition", `goal "${goal.goalId}" is unknown; the gate runs on an accepted goal (SPEC 13.6)`);
251
+ if (gateSpec.value.guard !== args.guardEndpoint)
252
+ throw new EpEnvelopeError("failed-precondition", `goal "${goal.goalId}"'s accepted record ${gateSpec.value.guard === undefined ? "binds no guard" : `binds guard ${JSON.stringify(gateSpec.value.guard)}`} but the gate was asked to consult ${JSON.stringify(args.guardEndpoint)}; an unrecorded or mismatched guard binding is unenforceable and never gates (SPEC 13.6/13.7)`);
253
+ let verdict;
254
+ try {
255
+ verdict = await runGuardGate({
256
+ guardEndpoint: args.guardEndpoint,
257
+ request: { endpoint: goal.endpoint, id: goal.goalId, caller: goal.caller },
258
+ callGuard: args.callGuard,
259
+ deadlineMs: args.deadlineMs,
260
+ now: args.now,
261
+ space: ctx.space,
262
+ resolveAnchor: args.resolveAnchor,
263
+ });
264
+ }
265
+ catch (e) {
266
+ if (!(e instanceof EpEnvelopeError && e.code === "permission-denied"))
267
+ throw e; // wiring errors propagate; only the gate's fail-closed deny terminalizes
268
+ const res = await commitGoalResult(ctx, {
269
+ ref: goal, now: args.now, cause: "deny", denial: { kind: "owner", owner: ownerCommitProof(ctx) },
270
+ data: { code: "permission-denied", reason: e.message },
271
+ });
272
+ return { outcome: "denied", won: res.won, fact: res.fact, status: res.status };
273
+ }
274
+ if (verdict.decision === "hold") {
275
+ // The VERIFIED obligations ride the hold's durable record (§13.6/§13.10: MUST-apply,
276
+ // reusable within the goal) — verified-then-dropped would release the executor with zero
277
+ // attenuations after the pause.
278
+ const status = await holdGuardedGoal(ctx, {
279
+ goal, hold: { token: verdict.token, holdDeadlineMs: verdict.holdDeadlineMs, responder: verdict.responder, obligations: verdict.obligations },
280
+ instanceId: args.instanceId, epoch: args.epoch, now: args.now,
281
+ });
282
+ return { outcome: "waiting", hold: { token: verdict.token, holdDeadlineMs: verdict.holdDeadlineMs }, obligations: verdict.obligations, status };
283
+ }
284
+ const status = await transitionGoal(ctx, goal, "running", { owner: ownerCommitProof(ctx), clearance: mintGuardClearance(ctx, goal.goalId) });
285
+ return { outcome: "running", obligations: verdict.obligations, status };
286
+ }
287
+ /** The durable HOLD reconciler (§13.6): converge a goal whose guard-hold checkpoint SETTLED
288
+ * while the goal projection lags (a release or expiry crashed mid-flight, or the timer fire
289
+ * settled the checkpoint and the owner's projection is still owed). For a goal `waiting` on
290
+ * checkpoint T whose spec binds THIS goal:
291
+ * - settle RESUMED: finish the projection to `running` (idempotent);
292
+ * - settle EXPIRED: drive the terminal deny via {@link expireGuardHold} (idempotent);
293
+ * - still live: nothing to do — the timer plane owns the deadline.
294
+ * A goal not waiting, or waiting on a token whose checkpoint does not bind it, is left
295
+ * untouched: this reconciler converges exactly the holds this module minted. (The
296
+ * mint-then-no-wait partial state is recovered by RETRYING the gate — the mint is
297
+ * idempotent-if-identical and the transition completes; a dedicated repair arm was
298
+ * panel-adjudicated as insurance ahead of composition and deliberately not built.)
299
+ * A converged `running` carries the hold's RECORDED verified obligations (§13.6/§13.10:
300
+ * MUST-apply, reusable within the goal — the pause never launders them away). */
301
+ export async function reconcileGuardHold(ctx, args) {
302
+ const goal = snapshotRef(args.goal);
303
+ const status = await readGoalStatus(ctx, goal);
304
+ if (status === undefined || status.value.state !== "waiting" || status.value.checkpoint === undefined)
305
+ return { converged: "none" };
306
+ const token = status.value.checkpoint.token;
307
+ let obligations;
308
+ try {
309
+ ({ obligations } = await bindCheckpointToGoal(ctx, goal, token));
310
+ }
311
+ catch {
312
+ return { converged: "none" };
313
+ } // a foreign/unknown token's wait is not this reconciler's to converge
314
+ const settle = await readCheckpointSettle(ctx.jsm, ctx.space, { endpoint: goal.endpoint, token });
315
+ if (settle === undefined)
316
+ return { converged: "none" };
317
+ if (settle.settle === "resumed") {
318
+ const cur = await readGoalStatus(ctx, goal);
319
+ if (cur?.value.state === "waiting" && cur.value.checkpoint?.token === token)
320
+ await transitionGoal(ctx, goal, "running", { owner: ownerCommitProof(ctx), clearance: mintGuardClearance(ctx, goal.goalId) });
321
+ return { converged: "running", obligations };
322
+ }
323
+ await expireGuardHold(ctx, { goal, token, now: args.now });
324
+ return { converged: "denied" };
325
+ }
326
+ /** Convert a HELD action to `waiting` on a checkpoint OWNED BY THE GUARD DECISION (§13.6): the
327
+ * checkpoint's holder is the guard's authenticated responder (only IT may resume), the
328
+ * deadline is the hold's (mandatory), and the goal's status projects `waiting` carrying the
329
+ * checkpoint coordinate. The mint is idempotent and the timer is armed through the mediated
330
+ * plane by the checkpoint module. */
331
+ export async function holdGuardedGoal(ctx, args) {
332
+ // The durable ingress admits ONLY gate-verified obligations (freelance HIGH): this is a
333
+ // public composition seam, and the store carries the persisted set as custody WITHOUT
334
+ // re-verifying (the gate verified at HOLD time) - so a structurally shaped set that never
335
+ // passed runGuardGate's verification must refuse HERE, or release/reconcile would later
336
+ // return it under the same trusted type as a verified one.
337
+ for (const [i, ob] of (args.hold.obligations ?? []).entries())
338
+ if (!VERIFIED_OBLIGATIONS.has(ob))
339
+ throw new EpEnvelopeError("permission-denied", `hold obligation[${i}] was not verified by THIS gate; obligations enter a hold only through runGuardGate's verification (signature, anchor role/scope, window, request binding) - a structurally shaped set never authorizes (SPEC 13.6/13.10)`);
340
+ await mintCheckpoint(ctx.kv, ctx.js, ctx.space, {
341
+ ref: { endpoint: args.goal.endpoint, token: args.hold.token },
342
+ instanceId: args.instanceId, epoch: args.epoch,
343
+ goal: { caller: args.goal.caller, goalId: args.goal.goalId },
344
+ ...(args.hold.obligations !== undefined && args.hold.obligations.length > 0 ? { obligations: args.hold.obligations } : {}),
345
+ holder: args.hold.responder,
346
+ deadline: args.now + args.hold.holdDeadlineMs, now: args.now,
347
+ });
348
+ // The pause is OWNER-authored (the owner mints the checkpoint and records the wait), not a
349
+ // remote executor's progress step, so a target-pinned goal's hold does not require executor
350
+ // currency here — the guard responder, not a superseded executor, is the checkpoint holder.
351
+ // The authority is the CONSTRUCTION-BOUND owner proof from this context, never a raw flag.
352
+ return transitionGoal(ctx, args.goal, "waiting", { fields: { checkpoint: { token: args.hold.token, deadlineGeneration: 1 } }, owner: ownerCommitProof(ctx) });
353
+ }
354
+ /** Bind a hold's checkpoint token to THIS goal (§13.6): read the checkpoint's recorded spec and
355
+ * require its `goal` to be the exact goal being released/expired — a checkpoint pauses ONE
356
+ * recorded goal (holdGuardedGoal mints it with that binding), so a valid token for goal A must
357
+ * never drive a transition on unrelated goal B. Fail-closed: an unknown token, a spec with no
358
+ * goal binding, or a mismatched caller/goalId all refuse before any state is touched. */
359
+ async function bindCheckpointToGoal(ctx, goal, token) {
360
+ const spec = await readCheckpointSpec(ctx.kv, { endpoint: goal.endpoint, token });
361
+ if (spec === undefined)
362
+ throw new EpEnvelopeError("failed-precondition", `checkpoint "${token}" is unknown on endpoint "${goal.endpoint}"; a guard hold names a minted checkpoint (SPEC 13.6)`);
363
+ const g = spec.goal;
364
+ if (g === undefined)
365
+ throw new EpEnvelopeError("permission-denied", `checkpoint "${token}" records no goal binding; it does not pause goal "${goal.goalId}" and cannot drive its transition (SPEC 13.6)`);
366
+ if (g.goalId !== goal.goalId || g.caller.owner !== goal.caller.owner || g.caller.actor !== goal.caller.actor || g.caller.uid !== goal.caller.uid)
367
+ throw new EpEnvelopeError("permission-denied", `checkpoint "${token}" pauses goal "${g.goalId}" (${g.caller.owner}.${g.caller.actor}/${g.caller.uid}), not the presented goal "${goal.goalId}"; a hold's token is goal-bound, never a free release of any goal on the endpoint (SPEC 13.6)`);
368
+ // The hold's RECORDED verified obligations (persisted at mint; §13.6/§13.10 MUST-apply,
369
+ // reusable within the goal): release/reconcile return exactly this set, signatures intact.
370
+ return { obligations: (spec.obligations ?? []) };
371
+ }
372
+ /** Release a guard hold: the GUARD (the checkpoint's holder, presenting as itself) resumes the
373
+ * one-use checkpoint, and the goal leaves `waiting` back to `running`. The token is first bound
374
+ * to THIS goal (a valid token for another goal never releases it), THEN the resume seam
375
+ * enforces holder binding, one-use, and the deadline fence (a hold past its deadline drives
376
+ * the EXPIRED settlement there and refuses; an expired hold never releases).
377
+ *
378
+ * CRASH CONVERGENCE (the checkpoint settlement is the arbiter; the goal transition is its
379
+ * derived projection): a crash between the one-use resume and the goal transition leaves the
380
+ * checkpoint `resumed` and the goal `waiting` — the RETRY's resume loses `conflict`, so it
381
+ * OBSERVES the recorded settlement, requires it to be THIS presenter's own `resumed` (a
382
+ * foreign or expired settlement rethrows), and finishes the projection idempotently (a goal
383
+ * already `running` is the converged state, not an error). */
384
+ export async function releaseGuardHold(ctx, args) {
385
+ // Entry snapshots (single-read): the presenter is compared against the recorded settlement on
386
+ // the convergence path, and the FULL goal detaches ONCE here (MEDIUM) so bind, resume, and the
387
+ // projection all read this snapshot - a goal mutated across the resume await can never validate
388
+ // goal A's checkpoint and then project goal B.
389
+ const presenter = Object.freeze({ id: String(args.presenter.id), lifecycleUid: String(args.presenter.lifecycleUid) });
390
+ const goal = snapshotRef(args.goal);
391
+ const token = String(args.token);
392
+ const cpRef = { endpoint: goal.endpoint, token };
393
+ const { obligations } = await bindCheckpointToGoal(ctx, goal, token); // goal-binding BEFORE consuming the one-use resume
394
+ let settle;
395
+ try {
396
+ settle = await resumeCheckpoint(ctx.kv, ctx.js, ctx.jsm, ctx.space, { ref: cpRef, presenter, now: args.now });
397
+ }
398
+ catch (e) {
399
+ if (!(e instanceof EpEnvelopeError && e.code === "conflict"))
400
+ throw e;
401
+ // The one-use resume is already consumed: converge IFF the recorded settlement is THIS
402
+ // presenter's own resume (the crashed earlier attempt won); anything else rethrows.
403
+ const winner = await readCheckpointSettle(ctx.jsm, ctx.space, cpRef);
404
+ if (winner === undefined || winner.settle !== "resumed"
405
+ || winner.holder?.id !== presenter.id || winner.holder?.lifecycleUid !== presenter.lifecycleUid)
406
+ throw e;
407
+ settle = winner;
408
+ }
409
+ // The goal returns from its owner-driven pause to running (the guard's holder-bound resume is
410
+ // the authority, verified by resumeCheckpoint; the proof is construction-bound), but ONLY if it
411
+ // is currently waiting on THIS hold's checkpoint (HIGH 1): a stale or replayed release of an OLD
412
+ // (already-resumed) hold must never move a goal that is now waiting on a DIFFERENT, live hold. An
413
+ // already-running goal is the converged crash state (idempotent); a goal waiting on another token
414
+ // (or terminal/unknown) refuses.
415
+ const current = await readGoalStatus(ctx, goal);
416
+ if (current?.value.state === "running")
417
+ return { settle, status: current.value, obligations };
418
+ const waitingToken = current?.value.state === "waiting" ? current.value.checkpoint?.token : undefined;
419
+ if (waitingToken !== token)
420
+ throw new EpEnvelopeError("failed-precondition", `goal "${goal.goalId}" is not waiting on checkpoint "${token}" (${current === undefined ? "unknown goal" : current.value.state === "waiting" ? `it waits on "${String(waitingToken)}"` : `it is ${current.value.state}`}); a release of an old hold never moves a goal paused on a newer one (SPEC 13.6)`);
421
+ const status = await transitionGoal(ctx, goal, "running", { owner: ownerCommitProof(ctx), clearance: mintGuardClearance(ctx, goal.goalId) });
422
+ return { settle, status, obligations };
423
+ }
424
+ /** Settle an EXPIRED guard hold onto the goal: an expired hold is DENY (fail closed). The token
425
+ * is first bound to THIS goal (an arbitrary token never terminal-fails an unrelated goal), then
426
+ * the CHECKPOINT is owner-expired (settling its status and stopping its timers, so no orphaned
427
+ * schedule lingers until the checkpoint's own deadline), and finally the goal commits terminal
428
+ * `failed` (permission-denied) at the shared commit point — where a racing completion or cancel
429
+ * may lawfully have won first (the caller observes the winner; the projection converges either
430
+ * way). Idempotent: an already-terminal goal returns its winner. */
431
+ export async function expireGuardHold(ctx, args) {
432
+ const goal = snapshotRef(args.goal); // detach the full goal ONCE (same discipline as release)
433
+ const token = String(args.token);
434
+ await bindCheckpointToGoal(ctx, goal, token); // goal-binding BEFORE terminalizing anything
435
+ const status = await readGoalStatus(ctx, goal);
436
+ if (status === undefined)
437
+ throw new EpEnvelopeError("failed-precondition", `goal "${goal.goalId}" is unknown; an expiry settles only an accepted goal (SPEC 13.6)`);
438
+ // Owner-expire the DUE checkpoint so its status settles and its timers stop (idempotent; an
439
+ // already-settled checkpoint returns its winner). The goal terminal is the authority for the
440
+ // caller, but the checkpoint must not be left waiting with a live timer.
441
+ const settled = await expireCheckpoint(ctx.kv, ctx.js, ctx.jsm, ctx.space, { ref: { endpoint: goal.endpoint, token }, now: args.now });
442
+ if (settled.settle === "resumed") {
443
+ // The hold was lawfully RELEASED before this expiry: a resumed hold never denies. A raced
444
+ // caller observes the goal's recorded terminal if one exists. If the release resumed the
445
+ // checkpoint but CRASHED before projecting the goal, the goal is still waiting on THIS token -
446
+ // FINISH that projection here (goal -> running) so it never hangs waiting forever (HIGH 4: a
447
+ // plain refusal is not crash recovery), then refuse (there is no terminal to return, and a
448
+ // resumed hold never denies). Idempotent: an already-running/re-held goal is not re-projected.
449
+ const fact = await readGoalResult(ctx, goal);
450
+ if (fact !== undefined)
451
+ return { won: false, fact, status: await projectGoalTerminal(ctx, goal) };
452
+ const cur = await readGoalStatus(ctx, goal);
453
+ if (cur?.value.state === "waiting" && cur.value.checkpoint?.token === token)
454
+ await transitionGoal(ctx, goal, "running", { owner: ownerCommitProof(ctx), clearance: mintGuardClearance(ctx, goal.goalId) });
455
+ throw new EpEnvelopeError("failed-precondition", `the guard hold "${token}" was RELEASED (resumed at ${settled.ts}), not expired; the goal projection is converged to running and a resumed hold never denies (SPEC 13.6)`);
456
+ }
457
+ // An expired hold is DENY (fail closed) → the goal commits terminal failed via the `deny`
458
+ // cause at the shared commit point, where a racing completion/cancel may win first. The
459
+ // denial carries its AUTHORITATIVE PREDICATE: the commit boundary itself re-verifies that
460
+ // the named checkpoint binds THIS goal and that its recorded one-use settlement is EXPIRED
461
+ // (the expiry recorded just above) — a bare deny cause proves nothing and is refused there.
462
+ const res = await commitGoalResult(ctx, {
463
+ ref: goal, now: args.now, cause: "deny", denial: { kind: "hold-expired", token },
464
+ data: { code: "permission-denied", reason: `the guard hold "${token}" expired without a release; timeout is deny (SPEC 13.6: fail closed)` },
465
+ });
466
+ return res;
467
+ }
468
+ //# sourceMappingURL=endpoint-guard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-guard.js","sourceRoot":"","sources":["../src/endpoint-guard.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,mBAAmB,EAAE,uBAAuB,EAAuB,MAAM,uBAAuB,CAAC;AACnI,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,gBAAgB,EAA6B,MAAM,0BAA0B,CAAC;AACnK,OAAO,EAAE,cAAc,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,gBAAgB,EAAE,uBAAuB,EAAE,WAAW,EAA+E,MAAM,sBAAsB,CAAC;AAEhR,MAAM,KAAK,GAAG,CAAC,CAAU,EAAgC,EAAE,CAAC,CAAC,KAAK,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAErH;;;sFAGsF;AACtF,MAAM,kBAAkB,GAAG,uBAAuB,EAAE,CAAC;AAErD;;;;;;qBAMqB;AACrB,MAAM,oBAAoB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