@nimbus-sh/fabric 0.7.0 → 0.8.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 (52) hide show
  1. package/README.md +19 -1
  2. package/dist/bindings.d.ts +11 -0
  3. package/dist/bindings.d.ts.map +1 -1
  4. package/dist/bindings.js +19 -8
  5. package/dist/connections.d.ts +1 -1
  6. package/dist/connections.js +1 -1
  7. package/dist/do-calls.d.ts +71 -9
  8. package/dist/do-calls.d.ts.map +1 -1
  9. package/dist/do-calls.js +148 -22
  10. package/dist/facet-pool.d.ts +3 -0
  11. package/dist/facet-pool.d.ts.map +1 -1
  12. package/dist/facet-pool.js +3 -0
  13. package/dist/fanout.d.ts.map +1 -1
  14. package/dist/fanout.js +6 -3
  15. package/dist/fenced-work.d.ts +3 -3
  16. package/dist/host-dispatch.d.ts +12 -4
  17. package/dist/host-dispatch.d.ts.map +1 -1
  18. package/dist/host-dispatch.js +11 -4
  19. package/dist/image-store.js +2 -2
  20. package/dist/inner-do-registry.d.ts +9 -0
  21. package/dist/inner-do-registry.d.ts.map +1 -1
  22. package/dist/inner-do-registry.js +35 -0
  23. package/dist/isolate-pool.d.ts +8 -1
  24. package/dist/isolate-pool.d.ts.map +1 -1
  25. package/dist/isolate-pool.js +9 -7
  26. package/dist/process-fabric.d.ts +16 -5
  27. package/dist/process-fabric.d.ts.map +1 -1
  28. package/dist/process-fabric.js +18 -6
  29. package/dist/process-host.d.ts +5 -0
  30. package/dist/process-host.d.ts.map +1 -1
  31. package/dist/process-host.js +13 -11
  32. package/dist/supervisor-props.d.ts +47 -0
  33. package/dist/supervisor-props.d.ts.map +1 -0
  34. package/dist/supervisor-props.js +37 -0
  35. package/dist/workerd-facet-host.d.ts +4 -17
  36. package/dist/workerd-facet-host.d.ts.map +1 -1
  37. package/dist/workerd-facet-host.js +98 -32
  38. package/package.json +6 -6
  39. package/src/bindings.ts +25 -10
  40. package/src/connections.ts +1 -1
  41. package/src/do-calls.ts +182 -25
  42. package/src/facet-pool.ts +5 -0
  43. package/src/fanout.ts +6 -3
  44. package/src/fenced-work.ts +3 -3
  45. package/src/host-dispatch.ts +22 -7
  46. package/src/image-store.ts +2 -2
  47. package/src/inner-do-registry.ts +31 -0
  48. package/src/isolate-pool.ts +16 -8
  49. package/src/process-fabric.ts +33 -10
  50. package/src/process-host.ts +18 -11
  51. package/src/supervisor-props.ts +56 -0
  52. package/src/workerd-facet-host.ts +99 -37
@@ -1,6 +1,14 @@
1
- import type { createSupervisorOpHandler } from '@nimbus-sh/core/workspace/supervisor-op.js';
1
+ import { type HostRoute } from './composition.js';
2
+ import type { SupervisorOpDispatch } from '@nimbus-sh/core/workspace/supervisor-op.js';
2
3
  export type HostNamespaceBinding = Pick<DurableObjectNamespace, 'get' | 'idFromName' | 'idFromString'>;
3
- export type HostOpDispatch = ReturnType<typeof createSupervisorOpHandler>;
4
- export declare function hostNamespaceBinding(env: object | null | undefined, usage: string): HostNamespaceBinding;
5
- export declare function hostOpDispatch(stub: object, usage: string): HostOpDispatch;
4
+ export type HostOpDispatch = SupervisorOpDispatch;
5
+ /**
6
+ * The host's namespace binding. An entrypoint answering a facet passes the
7
+ * route the binding's props carry, minted in the host's isolate; the host
8
+ * itself, and a binding minted before routes travelled (a facet outlives
9
+ * the deploy that minted its binding), resolve from this isolate's
10
+ * composition.
11
+ */
12
+ export declare function hostNamespaceBinding(env: object | null | undefined, usage: string, route?: Pick<HostRoute, 'hostNamespace'>): HostNamespaceBinding;
13
+ export declare function hostOpDispatch(stub: object, usage: string, route?: Pick<HostRoute, 'hostDispatchMethod'>): HostOpDispatch;
6
14
  //# sourceMappingURL=host-dispatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"host-dispatch.d.ts","sourceRoot":"","sources":["../src/host-dispatch.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAE5F,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,EAAE,KAAK,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC;AACvG,MAAM,MAAM,cAAc,GAAG,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAQ1E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,oBAAoB,CAOxG;AAED,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CAW1E"}
