@volter/world-core 2.0.37 → 3.0.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 (205) hide show
  1. package/README.md +4 -5
  2. package/app-route.cjs +12 -6
  3. package/app-route.d.cts +1 -1
  4. package/dist/app-route.cjs +12 -6
  5. package/dist/app-route.d.cts +1 -1
  6. package/dist/generated/pack-facts.json +1410 -3069
  7. package/dist/inject.cjs +64 -9
  8. package/dist/pack-facts.cjs +44 -0
  9. package/dist/src/actions.d.ts +3 -3
  10. package/dist/src/actions.js +22 -16
  11. package/dist/src/ancestry.d.ts +14 -2
  12. package/dist/src/ancestry.js +92 -2
  13. package/dist/src/anthropic-wire.d.ts +39 -0
  14. package/dist/src/anthropic-wire.js +136 -0
  15. package/dist/src/bytes.d.ts +7 -0
  16. package/dist/src/bytes.js +35 -0
  17. package/dist/src/changeset.d.ts +1 -1
  18. package/dist/src/changeset.js +0 -0
  19. package/dist/src/clickhouse/index.d.ts +3 -0
  20. package/dist/src/clickhouse/index.js +6 -0
  21. package/dist/src/clickhouse/sql.d.ts +233 -0
  22. package/dist/src/clickhouse/sql.js +4329 -0
  23. package/dist/src/clickhouse/types.d.ts +18 -0
  24. package/dist/src/clickhouse/types.js +47 -0
  25. package/dist/src/clickhouse/values.d.ts +146 -0
  26. package/dist/src/clickhouse/values.js +858 -0
  27. package/dist/src/client-bundle.js +2 -3
  28. package/dist/src/cors.d.ts +15 -0
  29. package/dist/src/cors.js +31 -0
  30. package/dist/src/derived-core.d.ts +487 -24
  31. package/dist/src/derived-core.js +788 -144
  32. package/dist/src/derived-real.d.ts +13 -0
  33. package/dist/src/derived-real.js +518 -0
  34. package/dist/src/derived.d.ts +35 -1
  35. package/dist/src/derived.js +61 -9
  36. package/dist/src/emit.js +1 -2
  37. package/dist/src/events.d.ts +206 -0
  38. package/dist/src/events.js +341 -0
  39. package/dist/src/executor.d.ts +3 -0
  40. package/dist/src/executor.js +19 -2
  41. package/dist/src/file-response.d.ts +6 -0
  42. package/dist/src/file-response.js +30 -0
  43. package/dist/src/fork.js +3 -2
  44. package/dist/src/git/history.d.ts +7 -0
  45. package/dist/src/git/history.js +24 -0
  46. package/dist/src/git/index.d.ts +1 -0
  47. package/dist/src/git/index.js +1 -0
  48. package/dist/src/git/lfs.d.ts +28 -0
  49. package/dist/src/git/lfs.js +66 -0
  50. package/dist/src/git/objects.js +3 -8
  51. package/dist/src/git/smart-http.d.ts +3 -1
  52. package/dist/src/git/smart-http.js +67 -6
  53. package/dist/src/graphql-wire.d.ts +29 -0
  54. package/dist/src/graphql-wire.js +101 -0
  55. package/dist/src/grpc-wire.d.ts +67 -0
  56. package/dist/src/grpc-wire.js +170 -0
  57. package/dist/src/h2.d.ts +40 -0
  58. package/dist/src/h2.js +656 -0
  59. package/dist/src/head.d.ts +32 -3
  60. package/dist/src/head.js +161 -40
  61. package/dist/src/history.d.ts +1 -1
  62. package/dist/src/history.js +6 -6
  63. package/dist/src/hpack.json +1 -0
  64. package/dist/src/index.d.ts +64 -75
  65. package/dist/src/index.js +58 -101
  66. package/dist/src/log.js +28 -19
  67. package/dist/src/machines.d.ts +50 -0
  68. package/dist/src/machines.js +151 -0
  69. package/dist/src/managed-database.d.ts +86 -0
  70. package/dist/src/managed-database.js +283 -0
  71. package/dist/src/multipart.d.ts +11 -0
  72. package/dist/src/multipart.js +51 -0
  73. package/dist/src/observe.d.ts +15 -5
  74. package/dist/src/observe.js +23 -9
  75. package/dist/src/openai-wire.d.ts +108 -0
  76. package/dist/src/openai-wire.js +337 -0
  77. package/dist/src/pack-assets.d.ts +3 -4
  78. package/dist/src/pack-assets.js +15 -10
  79. package/dist/src/pack-fetch.d.ts +77 -0
  80. package/dist/src/pack-fetch.js +449 -0
  81. package/dist/src/pack-paths.d.ts +12 -0
  82. package/dist/src/pack-paths.js +86 -0
  83. package/dist/src/packRegistry.d.ts +69 -162
  84. package/dist/src/packRegistry.js +55 -20
  85. package/dist/src/people.d.ts +13 -0
  86. package/dist/src/people.js +18 -0
  87. package/dist/src/placeholder-image.d.ts +5 -0
  88. package/dist/src/placeholder-image.js +114 -0
  89. package/dist/src/protobuf.d.ts +28 -0
  90. package/dist/src/protobuf.js +332 -0
  91. package/dist/src/redis/engine.js +1 -1
  92. package/dist/src/request-scope.d.ts +1 -1
  93. package/dist/src/request-scope.js +6 -4
  94. package/dist/src/resource-blob.d.ts +5 -0
  95. package/dist/src/resource-blob.js +11 -0
  96. package/dist/src/runtime.d.ts +85 -0
  97. package/dist/src/runtime.js +104 -0
  98. package/dist/src/s3/wire.d.ts +60 -0
  99. package/dist/src/s3/wire.js +157 -0
  100. package/dist/src/scenario.d.ts +3 -0
  101. package/dist/src/scenario.js +2 -0
  102. package/dist/src/schema-sample.d.ts +1 -0
  103. package/dist/src/schema-sample.js +21 -0
  104. package/dist/src/sealed-box.d.ts +14 -0
  105. package/dist/src/sealed-box.js +225 -0
  106. package/dist/src/serve-http.d.ts +14 -0
  107. package/dist/src/serve-http.js +27 -3
  108. package/dist/src/serve.d.ts +6 -0
  109. package/dist/src/serve.js +69 -14
  110. package/dist/src/signing.d.ts +135 -0
  111. package/dist/src/signing.js +222 -0
  112. package/dist/src/sigv4.d.ts +48 -0
  113. package/dist/src/sigv4.js +167 -0
  114. package/dist/src/smtp.d.ts +16 -0
  115. package/dist/src/smtp.js +72 -0
  116. package/dist/src/sockets.d.ts +51 -0
  117. package/dist/src/sockets.js +90 -0
  118. package/dist/src/state-system.d.ts +1 -0
  119. package/dist/src/state-system.js +1 -1
  120. package/dist/src/storage.d.ts +1 -1
  121. package/dist/src/storage.js +3 -3
  122. package/dist/src/trace-context.js +1 -1
  123. package/dist/src/twin-fetch.d.ts +0 -7
  124. package/dist/src/twin-fetch.js +0 -14
  125. package/dist/src/vendor-call.d.ts +6 -0
  126. package/dist/src/vendor-call.js +41 -0
  127. package/dist/src/world-store.js +1 -1
  128. package/dist/vendor-hosts.cjs +36 -125
  129. package/dist/vendor-hosts.d.cts +8 -0
  130. package/generated/pack-facts.json +1410 -3069
  131. package/inject.cjs +64 -9
  132. package/pack-facts.cjs +44 -0
  133. package/package.json +17 -3
  134. package/src/actions.ts +23 -16
  135. package/src/ancestry.ts +74 -2
  136. package/src/anthropic-wire.ts +137 -0
  137. package/src/bytes.ts +42 -0
  138. package/src/changeset.ts +5 -5
  139. package/src/clickhouse/index.ts +6 -0
  140. package/src/clickhouse/sql.ts +3059 -0
  141. package/src/clickhouse/types.ts +44 -0
  142. package/src/clickhouse/values.ts +697 -0
  143. package/src/client-bundle.ts +2 -3
  144. package/src/cors.ts +34 -0
  145. package/src/derived-core.ts +1013 -146
  146. package/src/derived-real.ts +434 -0
  147. package/src/derived.ts +73 -3
  148. package/src/emit.ts +1 -2
  149. package/src/events.ts +449 -0
  150. package/src/executor.ts +24 -2
  151. package/src/file-response.ts +27 -0
  152. package/src/fork.ts +3 -2
  153. package/src/git/history.ts +19 -0
  154. package/src/git/index.ts +1 -0
  155. package/src/git/lfs.ts +67 -0
  156. package/src/git/objects.ts +3 -5
  157. package/src/git/smart-http.ts +56 -6
  158. package/src/graphql-wire.ts +106 -0
  159. package/src/grpc-wire.ts +159 -0
  160. package/src/h2.ts +627 -0
  161. package/src/head.ts +132 -41
  162. package/src/history.ts +6 -6
  163. package/src/hpack.json +1 -0
  164. package/src/index.ts +82 -329
  165. package/src/log.ts +27 -18
  166. package/src/machines.ts +151 -0
  167. package/src/managed-database.ts +299 -0
  168. package/src/multipart.ts +51 -0
  169. package/src/observe.ts +31 -15
  170. package/src/openai-wire.ts +371 -0
  171. package/src/pack-assets.ts +15 -11
  172. package/src/pack-fetch.ts +458 -0
  173. package/src/pack-paths.ts +72 -0
  174. package/src/packRegistry.ts +79 -167
  175. package/src/people.ts +31 -0
  176. package/src/placeholder-image.ts +88 -0
  177. package/src/protobuf.ts +251 -0
  178. package/src/redis/engine.ts +1 -1
  179. package/src/request-scope.ts +8 -4
  180. package/src/resource-blob.ts +13 -0
  181. package/src/runtime.ts +344 -0
  182. package/src/s3/wire.ts +172 -0
  183. package/src/scenario.ts +4 -0
  184. package/src/schema-sample.ts +24 -0
  185. package/src/sealed-box.ts +182 -0
  186. package/src/serve-http.ts +31 -3
  187. package/src/serve.ts +58 -14
  188. package/src/signing.ts +231 -0
  189. package/src/sigv4.ts +158 -0
  190. package/src/smtp.ts +76 -0
  191. package/src/sockets.ts +140 -0
  192. package/src/state-system.ts +2 -2
  193. package/src/storage.ts +3 -3
  194. package/src/trace-context.ts +1 -1
  195. package/src/twin-fetch.ts +0 -20
  196. package/src/vendor-call.ts +41 -0
  197. package/src/world-store.ts +1 -1
  198. package/vendor-hosts.cjs +36 -125
  199. package/vendor-hosts.d.cts +8 -0
  200. package/dist/src/mirror-shell.d.ts +0 -2
  201. package/dist/src/mirror-shell.js +0 -13
  202. package/dist/src/v1-removed.d.ts +0 -159
  203. package/dist/src/v1-removed.js +0 -124
  204. package/src/mirror-shell.ts +0 -15
  205. package/src/v1-removed.ts +0 -172
