@party-stack/ontology-server 0.13.0 → 0.15.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.
package/lib/rpc.js CHANGED
@@ -9,7 +9,7 @@ import { Cause, Context, Deferred, Effect, Exit, Layer, PubSub, Random, Schedule
9
9
  import { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSchema } from "effect/rpc";
10
10
  import { ontologyDefinitionContractHash, ontologyDefinitionHash, ontologyDefinitionSignature } from "@party-stack/ontology-storage";
11
11
  import { Table } from "@party-stack/ontology-storage/tables";
12
- import { pinOntology } from "@party-stack/ontology-replica";
12
+ import { systemOntology } from "@party-stack/ontology-replica";
13
13
  import { objectSubset } from "@party-stack/ontology-backend/subset";
14
14
  import { ClientLeaseSchema, ClientSessionSchema, ClientTokenSchema } from "@party-stack/ontology-backend/clients";
15
15
  import { DeliveryFrameCodec, DeliveryPositionSchema } from "@party-stack/ontology-backend/delivery";
@@ -213,7 +213,7 @@ const baseOntologyRpcHandlers = (options) => {
213
213
  watchSubset: clientSync && Boolean(operationOptions.backend?.watchSubset || options.ir?.objectTypes.some((type) => typeof operationOptions.backend?.refresh?.(objectSubset(type.name))?.pollIntervalMs === "number")),
214
214
  actionParameterResolution: Boolean(options.backend?.resolveActionParameters || options.replica),
215
215
  queries: Boolean(options.backend),
216
- pins: Boolean(options.replica),
216
+ system: Boolean(options.replica),
217
217
  meta: Boolean(options.ir),
218
218
  attachments: options.backend ? options.backend.attachments && { stage: Boolean(options.backend.attachments.stage) } : options.replica ? { stage: true } : void 0,
219
219
  encrypted: Boolean(options.backend ? options.backend.encrypted : options.replica)
@@ -328,9 +328,9 @@ const resourceHeader = "x-party-stack-resource";
328
328
  const ontologyRpcHandlers = (options) => Layer.unwrap(Effect.gen(function* () {
329
329
  const scope = yield* Effect.scope;
330
330
  const ordinary = yield* Layer.buildWithScope(baseOntologyRpcHandlers(options), scope);
331
- const pins = yield* Effect.cached(Effect.gen(function* () {
331
+ const system = yield* Effect.cached(Effect.gen(function* () {
332
332
  if (!options.replica) return yield* new BackendError({
333
- operation: "pins",
333
+ operation: "system",
334
334
  kind: "NotImplemented",
335
335
  retryable: false,
336
336
  message: "This endpoint does not own downloads."
@@ -338,11 +338,11 @@ const ontologyRpcHandlers = (options) => Layer.unwrap(Effect.gen(function* () {
338
338
  const backend = yield* options.replica.demand.pins.backend;
339
339
  return yield* Layer.buildWithScope(baseOntologyRpcHandlers({
340
340
  backend,
341
- ir: pinOntology,
341
+ ir: systemOntology,
342
342
  context: options.context,
343
343
  enableRealtime: options.enableRealtime,
344
344
  errors: options.errors,
345
- authorize: (_, headers) => options.authorize({ operation: "Pins" }, headers)
345
+ authorize: (_, headers) => options.authorize({ operation: "System" }, headers)
346
346
  }), scope);
347
347
  }));
348
348
  const describeAccess = (headers) => options.authorize({ operation: "Describe" }, headers);
@@ -366,14 +366,14 @@ const ontologyRpcHandlers = (options) => Layer.unwrap(Effect.gen(function* () {
366
366
  const handlers = Object.fromEntries([...OntologyRpcs.requests].map(([tag, rpc]) => {
367
367
  const invoke = (payload, request) => Effect.gen(function* () {
368
368
  const resource = request.headers[resourceHeader];
369
- if (resource !== void 0 && resource !== "pins" && resource !== "meta") return yield* new BackendError({
369
+ if (resource !== void 0 && resource !== "system" && resource !== "meta") return yield* new BackendError({
370
370
  operation: "ontology.resource",
371
371
  kind: "NotFound",
372
372
  retryable: false,
373
373
  message: "Unknown ontology resource."
374
374
  });
375
- if (resource === "pins") yield* options.authorize({ operation: "Pins" }, request.headers);
376
- const context = resource === "pins" ? yield* pins : resource === "meta" ? yield* meta : ordinary;
375
+ if (resource === "system") yield* options.authorize({ operation: "System" }, request.headers);
376
+ const context = resource === "system" ? yield* system : resource === "meta" ? yield* meta : ordinary;
377
377
  return (yield* OntologyRpcs.accessHandler(tag).pipe(Effect.provideContext(context)))(payload, request);
378
378
  });
379
379
  return [tag, RpcSchema.isStreamSchema(rpc.successSchema) ? (payload, request) => Stream.unwrap(invoke(payload, request).pipe(Effect.map((result) => result))) : (payload, request) => Effect.flatten(invoke(payload, request).pipe(Effect.map((result) => result)))];
@@ -381,7 +381,7 @@ const ontologyRpcHandlers = (options) => Layer.unwrap(Effect.gen(function* () {
381
381
  return Layer.merge(OntologyRpcs.toLayer(handlers), errorProjectionLayer(options));
382
382
  }));
383
383
  const resourceDefinitions = {
384
- pins: pinOntology,
384
+ system: systemOntology,
385
385
  meta: metaOntology
386
386
  };
387
387
  const selectResource = (client, resource) => Object.fromEntries([...OntologyRpcs.requests.keys()].map((tag) => [tag, (payload, settings) => Reflect.apply(Reflect.get(client, tag), client, [payload, {
@@ -423,7 +423,7 @@ const protocolIdentity = (description) => ({
423
423
  watchSubset: Boolean(description.watchSubset),
424
424
  actionParameterResolution: Boolean(description.actionParameterResolution),
425
425
  queries: Boolean(description.queries),
426
- pins: Boolean(description.pins),
426
+ system: Boolean(description.system),
427
427
  meta: Boolean(description.meta),
428
428
  attachments: Boolean(description.attachments),
429
429
  stageAttachments: Boolean(description.attachments?.stage),
@@ -615,21 +615,30 @@ const openProtocolClient = Effect.fnUntraced(function* (client, options, accept,
615
615
  });
616
616
  if (!ir && description.meta) ({description, ir} = yield* readDefinition(client, description, open));
617
617
  const described = yield* makeDefinitionClient(client, description, ir, options);
618
- const pinBackend = description.pins && !options?.resource ? open(base, { resource: "pins" }).pipe(Effect.map((resource) => resource.backend)) : void 0;
619
- const metaBackend = description.meta && !options?.resource ? open(base, { resource: "meta" }).pipe(Effect.map((resource) => resource.backend)) : void 0;
618
+ const systemBackend = description.system && !options?.resource ? open(base, {
619
+ resource: "system",
620
+ networks: options?.networks
621
+ }).pipe(Effect.map((resource) => resource.backend)) : void 0;
622
+ const metaBackend = description.meta && !options?.resource ? open(base, {
623
+ resource: "meta",
624
+ networks: options?.networks
625
+ }).pipe(Effect.map((resource) => resource.backend)) : void 0;
620
626
  client = described.client;
621
627
  const operations = yield* makeOntologyOperationsClient(client);
622
628
  const common = {
623
629
  description,
624
630
  definition: metaBackend && !options?.resource ? watchDefinition(described.definition, metaBackend) : described.definition,
625
631
  operations,
626
- pinBackend,
632
+ systemBackend,
627
633
  metaBackend,
628
634
  sourceId: description.sourceId,
629
635
  definitionHash: description.definitionHash,
630
636
  ir,
631
637
  context: description.context,
632
- backend: makeRpcBackend(client, description, operations)
638
+ backend: {
639
+ ...makeRpcBackend(client, description, operations),
640
+ ...options?.networks && { networks: options.networks }
641
+ }
633
642
  };
634
643
  if (description.replication === "committed") return {
635
644
  ...common,
package/lib/rpc.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"rpc.js","names":[],"sources":["../src/rpc.ts"],"sourcesContent":["import { BackendError, classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport {\n ClientLeaseSchema,\n ClientSessionSchema,\n ClientTokenSchema,\n} from \"@party-stack/ontology-backend/clients\";\nimport { DeliveryFrameCodec, DeliveryPositionSchema } from \"@party-stack/ontology-backend/delivery\";\nimport { OntologyDescriptionCodec, ontologyProtocolVersion } from \"@party-stack/ontology-backend/description\";\nimport { makeMetadataBackend, pull } from \"@party-stack/ontology-backend/meta\";\nimport {\n CompiledSubsetCodec,\n ClientStateCodec,\n ClientSubmissionCodec,\n ClientViewCodec,\n ObjectSelectionCodec,\n} from \"@party-stack/ontology-backend/protocol\";\nimport { objectSubset } from \"@party-stack/ontology-backend/subset\";\nimport { pinOntology } from \"@party-stack/ontology-replica\";\nimport metaOntology from \"@party-stack/ontology-spec/meta\";\nimport {\n ontologyDefinitionSignature,\n ontologyDefinitionContractHash,\n ontologyDefinitionHash,\n} from \"@party-stack/ontology-storage\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport {\n Cause,\n Context,\n Deferred,\n Effect,\n Exit,\n Layer,\n PubSub,\n Random,\n Schedule,\n Schema,\n Scope,\n Stream,\n SubscriptionRef,\n} from \"effect\";\nimport { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSchema } from \"effect/rpc\";\nimport { expectedBindingHeaders, expectedDefinitionHeader, withExpectedBinding } from \"./bindingFence.js\";\nimport {\n OntologyErrorProjection,\n errorProjectionLayer,\n projectStateFailures,\n projectActionFailure,\n type ErrorProjectionOptions,\n} from \"./errorProjection.js\";\nimport {\n OntologyOperationRpcs,\n ontologyOperationHandlers,\n makeOntologyOperationsClient,\n type OntologyOperationRequest,\n type OntologyOperationsClient,\n} from \"./operations.js\";\nimport { RpcActivity } from \"./rpcActivity.js\";\nimport { makeRpcBackend } from \"./rpcBackend.js\";\nimport type { AttachmentTransferPolicy } from \"./attachmentTransfers.js\";\nimport type { ObjectSelection } from \"@party-stack/ontology-backend\";\nimport type { ClientSession, ClientToken } from \"@party-stack/ontology-backend/clients\";\nimport type { DeliveryFrame } from \"@party-stack/ontology-backend/delivery\";\nimport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nimport type { ClientSubmission, ClientView, OntologySource } from \"@party-stack/ontology-backend/protocol\";\nimport type { CompiledSubset } from \"@party-stack/ontology-backend/subset\";\nimport type { ReplicaService } from \"@party-stack/ontology-replica\";\nimport type { TraceStore } from \"@party-stack/runtime/tracing\";\nimport type { Headers } from \"effect/http/Headers\";\n\nconst Counter = Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }));\nconst DeliveryStrategy = Schema.Literals([\"auto\", \"snapshot\", \"incremental\"]);\nconst Description = OntologyDescriptionCodec;\nconst ReplicaRpcs = RpcGroup.make(\n Rpc.make(\"Describe\", { success: Description, error: BackendError }),\n Rpc.make(\"SubscribeSelection\", {\n payload: { selection: ObjectSelectionCodec, resume: Schema.optional(DeliveryPositionSchema) },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"SubscribeState\", {\n payload: {\n session: ClientSessionSchema,\n view: ClientViewCodec,\n resume: Schema.optional(DeliveryPositionSchema),\n },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"UpdateView\", {\n payload: { session: ClientSessionSchema, view: ClientViewCodec },\n error: BackendError,\n }),\n Rpc.make(\"AckDelivery\", {\n payload: { kind: Schema.Literals([\"committed\", \"speculative\"]), position: DeliveryPositionSchema },\n error: BackendError,\n }),\n Rpc.make(\"Accept\", { payload: ClientSubmissionCodec, error: BackendError }),\n Rpc.make(\"OpenClient\", {\n payload: { resume: Schema.optional(ClientTokenSchema) },\n success: ClientLeaseSchema,\n error: BackendError,\n }),\n Rpc.make(\"Read\", {\n payload: { session: ClientSessionSchema, view: Schema.optional(ClientViewCodec) },\n success: ClientStateCodec,\n error: BackendError,\n }),\n Rpc.make(\"Submit\", { payload: ClientSubmissionCodec, success: ClientStateCodec, error: BackendError }),\n Rpc.make(\"Acknowledge\", {\n payload: {\n session: ClientSessionSchema,\n revision: Counter,\n through: Counter,\n viewGeneration: Schema.optional(Counter),\n },\n error: BackendError,\n }),\n Rpc.make(\"Demand\", {\n payload: CompiledSubsetCodec,\n success: Schema.Literal(\"ready\"),\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"Changes\", { success: Schema.Literal(\"invalidate\"), error: BackendError, stream: true })\n);\n\nexport const OntologyRpcs = ReplicaRpcs.merge(OntologyOperationRpcs).middleware(OntologyErrorProjection);\n\n// Client-only telemetry middleware: classification follows the RPC schema, not\n// method-name guesses or elapsed duration. The server wire contract is unchanged.\nclass SubscriptionTracing extends RpcMiddleware.Service<SubscriptionTracing>()(\n \"@party-stack/ontology-server/SubscriptionTracing\",\n { requiredForClient: true }\n) {}\nconst subscriptionTracingLayer = RpcMiddleware.layerClient(SubscriptionTracing, ({ rpc, request, next }) =>\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? Effect.annotateCurrentSpan(\"activity\", Context.get(rpc.annotations, RpcActivity)).pipe(\n Effect.andThen(next(request))\n )\n : next(request)\n);\nexport const makeTracedRpcClient = <Rpcs extends Rpc.Any>(group: RpcGroup.RpcGroup<Rpcs>) =>\n RpcClient.make(group.middleware(SubscriptionTracing)).pipe(Effect.provide(subscriptionTracingLayer));\n\n/** The in-process transport keeps the same subscription/transfer trace classification. */\nexport const makeTracedRpcClientNoSerialization = <Rpcs extends Rpc.Any, E>(\n group: RpcGroup.RpcGroup<Rpcs>,\n options: Parameters<\n typeof RpcClient.makeNoSerialization<Rpc.AddMiddleware<Rpcs, typeof SubscriptionTracing>, E>\n >[1]\n) =>\n RpcClient.makeNoSerialization(group.middleware(SubscriptionTracing), options).pipe(\n Effect.provide(subscriptionTracingLayer)\n );\n\nexport const makeOntologyRpcClient = makeTracedRpcClient(OntologyRpcs);\n\nexport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nexport interface OntologyClientOptions {\n /** Previously accepted, public source binding; never inferred from cached rows. */\n readonly description?: OntologyDescription;\n /** The definition `description` was accepted with. Required with `description`; otherwise\n * the client reads the definition from the server's `meta` resource. */\n readonly ir?: import(\"@party-stack/ontology-spec\").OntologyIR;\n /** Open one of the endpoint's system resources (the definition as meta ontology rows, or\n * downloads) instead of the ontology itself. */\n readonly resource?: OntologyResource;\n /** @internal The server's own definition, for a client in the same runtime: used instead of\n * reading a copy while it is the one described. */\n readonly localDefinition?: Effect.Effect<import(\"@party-stack/ontology-spec\").OntologyIR | undefined>;\n /** Validate/adopt definition compatibility after source/context/protocol checks. */\n readonly validate?: (fresh: OntologyDescription) => Effect.Effect<void, BackendError>;\n /** Notification only. Coordinate replacement outside this client scope. */\n readonly onIncompatible?: (error: BackendError) => Effect.Effect<void>;\n}\nexport interface OntologyClientDefinitionStatus {\n readonly status: \"retained\" | \"current\" | \"incompatible\";\n readonly refreshing: boolean;\n readonly error?: BackendError;\n}\nexport interface OntologyClientDefinition {\n readonly get: Effect.Effect<OntologyClientDefinitionStatus>;\n readonly changes: Stream.Stream<OntologyClientDefinitionStatus>;\n /** Explicit, coalesced metadata acquisition. Never required before ordinary operations. */\n readonly refresh: Effect.Effect<OntologyDescription, BackendError>;\n}\n/** A scoped client of an ontology server, separate from Connect's account connections. */\n/** One transport shared by independently scoped, ontology-bound handles. */\nexport interface OntologyServerClient {\n readonly ontology: (\n name?: string,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>;\n}\n\nexport interface OntologyClient {\n /** The accepted description used to construct this binding's fixed capabilities. */\n readonly description: OntologyDescription;\n readonly definition: OntologyClientDefinition;\n readonly sourceId: string;\n readonly definitionHash?: string;\n readonly ir?: import(\"@party-stack/ontology-spec\").OntologyIR;\n readonly context?: Record<string, unknown>;\n readonly operations: OntologyOperationsClient;\n /** Ordinary ontology operations over the selected replica's download inventory. */\n readonly pinBackend?: Effect.Effect<\n import(\"@party-stack/ontology-backend\").OntologyBackendService,\n BackendError,\n Scope.Scope\n >;\n /** The endpoint's current definition as meta ontology rows (`@party-stack/ontology-spec/meta`).\n * It follows the endpoint: after a definition change it serves the new one. */\n readonly metaBackend?: Effect.Effect<\n import(\"@party-stack/ontology-backend\").OntologyBackendService,\n BackendError,\n Scope.Scope\n >;\n /** Finite operations are available for all server roles. */\n readonly backend: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n readonly replication:\n | { readonly kind: \"committed\" }\n | { readonly kind: \"speculative\"; readonly source: OntologySource };\n}\n\nexport type OntologyRpcRequest =\n | OntologyOperationRequest\n | { readonly operation: \"Describe\" | \"Changes\" }\n | { readonly operation: \"OpenClient\"; readonly resume?: ClientToken }\n | { readonly operation: \"Read\"; readonly session: ClientSession; readonly view?: ClientView }\n | { readonly operation: \"Submit\" | \"Accept\"; readonly submission: ClientSubmission }\n | {\n readonly operation: \"SubscribeSelection\";\n readonly selection: ObjectSelection;\n }\n | { readonly operation: \"SubscribeState\"; readonly session: ClientSession; readonly view: ClientView }\n | { readonly operation: \"UpdateView\"; readonly session: ClientSession; readonly view: ClientView }\n | {\n readonly operation: \"AckDelivery\";\n readonly kind: \"committed\" | \"speculative\";\n readonly position: import(\"@party-stack/ontology-backend/delivery\").DeliveryPosition;\n }\n | {\n readonly operation: \"Acknowledge\";\n readonly session: ClientSession;\n readonly revision: number;\n readonly through: number;\n readonly viewGeneration?: number;\n }\n | { readonly operation: \"Demand\"; readonly subset: CompiledSubset };\n\n/** Bind to an authenticated source/principal partition. Authorization is mandatory:\n * granting domain row access alone does not authorize action parameters or base\n * state inspection. Restricted sources must also project their returned state.\n */\nexport interface OntologyRpcServerOptions<R = never> extends ErrorProjectionOptions {\n /** Already projected client context. Never use request payloads as trusted context. */\n readonly context?: Record<string, unknown>;\n readonly attachmentTransfers?: AttachmentTransferPolicy<R>;\n /** Opt into downstream watches, change reads and replication sessions. Finite\n * queries/actions and the backend's own upstream lifecycle remain available.\n */\n readonly enableRealtime?: boolean;\n /** Outgoing replication only. Snapshot uses invalidations and finite reads;\n * incremental requires native selected delivery. Auto preserves capability selection.\n */\n readonly deliveryStrategy?: Schema.Schema.Type<typeof DeliveryStrategy>;\n /** Server-controlled selected-delivery capacity, frame and acknowledgment bounds. */\n readonly delivery?: import(\"@party-stack/ontology-backend/delivery\").DeliveryPolicy;\n readonly source?: OntologySource;\n readonly replica?: ReplicaService;\n readonly traces?: TraceStore;\n readonly backend?: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n /** Worker bootstrap may run while transport starts accepting requests. */\n readonly ready?: Effect.Effect<void, BackendError, R>;\n /** Explicit local-partition administration; omitted helpers cannot delete data or stop an owner. */\n readonly deleteLocalData?: Effect.Effect<void, BackendError, R>;\n readonly releaseOwner?: Effect.Effect<void, BackendError, R>;\n readonly authorize: (\n request: OntologyRpcRequest,\n headers: Headers\n ) => Effect.Effect<void, BackendError, R>;\n}\n\n// This gate also rejects direct RPC calls: capability discovery is not enforcement.\nconst clientSyncOperations: ReadonlySet<OntologyRpcRequest[\"operation\"]> = new Set([\n \"WatchSubset\",\n \"WatchChanges\",\n \"PullChanges\",\n \"SubscribeSelection\",\n \"AckDelivery\",\n \"SubscribeState\",\n \"UpdateView\",\n \"OpenClient\",\n \"Read\",\n \"Submit\",\n \"Accept\",\n \"Acknowledge\",\n \"Demand\",\n \"Changes\",\n]);\n\nconst baseOntologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) => {\n const clientSync = options.enableRealtime === true;\n const bindingAuthorization = withExpectedBinding(options);\n const authorize = Effect.fnUntraced(function* (request: OntologyRpcRequest, headers: Headers) {\n yield* bindingAuthorization(request, headers);\n if (!clientSync && clientSyncOperations.has(request.operation))\n return yield* new BackendError({\n operation: request.operation,\n kind: \"NotImplemented\",\n message: \"Client synchronization is disabled on this endpoint.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n });\n });\n const snapshots = options.deliveryStrategy === \"snapshot\";\n // Snapshot readers must not silently switch to the committed journal path.\n // Its watch stream can still provide ordinary subset invalidation hints.\n const operationOptions = snapshots\n ? {\n ...options,\n get replica() {\n return options.replica;\n },\n get backend() {\n const backend = options.backend;\n if (!backend) return undefined;\n const watch = backend.changes?.watch;\n return {\n ...backend,\n changes: undefined,\n watchSubset: backend.watchSubset ?? (watch ? () => watch : undefined),\n };\n },\n }\n : options;\n const unavailableSource = () =>\n Effect.fail(\n new BackendError({\n operation: \"replication\",\n kind: \"NotImplemented\",\n message: \"This endpoint serves stateless operations only.\",\n retryable: false,\n })\n );\n const unavailableDelivery = () =>\n Effect.fail(\n new BackendError({\n operation: \"delivery\",\n kind: \"NotImplemented\",\n message: \"Selected incremental delivery is disabled or unavailable on this endpoint.\",\n retryable: false,\n })\n );\n const source: OntologySource = options.source ?? {\n sourceId: options.backend?.sourceId ?? \"stateless\",\n supportsIdempotency: options.backend?.supportsIdempotency ?? false,\n openClient: unavailableSource,\n read: unavailableSource,\n submit: unavailableSource,\n acknowledge: unavailableSource,\n demand: () => Stream.fromEffect(unavailableSource()),\n subscribeChanges: unavailableSource(),\n };\n return ReplicaRpcs.toLayer({\n Describe: (_, context) =>\n authorize({ operation: \"Describe\" }, context.headers).pipe(\n Effect.andThen(options.ready ?? Effect.void),\n Effect.andThen(\n Effect.gen(function* () {\n const strategy = yield* Schema.decodeUnknownEffect(DeliveryStrategy)(\n options.deliveryStrategy ?? \"auto\"\n ).pipe(\n Effect.mapError(\n () =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid delivery strategy.\",\n retryable: false,\n })\n )\n );\n const committedDelivery =\n clientSync &&\n Boolean(\n options.backend?.subscribeSelection && options.backend.acknowledgeDelivery\n );\n const speculativeDelivery =\n clientSync &&\n Boolean(source.subscribe && source.acknowledgeDelivery && source.accept);\n if (\n clientSync &&\n strategy === \"incremental\" &&\n !(options.source ? speculativeDelivery : committedDelivery)\n )\n return yield* new BackendError({\n operation: \"describe\",\n kind: \"NotImplemented\",\n message: \"This source does not support incremental selected delivery.\",\n retryable: false,\n });\n const signature = options.ir\n ? yield* Effect.try({\n try: () => ontologyDefinitionSignature(options.ir!),\n catch: (cause) =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid ontology definition.\",\n retryable: false,\n cause,\n }),\n })\n : undefined;\n // Cached per definition: Describe must not rehash a large IR per client.\n const definitionHash =\n options.ir && signature !== undefined\n ? yield* ontologyDefinitionHash(options.ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"describe\", cause))\n )\n : undefined;\n const contractHash =\n options.ir && signature !== undefined\n ? yield* ontologyDefinitionContractHash(options.ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"describe\", cause))\n )\n : undefined;\n return {\n version: ontologyProtocolVersion,\n replication:\n clientSync && options.source\n ? (\"speculative\" as const)\n : (\"committed\" as const),\n definitionHash,\n contractHash,\n sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? \"stateless\",\n context: options.context,\n supportsIdempotency:\n options.source?.supportsIdempotency ??\n options.backend?.supportsIdempotency ??\n false,\n delivery: !snapshots && committedDelivery,\n stateDelivery: Boolean(options.source) && !snapshots && speculativeDelivery,\n changes: clientSync && Boolean(operationOptions.backend?.changes),\n watchChanges: clientSync && Boolean(operationOptions.backend?.changes?.watch),\n watchSubset:\n clientSync &&\n Boolean(\n operationOptions.backend?.watchSubset ||\n options.ir?.objectTypes.some(\n (type) =>\n typeof operationOptions.backend?.refresh?.(\n objectSubset(type.name)\n )?.pollIntervalMs === \"number\"\n )\n ),\n actionParameterResolution: Boolean(\n options.backend?.resolveActionParameters || options.replica\n ),\n queries: Boolean(options.backend),\n pins: Boolean(options.replica),\n meta: Boolean(options.ir),\n attachments: options.backend\n ? options.backend.attachments && {\n stage: Boolean(options.backend.attachments.stage),\n }\n : options.replica\n ? { stage: true }\n : undefined,\n encrypted: Boolean(options.backend ? options.backend.encrypted : options.replica),\n };\n })\n )\n ),\n SubscribeSelection: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize(\n { operation: \"SubscribeSelection\", selection: request.selection },\n context.headers\n );\n if (snapshots || !options.backend?.subscribeSelection)\n return yield* unavailableDelivery();\n const delivery = yield* options.backend.subscribeSelection(\n request.selection,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.mapEffect((frame) =>\n Effect.gen(function* () {\n if (!frame.metadata) return frame;\n if (frame.metadata.sourceId !== options.backend!.sourceId)\n return yield* new BackendError({\n operation: \"delivery\",\n kind: \"SourceMismatch\",\n message: \"The committed delivery source changed.\",\n retryable: false,\n });\n // The endpoint binds one logical source/session lifetime. A replica\n // server's committed facet forwards upstream rows under that identity.\n return {\n ...frame,\n metadata: {\n ...frame.metadata,\n sourceId:\n options.source?.sourceId ??\n options.backend?.sourceId ??\n \"stateless\",\n },\n };\n })\n )\n );\n })\n ),\n SubscribeState: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize({ operation: \"SubscribeState\", ...request }, context.headers);\n if (snapshots || !source.subscribe) return yield* unavailableDelivery();\n const delivery = yield* source.subscribe(\n request.session,\n request.view,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.map((frame) => ({\n ...frame,\n changes: frame.changes.map((change) =>\n change.kind === \"put\" &&\n (change.record.kind === \"pending\" || change.record.kind === \"completed\")\n ? {\n ...change,\n record: {\n ...change.record,\n value: projectActionFailure(change.record.value, options),\n },\n }\n : change\n ),\n }))\n );\n })\n ),\n UpdateView: (request, context) =>\n authorize({ operation: \"UpdateView\", ...request }, context.headers).pipe(\n Effect.andThen(() => {\n if (snapshots || !source.subscribe) return unavailableDelivery();\n return source.updateView\n ? source.updateView(request.session, request.view)\n : Effect.fail(\n new BackendError({\n operation: \"UpdateView\",\n kind: \"ViewReplaced\",\n retryable: true,\n message: \"This source replaces views by subscribing again.\",\n })\n );\n })\n ),\n AckDelivery: (request, context) =>\n authorize({ operation: \"AckDelivery\", ...request }, context.headers).pipe(\n Effect.andThen(() => {\n if (snapshots) return unavailableDelivery();\n const ack =\n request.kind === \"committed\"\n ? options.backend?.acknowledgeDelivery\n : source.acknowledgeDelivery;\n return ack ? ack(request.position) : unavailableSource();\n })\n ),\n Accept: (request, context) =>\n authorize({ operation: \"Accept\", submission: request }, context.headers).pipe(\n Effect.andThen(() => (source.accept ? source.accept(request) : unavailableSource()))\n ),\n OpenClient: (request, context) =>\n authorize({ operation: \"OpenClient\", ...request }, context.headers).pipe(\n Effect.andThen(() => source.openClient(request.resume))\n ),\n Read: (request, context) =>\n authorize({ operation: \"Read\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.read(request.session, request.view).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Submit: (request, context) =>\n authorize({ operation: \"Submit\", submission: request }, context.headers).pipe(\n Effect.andThen(() =>\n source.submit(request).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Acknowledge: (request, context) =>\n authorize({ operation: \"Acknowledge\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.acknowledge(\n request.session,\n request.revision,\n request.through,\n request.viewGeneration\n )\n )\n ),\n Demand: (subset, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Demand\", subset }, context.headers);\n return source.demand(subset).pipe(Stream.as(\"ready\" as const));\n })\n ),\n Changes: (_, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Changes\" }, context.headers);\n const changes = options.source ? yield* source.subscribeChanges : undefined;\n if (!changes) return yield* unavailableSource();\n // A new stream is a repair boundary, not proof that no updates were missed.\n return Stream.concat(\n Stream.make(\"invalidate\" as const),\n Stream.map(changes, () => \"invalidate\" as const)\n );\n })\n ),\n }).pipe(\n Layer.merge(ontologyOperationHandlers(operationOptions, authorize)),\n Layer.merge(errorProjectionLayer(options))\n );\n};\n\nconst resourceHeader = \"x-party-stack-resource\";\n\n/** Administrative resources use the same ontology RPCs and transport. Access is\n * still gated by the parent endpoint before the resource is acquired. */\nexport const ontologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const scope = yield* Effect.scope;\n const ordinary = yield* Layer.buildWithScope(baseOntologyRpcHandlers(options), scope);\n const pins = yield* Effect.cached(\n Effect.gen(function* () {\n if (!options.replica)\n return yield* new BackendError({\n operation: \"pins\",\n kind: \"NotImplemented\",\n retryable: false,\n message: \"This endpoint does not own downloads.\",\n });\n const backend = yield* options.replica.demand.pins.backend;\n return yield* Layer.buildWithScope(\n baseOntologyRpcHandlers({\n backend,\n ir: pinOntology,\n context: options.context,\n enableRealtime: options.enableRealtime,\n errors: options.errors,\n authorize: (_, headers) => options.authorize({ operation: \"Pins\" }, headers),\n }),\n scope\n );\n })\n );\n // The definition this endpoint serves, as meta ontology rows. Reading it needs the\n // same access as Describe.\n const describeAccess = (headers: Headers) =>\n options.authorize({ operation: \"Describe\" }, headers);\n const meta = yield* Effect.cached(\n Effect.gen(function* () {\n if (!options.ir)\n return yield* new BackendError({\n operation: \"meta\",\n kind: \"NotImplemented\",\n retryable: false,\n message: \"This endpoint has no definition to describe.\",\n });\n // A replica that reopens under another definition replaces this endpoint's;\n // watches on it report that, so clients read the definition again.\n const replica = options.replica;\n const boundTo = replica?.ir;\n return yield* Layer.buildWithScope(\n baseOntologyRpcHandlers({\n backend: makeMetadataBackend(options.ir, {\n ...(replica && {\n replaced: replica.definition.changes.pipe(\n Stream.filter((ir) => ir !== boundTo),\n Stream.take(1)\n ),\n }),\n }),\n ir: metaOntology,\n enableRealtime: options.enableRealtime,\n errors: options.errors,\n authorize: (_, headers) => describeAccess(headers),\n }),\n scope\n );\n })\n );\n type Rpcs = RpcGroup.Rpcs<typeof OntologyRpcs>;\n type Handler = RpcGroup.HandlersFrom<Rpcs>[Rpcs[\"_tag\"]];\n const handlers = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => {\n const invoke = (payload: never, request: Parameters<Handler>[1]) =>\n Effect.gen(function* () {\n const resource = request.headers[resourceHeader];\n if (resource !== undefined && resource !== \"pins\" && resource !== \"meta\")\n return yield* new BackendError({\n operation: \"ontology.resource\",\n kind: \"NotFound\",\n retryable: false,\n message: \"Unknown ontology resource.\",\n });\n if (resource === \"pins\")\n yield* options.authorize({ operation: \"Pins\" }, request.headers);\n const context =\n resource === \"pins\"\n ? yield* pins\n : resource === \"meta\"\n ? yield* meta\n : ordinary;\n const handler = yield* OntologyRpcs.accessHandler(tag as Rpcs[\"_tag\"]).pipe(\n Effect.provideContext(context)\n );\n return handler(payload, request);\n });\n return [\n tag,\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? (payload: never, request: Parameters<Handler>[1]) =>\n Stream.unwrap(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Stream.Stream<unknown, BackendError, R>\n )\n )\n )\n : (payload: never, request: Parameters<Handler>[1]) =>\n Effect.flatten(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Effect.Effect<unknown, BackendError, R>\n )\n )\n ),\n ];\n })\n ) as unknown as {\n readonly [Procedure in Rpcs as Procedure[\"_tag\"]]: Rpc.ToHandlerFn<\n Procedure,\n R | Scope.Scope\n >;\n };\n return Layer.merge(OntologyRpcs.toLayer(handlers), errorProjectionLayer(options));\n })\n );\n\nexport type OntologyResource = \"pins\" | \"meta\";\nconst resourceDefinitions = { pins: pinOntology, meta: metaOntology } as const;\nconst selectResource = (client: OntologyRpcClient, resource: OntologyResource): OntologyRpcClient =>\n Object.fromEntries(\n [...OntologyRpcs.requests.keys()].map((tag) => [\n tag,\n (payload: unknown, settings?: { readonly headers?: Record<string, string> }) =>\n Reflect.apply(Reflect.get(client, tag), client, [\n payload,\n { ...settings, headers: { ...settings?.headers, [resourceHeader]: resource } },\n ]),\n ])\n ) as OntologyRpcClient;\n\nexport type OntologyRpcClient = Effect.Success<\n ReturnType<typeof RpcClient.make<RpcGroup.Rpcs<typeof OntologyRpcs>>>\n>;\nconst unavailable = (cause: unknown) => classifyBackendFailure(\"remote.protocol\", cause);\n/** A fresh description must speak this client's protocol: an older server describes its\n * definition differently and has no `meta` resource. */\nconst requireProtocol = (description: OntologyDescription) =>\n description.version === ontologyProtocolVersion\n ? Effect.succeed(description)\n : Effect.fail(\n new BackendError({\n operation: \"remote.describe\",\n kind: \"NotImplemented\",\n retryable: false,\n message: `The server speaks ontology protocol version ${description.version}; this client needs version ${ontologyProtocolVersion}.`,\n })\n );\nconst copyDescription = (description: OntologyDescription) =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(Description)(Schema.encodeSync(Description)(description)),\n catch: (cause) =>\n new BackendError({\n operation: \"remote.describe\",\n kind: \"InvalidResponse\",\n retryable: false,\n message: \"Invalid ontology description.\",\n cause,\n }),\n });\n\nconst descriptionValue = Table.make<unknown>({ name: \"ontology-description-identity\" });\nconst sameDescriptionValue = (left: unknown, right: unknown) =>\n descriptionValue.encode(left) === descriptionValue.encode(right);\nconst protocolIdentity = (description: OntologyDescription) => ({\n version: description.version,\n replication: description.replication,\n supportsIdempotency: description.supportsIdempotency,\n delivery: Boolean(description.delivery),\n stateDelivery: Boolean(description.stateDelivery),\n changes: Boolean(description.changes),\n watchChanges: Boolean(description.watchChanges),\n watchSubset: Boolean(description.watchSubset),\n actionParameterResolution: Boolean(description.actionParameterResolution),\n queries: Boolean(description.queries),\n pins: Boolean(description.pins),\n meta: Boolean(description.meta),\n attachments: Boolean(description.attachments),\n stageAttachments: Boolean(description.attachments?.stage),\n encrypted: Boolean(description.encrypted),\n});\nconst checkBootstrapBinding = (accepted: OntologyDescription, fresh: OntologyDescription) =>\n Effect.gen(function* () {\n if (fresh.sourceId !== accepted.sourceId)\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology source changed.\",\n });\n if (!sameDescriptionValue(fresh.context ?? {}, accepted.context ?? {}))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology context changed.\",\n });\n if (!sameDescriptionValue(protocolIdentity(fresh), protocolIdentity(accepted)))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology protocol capabilities changed.\",\n });\n });\n\nconst definitionFailure: unique symbol = Symbol(\"OntologyClient.definitionFailure\");\ninterface InternalDefinition extends OntologyClientDefinition {\n readonly [definitionFailure]: (error: BackendError) => Effect.Effect<void>;\n}\n/** HTTP byte operations use the same incompatibility notification as typed RPC. */\nexport const observeOntologyClientFailure = <A, R>(\n client: OntologyClient,\n work: Effect.Effect<A, BackendError, R>\n) =>\n work.pipe(\n Effect.tapError(\n (error) =>\n (client.definition as Partial<InternalDefinition>)[definitionFailure]?.(error) ?? Effect.void\n )\n );\n\ntype AcceptDescription = (\n description: OntologyDescription\n) => Effect.Effect<OntologyDescription, BackendError>;\n\nconst makeDefinitionClient = Effect.fnUntraced(function* (\n raw: OntologyRpcClient,\n description: OntologyDescription,\n ir: import(\"@party-stack/ontology-spec\").OntologyIR | undefined,\n options: OntologyClientOptions | undefined\n) {\n const scope = yield* Effect.scope;\n const state = yield* SubscriptionRef.make<OntologyClientDefinitionStatus>({\n status: options?.description ? \"retained\" : \"current\",\n refreshing: false,\n });\n yield* Effect.addFinalizer(() => PubSub.shutdown(state.pubsub));\n let attempt: Deferred.Deferred<OntologyDescription, BackendError> | undefined;\n const incompatible = (error: BackendError) =>\n error.kind === \"SchemaMismatch\" || error.kind === \"SourceMismatch\";\n const notify = (error: BackendError) => options?.onIncompatible?.(error) ?? Effect.void;\n const failed = Effect.fnUntraced(function* (error: BackendError) {\n const previous = yield* SubscriptionRef.get(state);\n yield* SubscriptionRef.set(state, {\n ...previous,\n status: incompatible(error) ? \"incompatible\" : previous.status,\n refreshing: false,\n error: previous.status === \"incompatible\" && !incompatible(error) ? previous.error : error,\n });\n if (\n incompatible(error) &&\n (previous.status !== \"incompatible\" || previous.error?.kind !== error.kind)\n )\n yield* notify(error).pipe(\n Effect.catchCause((cause) =>\n Effect.logError(\"Ontology incompatibility callback failed\", cause)\n ),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n // The contract this client accepted: of its definition, or as described.\n const schemaHash = ir\n ? yield* ontologyDefinitionContractHash(ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"remote.definition\", cause))\n )\n : description.contractHash;\n const validate =\n options?.validate ??\n ((fresh: OntologyDescription) =>\n fresh.contractHash === schemaHash\n ? Effect.void\n : Effect.fail(\n new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology definition changed.\",\n })\n ));\n const refresh = Effect.uninterruptibleMask((restore) =>\n Effect.suspend(() => {\n if (attempt) return restore(Deferred.await(attempt));\n const pending = Deferred.makeUnsafe<OntologyDescription, BackendError>();\n attempt = pending;\n const check = SubscriptionRef.update(state, (current) => ({ ...current, refreshing: true })).pipe(\n Effect.andThen(\n raw.Describe().pipe(Effect.mapError(unavailable), Effect.flatMap(requireProtocol))\n ),\n Effect.tap((fresh) => checkBootstrapBinding(description, fresh)),\n Effect.tap(validate),\n Effect.tap(() => SubscriptionRef.set(state, { status: \"current\", refreshing: false })),\n Effect.onExit((exit) =>\n Effect.gen(function* () {\n if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {\n const error = Cause.findErrorOption(exit.cause);\n yield* failed(\n error._tag === \"Some\" ? error.value : unavailable(Cause.squash(exit.cause))\n );\n }\n if (attempt === pending) attempt = undefined;\n yield* Deferred.done(pending, exit);\n })\n ),\n Effect.catchCause(() => Effect.void)\n );\n return Effect.forkIn(check, scope, { startImmediately: true }).pipe(\n Effect.andThen(restore(Deferred.await(pending)))\n );\n })\n );\n const report = Effect.fnUntraced(function* (error: BackendError) {\n if (!incompatible(error)) return;\n yield* failed(error);\n // Rebinding a source/account needs an explicit acquisition. A metadata\n // refresh must not turn that failure into permission to reset its cache.\n if (error.kind === \"SourceMismatch\") return;\n yield* refresh.pipe(\n Effect.catchCause(() => Effect.void),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n // Delivery metadata already carries the contract hash. Check it at the\n // client boundary too, so a receiver's schema failure reaches definition\n // lifecycle handling even when the transport successfully delivered a frame.\n // Requests carry it too, so a server whose definition changed rejects them with\n // SchemaMismatch instead of serving them under a contract the client does not know.\n const headers = {\n ...expectedBindingHeaders(description),\n ...(schemaHash !== undefined ? { [expectedDefinitionHeader]: schemaHash } : {}),\n };\n const checkFrame = Effect.fnUntraced(function* (frame: DeliveryFrame) {\n if (frame.metadata) {\n if (frame.metadata.sourceId !== description.sourceId)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The delivered ontology source changed.\",\n });\n if (schemaHash !== undefined && frame.metadata.schemaHash !== schemaHash)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The delivered ontology definition changed.\",\n });\n }\n return frame;\n });\n const client = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => [\n tag,\n (payload: unknown, options?: { readonly headers?: Record<string, string> }) => {\n const invoke = () =>\n Reflect.apply(Reflect.get(raw, tag), raw, [\n payload,\n tag === \"Describe\"\n ? options\n : { ...options, headers: { ...options?.headers, ...headers } },\n ]);\n if (RpcSchema.isStreamSchema(rpc.successSchema)) {\n const stream =\n tag === \"SubscribeSelection\" || tag === \"SubscribeState\"\n ? (invoke() as Stream.Stream<DeliveryFrame, BackendError>).pipe(\n Stream.mapEffect(checkFrame)\n )\n : (invoke() as Stream.Stream<unknown, BackendError>);\n return stream.pipe(Stream.tapError(report));\n }\n return (invoke() as Effect.Effect<unknown, BackendError>).pipe(Effect.tapError(report));\n },\n ])\n ) as unknown as OntologyRpcClient;\n const definition: InternalDefinition = {\n get: SubscriptionRef.get(state),\n changes: SubscriptionRef.changes(state),\n refresh,\n [definitionFailure]: report,\n };\n return {\n client,\n definition,\n };\n});\n\n/**\n * Read the definition an endpoint describes from its `meta` resource. The rows are read in one\n * request, but the endpoint may change definition between `Describe` and the read: the result\n * must hash to the described definition, or the endpoint is described again.\n */\nconst readDefinition = Effect.fnUntraced(function* (\n client: OntologyRpcClient,\n described: OntologyDescription,\n open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>\n) {\n let description = described;\n for (let attempt = 0; attempt < 3; attempt++) {\n const ir = yield* Effect.scoped(\n Effect.flatMap(open(client, { resource: \"meta\" }), (meta) => pull(meta.backend))\n );\n const hash = yield* ontologyDefinitionHash(ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"remote.definition\", cause))\n );\n if (hash === description.definitionHash) return { description, ir };\n description = yield* client\n .Describe()\n .pipe(Effect.mapError(unavailable), Effect.flatMap(requireProtocol));\n }\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"The ontology definition changed while it was being read.\",\n });\n});\n\n/**\n * While someone follows the definition status, notice a new definition without waiting for a\n * request to fail: watch the endpoint's metadata. Without realtime the endpoint offers no watch,\n * and the next request after a change reports it instead.\n */\nconst watchDefinition = (\n definition: InternalDefinition,\n metaBackend: NonNullable<OntologyClient[\"metaBackend\"]>\n): InternalDefinition => {\n // Every client watching a route sees its change at once; spread their checks (a Describe and\n // a definition read each) over a couple of seconds.\n const check = Effect.andThen(\n Effect.flatMap(Random.nextIntBetween(0, 2_000), (delay) => Effect.sleep(delay)),\n Effect.ignore(definition.refresh)\n );\n const signals = Stream.unwrap(\n Effect.gen(function* () {\n const backend = yield* metaBackend;\n const events = backend.watchSubset?.(objectSubset(\"Ontology\"));\n // The watch reports changes after it is acquired; check once for any before.\n return events ? Stream.concat(Stream.make(undefined), yield* events) : Stream.empty;\n })\n ).pipe(\n // A dropped connection is watched again; a mismatch is already in the status.\n Stream.retry(($) =>\n $(Schedule.spaced(\"5 seconds\")).pipe(\n Schedule.jittered,\n Schedule.while(({ input }) => input.retryable)\n )\n )\n );\n const watch = signals.pipe(\n Stream.mapEffect(() => check),\n Stream.catchCause(() => Stream.empty),\n Stream.drain\n );\n return { ...definition, changes: Stream.merge(definition.changes, watch, { haltStrategy: \"left\" }) };\n};\n\nconst makeProtocolClient = (accept: AcceptDescription) => {\n const open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope> = Effect.fn(\"RemoteOntology.protocol\")(\n function* (client: OntologyRpcClient, options?: OntologyClientOptions) {\n return yield* openProtocolClient(client, options, accept, open);\n }\n );\n return open;\n};\n/** Use the same source contract with Effect RPC's worker, HTTP or socket transport. */\nexport const makeOntologyProtocolClient = makeProtocolClient(copyDescription);\n/** Same-runtime transports without serialization receive the server's own,\n * already validated description. Skip the defensive wire copy: re-encoding and\n * decoding a large definition dominates startup on mobile JavaScript engines,\n * and sharing the definition object lets per-definition signature caches apply.\n */\nexport const makeTrustedOntologyProtocolClient = makeProtocolClient(Effect.succeed);\n\nconst openProtocolClient = Effect.fnUntraced(function* (\n client: OntologyRpcClient,\n options: OntologyClientOptions | undefined,\n accept: AcceptDescription,\n open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>\n): Effect.fn.Return<OntologyClient, BackendError, Scope.Scope> {\n const base = client;\n if (options?.resource) client = selectResource(client, options.resource);\n // Serialized RPC clients already decoded Describe with its success schema, and\n // a same-runtime client receives the server's validated value: neither needs a\n // second encode/decode copy. Only a caller-retained description is copied.\n let description = yield* options?.description\n ? accept(options.description)\n : client.Describe().pipe(Effect.mapError(unavailable), Effect.flatMap(requireProtocol));\n let ir = options?.ir ?? (options?.resource ? resourceDefinitions[options.resource] : undefined);\n // A client in the server's own runtime uses the server's definition object while it is still\n // the one described, instead of reading a copy.\n if (!ir && options?.localDefinition && description.definitionHash !== undefined) {\n const local = yield* options.localDefinition;\n const hash = local && (yield* Effect.orElseSucceed(ontologyDefinitionHash(local), () => undefined));\n if (hash === description.definitionHash) ir = local;\n }\n if (options?.description && !ir)\n return yield* new BackendError({\n operation: \"remote.bootstrap\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A retained ontology description needs the definition it was accepted with.\",\n });\n if (!ir && description.meta) ({ description, ir } = yield* readDefinition(client, description, open));\n const described = yield* makeDefinitionClient(client, description, ir, options);\n const pinBackend =\n description.pins && !options?.resource\n ? open(base, { resource: \"pins\" }).pipe(Effect.map((resource) => resource.backend))\n : undefined;\n const metaBackend =\n description.meta && !options?.resource\n ? open(base, { resource: \"meta\" }).pipe(Effect.map((resource) => resource.backend))\n : undefined;\n client = described.client;\n const operations = yield* makeOntologyOperationsClient(client);\n const common = {\n description,\n definition:\n metaBackend && !options?.resource\n ? watchDefinition(described.definition, metaBackend)\n : described.definition,\n operations,\n pinBackend,\n metaBackend,\n sourceId: description.sourceId,\n definitionHash: description.definitionHash,\n ir,\n context: description.context,\n backend: makeRpcBackend(client, description, operations),\n };\n if (description.replication === \"committed\") return { ...common, replication: { kind: \"committed\" } };\n const source: OntologySource = {\n sourceId: description.sourceId,\n outbox: operations.outbox,\n supportsIdempotency: description.supportsIdempotency,\n openClient: (resume) => client.OpenClient({ resume }).pipe(Effect.mapError(unavailable)),\n read: (session, view) => client.Read({ session, view }).pipe(Effect.mapError(unavailable)),\n submit: (request) => client.Submit(request).pipe(Effect.mapError(unavailable)),\n accept: description.stateDelivery\n ? (request) => client.Accept(request).pipe(Effect.mapError(unavailable))\n : undefined,\n subscribe: description.stateDelivery\n ? (session, view, _policy, resume) =>\n Effect.succeed({\n frames: client\n .SubscribeState({ session, view, resume })\n .pipe(Stream.mapError(unavailable)),\n acknowledge: (position) =>\n client\n .AckDelivery({ kind: \"speculative\", position })\n .pipe(Effect.mapError(unavailable)),\n })\n : undefined,\n acknowledgeDelivery: description.stateDelivery\n ? (position) =>\n client.AckDelivery({ kind: \"speculative\", position }).pipe(Effect.mapError(unavailable))\n : undefined,\n updateView: description.stateDelivery\n ? (session, view) => client.UpdateView({ session, view }).pipe(Effect.mapError(unavailable))\n : undefined,\n acknowledge: (session, revision, through, viewGeneration) =>\n client\n .Acknowledge({ session, revision, through, viewGeneration })\n .pipe(Effect.mapError(unavailable)),\n subscribeChanges: Effect.succeed(\n client.Changes().pipe(\n Stream.map(() => undefined),\n Stream.mapError(unavailable)\n )\n ),\n demand: (subset) => client.Demand(subset).pipe(Stream.as(undefined), Stream.mapError(unavailable)),\n };\n return { ...common, replication: { kind: \"speculative\", source } };\n});\n\nexport { errorProjectionLayer } from \"./errorProjection.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqEA,MAAM,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS,OAAO;AAAiB,CAAC,CAAC;AACnG,MAAM,mBAAmB,OAAO,SAAS;CAAC;CAAQ;CAAY;AAAa,CAAC;AAC5E,MAAM,cAAc;AACpB,MAAM,cAAc,SAAS,KACzB,IAAI,KAAK,YAAY;CAAE,SAAS;CAAa,OAAO;AAAa,CAAC,GAClE,IAAI,KAAK,sBAAsB;CAC3B,SAAS;EAAE,WAAW;EAAsB,QAAQ,OAAO,SAAS,sBAAsB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","names":[],"sources":["../src/rpc.ts"],"sourcesContent":["import { BackendError, classifyBackendFailure } from \"@party-stack/ontology-backend\";\nimport {\n ClientLeaseSchema,\n ClientSessionSchema,\n ClientTokenSchema,\n} from \"@party-stack/ontology-backend/clients\";\nimport { DeliveryFrameCodec, DeliveryPositionSchema } from \"@party-stack/ontology-backend/delivery\";\nimport { OntologyDescriptionCodec, ontologyProtocolVersion } from \"@party-stack/ontology-backend/description\";\nimport { makeMetadataBackend, pull } from \"@party-stack/ontology-backend/meta\";\nimport {\n CompiledSubsetCodec,\n ClientStateCodec,\n ClientSubmissionCodec,\n ClientViewCodec,\n ObjectSelectionCodec,\n} from \"@party-stack/ontology-backend/protocol\";\nimport { objectSubset } from \"@party-stack/ontology-backend/subset\";\nimport { systemOntology } from \"@party-stack/ontology-replica\";\nimport metaOntology from \"@party-stack/ontology-spec/meta\";\nimport {\n ontologyDefinitionSignature,\n ontologyDefinitionContractHash,\n ontologyDefinitionHash,\n} from \"@party-stack/ontology-storage\";\nimport { Table } from \"@party-stack/ontology-storage/tables\";\nimport {\n Cause,\n Context,\n Deferred,\n Effect,\n Exit,\n Layer,\n PubSub,\n Random,\n Schedule,\n Schema,\n Scope,\n Stream,\n SubscriptionRef,\n} from \"effect\";\nimport { Rpc, RpcClient, RpcGroup, RpcMiddleware, RpcSchema } from \"effect/rpc\";\nimport { expectedBindingHeaders, expectedDefinitionHeader, withExpectedBinding } from \"./bindingFence.js\";\nimport {\n OntologyErrorProjection,\n errorProjectionLayer,\n projectStateFailures,\n projectActionFailure,\n type ErrorProjectionOptions,\n} from \"./errorProjection.js\";\nimport {\n OntologyOperationRpcs,\n ontologyOperationHandlers,\n makeOntologyOperationsClient,\n type OntologyOperationRequest,\n type OntologyOperationsClient,\n} from \"./operations.js\";\nimport { RpcActivity } from \"./rpcActivity.js\";\nimport { makeRpcBackend } from \"./rpcBackend.js\";\nimport type { AttachmentTransferPolicy } from \"./attachmentTransfers.js\";\nimport type { ObjectSelection } from \"@party-stack/ontology-backend\";\nimport type { ClientSession, ClientToken } from \"@party-stack/ontology-backend/clients\";\nimport type { DeliveryFrame } from \"@party-stack/ontology-backend/delivery\";\nimport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nimport type { ClientSubmission, ClientView, OntologySource } from \"@party-stack/ontology-backend/protocol\";\nimport type { CompiledSubset } from \"@party-stack/ontology-backend/subset\";\nimport type { ReplicaService } from \"@party-stack/ontology-replica\";\nimport type { TraceStore } from \"@party-stack/runtime/tracing\";\nimport type { Headers } from \"effect/http/Headers\";\n\nconst Counter = Schema.Int.check(Schema.isBetween({ minimum: 0, maximum: Number.MAX_SAFE_INTEGER }));\nconst DeliveryStrategy = Schema.Literals([\"auto\", \"snapshot\", \"incremental\"]);\nconst Description = OntologyDescriptionCodec;\nconst ReplicaRpcs = RpcGroup.make(\n Rpc.make(\"Describe\", { success: Description, error: BackendError }),\n Rpc.make(\"SubscribeSelection\", {\n payload: { selection: ObjectSelectionCodec, resume: Schema.optional(DeliveryPositionSchema) },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"SubscribeState\", {\n payload: {\n session: ClientSessionSchema,\n view: ClientViewCodec,\n resume: Schema.optional(DeliveryPositionSchema),\n },\n success: DeliveryFrameCodec,\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"UpdateView\", {\n payload: { session: ClientSessionSchema, view: ClientViewCodec },\n error: BackendError,\n }),\n Rpc.make(\"AckDelivery\", {\n payload: { kind: Schema.Literals([\"committed\", \"speculative\"]), position: DeliveryPositionSchema },\n error: BackendError,\n }),\n Rpc.make(\"Accept\", { payload: ClientSubmissionCodec, error: BackendError }),\n Rpc.make(\"OpenClient\", {\n payload: { resume: Schema.optional(ClientTokenSchema) },\n success: ClientLeaseSchema,\n error: BackendError,\n }),\n Rpc.make(\"Read\", {\n payload: { session: ClientSessionSchema, view: Schema.optional(ClientViewCodec) },\n success: ClientStateCodec,\n error: BackendError,\n }),\n Rpc.make(\"Submit\", { payload: ClientSubmissionCodec, success: ClientStateCodec, error: BackendError }),\n Rpc.make(\"Acknowledge\", {\n payload: {\n session: ClientSessionSchema,\n revision: Counter,\n through: Counter,\n viewGeneration: Schema.optional(Counter),\n },\n error: BackendError,\n }),\n Rpc.make(\"Demand\", {\n payload: CompiledSubsetCodec,\n success: Schema.Literal(\"ready\"),\n error: BackendError,\n stream: true,\n }),\n Rpc.make(\"Changes\", { success: Schema.Literal(\"invalidate\"), error: BackendError, stream: true })\n);\n\nexport const OntologyRpcs = ReplicaRpcs.merge(OntologyOperationRpcs).middleware(OntologyErrorProjection);\n\n// Client-only telemetry middleware: classification follows the RPC schema, not\n// method-name guesses or elapsed duration. The server wire contract is unchanged.\nclass SubscriptionTracing extends RpcMiddleware.Service<SubscriptionTracing>()(\n \"@party-stack/ontology-server/SubscriptionTracing\",\n { requiredForClient: true }\n) {}\nconst subscriptionTracingLayer = RpcMiddleware.layerClient(SubscriptionTracing, ({ rpc, request, next }) =>\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? Effect.annotateCurrentSpan(\"activity\", Context.get(rpc.annotations, RpcActivity)).pipe(\n Effect.andThen(next(request))\n )\n : next(request)\n);\nexport const makeTracedRpcClient = <Rpcs extends Rpc.Any>(group: RpcGroup.RpcGroup<Rpcs>) =>\n RpcClient.make(group.middleware(SubscriptionTracing)).pipe(Effect.provide(subscriptionTracingLayer));\n\n/** The in-process transport keeps the same subscription/transfer trace classification. */\nexport const makeTracedRpcClientNoSerialization = <Rpcs extends Rpc.Any, E>(\n group: RpcGroup.RpcGroup<Rpcs>,\n options: Parameters<\n typeof RpcClient.makeNoSerialization<Rpc.AddMiddleware<Rpcs, typeof SubscriptionTracing>, E>\n >[1]\n) =>\n RpcClient.makeNoSerialization(group.middleware(SubscriptionTracing), options).pipe(\n Effect.provide(subscriptionTracingLayer)\n );\n\nexport const makeOntologyRpcClient = makeTracedRpcClient(OntologyRpcs);\n\nexport type { OntologyDescription } from \"@party-stack/ontology-backend/description\";\nexport interface OntologyClientOptions {\n /** @internal The networks the transport reaches the server on, for the client's backends\n * (`OntologyBackendService.networks`). A transport on the same device is on none. */\n readonly networks?: readonly string[];\n /** Previously accepted, public source binding; never inferred from cached rows. */\n readonly description?: OntologyDescription;\n /** The definition `description` was accepted with. Required with `description`; otherwise\n * the client reads the definition from the server's `meta` resource. */\n readonly ir?: import(\"@party-stack/ontology-spec\").OntologyIR;\n /** Open one of the endpoint's system resources (the definition as meta ontology rows, or\n * downloads) instead of the ontology itself. */\n readonly resource?: OntologyResource;\n /** @internal The server's own definition, for a client in the same runtime: used instead of\n * reading a copy while it is the one described. */\n readonly localDefinition?: Effect.Effect<import(\"@party-stack/ontology-spec\").OntologyIR | undefined>;\n /** Validate/adopt definition compatibility after source/context/protocol checks. */\n readonly validate?: (fresh: OntologyDescription) => Effect.Effect<void, BackendError>;\n /** Notification only. Coordinate replacement outside this client scope. */\n readonly onIncompatible?: (error: BackendError) => Effect.Effect<void>;\n}\nexport interface OntologyClientDefinitionStatus {\n readonly status: \"retained\" | \"current\" | \"incompatible\";\n readonly refreshing: boolean;\n readonly error?: BackendError;\n}\nexport interface OntologyClientDefinition {\n readonly get: Effect.Effect<OntologyClientDefinitionStatus>;\n readonly changes: Stream.Stream<OntologyClientDefinitionStatus>;\n /** Explicit, coalesced metadata acquisition. Never required before ordinary operations. */\n readonly refresh: Effect.Effect<OntologyDescription, BackendError>;\n}\n/** A scoped client of an ontology server, separate from Connect's account connections. */\n/** One transport shared by independently scoped, ontology-bound handles. */\nexport interface OntologyServerClient {\n readonly ontology: (\n name?: string,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>;\n}\n\nexport interface OntologyClient {\n /** The accepted description used to construct this binding's fixed capabilities. */\n readonly description: OntologyDescription;\n readonly definition: OntologyClientDefinition;\n readonly sourceId: string;\n readonly definitionHash?: string;\n readonly ir?: import(\"@party-stack/ontology-spec\").OntologyIR;\n readonly context?: Record<string, unknown>;\n readonly operations: OntologyOperationsClient;\n /** Ordinary ontology operations over the endpoint's system ontology: its downloads and replica status. */\n readonly systemBackend?: Effect.Effect<\n import(\"@party-stack/ontology-backend\").OntologyBackendService,\n BackendError,\n Scope.Scope\n >;\n /** The endpoint's current definition as meta ontology rows (`@party-stack/ontology-spec/meta`).\n * It follows the endpoint: after a definition change it serves the new one. */\n readonly metaBackend?: Effect.Effect<\n import(\"@party-stack/ontology-backend\").OntologyBackendService,\n BackendError,\n Scope.Scope\n >;\n /** Finite operations are available for all server roles. */\n readonly backend: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n readonly replication:\n | { readonly kind: \"committed\" }\n | { readonly kind: \"speculative\"; readonly source: OntologySource };\n}\n\nexport type OntologyRpcRequest =\n | OntologyOperationRequest\n | { readonly operation: \"Describe\" | \"Changes\" }\n | { readonly operation: \"OpenClient\"; readonly resume?: ClientToken }\n | { readonly operation: \"Read\"; readonly session: ClientSession; readonly view?: ClientView }\n | { readonly operation: \"Submit\" | \"Accept\"; readonly submission: ClientSubmission }\n | {\n readonly operation: \"SubscribeSelection\";\n readonly selection: ObjectSelection;\n }\n | { readonly operation: \"SubscribeState\"; readonly session: ClientSession; readonly view: ClientView }\n | { readonly operation: \"UpdateView\"; readonly session: ClientSession; readonly view: ClientView }\n | {\n readonly operation: \"AckDelivery\";\n readonly kind: \"committed\" | \"speculative\";\n readonly position: import(\"@party-stack/ontology-backend/delivery\").DeliveryPosition;\n }\n | {\n readonly operation: \"Acknowledge\";\n readonly session: ClientSession;\n readonly revision: number;\n readonly through: number;\n readonly viewGeneration?: number;\n }\n | { readonly operation: \"Demand\"; readonly subset: CompiledSubset };\n\n/** Bind to an authenticated source/principal partition. Authorization is mandatory:\n * granting domain row access alone does not authorize action parameters or base\n * state inspection. Restricted sources must also project their returned state.\n */\nexport interface OntologyRpcServerOptions<R = never> extends ErrorProjectionOptions {\n /** Already projected client context. Never use request payloads as trusted context. */\n readonly context?: Record<string, unknown>;\n readonly attachmentTransfers?: AttachmentTransferPolicy<R>;\n /** Opt into downstream watches, change reads and replication sessions. Finite\n * queries/actions and the backend's own upstream lifecycle remain available.\n */\n readonly enableRealtime?: boolean;\n /** Outgoing replication only. Snapshot uses invalidations and finite reads;\n * incremental requires native selected delivery. Auto preserves capability selection.\n */\n readonly deliveryStrategy?: Schema.Schema.Type<typeof DeliveryStrategy>;\n /** Server-controlled selected-delivery capacity, frame and acknowledgment bounds. */\n readonly delivery?: import(\"@party-stack/ontology-backend/delivery\").DeliveryPolicy;\n readonly source?: OntologySource;\n readonly replica?: ReplicaService;\n readonly traces?: TraceStore;\n readonly backend?: import(\"@party-stack/ontology-backend\").OntologyBackendService;\n /** Worker bootstrap may run while transport starts accepting requests. */\n readonly ready?: Effect.Effect<void, BackendError, R>;\n /** Explicit local-partition administration; omitted helpers cannot delete data or stop an owner. */\n readonly deleteLocalData?: Effect.Effect<void, BackendError, R>;\n readonly releaseOwner?: Effect.Effect<void, BackendError, R>;\n readonly authorize: (\n request: OntologyRpcRequest,\n headers: Headers\n ) => Effect.Effect<void, BackendError, R>;\n}\n\n// This gate also rejects direct RPC calls: capability discovery is not enforcement.\nconst clientSyncOperations: ReadonlySet<OntologyRpcRequest[\"operation\"]> = new Set([\n \"WatchSubset\",\n \"WatchChanges\",\n \"PullChanges\",\n \"SubscribeSelection\",\n \"AckDelivery\",\n \"SubscribeState\",\n \"UpdateView\",\n \"OpenClient\",\n \"Read\",\n \"Submit\",\n \"Accept\",\n \"Acknowledge\",\n \"Demand\",\n \"Changes\",\n]);\n\nconst baseOntologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) => {\n const clientSync = options.enableRealtime === true;\n const bindingAuthorization = withExpectedBinding(options);\n const authorize = Effect.fnUntraced(function* (request: OntologyRpcRequest, headers: Headers) {\n yield* bindingAuthorization(request, headers);\n if (!clientSync && clientSyncOperations.has(request.operation))\n return yield* new BackendError({\n operation: request.operation,\n kind: \"NotImplemented\",\n message: \"Client synchronization is disabled on this endpoint.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n });\n });\n const snapshots = options.deliveryStrategy === \"snapshot\";\n // Snapshot readers must not silently switch to the committed journal path.\n // Its watch stream can still provide ordinary subset invalidation hints.\n const operationOptions = snapshots\n ? {\n ...options,\n get replica() {\n return options.replica;\n },\n get backend() {\n const backend = options.backend;\n if (!backend) return undefined;\n const watch = backend.changes?.watch;\n return {\n ...backend,\n changes: undefined,\n watchSubset: backend.watchSubset ?? (watch ? () => watch : undefined),\n };\n },\n }\n : options;\n const unavailableSource = () =>\n Effect.fail(\n new BackendError({\n operation: \"replication\",\n kind: \"NotImplemented\",\n message: \"This endpoint serves stateless operations only.\",\n retryable: false,\n })\n );\n const unavailableDelivery = () =>\n Effect.fail(\n new BackendError({\n operation: \"delivery\",\n kind: \"NotImplemented\",\n message: \"Selected incremental delivery is disabled or unavailable on this endpoint.\",\n retryable: false,\n })\n );\n const source: OntologySource = options.source ?? {\n sourceId: options.backend?.sourceId ?? \"stateless\",\n supportsIdempotency: options.backend?.supportsIdempotency ?? false,\n openClient: unavailableSource,\n read: unavailableSource,\n submit: unavailableSource,\n acknowledge: unavailableSource,\n demand: () => Stream.fromEffect(unavailableSource()),\n subscribeChanges: unavailableSource(),\n };\n return ReplicaRpcs.toLayer({\n Describe: (_, context) =>\n authorize({ operation: \"Describe\" }, context.headers).pipe(\n Effect.andThen(options.ready ?? Effect.void),\n Effect.andThen(\n Effect.gen(function* () {\n const strategy = yield* Schema.decodeUnknownEffect(DeliveryStrategy)(\n options.deliveryStrategy ?? \"auto\"\n ).pipe(\n Effect.mapError(\n () =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid delivery strategy.\",\n retryable: false,\n })\n )\n );\n const committedDelivery =\n clientSync &&\n Boolean(\n options.backend?.subscribeSelection && options.backend.acknowledgeDelivery\n );\n const speculativeDelivery =\n clientSync &&\n Boolean(source.subscribe && source.acknowledgeDelivery && source.accept);\n if (\n clientSync &&\n strategy === \"incremental\" &&\n !(options.source ? speculativeDelivery : committedDelivery)\n )\n return yield* new BackendError({\n operation: \"describe\",\n kind: \"NotImplemented\",\n message: \"This source does not support incremental selected delivery.\",\n retryable: false,\n });\n const signature = options.ir\n ? yield* Effect.try({\n try: () => ontologyDefinitionSignature(options.ir!),\n catch: (cause) =>\n new BackendError({\n operation: \"describe\",\n kind: \"InvalidConfiguration\",\n message: \"Invalid ontology definition.\",\n retryable: false,\n cause,\n }),\n })\n : undefined;\n // Cached per definition: Describe must not rehash a large IR per client.\n const definitionHash =\n options.ir && signature !== undefined\n ? yield* ontologyDefinitionHash(options.ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"describe\", cause))\n )\n : undefined;\n const contractHash =\n options.ir && signature !== undefined\n ? yield* ontologyDefinitionContractHash(options.ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"describe\", cause))\n )\n : undefined;\n return {\n version: ontologyProtocolVersion,\n replication:\n clientSync && options.source\n ? (\"speculative\" as const)\n : (\"committed\" as const),\n definitionHash,\n contractHash,\n sourceId: options.source?.sourceId ?? options.backend?.sourceId ?? \"stateless\",\n context: options.context,\n supportsIdempotency:\n options.source?.supportsIdempotency ??\n options.backend?.supportsIdempotency ??\n false,\n delivery: !snapshots && committedDelivery,\n stateDelivery: Boolean(options.source) && !snapshots && speculativeDelivery,\n changes: clientSync && Boolean(operationOptions.backend?.changes),\n watchChanges: clientSync && Boolean(operationOptions.backend?.changes?.watch),\n watchSubset:\n clientSync &&\n Boolean(\n operationOptions.backend?.watchSubset ||\n options.ir?.objectTypes.some(\n (type) =>\n typeof operationOptions.backend?.refresh?.(\n objectSubset(type.name)\n )?.pollIntervalMs === \"number\"\n )\n ),\n actionParameterResolution: Boolean(\n options.backend?.resolveActionParameters || options.replica\n ),\n queries: Boolean(options.backend),\n system: Boolean(options.replica),\n meta: Boolean(options.ir),\n attachments: options.backend\n ? options.backend.attachments && {\n stage: Boolean(options.backend.attachments.stage),\n }\n : options.replica\n ? { stage: true }\n : undefined,\n encrypted: Boolean(options.backend ? options.backend.encrypted : options.replica),\n };\n })\n )\n ),\n SubscribeSelection: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize(\n { operation: \"SubscribeSelection\", selection: request.selection },\n context.headers\n );\n if (snapshots || !options.backend?.subscribeSelection)\n return yield* unavailableDelivery();\n const delivery = yield* options.backend.subscribeSelection(\n request.selection,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.mapEffect((frame) =>\n Effect.gen(function* () {\n if (!frame.metadata) return frame;\n if (frame.metadata.sourceId !== options.backend!.sourceId)\n return yield* new BackendError({\n operation: \"delivery\",\n kind: \"SourceMismatch\",\n message: \"The committed delivery source changed.\",\n retryable: false,\n });\n // The endpoint binds one logical source/session lifetime. A replica\n // server's committed facet forwards upstream rows under that identity.\n return {\n ...frame,\n metadata: {\n ...frame.metadata,\n sourceId:\n options.source?.sourceId ??\n options.backend?.sourceId ??\n \"stateless\",\n },\n };\n })\n )\n );\n })\n ),\n SubscribeState: (request, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* authorize({ operation: \"SubscribeState\", ...request }, context.headers);\n if (snapshots || !source.subscribe) return yield* unavailableDelivery();\n const delivery = yield* source.subscribe(\n request.session,\n request.view,\n options.delivery,\n request.resume\n );\n return delivery.frames.pipe(\n Stream.map((frame) => ({\n ...frame,\n changes: frame.changes.map((change) =>\n change.kind === \"put\" &&\n (change.record.kind === \"pending\" || change.record.kind === \"completed\")\n ? {\n ...change,\n record: {\n ...change.record,\n value: projectActionFailure(change.record.value, options),\n },\n }\n : change\n ),\n }))\n );\n })\n ),\n UpdateView: (request, context) =>\n authorize({ operation: \"UpdateView\", ...request }, context.headers).pipe(\n Effect.andThen(() => {\n if (snapshots || !source.subscribe) return unavailableDelivery();\n return source.updateView\n ? source.updateView(request.session, request.view)\n : Effect.fail(\n new BackendError({\n operation: \"UpdateView\",\n kind: \"ViewReplaced\",\n retryable: true,\n message: \"This source replaces views by subscribing again.\",\n })\n );\n })\n ),\n AckDelivery: (request, context) =>\n authorize({ operation: \"AckDelivery\", ...request }, context.headers).pipe(\n Effect.andThen(() => {\n if (snapshots) return unavailableDelivery();\n const ack =\n request.kind === \"committed\"\n ? options.backend?.acknowledgeDelivery\n : source.acknowledgeDelivery;\n return ack ? ack(request.position) : unavailableSource();\n })\n ),\n Accept: (request, context) =>\n authorize({ operation: \"Accept\", submission: request }, context.headers).pipe(\n Effect.andThen(() => (source.accept ? source.accept(request) : unavailableSource()))\n ),\n OpenClient: (request, context) =>\n authorize({ operation: \"OpenClient\", ...request }, context.headers).pipe(\n Effect.andThen(() => source.openClient(request.resume))\n ),\n Read: (request, context) =>\n authorize({ operation: \"Read\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.read(request.session, request.view).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Submit: (request, context) =>\n authorize({ operation: \"Submit\", submission: request }, context.headers).pipe(\n Effect.andThen(() =>\n source.submit(request).pipe(\n Effect.map((result) => ({\n ...result,\n state: projectStateFailures(result.state, options),\n }))\n )\n )\n ),\n Acknowledge: (request, context) =>\n authorize({ operation: \"Acknowledge\", ...request }, context.headers).pipe(\n Effect.andThen(() =>\n source.acknowledge(\n request.session,\n request.revision,\n request.through,\n request.viewGeneration\n )\n )\n ),\n Demand: (subset, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Demand\", subset }, context.headers);\n return source.demand(subset).pipe(Stream.as(\"ready\" as const));\n })\n ),\n Changes: (_, context) =>\n Stream.unwrap(\n Effect.gen(function* () {\n yield* Effect.annotateCurrentSpan(\"activity\", \"subscription\");\n yield* authorize({ operation: \"Changes\" }, context.headers);\n const changes = options.source ? yield* source.subscribeChanges : undefined;\n if (!changes) return yield* unavailableSource();\n // A new stream is a repair boundary, not proof that no updates were missed.\n return Stream.concat(\n Stream.make(\"invalidate\" as const),\n Stream.map(changes, () => \"invalidate\" as const)\n );\n })\n ),\n }).pipe(\n Layer.merge(ontologyOperationHandlers(operationOptions, authorize)),\n Layer.merge(errorProjectionLayer(options))\n );\n};\n\nconst resourceHeader = \"x-party-stack-resource\";\n\n/** Administrative resources use the same ontology RPCs and transport. Access is\n * still gated by the parent endpoint before the resource is acquired. */\nexport const ontologyRpcHandlers = <R>(options: OntologyRpcServerOptions<R>) =>\n Layer.unwrap(\n Effect.gen(function* () {\n const scope = yield* Effect.scope;\n const ordinary = yield* Layer.buildWithScope(baseOntologyRpcHandlers(options), scope);\n const system = yield* Effect.cached(\n Effect.gen(function* () {\n if (!options.replica)\n return yield* new BackendError({\n operation: \"system\",\n kind: \"NotImplemented\",\n retryable: false,\n message: \"This endpoint does not own downloads.\",\n });\n const backend = yield* options.replica.demand.pins.backend;\n return yield* Layer.buildWithScope(\n baseOntologyRpcHandlers({\n backend,\n ir: systemOntology,\n context: options.context,\n enableRealtime: options.enableRealtime,\n errors: options.errors,\n authorize: (_, headers) => options.authorize({ operation: \"System\" }, headers),\n }),\n scope\n );\n })\n );\n // The definition this endpoint serves, as meta ontology rows. Reading it needs the\n // same access as Describe.\n const describeAccess = (headers: Headers) =>\n options.authorize({ operation: \"Describe\" }, headers);\n const meta = yield* Effect.cached(\n Effect.gen(function* () {\n if (!options.ir)\n return yield* new BackendError({\n operation: \"meta\",\n kind: \"NotImplemented\",\n retryable: false,\n message: \"This endpoint has no definition to describe.\",\n });\n // A replica that reopens under another definition replaces this endpoint's;\n // watches on it report that, so clients read the definition again.\n const replica = options.replica;\n const boundTo = replica?.ir;\n return yield* Layer.buildWithScope(\n baseOntologyRpcHandlers({\n backend: makeMetadataBackend(options.ir, {\n ...(replica && {\n replaced: replica.definition.changes.pipe(\n Stream.filter((ir) => ir !== boundTo),\n Stream.take(1)\n ),\n }),\n }),\n ir: metaOntology,\n enableRealtime: options.enableRealtime,\n errors: options.errors,\n authorize: (_, headers) => describeAccess(headers),\n }),\n scope\n );\n })\n );\n type Rpcs = RpcGroup.Rpcs<typeof OntologyRpcs>;\n type Handler = RpcGroup.HandlersFrom<Rpcs>[Rpcs[\"_tag\"]];\n const handlers = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => {\n const invoke = (payload: never, request: Parameters<Handler>[1]) =>\n Effect.gen(function* () {\n const resource = request.headers[resourceHeader];\n if (resource !== undefined && resource !== \"system\" && resource !== \"meta\")\n return yield* new BackendError({\n operation: \"ontology.resource\",\n kind: \"NotFound\",\n retryable: false,\n message: \"Unknown ontology resource.\",\n });\n if (resource === \"system\")\n yield* options.authorize({ operation: \"System\" }, request.headers);\n const context =\n resource === \"system\"\n ? yield* system\n : resource === \"meta\"\n ? yield* meta\n : ordinary;\n const handler = yield* OntologyRpcs.accessHandler(tag as Rpcs[\"_tag\"]).pipe(\n Effect.provideContext(context)\n );\n return handler(payload, request);\n });\n return [\n tag,\n RpcSchema.isStreamSchema(rpc.successSchema)\n ? (payload: never, request: Parameters<Handler>[1]) =>\n Stream.unwrap(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Stream.Stream<unknown, BackendError, R>\n )\n )\n )\n : (payload: never, request: Parameters<Handler>[1]) =>\n Effect.flatten(\n invoke(payload, request).pipe(\n Effect.map(\n (result) => result as Effect.Effect<unknown, BackendError, R>\n )\n )\n ),\n ];\n })\n ) as unknown as {\n readonly [Procedure in Rpcs as Procedure[\"_tag\"]]: Rpc.ToHandlerFn<\n Procedure,\n R | Scope.Scope\n >;\n };\n return Layer.merge(OntologyRpcs.toLayer(handlers), errorProjectionLayer(options));\n })\n );\n\nexport type OntologyResource = \"system\" | \"meta\";\nconst resourceDefinitions = { system: systemOntology, meta: metaOntology } as const;\nconst selectResource = (client: OntologyRpcClient, resource: OntologyResource): OntologyRpcClient =>\n Object.fromEntries(\n [...OntologyRpcs.requests.keys()].map((tag) => [\n tag,\n (payload: unknown, settings?: { readonly headers?: Record<string, string> }) =>\n Reflect.apply(Reflect.get(client, tag), client, [\n payload,\n { ...settings, headers: { ...settings?.headers, [resourceHeader]: resource } },\n ]),\n ])\n ) as OntologyRpcClient;\n\nexport type OntologyRpcClient = Effect.Success<\n ReturnType<typeof RpcClient.make<RpcGroup.Rpcs<typeof OntologyRpcs>>>\n>;\nconst unavailable = (cause: unknown) => classifyBackendFailure(\"remote.protocol\", cause);\n/** A fresh description must speak this client's protocol: an older server describes its\n * definition differently and has no `meta` resource. */\nconst requireProtocol = (description: OntologyDescription) =>\n description.version === ontologyProtocolVersion\n ? Effect.succeed(description)\n : Effect.fail(\n new BackendError({\n operation: \"remote.describe\",\n kind: \"NotImplemented\",\n retryable: false,\n message: `The server speaks ontology protocol version ${description.version}; this client needs version ${ontologyProtocolVersion}.`,\n })\n );\nconst copyDescription = (description: OntologyDescription) =>\n Effect.try({\n try: () => Schema.decodeUnknownSync(Description)(Schema.encodeSync(Description)(description)),\n catch: (cause) =>\n new BackendError({\n operation: \"remote.describe\",\n kind: \"InvalidResponse\",\n retryable: false,\n message: \"Invalid ontology description.\",\n cause,\n }),\n });\n\nconst descriptionValue = Table.make<unknown>({ name: \"ontology-description-identity\" });\nconst sameDescriptionValue = (left: unknown, right: unknown) =>\n descriptionValue.encode(left) === descriptionValue.encode(right);\nconst protocolIdentity = (description: OntologyDescription) => ({\n version: description.version,\n replication: description.replication,\n supportsIdempotency: description.supportsIdempotency,\n delivery: Boolean(description.delivery),\n stateDelivery: Boolean(description.stateDelivery),\n changes: Boolean(description.changes),\n watchChanges: Boolean(description.watchChanges),\n watchSubset: Boolean(description.watchSubset),\n actionParameterResolution: Boolean(description.actionParameterResolution),\n queries: Boolean(description.queries),\n system: Boolean(description.system),\n meta: Boolean(description.meta),\n attachments: Boolean(description.attachments),\n stageAttachments: Boolean(description.attachments?.stage),\n encrypted: Boolean(description.encrypted),\n});\nconst checkBootstrapBinding = (accepted: OntologyDescription, fresh: OntologyDescription) =>\n Effect.gen(function* () {\n if (fresh.sourceId !== accepted.sourceId)\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology source changed.\",\n });\n if (!sameDescriptionValue(fresh.context ?? {}, accepted.context ?? {}))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The ontology context changed.\",\n });\n if (!sameDescriptionValue(protocolIdentity(fresh), protocolIdentity(accepted)))\n return yield* new BackendError({\n operation: \"remote.validate\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology protocol capabilities changed.\",\n });\n });\n\nconst definitionFailure: unique symbol = Symbol(\"OntologyClient.definitionFailure\");\ninterface InternalDefinition extends OntologyClientDefinition {\n readonly [definitionFailure]: (error: BackendError) => Effect.Effect<void>;\n}\n/** HTTP byte operations use the same incompatibility notification as typed RPC. */\nexport const observeOntologyClientFailure = <A, R>(\n client: OntologyClient,\n work: Effect.Effect<A, BackendError, R>\n) =>\n work.pipe(\n Effect.tapError(\n (error) =>\n (client.definition as Partial<InternalDefinition>)[definitionFailure]?.(error) ?? Effect.void\n )\n );\n\ntype AcceptDescription = (\n description: OntologyDescription\n) => Effect.Effect<OntologyDescription, BackendError>;\n\nconst makeDefinitionClient = Effect.fnUntraced(function* (\n raw: OntologyRpcClient,\n description: OntologyDescription,\n ir: import(\"@party-stack/ontology-spec\").OntologyIR | undefined,\n options: OntologyClientOptions | undefined\n) {\n const scope = yield* Effect.scope;\n const state = yield* SubscriptionRef.make<OntologyClientDefinitionStatus>({\n status: options?.description ? \"retained\" : \"current\",\n refreshing: false,\n });\n yield* Effect.addFinalizer(() => PubSub.shutdown(state.pubsub));\n let attempt: Deferred.Deferred<OntologyDescription, BackendError> | undefined;\n const incompatible = (error: BackendError) =>\n error.kind === \"SchemaMismatch\" || error.kind === \"SourceMismatch\";\n const notify = (error: BackendError) => options?.onIncompatible?.(error) ?? Effect.void;\n const failed = Effect.fnUntraced(function* (error: BackendError) {\n const previous = yield* SubscriptionRef.get(state);\n yield* SubscriptionRef.set(state, {\n ...previous,\n status: incompatible(error) ? \"incompatible\" : previous.status,\n refreshing: false,\n error: previous.status === \"incompatible\" && !incompatible(error) ? previous.error : error,\n });\n if (\n incompatible(error) &&\n (previous.status !== \"incompatible\" || previous.error?.kind !== error.kind)\n )\n yield* notify(error).pipe(\n Effect.catchCause((cause) =>\n Effect.logError(\"Ontology incompatibility callback failed\", cause)\n ),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n // The contract this client accepted: of its definition, or as described.\n const schemaHash = ir\n ? yield* ontologyDefinitionContractHash(ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"remote.definition\", cause))\n )\n : description.contractHash;\n const validate =\n options?.validate ??\n ((fresh: OntologyDescription) =>\n fresh.contractHash === schemaHash\n ? Effect.void\n : Effect.fail(\n new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The ontology definition changed.\",\n })\n ));\n const refresh = Effect.uninterruptibleMask((restore) =>\n Effect.suspend(() => {\n if (attempt) return restore(Deferred.await(attempt));\n const pending = Deferred.makeUnsafe<OntologyDescription, BackendError>();\n attempt = pending;\n const check = SubscriptionRef.update(state, (current) => ({ ...current, refreshing: true })).pipe(\n Effect.andThen(\n raw.Describe().pipe(Effect.mapError(unavailable), Effect.flatMap(requireProtocol))\n ),\n Effect.tap((fresh) => checkBootstrapBinding(description, fresh)),\n Effect.tap(validate),\n Effect.tap(() => SubscriptionRef.set(state, { status: \"current\", refreshing: false })),\n Effect.onExit((exit) =>\n Effect.gen(function* () {\n if (Exit.isFailure(exit) && !Cause.hasInterruptsOnly(exit.cause)) {\n const error = Cause.findErrorOption(exit.cause);\n yield* failed(\n error._tag === \"Some\" ? error.value : unavailable(Cause.squash(exit.cause))\n );\n }\n if (attempt === pending) attempt = undefined;\n yield* Deferred.done(pending, exit);\n })\n ),\n Effect.catchCause(() => Effect.void)\n );\n return Effect.forkIn(check, scope, { startImmediately: true }).pipe(\n Effect.andThen(restore(Deferred.await(pending)))\n );\n })\n );\n const report = Effect.fnUntraced(function* (error: BackendError) {\n if (!incompatible(error)) return;\n yield* failed(error);\n // Rebinding a source/account needs an explicit acquisition. A metadata\n // refresh must not turn that failure into permission to reset its cache.\n if (error.kind === \"SourceMismatch\") return;\n yield* refresh.pipe(\n Effect.catchCause(() => Effect.void),\n Effect.forkIn(scope),\n Effect.asVoid\n );\n });\n // Delivery metadata already carries the contract hash. Check it at the\n // client boundary too, so a receiver's schema failure reaches definition\n // lifecycle handling even when the transport successfully delivered a frame.\n // Requests carry it too, so a server whose definition changed rejects them with\n // SchemaMismatch instead of serving them under a contract the client does not know.\n const headers = {\n ...expectedBindingHeaders(description),\n ...(schemaHash !== undefined ? { [expectedDefinitionHeader]: schemaHash } : {}),\n };\n const checkFrame = Effect.fnUntraced(function* (frame: DeliveryFrame) {\n if (frame.metadata) {\n if (frame.metadata.sourceId !== description.sourceId)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SourceMismatch\",\n retryable: false,\n message: \"The delivered ontology source changed.\",\n });\n if (schemaHash !== undefined && frame.metadata.schemaHash !== schemaHash)\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"SchemaMismatch\",\n retryable: false,\n message: \"The delivered ontology definition changed.\",\n });\n }\n return frame;\n });\n const client = Object.fromEntries(\n [...OntologyRpcs.requests].map(([tag, rpc]) => [\n tag,\n (payload: unknown, options?: { readonly headers?: Record<string, string> }) => {\n const invoke = () =>\n Reflect.apply(Reflect.get(raw, tag), raw, [\n payload,\n tag === \"Describe\"\n ? options\n : { ...options, headers: { ...options?.headers, ...headers } },\n ]);\n if (RpcSchema.isStreamSchema(rpc.successSchema)) {\n const stream =\n tag === \"SubscribeSelection\" || tag === \"SubscribeState\"\n ? (invoke() as Stream.Stream<DeliveryFrame, BackendError>).pipe(\n Stream.mapEffect(checkFrame)\n )\n : (invoke() as Stream.Stream<unknown, BackendError>);\n return stream.pipe(Stream.tapError(report));\n }\n return (invoke() as Effect.Effect<unknown, BackendError>).pipe(Effect.tapError(report));\n },\n ])\n ) as unknown as OntologyRpcClient;\n const definition: InternalDefinition = {\n get: SubscriptionRef.get(state),\n changes: SubscriptionRef.changes(state),\n refresh,\n [definitionFailure]: report,\n };\n return {\n client,\n definition,\n };\n});\n\n/**\n * Read the definition an endpoint describes from its `meta` resource. The rows are read in one\n * request, but the endpoint may change definition between `Describe` and the read: the result\n * must hash to the described definition, or the endpoint is described again.\n */\nconst readDefinition = Effect.fnUntraced(function* (\n client: OntologyRpcClient,\n described: OntologyDescription,\n open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>\n) {\n let description = described;\n for (let attempt = 0; attempt < 3; attempt++) {\n const ir = yield* Effect.scoped(\n Effect.flatMap(open(client, { resource: \"meta\" }), (meta) => pull(meta.backend))\n );\n const hash = yield* ontologyDefinitionHash(ir).pipe(\n Effect.mapError((cause) => classifyBackendFailure(\"remote.definition\", cause))\n );\n if (hash === description.definitionHash) return { description, ir };\n description = yield* client\n .Describe()\n .pipe(Effect.mapError(unavailable), Effect.flatMap(requireProtocol));\n }\n return yield* new BackendError({\n operation: \"remote.definition\",\n kind: \"Unavailable\",\n retryable: true,\n message: \"The ontology definition changed while it was being read.\",\n });\n});\n\n/**\n * While someone follows the definition status, notice a new definition without waiting for a\n * request to fail: watch the endpoint's metadata. Without realtime the endpoint offers no watch,\n * and the next request after a change reports it instead.\n */\nconst watchDefinition = (\n definition: InternalDefinition,\n metaBackend: NonNullable<OntologyClient[\"metaBackend\"]>\n): InternalDefinition => {\n // Every client watching a route sees its change at once; spread their checks (a Describe and\n // a definition read each) over a couple of seconds.\n const check = Effect.andThen(\n Effect.flatMap(Random.nextIntBetween(0, 2_000), (delay) => Effect.sleep(delay)),\n Effect.ignore(definition.refresh)\n );\n const signals = Stream.unwrap(\n Effect.gen(function* () {\n const backend = yield* metaBackend;\n const events = backend.watchSubset?.(objectSubset(\"Ontology\"));\n // The watch reports changes after it is acquired; check once for any before.\n return events ? Stream.concat(Stream.make(undefined), yield* events) : Stream.empty;\n })\n ).pipe(\n // A dropped connection is watched again; a mismatch is already in the status.\n Stream.retry(($) =>\n $(Schedule.spaced(\"5 seconds\")).pipe(\n Schedule.jittered,\n Schedule.while(({ input }) => input.retryable)\n )\n )\n );\n const watch = signals.pipe(\n Stream.mapEffect(() => check),\n Stream.catchCause(() => Stream.empty),\n Stream.drain\n );\n return { ...definition, changes: Stream.merge(definition.changes, watch, { haltStrategy: \"left\" }) };\n};\n\nconst makeProtocolClient = (accept: AcceptDescription) => {\n const open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope> = Effect.fn(\"RemoteOntology.protocol\")(\n function* (client: OntologyRpcClient, options?: OntologyClientOptions) {\n return yield* openProtocolClient(client, options, accept, open);\n }\n );\n return open;\n};\n/** Use the same source contract with Effect RPC's worker, HTTP or socket transport. */\nexport const makeOntologyProtocolClient = makeProtocolClient(copyDescription);\n/** Same-runtime transports without serialization receive the server's own,\n * already validated description. Skip the defensive wire copy: re-encoding and\n * decoding a large definition dominates startup on mobile JavaScript engines,\n * and sharing the definition object lets per-definition signature caches apply.\n */\nexport const makeTrustedOntologyProtocolClient = makeProtocolClient(Effect.succeed);\n\nconst openProtocolClient = Effect.fnUntraced(function* (\n client: OntologyRpcClient,\n options: OntologyClientOptions | undefined,\n accept: AcceptDescription,\n open: (\n client: OntologyRpcClient,\n options?: OntologyClientOptions\n ) => Effect.Effect<OntologyClient, BackendError, Scope.Scope>\n): Effect.fn.Return<OntologyClient, BackendError, Scope.Scope> {\n const base = client;\n if (options?.resource) client = selectResource(client, options.resource);\n // Serialized RPC clients already decoded Describe with its success schema, and\n // a same-runtime client receives the server's validated value: neither needs a\n // second encode/decode copy. Only a caller-retained description is copied.\n let description = yield* options?.description\n ? accept(options.description)\n : client.Describe().pipe(Effect.mapError(unavailable), Effect.flatMap(requireProtocol));\n let ir = options?.ir ?? (options?.resource ? resourceDefinitions[options.resource] : undefined);\n // A client in the server's own runtime uses the server's definition object while it is still\n // the one described, instead of reading a copy.\n if (!ir && options?.localDefinition && description.definitionHash !== undefined) {\n const local = yield* options.localDefinition;\n const hash = local && (yield* Effect.orElseSucceed(ontologyDefinitionHash(local), () => undefined));\n if (hash === description.definitionHash) ir = local;\n }\n if (options?.description && !ir)\n return yield* new BackendError({\n operation: \"remote.bootstrap\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: \"A retained ontology description needs the definition it was accepted with.\",\n });\n if (!ir && description.meta) ({ description, ir } = yield* readDefinition(client, description, open));\n const described = yield* makeDefinitionClient(client, description, ir, options);\n const systemBackend =\n description.system && !options?.resource\n ? open(base, { resource: \"system\", networks: options?.networks }).pipe(\n Effect.map((resource) => resource.backend)\n )\n : undefined;\n const metaBackend =\n description.meta && !options?.resource\n ? open(base, { resource: \"meta\", networks: options?.networks }).pipe(\n Effect.map((resource) => resource.backend)\n )\n : undefined;\n client = described.client;\n const operations = yield* makeOntologyOperationsClient(client);\n const common = {\n description,\n definition:\n metaBackend && !options?.resource\n ? watchDefinition(described.definition, metaBackend)\n : described.definition,\n operations,\n systemBackend,\n metaBackend,\n sourceId: description.sourceId,\n definitionHash: description.definitionHash,\n ir,\n context: description.context,\n backend: {\n ...makeRpcBackend(client, description, operations),\n ...(options?.networks && { networks: options.networks }),\n },\n };\n if (description.replication === \"committed\") return { ...common, replication: { kind: \"committed\" } };\n const source: OntologySource = {\n sourceId: description.sourceId,\n outbox: operations.outbox,\n supportsIdempotency: description.supportsIdempotency,\n openClient: (resume) => client.OpenClient({ resume }).pipe(Effect.mapError(unavailable)),\n read: (session, view) => client.Read({ session, view }).pipe(Effect.mapError(unavailable)),\n submit: (request) => client.Submit(request).pipe(Effect.mapError(unavailable)),\n accept: description.stateDelivery\n ? (request) => client.Accept(request).pipe(Effect.mapError(unavailable))\n : undefined,\n subscribe: description.stateDelivery\n ? (session, view, _policy, resume) =>\n Effect.succeed({\n frames: client\n .SubscribeState({ session, view, resume })\n .pipe(Stream.mapError(unavailable)),\n acknowledge: (position) =>\n client\n .AckDelivery({ kind: \"speculative\", position })\n .pipe(Effect.mapError(unavailable)),\n })\n : undefined,\n acknowledgeDelivery: description.stateDelivery\n ? (position) =>\n client.AckDelivery({ kind: \"speculative\", position }).pipe(Effect.mapError(unavailable))\n : undefined,\n updateView: description.stateDelivery\n ? (session, view) => client.UpdateView({ session, view }).pipe(Effect.mapError(unavailable))\n : undefined,\n acknowledge: (session, revision, through, viewGeneration) =>\n client\n .Acknowledge({ session, revision, through, viewGeneration })\n .pipe(Effect.mapError(unavailable)),\n subscribeChanges: Effect.succeed(\n client.Changes().pipe(\n Stream.map(() => undefined),\n Stream.mapError(unavailable)\n )\n ),\n demand: (subset) => client.Demand(subset).pipe(Stream.as(undefined), Stream.mapError(unavailable)),\n };\n return { ...common, replication: { kind: \"speculative\", source } };\n});\n\nexport { errorProjectionLayer } from \"./errorProjection.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqEA,MAAM,UAAU,OAAO,IAAI,MAAM,OAAO,UAAU;CAAE,SAAS;CAAG,SAAS,OAAO;AAAiB,CAAC,CAAC;AACnG,MAAM,mBAAmB,OAAO,SAAS;CAAC;CAAQ;CAAY;AAAa,CAAC;AAC5E,MAAM,cAAc;AACpB,MAAM,cAAc,SAAS,KACzB,IAAI,KAAK,YAAY;CAAE,SAAS;CAAa,OAAO;AAAa,CAAC,GAClE,IAAI,KAAK,sBAAsB;CAC3B,SAAS;EAAE,WAAW;EAAsB,QAAQ,OAAO,SAAS,sBAAsB;CAAE;CAC5F,SAAS;CACT,OAAO;CACP,QAAQ;AACZ,CAAC,GACD,IAAI,KAAK,kBAAkB;CACvB,SAAS;EACL,SAAS;EACT,MAAM;EACN,QAAQ,OAAO,SAAS,sBAAsB;CAClD;CACA,SAAS;CACT,OAAO;CACP,QAAQ;AACZ,CAAC,GACD,IAAI,KAAK,cAAc;CACnB,SAAS;E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,OAAA,6BAAA,IAAA,MAAA"}
1
+ {"version":3,"file":"rpcLocal.d.ts","names":[],"sources":["../src/rpcLocal.ts"],"mappings":";;;;;;;;qBAgBa,0BAAuE,GAAC,QAAA,eAAA,IAAA;WAEjD;kBAmClC,OAAA,OAAA,6BAAA,IAAA,MAAA"}
package/lib/rpcLocal.js CHANGED
@@ -20,6 +20,7 @@ const makeOntologyLocalClient = Effect.fn("OntologyClient.local")(function* (ser
20
20
  const name = selected ?? options?.ontology;
21
21
  return yield* makeTrustedOntologyProtocolClient(name === void 0 ? rpc : selectOntology(rpc, name), {
22
22
  ...clientOptions,
23
+ networks: [],
23
24
  localDefinition: Effect.scoped(server.bind(name ?? server.defaultOntology ?? "")).pipe(Effect.map((bound) => bound.options.ir), Effect.orElseSucceed(() => void 0), Effect.provideContext(context))
24
25
  });
25
26
  }) };
@@ -1 +1 @@
1
- {"version":3,"file":"rpcLocal.js","names":[],"sources":["../src/rpcLocal.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { RpcGroup, RpcServer } from \"effect/rpc\";\nimport { ontologyServerDispatch, selectOntology } from \"./routing.js\";\nimport {\n makeTracedRpcClientNoSerialization,\n makeTrustedOntologyProtocolClient,\n OntologyRpcs,\n} from \"./rpc.js\";\nimport type { OntologyServer } from \"./routing.js\";\nimport type { OntologyServerClient, OntologyClientOptions } from \"./rpc.js\";\nimport type { Scope } from \"effect\";\n\n/** Connect to a borrowed server in the same JavaScript runtime. The connection\n * owns its RPC requests and subscriptions; closing it never closes the server.\n * Local routes use their trusted context binding, like worker routes.\n */\nexport const makeOntologyLocalClient = Effect.fn(\"OntologyClient.local\")(function* <R>(\n server: OntologyServer<R>,\n options?: { readonly ontology?: string }\n): Effect.fn.Return<OntologyServerClient, never, R | Scope.Scope> {\n type Rpcs = RpcGroup.Rpcs<typeof OntologyRpcs>;\n let client!: Effect.Success<ReturnType<typeof makeTracedRpcClientNoSerialization<Rpcs, never>>>;\n const dispatch = yield* RpcServer.makeNoSerialization(OntologyRpcs, {\n onFromServer: (response) => client.write(response),\n }).pipe(Effect.provide(ontologyServerDispatch(server)));\n client = yield* makeTracedRpcClientNoSerialization(OntologyRpcs, {\n supportsAck: true,\n onFromClient: ({ message }) => dispatch.write(0, message),\n });\n const rpc = client.client;\n const context = yield* Effect.context<R>();\n return {\n ontology: Effect.fn(\"OntologyClient.select\")(function* (\n selected?: string,\n clientOptions?: OntologyClientOptions\n ) {\n const name = selected ?? options?.ontology;\n return yield* makeTrustedOntologyProtocolClient(\n name === undefined ? rpc : selectOntology(rpc, name),\n {\n ...clientOptions,\n // The definition object the server serves this route now, instead of a copy.\n localDefinition: Effect.scoped(server.bind(name ?? server.defaultOntology ?? \"\")).pipe(\n Effect.map((bound) => bound.options.ir),\n Effect.orElseSucceed(() => undefined),\n Effect.provideContext(context)\n ),\n }\n );\n }),\n };\n});\n"],"mappings":";;;;;;;;;AAgBA,MAAa,0BAA0B,OAAO,GAAG,sBAAsB,CAAC,CAAC,WACrE,QACA,SAC8D;CAE9D,IAAI;CACJ,MAAM,WAAW,OAAO,UAAU,oBAAoB,cAAc,EAChE,eAAe,aAAa,OAAO,MAAM,QAAQ,EACrD,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,uBAAuB,MAAM,CAAC,CAAC;CACtD,SAAS,OAAO,mCAAmC,cAAc;EAC7D,aAAa;EACb,eAAe,EAAE,cAAc,SAAS,MAAM,GAAG,OAAO;CAC5D,CAAC;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,OAAO,OAAO,QAAW;CACzC,OAAO,EACH,UAAU,OAAO,GAAG,uBAAuB,CAAC,CAAC,WACzC,UACA,eACF;EACE,MAAM,OAAO,YAAY,SAAS;EAClC,OAAO,OAAO,kCACV,SAAS,KAAA,IAAY,MAAM,eAAe,KAAK,IAAI,GACnD;GACI,GAAG;GAEH,iBAAiB,OAAO,OAAO,OAAO,KAAK,QAAQ,OAAO,mBAAmB,EAAE,CAAC,CAAC,CAAC,KAC9E,OAAO,KAAK,UAAU,MAAM,QAAQ,EAAE,GACtC,OAAO,oBAAoB,KAAA,CAAS,GACpC,OAAO,eAAe,OAAO,CACjC;EACJ,CACJ;CACJ,CAAC,EACL;AACJ,CAAC"}
1
+ {"version":3,"file":"rpcLocal.js","names":[],"sources":["../src/rpcLocal.ts"],"sourcesContent":["import { Effect } from \"effect\";\nimport { RpcGroup, RpcServer } from \"effect/rpc\";\nimport { ontologyServerDispatch, selectOntology } from \"./routing.js\";\nimport {\n makeTracedRpcClientNoSerialization,\n makeTrustedOntologyProtocolClient,\n OntologyRpcs,\n} from \"./rpc.js\";\nimport type { OntologyServer } from \"./routing.js\";\nimport type { OntologyServerClient, OntologyClientOptions } from \"./rpc.js\";\nimport type { Scope } from \"effect\";\n\n/** Connect to a borrowed server in the same JavaScript runtime. The connection\n * owns its RPC requests and subscriptions; closing it never closes the server.\n * Local routes use their trusted context binding, like worker routes.\n */\nexport const makeOntologyLocalClient = Effect.fn(\"OntologyClient.local\")(function* <R>(\n server: OntologyServer<R>,\n options?: { readonly ontology?: string }\n): Effect.fn.Return<OntologyServerClient, never, R | Scope.Scope> {\n type Rpcs = RpcGroup.Rpcs<typeof OntologyRpcs>;\n let client!: Effect.Success<ReturnType<typeof makeTracedRpcClientNoSerialization<Rpcs, never>>>;\n const dispatch = yield* RpcServer.makeNoSerialization(OntologyRpcs, {\n onFromServer: (response) => client.write(response),\n }).pipe(Effect.provide(ontologyServerDispatch(server)));\n client = yield* makeTracedRpcClientNoSerialization(OntologyRpcs, {\n supportsAck: true,\n onFromClient: ({ message }) => dispatch.write(0, message),\n });\n const rpc = client.client;\n const context = yield* Effect.context<R>();\n return {\n ontology: Effect.fn(\"OntologyClient.select\")(function* (\n selected?: string,\n clientOptions?: OntologyClientOptions\n ) {\n const name = selected ?? options?.ontology;\n return yield* makeTrustedOntologyProtocolClient(\n name === undefined ? rpc : selectOntology(rpc, name),\n {\n ...clientOptions,\n // The same process: no network to wait on.\n networks: [],\n // The definition object the server serves this route now, instead of a copy.\n localDefinition: Effect.scoped(server.bind(name ?? server.defaultOntology ?? \"\")).pipe(\n Effect.map((bound) => bound.options.ir),\n Effect.orElseSucceed(() => undefined),\n Effect.provideContext(context)\n ),\n }\n );\n }),\n };\n});\n"],"mappings":";;;;;;;;;AAgBA,MAAa,0BAA0B,OAAO,GAAG,sBAAsB,CAAC,CAAC,WACrE,QACA,SAC8D;CAE9D,IAAI;CACJ,MAAM,WAAW,OAAO,UAAU,oBAAoB,cAAc,EAChE,eAAe,aAAa,OAAO,MAAM,QAAQ,EACrD,CAAC,CAAC,CAAC,KAAK,OAAO,QAAQ,uBAAuB,MAAM,CAAC,CAAC;CACtD,SAAS,OAAO,mCAAmC,cAAc;EAC7D,aAAa;EACb,eAAe,EAAE,cAAc,SAAS,MAAM,GAAG,OAAO;CAC5D,CAAC;CACD,MAAM,MAAM,OAAO;CACnB,MAAM,UAAU,OAAO,OAAO,QAAW;CACzC,OAAO,EACH,UAAU,OAAO,GAAG,uBAAuB,CAAC,CAAC,WACzC,UACA,eACF;EACE,MAAM,OAAO,YAAY,SAAS;EAClC,OAAO,OAAO,kCACV,SAAS,KAAA,IAAY,MAAM,eAAe,KAAK,IAAI,GACnD;GACI,GAAG;GAEH,UAAU,CAAC;GAEX,iBAAiB,OAAO,OAAO,OAAO,KAAK,QAAQ,OAAO,mBAAmB,EAAE,CAAC,CAAC,CAAC,KAC9E,OAAO,KAAK,UAAU,MAAM,QAAQ,EAAE,GACtC,OAAO,oBAAoB,KAAA,CAAS,GACpC,OAAO,eAAe,OAAO,CACjC;EACJ,CACJ;CACJ,CAAC,EACL;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"rpcWorker.d.ts","names":[],"sources":["../src/rpcWorker.ts"],"mappings":";;;;;;;;;;;;qBA0Ba,sBAAyE,GAAC,SAAA,OAAA,OAAA,eAAA,aAAA,IAAA,MAAA,SAAA,yBAAA,KAAA,eAAA,OAAA,OAAA,OAAA,MAAA,aAAA,cAAA,iWAAA,IAAA,MAAA,QAAA,aAAA;;;;qBAmE1E,2BAAwB;;WAEF;WACX;kBAqGtB,OAAA,OAAA,sBAAA,iWAAA,MAAA,QAAA,OAAA,UAAA,OAAA;iBAEe,iCAAiC,mBAAmB,KACjE,yBAAyB;WAGhB;;WAEA,MAAM,OAAO;aAEL,SAAS;aACT,UAAU;aACV,UAAU;aACV,SAAS;aACT,kBAAkB,OAAO,aAAa;KAEnD,cACA,IAAI,MAAM;;;;;qBAOL,4BAA8E,GAAC,SAAA,iCAAA,OAAA,OAAA,kBAAA,kWAAA,aAAA,aAAA,uBAAA,QAAA,GAAA,MAAA"}
1
+ {"version":3,"file":"rpcWorker.d.ts","names":[],"sources":["../src/rpcWorker.ts"],"mappings":";;;;;;;;;;;;qBA0Ba,sBAAyE,GAAC,SAAA,OAAA,OAAA,eAAA,aAAA,IAAA,MAAA,SAAA,yBAAA,KAAA,eAAA,OAAA,OAAA,OAAA,MAAA,aAAA,cAAA,iWAAA,IAAA,MAAA,QAAA,aAAA;;;;qBAmE1E,2BAAwB;;WAEF;WACX;kBAsGtB,OAAA,OAAA,sBAAA,iWAAA,MAAA,QAAA,OAAA,UAAA,OAAA;iBAEe,iCAAiC,mBAAmB,KACjE,yBAAyB;WAGhB;;WAEA,MAAM,OAAO;aAEL,SAAS;aACT,UAAU;aACV,UAAU;aACV,SAAS;aACT,kBAAkB,OAAO,aAAa;KAEnD,cACA,IAAI,MAAM;;;;;qBAOL,4BAA8E,GAAC,SAAA,iCAAA,OAAA,OAAA,kBAAA,kWAAA,aAAA,aAAA,uBAAA,QAAA,GAAA,MAAA"}
package/lib/rpcWorker.js CHANGED
@@ -90,7 +90,10 @@ const makeOntologyWorkerClient = Effect.fn("OntologyClient.worker")(function* (o
90
90
  return { ontology: Effect.fn("OntologyClient.select")(function* (selected, clientOptions) {
91
91
  const name = selected ?? options?.ontology;
92
92
  const client = name === void 0 ? rpc : selectOntology(rpc, name);
93
- return yield* makeOntologyProtocolClient(client, clientOptions);
93
+ return yield* makeOntologyProtocolClient(client, {
94
+ ...clientOptions,
95
+ networks: []
96
+ });
94
97
  }) };
95
98
  }), connectionScope).pipe(Effect.onExit((exit) => Exit.isFailure(exit) ? Scope.close(connectionScope, exit) : Effect.void));
96
99
  });