@cotal-ai/core 0.12.0 → 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 (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,431 @@
1
+ /**
2
+ * v0.4 journal-contract helpers (SPEC §13.4) — the semantic fingerprint, the decision and
3
+ * quarantine fact shapes with their consuming-boundary validators, and the create-only
4
+ * decision CAS the canonicalizer decides with.
5
+ *
6
+ * The journal is an explicitly UNTRUSTED at-least-once submission log (`epj`) feeding
7
+ * canonical accepted-fact subjects (`epf`) through ONE mediated writer, the canonicalizer.
8
+ * Effects consume only canonical facts, never raw submissions. Submissions append PLAIN —
9
+ * a conformant submitter never sets `Nats-Msg-Id` (native stream-wide dedupe is a
10
+ * cross-caller suppression vector, §13.4 item 1); every transport retry simply appends again,
11
+ * and the caller-scoped decision CAS resolves every copy to one durable decision.
12
+ */
13
+ import { headers as natsHeaders } from "@nats-io/transport-node";
14
+ import { token } from "./subjects.js";
15
+ import { contractDigest, rawDigest } from "./canonical.js";
16
+ import { epfSubject, parseEpSubject, endpointToken, assertBoundedOwner, assertIdToken, assertLifecycleToken, } from "./endpoint-subjects.js";
17
+ import { EpEnvelopeError, isEpErrorCode, parseEndpointRequest } from "./endpoint-envelope.js";
18
+ import { isCasLoss } from "./endpoint-records.js";
19
+ /** §13.12 stream names for the two journal-side streams. */
20
+ export function epjStreamName(space) { return `EPJ_${token(space)}`; }
21
+ export function epfStreamName(space) { return `EPF_${token(space)}`; }
22
+ /** The canonicalizer's durable (§13.9 consumer-name grammar): `canon_<e>`. Uses the fail-loud
23
+ * {@link endpointToken} (not the lenient `token`) so a malformed endpoint is refused, never
24
+ * silently sanitized into a colliding durable name. */
25
+ export function canonDurable(endpoint) { return `canon_${endpointToken(endpoint)}`; }
26
+ /** Decision facts live on the caller-scoped subject — distinct callers can never squat each
27
+ * other's ids because the caller triple IS part of the subject (§13.4 item 3). Provenance is
28
+ * STRUCTURAL, as for {@link deriveReplySubject}: the builder takes the broker-authenticated
29
+ * PARSED submission and derives endpoint + caller internally — there is no argument through
30
+ * which a body-supplied `from`/`op.endpoint` could address another caller's rail (the
31
+ * canonicalizer holds broad `epf.<e>.dec.>` authority; the broker cannot catch a confused
32
+ * call site, so the API must). */
33
+ export function epfDecisionSubject(space, request, id) {
34
+ const c = request.caller;
35
+ return epfSubject(space, request.endpoint, ["dec", c.owner, c.actor, c.uid, id]);
36
+ }
37
+ /** Quarantine facts key on the source SEQUENCE — a family disjoint from caller-chosen `dec`
38
+ * ids by construction, so no legal request id can collide with a quarantine key. */
39
+ export function epfQuarantineSubject(space, endpoint, sourceSeq) {
40
+ if (!Number.isSafeInteger(sourceSeq) || sourceSeq < 1)
41
+ throw new Error(`sourceSeq ${sourceSeq} is not a positive integer`);
42
+ return epfSubject(space, endpoint, ["quar", String(sourceSeq)]);
43
+ }
44
+ /** The per-goal first-wins bind (§13.4 item 3): stops a second id naming one goalId BEFORE
45
+ * acceptance and effect. Structural provenance as {@link epfDecisionSubject}. */
46
+ export function epfGoalBindSubject(space, source, goalId) {
47
+ const c = source.caller;
48
+ return epfSubject(space, source.endpoint, ["goal", c.owner, c.actor, c.uid, goalId, "bind"]);
49
+ }
50
+ /** The non-action effects completion fact (§13.9 ack barrier):
51
+ * `epf.<e>.eff.<caller triple>.<id>`. */
52
+ export function epfEffectSubject(space, endpoint, caller, id) {
53
+ return epfSubject(space, endpoint, ["eff", caller.owner, caller.actor, caller.uid, assertIdToken(id, "effect id")]);
54
+ }
55
+ /** Default idempotency horizon (§13.4 item 6; space-configurable). The horizon is REALIZED by
56
+ * decision-fact retention, never by a clock: the create-only CAS returns the recorded decision
57
+ * for exactly as long as the fact exists. */
58
+ export const IDEMPOTENCY_HORIZON_MS_DEFAULT = 24 * 60 * 60 * 1000;
59
+ // ---- the semantic fingerprint (§13.4 item 2) -------------------------------------------------
60
+ const FINGERPRINT_FIELDS = ["id", "goalId", "class", "args"];
61
+ /** Build the §13.4 fingerprint for a PARSEABLE submission: the effect-defining subset it
62
+ * carries — absent optional fields are OMITTED, never `null`, so two implementations digest
63
+ * identical bytes; an incomplete envelope fingerprints the subset it has. The caller identity
64
+ * and authorization mode come from the broker-authenticated SUBJECT, never the body. Throws
65
+ * when the carried values are not canonicalizable I-JSON (lone surrogate, duplicate names
66
+ * survive parsing as last-wins so cannot reach here, non-finite number) — that submission has
67
+ * no interoperable RFC 8785 form, hence NO fingerprint, and takes the quarantine path. */
68
+ export function submissionFingerprint(raw, subject) {
69
+ const body = (raw !== null && typeof raw === "object" && !Array.isArray(raw) ? raw : {});
70
+ const op = (body.op !== null && typeof body.op === "object" && !Array.isArray(body.op) ? body.op : {});
71
+ const object = {};
72
+ if (op.endpoint !== undefined)
73
+ object.endpoint = op.endpoint;
74
+ if (op.command !== undefined)
75
+ object.command = op.command;
76
+ for (const k of FINGERPRINT_FIELDS)
77
+ if (body[k] !== undefined)
78
+ object[k] = body[k];
79
+ if (op.inputDigest !== undefined)
80
+ object.inputDigest = op.inputDigest;
81
+ if (op.outputDigest !== undefined)
82
+ object.outputDigest = op.outputDigest;
83
+ if (subject.target)
84
+ object.authz = subject.target.mode;
85
+ if (body.target !== undefined)
86
+ object.target = body.target;
87
+ if (body.auth !== undefined) {
88
+ if (typeof body.auth === "string")
89
+ object.authDigest = rawDigest(body.auth); // throws on a lone surrogate → quarantine
90
+ // Wrong-typed but canonicalizable auth is CARRIED effect-defining content: fingerprint it
91
+ // as carried (distinct from absent auth AND from a real authDigest), never collapse it.
92
+ else
93
+ object.auth = body.auth;
94
+ }
95
+ object.caller = { id: `${subject.caller.owner}.${subject.caller.actor}`, lifecycleUid: subject.caller.uid };
96
+ return { object, fingerprint: contractDigest(object) }; // contractDigest throws on non-I-JSON → quarantine
97
+ }
98
+ /** Build the durable completion marker for one validated non-action `effects` acceptance. */
99
+ export function effectFactOf(acceptance, ts) {
100
+ if (acceptance.route !== "effects" || typeof acceptance.request.goalId === "string")
101
+ throw new EpEnvelopeError("failed-precondition", "an effect completion fact is only for a non-action route:effects acceptance (actions complete through goal.result)");
102
+ if (!isDigest(acceptance.fingerprint) || !posInt(acceptance.sourceSeq) || !wireInt(ts))
103
+ throw new EpEnvelopeError("failed-precondition", "an effect completion fact requires a validated acceptance fingerprint/sourceSeq and non-negative timestamp");
104
+ const caller = checkCaller(acceptance.caller, "effect acceptance caller");
105
+ return { v: 1, id: assertIdToken(acceptance.id, "effect id"), fingerprint: acceptance.fingerprint, caller, sourceSeq: acceptance.sourceSeq, ts, outcome: "ran" };
106
+ }
107
+ /** Build the retirement-cancelled completion marker for one validated non-action `effects`
108
+ * acceptance (§13.8 option (i)): the acceptance's own identity spine + the retirement binding.
109
+ * The caller supplies the retirement's `opId` and the RETIRING target; the acceptance's own
110
+ * `target` must name that same lifecycle (a retirement never cancels a foreign target's work). */
111
+ export function effectCancelledFactOf(acceptance, cancelled, ts) {
112
+ const base = effectFactOf(acceptance, ts);
113
+ if (typeof cancelled.opId !== "string" || cancelled.opId.length === 0 || cancelled.opId.length > 64)
114
+ throw new EpEnvelopeError("failed-precondition", "a cancelled effect marker requires the retirement opId (SPEC 13.8)");
115
+ const t = cancelled.target;
116
+ if (typeof t?.owner !== "string" || t.owner.length === 0 || typeof t.actor !== "string" || t.actor.length === 0 || typeof t.lifecycleUid !== "string" || t.lifecycleUid.length === 0)
117
+ throw new EpEnvelopeError("failed-precondition", "a cancelled effect marker requires the retiring target triple (SPEC 13.8)");
118
+ if (acceptance.target === undefined || acceptance.target.lifecycleUid !== t.lifecycleUid)
119
+ throw new EpEnvelopeError("failed-precondition", `a retirement cancels only ITS target's accepted work: the acceptance targets ${acceptance.target?.lifecycleUid ?? "(none)"}, not ${t.lifecycleUid} (SPEC 13.8)`);
120
+ return { ...base, outcome: "cancelled", cancelled: { opId: cancelled.opId, target: { owner: t.owner, actor: t.actor, lifecycleUid: t.lifecycleUid } } };
121
+ }
122
+ function factFail(what) {
123
+ throw new EpEnvelopeError("internal", `fact does not validate: ${what}`);
124
+ }
125
+ const isRec = (v) => v !== null && typeof v === "object" && !Array.isArray(v);
126
+ const wireInt = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 0;
127
+ const posInt = (v) => typeof v === "number" && Number.isSafeInteger(v) && v >= 1;
128
+ const isDigest = (v) => typeof v === "string" && /^sha256:[0-9a-f]{64}$/.test(v);
129
+ function assertClosedKeys(o, allowed, what) {
130
+ const ok = new Set(allowed);
131
+ for (const k of Object.keys(o))
132
+ if (!ok.has(k))
133
+ factFail(`${what} carries unknown field ${k}`);
134
+ }
135
+ function checkError(v, what) {
136
+ if (!isRec(v) || typeof v.code !== "string" || !isEpErrorCode(v.code))
137
+ factFail(`${what}.code`);
138
+ if (v.detail !== undefined && (typeof v.detail !== "string" || Buffer.byteLength(v.detail, "utf8") > 256))
139
+ factFail(`${what}.detail exceeds 256 bytes`);
140
+ return v;
141
+ }
142
+ function checkCaller(v, what) {
143
+ if (!isRec(v) || typeof v.id !== "string" || typeof v.lifecycleUid !== "string")
144
+ factFail(what);
145
+ const toks = v.id.split(".");
146
+ if (toks.length !== 2)
147
+ factFail(`${what}.id is not an <owner>.<actor> principal`);
148
+ try {
149
+ assertBoundedOwner(toks[0], `${what} owner`);
150
+ assertBoundedOwner(toks[1], `${what} actor`);
151
+ assertLifecycleToken(v.lifecycleUid, `${what}.lifecycleUid`);
152
+ }
153
+ catch (e) {
154
+ factFail(`${what}: ${e.message}`);
155
+ }
156
+ return v;
157
+ }
158
+ function checkAuthzDecision(v, what) {
159
+ if (!isRec(v) || !wireInt(v.revision) || !wireInt(v.epoch))
160
+ factFail(what);
161
+ }
162
+ function checkTarget(v) {
163
+ if (!isRec(v) || typeof v.owner !== "string" || typeof v.actor !== "string" || typeof v.lifecycleUid !== "string")
164
+ factFail("target");
165
+ try {
166
+ assertBoundedOwner(v.owner, "target owner");
167
+ assertBoundedOwner(v.actor, "target actor");
168
+ assertLifecycleToken(v.lifecycleUid, "target lifecycleUid");
169
+ }
170
+ catch (e) {
171
+ factFail(`target: ${e.message}`);
172
+ }
173
+ if (v.mappingRevision !== undefined && !wireInt(v.mappingRevision))
174
+ factFail("target.mappingRevision");
175
+ }
176
+ /** The embedded canonical request of an acceptance: it MUST be a fully valid canonical
177
+ * `EndpointRequest` (§13.3/§13.4), not merely a `{v,id,class,op}` shell — so it is routed
178
+ * through the SAME {@link parseEndpointRequest} the request boundary uses (its boundary error,
179
+ * a caller-facing code, maps to `internal` here because a malformed STORED request is a writer
180
+ * bug, not a caller error). Then it is cross-checked against the fact address so a stored
181
+ * acceptance can never smuggle a request for a different id/endpoint/caller into effects or
182
+ * replay: journal class, id, op.endpoint, and the request's own `from.id` must all agree with
183
+ * the broker-authenticated fact subject. Returns the parsed request for the target cross-check. */
184
+ function checkEmbeddedRequest(v, addr) {
185
+ let req;
186
+ try {
187
+ req = parseEndpointRequest(v);
188
+ }
189
+ catch (e) {
190
+ return factFail(`request is not a canonical EndpointRequest: ${e.message}`);
191
+ }
192
+ if (req.class !== "journal")
193
+ factFail("request.class (only journal-class submissions produce decision facts)");
194
+ if (req.id !== addr.id)
195
+ factFail("request.id disagrees with the fact address");
196
+ if (req.op.endpoint !== addr.endpoint)
197
+ factFail("request.op.endpoint disagrees with the fact address");
198
+ if (req.from.id !== addr.caller.id)
199
+ factFail("request.from.id disagrees with the authenticated fact caller");
200
+ return req;
201
+ }
202
+ /** Parse a decision-fact subject into its address — the mandatory seam through which every
203
+ * consuming boundary proves body↔subject agreement. Throws `internal` on a non-decision
204
+ * subject (a consumer wired to the wrong subject family is a bug, never a data error). */
205
+ export function parseDecisionFactSubject(subject) {
206
+ const p = parseEpSubject(subject);
207
+ if (!p || p.plane !== "fact" || p.topic.length !== 5 || p.topic[0] !== "dec")
208
+ throw new EpEnvelopeError("internal", `${subject} is not a decision-fact subject`);
209
+ return { endpoint: p.endpoint, caller: { id: `${p.topic[1]}.${p.topic[2]}`, lifecycleUid: p.topic[3] }, id: p.topic[4] };
210
+ }
211
+ /** Parse an effect-completion fact subject into its authenticated acceptance identity. */
212
+ export function parseEffectFactSubject(subject) {
213
+ const p = parseEpSubject(subject);
214
+ if (!p || p.plane !== "fact" || p.topic.length !== 5 || p.topic[0] !== "eff")
215
+ throw new EpEnvelopeError("internal", `${subject} is not an effect-completion fact subject`);
216
+ return { endpoint: p.endpoint, caller: { id: `${p.topic[1]}.${p.topic[2]}`, lifecycleUid: p.topic[3] }, id: p.topic[4] };
217
+ }
218
+ /** Validate a decision fact at its consuming boundary (§13.3: every plane is runtime-validated;
219
+ * effects and replay read THE FACT, never the raw submission). The fact must be
220
+ * SELF-SUFFICIENT canonical authority: every field is grammar-validated (caller principal,
221
+ * positive source sequence/timestamp, digest forms, the embedded canonical request, the
222
+ * resolved target triple), and the body's id/caller/endpoint must AGREE with the
223
+ * broker-authenticated fact subject — a mismatch is a writer bug or corrupt store and fails
224
+ * loud before effects or replay can attribute the decision. */
225
+ export function parseDecisionFact(raw, subject) {
226
+ const addr = parseDecisionFactSubject(subject);
227
+ const o = isRec(raw) ? raw : factFail("not an object");
228
+ if (o.v !== 1)
229
+ factFail("v");
230
+ if (typeof o.id !== "string")
231
+ factFail("id");
232
+ try {
233
+ assertIdToken(o.id, "fact id");
234
+ }
235
+ catch {
236
+ factFail("id grammar");
237
+ }
238
+ if (o.id !== addr.id)
239
+ factFail("id disagrees with the fact subject");
240
+ if (!isDigest(o.fingerprint))
241
+ factFail("fingerprint");
242
+ // sourceSeq is a stream sequence (>= 1); ts is a wire timestamp (>= 0, §13.7).
243
+ if (!posInt(o.sourceSeq))
244
+ factFail("sourceSeq must be a positive stream sequence");
245
+ if (!wireInt(o.ts))
246
+ factFail("ts must be a non-negative integer");
247
+ const caller = checkCaller(o.caller, "caller");
248
+ if (caller.id !== addr.caller.id || caller.lifecycleUid !== addr.caller.lifecycleUid)
249
+ factFail("caller disagrees with the fact subject");
250
+ if (o.decision === "rejected") {
251
+ checkError(o.error, "error");
252
+ if (o.authzDecision !== undefined)
253
+ checkAuthzDecision(o.authzDecision, "authzDecision");
254
+ return o;
255
+ }
256
+ if (o.decision !== "accepted")
257
+ factFail(`decision ${JSON.stringify(o.decision)}`);
258
+ const req = checkEmbeddedRequest(o.request, addr);
259
+ // The stored acceptance must expose ONE coherent effect authority (§13.4: self-sufficient for
260
+ // effect and replay) — target presence is EQUIVALENT to the request's (§13.3: a body target
261
+ // exists exactly for the targeted modes): a targeted acceptance that dropped its target is not
262
+ // replayable, and an untargeted request with a spurious fact target smuggles authority the
263
+ // caller never asked for.
264
+ if ((req.target !== undefined) !== (o.target !== undefined))
265
+ factFail(req.target !== undefined
266
+ ? "a targeted request's acceptance must persist the resolved target"
267
+ : "an untargeted request's acceptance must not carry a target");
268
+ if (o.target !== undefined && req.target !== undefined) {
269
+ checkTarget(o.target);
270
+ // The fact target must equal the request's FULL tuple. lifecycleUid is the caller's EXPECTED
271
+ // binding, validator-checked against the current mapping (§13.3) — resolution validates it,
272
+ // never replaces it; goals bind (principal, lifecycleUid) (§13.6), so a substituted UID
273
+ // redirects effect/replay to a recycled alias. A caller-pinned mappingRevision pins the
274
+ // exact observed revision; only an OMITTED one may be filled by resolution.
275
+ const ft = o.target;
276
+ if (req.target.owner !== ft.owner || req.target.actor !== ft.actor || req.target.lifecycleUid !== ft.lifecycleUid)
277
+ factFail("the fact target does not equal the embedded request's target tuple");
278
+ if (req.target.mappingRevision !== undefined && ft.mappingRevision !== req.target.mappingRevision)
279
+ factFail("the fact target does not carry the mappingRevision the request pinned");
280
+ }
281
+ const cd = o.contractDigests;
282
+ if (!isRec(cd) || !isDigest(cd.input) || !isDigest(cd.output))
283
+ factFail("contractDigests");
284
+ // Where the request pinned contract digests (§13.3: required on every command except
285
+ // `describe`), the fact's contractDigests must EQUAL them — otherwise consumers validate and
286
+ // effect under a different contract than the caller accepted. An omitted digest (describe)
287
+ // is the only fill: the fact then carries the canonicalizer-resolved digest uncompared.
288
+ if (req.op.inputDigest !== undefined && cd.input !== req.op.inputDigest)
289
+ factFail("contractDigests.input disagrees with the embedded request's pinned op.inputDigest");
290
+ if (req.op.outputDigest !== undefined && cd.output !== req.op.outputDigest)
291
+ factFail("contractDigests.output disagrees with the embedded request's pinned op.outputDigest");
292
+ checkAuthzDecision(o.authzDecision, "authzDecision");
293
+ if (o.route !== "effects" && !(typeof o.route === "string" && /^pool\.[a-z0-9-]{1,32}$/.test(o.route)))
294
+ factFail("route");
295
+ if (o.readinessDeadlineMs !== undefined && !wireInt(o.readinessDeadlineMs))
296
+ factFail("readinessDeadlineMs must be a non-negative integer");
297
+ if (o.workExpiry !== undefined && !posInt(o.workExpiry))
298
+ factFail("workExpiry");
299
+ if (String(o.route).startsWith("pool.") !== (o.workExpiry !== undefined))
300
+ factFail("workExpiry is present iff the route is a pool");
301
+ return o;
302
+ }
303
+ /** Validate a non-action effects completion fact at the consuming boundary — the CLOSED
304
+ * two-member union: the effect ran ({@link EffectFact}) or it was retirement-cancelled
305
+ * ({@link EffectCancelledFact}; the `cancelled` discriminator, whose block must itself be
306
+ * closed and complete). A bare marker on the right subject is not enough: the body must bind
307
+ * the accepted fingerprint and source sequence so the drain can compare it to the decision
308
+ * that authorized this exact effect — for BOTH members. */
309
+ export function parseEffectFact(raw, subject) {
310
+ const addr = parseEffectFactSubject(subject);
311
+ const o = isRec(raw) ? raw : factFail("effect fact is not an object");
312
+ // The SYMMETRIC outcome discriminant (the goal union's bar): every member declares its outcome,
313
+ // so a fact missing it — or claiming one outcome while carrying the other's fields — refuses.
314
+ if (o.outcome !== "ran" && o.outcome !== "cancelled")
315
+ factFail("effect.outcome must be \"ran\" or \"cancelled\"");
316
+ const isCancelled = o.outcome === "cancelled";
317
+ assertClosedKeys(o, isCancelled ? ["v", "id", "fingerprint", "caller", "sourceSeq", "ts", "outcome", "cancelled"] : ["v", "id", "fingerprint", "caller", "sourceSeq", "ts", "outcome"], `effect fact on ${subject}`);
318
+ if (o.v !== 1)
319
+ factFail("effect.v");
320
+ if (o.id !== addr.id)
321
+ factFail("effect.id disagrees with the fact subject");
322
+ if (!isDigest(o.fingerprint))
323
+ factFail("effect.fingerprint");
324
+ if (!posInt(o.sourceSeq))
325
+ factFail("effect.sourceSeq must be a positive stream sequence");
326
+ if (!wireInt(o.ts))
327
+ factFail("effect.ts must be a non-negative integer");
328
+ const caller = checkCaller(o.caller, "effect.caller");
329
+ if (caller.id !== addr.caller.id || caller.lifecycleUid !== addr.caller.lifecycleUid)
330
+ factFail("effect.caller disagrees with the fact subject");
331
+ const base = { v: 1, id: addr.id, fingerprint: o.fingerprint, caller, sourceSeq: o.sourceSeq, ts: o.ts };
332
+ if (!isCancelled)
333
+ return { ...base, outcome: "ran" };
334
+ const c = o.cancelled;
335
+ if (!isRec(c))
336
+ factFail("effect.cancelled is not an object");
337
+ assertClosedKeys(c, ["opId", "target"], `effect.cancelled on ${subject}`);
338
+ if (typeof c.opId !== "string" || c.opId.length === 0 || c.opId.length > 64)
339
+ factFail("effect.cancelled.opId");
340
+ const t = c.target;
341
+ if (!isRec(t))
342
+ factFail("effect.cancelled.target is not an object");
343
+ assertClosedKeys(t, ["owner", "actor", "lifecycleUid"], `effect.cancelled.target on ${subject}`);
344
+ if (typeof t.owner !== "string" || t.owner.length === 0 || typeof t.actor !== "string" || t.actor.length === 0 || typeof t.lifecycleUid !== "string" || t.lifecycleUid.length === 0)
345
+ factFail("effect.cancelled.target triple");
346
+ return { ...base, outcome: "cancelled", cancelled: { opId: c.opId, target: { owner: t.owner, actor: t.actor, lifecycleUid: t.lifecycleUid } } };
347
+ }
348
+ /** Validate a quarantine fact at its consuming boundary; the body's source sequence must agree
349
+ * with the `epf….quar.<seq>` subject it was stored under. */
350
+ export function parseQuarantineFact(raw, subject) {
351
+ const p = parseEpSubject(subject);
352
+ if (!p || p.plane !== "fact" || p.topic.length !== 2 || p.topic[0] !== "quar")
353
+ throw new EpEnvelopeError("internal", `${subject} is not a quarantine-fact subject`);
354
+ const o = isRec(raw) ? raw : factFail("not an object");
355
+ if (o.v !== 1 || o.decision !== "quarantined")
356
+ factFail("v/decision");
357
+ if (!posInt(o.sourceSeq))
358
+ factFail("sourceSeq must be a positive integer");
359
+ if (String(o.sourceSeq) !== p.topic[1])
360
+ factFail("sourceSeq disagrees with the fact subject");
361
+ if (!isDigest(o.submissionDigest))
362
+ factFail("submissionDigest");
363
+ checkError(o.error, "error");
364
+ if (o.caller !== undefined)
365
+ checkCaller(o.caller, "caller");
366
+ if (!wireInt(o.ts))
367
+ factFail("ts must be a non-negative integer");
368
+ return o;
369
+ }
370
+ /** Preflight a fact's SERIALIZED size against the broker's max_payload (§13.4 item 5): an
371
+ * acceptance that would not fit is rejected `resource-exhausted` BEFORE any decision exists
372
+ * (the rejection fact always fits by construction — every field bounded or fixed-size). */
373
+ export function assertFactFits(fact, maxPayload) {
374
+ const bytes = new TextEncoder().encode(JSON.stringify(fact));
375
+ if (bytes.length > maxPayload)
376
+ throw new EpEnvelopeError("resource-exhausted", `the serialized decision fact is ${bytes.length} bytes (max_payload ${maxPayload}); a submission whose acceptance cannot fit is refused loudly, never spilled into storage`);
377
+ return bytes;
378
+ }
379
+ // ---- the decision CAS (§13.4 item 3: first decision wins atomically) -------------------------
380
+ /** Append a submission PLAIN (§13.4 item 1): never a `Nats-Msg-Id`, no dedupe header of any
381
+ * kind — the guarantee rests on the header rule, not the window. Returns the stream ack. */
382
+ export async function appendSubmission(js, subject, envelope) {
383
+ const pa = await js.publish(subject, new TextEncoder().encode(JSON.stringify(envelope)));
384
+ return { seq: pa.seq };
385
+ }
386
+ /** Publish a fact with create-only CAS (expected last sequence ON THE SUBJECT = 0). Returns
387
+ * `{ won: true, seq }` or `{ won: false }` on a lost CAS — the loser then READS the winning
388
+ * fact ({@link readLastFact}) instead of deciding again. Any non-CAS failure propagates. */
389
+ export async function publishFactCreateOnly(js, subject, factBytes) {
390
+ const h = natsHeaders();
391
+ h.set("Nats-Expected-Last-Subject-Sequence", "0");
392
+ try {
393
+ const pa = await js.publish(subject, factBytes, { headers: h });
394
+ return { won: true, seq: pa.seq };
395
+ }
396
+ catch (e) {
397
+ // The SHARED structured classifier (err_code, never message text): a missed classification
398
+ // here would turn a benign concurrent decision into an unhandled throw in the mediated
399
+ // writer — a normal race becoming an error/stall is exactly the failure text-matching risks.
400
+ if (isCasLoss(e))
401
+ return { won: false };
402
+ throw e;
403
+ }
404
+ }
405
+ /** Last-by-subject read of a fact — LEADER-SERVED (`STREAM.MSG.GET`, never `DIRECT.GET`). The
406
+ * §13.4 loser-reads-winner contract needs read-your-writes against the leader that just
407
+ * rejected the CAS: a follower-served Direct Get carries no such guarantee and, after legal
408
+ * post-horizon id reuse, can return a STALE prior fact (semantically a DIFFERENT decision) or
409
+ * nothing — and no retry can distinguish a stale nonempty fact from the current winner. EPF
410
+ * keeps `allow_direct=true` for other trusted subject-confined reads (§13.12); the CAS-winner
411
+ * read is deliberately not one of them. `undefined` when no fact exists on the subject. */
412
+ export async function readLastFact(jsm, stream, subject) {
413
+ let m;
414
+ try {
415
+ m = await jsm.streams.getMessage(stream, { last_by_subj: subject });
416
+ }
417
+ catch (e) {
418
+ if (e.code === 10037)
419
+ return undefined; // no message found on the subject
420
+ throw e;
421
+ }
422
+ if (!m)
423
+ return undefined;
424
+ try {
425
+ return JSON.parse(new TextDecoder().decode(m.data));
426
+ }
427
+ catch (e) {
428
+ throw new EpEnvelopeError("internal", `fact on ${subject} does not decode as JSON: ${e.message}`);
429
+ }
430
+ }
431
+ //# sourceMappingURL=endpoint-journal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"endpoint-journal.js","sourceRoot":"","sources":["../src/endpoint-journal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEjE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EACL,UAAU,EAAE,cAAc,EAAE,aAAa,EAAE,kBAAkB,EAAE,aAAa,EAC5E,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,oBAAoB,EAAwB,MAAM,wBAAwB,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElD,4DAA4D;AAC5D,MAAM,UAAU,aAAa,CAAC,KAAa,IAAY,OAAO,OAAO,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AACtF,MAAM,UAAU,aAAa,CAAC,KAAa,IAAY,OAAO,OAAO,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC;AACtF;;wDAEwD;AACxD,MAAM,UAAU,YAAY,CAAC,QAAgB,IAAY,OAAO,SAAS,aAAa,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;AAErG;;;;;;mCAMm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