@@ -9,6 +9,13 @@ export type PushOutcome = {
9
9
  externalId: string;
10
10
  url?: string;
11
11
  data?: Record<string, unknown>;
12
+ /** the group's entry the id is for, when it is not the group's first (a cascade writes children first) */
13
+ actionId?: string;
14
+ /** the group's other entries the answer named an id for (a resource's `companions`) */
15
+ also?: Array<{
16
+ actionId: string;
17
+ externalId: string;
18
+ }>;
12
19
  };
13
20
  /** What a perform is handed beside the executor: a resolver from a local id to the vendor's (an
14
21
  * entry authored against `twin-1` crosses against `REAL-42` once that subject's landing adopted it). */
@@ -22,7 +29,8 @@ export type PerformContext = {
22
29
  root?: string;
23
30
  credential?: string;
24
31
  };
25
- export type PerformAction = (execute: RemoteExecute, action: TwinAction, ctx: PerformContext) => Promise<PushOutcome>;
32
+ /** One request's entries (a group: they share its `correlationId`), performed as the one call that made them. */
33
+ export type PerformAction = (execute: RemoteExecute, group: TwinAction[], ctx: PerformContext) => Promise<PushOutcome>;
26
34
  export declare function performContext(service: string, root?: string, credential?: string): PerformContext;
27
35
  /** The user's key-encryption key: `$XDG_CONFIG_HOME/volter/kek` (created on first use). */
28
36
  export declare function userKekPath(): string;
@@ -129,9 +137,18 @@ export type DeployReport = {
129
137
  skipped: string[];
130
138
  /** entries whose landed copy already said `deployed` — not performed again */
131
139
  replayed: string[];
140
+ /** entries the World's own doors made (a door, a screen, the gap, the clock, a seed): never offered to the vendor */
141
+ worldOnly: string[];
132
142
  };
133
- /** The branch entries a root twin still has to perform: `set` rows, not reverted, whose landed copy
134
- * is absent or says `failed`/`skipped` (a `deployed` or `refused` copy settles the entry). */
143
+ /** The branch entries a root twin still has to settle: `set` rows, not reverted, whose landed copy is absent or says
144
+ * `failed`/`skipped` (a `deployed` or `refused` copy settles the entry), split into what is offered to the vendor (a
145
+ * surface write on a subject the vendor can have) and what is the World's own: a write a door, a screen, the gap, the
146
+ * clock or a seed made, and any write on a subject only the World's own writes made. */
147
+ export declare function settlingEntries(service: string, root?: string): {
148
+ offered: TwinAction[];
149
+ worldOnly: TwinAction[];
150
+ };
151
+ /** The entries a root twin offers the vendor (settlingEntries' `offered`). */
135
152
  export declare function deployableEntries(service: string, root?: string): TwinAction[];
136
153
  /**
137
154
  * PERFORM this twin's deployable entries against its root, in order, checks in front of every one,
@@ -157,6 +174,18 @@ export declare function performAtHead(service: string, action: Pick<TwinAction,
157
174
  externalId?: string;
158
175
  data?: unknown;
159
176
  }>;
177
+ /** Run a pack fetch's handling of one request with its writes' perform deferred to the group (`performRequestGroup`):
178
+ * its answer, and whether it appended (a request that wrote nothing has no group, and consults no head). */
179
+ export declare function deferPerform<T>(request: string, fn: () => Promise<T>): Promise<{
180
+ value: T;
181
+ appended: boolean;
182
+ }>;
183
+ /** Under `auto`, perform the entries one request made as one call (the real-system adapters, "Perform"): the ids the
184
+ * vendor gave them by local id, or the vendor's refusal or failure, the request's entries reverted as performAtHead
185
+ * reverts one. Nothing when the head is not real and auto, or the request wrote nothing the vendor is offered. */
186
+ export declare function performRequestGroup(service: string, request: string, root?: string): Promise<{
187
+ ids: Map<string, string>;
188
+ } | RefusedWriteError | VendorWriteError>;
160
189
  /** Wrap a pack's fetch: a `RefusedWriteError` or `VendorWriteError` the head raised becomes the
161
190
  * vendor's own error body (the pack's `shape`), so an app under live use sees what the vendor
162
191
  * would have said. Anything else propagates. */
package/dist/src/head.js CHANGED
@@ -18,7 +18,7 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
18
18
  import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
