@party-stack/ontology-backend 0.6.0 → 0.7.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/description.d.ts +2 -1
- package/lib/description.d.ts.map +1 -1
- package/lib/description.js +2 -1
- package/lib/description.js.map +1 -1
- package/lib/index.d.ts +7 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/meta.d.ts.map +1 -1
- package/lib/meta.js +3 -3
- package/lib/meta.js.map +1 -1
- package/lib/owned.d.ts.map +1 -1
- package/lib/owned.js +2 -1
- package/lib/owned.js.map +1 -1
- package/lib/storage.d.ts +1 -0
- package/lib/storage.d.ts.map +1 -1
- package/package.json +3 -3
package/lib/description.d.ts
CHANGED
|
@@ -23,7 +23,8 @@ export declare const OntologyDescriptionCodec: Schema.Struct<{
|
|
|
23
23
|
readonly watchSubset: Schema.optional<Schema.Boolean>;
|
|
24
24
|
readonly actionParameterResolution: Schema.optional<Schema.Boolean>;
|
|
25
25
|
readonly queries: Schema.optional<Schema.Boolean>;
|
|
26
|
-
|
|
26
|
+
/** The endpoint serves its system ontology (downloads and replica status) as the `system` resource. */
|
|
27
|
+
readonly system: Schema.optional<Schema.Boolean>;
|
|
27
28
|
/** The definition is also served as meta ontology rows on the `meta` resource. */
|
|
28
29
|
readonly meta: Schema.optional<Schema.Boolean>;
|
|
29
30
|
readonly attachments: Schema.optional<Schema.Struct<{
|
package/lib/description.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"description.d.ts","names":[],"sources":["../src/description.ts"],"mappings":";;;;qBAKa,0BAAwB,OAAA
|
|
1
|
+
{"version":3,"file":"description.d.ts","names":[],"sources":["../src/description.ts"],"mappings":";;;;qBAKa,0BAAwB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YA0BzB,6BAA6B,yBAAyB;;qBAErD"}
|
package/lib/description.js
CHANGED
|
@@ -22,7 +22,8 @@ const OntologyDescriptionCodec = Schema.Struct({
|
|
|
22
22
|
watchSubset: Schema.optional(Schema.Boolean),
|
|
23
23
|
actionParameterResolution: Schema.optional(Schema.Boolean),
|
|
24
24
|
queries: Schema.optional(Schema.Boolean),
|
|
25
|
-
|
|
25
|
+
/** The endpoint serves its system ontology (downloads and replica status) as the `system` resource. */
|
|
26
|
+
system: Schema.optional(Schema.Boolean),
|
|
26
27
|
/** The definition is also served as meta ontology rows on the `meta` resource. */
|
|
27
28
|
meta: Schema.optional(Schema.Boolean),
|
|
28
29
|
attachments: Schema.optional(Schema.Struct({ stage: Schema.Boolean })),
|
package/lib/description.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"description.js","names":[],"sources":["../src/description.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { protocolValueCodec } from \"./protocol.js\";\n\n/** The authenticated binding and capabilities needed to reopen a protocol client. The definition\n * itself is served as meta ontology rows on the `meta` resource; the hashes identify it. */\nexport const OntologyDescriptionCodec = Schema.Struct({\n /** The protocol version. 2 serves the definition on the `meta` resource instead of here;\n * a retained version 1 description is still read, with the definition it was accepted with. */\n version: Schema.Literals([1, 2]),\n replication: Schema.Literals([\"committed\", \"speculative\"]),\n /** Hash of the whole definition the endpoint serves. */\n definitionHash: Schema.optional(Schema.String),\n /** Hash of its contract (without presentation); requests and delivery frames carry it. */\n contractHash: Schema.optional(Schema.String),\n sourceId: Schema.NonEmptyString,\n context: Schema.optional(protocolValueCodec(Schema.Record(Schema.String, Schema.Unknown))),\n supportsIdempotency: Schema.Boolean,\n delivery: Schema.optional(Schema.Boolean),\n stateDelivery: Schema.optional(Schema.Boolean),\n changes: Schema.optional(Schema.Boolean),\n watchChanges: Schema.optional(Schema.Boolean),\n watchSubset: Schema.optional(Schema.Boolean),\n actionParameterResolution: Schema.optional(Schema.Boolean),\n queries: Schema.optional(Schema.Boolean),\n
|
|
1
|
+
{"version":3,"file":"description.js","names":[],"sources":["../src/description.ts"],"sourcesContent":["import { Schema } from \"effect\";\nimport { protocolValueCodec } from \"./protocol.js\";\n\n/** The authenticated binding and capabilities needed to reopen a protocol client. The definition\n * itself is served as meta ontology rows on the `meta` resource; the hashes identify it. */\nexport const OntologyDescriptionCodec = Schema.Struct({\n /** The protocol version. 2 serves the definition on the `meta` resource instead of here;\n * a retained version 1 description is still read, with the definition it was accepted with. */\n version: Schema.Literals([1, 2]),\n replication: Schema.Literals([\"committed\", \"speculative\"]),\n /** Hash of the whole definition the endpoint serves. */\n definitionHash: Schema.optional(Schema.String),\n /** Hash of its contract (without presentation); requests and delivery frames carry it. */\n contractHash: Schema.optional(Schema.String),\n sourceId: Schema.NonEmptyString,\n context: Schema.optional(protocolValueCodec(Schema.Record(Schema.String, Schema.Unknown))),\n supportsIdempotency: Schema.Boolean,\n delivery: Schema.optional(Schema.Boolean),\n stateDelivery: Schema.optional(Schema.Boolean),\n changes: Schema.optional(Schema.Boolean),\n watchChanges: Schema.optional(Schema.Boolean),\n watchSubset: Schema.optional(Schema.Boolean),\n actionParameterResolution: Schema.optional(Schema.Boolean),\n queries: Schema.optional(Schema.Boolean),\n /** The endpoint serves its system ontology (downloads and replica status) as the `system` resource. */\n system: Schema.optional(Schema.Boolean),\n /** The definition is also served as meta ontology rows on the `meta` resource. */\n meta: Schema.optional(Schema.Boolean),\n attachments: Schema.optional(Schema.Struct({ stage: Schema.Boolean })),\n encrypted: Schema.optional(Schema.Boolean),\n});\nexport type OntologyDescription = typeof OntologyDescriptionCodec.Type;\n/** The protocol version servers describe and clients require from a fresh description. */\nexport const ontologyProtocolVersion = 2 as const;\n"],"mappings":";;;;;AAKA,MAAa,2BAA2B,OAAO,OAAO;;;CAGlD,SAAS,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;CAC/B,aAAa,OAAO,SAAS,CAAC,aAAa,aAAa,CAAC;;CAEzD,gBAAgB,OAAO,SAAS,OAAO,MAAM;;CAE7C,cAAc,OAAO,SAAS,OAAO,MAAM;CAC3C,UAAU,OAAO;CACjB,SAAS,OAAO,SAAS,mBAAmB,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO,CAAC,CAAC;CACzF,qBAAqB,OAAO;CAC5B,UAAU,OAAO,SAAS,OAAO,OAAO;CACxC,eAAe,OAAO,SAAS,OAAO,OAAO;CAC7C,SAAS,OAAO,SAAS,OAAO,OAAO;CACvC,cAAc,OAAO,SAAS,OAAO,OAAO;CAC5C,aAAa,OAAO,SAAS,OAAO,OAAO;CAC3C,2BAA2B,OAAO,SAAS,OAAO,OAAO;CACzD,SAAS,OAAO,SAAS,OAAO,OAAO;;CAEvC,QAAQ,OAAO,SAAS,OAAO,OAAO;;CAEtC,MAAM,OAAO,SAAS,OAAO,OAAO;CACpC,aAAa,OAAO,SAAS,OAAO,OAAO,EAAE,OAAO,OAAO,QAAQ,CAAC,CAAC;CACrE,WAAW,OAAO,SAAS,OAAO,OAAO;AAC7C,CAAC;;AAGD,MAAa,0BAA0B"}
|
package/lib/index.d.ts
CHANGED
|
@@ -260,6 +260,13 @@ export interface OntologyBackendService {
|
|
|
260
260
|
* Merely receiving an ID, or an action being naturally idempotent, is insufficient.
|
|
261
261
|
*/
|
|
262
262
|
readonly supportsIdempotency: boolean;
|
|
263
|
+
/**
|
|
264
|
+
* The networks this source is on, such as `"internet"`: its replica syncs while a device link
|
|
265
|
+
* reaching one of them is available (the runtime's `links`). Omitted means the internet. A
|
|
266
|
+
* source on the same device (in the same process, a worker or a message port) is on none, so
|
|
267
|
+
* its replicas sync whatever the device's links report.
|
|
268
|
+
*/
|
|
269
|
+
readonly networks?: readonly string[];
|
|
263
270
|
/** Indexed bounded local maintenance; the backend owner schedules it. */
|
|
264
271
|
readonly maintenance?: Effect.Effect<void, BackendError>;
|
|
265
272
|
/** Return the request or explicitly describe the region actually fulfilled.
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["_$__encrypted_js0.DecryptedValue","_$__delivery_js0.DeliveryPolicy","_$__delivery_js0.DeliveryPosition","_$__delivery_js0.DeliverySubscription","_$__errors_js0.ValidationReport"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;iBAuCiB;WACJ,kBAAkB;;iBAEd;;;;;;;WAOJ,kBAAkB;WAClB,eAAe,IAAI;;WAEnB;;;;WAIA;;WAEA,WAAW;;WAEX;;qBAEA,uBAAqB,OAAA;;;;;;;;;;;;;;;;YAetB,kBAAkB,OAAO,OAAO,YAAY;YAC5C;WAEO;WACA;WACA,KAAK;WACL,OAAO;;WAET;WAAyB;WAA6B,KAAK;;iBAC3D;WACJ;WACA,kBAAkB;WAClB;;iBAEI;WACJ,kBAAkB;WAClB;WACA;;iBAEI;WACJ,YAAY;WACZ,MAAM;WACN,SAAS;;iBAEL;;WAEJ;WACA;WACA,YAAY;WACZ,6BAA6B;;WAE7B;aAAoB;aAAsB;;;iBAEtC;;WAEJ;;WAEA;;WAEA;WACA;;WAEA;;;;;;WAMA;aACI;aACA,gBAAgB;;;;;WAKpB;WACA;aAA2C;aAA0B;;;qBAGrE,oBAAkB,OAAA,gBAAA,OAAA;;;;;;;;;;qBASlB,qBAAmB,OAAA;;;;;;;;;;;;;;;;qBAgBnB,qBAAmB,OAAA;;;;;;;;;;;;;;qBAKnB,uBAAqB,OAAA;;;;;;;;;;;;;;;;;;;;;;;;;;qBAUrB,yBAAuB,OAAA;;;;;;;;;;;;;;;;;;iBAMnB;;WAEJ,SACL,OAAO,YACP,OAAO,WACP;aAAqB,SAAS;QAC7B,OAAO,OAAO,YAAY;;WAEtB,OACL,OAAO,YACP;aAAqB;aAA0B;QAC9C,OAAO,OAAO,WAAW,cAAc,MAAM;WACzC,WACL,OAAO,YACP;aAAqB;QACpB,OAAO;aAEK;aACA;aACA;aACA;eAAwB;eAAwB;;KAE7D;;iBAWS;;WAEJ,UACL,OAAO,uBACN,OAAO,OADDA,gBACiD;;;;;;;;YAQpD;WACK;WAAsB,KAAK;WAAc,OAAO;;WAChD;WAAuB,KAAK;;WAC5B;WAAyB,KAAK;;;;;;;;YAOnC;WAA+C,kBAAkB;;iBAE5D;WACJ;;WAEA;;;;;;WAMA;;WAEA,cAAc,OAAO,aAAa;;;;WAIlC,aAAa,QAAQ,iBAAiB,OAAO,OAAO,iBAAiB;;;;;WAKrE,QACL,UAAU,eACV;aAAqB,SAAS;QAC7B,OAAO,OAAO,yBAAyB;;WAEnC,sBACL,WAAW,iBACX,SADWC,gBAEX,SADiCC,qBAEhC,OAAO,OADyBC,sBAC4B,cAAc,MAAM;WAC5E,uBACL,UAFQD,qBAGP,OAAO,aAAa;;WAEhB,2BACL,cACA,YAAY,4BACX,OAAO,OAAO,yBAAyB;;;;;;;;;WASnC,eACL,QAAQ,iBACP,OAAO,OAAO,OAAO,OAAO,kBAAkB,eAAe,cAAc,MAAM;;;WAG7E,WAAW,QAAQ;aAET;aACA;;WAGV,kBACL,cACA,YAAY,yBACZ;aAAqB;QACpB,OAAO,OAFIE,kBAE2C;WAClD,cAAc,YAAY,kBAAkB,OAAO,OAAO,eAAe;WACzE,gBACL,cACA,YAAY,4BACX,OAAO,gBAAgB;WACnB;aACI,OAAO;eACH;eACA;UACP,OAAO,OAAO,mBAAmB;;;;aAI9B,QAAQ,OAAO,OAAO,OAAO,aAAa,eAAe,cAAc,MAAM;;WAEjF,cAAc;WACd,YAAY;;;;qBAIZ,wBAAwB"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["_$__encrypted_js0.DecryptedValue","_$__delivery_js0.DeliveryPolicy","_$__delivery_js0.DeliveryPosition","_$__delivery_js0.DeliverySubscription","_$__errors_js0.ValidationReport"],"sources":["../src/index.ts"],"mappings":";;;;;;;;;;;iBAuCiB;WACJ,kBAAkB;;iBAEd;;;;;;;WAOJ,kBAAkB;WAClB,eAAe,IAAI;;WAEnB;;;;WAIA;;WAEA,WAAW;;WAEX;;qBAEA,uBAAqB,OAAA;;;;;;;;;;;;;;;;YAetB,kBAAkB,OAAO,OAAO,YAAY;YAC5C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AEhC,OAAO,OADyBC,sBAC4B,cAAc,MAAM;WAC5E,uBACL,UAFQD,qBAGP,OAAO,aAAa;;WAEhB,2BACL,cACA,YAAY,4BACX,OAAO,OAAO,yBAAyB;;;;;;;;;WASnC,eACL,QAAQ,iBACP,OAAO,OAAO,OAAO,OAAO,kBAAkB,eAAe,cAAc,MAAM;;;WAG7E,WAAW,QAAQ;aAET;aACA;;WAGV,kBACL,cACA,YAAY,yBACZ;aAAqB;QACpB,OAAO,OAFIE,kBAE2C;WAClD,cAAc,YAAY,kBAAkB,OAAO,OAAO,eAAe;WACzE,gBACL,cACA,YAAY,4BACX,OAAO,gBAAgB;WACnB;aACI,OAAO;eACH;eACA;UACP,OAAO,OAAO,mBAAmB;;;;aAI9B,QAAQ,OAAO,OAAO,OAAO,aAAa,eAAe,cAAc,MAAM;;WAEjF,cAAc;WACd,YAAY;;;;qBAIZ,wBAAwB"}
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\nimport { ObjectSubsetSchema } from \"./subsetSchema.js\";\nimport type { AttachmentTypeDef, QueryDocument } from \"@party-stack/ontology-spec\";\nimport type { ObjectSubset } from \"@party-stack/ontology-spec/query\";\nimport type { attachment, Encrypted } from \"@party-stack/ontology-spec/values\";\nimport type { Key, Row } from \"@party-stack/ontology-storage\";\nimport type { ByteInput } from \"@party-stack/ontology-storage/blobs\";\nimport type { Scope, Effect, Stream } from \"effect\";\n\nexport {\n schemaValidationIssues,\n BackendError,\n BackendErrorKindSchema,\n backendErrorStatus,\n ValidationIssueSchema,\n ValidationReportSchema,\n unauthenticated,\n isUnauthenticatedError,\n classifyBackendFailure,\n projectBackendError,\n projectValidationIssue,\n isUnknownActionOutcome,\n} from \"./errors.js\";\nexport type {\n BackendErrorKind,\n ReplicationErrorKind,\n ReplicationError,\n ErrorProjection,\n ErrorProjectionContext,\n ValidationReport,\n ValidationIssue,\n UnauthenticatedError,\n ApplyActionError,\n ValidateActionError,\n LoadSubsetError,\n} from \"./errors.js\";\nimport { BackendError } from \"./errors.js\";\nexport { makeOntologyBackend } from \"./query.js\";\n\nexport interface ObjectSelection {\n readonly subsets: readonly ObjectSubset[];\n}\nexport interface BackendSnapshot {\n /** Region represented by these rows, including any window already applied.\n * Omitted means the requested subset. A broader unwindowed region lets the\n * engine finish filtering/ordering/windowing and optionally cache extra objects.\n * Rows may include residual candidates outside this region; consumers discard\n * them before installing its objects or recording complete coverage.\n */\n readonly fulfilledSubset?: ObjectSubset;\n readonly rows: readonly Row<Record<string, unknown>>[];\n /** Complete for fulfilledSubset (or the request when omitted), including its window. */\n readonly complete: boolean;\n /** Rows fetched from the provider, before adapter-side filtering/windowing.\n * Diagnostic only; omitted when the adapter cannot report it. Not a DB scan count.\n */\n readonly fetchedRows?: number;\n /** Diagnostic provider filter, not a query-capability or coverage contract. */\n readonly pushdown?: SourceQueryPlan;\n /** Position coordinated with this snapshot, when the backend exposes a durable change stream. */\n readonly cursor?: string;\n}\nexport const SourceQueryPlanSchema = Schema.Struct({\n source: Schema.String,\n /** Paths into the request's portable where tree: AND/OR child indices, NOT child 0, [] for the root. */\n predicates: Schema.Array(\n Schema.Struct({\n path: Schema.Array(Schema.Int),\n execution: Schema.Literals([\"source\", \"candidate\", \"adapter\", \"engine\"]),\n })\n ),\n sorting: Schema.Literals([\"source\", \"adapter\", \"engine\", \"none\"]),\n pagination: Schema.Literals([\"source\", \"adapter\", \"engine\", \"none\"]),\n rechecksFilter: Schema.Boolean,\n /** Optional native syntax for raw inspection. Consumers must not parse it to infer execution. */\n native: Schema.optional(Schema.Struct({ language: Schema.String, text: Schema.String })),\n});\nexport type SourceQueryPlan = Schema.Schema.Type<typeof SourceQueryPlanSchema>;\nexport type ObjectChange =\n | {\n readonly kind: \"put\";\n readonly objectType: string;\n readonly key: Key;\n readonly value: Record<string, unknown>;\n }\n | { readonly kind: \"delete\"; readonly objectType: string; readonly key: Key };\nexport interface BackendCommit {\n readonly cursor: string;\n readonly changes: readonly ObjectChange[];\n readonly operationId?: string;\n}\nexport interface BackendChangePage {\n readonly commits: readonly BackendCommit[];\n readonly cursor: string;\n readonly hasMore: boolean;\n}\nexport interface AttachmentUpload {\n readonly attachment: attachment;\n readonly blob: ByteInput;\n readonly target?: AttachmentTypeDef;\n}\nexport interface ActionRequest {\n /** Stable across retries. The source must separately guarantee keyed idempotency. */\n readonly id: string;\n readonly name: string;\n readonly parameters: Record<string, unknown>;\n readonly attachmentUploads?: readonly AttachmentUpload[];\n /** Portable replay inputs, preserved across rebases, forwarding and authoritative execution. */\n readonly replay?: { readonly now: string; readonly seed: string };\n}\nexport interface ActionReceipt {\n /** The submitted ActionRequest.id, also supplied as the application's idempotencyKey. */\n readonly operationId: string;\n /** Provider commitment is recorded before local read-back/reconciliation. Parent acceptance is separate. */\n readonly outcome: \"committed\";\n /** Encoded authoritative return value, interpreted using the action returnType. Never a journal payload. */\n readonly result?: unknown;\n readonly cursor?: string;\n /** Optional upstream execution ID. Never substitutes for our stable retry identity. */\n readonly providerOperationId?: string;\n /** Read-back targets for a committed non-journal action. Missing keys\n * means the whole type; an empty list means no modeled object changes.\n * Omission conservatively refreshes every modeled type.\n * Targets are complete unless affectedComplete is explicitly false.\n */\n readonly affected?: readonly {\n readonly objectType: string;\n readonly keys?: readonly Key[];\n }[];\n /** False when these are known targets but automation may have changed other\n * modeled records. Confirmation must not use them as an exhaustive edit list.\n */\n readonly affectedComplete?: boolean;\n readonly attachmentIdMappings?: readonly { readonly localId: string; readonly remoteId: string }[];\n}\nconst KeySchema = Schema.Union([Schema.String, Schema.Finite]);\nexport const ObjectChangeSchema = Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"put\"),\n objectType: Schema.String,\n key: KeySchema,\n value: Schema.Record(Schema.String, Schema.Unknown),\n }),\n Schema.Struct({ kind: Schema.Literal(\"delete\"), objectType: Schema.String, key: KeySchema }),\n]);\nexport const ActionReceiptSchema = Schema.Struct({\n operationId: Schema.String,\n outcome: Schema.Literal(\"committed\"),\n result: Schema.optional(Schema.Unknown),\n cursor: Schema.optional(Schema.String),\n providerOperationId: Schema.optional(Schema.String),\n affected: Schema.optional(\n Schema.Array(\n Schema.Struct({ objectType: Schema.String, keys: Schema.optional(Schema.Array(KeySchema)) })\n )\n ),\n affectedComplete: Schema.optional(Schema.Boolean),\n attachmentIdMappings: Schema.optional(\n Schema.Array(Schema.Struct({ localId: Schema.String, remoteId: Schema.String }))\n ),\n});\nexport const BackendCommitSchema = Schema.Struct({\n cursor: Schema.String,\n changes: Schema.Array(ObjectChangeSchema),\n operationId: Schema.optional(Schema.String),\n});\nexport const BackendSnapshotSchema = Schema.Struct({\n fulfilledSubset: Schema.optional(ObjectSubsetSchema),\n fetchedRows: Schema.optional(Schema.Number),\n pushdown: Schema.optional(SourceQueryPlanSchema),\n rows: Schema.Array(\n Schema.Struct({ key: KeySchema, value: Schema.Record(Schema.String, Schema.Unknown) })\n ),\n complete: Schema.Boolean,\n cursor: Schema.optional(Schema.String),\n});\nexport const BackendChangePageSchema = Schema.Struct({\n commits: Schema.Array(BackendCommitSchema),\n cursor: Schema.String,\n hasMore: Schema.Boolean,\n});\n\nexport interface BackendAttachments {\n /** Optional authoritative staging before a subsequent action references the handle. */\n readonly stage?: (\n value: attachment,\n bytes: ByteInput,\n options?: { readonly target?: AttachmentTypeDef }\n ) => Effect.Effect<attachment, BackendError>;\n /** Keep the caller Scope open through consumption; closing it cancels an unconsumed download too. */\n readonly read: (\n value: attachment,\n options?: { readonly offset?: number; readonly length?: number }\n ) => Effect.Effect<ByteInput, BackendError, Scope.Scope>;\n readonly metadata: (\n value: attachment,\n options?: { readonly select?: readonly (\"size\" | \"type\" | \"name\" | \"dimensions\")[] }\n ) => Effect.Effect<\n {\n readonly size?: number;\n readonly type?: string;\n readonly name?: string;\n readonly dimensions?: { readonly width: number; readonly height: number };\n },\n BackendError\n >;\n}\nexport {\n EncryptedValueSchema,\n DecryptedValueSchema,\n encryptedPropertyCodec,\n makePropertyDecryption,\n} from \"./encrypted.js\";\nexport type { DecryptedValue } from \"./encrypted.js\";\n\nexport interface BackendEncryptedValues {\n /** Explicit operation. Ordinary record loads return handles and never decrypt them. */\n readonly decrypt: (\n value: Encrypted<unknown>\n ) => Effect.Effect<import(\"./encrypted.js\").DecryptedValue, BackendError>;\n}\n/** One object a watch reports, in the watched subset's object type.\n * - `put`: the object is now in the subset with this complete value.\n * - `exit`: the object left the subset. It may have changed or been deleted; the\n * replica reads it back by primary key to tell which.\n * - `delete`: the object no longer exists anywhere.\n */\nexport type SubsetWatchChange =\n | { readonly kind: \"put\"; readonly key: Key; readonly value: Record<string, unknown> }\n | { readonly kind: \"exit\"; readonly key: Key }\n | { readonly kind: \"delete\"; readonly key: Key };\n/** A reset requests repair after starting/restarting a watch; it does not\n * assert that data changed. Ordinary void hints always invalidate coverage.\n * `changes` describes exactly what changed, so the replica can apply it without\n * reloading the subset. Report only what is certain: a `put` must carry every\n * property; anything less precise must be an invalidation hint instead.\n */\nexport type SubsetWatchEvent = void | \"reset\" | { readonly changes: readonly SubsetWatchChange[] };\n\nexport interface OntologyBackendService {\n readonly name: string;\n /** Stable identity for the source whose cursors and receipts this binding returns. */\n readonly sourceId: string;\n /** Durable keyed idempotency within the configured receipt-retention window:\n * repeated IDs return the recorded result, with\n * conflicting payloads rejected. The guarantee must survive source restart.\n * Merely receiving an ID, or an action being naturally idempotent, is insufficient.\n */\n readonly supportsIdempotency: boolean;\n /** Indexed bounded local maintenance; the backend owner schedules it. */\n readonly maintenance?: Effect.Effect<void, BackendError>;\n /** Return the request or explicitly describe the region actually fulfilled.\n * Consumers use the shared subset normalizer before applying requested windows.\n */\n readonly loadSubset: (subset: ObjectSubset) => Effect.Effect<BackendSnapshot, BackendError>;\n /** Finite Query IR execution using this binding's trusted context and read path.\n * Provider adapters may evaluate through subset loads; owned storage uses one\n * read transaction. Callers supply query inputs, never authentication context.\n */\n readonly query: (\n document: QueryDocument,\n options?: { readonly inputs?: Record<string, unknown> }\n ) => Effect.Effect<Record<string, unknown>, BackendError>;\n /** Optional selected committed rows. Closing the Scope releases demand; delivery state expires by policy. */\n readonly subscribeSelection?: (\n selection: ObjectSelection,\n policy?: import(\"./delivery.js\").DeliveryPolicy,\n resume?: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<import(\"./delivery.js\").DeliverySubscription, BackendError, Scope.Scope>;\n readonly acknowledgeDelivery?: (\n position: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<void, BackendError>;\n /** Read-only defaults and edit prefills; never invokes the action. */\n readonly resolveActionParameters?: (\n name: string,\n parameters: Record<string, unknown>\n ) => Effect.Effect<Record<string, unknown>, BackendError>;\n /** Acquire a demand-scoped watch before reading its snapshot. Completion proves\n * registration and buffering are active, even before the returned stream is pulled.\n * The acquiring Scope owns registration and release. Undefined means polling.\n * Reconnect within the same stream must fail or emit reset/invalidation;\n * reacquisition establishes a new readiness boundary for a fresh read.\n * Must cover every change relevant to the requested subset; broader watches\n * may emit extra hints. It does not maintain broader fulfilledSubset coverage.\n */\n readonly watchSubset?: (\n subset: ObjectSubset\n ) => Effect.Effect<Stream.Stream<SubsetWatchEvent, BackendError>, BackendError, Scope.Scope> | undefined;\n /** Recommended demand refresh defaults. Caller configuration wins; healthy\n * watches/journals keep coverage current independently of snapshot age. */\n readonly refresh?: (subset: ObjectSubset) =>\n | {\n readonly pollIntervalMs?: number | false;\n readonly maxCoverageAgeMs?: number;\n }\n | undefined;\n readonly validateAction?: (\n name: string,\n parameters: Record<string, unknown>,\n options?: { readonly knownParameters?: readonly string[] }\n ) => Effect.Effect<import(\"./errors.js\").ValidationReport, BackendError>;\n readonly applyAction: (invocation: ActionRequest) => Effect.Effect<ActionReceipt, BackendError>;\n readonly queryFunction: (\n name: string,\n parameters: Record<string, unknown>\n ) => Effect.Effect<unknown, BackendError>;\n readonly changes?: {\n readonly pull: (options: {\n readonly cursor?: string;\n readonly limit?: number;\n }) => Effect.Effect<BackendChangePage, BackendError>;\n /** Acquire registered, buffered wake-up hints in the caller's Scope before\n * pulling durable changes. Stream consumption does not initiate registration.\n * Call pull to recover changes after reconnect or restart. */\n readonly watch?: Effect.Effect<Stream.Stream<void, BackendError>, BackendError, Scope.Scope>;\n };\n readonly attachments?: BackendAttachments;\n readonly encrypted?: BackendEncryptedValues;\n}\n\n/** Backend protocol independent of TanStack collections and client lifecycle management. */\nexport class OntologyBackend extends Context.Service<OntologyBackend, OntologyBackendService>()(\n \"@party-stack/ontology-backend/OntologyBackend\"\n) {}\n"],"mappings":";;;;;;AA8DA,MAAa,wBAAwB,OAAO,OAAO;CAC/C,QAAQ,OAAO;;CAEf,YAAY,OAAO,MACf,OAAO,OAAO;EACV,MAAM,OAAO,MAAM,OAAO,GAAG;EAC7B,WAAW,OAAO,SAAS;GAAC;GAAU;GAAa;GAAW;EAAQ,CAAC;CAC3E,CAAC,CACL;CACA,SAAS,OAAO,SAAS;EAAC;EAAU;EAAW;EAAU;CAAM,CAAC;CAChE,YAAY,OAAO,SAAS;EAAC;EAAU;EAAW;EAAU;CAAM,CAAC;CACnE,gBAAgB,OAAO;;CAEvB,QAAQ,OAAO,SAAS,OAAO,OAAO;EAAE,UAAU,OAAO;EAAQ,MAAM,OAAO;CAAO,CAAC,CAAC;AAC3F,CAAC;AA2DD,MAAM,YAAY,OAAO,MAAM,CAAC,OAAO,QAAQ,OAAO,MAAM,CAAC;AAC7D,MAAa,qBAAqB,OAAO,MAAM,CAC3C,OAAO,OAAO;CACV,MAAM,OAAO,QAAQ,KAAK;CAC1B,YAAY,OAAO;CACnB,KAAK;CACL,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;AACtD,CAAC,GACD,OAAO,OAAO;CAAE,MAAM,OAAO,QAAQ,QAAQ;CAAG,YAAY,OAAO;CAAQ,KAAK;AAAU,CAAC,CAC/F,CAAC;AACD,MAAa,sBAAsB,OAAO,OAAO;CAC7C,aAAa,OAAO;CACpB,SAAS,OAAO,QAAQ,WAAW;CACnC,QAAQ,OAAO,SAAS,OAAO,OAAO;CACtC,QAAQ,OAAO,SAAS,OAAO,MAAM;CACrC,qBAAqB,OAAO,SAAS,OAAO,MAAM;CAClD,UAAU,OAAO,SACb,OAAO,MACH,OAAO,OAAO;EAAE,YAAY,OAAO;EAAQ,MAAM,OAAO,SAAS,OAAO,MAAM,SAAS,CAAC;CAAE,CAAC,CAC/F,CACJ;CACA,kBAAkB,OAAO,SAAS,OAAO,OAAO;CAChD,sBAAsB,OAAO,SACzB,OAAO,MAAM,OAAO,OAAO;EAAE,SAAS,OAAO;EAAQ,UAAU,OAAO;CAAO,CAAC,CAAC,CACnF;AACJ,CAAC;AACD,MAAa,sBAAsB,OAAO,OAAO;CAC7C,QAAQ,OAAO;CACf,SAAS,OAAO,MAAM,kBAAkB;CACxC,aAAa,OAAO,SAAS,OAAO,MAAM;AAC9C,CAAC;AACD,MAAa,wBAAwB,OAAO,OAAO;CAC/C,iBAAiB,OAAO,SAAS,kBAAkB;CACnD,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,UAAU,OAAO,SAAS,qBAAqB;CAC/C,MAAM,OAAO,MACT,OAAO,OAAO;EAAE,KAAK;EAAW,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;CAAE,CAAC,CACzF;CACA,UAAU,OAAO;CACjB,QAAQ,OAAO,SAAS,OAAO,MAAM;AACzC,CAAC;AACD,MAAa,0BAA0B,OAAO,OAAO;CACjD,SAAS,OAAO,MAAM,mBAAmB;CACzC,QAAQ,OAAO;CACf,SAAS,OAAO;AACpB,CAAC;;AA6ID,IAAa,kBAAb,cAAqC,QAAQ,QAAiD,CAAC,CAC3F,+CACJ,CAAC,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { Context, Schema } from \"effect\";\nimport { ObjectSubsetSchema } from \"./subsetSchema.js\";\nimport type { AttachmentTypeDef, QueryDocument } from \"@party-stack/ontology-spec\";\nimport type { ObjectSubset } from \"@party-stack/ontology-spec/query\";\nimport type { attachment, Encrypted } from \"@party-stack/ontology-spec/values\";\nimport type { Key, Row } from \"@party-stack/ontology-storage\";\nimport type { ByteInput } from \"@party-stack/ontology-storage/blobs\";\nimport type { Scope, Effect, Stream } from \"effect\";\n\nexport {\n schemaValidationIssues,\n BackendError,\n BackendErrorKindSchema,\n backendErrorStatus,\n ValidationIssueSchema,\n ValidationReportSchema,\n unauthenticated,\n isUnauthenticatedError,\n classifyBackendFailure,\n projectBackendError,\n projectValidationIssue,\n isUnknownActionOutcome,\n} from \"./errors.js\";\nexport type {\n BackendErrorKind,\n ReplicationErrorKind,\n ReplicationError,\n ErrorProjection,\n ErrorProjectionContext,\n ValidationReport,\n ValidationIssue,\n UnauthenticatedError,\n ApplyActionError,\n ValidateActionError,\n LoadSubsetError,\n} from \"./errors.js\";\nimport { BackendError } from \"./errors.js\";\nexport { makeOntologyBackend } from \"./query.js\";\n\nexport interface ObjectSelection {\n readonly subsets: readonly ObjectSubset[];\n}\nexport interface BackendSnapshot {\n /** Region represented by these rows, including any window already applied.\n * Omitted means the requested subset. A broader unwindowed region lets the\n * engine finish filtering/ordering/windowing and optionally cache extra objects.\n * Rows may include residual candidates outside this region; consumers discard\n * them before installing its objects or recording complete coverage.\n */\n readonly fulfilledSubset?: ObjectSubset;\n readonly rows: readonly Row<Record<string, unknown>>[];\n /** Complete for fulfilledSubset (or the request when omitted), including its window. */\n readonly complete: boolean;\n /** Rows fetched from the provider, before adapter-side filtering/windowing.\n * Diagnostic only; omitted when the adapter cannot report it. Not a DB scan count.\n */\n readonly fetchedRows?: number;\n /** Diagnostic provider filter, not a query-capability or coverage contract. */\n readonly pushdown?: SourceQueryPlan;\n /** Position coordinated with this snapshot, when the backend exposes a durable change stream. */\n readonly cursor?: string;\n}\nexport const SourceQueryPlanSchema = Schema.Struct({\n source: Schema.String,\n /** Paths into the request's portable where tree: AND/OR child indices, NOT child 0, [] for the root. */\n predicates: Schema.Array(\n Schema.Struct({\n path: Schema.Array(Schema.Int),\n execution: Schema.Literals([\"source\", \"candidate\", \"adapter\", \"engine\"]),\n })\n ),\n sorting: Schema.Literals([\"source\", \"adapter\", \"engine\", \"none\"]),\n pagination: Schema.Literals([\"source\", \"adapter\", \"engine\", \"none\"]),\n rechecksFilter: Schema.Boolean,\n /** Optional native syntax for raw inspection. Consumers must not parse it to infer execution. */\n native: Schema.optional(Schema.Struct({ language: Schema.String, text: Schema.String })),\n});\nexport type SourceQueryPlan = Schema.Schema.Type<typeof SourceQueryPlanSchema>;\nexport type ObjectChange =\n | {\n readonly kind: \"put\";\n readonly objectType: string;\n readonly key: Key;\n readonly value: Record<string, unknown>;\n }\n | { readonly kind: \"delete\"; readonly objectType: string; readonly key: Key };\nexport interface BackendCommit {\n readonly cursor: string;\n readonly changes: readonly ObjectChange[];\n readonly operationId?: string;\n}\nexport interface BackendChangePage {\n readonly commits: readonly BackendCommit[];\n readonly cursor: string;\n readonly hasMore: boolean;\n}\nexport interface AttachmentUpload {\n readonly attachment: attachment;\n readonly blob: ByteInput;\n readonly target?: AttachmentTypeDef;\n}\nexport interface ActionRequest {\n /** Stable across retries. The source must separately guarantee keyed idempotency. */\n readonly id: string;\n readonly name: string;\n readonly parameters: Record<string, unknown>;\n readonly attachmentUploads?: readonly AttachmentUpload[];\n /** Portable replay inputs, preserved across rebases, forwarding and authoritative execution. */\n readonly replay?: { readonly now: string; readonly seed: string };\n}\nexport interface ActionReceipt {\n /** The submitted ActionRequest.id, also supplied as the application's idempotencyKey. */\n readonly operationId: string;\n /** Provider commitment is recorded before local read-back/reconciliation. Parent acceptance is separate. */\n readonly outcome: \"committed\";\n /** Encoded authoritative return value, interpreted using the action returnType. Never a journal payload. */\n readonly result?: unknown;\n readonly cursor?: string;\n /** Optional upstream execution ID. Never substitutes for our stable retry identity. */\n readonly providerOperationId?: string;\n /** Read-back targets for a committed non-journal action. Missing keys\n * means the whole type; an empty list means no modeled object changes.\n * Omission conservatively refreshes every modeled type.\n * Targets are complete unless affectedComplete is explicitly false.\n */\n readonly affected?: readonly {\n readonly objectType: string;\n readonly keys?: readonly Key[];\n }[];\n /** False when these are known targets but automation may have changed other\n * modeled records. Confirmation must not use them as an exhaustive edit list.\n */\n readonly affectedComplete?: boolean;\n readonly attachmentIdMappings?: readonly { readonly localId: string; readonly remoteId: string }[];\n}\nconst KeySchema = Schema.Union([Schema.String, Schema.Finite]);\nexport const ObjectChangeSchema = Schema.Union([\n Schema.Struct({\n kind: Schema.Literal(\"put\"),\n objectType: Schema.String,\n key: KeySchema,\n value: Schema.Record(Schema.String, Schema.Unknown),\n }),\n Schema.Struct({ kind: Schema.Literal(\"delete\"), objectType: Schema.String, key: KeySchema }),\n]);\nexport const ActionReceiptSchema = Schema.Struct({\n operationId: Schema.String,\n outcome: Schema.Literal(\"committed\"),\n result: Schema.optional(Schema.Unknown),\n cursor: Schema.optional(Schema.String),\n providerOperationId: Schema.optional(Schema.String),\n affected: Schema.optional(\n Schema.Array(\n Schema.Struct({ objectType: Schema.String, keys: Schema.optional(Schema.Array(KeySchema)) })\n )\n ),\n affectedComplete: Schema.optional(Schema.Boolean),\n attachmentIdMappings: Schema.optional(\n Schema.Array(Schema.Struct({ localId: Schema.String, remoteId: Schema.String }))\n ),\n});\nexport const BackendCommitSchema = Schema.Struct({\n cursor: Schema.String,\n changes: Schema.Array(ObjectChangeSchema),\n operationId: Schema.optional(Schema.String),\n});\nexport const BackendSnapshotSchema = Schema.Struct({\n fulfilledSubset: Schema.optional(ObjectSubsetSchema),\n fetchedRows: Schema.optional(Schema.Number),\n pushdown: Schema.optional(SourceQueryPlanSchema),\n rows: Schema.Array(\n Schema.Struct({ key: KeySchema, value: Schema.Record(Schema.String, Schema.Unknown) })\n ),\n complete: Schema.Boolean,\n cursor: Schema.optional(Schema.String),\n});\nexport const BackendChangePageSchema = Schema.Struct({\n commits: Schema.Array(BackendCommitSchema),\n cursor: Schema.String,\n hasMore: Schema.Boolean,\n});\n\nexport interface BackendAttachments {\n /** Optional authoritative staging before a subsequent action references the handle. */\n readonly stage?: (\n value: attachment,\n bytes: ByteInput,\n options?: { readonly target?: AttachmentTypeDef }\n ) => Effect.Effect<attachment, BackendError>;\n /** Keep the caller Scope open through consumption; closing it cancels an unconsumed download too. */\n readonly read: (\n value: attachment,\n options?: { readonly offset?: number; readonly length?: number }\n ) => Effect.Effect<ByteInput, BackendError, Scope.Scope>;\n readonly metadata: (\n value: attachment,\n options?: { readonly select?: readonly (\"size\" | \"type\" | \"name\" | \"dimensions\")[] }\n ) => Effect.Effect<\n {\n readonly size?: number;\n readonly type?: string;\n readonly name?: string;\n readonly dimensions?: { readonly width: number; readonly height: number };\n },\n BackendError\n >;\n}\nexport {\n EncryptedValueSchema,\n DecryptedValueSchema,\n encryptedPropertyCodec,\n makePropertyDecryption,\n} from \"./encrypted.js\";\nexport type { DecryptedValue } from \"./encrypted.js\";\n\nexport interface BackendEncryptedValues {\n /** Explicit operation. Ordinary record loads return handles and never decrypt them. */\n readonly decrypt: (\n value: Encrypted<unknown>\n ) => Effect.Effect<import(\"./encrypted.js\").DecryptedValue, BackendError>;\n}\n/** One object a watch reports, in the watched subset's object type.\n * - `put`: the object is now in the subset with this complete value.\n * - `exit`: the object left the subset. It may have changed or been deleted; the\n * replica reads it back by primary key to tell which.\n * - `delete`: the object no longer exists anywhere.\n */\nexport type SubsetWatchChange =\n | { readonly kind: \"put\"; readonly key: Key; readonly value: Record<string, unknown> }\n | { readonly kind: \"exit\"; readonly key: Key }\n | { readonly kind: \"delete\"; readonly key: Key };\n/** A reset requests repair after starting/restarting a watch; it does not\n * assert that data changed. Ordinary void hints always invalidate coverage.\n * `changes` describes exactly what changed, so the replica can apply it without\n * reloading the subset. Report only what is certain: a `put` must carry every\n * property; anything less precise must be an invalidation hint instead.\n */\nexport type SubsetWatchEvent = void | \"reset\" | { readonly changes: readonly SubsetWatchChange[] };\n\nexport interface OntologyBackendService {\n readonly name: string;\n /** Stable identity for the source whose cursors and receipts this binding returns. */\n readonly sourceId: string;\n /** Durable keyed idempotency within the configured receipt-retention window:\n * repeated IDs return the recorded result, with\n * conflicting payloads rejected. The guarantee must survive source restart.\n * Merely receiving an ID, or an action being naturally idempotent, is insufficient.\n */\n readonly supportsIdempotency: boolean;\n /**\n * The networks this source is on, such as `\"internet\"`: its replica syncs while a device link\n * reaching one of them is available (the runtime's `links`). Omitted means the internet. A\n * source on the same device (in the same process, a worker or a message port) is on none, so\n * its replicas sync whatever the device's links report.\n */\n readonly networks?: readonly string[];\n /** Indexed bounded local maintenance; the backend owner schedules it. */\n readonly maintenance?: Effect.Effect<void, BackendError>;\n /** Return the request or explicitly describe the region actually fulfilled.\n * Consumers use the shared subset normalizer before applying requested windows.\n */\n readonly loadSubset: (subset: ObjectSubset) => Effect.Effect<BackendSnapshot, BackendError>;\n /** Finite Query IR execution using this binding's trusted context and read path.\n * Provider adapters may evaluate through subset loads; owned storage uses one\n * read transaction. Callers supply query inputs, never authentication context.\n */\n readonly query: (\n document: QueryDocument,\n options?: { readonly inputs?: Record<string, unknown> }\n ) => Effect.Effect<Record<string, unknown>, BackendError>;\n /** Optional selected committed rows. Closing the Scope releases demand; delivery state expires by policy. */\n readonly subscribeSelection?: (\n selection: ObjectSelection,\n policy?: import(\"./delivery.js\").DeliveryPolicy,\n resume?: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<import(\"./delivery.js\").DeliverySubscription, BackendError, Scope.Scope>;\n readonly acknowledgeDelivery?: (\n position: import(\"./delivery.js\").DeliveryPosition\n ) => Effect.Effect<void, BackendError>;\n /** Read-only defaults and edit prefills; never invokes the action. */\n readonly resolveActionParameters?: (\n name: string,\n parameters: Record<string, unknown>\n ) => Effect.Effect<Record<string, unknown>, BackendError>;\n /** Acquire a demand-scoped watch before reading its snapshot. Completion proves\n * registration and buffering are active, even before the returned stream is pulled.\n * The acquiring Scope owns registration and release. Undefined means polling.\n * Reconnect within the same stream must fail or emit reset/invalidation;\n * reacquisition establishes a new readiness boundary for a fresh read.\n * Must cover every change relevant to the requested subset; broader watches\n * may emit extra hints. It does not maintain broader fulfilledSubset coverage.\n */\n readonly watchSubset?: (\n subset: ObjectSubset\n ) => Effect.Effect<Stream.Stream<SubsetWatchEvent, BackendError>, BackendError, Scope.Scope> | undefined;\n /** Recommended demand refresh defaults. Caller configuration wins; healthy\n * watches/journals keep coverage current independently of snapshot age. */\n readonly refresh?: (subset: ObjectSubset) =>\n | {\n readonly pollIntervalMs?: number | false;\n readonly maxCoverageAgeMs?: number;\n }\n | undefined;\n readonly validateAction?: (\n name: string,\n parameters: Record<string, unknown>,\n options?: { readonly knownParameters?: readonly string[] }\n ) => Effect.Effect<import(\"./errors.js\").ValidationReport, BackendError>;\n readonly applyAction: (invocation: ActionRequest) => Effect.Effect<ActionReceipt, BackendError>;\n readonly queryFunction: (\n name: string,\n parameters: Record<string, unknown>\n ) => Effect.Effect<unknown, BackendError>;\n readonly changes?: {\n readonly pull: (options: {\n readonly cursor?: string;\n readonly limit?: number;\n }) => Effect.Effect<BackendChangePage, BackendError>;\n /** Acquire registered, buffered wake-up hints in the caller's Scope before\n * pulling durable changes. Stream consumption does not initiate registration.\n * Call pull to recover changes after reconnect or restart. */\n readonly watch?: Effect.Effect<Stream.Stream<void, BackendError>, BackendError, Scope.Scope>;\n };\n readonly attachments?: BackendAttachments;\n readonly encrypted?: BackendEncryptedValues;\n}\n\n/** Backend protocol independent of TanStack collections and client lifecycle management. */\nexport class OntologyBackend extends Context.Service<OntologyBackend, OntologyBackendService>()(\n \"@party-stack/ontology-backend/OntologyBackend\"\n) {}\n"],"mappings":";;;;;;AA8DA,MAAa,wBAAwB,OAAO,OAAO;CAC/C,QAAQ,OAAO;;CAEf,YAAY,OAAO,MACf,OAAO,OAAO;EACV,MAAM,OAAO,MAAM,OAAO,GAAG;EAC7B,WAAW,OAAO,SAAS;GAAC;GAAU;GAAa;GAAW;EAAQ,CAAC;CAC3E,CAAC,CACL;C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,wBAAwB,OAAO,OAAO;CAC/C,iBAAiB,OAAO,SAAS,kBAAkB;CACnD,aAAa,OAAO,SAAS,OAAO,MAAM;CAC1C,UAAU,OAAO,SAAS,qBAAqB;CAC/C,MAAM,OAAO,MACT,OAAO,OAAO;EAAE,KAAK;EAAW,OAAO,OAAO,OAAO,OAAO,QAAQ,OAAO,OAAO;CAAE,CAAC,CACzF;CACA,UAAU,OAAO;CACjB,QAAQ,OAAO,SAAS,OAAO,MAAM;AACzC,CAAC;AACD,MAAa,0BAA0B,OAAO,OAAO;CACjD,SAAS,OAAO,MAAM,mBAAmB;CACzC,QAAQ,OAAO;CACf,SAAS,OAAO;AACpB,CAAC;;AAoJD,IAAa,kBAAb,cAAqC,QAAQ,QAAiD,CAAC,CAC3F,+CACJ,CAAC,CAAC,CAAC"}
|
package/lib/meta.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","names":[],"sources":["../src/meta.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"meta.d.ts","names":[],"sources":["../src/meta.ts"],"mappings":";;;;;iBAiEiB;;EAEb;EACA;EACA;;EAEA,aAAa,UAAU,eAAe,aAAa,QAAQ;;EAE3D;;;YAGQ,sBAAsB,KAAK;iBAEtB;;WAEJ,UAAU;;;;;WAKV,kBAAkB;;;;;;;;wBAyKf,KACZ,SAAS,KAAK,kCACd,SAAS;WAAyB;IACnC,OAAO,OAAO,YAAY;wBACb,KACZ,SAAS,KAAK,kCACd,UAAU,cACX,OAAO,OAAO,YAAY;;;;qBAYhB,iBAAc,SAAa,KAAK,qCAAgC,OAAA,OAAA,YAAA;iBAE5D;;;WAGJ,WAAW,OAAO,gBAAgB;;;wBAG/B,oBACZ,IAAI,YACJ,UAAS,yBACV;iBA0Ec,mBAAmB,mBAAmB,KAAK;WAC/C;WACA,SAAS,OAAO,OAAO,wBAAwB,cAAc,IAAI,MAAM"}
|
package/lib/meta.js
CHANGED
|
@@ -5,7 +5,7 @@ import { makeOntologyBackend } from "./query.js";
|
|
|
5
5
|
import * as q from "@party-stack/ontology-spec/query";
|
|
6
6
|
import { and, evaluateQuery, field, inArray } from "@party-stack/ontology-storage";
|
|
7
7
|
import { Effect, Stream } from "effect";
|
|
8
|
-
import { omitInvalid, withDefinitionIds, withoutDefaultIds } from "@party-stack/ontology-spec";
|
|
8
|
+
import { cloneDefinition, omitInvalid, withDefinitionIds, withoutDefaultIds } from "@party-stack/ontology-spec";
|
|
9
9
|
import metaOntology from "@party-stack/ontology-spec/meta";
|
|
10
10
|
//#region src/meta.ts
|
|
11
11
|
function getValueTypes(type) {
|
|
@@ -138,7 +138,7 @@ const pullDefinitions = Effect.fn("Metadata.pull")(function* (backend, options =
|
|
|
138
138
|
message: `Pulled ontology is invalid: ${repaired.issues.map((issue) => issue.message).join(" ")}`,
|
|
139
139
|
issues: repaired.issues
|
|
140
140
|
});
|
|
141
|
-
if (repaired.omitted.length) yield* Effect.logWarning("Omitted definitions the Ontology IR cannot represent.").pipe(Effect.annotateLogs({ omitted: repaired.omitted.map((entry) => `${entry.name}${entry.parameter ? `.${entry.parameter}` : ""}`) }));
|
|
141
|
+
if (repaired.omitted.length) yield* Effect.logWarning("Omitted definitions the Ontology IR cannot represent.").pipe(Effect.annotateLogs({ omitted: repaired.omitted.map((entry) => `${entry.name}${entry.parameter ? `.${entry.parameter}` : ""}: ${entry.issues.map((issue) => issue.message).join(" ")}`) }));
|
|
142
142
|
return {
|
|
143
143
|
ontology: repaired.ontology,
|
|
144
144
|
omitted: repaired.omitted
|
|
@@ -154,7 +154,7 @@ function pull(backend, options = {}) {
|
|
|
154
154
|
const loadDefinition = (backend) => pull(backend);
|
|
155
155
|
/** Serve a definition as meta ontology rows. */
|
|
156
156
|
function makeMetadataBackend(ir, options = {}) {
|
|
157
|
-
ir = withDefinitionIds(
|
|
157
|
+
ir = withDefinitionIds(cloneDefinition(ir));
|
|
158
158
|
return makeOntologyBackend({
|
|
159
159
|
ir: metaOntology,
|
|
160
160
|
name: "local-metadata",
|
package/lib/meta.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","names":[],"sources":["../src/meta.ts"],"sourcesContent":["import { omitInvalid, withDefinitionIds, withoutDefaultIds } from \"@party-stack/ontology-spec\";\nimport metaOntology from \"@party-stack/ontology-spec/meta\";\nimport * as q from \"@party-stack/ontology-spec/query\";\nimport { and, inArray, field, evaluateQuery } from \"@party-stack/ontology-storage\";\nimport { Effect, Stream } from \"effect\";\nimport { makeOntologyBackend } from \"./query.js\";\nimport { compileObjectSubset, objectSubset } from \"./subset.js\";\nimport { BackendError } from \"./index.js\";\nimport type { OntologyBackendService, SubsetWatchEvent } from \"./index.js\";\nimport type { OmittedDefinition, OntologyIR } from \"@party-stack/ontology-spec\";\nimport type {\n ActionType,\n ObjectType,\n QueryFunctionType,\n TypeDef,\n Ontology as OntologyDescriptor,\n} from \"@party-stack/ontology-spec/meta\";\nimport type { Scope } from \"effect\";\n\nfunction getValueTypes(type: TypeDef): string[] {\n switch (type.kind) {\n case \"list\":\n return getValueTypes(type.value.elementType);\n case \"map\":\n return [...getValueTypes(type.value.keyType), ...getValueTypes(type.value.valueType)];\n case \"optional\":\n return getValueTypes(type.value.type);\n case \"encrypted\":\n return getValueTypes(type.value.type);\n case \"result\":\n return [...getValueTypes(type.value.okType), ...getValueTypes(type.value.errType)];\n case \"struct\":\n return type.value.fields.flatMap((field) => getValueTypes(field.type));\n case \"union\":\n return type.value.variants.flatMap((variant) => getValueTypes(variant.type));\n case \"ref\":\n return [type.value.name];\n default:\n return [];\n }\n}\n\nfunction getObjectTypeValueTypes(objectType: ObjectType): string[] {\n return Array.from(new Set(objectType.properties.flatMap((p) => getValueTypes(p.type))));\n}\n\nfunction getActionTypeValueTypes(actionType: ActionType): string[] {\n return [\n ...actionType.parameters.flatMap((parameter) => getValueTypes(parameter.type)),\n ...(actionType.returnType ? getValueTypes(actionType.returnType) : []),\n ];\n}\n\nfunction getQueryFunctionTypeValueTypes(queryFunctionType: QueryFunctionType): string[] {\n return [\n ...queryFunctionType.parameters.flatMap((parameter) => getValueTypes(parameter.type)),\n ...getValueTypes(queryFunctionType.returnType),\n ];\n}\n\nexport interface PullOptions {\n /** Omitted selects all definitions of this kind; an empty array selects none. */\n objectTypeNames?: string[];\n actionTypeNames?: string[];\n queryFunctionTypeNames?: string[];\n /** App-specific definition edits, applied before invalid definitions are omitted. */\n transform?: (ontology: OntologyIR) => OntologyIR | Promise<OntologyIR>;\n /** Resolve to `{ ontology, omitted }` instead of the IR alone. */\n includeOmitted?: boolean;\n}\n/** Which definitions to take from the metadata, and app-specific edits to apply to them. */\nexport type DefinitionSelection = Omit<PullOptions, \"includeOmitted\">;\n\nexport interface PullResult {\n /** A valid Ontology. */\n readonly ontology: OntologyIR;\n /**\n * Definitions (or action parameter defaults) the provider exposes but the IR could not\n * represent, and why. A caller that needs the complete Ontology treats any entry as a failure.\n */\n readonly omitted: readonly OmittedDefinition[];\n}\n\nconst pullDefinitions = Effect.fn(\"Metadata.pull\")(function* (\n backend: Pick<OntologyBackendService, \"query\">,\n options: PullOptions = {}\n) {\n const select = (objectType: string, scan: Parameters<typeof objectSubset>[1]) => ({\n ...objectSubset(objectType, scan),\n select: metaOntology.objectTypes\n .find((type) => type.name === objectType)!\n .properties.map((property) => q.selectField(property.name, q.field(\"row\", property.name))),\n });\n const { objectTypeNames, actionTypeNames, queryFunctionTypeNames } = options;\n const result = yield* backend.query({\n select: [\n q.sub(\n \"objectTypes\",\n select(\"ObjectType\", { where: objectTypeNames && inArray(field(\"name\"), objectTypeNames) })\n ),\n q.sub(\n \"descriptors\",\n select(\"Ontology\", { orderBy: [{ field: field(\"id\"), direction: \"asc\" }], limit: 2 })\n ),\n q.sub(\n \"linkTypes\",\n select(\"LinkType\", {\n where:\n objectTypeNames &&\n and(\n inArray(field(\"source\", \"objectType\"), objectTypeNames),\n inArray(field(\"target\", \"objectType\"), objectTypeNames)\n ),\n })\n ),\n q.sub(\n \"actionTypes\",\n select(\"ActionType\", { where: actionTypeNames && inArray(field(\"name\"), actionTypeNames) })\n ),\n q.sub(\n \"queryFunctionTypes\",\n select(\"QueryFunctionType\", {\n where: queryFunctionTypeNames && inArray(field(\"name\"), queryFunctionTypeNames),\n })\n ),\n // Value types are referenced by name from inside other definitions' types, which a\n // query cannot follow. There are few, so read them all in the same request and keep\n // the ones the selection uses.\n q.sub(\"valueTypes\", select(\"ValueType\", {})),\n ],\n });\n // A projection reads every meta property; one a row does not set is absent, not undefined.\n const rows = <A>(value: unknown) =>\n (value as Record<string, unknown>[]).map(\n (row) => Object.fromEntries(Object.entries(row).filter(([, field]) => field !== undefined)) as A\n );\n const objectTypes = rows<ObjectType>(result.objectTypes);\n const descriptors = rows<OntologyDescriptor>(result.descriptors);\n const linkTypes = rows<OntologyIR[\"linkTypes\"][number]>(result.linkTypes);\n const actionTypes = rows<ActionType>(result.actionTypes);\n const queryFunctionTypes = rows<QueryFunctionType>(result.queryFunctionTypes);\n const valueTypes = new Map(\n rows<OntologyIR[\"types\"][number]>(result.valueTypes).map((type) => [type.name, type])\n );\n const invalid = (message: string) =>\n new BackendError({ operation: \"metadata.pull\", kind: \"InvalidResponse\", retryable: false, message });\n if (descriptors.length !== 1 || descriptors[0]?.id !== \"ontology\")\n return yield* invalid(\"Metadata must expose exactly one Ontology descriptor with id ontology.\");\n const descriptor = descriptors[0];\n\n for (const [kind, requested, definitions] of [\n [\"object types\", objectTypeNames, objectTypes],\n [\"action types\", actionTypeNames, actionTypes],\n [\"query function types\", queryFunctionTypeNames, queryFunctionTypes],\n ] as const) {\n if (!requested) continue;\n const returned = new Set(definitions.map((definition) => definition.name));\n const missing = [...new Set(requested)].filter((name) => !returned.has(name));\n if (missing.length)\n return yield* invalid(`Missing requested metadata ${kind}: ${missing.join(\", \")}.`);\n }\n\n const valueTypeNames = Array.from(\n new Set([\n ...objectTypes.flatMap(getObjectTypeValueTypes),\n ...actionTypes.flatMap(getActionTypeValueTypes),\n ...queryFunctionTypes.flatMap(getQueryFunctionTypeValueTypes),\n ...(descriptor?.context?.type ? getValueTypes(descriptor.context.type) : []),\n ])\n );\n\n // Everything when nothing is selected, so a definition round-trips whole; otherwise the\n // value types the selection uses, and the ones those use.\n const selected = objectTypeNames ?? actionTypeNames ?? queryFunctionTypeNames;\n const types: OntologyIR[\"types\"] = selected === undefined ? [...valueTypes.values()] : [];\n if (selected !== undefined) {\n const loaded = new Set<string>();\n let pending = valueTypeNames;\n while (pending.length) {\n const missing = pending.filter((name) => !valueTypes.has(name));\n if (missing.length) return yield* invalid(`Missing metadata value types: ${missing.join(\", \")}.`);\n const batch = pending.map((name) => valueTypes.get(name)!);\n for (const type of batch) {\n loaded.add(type.name);\n types.push(type);\n }\n pending = [...new Set(batch.flatMap((type) => getValueTypes(type.type)))].filter(\n (name) => !loaded.has(name)\n );\n }\n }\n // Rows carry every id; one equal to its default is left out, so a definition reads back as\n // it was written. Provider ids are kept.\n const pulled: OntologyIR = withoutDefaultIds({\n types,\n objectTypes,\n linkTypes,\n actionTypes,\n queryFunctionTypes,\n ...(descriptor?.displayName === undefined ? {} : { displayName: descriptor.displayName }),\n ...(descriptor?.description === undefined ? {} : { description: descriptor.description }),\n ...(descriptor?.context === undefined ? {} : { context: descriptor.context }),\n ...(descriptor?.policy === undefined ? {} : { policy: descriptor.policy }),\n });\n const definition = options.transform\n ? yield* Effect.tryPromise({\n try: async () => options.transform!(pulled),\n catch: (cause) =>\n new BackendError({\n operation: \"metadata.pull.transform\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: cause instanceof Error ? cause.message : \"The ontology transform failed.\",\n cause,\n }),\n })\n : pulled;\n // One definition the IR cannot represent should not make the whole Ontology unusable.\n const repaired = omitInvalid(definition);\n if (repaired.issues.length)\n return yield* new BackendError({\n operation: \"metadata.pull\",\n kind: options.transform ? \"InvalidConfiguration\" : \"InvalidResponse\",\n retryable: false,\n message: `Pulled ontology is invalid: ${repaired.issues.map((issue) => issue.message).join(\" \")}`,\n issues: repaired.issues,\n });\n if (repaired.omitted.length)\n yield* Effect.logWarning(\"Omitted definitions the Ontology IR cannot represent.\").pipe(\n Effect.annotateLogs({\n omitted: repaired.omitted.map(\n (entry) => `${entry.name}${entry.parameter ? `.${entry.parameter}` : \"\"}`\n ),\n })\n );\n const pulledResult: PullResult = { ontology: repaired.ontology, omitted: repaired.omitted };\n return pulledResult;\n});\n\n/**\n * Pull selected definitions directly from a metadata backend, without a replica or UI collections.\n *\n * Definitions the IR cannot represent are omitted (see `omitInvalid`) and logged as a warning,\n * rather than failing the pull. Pass `includeOmitted: true` to also receive what was omitted.\n */\nexport function pull(\n backend: Pick<OntologyBackendService, \"query\">,\n options: PullOptions & { readonly includeOmitted: true }\n): Effect.Effect<PullResult, BackendError>;\nexport function pull(\n backend: Pick<OntologyBackendService, \"query\">,\n options?: PullOptions\n): Effect.Effect<OntologyIR, BackendError>;\nexport function pull(\n backend: Pick<OntologyBackendService, \"query\">,\n options: PullOptions = {}\n): Effect.Effect<OntologyIR | PullResult, BackendError> {\n const result = pullDefinitions(backend, options);\n return options.includeOmitted ? result : Effect.map(result, (pulled) => pulled.ontology);\n}\n\n/** Assemble a runtime definition through ordinary metadata queries. Completeness\n * is the adapter's query contract; this does not invent an atomic provider revision.\n */\nexport const loadDefinition = (backend: Pick<OntologyBackendService, \"query\">) => pull(backend);\n\nexport interface MetadataBackendOptions {\n /** Emits when the definition this backend describes has been replaced. Watches report it as\n * a reset, so a replica of the metadata reloads it. */\n readonly replaced?: Stream.Stream<unknown, BackendError>;\n}\n/** Serve a definition as meta ontology rows. */\nexport function makeMetadataBackend(\n ir: OntologyIR,\n options: MetadataBackendOptions = {}\n): OntologyBackendService {\n // Meta rows always carry ids; a definition without them is given its defaults.\n ir = withDefinitionIds(structuredClone(ir));\n\n return makeOntologyBackend({\n ir: metaOntology,\n name: \"local-metadata\",\n sourceId: \"local-metadata\",\n supportsIdempotency: false,\n loadSubset: (request) =>\n Effect.flatMap(compileObjectSubset(metaOntology, request), (subset) =>\n Effect.suspend(() => {\n const rows: Record<string, readonly object[]> = {\n Ontology: [\n {\n id: \"ontology\",\n displayName: ir.displayName,\n description: ir.description,\n context: ir.context,\n policy: ir.policy,\n },\n ],\n ObjectType: ir.objectTypes,\n ValueType: ir.types,\n LinkType: ir.linkTypes,\n ActionType: ir.actionTypes,\n QueryFunctionType: ir.queryFunctionTypes,\n };\n const type = metaOntology.objectTypes.find((type) => type.name === subset.objectType);\n if (!type)\n return Effect.fail(\n new BackendError({\n operation: \"loadSubset\",\n kind: \"InvalidRequest\",\n message: \"Unknown metadata object type.\",\n retryable: false,\n })\n );\n return Effect.succeed({\n rows: evaluateQuery(\n rows[subset.objectType]!.map((row) => ({\n key: (row as Record<string, unknown>)[type.primaryKey] as string,\n value: row as Record<string, unknown>,\n })),\n subset.query ?? {}\n ),\n complete: true,\n });\n })\n ),\n ...(options.replaced && {\n watchSubset: () => Effect.succeed(Stream.map(options.replaced!, (): SubsetWatchEvent => \"reset\")),\n }),\n applyAction: () =>\n Effect.fail(\n new BackendError({\n operation: \"applyAction\",\n kind: \"NotImplemented\",\n message: \"Metadata is read-only.\",\n retryable: false,\n })\n ),\n queryFunction: () =>\n Effect.fail(\n new BackendError({\n operation: \"queryFunction\",\n kind: \"NotImplemented\",\n message: \"Local metadata has no query functions.\",\n retryable: false,\n })\n ),\n });\n}\n\nexport interface OntologyPullConfig<R = never> extends Omit<PullOptions, \"queryFunctionTypeNames\"> {\n readonly queryFunctionTypeNames?: string[];\n readonly backend: Effect.Effect<OntologyBackendService, BackendError, R | Scope.Scope>;\n}\n"],"mappings":";;;;;;;;;;AAmBA,SAAS,cAAc,MAAyB;CAC5C,QAAQ,KAAK,MAAb;EACI,KAAK,QACD,OAAO,cAAc,KAAK,MAAM,WAAW;EAC/C,KAAK,OACD,OAAO,CAAC,GAAG,cAAc,KAAK,MAAM,OAAO,GAAG,GAAG,cAAc,KAAK,MAAM,SAAS,CAAC;EACxF,KAAK,YACD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O,IAAI,QAAQ,gBAAmC,OAAO,CAAC,EACpG;EACA,mBACI,OAAO,KACH,IAAI,aAAa;GACb,WAAW;GACX,MAAM;GACN,SAAS;GACT,WAAW;EACf,CAAC,CACL;EACJ,qBACI,OAAO,KACH,IAAI,aAAa;GACb,WAAW;GACX,MAAM;GACN,SAAS;GACT,WAAW;EACf,CAAC,CACL;CACR,CAAC;AACL"}
|
|
1
|
+
{"version":3,"file":"meta.js","names":[],"sources":["../src/meta.ts"],"sourcesContent":["import {\n cloneDefinition,\n omitInvalid,\n withDefinitionIds,\n withoutDefaultIds,\n} from \"@party-stack/ontology-spec\";\nimport metaOntology from \"@party-stack/ontology-spec/meta\";\nimport * as q from \"@party-stack/ontology-spec/query\";\nimport { and, inArray, field, evaluateQuery } from \"@party-stack/ontology-storage\";\nimport { Effect, Stream } from \"effect\";\nimport { makeOntologyBackend } from \"./query.js\";\nimport { compileObjectSubset, objectSubset } from \"./subset.js\";\nimport { BackendError } from \"./index.js\";\nimport type { OntologyBackendService, SubsetWatchEvent } from \"./index.js\";\nimport type { OmittedDefinition, OntologyIR } from \"@party-stack/ontology-spec\";\nimport type {\n ActionType,\n ObjectType,\n QueryFunctionType,\n TypeDef,\n Ontology as OntologyDescriptor,\n} from \"@party-stack/ontology-spec/meta\";\nimport type { Scope } from \"effect\";\n\nfunction getValueTypes(type: TypeDef): string[] {\n switch (type.kind) {\n case \"list\":\n return getValueTypes(type.value.elementType);\n case \"map\":\n return [...getValueTypes(type.value.keyType), ...getValueTypes(type.value.valueType)];\n case \"optional\":\n return getValueTypes(type.value.type);\n case \"encrypted\":\n return getValueTypes(type.value.type);\n case \"result\":\n return [...getValueTypes(type.value.okType), ...getValueTypes(type.value.errType)];\n case \"struct\":\n return type.value.fields.flatMap((field) => getValueTypes(field.type));\n case \"union\":\n return type.value.variants.flatMap((variant) => getValueTypes(variant.type));\n case \"ref\":\n return [type.value.name];\n default:\n return [];\n }\n}\n\nfunction getObjectTypeValueTypes(objectType: ObjectType): string[] {\n return Array.from(new Set(objectType.properties.flatMap((p) => getValueTypes(p.type))));\n}\n\nfunction getActionTypeValueTypes(actionType: ActionType): string[] {\n return [\n ...actionType.parameters.flatMap((parameter) => getValueTypes(parameter.type)),\n ...(actionType.returnType ? getValueTypes(actionType.returnType) : []),\n ];\n}\n\nfunction getQueryFunctionTypeValueTypes(queryFunctionType: QueryFunctionType): string[] {\n return [\n ...queryFunctionType.parameters.flatMap((parameter) => getValueTypes(parameter.type)),\n ...getValueTypes(queryFunctionType.returnType),\n ];\n}\n\nexport interface PullOptions {\n /** Omitted selects all definitions of this kind; an empty array selects none. */\n objectTypeNames?: string[];\n actionTypeNames?: string[];\n queryFunctionTypeNames?: string[];\n /** App-specific definition edits, applied before invalid definitions are omitted. */\n transform?: (ontology: OntologyIR) => OntologyIR | Promise<OntologyIR>;\n /** Resolve to `{ ontology, omitted }` instead of the IR alone. */\n includeOmitted?: boolean;\n}\n/** Which definitions to take from the metadata, and app-specific edits to apply to them. */\nexport type DefinitionSelection = Omit<PullOptions, \"includeOmitted\">;\n\nexport interface PullResult {\n /** A valid Ontology. */\n readonly ontology: OntologyIR;\n /**\n * Definitions (or action parameter defaults) the provider exposes but the IR could not\n * represent, and why. A caller that needs the complete Ontology treats any entry as a failure.\n */\n readonly omitted: readonly OmittedDefinition[];\n}\n\nconst pullDefinitions = Effect.fn(\"Metadata.pull\")(function* (\n backend: Pick<OntologyBackendService, \"query\">,\n options: PullOptions = {}\n) {\n const select = (objectType: string, scan: Parameters<typeof objectSubset>[1]) => ({\n ...objectSubset(objectType, scan),\n select: metaOntology.objectTypes\n .find((type) => type.name === objectType)!\n .properties.map((property) => q.selectField(property.name, q.field(\"row\", property.name))),\n });\n const { objectTypeNames, actionTypeNames, queryFunctionTypeNames } = options;\n const result = yield* backend.query({\n select: [\n q.sub(\n \"objectTypes\",\n select(\"ObjectType\", { where: objectTypeNames && inArray(field(\"name\"), objectTypeNames) })\n ),\n q.sub(\n \"descriptors\",\n select(\"Ontology\", { orderBy: [{ field: field(\"id\"), direction: \"asc\" }], limit: 2 })\n ),\n q.sub(\n \"linkTypes\",\n select(\"LinkType\", {\n where:\n objectTypeNames &&\n and(\n inArray(field(\"source\", \"objectType\"), objectTypeNames),\n inArray(field(\"target\", \"objectType\"), objectTypeNames)\n ),\n })\n ),\n q.sub(\n \"actionTypes\",\n select(\"ActionType\", { where: actionTypeNames && inArray(field(\"name\"), actionTypeNames) })\n ),\n q.sub(\n \"queryFunctionTypes\",\n select(\"QueryFunctionType\", {\n where: queryFunctionTypeNames && inArray(field(\"name\"), queryFunctionTypeNames),\n })\n ),\n // Value types are referenced by name from inside other definitions' types, which a\n // query cannot follow. There are few, so read them all in the same request and keep\n // the ones the selection uses.\n q.sub(\"valueTypes\", select(\"ValueType\", {})),\n ],\n });\n // A projection reads every meta property; one a row does not set is absent, not undefined.\n const rows = <A>(value: unknown) =>\n (value as Record<string, unknown>[]).map(\n (row) => Object.fromEntries(Object.entries(row).filter(([, field]) => field !== undefined)) as A\n );\n const objectTypes = rows<ObjectType>(result.objectTypes);\n const descriptors = rows<OntologyDescriptor>(result.descriptors);\n const linkTypes = rows<OntologyIR[\"linkTypes\"][number]>(result.linkTypes);\n const actionTypes = rows<ActionType>(result.actionTypes);\n const queryFunctionTypes = rows<QueryFunctionType>(result.queryFunctionTypes);\n const valueTypes = new Map(\n rows<OntologyIR[\"types\"][number]>(result.valueTypes).map((type) => [type.name, type])\n );\n const invalid = (message: string) =>\n new BackendError({ operation: \"metadata.pull\", kind: \"InvalidResponse\", retryable: false, message });\n if (descriptors.length !== 1 || descriptors[0]?.id !== \"ontology\")\n return yield* invalid(\"Metadata must expose exactly one Ontology descriptor with id ontology.\");\n const descriptor = descriptors[0];\n\n for (const [kind, requested, definitions] of [\n [\"object types\", objectTypeNames, objectTypes],\n [\"action types\", actionTypeNames, actionTypes],\n [\"query function types\", queryFunctionTypeNames, queryFunctionTypes],\n ] as const) {\n if (!requested) continue;\n const returned = new Set(definitions.map((definition) => definition.name));\n const missing = [...new Set(requested)].filter((name) => !returned.has(name));\n if (missing.length)\n return yield* invalid(`Missing requested metadata ${kind}: ${missing.join(\", \")}.`);\n }\n\n const valueTypeNames = Array.from(\n new Set([\n ...objectTypes.flatMap(getObjectTypeValueTypes),\n ...actionTypes.flatMap(getActionTypeValueTypes),\n ...queryFunctionTypes.flatMap(getQueryFunctionTypeValueTypes),\n ...(descriptor?.context?.type ? getValueTypes(descriptor.context.type) : []),\n ])\n );\n\n // Everything when nothing is selected, so a definition round-trips whole; otherwise the\n // value types the selection uses, and the ones those use.\n const selected = objectTypeNames ?? actionTypeNames ?? queryFunctionTypeNames;\n const types: OntologyIR[\"types\"] = selected === undefined ? [...valueTypes.values()] : [];\n if (selected !== undefined) {\n const loaded = new Set<string>();\n let pending = valueTypeNames;\n while (pending.length) {\n const missing = pending.filter((name) => !valueTypes.has(name));\n if (missing.length) return yield* invalid(`Missing metadata value types: ${missing.join(\", \")}.`);\n const batch = pending.map((name) => valueTypes.get(name)!);\n for (const type of batch) {\n loaded.add(type.name);\n types.push(type);\n }\n pending = [...new Set(batch.flatMap((type) => getValueTypes(type.type)))].filter(\n (name) => !loaded.has(name)\n );\n }\n }\n // Rows carry every id; one equal to its default is left out, so a definition reads back as\n // it was written. Provider ids are kept.\n const pulled: OntologyIR = withoutDefaultIds({\n types,\n objectTypes,\n linkTypes,\n actionTypes,\n queryFunctionTypes,\n ...(descriptor?.displayName === undefined ? {} : { displayName: descriptor.displayName }),\n ...(descriptor?.description === undefined ? {} : { description: descriptor.description }),\n ...(descriptor?.context === undefined ? {} : { context: descriptor.context }),\n ...(descriptor?.policy === undefined ? {} : { policy: descriptor.policy }),\n });\n const definition = options.transform\n ? yield* Effect.tryPromise({\n try: async () => options.transform!(pulled),\n catch: (cause) =>\n new BackendError({\n operation: \"metadata.pull.transform\",\n kind: \"InvalidConfiguration\",\n retryable: false,\n message: cause instanceof Error ? cause.message : \"The ontology transform failed.\",\n cause,\n }),\n })\n : pulled;\n // One definition the IR cannot represent should not make the whole Ontology unusable.\n const repaired = omitInvalid(definition);\n if (repaired.issues.length)\n return yield* new BackendError({\n operation: \"metadata.pull\",\n kind: options.transform ? \"InvalidConfiguration\" : \"InvalidResponse\",\n retryable: false,\n message: `Pulled ontology is invalid: ${repaired.issues.map((issue) => issue.message).join(\" \")}`,\n issues: repaired.issues,\n });\n if (repaired.omitted.length)\n yield* Effect.logWarning(\"Omitted definitions the Ontology IR cannot represent.\").pipe(\n Effect.annotateLogs({\n // With the reason, so an omission can be fixed at its source without a debugger.\n omitted: repaired.omitted.map(\n (entry) =>\n `${entry.name}${entry.parameter ? `.${entry.parameter}` : \"\"}: ${entry.issues\n .map((issue) => issue.message)\n .join(\" \")}`\n ),\n })\n );\n const pulledResult: PullResult = { ontology: repaired.ontology, omitted: repaired.omitted };\n return pulledResult;\n});\n\n/**\n * Pull selected definitions directly from a metadata backend, without a replica or UI collections.\n *\n * Definitions the IR cannot represent are omitted (see `omitInvalid`) and logged as a warning,\n * rather than failing the pull. Pass `includeOmitted: true` to also receive what was omitted.\n */\nexport function pull(\n backend: Pick<OntologyBackendService, \"query\">,\n options: PullOptions & { readonly includeOmitted: true }\n): Effect.Effect<PullResult, BackendError>;\nexport function pull(\n backend: Pick<OntologyBackendService, \"query\">,\n options?: PullOptions\n): Effect.Effect<OntologyIR, BackendError>;\nexport function pull(\n backend: Pick<OntologyBackendService, \"query\">,\n options: PullOptions = {}\n): Effect.Effect<OntologyIR | PullResult, BackendError> {\n const result = pullDefinitions(backend, options);\n return options.includeOmitted ? result : Effect.map(result, (pulled) => pulled.ontology);\n}\n\n/** Assemble a runtime definition through ordinary metadata queries. Completeness\n * is the adapter's query contract; this does not invent an atomic provider revision.\n */\nexport const loadDefinition = (backend: Pick<OntologyBackendService, \"query\">) => pull(backend);\n\nexport interface MetadataBackendOptions {\n /** Emits when the definition this backend describes has been replaced. Watches report it as\n * a reset, so a replica of the metadata reloads it. */\n readonly replaced?: Stream.Stream<unknown, BackendError>;\n}\n/** Serve a definition as meta ontology rows. */\nexport function makeMetadataBackend(\n ir: OntologyIR,\n options: MetadataBackendOptions = {}\n): OntologyBackendService {\n // Meta rows always carry ids; a definition without them is given its defaults.\n ir = withDefinitionIds(cloneDefinition(ir));\n\n return makeOntologyBackend({\n ir: metaOntology,\n name: \"local-metadata\",\n sourceId: \"local-metadata\",\n supportsIdempotency: false,\n loadSubset: (request) =>\n Effect.flatMap(compileObjectSubset(metaOntology, request), (subset) =>\n Effect.suspend(() => {\n const rows: Record<string, readonly object[]> = {\n Ontology: [\n {\n id: \"ontology\",\n displayName: ir.displayName,\n description: ir.description,\n context: ir.context,\n policy: ir.policy,\n },\n ],\n ObjectType: ir.objectTypes,\n ValueType: ir.types,\n LinkType: ir.linkTypes,\n ActionType: ir.actionTypes,\n QueryFunctionType: ir.queryFunctionTypes,\n };\n const type = metaOntology.objectTypes.find((type) => type.name === subset.objectType);\n if (!type)\n return Effect.fail(\n new BackendError({\n operation: \"loadSubset\",\n kind: \"InvalidRequest\",\n message: \"Unknown metadata object type.\",\n retryable: false,\n })\n );\n return Effect.succeed({\n rows: evaluateQuery(\n rows[subset.objectType]!.map((row) => ({\n key: (row as Record<string, unknown>)[type.primaryKey] as string,\n value: row as Record<string, unknown>,\n })),\n subset.query ?? {}\n ),\n complete: true,\n });\n })\n ),\n ...(options.replaced && {\n watchSubset: () => Effect.succeed(Stream.map(options.replaced!, (): SubsetWatchEvent => \"reset\")),\n }),\n applyAction: () =>\n Effect.fail(\n new BackendError({\n operation: \"applyAction\",\n kind: \"NotImplemented\",\n message: \"Metadata is read-only.\",\n retryable: false,\n })\n ),\n queryFunction: () =>\n Effect.fail(\n new BackendError({\n operation: \"queryFunction\",\n kind: \"NotImplemented\",\n message: \"Local metadata has no query functions.\",\n retryable: false,\n })\n ),\n });\n}\n\nexport interface OntologyPullConfig<R = never> extends Omit<PullOptions, \"queryFunctionTypeNames\"> {\n readonly queryFunctionTypeNames?: string[];\n readonly backend: Effect.Eff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CAAC,MACD,OAAO,OAAO,KACV,IAAI,aAAa;IACb,WAAW;IACX,MAAM;IACN,SAAS;IACT,WAAW;GACf,CAAC,CACL;GACJ,OAAO,OAAO,QAAQ;IAClB,MAAM,cACF,KAAK,OAAO,WAAW,CAAE,KAAK,SAAS;KACnC,KAAM,IAAgC,KAAK;KAC3C,OAAO;IACX,EAAE,GACF,OAAO,SAAS,CAAC,CACrB;IACA,UAAU;GACd,CAAC;EACL,CAAC,CACL;EACJ,GAAI,QAAQ,YAAY,EACpB,mBAAmB,OAAO,QAAQ,OAAO,IAAI,QAAQ,gBAAmC,OAAO,CAAC,EACpG;EACA,mBACI,OAAO,KACH,IAAI,aAAa;GACb,WAAW;GACX,MAAM;GACN,SAAS;GACT,WAAW;EACf,CAAC,CACL;EACJ,qBACI,OAAO,KACH,IAAI,aAAa;GACb,WAAW;GACX,MAAM;GACN,SAAS;GACT,WAAW;EACf,CAAC,CACL;CACR,CAAC;AACL"}
|
package/lib/owned.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owned.d.ts","names":[],"sources":["../src/owned.ts"],"mappings":";;;;;;;;iBAgDiB;;WAEJ,qBACL,oBACA,WAAW,OACX,OAAO,UACN,OAAO;aACY,KAAK;aAAc,OAAO;mBAC9C;EAEJ,IAAI,oBAAoB,KAAK,MAAM,OAAO,OAAO,qCAAqC;EACtF,WACI,oBACA,QAAQ,QACT,OAAO;aAA2B,KAAK;aAAc,OAAO;OAA6B;;iBAE/E,yBAAyB;EACtC,IAAI,oBAAoB,OAAO,0BAA0B,OAAO,aAAa;;EAE7E,MACI,oBACA,KAAK,KACL;aAA6B;aAAkC;QAChE,OAAO,aAAa;EACvB,OAAO,oBAAoB,KAAK,MAAM,OAAO,aAAa;;;iBAG7C,gCAAgC;EAC7C,YAAY,oBAAoB,OAAO,QAAQ,OAAO,aAAa;;iBAEtD;WACJ,IAAI;WACJ,OAAO,GAAG,GAAG,GAClB,OAAO,IAAI,yBAA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ACzB,OAAO,IAAI,4BAA4B,OAAO,OAAO,GAAG,GAAG,OAC1D,OAAO,OAAO,GAAG,IAAI,cAAc;;iBAE3B;WACJ;WACA,IAAI;WACJ,QAAQ;WACR,sDAAsD;;WAEtD;WACA,WAAW;;WAEX;aAAqB;aAA8B;;;WAEnD;;;;WAIA;aAAiC;;WACjC,UAAU,SACf,gBAEK,IAAI,kBAAkB,YAAY,kBAAkB,OAAO,gBAAgB;WAG3E,iBAAiB,SACtB,gBAGQ,IAAI,sBACJ,YAAY,4BACX,OAAO,gBAAgB;WAG3B,cAAc;WACd,YAAY;;WAEZ,kBACL,YAAY,kBACX,OAAO,OAAO,OAAO,aAAa,eAAe;;iBAEzC,4BAA4B;WAChC,SAAS;;;qBA0CT,mBAAgB,SAAA,wBAAA,OAAA,OAAA,qBAAA,iWAAA,MAAA"}
|
package/lib/owned.js
CHANGED
|
@@ -13,6 +13,7 @@ import { byteSource, digestBytes } from "@party-stack/ontology-storage/blobs";
|
|
|
13
13
|
import { compileEffectSchemas } from "@party-stack/ontology-spec/effect";
|
|
14
14
|
import { Table, gt } from "@party-stack/ontology-storage/tables";
|
|
15
15
|
//#region src/owned.ts
|
|
16
|
+
const selectionIdentity = Table.make({ name: "delivery-selection" });
|
|
16
17
|
const fault = (operation, kind, message, cause) => new BackendError({
|
|
17
18
|
operation,
|
|
18
19
|
kind,
|
|
@@ -438,7 +439,7 @@ const makeOwnedBackend = Effect.fnUntraced(function* (options) {
|
|
|
438
439
|
},
|
|
439
440
|
resume,
|
|
440
441
|
binding: JSON.stringify([source, schemaHash]),
|
|
441
|
-
identity:
|
|
442
|
+
identity: selectionIdentity.encode(selection),
|
|
442
443
|
changes: PubSub.subscribe(wakes).pipe(Effect.map(Stream.fromSubscription)),
|
|
443
444
|
capture: (_tx, emit) => boundary(Effect.gen(function* () {
|
|
444
445
|
for (const subset of subsets) {
|
package/lib/owned.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"owned.js","names":[],"sources":["../src/owned.ts"],"sourcesContent":["import { compileEffectSchemas } from \"@party-stack/ontology-spec/effect\";\nimport { setAtPath } from \"@party-stack/ontology-spec/utils\";\nimport { ontologyDefinitionContractSignature } from \"@party-stack/ontology-storage\";\nimport {\n makeOntologyStorage,\n OntologyStorageError,\n makeStorageModel,\n field,\n lte,\n or,\n indexesForQuery,\n} from \"@party-stack/ontology-storage\";\nimport { digestBytes, byteSource } from \"@party-stack/ontology-storage/blobs\";\nimport { Table, gt } from \"@party-stack/ontology-storage/tables\";\nimport { Clock, Effect, PubSub, Redacted, Schema, Semaphore, Stream } from \"effect\";\nimport { makeDeliveryManager, scanSelectedRows } from \"./delivery.js\";\nimport { maintenanceInterval, scheduleMaintenance } from \"./maintenance.js\";\nimport { CurrentActionAuthorization, CurrentQueryAuthorization, CurrentExecutionContext } from \"./policy.js\";\nimport { executeQuery } from \"./query.js\";\nimport { actionReferenceIssues } from \"./references.js\";\nimport { compileObjectSubset } from \"./subset.js\";\nimport {\n classifyBackendFailure,\n schemaValidationIssues,\n BackendError,\n ActionReceiptSchema,\n BackendCommitSchema,\n} from \"./index.js\";\nimport type { DeliveryPolicy } from \"./delivery.js\";\nimport type {\n ActionRequest,\n ActionReceipt,\n BackendCommit,\n ObjectChange,\n OntologyBackendService,\n} from \"./index.js\";\nimport type { OntologyIR } from \"@party-stack/ontology-spec\";\nimport type {\n Index,\n Key,\n Query,\n Field,\n ReadStorageTransaction,\n StorageTransaction,\n} from \"@party-stack/ontology-storage\";\nimport type { TablesService } from \"@party-stack/ontology-storage/tables\";\nimport type { Scope } from \"effect\";\n\nexport interface OwnedReadTransaction {\n /** Exact grouped-read capability for the finite query executor, when available. */\n readonly loadGroupedSubset?: (\n objectType: string,\n partition: Field,\n query: Query\n ) => Effect.Effect<\n readonly { readonly key: Key; readonly value: Record<string, unknown> }[] | undefined,\n BackendError\n >;\n get(objectType: string, key: Key): Effect.Effect<Record<string, unknown> | undefined, BackendError>;\n loadSubset(\n objectType: string,\n query?: Query\n ): Effect.Effect<readonly { readonly key: Key; readonly value: Record<string, unknown> }[], BackendError>;\n}\nexport interface OwnedTransaction extends OwnedReadTransaction {\n put(objectType: string, value: Record<string, unknown>): Effect.Effect<void, BackendError>;\n /** Update explicit paths without reading or replacing unrelated private fields. */\n patch(\n objectType: string,\n key: Key,\n changes: readonly { readonly path: readonly string[]; readonly value: unknown }[]\n ): Effect.Effect<void, BackendError>;\n delete(objectType: string, key: Key): Effect.Effect<void, BackendError>;\n}\n/** Trusted persistence access, never exposed by the public backend/RPC contract. */\nexport interface OwnedStorageTransaction extends OwnedTransaction {\n ensureIndex(objectType: string, index: Index): Effect.Effect<void, BackendError>;\n}\nexport interface OwnedStorageService {\n readonly ir: OntologyIR;\n readonly read: <A, E, R>(\n body: (tx: OwnedReadTransaction) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | BackendError, R>;\n /** Data changes and their journal batch commit in the same native transaction. */\n readonly transaction: <A, E, R>(\n body: (tx: OwnedStorageTransaction) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | BackendError, R>;\n}\nexport interface OwnedBackendOptions {\n readonly namespace: string;\n readonly ir: OntologyIR;\n readonly tables: TablesService;\n readonly blobs?: import(\"@party-stack/ontology-storage/blobs\").BlobStorageService;\n /** Explicit authority scope; otherwise use the authenticated partition, or system for trusted unbound calls. */\n readonly actionScope?: string;\n readonly delivery?: DeliveryPolicy;\n /** Bounded replay history. Cursors behind this floor require a fresh snapshot. */\n readonly history?: { readonly maxCommits?: number; readonly maxAgeMs?: number };\n /** Infinity retains results indefinitely; finite windows bound idempotency. */\n readonly resultRetentionMs?: number;\n /** Owner-scoped sweep, every 60 seconds by default. False leaves scheduling to\n * an external owner (for example a DO alarm); maintenance remains callable.\n */\n readonly maintenance?: false | { readonly intervalMs?: number };\n readonly mutators: Readonly<\n Record<\n string,\n (tx: OwnedTransaction, invocation: ActionRequest) => Effect.Effect<unknown, BackendError>\n >\n >;\n readonly queryFunctions?: Readonly<\n Record<\n string,\n (\n tx: OwnedReadTransaction,\n parameters: Record<string, unknown>\n ) => Effect.Effect<unknown, BackendError>\n >\n >;\n readonly attachments?: OntologyBackendService[\"attachments\"];\n readonly encrypted?: OntologyBackendService[\"encrypted\"];\n /** Stage external bytes before opening the object transaction; returned metadata work joins its commit. */\n readonly prepareUploads?: (\n invocation: ActionRequest\n ) => Effect.Effect<Effect.Effect<void, BackendError>, BackendError>;\n}\nexport interface OwnedBackendService extends OntologyBackendService {\n readonly storage: OwnedStorageService;\n}\nconst fault = (operation: string, kind: BackendError[\"kind\"], message: string, cause?: unknown) =>\n new BackendError({\n operation,\n kind,\n message,\n retryable: false,\n cause: cause === undefined ? undefined : Redacted.make(cause),\n });\nconst boundary = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(Effect.mapError((error) => classifyBackendFailure(\"storage\", error)));\nconst CursorSchema = Schema.Struct({ source: Schema.String, revision: Schema.Int });\nconst ReceiptSchema = Schema.Struct({\n fingerprint: Schema.String,\n receipt: ActionReceiptSchema,\n completedAt: Schema.Finite,\n});\nconst JournalSchema = Schema.Struct({\n revision: Schema.Int,\n commit: BackendCommitSchema,\n committedAt: Schema.Finite,\n});\nconst stableValue = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(stableValue);\n if (value !== null && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, entry]) => [key, stableValue(entry)])\n );\n return value;\n};\n\ninterface ChangeTarget {\n readonly kind: \"put\" | \"delete\";\n readonly objectType: string;\n readonly key: Key;\n}\n\n/** Authoritative local backend with atomic mutation batches, durable receipts, and a pull journal. */\nexport const makeOwnedBackend = Effect.fnUntraced(function* (\n options: OwnedBackendOptions\n): Effect.fn.Return<OwnedBackendService, BackendError, Scope.Scope> {\n const schemas = yield* Effect.try({\n try: () => compileEffectSchemas(options.ir),\n catch: (cause) => fault(\"definition\", \"InvalidConfiguration\", \"Invalid ontology definition.\", cause),\n });\n // Backend protocols carry portable ontology values; Effect-facing clients may decode them at their boundary.\n const objectSchemas = Object.fromEntries(\n Object.entries(schemas.objectSchemas).map(([name, schema]) => [name, Schema.toEncoded(schema)])\n );\n const model = yield* boundary(\n makeStorageModel({ namespace: options.namespace, ir: options.ir, schemas: objectSchemas })\n );\n const storage = makeOntologyStorage(model, options.tables, { blobs: options.blobs });\n const tables = options.tables;\n const deliveries = yield* makeDeliveryManager({ tables, namespace: options.namespace });\n const definitionSignature = yield* Effect.try({\n try: () => ontologyDefinitionContractSignature(options.ir),\n catch: (cause) => fault(\"definition\", \"InvalidConfiguration\", \"Invalid ontology definition.\", cause),\n });\n const schemaHash = yield* boundary(\n digestBytes({\n type: \"application/json\",\n stream: Stream.make(new TextEncoder().encode(definitionSignature)),\n })\n );\n const maxCommits = options.history?.maxCommits ?? 10_000;\n if ((maxCommits !== Infinity && !Number.isSafeInteger(maxCommits)) || maxCommits < 1)\n return yield* fault(\n \"history\",\n \"InvalidConfiguration\",\n \"Journal retention requires a positive commit bound.\"\n );\n const resultRetentionMs = options.resultRetentionMs ?? 7 * 24 * 60 * 60 * 1000;\n const maintenanceIntervalMs = yield* maintenanceInterval(options.maintenance);\n if (resultRetentionMs <= 0 || Number.isNaN(resultRetentionMs))\n return yield* fault(\"retention\", \"InvalidConfiguration\", \"Result retention must be positive.\");\n if (\n options.history?.maxAgeMs !== undefined &&\n (options.history.maxAgeMs < 0 || Number.isNaN(options.history.maxAgeMs))\n )\n return yield* fault(\n \"retention\",\n \"InvalidConfiguration\",\n \"Journal retention age must be nonnegative.\"\n );\n const receiptKey = (id: string, scope?: string, legacy = false) =>\n JSON.stringify([\n options.actionScope ?? (legacy ? \"system\" : (scope ?? \"system\")),\n ...(scope === undefined ? [] : [scope]),\n id,\n ]);\n const metadata = Table.make<{ revision: number; source: string; journalFloor?: number }>({\n name: JSON.stringify([\"backend\", options.namespace, \"metadata\"]),\n });\n const receipts = Table.make<{ fingerprint: string; receipt: ActionReceipt; completedAt: number }>({\n name: JSON.stringify([\"backend\", options.namespace, \"receipts\"]),\n codec: {\n encode: (value) => Schema.encodeSync(ReceiptSchema)(value),\n decode: (value) =>\n Schema.decodeUnknownSync(ReceiptSchema)(value) as {\n fingerprint: string;\n receipt: ActionReceipt;\n completedAt: number;\n },\n },\n });\n const journal = Table.make<{ revision: number; commit: BackendCommit; committedAt: number }>({\n name: JSON.stringify([\"backend\", options.namespace, \"journal\"]),\n codec: {\n encode: (value) => Schema.encodeSync(JournalSchema)(value),\n decode: (value) =>\n Schema.decodeUnknownSync(JournalSchema)(value) as {\n revision: number;\n commit: BackendCommit;\n committedAt: number;\n },\n },\n });\n let source = \"\";\n const cursor = (revision: number) => JSON.stringify({ source, revision });\n const parseCursor = Effect.fnUntraced(function* (encoded: string | undefined, current: number) {\n if (encoded === undefined) return 0;\n const parsed = yield* Effect.try({\n try: () => Schema.decodeUnknownSync(Schema.fromJsonString(CursorSchema))(encoded),\n catch: () => fault(\"changes\", \"HistoryExpired\", \"Invalid backend change cursor.\"),\n });\n if (parsed.source !== source)\n return yield* fault(\"changes\", \"SourceMismatch\", \"Change cursor belongs to a different source.\");\n if (!Number.isSafeInteger(parsed.revision) || parsed.revision < 0 || parsed.revision > current)\n return yield* fault(\"changes\", \"HistoryExpired\", \"Invalid backend change position.\");\n return parsed.revision;\n });\n // The head is derived from committed journal rows. Updating one MVCC head\n // row on every action would make independent serializable writers conflict.\n const current = Effect.gen(function* () {\n const last = yield* tables.query(journal, {\n orderBy: [{ field: field(\"revision\"), direction: \"desc\" }],\n limit: 1,\n });\n return Math.max(last[0]?.value.revision ?? 0, (yield* tables.get(metadata, \"head\"))?.revision ?? 0);\n });\n let initialRevision = 0;\n const wakes = yield* PubSub.sliding<void>(1);\n yield* Effect.addFinalizer(() => PubSub.shutdown(wakes));\n yield* boundary(\n storage.transaction((native) =>\n Effect.gen(function* () {\n yield* tables.ensureIndex(journal, {\n name: \"revision\",\n field: { _tag: \"Field\", path: [\"revision\"] },\n unique: true,\n });\n for (const object of Object.values(model.objects))\n yield* native.ensureIndex(object, {\n name: \"primaryKey\",\n field: { _tag: \"Field\", path: [object.definition.primaryKey] },\n unique: true,\n });\n const head = yield* tables.get(metadata, \"head\");\n source = head?.source ?? `${options.namespace}:${crypto.randomUUID()}`;\n if (!head) yield* tables.put(metadata, \"head\", { source, revision: 0 });\n initialRevision = yield* current;\n })\n )\n );\n const object = (name: string) => {\n const store = model.objects[name];\n return store\n ? Effect.succeed(store)\n : Effect.fail(fault(\"object\", \"InvalidRequest\", `Unknown object type ${JSON.stringify(name)}.`));\n };\n const read = (native: ReadStorageTransaction): OwnedReadTransaction => ({\n get: (name, key) => boundary(Effect.flatMap(object(name), (store) => native.get(store, key))),\n loadSubset: (name, query) =>\n boundary(Effect.flatMap(object(name), (store) => native.query(store, query))),\n ...(native.queryGrouped\n ? {\n loadGroupedSubset: (name: string, partition: Field, query: Query) =>\n boundary(\n Effect.flatMap(object(name), (store) =>\n native.queryGrouped!(store, partition, query)\n )\n ),\n }\n : {}),\n });\n const mutation = (native: StorageTransaction) => {\n const changes = new Map<string, ChangeTarget>();\n // This gate belongs only to this transaction. Include patch reads and\n // journal tracking, beyond the lower storage layer's row/retention write.\n const gate = Semaphore.makeUnsafe(1);\n const put = (name: string, value: Record<string, unknown>) =>\n boundary(\n Effect.gen(function* () {\n const store = yield* object(name);\n const key = value[store.definition.primaryKey] as Key;\n changes.set(JSON.stringify([name, key]), {\n kind: \"put\",\n objectType: name,\n key,\n });\n yield* native.put(store, value);\n })\n );\n const tx: OwnedStorageTransaction = {\n ensureIndex: (name, index) =>\n boundary(Effect.flatMap(object(name), (store) => native.ensureIndex(store, index))),\n ...read(native),\n patch: (name, key, patches) =>\n boundary(\n Effect.gen(function* () {\n const store = yield* object(name);\n let value = yield* native.get(store, key);\n if (!value) return yield* fault(\"patch\", \"NotFound\", \"Object not found.\");\n for (const patch of patches) {\n if (!patch.path.length)\n return yield* fault(\n \"patch\",\n \"InvalidRequest\",\n \"Patch paths cannot be empty.\"\n );\n value = yield* Effect.try({\n try: () => setAtPath(value!, patch.path, patch.value),\n catch: (cause) =>\n fault(\"patch\", \"InvalidRequest\", \"Invalid patch path.\", cause),\n });\n }\n if (value[store.definition.primaryKey] !== key)\n return yield* fault(\n \"patch\",\n \"InvalidRequest\",\n \"Patches cannot change an object's identity.\"\n );\n yield* put(name, value);\n })\n ).pipe(gate.withPermits(1)),\n put: (name, value) => gate.withPermits(1)(put(name, value)),\n delete: (name, key) =>\n boundary(\n Effect.gen(function* () {\n const store = yield* object(name);\n changes.set(JSON.stringify([name, key]), {\n kind: \"delete\",\n objectType: name,\n key,\n });\n yield* native.delete(store, key);\n })\n ).pipe(gate.withPermits(1)),\n };\n return { tx, changes };\n };\n const append = Effect.fnUntraced(function* (\n native: ReadStorageTransaction,\n changes: ReadonlyMap<string, ChangeTarget>,\n operationId?: string\n ) {\n // Read canonical final values once per touched object. A failed publication\n // read rolls back the transaction rather than being caught inside a write.\n const published: ObjectChange[] = yield* Effect.forEach(changes.values(), (change) =>\n Effect.gen(function* () {\n if (change.kind === \"delete\") return { ...change, kind: \"delete\" as const };\n const value = yield* read(native).get(change.objectType, change.key);\n if (value === undefined)\n return yield* fault(\n \"commit\",\n \"Internal\",\n \"A written object is unavailable during publication.\"\n );\n return { ...change, kind: \"put\" as const, value };\n })\n );\n const revision = yield* tables.allocateRevision(journal.name, initialRevision);\n if (!Number.isSafeInteger(revision))\n return yield* fault(\"commit\", \"Unavailable\", \"Backend journal revision exhausted.\");\n const encodedCursor = cursor(revision);\n const commit: BackendCommit = { cursor: encodedCursor, operationId, changes: published };\n if (\n !(yield* tables.insert(journal, revision, {\n revision,\n commit,\n committedAt: yield* Clock.currentTimeMillis,\n }))\n )\n return yield* fault(\"commit\", \"Internal\", \"Publication revision was already committed.\");\n const journalFloor = Math.max(0, Number.isFinite(maxCommits) ? revision - maxCommits : 0);\n if (journalFloor > 0)\n for (const row of yield* tables.query(journal, {\n where: lte(field(\"revision\"), journalFloor),\n orderBy: [{ field: field(\"revision\") }],\n limit: 100,\n }))\n yield* tables.delete(journal, row.key);\n return encodedCursor;\n });\n const trustedStorage: OwnedStorageService = {\n ir: options.ir,\n read: (body) =>\n storage\n .read((native) => body(read(native)))\n .pipe(\n Effect.mapError((error) =>\n error instanceof OntologyStorageError\n ? classifyBackendFailure(\"storage\", error)\n : error\n )\n ),\n transaction: (body) =>\n Effect.gen(function* () {\n const result = yield* storage\n .transaction((native) =>\n Effect.gen(function* () {\n const { tx, changes } = mutation(native);\n const value = yield* body(tx);\n if (changes.size) yield* append(native, changes);\n return { value, changed: changes.size > 0 };\n })\n )\n .pipe(\n Effect.mapError((error) =>\n error instanceof OntologyStorageError\n ? classifyBackendFailure(\"storage\", error)\n : error\n )\n );\n if (result.changed) yield* PubSub.publish(wakes, undefined);\n return result.value;\n }),\n };\n const prepare = Effect.fn(\"OwnedBackend.prepare\")(function* (invocation: ActionRequest) {\n const authorization = yield* CurrentActionAuthorization;\n const parameterSchema = authorization\n ? authorization.parameterSchemas[invocation.name]\n : schemas.actionParameterSchemas[invocation.name];\n if (!parameterSchema) return yield* fault(\"applyAction\", \"InvalidRequest\", \"Unknown action type.\");\n if (!options.mutators[invocation.name])\n return yield* fault(\n \"applyAction\",\n \"NotImplemented\",\n `No action implementation for ${JSON.stringify(invocation.name)}.`\n );\n if (!invocation.id)\n return yield* fault(\"applyAction\", \"InvalidRequest\", \"Actions require a stable invocation ID.\");\n const encodedParameters = yield* Schema.encodeEffect(\n Schema.toCodecJson(Schema.toEncoded(parameterSchema))\n )(invocation.parameters).pipe(\n Effect.mapError(\n (error) =>\n new BackendError({\n operation: \"applyAction\",\n kind: \"ValidationFailed\",\n message: \"Action parameters do not match their definition.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n issues: schemaValidationIssues(error),\n })\n )\n );\n const attachmentIdentity = yield* Effect.forEach(invocation.attachmentUploads ?? [], (upload) =>\n digestBytes(upload.blob).pipe(\n Effect.map((digest) => ({\n id: upload.attachment.id,\n target: upload.target,\n type: byteSource(upload.blob).type,\n size: byteSource(upload.blob).size,\n digest,\n })),\n Effect.mapError((cause) =>\n fault(\"upload\", \"InvalidRequest\", \"Cannot identify attachment bytes.\", cause)\n )\n )\n );\n // A preflight avoids staging duplicate uploads on ordinary receipt retries. The\n // write transaction below rechecks identity to resolve concurrent invocations.\n const identity = JSON.stringify(\n stableValue([invocation.name, encodedParameters, attachmentIdentity, invocation.replay])\n );\n const key = receiptKey(invocation.id, authorization?.scope);\n const legacyKey = receiptKey(invocation.id, authorization?.scope, true);\n return {\n invocation,\n identity,\n receiptKey: key,\n legacyReceiptKey: key === legacyKey ? undefined : legacyKey,\n };\n });\n const invokeIn = Effect.fnUntraced(function* (\n native: StorageTransaction,\n prepared: {\n invocation: ActionRequest;\n identity: string;\n receiptKey: string;\n legacyReceiptKey?: string;\n },\n commitUploads: Effect.Effect<void, BackendError>\n ) {\n const { invocation } = prepared;\n const action = options.ir.actionTypes.find((candidate) => candidate.name === invocation.name);\n const mutator = options.mutators[invocation.name];\n if (!action || !mutator)\n return yield* fault(\n \"applyAction\",\n \"NotImplemented\",\n `No action implementation for ${JSON.stringify(invocation.name)}.`\n );\n if (!invocation.id)\n return yield* fault(\"applyAction\", \"InvalidRequest\", \"Actions require a stable invocation ID.\");\n const fingerprint = prepared.identity;\n const previous =\n (yield* tables.get(receipts, prepared.receiptKey, { forUpdate: true })) ??\n (prepared.legacyReceiptKey\n ? yield* tables.get(receipts, prepared.legacyReceiptKey, { forUpdate: true })\n : undefined);\n if (previous && previous.completedAt > (yield* Clock.currentTimeMillis) - resultRetentionMs) {\n if (previous.fingerprint !== fingerprint)\n return yield* fault(\n \"applyAction\",\n \"Conflict\",\n \"An invocation ID was reused with different parameters.\"\n );\n return { receipt: previous.receipt, changed: false };\n }\n const authorize = yield* CurrentActionAuthorization;\n const authorization = authorize ? yield* authorize.apply(read(native), invocation) : undefined;\n const permittedRead = authorization?.read ?? read(native);\n const parameters = yield* Schema.decodeUnknownEffect(\n Schema.toEncoded(schemas.actionParameterSchemas[invocation.name]!)\n )(authorization?.parameters ?? invocation.parameters).pipe(\n Effect.mapError(\n (error) =>\n new BackendError({\n operation: \"applyAction\",\n kind: \"ValidationFailed\",\n message: \"Action parameters do not match their definition.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n issues: schemaValidationIssues(error),\n })\n )\n );\n const issues = yield* actionReferenceIssues(options.ir, action.parameters, parameters, permittedRead);\n if (issues.length)\n return yield* new BackendError({\n operation: \"applyAction\",\n kind: \"ValidationFailed\",\n message: \"Submission failed validation.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n issues,\n });\n const { tx, changes } = mutation(native);\n const returned = yield* mutator({ ...tx, ...permittedRead }, { ...invocation, parameters });\n const resultSchema = schemas.actionReturnSchemas[invocation.name];\n const result = resultSchema\n ? yield* Schema.encodeEffect(Schema.toCodecJson(resultSchema))(returned).pipe(\n Effect.mapError(\n (cause) =>\n new BackendError({\n operation: \"applyAction.result\",\n kind: \"InvalidResponse\",\n retryable: false,\n actionOutcome: \"not-committed\",\n message: \"Action result does not match its definition.\",\n cause: Redacted.make(cause),\n })\n )\n )\n : undefined;\n yield* commitUploads;\n const affected = new Map<string, Set<Key>>();\n for (const change of changes.values()) {\n const keys = affected.get(change.objectType) ?? new Set<Key>();\n keys.add(change.key);\n affected.set(change.objectType, keys);\n }\n const receipt: ActionReceipt = {\n affected: [...affected].map(([objectType, keys]) => ({ objectType, keys: [...keys] })),\n affectedComplete: true,\n operationId: invocation.id,\n outcome: \"committed\",\n ...(resultSchema ? { result } : {}),\n cursor: yield* append(native, changes, invocation.id),\n };\n yield* tables.put(receipts, prepared.receiptKey, {\n fingerprint,\n receipt,\n completedAt: yield* Clock.currentTimeMillis,\n });\n return {\n receipt,\n changed: true,\n };\n });\n yield* boundary(\n tables.transaction((tx) =>\n Effect.gen(function* () {\n yield* tx.ensureIndex(receipts, { name: \"completedAt\", field: field(\"completedAt\") });\n yield* tx.ensureIndex(journal, { name: \"committedAt\", field: field(\"committedAt\") });\n })\n )\n );\n // Empty maintenance must not take predicate locks against active actions.\n // Probe a snapshot first, then recheck all conditions in the write transaction.\n const hasGarbage = tables.read((tx) =>\n Effect.gen(function* () {\n const now = yield* Clock.currentTimeMillis;\n if (Number.isFinite(resultRetentionMs)) {\n if (\n (yield* tx.query(receipts, {\n where: lte(field(\"completedAt\"), now - resultRetentionMs),\n limit: 1,\n })).length\n )\n return true;\n }\n const floor = Number.isFinite(maxCommits) ? (yield* current) - maxCommits : 0;\n const expired = [lte(field(\"revision\"), floor)];\n if (options.history?.maxAgeMs !== undefined && Number.isFinite(options.history.maxAgeMs))\n expired.push(lte(field(\"committedAt\"), now - options.history.maxAgeMs));\n return (yield* tx.query(journal, { where: or(...expired), limit: 1 })).length > 0;\n })\n );\n const collectGarbage = boundary(\n Effect.flatMap(hasGarbage, (needed) =>\n needed\n ? tables.transaction((tx) =>\n Effect.gen(function* () {\n const now = yield* Clock.currentTimeMillis;\n if (Number.isFinite(resultRetentionMs)) {\n for (const row of yield* tx.query(receipts, {\n where: lte(field(\"completedAt\"), now - resultRetentionMs),\n limit: 100,\n }))\n yield* tx.delete(receipts, row.key);\n }\n const revision = yield* current;\n const floor = Number.isFinite(maxCommits) ? revision - maxCommits : 0;\n const conditions = [lte(field(\"revision\"), floor)];\n if (\n options.history?.maxAgeMs !== undefined &&\n Number.isFinite(options.history.maxAgeMs)\n )\n conditions.push(lte(field(\"committedAt\"), now - options.history.maxAgeMs));\n const expired = yield* tx.query(journal, {\n where: or(...conditions),\n orderBy: [{ field: field(\"revision\") }],\n limit: 100,\n });\n const head = yield* tx.get(metadata, \"head\");\n if (head && expired.length)\n yield* tx.put(metadata, \"head\", {\n ...head,\n revision,\n journalFloor: Math.max(\n head.journalFloor ?? 0,\n ...expired.map((row) => row.value.revision)\n ),\n });\n for (const row of expired) yield* tx.delete(journal, row.key);\n })\n )\n : Effect.void\n )\n );\n const subscribeSelection: NonNullable<OntologyBackendService[\"subscribeSelection\"]> = Effect.fnUntraced(\n function* (selection, policy, resume) {\n const context = yield* CurrentExecutionContext;\n const subsets = yield* Effect.forEach(selection.subsets, (subset) =>\n compileObjectSubset(options.ir, subset, context)\n );\n return yield* deliveries.open({\n policy: { ...options.delivery, ...policy },\n resume,\n binding: JSON.stringify([source, schemaHash]),\n identity: JSON.stringify(selection),\n changes: PubSub.subscribe(wakes).pipe(Effect.map(Stream.fromSubscription)),\n capture: (_tx, emit) =>\n boundary(\n Effect.gen(function* () {\n for (const subset of subsets) {\n const store = yield* object(subset.objectType);\n yield* scanSelectedRows(\n (query) => boundary(storage.query(store, query)),\n subset.query,\n (row) => emit({ kind: \"base\", objectType: subset.objectType, ...row })\n );\n }\n const revision = yield* current;\n return {\n sourceId: source,\n schemaHash,\n generation: 1,\n revision: revision + 1,\n cursor: cursor(revision),\n coverage: subsets.map((subset) => ({ subset, complete: true })),\n };\n })\n ),\n });\n }\n );\n const maintenance = collectGarbage.pipe(Effect.andThen(deliveries.collectGarbage), Effect.asVoid);\n yield* scheduleMaintenance(maintenance, maintenanceIntervalMs);\n return {\n name: \"owned\",\n storage: trustedStorage,\n sourceId: source,\n maintenance,\n supportsIdempotency: true,\n subscribeSelection,\n acknowledgeDelivery: deliveries.acknowledge,\n query: (document, settings) =>\n boundary(\n storage.read((native) =>\n Effect.gen(function* () {\n const tx = read(native);\n return (yield* executeQuery(document, {\n reader: {\n ir: options.ir,\n loadSubset: (type, scan) => tx.loadSubset(type, scan),\n loadGroupedSubset: tx.loadGroupedSubset,\n },\n context: yield* CurrentExecutionContext,\n inputs: settings?.inputs,\n })).value;\n })\n )\n ),\n loadSubset: (request) =>\n boundary(\n Effect.gen(function* () {\n const subset = yield* compileObjectSubset(\n options.ir,\n request,\n yield* CurrentExecutionContext\n );\n const object = model.objects[subset.objectType];\n if (object)\n for (const index of indexesForQuery(\n subset.query ?? {},\n options.ir,\n object.definition\n ))\n yield* storage.ensureIndex(object, index);\n return yield* storage.read((native) =>\n Effect.gen(function* () {\n const rows = yield* read(native).loadSubset(subset.objectType, subset.query);\n return { rows, complete: true, cursor: cursor(yield* current) };\n })\n );\n })\n ),\n applyAction: Effect.fn(\"OwnedBackend.applyAction\")(function* (invocation: ActionRequest) {\n const prepared = yield* prepare(invocation);\n // Keep retrying retained receipts from older shared owners idempotent.\n // Both addresses include the exact authenticated scope; never probe another principal.\n const prior = yield* boundary(\n Effect.gen(function* () {\n return (\n (yield* tables.get(receipts, prepared.receiptKey)) ??\n (prepared.legacyReceiptKey\n ? yield* tables.get(receipts, prepared.legacyReceiptKey)\n : undefined)\n );\n })\n );\n if (prior && prior.completedAt > (yield* Clock.currentTimeMillis) - resultRetentionMs) {\n if (prior.fingerprint !== prepared.identity)\n return yield* fault(\n \"applyAction\",\n \"Conflict\",\n \"An invocation ID was reused with different parameters.\"\n );\n return prior.receipt;\n }\n const commitUploads = invocation.attachmentUploads?.length\n ? options.prepareUploads\n ? yield* options.prepareUploads(invocation)\n : yield* fault(\n \"applyAction\",\n \"NotImplemented\",\n \"This owned backend has no attachment upload coordinator.\"\n )\n : Effect.void;\n const result = yield* boundary(\n storage.transaction((native) => invokeIn(native, prepared, commitUploads))\n );\n if (result.changed) yield* PubSub.publish(wakes, undefined);\n // Keep cleanup throughput proportional to writes, in addition to idle maintenance.\n // A maintenance failure cannot overwrite a successful commit outcome.\n yield* collectGarbage.pipe(\n Effect.catch((error) =>\n Effect.logWarning(\"Ontology maintenance failed\", { kind: error.kind })\n )\n );\n return result.receipt;\n }),\n validateAction: (name, parameters, settings) =>\n Effect.gen(function* () {\n const action = options.ir.actionTypes.find((action) => action.name === name);\n if (!action) return yield* fault(\"validateAction\", \"InvalidRequest\", \"Unknown action type.\");\n const known = settings?.knownParameters;\n const definition = known\n ? {\n ...action,\n parameters: action.parameters.filter(\n (parameter) =>\n known.includes(parameter.name) || parameters[parameter.name] !== undefined\n ),\n }\n : action;\n const schema =\n definition === action\n ? schemas.actionParameterSchemas[name]!\n : compileEffectSchemas({ ...options.ir, actionTypes: [definition] })\n .actionParameterSchemas[name]!;\n const result = yield* Effect.result(\n Schema.decodeUnknownEffect(Schema.toEncoded(schema))(parameters)\n );\n if (result._tag === \"Failure\")\n return {\n certain: true as const,\n value: { kind: \"err\" as const, value: schemaValidationIssues(result.failure) },\n };\n const referenceIssues = yield* boundary(\n storage.read((native) =>\n actionReferenceIssues(options.ir, definition.parameters, result.success, read(native))\n )\n );\n if (referenceIssues.length)\n return {\n certain: true as const,\n value: { kind: \"err\" as const, value: referenceIssues },\n };\n // Shape validation cannot execute arbitrary mutator business logic, and\n // successful preflight never promises a later transaction will commit.\n return { certain: false as const };\n }),\n queryFunction: (name, parameters) =>\n boundary(\n storage.read((native) =>\n Effect.gen(function* () {\n const handler = options.queryFunctions?.[name];\n const definition = options.ir.queryFunctionTypes.find(\n (candidate) => candidate.name === name\n );\n if (!definition)\n return yield* fault(\"query\", \"InvalidRequest\", \"Unknown query function.\");\n if (!handler)\n return yield* fault(\n \"query\",\n \"NotImplemented\",\n `No query implementation for ${JSON.stringify(name)}.`\n );\n const parsed = yield* Schema.decodeUnknownEffect(\n Schema.toEncoded(schemas.queryParameterSchemas[name]!)\n )(parameters).pipe(\n Effect.mapError(() =>\n fault(\n \"query\",\n \"ValidationFailed\",\n \"Query parameters do not match their definition.\"\n )\n )\n );\n const authorize = yield* CurrentQueryAuthorization;\n const permittedRead = authorize\n ? yield* authorize(read(native), name, parsed)\n : read(native);\n const result = yield* handler(permittedRead, parsed);\n return yield* Schema.decodeUnknownEffect(\n Schema.toEncoded(schemas.queryReturnSchemas[name]!)\n )(result).pipe(\n Effect.mapError(() =>\n fault(\"query\", \"Internal\", \"Query result does not match its definition.\")\n )\n );\n })\n )\n ),\n changes: {\n pull: (request) =>\n boundary(\n storage.read(() =>\n Effect.gen(function* () {\n const head = yield* current;\n const after = yield* parseCursor(request.cursor, head);\n const floor = Math.max(\n (yield* tables.get(metadata, \"head\"))?.journalFloor ?? 0,\n Number.isFinite(maxCommits) ? head - maxCommits : 0\n );\n if (after < floor)\n return yield* fault(\n \"changes\",\n \"HistoryExpired\",\n \"Requested changes were compacted; acquire a fresh coordinated snapshot before resuming.\"\n );\n const limit = request.limit ?? 100;\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > 1000)\n return yield* fault(\n \"changes\",\n \"InvalidRequest\",\n \"Change page limit must be between 1 and 1000.\"\n );\n const rows = yield* tables.query(journal, {\n where: gt(field(\"revision\"), after),\n orderBy: [{ field: { _tag: \"Field\", path: [\"revision\"] } }],\n limit: limit + 1,\n });\n const page = rows.slice(0, limit);\n return {\n commits: page.map((row) => row.value.commit),\n cursor: cursor(page.at(-1)?.value.revision ?? head),\n hasMore: rows.length > limit,\n };\n })\n )\n ),\n watch: PubSub.subscribe(wakes).pipe(Effect.map(Stream.fromSubscription)),\n },\n attachments: options.attachments,\n encrypted: options.encrypted,\n };\n});\n"],"mappings":";;;;;;;;;;;;;;;AAiIA,MAAM,SAAS,WAAmB,MAA4B,SAAiB,UAC3E,IAAI,aAAa;CACb;CACA;CACA;CACA,WAAW;CACX,OAAO,UAAU,KAAA,IAAY,KAAA,IAAY,SAAS,KAAK,KAAK;AAChE,CAAC;AACL,MAAM,YAAqB,WACvB,OAAO,KAAK,OAAO,UAAU,UAAU,uBAAuB,WAAW,KAAK,CAAC,CAAC;AACpF,MAAM,eAAe,OAAO,OAAO;CAAE,QAAQ,OAAO;CAAQ,UAAU,OAAO;AAAI,CAAC;AAClF,MAAM,gBAAgB,OAAO,OAAO;CAChC,aAAa,OAAO;CACpB,SAAS;CACT,aAAa,OAAO;AACxB,CAAC;AACD,MAAM,gBAAgB,OAAO,OAAO;CAChC,UAAU,OAAO;CACjB,QAAQ;CACR,aAAa,OAAO;AACxB,CAAC;AACD,MAAM,eAAe,UAA4B;CAC7C,IAAI,MAAM,QAAQ,KAAK,GAAG,OAAO,MAAM,IAAI,WAAW;CACtD,IAAI,UAAU,QAAQ,OAAO,UAAU,UACn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AU,GAAG,KAAK;KAClC,SAAS,CAAC,EAAE,OAAO;MAAE,MAAM;MAAS,MAAM,CAAC,UAAU;KAAE,EAAE,CAAC;KAC1D,OAAO,QAAQ;IACnB,CAAC;IACD,MAAM,OAAO,KAAK,MAAM,GAAG,KAAK;IAChC,OAAO;KACH,SAAS,KAAK,KAAK,QAAQ,IAAI,MAAM,MAAM;KAC3C,QAAQ,OAAO,KAAK,GAAG,EAAE,CAAC,EAAE,MAAM,YAAY,IAAI;KAClD,SAAS,KAAK,SAAS;IAC3B;GACJ,CAAC,CACL,CACJ;GACJ,OAAO,OAAO,UAAU,KAAK,CAAC,CAAC,KAAK,OAAO,IAAI,OAAO,gBAAgB,CAAC;EAC3E;EACA,aAAa,QAAQ;EACrB,WAAW,QAAQ;CACvB;AACJ,CAAC"}
|
|
1
|
+
{"version":3,"file":"owned.js","names":[],"sources":["../src/owned.ts"],"sourcesContent":["import { compileEffectSchemas } from \"@party-stack/ontology-spec/effect\";\nimport { setAtPath } from \"@party-stack/ontology-spec/utils\";\nimport { ontologyDefinitionContractSignature } from \"@party-stack/ontology-storage\";\nimport {\n makeOntologyStorage,\n OntologyStorageError,\n makeStorageModel,\n field,\n lte,\n or,\n indexesForQuery,\n} from \"@party-stack/ontology-storage\";\nimport { digestBytes, byteSource } from \"@party-stack/ontology-storage/blobs\";\nimport { Table, gt } from \"@party-stack/ontology-storage/tables\";\nimport { Clock, Effect, PubSub, Redacted, Schema, Semaphore, Stream } from \"effect\";\nimport { makeDeliveryManager, scanSelectedRows } from \"./delivery.js\";\nimport { maintenanceInterval, scheduleMaintenance } from \"./maintenance.js\";\nimport { CurrentActionAuthorization, CurrentQueryAuthorization, CurrentExecutionContext } from \"./policy.js\";\nimport { executeQuery } from \"./query.js\";\nimport { actionReferenceIssues } from \"./references.js\";\nimport { compileObjectSubset } from \"./subset.js\";\nimport {\n classifyBackendFailure,\n schemaValidationIssues,\n BackendError,\n ActionReceiptSchema,\n BackendCommitSchema,\n} from \"./index.js\";\nimport type { DeliveryPolicy } from \"./delivery.js\";\nimport type {\n ActionRequest,\n ActionReceipt,\n BackendCommit,\n ObjectChange,\n OntologyBackendService,\n} from \"./index.js\";\nimport type { OntologyIR } from \"@party-stack/ontology-spec\";\nimport type {\n Index,\n Key,\n Query,\n Field,\n ReadStorageTransaction,\n StorageTransaction,\n} from \"@party-stack/ontology-storage\";\nimport type { TablesService } from \"@party-stack/ontology-storage/tables\";\nimport type { Scope } from \"effect\";\n\nexport interface OwnedReadTransaction {\n /** Exact grouped-read capability for the finite query executor, when available. */\n readonly loadGroupedSubset?: (\n objectType: string,\n partition: Field,\n query: Query\n ) => Effect.Effect<\n readonly { readonly key: Key; readonly value: Record<string, unknown> }[] | undefined,\n BackendError\n >;\n get(objectType: string, key: Key): Effect.Effect<Record<string, unknown> | undefined, BackendError>;\n loadSubset(\n objectType: string,\n query?: Query\n ): Effect.Effect<readonly { readonly key: Key; readonly value: Record<string, unknown> }[], BackendError>;\n}\nexport interface OwnedTransaction extends OwnedReadTransaction {\n put(objectType: string, value: Record<string, unknown>): Effect.Effect<void, BackendError>;\n /** Update explicit paths without reading or replacing unrelated private fields. */\n patch(\n objectType: string,\n key: Key,\n changes: readonly { readonly path: readonly string[]; readonly value: unknown }[]\n ): Effect.Effect<void, BackendError>;\n delete(objectType: string, key: Key): Effect.Effect<void, BackendError>;\n}\n/** Trusted persistence access, never exposed by the public backend/RPC contract. */\nexport interface OwnedStorageTransaction extends OwnedTransaction {\n ensureIndex(objectType: string, index: Index): Effect.Effect<void, BackendError>;\n}\nexport interface OwnedStorageService {\n readonly ir: OntologyIR;\n readonly read: <A, E, R>(\n body: (tx: OwnedReadTransaction) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | BackendError, R>;\n /** Data changes and their journal batch commit in the same native transaction. */\n readonly transaction: <A, E, R>(\n body: (tx: OwnedStorageTransaction) => Effect.Effect<A, E, R>\n ) => Effect.Effect<A, E | BackendError, R>;\n}\nexport interface OwnedBackendOptions {\n readonly namespace: string;\n readonly ir: OntologyIR;\n readonly tables: TablesService;\n readonly blobs?: import(\"@party-stack/ontology-storage/blobs\").BlobStorageService;\n /** Explicit authority scope; otherwise use the authenticated partition, or system for trusted unbound calls. */\n readonly actionScope?: string;\n readonly delivery?: DeliveryPolicy;\n /** Bounded replay history. Cursors behind this floor require a fresh snapshot. */\n readonly history?: { readonly maxCommits?: number; readonly maxAgeMs?: number };\n /** Infinity retains results indefinitely; finite windows bound idempotency. */\n readonly resultRetentionMs?: number;\n /** Owner-scoped sweep, every 60 seconds by default. False leaves scheduling to\n * an external owner (for example a DO alarm); maintenance remains callable.\n */\n readonly maintenance?: false | { readonly intervalMs?: number };\n readonly mutators: Readonly<\n Record<\n string,\n (tx: OwnedTransaction, invocation: ActionRequest) => Effect.Effect<unknown, BackendError>\n >\n >;\n readonly queryFunctions?: Readonly<\n Record<\n string,\n (\n tx: OwnedReadTransaction,\n parameters: Record<string, unknown>\n ) => Effect.Effect<unknown, BackendError>\n >\n >;\n readonly attachments?: OntologyBackendService[\"attachments\"];\n readonly encrypted?: OntologyBackendService[\"encrypted\"];\n /** Stage external bytes before opening the object transaction; returned metadata work joins its commit. */\n readonly prepareUploads?: (\n invocation: ActionRequest\n ) => Effect.Effect<Effect.Effect<void, BackendError>, BackendError>;\n}\nexport interface OwnedBackendService extends OntologyBackendService {\n readonly storage: OwnedStorageService;\n}\nconst selectionIdentity = Table.make<unknown>({ name: \"delivery-selection\" });\nconst fault = (operation: string, kind: BackendError[\"kind\"], message: string, cause?: unknown) =>\n new BackendError({\n operation,\n kind,\n message,\n retryable: false,\n cause: cause === undefined ? undefined : Redacted.make(cause),\n });\nconst boundary = <A, E, R>(effect: Effect.Effect<A, E, R>) =>\n effect.pipe(Effect.mapError((error) => classifyBackendFailure(\"storage\", error)));\nconst CursorSchema = Schema.Struct({ source: Schema.String, revision: Schema.Int });\nconst ReceiptSchema = Schema.Struct({\n fingerprint: Schema.String,\n receipt: ActionReceiptSchema,\n completedAt: Schema.Finite,\n});\nconst JournalSchema = Schema.Struct({\n revision: Schema.Int,\n commit: BackendCommitSchema,\n committedAt: Schema.Finite,\n});\nconst stableValue = (value: unknown): unknown => {\n if (Array.isArray(value)) return value.map(stableValue);\n if (value !== null && typeof value === \"object\")\n return Object.fromEntries(\n Object.entries(value)\n .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n .map(([key, entry]) => [key, stableValue(entry)])\n );\n return value;\n};\n\ninterface ChangeTarget {\n readonly kind: \"put\" | \"delete\";\n readonly objectType: string;\n readonly key: Key;\n}\n\n/** Authoritative local backend with atomic mutation batches, durable receipts, and a pull journal. */\nexport const makeOwnedBackend = Effect.fnUntraced(function* (\n options: OwnedBackendOptions\n): Effect.fn.Return<OwnedBackendService, BackendError, Scope.Scope> {\n const schemas = yield* Effect.try({\n try: () => compileEffectSchemas(options.ir),\n catch: (cause) => fault(\"definition\", \"InvalidConfiguration\", \"Invalid ontology definition.\", cause),\n });\n // Backend protocols carry portable ontology values; Effect-facing clients may decode them at their boundary.\n const objectSchemas = Object.fromEntries(\n Object.entries(schemas.objectSchemas).map(([name, schema]) => [name, Schema.toEncoded(schema)])\n );\n const model = yield* boundary(\n makeStorageModel({ namespace: options.namespace, ir: options.ir, schemas: objectSchemas })\n );\n const storage = makeOntologyStorage(model, options.tables, { blobs: options.blobs });\n const tables = options.tables;\n const deliveries = yield* makeDeliveryManager({ tables, namespace: options.namespace });\n const definitionSignature = yield* Effect.try({\n try: () => ontologyDefinitionContractSignature(options.ir),\n catch: (cause) => fault(\"definition\", \"InvalidConfiguration\", \"Invalid ontology definition.\", cause),\n });\n const schemaHash = yield* boundary(\n digestBytes({\n type: \"application/json\",\n stream: Stream.make(new TextEncoder().encode(definitionSignature)),\n })\n );\n const maxCommits = options.history?.maxCommits ?? 10_000;\n if ((maxCommits !== Infinity && !Number.isSafeInteger(maxCommits)) || maxCommits < 1)\n return yield* fault(\n \"history\",\n \"InvalidConfiguration\",\n \"Journal retention requires a positive commit bound.\"\n );\n const resultRetentionMs = options.resultRetentionMs ?? 7 * 24 * 60 * 60 * 1000;\n const maintenanceIntervalMs = yield* maintenanceInterval(options.maintenance);\n if (resultRetentionMs <= 0 || Number.isNaN(resultRetentionMs))\n return yield* fault(\"retention\", \"InvalidConfiguration\", \"Result retention must be positive.\");\n if (\n options.history?.maxAgeMs !== undefined &&\n (options.history.maxAgeMs < 0 || Number.isNaN(options.history.maxAgeMs))\n )\n return yield* fault(\n \"retention\",\n \"InvalidConfiguration\",\n \"Journal retention age must be nonnegative.\"\n );\n const receiptKey = (id: string, scope?: string, legacy = false) =>\n JSON.stringify([\n options.actionScope ?? (legacy ? \"system\" : (scope ?? \"system\")),\n ...(scope === undefined ? [] : [scope]),\n id,\n ]);\n const metadata = Table.make<{ revision: number; source: string; journalFloor?: number }>({\n name: JSON.stringify([\"backend\", options.namespace, \"metadata\"]),\n });\n const receipts = Table.make<{ fingerprint: string; receipt: ActionReceipt; completedAt: number }>({\n name: JSON.stringify([\"backend\", options.namespace, \"receipts\"]),\n codec: {\n encode: (value) => Schema.encodeSync(ReceiptSchema)(value),\n decode: (value) =>\n Schema.decodeUnknownSync(ReceiptSchema)(value) as {\n fingerprint: string;\n receipt: ActionReceipt;\n completedAt: number;\n },\n },\n });\n const journal = Table.make<{ revision: number; commit: BackendCommit; committedAt: number }>({\n name: JSON.stringify([\"backend\", options.namespace, \"journal\"]),\n codec: {\n encode: (value) => Schema.encodeSync(JournalSchema)(value),\n decode: (value) =>\n Schema.decodeUnknownSync(JournalSchema)(value) as {\n revision: number;\n commit: BackendCommit;\n committedAt: number;\n },\n },\n });\n let source = \"\";\n const cursor = (revision: number) => JSON.stringify({ source, revision });\n const parseCursor = Effect.fnUntraced(function* (encoded: string | undefined, current: number) {\n if (encoded === undefined) return 0;\n const parsed = yield* Effect.try({\n try: () => Schema.decodeUnknownSync(Schema.fromJsonString(CursorSchema))(encoded),\n catch: () => fault(\"changes\", \"HistoryExpired\", \"Invalid backend change cursor.\"),\n });\n if (parsed.source !== source)\n return yield* fault(\"changes\", \"SourceMismatch\", \"Change cursor belongs to a different source.\");\n if (!Number.isSafeInteger(parsed.revision) || parsed.revision < 0 || parsed.revision > current)\n return yield* fault(\"changes\", \"HistoryExpired\", \"Invalid backend change position.\");\n return parsed.revision;\n });\n // The head is derived from committed journal rows. Updating one MVCC head\n // row on every action would make independent serializable writers conflict.\n const current = Effect.gen(function* () {\n const last = yield* tables.query(journal, {\n orderBy: [{ field: field(\"revision\"), direction: \"desc\" }],\n limit: 1,\n });\n return Math.max(last[0]?.value.revision ?? 0, (yield* tables.get(metadata, \"head\"))?.revision ?? 0);\n });\n let initialRevision = 0;\n const wakes = yield* PubSub.sliding<void>(1);\n yield* Effect.addFinalizer(() => PubSub.shutdown(wakes));\n yield* boundary(\n storage.transaction((native) =>\n Effect.gen(function* () {\n yield* tables.ensureIndex(journal, {\n name: \"revision\",\n field: { _tag: \"Field\", path: [\"revision\"] },\n unique: true,\n });\n for (const object of Object.values(model.objects))\n yield* native.ensureIndex(object, {\n name: \"primaryKey\",\n field: { _tag: \"Field\", path: [object.definition.primaryKey] },\n unique: true,\n });\n const head = yield* tables.get(metadata, \"head\");\n source = head?.source ?? `${options.namespace}:${crypto.randomUUID()}`;\n if (!head) yield* tables.put(metadata, \"head\", { source, revision: 0 });\n initialRevision = yield* current;\n })\n )\n );\n const object = (name: string) => {\n const store = model.objects[name];\n return store\n ? Effect.succeed(store)\n : Effect.fail(fault(\"object\", \"InvalidRequest\", `Unknown object type ${JSON.stringify(name)}.`));\n };\n const read = (native: ReadStorageTransaction): OwnedReadTransaction => ({\n get: (name, key) => boundary(Effect.flatMap(object(name), (store) => native.get(store, key))),\n loadSubset: (name, query) =>\n boundary(Effect.flatMap(object(name), (store) => native.query(store, query))),\n ...(native.queryGrouped\n ? {\n loadGroupedSubset: (name: string, partition: Field, query: Query) =>\n boundary(\n Effect.flatMap(object(name), (store) =>\n native.queryGrouped!(store, partition, query)\n )\n ),\n }\n : {}),\n });\n const mutation = (native: StorageTransaction) => {\n const changes = new Map<string, ChangeTarget>();\n // This gate belongs only to this transaction. Include patch reads and\n // journal tracking, beyond the lower storage layer's row/retention write.\n const gate = Semaphore.makeUnsafe(1);\n const put = (name: string, value: Record<string, unknown>) =>\n boundary(\n Effect.gen(function* () {\n const store = yield* object(name);\n const key = value[store.definition.primaryKey] as Key;\n changes.set(JSON.stringify([name, key]), {\n kind: \"put\",\n objectType: name,\n key,\n });\n yield* native.put(store, value);\n })\n );\n const tx: OwnedStorageTransaction = {\n ensureIndex: (name, index) =>\n boundary(Effect.flatMap(object(name), (store) => native.ensureIndex(store, index))),\n ...read(native),\n patch: (name, key, patches) =>\n boundary(\n Effect.gen(function* () {\n const store = yield* object(name);\n let value = yield* native.get(store, key);\n if (!value) return yield* fault(\"patch\", \"NotFound\", \"Object not found.\");\n for (const patch of patches) {\n if (!patch.path.length)\n return yield* fault(\n \"patch\",\n \"InvalidRequest\",\n \"Patch paths cannot be empty.\"\n );\n value = yield* Effect.try({\n try: () => setAtPath(value!, patch.path, patch.value),\n catch: (cause) =>\n fault(\"patch\", \"InvalidRequest\", \"Invalid patch path.\", cause),\n });\n }\n if (value[store.definition.primaryKey] !== key)\n return yield* fault(\n \"patch\",\n \"InvalidRequest\",\n \"Patches cannot change an object's identity.\"\n );\n yield* put(name, value);\n })\n ).pipe(gate.withPermits(1)),\n put: (name, value) => gate.withPermits(1)(put(name, value)),\n delete: (name, key) =>\n boundary(\n Effect.gen(function* () {\n const store = yield* object(name);\n changes.set(JSON.stringify([name, key]), {\n kind: \"delete\",\n objectType: name,\n key,\n });\n yield* native.delete(store, key);\n })\n ).pipe(gate.withPermits(1)),\n };\n return { tx, changes };\n };\n const append = Effect.fnUntraced(function* (\n native: ReadStorageTransaction,\n changes: ReadonlyMap<string, ChangeTarget>,\n operationId?: string\n ) {\n // Read canonical final values once per touched object. A failed publication\n // read rolls back the transaction rather than being caught inside a write.\n const published: ObjectChange[] = yield* Effect.forEach(changes.values(), (change) =>\n Effect.gen(function* () {\n if (change.kind === \"delete\") return { ...change, kind: \"delete\" as const };\n const value = yield* read(native).get(change.objectType, change.key);\n if (value === undefined)\n return yield* fault(\n \"commit\",\n \"Internal\",\n \"A written object is unavailable during publication.\"\n );\n return { ...change, kind: \"put\" as const, value };\n })\n );\n const revision = yield* tables.allocateRevision(journal.name, initialRevision);\n if (!Number.isSafeInteger(revision))\n return yield* fault(\"commit\", \"Unavailable\", \"Backend journal revision exhausted.\");\n const encodedCursor = cursor(revision);\n const commit: BackendCommit = { cursor: encodedCursor, operationId, changes: published };\n if (\n !(yield* tables.insert(journal, revision, {\n revision,\n commit,\n committedAt: yield* Clock.currentTimeMillis,\n }))\n )\n return yield* fault(\"commit\", \"Internal\", \"Publication revision was already committed.\");\n const journalFloor = Math.max(0, Number.isFinite(maxCommits) ? revision - maxCommits : 0);\n if (journalFloor > 0)\n for (const row of yield* tables.query(journal, {\n where: lte(field(\"revision\"), journalFloor),\n orderBy: [{ field: field(\"revision\") }],\n limit: 100,\n }))\n yield* tables.delete(journal, row.key);\n return encodedCursor;\n });\n const trustedStorage: OwnedStorageService = {\n ir: options.ir,\n read: (body) =>\n storage\n .read((native) => body(read(native)))\n .pipe(\n Effect.mapError((error) =>\n error instanceof OntologyStorageError\n ? classifyBackendFailure(\"storage\", error)\n : error\n )\n ),\n transaction: (body) =>\n Effect.gen(function* () {\n const result = yield* storage\n .transaction((native) =>\n Effect.gen(function* () {\n const { tx, changes } = mutation(native);\n const value = yield* body(tx);\n if (changes.size) yield* append(native, changes);\n return { value, changed: changes.size > 0 };\n })\n )\n .pipe(\n Effect.mapError((error) =>\n error instanceof OntologyStorageError\n ? classifyBackendFailure(\"storage\", error)\n : error\n )\n );\n if (result.changed) yield* PubSub.publish(wakes, undefined);\n return result.value;\n }),\n };\n const prepare = Effect.fn(\"OwnedBackend.prepare\")(function* (invocation: ActionRequest) {\n const authorization = yield* CurrentActionAuthorization;\n const parameterSchema = authorization\n ? authorization.parameterSchemas[invocation.name]\n : schemas.actionParameterSchemas[invocation.name];\n if (!parameterSchema) return yield* fault(\"applyAction\", \"InvalidRequest\", \"Unknown action type.\");\n if (!options.mutators[invocation.name])\n return yield* fault(\n \"applyAction\",\n \"NotImplemented\",\n `No action implementation for ${JSON.stringify(invocation.name)}.`\n );\n if (!invocation.id)\n return yield* fault(\"applyAction\", \"InvalidRequest\", \"Actions require a stable invocation ID.\");\n const encodedParameters = yield* Schema.encodeEffect(\n Schema.toCodecJson(Schema.toEncoded(parameterSchema))\n )(invocation.parameters).pipe(\n Effect.mapError(\n (error) =>\n new BackendError({\n operation: \"applyAction\",\n kind: \"ValidationFailed\",\n message: \"Action parameters do not match their definition.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n issues: schemaValidationIssues(error),\n })\n )\n );\n const attachmentIdentity = yield* Effect.forEach(invocation.attachmentUploads ?? [], (upload) =>\n digestBytes(upload.blob).pipe(\n Effect.map((digest) => ({\n id: upload.attachment.id,\n target: upload.target,\n type: byteSource(upload.blob).type,\n size: byteSource(upload.blob).size,\n digest,\n })),\n Effect.mapError((cause) =>\n fault(\"upload\", \"InvalidRequest\", \"Cannot identify attachment bytes.\", cause)\n )\n )\n );\n // A preflight avoids staging duplicate uploads on ordinary receipt retries. The\n // write transaction below rechecks identity to resolve concurrent invocations.\n const identity = JSON.stringify(\n stableValue([invocation.name, encodedParameters, attachmentIdentity, invocation.replay])\n );\n const key = receiptKey(invocation.id, authorization?.scope);\n const legacyKey = receiptKey(invocation.id, authorization?.scope, true);\n return {\n invocation,\n identity,\n receiptKey: key,\n legacyReceiptKey: key === legacyKey ? undefined : legacyKey,\n };\n });\n const invokeIn = Effect.fnUntraced(function* (\n native: StorageTransaction,\n prepared: {\n invocation: ActionRequest;\n identity: string;\n receiptKey: string;\n legacyReceiptKey?: string;\n },\n commitUploads: Effect.Effect<void, BackendError>\n ) {\n const { invocation } = prepared;\n const action = options.ir.actionTypes.find((candidate) => candidate.name === invocation.name);\n const mutator = options.mutators[invocation.name];\n if (!action || !mutator)\n return yield* fault(\n \"applyAction\",\n \"NotImplemented\",\n `No action implementation for ${JSON.stringify(invocation.name)}.`\n );\n if (!invocation.id)\n return yield* fault(\"applyAction\", \"InvalidRequest\", \"Actions require a stable invocation ID.\");\n const fingerprint = prepared.identity;\n const previous =\n (yield* tables.get(receipts, prepared.receiptKey, { forUpdate: true })) ??\n (prepared.legacyReceiptKey\n ? yield* tables.get(receipts, prepared.legacyReceiptKey, { forUpdate: true })\n : undefined);\n if (previous && previous.completedAt > (yield* Clock.currentTimeMillis) - resultRetentionMs) {\n if (previous.fingerprint !== fingerprint)\n return yield* fault(\n \"applyAction\",\n \"Conflict\",\n \"An invocation ID was reused with different parameters.\"\n );\n return { receipt: previous.receipt, changed: false };\n }\n const authorize = yield* CurrentActionAuthorization;\n const authorization = authorize ? yield* authorize.apply(read(native), invocation) : undefined;\n const permittedRead = authorization?.read ?? read(native);\n const parameters = yield* Schema.decodeUnknownEffect(\n Schema.toEncoded(schemas.actionParameterSchemas[invocation.name]!)\n )(authorization?.parameters ?? invocation.parameters).pipe(\n Effect.mapError(\n (error) =>\n new BackendError({\n operation: \"applyAction\",\n kind: \"ValidationFailed\",\n message: \"Action parameters do not match their definition.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n issues: schemaValidationIssues(error),\n })\n )\n );\n const issues = yield* actionReferenceIssues(options.ir, action.parameters, parameters, permittedRead);\n if (issues.length)\n return yield* new BackendError({\n operation: \"applyAction\",\n kind: \"ValidationFailed\",\n message: \"Submission failed validation.\",\n retryable: false,\n actionOutcome: \"not-committed\",\n issues,\n });\n const { tx, changes } = mutation(native);\n const returned = yield* mutator({ ...tx, ...permittedRead }, { ...invocation, parameters });\n const resultSchema = schemas.actionReturnSchemas[invocation.name];\n const result = resultSchema\n ? yield* Schema.encodeEffect(Schema.toCodecJson(resultSchema))(returned).pipe(\n Effect.mapError(\n (cause) =>\n new BackendError({\n operation: \"applyAction.result\",\n kind: \"InvalidResponse\",\n retryable: false,\n actionOutcome: \"not-committed\",\n message: \"Action result does not match its definition.\",\n cause: Redacted.make(cause),\n })\n )\n )\n : undefined;\n yield* commitUploads;\n const affected = new Map<string, Set<Key>>();\n for (const change of changes.values()) {\n const keys = affected.get(change.objectType) ?? new Set<Key>();\n keys.add(change.key);\n affected.set(change.objectType, keys);\n }\n const receipt: ActionReceipt = {\n affected: [...affected].map(([objectType, keys]) => ({ objectType, keys: [...keys] })),\n affectedComplete: true,\n operationId: invocation.id,\n outcome: \"committed\",\n ...(resultSchema ? { result } : {}),\n cursor: yield* append(native, changes, invocation.id),\n };\n yield* tables.put(receipts, prepared.receiptKey, {\n fingerprint,\n receipt,\n completedAt: yield* Clock.currentTimeMillis,\n });\n return {\n receipt,\n changed: true,\n };\n });\n yield* boundary(\n tables.transaction((tx) =>\n Effect.gen(function* () {\n yield* tx.ensureIndex(receipts, { name: \"completedAt\", field: field(\"completedAt\") });\n yield* tx.ensureIndex(journal, { name: \"committedAt\", field: field(\"committedAt\") });\n })\n )\n );\n // Empty maintenance must not take predicate locks against active actions.\n // Probe a snapshot first, then recheck all conditions in the write transaction.\n const hasGarbage = tables.read((tx) =>\n Effect.gen(function* () {\n const now = yield* Clock.currentTimeMillis;\n if (Number.isFinite(resultRetentionMs)) {\n if (\n (yield* tx.query(receipts, {\n where: lte(field(\"completedAt\"), now - resultRetentionMs),\n limit: 1,\n })).length\n )\n return true;\n }\n const floor = Number.isFinite(maxCommits) ? (yield* current) - maxCommits : 0;\n const expired = [lte(field(\"revision\"), floor)];\n if (options.history?.maxAgeMs !== undefined && Number.isFinite(options.history.maxAgeMs))\n expired.push(lte(field(\"committedAt\"), now - options.history.maxAgeMs));\n return (yield* tx.query(journal, { where: or(...expired), limit: 1 })).length > 0;\n })\n );\n const collectGarbage = boundary(\n Effect.flatMap(hasGarbage, (needed) =>\n needed\n ? tables.transaction((tx) =>\n Effect.gen(function* () {\n const now = yield* Clock.currentTimeMillis;\n if (Number.isFinite(resultRetentionMs)) {\n for (const row of yield* tx.query(receipts, {\n where: lte(field(\"completedAt\"), now - resultRetentionMs),\n limit: 100,\n }))\n yield* tx.delete(receipts, row.key);\n }\n const revision = yield* current;\n const floor = Number.isFinite(maxCommits) ? revision - maxCommits : 0;\n const conditions = [lte(field(\"revision\"), floor)];\n if (\n options.history?.maxAgeMs !== undefined &&\n Number.isFinite(options.history.maxAgeMs)\n )\n conditions.push(lte(field(\"committedAt\"), now - options.history.maxAgeMs));\n const expired = yield* tx.query(journal, {\n where: or(...conditions),\n orderBy: [{ field: field(\"revision\") }],\n limit: 100,\n });\n const head = yield* tx.get(metadata, \"head\");\n if (head && expired.length)\n yield* tx.put(metadata, \"head\", {\n ...head,\n revision,\n journalFloor: Math.max(\n head.journalFloor ?? 0,\n ...expired.map((row) => row.value.revision)\n ),\n });\n for (const row of expired) yield* tx.delete(journal, row.key);\n })\n )\n : Effect.void\n )\n );\n const subscribeSelection: NonNullable<OntologyBackendService[\"subscribeSelection\"]> = Effect.fnUntraced(\n function* (selection, policy, resume) {\n const context = yield* CurrentExecutionContext;\n const subsets = yield* Effect.forEach(selection.subsets, (subset) =>\n compileObjectSubset(options.ir, subset, context)\n );\n return yield* deliveries.open({\n policy: { ...options.delivery, ...policy },\n resume,\n binding: JSON.stringify([source, schemaHash]),\n // Through the value codec: filter values may be dates, bigints or undefined.\n identity: selectionIdentity.encode(selection),\n changes: PubSub.subscribe(wakes).pipe(Effect.map(Stream.fromSubscription)),\n capture: (_tx, emit) =>\n boundary(\n Effect.gen(function* () {\n for (const subset of subsets) {\n const store = yield* object(subset.objectType);\n yield* scanSelectedRows(\n (query) => boundary(storage.query(store, query)),\n subset.query,\n (row) => emit({ kind: \"base\", objectType: subset.objectType, ...row })\n );\n }\n const revision = yield* current;\n return {\n sourceId: source,\n schemaHash,\n generation: 1,\n revision: revision + 1,\n cursor: cursor(revision),\n coverage: subsets.map((subset) => ({ subset, complete: true })),\n };\n })\n ),\n });\n }\n );\n const maintenance = collectGarbage.pipe(Effect.andThen(deliveries.collectGarbage), Effect.asVoid);\n yield* scheduleMaintenance(maintenance, maintenanceIntervalMs);\n return {\n name: \"owned\",\n storage: trustedStorage,\n sourceId: source,\n maintenance,\n supportsIdempotency: true,\n subscribeSelection,\n acknowledgeDelivery: deliveries.acknowledge,\n query: (document, settings) =>\n boundary(\n storage.read((native) =>\n Effect.gen(function* () {\n const tx = read(native);\n return (yield* executeQuery(document, {\n reader: {\n ir: options.ir,\n loadSubset: (type, scan) => tx.loadSubset(type, scan),\n loadGroupedSubset: tx.loadGroupedSubset,\n },\n context: yield* CurrentExecutionContext,\n inputs: settings?.inputs,\n })).value;\n })\n )\n ),\n loadSubset: (request) =>\n boundary(\n Effect.gen(function* () {\n const subset = yield* compileObjectSubset(\n options.ir,\n request,\n yield* CurrentExecutionContext\n );\n const object = model.objects[subset.objectType];\n if (object)\n for (const index of indexesForQuery(\n subset.query ?? {},\n options.ir,\n object.definition\n ))\n yield* storage.ensureIndex(object, index);\n return yield* storage.read((native) =>\n Effect.gen(function* () {\n const rows = yield* read(native).loadSubset(subset.objectType, subset.query);\n return { rows, complete: true, cursor: cursor(yield* current) };\n })\n );\n })\n ),\n applyAction: Effect.fn(\"OwnedBackend.applyAction\")(function* (invocation: ActionRequest) {\n const prepared = yield* prepare(invocation);\n // Keep retrying retained receipts from older shared owners idempotent.\n // Both addresses include the exact authenticated scope; never probe another principal.\n const prior = yield* boundary(\n Effect.gen(function* () {\n return (\n (yield* tables.get(receipts, prepared.receiptKey)) ??\n (prepared.legacyReceiptKey\n ? yield* tables.get(receipts, prepared.legacyReceiptKey)\n : undefined)\n );\n })\n );\n if (prior && prior.completedAt > (yield* Clock.currentTimeMillis) - resultRetentionMs) {\n if (prior.fingerprint !== prepared.identity)\n return yield* fault(\n \"applyAction\",\n \"Conflict\",\n \"An invocation ID was reused with different parameters.\"\n );\n return prior.receipt;\n }\n const commitUploads = invocation.attachmentUploads?.length\n ? options.prepareUploads\n ? yield* options.prepareUploads(invocation)\n : yield* fault(\n \"applyAction\",\n \"NotImplemented\",\n \"This owned backend has no attachment upload coordinator.\"\n )\n : Effect.void;\n const result = yield* boundary(\n storage.transaction((native) => invokeIn(native, prepared, commitUploads))\n );\n if (result.changed) yield* PubSub.publish(wakes, undefined);\n // Keep cleanup throughput proportional to writes, in addition to idle maintenance.\n // A maintenance failure cannot overwrite a successful commit outcome.\n yield* collectGarbage.pipe(\n Effect.catch((error) =>\n Effect.logWarning(\"Ontology maintenance failed\", { kind: error.kind })\n )\n );\n return result.receipt;\n }),\n validateAction: (name, parameters, settings) =>\n Effect.gen(function* () {\n const action = options.ir.actionTypes.find((action) => action.name === name);\n if (!action) return yield* fault(\"validateAction\", \"InvalidRequest\", \"Unknown action type.\");\n const known = settings?.knownParameters;\n const definition = known\n ? {\n ...action,\n parameters: action.parameters.filter(\n (parameter) =>\n known.includes(parameter.name) || parameters[parameter.name] !== undefined\n ),\n }\n : action;\n const schema =\n definition === action\n ? schemas.actionParameterSchemas[name]!\n : compileEffectSchemas({ ...options.ir, actionTypes: [definition] })\n .actionParameterSchemas[name]!;\n const result = yield* Effect.result(\n Schema.decodeUnknownEffect(Schema.toEncoded(schema))(parameters)\n );\n if (result._tag === \"Failure\")\n return {\n certain: true as const,\n value: { kind: \"err\" as const, value: schemaValidationIssues(result.failure) },\n };\n const referenceIssues = yield* boundary(\n storage.read((native) =>\n actionReferenceIssues(options.ir, definition.parameters, result.success, read(native))\n )\n );\n if (referenceIssues.length)\n return {\n certain: true as const,\n value: { kind: \"err\" as const, value: referenceIssues },\n };\n // Shape validation cannot execute arbitrary mutator business logic, and\n // successful preflight never promises a later transaction will commit.\n return { certain: false as const };\n }),\n queryFunction: (name, parameters) =>\n boundary(\n storage.read((native) =>\n Effect.gen(function* () {\n const handler = options.queryFunctions?.[name];\n const definition = options.ir.queryFunctionTypes.find(\n (candidate) => candidate.name === name\n );\n if (!definition)\n return yield* fault(\"query\", \"InvalidRequest\", \"Unknown query function.\");\n if (!handler)\n return yield* fault(\n \"query\",\n \"NotImplemented\",\n `No query implementation for ${JSON.stringify(name)}.`\n );\n const parsed = yield* Schema.decodeUnknownEffect(\n Schema.toEncoded(schemas.queryParameterSchemas[name]!)\n )(parameters).pipe(\n Effect.mapError(() =>\n fault(\n \"query\",\n \"ValidationFailed\",\n \"Query parameters do not match their definition.\"\n )\n )\n );\n const authorize = yield* CurrentQueryAuthorization;\n const permittedRead = authorize\n ? yield* authorize(read(native), name, parsed)\n : read(native);\n const result = yield* handler(permittedRead, parsed);\n return yield* Schema.decodeUnknownEffect(\n Schema.toEncoded(schemas.queryReturnSchemas[name]!)\n )(result).pipe(\n Effect.mapError(() =>\n fault(\"query\", \"Internal\", \"Query result does not match its definition.\")\n )\n );\n })\n )\n ),\n changes: {\n pull: (request) =>\n boundary(\n storage.read(() =>\n Effect.gen(function* () {\n const head = yield* current;\n const after = yield* parseCursor(request.cursor, head);\n const floor = Math.max(\n (yield* tables.get(metadata, \"head\"))?.journalFloor ?? 0,\n Number.isFinite(maxCommits) ? head - maxCommits : 0\n );\n if (after < floor)\n return yield* fault(\n \"changes\",\n \"HistoryExpired\",\n \"Requested changes were compacted; acquire a fresh coordinated snapshot before resuming.\"\n );\n const limit = request.limit ?? 100;\n if (!Number.isSafeInteger(limit) || limit < 1 || limit > 1000)\n return yield* fault(\n \"changes\",\n \"InvalidRequest\",\n \"Change page limit must be between 1 and 1000.\"\n );\n const rows = yield* tables.query(journal, {\n where: gt(field(\"revision\"), after),\n orderBy: [{ field: { _tag: \"Field\", path: [\"revision\"] } }],\n limit: limit + 1,\n });\n const page = rows.slice(0, limit);\n return {\n commits: page.map((row) => row.value.commit),\n cursor: cursor(page.at(-1)?.value.revision ?? head),\n hasMore: rows.length > limit,\n };\n })\n )\n ),\n watch: PubSub.subscribe(wakes).pipe(Effect.map(Stream.fromSubscription)),\n },\n attachments: options.attachments,\n encrypted: options.encrypted,\n };\n});\n"],"mappings":";;;;;;;;;;;;;;;AAiIA,MAAM,oBAAoB,MAA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Backend: (options: StorageBackendOptions) => Eff
|
|
|
17
17
|
name: string;
|
|
18
18
|
sourceId: string;
|
|
19
19
|
supportsIdempotency: boolean;
|
|
20
|
+
networks?: readonly string[];
|
|
20
21
|
loadSubset: (subset: import("@party-stack/ontology-spec/query").ObjectSubset) => Effect.Effect<BackendSnapshot, BackendError>;
|
|
21
22
|
subscribeSelection?: (selection: ObjectSelection, policy?: DeliveryPolicy, resume?: DeliveryPosition) => Effect.Effect<DeliverySubscription, BackendError, import("effect/Scope").Scope>;
|
|
22
23
|
acknowledgeDelivery?: (position: DeliveryPosition) => Effect.Effect<void, BackendError>;
|
package/lib/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","names":["_$__index_js0.BackendSnapshot","_$__index_js0.ObjectSelection","_$__delivery_js0.DeliveryPolicy","_$__delivery_js0.DeliveryPosition","_$__delivery_js0.DeliverySubscription","_$__index_js0.SubsetWatchEvent","_$__errors_js0.ValidationReport","_$__index_js0.BackendChangePage","_$__index_js0.BackendAttachments","_$__index_js0.BackendEncryptedValues","_$__owned_js0.OwnedStorageService","_$__index_js0.ActionReceipt"],"sources":["../src/storage.ts"],"mappings":";;;;;;;;iBAoBiB,8BAA8B,KAC3C;WAGS,OAAO;WACP,oBAAoB;WACpB,UAAU;WACV,WAAW;;;qBAMX,qBAAkB,SAAA,0BAAA,OAAA
|
|
1
|
+
{"version":3,"file":"storage.d.ts","names":["_$__index_js0.BackendSnapshot","_$__index_js0.ObjectSelection","_$__delivery_js0.DeliveryPolicy","_$__delivery_js0.DeliveryPosition","_$__delivery_js0.DeliverySubscription","_$__index_js0.SubsetWatchEvent","_$__errors_js0.ValidationReport","_$__index_js0.BackendChangePage","_$__index_js0.BackendAttachments","_$__index_js0.BackendEncryptedValues","_$__owned_js0.OwnedStorageService","_$__index_js0.ActionReceipt"],"sources":["../src/storage.ts"],"mappings":";;;;;;;;iBAoBiB,8BAA8B,KAC3C;WAGS,OAAO;WACP,oBAAoB;WACpB,UAAU;WACV,WAAW;;;qBAMX,qBAAkB,SAAA,0BAAA,OAAA;;;;;iGAAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8KO,iBAAA;aAAW;aAAiC;QAAgB,OAAA,eAAA;GA8ChG,wXAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@party-stack/ontology-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib"
|
|
6
6
|
],
|
|
@@ -57,8 +57,8 @@
|
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"temporal-polyfill": "^0.3.0",
|
|
60
|
-
"@party-stack/ontology-spec": "0.5.
|
|
61
|
-
"@party-stack/ontology-storage": "0.4.
|
|
60
|
+
"@party-stack/ontology-spec": "0.5.1",
|
|
61
|
+
"@party-stack/ontology-storage": "0.4.1"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@effect/vitest": "^4.0.5",
|