@sixb/core 0.1.16 → 0.1.18
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 +30 -27
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/read-facade.d.ts +1 -1
- package/dist/actions/types/context.d.ts +2 -2
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/actions/validation.d.ts.map +1 -1
- package/dist/actions/worker.js +6 -2
- package/dist/actions/worker.js.map +3 -3
- package/dist/agents/adapters.d.ts +7 -0
- package/dist/agents/adapters.d.ts.map +1 -1
- package/dist/agents/authority.d.ts +7 -0
- package/dist/agents/authority.d.ts.map +1 -1
- package/dist/agents/context/entries.d.ts +10 -1
- package/dist/agents/context/entries.d.ts.map +1 -1
- package/dist/agents/context/index.d.ts +1 -1
- package/dist/agents/context/index.d.ts.map +1 -1
- package/dist/agents/context/index.js +4 -2
- package/dist/agents/context/index.js.map +1 -1
- package/dist/agents/context-compaction.d.ts.map +1 -1
- package/dist/agents/errors.d.ts +1 -1
- package/dist/agents/errors.d.ts.map +1 -1
- package/dist/agents/index.d.ts +6 -4
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +54 -46
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/message.d.ts +8 -1
- package/dist/agents/message.d.ts.map +1 -1
- package/dist/agents/request.d.ts +19 -5
- package/dist/agents/request.d.ts.map +1 -1
- package/dist/agents/skills.d.ts +41 -0
- package/dist/agents/skills.d.ts.map +1 -0
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.js +1 -1
- package/dist/agents/types.d.ts +33 -4
- package/dist/agents/types.d.ts.map +1 -1
- package/dist/auth/index.js +9 -6
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/runtime.d.ts.map +1 -1
- package/dist/auth/types.d.ts +6 -0
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/authorization/index.js +5 -3
- package/dist/authorization/index.js.map +1 -1
- package/dist/authorization/resolve.d.ts +1 -1
- package/dist/authorization/resolve.d.ts.map +1 -1
- package/dist/authorization/types.d.ts +7 -0
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/blob-storage/browser.js +1 -1
- package/dist/blob-storage/download-urls.d.ts +41 -0
- package/dist/blob-storage/download-urls.d.ts.map +1 -0
- package/dist/blob-storage/execution.d.ts +9 -1
- package/dist/blob-storage/execution.d.ts.map +1 -1
- package/dist/blob-storage/file-content.d.ts +18 -0
- package/dist/blob-storage/file-content.d.ts.map +1 -0
- package/dist/blob-storage/index.d.ts +1 -1
- package/dist/blob-storage/index.d.ts.map +1 -1
- package/dist/blob-storage/index.js +6 -4
- package/dist/blob-storage/index.js.map +1 -1
- package/dist/blob-storage/internal.d.ts +4 -0
- package/dist/blob-storage/internal.d.ts.map +1 -0
- package/dist/blob-storage/internal.js +23 -0
- package/dist/blob-storage/internal.js.map +9 -0
- package/dist/blob-storage/media-type.d.ts +8 -0
- package/dist/blob-storage/media-type.d.ts.map +1 -0
- package/dist/blob-storage/types.d.ts +12 -1
- package/dist/blob-storage/types.d.ts.map +1 -1
- package/dist/blob-storage/validation.d.ts +6 -0
- package/dist/blob-storage/validation.d.ts.map +1 -1
- package/dist/bootstrap/agent-context.d.ts +33 -0
- package/dist/bootstrap/agent-context.d.ts.map +1 -0
- package/dist/bootstrap/discovery.d.ts +23 -3
- package/dist/bootstrap/discovery.d.ts.map +1 -1
- package/dist/bootstrap/index.d.ts +2 -1
- package/dist/bootstrap/index.d.ts.map +1 -1
- package/dist/bootstrap/index.js +287 -75
- package/dist/bootstrap/index.js.map +4 -3
- package/dist/bootstrap/ontology-type-manifest.d.ts.map +1 -1
- package/dist/{chunk-kttr5ftm.js → chunk-1b1f2d5f.js} +23 -6
- package/dist/chunk-1b1f2d5f.js.map +12 -0
- package/dist/{chunk-hgqpcmyr.js → chunk-1hqwggsn.js} +47 -19
- package/dist/chunk-1hqwggsn.js.map +12 -0
- package/dist/{chunk-9vx5e9g1.js → chunk-1sr8ryzk.js} +3 -3
- package/dist/chunk-1sr8ryzk.js.map +11 -0
- package/dist/{chunk-4gmng3vf.js → chunk-22v5bpz3.js} +1 -1
- package/dist/{chunk-tnvafr7g.js → chunk-29yx306f.js} +124 -9
- package/dist/chunk-29yx306f.js.map +22 -0
- package/dist/{chunk-fj1dvp37.js → chunk-2vhg6ysa.js} +1 -1
- package/dist/chunk-3zxk45er.js +152 -0
- package/dist/chunk-3zxk45er.js.map +11 -0
- package/dist/{chunk-gmdvns8f.js → chunk-48e3cn2d.js} +2 -2
- package/dist/{chunk-jgwb25gc.js → chunk-4as3wt1c.js} +13 -5
- package/dist/chunk-4as3wt1c.js.map +12 -0
- package/dist/{chunk-91kcnbf0.js → chunk-6gmfggss.js} +22 -9
- package/dist/chunk-6gmfggss.js.map +10 -0
- package/dist/{chunk-2xvgy3x5.js → chunk-6h5m9xjx.js} +43 -415
- package/dist/{chunk-2xvgy3x5.js.map → chunk-6h5m9xjx.js.map} +7 -11
- package/dist/{chunk-cq44v1a6.js → chunk-7hpdd6r9.js} +3 -3
- package/dist/{chunk-f85hpqnm.js → chunk-99nd4rc1.js} +3 -3
- package/dist/{chunk-f85hpqnm.js.map → chunk-99nd4rc1.js.map} +3 -3
- package/dist/chunk-b9affek3.js +261 -0
- package/dist/chunk-b9affek3.js.map +12 -0
- package/dist/{chunk-zvmr2hqk.js → chunk-bs7sqkre.js} +10 -4
- package/dist/chunk-bs7sqkre.js.map +12 -0
- package/dist/{chunk-rb143ggb.js → chunk-bwjcehza.js} +1 -1
- package/dist/{chunk-667x4drs.js → chunk-d0eb5yy6.js} +143 -7
- package/dist/chunk-d0eb5yy6.js.map +14 -0
- package/dist/chunk-d62kjtbg.js.map +2 -2
- package/dist/{chunk-gkxsenvp.js → chunk-de4z2bj6.js} +31 -7
- package/dist/{chunk-gkxsenvp.js.map → chunk-de4z2bj6.js.map} +5 -4
- package/dist/{chunk-mdnw7nj8.js → chunk-dnmadg9k.js} +35 -10
- package/dist/chunk-dnmadg9k.js.map +15 -0
- package/dist/chunk-enpsx8k5.js +127 -0
- package/dist/chunk-enpsx8k5.js.map +10 -0
- package/dist/{chunk-xnx96gfy.js → chunk-ere85b8y.js} +17 -8
- package/dist/chunk-ere85b8y.js.map +15 -0
- package/dist/{chunk-k4kkp58d.js → chunk-ewqa58h9.js} +12 -2
- package/dist/chunk-ewqa58h9.js.map +11 -0
- package/dist/{chunk-7g2gjvah.js → chunk-ex496vct.js} +1 -1
- package/dist/{chunk-nvymebc1.js → chunk-f1zxad2t.js} +1 -1
- package/dist/{chunk-3q7z9hd4.js → chunk-fe52eczz.js} +483 -101
- package/dist/chunk-fe52eczz.js.map +49 -0
- package/dist/{chunk-8x74221e.js → chunk-fx93hd2n.js} +79 -32
- package/dist/chunk-fx93hd2n.js.map +20 -0
- package/dist/{chunk-39tqv9hz.js → chunk-gc4ntf7d.js} +6 -7
- package/dist/{chunk-39tqv9hz.js.map → chunk-gc4ntf7d.js.map} +3 -4
- package/dist/chunk-h8teetr0.js +9 -0
- package/dist/chunk-h8teetr0.js.map +10 -0
- package/dist/{chunk-98cw09sw.js → chunk-hkc3jct7.js} +4 -2
- package/dist/chunk-hkc3jct7.js.map +10 -0
- package/dist/chunk-hn2r7z41.js.map +1 -1
- package/dist/{chunk-h044jb97.js → chunk-htr6wjmv.js} +282 -58
- package/dist/chunk-htr6wjmv.js.map +19 -0
- package/dist/{chunk-h3v76ams.js → chunk-jhm3zsa7.js} +25 -2
- package/dist/chunk-jhm3zsa7.js.map +12 -0
- package/dist/{chunk-chdg6eqq.js → chunk-k6hrnf35.js} +5 -5
- package/dist/chunk-k6hrnf35.js.map +10 -0
- package/dist/{chunk-a0073121.js → chunk-kpx7jrmn.js} +3 -1
- package/dist/chunk-kpx7jrmn.js.map +12 -0
- package/dist/{chunk-b9y8hcm2.js → chunk-mfs23znk.js} +1 -1
- package/dist/{chunk-kvysp909.js → chunk-ny3xyvcn.js} +32 -19
- package/dist/chunk-ny3xyvcn.js.map +17 -0
- package/dist/{chunk-h4138ww2.js → chunk-p0dqwj3n.js} +450 -799
- package/dist/chunk-p0dqwj3n.js.map +49 -0
- package/dist/{chunk-f72rbvsb.js → chunk-p844e0rn.js} +23 -8
- package/dist/chunk-p844e0rn.js.map +19 -0
- package/dist/{chunk-dmn70ztd.js → chunk-pfp1txq2.js} +25 -6
- package/dist/chunk-pfp1txq2.js.map +11 -0
- package/dist/chunk-pqajwytd.js.map +3 -3
- package/dist/{chunk-mr60an99.js → chunk-qczk96d9.js} +22 -2
- package/dist/{chunk-mr60an99.js.map → chunk-qczk96d9.js.map} +3 -3
- package/dist/{chunk-69kt9q43.js → chunk-qkbx3tf6.js} +17 -128
- package/dist/{chunk-69kt9q43.js.map → chunk-qkbx3tf6.js.map} +6 -7
- package/dist/{chunk-h866d223.js → chunk-qkvz64nd.js} +2 -2
- package/dist/{chunk-vsvrv7n8.js → chunk-qmnnhde6.js} +4 -8
- package/dist/{chunk-vsvrv7n8.js.map → chunk-qmnnhde6.js.map} +3 -3
- package/dist/{chunk-6z1q7j19.js → chunk-qq90g05n.js} +1128 -782
- package/dist/chunk-qq90g05n.js.map +66 -0
- package/dist/{chunk-40qb8wpe.js → chunk-qxvp5epv.js} +84 -29
- package/dist/{chunk-40qb8wpe.js.map → chunk-qxvp5epv.js.map} +10 -9
- package/dist/chunk-rdghfsss.js.map +2 -2
- package/dist/{chunk-s3csryxe.js → chunk-rj69qcrd.js} +8 -2
- package/dist/chunk-rj69qcrd.js.map +11 -0
- package/dist/{chunk-tkdbge6v.js → chunk-rt9p8m9t.js} +1 -1
- package/dist/{chunk-cd234ba4.js → chunk-rz53yb4v.js} +10 -5
- package/dist/chunk-rz53yb4v.js.map +14 -0
- package/dist/{chunk-a7ne02hk.js → chunk-s4jhg8a3.js} +351 -296
- package/dist/chunk-s4jhg8a3.js.map +15 -0
- package/dist/{chunk-69266efg.js → chunk-s54c868q.js} +12 -4
- package/dist/chunk-s54c868q.js.map +12 -0
- package/dist/{chunk-dsv8kdgk.js → chunk-tffvfy6s.js} +8 -7
- package/dist/{chunk-dsv8kdgk.js.map → chunk-tffvfy6s.js.map} +3 -3
- package/dist/{chunk-sbcm1b92.js → chunk-v6xpd60t.js} +3 -3
- package/dist/{chunk-nj0020ay.js → chunk-vgk3hknm.js} +1 -1
- package/dist/{chunk-qnd7ehe5.js → chunk-vx2yp45y.js} +2 -2
- package/dist/{chunk-vjqt7q3a.js → chunk-vz3gc1tm.js} +607 -45
- package/dist/chunk-vz3gc1tm.js.map +41 -0
- package/dist/{chunk-g4rbm4a6.js → chunk-wt4szfec.js} +379 -331
- package/dist/chunk-wt4szfec.js.map +14 -0
- package/dist/chunk-xt1zt7gv.js +471 -0
- package/dist/chunk-xt1zt7gv.js.map +13 -0
- package/dist/{chunk-swxzncrv.js → chunk-y05543x6.js} +51 -8
- package/dist/{chunk-swxzncrv.js.map → chunk-y05543x6.js.map} +5 -5
- package/dist/{chunk-zdkcdshk.js → chunk-y9jmd7e5.js} +41 -3
- package/dist/{chunk-zdkcdshk.js.map → chunk-y9jmd7e5.js.map} +4 -3
- package/dist/{chunk-nkbev3tr.js → chunk-yv9czyfr.js} +3 -3
- package/dist/{chunk-z5rnrmz1.js → chunk-yw9pyg66.js} +5 -3
- package/dist/chunk-yw9pyg66.js.map +11 -0
- package/dist/{chunk-cxj8y8t0.js → chunk-za5yd58j.js} +2 -2
- package/dist/{chunk-zb47r1c8.js → chunk-zb77kjth.js} +3 -3
- package/dist/{chunk-dp7yk20b.js → chunk-zxawp1n2.js} +1 -1
- package/dist/datasets/builders.d.ts +12 -1
- package/dist/datasets/builders.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts +27 -1
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/datasets/index.d.ts +1 -1
- package/dist/datasets/index.d.ts.map +1 -1
- package/dist/datasets/types.d.ts +2 -0
- package/dist/datasets/types.d.ts.map +1 -1
- package/dist/datasets/write.d.ts +5 -0
- package/dist/datasets/write.d.ts.map +1 -1
- package/dist/datasets/write.js +10 -5
- package/dist/datasets/write.js.map +1 -1
- package/dist/edits/properties.d.ts.map +1 -1
- package/dist/events/execution.d.ts +2 -1
- package/dist/events/execution.d.ts.map +1 -1
- package/dist/events/types/objects.d.ts +5 -0
- package/dist/events/types/objects.d.ts.map +1 -1
- package/dist/execution/agent.d.ts +10 -0
- package/dist/execution/agent.d.ts.map +1 -1
- package/dist/execution/agent.js +49 -43
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorized-object-reader.d.ts +9 -2
- package/dist/execution/authorized-object-reader.d.ts.map +1 -1
- package/dist/execution/primitive.js +45 -41
- package/dist/execution/primitive.js.map +2 -2
- package/dist/execution/request.js +46 -42
- package/dist/execution/request.js.map +2 -2
- package/dist/http/api-routes.d.ts.map +1 -1
- package/dist/http/index.js +1 -1
- package/dist/index.d.ts +16 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -71
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/in-memory.d.ts +5 -1
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +1 -1
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +8 -5
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/types.d.ts +26 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/maintenance/ontology-maintenance.d.ts +5 -1
- package/dist/maintenance/ontology-maintenance.d.ts.map +1 -1
- package/dist/maintenance/types.d.ts +1 -4
- package/dist/maintenance/types.d.ts.map +1 -1
- package/dist/materialization/event-envelopes.d.ts +20 -0
- package/dist/materialization/event-envelopes.d.ts.map +1 -0
- package/dist/materialization/events.d.ts +29 -3
- package/dist/materialization/events.d.ts.map +1 -1
- package/dist/materialization/index.d.ts +4 -1
- package/dist/materialization/index.d.ts.map +1 -1
- package/dist/materialization/index.js +9 -3
- package/dist/materialization/index.js.map +1 -1
- package/dist/materializer/edits/plan.d.ts +2 -10
- package/dist/materializer/edits/plan.d.ts.map +1 -1
- package/dist/materializer/effective/build-events.d.ts +5 -21
- package/dist/materializer/effective/build-events.d.ts.map +1 -1
- package/dist/materializer/effective/vector-indexing.d.ts +2 -3
- package/dist/materializer/effective/vector-indexing.d.ts.map +1 -1
- package/dist/materializer/effective/vectors.d.ts +2 -3
- package/dist/materializer/effective/vectors.d.ts.map +1 -1
- package/dist/materializer/execution/scope.d.ts +1 -11
- package/dist/materializer/execution/scope.d.ts.map +1 -1
- package/dist/materializer/execution/work-executor.d.ts +5 -7
- package/dist/materializer/execution/work-executor.d.ts.map +1 -1
- package/dist/materializer/execution/work-records.d.ts +1 -3
- package/dist/materializer/execution/work-records.d.ts.map +1 -1
- package/dist/materializer/index.js +35 -33
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/projections/replace.d.ts.map +1 -1
- package/dist/materializer/projections/replacement-plan.d.ts +8 -11
- package/dist/materializer/projections/replacement-plan.d.ts.map +1 -1
- package/dist/materializer/shared/batching.d.ts +5 -0
- package/dist/materializer/shared/batching.d.ts.map +1 -1
- package/dist/materializer/telemetry/plan.d.ts +2 -8
- package/dist/materializer/telemetry/plan.d.ts.map +1 -1
- package/dist/models/audio/catalog.d.ts +20 -0
- package/dist/models/audio/catalog.d.ts.map +1 -0
- package/dist/models/audio/errors.d.ts +8 -0
- package/dist/models/audio/errors.d.ts.map +1 -0
- package/dist/models/audio/file.d.ts +9 -0
- package/dist/models/audio/file.d.ts.map +1 -0
- package/dist/models/audio/runtime.d.ts +8 -0
- package/dist/models/audio/runtime.d.ts.map +1 -0
- package/dist/models/audio/types.d.ts +60 -0
- package/dist/models/audio/types.d.ts.map +1 -0
- package/dist/models/catalog.d.ts +24 -2
- package/dist/models/catalog.d.ts.map +1 -1
- package/dist/models/definitions.d.ts +1 -1
- package/dist/models/definitions.d.ts.map +1 -1
- package/dist/models/events.d.ts +3 -0
- package/dist/models/events.d.ts.map +1 -1
- package/dist/models/execution/binding.d.ts +6 -0
- package/dist/models/execution/binding.d.ts.map +1 -1
- package/dist/models/execution/index.js +27 -24
- package/dist/models/execution/index.js.map +1 -1
- package/dist/models/execution/model-call-admission.d.ts +6 -1
- package/dist/models/execution/model-call-admission.d.ts.map +1 -1
- package/dist/models/execution/model-call-limits.d.ts.map +1 -1
- package/dist/models/execution/model-call-recorder.d.ts +4 -0
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution/reranking.d.ts +4 -0
- package/dist/models/execution/reranking.d.ts.map +1 -0
- package/dist/models/execution/usage.d.ts.map +1 -1
- package/dist/models/execution.d.ts +2 -1
- package/dist/models/execution.d.ts.map +1 -1
- package/dist/models/generation-types.d.ts +2 -0
- package/dist/models/generation-types.d.ts.map +1 -1
- package/dist/models/index.d.ts +7 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +6 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/language-model.d.ts +6 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/pricing.d.ts +2 -2
- package/dist/models/pricing.d.ts.map +1 -1
- package/dist/models/reranking-model.d.ts +49 -0
- package/dist/models/reranking-model.d.ts.map +1 -0
- package/dist/objects/context/index.d.ts +1 -1
- package/dist/objects/context/index.d.ts.map +1 -1
- package/dist/objects/context/types.d.ts +6 -0
- package/dist/objects/context/types.d.ts.map +1 -1
- package/dist/objects/execution.d.ts +2 -1
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +31 -27
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/materializer-adapter.d.ts.map +1 -1
- package/dist/objects/object/upsert-batch.d.ts.map +1 -1
- package/dist/objects/object/upsert.d.ts.map +1 -1
- package/dist/objects/property-clearance.d.ts +41 -0
- package/dist/objects/property-clearance.d.ts.map +1 -0
- package/dist/objects/query/executor.d.ts +5 -1
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +1 -1
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +27 -24
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/ir.d.ts +8 -1
- package/dist/objects/query/ir.d.ts.map +1 -1
- package/dist/objects/query/normalize.d.ts.map +1 -1
- package/dist/objects/query/planner.d.ts +1 -1
- package/dist/objects/query/planner.d.ts.map +1 -1
- package/dist/objects/query/primary-id.d.ts +7 -0
- package/dist/objects/query/primary-id.d.ts.map +1 -0
- package/dist/objects/query/reranking-executor.d.ts +13 -0
- package/dist/objects/query/reranking-executor.d.ts.map +1 -0
- package/dist/objects/query/reranking-limits.d.ts +3 -0
- package/dist/objects/query/reranking-limits.d.ts.map +1 -0
- package/dist/objects/query/reranking-query.d.ts +4 -0
- package/dist/objects/query/reranking-query.d.ts.map +1 -0
- package/dist/objects/query/validate.d.ts +10 -1
- package/dist/objects/query/validate.d.ts.map +1 -1
- package/dist/objects/sdk/file-handle.d.ts +6 -0
- package/dist/objects/sdk/file-handle.d.ts.map +1 -0
- package/dist/objects/sdk/object-handle.d.ts +2 -2
- package/dist/objects/sdk/object-handle.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts +2 -0
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/objects/sdk/query-builder.d.ts +8 -0
- package/dist/objects/sdk/query-builder.d.ts.map +1 -1
- package/dist/objects/sdk/query-executor.d.ts +2 -2
- package/dist/objects/sdk/query-executor.d.ts.map +1 -1
- package/dist/objects/sdk/runtime-query-executor.d.ts.map +1 -1
- package/dist/objects/vectors/indexing-dispatch.d.ts +21 -0
- package/dist/objects/vectors/indexing-dispatch.d.ts.map +1 -0
- package/dist/objects/vectors/query.d.ts.map +1 -1
- package/dist/ontology/builders.d.ts +12 -1
- package/dist/ontology/builders.d.ts.map +1 -1
- package/dist/ontology/docs-markdown.d.ts +35 -0
- package/dist/ontology/docs-markdown.d.ts.map +1 -0
- package/dist/ontology/docs.d.ts +50 -0
- package/dist/ontology/docs.d.ts.map +1 -0
- package/dist/ontology/index.d.ts +1 -1
- package/dist/ontology/index.d.ts.map +1 -1
- package/dist/ontology/index.js +7 -4
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/inference/index.d.ts +19 -0
- package/dist/ontology/inference/index.d.ts.map +1 -1
- package/dist/ontology/internal.d.ts +3 -1
- package/dist/ontology/internal.d.ts.map +1 -1
- package/dist/ontology/internal.js +276 -3
- package/dist/ontology/internal.js.map +4 -3
- package/dist/ontology/query-capabilities.d.ts +1 -0
- package/dist/ontology/query-capabilities.d.ts.map +1 -1
- package/dist/ontology/tokens.d.ts +8 -1
- package/dist/ontology/tokens.d.ts.map +1 -1
- package/dist/ontology/types.d.ts +25 -0
- package/dist/ontology/types.d.ts.map +1 -1
- package/dist/ontology/validation/index.d.ts +1 -1
- package/dist/ontology/validation/index.d.ts.map +1 -1
- package/dist/ontology/validation/query.d.ts.map +1 -1
- package/dist/ontology/validation/schema.d.ts +7 -0
- package/dist/ontology/validation/schema.d.ts.map +1 -1
- package/dist/pipelines/index.js +29 -26
- package/dist/pipelines/index.js.map +1 -1
- package/dist/projections/internal.js +27 -24
- package/dist/projections/internal.js.map +1 -1
- package/dist/query.d.ts +4 -2
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +2 -2
- package/dist/queues/in-memory.d.ts +3 -0
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +4 -0
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/create.d.ts +11 -2
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/definitions.d.ts +3 -1
- package/dist/runtime/definitions.d.ts.map +1 -1
- package/dist/runtime/host.d.ts +14 -2
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/index.d.ts +1 -1
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/internal.d.ts +1 -0
- package/dist/runtime/internal.d.ts.map +1 -1
- package/dist/runtime/internal.js +32 -27
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/locale.d.ts +9 -0
- package/dist/runtime/locale.d.ts.map +1 -0
- package/dist/runtime/public-origin.d.ts +10 -0
- package/dist/runtime/public-origin.d.ts.map +1 -0
- package/dist/runtime/resolve-definitions.d.ts +4 -2
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/sixb.d.ts +1 -0
- package/dist/runtime/sixb.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +42 -5
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandboxes/index.js +7 -6
- package/dist/sandboxes/index.js.map +1 -1
- package/dist/scheduler/index.js +1 -1
- package/dist/scheduler/runtime.d.ts +3 -0
- package/dist/scheduler/runtime.d.ts.map +1 -1
- package/dist/security/builders.d.ts +11 -2
- package/dist/security/builders.d.ts.map +1 -1
- package/dist/security/index.d.ts +4 -4
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/markings.d.ts +19 -0
- package/dist/security/markings.d.ts.map +1 -0
- package/dist/security/redactions.d.ts +4 -0
- package/dist/security/redactions.d.ts.map +1 -0
- package/dist/security/registry.d.ts +7 -1
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +25 -0
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts +4 -1
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/shares/internal.js +24 -21
- package/dist/shares/internal.js.map +2 -2
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +5 -4
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +15 -9
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/analytics.d.ts +1 -0
- package/dist/storage/ai-cost/analytics.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +3 -3
- package/dist/storage/ai-cost/types.d.ts +1 -1
- package/dist/storage/ai-cost/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/validation.d.ts.map +1 -1
- package/dist/storage/ai-limits/enforcement.js +2 -2
- package/dist/storage/ai-limits/in-memory.d.ts.map +1 -1
- package/dist/storage/ai-limits/provider.d.ts +7 -2
- package/dist/storage/ai-limits/provider.d.ts.map +1 -1
- package/dist/storage/ai-limits/provider.js +4 -2
- package/dist/storage/ai-limits/provider.js.map +1 -1
- package/dist/storage/ai-limits/types.d.ts +3 -0
- package/dist/storage/ai-limits/types.d.ts.map +1 -1
- package/dist/storage/ai-usage/record.d.ts.map +1 -1
- package/dist/storage/ai-usage/types.d.ts +8 -4
- package/dist/storage/ai-usage/types.d.ts.map +1 -1
- package/dist/storage/ai-usage/usage.d.ts.map +1 -1
- package/dist/storage/file-download-grants/in-memory.d.ts +11 -0
- package/dist/storage/file-download-grants/in-memory.d.ts.map +1 -0
- package/dist/storage/file-download-grants/index.d.ts +3 -0
- package/dist/storage/file-download-grants/index.d.ts.map +1 -0
- package/dist/storage/file-download-grants/record.d.ts +11 -0
- package/dist/storage/file-download-grants/record.d.ts.map +1 -0
- package/dist/storage/file-download-grants/types.d.ts +44 -0
- package/dist/storage/file-download-grants/types.d.ts.map +1 -0
- package/dist/storage/file-upload-sessions/provider.js +10 -7
- package/dist/storage/file-upload-sessions/provider.js.map +1 -1
- package/dist/storage/in-memory/index.d.ts +4 -0
- package/dist/storage/in-memory/index.d.ts.map +1 -1
- package/dist/storage/index.d.ts +6 -3
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +35 -32
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +1 -0
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +9 -4
- package/dist/storage/internal.js.map +1 -1
- package/dist/storage/migrations/index.d.ts +1 -1
- package/dist/storage/migrations/index.d.ts.map +1 -1
- package/dist/storage/migrations/migrate-storage.d.ts +3 -3
- package/dist/storage/migrations/migrate-storage.d.ts.map +1 -1
- package/dist/storage/migrations/types.d.ts +7 -0
- package/dist/storage/migrations/types.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/query.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/selected-reader.d.ts.map +1 -1
- package/dist/storage/objects/in-memory/storage.d.ts.map +1 -1
- package/dist/storage/objects/query-preparation.d.ts +39 -0
- package/dist/storage/objects/query-preparation.d.ts.map +1 -0
- package/dist/storage/objects/types.d.ts +9 -0
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/ontology/commits.d.ts +1 -6
- package/dist/storage/ontology/commits.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/index.d.ts +4 -2
- package/dist/storage/ontology/in-memory/index.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations-state.d.ts +0 -2
- package/dist/storage/ontology/in-memory/materializations-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations-work.d.ts +1 -3
- package/dist/storage/ontology/in-memory/materializations-work.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/materializations.d.ts +23 -57
- package/dist/storage/ontology/in-memory/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/outbox.d.ts +3 -2
- package/dist/storage/ontology/in-memory/outbox.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts +104 -0
- package/dist/storage/ontology/in-memory/replacement-plans.d.ts.map +1 -0
- package/dist/storage/ontology/in-memory/shared-state.d.ts +17 -2
- package/dist/storage/ontology/in-memory/shared-state.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/source-roots.d.ts +3 -1
- package/dist/storage/ontology/in-memory/source-roots.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/sources.d.ts +1 -2
- package/dist/storage/ontology/in-memory/sources.d.ts.map +1 -1
- package/dist/storage/ontology/in-memory/state-reader.d.ts +25 -0
- package/dist/storage/ontology/in-memory/state-reader.d.ts.map +1 -0
- package/dist/storage/ontology/index.d.ts +6 -3
- package/dist/storage/ontology/index.d.ts.map +1 -1
- package/dist/storage/ontology/materializations.d.ts +40 -59
- package/dist/storage/ontology/materializations.d.ts.map +1 -1
- package/dist/storage/ontology/outbox.d.ts +4 -6
- package/dist/storage/ontology/outbox.d.ts.map +1 -1
- package/dist/storage/ontology/provider-work.d.ts +114 -3
- package/dist/storage/ontology/provider-work.d.ts.map +1 -1
- package/dist/storage/ontology/provider.d.ts +14 -39
- package/dist/storage/ontology/provider.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +26 -12
- package/dist/storage/ontology/provider.js.map +1 -1
- package/dist/storage/ontology/replacement-plans.d.ts +103 -0
- package/dist/storage/ontology/replacement-plans.d.ts.map +1 -0
- package/dist/storage/ontology/sources.d.ts +0 -8
- package/dist/storage/ontology/sources.d.ts.map +1 -1
- package/dist/storage/operation-scope.d.ts.map +1 -1
- package/dist/storage/operation-scope.js +1 -1
- package/dist/storage/projection-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/projection-runs/types.d.ts +2 -0
- package/dist/storage/projection-runs/types.d.ts.map +1 -1
- package/dist/storage/types.d.ts +2 -0
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +10 -7
- package/dist/storage/workflow-runs/provider.js.map +1 -1
- package/dist/syncs/index.js +30 -27
- package/dist/syncs/index.js.map +1 -1
- package/dist/testing/ai-cost-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-limit-storage-contract.d.ts.map +1 -1
- package/dist/testing/ai-usage-storage-contract.d.ts.map +1 -1
- package/dist/testing/file-download-grant-storage-contract.d.ts +9 -0
- package/dist/testing/file-download-grant-storage-contract.d.ts.map +1 -0
- package/dist/testing/index.d.ts +1 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2556 -1495
- package/dist/testing/index.js.map +14 -13
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/materializer-storage-contract.d.ts +14 -0
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-read-scope-contract.d.ts.map +1 -1
- package/dist/testing/ontology-contract-fixture.d.ts +5 -1
- package/dist/testing/ontology-contract-fixture.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/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +25 -22
- package/dist/webhooks/internal.js.map +2 -2
- package/dist/workers/index.js +15 -17
- package/dist/workers/index.js.map +3 -3
- package/dist/workers/queue-worker.d.ts +3 -2
- package/dist/workers/queue-worker.d.ts.map +1 -1
- package/dist/workflows/builders.d.ts.map +1 -1
- package/dist/workflows/index.js +51 -47
- package/dist/workflows/index.js.map +1 -1
- package/dist/workflows/request.d.ts.map +1 -1
- package/dist/workflows/types.d.ts +6 -3
- package/dist/workflows/types.d.ts.map +1 -1
- package/dist/workflows/validation.d.ts +2 -1
- package/dist/workflows/validation.d.ts.map +1 -1
- package/package.json +7 -1
- package/src/actions/read-facade.ts +2 -1
- package/src/actions/types/context.ts +5 -2
- package/src/actions/validation.ts +4 -1
- package/src/agents/adapters.ts +15 -0
- package/src/agents/authority.ts +15 -0
- package/src/agents/context/entries.ts +48 -4
- package/src/agents/context/index.ts +1 -0
- package/src/agents/context-compaction.ts +6 -0
- package/src/agents/errors.ts +3 -0
- package/src/agents/index.ts +13 -1
- package/src/agents/message.ts +9 -0
- package/src/agents/request.ts +178 -22
- package/src/agents/skills.ts +63 -0
- package/src/agents/types.ts +35 -5
- package/src/auth/runtime.ts +14 -0
- package/src/auth/types.ts +6 -0
- package/src/authorization/resolve.ts +6 -1
- package/src/authorization/types.ts +7 -0
- package/src/blob-storage/download-urls.ts +138 -0
- package/src/blob-storage/execution.ts +44 -1
- package/src/blob-storage/file-content.ts +106 -0
- package/src/blob-storage/index.ts +1 -0
- package/src/blob-storage/internal.ts +8 -0
- package/src/blob-storage/media-type.ts +29 -0
- package/src/blob-storage/types.ts +13 -1
- package/src/blob-storage/validation.ts +13 -0
- package/src/bootstrap/agent-context.ts +356 -0
- package/src/bootstrap/discovery.ts +100 -33
- package/src/bootstrap/index.ts +1 -1
- package/src/bootstrap/ontology-type-manifest.ts +3 -38
- package/src/datasets/builders.ts +17 -1
- package/src/datasets/execution.ts +110 -2
- package/src/datasets/index.ts +7 -1
- package/src/datasets/types.ts +2 -0
- package/src/datasets/write.ts +21 -2
- package/src/edits/properties.ts +3 -0
- package/src/events/execution.ts +15 -16
- package/src/events/types/objects.ts +5 -0
- package/src/execution/agent.ts +27 -0
- package/src/execution/authorization.ts +1 -0
- package/src/execution/authorized-object-reader.ts +104 -35
- package/src/execution/scopes.ts +2 -6
- package/src/http/api-routes.ts +4 -3
- package/src/index.ts +52 -2
- package/src/lake-storage/in-memory.ts +38 -9
- package/src/lake-storage/index.ts +2 -0
- package/src/lake-storage/types.ts +30 -0
- package/src/maintenance/ontology-maintenance.ts +50 -23
- package/src/maintenance/types.ts +1 -4
- package/src/materialization/event-envelopes.ts +168 -0
- package/src/materialization/events.ts +40 -4
- package/src/materialization/index.ts +9 -1
- package/src/materializer/README.md +55 -10
- package/src/materializer/edits/commit.ts +3 -19
- package/src/materializer/edits/plan.ts +20 -71
- package/src/materializer/effective/build-events.ts +42 -136
- package/src/materializer/effective/vector-indexing.ts +2 -3
- package/src/materializer/effective/vectors.ts +2 -3
- package/src/materializer/execution/scope.ts +1 -38
- package/src/materializer/execution/work-executor.ts +21 -115
- package/src/materializer/execution/work-records.ts +0 -15
- package/src/materializer/projections/replace.ts +106 -63
- package/src/materializer/projections/replacement-plan.ts +73 -218
- package/src/materializer/shared/batching.ts +7 -0
- package/src/materializer/telemetry/append.ts +2 -14
- package/src/materializer/telemetry/plan.ts +6 -43
- package/src/models/audio/catalog.ts +90 -0
- package/src/models/audio/errors.ts +19 -0
- package/src/models/audio/file.ts +78 -0
- package/src/models/audio/runtime.ts +182 -0
- package/src/models/audio/types.ts +69 -0
- package/src/models/catalog.ts +78 -7
- package/src/models/definitions.ts +8 -1
- package/src/models/events.ts +3 -0
- package/src/models/execution/README.md +24 -4
- package/src/models/execution/binding.ts +6 -0
- package/src/models/execution/model-call-admission.ts +6 -1
- package/src/models/execution/model-call-limits.ts +21 -11
- package/src/models/execution/model-call-recorder.ts +11 -0
- package/src/models/execution/model-call-recovery.ts +1 -0
- package/src/models/execution/reranking.ts +137 -0
- package/src/models/execution/session.ts +2 -2
- package/src/models/execution/usage.ts +1 -0
- package/src/models/execution.ts +11 -3
- package/src/models/generation-types.ts +2 -0
- package/src/models/index.ts +32 -0
- package/src/models/language-model.ts +6 -0
- package/src/models/pricing.ts +2 -1
- package/src/models/reranking-model.ts +114 -0
- package/src/objects/context/index.ts +1 -0
- package/src/objects/context/types.ts +7 -0
- package/src/objects/execution.ts +4 -1
- package/src/objects/materializer-adapter.ts +3 -0
- package/src/objects/object/upsert-batch.ts +4 -1
- package/src/objects/object/upsert.ts +3 -1
- package/src/objects/property-clearance.ts +209 -0
- package/src/objects/query/executor.ts +85 -38
- package/src/objects/query/explain.ts +8 -0
- package/src/objects/query/index.ts +1 -0
- package/src/objects/query/ir.ts +10 -0
- package/src/objects/query/normalize.ts +2 -0
- package/src/objects/query/planner.ts +12 -1
- package/src/objects/query/primary-id.ts +56 -0
- package/src/objects/query/reranking-executor.ts +91 -0
- package/src/objects/query/reranking-limits.ts +3 -0
- package/src/objects/query/reranking-query.ts +8 -0
- package/src/objects/query/validate.ts +166 -15
- package/src/objects/sdk/file-handle.ts +77 -0
- package/src/objects/sdk/object-handle.ts +8 -4
- package/src/objects/sdk/object-set.ts +5 -2
- package/src/objects/sdk/query-builder.ts +15 -2
- package/src/objects/sdk/query-executor.ts +2 -2
- package/src/objects/sdk/runtime-query-executor.ts +7 -4
- package/src/objects/vectors/README.md +6 -2
- package/src/objects/vectors/indexing-dispatch.ts +83 -0
- package/src/objects/vectors/query.ts +3 -0
- package/src/ontology/builders.ts +19 -2
- package/src/ontology/docs-markdown.ts +394 -0
- package/src/ontology/docs.ts +196 -0
- package/src/ontology/index.ts +2 -0
- package/src/ontology/inference/index.ts +25 -0
- package/src/ontology/internal.ts +7 -0
- package/src/ontology/query-capabilities.ts +1 -1
- package/src/ontology/tokens.ts +13 -2
- package/src/ontology/types.ts +26 -0
- package/src/ontology/validation/index.ts +1 -0
- package/src/ontology/validation/query.ts +57 -0
- package/src/ontology/validation/schema.ts +26 -1
- package/src/query.ts +4 -0
- package/src/queues/in-memory.ts +54 -19
- package/src/queues/types.ts +4 -0
- package/src/runtime/create.ts +34 -4
- package/src/runtime/definitions.ts +3 -1
- package/src/runtime/host.ts +73 -2
- package/src/runtime/index.ts +4 -0
- package/src/runtime/internal.ts +1 -0
- package/src/runtime/locale.ts +26 -0
- package/src/runtime/public-origin.ts +33 -0
- package/src/runtime/resolve-definitions.ts +28 -1
- package/src/runtime/sixb.ts +14 -3
- package/src/runtime/types.ts +51 -5
- package/src/scheduler/runtime.ts +11 -2
- package/src/security/builders.ts +49 -5
- package/src/security/index.ts +6 -1
- package/src/security/markings.ts +313 -0
- package/src/security/redactions.ts +6 -0
- package/src/security/registry.ts +21 -1
- package/src/security/types.ts +26 -0
- package/src/security/validation.ts +59 -2
- package/src/storage/agents/provider.ts +11 -0
- package/src/storage/agents/types.ts +15 -7
- package/src/storage/ai-cost/analytics.ts +2 -0
- package/src/storage/ai-cost/codec.ts +2 -1
- package/src/storage/ai-cost/types.ts +1 -0
- package/src/storage/ai-cost/validation.ts +21 -8
- package/src/storage/ai-limits/in-memory.ts +10 -2
- package/src/storage/ai-limits/provider.ts +29 -2
- package/src/storage/ai-limits/types.ts +3 -0
- package/src/storage/ai-usage/record.ts +9 -0
- package/src/storage/ai-usage/types.ts +8 -4
- package/src/storage/ai-usage/usage.ts +2 -0
- package/src/storage/file-download-grants/in-memory.ts +73 -0
- package/src/storage/file-download-grants/index.ts +8 -0
- package/src/storage/file-download-grants/record.ts +47 -0
- package/src/storage/file-download-grants/types.ts +48 -0
- package/src/storage/in-memory/index.ts +13 -2
- package/src/storage/index.ts +32 -13
- package/src/storage/internal.ts +1 -0
- package/src/storage/migrations/index.ts +1 -0
- package/src/storage/migrations/migrate-storage.ts +36 -12
- package/src/storage/migrations/types.ts +8 -0
- package/src/storage/objects/in-memory/query.ts +2 -0
- package/src/storage/objects/in-memory/selected-reader.ts +1 -0
- package/src/storage/objects/in-memory/storage.ts +1 -0
- package/src/storage/objects/query-preparation.ts +77 -0
- package/src/storage/objects/types.ts +9 -0
- package/src/storage/ontology/commits.ts +1 -6
- package/src/storage/ontology/in-memory/index.ts +28 -9
- package/src/storage/ontology/in-memory/materializations-finalization.ts +35 -68
- package/src/storage/ontology/in-memory/materializations-state.ts +0 -22
- package/src/storage/ontology/in-memory/materializations-work.ts +0 -45
- package/src/storage/ontology/in-memory/materializations.ts +172 -653
- package/src/storage/ontology/in-memory/outbox.ts +37 -29
- package/src/storage/ontology/in-memory/replacement-plans.ts +697 -0
- package/src/storage/ontology/in-memory/shared-state.ts +24 -2
- package/src/storage/ontology/in-memory/source-roots.ts +7 -2
- package/src/storage/ontology/in-memory/sources.ts +7 -33
- package/src/storage/ontology/in-memory/state-reader.ts +245 -0
- package/src/storage/ontology/index.ts +19 -13
- package/src/storage/ontology/materializations.ts +45 -74
- package/src/storage/ontology/outbox.ts +4 -7
- package/src/storage/ontology/provider-header-validation.ts +0 -57
- package/src/storage/ontology/provider-work.ts +381 -90
- package/src/storage/ontology/provider.ts +74 -171
- package/src/storage/ontology/replacement-plans.ts +117 -0
- package/src/storage/ontology/sources.ts +0 -12
- package/src/storage/operation-scope.ts +33 -1
- package/src/storage/projection-runs/in-memory.ts +7 -1
- package/src/storage/projection-runs/types.ts +2 -0
- package/src/storage/types.ts +2 -0
- package/src/testing/ai-cost-storage-contract.ts +1 -0
- package/src/testing/ai-limit-storage-contract.ts +62 -0
- package/src/testing/ai-usage-storage-contract.ts +31 -0
- package/src/testing/file-download-grant-storage-contract.ts +139 -0
- package/src/testing/index.ts +4 -0
- package/src/testing/lake-storage-contract.ts +87 -1
- package/src/testing/materializer-storage-contract.ts +1008 -1
- package/src/testing/object-read-scope-contract.ts +1 -0
- package/src/testing/ontology-contract-fixture.ts +11 -87
- package/src/testing/ontology-storage-contract.ts +70 -39
- package/src/testing/projection-run-storage-contract.ts +14 -0
- package/src/testing/queues-contract.ts +59 -0
- package/src/workers/queue-worker.ts +19 -16
- package/src/workflows/builders.ts +24 -1
- package/src/workflows/request.ts +3 -0
- package/src/workflows/types.ts +6 -3
- package/src/workflows/validation.ts +32 -4
- package/dist/chunk-3q7z9hd4.js.map +0 -46
- package/dist/chunk-667x4drs.js.map +0 -12
- package/dist/chunk-69266efg.js.map +0 -12
- package/dist/chunk-6z1q7j19.js.map +0 -62
- package/dist/chunk-7ytf06d3.js +0 -113
- package/dist/chunk-7ytf06d3.js.map +0 -10
- package/dist/chunk-8x74221e.js.map +0 -20
- package/dist/chunk-91kcnbf0.js.map +0 -10
- package/dist/chunk-98cw09sw.js.map +0 -10
- package/dist/chunk-9vx5e9g1.js.map +0 -11
- package/dist/chunk-a0073121.js.map +0 -12
- package/dist/chunk-a7ne02hk.js.map +0 -15
- package/dist/chunk-cd234ba4.js.map +0 -14
- package/dist/chunk-chdg6eqq.js.map +0 -10
- package/dist/chunk-dmn70ztd.js.map +0 -11
- package/dist/chunk-f72rbvsb.js.map +0 -19
- package/dist/chunk-g4rbm4a6.js.map +0 -15
- package/dist/chunk-h044jb97.js.map +0 -15
- package/dist/chunk-h3v76ams.js.map +0 -11
- package/dist/chunk-h4138ww2.js.map +0 -50
- package/dist/chunk-hgqpcmyr.js.map +0 -12
- package/dist/chunk-jgwb25gc.js.map +0 -12
- package/dist/chunk-k4kkp58d.js.map +0 -11
- package/dist/chunk-kttr5ftm.js.map +0 -12
- package/dist/chunk-kvysp909.js.map +0 -17
- package/dist/chunk-mdnw7nj8.js.map +0 -15
- package/dist/chunk-s3csryxe.js.map +0 -11
- package/dist/chunk-tnvafr7g.js.map +0 -19
- package/dist/chunk-vjqt7q3a.js.map +0 -36
- package/dist/chunk-xnx96gfy.js.map +0 -15
- package/dist/chunk-z5rnrmz1.js.map +0 -11
- package/dist/chunk-zvmr2hqk.js.map +0 -12
- package/dist/materializer/execution/plan-stream.d.ts +0 -8
- package/dist/materializer/execution/plan-stream.d.ts.map +0 -1
- package/src/materializer/execution/plan-stream.ts +0 -121
- /package/dist/{chunk-4gmng3vf.js.map → chunk-22v5bpz3.js.map} +0 -0
- /package/dist/{chunk-fj1dvp37.js.map → chunk-2vhg6ysa.js.map} +0 -0
- /package/dist/{chunk-gmdvns8f.js.map → chunk-48e3cn2d.js.map} +0 -0
- /package/dist/{chunk-cq44v1a6.js.map → chunk-7hpdd6r9.js.map} +0 -0
- /package/dist/{chunk-rb143ggb.js.map → chunk-bwjcehza.js.map} +0 -0
- /package/dist/{chunk-7g2gjvah.js.map → chunk-ex496vct.js.map} +0 -0
- /package/dist/{chunk-nvymebc1.js.map → chunk-f1zxad2t.js.map} +0 -0
- /package/dist/{chunk-b9y8hcm2.js.map → chunk-mfs23znk.js.map} +0 -0
- /package/dist/{chunk-h866d223.js.map → chunk-qkvz64nd.js.map} +0 -0
- /package/dist/{chunk-tkdbge6v.js.map → chunk-rt9p8m9t.js.map} +0 -0
- /package/dist/{chunk-sbcm1b92.js.map → chunk-v6xpd60t.js.map} +0 -0
- /package/dist/{chunk-nj0020ay.js.map → chunk-vgk3hknm.js.map} +0 -0
- /package/dist/{chunk-qnd7ehe5.js.map → chunk-vx2yp45y.js.map} +0 -0
- /package/dist/{chunk-nkbev3tr.js.map → chunk-yv9czyfr.js.map} +0 -0
- /package/dist/{chunk-cxj8y8t0.js.map → chunk-za5yd58j.js.map} +0 -0
- /package/dist/{chunk-zb47r1c8.js.map → chunk-zb77kjth.js.map} +0 -0
- /package/dist/{chunk-dp7yk20b.js.map → chunk-zxawp1n2.js.map} +0 -0
|
@@ -15,8 +15,12 @@ import {
|
|
|
15
15
|
linkScopeSortKey2,
|
|
16
16
|
telemetryPointSortKey2,
|
|
17
17
|
compareObjectRefs2,
|
|
18
|
-
compareLinkRefs2
|
|
19
|
-
|
|
18
|
+
compareLinkRefs2,
|
|
19
|
+
materializationEventKindOrdinal2,
|
|
20
|
+
sha256Canonical2,
|
|
21
|
+
createRequestHash2,
|
|
22
|
+
createCommitId2
|
|
23
|
+
} from "./chunk-b9affek3.js";
|
|
20
24
|
import {
|
|
21
25
|
withFailureMessage
|
|
22
26
|
} from "./chunk-z3y5kg1x.js";
|
|
@@ -31,37 +35,32 @@ import {
|
|
|
31
35
|
normalizeLinkProperties2,
|
|
32
36
|
validateLinkProperties2,
|
|
33
37
|
validateTelemetryUnit2
|
|
34
|
-
} from "./chunk-
|
|
35
|
-
import {
|
|
36
|
-
materializationEventKindOrdinal2,
|
|
37
|
-
sha256Canonical2,
|
|
38
|
-
createRequestHash2,
|
|
39
|
-
createCommitId2,
|
|
40
|
-
createEventId2,
|
|
41
|
-
materializationApplyPhase
|
|
42
|
-
} from "./chunk-g4rbm4a6.js";
|
|
38
|
+
} from "./chunk-y05543x6.js";
|
|
43
39
|
import {
|
|
44
40
|
ProjectionValidationError2,
|
|
45
41
|
validateProjectionsAtStartup,
|
|
46
42
|
isProjectionDefinition2,
|
|
47
43
|
resolveExecutionScopeAuthorization
|
|
48
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-qkbx3tf6.js";
|
|
49
45
|
import {
|
|
50
46
|
objectBatchKey2,
|
|
51
47
|
vectorConfiguration,
|
|
52
48
|
vectorSources,
|
|
53
49
|
normalizeVector2
|
|
54
|
-
} from "./chunk-
|
|
50
|
+
} from "./chunk-qq90g05n.js";
|
|
51
|
+
import {
|
|
52
|
+
materializationApplyPhase2
|
|
53
|
+
} from "./chunk-wt4szfec.js";
|
|
55
54
|
import {
|
|
56
55
|
parseDatasetTimestamp2
|
|
57
56
|
} from "./chunk-z667z3sg.js";
|
|
58
57
|
import {
|
|
59
58
|
executionRecordInputFromRuntime,
|
|
60
59
|
ensureExecutionRecord2
|
|
61
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-ex496vct.js";
|
|
62
61
|
import {
|
|
63
62
|
isStorageSerializationFailure2
|
|
64
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-y9jmd7e5.js";
|
|
65
64
|
import {
|
|
66
65
|
assertPinnedDatasetWatermark2
|
|
67
66
|
} from "./chunk-6aawea28.js";
|
|
@@ -508,7 +507,8 @@ var DEFAULT_MATERIALIZATION_BATCHING = Object.freeze({
|
|
|
508
507
|
sourceStageBytes: 4 * 1024 * 1024,
|
|
509
508
|
statePageRows: 1000,
|
|
510
509
|
planChunkRows: 1000,
|
|
511
|
-
planChunkBytes: 4 * 1024 * 1024
|
|
510
|
+
planChunkBytes: 4 * 1024 * 1024,
|
|
511
|
+
transactionReplanRows: 1000
|
|
512
512
|
});
|
|
513
513
|
function resolveMaterializationBatching(overrides = {}) {
|
|
514
514
|
const resolved = { ...DEFAULT_MATERIALIZATION_BATCHING, ...overrides };
|
|
@@ -666,29 +666,9 @@ function prepareMaterializerExecution(projectId, scope) {
|
|
|
666
666
|
runtimeAuthorization: scope.authorization
|
|
667
667
|
}),
|
|
668
668
|
executionId: scope.execution.id,
|
|
669
|
-
correlationId: scope.execution.correlationId
|
|
670
|
-
attribution: executionAttribution(scope)
|
|
669
|
+
correlationId: scope.execution.correlationId
|
|
671
670
|
};
|
|
672
671
|
}
|
|
673
|
-
function executionAttribution(scope) {
|
|
674
|
-
const { requestedBy, executor } = scope.execution;
|
|
675
|
-
const attributed = { executor: eventExecutor(executor) };
|
|
676
|
-
if (requestedBy === undefined)
|
|
677
|
-
return attributed;
|
|
678
|
-
return { ...attributed, requestedBy: { type: requestedBy.type, id: requestedBy.id } };
|
|
679
|
-
}
|
|
680
|
-
function eventExecutor(executor) {
|
|
681
|
-
switch (executor.type) {
|
|
682
|
-
case "request":
|
|
683
|
-
return { type: "request", requestId: executor.requestId };
|
|
684
|
-
case "primitive":
|
|
685
|
-
return { type: "primitive", kind: executor.kind, id: executor.id, runId: executor.runId };
|
|
686
|
-
case "agent":
|
|
687
|
-
return { type: "agent", runId: executor.runId };
|
|
688
|
-
case "kernel":
|
|
689
|
-
return { type: "kernel", operation: structuredClone(executor.operation) };
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
672
|
function ensureMaterializerExecution(executions, execution) {
|
|
693
673
|
return ensureExecutionRecord2(executions, execution.record);
|
|
694
674
|
}
|
|
@@ -710,138 +690,6 @@ function assertMaterializerRunExecution(execution, runExecutionId, label) {
|
|
|
710
690
|
throw new MaterializationConflictError2("run-correlation", `${label} belongs to execution '${runExecutionId}', not '${execution.executionId}'.`);
|
|
711
691
|
}
|
|
712
692
|
|
|
713
|
-
// src/materializer/effective/build-events.ts
|
|
714
|
-
function buildObjectMaterializationEventDraft(input) {
|
|
715
|
-
const draft = buildObjectEventDraft(input, input.change);
|
|
716
|
-
return orderedDraft(objectRefSortKey2(input.change.ref), draft);
|
|
717
|
-
}
|
|
718
|
-
function buildObjectEventDraft(context, change) {
|
|
719
|
-
const base = eventDraftBase(context);
|
|
720
|
-
const partitionKey = `${change.ref.objectTypeId}:${change.ref.primaryId}`;
|
|
721
|
-
if (change.kind === "deleted") {
|
|
722
|
-
return {
|
|
723
|
-
...base,
|
|
724
|
-
type: "object.deleted",
|
|
725
|
-
topic: "objects",
|
|
726
|
-
partitionKey,
|
|
727
|
-
payload: {
|
|
728
|
-
objectTypeId: change.ref.objectTypeId,
|
|
729
|
-
primaryId: change.ref.primaryId,
|
|
730
|
-
propertyChanges: change.propertyChanges
|
|
731
|
-
}
|
|
732
|
-
};
|
|
733
|
-
}
|
|
734
|
-
const type = objectEventType(change);
|
|
735
|
-
return {
|
|
736
|
-
...base,
|
|
737
|
-
type,
|
|
738
|
-
topic: "objects",
|
|
739
|
-
partitionKey,
|
|
740
|
-
payload: {
|
|
741
|
-
objectTypeId: change.ref.objectTypeId,
|
|
742
|
-
primaryId: change.ref.primaryId,
|
|
743
|
-
properties: change.after.properties,
|
|
744
|
-
propertyChanges: change.propertyChanges
|
|
745
|
-
}
|
|
746
|
-
};
|
|
747
|
-
}
|
|
748
|
-
function objectEventType(change) {
|
|
749
|
-
if (change.kind === "created")
|
|
750
|
-
return "object.created";
|
|
751
|
-
return "object.updated";
|
|
752
|
-
}
|
|
753
|
-
function buildLinkMaterializationEventDraft(input) {
|
|
754
|
-
const draft = buildLinkEventDraft(input, input.change);
|
|
755
|
-
return orderedDraft(linkRefSortKey2(input.change.ref), draft);
|
|
756
|
-
}
|
|
757
|
-
function buildLinkEventDraft(context, change) {
|
|
758
|
-
const base = eventDraftBase(context);
|
|
759
|
-
const partitionKey = `${change.ref.source.objectTypeId}:${change.ref.source.primaryId}:${change.ref.linkId}`;
|
|
760
|
-
const commonPayload = {
|
|
761
|
-
sourceTypeId: change.ref.source.objectTypeId,
|
|
762
|
-
sourceId: change.ref.source.primaryId,
|
|
763
|
-
linkId: change.ref.linkId,
|
|
764
|
-
targetTypeId: change.ref.target.objectTypeId,
|
|
765
|
-
targetId: change.ref.target.primaryId,
|
|
766
|
-
propertyChanges: change.propertyChanges
|
|
767
|
-
};
|
|
768
|
-
if (change.kind === "deleted") {
|
|
769
|
-
return {
|
|
770
|
-
...base,
|
|
771
|
-
type: "link.deleted",
|
|
772
|
-
topic: "links",
|
|
773
|
-
partitionKey,
|
|
774
|
-
payload: commonPayload
|
|
775
|
-
};
|
|
776
|
-
}
|
|
777
|
-
const type = linkEventType(change);
|
|
778
|
-
if (change.after.properties === undefined) {
|
|
779
|
-
return { ...base, type, topic: "links", partitionKey, payload: commonPayload };
|
|
780
|
-
}
|
|
781
|
-
return {
|
|
782
|
-
...base,
|
|
783
|
-
type,
|
|
784
|
-
topic: "links",
|
|
785
|
-
partitionKey,
|
|
786
|
-
payload: { ...commonPayload, properties: change.after.properties }
|
|
787
|
-
};
|
|
788
|
-
}
|
|
789
|
-
function linkEventType(change) {
|
|
790
|
-
if (change.kind === "created")
|
|
791
|
-
return "link.created";
|
|
792
|
-
return "link.updated";
|
|
793
|
-
}
|
|
794
|
-
function buildTelemetryMaterializationEventDraft(input) {
|
|
795
|
-
const draft = buildTelemetryEventDraft(input, input.point);
|
|
796
|
-
return orderedDraft(telemetryPointSortKey2(input.point.series, input.point.at), draft);
|
|
797
|
-
}
|
|
798
|
-
function buildTelemetryEventDraft(context, point) {
|
|
799
|
-
const base = eventDraftBase(context);
|
|
800
|
-
const partitionKey = `${point.series.object.objectTypeId}:${point.series.object.primaryId}:${point.series.propertyId}`;
|
|
801
|
-
const payload = {
|
|
802
|
-
objectTypeId: point.series.object.objectTypeId,
|
|
803
|
-
objectId: point.series.object.primaryId,
|
|
804
|
-
propertyId: point.series.propertyId,
|
|
805
|
-
value: point.value,
|
|
806
|
-
at: point.at
|
|
807
|
-
};
|
|
808
|
-
if (point.unit === undefined) {
|
|
809
|
-
return { ...base, type: "telemetry.appended", topic: "telemetry", partitionKey, payload };
|
|
810
|
-
}
|
|
811
|
-
return {
|
|
812
|
-
...base,
|
|
813
|
-
type: "telemetry.appended",
|
|
814
|
-
topic: "telemetry",
|
|
815
|
-
partitionKey,
|
|
816
|
-
payload: { ...payload, unit: point.unit }
|
|
817
|
-
};
|
|
818
|
-
}
|
|
819
|
-
function eventDraftBase(context) {
|
|
820
|
-
return {
|
|
821
|
-
schemaVersion: 1,
|
|
822
|
-
projectId: context.projectId,
|
|
823
|
-
occurredAt: context.committedAt,
|
|
824
|
-
correlationId: context.correlationId,
|
|
825
|
-
origin: context.origin,
|
|
826
|
-
...context.attribution,
|
|
827
|
-
commitId: context.commitId
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
function orderedDraft(sortKey, draft) {
|
|
831
|
-
return {
|
|
832
|
-
kindRank: materializationEventKindOrdinal2(draft.type),
|
|
833
|
-
sortKey,
|
|
834
|
-
draft
|
|
835
|
-
};
|
|
836
|
-
}
|
|
837
|
-
function sequenceMaterializationEvent(projectId, commitId, commitOrdinal, draft) {
|
|
838
|
-
const sequence = {
|
|
839
|
-
id: createEventId2(projectId, commitId, commitOrdinal),
|
|
840
|
-
commitOrdinal
|
|
841
|
-
};
|
|
842
|
-
return { ...draft, ...sequence };
|
|
843
|
-
}
|
|
844
|
-
|
|
845
693
|
// src/materializer/effective/vector-indexing.ts
|
|
846
694
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
847
695
|
async function scheduleVectorChanges(context, storage, items, session, projection = false) {
|
|
@@ -966,237 +814,7 @@ async function* chunkBySize(items, input) {
|
|
|
966
814
|
yield chunk;
|
|
967
815
|
}
|
|
968
816
|
|
|
969
|
-
// src/materializer/execution/plan-stream.ts
|
|
970
|
-
async function* planStream(items, batching) {
|
|
971
|
-
for await (const itemsChunk of chunkBySize(items, {
|
|
972
|
-
maxRows: batching.planChunkRows,
|
|
973
|
-
maxBytes: batching.planChunkBytes,
|
|
974
|
-
byteLength: utf8JsonByteLength
|
|
975
|
-
})) {
|
|
976
|
-
const chunk = mutableChunk();
|
|
977
|
-
for (const item of itemsChunk)
|
|
978
|
-
appendItem(chunk, item);
|
|
979
|
-
yield chunk;
|
|
980
|
-
}
|
|
981
|
-
}
|
|
982
|
-
function mutableChunk() {
|
|
983
|
-
return {
|
|
984
|
-
overrides: {
|
|
985
|
-
objects: { upserts: [], deletes: [] },
|
|
986
|
-
links: {
|
|
987
|
-
edges: { upserts: [], deletes: [] },
|
|
988
|
-
slots: { upserts: [], deletes: [] }
|
|
989
|
-
}
|
|
990
|
-
},
|
|
991
|
-
effective: { objectUpserts: [], objectDeletes: [], linkUpserts: [], linkDeletes: [] },
|
|
992
|
-
timeseries: { pointUpserts: [] },
|
|
993
|
-
outbox: []
|
|
994
|
-
};
|
|
995
|
-
}
|
|
996
|
-
function appendItem(chunk, item) {
|
|
997
|
-
switch (item.kind) {
|
|
998
|
-
case "object-override-upsert":
|
|
999
|
-
chunk.overrides.objects.upserts.push(item.value);
|
|
1000
|
-
break;
|
|
1001
|
-
case "object-override-delete":
|
|
1002
|
-
chunk.overrides.objects.deletes.push(item.value);
|
|
1003
|
-
break;
|
|
1004
|
-
case "link-override-upsert":
|
|
1005
|
-
chunk.overrides.links.edges.upserts.push(item.value);
|
|
1006
|
-
break;
|
|
1007
|
-
case "link-override-delete":
|
|
1008
|
-
chunk.overrides.links.edges.deletes.push(item.value);
|
|
1009
|
-
break;
|
|
1010
|
-
case "link-slot-override-upsert":
|
|
1011
|
-
chunk.overrides.links.slots.upserts.push(item.value);
|
|
1012
|
-
break;
|
|
1013
|
-
case "link-slot-override-delete":
|
|
1014
|
-
chunk.overrides.links.slots.deletes.push(item.value);
|
|
1015
|
-
break;
|
|
1016
|
-
case "object-upsert":
|
|
1017
|
-
chunk.effective.objectUpserts.push(item.value);
|
|
1018
|
-
break;
|
|
1019
|
-
case "object-delete":
|
|
1020
|
-
chunk.effective.objectDeletes.push(item.value);
|
|
1021
|
-
break;
|
|
1022
|
-
case "link-upsert":
|
|
1023
|
-
chunk.effective.linkUpserts.push(item.value);
|
|
1024
|
-
break;
|
|
1025
|
-
case "link-delete":
|
|
1026
|
-
chunk.effective.linkDeletes.push(item.value);
|
|
1027
|
-
break;
|
|
1028
|
-
case "point-upsert":
|
|
1029
|
-
chunk.timeseries.pointUpserts.push(item.value);
|
|
1030
|
-
break;
|
|
1031
|
-
case "outbox":
|
|
1032
|
-
chunk.outbox.push(item.value);
|
|
1033
|
-
break;
|
|
1034
|
-
}
|
|
1035
|
-
}
|
|
1036
|
-
|
|
1037
|
-
// src/materializer/execution/work-records.ts
|
|
1038
|
-
function appendObjectOverrideWork(items, working, identity) {
|
|
1039
|
-
if (stableJsonStringify2(working.originalOverride?.value ?? null) === stableJsonStringify2(working.override) && stableJsonStringify2(working.originalEditedAt) === stableJsonStringify2(working.editedAt)) {
|
|
1040
|
-
return;
|
|
1041
|
-
}
|
|
1042
|
-
if (working.override) {
|
|
1043
|
-
items.push({
|
|
1044
|
-
kind: "object-override-upsert",
|
|
1045
|
-
value: {
|
|
1046
|
-
ref: working.ref,
|
|
1047
|
-
value: working.override,
|
|
1048
|
-
editedAt: working.editedAt,
|
|
1049
|
-
expectedLastCommitId: working.originalOverride?.lastCommitId ?? null,
|
|
1050
|
-
lastCommitId: identity.commitId,
|
|
1051
|
-
updatedAt: identity.committedAt
|
|
1052
|
-
}
|
|
1053
|
-
});
|
|
1054
|
-
} else if (working.originalOverride) {
|
|
1055
|
-
items.push({
|
|
1056
|
-
kind: "object-override-delete",
|
|
1057
|
-
value: { ref: working.ref, expectedLastCommitId: working.originalOverride.lastCommitId }
|
|
1058
|
-
});
|
|
1059
|
-
}
|
|
1060
|
-
}
|
|
1061
|
-
function appendLinkEdgeOverrideWork(items, working, identity) {
|
|
1062
|
-
if (stableJsonStringify2(working.originalOverride?.value ?? null) === stableJsonStringify2(working.override)) {
|
|
1063
|
-
return;
|
|
1064
|
-
}
|
|
1065
|
-
if (working.override) {
|
|
1066
|
-
items.push({
|
|
1067
|
-
kind: "link-override-upsert",
|
|
1068
|
-
value: {
|
|
1069
|
-
ref: working.ref,
|
|
1070
|
-
value: working.override,
|
|
1071
|
-
expectedLastCommitId: working.originalOverride?.lastCommitId ?? null,
|
|
1072
|
-
lastCommitId: identity.commitId,
|
|
1073
|
-
updatedAt: identity.committedAt
|
|
1074
|
-
}
|
|
1075
|
-
});
|
|
1076
|
-
} else if (working.originalOverride) {
|
|
1077
|
-
items.push({
|
|
1078
|
-
kind: "link-override-delete",
|
|
1079
|
-
value: { ref: working.ref, expectedLastCommitId: working.originalOverride.lastCommitId }
|
|
1080
|
-
});
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
function appendLinkSlotOverrideWork(items, working, identity) {
|
|
1084
|
-
if (stableJsonStringify2(working.originalOverride?.value ?? null) === stableJsonStringify2(working.override)) {
|
|
1085
|
-
return;
|
|
1086
|
-
}
|
|
1087
|
-
if (working.override) {
|
|
1088
|
-
items.push({
|
|
1089
|
-
kind: "link-slot-override-upsert",
|
|
1090
|
-
value: {
|
|
1091
|
-
ref: working.ref,
|
|
1092
|
-
value: working.override,
|
|
1093
|
-
expectedLastCommitId: working.originalOverride?.lastCommitId ?? null,
|
|
1094
|
-
lastCommitId: identity.commitId,
|
|
1095
|
-
updatedAt: identity.committedAt
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
} else if (working.originalOverride) {
|
|
1099
|
-
items.push({
|
|
1100
|
-
kind: "link-slot-override-delete",
|
|
1101
|
-
value: {
|
|
1102
|
-
ref: working.ref,
|
|
1103
|
-
expectedLastCommitId: working.originalOverride.lastCommitId
|
|
1104
|
-
}
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
}
|
|
1108
|
-
function appendEffectiveObjectWork(items, change) {
|
|
1109
|
-
if (change.kind === "deleted") {
|
|
1110
|
-
items.push({
|
|
1111
|
-
kind: "object-delete",
|
|
1112
|
-
value: {
|
|
1113
|
-
ref: change.ref,
|
|
1114
|
-
expected: expectedObject(change.before)
|
|
1115
|
-
}
|
|
1116
|
-
});
|
|
1117
|
-
} else {
|
|
1118
|
-
items.push({
|
|
1119
|
-
kind: "object-upsert",
|
|
1120
|
-
value: {
|
|
1121
|
-
row: change.after,
|
|
1122
|
-
expected: change.before ? expectedObject(change.before) : { ref: change.ref, exists: false }
|
|
1123
|
-
}
|
|
1124
|
-
});
|
|
1125
|
-
}
|
|
1126
|
-
}
|
|
1127
|
-
function appendEffectiveLinkWork(items, change) {
|
|
1128
|
-
if (change.kind === "deleted") {
|
|
1129
|
-
items.push({
|
|
1130
|
-
kind: "link-delete",
|
|
1131
|
-
value: {
|
|
1132
|
-
ref: change.ref,
|
|
1133
|
-
expected: expectedLink(change.before)
|
|
1134
|
-
}
|
|
1135
|
-
});
|
|
1136
|
-
} else {
|
|
1137
|
-
items.push({
|
|
1138
|
-
kind: "link-upsert",
|
|
1139
|
-
value: {
|
|
1140
|
-
row: change.after,
|
|
1141
|
-
expected: change.before ? expectedLink(change.before) : { ref: change.ref, exists: false }
|
|
1142
|
-
}
|
|
1143
|
-
});
|
|
1144
|
-
}
|
|
1145
|
-
}
|
|
1146
|
-
function outboxItem(event, committedAt) {
|
|
1147
|
-
const value = {
|
|
1148
|
-
envelope: event,
|
|
1149
|
-
availableAt: committedAt,
|
|
1150
|
-
createdAt: committedAt
|
|
1151
|
-
};
|
|
1152
|
-
return { kind: "outbox", value };
|
|
1153
|
-
}
|
|
1154
|
-
function classificationWork(entityKind, identityKey, sortKey) {
|
|
1155
|
-
return {
|
|
1156
|
-
kind: "classification",
|
|
1157
|
-
recordKey: `classification:${entityKind}:${sortKey}`,
|
|
1158
|
-
entityKind,
|
|
1159
|
-
identityKey
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
|
-
function planWork(item, sortKey) {
|
|
1163
|
-
const applyPhase = materializationApplyPhase(item.kind);
|
|
1164
|
-
return {
|
|
1165
|
-
kind: "plan",
|
|
1166
|
-
recordKey: `plan:${item.kind}:${sortKey}`,
|
|
1167
|
-
applyPhase,
|
|
1168
|
-
sortKey,
|
|
1169
|
-
item
|
|
1170
|
-
};
|
|
1171
|
-
}
|
|
1172
|
-
function eventWork(value) {
|
|
1173
|
-
return {
|
|
1174
|
-
kind: "event",
|
|
1175
|
-
recordKey: `event:${value.kindRank}:${value.sortKey}`,
|
|
1176
|
-
eventKindRank: value.kindRank,
|
|
1177
|
-
sortKey: value.sortKey,
|
|
1178
|
-
draft: value.draft
|
|
1179
|
-
};
|
|
1180
|
-
}
|
|
1181
|
-
function expectedObject(snapshot) {
|
|
1182
|
-
return {
|
|
1183
|
-
ref: snapshot.ref,
|
|
1184
|
-
exists: true,
|
|
1185
|
-
version: snapshot.version,
|
|
1186
|
-
lastCommitId: snapshot.lastCommitId
|
|
1187
|
-
};
|
|
1188
|
-
}
|
|
1189
|
-
function expectedLink(snapshot) {
|
|
1190
|
-
return { ref: snapshot.ref, exists: true, lastCommitId: snapshot.lastCommitId };
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
817
|
// src/materializer/execution/work-executor.ts
|
|
1194
|
-
async function applyItems(context, storage, session, items, signal) {
|
|
1195
|
-
for await (const chunk of planStream(items, context.batching)) {
|
|
1196
|
-
throwIfAborted(signal);
|
|
1197
|
-
await storage.applyChunk({ session, chunk });
|
|
1198
|
-
}
|
|
1199
|
-
}
|
|
1200
818
|
async function stageWorkBounded(context, storage, session, records) {
|
|
1201
819
|
for await (const chunk of chunkBySize(records, {
|
|
1202
820
|
maxRows: context.batching.planChunkRows,
|
|
@@ -1206,84 +824,23 @@ async function stageWorkBounded(context, storage, session, records) {
|
|
|
1206
824
|
await storage.stageWork({ session, records: chunk });
|
|
1207
825
|
}
|
|
1208
826
|
}
|
|
1209
|
-
async function
|
|
827
|
+
async function applyStagedWork(context, transactionStorage, session, signal, projection = false) {
|
|
1210
828
|
const ontologyStorage = transactionStorage.ontology;
|
|
1211
829
|
const storage = ontologyStorage.materializations;
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
};
|
|
1222
|
-
for await (const page of storage.streamWork({
|
|
1223
|
-
session,
|
|
1224
|
-
order: "apply",
|
|
1225
|
-
pageRows: context.batching.planChunkRows
|
|
1226
|
-
})) {
|
|
1227
|
-
for (const record of page.records) {
|
|
1228
|
-
if (record.kind !== "plan") {
|
|
1229
|
-
throw new MaterializationValidationError2("Provider returned non-plan apply work.");
|
|
1230
|
-
}
|
|
1231
|
-
if (phase !== null && record.applyPhase !== phase)
|
|
1232
|
-
await flush();
|
|
1233
|
-
phase = record.applyPhase;
|
|
1234
|
-
pending.push(record.item);
|
|
1235
|
-
if (pending.length >= context.batching.planChunkRows)
|
|
1236
|
-
await flush();
|
|
1237
|
-
}
|
|
1238
|
-
}
|
|
1239
|
-
await flush();
|
|
1240
|
-
}
|
|
1241
|
-
async function validateStagedCardinality(context, storage, session, signal) {
|
|
1242
|
-
let currentView = null;
|
|
1243
|
-
let currentScope = null;
|
|
1244
|
-
let occupant = null;
|
|
1245
|
-
for await (const page of storage.streamWork({
|
|
1246
|
-
session,
|
|
1247
|
-
order: "cardinality",
|
|
1248
|
-
pageRows: context.batching.statePageRows
|
|
1249
|
-
})) {
|
|
1250
|
-
throwIfAborted(signal);
|
|
1251
|
-
for (const record of page.records) {
|
|
1252
|
-
if (record.kind !== "cardinality") {
|
|
1253
|
-
throw new MaterializationValidationError2("Provider returned non-cardinality cardinality work.");
|
|
1254
|
-
}
|
|
1255
|
-
if (record.view !== currentView || record.scopeSortKey !== currentScope) {
|
|
1256
|
-
currentView = record.view;
|
|
1257
|
-
currentScope = record.scopeSortKey;
|
|
1258
|
-
occupant = null;
|
|
1259
|
-
}
|
|
1260
|
-
if (!record.occupied)
|
|
1261
|
-
continue;
|
|
1262
|
-
if (occupant && occupant !== record.linkSortKey) {
|
|
1263
|
-
throw new MaterializationValidationError2(record.view === "candidate" ? `Projection source scope '${record.ref.source.objectTypeId}.${record.ref.linkId}' has cardinality one.` : `Link scope '${record.ref.source.objectTypeId}.${record.ref.linkId}' has cardinality one.`);
|
|
1264
|
-
}
|
|
1265
|
-
occupant = record.linkSortKey;
|
|
1266
|
-
}
|
|
1267
|
-
}
|
|
1268
|
-
}
|
|
1269
|
-
async function drainStagedEvents(context, storage, session, identity, signal) {
|
|
1270
|
-
let ordinal = 0;
|
|
1271
|
-
for await (const page of storage.streamWork({
|
|
1272
|
-
session,
|
|
1273
|
-
order: "event",
|
|
1274
|
-
pageRows: context.batching.planChunkRows
|
|
1275
|
-
})) {
|
|
1276
|
-
const items = [];
|
|
1277
|
-
for (const record of page.records) {
|
|
1278
|
-
if (record.kind !== "event") {
|
|
1279
|
-
throw new MaterializationValidationError2("Provider returned non-event event work.");
|
|
1280
|
-
}
|
|
1281
|
-
const event = sequenceMaterializationEvent(context.projectId, identity.commitId, ordinal++, record.draft);
|
|
1282
|
-
items.push(outboxItem(event, identity.committedAt));
|
|
830
|
+
if (ontologyStorage.vectorIndexing || ontologyStorage.vectors) {
|
|
831
|
+
for await (const page of storage.streamVectorChanges({
|
|
832
|
+
session,
|
|
833
|
+
objectTypeIds: context.ontology.listObjectTypes().filter((type) => Object.keys(type.search?.vectors ?? {}).length > 0).map((type) => type.id),
|
|
834
|
+
pageRows: context.batching.planChunkRows
|
|
835
|
+
})) {
|
|
836
|
+
throwIfAborted(signal);
|
|
837
|
+
await scheduleVectorChanges(context, transactionStorage, page.items, session, projection);
|
|
838
|
+
await invalidateVectorChanges(context.projectId, ontologyStorage.vectors, page.items, session);
|
|
1283
839
|
}
|
|
1284
|
-
await applyItems(context, storage, session, items, signal);
|
|
1285
840
|
}
|
|
1286
|
-
|
|
841
|
+
throwIfAborted(signal);
|
|
842
|
+
const { eventCount } = await storage.apply({ session });
|
|
843
|
+
return eventCount;
|
|
1287
844
|
}
|
|
1288
845
|
|
|
1289
846
|
// src/materializer/shared/normalize.ts
|
|
@@ -2731,112 +2288,336 @@ function applyLinkSlotOperation(context, state, operation, normalizedProperties,
|
|
|
2731
2288
|
if (current && linkRefKey2(current.ref) !== linkRefKey2(operation.ref)) {
|
|
2732
2289
|
throw new MaterializationValidationError2(`Link scope '${operation.ref.source.objectTypeId}.${operation.ref.linkId}' has cardinality one.`);
|
|
2733
2290
|
}
|
|
2734
|
-
next = {
|
|
2735
|
-
kind: "set",
|
|
2736
|
-
target: operation.ref.target,
|
|
2737
|
-
...normalizedProperties !== undefined ? { properties: normalizedProperties } : {}
|
|
2738
|
-
};
|
|
2739
|
-
break;
|
|
2740
|
-
case "link.delete":
|
|
2741
|
-
if (current && linkRefKey2(current.ref) === linkRefKey2(operation.ref)) {
|
|
2742
|
-
next = { kind: "clear", target: operation.ref.target };
|
|
2291
|
+
next = {
|
|
2292
|
+
kind: "set",
|
|
2293
|
+
target: operation.ref.target,
|
|
2294
|
+
...normalizedProperties !== undefined ? { properties: normalizedProperties } : {}
|
|
2295
|
+
};
|
|
2296
|
+
break;
|
|
2297
|
+
case "link.delete":
|
|
2298
|
+
if (current && linkRefKey2(current.ref) === linkRefKey2(operation.ref)) {
|
|
2299
|
+
next = { kind: "clear", target: operation.ref.target };
|
|
2300
|
+
}
|
|
2301
|
+
break;
|
|
2302
|
+
case "link.reset":
|
|
2303
|
+
if (previous && objectRefKey2(previous.target) === objectRefKey2(operation.ref.target)) {
|
|
2304
|
+
next = null;
|
|
2305
|
+
}
|
|
2306
|
+
break;
|
|
2307
|
+
}
|
|
2308
|
+
const changed = stableJsonStringify2(previous) !== stableJsonStringify2(next);
|
|
2309
|
+
working.override = next;
|
|
2310
|
+
journal?.push({
|
|
2311
|
+
restore: () => {
|
|
2312
|
+
working.override = previous;
|
|
2313
|
+
}
|
|
2314
|
+
});
|
|
2315
|
+
return { id: operation.id, ok: true, authority: authorityOutcome(changed) };
|
|
2316
|
+
}
|
|
2317
|
+
function requireWorkingLinkEdge(state, operation) {
|
|
2318
|
+
const working = state.links.edges.get(linkRefKey2(operation.ref));
|
|
2319
|
+
if (!working)
|
|
2320
|
+
throw new MaterializationValidationError2("Link state was not loaded.");
|
|
2321
|
+
return working;
|
|
2322
|
+
}
|
|
2323
|
+
function validateLinkEndpoints(context, state, operation) {
|
|
2324
|
+
if (operation.kind !== "link.upsert")
|
|
2325
|
+
return;
|
|
2326
|
+
const source = state.objects.get(objectRefKey2(operation.ref.source));
|
|
2327
|
+
const target = state.objects.get(objectRefKey2(operation.ref.target));
|
|
2328
|
+
const sourceExists = source && resolveObject(context.ontology, source);
|
|
2329
|
+
const targetExists = target && resolveObject(context.ontology, target);
|
|
2330
|
+
if (sourceExists && targetExists)
|
|
2331
|
+
return;
|
|
2332
|
+
throw new MaterializationValidationError2("Link upsert requires both endpoints to be effective.");
|
|
2333
|
+
}
|
|
2334
|
+
function validateLinkOperation(context, operation) {
|
|
2335
|
+
if (operation.kind !== "link.upsert")
|
|
2336
|
+
return;
|
|
2337
|
+
return validateLinkAuthorityProperties(context.ontology, operation.ref, operation.properties);
|
|
2338
|
+
}
|
|
2339
|
+
function applyLinkEdgeTransition(working, next, journal) {
|
|
2340
|
+
const previous = working.override;
|
|
2341
|
+
working.override = next;
|
|
2342
|
+
journal?.push({
|
|
2343
|
+
restore: () => {
|
|
2344
|
+
working.override = previous;
|
|
2345
|
+
}
|
|
2346
|
+
});
|
|
2347
|
+
}
|
|
2348
|
+
function authorityOutcome(changed) {
|
|
2349
|
+
if (changed)
|
|
2350
|
+
return "changed";
|
|
2351
|
+
return "unchanged";
|
|
2352
|
+
}
|
|
2353
|
+
function isObjectOperation2(operation) {
|
|
2354
|
+
switch (operation.kind) {
|
|
2355
|
+
case "object.create":
|
|
2356
|
+
case "object.upsert":
|
|
2357
|
+
case "object.patch":
|
|
2358
|
+
case "object.delete":
|
|
2359
|
+
case "object.restore":
|
|
2360
|
+
return true;
|
|
2361
|
+
case "link.upsert":
|
|
2362
|
+
case "link.delete":
|
|
2363
|
+
case "link.reset":
|
|
2364
|
+
return false;
|
|
2365
|
+
}
|
|
2366
|
+
}
|
|
2367
|
+
|
|
2368
|
+
// src/materializer/effective/build-events.ts
|
|
2369
|
+
function buildObjectMaterializationEventDraft(change) {
|
|
2370
|
+
return orderedDraft(objectRefSortKey2(change.ref), buildObjectEventDraft(change));
|
|
2371
|
+
}
|
|
2372
|
+
function buildObjectEventDraft(change) {
|
|
2373
|
+
const identity = { objectTypeId: change.ref.objectTypeId, primaryId: change.ref.primaryId };
|
|
2374
|
+
switch (change.kind) {
|
|
2375
|
+
case "created":
|
|
2376
|
+
return {
|
|
2377
|
+
type: "object.created",
|
|
2378
|
+
payload: { ...identity, properties: change.after.properties }
|
|
2379
|
+
};
|
|
2380
|
+
case "updated":
|
|
2381
|
+
return {
|
|
2382
|
+
type: "object.updated",
|
|
2383
|
+
payload: {
|
|
2384
|
+
...identity,
|
|
2385
|
+
properties: change.after.properties,
|
|
2386
|
+
propertyChanges: change.propertyChanges
|
|
2387
|
+
}
|
|
2388
|
+
};
|
|
2389
|
+
case "deleted":
|
|
2390
|
+
return {
|
|
2391
|
+
type: "object.deleted",
|
|
2392
|
+
payload: { ...identity, propertyChanges: change.propertyChanges }
|
|
2393
|
+
};
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
function buildLinkMaterializationEventDraft(change) {
|
|
2397
|
+
return orderedDraft(linkRefSortKey2(change.ref), buildLinkEventDraft(change));
|
|
2398
|
+
}
|
|
2399
|
+
function buildLinkEventDraft(change) {
|
|
2400
|
+
const identity = {
|
|
2401
|
+
sourceTypeId: change.ref.source.objectTypeId,
|
|
2402
|
+
sourceId: change.ref.source.primaryId,
|
|
2403
|
+
linkId: change.ref.linkId,
|
|
2404
|
+
targetTypeId: change.ref.target.objectTypeId,
|
|
2405
|
+
targetId: change.ref.target.primaryId
|
|
2406
|
+
};
|
|
2407
|
+
if (change.kind === "deleted") {
|
|
2408
|
+
return {
|
|
2409
|
+
type: "link.deleted",
|
|
2410
|
+
payload: { ...identity, propertyChanges: change.propertyChanges }
|
|
2411
|
+
};
|
|
2412
|
+
}
|
|
2413
|
+
const properties = change.after.properties === undefined ? {} : { properties: change.after.properties };
|
|
2414
|
+
if (change.kind === "created") {
|
|
2415
|
+
return { type: "link.created", payload: { ...identity, ...properties } };
|
|
2416
|
+
}
|
|
2417
|
+
return {
|
|
2418
|
+
type: "link.updated",
|
|
2419
|
+
payload: { ...identity, ...properties, propertyChanges: change.propertyChanges }
|
|
2420
|
+
};
|
|
2421
|
+
}
|
|
2422
|
+
function buildTelemetryMaterializationEventDraft(point) {
|
|
2423
|
+
const payload = {
|
|
2424
|
+
objectTypeId: point.series.object.objectTypeId,
|
|
2425
|
+
objectId: point.series.object.primaryId,
|
|
2426
|
+
propertyId: point.series.propertyId,
|
|
2427
|
+
value: point.value,
|
|
2428
|
+
at: point.at,
|
|
2429
|
+
...point.unit === undefined ? {} : { unit: point.unit }
|
|
2430
|
+
};
|
|
2431
|
+
return orderedDraft(telemetryPointSortKey2(point.series, point.at), {
|
|
2432
|
+
type: "telemetry.appended",
|
|
2433
|
+
payload
|
|
2434
|
+
});
|
|
2435
|
+
}
|
|
2436
|
+
function orderedDraft(sortKey, draft) {
|
|
2437
|
+
return {
|
|
2438
|
+
kindRank: materializationEventKindOrdinal2(draft.type),
|
|
2439
|
+
sortKey,
|
|
2440
|
+
draft
|
|
2441
|
+
};
|
|
2442
|
+
}
|
|
2443
|
+
|
|
2444
|
+
// src/materializer/execution/work-records.ts
|
|
2445
|
+
function appendObjectOverrideWork(items, working, identity) {
|
|
2446
|
+
if (stableJsonStringify2(working.originalOverride?.value ?? null) === stableJsonStringify2(working.override) && stableJsonStringify2(working.originalEditedAt) === stableJsonStringify2(working.editedAt)) {
|
|
2447
|
+
return;
|
|
2448
|
+
}
|
|
2449
|
+
if (working.override) {
|
|
2450
|
+
items.push({
|
|
2451
|
+
kind: "object-override-upsert",
|
|
2452
|
+
value: {
|
|
2453
|
+
ref: working.ref,
|
|
2454
|
+
value: working.override,
|
|
2455
|
+
editedAt: working.editedAt,
|
|
2456
|
+
expectedLastCommitId: working.originalOverride?.lastCommitId ?? null,
|
|
2457
|
+
lastCommitId: identity.commitId,
|
|
2458
|
+
updatedAt: identity.committedAt
|
|
2459
|
+
}
|
|
2460
|
+
});
|
|
2461
|
+
} else if (working.originalOverride) {
|
|
2462
|
+
items.push({
|
|
2463
|
+
kind: "object-override-delete",
|
|
2464
|
+
value: { ref: working.ref, expectedLastCommitId: working.originalOverride.lastCommitId }
|
|
2465
|
+
});
|
|
2466
|
+
}
|
|
2467
|
+
}
|
|
2468
|
+
function appendLinkEdgeOverrideWork(items, working, identity) {
|
|
2469
|
+
if (stableJsonStringify2(working.originalOverride?.value ?? null) === stableJsonStringify2(working.override)) {
|
|
2470
|
+
return;
|
|
2471
|
+
}
|
|
2472
|
+
if (working.override) {
|
|
2473
|
+
items.push({
|
|
2474
|
+
kind: "link-override-upsert",
|
|
2475
|
+
value: {
|
|
2476
|
+
ref: working.ref,
|
|
2477
|
+
value: working.override,
|
|
2478
|
+
expectedLastCommitId: working.originalOverride?.lastCommitId ?? null,
|
|
2479
|
+
lastCommitId: identity.commitId,
|
|
2480
|
+
updatedAt: identity.committedAt
|
|
2481
|
+
}
|
|
2482
|
+
});
|
|
2483
|
+
} else if (working.originalOverride) {
|
|
2484
|
+
items.push({
|
|
2485
|
+
kind: "link-override-delete",
|
|
2486
|
+
value: { ref: working.ref, expectedLastCommitId: working.originalOverride.lastCommitId }
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
function appendLinkSlotOverrideWork(items, working, identity) {
|
|
2491
|
+
if (stableJsonStringify2(working.originalOverride?.value ?? null) === stableJsonStringify2(working.override)) {
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
if (working.override) {
|
|
2495
|
+
items.push({
|
|
2496
|
+
kind: "link-slot-override-upsert",
|
|
2497
|
+
value: {
|
|
2498
|
+
ref: working.ref,
|
|
2499
|
+
value: working.override,
|
|
2500
|
+
expectedLastCommitId: working.originalOverride?.lastCommitId ?? null,
|
|
2501
|
+
lastCommitId: identity.commitId,
|
|
2502
|
+
updatedAt: identity.committedAt
|
|
2503
|
+
}
|
|
2504
|
+
});
|
|
2505
|
+
} else if (working.originalOverride) {
|
|
2506
|
+
items.push({
|
|
2507
|
+
kind: "link-slot-override-delete",
|
|
2508
|
+
value: {
|
|
2509
|
+
ref: working.ref,
|
|
2510
|
+
expectedLastCommitId: working.originalOverride.lastCommitId
|
|
2743
2511
|
}
|
|
2744
|
-
|
|
2745
|
-
|
|
2746
|
-
|
|
2747
|
-
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
function appendEffectiveObjectWork(items, change) {
|
|
2516
|
+
if (change.kind === "deleted") {
|
|
2517
|
+
items.push({
|
|
2518
|
+
kind: "object-delete",
|
|
2519
|
+
value: {
|
|
2520
|
+
ref: change.ref,
|
|
2521
|
+
expected: expectedObject(change.before)
|
|
2748
2522
|
}
|
|
2749
|
-
|
|
2523
|
+
});
|
|
2524
|
+
} else {
|
|
2525
|
+
items.push({
|
|
2526
|
+
kind: "object-upsert",
|
|
2527
|
+
value: {
|
|
2528
|
+
row: change.after,
|
|
2529
|
+
expected: change.before ? expectedObject(change.before) : { ref: change.ref, exists: false }
|
|
2530
|
+
}
|
|
2531
|
+
});
|
|
2750
2532
|
}
|
|
2751
|
-
const changed = stableJsonStringify2(previous) !== stableJsonStringify2(next);
|
|
2752
|
-
working.override = next;
|
|
2753
|
-
journal?.push({
|
|
2754
|
-
restore: () => {
|
|
2755
|
-
working.override = previous;
|
|
2756
|
-
}
|
|
2757
|
-
});
|
|
2758
|
-
return { id: operation.id, ok: true, authority: authorityOutcome(changed) };
|
|
2759
2533
|
}
|
|
2760
|
-
function
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2534
|
+
function appendEffectiveLinkWork(items, change) {
|
|
2535
|
+
if (change.kind === "deleted") {
|
|
2536
|
+
items.push({
|
|
2537
|
+
kind: "link-delete",
|
|
2538
|
+
value: {
|
|
2539
|
+
ref: change.ref,
|
|
2540
|
+
expected: expectedLink(change.before)
|
|
2541
|
+
}
|
|
2542
|
+
});
|
|
2543
|
+
} else {
|
|
2544
|
+
items.push({
|
|
2545
|
+
kind: "link-upsert",
|
|
2546
|
+
value: {
|
|
2547
|
+
row: change.after,
|
|
2548
|
+
expected: change.before ? expectedLink(change.before) : { ref: change.ref, exists: false }
|
|
2549
|
+
}
|
|
2550
|
+
});
|
|
2551
|
+
}
|
|
2765
2552
|
}
|
|
2766
|
-
function
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2770
|
-
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
if (sourceExists && targetExists)
|
|
2774
|
-
return;
|
|
2775
|
-
throw new MaterializationValidationError2("Link upsert requires both endpoints to be effective.");
|
|
2553
|
+
function classificationWork(entityKind, identityKey, sortKey) {
|
|
2554
|
+
return {
|
|
2555
|
+
kind: "classification",
|
|
2556
|
+
recordKey: `classification:${entityKind}:${sortKey}`,
|
|
2557
|
+
entityKind,
|
|
2558
|
+
identityKey
|
|
2559
|
+
};
|
|
2776
2560
|
}
|
|
2777
|
-
function
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2561
|
+
function planWork(item, sortKey) {
|
|
2562
|
+
const applyPhase = materializationApplyPhase2(item.kind);
|
|
2563
|
+
return {
|
|
2564
|
+
kind: "plan",
|
|
2565
|
+
recordKey: `plan:${item.kind}:${sortKey}`,
|
|
2566
|
+
applyPhase,
|
|
2567
|
+
sortKey,
|
|
2568
|
+
item
|
|
2569
|
+
};
|
|
2781
2570
|
}
|
|
2782
|
-
function
|
|
2783
|
-
|
|
2784
|
-
|
|
2785
|
-
|
|
2786
|
-
|
|
2787
|
-
|
|
2788
|
-
|
|
2789
|
-
}
|
|
2571
|
+
function eventWork(value) {
|
|
2572
|
+
return {
|
|
2573
|
+
kind: "event",
|
|
2574
|
+
recordKey: `event:${value.kindRank}:${value.sortKey}`,
|
|
2575
|
+
eventKindRank: value.kindRank,
|
|
2576
|
+
sortKey: value.sortKey,
|
|
2577
|
+
draft: value.draft
|
|
2578
|
+
};
|
|
2790
2579
|
}
|
|
2791
|
-
function
|
|
2792
|
-
|
|
2793
|
-
|
|
2794
|
-
|
|
2580
|
+
function expectedObject(snapshot) {
|
|
2581
|
+
return {
|
|
2582
|
+
ref: snapshot.ref,
|
|
2583
|
+
exists: true,
|
|
2584
|
+
version: snapshot.version,
|
|
2585
|
+
lastCommitId: snapshot.lastCommitId
|
|
2586
|
+
};
|
|
2795
2587
|
}
|
|
2796
|
-
function
|
|
2797
|
-
|
|
2798
|
-
case "object.create":
|
|
2799
|
-
case "object.upsert":
|
|
2800
|
-
case "object.patch":
|
|
2801
|
-
case "object.delete":
|
|
2802
|
-
case "object.restore":
|
|
2803
|
-
return true;
|
|
2804
|
-
case "link.upsert":
|
|
2805
|
-
case "link.delete":
|
|
2806
|
-
case "link.reset":
|
|
2807
|
-
return false;
|
|
2808
|
-
}
|
|
2588
|
+
function expectedLink(snapshot) {
|
|
2589
|
+
return { ref: snapshot.ref, exists: true, lastCommitId: snapshot.lastCommitId };
|
|
2809
2590
|
}
|
|
2810
2591
|
|
|
2811
2592
|
// src/materializer/edits/plan.ts
|
|
2812
|
-
async function stageEditPlan(context, storage, session, state,
|
|
2593
|
+
async function stageEditPlan(context, storage, session, state, identity) {
|
|
2813
2594
|
validateWorkingCardinality(state.links.slots);
|
|
2814
2595
|
const objectChanges = [];
|
|
2815
2596
|
for (const working of sortedObjects(state.objects)) {
|
|
2816
|
-
const change = await stageObject(context, storage, session, working,
|
|
2597
|
+
const change = await stageObject(context, storage, session, working, identity);
|
|
2817
2598
|
if (change)
|
|
2818
2599
|
objectChanges.push(change);
|
|
2819
2600
|
}
|
|
2820
2601
|
const linkChanges = [];
|
|
2821
2602
|
for (const working of sortedLinkEdges(state.links.edges)) {
|
|
2822
|
-
const change = await stageLinkEdge(context, storage, session, state.objects, working,
|
|
2603
|
+
const change = await stageLinkEdge(context, storage, session, state.objects, working, identity);
|
|
2823
2604
|
if (change)
|
|
2824
2605
|
linkChanges.push(change);
|
|
2825
2606
|
}
|
|
2826
2607
|
for (const working of sortedLinkSlots(state.links.slots)) {
|
|
2827
|
-
linkChanges.push(...await stageLinkSlot(context, storage, session, state.objects, working,
|
|
2608
|
+
linkChanges.push(...await stageLinkSlot(context, storage, session, state.objects, working, identity));
|
|
2828
2609
|
}
|
|
2829
2610
|
return { objects: objectChanges, links: linkChanges };
|
|
2830
2611
|
}
|
|
2831
|
-
async function stageLinkSlot(context, storage, session, objects, working,
|
|
2612
|
+
async function stageLinkSlot(context, storage, session, objects, working, identity) {
|
|
2832
2613
|
const overrideItems = [];
|
|
2833
|
-
appendLinkSlotOverrideWork(overrideItems, working,
|
|
2614
|
+
appendLinkSlotOverrideWork(overrideItems, working, identity);
|
|
2834
2615
|
const resolved = resolveLinkSlot(context.ontology, working, objects);
|
|
2835
2616
|
const changes = diffEffectiveLinkSlot({
|
|
2836
2617
|
before: working.before,
|
|
2837
2618
|
resolved,
|
|
2838
|
-
commitId:
|
|
2839
|
-
committedAt:
|
|
2619
|
+
commitId: identity.commitId,
|
|
2620
|
+
committedAt: identity.committedAt
|
|
2840
2621
|
});
|
|
2841
2622
|
const representative = resolved?.ref ?? working.before?.ref ?? (working.override ? {
|
|
2842
2623
|
source: working.ref.source,
|
|
@@ -2853,22 +2634,22 @@ async function stageLinkSlot(context, storage, session, objects, working, planCo
|
|
|
2853
2634
|
appendEffectiveLinkWork(effectiveItems, change);
|
|
2854
2635
|
const sortKey = linkRefSortKey2(change.ref);
|
|
2855
2636
|
work.push(...effectiveItems.map((item) => planWork(item, sortKey)));
|
|
2856
|
-
work.push(eventWork(
|
|
2637
|
+
work.push(eventWork(buildLinkMaterializationEventDraft(change)));
|
|
2857
2638
|
}
|
|
2858
2639
|
await stageWorkBounded(context, storage, session, work);
|
|
2859
2640
|
return changes;
|
|
2860
2641
|
}
|
|
2861
|
-
async function stageObject(context, storage, session, working,
|
|
2642
|
+
async function stageObject(context, storage, session, working, identity) {
|
|
2862
2643
|
const items = [];
|
|
2863
|
-
appendObjectOverrideWork(items, working,
|
|
2644
|
+
appendObjectOverrideWork(items, working, identity);
|
|
2864
2645
|
const resolved = resolveObject(context.ontology, working);
|
|
2865
2646
|
if (resolved)
|
|
2866
2647
|
validateEffectiveObject(context.ontology, resolved.ref, resolved.properties);
|
|
2867
2648
|
const change = diffEffectiveObject({
|
|
2868
2649
|
before: working.before,
|
|
2869
2650
|
resolved,
|
|
2870
|
-
commitId:
|
|
2871
|
-
committedAt:
|
|
2651
|
+
commitId: identity.commitId,
|
|
2652
|
+
committedAt: identity.committedAt
|
|
2872
2653
|
});
|
|
2873
2654
|
if (change)
|
|
2874
2655
|
appendEffectiveObjectWork(items, change);
|
|
@@ -2878,20 +2659,20 @@ async function stageObject(context, storage, session, working, planContext) {
|
|
|
2878
2659
|
...items.map((item) => planWork(item, sortKey))
|
|
2879
2660
|
];
|
|
2880
2661
|
if (change) {
|
|
2881
|
-
work.push(eventWork(
|
|
2662
|
+
work.push(eventWork(buildObjectMaterializationEventDraft(change)));
|
|
2882
2663
|
}
|
|
2883
2664
|
await stageWorkBounded(context, storage, session, work);
|
|
2884
2665
|
return change;
|
|
2885
2666
|
}
|
|
2886
|
-
async function stageLinkEdge(context, storage, session, objects, working,
|
|
2667
|
+
async function stageLinkEdge(context, storage, session, objects, working, identity) {
|
|
2887
2668
|
const items = [];
|
|
2888
|
-
appendLinkEdgeOverrideWork(items, working,
|
|
2669
|
+
appendLinkEdgeOverrideWork(items, working, identity);
|
|
2889
2670
|
const resolved = resolveLinkEdge(context.ontology, working, objects);
|
|
2890
2671
|
const change = diffEffectiveLink({
|
|
2891
2672
|
before: working.before,
|
|
2892
2673
|
resolved,
|
|
2893
|
-
commitId:
|
|
2894
|
-
committedAt:
|
|
2674
|
+
commitId: identity.commitId,
|
|
2675
|
+
committedAt: identity.committedAt
|
|
2895
2676
|
});
|
|
2896
2677
|
if (change)
|
|
2897
2678
|
appendEffectiveLinkWork(items, change);
|
|
@@ -2901,29 +2682,11 @@ async function stageLinkEdge(context, storage, session, objects, working, planCo
|
|
|
2901
2682
|
...items.map((item) => planWork(item, sortKey))
|
|
2902
2683
|
];
|
|
2903
2684
|
if (change) {
|
|
2904
|
-
work.push(eventWork(
|
|
2685
|
+
work.push(eventWork(buildLinkMaterializationEventDraft(change)));
|
|
2905
2686
|
}
|
|
2906
2687
|
await stageWorkBounded(context, storage, session, work);
|
|
2907
2688
|
return change;
|
|
2908
2689
|
}
|
|
2909
|
-
function buildObjectEvent(context, planContext, change) {
|
|
2910
|
-
const eventContext = materializationEventContext(context, planContext);
|
|
2911
|
-
return buildObjectMaterializationEventDraft({ ...eventContext, change });
|
|
2912
|
-
}
|
|
2913
|
-
function buildLinkEvent(context, planContext, change) {
|
|
2914
|
-
const eventContext = materializationEventContext(context, planContext);
|
|
2915
|
-
return buildLinkMaterializationEventDraft({ ...eventContext, change });
|
|
2916
|
-
}
|
|
2917
|
-
function materializationEventContext(context, planContext) {
|
|
2918
|
-
return {
|
|
2919
|
-
projectId: context.projectId,
|
|
2920
|
-
commitId: planContext.identity.commitId,
|
|
2921
|
-
committedAt: planContext.identity.committedAt,
|
|
2922
|
-
origin: planContext.origin,
|
|
2923
|
-
correlationId: planContext.correlationId,
|
|
2924
|
-
attribution: planContext.attribution
|
|
2925
|
-
};
|
|
2926
|
-
}
|
|
2927
2690
|
function sortedObjects(objects) {
|
|
2928
2691
|
return [...objects.values()].sort((left, right) => compareObjectRefs2(left.ref, right.ref));
|
|
2929
2692
|
}
|
|
@@ -3123,10 +2886,9 @@ async function executeEditTransaction(context, storage, command) {
|
|
|
3123
2886
|
const session = await beginEditMaterialization(context, storage, command);
|
|
3124
2887
|
const workingState = await loadEditWorkingState(context, storage.ontology.materializations, session, command.input.operations);
|
|
3125
2888
|
const outcomes = applyEditOperations(context, workingState, command);
|
|
3126
|
-
const changes = await stageEditPlan(context, storage.ontology.materializations, session, workingState,
|
|
3127
|
-
await
|
|
2889
|
+
const changes = await stageEditPlan(context, storage.ontology.materializations, session, workingState, command.identity);
|
|
2890
|
+
const eventCount = await applyStagedWork(context, storage, session);
|
|
3128
2891
|
await commitVectorWrites(context, storage, command.input, command.identity.commitId, session);
|
|
3129
|
-
const eventCount = await drainStagedEvents(context, storage.ontology.materializations, session, command.identity);
|
|
3130
2892
|
const result = {
|
|
3131
2893
|
kind: "edit",
|
|
3132
2894
|
commitId: command.identity.commitId,
|
|
@@ -3157,7 +2919,6 @@ function buildEditCommit(context, command) {
|
|
|
3157
2919
|
requestHash: command.identity.requestHash,
|
|
3158
2920
|
executionId: command.execution.executionId,
|
|
3159
2921
|
origin: command.origin,
|
|
3160
|
-
...command.execution.attribution,
|
|
3161
2922
|
ontologyRevision: context.projectionRegistry.ontologyRevision,
|
|
3162
2923
|
intent: {
|
|
3163
2924
|
kind: "edit",
|
|
@@ -3234,14 +2995,6 @@ function isRecoverableEditValidation(input, error) {
|
|
|
3234
2995
|
return false;
|
|
3235
2996
|
return error instanceof MaterializationValidationError2;
|
|
3236
2997
|
}
|
|
3237
|
-
function editPlanContext(command) {
|
|
3238
|
-
return {
|
|
3239
|
-
identity: command.identity,
|
|
3240
|
-
origin: command.origin,
|
|
3241
|
-
correlationId: command.execution.correlationId,
|
|
3242
|
-
attribution: command.execution.attribution
|
|
3243
|
-
};
|
|
3244
|
-
}
|
|
3245
2998
|
async function finalizeEditMaterialization(storage, session, result) {
|
|
3246
2999
|
const applied = await storage.ontology.materializations.finalize({
|
|
3247
3000
|
session,
|
|
@@ -3570,44 +3323,52 @@ function projectionLinkTargetType(resolved, assertion) {
|
|
|
3570
3323
|
}
|
|
3571
3324
|
|
|
3572
3325
|
// src/materializer/projections/replacement-plan.ts
|
|
3573
|
-
async function planProjectionReplacement(context,
|
|
3574
|
-
const
|
|
3326
|
+
async function planProjectionReplacement(context, plans, plan, input) {
|
|
3327
|
+
const staged = { ...plan, commit: input.commit };
|
|
3575
3328
|
if (input.projectionKind === "object") {
|
|
3576
|
-
await
|
|
3329
|
+
for await (const page of plans.streamState({
|
|
3330
|
+
...plan,
|
|
3331
|
+
entityKind: "object",
|
|
3332
|
+
pageRows: context.batching.statePageRows
|
|
3333
|
+
})) {
|
|
3334
|
+
throwIfAborted(input.signal);
|
|
3335
|
+
await stagePlanned(context, plans, staged, page.objects.map((state) => ({
|
|
3336
|
+
identity: { kind: "object", ref: state.ref },
|
|
3337
|
+
records: planReplacementObject(context, input, state)
|
|
3338
|
+
})));
|
|
3339
|
+
}
|
|
3577
3340
|
}
|
|
3578
|
-
await
|
|
3579
|
-
|
|
3580
|
-
|
|
3581
|
-
}
|
|
3582
|
-
async function planObjectReplacement(context, storage, session, input, counts) {
|
|
3583
|
-
for await (const page of storage.streamSourceReplacementState({
|
|
3584
|
-
session,
|
|
3585
|
-
source: input.source,
|
|
3586
|
-
candidateMaterializationId: input.materializationId,
|
|
3587
|
-
entityKind: "object",
|
|
3341
|
+
for await (const page of plans.streamState({
|
|
3342
|
+
...plan,
|
|
3343
|
+
entityKind: "link",
|
|
3588
3344
|
pageRows: context.batching.statePageRows
|
|
3589
3345
|
})) {
|
|
3590
3346
|
throwIfAborted(input.signal);
|
|
3591
|
-
const
|
|
3592
|
-
await
|
|
3347
|
+
const endpoints = new Map(page.endpoints.map((endpoint) => [objectRefKey2(endpoint.ref), endpoint.exists]));
|
|
3348
|
+
await stagePlanned(context, plans, staged, page.links.map((state) => ({
|
|
3349
|
+
identity: { kind: "link", ref: state.ref },
|
|
3350
|
+
records: planReplacementLink(context, input, state, endpoints)
|
|
3351
|
+
})));
|
|
3593
3352
|
}
|
|
3594
3353
|
}
|
|
3595
|
-
function
|
|
3596
|
-
const
|
|
3597
|
-
|
|
3598
|
-
|
|
3354
|
+
async function stagePlanned(context, plans, plan, planned) {
|
|
3355
|
+
for await (const chunk of chunkBySize(planned, {
|
|
3356
|
+
maxRows: context.batching.planChunkRows,
|
|
3357
|
+
maxBytes: context.batching.planChunkBytes,
|
|
3358
|
+
byteLength: (value) => utf8JsonByteLength(value.records)
|
|
3359
|
+
})) {
|
|
3360
|
+
await plans.stage({ ...plan, planned: chunk });
|
|
3599
3361
|
}
|
|
3600
|
-
return work;
|
|
3601
3362
|
}
|
|
3602
|
-
function planReplacementObject(context, input, state
|
|
3363
|
+
function planReplacementObject(context, input, state) {
|
|
3603
3364
|
const resolved = resolveReplacementObject(context, state);
|
|
3604
3365
|
if (resolved)
|
|
3605
3366
|
validateEffectiveObject(context.ontology, resolved.ref, resolved.properties);
|
|
3606
3367
|
const change = diffEffectiveObject({
|
|
3607
3368
|
before: state.effective,
|
|
3608
3369
|
resolved,
|
|
3609
|
-
commitId: input.
|
|
3610
|
-
committedAt: input.
|
|
3370
|
+
commitId: input.commit.id,
|
|
3371
|
+
committedAt: input.commit.committedAt
|
|
3611
3372
|
});
|
|
3612
3373
|
const sortKey = objectRefSortKey2(state.ref);
|
|
3613
3374
|
const work = [
|
|
@@ -3622,88 +3383,19 @@ function planReplacementObject(context, input, state, counts) {
|
|
|
3622
3383
|
if (Boolean(state.effective) !== Boolean(resolved)) {
|
|
3623
3384
|
work.push({ kind: "incident-object", recordKey: `incident:${sortKey}`, ref: state.ref });
|
|
3624
3385
|
}
|
|
3625
|
-
if (!change)
|
|
3626
|
-
counts.objectsUnchanged += 1;
|
|
3386
|
+
if (!change)
|
|
3627
3387
|
return work;
|
|
3628
|
-
|
|
3629
|
-
incrementObjectCount(counts, change.kind);
|
|
3630
|
-
appendObjectChangeWork(work, sortKey, context, input, change);
|
|
3388
|
+
appendObjectChangeWork(work, sortKey, change);
|
|
3631
3389
|
return work;
|
|
3632
3390
|
}
|
|
3633
|
-
function appendObjectChangeWork(work, sortKey,
|
|
3391
|
+
function appendObjectChangeWork(work, sortKey, change) {
|
|
3634
3392
|
const items = [];
|
|
3635
3393
|
appendEffectiveObjectWork(items, change);
|
|
3636
3394
|
for (const item of items)
|
|
3637
3395
|
work.push(planWork(item, sortKey));
|
|
3638
|
-
work.push(eventWork(buildObjectMaterializationEventDraft(
|
|
3639
|
-
projectId: context.projectId,
|
|
3640
|
-
commitId: input.identity.commitId,
|
|
3641
|
-
committedAt: input.identity.committedAt,
|
|
3642
|
-
origin: input.origin,
|
|
3643
|
-
correlationId: input.correlationId,
|
|
3644
|
-
attribution: input.attribution,
|
|
3645
|
-
change
|
|
3646
|
-
})));
|
|
3647
|
-
}
|
|
3648
|
-
async function planLinkReplacement(context, storage, session, input, counts) {
|
|
3649
|
-
for await (const page of storage.streamSourceReplacementState({
|
|
3650
|
-
session,
|
|
3651
|
-
source: input.source,
|
|
3652
|
-
candidateMaterializationId: input.materializationId,
|
|
3653
|
-
entityKind: "link",
|
|
3654
|
-
pageRows: context.batching.statePageRows
|
|
3655
|
-
})) {
|
|
3656
|
-
throwIfAborted(input.signal);
|
|
3657
|
-
const endpointExistence = await loadEndpointExistence(context, storage, session, page);
|
|
3658
|
-
const work = planLinkPage(context, input, page, endpointExistence, counts);
|
|
3659
|
-
await stageWorkBounded(context, storage, session, work);
|
|
3660
|
-
}
|
|
3661
|
-
}
|
|
3662
|
-
async function loadEndpointExistence(context, storage, session, page) {
|
|
3663
|
-
const endpointRefs = collectEndpointRefs(page.links);
|
|
3664
|
-
const endpointExistence = new Map;
|
|
3665
|
-
for (const value of await storage.readObjectExistence({
|
|
3666
|
-
session,
|
|
3667
|
-
refs: [...endpointRefs.values()]
|
|
3668
|
-
})) {
|
|
3669
|
-
endpointExistence.set(objectRefKey2(value.ref), value.exists);
|
|
3670
|
-
}
|
|
3671
|
-
const missingEndpoints = [...endpointRefs.values()].filter((ref) => !endpointExistence.has(objectRefKey2(ref)));
|
|
3672
|
-
if (missingEndpoints.length === 0)
|
|
3673
|
-
return endpointExistence;
|
|
3674
|
-
for await (const endpointPage of storage.streamState({
|
|
3675
|
-
session,
|
|
3676
|
-
requests: oneStateRequest({
|
|
3677
|
-
objects: missingEndpoints,
|
|
3678
|
-
links: [],
|
|
3679
|
-
linkScopes: [],
|
|
3680
|
-
incidentObjects: [],
|
|
3681
|
-
points: []
|
|
3682
|
-
}),
|
|
3683
|
-
pageRows: context.batching.statePageRows
|
|
3684
|
-
})) {
|
|
3685
|
-
for (const endpoint of endpointPage.objects) {
|
|
3686
|
-
endpointExistence.set(objectRefKey2(endpoint.ref), endpoint.effective !== null);
|
|
3687
|
-
}
|
|
3688
|
-
}
|
|
3689
|
-
return endpointExistence;
|
|
3690
|
-
}
|
|
3691
|
-
function collectEndpointRefs(links) {
|
|
3692
|
-
const refs = new Map;
|
|
3693
|
-
for (const state of links) {
|
|
3694
|
-
refs.set(objectRefKey2(state.ref.source), state.ref.source);
|
|
3695
|
-
refs.set(objectRefKey2(state.ref.target), state.ref.target);
|
|
3696
|
-
}
|
|
3697
|
-
return refs;
|
|
3698
|
-
}
|
|
3699
|
-
function planLinkPage(context, input, page, endpointExistence, counts) {
|
|
3700
|
-
const work = [];
|
|
3701
|
-
for (const state of page.links) {
|
|
3702
|
-
work.push(...planReplacementLink(context, input, state, endpointExistence, counts));
|
|
3703
|
-
}
|
|
3704
|
-
return work;
|
|
3396
|
+
work.push(eventWork(buildObjectMaterializationEventDraft(change)));
|
|
3705
3397
|
}
|
|
3706
|
-
function planReplacementLink(context, input, state, endpointExistence
|
|
3398
|
+
function planReplacementLink(context, input, state, endpointExistence) {
|
|
3707
3399
|
const resolved = resolveReplacementLink(context, state, endpointExistence);
|
|
3708
3400
|
const work = cardinalityWork(context, state, resolved !== null);
|
|
3709
3401
|
if (!state.diffRequired)
|
|
@@ -3711,17 +3403,14 @@ function planReplacementLink(context, input, state, endpointExistence, counts) {
|
|
|
3711
3403
|
const change = diffEffectiveLink({
|
|
3712
3404
|
before: state.effective,
|
|
3713
3405
|
resolved,
|
|
3714
|
-
commitId: input.
|
|
3715
|
-
committedAt: input.
|
|
3406
|
+
commitId: input.commit.id,
|
|
3407
|
+
committedAt: input.commit.committedAt
|
|
3716
3408
|
});
|
|
3717
3409
|
const sortKey = linkRefSortKey2(state.ref);
|
|
3718
3410
|
work.push(classificationWork("link", linkRefKey2(state.ref), sortKey));
|
|
3719
|
-
if (!change)
|
|
3720
|
-
counts.linksUnchanged += 1;
|
|
3411
|
+
if (!change)
|
|
3721
3412
|
return work;
|
|
3722
|
-
|
|
3723
|
-
incrementLinkCount(counts, change.kind);
|
|
3724
|
-
appendLinkChangeWork(work, sortKey, context, input, change);
|
|
3413
|
+
appendLinkChangeWork(work, sortKey, change);
|
|
3725
3414
|
return work;
|
|
3726
3415
|
}
|
|
3727
3416
|
function resolveReplacementLink(context, state, endpointExistence) {
|
|
@@ -3771,20 +3460,12 @@ function cardinalityWork(context, state, occupied) {
|
|
|
3771
3460
|
}
|
|
3772
3461
|
];
|
|
3773
3462
|
}
|
|
3774
|
-
function appendLinkChangeWork(work, sortKey,
|
|
3463
|
+
function appendLinkChangeWork(work, sortKey, change) {
|
|
3775
3464
|
const items = [];
|
|
3776
3465
|
appendEffectiveLinkWork(items, change);
|
|
3777
3466
|
for (const item of items)
|
|
3778
3467
|
work.push(planWork(item, sortKey));
|
|
3779
|
-
work.push(eventWork(buildLinkMaterializationEventDraft(
|
|
3780
|
-
projectId: context.projectId,
|
|
3781
|
-
commitId: input.identity.commitId,
|
|
3782
|
-
committedAt: input.identity.committedAt,
|
|
3783
|
-
origin: input.origin,
|
|
3784
|
-
correlationId: input.correlationId,
|
|
3785
|
-
attribution: input.attribution,
|
|
3786
|
-
change
|
|
3787
|
-
})));
|
|
3468
|
+
work.push(eventWork(buildLinkMaterializationEventDraft(change)));
|
|
3788
3469
|
}
|
|
3789
3470
|
function resolveReplacementObject(context, state) {
|
|
3790
3471
|
return resolveEffectiveObject({
|
|
@@ -3796,34 +3477,6 @@ function resolveReplacementObject(context, state) {
|
|
|
3796
3477
|
latestTelemetry: state.latestTelemetry
|
|
3797
3478
|
});
|
|
3798
3479
|
}
|
|
3799
|
-
function emptyCounts() {
|
|
3800
|
-
return {
|
|
3801
|
-
objectsCreated: 0,
|
|
3802
|
-
objectsUpdated: 0,
|
|
3803
|
-
objectsDeleted: 0,
|
|
3804
|
-
objectsUnchanged: 0,
|
|
3805
|
-
linksCreated: 0,
|
|
3806
|
-
linksUpdated: 0,
|
|
3807
|
-
linksDeleted: 0,
|
|
3808
|
-
linksUnchanged: 0
|
|
3809
|
-
};
|
|
3810
|
-
}
|
|
3811
|
-
function incrementObjectCount(counts, kind) {
|
|
3812
|
-
if (kind === "created")
|
|
3813
|
-
counts.objectsCreated += 1;
|
|
3814
|
-
else if (kind === "updated")
|
|
3815
|
-
counts.objectsUpdated += 1;
|
|
3816
|
-
else
|
|
3817
|
-
counts.objectsDeleted += 1;
|
|
3818
|
-
}
|
|
3819
|
-
function incrementLinkCount(counts, kind) {
|
|
3820
|
-
if (kind === "created")
|
|
3821
|
-
counts.linksCreated += 1;
|
|
3822
|
-
else if (kind === "updated")
|
|
3823
|
-
counts.linksUpdated += 1;
|
|
3824
|
-
else
|
|
3825
|
-
counts.linksDeleted += 1;
|
|
3826
|
-
}
|
|
3827
3480
|
|
|
3828
3481
|
// src/materializer/projections/source-materialization.ts
|
|
3829
3482
|
async function stageProjectionMaterialization(context, input) {
|
|
@@ -4055,15 +3708,36 @@ async function stageCandidateEntries(context, input, signal) {
|
|
|
4055
3708
|
return stageProjectionMaterialization(context, input);
|
|
4056
3709
|
return stageProjectionMaterialization(context, { ...input, signal });
|
|
4057
3710
|
}
|
|
3711
|
+
var MAX_PLAN_ROUNDS = 3;
|
|
4058
3712
|
async function commitProjectionCandidate(context, command, ready) {
|
|
4059
|
-
|
|
3713
|
+
const plans = context.storage.ontology.replacementPlans;
|
|
3714
|
+
const plan = {
|
|
3715
|
+
projectId: context.projectId,
|
|
3716
|
+
source: command.source,
|
|
3717
|
+
materializationId: ready.materializationId,
|
|
3718
|
+
execution: command.execution
|
|
3719
|
+
};
|
|
3720
|
+
const { committedAt } = await plans.open({
|
|
3721
|
+
...plan,
|
|
3722
|
+
commit: projectionCommit(context.projectId, command, ready.identity)
|
|
3723
|
+
});
|
|
3724
|
+
const commit = projectionCommit(context.projectId, command, { ...ready.identity, committedAt });
|
|
3725
|
+
for (let round = 1;; round += 1) {
|
|
3726
|
+
await planProjectionReplacement(context, plans, plan, planInput(command, commit));
|
|
3727
|
+
const attempt = await withSerializationRetry(context, () => context.storage.transaction((storage) => executeProjectionTransaction(context, storage, command, ready, commit, plan), { isolation: "serializable" }));
|
|
3728
|
+
if (attempt.kind === "committed")
|
|
3729
|
+
return attempt.result;
|
|
3730
|
+
if (round === MAX_PLAN_ROUNDS) {
|
|
3731
|
+
throw new MaterializationConflictError2("effective-state", `Projection '${command.source.projectionId}' inputs kept changing while it was planned ` + `(${attempt.unplanned} changed during the last of ${MAX_PLAN_ROUNDS} rounds).`);
|
|
3732
|
+
}
|
|
3733
|
+
}
|
|
4060
3734
|
}
|
|
4061
|
-
async function executeProjectionTransaction(context, storage, command, ready) {
|
|
3735
|
+
async function executeProjectionTransaction(context, storage, command, ready, commit, plan) {
|
|
4062
3736
|
await ensureMaterializerExecution(storage.executions, command.scopeExecution);
|
|
4063
3737
|
await assertProjectionExecution(storage, context.projectId, command);
|
|
4064
3738
|
const replay = await replayCommitRecord(context, command.identity, command.scopeExecution.executionId, storage);
|
|
4065
3739
|
if (replay)
|
|
4066
|
-
return projectionReplayResult(replay, command);
|
|
3740
|
+
return { kind: "committed", result: projectionReplayResult(replay, command) };
|
|
4067
3741
|
if (command.base) {
|
|
4068
3742
|
const active = await storage.ontology.sources.getActive({
|
|
4069
3743
|
projectId: context.projectId,
|
|
@@ -4072,37 +3746,49 @@ async function executeProjectionTransaction(context, storage, command, ready) {
|
|
|
4072
3746
|
validateProjectionWatermark(active, command.datasetVersion);
|
|
4073
3747
|
assertDeltaBase(active, command);
|
|
4074
3748
|
}
|
|
4075
|
-
const origin = projectionOrigin(command);
|
|
4076
3749
|
throwIfAborted(command.signal);
|
|
3750
|
+
const status = await refreshProjectionPlan(context, storage, command, commit, plan);
|
|
3751
|
+
if (!status.fresh)
|
|
3752
|
+
return { kind: "stale", unplanned: status.unplanned };
|
|
4077
3753
|
const session = await storage.ontology.materializations.begin({
|
|
4078
|
-
commit
|
|
3754
|
+
commit,
|
|
4079
3755
|
expected: {
|
|
4080
3756
|
sources: [ready.expectedSource],
|
|
4081
3757
|
objects: [],
|
|
4082
3758
|
links: [],
|
|
4083
3759
|
linkScopes: [],
|
|
4084
3760
|
points: []
|
|
4085
|
-
}
|
|
3761
|
+
},
|
|
3762
|
+
plan: { source: command.source, materializationId: ready.materializationId }
|
|
4086
3763
|
});
|
|
4087
|
-
const
|
|
4088
|
-
await drainStagedWork(context, storage, session, command.signal, true);
|
|
4089
|
-
const eventCount = await drainStagedEvents(context, storage.ontology.materializations, session, ready.identity, command.signal);
|
|
3764
|
+
const eventCount = await applyStagedWork(context, storage, session, command.signal, true);
|
|
4090
3765
|
const result = {
|
|
4091
3766
|
kind: "projection",
|
|
4092
|
-
commitId:
|
|
3767
|
+
commitId: commit.id,
|
|
4093
3768
|
created: true,
|
|
4094
3769
|
eventCount,
|
|
4095
|
-
committedAt:
|
|
4096
|
-
counts
|
|
3770
|
+
committedAt: commit.committedAt,
|
|
3771
|
+
counts: status.counts
|
|
4097
3772
|
};
|
|
4098
3773
|
throwIfAborted(command.signal);
|
|
4099
|
-
return
|
|
3774
|
+
return {
|
|
3775
|
+
kind: "committed",
|
|
3776
|
+
result: await finalizeProjectionMaterialization(storage, session, command, ready, commit, result)
|
|
3777
|
+
};
|
|
3778
|
+
}
|
|
3779
|
+
async function refreshProjectionPlan(context, storage, command, commit, plan) {
|
|
3780
|
+
const plans = storage.ontology.replacementPlans;
|
|
3781
|
+
const status = await plans.refresh(plan);
|
|
3782
|
+
if (status.fresh || status.unplanned > context.batching.transactionReplanRows)
|
|
3783
|
+
return status;
|
|
3784
|
+
await planProjectionReplacement(context, plans, plan, planInput(command, commit));
|
|
3785
|
+
return plans.refresh(plan);
|
|
4100
3786
|
}
|
|
4101
|
-
async function finalizeProjectionMaterialization(storage, session, command, ready, result) {
|
|
3787
|
+
async function finalizeProjectionMaterialization(storage, session, command, ready, commit, result) {
|
|
4102
3788
|
const applied = await storage.ontology.materializations.finalize({
|
|
4103
3789
|
session,
|
|
4104
3790
|
finalization: {
|
|
4105
|
-
sourceActivations: [projectionActivation(command, ready)],
|
|
3791
|
+
sourceActivations: [projectionActivation(command, ready, commit)],
|
|
4106
3792
|
result
|
|
4107
3793
|
}
|
|
4108
3794
|
});
|
|
@@ -4117,15 +3803,14 @@ function projectionOrigin(command) {
|
|
|
4117
3803
|
datasetVersionId: command.datasetVersion.versionId
|
|
4118
3804
|
};
|
|
4119
3805
|
}
|
|
4120
|
-
function projectionCommit(projectId, command, identity
|
|
3806
|
+
function projectionCommit(projectId, command, identity) {
|
|
4121
3807
|
return {
|
|
4122
3808
|
projectId,
|
|
4123
3809
|
id: identity.commitId,
|
|
4124
3810
|
idempotencyKey: identity.idempotencyKey,
|
|
4125
3811
|
requestHash: identity.requestHash,
|
|
4126
3812
|
executionId: command.scopeExecution.executionId,
|
|
4127
|
-
origin,
|
|
4128
|
-
...command.scopeExecution.attribution,
|
|
3813
|
+
origin: projectionOrigin(command),
|
|
4129
3814
|
ontologyRevision: command.runIdentity.ontologyRevision,
|
|
4130
3815
|
projectionRevision: command.runIdentity.projectionRevision,
|
|
4131
3816
|
ownershipHash: command.runIdentity.ownershipHash,
|
|
@@ -4133,25 +3818,11 @@ function projectionCommit(projectId, command, identity, origin) {
|
|
|
4133
3818
|
committedAt: identity.committedAt
|
|
4134
3819
|
};
|
|
4135
3820
|
}
|
|
4136
|
-
|
|
4137
|
-
const input = {
|
|
4138
|
-
|
|
4139
|
-
materializationId: ready.materializationId,
|
|
4140
|
-
projectionKind: command.projectionKind,
|
|
4141
|
-
identity: ready.identity,
|
|
4142
|
-
origin,
|
|
4143
|
-
correlationId: command.scopeExecution.correlationId,
|
|
4144
|
-
attribution: command.scopeExecution.attribution
|
|
4145
|
-
};
|
|
4146
|
-
if (command.signal === undefined) {
|
|
4147
|
-
return planProjectionReplacement(context, storage, session, input);
|
|
4148
|
-
}
|
|
4149
|
-
return planProjectionReplacement(context, storage, session, {
|
|
4150
|
-
...input,
|
|
4151
|
-
signal: command.signal
|
|
4152
|
-
});
|
|
3821
|
+
function planInput(command, commit) {
|
|
3822
|
+
const input = { projectionKind: command.projectionKind, commit };
|
|
3823
|
+
return command.signal === undefined ? input : { ...input, signal: command.signal };
|
|
4153
3824
|
}
|
|
4154
|
-
function projectionActivation(command, ready) {
|
|
3825
|
+
function projectionActivation(command, ready, commit) {
|
|
4155
3826
|
return {
|
|
4156
3827
|
source: command.source,
|
|
4157
3828
|
materializationId: ready.materializationId,
|
|
@@ -4163,8 +3834,8 @@ function projectionActivation(command, ready) {
|
|
|
4163
3834
|
ownershipHash: command.runIdentity.ownershipHash,
|
|
4164
3835
|
ontologyRevision: command.runIdentity.ontologyRevision,
|
|
4165
3836
|
expected: ready.expectedSource,
|
|
4166
|
-
lastCommitId:
|
|
4167
|
-
updatedAt:
|
|
3837
|
+
lastCommitId: commit.id,
|
|
3838
|
+
updatedAt: commit.committedAt
|
|
4168
3839
|
};
|
|
4169
3840
|
}
|
|
4170
3841
|
function validateProjectionWatermark(active, next) {
|
|
@@ -4182,9 +3853,9 @@ function assertDeltaBase(active, command) {
|
|
|
4182
3853
|
}
|
|
4183
3854
|
|
|
4184
3855
|
// src/materializer/telemetry/plan.ts
|
|
4185
|
-
async function planTelemetryAppend(context, storage, session, input, identity
|
|
3856
|
+
async function planTelemetryAppend(context, storage, session, input, identity) {
|
|
4186
3857
|
const counts = emptyTelemetryCounts();
|
|
4187
|
-
const planContext = { input, identity
|
|
3858
|
+
const planContext = { input, identity };
|
|
4188
3859
|
const objects = await loadTelemetryObjects(context, storage, session, input.points);
|
|
4189
3860
|
const existingPoints = await loadExistingPoints(context, storage, session, input.points);
|
|
4190
3861
|
for (const group of telemetryObjectGroups(input.points)) {
|
|
@@ -4214,7 +3885,7 @@ async function planTelemetryObject(context, storage, session, planContext, group
|
|
|
4214
3885
|
for (let start = group.start;start < group.end; start += context.batching.statePageRows) {
|
|
4215
3886
|
const end = Math.min(group.end, start + context.batching.statePageRows);
|
|
4216
3887
|
const points = planContext.input.points.slice(start, end);
|
|
4217
|
-
const work = planTelemetryChunk(
|
|
3888
|
+
const work = planTelemetryChunk(planContext, points, existingPoints, latest, counts);
|
|
4218
3889
|
await stageWorkBounded(context, storage, session, work);
|
|
4219
3890
|
}
|
|
4220
3891
|
working.latestTelemetry = [...latest.values()];
|
|
@@ -4233,10 +3904,10 @@ async function loadTelemetryObjects(context, storage, session, points) {
|
|
|
4233
3904
|
});
|
|
4234
3905
|
return new Map(objectState.objects.map((object) => [objectRefKey2(object.ref), object]));
|
|
4235
3906
|
}
|
|
4236
|
-
function planTelemetryChunk(
|
|
3907
|
+
function planTelemetryChunk(planContext, points, existingPoints, latest, counts) {
|
|
4237
3908
|
const work = [];
|
|
4238
3909
|
for (const point of points) {
|
|
4239
|
-
work.push(...planTelemetryPoint(
|
|
3910
|
+
work.push(...planTelemetryPoint(planContext, point, existingPoints, latest, counts));
|
|
4240
3911
|
}
|
|
4241
3912
|
return work;
|
|
4242
3913
|
}
|
|
@@ -4260,7 +3931,7 @@ async function loadExistingPoints(context, storage, session, points) {
|
|
|
4260
3931
|
context.observeCoreBuffer?.("telemetry.existing-points", existingPoints.size);
|
|
4261
3932
|
return existingPoints;
|
|
4262
3933
|
}
|
|
4263
|
-
function planTelemetryPoint(
|
|
3934
|
+
function planTelemetryPoint(planContext, point, existingPoints, latest, counts) {
|
|
4264
3935
|
const identityKey = telemetryPointKey2(point.series, point.at);
|
|
4265
3936
|
const sortKey = telemetryPointSortKey2(point.series, point.at);
|
|
4266
3937
|
const existing = existingPoints.get(identityKey);
|
|
@@ -4271,7 +3942,7 @@ function planTelemetryPoint(context, planContext, point, existingPoints, latest,
|
|
|
4271
3942
|
} else {
|
|
4272
3943
|
countTelemetryPointChange(counts, existing);
|
|
4273
3944
|
work.push(planWork(telemetryPointUpsert(point, existing, planContext.identity), sortKey));
|
|
4274
|
-
work.push(eventWork(
|
|
3945
|
+
work.push(eventWork(buildTelemetryMaterializationEventDraft(point)));
|
|
4275
3946
|
}
|
|
4276
3947
|
updateLatestPoint(latest, point, existing, unchanged, planContext.identity);
|
|
4277
3948
|
return work;
|
|
@@ -4312,10 +3983,6 @@ function storedTelemetryPointWithUnit(point, unit) {
|
|
|
4312
3983
|
return point;
|
|
4313
3984
|
return { ...point, unit };
|
|
4314
3985
|
}
|
|
4315
|
-
function buildTelemetryEvent(context, planContext, point) {
|
|
4316
|
-
const eventContext = telemetryEventContext(context, planContext);
|
|
4317
|
-
return buildTelemetryMaterializationEventDraft({ ...eventContext, point });
|
|
4318
|
-
}
|
|
4319
3986
|
function updateLatestPoint(latest, point, existing, unchanged, identity) {
|
|
4320
3987
|
const current = latest.get(point.series.propertyId);
|
|
4321
3988
|
if (current && point.at < current.at)
|
|
@@ -4354,21 +4021,10 @@ async function stageTelemetryObjectPlan(context, storage, session, planContext,
|
|
|
4354
4021
|
const items = [];
|
|
4355
4022
|
appendEffectiveObjectWork(items, change);
|
|
4356
4023
|
work.push(...items.map((item) => planWork(item, sortKey)));
|
|
4357
|
-
|
|
4358
|
-
work.push(eventWork(buildObjectMaterializationEventDraft({ ...eventContext, change })));
|
|
4024
|
+
work.push(eventWork(buildObjectMaterializationEventDraft(change)));
|
|
4359
4025
|
}
|
|
4360
4026
|
await stageWorkBounded(context, storage, session, work);
|
|
4361
4027
|
}
|
|
4362
|
-
function telemetryEventContext(context, planContext) {
|
|
4363
|
-
return {
|
|
4364
|
-
projectId: context.projectId,
|
|
4365
|
-
commitId: planContext.identity.commitId,
|
|
4366
|
-
committedAt: planContext.identity.committedAt,
|
|
4367
|
-
origin: planContext.origin,
|
|
4368
|
-
correlationId: planContext.event.correlationId,
|
|
4369
|
-
attribution: planContext.event.attribution
|
|
4370
|
-
};
|
|
4371
|
-
}
|
|
4372
4028
|
function emptyTelemetryCounts() {
|
|
4373
4029
|
return {
|
|
4374
4030
|
pointsCreated: 0,
|
|
@@ -4564,12 +4220,8 @@ async function executeTelemetryTransaction(context, storage, command) {
|
|
|
4564
4220
|
}
|
|
4565
4221
|
const origin = telemetryOrigin(command);
|
|
4566
4222
|
const session = await beginTelemetryMaterialization(context, storage, command, origin);
|
|
4567
|
-
const counts = await planTelemetryAppend(context, storage.ontology.materializations, session, command.input, command.identity
|
|
4568
|
-
|
|
4569
|
-
attribution: command.execution.attribution
|
|
4570
|
-
});
|
|
4571
|
-
await drainStagedWork(context, storage, session);
|
|
4572
|
-
const eventCount = await drainStagedEvents(context, storage.ontology.materializations, session, command.identity);
|
|
4223
|
+
const counts = await planTelemetryAppend(context, storage.ontology.materializations, session, command.input, command.identity);
|
|
4224
|
+
const eventCount = await applyStagedWork(context, storage, session);
|
|
4573
4225
|
const result = {
|
|
4574
4226
|
kind: "telemetry",
|
|
4575
4227
|
commitId: command.identity.commitId,
|
|
@@ -4616,7 +4268,6 @@ function telemetryCommit(projectId, command, origin) {
|
|
|
4616
4268
|
requestHash: command.identity.requestHash,
|
|
4617
4269
|
executionId: command.execution.executionId,
|
|
4618
4270
|
origin,
|
|
4619
|
-
...command.execution.attribution,
|
|
4620
4271
|
ontologyRevision: command.ontologyRevision,
|
|
4621
4272
|
intent: telemetryCommitIntent(command),
|
|
4622
4273
|
committedAt: command.identity.committedAt
|
|
@@ -4723,4 +4374,4 @@ function createOntologyMaterializer2(input) {
|
|
|
4723
4374
|
}
|
|
4724
4375
|
export { computeOntologyRevision2, computeProjectionRevision2, computeProjectionOwnershipHash2, ProjectionRegistry2, createActionIdempotencyKey2, createRuntimeIdempotencyKey2, createProjectionIdempotencyKey2, createRuntimeTelemetryIdempotencyKey2, createProjectionTelemetryIdempotencyKey2, createCommitIdentity2, timestampCommitIdentity2, createTimedCommitIdentity2, createProjectionMaterializationId2, createLinkScopeFingerprint2, normalizeJsonProperties2, normalizeOntologyEditCommit2, normalizeProjectionExecution2, normalizeProjectionSourceEntry2, normalizeTelemetryAppend2, OntologyMaterializer2, createOntologyMaterializer2 };
|
|
4725
4376
|
|
|
4726
|
-
//# debugId=
|
|
4377
|
+
//# debugId=D24ACD49CAAE262364756E2164756E21
|