19
19
  import { homedir } from 'node:os';
20
20
  import { basename, dirname, isAbsolute, join, resolve } from 'node:path';
21
- import { confirmAction, isTwinBookkeeping, resolveSubjectId, revertAction } from "./actions.js";
21
+ import { confirmAction, currentCorrelationId, isTwinBookkeeping, resolveSubjectId, revertAction } from "./actions.js";
22
22
  import { keySealer } from "./credential.js";
23
23
  import { buildRemoteExecute, validateRemoteOrigin } from "./executor.js";
24
24
  import { getPack } from "./packRegistry.js";
@@ -250,19 +250,47 @@ function receiptsByEntry(parent) {
250
250
  out.set(e.landsId, e.receipt);
251
251
  return out;
252
252
  }
253
- /** The branch entries a root twin still has to perform: `set` rows, not reverted, whose landed copy
254
- * is absent or says `failed`/`skipped` (a `deployed` or `refused` copy settles the entry). */
255
- export function deployableEntries(service, root) {
253
+ /** Whether an entry records a call of the vendor's surface (an operation or a GraphQL mutation): what a perform can send
254
+ * again (the real-system adapters, "What the derived core records with a write"). */
255
+ function surfaceWrite(e) {
256
+ return typeof e.input?.operationId === 'string' || (e.input?.graphql !== undefined && e.input.graphql !== null);
257
+ }
258
+ /** The branch entries a root twin still has to settle: `set` rows, not reverted, whose landed copy is absent or says
259
+ * `failed`/`skipped` (a `deployed` or `refused` copy settles the entry), split into what is offered to the vendor (a
260
+ * surface write on a subject the vendor can have) and what is the World's own: a write a door, a screen, the gap, the
261
+ * clock or a seed made, and any write on a subject only the World's own writes made. */
262
+ export function settlingEntries(service, root) {
256
263
  const parent = parentEntries(service, root);
257
264
  const receipts = receiptsByEntry(parent);
258
265
  const branch = branchEntries(service, root);
259
266
  const reverted = new Set(branch.filter((e) => e.op === 'revert' && e.revertsActionId).map((e) => e.revertsActionId));
260
- return branch.filter((e) => {
261
- if (e.op !== 'set' || reverted.has(e.id) || isTwinBookkeeping(e))
262
- return false;
263
- const r = receipts.get(e.id);
264
- return r === undefined || r.status === 'failed' || r.status === 'skipped';
265
- });
267
+ const live = branch.filter((e) => e.op === 'set' && !reverted.has(e.id) && !isTwinBookkeeping(e));
268
+ // a subject some surface write made (or the vendor holds: the parent log knows it) is the vendor's; one only the
269
+ // World's own writes made is not, and nothing written to it is sent
270
+ const key = (e) => `${e.subject.type}\u0000${e.subject.id}`;
271
+ const first = new Map();
272
+ for (const e of live)
273
+ if (!first.has(key(e)))
274
+ first.set(key(e), e);
275
+ const vendors = new Set([...[...first].filter(([, e]) => surfaceWrite(e)).map(([k]) => k), ...parent.filter((e) => !e.landsId).map(key)]);
276
+ const pending = live.filter((e) => { const r = receipts.get(e.id); return r === undefined || r.status === 'failed' || r.status === 'skipped'; });
277
+ return {
278
+ offered: pending.filter((e) => surfaceWrite(e) && vendors.has(key(e))),
279
+ worldOnly: pending.filter((e) => !surfaceWrite(e) || !vendors.has(key(e))),
280
+ };
281
+ }
282
+ /** The entries a root twin offers the vendor (settlingEntries' `offered`). */
283
+ export function deployableEntries(service, root) {
284
+ return settlingEntries(service, root).offered;
285
+ }
286
+ /** Entries in groups of the request that made them (their `correlationId`), each group in log order. */
287
+ function groupsOf(entries) {
288
+ const groups = new Map();
289
+ for (const e of entries) {
290
+ const k = e.correlationId ?? e.id;
291
+ groups.set(k, [...(groups.get(k) ?? []), e]);
292
+ }
293
+ return [...groups.values()];
266
294
  }
267
295
  const queues = new Map(); // one performer per twin: wire writes perform in append order
268
296
  /**
@@ -294,63 +322,104 @@ async function performNow(opts) {
294
322
  const vendor = bound.vendor;
295
323
  const adapters = opts.adapters ?? stateSystemFor(vendor) ?? stateSystemFor(service);
296
324
  if (!adapters?.perform)
297
- throw new Error(`the ${vendor} twin has no perform adapter — a protocol 2 pack names one in its descriptor and registers itself (registerPack)`);
325
+ throw new Error(`the ${vendor} twin has no perform adapter — a pack names one in its descriptor and registers itself (registerPack)`);
298
326
  // the caller's executor, or the one built over the sealed credential; an unsealed root has no other
299
- const execute = opts.execute ?? buildRemoteExecute(validateRemoteOrigin(bound.sealed.url, { allowInsecureLoopback: true }), await openRootCredential(bound.sealed, vendor), authStrategyFor(vendor), getPack(vendor)?.hosts, { custody: rootCustody(bound.sealed, vendor) });
327
+ const execute = opts.execute ?? buildRemoteExecute(validateRemoteOrigin(bound.sealed.url, { allowInsecureLoopback: true }), await openRootCredential(bound.sealed, vendor), authStrategyFor(vendor), getPack(vendor)?.hosts, { custody: rootCustody(bound.sealed, vendor), vendor });
300
328
  // an unsealed root's World is where its state resolves (the root given, PROJECT_ROOT, or the working directory)
301
329
  const checks = opts.checks ?? (await loadChecks(bound.sealed ? worldRootOf(bound.sealed) : worldPaths(service, root).root));
302
- const deployable = deployableEntries(service, root);
303
- const entries = opts.actionIds === undefined ? deployable : opts.actionIds.map((id) => deployable.find((a) => a.id === id)).filter((a) => a !== undefined);
304
- const report = { pushed: 0, deployed: [], skipped: [], replayed: [] };
330
+ const settling = settlingEntries(service, root);
331
+ const pick = (list) => (opts.actionIds === undefined ? list : opts.actionIds.map((id) => list.find((a) => a.id === id)).filter((a) => a !== undefined));
332
+ const report = { pushed: 0, deployed: [], skipped: [], replayed: [], worldOnly: pick(settling.worldOnly).map((e) => e.id) };
305
333
  if (opts.actionIds) {
306
334
  const settled = receiptsByEntry(parentEntries(service, root));
307
335
  for (const id of opts.actionIds)
308
336
  if (settled.get(id)?.status === 'deployed')
309
337
  report.replayed.push(id);
310
338
  }
339
+ const settle = (action, at, receipt, fields = action.fields ?? {}, vendorSubjectId) => {
340
+ confirmAction({ service, actionId: action.id, subject: action.subject, fields, occurredAt: at, ...(vendorSubjectId ? { vendorSubjectId } : {}), receipt, ...(root !== undefined ? { root } : {}) });
341
+ };
342
+ // the subjects the vendor refused and never took: a request naming one is the World's alone, never sent (the
343
+ // real-system adapters, "Perform" 3), settled as it landed here
344
+ const parent = parentEntries(service, root);
345
+ const taken = new Set();
346
+ const refusedIds = new Set();
347
+ for (const e of parent) {
348
+ if (e.receipt?.status === 'deployed')
349
+ taken.add(e.aliasOf ?? e.subject.id);
350
+ else if (e.receipt?.status === 'refused')
351
+ refusedIds.add(e.subject.id);
352
+ }
353
+ for (const id of taken)
354
+ refusedIds.delete(id);
355
+ const named = (action) => { const out = []; const walk = (v) => { if (typeof v === 'string')
356
+ out.push(v);
357
+ else if (v && typeof v === 'object')
358
+ for (const x of Object.values(v))
359
+ walk(x); }; const i = (action.input ?? {}); walk(i.path); walk(i.query); walk(i.body); return out; };
311
360
  let stopped = false;
312
- for (const action of entries) {
361
+ for (const group of groupsOf(pick(settling.offered))) {
313
362
  if (stopped) {
314
- report.skipped.push(action.id);
363
+ report.skipped.push(...group.map((a) => a.id));
364
+ continue;
365
+ }
366
+ if (named(group[0]).some((v) => refusedIds.has(v))) {
367
+ const at = opts.at ?? worldNow();
368
+ for (const action of group) {
369
+ settle(action, at, { status: 'landed', reason: 'names a subject the vendor refused: the World\'s alone' });
370
+ refusedIds.add(action.subject.id);
371
+ }
372
+ report.worldOnly.push(...group.map((a) => a.id));
315
373
  continue;
316
374
  }
317
375
  const at = opts.at ?? worldNow();
318
- const verdict = await runChecks(checks, action, readTree(service, root));
376
+ // checks in front of every entry: one refused refuses the group, which is one call
377
+ let verdict = null;
378
+ for (const action of group) {
379
+ verdict = await runChecks(checks, action, readTree(service, root));
380
+ if (verdict)
381
+ break;
382
+ }
319
383
  if (verdict) {
320
- confirmAction({ service, actionId: action.id, subject: action.subject, fields: action.fields ?? {}, occurredAt: at, receipt: { status: 'refused', reason: `${verdict.name}: ${verdict.reason}` }, ...(root !== undefined ? { root } : {}) });
321
- report.refused = { actionId: action.id, check: verdict.name, reason: verdict.reason };
384
+ for (const action of group)
385
+ settle(action, at, { status: 'refused', reason: `${verdict.name}: ${verdict.reason}` });
386
+ report.refused = { actionId: group[0].id, check: verdict.name, reason: verdict.reason };
322
387
  stopped = true;
323
388
  continue;
324
389
  }
390
+ // a declared reference to an adopted id is resolved before the pack sees the entry: the vendor is
391
+ // asked about #7, never the local #3 (docs/contributing/architecture.md#alias-aware-lookup-at-the-request-boundary)
392
+ const aliases = aliasesFrom(parentEntries(service, root));
393
+ const resolved = group.map((action) => { const fields = resolveReferences(service, action.subject.type, action.fields ?? {}, aliases); return fields === action.fields ? action : { ...action, fields }; });
325
394
  try {
326
- // a declared reference to an adopted id is resolved before the pack sees the entry: the vendor is
327
- // asked about #7, never the local #3 (docs/contributing/architecture.md#alias-aware-lookup-at-the-request-boundary)
328
- const fields = resolveReferences(service, action.subject.type, action.fields ?? {}, aliasesFrom(parentEntries(service, root)));
329
- const outcome = await adapters.perform(execute, fields === action.fields ? action : { ...action, fields }, performContext(service, root, bound.sealed ? rootCredentialFingerprint(bound.sealed) : undefined));
330
- // the vendor's answer, when the adapter returned one as fields, is what the landed copy holds
395
+ const outcome = await adapters.perform(execute, resolved, performContext(service, root, bound.sealed ? rootCredentialFingerprint(bound.sealed) : undefined));
396
+ // the vendor's answer, when the adapter returned one as fields, is what the primary entry's landed copy holds
331
397
  const answered = outcome.data !== null && typeof outcome.data === 'object' && !Array.isArray(outcome.data) ? outcome.data : {};
332
- confirmAction({
333
- service, actionId: action.id, subject: action.subject, fields: { ...fields, ...answered }, occurredAt: at,
334
- ...(outcome.externalId ? { vendorSubjectId: outcome.externalId } : {}),
335
- receipt: { status: 'deployed', ...(outcome.url ? { url: outcome.url } : {}) },
336
- ...(root !== undefined ? { root } : {}),
337
- });
338
- report.pushed += 1;
339
- report.deployed.push({ actionId: action.id, at, ...(outcome.externalId ? { externalId: outcome.externalId } : {}), ...(outcome.data !== undefined ? { data: outcome.data } : {}) });
398
+ const primary = resolved.find((a) => a.id === outcome.actionId) ?? resolved[0];
399
+ const also = new Map((outcome.also ?? []).map((a) => [a.actionId, a.externalId]));
400
+ for (const action of resolved) {
401
+ const externalId = action === primary ? outcome.externalId : also.get(action.id);
402
+ settle(action, at, { status: 'deployed', ...(action === primary && outcome.url ? { url: outcome.url } : {}) }, action === primary ? { ...action.fields, ...answered } : action.fields ?? {}, externalId || undefined);
403
+ report.pushed += 1;
404
+ report.deployed.push({ actionId: action.id, at, ...(externalId ? { externalId } : {}), ...(action === primary && outcome.data !== undefined ? { data: outcome.data } : {}) });
405
+ }
340
406
  }
341
407
  catch (error) {
342
- // a write the pack itself refuses (it can never be sent: its subject never reached the vendor) is
343
- // settled as refused, as a check's refusal is, so the next deploy moves on to the entry after it;
344
- // anything else failed and stays deployable for a retry
408
+ // a write the vendor refuses (a 4xx: it can never be sent as it is) settles the group refused, as a check's
409
+ // refusal does, so the next deploy moves on to the group after it; anything else failed and stays offered
345
410
  if (error instanceof RefusedWriteError) {
346
- confirmAction({ service, actionId: action.id, subject: action.subject, fields: action.fields ?? {}, occurredAt: at, receipt: { status: 'refused', reason: error.message }, ...(root !== undefined ? { root } : {}) });
347
- report.refused = { actionId: action.id, check: error.check, reason: error.reason };
411
+ for (const action of group) {
412
+ settle(action, at, { status: 'refused', reason: error.message });
413
+ refusedIds.add(action.subject.id);
414
+ }
415
+ report.refused = { actionId: group[0].id, check: error.check, reason: error.reason };
348
416
  stopped = true;
349
417
  continue;
350
418
  }
351
419
  const message = error instanceof Error ? error.message : String(error);
352
- confirmAction({ service, actionId: action.id, subject: action.subject, fields: action.fields ?? {}, occurredAt: at, receipt: { status: 'failed', reason: message }, ...(root !== undefined ? { root } : {}) });
353
- report.failed = { actionId: action.id, error: message };
420
+ for (const action of group)
421
+ settle(action, at, { status: 'failed', reason: message });
422
+ report.failed = { actionId: group[0].id, error: message };
354
423
  stopped = true;
355
424
  }
356
425
  }
@@ -362,6 +431,13 @@ async function performNow(opts) {
362
431
  * Raises `RefusedWriteError` / `VendorWriteError` for the pack to answer in the vendor's shape.
363
432
  */
364
433
  export async function performAtHead(service, action, root) {
434
+ // a pack fetch performs its request's entries as one group after the handler (performRequestGroup)
435
+ const request = currentCorrelationId();
436
+ const mark = request !== undefined ? deferred.get(request) : undefined;
437
+ if (mark) {
438
+ mark.appended = true;
439
+ return { performed: false };
440
+ }
365
441
  const head = headOf(service, root);
366
442
  if (head.kind !== 'real' || head.deploy !== 'auto')
367
443
  return { performed: false };
@@ -384,6 +460,51 @@ export async function performAtHead(service, action, root) {
384
460
  const done = report.deployed.find((d) => d.actionId === action.id);
385
461
  return { performed: done !== undefined, ...(done?.externalId ? { externalId: done.externalId } : {}), ...(done?.data !== undefined ? { data: done.data } : {}) };
386
462
  }
463
+ /** The requests a pack fetch is answering, whose entries it performs as one group when the handler returns, and
464
+ * whether each has appended any. */
465
+ const deferred = new Map();
466
+ /** Run a pack fetch's handling of one request with its writes' perform deferred to the group (`performRequestGroup`):
467
+ * its answer, and whether it appended (a request that wrote nothing has no group, and consults no head). */
468
+ export async function deferPerform(request, fn) {
469
+ const mark = { appended: false };
470
+ deferred.set(request, mark);
471
+ try {
472
+ return { value: await fn(), appended: mark.appended };
473
+ }
474
+ finally {
475
+ deferred.delete(request);
476
+ }
477
+ }
478
+ /** Under `auto`, perform the entries one request made as one call (the real-system adapters, "Perform"): the ids the
479
+ * vendor gave them by local id, or the vendor's refusal or failure, the request's entries reverted as performAtHead
480
+ * reverts one. Nothing when the head is not real and auto, or the request wrote nothing the vendor is offered. */
481
+ export async function performRequestGroup(service, request, root) {
482
+ const head = headOf(service, root);
483
+ const ids = new Map();
484
+ if (head.kind !== 'real' || head.deploy !== 'auto')
485
+ return { ids };
486
+ const group = deployableEntries(service, root).filter((e) => e.correlationId === request);
487
+ if (!group.length)
488
+ return { ids };
489
+ let report;
490
+ try {
491
+ report = await performEntries({ service, actionIds: group.map((e) => e.id), ...(root !== undefined ? { root } : {}) });
492
+ }
493
+ catch (error) {
494
+ throw error instanceof HeadError ? error : new HeadError(error instanceof Error ? error.message : String(error));
495
+ }
496
+ if (report.refused || report.failed) {
497
+ for (const e of [...group].reverse())
498
+ revertAction({ service, actionId: e.id, occurredAt: worldNow(), ...(root !== undefined ? { root } : {}) });
499
+ return report.refused ? new RefusedWriteError(report.refused.check, report.refused.reason, report.refused.actionId) : new VendorWriteError(report.failed.error, report.failed.actionId);
500
+ }
501
+ for (const d of report.deployed) {
502
+ const e = group.find((g) => g.id === d.actionId);
503
+ if (e && d.externalId && d.externalId !== e.subject.id)
504
+ ids.set(e.subject.id, d.externalId);
505
+ }
506
+ return { ids };
507
+ }
387
508
  /** Wrap a pack's fetch: a `RefusedWriteError` or `VendorWriteError` the head raised becomes the
388
509
  * vendor's own error body (the pack's `shape`), so an app under live use sees what the vendor
389
510
  * would have said. Anything else propagates. */
@@ -50,7 +50,7 @@ export declare function saveHistoryView(directory: string, view: HistoryView): s
50
50
  * refuses (`historyEntries`), instead of serving a tree folded from the history it replaced. */
51
51
  export declare function inheritedHistoryKey(service: string, root?: string): string;
52
52
  export declare function inheritedHistory(service: string, root?: string): HistoryView | undefined;
53
- /** Capture under the same coordinator as append and complete observation batches. */
53
+ /** Capture under the directory's history lock, as appends and complete observation batches are made. */
54
54
  export declare function captureHistory(service: string, root?: string): {
55
55
  view: string;
56
56
  position: number;
@@ -3,7 +3,7 @@ import { createHash } from 'node:crypto';
3
3
  import { join } from 'node:path';
4
4
  import { resolveReferences } from "./references.js";
5
5
  import { canonicalJson } from "./hash.js";
6
- import { canonicalStatePath, checkParent, commitParentPin, pinParent, stateGeneration, withAncestryLock } from "./ancestry.js";
6
+ import { canonicalStatePath, checkParent, commitParentPin, pinParent, stateGeneration, withAncestryLock, withHistoryLock } from "./ancestry.js";
7
7
  import { getActiveWorldStore } from "./world-store.js";
8
8
  import { worldPaths } from "./storage.js";
9
9
  import { aliasesFrom, foldHistory, branchEntries, isUrlParent, readBranchMeta, toEntry } from "./log.js";
@@ -144,9 +144,9 @@ export function inheritedHistory(service, root) {
144
144
  checkParent(worldPaths(service, parent.at).dir, parent.generation);
145
145
  return historyPrefix(readHistoryView(directory, parent.view), parent.position);
146
146
  }
147
- /** Capture under the same coordinator as append and complete observation batches. */
147
+ /** Capture under the directory's history lock, as appends and complete observation batches are made. */
148
148
  export function captureHistory(service, root) {
149
- return withAncestryLock(() => {
149
+ return withHistoryLock(worldPaths(service, root).dir, () => {
150
150
  const directory = canonicalStatePath(worldPaths(service, root).dir);
151
151
  getActiveWorldStore().mkdir(directory);
152
152
  if (!getActiveWorldStore().exists(join(directory, 'history-format.json')))
@@ -170,7 +170,7 @@ export function originHead(service, root) {
170
170
  }
171
171
  /** A complete remote view shares cached rows by content, never by mutable offsets or entry ID. */
172
172
  export function publishOriginHistory(service, root, remoteView, layout, entries) {
173
- return withAncestryLock(() => {
173
+ return withHistoryLock(worldPaths(service, root).dir, () => {
174
174
  if (entries.length !== historyLength(layout))
175
175
  throw new Error('Incomplete origin history view');
176
176
  const directory = canonicalStatePath(worldPaths(service, root).dir);
@@ -209,7 +209,7 @@ export function publishOriginHistory(service, root, remoteView, layout, entries)
209
209
  }
210
210
  /** A changeset binds the complete inherited view, including this root's observations. */
211
211
  export function captureParentHistory(service, root) {
212
- return withAncestryLock(() => {
212
+ return withHistoryLock(worldPaths(service, root).dir, () => {
213
213
  const head = captureHistory(service, root);
214
214
  const position = head.position - head.descriptor.layout.branch;
215
215
  return { view: saveHistoryView(worldPaths(service, root).dir, historyPrefix(head.descriptor, position)), position };
@@ -242,7 +242,7 @@ export function historyChanges(service, before, after) {
242
242
  }
243
243
  /** A timestamp can select across layers; represent it as a view, never a misleading offset. */
244
244
  export function historyAtInstant(service, instant, root, selectedView) {
245
- return withAncestryLock(() => {
245
+ return withHistoryLock(worldPaths(service, root).dir, () => {
246
246
  const stamp = Date.parse(instant);
247
247
  if (!Number.isFinite(stamp))
248
248
  throw new Error('Invalid history instant');
@@ -0,0 +1 @@
1
+ {"source":"RFC 7541 Appendix A and B","staticTable":[[":authority",""],[":method","GET"],[":method","POST"],[":path","/"],[":path","/index.html"],[":scheme","http"],[":scheme","https"],[":status","200"],[":status","204"],[":status","206"],[":status","304"],[":status","400"],[":status","404"],[":status","500"],["accept-charset",""],["accept-encoding","gzip, deflate"],["accept-language",""],["accept-ranges",""],["accept",""],["access-control-allow-origin",""],["age",""],["allow",""],["authorization",""],["cache-control",""],["content-disposition",""],["content-encoding",""],["content-language",""],["content-length",""],["content-location",""],["content-range",""],["content-type",""],["cookie",""],["date",""],["etag",""],["expect",""],["expires",""],["from",""],["host",""],["if-match",""],["if-modified-since",""],["if-none-match",""],["if-range",""],["if-unmodified-since",""],["last-modified",""],["link",""],["location",""],["max-forwards",""],["proxy-authenticate",""],["proxy-authorization",""],["range",""],["referer",""],["refresh",""],["retry-after",""],["server",""],["set-cookie",""],["strict-transport-security",""],["transfer-encoding",""],["user-agent",""],["vary",""],["via",""],["www-authenticate",""]],"huffman":[[8184,13],[8388568,23],[268435426,28],[268435427,28],[268435428,28],[268435429,28],[268435430,28],[268435431,28],[268435432,28],[16777194,24],[1073741820,30],[268435433,28],[268435434,28],[1073741821,30],[268435435,28],[268435436,28],[268435437,28],[268435438,28],[268435439,28],[268435440,28],[268435441,28],[268435442,28],[1073741822,30],[268435443,28],[268435444,28],[268435445,28],[268435446,28],[268435447,28],[268435448,28],[268435449,28],[268435450,28],[268435451,28],[20,6],[1016,10],[1017,10],[4090,12],[8185,13],[21,6],[248,8],[2042,11],[1018,10],[1019,10],[249,8],[2043,11],[250,8],[22,6],[23,6],[24,6],[0,5],[1,5],[2,5],[25,6],[26,6],[27,6],[28,6],[29,6],[30,6],[31,6],[92,7],[251,8],[32764,15],[32,6],[4091,12],[1020,10],[8186,13],[33,6],[93,7],[94,7],[95,7],[96,7],[97,7],[98,7],[99,7],[100,7],[101,7],[102,7],[103,7],[104,7],[105,7],[106,7],[107,7],[108,7],[109,7],[110,7],[111,7],[112,7],[113,7],[114,7],[252,8],[115,7],[253,8],[8187,13],[524272,19],[8188,13],[16380,14],[34,6],[32765,15],[3,5],[35,6],[4,5],[36,6],[5,5],[37,6],[38,6],[39,6],[6,5],[116,7],[117,7],[40,6],[41,6],[42,6],[7,5],[43,6],[118,7],[44,6],[8,5],[9,5],[45,6],[119,7],[120,7],[121,7],[122,7],[123,7],[32766,15],[2044,11],[16381,14],[8189,13],[268435452,28],[1048550,20],[4194258,22],[1048551,20],[1048552,20],[4194259,22],[4194260,22],[4194261,22],[8388569,23],[4194262,22],[8388570,23],[8388571,23],[8388572,23],[8388573,23],[8388574,23],[16777195,24],[8388575,23],[16777196,24],[16777197,24],[4194263,22],[8388576,23],[16777198,24],[8388577,23],[8388578,23],[8388579,23],[8388580,23],[2097116,21],[4194264,22],[8388581,23],[4194265,22],[8388582,23],[8388583,23],[16777199,24],[4194266,22],[2097117,21],[1048553,20],[4194267,22],[4194268,22],[8388584,23],[8388585,23],[2097118,21],[8388586,23],[4194269,22],[4194270,22],[16777200,24],[2097119,21],[4194271,22],[8388587,23],[8388588,23],[2097120,21],[2097121,21],[4194272,22],[2097122,21],[8388589,23],[4194273,22],[8388590,23],[8388591,23],[1048554,20],[4194274,22],[4194275,22],[4194276,22],[8388592,23],[4194277,22],[4194278,22],[8388593,23],[67108832,26],[67108833,26],[1048555,20],[524273,19],[4194279,22],[8388594,23],[4194280,22],[33554412,25],[67108834,26],[67108835,26],[67108836,26],[134217694,27],[134217695,27],[67108837,26],[16777201,24],[33554413,25],[524274,19],[2097123,21],[67108838,26],[134217696,27],[134217697,27],[67108839,26],[134217698,27],[16777202,24],[2097124,21],[2097125,21],[67108840,26],[67108841,26],[268435453,28],[134217699,27],[134217700,27],[134217701,27],[1048556,20],[16777203,24],[1048557,20],[2097126,21],[4194281,22],[2097127,21],[2097128,21],[8388595,23],[4194282,22],[4194283,22],[33554414,25],[33554415,25],[16777204,24],[16777205,24],[67108842,26],[8388596,23],[67108843,26],[134217702,27],[67108844,26],[67108845,26],[134217703,27],[134217704,27],[134217705,27],[134217706,27],[134217707,27],[268435454,28],[134217708,27],[134217709,27],[134217710,27],[134217711,27],[134217712,27],[67108846,26],[1073741823,30]]}
@@ -1,76 +1,65 @@
1
- export { clearRegistry, getPack, hasPack, listPacks, registerPack, pullPosture, assertContinuousPullAllowed, pullOnSchedule, resolvePullVendor, DEFAULT_PULL_POSTURE, DEFAULT_PULL_TRIGGER, PROTOCOL_VERSION, PROTOCOL_MAJOR, protocolStanding } from './packRegistry.js';
2
- export type { PackTransport, PullPosture, PullTrigger, PullVendor, RoundTripWrite, TwinPack } from './packRegistry.js';
3
- export { parseScenarioDocument, scenarioFaultResult, ScenarioEngine, ScenarioError, statefulTwinManifest, twinManifest } from './scenario.js';
4
- export { WORLD_CLOCK_ENV, worldNow } from './world-clock.js';
5
- export { WORLD_ENV_NAMES_ENV, worldEnvValue } from './world-env.js';
6
- export { createTwinFetchFromHandler, TWIN_PREFIX_HEADER, TWIN_REQUEST_SCOPES, twinPublicBase, withRequestScopes } from './twin-fetch.js';
7
- export { isReadOnlyRequest, READ_ONLY_REQUEST_HEADER, ReadOnlyRequestError, runAsReadOnlyRequest, runAsVendorMove, writesRefused } from './request-scope.js';
8
- export { compileSurface, createDerivedFetch, matchOperation } from './derived.js';
9
- export { currentTraceparent, deliveryTraceHeaders, newTraceparent, parseTraceparent, runWithRequestTrace, runWithTraceparent, TRACEPARENT_HEADER, traceparentForDelivery, validTraceparent } from './trace-context.js';
10
- export type { Traceparent } from './trace-context.js';
11
- export type { DerivedCall, DerivedCoreOutcome, DerivedFetch, DerivedFetchOptions, DerivedHandler, DerivedOperation, DerivedOwner, DerivedSurface } from './derived.js';
12
- export { bindSemantics, coreFor, crossCutting, derivedRequestScopes, observeTransitions, resourcesOfType as twinResourcesOfType, semanticsContext, stateOf, transitionFor, parseBracketForm, readParams, render as renderDerived, serveCore, sse, vendorError } from './derived-core.js';
13
- export type { Actor, CoreScope, DerivedManifest, ErrorSpec, FieldRule, Handler, HandlerContext, ResourceDecl, WriteHookContext, ScreenDecl, Semantics, SemanticsContext, StateField, Transition, TransitionObserver } from './derived-core.js';
14
- export type { RemoteExecute, RemoteExecuteRequest, RemoteExecuteResponse } from './remote-execute.js';
15
- export type { TwinFetchAdapterConfig, TwinFetchHandlerRequest, TwinFetchHandlerResult, TwinStream, TwinStreamConnection, TwinStreamSink } from './twin-fetch.js';
16
- export type { PackScenarioAdapter, ScenarioDecision, ScenarioDocument, ScenarioExtractorSpec, ScenarioFault, ScenarioFaultResult, ScenarioFeatures, ScenarioHandler, ScenarioMatcher, ScenarioMissRecord, ScenarioStatus } from './scenario.js';
17
- export { emitTwinEvent, eventSubscriptionMatches, listEmittable, runEmitCli } from './emit.js';
18
- export type { EmitDeliveryResult, EmitEndpoint, EmitReport, EmittableEvent, SynthesizedDelivery, TwinEmitter } from './emit.js';
19
- export { DEFAULT_RATE_BUDGET, MAX_RATE_BUDGET_CEILING, MAX_RATE_BUDGET_WINDOW_MS, MIN_RATE_BUDGET_WEIGHT, MIN_RATE_BUDGET_WINDOW_MS, RateBudget, RateBudgetError, declareRateBudget, hasRateBudgetDeclaration, listRateBudgets, priceCall, rateBudgetPath, rateBudgetPolicy, rateBudgetWeight, resetToSeconds, assertBudgetGuardIntact, } from './rateBudget.js';
20
- export type { RateBudgetDeclaration, RateBudgetErrorKind, RateBudgetOptions, RateBudgetPolicy, RateBudgetReservation, RateBudgetSnapshot, RateBudgetWeightRule, } from './rateBudget.js';
21
- export { GenericWorldStateSchema, WorldActorSchema, WorldExternalRefSchema, WorldServiceEventSchema, WorldSubjectSchema, } from './schemas.js';
22
- export { loadWorldConfig, } from './worldConfig.js';
23
- export type { WorldConfig, WorldServiceConfig, } from './worldConfig.js';
24
- export { DELTA_TYPE_SUFFIX, diffSubjectFields, hashFieldValue, subjectKey, deltaAfterFields } from './hash.js';
25
- export type { FieldChange, SubjectFields, } from './hash.js';
26
- export { appendDurable, appendEvent, createEvent, emptyGenericState, genericWorldReducer, listEvents, loadState, projectionLockPath, readJsonFile, rebuildGenericState, rebuildState, scrubService, scrubWorld, stateDirName, twinLog, withFileLock, worldPaths, worldStateRoot, ownerStoreRoots, WORLD_DATA_ENV, } from './storage.js';
27
- export type { AppendEventResult, CommitQueuedEventsResult, GenericWorldState, EnqueueEventResult, QueuedWorldServiceEvent, WorldPaths, WorldReducer, WorldServiceEvent, } from './types.js';
28
- export type { ScrubResult } from './storage.js';
29
- export { FsWorldStore, MemoryWorldStore, getActiveWorldStore, setActiveWorldStore, withWorldStore, hydrateInto, flushFrom, } from './world-store.js';
30
- export type { WorldStore, WorldStat, HydrationSource, HydrationSink } from './world-store.js';
31
- export type { CheckLoader } from './head.js';
32
- export { SqlWorldStore } from './world-store-sql.js';
33
- export type { SqlExec } from './world-store-sql.js';
34
- export { FsBlobStore, MemoryBlobStore, blobDigest, getActiveBlobStore, setActiveBlobStore, withBlobStore, readBlobRange, } from './blob-store.js';
35
- export type { BlobStore } from './blob-store.js';
36
- export { applyTwinWrite, applyTwinWriteAtomic, createTwinServer, CALLER_HEADER, journalTwinRequest, twinRequestJournalFailures, twinRequestCredentials, readTwinRequestJournal, resolveTwinRead, twinRequestJournalEnabled, twinRequestJournalPath, readTwinRequestJournalFrom, type TwinRequestJournalCursor, twinResources, } from './serve.js';
37
- export type { AtomicTwinWriteDecision, TwinRequestJournalEntry, TwinResource, TwinWriteInput, TwinWriteResult, } from './serve.js';
38
- export { createTwinProxy } from './proxy.js';
39
- export type { TwinProxy, TwinProxyOptions, VendorRoute } from './proxy.js';
40
- export { forkTwin, isFork, readForkMeta, } from './fork.js';
41
- export type { ForkMeta } from './fork.js';
42
- export { appendAction, appendTransactionCommit, checkPrecondition, confirmAction, listActions, listTransactionCommits, pendingActions, pushablePendingActions, isTwinBookkeeping, pendingTransactionCommits, projectResources, projectOwnerResources, OwnerStoreAmbiguousError, revertAction, TwinActionPreconditionError, subjectAliases, resolveSubjectId, runWithCorrelationId, currentCorrelationId } from './actions.js';
43
- export type { ActionProjection, ProjectedDelivery, ProjectedResource, ProjectedResourcePatch, ProjectedResourceRef, TwinAction, TwinActionOp, TwinActionPrecondition, TwinActionPreconditionOp, TwinActionRevertSpec, TwinTransactionCommit, TwinTransactionCommitOp, TwinTransactionPrecondition, TwinTransactionRevertSpec, } from './actions.js';
44
- export { approveChangeset, assertMarkerBelongsTo, assertSafeChangesetName, assertValidVerifiers, buildChangeset, captureMarker, changesetContentHash, changesetHashMatches, changesetReadiness, approverOf, CHANGESET_KIND, diffLedgers, formatApplication, formatChangeset, formatRebaseReport, narrateActions, narrationDrift, rebaseChangeset, formatChangesetStatus, formatLedgerDelta, formatReplayReport, formatVerification, MARKER_KIND, normalizeChangeset, parseVerifierExpression, replayChangeset, runChangesetVerifiers, summarizeByVendor, twinWriteShape, withApplication, withVerification, worldBootMarker, WORLD_BOOT_MARKER_ID, } from './changeset.js';
45
- export type { ApplyReceipt, RebaseActionResult, RebaseReport, RebaseTarget, Changeset, ChangesetAction, ChangesetApplication, CompensationEntry, ChangesetApproval, ChangesetReadiness, ChangesetVerification, ChangesetVerifier, ChangesetVerifierResult, LedgerDelta, LedgerPosition, LedgerRef, ReplayActionResult, ReplayReport, ReplayTarget, VendorSummary, WorldMarker, } from './changeset.js';
46
- export { getActivePackAssets, setActivePackAssets, packAsset, assetContentType, confinedAssetPath, LocalPackAssets, BindingPackAssets, type PackAssetStore } from './pack-assets.js';
1
+ import { bindSemantics as bindAny, type CoreScope, type Handler } from './derived-core.js';
2
+ import type { DerivedHandler, DerivedSurface } from './derived.js';
3
+ import type { DerivedManifest } from './derived-core.js';
4
+ import { type PackDescriptor } from './packRegistry.js';
5
+ export type { PackDescriptor, PackTransport } from './packRegistry.js';
6
+ /** The descriptor a manifest declares, with its vendor ("The descriptor"); given the pack's generated surface (a vendor of
7
+ * lanes: each lane's manifest and surface), with the real-system adapters the kernel derives from them. */
8
+ export declare const packOf: (manifest: {
9
+ vendor: string;
10
+ descriptor?: Omit<PackDescriptor, "vendor">;
11
+ }, surface?: DerivedSurface | Record<string, {
12
+ manifest: DerivedManifest;
13
+ surface: DerivedSurface;
14
+ }>) => PackDescriptor;
15
+ /** The pack registered, so the World finds it. */
16
+ export declare const registerPack: (pack: PackDescriptor) => PackDescriptor;
17
+ export type { Actor, CoreScope, DerivedManifest, ErrorSpec, LaneRoute, LanesDecl, VendorManifest, FieldRule, ResourceDecl, ScreenDecl, SeedCall, StateField, Transition } from './derived-core.js';
18
+ export type { ApplicationAnswer, EndpointsDecl, EventRender, EventScheme, EventsDecl, EventTransport, EventValues, EventWrite } from './events.js';
19
+ export { verifyEvent } from './events.js';
20
+ export { deriveStateSystem, deriveVendorStateSystem } from './derived-real.js';
21
+ export type { IngestDecl } from './derived-core.js';
22
+ export type { SocketDecl, SocketEngine, SocketSession } from './sockets.js';
23
+ export { machinePool, type ExecSpec, type MachinePool, type MachineProcess, type MachineRun, type MachineSpec } from './machines.js';
24
+ export type { CorsDecl } from './cors.js';
25
+ export type { Handler, HandlerContext, WriteHookContext } from './derived-core.js';
26
+ export type { MultipartPart } from './multipart.js';
27
+ /** A pack's handlers, by operationId, bound to the manifest: each is answered over the contract's context. */
28
+ export declare const bindSemantics: (m: Parameters<typeof bindAny>[0], handlers: Record<string, Handler>, scope?: CoreScope) => Record<string, DerivedHandler>;
29
+ export { createPackFetch, createVendorFetch, type LanePart, type PackFetchOptions, type PackParts, type PackScenario } from './pack-fetch.js';
30
+ export { createDerivedFetch } from './derived.js';
31
+ export type { DerivedCall, DerivedFetch, DerivedFetchOptions, DerivedHandler, DerivedOperation, DerivedSurface } from './derived.js';
32
+ export { coreFor, crossCutting, derivedRequestScopes, vendorError } from './derived-core.js';
33
+ export { answerVendorErrors, RefusedWriteError } from './head.js';
34
+ export { GraphqlError, type GraphqlPart, type GraphqlResolver } from './graphql-wire.js';
35
+ export { VendorUnreachableError } from './vendor-call.js';
36
+ export { isReadOnlyRequest, READ_ONLY_REQUEST_HEADER } from './request-scope.js';
37
+ export { serveHttp, serveStream, type HttpHandler, type HttpServer, type ServeHttpOptions } from './serve-http.js';
38
+ export type { TwinStream, TwinStreamConnection, TwinStreamSink } from './twin-fetch.js';
39
+ export { statefulTwinManifest, twinManifest } from './scenario.js';
40
+ export { assetContentType, packAsset } from './pack-assets.js';
41
+ export { bytesResponse, contentTypeOf, fileResponse } from './file-response.js';
42
+ export { certificateOf, digest, digestBytes, equalSecrets, oauth1BaseString, oauth1Encode, oauth1Header, oauth1Signature, hmac, jwks, jwtDecode, jwtSign, jwtVerify, keyId, lettersFrom, md5, publicKeyOf, sha256, signWith, SIGNING_ALGORITHMS, uuidFrom, verifyWith } from './signing.js';
43
+ export type { HandlerCrypto, Jwk, Jwks, JwtVerdict, SigningKey } from './signing.js';
44
+ export { blobDigest } from './blob-store.js';
45
+ export { gunzip, gzip } from './bytes.js';
46
+ export { ownFields } from './log.js';
47
+ export type { TwinResource } from './serve.js';
48
+ export { passwordHash, personOf, personWith, recordPerson, type Person } from './people.js';
49
+ export { EngineDatabaseError, EngineUnavailableError, quoteIdent, worldClockSql } from './managed-database.js';
50
+ export type { Batch as EngineBatch, ManagedDatabase, Statement as EngineStatement, StatementResult as EngineStatementResult } from './managed-database.js';
51
+ export type { Mail, SmtpRoute } from './smtp.js';
52
+ export * as s3 from './s3/wire.js';
53
+ export * as clickhouse from './clickhouse/index.js';
54
+ export { sampleFromSchema } from './schema-sample.js';
55
+ export * as openaiWire from './openai-wire.js';
56
+ export * as anthropicWire from './anthropic-wire.js';
57
+ export * as protobuf from './protobuf.js';
58
+ export * as grpc from './grpc-wire.js';
59
+ export { acceptH2Connection, type H2Handler, type Http1Handler } from './h2.js';
60
+ export { placeholderPng } from './placeholder-image.js';
61
+ export { presignSigV4, signSigV4, verifySigV4, type SigV4Verdict } from './sigv4.js';
62
+ export * as redis from './redis/index.js';
47
63
  export * as git from './git/index.js';
48
- export { PLACEHOLDER_REMOTE, beginPlaceholderPull, endPlaceholderPull, placeholderPullActive, placeholderPullMarkerPath, withPlaceholderPull, placeholderEventsFor } from './placeholder-remote.js';
49
- export { ownFields, subjectHistory, rebaseBranch, cutCheckpoint, appendParentEntry, wholeLog, branchEntries, branchLogPath, branchMetaPath, CHECKPOINT_EVERY, dropCheckpoint, foldEntries, landedCopy, landedIds, parentEntries, parentLogPath, position, readBranchMeta, readTree, toEntry, toEvent, unpushedEntries, writeBranchMeta } from './log.js';
50
- export type { BranchMeta, Entry, EntryOp, Receipt } from './log.js';
51
- export { sealCredential, openSealedCredential, MemoryCredentialStorage, keySealer, transitSealer, type Rewrapped, type Sealer, type TransitSealerOptions, type SealedByVault, type SealedUnderKey } from './credential.js';
52
- export type { CredentialPayload, CredentialStorage, SealedCredential } from './credential.js';
53
- export { validateRemoteOrigin, buildRemoteExecute, type CredentialCustody } from './executor.js';
54
- export type { TwinAuthStrategy } from './executor.js';
55
- export { clearRoot, authStrategyFor, clearStateSystems, NO_SECRETS_CHECK, readRoot, registerAuthStrategy, registerStateSystem, rootPath, runChecks, stateSystemFor, writeRoot } from './state-system.js';
56
- export type { Check, CheckVerdict, DeployPolicy, RootConfig, StateSystemAdapters } from './state-system.js';
57
- export { observeAppends } from './actions.js';
58
- export { appendActionIfAbsent, appendActionOccurrence } from './actions.js';
59
- export { answerVendorErrors, performEntries, performAtHead, deployableEntries, headOf, boundRoot, loadChecks, loadCheck, openRootCredential, resealRootCredential, destinationOf, openSealedRecord, sealsThroughVault, rootCustody, sealingKey, setCheckLoader, setSealingKeySource, setSealer, currentSealer, openSealedAt, userKek, userKekPath, vendorOf, worldRootOf, RefusedWriteError, VendorWriteError, HeadError } from './head.js';
60
- export type { BoundRoot, DeployReport, Head, PerformAction, PerformContext, PushOutcome } from './head.js';
61
- export { observeResource, observeResources, collectObservations, foldObservations } from './observe.js';
62
- export type { ObservedResource, ObserveReport, Observation } from './observe.js';
63
- export { readTreeMap, readParentTreeMap, treeStamp, treeChangesSince, originEntries, appendOriginEntry, originLogPath, isUrlParent, parentPosition, positionAt, splitsBatch, assertBatchBoundary } from './log.js';
64
- export * from './v1-removed.js';
65
- export { referenceField, registerReferences, packReferences, resolveReferences, type ReferenceDeclaration } from './references.js';
66
- export { serveHttp, nodeBuiltin, WORLD_BOOT_PATH, type HttpServer, type ServeHttpOptions, type HttpHandler } from './serve-http.js';
67
- export { fileResponse, contentTypeOf } from './file-response.js';
68
- export { bundleClient, filePathOf } from './client-bundle.js';
69
- export { brandTokensResponse } from './brand-tokens.js';
70
- export { readResourceBlob, readResourceBlobRange, resourceBlobSize, resourceChain } from './resource-blob.js';
71
- export { mirrorShellUnder } from './mirror-shell.js';
72
- export { assertStateRemovable, checkParent, stateGeneration, withAncestryLock, withStateRemoval } from './ancestry.js';
73
- export { captureHistory, captureParentHistory, historyChanges, historyAtInstant, historyDigest, historyEntries, historyLength, historyPrefix, inheritedHistory, originHead, publishOriginHistory, readHistoryView } from './history.js';
74
- export type { HistoryView, HistoryLayout, HistoryReference, HistoryOrigin } from './history.js';
75
- export { foldHistory } from './log.js';
76
- export { volterHome } from './volter-home.js';
64
+ export { parseScenarioDocument, scenarioFaultResult, ScenarioEngine, ScenarioError } from './scenario.js';
65
+ export type { PackScenarioAdapter, ScenarioDecision, ScenarioDocument, ScenarioExtractorSpec, ScenarioFault, ScenarioFaultResult, ScenarioFeatures, ScenarioHandler, ScenarioMatcher, ScenarioMissRecord, ScenarioStatus } from './scenario.js';