1
+ {"version":3,"file":"host-dispatch.d.ts","sourceRoot":"","sources":["../src/host-dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAqC,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,sBAAsB,EAAE,KAAK,GAAG,YAAY,GAAG,cAAc,CAAC,CAAC;AACvG,MAAM,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAQlD;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC9B,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,eAAe,CAAC,GACvC,oBAAoB,CAOtB;AAED,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,IAAI,CAAC,SAAS,EAAE,oBAAoB,CAAC,GAC5C,cAAc,CAWhB"}
@@ -5,16 +5,23 @@ function isNamespace(value) {
5
5
  && typeof Reflect.get(value, 'idFromString') === 'function'
6
6
  && typeof Reflect.get(value, 'get') === 'function';
7
7
  }
8
- export function hostNamespaceBinding(env, usage) {
9
- const name = hostNamespace();
8
+ /**
9
+ * The host's namespace binding. An entrypoint answering a facet passes the
10
+ * route the binding's props carry, minted in the host's isolate; the host
11
+ * itself, and a binding minted before routes travelled (a facet outlives
12
+ * the deploy that minted its binding), resolve from this isolate's
13
+ * composition.
14
+ */
15
+ export function hostNamespaceBinding(env, usage, route) {
16
+ const name = route?.hostNamespace ?? hostNamespace();
10
17
  const binding = env ? Reflect.get(env, name) : undefined;
11
18
  if (binding === null || (typeof binding !== 'object' && typeof binding !== 'function') || !isNamespace(binding)) {
12
19
  throw new BindingError(`${usage}: env.${name} must be the Durable Object namespace configured by composeFabric`);
13
20
  }
14
21
  return binding;
15
22
  }
16
- export function hostOpDispatch(stub, usage) {
17
- const name = hostDispatchMethod();
23
+ export function hostOpDispatch(stub, usage, route) {
24
+ const name = route?.hostDispatchMethod ?? hostDispatchMethod();
18
25
  if (stub === null || (typeof stub !== 'object' && typeof stub !== 'function')) {
19
26
  throw new BindingError(`${usage}: the workspace namespace returned no stub`);
20
27
  }
@@ -111,12 +111,12 @@ export class ImageStore {
111
111
  fs.mkdirp(FACET_IMAGE_DIR);
112
112
  let count = 0;
113
113
  for await (const [moduleName, source] of images) {
114
- const path = facetImagePath(await facetImageDigest(source));
114
+ const bytes = new TextEncoder().encode(source);
115
+ const path = facetImagePath(await facetImageDigest(bytes));
115
116
  paths[moduleName] = path;
116
117
  rooted.push(path);
117
118
  count++;
118
119
  const stored = path.replace(/^\/+/, '');
119
- const bytes = new TextEncoder().encode(source);
120
120
  console.log('[image-store] pid=' + pid + ' image ' + count + ' ' + moduleName + ' → '
121
121
  + path.slice(-12) + ' ' + bytes.byteLength + ' bytes, slice=' + FACET_IMAGE_WRITE_SLICE_BYTES
122
122
  + ' turns=' + pacer.chunks);
@@ -38,4 +38,13 @@ export declare function getInnerDoClass(supervisorDoId: string, bindingName: str
38
38
  export declare function registerInnerDoClass(supervisorDoId: string, bindingName: string, cls: DurableObjectClass): void;
39
39
  /** Clear all registrations belonging to a supervisor DO (called on rebuild). */
40
40
  export declare function clearInnerDoClasses(supervisorDoId: string): void;
41
+ /**
42
+ * Record that this incarnation opens `facetName` for `bindingName`. True on the
43
+ * name's first open since the incarnation began or the binding's facets were
44
+ * last aborted: whatever still runs under it has a class this build no longer
45
+ * uses, and a get() with the new class on it resets the whole object.
46
+ */
47
+ export declare function noteInnerDoFacetOpened(ctx: DurableObjectState, bindingName: string, facetName: string): boolean;
48
+ /** Abort the facets this incarnation opened for `bindingNames`, keeping their storage, so each next request starts the class registered then. */
49
+ export declare function abortInnerDoFacets(ctx: DurableObjectState, bindingNames: Iterable<string>, reason: Error): void;
41
50
  //# sourceMappingURL=inner-do-registry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"inner-do-registry.d.ts","sourceRoot":"","sources":["../src/inner-do-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE3G;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,kBAAkB,GACtB,IAAI,CAEN;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAKhE"}
1
+ {"version":3,"file":"inner-do-registry.d.ts","sourceRoot":"","sources":["../src/inner-do-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAIH,2EAA2E;AAC3E,wBAAgB,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS,CAE3G;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,cAAc,EAAE,MAAM,EACtB,WAAW,EAAE,MAAM,EACnB,GAAG,EAAE,kBAAkB,GACtB,IAAI,CAEN;AAED,gFAAgF;AAChF,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAKhE;AAKD;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAQ/G;AAED,iJAAiJ;AACjJ,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,kBAAkB,EAAE,YAAY,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,IAAI,CAS/G"}
@@ -49,3 +49,38 @@ export function clearInnerDoClasses(supervisorDoId) {
49
49
  _NIMBUS_INNER_DO_CLASSES.delete(k);
50
50
  }
51
51
  }
52
+ /** Inner-DO facet names each incarnation has opened, by binding; keyed off ctx, so a new incarnation starts empty. */
53
+ const openedInnerDoFacets = new WeakMap();
54
+ /**
55
+ * Record that this incarnation opens `facetName` for `bindingName`. True on the
56
+ * name's first open since the incarnation began or the binding's facets were
57
+ * last aborted: whatever still runs under it has a class this build no longer
58
+ * uses, and a get() with the new class on it resets the whole object.
59
+ */
60
+ export function noteInnerDoFacetOpened(ctx, bindingName, facetName) {
61
+ let byBinding = openedInnerDoFacets.get(ctx);
62
+ if (!byBinding)
63
+ openedInnerDoFacets.set(ctx, byBinding = new Map());
64
+ let names = byBinding.get(bindingName);
65
+ if (!names)
66
+ byBinding.set(bindingName, names = new Set());
67
+ if (names.has(facetName))
68
+ return false;
69
+ names.add(facetName);
70
+ return true;
71
+ }
72
+ /** Abort the facets this incarnation opened for `bindingNames`, keeping their storage, so each next request starts the class registered then. */
73
+ export function abortInnerDoFacets(ctx, bindingNames, reason) {
74
+ const byBinding = openedInnerDoFacets.get(ctx);
75
+ if (!byBinding)
76
+ return;
77
+ for (const bindingName of bindingNames) {
78
+ for (const facetName of byBinding.get(bindingName) ?? []) {
79
+ try {
80
+ ctx.facets.abort(facetName, reason);
81
+ }
82
+ catch { /* already gone */ }
83
+ }
84
+ byBinding.delete(bindingName);
85
+ }
86
+ }
@@ -15,7 +15,7 @@
15
15
  * 3. **Supervisor autoinjection**. The pool grabs the embedder's
16
16
  * registered supervisor entrypoint stub (see `supervisorEntrypoint` in
17
17
  * composition.ts) and forwards it as `env.SUPERVISOR` to every facet,
18
- * same pattern as git-network-facet.ts. Callers can add more bindings
18
+ * same pattern as git/network-facet.ts. Callers can add more bindings
19
19
  * via `extraBindings`.
20
20
  * 4. **Fail-loud defaults**: timeout 60s, retries 0, onError 'throw'.
21
21
  * Caller opts in to leniency.
@@ -23,6 +23,7 @@
23
23
  * The vendored directory contains only the upstream serialization, error,
24
24
  * and binding types used by this implementation.
25
25
  */
26
+ import { type HostRoute } from './composition.js';
26
27
  import type { FacetBindings } from '@nimbus-sh/core/runtime/facet-host.js';
27
28
  import type { WorkerLoader } from './vendor/types.js';
28
29
  /**
@@ -102,6 +103,12 @@ export interface IsolatePoolOptions {
102
103
  * coordinator. Effective only when `omitSupervisor !== true`.
103
104
  */
104
105
  supervisorDoIdOverride?: string;
106
+ /**
107
+ * The coordinator's route, forwarded with `supervisorDoIdOverride`: the
108
+ * binding is the coordinator's, so its way back is the coordinator's
109
+ * too, whatever this peer's isolate composed.
110
+ */
111
+ supervisorRoute?: HostRoute;
105
112
  /**
106
113
  * Process pid baked into the auto-injected SUPERVISOR binding's props.
107
114
  * The supervisor derives the write credential from this pid
@@ -1 +1 @@
1
- {"version":3,"file":"isolate-pool.d.ts","sourceRoot":"","sources":["../src/isolate-pool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAgBH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,KAAK,EAAiB,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAErE;;;;;;;;GAQG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,EAAE,CAAC,IAAI;IAC9B,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,aAAa,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AAO,CAAC,QAAQ,CAAC;IAwBpB;;;;;OAKG;IACG,GAAG,CAAC,CAAC,EAAE,CAAC,EACZ,EAAE,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EACrB,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,EAAE,iBAAiB,GACvB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAOpC;;;;;;;;;;;;;;;;OAgBG;IACG,SAAS,CAAC,CAAC,EAAE,CAAC,EAClB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,CAAC,EAAE,EACV,IAAI,CAAC,EAAE,iBAAiB,GACvB,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IA+DpC;;;;;;;;;;;;;;OAcG;IACH,OAAO,IAAI,IAAI;CAShB"}
@@ -15,7 +15,7 @@
15
15
  * 3. **Supervisor autoinjection**. The pool grabs the embedder's
16
16
  * registered supervisor entrypoint stub (see `supervisorEntrypoint` in
17
17
  * composition.ts) and forwards it as `env.SUPERVISOR` to every facet,
18
- * same pattern as git-network-facet.ts. Callers can add more bindings
18
+ * same pattern as git/network-facet.ts. Callers can add more bindings
19
19
  * via `extraBindings`.
20
20
  * 4. **Fail-loud defaults**: timeout 60s, retries 0, onError 'throw'.
21
21
  * Caller opts in to leniency.
@@ -25,6 +25,7 @@
25
25
  */
26
26
  import { CF_COMPAT_DATE } from '@nimbus-sh/core/constants.js';
27
27
  import { supervisorEntrypoint } from './composition.js';
28
+ import { supervisorBindingProps, supervisorLoaderKey } from './supervisor-props.js';
28
29
  import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
29
30
  import { serializeFunction, hashSource } from './vendor/serialize.js';
30
31
  import { beginLoaderFetch, recordLoaderId, withDynamicWorkerCapNamed } from './budgets.js';
@@ -240,11 +241,11 @@ export class IsolatePool {
240
241
  // via supervisorDoIdOverride so SUPERVISOR.* RPCs route back
241
242
  // to the user's session DO, not the peer DO. Default to the
242
243
  // local ctx.id (single-DO callers and the in-DO in-DO fanout path).
243
- const supDoId = opts?.supervisorDoIdOverride ?? ctx.id.toString();
244
- const supPid = opts?.supervisorPid ?? 0;
245
- bindings.SUPERVISOR = supervisorRpc({
246
- props: { doId: supDoId, pid: supPid },
244
+ const supervisor = supervisorBindingProps(ctx, opts?.supervisorPid ?? 0, {
245
+ doId: opts?.supervisorDoIdOverride,
246
+ route: opts?.supervisorRoute,
247
247
  });
248
+ bindings.SUPERVISOR = supervisorRpc({ props: supervisor });
248
249
  // Whatever the minted worker's env carries must be in its loader
249
250
  // cache key — workerd's loader cache survives a DO hibernation
250
251
  // wake while generation-strided pids (1000001 → 2000001) do not:
@@ -252,8 +253,9 @@ export class IsolatePool {
252
253
  // the new generation still credentialed to the dead pid, and
253
254
  // every pid-authorized RPC from it fails "process pid … does
254
255
  // not exist". doIdShort alone cannot cover this — it changes
255
- // across sessions, not across wakes of the same session.
256
- this.supervisorKey = `s${supDoId.slice(0, 12)}-${supPid}`;
256
+ // across sessions, not across wakes of the same session. So does
257
+ // the instance a binding delivers mutations to, when it names one.
258
+ this.supervisorKey = supervisorLoaderKey(`s${supervisor.doId.slice(0, 12)}-${supervisor.pid}`, supervisor);
257
259
  }
258
260
  else {
259
261
  // Supervisor entrypoint unavailable — running without ctx.exports
@@ -73,6 +73,7 @@
73
73
  * bytes, and the host reads them off the coordinator's own disk through the
74
74
  * `ResidentDiskReader` it was given.
75
75
  */
76
+ import type { SupervisorBindingProps } from './supervisor-props.js';
76
77
  import { z } from 'zod/v4';
77
78
  import type { RouteableFacetTarget } from '@nimbus-sh/core/runtime/os-contracts.js';
78
79
  import type { ServiceStub } from './vendor/types.js';
@@ -177,7 +178,7 @@ export declare const FACET_IMAGE_DIR = "var/lib/nimbus/facet-images";
177
178
  * generated text into `startArgs` would make every image per-PROGRAM and
178
179
  * shareable across spawns and sessions; the sweep bounds the store either way.
179
180
  */
180
- export declare function facetImageDigest(source: string): Promise<string>;
181
+ export declare function facetImageDigest(image: string | Uint8Array): Promise<string>;
181
182
  export declare function facetImagePath(digest: string): string;
182
183
  /**
183
184
  * The digest an image path claims, for the reader's verify-on-read. Content
@@ -216,11 +217,12 @@ export declare function residentLoaderConfig(spec: ResidentCodeSpec, disk: Resid
216
217
  /**
217
218
  * The identity a resident process's SUPERVISOR binding is minted for. Always
218
219
  * the COORDINATOR's — a process hosted somewhere else still reads and writes
219
- * the user's disk, and still reports to the user's process table.
220
+ * the user's disk, and still reports to the user's process table. Minted by
221
+ * `supervisorBindingProps` on the coordinator; `route` is absent only when
222
+ * the coordinator's isolate composed nothing, in which case no supervisor
223
+ * binding is minted either.
220
224
  */
221
- export interface ResidentSupervisorProps {
222
- doId: string;
223
- pid: number;
225
+ export interface ResidentSupervisorProps extends SupervisorBindingProps {
224
226
  writerId: string;
225
227
  }
226
228
  /** Everything a host needs to run one process. Substrate-free by construction. */
@@ -246,6 +248,13 @@ export interface ProcessHostParams {
246
248
  name: string;
247
249
  durable: boolean;
248
250
  };
251
+ /**
252
+ * Bytes the process's store is filled with before it runs (its data plan).
253
+ * The hosting actor's storage ledger (N18) admits them under the facet's
254
+ * name before the facet starts: ENOSPC, and no facet, when they would cross
255
+ * the storage limit.
256
+ */
257
+ storageBytes?: number;
249
258
  }
250
259
  /**
251
260
  * One resident process, as its coordinator sees it. Identical in meaning on
@@ -517,6 +526,8 @@ export interface ResidentProcessSpawn {
517
526
  name: string;
518
527
  durable: boolean;
519
528
  };
529
+ /** See {@link ProcessHostParams.storageBytes}. */
530
+ storageBytes?: number;
520
531
  /**
521
532
  * Called before any concrete host capability can expose this writer.
522
533
  * A spawn must not proceed unless the supervisor accepts the authority.
@@ -1 +1 @@
1
- {"version":3,"file":"process-fabric.d.ts","sourceRoot":"","sources":["../src/process-fabric.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAiB,IAAI,MAAM;IAI3B,2DAA2D;IAC3D,IAAI,IAAI,IAAI;CAKb;AAID,MAAM,WAAW,oBAAoB;IACnC,sDAAsD;IACtD,aAAa,EAAE,aAAa,CAAC;IAC7B,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,uEAAuE;IACvE,SAAS,EAAE,MAAM,CAAC;IAClB,mCAAmC;IACnC,IAAI,EAAE,gBAAgB,CAAC;IACvB,uDAAuD;IACvD,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,OAAO,CAAA;KAAE,CAAC;IAC3C,kDAAkD;IAClD,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;OAGG;IACH,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,iFAAiF;IACjF,eAAe,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C;AASD,qBAAa,aAAa;IACZ,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,WAAW;IAE9C;;;;;;;;OAQG;IACG,oBAAoB,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC;CA0DxF"}
@@ -179,8 +179,10 @@ export const FACET_IMAGE_DIR = 'var/lib/nimbus/facet-images';
179
179
  * generated text into `startArgs` would make every image per-PROGRAM and
180
180
  * shareable across spawns and sessions; the sweep bounds the store either way.
181
181
  */
182
- export async function facetImageDigest(source) {
183
- const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(source));
182
+ export async function facetImageDigest(image) {
183
+ // An image is its UTF-8 bytes; a caller holding them is not made to encode a second copy.
184
+ const bytes = typeof image === 'string' ? new TextEncoder().encode(image) : image;
185
+ const digest = await crypto.subtle.digest('SHA-256', bytes);
184
186
  return Array.from(new Uint8Array(digest), (b) => b.toString(16).padStart(2, '0')).join('');
185
187
  }
186
188
  export function facetImagePath(digest) {
@@ -212,8 +214,16 @@ export async function residentLoaderConfig(spec, disk) {
212
214
  const resolved = {};
213
215
  for (const [moduleName, path] of Object.entries(spec.vfsWasmModules ?? {})) {
214
216
  const bytes = await disk.readFile(path);
217
+ // The read's own buffer when it fits exactly, and only otherwise a copy.
218
+ // These are the largest members a spec carries — ruby's interpreter image
219
+ // is 34.3 MiB, esbuild's 13.3 — and an unconditional slice held both
220
+ // copies at once in the coordinator's 128 MiB isolate, at the one moment
221
+ // the module map is also resident.
222
+ const exact = bytes.byteOffset === 0 && bytes.byteLength === bytes.buffer.byteLength;
215
223
  resolved[moduleName] = {
216
- wasm: bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength),
224
+ wasm: exact
225
+ ? bytes.buffer
226
+ : bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength),
217
227
  };
218
228
  }
219
229
  for (const [moduleName, path] of Object.entries(spec.vfsTextModules ?? {})) {
@@ -240,13 +250,14 @@ async function readFacetImage(disk, path) {
240
250
  if (!expected) {
241
251
  throw new Error(`Nimbus: '${path}' is not a content-addressed facet image path`);
242
252
  }
243
- const source = new TextDecoder().decode(await disk.readFile(path));
244
- const actual = await facetImageDigest(source);
253
+ // Verified from the bytes read, and decoded only after: re-encoding the decoded string held a third copy of the largest member.
254
+ const bytes = await disk.readFile(path);
255
+ const actual = await facetImageDigest(bytes);
245
256
  if (actual !== expected) {
246
257
  throw new Error(`Nimbus: facet image '${path}' does not match its digest (read ${actual}); `
247
258
  + 'the image store is corrupt and the process cannot boot from it');
248
259
  }
249
- return source;
260
+ return new TextDecoder().decode(bytes);
250
261
  }
251
262
  // ── Handle ──────────────────────────────────────────────────────────────────
252
263
  /**
@@ -350,6 +361,7 @@ export class ProcessFabric {
350
361
  writerId,
351
362
  startArgs: spawn.startArgs,
352
363
  ...(spawn.facet !== undefined ? { facet: spawn.facet } : {}),
364
+ ...(spawn.storageBytes !== undefined ? { storageBytes: spawn.storageBytes } : {}),
353
365
  });
354
366
  }
355
367
  catch (error) {
@@ -64,6 +64,7 @@
64
64
  * that pair unforgeable by anything that did not open the process.
65
65
  */
66
66
  import { type ProcessHost, type ResidentDiskReader } from './process-fabric.js';
67
+ import type { HostRoute } from './composition.js';
67
68
  /** The substrates this deployment can be configured for. */
68
69
  export type ProcessHostMode = 'facet' | 'peer';
69
70
  /**
@@ -79,8 +80,12 @@ export declare function isolateToken(): string;
79
80
  /** Options the coordinator hands a hosting peer. */
80
81
  export interface HostProcessOpts {
81
82
  coordinatorDoId: string;
83
+ /** The coordinator's route, minted into the process's SUPERVISOR binding. */
84
+ route?: HostRoute;
82
85
  pid: number;
83
86
  writerId: string;
87
+ /** The coordinator instance's delivery incarnation, minted into the SUPERVISOR binding (ResidentSupervisorProps). */
88
+ hostIncarnation?: string;
84
89
  workerKey: string;
85
90
  /** Unforgeable capability for the fetch-semantic WebSocket hop. */
86
91
  webSocketCapability: string;
@@ -1 +1 @@
1
- {"version":3,"file":"process-host.d.ts","sourceRoot":"","sources":["../src/process-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAOH,OAAO,EAGL,KAAK,WAAW,EAIhB,KAAK,kBAAkB,EAExB,MAAM,qBAAqB,CAAC;AAQ7B,4DAA4D;AAC5D,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,MAAM,CAAC;AAE/C;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,eAAe,EACrB,GAAG,EAAE,kBAAkB,EACvB,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,kBAAkB,GAC7B,WAAW,CAIb;AA8ED,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,GAAG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EACrB,GAAG,EAAE,kBAAkB,EACvB,GAAG,EAAE,OAAO,EACZ,IAAI,EAAE,MAAM,kBAAkB,GAC7B,WAAW,CAIb;AA0ED,wBAAgB,YAAY,IAAI,MAAM,CAGrC;AAED,oDAAoD;AACpD,MAAM,WAAW,eAAe;IAC9B,eAAe,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,qHAAqH;IACrH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,mEAAmE;IACnE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;;;;GAMG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC5B,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC5B,IAAI,EAAE,cAAc,GAAG,IAAI,CAAC;CAC7B;AAaD;;;;;;;;;GASG;AACH,eAAO,MAAM,2BAA2B,8BAA8B,CAAC;AACvE,eAAO,MAAM,kCAAkC,yCAAyC,CAAC;AAqUzF;;;;;;;;;;GAUG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAWhE"}
@@ -64,13 +64,14 @@
64
64
  * that pair unforgeable by anything that did not open the process.
65
65
  */
66
66
  import { disposeRpcResource } from '@nimbus-sh/platform/rpc-dispose.js';
67
- import { isTransientDoReset } from '@nimbus-sh/platform/oom-classify.js';
67
+ import { classifyDoCall, isRetryableDoCall } from '@nimbus-sh/platform/oom-classify.js';
68
68
  import { PEER_RETRY_BACKOFF_MS, PEER_TRANSIENT_RESET_RETRIES } from './fanout.js';
69
69
  import { hostNamespaceBinding, hostOpDispatch } from './host-dispatch.js';
70
70
  import { z } from 'zod/v4';
71
71
  import { DYNAMIC_WORKER_CODE_LIMIT_BYTES } from './budgets.js';
72
72
  import { BindingError } from './vendor/errors.js';
73
73
  import { processes, } from './workerd-facet-host.js';
74
+ import { supervisorBindingProps } from './supervisor-props.js';
74
75
  /**
75
76
  * The substrate for this deployment, resolved once. The mode arrives already
76
77
  * decided — the embedder owns the config var that picks it, and refuses an
@@ -108,14 +109,10 @@ class FacetProcessHost {
108
109
  this.coordDoId = ctx.id.toString();
109
110
  }
110
111
  runOnce(params, consume) {
111
- return processes(this.ctx, this.env).run({ doId: this.coordDoId, pid: params.pid, writerId: params.writerId }, params, consume);
112
+ return processes(this.ctx, this.env).run({ ...supervisorBindingProps(this.ctx, params.pid), writerId: params.writerId }, params, consume);
112
113
  }
113
114
  async open(params) {
114
- const supervisor = {
115
- doId: this.coordDoId,
116
- pid: params.pid,
117
- writerId: params.writerId,
118
- };
115
+ const supervisor = { ...supervisorBindingProps(this.ctx, params.pid), writerId: params.writerId };
119
116
  const { name, ...facet } = processes(this.ctx, this.env).spawn(this.disk, supervisor, params);
120
117
  return {
121
118
  ...facet,
@@ -259,7 +256,7 @@ class PeerProcessHost {
259
256
  * worker of the coordinator here exactly as it does on `facet`.
260
257
  */
261
258
  runOnce(params, consume) {
262
- return processes(this.ctx, this.env).run({ doId: this.coordDoId, pid: params.pid, writerId: params.writerId }, params, consume);
259
+ return processes(this.ctx, this.env).run({ ...supervisorBindingProps(this.ctx, params.pid), writerId: params.writerId }, params, consume);
263
260
  }
264
261
  async open(params) {
265
262
  if (params.facet) {
@@ -278,10 +275,15 @@ class PeerProcessHost {
278
275
  // also what keeps the hosting DO resident. It settles when a `lifetime`
279
276
  // runner exits or when a `boot` runner's host is cancelled, and rejects if
280
277
  // the peer dies under either.
278
+ // The peer mints the process's binding from these, for THIS object: the
279
+ // coordinator's doId, route and delivery instance.
280
+ const supervisor = supervisorBindingProps(this.ctx, params.pid);
281
281
  const hostLeg = placement.stub._rpcHostProcess(params.boot, {
282
- coordinatorDoId: this.coordDoId,
283
- pid: params.pid,
282
+ coordinatorDoId: supervisor.doId,
283
+ route: supervisor.route,
284
+ pid: supervisor.pid,
284
285
  writerId: params.writerId,
286
+ hostIncarnation: supervisor.hostIncarnation,
285
287
  workerKey: params.workerKey,
286
288
  webSocketCapability,
287
289
  startArgs: params.startArgs,
@@ -393,7 +395,7 @@ class PeerProcessHost {
393
395
  return probe;
394
396
  }
395
397
  catch (err) {
396
- if (attempt < PEER_TRANSIENT_RESET_RETRIES && isTransientDoReset(err)) {
398
+ if (attempt < PEER_TRANSIENT_RESET_RETRIES && isRetryableDoCall(classifyDoCall(err))) {
397
399
  await new Promise((r) => setTimeout(r, PEER_RETRY_BACKOFF_MS[Math.min(attempt, PEER_RETRY_BACKOFF_MS.length - 1)]));
398
400
  continue;
399
401
  }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * supervisor-props.ts — what every SUPERVISOR binding a Durable Object mints
3
+ * for a process carries, and the one rule for naming the instance in it.
4
+ *
5
+ * A binding names its host INSTANCE (`hostIncarnation`) exactly when a
6
+ * mutation sent through it can be delivered once
7
+ * (@nimbus-sh/core/workspace/supervisor-delivery.js): the host opened a
8
+ * delivery store, the binding acts as a real process (SupervisorRPC refuses
9
+ * every filesystem mutation of pid 0), and it routes back to this very
10
+ * object rather than another (a fanout pool writes to its coordinator).
11
+ * Minting every binding here is what keeps a new mint site from forgetting
12
+ * that, which would fail silently: its mutations would simply never be
13
+ * re-sent.
14
+ */
15
+ import { type HostRoute } from './composition.js';
16
+ /** The props every SUPERVISOR binding for a process carries. */
17
+ export interface SupervisorBindingProps {
18
+ /** The Durable Object the binding's calls reach. */
19
+ doId: string;
20
+ /** The process the calls act as; 0 is none, and can mutate nothing. */
21
+ pid: number;
22
+ /** The way back, minted with the binding in the host's isolate. */
23
+ route?: HostRoute;
24
+ /** The host instance that applies this binding's mutations once, when there is one. */
25
+ hostIncarnation?: string;
26
+ }
27
+ /**
28
+ * The props of a SUPERVISOR binding minted in the Durable Object whose state
29
+ * is `ctx`, for process `pid`, reaching `options.doId` (this object by
30
+ * default) by `options.route` (this isolate's composition by default).
31
+ */
32
+ export declare function supervisorBindingProps(ctx: {
33
+ readonly id: {
34
+ toString(): string;
35
+ };
36
+ }, pid: number, options?: {
37
+ doId?: string;
38
+ route?: HostRoute;
39
+ }): SupervisorBindingProps;
40
+ /**
41
+ * `key`, for a loader cache entry whose worker holds a binding with `props`:
42
+ * made specific to the host instance the binding names, since the loader
43
+ * outlives that instance and the next one refuses every mutation the binding
44
+ * would deliver. A binding that names none keeps `key`, and its warm worker.
45
+ */
46
+ export declare function supervisorLoaderKey(key: string, props: Pick<SupervisorBindingProps, 'hostIncarnation'>): string;
47
+ //# sourceMappingURL=supervisor-props.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"supervisor-props.d.ts","sourceRoot":"","sources":["../src/supervisor-props.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7D,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACrC,oDAAoD;IACpD,IAAI,EAAE,MAAM,CAAC;IACb,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,mEAAmE;IACnE,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB,uFAAuF;IACvF,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE;IAAE,QAAQ,CAAC,EAAE,EAAE;QAAE,QAAQ,IAAI,MAAM,CAAA;KAAE,CAAA;CAAE,EAC5C,GAAG,EAAE,MAAM,EACX,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,SAAS,CAAA;CAAO,GACjD,sBAAsB,CAMxB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,GAAG,MAAM,CAE/G"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * supervisor-props.ts — what every SUPERVISOR binding a Durable Object mints
3
+ * for a process carries, and the one rule for naming the instance in it.
4
+ *
5
+ * A binding names its host INSTANCE (`hostIncarnation`) exactly when a
6
+ * mutation sent through it can be delivered once
7
+ * (@nimbus-sh/core/workspace/supervisor-delivery.js): the host opened a
8
+ * delivery store, the binding acts as a real process (SupervisorRPC refuses
9
+ * every filesystem mutation of pid 0), and it routes back to this very
10
+ * object rather than another (a fanout pool writes to its coordinator).
11
+ * Minting every binding here is what keeps a new mint site from forgetting
12
+ * that, which would fail silently: its mutations would simply never be
13
+ * re-sent.
14
+ */
15
+ import { supervisorDeliveryProps } from '@nimbus-sh/core/workspace/supervisor-delivery.js';
16
+ import { hostRoute } from './composition.js';
17
+ /**
18
+ * The props of a SUPERVISOR binding minted in the Durable Object whose state
19
+ * is `ctx`, for process `pid`, reaching `options.doId` (this object by
20
+ * default) by `options.route` (this isolate's composition by default).
21
+ */
22
+ export function supervisorBindingProps(ctx, pid, options = {}) {
23
+ const own = ctx.id.toString();
24
+ const doId = options.doId ?? own;
25
+ const route = options.route ?? hostRoute() ?? undefined;
26
+ const delivery = pid > 0 && doId === own ? supervisorDeliveryProps(ctx) : {};
27
+ return { doId, pid, route, ...delivery };
28
+ }
29
+ /**
30
+ * `key`, for a loader cache entry whose worker holds a binding with `props`:
31
+ * made specific to the host instance the binding names, since the loader
32
+ * outlives that instance and the next one refuses every mutation the binding
33
+ * would deliver. A binding that names none keeps `key`, and its warm worker.
34
+ */
35
+ export function supervisorLoaderKey(key, props) {
36
+ return props.hostIncarnation === undefined ? key : `${key}:${props.hostIncarnation}`;
37
+ }
@@ -24,11 +24,7 @@ export interface NimbusCtxExports {
24
24
  key: string;
25
25
  name: string | null;
26
26
  depth: number;
27
- supervisor: {
28
- doId: string;
29
- pid: number;
30
- writerId: string;
31
- };
27
+ supervisor: ResidentSupervisorProps;
32
28
  stage?: unknown;
33
29
  };
34
30
  }) => LoadedWorkerEntrypointStub;
@@ -40,11 +36,7 @@ export declare function getNimbusCtxExports(): NimbusCtxExports;
40
36
  * request rather than leaving it resident: their module map is assembled in
41
37
  * that stateless entrypoint's own isolate, never in a session DO.
42
38
  */
43
- export declare function createLoadedWorkerEntrypoint(ctxExports: NimbusCtxExports, supervisor: {
44
- doId: string;
45
- pid: number;
46
- writerId: string;
47
- }, stage: unknown, name?: string | null): Promise<LoadedWorkerEntrypointStub>;
39
+ export declare function createLoadedWorkerEntrypoint(ctxExports: NimbusCtxExports, supervisor: ResidentSupervisorProps, stage: unknown, name?: string | null): Promise<LoadedWorkerEntrypointStub>;
48
40
  /** What an unkeyed `LOADER.load` hands back. */
49
41
  interface LoadedWorkerStub {
50
42
  getEntrypoint(): LoadedWorkerEntrypointStub;
@@ -133,13 +125,8 @@ export declare function cloneStorage(ctx: DurableObjectState, clone: {
133
125
  export declare function residentFacetName(slot: number): string;
134
126
  /** The prefix every durable application's facet name carries. */
135
127
  export declare const DURABLE_FACET_NAME_PREFIX = "app-slot-";
136
- /**
137
- * Drop one facet's SQLite by name — the ONLY call site that may delete facet
138
- * storage. `spawnResident` releases ephemeral processes with abort+delete
139
- * (storage is slot-reuse hygiene) and durable ones with abort alone (the
140
- * storage IS the durable application's state); explicit removal arrives here
141
- * through the coordinator's durable-slot book, owner-checked.
142
- */
128
+ /** The facet a running resident process `pid` lives in on this actor, for its storage ledger row. */
129
+ export declare function residentFacetOf(ctx: DurableObjectState, pid: number): string | undefined;
143
130
  export declare function deleteFacetStorage(ctx: DurableObjectState, name: string): void;
144
131
  /**
145
132
  * What `processes(ctx, env).spawn` hands back: a running process, minus its placement.
@@ -1 +1 @@
1
- {"version":3,"file":"workerd-facet-host.d.ts","sourceRoot":"","sources":["../src/workerd-facet-host.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAmBH,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC7B,MAAM,qBAAqB,CAAC;AAI7B,+DAA+D;AAC/D,MAAM,WAAW,0BAA0B;IACzC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5D,KAAK,CAAC,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,gBAAgB;IAC/B,sBAAsB,CAAC,EAAE,CAAC,OAAO,EAAE;QACjC,KAAK,EAAE;YACL,GAAG,EAAE,MAAM,CAAC;YACZ,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;YACpB,KAAK,EAAE,MAAM,CAAC;YACd,UAAU,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,GAAG,EAAE,MAAM,CAAC;gBAAC,QAAQ,EAAE,MAAM,CAAA;aAAE,CAAC;YAC5D,KAAK,CAAC,EAAE,OAAO,CAAC;SACjB,CAAC;KACH,KAAK,0BAA0B,CAAC;CAClC;AAED,wBAAgB,mBAAmB,IAAI,gBAAgB,CAMtD;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAChD,UAAU,EAAE,gBAAgB,EAC5B,UAAU,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,EAC3D,KAAK,EAAE,OAAO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