@earendil-works/chord 1.2.0 → 1.3.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 (86) hide show
  1. package/CHANGELOG.md +58 -0
  2. package/README.md +14 -13
  3. package/dist/cell.d.ts +30 -9
  4. package/dist/cell.d.ts.map +1 -1
  5. package/dist/cell.js +52 -12
  6. package/dist/cell.js.map +1 -1
  7. package/dist/cluster.d.ts +4 -3
  8. package/dist/cluster.d.ts.map +1 -1
  9. package/dist/cluster.js +58 -42
  10. package/dist/cluster.js.map +1 -1
  11. package/dist/connection.d.ts +171 -58
  12. package/dist/connection.d.ts.map +1 -1
  13. package/dist/connection.js +676 -217
  14. package/dist/connection.js.map +1 -1
  15. package/dist/contract.d.ts +120 -45
  16. package/dist/contract.d.ts.map +1 -1
  17. package/dist/contract.js +104 -15
  18. package/dist/contract.js.map +1 -1
  19. package/dist/declare.d.ts +11 -48
  20. package/dist/declare.d.ts.map +1 -1
  21. package/dist/declare.js +1 -21
  22. package/dist/declare.js.map +1 -1
  23. package/dist/delta/index.d.ts +2 -1
  24. package/dist/delta/index.d.ts.map +1 -1
  25. package/dist/delta/index.js +4 -0
  26. package/dist/delta/index.js.map +1 -1
  27. package/dist/errors.d.ts +4 -3
  28. package/dist/errors.d.ts.map +1 -1
  29. package/dist/errors.js +15 -0
  30. package/dist/errors.js.map +1 -1
  31. package/dist/host.d.ts +214 -120
  32. package/dist/host.d.ts.map +1 -1
  33. package/dist/host.js +446 -241
  34. package/dist/host.js.map +1 -1
  35. package/dist/index.d.ts +8 -8
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +4 -4
  38. package/dist/index.js.map +1 -1
  39. package/dist/link.d.ts +47 -12
  40. package/dist/link.d.ts.map +1 -1
  41. package/dist/link.js +200 -14
  42. package/dist/link.js.map +1 -1
  43. package/dist/loader.d.ts.map +1 -1
  44. package/dist/loader.js +7 -2
  45. package/dist/loader.js.map +1 -1
  46. package/dist/manager.d.ts.map +1 -1
  47. package/dist/manager.js +35 -9
  48. package/dist/manager.js.map +1 -1
  49. package/dist/object.d.ts +438 -0
  50. package/dist/object.d.ts.map +1 -0
  51. package/dist/{record.js → object.js} +614 -335
  52. package/dist/object.js.map +1 -0
  53. package/dist/output.d.ts +85 -0
  54. package/dist/output.d.ts.map +1 -0
  55. package/dist/output.js +350 -0
  56. package/dist/output.js.map +1 -0
  57. package/dist/registry.d.ts +3 -3
  58. package/dist/registry.d.ts.map +1 -1
  59. package/dist/registry.js +1 -1
  60. package/dist/registry.js.map +1 -1
  61. package/dist/reload.d.ts +35 -27
  62. package/dist/reload.d.ts.map +1 -1
  63. package/dist/reload.js +256 -192
  64. package/dist/reload.js.map +1 -1
  65. package/dist/remote.d.ts +130 -35
  66. package/dist/remote.d.ts.map +1 -1
  67. package/dist/remote.js +493 -189
  68. package/dist/remote.js.map +1 -1
  69. package/dist/types.d.ts +39 -28
  70. package/dist/types.d.ts.map +1 -1
  71. package/dist/types.js.map +1 -1
  72. package/dist/websocket.d.ts +4 -5
  73. package/dist/websocket.d.ts.map +1 -1
  74. package/dist/websocket.js +3 -2
  75. package/dist/websocket.js.map +1 -1
  76. package/dist/wire.d.ts +210 -129
  77. package/dist/wire.d.ts.map +1 -1
  78. package/dist/wire.js +108 -55
  79. package/dist/wire.js.map +1 -1
  80. package/docs/guide.md +267 -203
  81. package/docs/spec.md +141 -114
  82. package/docs/tutorial.md +257 -235
  83. package/package.json +6 -1
  84. package/dist/record.d.ts +0 -320
  85. package/dist/record.d.ts.map +0 -1
  86. package/dist/record.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"record.js","sourceRoot":"","sources":["../src/record.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAKN,IAAI,EAGJ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AAQ,EAAE,QAA6B;gBACvC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;gBACvC,KAAK;aACL,CAAC,CAAC;QACJ,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { TSchema } from \"typebox\";\nimport { Value } from \"typebox/value\";\nimport { Cell, Derived, isSource, notReady } from \"./cell.ts\";\nimport {\n\ttype Accepts,\n\ttype Adapter,\n\ttype AnyContract,\n\ttype BehaviorOf,\n\tbind,\n\ttype Handle,\n\ttype InputOf,\n\tLOCAL_VARIANT,\n\ttype MemberDescription,\n} from \"./contract.ts\";\nimport {\n\ttype CellDecl,\n\ttype Cells,\n\ttype DerivationDecl,\n\ttype Derivations,\n\tdeclKind,\n\ttype ListenerDecl,\n\ttype Resource,\n\ttype ResourceDecl,\n\ttype ResourceSpec,\n\ttype Resources,\n\ttype Subscribable,\n} from \"./declare.ts\";\nimport { asChordError, ChordError, invalid, runAll } from \"./errors.ts\";\nimport { enqueue } from \"./publish.ts\";\nimport type { Registration, Registry } from \"./registry.ts\";\nimport { assertValid } from \"./schema.ts\";\nimport type { Ctx, Exposed, GetOptions, HandleStatus, Principal, Readable, Shape, StateEvent } from \"./types.ts\";\n\nconst noop = (): void => {};\n\n// ─── Services ────────────────────────────────────────────────────────────────\n\nexport interface ServeOptions<C extends AnyContract = AnyContract> {\n\t/**\n\t * State version: the meaning of the record's cells. At a bump, `migrate[name](old, fromVersion)` maps a cell's value;\n\t * the record may be several versions behind.\n\t */\n\treadonly state?: {\n\t\treadonly version: number;\n\t\treadonly migrate?: Readonly<Record<string, (old: unknown, fromVersion: number) => unknown>>;\n\t};\n\t/** Milliseconds a record stays alive after its last hold is released. */\n\treadonly linger?: number;\n\t/** Host-held record created with this input (true: `{}` normalized). Only eager records may register. */\n\treadonly eager?: boolean | { readonly input: InputOf<C> };\n\t/** Adapters for consumers built against older contract versions. */\n\treadonly accepts?: Accepts;\n}\n\nexport type Factory<C extends AnyContract> = (input: InputOf<C>, principal: Principal, self: Self) => BehaviorOf<C>;\ntype AnyFactory = (input: unknown, principal: Principal, self: Self) => unknown;\n\nexport interface Service {\n\treadonly contract: AnyContract;\n\treadonly factory: AnyFactory;\n\treadonly options: ServeOptions;\n\treadonly facet: string;\n\treadonly stateVersion: number;\n}\n\nexport const makeService = <C extends AnyContract>(\n\tcontract: C,\n\tfactory: Factory<C>,\n\toptions: ServeOptions<C>,\n\tfacet: string,\n): Service => ({\n\tcontract,\n\tfactory: factory as unknown as AnyFactory,\n\toptions: options as ServeOptions,\n\tfacet,\n\tstateVersion: options.state?.version ?? 1,\n});\n\n// ─── Declarations ────────────────────────────────────────────────────────────\n\nexport interface Self {\n\t/** Cells by name. Existing names keep their cell (and value) across reloads. */\n\tstate<const D extends Readonly<Record<string, CellDecl<unknown>>>>(cells: D): Cells<D>;\n\t/** A record-owned hold, identified by its address. */\n\tget<C extends AnyContract>(type: C, input: InputOf<C>, options?: GetOptions): Handle<C>;\n\tresources<const D extends Readonly<Record<string, ResourceDecl<unknown>>>>(resources: D): Resources<D>;\n\tlisten(listeners: Readonly<Record<string, ListenerDecl>>): void;\n\ttasks(tasks: Readonly<Record<string, (ctx: Ctx) => Promise<void>>>): void;\n\tderive<const D extends Readonly<Record<string, DerivationDecl<unknown>>>>(derivations: D): Derivations<D>;\n\t/** Eager records only. Keys are the registry's own keys. */\n\tregister<V>(registry: Registry<V>, entries: Readonly<Record<string, V>>): void;\n\t/**\n\t * A member backed by one of this record's resources, for local contracts: handles read the resource's value once\n\t * the record is live (`undefined` before). Typically an `opaque` member: `{ harness: self.expose(res.durable) }`.\n\t */\n\texpose<T>(resource: Resource<T>): Exposed<T>;\n}\n\n/** Runtime form of `Exposed<T>`. */\nclass ExposedImpl {\n\treadonly resource: ResourceImpl;\n\tconstructor(resource: ResourceImpl) {\n\t\tthis.resource = resource;\n\t}\n}\n\nexport class ResourceImpl<T = unknown> implements Resource<T> {\n\treadonly key: string;\n\treadonly spec: ResourceSpec<T>;\n\treadonly deps: readonly (Hold | ResourceImpl)[];\n\t/** `unavailable`: a close/reopen failed during a reload rollback; the value is gone for good. */\n\tstate: \"closed\" | \"opening\" | \"open\" | \"unavailable\" = \"closed\";\n\t#value: T | undefined;\n\n\tconstructor(key: string, spec: ResourceSpec<T>, deps: readonly (Hold | ResourceImpl)[]) {\n\t\tthis.key = key;\n\t\tthis.spec = spec;\n\t\tthis.deps = deps;\n\t}\n\n\tget value(): T {\n\t\tif (this.state === \"unavailable\")\n\t\t\tthrow new ChordError(\"unavailable\", `resource ${this.key} could not be restored`);\n\t\tif (this.state !== \"open\") throw notReady(`resource ${this.key}`);\n\t\treturn this.#value as T;\n\t}\n\n\tget exclusive(): boolean {\n\t\treturn this.spec.exclusive === true;\n\t}\n\n\t/**\n\t * Opens the resource. An open that completes after `signal` aborted (rollback, abandonment) closes the value it\n\t * produced at once: nobody owns it any more.\n\t */\n\tasync open(signal: AbortSignal, order: ResourceImpl[]): Promise<void> {\n\t\tif (this.state !== \"closed\") return;\n\t\tthis.state = \"opening\";\n\t\tlet value: T;\n\t\ttry {\n\t\t\tvalue = await this.spec.open({ signal });\n\t\t} catch (error) {\n\t\t\tthis.state = \"closed\";\n\t\t\tthrow error;\n\t\t}\n\t\tif (signal.aborted) {\n\t\t\tthis.state = \"closed\";\n\t\t\tawait this.spec.close?.(value);\n\t\t\tthrow new ChordError(\"aborted\", `resource ${this.key} opened after abort`);\n\t\t}\n\t\tthis.#value = value;\n\t\tthis.state = \"open\";\n\t\torder.push(this);\n\t}\n\n\tasync close(order: ResourceImpl[]): Promise<void> {\n\t\tif (this.state !== \"open\") return;\n\t\tthis.state = \"closed\";\n\t\tconst index = order.indexOf(this);\n\t\tif (index !== -1) order.splice(index, 1);\n\t\tconst value = this.#value as T;\n\t\tthis.#value = undefined;\n\t\tawait this.spec.close?.(value);\n\t}\n\n\tmarkUnavailable(): void {\n\t\tthis.state = \"unavailable\";\n\t\tthis.#value = undefined;\n\t}\n}\n\n/**\n * What `self.resources` returns: the resource, except that `.value` throws `not_ready` while any factory runs, even\n * if the resource is open (a reload's prepare rerun must not touch the native resource the old code uses).\n */\nclass ResourceFacade<T> implements Resource<T> {\n\treadonly #resource: ResourceImpl<T>;\n\treadonly #host: HostCore;\n\n\tconstructor(resource: ResourceImpl<T>, host: HostCore) {\n\t\tthis.#resource = resource;\n\t\tthis.#host = host;\n\t\tfacades.set(this, resource as ResourceImpl);\n\t}\n\n\tget key(): string {\n\t\treturn this.#resource.key;\n\t}\n\n\tget value(): T {\n\t\tif (this.#host.inFactory > 0) throw notReady(`resource ${this.key} (inside a factory)`);\n\t\treturn this.#resource.value;\n\t}\n}\n\nconst facades = new WeakMap<object, ResourceImpl>();\nconst resourceOf = (value: unknown): ResourceImpl | undefined =>\n\tvalue instanceof ResourceImpl ? value : value !== null && typeof value === \"object\" ? facades.get(value) : undefined;\n\ntype TaskFn = (ctx: Ctx) => Promise<void>;\n\n/** Everything one factory run declared, by kind and key. */\nexport class Decls {\n\treadonly cells = new Map<string, Cell<unknown>>();\n\treadonly cellSchemas = new Map<string, TSchema>();\n\treadonly holds = new Map<string, Hold>();\n\treadonly resources = new Map<string, ResourceImpl>();\n\treadonly listeners = new Map<string, ListenerDecl>();\n\treadonly tasks = new Map<string, TaskFn>();\n\treadonly derives = new Map<string, Derived<unknown>>();\n\treadonly deriveFns = new Map<string, (...values: never[]) => unknown>();\n\treadonly registrations = new Map<string, Registration>();\n}\n\n/** One factory run: its behavior, declarations and the objects it created (not reused from the previous run). */\nexport interface Run {\n\treadonly behavior: Record<string, unknown>;\n\treadonly decls: Decls;\n\treadonly created: {\n\t\treadonly holds: Hold[];\n\t\treadonly resources: ResourceImpl[];\n\t\treadonly derives: Derived<unknown>[];\n\t};\n}\n\nexport interface Installed {\n\treadonly epoch: number;\n\treadonly service: Service;\n\treadonly behavior: Record<string, unknown>;\n\treadonly decls: Decls;\n}\n\n// ─── Host interface the runtime pieces use ───────────────────────────────────\n\nexport interface HostCore {\n\treadonly name: string;\n\treadonly dev: boolean;\n\treadonly principal: Principal;\n\tinFactory: number;\n\t/** Set when a commit failed midway: the host admits no more work (terminal). */\n\treadonly failed: unknown;\n\treport(error: unknown): void;\n\tcurrentEpoch(): number;\n\thasEpoch(epoch: number): boolean;\n\tretainedEpochs(): Iterable<readonly [number, ReadonlyMap<string, Service>]>;\n\tpendingEpoch(): number | undefined;\n\tservice(typeName: string): Service | undefined;\n\tacquire(\n\t\ttype: AnyContract,\n\t\tinput: unknown,\n\t\toptions: GetOptions | undefined,\n\t\towner: HoldOwner,\n\t\tfrom?: RecordImpl,\n\t\tcandidate?: boolean,\n\t): Hold;\n\taddressOf(type: AnyContract, input: unknown, principal: Principal, at?: string, candidate?: boolean): string;\n\troot<T>(fn: (ctx: Ctx) => T | Promise<T>, options?: { epoch?: number; signal?: AbortSignal }): Promise<T>;\n\ttouch(rootId: string, record: RecordImpl): void;\n\tforget(record: RecordImpl): void;\n\tcheckRegistrations(record: RecordImpl, decls: Decls): void;\n\t/** Rebuilds the current registry tables from live records (plus `including`, which is finishing activation). */\n\tregistriesChanged(including?: RecordImpl): void;\n}\n\n// ─── Contexts ────────────────────────────────────────────────────────────────\n\nexport class CtxImpl implements Ctx {\n\treadonly host: HostCore;\n\treadonly signal: AbortSignal;\n\treadonly rootId: string;\n\treadonly epoch: number;\n\treadonly principal: Principal;\n\t/** Code holders (tasks): every call they make starts a fresh root. */\n\treadonly holder: boolean;\n\treadonly #holds: Hold[] = [];\n\t#closed = false;\n\n\t/** True after the call or root that received this ctx settled: it may no longer start work. */\n\tget closed(): boolean {\n\t\treturn this.#closed;\n\t}\n\n\t/** Throws unless this ctx may start work on `host` now (not expired, not aborted, not from another host). */\n\tcheck(host: HostCore): void {\n\t\tif (this.host !== host) throw invalid(\"foreign_ctx\", \"ctx belongs to another host\");\n\t\tif (this.#closed) throw new ChordError(\"aborted\", \"ctx expired: its call already settled\", { reason: \"expired\" });\n\t\tif (this.signal.aborted) throw new ChordError(\"aborted\", \"ctx aborted\", { cause: this.signal.reason });\n\t}\n\n\tconstructor(\n\t\thost: HostCore,\n\t\tfields: { signal: AbortSignal; rootId: string; epoch: number; principal: Principal; holder?: boolean },\n\t) {\n\t\tthis.host = host;\n\t\tthis.signal = fields.signal;\n\t\tthis.rootId = fields.rootId;\n\t\tthis.epoch = fields.epoch;\n\t\tthis.principal = fields.principal;\n\t\tthis.holder = fields.holder ?? false;\n\t}\n\n\tget<C extends AnyContract>(type: C, input: InputOf<C>, options?: GetOptions): Handle<C> {\n\t\tthis.check(this.host);\n\t\tconst handle = this.host.acquire(type, input, { principal: this.principal, ...options }, \"call\");\n\t\tthis.#holds.push(handle);\n\t\treturn handle.proxy as Handle<C>;\n\t}\n\n\t/**\n\t * A context for a call into `record`: same root and epoch, its own call-owned holds, aborted on forced disposal.\n\t * Code inside an object acts as the host principal.\n\t */\n\tchild(record: RecordImpl): CtxImpl {\n\t\treturn new CtxImpl(this.host, {\n\t\t\tsignal: AbortSignal.any([this.signal, record.callAbort.signal]),\n\t\t\trootId: this.rootId,\n\t\t\tepoch: this.epoch,\n\t\t\tprincipal: this.host.principal,\n\t\t});\n\t}\n\n\tclose(): void {\n\t\tthis.#closed = true;\n\t\tfor (const handle of this.#holds.splice(0)) handle.release();\n\t}\n}\n\nexport async function raceSignal<T>(promise: Promise<T>, signal: AbortSignal): Promise<T> {\n\tif (signal.aborted) throw new ChordError(\"aborted\", \"call aborted\", { cause: signal.reason });\n\tlet onAbort = noop;\n\tconst aborted = new Promise<never>((_, reject) => {\n\t\tonAbort = () => reject(new ChordError(\"aborted\", \"call aborted\", { cause: signal.reason }));\n\t\tsignal.addEventListener(\"abort\", onAbort, { once: true });\n\t});\n\ttry {\n\t\treturn await Promise.race([promise, aborted]);\n\t} finally {\n\t\tsignal.removeEventListener(\"abort\", onAbort);\n\t}\n}\n\n// ─── Handles ─────────────────────────────────────────────────────────────────\n\n/** Who a hold belongs to. `connection`: a peer host over a link; `client`: a browser (not a reload participant). */\nexport type HoldOwner = \"record\" | \"call\" | \"host\" | \"external\" | \"connection\" | \"client\";\n\n/** A claim on an object: a local `HandleImpl`, or a `RemoteHandle` on another host (no record here). */\nexport interface Hold {\n\treadonly address: string;\n\treadonly contract: AnyContract;\n\treadonly status: HandleStatus;\n\treadonly ready: Promise<void>;\n\treadonly proxy: object;\n\treadonly record: RecordImpl | undefined;\n\trelease(): void;\n}\n\nexport const HANDLE_BASE: ReadonlySet<PropertyKey> = new Set([\n\t\"contract\",\n\t\"status\",\n\t\"ready\",\n\t\"kind\",\n\t\"shape\",\n\t\"error\",\n\t\"onShape\",\n\t\"onStatus\",\n\t\"release\",\n]);\n\nexport type StatusListener = (status: HandleStatus, error: unknown) => void;\n\n/** Queues a status notification (after the change that caused it is complete, like every publication). */\nexport function notifyStatus(\n\tlisteners: ReadonlySet<StatusListener>,\n\tstatus: HandleStatus,\n\terror: unknown,\n\treport: (error: unknown) => void,\n): void {\n\tif (listeners.size === 0) return;\n\tconst current = [...listeners];\n\tenqueue(() => {\n\t\tfor (const listener of current) {\n\t\t\ttry {\n\t\t\t\tlistener(status, error);\n\t\t\t} catch (thrown) {\n\t\t\t\treport(thrown);\n\t\t\t}\n\t\t}\n\t});\n}\n\n/** Proxy → hold, for `deps: [handle]` and links. */\nexport const holdsByProxy = new WeakMap<object, Hold>();\nexport const handleOf = (value: unknown): Hold | undefined =>\n\tvalue !== null && typeof value === \"object\" ? holdsByProxy.get(value) : undefined;\n\n/**\n * A handle's state member: a stable readable that follows whatever source the current behavior exposes under that\n * name. `undefined` until the handle is live (or while the variant lacks the member). Rebinding (reload, variant)\n * delivers a reset. Upstream is subscribed only while someone listens.\n */\nclass MemberReadable implements Readable<unknown> {\n\treadonly #handle: HandleImpl;\n\treadonly #name: string;\n\treadonly #values = new Set<(value: unknown) => void>();\n\treadonly #events = new Set<(event: StateEvent<unknown>) => void>();\n\t#source: Readable<unknown> | undefined;\n\t#upstream = noop;\n\t/** The value listeners last saw; a first upstream snapshot equal to it is not re-announced. */\n\t#seen: unknown;\n\n\tconstructor(handle: HandleImpl, name: string) {\n\t\tthis.#handle = handle;\n\t\tthis.#name = name;\n\t}\n\n\tget value(): unknown {\n\t\treturn this.#current()?.value;\n\t}\n\n\tsubscribe(listener: (value: unknown) => void): () => void {\n\t\tthis.#values.add(listener);\n\t\tthis.#seen = this.value;\n\t\tthis.#safe(() => listener(this.#seen));\n\t\tthis.bind();\n\t\treturn () => this.#remove(this.#values, listener);\n\t}\n\n\tevents(listener: (event: StateEvent<unknown>) => void): () => void {\n\t\tthis.#events.add(listener);\n\t\tthis.#seen = this.value;\n\t\tthis.#safe(() => listener({ type: \"snap\", value: this.#seen }));\n\t\tthis.bind();\n\t\treturn () => this.#remove(this.#events, listener);\n\t}\n\n\t/** (Re)subscribes upstream to the current source; a changed source is announced as a reset. */\n\tbind(): void {\n\t\tconst source = this.#values.size + this.#events.size > 0 ? this.#current() : undefined;\n\t\tif (source === this.#source) return;\n\t\tthis.#upstream();\n\t\tthis.#upstream = noop;\n\t\tthis.#source = source;\n\t\tif (source === undefined) return;\n\t\tlet first = true;\n\t\tthis.#upstream = source.events((event) => {\n\t\t\tconst isFirst = first;\n\t\t\tfirst = false;\n\t\t\tif (isFirst && event.value === this.#seen) return;\n\t\t\tthis.#seen = event.value;\n\t\t\tconst translated: StateEvent<unknown> = isFirst ? { type: \"reset\", value: event.value } : event;\n\t\t\tconst events = [...this.#events];\n\t\t\tconst values = [...this.#values];\n\t\t\t// Queued: a rebind during a commit must not run observers before the commit completes.\n\t\t\tenqueue(() => {\n\t\t\t\tfor (const listener of events) if (this.#events.has(listener)) this.#safe(() => listener(translated));\n\t\t\t\tfor (const listener of values) if (this.#values.has(listener)) this.#safe(() => listener(event.value));\n\t\t\t});\n\t\t});\n\t}\n\n\tstop(): void {\n\t\tthis.#values.clear();\n\t\tthis.#events.clear();\n\t\tthis.bind();\n\t}\n\n\t#current(): Readable<unknown> | undefined {\n\t\tconst view = this.#handle.currentView();\n\t\tif (view === undefined || !this.#handle.inVariant(view, this.#name)) return undefined;\n\t\tconst value = view[this.#name];\n\t\t// Cells and derivations, or any readable an `accepts` adapter maps them to.\n\t\treturn isSource(value) || isReadableLike(value) ? (value as Readable<unknown>) : undefined;\n\t}\n\n\t#remove<T>(set: Set<T>, listener: T): void {\n\t\tset.delete(listener);\n\t\tthis.bind();\n\t}\n\n\t#safe(fn: () => void): void {\n\t\ttry {\n\t\t\tfn();\n\t\t} catch (error) {\n\t\t\tthis.#handle.record.host.report(error);\n\t\t}\n\t}\n}\n\n/** One hold on a record. Exposed through a Proxy so members bind late to the current behavior. */\nexport class HandleImpl {\n\treadonly record: RecordImpl;\n\treadonly contract: AnyContract;\n\treadonly owner: HoldOwner;\n\treadonly address: string;\n\treadonly proxy: object;\n\treadonly ready: Promise<void>;\n\tstatus: HandleStatus;\n\terror: unknown;\n\treadonly shapeListeners = new Set<(shape: Shape) => void>();\n\t/** Internal: notified when the handle becomes gone (links forward it). */\n\treadonly goneListeners = new Set<(error: unknown) => void>();\n\treadonly readables = new Map<string, MemberReadable>();\n\treadonly bindings = new Map<Service, Adapter | undefined>();\n\treadonly views = new WeakMap<Record<string, unknown>, Record<string, unknown>>();\n\treadonly callers = new Map<string, (args: unknown, ctx?: Ctx) => Promise<unknown>>();\n\n\tconstructor(record: RecordImpl, contract: AnyContract, owner: HoldOwner) {\n\t\tthis.record = record;\n\t\tthis.contract = contract;\n\t\tthis.owner = owner;\n\t\tthis.address = record.address;\n\t\tthis.status = record.status === \"live\" ? \"live\" : \"loading\";\n\t\tthis.ready = record.ready.then(() => {\n\t\t\tif (this.status === \"gone\") throw this.error;\n\t\t\tif (this.status === \"released\") throw new ChordError(\"released\", `handle ${this.address} released`);\n\t\t});\n\t\tthis.ready.catch(noop);\n\t\tthis.proxy = new Proxy(this, {\n\t\t\tget: (target, property) => {\n\t\t\t\tif (HANDLE_BASE.has(property)) {\n\t\t\t\t\tconst value: unknown = Reflect.get(target, property, target);\n\t\t\t\t\treturn typeof value === \"function\" ? value.bind(target) : value;\n\t\t\t\t}\n\t\t\t\tif (typeof property !== \"string\" || property === \"then\") return undefined;\n\t\t\t\treturn target.member(property);\n\t\t\t},\n\t\t\thas: (target, property) => HANDLE_BASE.has(property) || target.member(String(property)) !== undefined,\n\t\t});\n\t\tholdsByProxy.set(this.proxy, this);\n\t}\n\n\tget kind(): string | undefined {\n\t\tconst view = this.currentView();\n\t\treturn view === undefined ? undefined : kindOf(view);\n\t}\n\n\tget shape(): Shape | undefined {\n\t\tconst installed = this.status === \"live\" ? this.record.currentInstalled() : undefined;\n\t\tconst view = installed === undefined ? undefined : this.#safeView(installed);\n\t\tif (installed === undefined || view === undefined) return undefined;\n\t\treturn {\n\t\t\tkind: kindOf(view),\n\t\t\tmembers: Object.keys(view).filter((key) => key !== \"kind\"),\n\t\t\tcontract: installed.service.contract.fingerprint,\n\t\t\tepoch: installed.epoch,\n\t\t};\n\t}\n\n\tonShape(listener: (shape: Shape) => void): () => void {\n\t\tthis.shapeListeners.add(listener);\n\t\treturn () => this.shapeListeners.delete(listener);\n\t}\n\n\tonStatus(listener: StatusListener): () => void {\n\t\tthis.#statusListeners.add(listener);\n\t\treturn () => this.#statusListeners.delete(listener);\n\t}\n\n\treadonly #statusListeners = new Set<StatusListener>();\n\n\t#statusChanged(): void {\n\t\tnotifyStatus(this.#statusListeners, this.status, this.error, (error) => this.record.host.report(error));\n\t}\n\n\trelease(): void {\n\t\tif (this.status === \"released\" || this.status === \"gone\") return;\n\t\tthis.status = \"released\";\n\t\tthis.#stopReadables();\n\t\tthis.#statusChanged();\n\t\tthis.record.release(this);\n\t}\n\n\t// ─── internal ───\n\n\tlive(): void {\n\t\tif (this.status !== \"loading\") return;\n\t\tthis.status = \"live\";\n\t\tthis.#statusChanged();\n\t\tthis.shapeChanged();\n\t}\n\n\tgone(error: unknown): void {\n\t\tif (this.status === \"released\" || this.status === \"gone\") return;\n\t\tthis.status = \"gone\";\n\t\tthis.error = error;\n\t\tthis.#stopReadables();\n\t\tthis.#statusChanged();\n\t\tfor (const listener of [...this.goneListeners]) listener(error);\n\t}\n\n\tshapeChanged(): void {\n\t\tfor (const readable of this.readables.values()) readable.bind();\n\t\tconst shape = this.shape;\n\t\tif (shape === undefined) return;\n\t\tconst listeners = [...this.shapeListeners];\n\t\tenqueue(() => {\n\t\t\tfor (const listener of listeners) {\n\t\t\t\ttry {\n\t\t\t\t\tlistener(shape);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tthis.record.host.report(error);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t}\n\n\tterminalError(): unknown {\n\t\treturn this.status === \"gone\" ? this.error : new ChordError(\"released\", `handle ${this.address} released`);\n\t}\n\n\t/** The behavior as this consumer sees it (through an accepts adapter when bound to another version). */\n\tviewOf(installed: Installed): Record<string, unknown> {\n\t\tlet adapter = this.bindings.get(installed.service);\n\t\tif (!this.bindings.has(installed.service)) {\n\t\t\tadapter = bind(installed.service.contract, installed.service.options.accepts, this.contract);\n\t\t\tthis.bindings.set(installed.service, adapter);\n\t\t}\n\t\tif (adapter === undefined) return installed.behavior;\n\t\tlet view = this.views.get(installed.behavior);\n\t\tif (view === undefined) {\n\t\t\tview = adapter(installed.behavior);\n\t\t\tthis.views.set(installed.behavior, view);\n\t\t}\n\t\treturn view;\n\t}\n\n\tcurrentView(): Record<string, unknown> | undefined {\n\t\tif (this.status !== \"live\") return undefined;\n\t\tconst installed = this.record.currentInstalled();\n\t\treturn installed === undefined ? undefined : this.#safeView(installed);\n\t}\n\n\t/** The view, or undefined when this consumer no longer binds (reported; calls reject with the bind error). */\n\t#safeView(installed: Installed): Record<string, unknown> | undefined {\n\t\ttry {\n\t\t\treturn this.viewOf(installed);\n\t\t} catch (error) {\n\t\t\tthis.record.host.report(error);\n\t\t\treturn undefined;\n\t\t}\n\t}\n\n\tdescribe(kind: string | undefined, member: string): MemberDescription | undefined {\n\t\tconst variants = this.contract.description.variants;\n\t\tif (kind !== undefined) return variants[kind]?.[member];\n\t\tfor (const members of Object.values(variants)) if (members[member] !== undefined) return members[member];\n\t\treturn undefined;\n\t}\n\n\t/** Remote consumers see only the members their contract lists for the current variant. */\n\tinVariant(view: Record<string, unknown>, name: string): boolean {\n\t\treturn this.contract.scope !== \"remote\" || this.describe(kindOf(view), name) !== undefined;\n\t}\n\n\tmember(name: string): unknown {\n\t\tconst declared = this.describe(undefined, name);\n\t\tconst view = this.currentView();\n\t\tconst value = view?.[name];\n\t\tif (declared?.kind === \"method\" || (declared === undefined && typeof value === \"function\")) {\n\t\t\treturn this.caller(name);\n\t\t}\n\t\tif (declared?.kind === \"state\" || (declared === undefined && (isSource(value) || isReadableLike(value)))) {\n\t\t\tlet readable = this.readables.get(name);\n\t\t\tif (readable === undefined) {\n\t\t\t\treadable = new MemberReadable(this, name);\n\t\t\t\tthis.readables.set(name, readable);\n\t\t\t}\n\t\t\treturn readable;\n\t\t}\n\t\tif (view === undefined || !this.inVariant(view, name)) return undefined;\n\t\treturn value instanceof ExposedImpl ? value.resource.value : value;\n\t}\n\n\tcaller(name: string): (args: unknown, ctx?: Ctx) => Promise<unknown> {\n\t\tlet caller = this.callers.get(name);\n\t\tif (caller === undefined) {\n\t\t\tcaller = (args, ctx) => {\n\t\t\t\tif (this.record.host.inFactory > 0) {\n\t\t\t\t\tthrow new ChordError(\"not_ready\", `${this.address}.${name} called inside a factory`);\n\t\t\t\t}\n\t\t\t\tif (ctx !== undefined && !(ctx instanceof CtxImpl)) {\n\t\t\t\t\treturn Promise.reject(invalid(\"foreign_ctx\", \"ctx must come from a Chord host\"));\n\t\t\t\t}\n\t\t\t\tif (ctx === undefined || ctx.holder) {\n\t\t\t\t\t// A code holder (task) starts a fresh root per call, cancelled with the holder.\n\t\t\t\t\ttry {\n\t\t\t\t\t\tctx?.check(this.record.host);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\treturn Promise.reject(error);\n\t\t\t\t\t}\n\t\t\t\t\treturn this.record.host.root((root) => this.record.call(this, name, args, root as CtxImpl), {\n\t\t\t\t\t\tsignal: ctx?.signal,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn this.record.call(this, name, args, ctx);\n\t\t\t};\n\t\t\tthis.callers.set(name, caller);\n\t\t}\n\t\treturn caller;\n\t}\n\n\t#stopReadables(): void {\n\t\tfor (const readable of this.readables.values()) readable.stop();\n\t}\n}\n\nexport const kindOf = (behavior: Record<string, unknown>): string | undefined =>\n\ttypeof behavior.kind === \"string\" ? behavior.kind : undefined;\n\n// ─── Records ─────────────────────────────────────────────────────────────────\n\nexport type RecordStatus = \"activating\" | \"live\" | \"failed\" | \"disposing\" | \"disposed\";\n\ninterface Gate {\n\treadonly grandfathered: Set<string>;\n\treadonly queue: { readonly key: string; readonly event: unknown }[];\n\tdrained: () => void;\n}\n\ninterface Subscription {\n\t/** What the listener was declared on: the resource (not its facade), or the source itself. */\n\treadonly origin: unknown;\n\treadonly select: ListenerDecl[\"select\"];\n\tunsubscribe: () => void;\n}\n\n/**\n * Two `select` functions are the same if they are identical or have the same source text: an inline arrow is a new\n * object on every factory run, but its code is what matters. (A select whose behavior depends on captured values\n * that change between runs is not detected; such a listener keeps its old subscription until its source changes.)\n */\nconst sameSelect = (a: ListenerDecl[\"select\"], b: ListenerDecl[\"select\"]): boolean =>\n\ta === b || (a !== undefined && b !== undefined && String(a) === String(b));\n\n/** Listener subscriptions made ahead of a commit: `activate` switches over, `discard` drops them. */\nexport interface StagedListeners {\n\tactivate(): void;\n\tdiscard(): void;\n}\n\ninterface RunningTask {\n\treadonly controller: AbortController;\n\treadonly done: Promise<void>;\n}\n\nexport interface RecordIdentity {\n\treadonly address: string;\n\treadonly typeName: string;\n\treadonly input: unknown;\n\treadonly principal: Principal;\n\treadonly eager: boolean;\n}\n\nexport class RecordImpl {\n\treadonly host: HostCore;\n\treadonly address: string;\n\treadonly typeName: string;\n\treadonly input: unknown;\n\treadonly principal: Principal;\n\treadonly eager: boolean;\n\tstatus: RecordStatus = \"activating\";\n\tready: Promise<void> = Promise.resolve();\n\tservice: Service | undefined;\n\tstateVersion = 0;\n\t/** Calls carrying an older epoch are rejected upgrade_conflict (state bump or exclusive resource replaced). */\n\tminEpoch = 0;\n\tdecls = new Decls();\n\t/** Declarations of a factory run that has not been installed yet (activation or reload candidate). */\n\treadonly pending = new Set<Decls>();\n\treadonly behaviors = new Map<number, Installed>();\n\treadonly holds = new Set<HandleImpl>();\n\treadonly leases = new Map<string, number>();\n\treadonly openOrder: ResourceImpl[] = [];\n\treadonly callAbort = new AbortController();\n\treadonly activationAbort = new AbortController();\n\tgate: Gate | undefined;\n\t/** Served only by a running reload's pending epoch: listeners, tasks and registrations start at its commit. */\n\tdeferredRuntime = false;\n\treadonly #subscriptions = new Map<string, Subscription>();\n\treadonly #invocations = new Set<Promise<unknown>>();\n\t#tasks = new Map<string, RunningTask>();\n\treadonly #stopped: Promise<void>[] = [];\n\t#linger: ReturnType<typeof setTimeout> | undefined;\n\t#disposal: Promise<void> | undefined;\n\n\tconstructor(host: HostCore, identity: RecordIdentity) {\n\t\tthis.host = host;\n\t\tthis.address = identity.address;\n\t\tthis.typeName = identity.typeName;\n\t\tthis.input = identity.input;\n\t\tthis.principal = identity.principal;\n\t\tthis.eager = identity.eager;\n\t}\n\n\tstart(after: Promise<void> | undefined): void {\n\t\tthis.ready = this.#activate(after).then(\n\t\t\t() => {\n\t\t\t\tfor (const handle of this.holds) handle.live();\n\t\t\t\tthis.#maybeIdle();\n\t\t\t},\n\t\t\t(cause: unknown) => {\n\t\t\t\tif (this.status === \"activating\") this.status = \"failed\";\n\t\t\t\tthis.host.forget(this);\n\t\t\t\t// A ChordError (forbidden, a dependency's error, ...) keeps its code; anything else is `unavailable`.\n\t\t\t\tconst error = asChordError(cause, `activating ${this.address}`);\n\t\t\t\tfor (const handle of this.holds) handle.gone(error);\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t);\n\t\tthis.ready.catch(noop);\n\t}\n\n\t/**\n\t * Activation as one transaction: factory, opens, then a synchronous finalization (registry check and publication,\n\t * behaviors, runtime). Every failure, including one during finalization or a release while listeners start,\n\t * unwinds everything this activation did.\n\t */\n\tasync #activate(after: Promise<void> | undefined): Promise<void> {\n\t\tawait after?.catch(noop);\n\t\tconst signal = this.activationAbort.signal;\n\t\tconst abandoned = (): ChordError => new ChordError(\"aborted\", `${this.address} abandoned`);\n\t\tif (signal.aborted) throw abandoned();\n\t\tconst service = this.host.service(this.typeName);\n\t\tif (service === undefined)\n\t\t\tthrow new ChordError(\"unavailable\", `${this.typeName} is not served`, { reason: \"unknown_type\" });\n\t\tthis.service = service;\n\t\tthis.stateVersion = service.stateVersion;\n\t\tconst run = this.run(service, undefined);\n\t\ttry {\n\t\t\tawait this.open(run.created.resources, run.created.holds, signal);\n\t\t\tif (signal.aborted) throw abandoned();\n\t\t\tthis.host.checkRegistrations(this, run.decls);\n\t\t\tthis.decls = run.decls;\n\t\t\tfor (const [retained, services] of this.host.retainedEpochs()) {\n\t\t\t\tif (services.get(this.typeName) === service) {\n\t\t\t\t\tthis.behaviors.set(retained, { epoch: retained, service, behavior: run.behavior, decls: run.decls });\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst pending = this.host.pendingEpoch();\n\t\t\tif (!this.behaviors.has(this.host.currentEpoch()) && (pending === undefined || !this.behaviors.has(pending))) {\n\t\t\t\tthrow new ChordError(\"superseded\", `${this.address}: code changed during activation`);\n\t\t\t}\n\t\t\tfor (const derived of run.created.derives) derived.attach();\n\t\t\tthis.refreshSchemas();\n\t\t\t// Served only by a running reload's pending epoch: new code must not run (listeners, tasks, registrations)\n\t\t\t// before that reload commits.\n\t\t\tthis.deferredRuntime = !this.behaviors.has(this.host.currentEpoch());\n\t\t\tif (!this.deferredRuntime) {\n\t\t\t\tif (run.decls.registrations.size > 0) this.host.registriesChanged(this);\n\t\t\t\tthis.startRuntime();\n\t\t\t}\n\t\t\t// A listener starting up may have released the last hold synchronously: no resurrection.\n\t\t\tif (signal.aborted) throw abandoned();\n\t\t\tthis.status = \"live\";\n\t\t} catch (error) {\n\t\t\t// Invocations started during finalization (listener roots) end before their resources close.\n\t\t\tthis.callAbort.abort(error);\n\t\t\tthis.stopListeners();\n\t\t\tthis.stopTasks();\n\t\t\tconst registered = this.decls.registrations.size > 0 && !this.deferredRuntime;\n\t\t\tthis.behaviors.clear();\n\t\t\tthis.decls = new Decls();\n\t\t\tif (registered) this.host.registriesChanged();\n\t\t\tawait Promise.allSettled([...this.#invocations, ...this.#stopped.splice(0)]);\n\t\t\tawait this.unwind(run).catch((cleanup: unknown) => this.host.report(cleanup));\n\t\t\tthrow error;\n\t\t} finally {\n\t\t\tthis.pending.delete(run.decls);\n\t\t}\n\t}\n\n\t/**\n\t * Runs the factory synchronously. With `previous`, runs in recording mode for a reload prepare. The run's\n\t * declarations stay in `pending` (visible to the cycle check) until the caller installs or discards them.\n\t */\n\trun(service: Service, previous: Decls | undefined): Run {\n\t\tconst self = new SelfImpl(this, previous);\n\t\tconst discard = (run: Run): void => {\n\t\t\tthis.pending.delete(run.decls);\n\t\t\tvoid this.unwind(run).catch((cleanup: unknown) => this.host.report(cleanup));\n\t\t};\n\t\tthis.pending.add(self.run(undefined).decls);\n\t\tthis.host.inFactory++;\n\t\tlet behavior: unknown;\n\t\ttry {\n\t\t\tbehavior = service.factory(this.input, this.principal, self);\n\t\t} catch (error) {\n\t\t\tthis.host.inFactory--;\n\t\t\tdiscard(self.run(undefined));\n\t\t\tthrow error;\n\t\t}\n\t\tthis.host.inFactory--;\n\t\tconst run = self.run(behavior);\n\t\ttry {\n\t\t\tif (behavior instanceof Promise) throw invalid(\"behavior\", `${this.typeName}: factories must be synchronous`);\n\t\t\tvalidateBehavior(service, run.behavior);\n\t\t} catch (error) {\n\t\t\tdiscard(run);\n\t\t\tthrow error;\n\t\t}\n\t\treturn run;\n\t}\n\n\t/** Opens resources (dependencies first) and waits for holds; settles all before failing. */\n\tasync open(resources: readonly ResourceImpl[], holds: readonly Hold[], signal: AbortSignal): Promise<void> {\n\t\tconst opening = new Map<ResourceImpl, Promise<void>>();\n\t\tconst openOne = (resource: ResourceImpl): Promise<void> => {\n\t\t\tlet promise = opening.get(resource);\n\t\t\tif (promise === undefined) {\n\t\t\t\tpromise = (async () => {\n\t\t\t\t\tawait Promise.all(\n\t\t\t\t\t\tresource.deps.map((dep) =>\n\t\t\t\t\t\t\t!(dep instanceof ResourceImpl) ? dep.ready : resources.includes(dep) ? openOne(dep) : undefined,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\tawait resource.open(signal, this.openOrder);\n\t\t\t\t})();\n\t\t\t\topening.set(resource, promise);\n\t\t\t}\n\t\t\treturn promise;\n\t\t};\n\t\tconst results = await Promise.allSettled([...resources.map(openOne), ...holds.map((hold) => hold.ready)]);\n\t\tconst failure = results.find((result) => result.status === \"rejected\");\n\t\tif (failure !== undefined) throw failure.reason;\n\t}\n\n\t/** Undoes the objects a run created: closes its resources (reverse order) and releases its holds. */\n\tasync unwind(run: Run): Promise<void> {\n\t\tfor (const derived of run.created.derives) derived.detach();\n\t\tconst resources = [...run.created.resources].sort(\n\t\t\t(a, b) => this.openOrder.indexOf(b) - this.openOrder.indexOf(a),\n\t\t);\n\t\tawait runAll(\n\t\t\t[\n\t\t\t\t...resources.map((resource) => () => resource.close(this.openOrder)),\n\t\t\t\t...run.created.holds.map((hold) => () => hold.release()),\n\t\t\t],\n\t\t\t`${this.address}: cleanup failed`,\n\t\t);\n\t}\n\n\tcurrentInstalled(): Installed | undefined {\n\t\treturn this.behaviors.get(this.host.currentEpoch()) ?? [...this.behaviors.values()].at(-1);\n\t}\n\n\t/** Every state source exposed as a remote state member gets that member's schema (checked per write in dev mode). */\n\trefreshSchemas(): void {\n\t\tconst schemas = new Map<Readable<unknown>, TSchema[]>();\n\t\tfor (const installed of this.behaviors.values()) {\n\t\t\tfor (const [source, list] of memberSchemas(installed.service, installed.behavior)) {\n\t\t\t\tschemas.set(source, [...(schemas.get(source) ?? []), ...list]);\n\t\t\t}\n\t\t}\n\t\tfor (const decls of this.allDecls()) {\n\t\t\tfor (const source of [...decls.cells.values(), ...decls.derives.values()])\n\t\t\t\tsource.schemas = schemas.get(source) ?? [];\n\t\t}\n\t}\n\n\tallDecls(): Set<Decls> {\n\t\tconst result = new Set<Decls>([this.decls, ...this.pending]);\n\t\tfor (const installed of this.behaviors.values()) result.add(installed.decls);\n\t\treturn result;\n\t}\n\n\t// ─── runtime: listeners and tasks of the current declarations ───\n\n\t/** The resource a listener is declared on, or its source itself. */\n\t#origin(decl: ListenerDecl): unknown {\n\t\treturn resourceOf(decl.source) ?? decl.source;\n\t}\n\n\t/** Resolves a listener's subscribable: `select(resource value)`, `select(source)` or the source itself. */\n\t#listenSource(key: string, decl: ListenerDecl): Subscribable<unknown> {\n\t\tconst resource = resourceOf(decl.source);\n\t\tconst value = resource === undefined ? decl.source : resource.value;\n\t\tconst source = (decl.select === undefined ? value : decl.select(value as never)) as Subscribable<unknown>;\n\t\tif (typeof source?.subscribe !== \"function\")\n\t\t\tthrow invalid(\"behavior\", `listener ${key}: source has no subscribe()`);\n\t\treturn source;\n\t}\n\n\t/**\n\t * Subscribes the listeners of `decls` without delivering: events are buffered until `activate`. A listener declared\n\t * on the same resource (or source) with the same `select` keeps its subscription without calling `select` again\n\t * (only its function is swapped, by name), so sources that accept a single subscriber survive reloads. Throws, with\n\t * nothing left subscribed, if any source fails.\n\t */\n\tstageListeners(decls: Decls): StagedListeners {\n\t\tconst fresh = new Map<string, Subscription & { buffer: unknown[] | undefined }>();\n\t\tconst kept = new Set<string>();\n\t\ttry {\n\t\t\tfor (const [key, decl] of decls.listeners) {\n\t\t\t\tconst origin = this.#origin(decl);\n\t\t\t\tconst previous = this.#subscriptions.get(key);\n\t\t\t\tif (previous !== undefined && previous.origin === origin && sameSelect(previous.select, decl.select)) {\n\t\t\t\t\tkept.add(key);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t\tconst source = this.#listenSource(key, decl);\n\t\t\t\tconst entry: Subscription & { buffer: unknown[] | undefined } = {\n\t\t\t\t\torigin,\n\t\t\t\t\tselect: decl.select,\n\t\t\t\t\tunsubscribe: noop,\n\t\t\t\t\tbuffer: [],\n\t\t\t\t};\n\t\t\t\tfresh.set(key, entry);\n\t\t\t\tentry.unsubscribe = source.subscribe((event) => {\n\t\t\t\t\tif (entry.buffer !== undefined) entry.buffer.push(event);\n\t\t\t\t\telse this.#deliver(key, event);\n\t\t\t\t});\n\t\t\t}\n\t\t} catch (error) {\n\t\t\tfor (const entry of fresh.values()) entry.unsubscribe();\n\t\t\tthrow error;\n\t\t}\n\t\treturn {\n\t\t\tactivate: () => {\n\t\t\t\tfor (const [key, subscription] of this.#subscriptions) {\n\t\t\t\t\tif (kept.has(key)) continue;\n\t\t\t\t\tsubscription.unsubscribe();\n\t\t\t\t\tthis.#subscriptions.delete(key);\n\t\t\t\t}\n\t\t\t\tfor (const [key, entry] of fresh) {\n\t\t\t\t\tthis.#subscriptions.set(key, entry);\n\t\t\t\t\tconst buffered = entry.buffer ?? [];\n\t\t\t\t\tentry.buffer = undefined;\n\t\t\t\t\tfor (const event of buffered) this.#deliver(key, event);\n\t\t\t\t}\n\t\t\t},\n\t\t\tdiscard: () => {\n\t\t\t\tfor (const entry of fresh.values()) entry.unsubscribe();\n\t\t\t},\n\t\t};\n\t}\n\n\tstartRuntime(): void {\n\t\tthis.stageListeners(this.decls).activate();\n\t\tthis.startTasks();\n\t}\n\n\tstartTasks(): void {\n\t\tfor (const key of this.decls.tasks.keys()) this.startTask(key, this.host.currentEpoch());\n\t}\n\n\tstopListeners(): void {\n\t\tfor (const subscription of this.#subscriptions.values()) subscription.unsubscribe();\n\t\tthis.#subscriptions.clear();\n\t}\n\n\tstartTask(key: string, epoch: number): void {\n\t\tconst fn = this.decls.tasks.get(key);\n\t\tif (fn === undefined) return;\n\t\tconst controller = new AbortController();\n\t\tconst ctx = new CtxImpl(this.host, {\n\t\t\tsignal: AbortSignal.any([controller.signal, this.callAbort.signal]),\n\t\t\trootId: `task:${this.address}:${key}`,\n\t\t\tepoch,\n\t\t\tprincipal: this.host.principal,\n\t\t\tholder: true,\n\t\t});\n\t\tconst done = (async () => {\n\t\t\ttry {\n\t\t\t\tawait fn(ctx);\n\t\t\t} catch (error) {\n\t\t\t\tif (!ctx.signal.aborted) this.host.report(error);\n\t\t\t} finally {\n\t\t\t\tctx.close();\n\t\t\t\tif (this.#tasks.get(key)?.controller === controller) this.#tasks.delete(key);\n\t\t\t}\n\t\t})();\n\t\tthis.#tasks.set(key, { controller, done });\n\t}\n\n\t/** Aborts running tasks; their completion is awaited at disposal. */\n\tstopTasks(): void {\n\t\tfor (const task of this.#tasks.values()) {\n\t\t\ttask.controller.abort(new ChordError(\"aborted\", \"task stopped\"));\n\t\t\tthis.#stopped.push(task.done);\n\t\t}\n\t\tthis.#tasks.clear();\n\t}\n\n\t/**\n\t * Delivers one listener event, in publication order. The invocation is a root that holds a lease on this record\n\t * (a reload gate waits for it like for any other root that touched the record), counts as an invocation (disposal\n\t * waits for it) and is cancelled by forced disposal.\n\t */\n\t#deliver(key: string, event: unknown): void {\n\t\tenqueue(() => {\n\t\t\tif (this.gate !== undefined) {\n\t\t\t\tthis.gate.queue.push({ key, event });\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst decl = this.decls.listeners.get(key);\n\t\t\tif (decl === undefined || (this.status !== \"live\" && this.status !== \"activating\")) return;\n\t\t\tconst invocation = this.host.root((root) => {\n\t\t\t\tthis.lease(root);\n\t\t\t\tconst child = (root as CtxImpl).child(this);\n\t\t\t\treturn this.#invoke(async () => {\n\t\t\t\t\ttry {\n\t\t\t\t\t\tawait decl.fn(event, child);\n\t\t\t\t\t} finally {\n\t\t\t\t\t\tchild.close();\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t});\n\t\t\tinvocation.catch((error: unknown) => this.host.report(error));\n\t\t});\n\t}\n\n\t/** Opens the record's gate and replays queued listener events through the current listeners. */\n\topenGate(): void {\n\t\tconst gate = this.gate;\n\t\tthis.gate = undefined;\n\t\tfor (const { key, event } of gate?.queue ?? []) this.#deliver(key, event);\n\t}\n\n\t// ─── calls ───\n\n\t/** Admission for a call or write carrying `ctx`. */\n\tadmit(ctx: Ctx): void {\n\t\tif (this.host.failed !== undefined) {\n\t\t\tthrow new ChordError(\"unavailable\", `${this.host.name} failed and admits no work`, { reason: \"host_failed\" });\n\t\t}\n\t\tif (!this.host.hasEpoch(ctx.epoch)) throw new ChordError(\"superseded\", `epoch ${ctx.epoch} is retired`);\n\t\tif (ctx.epoch < this.minEpoch) {\n\t\t\tthrow new ChordError(\"upgrade_conflict\", `${this.address} was upgraded in epoch ${this.minEpoch}`);\n\t\t}\n\t\tif (this.gate !== undefined && !this.gate.grandfathered.has(ctx.rootId)) {\n\t\t\tthrow new ChordError(\"upgrade_conflict\", `${this.address} is being upgraded`);\n\t\t}\n\t}\n\n\t/** Records that the root of `ctx` touched this record (a reload gate grandfathers it). */\n\tlease(ctx: Ctx): void {\n\t\tif (this.leases.has(ctx.rootId)) return;\n\t\tthis.leases.set(ctx.rootId, ctx.epoch);\n\t\tthis.host.touch(ctx.rootId, this);\n\t}\n\n\tguard = (ctx: Ctx): void => {\n\t\tif (this.host.inFactory > 0) throw invalid(\"read_only\", \"cells cannot be written while a factory runs\");\n\t\tif (ctx instanceof CtxImpl) ctx.check(this.host);\n\t\tif (ctx.signal.aborted) throw new ChordError(\"aborted\", \"write with an aborted ctx\");\n\t\tif (this.status === \"disposed\") throw new ChordError(\"gone\", `${this.address} is disposed`);\n\t\tif (ctx.rootId.startsWith(\"task:\")) return;\n\t\tthis.admit(ctx);\n\t};\n\n\tasync call(handle: HandleImpl, name: string, args: unknown, ctx: CtxImpl): Promise<unknown> {\n\t\tctx.check(this.host);\n\t\tif (handle.status === \"released\" || handle.status === \"gone\") throw handle.terminalError();\n\t\tif (handle.status === \"loading\") await raceSignal(handle.ready, ctx.signal);\n\t\tif (handle.status !== \"live\" || this.status !== \"live\") {\n\t\t\tthrow handle.status === \"live\"\n\t\t\t\t? new ChordError(\"gone\", `${this.address} is ${this.status}`)\n\t\t\t\t: handle.terminalError();\n\t\t}\n\t\tthis.admit(ctx);\n\t\tconst installed = this.behaviors.get(ctx.epoch);\n\t\tif (installed === undefined)\n\t\t\tthrow new ChordError(\"superseded\", `${this.address} has no behavior for epoch ${ctx.epoch}`);\n\t\tconst view = handle.viewOf(installed);\n\t\tconst kind = kindOf(view);\n\t\tconst wanted = handle.describe(handle.contract.scope === \"remote\" ? kind : LOCAL_VARIANT, name);\n\t\tconst fn = view[name];\n\t\tif (typeof fn !== \"function\" || (handle.contract.scope === \"remote\" && wanted?.kind !== \"method\")) {\n\t\t\tthrow new ChordError(\n\t\t\t\t\"not_in_variant\",\n\t\t\t\t`${this.address}: ${name} is not a method of variant ${kind ?? \"(local)\"}`,\n\t\t\t);\n\t\t}\n\t\tconst direct = view === installed.behavior;\n\t\tconst schema = direct ? installed.service.contract.description.variants[kind ?? LOCAL_VARIANT]?.[name] : wanted;\n\t\tconst validated = handle.contract.scope === \"remote\" && schema?.kind === \"method\" ? schema : undefined;\n\t\t// The additive rule assumes a consumer sends only what its own schema knows, and a provider sees only what its\n\t\t// schema knows: strip with both before validating.\n\t\tconst own = handle.contract.scope === \"remote\" && wanted?.kind === \"method\" ? wanted.args : undefined;\n\t\tconst sent = own === undefined ? args : Value.Clean(own, Value.Clone(args));\n\t\tconst input = validated ? Value.Clean(validated.args, Value.Clone(sent)) : sent;\n\t\tif (validated) assertValid(\"args\", `${this.address}.${name} args`, validated.args, input);\n\t\tthis.lease(ctx);\n\t\tconst child = ctx.child(this);\n\t\tlet result: unknown;\n\t\ttry {\n\t\t\tresult = await this.#invoke(() => (fn as (args: unknown, ctx: Ctx) => unknown)(input, child));\n\t\t} finally {\n\t\t\tchild.close();\n\t\t}\n\t\tif (validated) assertValid(\"result\", `${this.address}.${name} result`, validated.result, result);\n\t\treturn result;\n\t}\n\n\t/** Runs an invocation (method or listener) that keeps the record alive until it settles. */\n\t#invoke<T>(fn: () => T | Promise<T>): Promise<T> {\n\t\tconst invocation = (async () => fn())();\n\t\tthis.#invocations.add(invocation);\n\t\tconst done = (): void => {\n\t\t\tthis.#invocations.delete(invocation);\n\t\t\tif (this.#invocations.size === 0) this.#maybeIdle();\n\t\t};\n\t\tinvocation.then(done, done);\n\t\treturn invocation;\n\t}\n\n\trootEnded(rootId: string): void {\n\t\tthis.leases.delete(rootId);\n\t\tconst gate = this.gate;\n\t\tif (gate?.grandfathered.delete(rootId) && gate.grandfathered.size === 0) gate.drained();\n\t}\n\n\t// ─── lifetime ───\n\n\taddHold(handle: HandleImpl): void {\n\t\tthis.holds.add(handle);\n\t\tif (this.#linger !== undefined) clearTimeout(this.#linger);\n\t\tthis.#linger = undefined;\n\t}\n\n\trelease(handle: HandleImpl): void {\n\t\tif (this.holds.delete(handle)) this.#maybeIdle();\n\t}\n\n\t/** No holds and no invocations: dispose (after `linger` for a live record). */\n\t#maybeIdle(): void {\n\t\tif (this.holds.size > 0 || this.#invocations.size > 0 || this.#linger !== undefined) return;\n\t\tif (this.status === \"activating\") {\n\t\t\tthis.#background(this.dispose(false));\n\t\t\treturn;\n\t\t}\n\t\tif (this.status !== \"live\") return;\n\t\tconst linger = this.service?.options.linger ?? 0;\n\t\tif (linger <= 0) {\n\t\t\tthis.#background(this.dispose(false));\n\t\t\treturn;\n\t\t}\n\t\tthis.#linger = setTimeout(() => {\n\t\t\tthis.#linger = undefined;\n\t\t\tif (this.holds.size === 0 && this.#invocations.size === 0 && this.status === \"live\") {\n\t\t\t\tthis.#background(this.dispose(false));\n\t\t\t}\n\t\t}, linger);\n\t\tthis.#linger.unref?.();\n\t}\n\n\t#background(disposal: Promise<void>): void {\n\t\tdisposal.catch((error: unknown) => this.host.report(error));\n\t}\n\n\t/**\n\t * Disposes the record. Forced: handles become gone at once (new calls are rejected) and running invocations are\n\t * cancelled. Either way, resources close only after every invocation settled.\n\t */\n\tdispose(forced: boolean, reason?: unknown): Promise<void> {\n\t\tthis.#disposal ??= this.#dispose(forced, reason);\n\t\treturn this.#disposal;\n\t}\n\n\tasync #dispose(forced: boolean, reason: unknown): Promise<void> {\n\t\tconst wasActivating = this.status === \"activating\";\n\t\tthis.status = \"disposing\";\n\t\tthis.host.forget(this);\n\t\tif (this.#linger !== undefined) clearTimeout(this.#linger);\n\t\tthis.#linger = undefined;\n\t\tconst error = reason ?? new ChordError(\"gone\", `${this.address} was disposed`);\n\t\tif (forced) {\n\t\t\tfor (const handle of this.holds) handle.gone(error);\n\t\t\tthis.callAbort.abort(error);\n\t\t}\n\t\tthis.activationAbort.abort(error);\n\t\tif (wasActivating) await this.ready.catch(noop);\n\t\tfor (const handle of this.holds) handle.gone(error);\n\t\tconst decls = this.allDecls();\n\t\tthis.stopTasks();\n\t\tthis.stopListeners();\n\t\tawait Promise.allSettled([...this.#invocations]);\n\t\tconst registered = [...decls].some((set) => set.registrations.size > 0) && !this.deferredRuntime;\n\t\tthis.behaviors.clear();\n\t\tthis.decls = new Decls();\n\t\tif (registered) this.host.registriesChanged();\n\t\tconst holds = new Set<Hold>();\n\t\tfor (const set of decls) {\n\t\t\tfor (const derived of set.derives.values()) derived.detach();\n\t\t\tfor (const hold of set.holds.values()) holds.add(hold);\n\t\t}\n\t\ttry {\n\t\t\tawait runAll(\n\t\t\t\t[\n\t\t\t\t\t() => Promise.allSettled(this.#stopped.splice(0)),\n\t\t\t\t\t...[...this.openOrder].reverse().map((resource) => () => resource.close(this.openOrder)),\n\t\t\t\t\t...[...holds].map((hold) => () => hold.release()),\n\t\t\t\t],\n\t\t\t\t`${this.address}: disposal failed`,\n\t\t\t);\n\t\t} finally {\n\t\t\tthis.status = \"disposed\";\n\t\t}\n\t}\n}\n\nconst isReadableLike = (value: unknown): boolean =>\n\tvalue !== null &&\n\ttypeof value === \"object\" &&\n\ttypeof (value as Readable<unknown>).events === \"function\" &&\n\ttypeof (value as Readable<unknown>).subscribe === \"function\";\n\n/** The remote state-member schemas a behavior exposes, by source. */\nexport function memberSchemas(service: Service, behavior: Record<string, unknown>): Map<Readable<unknown>, TSchema[]> {\n\tconst schemas = new Map<Readable<unknown>, TSchema[]>();\n\tconst contract = service.contract;\n\tif (contract.scope !== \"remote\") return schemas;\n\tconst members = contract.description.variants[kindOf(behavior) ?? \"\"] ?? {};\n\tfor (const [name, description] of Object.entries(members)) {\n\t\tconst source = behavior[name];\n\t\tif (description.kind !== \"state\" || !isSource(source)) continue;\n\t\tschemas.set(source, [...(schemas.get(source) ?? []), description.schema]);\n\t}\n\treturn schemas;\n}\n\nfunction validateBehavior(service: Service, behavior: Record<string, unknown>): void {\n\tconst contract = service.contract;\n\tconst fail = (message: string): never => {\n\t\tthrow invalid(\"behavior\", `${contract.name}: ${message}`);\n\t};\n\tif (behavior === null || typeof behavior !== \"object\") fail(\"factory must return an object\");\n\tlet members: Readonly<Record<string, MemberDescription>>;\n\tif (contract.scope === \"remote\") {\n\t\tconst kind = behavior.kind;\n\t\tif (typeof kind !== \"string\" || contract.description.variants[kind] === undefined)\n\t\t\tfail(`unknown variant ${String(kind)}`);\n\t\tmembers = contract.description.variants[kind as string]!;\n\t\tfor (const key of Object.keys(behavior))\n\t\t\tif (key !== \"kind\" && members[key] === undefined) fail(`${key} is not in variant ${String(kind)}`);\n\t} else {\n\t\tmembers = contract.description.variants[LOCAL_VARIANT] ?? {};\n\t}\n\tfor (const [name, description] of Object.entries(members)) {\n\t\tconst value = behavior[name];\n\t\tif (description.kind === \"method\" && typeof value !== \"function\") fail(`${name} must be a method`);\n\t\tif (description.kind === \"state\" && !isSource(value) && !isReadableLike(value)) {\n\t\t\tfail(`${name} must be a cell, a derivation or a held object's state member`);\n\t\t}\n\t\tif (description.kind === \"opaque\" && value === undefined) fail(`${name} is missing`);\n\t}\n}\n\n// ─── The factory's `self` ────────────────────────────────────────────────────\n\nclass SelfImpl implements Self {\n\treadonly #record: RecordImpl;\n\treadonly #previous: Decls | undefined;\n\treadonly #decls = new Decls();\n\treadonly #created: { holds: Hold[]; resources: ResourceImpl[]; derives: Derived<unknown>[] } = {\n\t\tholds: [],\n\t\tresources: [],\n\t\tderives: [],\n\t};\n\n\tconstructor(record: RecordImpl, previous: Decls | undefined) {\n\t\tthis.#record = record;\n\t\tthis.#previous = previous;\n\t}\n\n\trun(behavior: unknown): Run {\n\t\treturn { behavior: behavior as Record<string, unknown>, decls: this.#decls, created: this.#created };\n\t}\n\n\t/** Iterates named declarations of one kind, rejecting repeated names and wrong descriptors. */\n\t*#entries<T>(\n\t\tmap: ReadonlyMap<string, unknown>,\n\t\tkind: string,\n\t\tentries: Readonly<Record<string, T>>,\n\t\tdescriptor?: string,\n\t) {\n\t\tif (entries === null || typeof entries !== \"object\")\n\t\t\tthrow new TypeError(`${kind} takes an object of named declarations`);\n\t\tfor (const [name, value] of Object.entries(entries)) {\n\t\t\tif (map.has(name)) throw invalid(\"duplicate\", `${this.#record.typeName}: duplicate ${kind} name ${name}`);\n\t\t\tif (descriptor !== undefined && declKind(value) !== descriptor) {\n\t\t\t\tthrow new TypeError(`${kind}.${name} must be declared with ${descriptor}()`);\n\t\t\t}\n\t\t\tyield [name, value] as const;\n\t\t}\n\t}\n\n\tstate<const D extends Readonly<Record<string, CellDecl<unknown>>>>(cells: D): Cells<D> {\n\t\tconst result: Record<string, Cell<unknown>> = {};\n\t\tconst host = this.#record.host;\n\t\tfor (const [name, decl] of this.#entries(this.#decls.cells, \"state\", cells, \"cell\")) {\n\t\t\tconst cell =\n\t\t\t\tthis.#previous?.cells.get(name) ??\n\t\t\t\tnew Cell(name, decl.schema, decl.initial, this.#record.guard, {\n\t\t\t\t\tdev: host.dev,\n\t\t\t\t\treport: (error) => host.report(error),\n\t\t\t\t});\n\t\t\tthis.#decls.cells.set(name, cell);\n\t\t\tthis.#decls.cellSchemas.set(name, decl.schema);\n\t\t\tresult[name] = cell;\n\t\t}\n\t\treturn result as Cells<D>;\n\t}\n\n\tget<C extends AnyContract>(type: C, input: InputOf<C>, options?: GetOptions): Handle<C> {\n\t\tconst host = this.#record.host;\n\t\t// A prepare rerun (recording mode) binds new holds against the reload's pending contracts: a breaking provider\n\t\t// change and its updated consumer reload together.\n\t\tconst candidate = this.#previous !== undefined;\n\t\tconst address = host.addressOf(type, input, options?.principal ?? host.principal, options?.at, candidate);\n\t\tconst declared = this.#decls.holds.get(address);\n\t\tif (declared !== undefined) {\n\t\t\tif (declared.contract.fingerprint !== type.fingerprint) {\n\t\t\t\tthrow invalid(\"duplicate\", `${this.#record.typeName}: ${type.name} held twice with different contracts`);\n\t\t\t}\n\t\t\treturn declared.proxy as Handle<C>;\n\t\t}\n\t\tconst existing = this.#previous?.holds.get(address);\n\t\tif (\n\t\t\texisting !== undefined &&\n\t\t\texisting.contract.fingerprint === type.fingerprint &&\n\t\t\texisting.status !== \"gone\" &&\n\t\t\texisting.status !== \"released\"\n\t\t) {\n\t\t\tthis.#decls.holds.set(address, existing);\n\t\t\treturn existing.proxy as Handle<C>;\n\t\t}\n\t\tconst handle = host.acquire(type, input, options, \"record\", this.#record, candidate);\n\t\tthis.#decls.holds.set(address, handle);\n\t\tthis.#created.holds.push(handle);\n\t\treturn handle.proxy as Handle<C>;\n\t}\n\n\tresources<const D extends Readonly<Record<string, ResourceDecl<unknown>>>>(resources: D): Resources<D> {\n\t\tconst result: Record<string, ResourceImpl> = {};\n\t\tfor (const [name, { spec }] of this.#entries(this.#decls.resources, \"resources\", resources, \"resource\")) {\n\t\t\tconst deps = (spec.deps ?? []).map((dep) => {\n\t\t\t\tconst resolved = handleOf(dep) ?? resourceOf(dep);\n\t\t\t\tif (resolved === undefined) {\n\t\t\t\t\tthrow new TypeError(`resource ${name}: deps must be handles or resources of this record`);\n\t\t\t\t}\n\t\t\t\treturn resolved;\n\t\t\t});\n\t\t\tconst existing = this.#previous?.resources.get(name);\n\t\t\tconst kept =\n\t\t\t\texisting !== undefined &&\n\t\t\t\texisting.spec.rev === spec.rev &&\n\t\t\t\texisting.exclusive === (spec.exclusive === true) &&\n\t\t\t\texisting.deps.length === deps.length &&\n\t\t\t\texisting.deps.every((dep, index) => dep === deps[index]);\n\t\t\tconst resource = kept ? existing : new ResourceImpl(name, spec, deps);\n\t\t\tif (!kept) this.#created.resources.push(resource);\n\t\t\tthis.#decls.resources.set(name, resource);\n\t\t\tresult[name] = new ResourceFacade(resource, this.#record.host) as unknown as ResourceImpl;\n\t\t}\n\t\treturn result as unknown as Resources<D>;\n\t}\n\n\tlisten(listeners: Readonly<Record<string, ListenerDecl>>): void {\n\t\tfor (const [name, decl] of this.#entries(this.#decls.listeners, \"listen\", listeners, \"listener\")) {\n\t\t\tthis.#decls.listeners.set(name, decl);\n\t\t}\n\t}\n\n\ttasks(tasks: Readonly<Record<string, (ctx: Ctx) => Promise<void>>>): void {\n\t\tfor (const [name, fn] of this.#entries(this.#decls.tasks, \"tasks\", tasks)) {\n\t\t\tif (typeof fn !== \"function\") throw new TypeError(`tasks.${name} must be a function`);\n\t\t\tthis.#decls.tasks.set(name, fn);\n\t\t}\n\t}\n\n\tderive<const D extends Readonly<Record<string, DerivationDecl<unknown>>>>(derivations: D): Derivations<D> {\n\t\tconst result: Record<string, Derived<unknown>> = {};\n\t\tconst host = this.#record.host;\n\t\tfor (const [name, { sources, fn }] of this.#entries(this.#decls.derives, \"derive\", derivations, \"derivation\")) {\n\t\t\tconst existing = this.#previous?.derives.get(name);\n\t\t\tlet derived: Derived<unknown>;\n\t\t\tif (\n\t\t\t\texisting !== undefined &&\n\t\t\t\texisting.sources.length === sources.length &&\n\t\t\t\texisting.sources.every((source, index) => source === sources[index])\n\t\t\t) {\n\t\t\t\tderived = existing;\n\t\t\t} else {\n\t\t\t\tderived = new Derived(name, sources, fn, { dev: host.dev, report: (error) => host.report(error) });\n\t\t\t\tthis.#created.derives.push(derived);\n\t\t\t}\n\t\t\tthis.#decls.derives.set(name, derived);\n\t\t\tthis.#decls.deriveFns.set(name, fn);\n\t\t\tresult[name] = derived;\n\t\t}\n\t\treturn result as unknown as Derivations<D>;\n\t}\n\n\texpose<T>(resource: Resource<T>): Exposed<T> {\n\t\tconst resolved = resourceOf(resource);\n\t\tif (resolved === undefined || ![...this.#decls.resources.values()].includes(resolved)) {\n\t\t\tthrow new TypeError(\"expose takes a resource declared by this record\");\n\t\t}\n\t\treturn new ExposedImpl(resolved) as unknown as Exposed<T>;\n\t}\n\n\tregister<V>(registry: Registry<V>, entries: Readonly<Record<string, V>>): void {\n\t\tif (!this.#record.eager) throw invalid(\"not_eager\", `${this.#record.typeName}: only eager records may register`);\n\t\tconst prefixed: Record<string, V> = {};\n\t\tfor (const [key, value] of Object.entries(entries)) prefixed[`${registry.name}\\u0000${key}`] = value;\n\t\tfor (const [id, value] of this.#entries(this.#decls.registrations, \"register\", prefixed)) {\n\t\t\tthis.#decls.registrations.set(id, {\n\t\t\t\tregistry: registry as Registry<unknown>,\n\t\t\t\tkey: id.slice(registry.name.length + 1),\n\t\t\t\tvalue,\n\t\t\t});\n\t\t}\n\t}\n}\n"]}