@sixb/core 0.1.9 → 0.1.11
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/dist/actions/index.js +9 -9
- package/dist/agents/index.js +17 -16
- package/dist/agents/index.js.map +1 -1
- package/dist/blob-storage/types.d.ts +4 -1
- package/dist/blob-storage/types.d.ts.map +1 -1
- package/dist/bootstrap/index.js +21 -20
- package/dist/bootstrap/index.js.map +1 -1
- package/dist/broker/in-memory.d.ts +8 -2
- package/dist/broker/in-memory.d.ts.map +1 -1
- package/dist/broker/index.d.ts +4 -2
- package/dist/broker/index.d.ts.map +1 -1
- package/dist/broker/index.js +7 -3
- package/dist/broker/index.js.map +1 -1
- package/dist/broker/retention.d.ts +4 -0
- package/dist/broker/retention.d.ts.map +1 -0
- package/dist/broker/subscriber.d.ts +10 -0
- package/dist/broker/subscriber.d.ts.map +1 -0
- package/dist/broker/types.d.ts +14 -1
- package/dist/broker/types.d.ts.map +1 -1
- package/dist/{chunk-ypbtykv6.js → chunk-01kj2pbh.js} +1 -1
- package/dist/{chunk-k3cqkkn2.js → chunk-1824gssz.js} +30 -65
- package/dist/chunk-1824gssz.js.map +12 -0
- package/dist/{chunk-xyr8kppc.js → chunk-1yefycb1.js} +1 -1
- package/dist/chunk-2c4j899j.js.map +1 -1
- package/dist/{chunk-ppytyr6w.js → chunk-358caqf5.js} +4 -4
- package/dist/chunk-358caqf5.js.map +12 -0
- package/dist/{chunk-m3z3x9v0.js → chunk-3ckk0xfj.js} +2 -2
- package/dist/{chunk-kxwa347f.js → chunk-3qms4nax.js} +2 -2
- package/dist/{chunk-kxwa347f.js.map → chunk-3qms4nax.js.map} +3 -3
- package/dist/{chunk-52hbv0ak.js → chunk-4zhmdsx6.js} +141 -55
- package/dist/chunk-4zhmdsx6.js.map +36 -0
- package/dist/{chunk-zcnq6105.js → chunk-85cd7e8c.js} +2 -1
- package/dist/chunk-85cd7e8c.js.map +10 -0
- package/dist/{chunk-3f7veca0.js → chunk-9x8dybsb.js} +3 -3
- package/dist/chunk-9x8dybsb.js.map +10 -0
- package/dist/{chunk-0w35wavj.js → chunk-a0e6x5hd.js} +1 -1
- package/dist/{chunk-r29fxdhn.js → chunk-aa6z4a19.js} +160 -44
- package/dist/chunk-aa6z4a19.js.map +12 -0
- package/dist/{chunk-emyyk7dx.js → chunk-cfvakeax.js} +22 -145
- package/dist/chunk-cfvakeax.js.map +12 -0
- package/dist/chunk-d62kjtbg.js.map +1 -1
- package/dist/{chunk-h1gfhhbh.js → chunk-d63nnr5b.js} +2 -2
- package/dist/{chunk-r4tfx1sf.js → chunk-fh8kgex1.js} +5 -5
- package/dist/{chunk-an5tt9y0.js → chunk-ftv470j8.js} +42 -4
- package/dist/{chunk-an5tt9y0.js.map → chunk-ftv470j8.js.map} +7 -7
- package/dist/{chunk-jjy0fhrn.js → chunk-g91qxjj0.js} +20 -3
- package/dist/chunk-g91qxjj0.js.map +12 -0
- package/dist/{chunk-hpr1r6av.js → chunk-gq8vhakp.js} +51 -40
- package/dist/{chunk-hpr1r6av.js.map → chunk-gq8vhakp.js.map} +6 -6
- package/dist/{chunk-x57ycxq0.js → chunk-gqh45d2n.js} +42 -3
- package/dist/{chunk-x57ycxq0.js.map → chunk-gqh45d2n.js.map} +3 -3
- package/dist/{chunk-mjbk2djy.js → chunk-gqm76kse.js} +231 -125
- package/dist/{chunk-mjbk2djy.js.map → chunk-gqm76kse.js.map} +9 -8
- package/dist/{chunk-e0d1rzef.js → chunk-jsy70480.js} +16 -3
- package/dist/chunk-jsy70480.js.map +15 -0
- package/dist/{chunk-0rdrecsb.js → chunk-kfee1h52.js} +116 -32
- package/dist/chunk-kfee1h52.js.map +13 -0
- package/dist/{chunk-3frsnm7x.js → chunk-qma80ych.js} +4 -6
- package/dist/chunk-qma80ych.js.map +11 -0
- package/dist/{chunk-vf691g1r.js → chunk-sepyxgpc.js} +3 -3
- package/dist/chunk-v2vcg0w6.js +151 -0
- package/dist/chunk-v2vcg0w6.js.map +11 -0
- package/dist/{chunk-3tgwrcyh.js → chunk-wf88w4kp.js} +17 -23
- package/dist/chunk-wf88w4kp.js.map +14 -0
- package/dist/{chunk-xfbydgzy.js → chunk-x9m9x2eq.js} +7 -8
- package/dist/{chunk-xfbydgzy.js.map → chunk-x9m9x2eq.js.map} +3 -3
- package/dist/{chunk-qhcpj9wc.js → chunk-z0271qkp.js} +98 -2
- package/dist/chunk-z0271qkp.js.map +15 -0
- package/dist/{chunk-1enhpacz.js → chunk-z0s4axeh.js} +6 -6
- package/dist/connectors/connections/authorizations.d.ts.map +1 -1
- package/dist/connectors/connections/command-context.d.ts +2 -0
- package/dist/connectors/connections/command-context.d.ts.map +1 -1
- package/dist/connectors/connections/contracts.d.ts +4 -1
- package/dist/connectors/connections/contracts.d.ts.map +1 -1
- package/dist/connectors/connections/execution.d.ts +1 -0
- package/dist/connectors/connections/execution.d.ts.map +1 -1
- package/dist/connectors/connections/internal.js +1 -1
- package/dist/connectors/connections/request.d.ts +3 -1
- package/dist/connectors/connections/request.d.ts.map +1 -1
- package/dist/connectors/connections/runs.d.ts +1 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/connectors/connections/service.d.ts +2 -0
- package/dist/connectors/connections/service.d.ts.map +1 -1
- package/dist/connectors/connections/tokens.d.ts.map +1 -1
- package/dist/connectors/connections/validation.d.ts +5 -1
- package/dist/connectors/connections/validation.d.ts.map +1 -1
- package/dist/connectors/types.d.ts +19 -4
- package/dist/connectors/types.d.ts.map +1 -1
- package/dist/events/execution.d.ts +1 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/outbox-dispatcher.d.ts +2 -2
- package/dist/events/outbox-dispatcher.d.ts.map +1 -1
- package/dist/events/service.d.ts +2 -2
- package/dist/events/service.d.ts.map +1 -1
- package/dist/execution/agent.js +17 -16
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/primitive.js +17 -16
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +17 -16
- package/dist/execution/request.js.map +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -29
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/changes.d.ts +5 -0
- package/dist/lake-storage/changes.d.ts.map +1 -0
- package/dist/lake-storage/in-memory.d.ts +2 -1
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +2 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +4 -2
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/types.d.ts +38 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/logging/internal.js +1 -1
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
- package/dist/maintenance/types.d.ts +1 -1
- package/dist/maintenance/types.d.ts.map +1 -1
- package/dist/materialization/index.d.ts +1 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/model.d.ts +12 -1
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.d.ts +1 -1
- package/dist/materializer/index.d.ts.map +1 -1
- package/dist/materializer/index.js +6 -6
- package/dist/materializer/materializer.d.ts +5 -1
- package/dist/materializer/materializer.d.ts.map +1 -1
- package/dist/materializer/projections/entry-validator.d.ts +2 -1
- package/dist/materializer/projections/entry-validator.d.ts.map +1 -1
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/source-materialization.d.ts +4 -3
- package/dist/materializer/projections/source-materialization.d.ts.map +1 -1
- package/dist/materializer/shared/normalize.d.ts +2 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +7 -0
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/execution/index.js +6 -6
- package/dist/models/index.js +1 -1
- package/dist/objects/index.js +10 -10
- package/dist/objects/query/index.js +6 -6
- package/dist/pipelines/index.js +7 -7
- package/dist/pipelines/run-dispatch.d.ts.map +1 -1
- package/dist/projections/internal.js +7 -9
- package/dist/projections/internal.js.map +1 -1
- package/dist/projections/run-dispatch.d.ts.map +1 -1
- package/dist/queues/in-memory.d.ts +7 -3
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/indexed-heap.d.ts +15 -0
- package/dist/queues/indexed-heap.d.ts.map +1 -0
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.js +1 -1
- package/dist/runtime/ontology-mutations.d.ts +3 -1
- package/dist/runtime/ontology-mutations.d.ts.map +1 -1
- package/dist/shares/internal.js +5 -5
- package/dist/storage/agents/provider.js +1 -1
- package/dist/storage/connector-connections/in-memory.d.ts +1 -0
- package/dist/storage/connector-connections/in-memory.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/connections.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/runs.d.ts +1 -0
- package/dist/storage/connector-connections/provider/runs.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider/shared.d.ts +1 -0
- package/dist/storage/connector-connections/provider/shared.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.d.ts +1 -0
- package/dist/storage/connector-connections/provider.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +11 -17
- package/dist/storage/connector-connections/provider.js.map +6 -6
- package/dist/storage/connector-connections/types.d.ts +6 -3
- package/dist/storage/connector-connections/types.d.ts.map +1 -1
- package/dist/storage/index.d.ts +1 -1
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +5 -5
- package/dist/storage/internal.js +1 -1
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/shared-state.d.ts +15 -2
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/source-roots.d.ts +6 -0
- package/dist/storage/ontology/in-memory/source-roots.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
- package/dist/storage/ontology/index.d.ts +1 -1
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/outbox.d.ts +1 -0
- package/dist/storage/ontology/outbox.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +16 -0
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +4 -2
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/ontology/sources.d.ts +13 -4
- package/dist/storage/ontology/sources.d.ts.map +1 -1
- package/dist/storage/projection-runs/lifecycle.d.ts.map +1 -1
- package/dist/storage/projection-runs/provider.js +2 -2
- package/dist/storage/projection-runs/types.d.ts +2 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -1
- package/dist/syncs/index.js +9 -8
- package/dist/syncs/index.js.map +1 -1
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/broker-contract.d.ts.map +1 -1
- package/dist/testing/connector-connection-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1499 -963
- package/dist/testing/index.js.map +10 -9
- package/dist/testing/lake-changes-contract.d.ts +6 -0
- package/dist/testing/lake-changes-contract.d.ts.map +1 -0
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/ontology-storage-contract.d.ts.map +1 -1
- package/dist/testing/projection-run-storage-contract.d.ts.map +1 -1
- package/dist/webhooks/connections.d.ts +6 -0
- package/dist/webhooks/connections.d.ts.map +1 -0
- package/dist/webhooks/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts.map +1 -1
- package/dist/webhooks/internal.d.ts +2 -0
- package/dist/webhooks/internal.d.ts.map +1 -1
- package/dist/webhooks/internal.js +55 -10
- package/dist/webhooks/internal.js.map +4 -3
- package/dist/webhooks/registry.d.ts +1 -1
- package/dist/webhooks/registry.d.ts.map +1 -1
- package/dist/webhooks/types.d.ts +15 -4
- package/dist/webhooks/types.d.ts.map +1 -1
- package/dist/workflows/index.js +18 -17
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/run-dispatch.d.ts +3 -1
- package/dist/workflows/run-dispatch.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/agents/model-loop.ts +7 -0
- package/src/blob-storage/types.ts +4 -1
- package/src/broker/in-memory.ts +104 -39
- package/src/broker/index.ts +4 -1
- package/src/broker/retention.ts +28 -0
- package/src/broker/subscriber.ts +21 -0
- package/src/broker/types.ts +15 -1
- package/src/connectors/builders.ts +0 -6
- package/src/connectors/connections/authorizations.ts +11 -5
- package/src/connectors/connections/command-context.ts +21 -4
- package/src/connectors/connections/contracts.ts +7 -1
- package/src/connectors/connections/execution.ts +3 -0
- package/src/connectors/connections/request.ts +56 -22
- package/src/connectors/connections/runs.ts +39 -1
- package/src/connectors/connections/service.ts +6 -0
- package/src/connectors/connections/tokens.ts +4 -0
- package/src/connectors/connections/validation.ts +91 -5
- package/src/connectors/types.ts +19 -4
- package/src/events/execution.ts +2 -2
- package/src/events/outbox-dispatcher.ts +20 -26
- package/src/events/service.ts +3 -3
- package/src/index.ts +10 -2
- package/src/lake-storage/changes.ts +43 -0
- package/src/lake-storage/in-memory.ts +75 -0
- package/src/lake-storage/index.ts +4 -0
- package/src/lake-storage/types.ts +42 -0
- package/src/logging/service.ts +1 -1
- package/src/maintenance/ontology-maintenance.ts +6 -2
- package/src/maintenance/types.ts +1 -1
- package/src/materialization/index.ts +2 -0
- package/src/materialization/model.ts +14 -1
- package/src/materializer/README.md +1 -1
- package/src/materializer/index.ts +2 -0
- package/src/materializer/materializer.ts +10 -0
- package/src/materializer/projections/entry-validator.ts +19 -1
- package/src/materializer/projections/replace.ts +36 -1
- package/src/materializer/projections/source-materialization.ts +26 -6
- package/src/materializer/shared/normalize.ts +1 -1
- package/src/models/definitions.ts +19 -0
- package/src/models/pricing.ts +6 -2
- package/src/pipelines/run-dispatch.ts +21 -1
- package/src/projections/run-dispatch.ts +30 -68
- package/src/queues/in-memory.ts +105 -62
- package/src/queues/indexed-heap.ts +74 -0
- package/src/runtime/host.ts +0 -14
- package/src/runtime/ontology-mutations.ts +4 -0
- package/src/storage/connector-connections/in-memory.ts +19 -19
- package/src/storage/connector-connections/provider/connections.ts +1 -15
- package/src/storage/connector-connections/provider/runs.ts +9 -1
- package/src/storage/connector-connections/provider/shared.ts +2 -3
- package/src/storage/connector-connections/provider.ts +6 -0
- package/src/storage/connector-connections/types.ts +8 -3
- package/src/storage/index.ts +1 -0
- package/src/storage/ontology/in-memory/materializations-state.ts +5 -18
- package/src/storage/ontology/in-memory/materializations.ts +73 -92
- package/src/storage/ontology/in-memory/shared-state.ts +36 -4
- package/src/storage/ontology/in-memory/source-roots.ts +123 -0
- package/src/storage/ontology/in-memory/sources.ts +78 -23
- package/src/storage/ontology/index.ts +1 -0
- package/src/storage/ontology/outbox.ts +1 -0
- package/src/storage/ontology/provider.ts +70 -0
- package/src/storage/ontology/sources.ts +14 -3
- package/src/storage/projection-runs/lifecycle.ts +5 -2
- package/src/storage/projection-runs/types.ts +4 -3
- package/src/syncs/run-dispatch.ts +19 -1
- package/src/testing/broker-contract.ts +95 -0
- package/src/testing/connector-connection-storage-contract.ts +29 -12
- package/src/testing/index.ts +1 -0
- package/src/testing/lake-changes-contract.ts +240 -0
- package/src/testing/lake-storage-contract.ts +29 -0
- package/src/testing/materializer-storage-contract.ts +172 -1
- package/src/testing/ontology-storage-contract.ts +15 -3
- package/src/testing/projection-run-storage-contract.ts +34 -0
- package/src/webhooks/connections.ts +56 -0
- package/src/webhooks/index.ts +2 -0
- package/src/webhooks/internal.ts +2 -0
- package/src/webhooks/registry.ts +3 -4
- package/src/webhooks/types.ts +17 -4
- package/src/workflows/run-dispatch.ts +42 -29
- package/dist/chunk-0rdrecsb.js.map +0 -11
- package/dist/chunk-3f7veca0.js.map +0 -10
- package/dist/chunk-3frsnm7x.js.map +0 -11
- package/dist/chunk-3tgwrcyh.js.map +0 -14
- package/dist/chunk-52hbv0ak.js.map +0 -36
- package/dist/chunk-e0d1rzef.js.map +0 -15
- package/dist/chunk-emyyk7dx.js.map +0 -14
- package/dist/chunk-jjy0fhrn.js.map +0 -12
- package/dist/chunk-k3cqkkn2.js.map +0 -12
- package/dist/chunk-ppytyr6w.js.map +0 -12
- package/dist/chunk-qhcpj9wc.js.map +0 -14
- package/dist/chunk-r29fxdhn.js.map +0 -11
- package/dist/chunk-zcnq6105.js.map +0 -10
- /package/dist/{chunk-ypbtykv6.js.map → chunk-01kj2pbh.js.map} +0 -0
- /package/dist/{chunk-xyr8kppc.js.map → chunk-1yefycb1.js.map} +0 -0
- /package/dist/{chunk-m3z3x9v0.js.map → chunk-3ckk0xfj.js.map} +0 -0
- /package/dist/{chunk-0w35wavj.js.map → chunk-a0e6x5hd.js.map} +0 -0
- /package/dist/{chunk-h1gfhhbh.js.map → chunk-d63nnr5b.js.map} +0 -0
- /package/dist/{chunk-r4tfx1sf.js.map → chunk-fh8kgex1.js.map} +0 -0
- /package/dist/{chunk-vf691g1r.js.map → chunk-sepyxgpc.js.map} +0 -0
- /package/dist/{chunk-1enhpacz.js.map → chunk-z0s4axeh.js.map} +0 -0
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/runtime/errors.ts", "../src/models/definitions.ts", "../src/models/catalog.ts", "../src/models/errors.ts", "../src/models/pricing.ts", "../src/models/rate-card.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"/**\n * Thrown for runtime setup, lifecycle, and internal invariant failures\n * that are not validation errors (e.g., duplicate registrations, missing\n * bootstrap resources, failed event appends, module load failures).\n */\nexport class RuntimeError extends Error {\n readonly name = \"RuntimeError\"\n}\n",
|
|
6
|
-
"import {\n MODEL_REASONING_EFFORTS,\n type ModelCapabilities,\n type ModelReasoningBudgetCapabilities,\n type ModelReasoningCapabilities,\n} from \"./language-model\"\n\nexport type ModelKind = \"language\" | \"image\" | \"video\" | \"embedding\"\n\n/** Common catalog identity shared by every present and future model runtime. */\nexport interface ModelDefinition {\n readonly kind: ModelKind\n readonly providerId: string\n readonly modelId: string\n readonly name?: string\n readonly description?: string\n readonly family?: string\n readonly tags?: readonly string[]\n readonly releaseDate?: string\n}\n\n/** Serializable facts about one concrete model offering from one provider. */\nexport interface LanguageModelDefinition extends ModelDefinition {\n readonly kind: \"language\"\n readonly knowledgeCutoff?: string\n readonly contextWindow?: number\n /** Maximum input tokens, distinct from a shared input/output context window. */\n readonly maxInputTokens?: number\n readonly maxOutputTokens?: number\n readonly capabilities: ModelCapabilities\n}\n\nexport function defineLanguageModel(definition: LanguageModelDefinition): LanguageModelDefinition {\n if (definition.kind !== \"language\") {\n throw new TypeError(\"[Sixb] Language model definitions must use kind 'language'.\")\n }\n assertModelId(definition.providerId, \"providerId\")\n assertModelId(definition.modelId, \"modelId\")\n assertOptionalString(definition.name, \"name\")\n assertOptionalString(definition.description, \"description\")\n assertOptionalString(definition.family, \"family\")\n assertOptionalString(definition.releaseDate, \"releaseDate\")\n assertOptionalString(definition.knowledgeCutoff, \"knowledgeCutoff\")\n const tags = freezeStrings(definition.tags, \"tags\")\n const capabilities = defineModelCapabilities(definition.capabilities)\n assertOptionalPositiveInteger(definition.contextWindow, \"contextWindow\")\n assertOptionalPositiveInteger(definition.maxInputTokens, \"maxInputTokens\")\n assertOptionalPositiveInteger(definition.maxOutputTokens, \"maxOutputTokens\")\n return Object.freeze({\n kind: \"language\",\n providerId: definition.providerId,\n modelId: definition.modelId,\n ...(definition.name === undefined ? {} : { name: definition.name }),\n ...(definition.description === undefined ? {} : { description: definition.description }),\n ...(definition.family === undefined ? {} : { family: definition.family }),\n ...(tags === undefined ? {} : { tags }),\n ...(definition.releaseDate === undefined ? {} : { releaseDate: definition.releaseDate }),\n ...(definition.knowledgeCutoff === undefined\n ? {}\n : { knowledgeCutoff: definition.knowledgeCutoff }),\n ...(definition.contextWindow === undefined ? {} : { contextWindow: definition.contextWindow }),\n ...(definition.maxInputTokens === undefined\n ? {}\n : { maxInputTokens: definition.maxInputTokens }),\n ...(definition.maxOutputTokens === undefined\n ? {}\n : { maxOutputTokens: definition.maxOutputTokens }),\n capabilities,\n })\n}\n\nfunction defineModelCapabilities(capabilities: unknown): ModelCapabilities {\n assertRecord(capabilities, \"capabilities\")\n const inputMediaTypes =\n capabilities.inputMediaTypes === \"any\"\n ? \"any\"\n : freezeStrings(capabilities.inputMediaTypes, \"capabilities.inputMediaTypes\")\n for (const [field, value] of Object.entries(capabilities)) {\n if (field === \"inputMediaTypes\" || field === \"reasoning\") continue\n if (value !== undefined && typeof value !== \"boolean\") {\n throw new TypeError(`[Sixb] Model capability '${field}' must be boolean.`)\n }\n }\n const reasoning = freezeReasoningCapabilities(capabilities.reasoning)\n const flags: {\n localTools?: boolean\n parallelToolCalls?: boolean\n nativeStructuredOutput?: boolean\n providerExecutedTools?: boolean\n } = {}\n for (const key of [\n \"localTools\",\n \"parallelToolCalls\",\n \"nativeStructuredOutput\",\n \"providerExecutedTools\",\n ] as const) {\n const value = capabilities[key]\n if (typeof value === \"boolean\") flags[key] = value\n }\n return Object.freeze({\n ...(inputMediaTypes === undefined ? {} : { inputMediaTypes }),\n ...(reasoning === undefined ? {} : { reasoning }),\n ...flags,\n })\n}\n\nfunction freezeReasoningCapabilities(reasoning: unknown): ModelCapabilities[\"reasoning\"] {\n if (reasoning === undefined || reasoning === false) return reasoning\n assertRecord(reasoning, \"reasoning\")\n if (reasoning.canDisable !== undefined && typeof reasoning.canDisable !== \"boolean\") {\n throw new TypeError(\"[Sixb] Model reasoning capability 'canDisable' must be boolean.\")\n }\n const efforts = freezeReasoningEfforts(reasoning.efforts)\n const budgetTokens = freezeReasoningBudgetCapabilities(reasoning.budgetTokens)\n return Object.freeze({\n ...(reasoning.canDisable === undefined ? {} : { canDisable: reasoning.canDisable }),\n ...(efforts === undefined ? {} : { efforts }),\n ...(budgetTokens === undefined ? {} : { budgetTokens }),\n } satisfies ModelReasoningCapabilities)\n}\n\nfunction freezeReasoningEfforts(\n efforts: unknown\n): readonly (typeof MODEL_REASONING_EFFORTS)[number][] | undefined {\n if (efforts === undefined) return undefined\n if (!Array.isArray(efforts)) {\n throw new TypeError(\"[Sixb] Model reasoning capability 'efforts' must be an array.\")\n }\n const seen = new Set<string>()\n return Object.freeze(\n efforts.map((value: unknown) => {\n const effort = MODEL_REASONING_EFFORTS.find((allowed) => allowed === value)\n if (effort === undefined) {\n throw new TypeError(`[Sixb] Model reasoning effort '${String(value)}' is invalid.`)\n }\n if (seen.has(effort)) {\n throw new TypeError(`[Sixb] Model reasoning effort '${effort}' is duplicated.`)\n }\n seen.add(effort)\n return effort\n })\n )\n}\n\nfunction freezeReasoningBudgetCapabilities(\n budget: unknown\n): ModelReasoningBudgetCapabilities | undefined {\n if (budget === undefined) return undefined\n assertRecord(budget, \"reasoning budgetTokens\")\n assertOptionalNonnegativeInteger(budget.min, \"capabilities.reasoning.budgetTokens.min\")\n assertOptionalNonnegativeInteger(budget.max, \"capabilities.reasoning.budgetTokens.max\")\n if (budget.min !== undefined && budget.max !== undefined && budget.max < budget.min) {\n throw new TypeError(\n \"[Sixb] Model reasoning token budget maximum must not be below its minimum.\"\n )\n }\n return Object.freeze({\n ...(budget.min === undefined ? {} : { min: budget.min }),\n ...(budget.max === undefined ? {} : { max: budget.max }),\n })\n}\n\nfunction assertModelId(value: string, field: string): void {\n if (!value.trim()) throw new TypeError(`[Sixb] Model ${field} must not be empty.`)\n}\n\nfunction assertOptionalPositiveInteger(value: number | undefined, field: string): void {\n if (value !== undefined && (!Number.isSafeInteger(value) || value <= 0)) {\n throw new TypeError(`[Sixb] Model ${field} must be a positive safe integer.`)\n }\n}\n\nfunction assertOptionalNonnegativeInteger(\n value: unknown,\n field: string\n): asserts value is number | undefined {\n if (\n value !== undefined &&\n (typeof value !== \"number\" || !Number.isSafeInteger(value) || value < 0)\n ) {\n throw new TypeError(`[Sixb] Model ${field} must be a nonnegative safe integer.`)\n }\n}\n\nfunction assertOptionalString(value: string | undefined, field: string): void {\n if (value !== undefined && typeof value !== \"string\") {\n throw new TypeError(`[Sixb] Model ${field} must be a string.`)\n }\n}\n\nfunction freezeStrings(value: unknown, field: string): readonly string[] | undefined {\n if (value === undefined) return undefined\n if (!Array.isArray(value) || value.some((entry) => typeof entry !== \"string\" || !entry.trim())) {\n throw new TypeError(`[Sixb] Model ${field} must contain nonempty strings.`)\n }\n return Object.freeze([...value])\n}\n\nfunction assertRecord(value: unknown, field: string): asserts value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value))\n throw new TypeError(`[Sixb] Model ${field} must be an object.`)\n}\n",
|
|
7
|
-
"import { RuntimeError } from \"../runtime/errors\"\nimport {\n defineLanguageModel,\n type LanguageModelDefinition,\n type ModelDefinition,\n} from \"./definitions\"\nimport type { LanguageModel } from \"./language-model\"\n\n/** Stable identity of one configured language-model binding. */\nexport interface LanguageModelRef {\n readonly provider: string\n readonly modelId: string\n}\n\n/** The configured language models, with the project default. */\nexport interface LanguageModelCatalog {\n readonly default: LanguageModelEntry\n list(): readonly LanguageModelEntry[]\n getByRef(ref: LanguageModelRef): LanguageModelEntry | null\n}\n\n/**\n * One configured language model.\n *\n * The identity describes the configured binding, not only a vendor model. For example,\n * A gateway binding and a direct provider binding for the same vendor model are distinct because their\n * `provider` values differ.\n */\nexport interface LanguageModelEntry extends LanguageModelRef {\n readonly model: LanguageModel\n}\n\n/** Models a project allows Sixb to use, organized by technical model kind. */\nexport interface ModelCatalog {\n readonly language: LanguageModelCatalog\n}\n\nexport interface ModelCatalogInput {\n /** Ordered; the first entry is the project default. */\n readonly language: readonly LanguageModel[]\n}\n\n/** Build the immutable project model catalog. Rejects invalid, duplicate, and empty catalogs. */\nexport function createModelCatalog(input: ModelCatalogInput): ModelCatalog {\n if (!Array.isArray(input?.language)) {\n throw new RuntimeError(\"[Sixb] 'models.language' must be an array of Sixb language models.\")\n }\n\n const entries: LanguageModelEntry[] = []\n const byProvider = new Map<string, Map<string, LanguageModelEntry>>()\n\n for (const [index, model] of input.language.entries()) {\n assertLanguageModel(model, index)\n\n let byModelId = byProvider.get(model.providerId)\n if (byModelId === undefined) {\n byModelId = new Map()\n byProvider.set(model.providerId, byModelId)\n }\n if (byModelId.has(model.modelId)) {\n throw new RuntimeError(\n `[Sixb] Duplicate language model '${model.providerId}/${model.modelId}' in 'models'. Each provider and model id pair may be configured once.`\n )\n }\n\n const entry = Object.freeze({\n provider: model.providerId,\n modelId: model.modelId,\n model,\n })\n byModelId.set(model.modelId, entry)\n entries.push(entry)\n }\n\n const [defaultEntry] = entries\n if (defaultEntry === undefined) {\n throw new RuntimeError(\n \"[Sixb] 'models.language' needs at least one model. Configure one or omit 'models' from createSixb().\"\n )\n }\n\n const listed = Object.freeze(entries.slice())\n const language: LanguageModelCatalog = Object.freeze({\n default: defaultEntry,\n list: () => listed,\n getByRef: (ref: LanguageModelRef) => byProvider.get(ref.provider)?.get(ref.modelId) ?? null,\n })\n\n return Object.freeze({ language })\n}\n\nfunction assertLanguageModel(model: unknown, index: number): asserts model is LanguageModel {\n if ((typeof model !== \"object\" && typeof model !== \"function\") || model === null) {\n throw invalidLanguageModel(index, \"expected a Sixb LanguageModel instance\")\n }\n\n const candidate = model as Record<string, unknown>\n assertModelIdentifier(candidate.providerId, \"provider\", index)\n assertModelIdentifier(candidate.modelId, \"modelId\", index)\n if (typeof candidate.stream !== \"function\") {\n throw invalidLanguageModel(index, \"expected 'stream' to be a function\")\n }\n try {\n const definition = defineLanguageModel(candidate.definition as LanguageModelDefinition)\n if (\n definition.providerId !== candidate.providerId ||\n definition.modelId !== candidate.modelId\n ) {\n throw new Error(\"definition identity does not match the binding\")\n }\n } catch (error) {\n throw invalidLanguageModel(index, error instanceof Error ? error.message : \"invalid definition\")\n }\n}\n\nfunction assertModelIdentifier(value: unknown, field: \"provider\" | \"modelId\", index: number): void {\n if (typeof value !== \"string\" || value.length === 0) {\n throw invalidLanguageModel(index, `expected '${field}' to be a non-empty string`)\n }\n if (value.trim() !== value) {\n throw invalidLanguageModel(index, `expected '${field}' not to have surrounding whitespace`)\n }\n}\n\nfunction invalidLanguageModel(index: number, detail: string): RuntimeError {\n return new RuntimeError(\n `[Sixb] Invalid language model at 'models.language[${index}]': ${detail}.`\n )\n}\n\n/** Provider-owned metadata lookup, independent from the project's configured bindings. */\nexport interface ModelDefinitionCatalog<TDefinition extends ModelDefinition = ModelDefinition> {\n get(modelId: string): Promise<TDefinition | undefined>\n list(): Promise<readonly TDefinition[]>\n}\n\nexport type LanguageModelDefinitionCatalog = ModelDefinitionCatalog<LanguageModelDefinition>\n",
|
|
8
|
-
"import type { ModelFinishReason, ModelUsage } from \"./events\"\nimport type { ModelCallCost } from \"./pricing\"\n\n/** Catalog transport/access failed; callers may use local metadata without masking invalid definitions. */\nexport class ModelCatalogUnavailableError extends Error {\n readonly name = \"ModelCatalogUnavailableError\"\n}\n\n/** A provider or provider protocol rejected a model request. */\nexport class ModelProviderError extends Error {\n readonly name = \"ModelProviderError\"\n\n constructor(\n message: string,\n readonly providerId: string,\n readonly modelId: string,\n options?: ErrorOptions & {\n readonly status?: number\n readonly code?: string\n readonly requestId?: string\n readonly retryAfterMs?: number\n readonly retryable?: boolean\n }\n ) {\n super(message, options)\n this.status = options?.status\n this.code = options?.code\n this.requestId = options?.requestId\n this.retryAfterMs = options?.retryAfterMs\n this.retryable = options?.retryable ?? false\n }\n\n readonly status?: number\n readonly code?: string\n readonly requestId?: string\n readonly retryAfterMs?: number\n readonly retryable: boolean\n}\n\nexport class ModelStreamError extends Error {\n readonly name = \"ModelStreamError\"\n}\n\nexport class UnsupportedModelFeatureError extends Error {\n readonly name = \"UnsupportedModelFeatureError\"\n\n constructor(\n message?: string,\n options?: ErrorOptions & {\n readonly reason?: \"unsupported-model\" | \"unsupported-schema\"\n }\n ) {\n super(message, options)\n this.reason = options?.reason\n }\n\n readonly reason?: \"unsupported-model\" | \"unsupported-schema\"\n}\n\nexport class StructuredOutputError extends Error {\n readonly name = \"StructuredOutputError\"\n\n constructor(\n message: string,\n options?: ErrorOptions & {\n readonly text?: string\n readonly providerId?: string\n readonly modelId?: string\n readonly responseId?: string\n readonly responseModelId?: string\n readonly finishReason?: ModelFinishReason\n readonly usage?: ModelUsage\n readonly cost?: ModelCallCost\n }\n ) {\n super(message, options)\n this.text = options?.text\n this.providerId = options?.providerId\n this.modelId = options?.modelId\n this.responseId = options?.responseId\n this.responseModelId = options?.responseModelId\n this.finishReason = options?.finishReason\n this.usage = options?.usage\n this.cost = options?.cost\n }\n\n readonly text?: string\n readonly providerId?: string\n readonly modelId?: string\n readonly responseId?: string\n readonly responseModelId?: string\n readonly finishReason?: ModelFinishReason\n readonly usage?: ModelUsage\n readonly cost?: ModelCallCost\n}\n",
|
|
9
|
-
"import type { ModelRoute, ModelUsage } from \"./events\"\nimport type { LanguageModel } from \"./language-model\"\nimport type { LanguageModelRateCard, ModelTokenPrice } from \"./rate-card\"\n\n/** Optional local financial enrichment cannot discard a completed, billable call. */\nexport function estimateModelCall(\n model: LanguageModel,\n input: Parameters<ModelCostEstimator[\"estimate\"]>[0]\n): ModelCostEstimate {\n try {\n return model.costEstimator?.estimate(input) ?? rateModelCall({ usage: input.usage })\n } catch {\n console.warn(\n \"[Sixb] Model cost estimation failed; preserving usage and available provider cost.\"\n )\n return { status: \"unpriceable\", reason: \"missing-rate-card\" }\n }\n}\n\nexport interface ModelMoney {\n readonly currency: \"USD\"\n /** Billionths of one currency unit, serialized as an integer string. */\n readonly amountNanos: string\n}\n\nexport interface ModelReportedCost {\n readonly money: ModelMoney\n readonly providerId?: string\n}\n\n/** A local estimate is never a provider-reported charge. No financial API is required to run. */\nexport type ModelCostEstimate = Exclude<ModelCallCost, { status: \"reported\" }>\n\nexport interface ModelCostEstimator {\n /** Conservative token-cost reservation, including cache writes and pricing tiers.\n * Return undefined when routing or non-token charges prevent a safe local estimate. */\n estimateReservation?(input: {\n readonly inputTokens: number\n readonly outputTokens: number\n }): ModelMoney | undefined\n\n estimate(input: {\n readonly usage: ModelUsage\n readonly route?: ModelRoute\n readonly responseModelId?: string\n }): ModelCostEstimate\n}\n\nexport type ModelCostMeter =\n | \"tokens.input.total\"\n | \"tokens.input.uncached\"\n | \"tokens.input.cacheRead\"\n | \"tokens.input.cacheWrite\"\n | \"tokens.input.cacheWrite5m\"\n | \"tokens.input.cacheWrite1h\"\n | \"tokens.output.total\"\n\nexport interface ModelCostComponent {\n readonly meter: ModelCostMeter\n readonly quantity: string\n readonly rateAmountNanosPerMillion: string\n readonly chargeAmountNanos: string\n}\n\nexport type ModelCallCost =\n | { readonly status: \"reported\"; readonly money: ModelMoney; readonly providerId?: string }\n | {\n readonly status: \"rated\"\n readonly money: ModelMoney\n readonly components: readonly ModelCostComponent[]\n }\n | {\n readonly status: \"unpriceable\"\n readonly reason: \"missing-rate-card\" | \"missing-usage\" | \"inconsistent-usage\"\n readonly missingMeters?: readonly ModelCostMeter[]\n }\n\n/** Reserve at the highest configured token rates, before cache usage and the final tier are known. */\nexport function estimateModelReservation(input: {\n readonly inputTokens: number\n readonly outputTokens: number\n readonly rateCard?: LanguageModelRateCard\n}): ModelMoney | undefined {\n if (!input.rateCard) return undefined\n if (![input.inputTokens, input.outputTokens].every((n) => Number.isSafeInteger(n) && n >= 0)) {\n throw new TypeError(\n \"[Sixb] Model reservation token estimates must be nonnegative safe integers.\"\n )\n }\n const maxRate = (prices: readonly (ModelTokenPrice | undefined)[]) => {\n const rates = prices.flatMap((price) =>\n price === undefined\n ? []\n : typeof price === \"string\"\n ? [price]\n : [price.default, ...price.tiers.map((tier) => tier.price)]\n )\n return rates.reduce((max, price) => {\n const rate = decimalDollarsToNanos(price)\n return rate > max ? rate : max\n }, 0n)\n }\n const card = input.rateCard\n const inputRate = maxRate([\n card.input,\n card.cacheReadInput,\n card.cacheWriteInput,\n card.cacheWriteInput5m,\n card.cacheWriteInput1h,\n ])\n const outputRate = maxRate([card.output])\n const charge = (tokens: number, rate: bigint) => (BigInt(tokens) * rate + 999_999n) / 1_000_000n\n return {\n currency: \"USD\",\n amountNanos: (\n charge(input.inputTokens, inputRate) + charge(input.outputTokens, outputRate)\n ).toString(),\n }\n}\n\n/** Prefer the provider's bill over rate-card estimates, then rate complete token meters locally. */\nexport function rateModelCall(input: {\n readonly usage: ModelUsage\n readonly rateCard?: LanguageModelRateCard\n readonly reported?: undefined\n}): ModelCostEstimate\nexport function rateModelCall(input: {\n readonly usage: ModelUsage\n readonly rateCard?: LanguageModelRateCard\n readonly reported?: ModelReportedCost\n}): ModelCallCost\nexport function rateModelCall(input: {\n readonly usage: ModelUsage\n readonly rateCard?: LanguageModelRateCard\n readonly reported?: ModelReportedCost\n}): ModelCallCost {\n if (input.reported) {\n assertAmountNanos(input.reported.money.amountNanos)\n return {\n status: \"reported\",\n money: input.reported.money,\n ...(input.reported.providerId === undefined ? {} : { providerId: input.reported.providerId }),\n }\n }\n if (!input.rateCard) return { status: \"unpriceable\", reason: \"missing-rate-card\" }\n const { usage, rateCard } = input\n if (!validUsageCounters(usage)) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n if (usage.inputTokens === undefined || usage.outputTokens === undefined) {\n return {\n status: \"unpriceable\",\n reason: \"missing-usage\",\n missingMeters: [\n ...(usage.inputTokens === undefined ? ([\"tokens.input.total\"] as const) : []),\n ...(usage.outputTokens === undefined ? ([\"tokens.output.total\"] as const) : []),\n ],\n }\n }\n\n const partitioned = partitionInputUsage(usage, rateCard)\n if (partitioned.status !== \"rated\") return partitioned\n\n const components: ModelCostComponent[] = []\n if (!partitioned.partitioned) {\n components.push(\n component(\"tokens.input.total\", usage.inputTokens, rateCard.input, usage.inputTokens)\n )\n } else {\n components.push(\n component(\"tokens.input.uncached\", partitioned.uncached, rateCard.input, usage.inputTokens)\n )\n if (partitioned.cacheRead !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheRead\",\n partitioned.cacheRead,\n rateCard.cacheReadInput!,\n usage.inputTokens\n )\n )\n }\n if (partitioned.cacheWrite !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheWrite\",\n partitioned.cacheWrite,\n rateCard.cacheWriteInput!,\n usage.inputTokens\n )\n )\n }\n if (partitioned.cacheWrite5m !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheWrite5m\",\n partitioned.cacheWrite5m,\n rateCard.cacheWriteInput5m ?? rateCard.cacheWriteInput!,\n usage.inputTokens\n )\n )\n }\n if (partitioned.cacheWrite1h !== undefined) {\n components.push(\n component(\n \"tokens.input.cacheWrite1h\",\n partitioned.cacheWrite1h,\n rateCard.cacheWriteInput1h ?? rateCard.cacheWriteInput!,\n usage.inputTokens\n )\n )\n }\n }\n components.push(\n component(\"tokens.output.total\", usage.outputTokens, rateCard.output, usage.inputTokens)\n )\n const total = components.reduce((sum, entry) => sum + BigInt(entry.chargeAmountNanos), 0n)\n return {\n status: \"rated\",\n money: { currency: rateCard.currency, amountNanos: total.toString() },\n components,\n }\n}\n\ntype PartitionResult =\n | { readonly status: \"rated\"; readonly partitioned: false }\n | {\n readonly status: \"rated\"\n readonly partitioned: true\n readonly uncached: number\n readonly cacheRead?: number\n readonly cacheWrite?: number\n readonly cacheWrite5m?: number\n readonly cacheWrite1h?: number\n }\n | Extract<ModelCallCost, { status: \"unpriceable\" }>\n\nfunction partitionInputUsage(usage: ModelUsage, rateCard: LanguageModelRateCard): PartitionResult {\n const hasSpecificWrites =\n usage.cacheWrite5mInputTokens !== undefined || usage.cacheWrite1hInputTokens !== undefined\n const cacheWriteSpecific =\n (usage.cacheWrite5mInputTokens ?? 0) + (usage.cacheWrite1hInputTokens ?? 0)\n if (\n hasSpecificWrites &&\n usage.cacheWriteInputTokens !== undefined &&\n usage.cacheWriteInputTokens !== cacheWriteSpecific\n ) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n\n const partitioned =\n usage.uncachedInputTokens !== undefined ||\n usage.cacheReadInputTokens !== undefined ||\n usage.cacheWriteInputTokens !== undefined ||\n hasSpecificWrites ||\n rateCard.cacheReadInput !== undefined ||\n rateCard.cacheWriteInput !== undefined ||\n rateCard.cacheWriteInput5m !== undefined ||\n rateCard.cacheWriteInput1h !== undefined\n if (!partitioned) return { status: \"rated\", partitioned: false }\n\n const cacheRead = usage.cacheReadInputTokens ?? 0\n const totalWrite = usage.cacheWriteInputTokens ?? cacheWriteSpecific\n if (usage.inputTokens !== undefined && cacheRead + totalWrite > usage.inputTokens) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n\n const missing: ModelCostMeter[] = []\n if (usage.uncachedInputTokens === undefined) missing.push(\"tokens.input.uncached\")\n if (rateCard.cacheReadInput !== undefined && usage.cacheReadInputTokens === undefined) {\n missing.push(\"tokens.input.cacheRead\")\n }\n if (\n rateCard.cacheWriteInput !== undefined &&\n rateCard.cacheWriteInput5m === undefined &&\n rateCard.cacheWriteInput1h === undefined &&\n usage.cacheWriteInputTokens === undefined\n ) {\n missing.push(\"tokens.input.cacheWrite\")\n }\n if (rateCard.cacheWriteInput5m !== undefined && usage.cacheWrite5mInputTokens === undefined) {\n missing.push(\"tokens.input.cacheWrite5m\")\n }\n if (rateCard.cacheWriteInput1h !== undefined && usage.cacheWrite1hInputTokens === undefined) {\n missing.push(\"tokens.input.cacheWrite1h\")\n }\n if (missing.length > 0) {\n return { status: \"unpriceable\", reason: \"missing-usage\", missingMeters: missing }\n }\n if (cacheRead > 0 && rateCard.cacheReadInput === undefined) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheRead\"],\n }\n }\n if (!hasSpecificWrites && totalWrite > 0 && rateCard.cacheWriteInput === undefined) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheWrite\"],\n }\n }\n if (\n (usage.cacheWrite5mInputTokens ?? 0) > 0 &&\n rateCard.cacheWriteInput5m === undefined &&\n rateCard.cacheWriteInput === undefined\n ) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheWrite5m\"],\n }\n }\n if (\n (usage.cacheWrite1hInputTokens ?? 0) > 0 &&\n rateCard.cacheWriteInput1h === undefined &&\n rateCard.cacheWriteInput === undefined\n ) {\n return {\n status: \"unpriceable\",\n reason: \"missing-rate-card\",\n missingMeters: [\"tokens.input.cacheWrite1h\"],\n }\n }\n\n const uncached = usage.uncachedInputTokens!\n if (uncached + cacheRead + totalWrite !== usage.inputTokens) {\n return { status: \"unpriceable\", reason: \"inconsistent-usage\" }\n }\n return {\n status: \"rated\",\n partitioned: true,\n uncached,\n ...(rateCard.cacheReadInput === undefined ? {} : { cacheRead }),\n ...(hasSpecificWrites\n ? {\n cacheWrite5m: usage.cacheWrite5mInputTokens ?? 0,\n cacheWrite1h: usage.cacheWrite1hInputTokens ?? 0,\n }\n : rateCard.cacheWriteInput === undefined\n ? {}\n : { cacheWrite: totalWrite }),\n }\n}\n\nfunction validUsageCounters(usage: ModelUsage): boolean {\n return Object.entries(usage)\n .filter(([key]) => key !== \"raw\")\n .every(([, value]) => value === undefined || (Number.isSafeInteger(value) && value >= 0))\n}\n\nfunction component(\n meter: ModelCostMeter,\n quantity: number,\n price: ModelTokenPrice,\n tierTokens: number\n): ModelCostComponent {\n const rate = decimalDollarsToNanos(resolvePrice(price, tierTokens))\n const charge = (BigInt(quantity) * rate + 500_000n) / 1_000_000n\n return {\n meter,\n quantity: quantity.toString(),\n rateAmountNanosPerMillion: rate.toString(),\n chargeAmountNanos: charge.toString(),\n }\n}\n\nfunction resolvePrice(price: ModelTokenPrice, tokens: number): string {\n if (typeof price === \"string\") return price\n return (\n price.tiers.find(\n (tier) =>\n tokens >= tier.minTokens && (tier.maxTokens === undefined || tokens < tier.maxTokens)\n )?.price ?? price.default\n )\n}\n\nfunction decimalDollarsToNanos(value: string): bigint {\n const [whole = \"0\", fraction = \"\"] = value.split(\".\")\n const nanos = fraction.slice(0, 9).padEnd(9, \"0\")\n const roundUp = Number(fraction[9] ?? \"0\") >= 5\n return BigInt(whole) * 1_000_000_000n + BigInt(nanos) + (roundUp ? 1n : 0n)\n}\n\nfunction assertAmountNanos(value: string): void {\n if (!/^(?:0|[1-9]\\d*)$/.test(value)) {\n throw new TypeError(\"[Sixb] Provider-reported model cost must use nonnegative amountNanos.\")\n }\n}\n",
|
|
10
|
-
"/** Decimal USD per million tokens. Strings keep provider prices exact. */\nexport type ModelUnitPrice = string\n\nexport interface ModelPricingTier {\n readonly minTokens: number\n readonly maxTokens?: number\n readonly price: ModelUnitPrice\n}\n\nexport type ModelTokenPrice =\n | ModelUnitPrice\n | { readonly default: ModelUnitPrice; readonly tiers: readonly ModelPricingTier[] }\n\nexport interface LanguageModelRateCard {\n readonly currency: \"USD\"\n readonly unit: \"million-tokens\"\n readonly input: ModelTokenPrice\n readonly output: ModelTokenPrice\n readonly cacheReadInput?: ModelTokenPrice\n readonly cacheWriteInput?: ModelTokenPrice\n readonly cacheWriteInput5m?: ModelTokenPrice\n readonly cacheWriteInput1h?: ModelTokenPrice\n}\n\n/** Validate and snapshot provider-owned pricing independently of operational metadata. */\nexport function defineModelRateCard(rateCard: LanguageModelRateCard): LanguageModelRateCard {\n assertRecord(rateCard, \"rate card\")\n if (rateCard.currency !== \"USD\" || rateCard.unit !== \"million-tokens\") {\n throw new TypeError(\"[Sixb] Model rate cards must use USD per million tokens.\")\n }\n return Object.freeze({\n currency: \"USD\",\n unit: \"million-tokens\",\n input: tokenPrice(rateCard.input),\n output: tokenPrice(rateCard.output),\n ...(rateCard.cacheReadInput === undefined\n ? {}\n : { cacheReadInput: tokenPrice(rateCard.cacheReadInput) }),\n ...(rateCard.cacheWriteInput === undefined\n ? {}\n : { cacheWriteInput: tokenPrice(rateCard.cacheWriteInput) }),\n ...(rateCard.cacheWriteInput5m === undefined\n ? {}\n : { cacheWriteInput5m: tokenPrice(rateCard.cacheWriteInput5m) }),\n ...(rateCard.cacheWriteInput1h === undefined\n ? {}\n : { cacheWriteInput1h: tokenPrice(rateCard.cacheWriteInput1h) }),\n })\n}\n\nfunction tokenPrice(value: ModelTokenPrice): ModelTokenPrice {\n if (typeof value === \"string\") return price(value)\n assertRecord(value, \"token price\")\n if (!Array.isArray(value.tiers)) throw new TypeError(\"[Sixb] Model price tiers must be an array.\")\n let previousMax = 0\n return Object.freeze({\n default: price(value.default),\n tiers: Object.freeze(\n value.tiers.map((tier, index) => {\n assertRecord(tier, \"price tier\")\n if (\n typeof tier.minTokens !== \"number\" ||\n !Number.isSafeInteger(tier.minTokens) ||\n tier.minTokens < 0\n ) {\n throw new TypeError(\"[Sixb] Model price tier has an invalid minimum.\")\n }\n if (index > 0 && tier.minTokens < previousMax) {\n throw new TypeError(\"[Sixb] Model price tiers must be ordered and nonoverlapping.\")\n }\n if (\n tier.maxTokens !== undefined &&\n (typeof tier.maxTokens !== \"number\" ||\n !Number.isSafeInteger(tier.maxTokens) ||\n tier.maxTokens <= tier.minTokens)\n ) {\n throw new TypeError(\"[Sixb] Model price tier has an invalid maximum.\")\n }\n previousMax = tier.maxTokens ?? Number.POSITIVE_INFINITY\n return Object.freeze({\n minTokens: tier.minTokens,\n ...(tier.maxTokens === undefined ? {} : { maxTokens: tier.maxTokens }),\n price: price(tier.price),\n })\n })\n ),\n })\n}\n\nfunction price(value: unknown): string {\n if (typeof value !== \"string\" || !/^(?:0|[1-9]\\d*)(?:\\.\\d+)?$/.test(value)) {\n throw new TypeError(\"[Sixb] Model price must be a nonnegative decimal string.\")\n }\n return value\n}\n\nfunction assertRecord(value: unknown, field: string): asserts value is Record<string, unknown> {\n if (value === null || typeof value !== \"object\" || Array.isArray(value)) {\n throw new TypeError(`[Sixb] Model ${field} must be an object.`)\n }\n}\n"
|
|
11
|
-
],
|
|
12
|
-
"mappings": ";;;;;AAKO,MAAM,sBAAqB,MAAM;AAAA,EAC7B,OAAO;AAClB;;;ACyBO,SA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AU,gBAAgB,0BAA0B;AAAA,EAChE;AAAA;",
|
|
13
|
-
"debugId": "810247FDAE074F0764756E2164756E21",
|
|
14
|
-
"names": []
|
|
15
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/connectors/errors.ts", "../src/syncs/errors.ts", "../src/syncs/run-dispatch.ts", "../src/syncs/request.ts", "../src/connectors/execution.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import {\n createSixbError,\n isSixbError,\n type SixbCodedError,\n type SixbErrorOptions,\n} from \"../errors/internal\"\nimport type { SixbErrorCode } from \"../errors/types\"\nimport { ConnectorConnectionStorageError } from \"../storage/connector-connections/errors\"\n\ntype ConnectorCodedErrorCode = Extract<SixbErrorCode, `connector.${string}`> | \"internal.unexpected\"\n\n/**\n * Legacy authoring error for static connector definitions and lookup.\n *\n * Persistent connection lifecycle failures use the global `SixbErrorCode` contract instead.\n * `ConnectorOAuthError` remains a class because adapters and Core need `instanceof` control flow at\n * the provider-effect boundary.\n */\nexport class ConnectorError extends Error {\n readonly name: string = \"ConnectorError\"\n}\n\nexport class ConnectorNotFoundError extends ConnectorError {\n override readonly name = \"ConnectorNotFoundError\"\n constructor(readonly connectorId: string) {\n super(`Unknown connector '${connectorId}'`)\n }\n}\n\n/**\n * Provider mutation outcome reported by an OAuth adapter.\n *\n * `retryable` guarantees that the provider made no change. `terminal` means the current grant can\n * no longer progress. `ambiguous` means the provider may have changed state; Core fails closed.\n * This classifies the provider effect, not the final Sixb error retry policy: Core also accounts for\n * one-use state, consumed authorization codes, and durable mutation phase before choosing a code.\n */\nexport type ConnectorOAuthErrorKind = \"retryable\" | \"terminal\" | \"ambiguous\"\n\n/** Adapter signal used by Core to decide whether a provider operation can be retried safely. */\nexport class ConnectorOAuthError extends ConnectorError {\n override readonly name = \"ConnectorOAuthError\"\n\n constructor(\n readonly kind: ConnectorOAuthErrorKind,\n message: string,\n options?: ErrorOptions\n ) {\n super(message, options)\n }\n}\n\n/** Internal factory for connector failures that cross a Sixb boundary. */\nexport function createConnectorCodedError(\n code: ConnectorCodedErrorCode,\n message: string,\n options: SixbErrorOptions = {}\n): SixbCodedError {\n return createSixbError(\n code,\n message.startsWith(\"[Sixb]\") ? message : `[Sixb] ${message}`,\n options\n )\n}\n\n/** Internal failure used when a provider operation may have completed after Core lost its fence. */\nexport function createAmbiguousProviderOperationError(\n options: SixbErrorOptions = {}\n): SixbCodedError {\n return createConnectorCodedError(\n \"connector.provider_failed\",\n \"Connector provider operation outcome is ambiguous.\",\n options\n )\n}\n\nexport function oauthErrorKind(error: unknown): ConnectorOAuthErrorKind {\n return error instanceof ConnectorOAuthError ? error.kind : \"ambiguous\"\n}\n\nexport function providerFailureCode(\n error: unknown\n): \"connector.provider_failed\" | \"connector.provider_unavailable\" {\n return oauthErrorKind(error) === \"retryable\"\n ? \"connector.provider_unavailable\"\n : \"connector.provider_failed\"\n}\n\nexport function providerBoundaryError(\n error: unknown,\n code: \"connector.provider_failed\" | \"connector.provider_unavailable\",\n message: string\n): Error {\n if (isSixbError(error) && error.code.startsWith(\"connector.\")) return error\n return createConnectorCodedError(code, message, { cause: error })\n}\n\nexport function isConnectorStorageError(\n error: unknown,\n code?: ConnectorConnectionStorageError[\"code\"]\n): error is ConnectorConnectionStorageError {\n return (\n error instanceof ConnectorConnectionStorageError && (code === undefined || error.code === code)\n )\n}\n\nexport function storageBoundaryError(error: unknown, message: string): SixbCodedError {\n return createConnectorCodedError(\"internal.unexpected\", message, { cause: error })\n}\n\nexport async function recoverConnectorFailure<T>(\n primaryError: unknown,\n message: string,\n recovery: () => Promise<T>\n): Promise<T> {\n try {\n return await recovery()\n } catch (recoveryError) {\n throw createConnectorCodedError(\"internal.unexpected\", message, {\n cause: new AggregateError([primaryError, recoveryError], message),\n })\n }\n}\n",
|
|
6
|
-
"export class SyncValidationError extends Error {\n readonly name = \"SyncValidationError\"\n}\n",
|
|
7
|
-
"import { randomUUID } from \"node:crypto\"\nimport { reportRunFailure } from \"../error-reporting/capability\"\nimport { createSixbError, toSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { RunDispatcher } from \"../execution/dispatch\"\nimport { createPrimitiveExecutionRecord } from \"../execution/durable\"\nimport type { Queues } from \"../queues\"\nimport type { SixbDefinitions } from \"../runtime/definitions\"\nimport type { CreateExecutionInput, Storage, SyncRunFailureCode, SyncRunRecord } from \"../storage\"\nimport { SYNC_RUN_FAILURE_CODES, SyncRunError } from \"../storage\"\nimport { SyncValidationError } from \"./errors\"\nimport type { SyncRunRequestOptions, SyncRunRequestResult } from \"./request\"\nimport type { SyncDefinition } from \"./types\"\n\nexport type AutomaticSyncExecutionSource =\n | { readonly type: \"schedule\"; readonly eventId: string }\n | { readonly type: \"event\"; readonly eventId: string }\n\nexport interface AutomaticSyncRunDispatchInput extends SyncRunRequestOptions {\n readonly syncId: string\n readonly runId: string\n readonly source: AutomaticSyncExecutionSource\n readonly correlationId: string\n readonly metadata?: Readonly<Record<string, string>>\n}\n\nexport type SyncRunDispatchPort = RunDispatcher<AutomaticSyncRunDispatchInput, SyncRunRequestResult>\n\nexport interface SyncRunDispatcherDependencies {\n readonly id: string\n readonly definitions: Pick<SixbDefinitions, \"syncs\">\n readonly storage: Storage\n readonly queues: Pick<Queues, \"syncRuns\">\n}\n\ninterface DispatchSyncRunInput extends SyncRunRequestOptions {\n readonly errorReporterHost: object\n readonly projectId: string\n readonly sync: SyncDefinition\n readonly storage: Storage\n readonly queue: Queues[\"syncRuns\"]\n readonly metadata?: Readonly<Record<string, string>>\n readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>\n readonly validateExistingRun?: (run: SyncRunRecord, storage: Storage) => Promise<void>\n}\n\ntype PersistedSyncRun =\n | { readonly publish: false; readonly run: SyncRunRecord }\n | {\n readonly publish: true\n readonly run: SyncRunRecord\n readonly execution: CreateExecutionInput\n readonly queuedAt: Date\n readonly created: boolean\n }\n\n/** Core-owned durable dispatch boundary used by automatic Sync triggers. */\nexport class SyncRunDispatcher implements SyncRunDispatchPort {\n constructor(private readonly dependencies: SyncRunDispatcherDependencies) {}\n\n async dispatch(input: AutomaticSyncRunDispatchInput): Promise<SyncRunRequestResult> {\n assertAutomaticDispatchInput(input)\n const sync = this.dependencies.definitions.syncs.getById(input.syncId)\n if (!sync) throw new SyncValidationError(`[Sixb] Unknown sync '${input.syncId}'`)\n\n return dispatchSyncRun({\n errorReporterHost: this.dependencies,\n projectId: this.dependencies.id,\n sync,\n storage: this.dependencies.storage,\n queue: this.dependencies.queues.syncRuns,\n runId: input.runId,\n expectedLatestVersionId: input.expectedLatestVersionId,\n commitMessage: input.commitMessage,\n metadata: input.metadata,\n validateExistingRun: (run, storage) =>\n assertAutomaticExecutionIdentity(storage, this.dependencies.id, input, run),\n createExecution: async (executionId, runId) =>\n createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"sync\", id: sync.id, runId },\n origin: {\n type: \"automatic\",\n projectId: this.dependencies.id,\n source: input.source,\n correlationId: input.correlationId,\n },\n }),\n })\n }\n}\n\n/** Persist a Sync execution and queued run before publishing its queue job. */\nexport async function dispatchSyncRun(input: DispatchSyncRunInput): Promise<SyncRunRequestResult> {\n const runId = createSyncRunId(input.runId)\n const persisted = await persistSyncRun(input, runId)\n if (!persisted.publish) return existingSyncRunResult(persisted.run)\n return publishSyncRun(input, persisted)\n}\n\nasync function persistSyncRun(\n input: DispatchSyncRunInput,\n runId: string\n): Promise<PersistedSyncRun> {\n const syncRuns = requireSyncRunStorage(input.storage)\n const existing = await syncRuns.getById({ projectId: input.projectId, id: runId })\n if (existing) return reuseSyncRun(input, existing)\n\n const execution = await input.createExecution(`exec_${randomUUID()}`, runId)\n const queuedAt = new Date()\n try {\n return await input.storage.transaction(\n async (tx): Promise<PersistedSyncRun> => {\n const transactionalRuns = requireSyncRunStorage(tx)\n const raced = await transactionalRuns.getById({ projectId: input.projectId, id: runId })\n if (raced) {\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, tx)\n return { publish: false, run: raced }\n }\n\n await tx.executions.create(execution)\n const run = await transactionalRuns.queue({\n projectId: input.projectId,\n id: runId,\n executionId: execution.id,\n syncId: input.sync.id,\n datasetId: input.sync.target.dataset.id,\n mode: input.sync.config.mode,\n queuedAt,\n expectedLatestVersionId: input.expectedLatestVersionId,\n commitMessage: input.commitMessage,\n })\n return { publish: true, run, execution, queuedAt, created: true }\n },\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof SyncRunError)) throw error\n const raced = await syncRuns.getById({ projectId: input.projectId, id: runId })\n if (!raced) throw error\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, input.storage)\n return { publish: false, run: raced }\n }\n}\n\nasync function reuseSyncRun(\n input: DispatchSyncRunInput,\n existing: SyncRunRecord\n): Promise<PersistedSyncRun> {\n assertExistingRunMatchesRequest(existing, input)\n await input.validateExistingRun?.(existing, input.storage)\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: existing.executionId,\n })\n if (!execution) {\n throw new SyncRunError(\n `[Sixb] Execution '${existing.executionId}' for Sync run '${existing.id}' was not found.`\n )\n }\n\n const queuedAt = new Date()\n const run = await requireSyncRunStorage(input.storage).queue({\n projectId: input.projectId,\n id: existing.id,\n executionId: existing.executionId,\n syncId: existing.syncId,\n datasetId: existing.datasetId,\n mode: existing.mode,\n queuedAt,\n expectedLatestVersionId: existing.expectedLatestVersionId,\n commitMessage: existing.commitMessage,\n })\n return { publish: true, run, execution, queuedAt, created: false }\n}\n\nasync function publishSyncRun(\n input: DispatchSyncRunInput,\n persisted: Extract<PersistedSyncRun, { readonly publish: true }>\n): Promise<SyncRunRequestResult> {\n try {\n const [job] = await input.queue.enqueue({\n projectId: input.projectId,\n jobs: [\n {\n id: persisted.run.id,\n type: \"sync.run.requested\",\n payload: { runId: persisted.run.id },\n ...(input.metadata === undefined ? {} : { metadata: input.metadata }),\n },\n ],\n })\n return {\n syncId: persisted.run.syncId,\n runId: persisted.run.id,\n queuedAt: persisted.queuedAt.toISOString(),\n ...(job?.id ? { jobId: job.id } : {}),\n created: persisted.created,\n }\n } catch (error) {\n const failedAt = new Date()\n const failure = toEnqueueFailure(error, persisted.run, failedAt)\n const failed = await requireSyncRunStorage(input.storage).finish({\n projectId: input.projectId,\n id: persisted.run.id,\n status: \"failed\",\n finishedAt: failedAt,\n error: failure,\n })\n reportRunFailure(input.errorReporterHost, error, {\n projectId: input.projectId,\n runKind: \"sync\",\n run: { runId: failed.id, syncId: failed.syncId },\n failure,\n })\n throw error\n }\n}\n\nfunction assertExistingRunMatchesRequest(\n existing: SyncRunRecord,\n input: Pick<DispatchSyncRunInput, \"sync\" | \"expectedLatestVersionId\" | \"commitMessage\">\n): void {\n if (\n existing.syncId !== input.sync.id ||\n existing.datasetId !== input.sync.target.dataset.id ||\n existing.mode !== input.sync.config.mode ||\n existing.expectedLatestVersionId !== input.expectedLatestVersionId ||\n existing.commitMessage !== input.commitMessage\n ) {\n throw new SyncRunError(\n `[Sixb] Sync run '${existing.id}' already exists with a different request payload.`\n )\n }\n}\n\nfunction existingSyncRunResult(existing: SyncRunRecord): SyncRunRequestResult {\n return {\n syncId: existing.syncId,\n runId: existing.id,\n queuedAt: existing.queuedAt.toISOString(),\n created: false,\n }\n}\n\nfunction requireSyncRunStorage(storage: Storage): NonNullable<Storage[\"syncRuns\"]> {\n if (!storage.syncRuns) throw new SyncValidationError(\"[Sixb] Sync run storage is not configured.\")\n return storage.syncRuns\n}\n\nfunction createSyncRunId(runId: string | undefined): string {\n if (runId === undefined) return `run_${randomUUID()}`\n if (!runId.trim()) throw new SyncValidationError(\"[Sixb] Sync run id must not be empty\")\n return runId\n}\n\nfunction assertAutomaticDispatchInput(input: AutomaticSyncRunDispatchInput): void {\n assertNonBlank(input.syncId, \"Sync id\")\n assertNonBlank(input.runId, \"Sync run id\")\n assertNonBlank(input.source.eventId, \"Sync source event id\")\n assertNonBlank(input.correlationId, \"Sync correlation id\")\n}\n\nasync function assertAutomaticExecutionIdentity(\n storage: Storage,\n projectId: string,\n input: AutomaticSyncRunDispatchInput,\n run: SyncRunRecord\n): Promise<void> {\n const execution = await storage.executions.getById({ projectId, id: run.executionId })\n if (\n !execution ||\n execution.source.type !== input.source.type ||\n execution.source.eventId !== input.source.eventId ||\n execution.correlationId !== input.correlationId ||\n execution.requestedBy !== undefined\n ) {\n throw new SyncValidationError(\n `[Sixb] Sync run '${run.id}' already exists with different automatic provenance.`\n )\n }\n}\n\nfunction toEnqueueFailure(\n error: unknown,\n run: SyncRunRecord,\n at: Date\n): SixbFailure<SyncRunFailureCode> {\n const enqueueError = createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue Sync run '${run.id}'.`,\n {\n cause: error,\n details: { syncId: run.syncId, runId: run.id, phase: \"enqueue\" },\n }\n )\n return toSixbFailure(enqueueError, { allowedCodes: SYNC_RUN_FAILURE_CODES, at })\n}\n\nfunction assertNonBlank(value: string, label: string): void {\n if (!value.trim()) throw new SyncValidationError(`[Sixb] ${label} must not be empty.`)\n}\n",
|
|
8
|
-
"import { assertAuthorized } from \"../authorization\"\nimport { resolveExecutionScopeAuthorization } from \"../execution/authorization\"\nimport {\n createPrimitiveExecutionRecord,\n ensureExecutionRecord,\n executionRecordInputFromRuntime,\n} from \"../execution/durable\"\nimport type { ExecutionContext } from \"../execution/types\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport { SyncValidationError } from \"./errors\"\nimport { dispatchSyncRun } from \"./run-dispatch\"\nimport type { SyncDefinition } from \"./types\"\n\nexport interface SyncRunRequestOptions {\n /** Stable identity used to make dispatch idempotent. */\n readonly runId?: string\n /** Optimistic concurrency guard: fail the run if the dataset moved past this version. */\n readonly expectedLatestVersionId?: string\n readonly commitMessage?: string\n}\n\nexport interface RequestSyncRunInput extends SyncRunRequestOptions {\n readonly syncId: string\n}\n\nexport interface SyncRunRequestResult {\n readonly syncId: string\n readonly runId: string\n /** Durable time at which the run entered the queue. */\n readonly queuedAt: string\n readonly jobId?: string\n readonly created: boolean\n}\n\n/**\n * Authorize and queue a sync run request.\n *\n * Operates on an already-resolved definition and the shared runtime context, so the HTTP route and\n * the runtime verb cannot drift apart.\n *\n * The immutable child execution and queued run are persisted before queue publication.\n */\nexport async function requestSyncRun(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n sync: SyncDefinition,\n options: SyncRunRequestOptions = {}\n): Promise<SyncRunRequestResult> {\n resolveExecutionScopeAuthorization(runtime.projectId, {\n execution,\n authorization: runtime.runtimeAuthorization,\n })\n assertAuthorized(runtime, { kind: \"sync.run\", syncId: sync.id })\n if (!runtime.storage.syncRuns) {\n throw new SyncValidationError(\"[Sixb] Sync run storage is not configured.\")\n }\n\n const queue = runtime.queues.syncRuns\n if (!queue) {\n throw new SyncValidationError(\"[Sixb] Sync run queue is not configured.\")\n }\n\n return dispatchSyncRun({\n errorReporterHost: runtime,\n projectId: runtime.projectId,\n sync,\n storage: runtime.storage,\n queue,\n ...options,\n createExecution: async (executionId, runId) => {\n const caller = await ensureExecutionRecord(\n runtime.storage.executions,\n executionRecordInputFromRuntime({\n execution,\n runtimeAuthorization: runtime.runtimeAuthorization,\n })\n )\n return createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"sync\", id: sync.id, runId },\n origin: { type: \"execution\", parent: caller },\n })\n },\n })\n}\n",
|
|
9
|
-
"import { AuthorizationError, assertProviderAccess } from \"../authorization\"\nimport type { ExecutionContext } from \"../execution\"\nimport { resolveExecutionScopeAuthorization } from \"../execution/authorization\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport { createConnectorCodedError } from \"./errors\"\nimport type { ConnectorService } from \"./service\"\nimport type {\n AnyConnectorAdapter,\n ConnectorAdapter,\n ConnectorClient,\n ConnectorConnectionMetadata,\n ConnectorConnectionSelector,\n ConnectorDefinition,\n OAuthConnectorAdapter,\n} from \"./types\"\nimport { isOAuthConnectorDefinition } from \"./types\"\n\n/** Resolve a registered connector through one authorized execution. */\nexport interface ConnectorRuntime {\n <TAdapter extends ConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>\n ): Promise<ConnectorClient<TAdapter>>\n <TAdapter extends OAuthConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>,\n selector: ConnectorConnectionSelector\n ): Promise<ConnectorClient<TAdapter>>\n}\n\nexport interface ConnectorExecutionSource<\n TAdapter extends AnyConnectorAdapter = AnyConnectorAdapter,\n> {\n readonly connection?: ConnectorConnectionMetadata\n connect(signal: AbortSignal): Promise<ConnectorClient<TAdapter>>\n}\n\nexport interface ConnectorExecutionSourceResolver {\n list<TAdapter extends AnyConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>\n ): Promise<readonly ConnectorExecutionSource<TAdapter>[]>\n}\n\nconst sourceResolvers = new WeakMap<ConnectorRuntime, ConnectorExecutionSourceResolver>()\n\nexport function createConnectorRuntime(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n service: ConnectorService\n): ConnectorRuntime {\n const connector = ((definition: ConnectorDefinition, selector?: ConnectorConnectionSelector) => {\n if (isOAuthConnectorDefinition(definition)) {\n assertConnectorConnectionAccess(runtime, execution)\n if (!selector) {\n throw createConnectorCodedError(\n \"connector.configuration_invalid\",\n `[Sixb] Connector '${definition.id}' uses persistent connections and requires an explicit owner and slot.`\n )\n }\n return service.connectConnection(definition, selector)\n }\n if (selector) {\n throw createConnectorCodedError(\n \"connector.configuration_invalid\",\n `[Sixb] Static connector '${definition.id}' does not accept a connection.`\n )\n }\n assertProviderAccess(runtime, execution, \"connector.connect\")\n return service.connect(definition as ConnectorDefinition<string, ConnectorAdapter>)\n }) as ConnectorRuntime\n\n registerConnectorExecutionSourceResolver(connector, {\n async list<TAdapter extends AnyConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>\n ): Promise<readonly ConnectorExecutionSource<TAdapter>[]> {\n if (!isOAuthConnectorDefinition(definition)) {\n return [\n {\n connect: (_signal) =>\n connector(definition as ConnectorDefinition<string, ConnectorAdapter>) as Promise<\n ConnectorClient<TAdapter>\n >,\n },\n ]\n }\n\n assertConnectorConnectionAccess(runtime, execution)\n const connections = await service.listExecutionConnections(definition)\n return connections.map((connection) => ({\n connection: {\n id: connection.id,\n connectorId: connection.connectorId,\n owner: connection.owner,\n slot: connection.slot,\n account: connection.account,\n },\n connect: (signal) =>\n service.connectExecutionConnection(definition, connection, signal) as Promise<\n ConnectorClient<TAdapter>\n >,\n }))\n },\n })\n return connector\n}\n\nfunction registerConnectorExecutionSourceResolver(\n connector: ConnectorRuntime,\n resolver: ConnectorExecutionSourceResolver\n): void {\n const registered = sourceResolvers.get(connector)\n if (registered && registered !== resolver) {\n throw new Error(\"[Sixb] Connector source resolver is already registered for this execution.\")\n }\n sourceResolvers.set(connector, resolver)\n}\n\nexport function getConnectorExecutionSourceResolver(\n connector: ConnectorRuntime\n): ConnectorExecutionSourceResolver {\n const resolver = sourceResolvers.get(connector)\n if (resolver) return resolver\n\n return {\n async list<TAdapter extends AnyConnectorAdapter>(\n definition: ConnectorDefinition<string, TAdapter>\n ): Promise<readonly ConnectorExecutionSource<TAdapter>[]> {\n if (isOAuthConnectorDefinition(definition)) {\n throw createConnectorCodedError(\n \"connector.configuration_invalid\",\n `[Sixb] OAuth connector '${definition.id}' cannot be resolved without the managed connection runtime.`\n )\n }\n return [\n {\n connect: (_signal) =>\n connector(definition as ConnectorDefinition<string, ConnectorAdapter>) as Promise<\n ConnectorClient<TAdapter>\n >,\n },\n ]\n },\n }\n}\n\nfunction assertConnectorConnectionAccess(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext\n): void {\n const resolved = resolveExecutionScopeAuthorization(runtime.projectId, {\n execution,\n authorization: runtime.runtimeAuthorization,\n })\n if (resolved.type === \"unrestricted\" && resolved.ref.type === \"trustedPrimitive\") return\n throw new AuthorizationError(\n \"privileged:connector-connection.connect\",\n \"[Sixb] Connector connection clients are restricted to trusted primitive executions.\"\n )\n}\n"
|
|
10
|
-
],
|
|
11
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkBO,MAAM,wBAAuB,MAAM;AAAA,EAC/B,OAAe;AAC1B;AAAA;AAEO,MAAM,gCAA+B,gBAAe;AAAA,EAEpC;AAAA,EADH,OAAO;AAAA,EACzB,WAAW,CAAU,aAAqB;AAAA,IACxC,MAAM,sBAAsB,cAAc;AAAA,IADvB;AAAA;AAGvB;AAAA;AAaO,MAAM,6BAA4B,gBAAe;AAAA,EAI3C;AAAA,EAHO,OAAO;AAAA,EAEzB,WAAW,CACA,MACT,SACA,SACA;AAAA,IACA,MAAM,SAAS,OAAO;AAAA,IAJb;AAAA;AAMb;AAGO,SAAS,yBAAyB,CACvC,MACA,SACA,UAA4B,CAAC,GACb;AAAA,EAChB,OAAO,iBACL,MACA,QAAQ,WAAW,QAAQ,IAAI,UAAU,UAAU,WACnD,OACF;AAAA;AAIK,SAAS,qCAAqC,CACnD,UAA4B,CAAC,GACb;AAAA,EAChB,OAAO,0BACL,6BACA,sDACA,OACF;AAAA;AAGK,SAAS,cAAc,CAAC,OAAyC;AAAA,EACtE,OAAO,iBAAiB,uBAAsB,MAAM,OAAO;AAAA;AAGtD,SAAS,mBAAmB,CACjC,OACgE;AAAA,EAChE,OAAO,eAAe,KAAK,MAAM,cAC7B,mCACA;AAAA;AAGC,SAAS,qBAAqB,CACnC,OACA,MACA,SACO;AAAA,EACP,IAAI,aAAY,KAAK,KAAK,MAAM,KAAK,WAAW,YAAY;AAAA,IAAG,OAAO;AAAA,EACtE,OAAO,0BAA0B,MAAM,SAAS,EAAE,OAAO,MAAM,CAAC;AAAA;AAG3D,SAAS,uBAAuB,CACrC,OACA,MAC0C;AAAA,EAC1C,OACE,iBAAiB,qCAAoC,SAAS,aAAa,MAAM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3,
|
|
3
|
-
"sources": ["../src/pipelines/errors.ts", "../src/pipelines/run-dispatch.ts", "../src/pipelines/request.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"export class PipelineError extends Error {\n readonly name = \"PipelineError\"\n}\n",
|
|
6
|
-
"import { randomUUID } from \"node:crypto\"\nimport { reportRunFailure } from \"../error-reporting/capability\"\nimport { createSixbError, toSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { RunDispatcher } from \"../execution/dispatch\"\nimport { createPrimitiveExecutionRecord } from \"../execution/durable\"\nimport type { Queues } from \"../queues\"\nimport type { SixbDefinitions } from \"../runtime/definitions\"\nimport type {\n CreateExecutionInput,\n PipelineRunFailureCode,\n PipelineRunRecord,\n Storage,\n} from \"../storage\"\nimport { PIPELINE_RUN_FAILURE_CODES, PipelineRunError } from \"../storage\"\nimport { PipelineError } from \"./errors\"\nimport type { PipelineRunRequestOptions, PipelineRunRequestResult } from \"./request\"\nimport type { PipelineDefinition } from \"./types\"\n\nexport type AutomaticPipelineExecutionSource =\n | { readonly type: \"schedule\"; readonly eventId: string }\n | { readonly type: \"event\"; readonly eventId: string }\n\nexport interface AutomaticPipelineRunDispatchInput extends PipelineRunRequestOptions {\n readonly pipelineId: string\n readonly runId: string\n readonly source: AutomaticPipelineExecutionSource\n readonly correlationId: string\n readonly metadata?: Readonly<Record<string, string>>\n}\n\nexport type PipelineRunDispatchPort = RunDispatcher<\n AutomaticPipelineRunDispatchInput,\n PipelineRunRequestResult\n>\n\nexport interface PipelineRunDispatcherDependencies {\n readonly id: string\n readonly definitions: Pick<SixbDefinitions, \"pipelines\">\n readonly storage: Storage\n readonly queues: Pick<Queues, \"pipelines\">\n}\n\ninterface DispatchPipelineRunInput extends PipelineRunRequestOptions {\n readonly errorReporterHost: object\n readonly projectId: string\n readonly pipeline: PipelineDefinition\n readonly storage: Storage\n readonly queue: Queues[\"pipelines\"]\n readonly metadata?: Readonly<Record<string, string>>\n readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>\n readonly validateExistingRun?: (run: PipelineRunRecord, storage: Storage) => Promise<void>\n}\n\ntype PersistedPipelineRun =\n | { readonly publish: false; readonly run: PipelineRunRecord }\n | {\n readonly publish: true\n readonly run: PipelineRunRecord\n readonly execution: CreateExecutionInput\n readonly queuedAt: Date\n readonly created: boolean\n }\n\n/** Core-owned durable dispatch boundary used by automatic Pipeline triggers. */\nexport class PipelineRunDispatcher implements PipelineRunDispatchPort {\n constructor(private readonly dependencies: PipelineRunDispatcherDependencies) {}\n\n async dispatch(input: AutomaticPipelineRunDispatchInput): Promise<PipelineRunRequestResult> {\n assertAutomaticDispatchInput(input)\n const pipeline = this.dependencies.definitions.pipelines.getById(input.pipelineId)\n if (!pipeline) throw new PipelineError(`[Sixb] Unknown pipeline '${input.pipelineId}'`)\n\n return dispatchPipelineRun({\n errorReporterHost: this.dependencies,\n projectId: this.dependencies.id,\n pipeline,\n storage: this.dependencies.storage,\n queue: this.dependencies.queues.pipelines,\n runId: input.runId,\n metadata: input.metadata,\n validateExistingRun: (run, storage) =>\n assertAutomaticExecutionIdentity(storage, this.dependencies.id, input, run),\n createExecution: async (executionId, runId) =>\n createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"pipeline\", id: pipeline.id, runId },\n origin: {\n type: \"automatic\",\n projectId: this.dependencies.id,\n source: input.source,\n correlationId: input.correlationId,\n },\n }),\n })\n }\n}\n\n/** Persist a Pipeline execution and queued run before publishing its queue job. */\nexport async function dispatchPipelineRun(\n input: DispatchPipelineRunInput\n): Promise<PipelineRunRequestResult> {\n const runId = createPipelineRunId(input.runId)\n const persisted = await persistPipelineRun(input, runId)\n if (!persisted.publish) return existingPipelineRunResult(persisted.run)\n return publishPipelineRun(input, persisted)\n}\n\nasync function persistPipelineRun(\n input: DispatchPipelineRunInput,\n runId: string\n): Promise<PersistedPipelineRun> {\n const pipelineRuns = requirePipelineRunStorage(input.storage)\n const existing = await pipelineRuns.getById({ projectId: input.projectId, id: runId })\n if (existing) return reusePipelineRun(input, existing)\n\n const execution = await input.createExecution(`exec_${randomUUID()}`, runId)\n const queuedAt = new Date()\n try {\n return await input.storage.transaction(\n async (tx): Promise<PersistedPipelineRun> => {\n const transactionalRuns = requirePipelineRunStorage(tx)\n const raced = await transactionalRuns.getById({ projectId: input.projectId, id: runId })\n if (raced) {\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, tx)\n return { publish: false, run: raced }\n }\n\n await tx.executions.create(execution)\n const run = await transactionalRuns.queue({\n projectId: input.projectId,\n id: runId,\n executionId: execution.id,\n pipelineId: input.pipeline.id,\n queuedAt,\n })\n return { publish: true, run, execution, queuedAt, created: true }\n },\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof PipelineRunError)) throw error\n const raced = await pipelineRuns.getById({ projectId: input.projectId, id: runId })\n if (!raced) throw error\n assertExistingRunMatchesRequest(raced, input)\n await input.validateExistingRun?.(raced, input.storage)\n return { publish: false, run: raced }\n }\n}\n\nasync function reusePipelineRun(\n input: DispatchPipelineRunInput,\n existing: PipelineRunRecord\n): Promise<PersistedPipelineRun> {\n assertExistingRunMatchesRequest(existing, input)\n await input.validateExistingRun?.(existing, input.storage)\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n\n const execution = await input.storage.executions.getById({\n projectId: input.projectId,\n id: existing.executionId,\n })\n if (!execution) {\n throw new PipelineRunError(\n `[Sixb] Execution '${existing.executionId}' for Pipeline run '${existing.id}' was not found.`\n )\n }\n\n const queuedAt = new Date()\n const run = await requirePipelineRunStorage(input.storage).queue({\n projectId: input.projectId,\n id: existing.id,\n executionId: existing.executionId,\n pipelineId: existing.pipelineId,\n queuedAt,\n })\n return { publish: true, run, execution, queuedAt, created: false }\n}\n\nasync function publishPipelineRun(\n input: DispatchPipelineRunInput,\n persisted: Extract<PersistedPipelineRun, { readonly publish: true }>\n): Promise<PipelineRunRequestResult> {\n try {\n const [job] = await input.queue.enqueue({\n projectId: input.projectId,\n jobs: [\n {\n id: persisted.run.id,\n type: \"pipeline.run.requested\",\n payload: { runId: persisted.run.id },\n ...(input.metadata === undefined ? {} : { metadata: input.metadata }),\n },\n ],\n })\n return {\n pipelineId: persisted.run.pipelineId,\n runId: persisted.run.id,\n queuedAt: persisted.queuedAt.toISOString(),\n ...(job?.id ? { jobId: job.id } : {}),\n created: persisted.created,\n }\n } catch (error) {\n const failedAt = new Date()\n const failure = toEnqueueFailure(error, persisted.run, failedAt)\n const failed = await requirePipelineRunStorage(input.storage).finish({\n projectId: input.projectId,\n id: persisted.run.id,\n status: \"failed\",\n finishedAt: failedAt,\n error: failure,\n })\n reportRunFailure(input.errorReporterHost, error, {\n projectId: input.projectId,\n runKind: \"pipeline\",\n run: { runId: failed.id, pipelineId: failed.pipelineId },\n failure,\n })\n throw error\n }\n}\n\nfunction assertExistingRunMatchesRequest(\n existing: PipelineRunRecord,\n input: Pick<DispatchPipelineRunInput, \"pipeline\">\n): void {\n if (existing.pipelineId !== input.pipeline.id) {\n throw new PipelineRunError(\n `[Sixb] Pipeline run '${existing.id}' already exists with a different request payload.`\n )\n }\n}\n\nfunction existingPipelineRunResult(existing: PipelineRunRecord): PipelineRunRequestResult {\n return {\n pipelineId: existing.pipelineId,\n runId: existing.id,\n queuedAt: existing.queuedAt.toISOString(),\n created: false,\n }\n}\n\nfunction requirePipelineRunStorage(storage: Storage): NonNullable<Storage[\"pipelineRuns\"]> {\n if (!storage.pipelineRuns) {\n throw new PipelineError(\"[Sixb] Pipeline run storage is not configured.\")\n }\n return storage.pipelineRuns\n}\n\nfunction createPipelineRunId(runId: string | undefined): string {\n if (runId === undefined) return `run_${randomUUID()}`\n if (!runId.trim()) throw new PipelineError(\"[Sixb] Pipeline run id must not be empty\")\n return runId\n}\n\nfunction assertAutomaticDispatchInput(input: AutomaticPipelineRunDispatchInput): void {\n assertNonBlank(input.pipelineId, \"Pipeline id\")\n assertNonBlank(input.runId, \"Pipeline run id\")\n assertNonBlank(input.source.eventId, \"Pipeline source event id\")\n assertNonBlank(input.correlationId, \"Pipeline correlation id\")\n}\n\nasync function assertAutomaticExecutionIdentity(\n storage: Storage,\n projectId: string,\n input: AutomaticPipelineRunDispatchInput,\n run: PipelineRunRecord\n): Promise<void> {\n const execution = await storage.executions.getById({ projectId, id: run.executionId })\n if (\n !execution ||\n execution.source.type !== input.source.type ||\n execution.source.eventId !== input.source.eventId ||\n execution.correlationId !== input.correlationId ||\n execution.requestedBy !== undefined\n ) {\n throw new PipelineError(\n `[Sixb] Pipeline run '${run.id}' already exists with different automatic provenance.`\n )\n }\n}\n\nfunction toEnqueueFailure(\n error: unknown,\n run: PipelineRunRecord,\n at: Date\n): SixbFailure<PipelineRunFailureCode> {\n const enqueueError = createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue Pipeline run '${run.id}'.`,\n {\n cause: error,\n details: { pipelineId: run.pipelineId, runId: run.id, phase: \"enqueue\" },\n }\n )\n return toSixbFailure(enqueueError, { allowedCodes: PIPELINE_RUN_FAILURE_CODES, at })\n}\n\nfunction assertNonBlank(value: string, label: string): void {\n if (!value.trim()) throw new PipelineError(`[Sixb] ${label} must not be empty.`)\n}\n",
|
|
7
|
-
"import { assertAuthorized } from \"../authorization\"\nimport { resolveExecutionScopeAuthorization } from \"../execution/authorization\"\nimport {\n createPrimitiveExecutionRecord,\n ensureExecutionRecord,\n executionRecordInputFromRuntime,\n} from \"../execution/durable\"\nimport type { ExecutionContext } from \"../execution/types\"\nimport type { SixbRuntimeContext } from \"../runtime/types\"\nimport { PipelineError } from \"./errors\"\nimport { dispatchPipelineRun } from \"./run-dispatch\"\nimport type { PipelineDefinition } from \"./types\"\n\nexport interface PipelineRunRequestOptions {\n /** Stable identity used to make dispatch idempotent. */\n readonly runId?: string\n}\n\nexport interface RequestPipelineRunInput extends PipelineRunRequestOptions {\n readonly pipelineId: string\n}\n\nexport interface PipelineRunRequestResult {\n readonly pipelineId: string\n readonly runId: string\n /** Durable time at which the run entered the queue. */\n readonly queuedAt: string\n readonly jobId?: string\n readonly created: boolean\n}\n\n/**\n * Authorize and queue a pipeline run request.\n *\n * Operates on an already-resolved definition and the shared runtime context, so the HTTP route and\n * the runtime verb cannot drift apart.\n *\n * The immutable child execution and queued run are persisted before queue publication.\n */\nexport async function requestPipelineRun(\n runtime: SixbRuntimeContext,\n execution: ExecutionContext,\n pipeline: PipelineDefinition,\n options: PipelineRunRequestOptions = {}\n): Promise<PipelineRunRequestResult> {\n resolveExecutionScopeAuthorization(runtime.projectId, {\n execution,\n authorization: runtime.runtimeAuthorization,\n })\n assertAuthorized(runtime, { kind: \"pipeline.run\", pipelineId: pipeline.id })\n if (!runtime.storage.pipelineRuns) {\n throw new PipelineError(\"[Sixb] Pipeline run storage is not configured.\")\n }\n\n const queue = runtime.queues.pipelines\n if (!queue) {\n throw new PipelineError(\"[Sixb] Pipeline run queue is not configured.\")\n }\n\n return dispatchPipelineRun({\n errorReporterHost: runtime,\n projectId: runtime.projectId,\n pipeline,\n storage: runtime.storage,\n queue,\n ...options,\n createExecution: async (executionId, runId) => {\n const caller = await ensureExecutionRecord(\n runtime.storage.executions,\n executionRecordInputFromRuntime({\n execution,\n runtimeAuthorization: runtime.runtimeAuthorization,\n })\n )\n return createPrimitiveExecutionRecord({\n id: executionId,\n primitive: { kind: \"pipeline\", id: pipeline.id, runId },\n origin: { type: \"execution\", parent: caller },\n })\n },\n })\n}\n"
|
|
8
|
-
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;AAAO,MAAM,uBAAsB,MAAM;AAAA,EAC9B,OAAO;AAClB;;;ACFA;AAiEO,MAAM,uBAAyD;AAAA,EACvC;AAAA,EAA7B,WAAW,CAAkB,cAAiD;AAAA,IAAjD;AAAA;AAAA,OAEvB,SAAQ,CAAC,OAA6E;AAAA,IAC1F,6BAA6B,KAAK;AAAA,IAClC,M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,EAC7B,IAAI,CAAC,OAAO;AAAA,IACV,MAAM,IAAI,eAAc,8CAA8C;AAAA,EACxE;AAAA,EAEA,OAAO,oBAAoB;AAAA,IACzB,mBAAmB;AAAA,IACnB,WAAW,QAAQ;AAAA,IACnB;AAAA,IACA,SAAS,QAAQ;AAAA,IACjB;AAAA,OACG;AAAA,IACH,iBAAiB,OAAO,aAAa,UAAU;AAAA,MAC7C,MAAM,SAAS,MAAM,uBACnB,QAAQ,QAAQ,YAChB,gCAAgC;AAAA,QAC9B;AAAA,QACA,sBAAsB,QAAQ;AAAA,MAChC,CAAC,CACH;AAAA,MACA,OAAO,+BAA+B;AAAA,QACpC,IAAI;AAAA,QACJ,WAAW,EAAE,MAAM,YAAY,IAAI,SAAS,IAAI,MAAM;AAAA,QACtD,QAAQ,EAAE,MAAM,aAAa,QAAQ,OAAO;AAAA,MAC9C,CAAC;AAAA;AAAA,EAEL,CAAC;AAAA;",
|
|
10
|
-
"debugId": "C687324B500486F164756E2164756E21",
|
|
11
|
-
"names": []
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/projections/capability.ts", "../src/projections/run-dispatch.ts", "../src/projections/run-id.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import type { ProjectionRegistry } from \"./registry\"\nimport type { ProjectionDispatchDescriptor } from \"./types\"\n\nconst projectionRegistryKey: unique symbol = Symbol(\"sixb.projectionRegistry\")\n\ninterface ProjectionRegistryOwner {\n readonly [projectionRegistryKey]?: ProjectionRegistry\n}\n\nexport function registerProjectionRegistry(owner: object, registry: ProjectionRegistry): void {\n const registered = (owner as ProjectionRegistryOwner)[projectionRegistryKey]\n if (registered && registered !== registry) {\n throw new Error(\"[Sixb] Projection registry is already registered for this owner.\")\n }\n Object.defineProperty(owner, projectionRegistryKey, {\n configurable: false,\n enumerable: false,\n value: registry,\n writable: false,\n })\n}\n\nexport function getProjectionRegistry(owner: object): ProjectionRegistry {\n const registry = (owner as ProjectionRegistryOwner)[projectionRegistryKey]\n if (registry) return registry\n throw new Error(\"[Sixb] Projection registry is not registered for this runtime.\")\n}\n\nexport function getProjectionDispatchDescriptors(\n owner: object\n): readonly ProjectionDispatchDescriptor[] {\n return getProjectionRegistry(owner).getDispatchDescriptors()\n}\n\nexport function shareProjectionRegistry(source: object, target: object): void {\n registerProjectionRegistry(target, getProjectionRegistry(source))\n}\n",
|
|
6
|
-
"import { randomUUID } from \"node:crypto\"\nimport { reportRunFailure } from \"../error-reporting/capability\"\nimport { createSixbError, toSixbFailure } from \"../errors/internal\"\nimport type { SixbFailure } from \"../errors/types\"\nimport type { RunDispatcher } from \"../execution/dispatch\"\nimport { createPrimitiveExecutionRecord } from \"../execution/durable\"\nimport type { DatasetProducer, LakeStorage } from \"../lake-storage\"\nimport type { Queues } from \"../queues\"\nimport type { SixbDefinitions } from \"../runtime/definitions\"\nimport type { ExecutionRecord, ProjectionRunRecord, Storage } from \"../storage\"\nimport { ProjectionRunError } from \"../storage\"\nimport { findPrimitiveRunExecution } from \"../storage/executions/run-link\"\nimport {\n assertProjectionRunDurableExecution,\n assertProjectionRunIdentityMatches,\n} from \"../storage/projection-runs/provider\"\nimport { getProjectionRegistry } from \"./capability\"\nimport { ProjectionValidationError } from \"./errors\"\nimport { createProjectionRunId } from \"./run-id\"\nimport {\n PROJECTION_RUN_FAILURE_CODES,\n type ProjectionDefinition,\n type ProjectionRunFailureCode,\n} from \"./types\"\n\n/** Target maximum mapped points per telemetry commit; a single-property projection reads 500 rows. */\nexport const PROJECTION_TELEMETRY_BATCH_SIZE = 500\n\nexport interface ProjectionRunDispatchInput {\n readonly projectionId: string\n readonly datasetVersion: {\n readonly datasetId: string\n readonly versionId: string\n readonly createdAt: string\n }\n readonly metadata?: Readonly<Record<string, string>>\n}\n\nexport interface ProjectionRunDispatchResult {\n readonly projectionId: string\n readonly runId: string\n readonly queuedAt: string\n readonly jobId?: string\n readonly created: boolean\n}\n\nexport type ProjectionRunDispatchPort = RunDispatcher<\n ProjectionRunDispatchInput,\n ProjectionRunDispatchResult\n>\n\nexport interface ProjectionRunDispatcherDependencies {\n readonly id: string\n readonly definitions: Pick<SixbDefinitions, \"projections\">\n readonly lakeStorage: Pick<LakeStorage, \"getVersion\">\n readonly storage: Storage\n readonly queues: Pick<Queues, \"projections\">\n}\n\ntype PersistedProjectionRun =\n | { readonly publish: false; readonly run: ProjectionRunRecord }\n | {\n readonly publish: true\n readonly run: ProjectionRunRecord\n readonly queuedAt: Date\n readonly created: boolean\n }\n\n/** Core-owned durable dispatch boundary for immutable dataset-version materialization. */\nexport class ProjectionRunDispatcher implements ProjectionRunDispatchPort {\n constructor(private readonly dependencies: ProjectionRunDispatcherDependencies) {}\n\n async dispatch(input: ProjectionRunDispatchInput): Promise<ProjectionRunDispatchResult> {\n assertDispatchInput(input)\n const registry = getProjectionRegistry(this.dependencies)\n const descriptor = registry.resolveDispatch(input.projectionId)\n if (descriptor.datasetId !== input.datasetVersion.datasetId) {\n throw new ProjectionValidationError(\n `[Sixb] Projection '${input.projectionId}' consumes dataset '${descriptor.datasetId}', not '${input.datasetVersion.datasetId}'.`\n )\n }\n const projection = this.dependencies.definitions.projections.getById(input.projectionId)\n if (!projection) {\n throw new ProjectionValidationError(`[Sixb] Unknown projection '${input.projectionId}'.`)\n }\n const version = await this.dependencies.lakeStorage.getVersion(\n input.datasetVersion.datasetId,\n input.datasetVersion.versionId\n )\n if (!version || version.createdAt.toISOString() !== input.datasetVersion.createdAt) {\n throw new ProjectionValidationError(\n `[Sixb] Dataset '${input.datasetVersion.datasetId}' version '${input.datasetVersion.versionId}' does not match its immutable metadata.`\n )\n }\n if (version.mode === \"schema\") {\n throw new ProjectionValidationError(\n `[Sixb] Projection '${input.projectionId}' cannot materialize a schema-only dataset version.`\n )\n }\n\n const { datasetId: _datasetId, ...semanticIdentity } = descriptor\n const identity = {\n ...semanticIdentity,\n datasetVersion: structuredClone(input.datasetVersion),\n }\n const runId = createProjectionRunId(this.dependencies.id, identity)\n const projectionRuns = requireProjectionRunStorage(this.dependencies.storage)\n const existing = await projectionRuns.getById({ projectId: this.dependencies.id, id: runId })\n const persisted = existing\n ? await reuseProjectionRun(this.dependencies, existing, identity)\n : await persistProjectionRun({\n dependencies: this.dependencies,\n runId,\n identity,\n projection,\n producerExecution: await resolveProducerExecution(\n this.dependencies.storage,\n this.dependencies.id,\n version.producer\n ),\n })\n\n if (!persisted.publish) return existingResult(persisted.run)\n return publishProjectionRun(this.dependencies, input.metadata, persisted)\n }\n}\n\nasync function persistProjectionRun(input: {\n readonly dependencies: ProjectionRunDispatcherDependencies\n readonly runId: string\n readonly identity: ProjectionRunRecord[\"identity\"]\n readonly projection: ProjectionDefinition\n readonly producerExecution: ExecutionRecord | null\n}): Promise<PersistedProjectionRun> {\n const execution = createPrimitiveExecutionRecord({\n id: `exec_${randomUUID()}`,\n primitive: { kind: \"projection\", id: input.identity.projectionId, runId: input.runId },\n origin: {\n type: \"automatic\",\n projectId: input.dependencies.id,\n source: {\n type: \"datasetVersion\",\n datasetId: input.identity.datasetVersion.datasetId,\n versionId: input.identity.datasetVersion.versionId,\n },\n correlationId: input.producerExecution?.correlationId ?? input.runId,\n requesterGroupIds: input.producerExecution?.requesterGroupIds,\n ...(input.producerExecution?.requestedBy === undefined\n ? {}\n : { requestedBy: input.producerExecution.requestedBy }),\n },\n })\n const queuedAt = new Date()\n\n try {\n return await input.dependencies.storage.transaction(\n async (tx): Promise<PersistedProjectionRun> => {\n const projectionRuns = requireProjectionRunStorage(tx)\n const raced = await projectionRuns.getById({\n projectId: input.dependencies.id,\n id: input.runId,\n })\n if (raced) {\n await assertExistingRun(tx, raced, input.identity)\n return { publish: false, run: raced }\n }\n await tx.executions.create(execution)\n const run = await queueProjectionRun(projectionRuns, {\n id: input.runId,\n projectId: input.dependencies.id,\n executionId: execution.id,\n identity: input.identity,\n projection: input.projection,\n queuedAt,\n })\n return { publish: true, run, queuedAt, created: true }\n },\n { isolation: \"serializable\" }\n )\n } catch (error) {\n if (!(error instanceof ProjectionRunError)) throw error\n const raced = await requireProjectionRunStorage(input.dependencies.storage).getById({\n projectId: input.dependencies.id,\n id: input.runId,\n })\n if (!raced) throw error\n await assertExistingRun(input.dependencies.storage, raced, input.identity)\n return { publish: false, run: raced }\n }\n}\n\nasync function reuseProjectionRun(\n dependencies: ProjectionRunDispatcherDependencies,\n existing: ProjectionRunRecord,\n identity: ProjectionRunRecord[\"identity\"]\n): Promise<PersistedProjectionRun> {\n await assertExistingRun(dependencies.storage, existing, identity)\n if (\n existing.status !== \"failed\" ||\n existing.error?.code !== \"queue.enqueue_failed\" ||\n !existing.error.retryable\n ) {\n return { publish: false, run: existing }\n }\n const queuedAt = new Date()\n const projectionRuns = requireProjectionRunStorage(dependencies.storage)\n try {\n const run = await requeueProjectionRun(projectionRuns, existing, queuedAt)\n return { publish: true, run, queuedAt, created: false }\n } catch (error) {\n if (!(error instanceof ProjectionRunError)) throw error\n const raced = await projectionRuns.getById({ projectId: existing.projectId, id: existing.id })\n if (\n !raced ||\n (raced.status === \"failed\" &&\n raced.error?.code === \"queue.enqueue_failed\" &&\n raced.error.retryable)\n ) {\n throw error\n }\n await assertExistingRun(dependencies.storage, raced, identity)\n return { publish: false, run: raced }\n }\n}\n\nasync function publishProjectionRun(\n dependencies: ProjectionRunDispatcherDependencies,\n metadata: Readonly<Record<string, string>> | undefined,\n persisted: Extract<PersistedProjectionRun, { readonly publish: true }>\n): Promise<ProjectionRunDispatchResult> {\n try {\n const [job] = await dependencies.queues.projections.enqueue({\n projectId: dependencies.id,\n jobs: [\n {\n id: persisted.run.id,\n type: \"projection.run.requested\",\n payload: { runId: persisted.run.id },\n ...(metadata === undefined ? {} : { metadata }),\n },\n ],\n })\n return {\n projectionId: persisted.run.identity.projectionId,\n runId: persisted.run.id,\n queuedAt: persisted.queuedAt.toISOString(),\n ...(job?.id ? { jobId: job.id } : {}),\n created: persisted.created,\n }\n } catch (error) {\n const failedAt = new Date()\n const failure = toEnqueueFailure(error, persisted.run, failedAt)\n const failed = await requireProjectionRunStorage(dependencies.storage).failEnqueue({\n projectId: dependencies.id,\n id: persisted.run.id,\n finishedAt: failedAt,\n error: failure,\n })\n reportRunFailure(dependencies, error, {\n projectId: dependencies.id,\n runKind: \"projection\",\n run: {\n runId: failed.id,\n projectionId: failed.identity.projectionId,\n projectionKind: failed.identity.projectionKind,\n },\n failure,\n })\n throw error\n }\n}\n\nasync function assertExistingRun(\n storage: Storage,\n run: ProjectionRunRecord,\n identity: ProjectionRunRecord[\"identity\"]\n): Promise<void> {\n assertProjectionRunIdentityMatches(run, identity)\n await assertProjectionRunDurableExecution({\n executions: storage.executions,\n projectId: run.projectId,\n executionId: run.executionId,\n runId: run.id,\n projectionId: run.identity.projectionId,\n datasetId: run.identity.datasetVersion.datasetId,\n datasetVersionId: run.identity.datasetVersion.versionId,\n })\n}\n\nasync function resolveProducerExecution(\n storage: Storage,\n projectId: string,\n producer: DatasetProducer | undefined\n): Promise<ExecutionRecord | null> {\n if (producer?.kind === \"ingest\") {\n return producer.id ? storage.executions.getById({ projectId, id: producer.id }) : null\n }\n if (!producer?.runId) return null\n if (producer.kind === \"sync\") {\n const run = await storage.syncRuns?.getById({ projectId, id: producer.runId })\n if (!run) return null\n assertProducerId(producer, run.syncId)\n return requireProducerExecution({\n executions: storage.executions,\n projectId,\n executionId: run.executionId,\n primitive: { kind: \"sync\", id: run.syncId, runId: run.id },\n })\n }\n\n const run = await storage.pipelineRuns?.getById({ projectId, id: producer.runId })\n if (!run) return null\n assertProducerId(producer, run.pipelineId)\n return requireProducerExecution({\n executions: storage.executions,\n projectId,\n executionId: run.executionId,\n primitive: { kind: \"pipeline\", id: run.pipelineId, runId: run.id },\n })\n}\n\nasync function requireProducerExecution(input: {\n readonly executions: Storage[\"executions\"]\n readonly projectId: string\n readonly executionId: string\n readonly primitive:\n | { readonly kind: \"sync\"; readonly id: string; readonly runId: string }\n | { readonly kind: \"pipeline\"; readonly id: string; readonly runId: string }\n}): Promise<ExecutionRecord> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: input.primitive,\n sourceTypes: [\"execution\", \"schedule\", \"event\"],\n })\n if (execution) return execution\n throw new ProjectionValidationError(\n `[Sixb] Dataset producer run '${input.primitive.runId}' references an invalid execution.`\n )\n}\n\nfunction assertProducerId(producer: DatasetProducer, runOwnerId: string): void {\n if (producer.id === undefined || producer.id === runOwnerId) return\n throw new ProjectionValidationError(\n `[Sixb] Dataset producer '${producer.kind}:${producer.id}' does not match run '${producer.runId}'.`\n )\n}\n\nfunction requireProjectionRunStorage(storage: Storage): NonNullable<Storage[\"projectionRuns\"]> {\n if (storage.projectionRuns) return storage.projectionRuns\n throw new ProjectionValidationError(\"[Sixb] Projection run storage is not configured.\")\n}\n\nfunction queueProjectionRun(\n storage: NonNullable<Storage[\"projectionRuns\"]>,\n input: {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly identity: ProjectionRunRecord[\"identity\"]\n readonly projection: ProjectionDefinition\n readonly queuedAt: Date\n }\n): Promise<ProjectionRunRecord> {\n const common = {\n id: input.id,\n projectId: input.projectId,\n executionId: input.executionId,\n queuedAt: input.queuedAt,\n }\n switch (input.projection._tag) {\n case \"ObjectProjectionDefinition\":\n if (input.identity.projectionKind !== \"object\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: { objectTypeId: input.projection.objectTypeId },\n })\n case \"LinkProjectionDefinition\":\n if (input.identity.projectionKind !== \"link\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: {\n sourceObjectTypeId: input.projection.sourceObjectTypeId,\n targetObjectTypeId: input.projection.targetObjectTypeId,\n },\n })\n case \"TelemetryProjectionDefinition\":\n if (input.identity.projectionKind !== \"telemetry\") {\n throw invalidProjectionDefinition(input.id)\n }\n return storage.queue({\n ...common,\n identity: input.identity,\n target: { objectTypeId: input.projection.objectTypeId },\n fixedBatchSize: telemetryProjectionBatchRowCount(input.projection),\n })\n }\n}\n\nfunction telemetryProjectionBatchRowCount(\n projection: Extract<ProjectionDefinition, { readonly _tag: \"TelemetryProjectionDefinition\" }>\n): number {\n const mappedPropertyCount = Object.keys(projection.properties).length\n if (mappedPropertyCount === 0) throw invalidProjectionDefinition(projection.id)\n return Math.max(1, Math.floor(PROJECTION_TELEMETRY_BATCH_SIZE / mappedPropertyCount))\n}\n\nfunction requeueProjectionRun(\n storage: NonNullable<Storage[\"projectionRuns\"]>,\n run: ProjectionRunRecord,\n queuedAt: Date\n): Promise<ProjectionRunRecord> {\n const common = {\n id: run.id,\n projectId: run.projectId,\n executionId: run.executionId,\n queuedAt,\n }\n switch (run.identity.projectionKind) {\n case \"object\": {\n if (!(\"objectTypeId\" in run.target)) throw invalidProjectionDefinition(run.id)\n return storage.queue({ ...common, identity: run.identity, target: run.target })\n }\n case \"link\": {\n if (!(\"sourceObjectTypeId\" in run.target)) throw invalidProjectionDefinition(run.id)\n return storage.queue({ ...common, identity: run.identity, target: run.target })\n }\n case \"telemetry\": {\n if (!(\"objectTypeId\" in run.target) || !run.telemetryCheckpoint) {\n throw invalidProjectionDefinition(run.id)\n }\n return storage.queue({\n ...common,\n identity: run.identity,\n target: run.target,\n fixedBatchSize: run.telemetryCheckpoint.fixedBatchSize,\n })\n }\n }\n}\n\nfunction invalidProjectionDefinition(runId: string): ProjectionValidationError {\n return new ProjectionValidationError(\n `[Sixb] Projection run '${runId}' has inconsistent definition metadata.`\n )\n}\n\nfunction existingResult(run: ProjectionRunRecord): ProjectionRunDispatchResult {\n return {\n projectionId: run.identity.projectionId,\n runId: run.id,\n queuedAt: run.queuedAt.toISOString(),\n created: false,\n }\n}\n\nfunction assertDispatchInput(input: ProjectionRunDispatchInput): void {\n for (const [field, value] of [\n [\"projectionId\", input.projectionId],\n [\"datasetId\", input.datasetVersion.datasetId],\n [\"versionId\", input.datasetVersion.versionId],\n ] as const) {\n if (!value.trim())\n throw new ProjectionValidationError(`[Sixb] Projection ${field} is required.`)\n }\n const timestamp = Date.parse(input.datasetVersion.createdAt)\n if (\n !Number.isFinite(timestamp) ||\n new Date(timestamp).toISOString() !== input.datasetVersion.createdAt\n ) {\n throw new ProjectionValidationError(\"[Sixb] Projection dataset version timestamp is invalid.\")\n }\n}\n\nfunction toEnqueueFailure(\n error: unknown,\n run: ProjectionRunRecord,\n at: Date\n): SixbFailure<ProjectionRunFailureCode> {\n const enqueueError = createSixbError(\n \"queue.enqueue_failed\",\n `[Sixb] Could not enqueue Projection run '${run.id}'.`,\n {\n cause: error,\n details: {\n projectionId: run.identity.projectionId,\n projectionKind: run.identity.projectionKind,\n runId: run.id,\n phase: \"enqueue\",\n },\n }\n )\n return toSixbFailure(enqueueError, { allowedCodes: PROJECTION_RUN_FAILURE_CODES, at })\n}\n",
|
|
7
|
-
"import { sha256Canonical } from \"../materialization/identity\"\nimport type { ProjectionMaterializationIdentity } from \"../materialization/model\"\n\nexport function createProjectionRunId(\n projectId: string,\n identity: ProjectionMaterializationIdentity\n): string {\n return sha256Canonical({\n projectId,\n projectionId: identity.projectionId,\n projectionKind: identity.projectionKind,\n protocol: identity.protocol,\n datasetId: identity.datasetVersion.datasetId,\n versionId: identity.datasetVersion.versionId,\n createdAt: identity.datasetVersion.createdAt,\n ontologyRevision: identity.ontologyRevision,\n projectionRevision: identity.projectionRevision,\n ownershipHash: identity.ownershipHash,\n })\n}\n"
|
|
8
|
-
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,IAAM,wBAAuC,OAAO,yBAAyB;AAMtE,SAAS,2BAA0B,CAAC,OAAe,UAAoC;AAAA,EAC5F,MAAM,aAAc,MAAkC;AAAA,EACtD,IAAI,cAAc,eAAe,UAAU;AAAA,IACzC,MAAM,IAAI,MAAM,kEAAkE;AAAA,EACpF;AAAA,EACA,OAAO,eAAe,OAAO,uBAAuB;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;AAAA,MAC3B,gBAAgB,IAAI,SAAS;AAAA,MAC7B,OAAO,IAAI;AAAA,MACX,OAAO;AAAA,IACT;AAAA,EACF,CACF;AAAA,EACA,OAAO,eAAc,cAAc,EAAE,cAAc,+BAA8B,GAAG,CAAC;AAAA;",
|
|
10
|
-
"debugId": "43DF77A719EA335B64756E2164756E21",
|
|
11
|
-
"names": []
|
|
12
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/storage/projection-runs/errors.ts", "../src/storage/projection-runs/lifecycle.ts", "../src/storage/projection-runs/provider.ts"],
|
|
4
|
-
"sourcesContent": [
|
|
5
|
-
"import {\n MaterializationConflictError,\n type MaterializationConflictKind,\n} from \"../../materialization/errors\"\n\n/**\n * Base error for projection-run storage operations.\n */\nexport class ProjectionRunError extends MaterializationConflictError {\n readonly name = \"ProjectionRunError\"\n\n constructor(message: string, kind: MaterializationConflictKind = \"run-correlation\") {\n super(kind, message)\n }\n}\n",
|
|
6
|
-
"import { parseSixbFailure } from \"../../errors/internal\"\nimport type { SixbFailure } from \"../../errors/types\"\nimport type {\n ProjectionMaterializationIdentity,\n ProjectionRunTerminalDecision,\n} from \"../../materialization/model\"\nimport type {\n ProjectionKind,\n ProjectionRunFailureCode,\n ProjectionTarget,\n} from \"../../projections/types\"\nimport { PROJECTION_RUN_FAILURE_CODES } from \"../../projections/types\"\nimport { ProjectionRunError } from \"./errors\"\nimport type {\n AdvanceProjectionTelemetryCheckpointInput,\n FailProjectionRunEnqueueInput,\n FinishProjectionRunInput,\n ProjectionMissingTarget,\n ProjectionRunClaim,\n ProjectionRunProgress,\n ProjectionRunRecord,\n ProjectionRunStatus,\n ProjectionTelemetryCheckpoint,\n QueueProjectionRunInput,\n StartOrReclaimProjectionRunInput,\n TelemetryProjectionRunRecord,\n} from \"./types\"\nimport { PROJECTION_RUN_PROGRESS_KEYS, zeroProjectionRunProgress } from \"./types\"\n\nexport type StoredProjectionRunRecord = ProjectionRunRecord & {\n readonly executionToken?: string\n}\n\nexport interface PersistedProjectionRunRecord {\n readonly id: string\n readonly projectId: string\n readonly executionId: string\n readonly projectionId: string\n readonly projectionKind: ProjectionKind\n readonly protocol?: \"replacement\" | \"telemetry\"\n readonly datasetId: string\n readonly datasetVersionId: string\n readonly datasetVersionCreatedAt?: string\n readonly ontologyRevision?: string\n readonly projectionRevision?: string\n readonly ownershipHash?: string\n readonly objectTypeId?: string\n readonly sourceObjectTypeId?: string\n readonly targetObjectTypeId?: string\n readonly status: ProjectionRunStatus\n readonly queuedAt: Date\n readonly startedAt?: Date\n readonly finishedAt?: Date\n readonly attempt: number\n readonly executionToken?: string\n readonly fixedBatchSize?: number\n readonly nextBatchOrdinal?: number\n readonly nextRowOffset?: number\n readonly inputExhausted?: boolean\n readonly missingTargetObjectTypeId?: string\n readonly missingTargetObjectId?: string\n readonly missingTargetBatchOrdinal?: number\n readonly missingTargetFirstSeenAt?: Date\n readonly progress: ProjectionRunProgress\n readonly error?: unknown\n}\n\nexport interface ProjectionTelemetryAdvance {\n readonly progress: ProjectionRunProgress\n readonly checkpoint: ProjectionTelemetryCheckpoint\n}\n\nexport interface ProjectionRunFinishPlan {\n readonly status: Exclude<ProjectionRunStatus, \"queued\" | \"running\">\n readonly finishedAt: Date\n readonly progress: ProjectionRunProgress\n readonly inputExhausted?: true\n readonly error?: SixbFailure<ProjectionRunFailureCode>\n}\n\n// ── Scalar and identity validation ──────────────────────────\n\nexport function assertProjectionRunNonEmpty(value: string, fieldName: string): void {\n if (typeof value !== \"string\" || value.trim().length === 0) {\n throw new ProjectionRunError(`[Sixb] Projection run ${fieldName} must not be empty.`)\n }\n}\n\nexport function assertProjectionRunCounter(value: number, fieldName: string): void {\n if (!Number.isSafeInteger(value) || value < 0) {\n throw new ProjectionRunError(\n `[Sixb] Projection run ${fieldName} must be a non-negative safe integer.`\n )\n }\n}\n\nexport function assertProjectionRunListWindow(value: number | undefined, fieldName: string): void {\n if (value !== undefined && (!Number.isSafeInteger(value) || value < 0)) {\n throw new ProjectionRunError(`[Sixb] Projection run list ${fieldName} must be >= 0.`)\n }\n}\n\nexport function addProjectionRunCounter(left: number, right: number, fieldName: string): number {\n const result = left + right\n if (!Number.isSafeInteger(result)) {\n throw new ProjectionRunError(`[Sixb] Projection run ${fieldName} exceeds safe integer range.`)\n }\n return result\n}\n\nexport function assertProjectionRunIdentity(identity: ProjectionMaterializationIdentity): void {\n assertProjectionRunNonEmpty(identity.projectionId, \"projectionId\")\n if (!isProjectionKind(identity.projectionKind)) {\n throw new ProjectionRunError(\n \"[Sixb] Projection run projectionKind must be 'object', 'link', or 'telemetry'.\"\n )\n }\n if (identity.protocol !== \"replacement\" && identity.protocol !== \"telemetry\") {\n throw new ProjectionRunError(\n \"[Sixb] Projection run protocol must be 'replacement' or 'telemetry'.\"\n )\n }\n assertProjectionRunNonEmpty(identity.datasetVersion.datasetId, \"datasetId\")\n assertProjectionRunNonEmpty(identity.datasetVersion.versionId, \"datasetVersionId\")\n assertCanonicalTimestamp(identity.datasetVersion.createdAt, \"datasetVersionCreatedAt\")\n assertProjectionRunNonEmpty(identity.ontologyRevision, \"ontologyRevision\")\n assertProjectionRunNonEmpty(identity.projectionRevision, \"projectionRevision\")\n assertProjectionRunNonEmpty(identity.ownershipHash, \"ownershipHash\")\n if ((identity.protocol === \"telemetry\") !== (identity.projectionKind === \"telemetry\")) {\n throw new ProjectionRunError(\n `[Sixb] Projection run protocol '${identity.protocol}' is incompatible with kind '${identity.projectionKind}'.`\n )\n }\n}\n\nexport function assertProjectionRunIdentityMatches(\n record: Pick<ProjectionRunRecord, \"id\" | \"identity\">,\n identity: ProjectionMaterializationIdentity\n): void {\n if (projectionRunIdentitiesEqual(record.identity, identity)) return\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' materialization identity does not match.`\n )\n}\n\nexport function assertProjectionRunTargetMatches(\n record: Pick<ProjectionRunRecord, \"id\" | \"target\">,\n target: ProjectionTarget\n): void {\n if (projectionTargetsEqual(record.target, target)) return\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' target object types do not match.`\n )\n}\n\nexport function assertProjectionRunStartInput(input: StartOrReclaimProjectionRunInput): void {\n assertProjectionRunNonEmpty(input.id, \"id\")\n assertProjectionRunNonEmpty(input.projectId, \"projectId\")\n assertProjectionRunIdentityAndTarget(input)\n if (input.startedAt) assertProjectionRunDate(input.startedAt, \"startedAt\")\n}\n\nexport function assertProjectionRunQueueInput(input: QueueProjectionRunInput): void {\n assertProjectionRunNonEmpty(input.id, \"id\")\n assertProjectionRunNonEmpty(input.projectId, \"projectId\")\n assertProjectionRunNonEmpty(input.executionId, \"executionId\")\n assertProjectionRunIdentityAndTarget(input)\n if (input.queuedAt) assertProjectionRunDate(input.queuedAt, \"queuedAt\")\n}\n\nfunction assertProjectionRunIdentityAndTarget(\n input: QueueProjectionRunInput | StartOrReclaimProjectionRunInput\n): void {\n assertProjectionRunIdentity(input.identity)\n assertProjectionTarget(input.identity.projectionKind, input.target)\n if (input.identity.projectionKind === \"telemetry\") {\n const telemetry = input as ProjectionRunIdentityInput<\"telemetry\">\n assertPositiveCounter(telemetry.fixedBatchSize, \"fixedBatchSize\")\n } else if (input.fixedBatchSize !== undefined) {\n throw new ProjectionRunError(\n \"[Sixb] Replacement projection runs cannot declare a telemetry fixedBatchSize.\"\n )\n }\n}\n\nexport function planProjectionRunReclaim(\n record: StoredProjectionRunRecord,\n input: StartOrReclaimProjectionRunInput\n): { readonly attempt: number } {\n if (record.status !== \"queued\" && record.status !== \"running\") {\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' cannot start from status '${record.status}'.`\n )\n }\n assertProjectionRunIdentityMatches(record, input.identity)\n assertProjectionRunTargetMatches(record, input.target)\n if (record.telemetryCheckpoint?.fixedBatchSize !== input.fixedBatchSize) {\n throw new ProjectionRunError(\n `[Sixb] Projection run '${input.id}' fixed batch size does not match.`\n )\n }\n return { attempt: record.status === \"queued\" ? 1 : nextProjectionRunAttempt(record.attempt) }\n}\n\n// ── Lifecycle transitions ───────────────────────────────────\n\nexport function createProjectionRunRecord(\n input: QueueProjectionRunInput,\n now: Date = new Date()\n): ProjectionRunRecord {\n assertProjectionRunQueueInput(input)\n const base = {\n id: input.id,\n projectId: input.projectId,\n executionId: input.executionId,\n status: \"queued\" as const,\n attempt: 0,\n progress: zeroProjectionRunProgress(),\n queuedAt: new Date(input.queuedAt ?? now),\n }\n switch (input.identity.projectionKind) {\n case \"object\": {\n const object = input as ProjectionRunAdmission<\"object\">\n return { ...base, identity: object.identity, target: object.target }\n }\n case \"link\": {\n const link = input as ProjectionRunAdmission<\"link\">\n return { ...base, identity: link.identity, target: link.target }\n }\n case \"telemetry\": {\n const telemetry = input as ProjectionRunAdmission<\"telemetry\">\n return {\n ...base,\n identity: telemetry.identity,\n target: telemetry.target,\n telemetryCheckpoint: {\n fixedBatchSize: telemetry.fixedBatchSize,\n nextBatchOrdinal: 0,\n nextRowOffset: 0,\n inputExhausted: false,\n },\n }\n }\n }\n}\n\nexport function assertProjectionRunRunning(\n record: Pick<ProjectionRunRecord, \"id\" | \"projectId\" | \"status\">\n): void {\n if (record.status === \"running\") return\n if (record.status !== \"queued\") {\n throw new ProjectionRunError(`[Sixb] Projection run '${record.id}' is already terminal.`)\n }\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' for project '${record.projectId}' is not running.`\n )\n}\n\nexport function assertProjectionRunAttempt(\n record: StoredProjectionRunRecord,\n input: {\n readonly id: string\n readonly executionToken: string\n readonly identity: ProjectionMaterializationIdentity\n }\n): asserts record is StoredProjectionRunRecord & { readonly executionToken: string } {\n assertProjectionRunNonEmpty(input.executionToken, \"executionToken\")\n assertProjectionRunIdentity(input.identity)\n assertProjectionRunRunning(record)\n assertProjectionRunIdentityMatches(record, input.identity)\n if (record.executionToken !== input.executionToken) {\n throw staleProjectionRunExecution(input.id)\n }\n}\n\nexport function nextProjectionRunAttempt(current: number): number {\n assertProjectionRunCounter(current, \"attempt\")\n return addProjectionRunCounter(current, 1, \"attempt\")\n}\n\nexport function mergeProjectionRunProgress(\n current: ProjectionRunProgress,\n patch: Partial<ProjectionRunProgress>\n): ProjectionRunProgress {\n const progress = { ...current }\n for (const key of PROJECTION_RUN_PROGRESS_KEYS) {\n const value = patch[key]\n if (value === undefined) continue\n assertProjectionRunCounter(value, key)\n if (value < current[key]) {\n throw new ProjectionRunError(`[Sixb] Projection run ${key} must not decrease.`)\n }\n progress[key] = value\n }\n assertProjectionRunProgress(progress)\n return progress\n}\n\nexport function assertGenericProgressDoesNotAdvanceTelemetry(\n record: Pick<ProjectionRunRecord, \"id\" | \"identity\" | \"progress\">,\n patch: Partial<ProjectionRunProgress>\n): void {\n if (record.identity.protocol !== \"telemetry\") return\n for (const key of PROJECTION_RUN_PROGRESS_KEYS) {\n if (patch[key] !== undefined && patch[key] !== record.progress[key]) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' progress can only advance with its checkpoint.`\n )\n }\n }\n}\n\nexport function advanceProjectionTelemetry(\n record: ProjectionRunRecord,\n input: AdvanceProjectionTelemetryCheckpointInput\n): ProjectionTelemetryAdvance {\n const telemetry = requireTelemetryProjectionRun(record)\n const checkpoint = telemetry.telemetryCheckpoint\n assertProjectionRunCounter(input.batchOrdinal, \"batchOrdinal\")\n assertPositiveCounter(input.batchRowCount, \"batchRowCount\")\n assertProjectionRunCounter(input.batchRowsSkipped, \"batchRowsSkipped\")\n if (input.batchRowsSkipped > input.batchRowCount) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' skipped rows exceed its batch row count.`\n )\n }\n if (input.batchOrdinal !== checkpoint.nextBatchOrdinal) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' expected batch ordinal ${checkpoint.nextBatchOrdinal}, got ${input.batchOrdinal}.`\n )\n }\n if (input.batchRowCount > checkpoint.fixedBatchSize) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' batch exceeds its fixed size.`\n )\n }\n if (!input.inputExhausted && input.batchRowCount !== checkpoint.fixedBatchSize) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' cannot advance past a partial non-final batch.`\n )\n }\n if (checkpoint.inputExhausted) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' has already exhausted its input.`\n )\n }\n\n const nextRowOffset = addProjectionRunCounter(\n checkpoint.nextRowOffset,\n input.batchRowCount,\n \"nextRowOffset\"\n )\n return {\n progress: {\n sourceRowsRead: nextRowOffset,\n sourceRowsSkipped: addProjectionRunCounter(\n telemetry.progress.sourceRowsSkipped,\n input.batchRowsSkipped,\n \"sourceRowsSkipped\"\n ),\n },\n checkpoint: {\n ...checkpoint,\n nextBatchOrdinal: addProjectionRunCounter(checkpoint.nextBatchOrdinal, 1, \"nextBatchOrdinal\"),\n nextRowOffset,\n inputExhausted: input.inputExhausted,\n },\n }\n}\n\nexport function planProjectionRunFinish(\n record: ProjectionRunRecord,\n input: FinishProjectionRunInput,\n now: Date = new Date()\n): ProjectionRunFinishPlan {\n assertFinishDecision(record, input)\n const patch = input.progress ?? {}\n assertGenericProgressDoesNotAdvanceTelemetry(record, patch)\n const progress = mergeProjectionRunProgress(record.progress, patch)\n const finishedAt = new Date(input.finishedAt ?? now)\n assertProjectionRunDate(finishedAt, \"finishedAt\")\n return {\n status: input.status,\n finishedAt,\n progress,\n ...(input.status === \"succeeded\" && input.protocol === \"telemetry\"\n ? { inputExhausted: true as const }\n : {}),\n ...(input.status === \"succeeded\" || input.error === undefined\n ? {}\n : { error: parseSixbFailure(input.error, PROJECTION_RUN_FAILURE_CODES) }),\n }\n}\n\nexport function finishProjectionRunRecord(\n record: StoredProjectionRunRecord,\n input: FinishProjectionRunInput,\n now: Date = new Date()\n): StoredProjectionRunRecord {\n const plan = planProjectionRunFinish(record, input, now)\n const terminal = {\n executionToken: undefined,\n status: plan.status,\n finishedAt: plan.finishedAt,\n progress: plan.progress,\n error: plan.error,\n }\n if (plan.inputExhausted) {\n const telemetry = requireTelemetryProjectionRun(record)\n return {\n ...telemetry,\n ...terminal,\n telemetryCheckpoint: { ...telemetry.telemetryCheckpoint, inputExhausted: true },\n }\n }\n return { ...record, ...terminal }\n}\n\nexport function failProjectionRunEnqueue(\n record: StoredProjectionRunRecord,\n input: FailProjectionRunEnqueueInput,\n now: Date = new Date()\n): StoredProjectionRunRecord {\n if (record.status !== \"queued\") {\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' cannot fail enqueue from status '${record.status}'.`\n )\n }\n const error = parseSixbFailure(input.error, PROJECTION_RUN_FAILURE_CODES)\n if (error.code !== \"queue.enqueue_failed\") {\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' enqueue failure must use code 'queue.enqueue_failed'.`\n )\n }\n const finishedAt = new Date(input.finishedAt ?? now)\n assertProjectionRunDate(finishedAt, \"finishedAt\")\n return {\n ...record,\n status: \"failed\",\n finishedAt,\n error,\n }\n}\n\nexport function canRequeueProjectionRunAfterEnqueueFailure(\n record: ProjectionRunRecord,\n input: QueueProjectionRunInput\n): boolean {\n return (\n record.status === \"failed\" &&\n record.error?.code === \"queue.enqueue_failed\" &&\n record.error.retryable &&\n record.executionId === input.executionId &&\n projectionRunIdentitiesEqual(record.identity, input.identity) &&\n projectionTargetsEqual(record.target, input.target) &&\n record.telemetryCheckpoint?.fixedBatchSize === input.fixedBatchSize\n )\n}\n\n// ── Persistence mapping ─────────────────────────────────────\n\nexport function restoreProjectionRun(row: PersistedProjectionRunRecord): StoredProjectionRunRecord {\n assertProjectionRunNonEmpty(row.id, \"id\")\n assertProjectionRunNonEmpty(row.projectId, \"projectId\")\n assertProjectionRunNonEmpty(row.executionId, \"executionId\")\n assertProjectionRunCounter(row.attempt, \"attempt\")\n assertProjectionRunProgress(row.progress)\n assertValidDate(row.queuedAt, \"queuedAt\")\n if (row.startedAt) assertValidDate(row.startedAt, \"startedAt\")\n if (row.finishedAt) assertValidDate(row.finishedAt, \"finishedAt\")\n assertPersistedLifecycle(row)\n\n const identity = restoreIdentity(row)\n const base = {\n id: row.id,\n projectId: row.projectId,\n executionId: row.executionId,\n identity,\n status: row.status,\n queuedAt: new Date(row.queuedAt),\n startedAt: row.startedAt ? new Date(row.startedAt) : undefined,\n finishedAt: row.finishedAt ? new Date(row.finishedAt) : undefined,\n attempt: row.attempt,\n progress: { ...row.progress },\n error:\n row.error === undefined\n ? undefined\n : parseSixbFailure(row.error, PROJECTION_RUN_FAILURE_CODES),\n executionToken: row.executionToken,\n }\n\n if (identity.projectionKind === \"link\") {\n if (!row.sourceObjectTypeId || !row.targetObjectTypeId || row.objectTypeId) {\n throw invalidProjectionRunTarget(row.id)\n }\n assertNoCheckpoint(row)\n return {\n ...base,\n identity,\n target: {\n sourceObjectTypeId: row.sourceObjectTypeId,\n targetObjectTypeId: row.targetObjectTypeId,\n },\n }\n }\n if (!row.objectTypeId || row.sourceObjectTypeId || row.targetObjectTypeId) {\n throw invalidProjectionRunTarget(row.id)\n }\n if (identity.projectionKind === \"telemetry\") {\n const telemetryCheckpoint = restoreCheckpoint(row)\n if (row.progress.sourceRowsRead !== telemetryCheckpoint.nextRowOffset) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${row.id}' progress does not match its checkpoint.`\n )\n }\n if (row.status === \"succeeded\" && !telemetryCheckpoint.inputExhausted) {\n throw incompleteProjectionRun(row.id)\n }\n const missingTarget = restoreMissingTarget(row, telemetryCheckpoint)\n return {\n ...base,\n identity,\n target: { objectTypeId: row.objectTypeId },\n telemetryCheckpoint,\n ...(missingTarget ? { missingTarget } : {}),\n }\n }\n assertNoCheckpoint(row)\n return { ...base, identity, target: { objectTypeId: row.objectTypeId } }\n}\n\nexport function publicProjectionRunRecord(record: StoredProjectionRunRecord): ProjectionRunRecord {\n const cloned = structuredClone(record)\n Reflect.deleteProperty(cloned, \"executionToken\")\n return cloned\n}\n\nexport function createProjectionRunClaim(record: StoredProjectionRunRecord): ProjectionRunClaim {\n assertProjectionRunRunning(record)\n const executionToken = requireProjectionRunExecutionToken(record)\n return {\n run: publicProjectionRunRecord(record),\n execution: { projectionRunId: record.id, executionToken },\n }\n}\n\nexport function requireProjectionRunExecutionToken(record: StoredProjectionRunRecord): string {\n if (record.executionToken) return record.executionToken\n throw incompleteProjectionRun(record.id)\n}\n\nexport function staleProjectionRunExecution(id: string): ProjectionRunError {\n return new ProjectionRunError(\n `[Sixb] Projection run '${id}' execution token is stale.`,\n \"execution-lost\"\n )\n}\n\nexport function projectionRunNotFound(projectId: string, id: string): ProjectionRunError {\n return new ProjectionRunError(\n `[Sixb] Projection run '${id}' not found for project '${projectId}'.`\n )\n}\n\nexport function immutableDatasetVersionConflict(\n identity: ProjectionMaterializationIdentity\n): ProjectionRunError {\n return new ProjectionRunError(\n `[Sixb] Dataset version '${identity.datasetVersion.versionId}' reused an immutable dataset version id with different metadata.`\n )\n}\n\n// ── Private helpers ─────────────────────────────────────────\n\nfunction assertPositiveCounter(value: number, fieldName: string): void {\n if (!Number.isSafeInteger(value) || value <= 0) {\n throw new ProjectionRunError(\n `[Sixb] Projection run ${fieldName} must be a positive safe integer.`\n )\n }\n}\n\nfunction assertCanonicalTimestamp(value: string, fieldName: string): void {\n const milliseconds = Date.parse(value)\n if (!Number.isFinite(milliseconds) || new Date(milliseconds).toISOString() !== value) {\n throw new ProjectionRunError(\n `[Sixb] Projection run ${fieldName} must be a canonical UTC timestamp.`\n )\n }\n}\n\nfunction assertValidDate(value: Date, fieldName: string): void {\n if (!Number.isFinite(value.getTime())) {\n throw new ProjectionRunError(`[Sixb] Projection run persisted ${fieldName} is invalid.`)\n }\n}\n\nfunction assertPersistedLifecycle(row: PersistedProjectionRunRecord): void {\n const hasError = row.error !== undefined\n\n if (row.status === \"queued\") {\n if (\n row.attempt !== 0 ||\n row.startedAt !== undefined ||\n row.finishedAt !== undefined ||\n row.executionToken !== undefined ||\n hasError\n ) {\n throw incompleteProjectionRun(row.id)\n }\n return\n }\n\n if (row.status === \"running\") {\n if (\n row.attempt < 1 ||\n row.startedAt === undefined ||\n row.finishedAt !== undefined ||\n row.executionToken === undefined ||\n hasError\n ) {\n throw incompleteProjectionRun(row.id)\n }\n return\n }\n\n if (row.finishedAt === undefined || row.executionToken !== undefined) {\n throw incompleteProjectionRun(row.id)\n }\n if (row.error !== undefined) {\n const failure = parseSixbFailure(row.error, PROJECTION_RUN_FAILURE_CODES)\n if (failure.code === \"queue.enqueue_failed\") {\n if (\n !failure.retryable ||\n row.status !== \"failed\" ||\n row.attempt !== 0 ||\n row.startedAt !== undefined\n ) {\n throw incompleteProjectionRun(row.id)\n }\n return\n }\n }\n if (row.attempt < 1 || row.startedAt === undefined || (row.status === \"succeeded\" && hasError)) {\n throw incompleteProjectionRun(row.id)\n }\n}\n\nfunction assertProjectionRunDate(value: Date, fieldName: string): void {\n if (!Number.isFinite(value.getTime())) {\n throw new ProjectionRunError(`[Sixb] Projection run ${fieldName} is invalid.`)\n }\n}\n\nfunction isProjectionKind(value: unknown): value is ProjectionKind {\n return value === \"object\" || value === \"link\" || value === \"telemetry\"\n}\n\nfunction assertProjectionTarget(kind: ProjectionKind, target: ProjectionTarget): void {\n if (kind === \"link\") {\n if (!(\"sourceObjectTypeId\" in target)) {\n throw new ProjectionRunError(\n \"[Sixb] Link projection runs must declare source and target object types.\"\n )\n }\n assertProjectionRunNonEmpty(target.sourceObjectTypeId, \"sourceObjectTypeId\")\n assertProjectionRunNonEmpty(target.targetObjectTypeId, \"targetObjectTypeId\")\n return\n }\n if (!(\"objectTypeId\" in target)) {\n throw new ProjectionRunError(\n \"[Sixb] Object and telemetry projection runs must declare one object type.\"\n )\n }\n assertProjectionRunNonEmpty(target.objectTypeId, \"objectTypeId\")\n}\n\nfunction projectionRunIdentitiesEqual(\n left: ProjectionMaterializationIdentity,\n right: ProjectionMaterializationIdentity\n): boolean {\n return (\n left.projectionId === right.projectionId &&\n left.projectionKind === right.projectionKind &&\n left.protocol === right.protocol &&\n left.datasetVersion.datasetId === right.datasetVersion.datasetId &&\n left.datasetVersion.versionId === right.datasetVersion.versionId &&\n left.datasetVersion.createdAt === right.datasetVersion.createdAt &&\n left.ontologyRevision === right.ontologyRevision &&\n left.projectionRevision === right.projectionRevision &&\n left.ownershipHash === right.ownershipHash\n )\n}\n\nfunction projectionTargetsEqual(left: ProjectionTarget, right: ProjectionTarget): boolean {\n if (\"sourceObjectTypeId\" in left || \"sourceObjectTypeId\" in right) {\n return (\n \"sourceObjectTypeId\" in left &&\n \"sourceObjectTypeId\" in right &&\n left.sourceObjectTypeId === right.sourceObjectTypeId &&\n left.targetObjectTypeId === right.targetObjectTypeId\n )\n }\n return left.objectTypeId === right.objectTypeId\n}\n\nfunction assertProjectionRunProgress(progress: ProjectionRunProgress): void {\n for (const key of PROJECTION_RUN_PROGRESS_KEYS) {\n assertProjectionRunCounter(progress[key], key)\n }\n if (progress.sourceRowsSkipped > progress.sourceRowsRead) {\n throw new ProjectionRunError(\n \"[Sixb] Projection run sourceRowsSkipped must not exceed sourceRowsRead.\"\n )\n }\n}\n\nfunction assertFinishDecision(\n record: ProjectionRunRecord,\n input: ProjectionRunTerminalDecision\n): void {\n if (input.status !== \"succeeded\" && input.status !== \"failed\" && input.status !== \"cancelled\") {\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' finish status must be terminal.`\n )\n }\n if (input.protocol !== \"replacement\" && input.protocol !== \"telemetry\") {\n throw new ProjectionRunError(`[Sixb] Projection run '${record.id}' finish protocol is invalid.`)\n }\n if (input.protocol !== record.identity.protocol) {\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' finish protocol does not match its identity.`\n )\n }\n const inputExhausted = \"inputExhausted\" in input ? input.inputExhausted : undefined\n if (input.status === \"succeeded\" && input.protocol === \"telemetry\") {\n if (inputExhausted === true) return\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' cannot succeed before input exhaustion.`\n )\n }\n if (inputExhausted !== undefined) {\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' contains telemetry-only completion metadata.`\n )\n }\n}\n\nfunction restoreIdentity(row: PersistedProjectionRunRecord): ProjectionMaterializationIdentity {\n if (\n !row.protocol ||\n !row.datasetVersionCreatedAt ||\n !row.ontologyRevision ||\n !row.projectionRevision ||\n !row.ownershipHash\n ) {\n throw incompleteProjectionRun(row.id)\n }\n const identity = {\n projectionId: row.projectionId,\n projectionKind: row.projectionKind,\n protocol: row.protocol,\n datasetVersion: {\n datasetId: row.datasetId,\n versionId: row.datasetVersionId,\n createdAt: row.datasetVersionCreatedAt,\n },\n ontologyRevision: row.ontologyRevision,\n projectionRevision: row.projectionRevision,\n ownershipHash: row.ownershipHash,\n } as ProjectionMaterializationIdentity\n assertProjectionRunIdentity(identity)\n return identity\n}\n\nfunction restoreCheckpoint(row: PersistedProjectionRunRecord): ProjectionTelemetryCheckpoint {\n if (\n row.fixedBatchSize === undefined ||\n row.nextBatchOrdinal === undefined ||\n row.nextRowOffset === undefined ||\n row.inputExhausted === undefined\n ) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${row.id}' has incomplete checkpoint state.`\n )\n }\n assertPositiveCounter(row.fixedBatchSize, \"fixedBatchSize\")\n assertProjectionRunCounter(row.nextBatchOrdinal, \"nextBatchOrdinal\")\n assertProjectionRunCounter(row.nextRowOffset, \"nextRowOffset\")\n return {\n fixedBatchSize: row.fixedBatchSize,\n nextBatchOrdinal: row.nextBatchOrdinal,\n nextRowOffset: row.nextRowOffset,\n inputExhausted: row.inputExhausted,\n }\n}\n\n/**\n * A wait is either fully persisted or absent. A partially written one would read as \"waiting since\n * the epoch\" or \"waiting for nothing\", and both would decide a run's fate.\n */\nfunction restoreMissingTarget(\n row: PersistedProjectionRunRecord,\n checkpoint: ProjectionTelemetryCheckpoint\n): ProjectionMissingTarget | undefined {\n const columns = [\n row.missingTargetObjectTypeId,\n row.missingTargetObjectId,\n row.missingTargetBatchOrdinal,\n row.missingTargetFirstSeenAt,\n ]\n if (columns.every((column) => column === undefined)) return undefined\n if (\n row.missingTargetObjectTypeId === undefined ||\n row.missingTargetObjectId === undefined ||\n row.missingTargetBatchOrdinal === undefined ||\n row.missingTargetFirstSeenAt === undefined\n ) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${row.id}' has a partially persisted missing target.`\n )\n }\n const missingTarget: ProjectionMissingTarget = {\n objectTypeId: row.missingTargetObjectTypeId,\n objectId: row.missingTargetObjectId,\n batchOrdinal: row.missingTargetBatchOrdinal,\n firstSeenAt: new Date(row.missingTargetFirstSeenAt),\n }\n assertValidDate(missingTarget.firstSeenAt, \"missingTarget.firstSeenAt\")\n assertProjectionRunCounter(missingTarget.batchOrdinal, \"missingTarget.batchOrdinal\")\n if (missingTarget.batchOrdinal !== checkpoint.nextBatchOrdinal) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${row.id}' is waiting on a batch it has already passed.`\n )\n }\n if (missingTarget.objectTypeId !== row.objectTypeId) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${row.id}' is waiting on an object type it does not write.`\n )\n }\n return missingTarget\n}\n\nfunction assertNoCheckpoint(row: PersistedProjectionRunRecord): void {\n if (\n row.fixedBatchSize === undefined &&\n row.nextBatchOrdinal === undefined &&\n row.nextRowOffset === undefined &&\n row.inputExhausted === undefined\n ) {\n return\n }\n throw new ProjectionRunError(\n `[Sixb] Replacement projection run '${row.id}' contains a telemetry checkpoint.`\n )\n}\n\nfunction incompleteProjectionRun(id: string): ProjectionRunError {\n return new ProjectionRunError(\n `[Sixb] Projection run '${id}' has incomplete materialization state.`\n )\n}\n\nfunction invalidProjectionRunTarget(id: string): ProjectionRunError {\n return new ProjectionRunError(`[Sixb] Projection run '${id}' has an invalid target.`)\n}\n\n/**\n * Validates a wait before it is stored, so every adapter refuses the same shapes and the SQL\n * `CHECK` behind them never has to be the thing that catches it.\n *\n * The ordinal has to be the batch the run is actually stuck on: anchored to a stale one, a wait\n * would survive the progress that resolved it and fail a run that is working. The object type\n * has to be the one this run writes, since that is the only type its telemetry can reference.\n */\nexport function assertProjectionMissingTarget(\n record: TelemetryProjectionRunRecord,\n missingTarget: ProjectionMissingTarget\n): ProjectionMissingTarget {\n assertProjectionRunNonEmpty(missingTarget.objectTypeId, \"missingTarget.objectTypeId\")\n assertProjectionRunNonEmpty(missingTarget.objectId, \"missingTarget.objectId\")\n assertProjectionRunCounter(missingTarget.batchOrdinal, \"missingTarget.batchOrdinal\")\n if (Number.isNaN(missingTarget.firstSeenAt.getTime())) {\n throw new ProjectionRunError(\"[Sixb] Projection run missingTarget.firstSeenAt is invalid.\")\n }\n if (missingTarget.objectTypeId !== record.target.objectTypeId) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' cannot wait on '${missingTarget.objectTypeId}'; it writes '${record.target.objectTypeId}'.`\n )\n }\n if (missingTarget.batchOrdinal !== record.telemetryCheckpoint.nextBatchOrdinal) {\n throw new ProjectionRunError(\n `[Sixb] Telemetry projection run '${record.id}' cannot wait on batch ${missingTarget.batchOrdinal}; it is at ${record.telemetryCheckpoint.nextBatchOrdinal}.`\n )\n }\n return missingTarget\n}\n\nexport function requireTelemetryProjectionRun<TRecord extends ProjectionRunRecord>(\n record: TRecord\n): TRecord & TelemetryProjectionRunRecord {\n if (isTelemetryProjectionRun(record)) return record as TRecord & TelemetryProjectionRunRecord\n throw new ProjectionRunError(\n `[Sixb] Projection run '${record.id}' does not have a telemetry checkpoint.`\n )\n}\n\ntype ProjectionRunIdentityInput<TKind extends ProjectionKind> = Extract<\n QueueProjectionRunInput | StartOrReclaimProjectionRunInput,\n { readonly identity: { readonly projectionKind: TKind } }\n>\n\ntype ProjectionRunAdmission<TKind extends ProjectionKind> = Extract<\n QueueProjectionRunInput,\n { readonly identity: { readonly projectionKind: TKind } }\n>\n\nfunction isTelemetryProjectionRun(\n record: ProjectionRunRecord\n): record is TelemetryProjectionRunRecord {\n return record.identity.projectionKind === \"telemetry\"\n}\n",
|
|
7
|
-
"import type { ExecutionStorage } from \"../executions\"\nimport { findPrimitiveRunExecution } from \"../executions/run-link\"\nimport { ProjectionRunError } from \"./errors\"\n\nexport * from \"./lifecycle\"\n\n/** Validate the semantic link between a durable Projection run and its immutable execution. */\nexport async function assertProjectionRunDurableExecution(input: {\n readonly executions: ExecutionStorage\n readonly projectId: string\n readonly executionId: string\n readonly runId: string\n readonly projectionId: string\n readonly datasetId: string\n readonly datasetVersionId: string\n}): Promise<void> {\n const execution = await findPrimitiveRunExecution({\n executions: input.executions,\n projectId: input.projectId,\n executionId: input.executionId,\n primitive: { kind: \"projection\", id: input.projectionId, runId: input.runId },\n sourceTypes: [\"datasetVersion\"],\n })\n if (\n !execution ||\n execution.source.type !== \"datasetVersion\" ||\n execution.source.datasetId !== input.datasetId ||\n execution.source.versionId !== input.datasetVersionId\n ) {\n throw new ProjectionRunError(\n `[Sixb] Execution '${input.executionId}' does not authorize Projection run '${input.runId}'.`\n )\n }\n}\n"
|
|
8
|
-
],
|
|
9
|
-
"mappings": ";;;;;;;;;;;;;;;;;AAQO,MAAM,4BAA2B,8BAA6B;AAAA,EAC1D,OAAO;AAAA,EAEhB,WAAW,CAAC,SAAiB,OAAoC,mBAAmB;AAAA,IAClF,MAAM,MAAM,OAAO;AAAA;AAEvB;;;ACoEO,SAAS,4BAA2B,CAAC,OAAe,WAAyB;AAAA,EAClF,IAAI,OAAO,UAAU,YAAY,MAAM,KAAK,EAAE,WAAW,GAAG;AAAA,IAC1D,MAAM,IAAI,oBAAmB,yBAAyB,8BAA8B;AAAA,EACtF;AAAA;AAGK,SAAS,2BAA0B,CAAC,OAAe,WAAyB;AAAA,EACjF,IAAI,CAAC,OAAO,cAAc,KAAK,KAAK,QAAQ,GAAG;AAAA,IAC7C,MAAM,IAAI,oBACR,yBAAyB,gDAC3B;AAAA,EACF;AAAA;AAGK,SAAS,8BAA6B,CAAC,OAA2B,WAAyB;AAAA,EAChG,IAAI,UAAU,cAAc,CAAC,OAAO,cAAc,KAAK,KAAK,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