@sixb/core 0.1.18 → 0.1.20
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/README.md +7 -6
- package/dist/actions/commit-edits.d.ts +7 -19
- package/dist/actions/commit-edits.d.ts.map +1 -1
- package/dist/actions/errors.d.ts +0 -3
- package/dist/actions/errors.d.ts.map +1 -1
- package/dist/actions/execution.d.ts +10 -3
- package/dist/actions/execution.d.ts.map +1 -1
- package/dist/actions/index.d.ts +6 -9
- package/dist/actions/index.d.ts.map +1 -1
- package/dist/actions/index.js +51 -50
- package/dist/actions/index.js.map +1 -1
- package/dist/actions/request.d.ts +14 -25
- package/dist/actions/request.d.ts.map +1 -1
- package/dist/actions/run/context.d.ts +40 -0
- package/dist/actions/run/context.d.ts.map +1 -0
- package/dist/actions/run/edits-commit.d.ts +31 -0
- package/dist/actions/run/edits-commit.d.ts.map +1 -0
- package/dist/actions/run/effects.d.ts +23 -0
- package/dist/actions/run/effects.d.ts.map +1 -0
- package/dist/actions/run/execute.d.ts +30 -0
- package/dist/actions/run/execute.d.ts.map +1 -0
- package/dist/actions/run/executor.d.ts +95 -0
- package/dist/actions/run/executor.d.ts.map +1 -0
- package/dist/actions/run/normalize.d.ts +36 -0
- package/dist/actions/run/normalize.d.ts.map +1 -0
- package/dist/actions/run/phase-types.d.ts +18 -0
- package/dist/actions/run/phase-types.d.ts.map +1 -0
- package/dist/actions/run/phases.d.ts +20 -0
- package/dist/actions/run/phases.d.ts.map +1 -0
- package/dist/actions/run/run-action.d.ts +25 -0
- package/dist/actions/run/run-action.d.ts.map +1 -0
- package/dist/actions/run/signals.d.ts +67 -0
- package/dist/actions/run/signals.d.ts.map +1 -0
- package/dist/actions/run/state.d.ts +47 -0
- package/dist/actions/run/state.d.ts.map +1 -0
- package/dist/actions/run/types.d.ts +54 -0
- package/dist/actions/run/types.d.ts.map +1 -0
- package/dist/actions/run/writeback.d.ts +17 -0
- package/dist/actions/run/writeback.d.ts.map +1 -0
- package/dist/actions/run-authorization.d.ts +1 -1
- package/dist/actions/run-authorization.d.ts.map +1 -1
- package/dist/actions/run-persistence.d.ts +53 -0
- package/dist/actions/run-persistence.d.ts.map +1 -0
- package/dist/actions/types/context.d.ts +10 -0
- package/dist/actions/types/context.d.ts.map +1 -1
- package/dist/agents/index.js +52 -55
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/streams/index.js +2 -2
- package/dist/agents/streams/internal.js +2 -2
- package/dist/auth/cookies.d.ts +2 -4
- package/dist/auth/cookies.d.ts.map +1 -1
- package/dist/auth/index.d.ts +0 -2
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +15 -21
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/runtime.d.ts +8 -10
- package/dist/auth/runtime.d.ts.map +1 -1
- package/dist/auth/session-cache.d.ts +1 -5
- package/dist/auth/session-cache.d.ts.map +1 -1
- package/dist/auth/strategy.js +1 -1
- package/dist/auth/types.d.ts +4 -8
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/auth/validation.d.ts +0 -1
- package/dist/auth/validation.d.ts.map +1 -1
- package/dist/authorization/decision.d.ts +0 -4
- package/dist/authorization/decision.d.ts.map +1 -1
- package/dist/authorization/event-visibility.d.ts.map +1 -1
- package/dist/authorization/grant-kinds.d.ts +6 -8
- package/dist/authorization/grant-kinds.d.ts.map +1 -1
- package/dist/authorization/index.d.ts +0 -1
- package/dist/authorization/index.d.ts.map +1 -1
- package/dist/authorization/index.js +5 -9
- 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/bootstrap/index.js +50 -53
- package/dist/bootstrap/index.js.map +2 -2
- package/dist/{chunk-vz3gc1tm.js → chunk-0rbyz4qy.js} +67 -69
- package/dist/{chunk-vz3gc1tm.js.map → chunk-0rbyz4qy.js.map} +4 -4
- package/dist/{chunk-rz53yb4v.js → chunk-0yh890a4.js} +1 -1
- package/dist/{chunk-vgk3hknm.js → chunk-1k89ecfr.js} +1 -1
- package/dist/{chunk-ny3xyvcn.js → chunk-1zq2p6g0.js} +3 -3
- package/dist/{chunk-dnmadg9k.js → chunk-3t2hgbgd.js} +2 -2
- package/dist/{chunk-k6hrnf35.js → chunk-4vyr1j8f.js} +51 -4
- package/dist/chunk-4vyr1j8f.js.map +11 -0
- package/dist/{chunk-22v5bpz3.js → chunk-5e43w60z.js} +1 -1
- package/dist/{chunk-de4z2bj6.js → chunk-5j58wjct.js} +17 -17
- package/dist/chunk-5j58wjct.js.map +18 -0
- package/dist/{chunk-fe52eczz.js → chunk-6c6sn0bh.js} +6352 -2127
- package/dist/chunk-6c6sn0bh.js.map +106 -0
- package/dist/{chunk-7hpdd6r9.js → chunk-6p49a5cq.js} +4 -4
- package/dist/{chunk-b9affek3.js → chunk-7n440zgt.js} +30 -30
- package/dist/{chunk-b9affek3.js.map → chunk-7n440zgt.js.map} +4 -4
- package/dist/{chunk-kkqwzy6h.js → chunk-7t429e3f.js} +1 -1
- package/dist/{chunk-6fsr7y93.js → chunk-8mx7qw3y.js} +14 -13
- package/dist/{chunk-6fsr7y93.js.map → chunk-8mx7qw3y.js.map} +4 -4
- package/dist/{chunk-kpx7jrmn.js → chunk-91mg3nj9.js} +59 -59
- package/dist/{chunk-kpx7jrmn.js.map → chunk-91mg3nj9.js.map} +5 -5
- package/dist/{chunk-ex496vct.js → chunk-9dmt152s.js} +1 -1
- package/dist/{chunk-48e3cn2d.js → chunk-9gyp8hg1.js} +2 -2
- package/dist/{chunk-ewqa58h9.js → chunk-9k93ah50.js} +4 -4
- package/dist/{chunk-ewqa58h9.js.map → chunk-9k93ah50.js.map} +1 -1
- package/dist/{chunk-zxawp1n2.js → chunk-9w055r5b.js} +1 -1
- package/dist/{chunk-4wn7bxxa.js → chunk-9ybhtmg4.js} +1 -1
- package/dist/{chunk-fc5zfxy1.js → chunk-a40ad1ft.js} +5 -13
- package/dist/chunk-a40ad1ft.js.map +10 -0
- package/dist/{chunk-y2aq6ag9.js → chunk-b38szspf.js} +5 -14
- package/dist/chunk-b38szspf.js.map +11 -0
- package/dist/{chunk-r2y23egw.js → chunk-bkpke1sg.js} +1 -10
- package/dist/chunk-bkpke1sg.js.map +10 -0
- package/dist/{chunk-htr6wjmv.js → chunk-bx9q3cwv.js} +22 -22
- package/dist/{chunk-htr6wjmv.js.map → chunk-bx9q3cwv.js.map} +1 -1
- package/dist/{chunk-vx2yp45y.js → chunk-c85m1hyj.js} +2 -2
- package/dist/{chunk-bs7sqkre.js → chunk-d09tj99x.js} +2 -2
- package/dist/{chunk-qkbx3tf6.js → chunk-d0bqz29d.js} +27 -47
- package/dist/chunk-d0bqz29d.js.map +23 -0
- package/dist/{chunk-zb77kjth.js → chunk-dk8tkk5f.js} +4 -4
- package/dist/{chunk-xt1zt7gv.js → chunk-es1gxsbf.js} +24 -15
- package/dist/chunk-es1gxsbf.js.map +13 -0
- package/dist/{chunk-vjcd8d27.js → chunk-fa02jy15.js} +1 -1
- package/dist/{chunk-za5yd58j.js → chunk-fkgc1wt8.js} +2 -2
- package/dist/{chunk-enpsx8k5.js → chunk-gsjm1wms.js} +16 -20
- package/dist/chunk-gsjm1wms.js.map +10 -0
- package/dist/{chunk-2jntasmh.js → chunk-hcbyfxbe.js} +25 -49
- package/dist/chunk-hcbyfxbe.js.map +12 -0
- package/dist/{chunk-p0dqwj3n.js → chunk-hjzdd750.js} +66 -47
- package/dist/{chunk-p0dqwj3n.js.map → chunk-hjzdd750.js.map} +4 -4
- package/dist/chunk-hkc3jct7.js.map +1 -1
- package/dist/{chunk-y05543x6.js → chunk-hvsb78a1.js} +4 -4
- package/dist/{chunk-y05543x6.js.map → chunk-hvsb78a1.js.map} +1 -1
- package/dist/{chunk-1b1f2d5f.js → chunk-k6q3n2sc.js} +9 -9
- package/dist/{chunk-1b1f2d5f.js.map → chunk-k6q3n2sc.js.map} +1 -1
- package/dist/{chunk-wr8qp979.js → chunk-m427qgq0.js} +9 -5
- package/dist/{chunk-wr8qp979.js.map → chunk-m427qgq0.js.map} +4 -3
- package/dist/{chunk-qq90g05n.js → chunk-n33z5bjw.js} +50 -240
- package/dist/{chunk-qq90g05n.js.map → chunk-n33z5bjw.js.map} +4 -4
- package/dist/{chunk-e1c18xjx.js → chunk-nq6gpjt7.js} +4 -45
- package/dist/{chunk-e1c18xjx.js.map → chunk-nq6gpjt7.js.map} +5 -5
- package/dist/{chunk-1hqwggsn.js → chunk-nzapm6p0.js} +1 -2
- package/dist/chunk-nzapm6p0.js.map +12 -0
- package/dist/{chunk-wt4szfec.js → chunk-pbcbn83d.js} +4 -4
- package/dist/{chunk-wt4szfec.js.map → chunk-pbcbn83d.js.map} +1 -1
- package/dist/{chunk-s4jhg8a3.js → chunk-ren4kg2j.js} +15 -15
- package/dist/{chunk-s4jhg8a3.js.map → chunk-ren4kg2j.js.map} +1 -1
- package/dist/{chunk-d0eb5yy6.js → chunk-rrzt8jdy.js} +5 -5
- package/dist/{chunk-d0eb5yy6.js.map → chunk-rrzt8jdy.js.map} +1 -1
- package/dist/{chunk-y9jmd7e5.js → chunk-s16apyk9.js} +102 -16
- package/dist/chunk-s16apyk9.js.map +16 -0
- package/dist/{chunk-6gmfggss.js → chunk-t7x8dmn0.js} +2 -2
- package/dist/{chunk-f1zxad2t.js → chunk-tg2cw67r.js} +6 -6
- package/dist/{chunk-f1zxad2t.js.map → chunk-tg2cw67r.js.map} +1 -1
- package/dist/{chunk-p844e0rn.js → chunk-tpn40322.js} +2 -2
- package/dist/{chunk-rt9p8m9t.js → chunk-v9xd5wzd.js} +1 -1
- package/dist/{chunk-6h5m9xjx.js → chunk-vpq4shxz.js} +49 -113
- package/dist/chunk-vpq4shxz.js.map +39 -0
- package/dist/{chunk-2vhg6ysa.js → chunk-vyf9kfqf.js} +1 -1
- package/dist/{chunk-bwjcehza.js → chunk-way52z4h.js} +1 -1
- package/dist/{chunk-qkvz64nd.js → chunk-x6m907x7.js} +3 -3
- package/dist/{chunk-yv9czyfr.js → chunk-xfs8x8m9.js} +5 -5
- package/dist/chunk-y0c4e6ex.js +16 -0
- package/dist/chunk-y0c4e6ex.js.map +10 -0
- package/dist/{chunk-v6xpd60t.js → chunk-yevzdx4y.js} +5 -5
- package/dist/{chunk-dfm066qg.js → chunk-yxd3nnqt.js} +2 -29
- package/dist/chunk-yxd3nnqt.js.map +11 -0
- package/dist/{chunk-70jmg2zx.js → chunk-yzwja0mj.js} +4 -19
- package/dist/{chunk-70jmg2zx.js.map → chunk-yzwja0mj.js.map} +3 -3
- package/dist/{chunk-qmnnhde6.js → chunk-z4m0yz8c.js} +1 -1
- package/dist/datasets/write.js +5 -5
- package/dist/deploy/index.d.ts +1 -1
- package/dist/deploy/index.d.ts.map +1 -1
- package/dist/deploy/internal.js +13 -10
- package/dist/deploy/internal.js.map +4 -4
- package/dist/deploy/services.d.ts +1 -2
- package/dist/deploy/services.d.ts.map +1 -1
- package/dist/deploy/types.d.ts +7 -7
- package/dist/deploy/types.d.ts.map +1 -1
- package/dist/deploy/validation.d.ts.map +1 -1
- package/dist/edits/index.js +3 -5
- package/dist/edits/index.js.map +1 -1
- package/dist/error-reporting/internal.js +3 -3
- package/dist/error-reporting/types.d.ts +2 -9
- package/dist/error-reporting/types.d.ts.map +1 -1
- package/dist/errors/catalog.d.ts +12 -0
- package/dist/errors/catalog.d.ts.map +1 -1
- package/dist/errors/internal.js +1 -1
- package/dist/events/definitions.d.ts +0 -5
- package/dist/events/definitions.d.ts.map +1 -1
- package/dist/events/index.d.ts +3 -3
- package/dist/events/index.d.ts.map +1 -1
- package/dist/events/index.js +6 -8
- package/dist/events/index.js.map +1 -1
- package/dist/events/scope.d.ts +0 -1
- package/dist/events/scope.d.ts.map +1 -1
- package/dist/events/scope.js +1 -1
- package/dist/events/selectors/builder.d.ts +1 -8
- package/dist/events/selectors/builder.d.ts.map +1 -1
- package/dist/events/selectors/index.d.ts +2 -2
- package/dist/events/selectors/index.d.ts.map +1 -1
- package/dist/events/selectors/index.js +2 -2
- package/dist/events/selectors/predicate.d.ts.map +1 -1
- package/dist/events/selectors/types.d.ts +2 -33
- package/dist/events/selectors/types.d.ts.map +1 -1
- package/dist/events/types/index.d.ts +1 -12
- package/dist/events/types/index.d.ts.map +1 -1
- package/dist/execution/agent.js +41 -44
- package/dist/execution/agent.js.map +1 -1
- package/dist/execution/authorization.d.ts.map +1 -1
- package/dist/execution/primitive.js +60 -91
- package/dist/execution/primitive.js.map +3 -4
- package/dist/execution/request.js +40 -43
- package/dist/execution/request.js.map +2 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +105 -127
- package/dist/index.js.map +1 -1
- package/dist/lake-storage/index.js +5 -5
- package/dist/materialization/index.js +3 -3
- package/dist/materialization/index.js.map +1 -1
- package/dist/materialization/model.d.ts +19 -6
- package/dist/materialization/model.d.ts.map +1 -1
- package/dist/materializer/index.js +31 -31
- package/dist/materializer/index.js.map +1 -1
- package/dist/materializer/shared/normalize.d.ts.map +1 -1
- package/dist/models/execution/index.js +21 -21
- package/dist/objects/action/errors.d.ts +0 -9
- package/dist/objects/action/errors.d.ts.map +1 -1
- package/dist/objects/action/index.d.ts +3 -3
- package/dist/objects/action/index.d.ts.map +1 -1
- package/dist/objects/action/request.d.ts +2 -8
- package/dist/objects/action/request.d.ts.map +1 -1
- package/dist/objects/execution.d.ts +0 -2
- package/dist/objects/execution.d.ts.map +1 -1
- package/dist/objects/index.js +44 -29
- package/dist/objects/index.js.map +1 -1
- package/dist/objects/query/index.js +29 -29
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/sdk/object-handle.d.ts.map +1 -1
- package/dist/objects/sdk/object-set.d.ts.map +1 -1
- package/dist/objects/service/index.d.ts +0 -1
- package/dist/objects/service/index.d.ts.map +1 -1
- package/dist/objects/vectors/handle.d.ts.map +1 -1
- package/dist/objects/vectors/profile.d.ts +5 -0
- package/dist/objects/vectors/profile.d.ts.map +1 -1
- package/dist/ontology/index.js +6 -6
- package/dist/ontology/index.js.map +1 -1
- package/dist/ontology/internal.js +2 -2
- package/dist/pipelines/index.js +28 -28
- package/dist/projections/internal.js +22 -22
- package/dist/projections/internal.js.map +1 -1
- package/dist/query.js +2 -2
- package/dist/queues/in-memory.d.ts +1 -2
- package/dist/queues/in-memory.d.ts.map +1 -1
- package/dist/queues/index.d.ts +1 -1
- package/dist/queues/index.d.ts.map +1 -1
- package/dist/queues/index.js +1 -1
- package/dist/queues/types.d.ts +0 -7
- package/dist/queues/types.d.ts.map +1 -1
- package/dist/runtime/host.d.ts.map +1 -1
- package/dist/runtime/internal.js +27 -28
- package/dist/runtime/internal.js.map +1 -1
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/runtime/types.d.ts +16 -36
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/sandboxes/index.js +5 -5
- package/dist/schedules/builders.d.ts.map +1 -1
- package/dist/schedules/index.js +3 -3
- package/dist/schedules/runtime.d.ts.map +1 -1
- package/dist/schedules/validation.d.ts +0 -1
- package/dist/schedules/validation.d.ts.map +1 -1
- package/dist/security/builders.d.ts.map +1 -1
- package/dist/security/every.d.ts +2 -5
- package/dist/security/every.d.ts.map +1 -1
- package/dist/security/grants.d.ts +2 -4
- package/dist/security/grants.d.ts.map +1 -1
- package/dist/security/index.d.ts +1 -2
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/membership-policies.d.ts.map +1 -1
- package/dist/security/public.d.ts +10 -0
- package/dist/security/public.d.ts.map +1 -0
- package/dist/security/public.js +10 -0
- package/dist/security/public.js.map +9 -0
- package/dist/security/registry.d.ts +0 -1
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/types.d.ts +13 -18
- package/dist/security/types.d.ts.map +1 -1
- package/dist/security/validation.d.ts +0 -6
- package/dist/security/validation.d.ts.map +1 -1
- package/dist/shares/internal.js +20 -20
- package/dist/storage/action-runs/failure.js +2 -2
- package/dist/storage/action-runs/idempotency.d.ts +3 -4
- package/dist/storage/action-runs/idempotency.d.ts.map +1 -1
- package/dist/storage/action-runs/in-memory.d.ts +2 -9
- package/dist/storage/action-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/action-runs/index.d.ts +1 -3
- package/dist/storage/action-runs/index.d.ts.map +1 -1
- package/dist/storage/action-runs/provider.js +1 -1
- package/dist/storage/action-runs/record.d.ts +20 -0
- package/dist/storage/action-runs/record.d.ts.map +1 -0
- package/dist/storage/action-runs/types.d.ts +39 -68
- package/dist/storage/action-runs/types.d.ts.map +1 -1
- package/dist/storage/agents/types.d.ts +1 -1
- package/dist/storage/ai-limits/enforcement.js +2 -2
- package/dist/storage/auth/in-memory/auth-storage.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/magic-links.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/oidc-attempts.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/sessions.d.ts +0 -10
- package/dist/storage/auth/in-memory/sessions.d.ts.map +1 -1
- package/dist/storage/auth/in-memory/shared.d.ts +1 -2
- package/dist/storage/auth/in-memory/shared.d.ts.map +1 -1
- package/dist/storage/auth/types.d.ts +1 -17
- package/dist/storage/auth/types.d.ts.map +1 -1
- package/dist/storage/connector-connections/provider.js +1 -1
- package/dist/storage/file-upload-sessions/provider.js +10 -10
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +21 -22
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/internal.d.ts +1 -1
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +9 -12
- package/dist/storage/internal.js.map +1 -1
- package/dist/storage/objects/execution-limits.d.ts +1 -1
- package/dist/storage/objects/execution-limits.d.ts.map +1 -1
- package/dist/storage/ontology/provider.js +2 -2
- package/dist/storage/projection-runs/provider.js +2 -2
- package/dist/storage/types.d.ts +1 -1
- package/dist/storage/types.d.ts.map +1 -1
- package/dist/storage/workflow-runs/provider.js +10 -10
- package/dist/syncs/index.js +29 -29
- package/dist/testing/action-execution.d.ts +34 -4
- package/dist/testing/action-execution.d.ts.map +1 -1
- package/dist/testing/action-run-storage-contract.d.ts +11 -0
- package/dist/testing/action-run-storage-contract.d.ts.map +1 -0
- package/dist/testing/auth-storage-contract.d.ts.map +1 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +3205 -2946
- package/dist/testing/index.js.map +9 -8
- package/dist/testing/materializer-storage-contract.d.ts.map +1 -1
- package/dist/testing/queues-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +26 -26
- package/dist/webhooks/internal.js.map +1 -1
- package/dist/workers/index.js +1 -1
- package/dist/workflows/index.js +48 -51
- package/dist/workflows/index.js.map +1 -1
- package/package.json +8 -8
- package/src/actions/commit-edits.ts +9 -37
- package/src/actions/errors.ts +0 -4
- package/src/actions/execution.ts +10 -10
- package/src/actions/index.ts +5 -24
- package/src/actions/request.ts +157 -295
- package/src/actions/run/context.ts +193 -0
- package/src/actions/run/edits-commit.ts +102 -0
- package/src/actions/run/effects.ts +105 -0
- package/src/actions/run/execute.ts +113 -0
- package/src/actions/run/executor.ts +314 -0
- package/src/actions/run/normalize.ts +142 -0
- package/src/actions/run/phase-types.ts +20 -0
- package/src/actions/run/phases.ts +150 -0
- package/src/actions/run/run-action.ts +170 -0
- package/src/actions/run/signals.ts +118 -0
- package/src/actions/run/state.ts +95 -0
- package/src/actions/run/types.ts +61 -0
- package/src/actions/run/writeback.ts +79 -0
- package/src/actions/run-authorization.ts +1 -1
- package/src/actions/run-persistence.ts +105 -0
- package/src/actions/types/context.ts +10 -0
- package/src/auth/cookies.ts +3 -20
- package/src/auth/index.ts +0 -6
- package/src/auth/runtime.ts +59 -76
- package/src/auth/session-cache.ts +2 -9
- package/src/auth/types.ts +4 -8
- package/src/auth/validation.ts +0 -2
- package/src/authorization/decision.ts +8 -23
- package/src/authorization/event-visibility.ts +0 -12
- package/src/authorization/grant-kinds.ts +20 -27
- package/src/authorization/index.ts +0 -1
- package/src/authorization/resolve.ts +10 -6
- package/src/deploy/index.ts +0 -1
- package/src/deploy/services.ts +2 -12
- package/src/deploy/types.ts +7 -8
- package/src/deploy/validation.ts +15 -7
- package/src/error-reporting/types.ts +2 -10
- package/src/errors/catalog.ts +13 -0
- package/src/events/definitions.ts +0 -17
- package/src/events/index.ts +0 -14
- package/src/events/scope.ts +0 -12
- package/src/events/selectors/builder.ts +0 -51
- package/src/events/selectors/index.ts +0 -6
- package/src/events/selectors/predicate.ts +0 -2
- package/src/events/selectors/types.ts +7 -65
- package/src/events/types/index.ts +0 -11
- package/src/execution/authorization.ts +11 -5
- package/src/index.ts +2 -33
- package/src/materialization/model.ts +26 -9
- package/src/materializer/README.md +6 -1
- package/src/materializer/edits/commit.ts +42 -32
- package/src/materializer/shared/normalize.ts +25 -14
- package/src/models/execution/embedding.ts +6 -6
- package/src/objects/action/errors.ts +0 -12
- package/src/objects/action/index.ts +3 -3
- package/src/objects/action/request.ts +2 -29
- package/src/objects/execution.ts +2 -2
- package/src/objects/sdk/object-handle.ts +3 -29
- package/src/objects/sdk/object-set.ts +5 -30
- package/src/objects/service/index.ts +0 -1
- package/src/objects/vectors/README.md +4 -0
- package/src/objects/vectors/handle.ts +11 -2
- package/src/objects/vectors/indexing-generate.ts +2 -2
- package/src/objects/vectors/profile.ts +5 -0
- package/src/queues/in-memory.ts +0 -6
- package/src/queues/index.ts +0 -2
- package/src/queues/types.ts +0 -11
- package/src/runtime/host.ts +5 -0
- package/src/runtime/resolve-definitions.ts +0 -1
- package/src/runtime/types.ts +16 -45
- package/src/schedules/builders.ts +1 -4
- package/src/schedules/runtime.ts +0 -41
- package/src/schedules/validation.ts +2 -16
- package/src/security/builders.ts +7 -2
- package/src/security/every.ts +1 -5
- package/src/security/grants.ts +5 -25
- package/src/security/index.ts +0 -3
- package/src/security/membership-policies.ts +3 -1
- package/src/security/public.ts +10 -0
- package/src/security/registry.ts +0 -8
- package/src/security/types.ts +19 -25
- package/src/security/validation.ts +19 -17
- package/src/storage/action-runs/idempotency.ts +13 -41
- package/src/storage/action-runs/in-memory.ts +20 -311
- package/src/storage/action-runs/index.ts +1 -16
- package/src/storage/action-runs/record.ts +130 -0
- package/src/storage/action-runs/types.ts +37 -92
- package/src/storage/agents/types.ts +1 -1
- package/src/storage/auth/in-memory/auth-storage.ts +0 -18
- package/src/storage/auth/in-memory/magic-links.ts +0 -3
- package/src/storage/auth/in-memory/oidc-attempts.ts +0 -3
- package/src/storage/auth/in-memory/sessions.ts +1 -25
- package/src/storage/auth/in-memory/shared.ts +1 -10
- package/src/storage/auth/types.ts +2 -18
- package/src/storage/index.ts +1 -9
- package/src/storage/internal.ts +1 -7
- package/src/storage/objects/execution-limits.ts +3 -2
- package/src/storage/types.ts +2 -4
- package/src/testing/action-execution.ts +73 -13
- package/src/testing/action-run-storage-contract.ts +335 -0
- package/src/testing/auth-storage-contract.ts +14 -107
- package/src/testing/execution-storage-contract.ts +0 -2
- package/src/testing/index.ts +8 -1
- package/src/testing/materializer-storage-contract.ts +174 -18
- package/src/testing/queues-contract.ts +0 -18
- package/dist/actions/run-dispatch.d.ts +0 -25
- package/dist/actions/run-dispatch.d.ts.map +0 -1
- package/dist/actions/worker.d.ts +0 -3
- package/dist/actions/worker.d.ts.map +0 -1
- package/dist/actions/worker.js +0 -325
- package/dist/actions/worker.js.map +0 -11
- package/dist/auth/audience.d.ts +0 -8
- package/dist/auth/audience.d.ts.map +0 -1
- package/dist/authorization/application-access.d.ts +0 -18
- package/dist/authorization/application-access.d.ts.map +0 -1
- package/dist/chunk-1hqwggsn.js.map +0 -12
- package/dist/chunk-2jntasmh.js.map +0 -13
- package/dist/chunk-6h5m9xjx.js.map +0 -40
- package/dist/chunk-85cd7e8c.js +0 -51
- package/dist/chunk-85cd7e8c.js.map +0 -10
- package/dist/chunk-de4z2bj6.js.map +0 -18
- package/dist/chunk-dfm066qg.js.map +0 -11
- package/dist/chunk-enpsx8k5.js.map +0 -10
- package/dist/chunk-fc5zfxy1.js.map +0 -11
- package/dist/chunk-fe52eczz.js.map +0 -49
- package/dist/chunk-fx93hd2n.js +0 -1614
- package/dist/chunk-fx93hd2n.js.map +0 -20
- package/dist/chunk-k6hrnf35.js.map +0 -10
- package/dist/chunk-qkbx3tf6.js.map +0 -24
- package/dist/chunk-qxvp5epv.js +0 -1329
- package/dist/chunk-qxvp5epv.js.map +0 -36
- package/dist/chunk-r2y23egw.js.map +0 -10
- package/dist/chunk-tffvfy6s.js +0 -593
- package/dist/chunk-tffvfy6s.js.map +0 -15
- package/dist/chunk-xt1zt7gv.js.map +0 -13
- package/dist/chunk-y2aq6ag9.js.map +0 -11
- package/dist/chunk-y9jmd7e5.js.map +0 -15
- package/dist/chunk-zvx7h87b.js +0 -12
- package/dist/chunk-zvx7h87b.js.map +0 -10
- package/dist/events/types/actions.d.ts +0 -39
- package/dist/events/types/actions.d.ts.map +0 -1
- package/dist/objects/service/action-service.d.ts +0 -13
- package/dist/objects/service/action-service.d.ts.map +0 -1
- package/dist/security/applications.d.ts +0 -15
- package/dist/security/applications.d.ts.map +0 -1
- package/src/actions/run-dispatch.ts +0 -282
- package/src/actions/worker.ts +0 -2
- package/src/auth/audience.ts +0 -28
- package/src/authorization/application-access.ts +0 -34
- package/src/events/types/actions.ts +0 -42
- package/src/objects/service/action-service.ts +0 -43
- package/src/security/applications.ts +0 -11
- /package/dist/{chunk-rz53yb4v.js.map → chunk-0yh890a4.js.map} +0 -0
- /package/dist/{chunk-vgk3hknm.js.map → chunk-1k89ecfr.js.map} +0 -0
- /package/dist/{chunk-ny3xyvcn.js.map → chunk-1zq2p6g0.js.map} +0 -0
- /package/dist/{chunk-dnmadg9k.js.map → chunk-3t2hgbgd.js.map} +0 -0
- /package/dist/{chunk-22v5bpz3.js.map → chunk-5e43w60z.js.map} +0 -0
- /package/dist/{chunk-7hpdd6r9.js.map → chunk-6p49a5cq.js.map} +0 -0
- /package/dist/{chunk-kkqwzy6h.js.map → chunk-7t429e3f.js.map} +0 -0
- /package/dist/{chunk-ex496vct.js.map → chunk-9dmt152s.js.map} +0 -0
- /package/dist/{chunk-48e3cn2d.js.map → chunk-9gyp8hg1.js.map} +0 -0
- /package/dist/{chunk-zxawp1n2.js.map → chunk-9w055r5b.js.map} +0 -0
- /package/dist/{chunk-4wn7bxxa.js.map → chunk-9ybhtmg4.js.map} +0 -0
- /package/dist/{chunk-vx2yp45y.js.map → chunk-c85m1hyj.js.map} +0 -0
- /package/dist/{chunk-bs7sqkre.js.map → chunk-d09tj99x.js.map} +0 -0
- /package/dist/{chunk-zb77kjth.js.map → chunk-dk8tkk5f.js.map} +0 -0
- /package/dist/{chunk-vjcd8d27.js.map → chunk-fa02jy15.js.map} +0 -0
- /package/dist/{chunk-za5yd58j.js.map → chunk-fkgc1wt8.js.map} +0 -0
- /package/dist/{chunk-6gmfggss.js.map → chunk-t7x8dmn0.js.map} +0 -0
- /package/dist/{chunk-p844e0rn.js.map → chunk-tpn40322.js.map} +0 -0
- /package/dist/{chunk-rt9p8m9t.js.map → chunk-v9xd5wzd.js.map} +0 -0
- /package/dist/{chunk-2vhg6ysa.js.map → chunk-vyf9kfqf.js.map} +0 -0
- /package/dist/{chunk-bwjcehza.js.map → chunk-way52z4h.js.map} +0 -0
- /package/dist/{chunk-qkvz64nd.js.map → chunk-x6m907x7.js.map} +0 -0
- /package/dist/{chunk-yv9czyfr.js.map → chunk-xfs8x8m9.js.map} +0 -0
- /package/dist/{chunk-v6xpd60t.js.map → chunk-yevzdx4y.js.map} +0 -0
- /package/dist/{chunk-qmnnhde6.js.map → chunk-z4m0yz8c.js.map} +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { reportRunFailure } from "../../error-reporting/capability"
|
|
2
|
+
import { createSixbError } from "../../errors/internal"
|
|
3
|
+
import type { ActionRunFailure, RecordActionRunInput } from "../../storage"
|
|
4
|
+
import { ActionRunError } from "../../storage"
|
|
5
|
+
import type { CommittedActionRun } from "./edits-commit"
|
|
6
|
+
import { runActionEffects } from "./effects"
|
|
7
|
+
import { isActionPhaseFailure, toActionRunFailure, unwrapActionPhaseError } from "./normalize"
|
|
8
|
+
import { executeActionPhases } from "./phases"
|
|
9
|
+
import type { ActionRunSignals } from "./signals"
|
|
10
|
+
import { ActionRunState, type FailedActionRunRecord } from "./state"
|
|
11
|
+
import type { ActionRunContext, ActionRunOutcome, RunActionInput } from "./types"
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* A run that ended, but whose terminal record could not be written.
|
|
15
|
+
*
|
|
16
|
+
* It carries that record, so that whoever reports this error still reports how the run ended. Its
|
|
17
|
+
* cause is the error that kept the record from being written.
|
|
18
|
+
*/
|
|
19
|
+
export class UnrecordedActionRunError extends Error {
|
|
20
|
+
override readonly name = "UnrecordedActionRunError"
|
|
21
|
+
|
|
22
|
+
constructor(
|
|
23
|
+
readonly record: RecordActionRunInput,
|
|
24
|
+
options: { readonly cause: unknown }
|
|
25
|
+
) {
|
|
26
|
+
super(`[Sixb] Action run '${record.id}' ended, but its record could not be written.`, options)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Execute a requested run to its end, and record it once.
|
|
32
|
+
*
|
|
33
|
+
* A run with edits is recorded by the commit of its edits; any other run, succeeded or failed, is
|
|
34
|
+
* recorded as soon as it ends. The run's effects are left to the caller to start: see
|
|
35
|
+
* {@link ActionRunOutcome.effects}. This rejects when the run cannot execute here, or with an
|
|
36
|
+
* {@link UnrecordedActionRunError} when its record cannot be written.
|
|
37
|
+
*/
|
|
38
|
+
export async function runAction(input: RunActionInput): Promise<ActionRunOutcome> {
|
|
39
|
+
const { runtime, run, signals } = input
|
|
40
|
+
const ids = { actionId: run.actionId, runId: run.id }
|
|
41
|
+
|
|
42
|
+
if (run.projectId !== runtime.id) {
|
|
43
|
+
throw createSixbError(
|
|
44
|
+
"internal.unexpected",
|
|
45
|
+
`[Sixb] Action run '${run.id}' belongs to project '${run.projectId}', not '${runtime.id}'.`,
|
|
46
|
+
{ details: { ...ids, durableProjectId: run.projectId } }
|
|
47
|
+
)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const state = new ActionRunState(run, new Date())
|
|
51
|
+
const action = runtime.actions.getById(run.actionId)
|
|
52
|
+
if (!action) {
|
|
53
|
+
const message = `[Sixb] Unknown action '${run.actionId}'.`
|
|
54
|
+
const error = createSixbError("internal.unexpected", message, { details: ids })
|
|
55
|
+
const failure = toActionRunFailure(error, "validation", { ...ids, at: new Date() })
|
|
56
|
+
return recordFailure(runtime, state.failed(failure), error)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
let committed: CommittedActionRun | null
|
|
60
|
+
try {
|
|
61
|
+
committed = await executeActionPhases({ runtime, action, state, signals })
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return recordFailure(runtime, state.failed(runFailure(error, state, signals)), error)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!committed) return recordRun(runtime, state.succeeded())
|
|
67
|
+
// A commit that already existed recorded the run with it, for another request.
|
|
68
|
+
if (!committed.commit.created) return findRecordedRun(runtime, committed.record)
|
|
69
|
+
const { commit } = committed
|
|
70
|
+
return {
|
|
71
|
+
record: committed.record,
|
|
72
|
+
recorded: true,
|
|
73
|
+
...(action.phases.effects
|
|
74
|
+
? {
|
|
75
|
+
effects: () =>
|
|
76
|
+
runActionEffects({
|
|
77
|
+
runtime,
|
|
78
|
+
action,
|
|
79
|
+
state,
|
|
80
|
+
commit,
|
|
81
|
+
startDeadline: () => signals.startEffects(),
|
|
82
|
+
}),
|
|
83
|
+
}
|
|
84
|
+
: {}),
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* The failure a run that threw records.
|
|
90
|
+
*
|
|
91
|
+
* A failed writeback fails the run with the writeback's own failure. Otherwise, only a run stopped
|
|
92
|
+
* before its boundary is the caller's or the deadline's doing. Past it, or when a phase classified
|
|
93
|
+
* its error before anything aborted, the run failed on its own merits.
|
|
94
|
+
*/
|
|
95
|
+
function runFailure(
|
|
96
|
+
error: unknown,
|
|
97
|
+
state: ActionRunState,
|
|
98
|
+
signals: ActionRunSignals
|
|
99
|
+
): ActionRunFailure {
|
|
100
|
+
if (state.writeback?.status === "failed") return state.writeback.error
|
|
101
|
+
const stopped =
|
|
102
|
+
!state.pastBoundary && signals.beforeBoundary.aborted && !isActionPhaseFailure(error)
|
|
103
|
+
return toActionRunFailure(stopped ? signals.stopReason() : error, state.phase, {
|
|
104
|
+
actionId: state.run.actionId,
|
|
105
|
+
runId: state.run.id,
|
|
106
|
+
at: new Date(),
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Record a failed run, and report its failure to `onError` once this request recorded it. A run its
|
|
112
|
+
* caller cancelled is not reported: it did not fail on its own.
|
|
113
|
+
*/
|
|
114
|
+
async function recordFailure(
|
|
115
|
+
runtime: ActionRunContext,
|
|
116
|
+
record: FailedActionRunRecord,
|
|
117
|
+
error: unknown
|
|
118
|
+
): Promise<ActionRunOutcome> {
|
|
119
|
+
const outcome = await recordRun(runtime, record)
|
|
120
|
+
if (outcome.recorded && record.error.code !== "runtime.cancelled") {
|
|
121
|
+
reportRunFailure(runtime.errorReporterHost, unwrapActionPhaseError(error), {
|
|
122
|
+
projectId: runtime.id,
|
|
123
|
+
runKind: "action",
|
|
124
|
+
run: { runId: record.id, actionId: record.actionId },
|
|
125
|
+
failure: record.error,
|
|
126
|
+
})
|
|
127
|
+
}
|
|
128
|
+
return outcome
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Write a run's terminal record. A run id is recorded once: when a concurrent request for the same
|
|
133
|
+
* run id recorded it first, with the same request, its record answers this one too.
|
|
134
|
+
*/
|
|
135
|
+
async function recordRun(
|
|
136
|
+
runtime: ActionRunContext,
|
|
137
|
+
record: RecordActionRunInput
|
|
138
|
+
): Promise<ActionRunOutcome> {
|
|
139
|
+
try {
|
|
140
|
+
return { record: await runtime.actionRunsStorage.record(record), recorded: true }
|
|
141
|
+
} catch (error) {
|
|
142
|
+
if (error instanceof ActionRunError) return findRecordedRun(runtime, record, error)
|
|
143
|
+
throw new UnrecordedActionRunError(record, { cause: error })
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/**
|
|
148
|
+
* The record another request wrote for this run. Whether it answers this request is the request's
|
|
149
|
+
* to decide, under the checks any record it finds gets.
|
|
150
|
+
*/
|
|
151
|
+
async function findRecordedRun(
|
|
152
|
+
runtime: ActionRunContext,
|
|
153
|
+
record: RecordActionRunInput,
|
|
154
|
+
cause?: unknown
|
|
155
|
+
): Promise<ActionRunOutcome> {
|
|
156
|
+
try {
|
|
157
|
+
const stored = await runtime.actionRunsStorage.getById({
|
|
158
|
+
projectId: record.projectId,
|
|
159
|
+
id: record.id,
|
|
160
|
+
})
|
|
161
|
+
if (!stored) {
|
|
162
|
+
throw (
|
|
163
|
+
cause ?? new ActionRunError(`[Sixb] Action run '${record.id}' committed without a record.`)
|
|
164
|
+
)
|
|
165
|
+
}
|
|
166
|
+
return { record: stored, recorded: false }
|
|
167
|
+
} catch (error) {
|
|
168
|
+
throw new UnrecordedActionRunError(record, { cause: error })
|
|
169
|
+
}
|
|
170
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import { createSixbError, isSixbError } from "../../errors/internal"
|
|
2
|
+
|
|
3
|
+
/** How long an Action run has to reach its irreversible boundary, and its effects after commit. */
|
|
4
|
+
export const ACTION_TIMEOUT_MS = 30_000
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How long a stopping process waits for its in-flight Action runs and their effects: a run's
|
|
8
|
+
* deadline, then its effects' deadline, plus a margin.
|
|
9
|
+
*
|
|
10
|
+
* It does not bound a whole run. Edits past the boundary are uninterruptible, and effects start
|
|
11
|
+
* only once they committed, so a run or its effects can still be executing when the wait ends. A
|
|
12
|
+
* deployment's kill timeout must exceed this bound.
|
|
13
|
+
*/
|
|
14
|
+
export const ACTION_RUN_DRAIN_TIMEOUT_MS = 2 * ACTION_TIMEOUT_MS + 5_000
|
|
15
|
+
|
|
16
|
+
export interface ActionRunSignalsInput {
|
|
17
|
+
readonly actionId: string
|
|
18
|
+
readonly runId: string
|
|
19
|
+
/** The caller's cancellation. It applies before the boundary only. */
|
|
20
|
+
readonly caller?: AbortSignal
|
|
21
|
+
/** Test-only override of {@link ACTION_TIMEOUT_MS}. */
|
|
22
|
+
readonly timeoutMs?: number
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* The cancellation one Action run observes, phase by phase.
|
|
27
|
+
*
|
|
28
|
+
* The irreversible boundary is a succeeded writeback, or the commit of an Action without one. Before
|
|
29
|
+
* it, validation, writeback and edits run under {@link beforeBoundary}, which aborts when the run's
|
|
30
|
+
* deadline elapses or its caller aborts. After it, edits and commit run under
|
|
31
|
+
* {@link uninterruptible}: abandoning them would strand an external change that the ontology never
|
|
32
|
+
* records. Effects run after the commit under a deadline of their own, which
|
|
33
|
+
* {@link startEffects} starts.
|
|
34
|
+
*
|
|
35
|
+
* Cancellation is cooperative: a handler stops early only when it forwards its `signal` to what it
|
|
36
|
+
* awaits. The run stops waiting for one that does not, wherever abandoning it loses nothing:
|
|
37
|
+
* validation, edits before the boundary, and effects (`untilAborted`). A writeback is always waited
|
|
38
|
+
* for, since only its result says whether the external change happened.
|
|
39
|
+
*/
|
|
40
|
+
export class ActionRunSignals {
|
|
41
|
+
readonly beforeBoundary: AbortSignal
|
|
42
|
+
/**
|
|
43
|
+
* Never aborts, for the work that must run to completion once it starts. One per run: whatever
|
|
44
|
+
* listens to it is released with the run, not kept for the life of the process.
|
|
45
|
+
*/
|
|
46
|
+
readonly uninterruptible: AbortSignal = new AbortController().signal
|
|
47
|
+
|
|
48
|
+
private readonly input: ActionRunSignalsInput
|
|
49
|
+
private readonly deadline: ActionDeadline
|
|
50
|
+
|
|
51
|
+
constructor(input: ActionRunSignalsInput) {
|
|
52
|
+
this.input = input
|
|
53
|
+
this.deadline = new ActionDeadline(input, "run")
|
|
54
|
+
this.beforeBoundary = input.caller
|
|
55
|
+
? AbortSignal.any([this.deadline.signal, input.caller])
|
|
56
|
+
: this.deadline.signal
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Why the run stopped before its boundary: its deadline's `action.timeout` when the deadline
|
|
61
|
+
* elapsed first, or else a `runtime.cancelled` error caused by what its caller aborted with.
|
|
62
|
+
*/
|
|
63
|
+
stopReason(): unknown {
|
|
64
|
+
const reason = this.beforeBoundary.reason
|
|
65
|
+
if (isActionTimeout(reason)) return reason
|
|
66
|
+
return createSixbError(
|
|
67
|
+
"runtime.cancelled",
|
|
68
|
+
`[Sixb] Action run '${this.input.runId}' was cancelled by its caller.`,
|
|
69
|
+
{ cause: reason, details: { actionId: this.input.actionId, runId: this.input.runId } }
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Start the deadline the run's effects run under. It is independent of the run's own: effects
|
|
75
|
+
* start after the run is recorded, and the caller of the deadline disposes it once they end.
|
|
76
|
+
*/
|
|
77
|
+
startEffects(): ActionDeadline {
|
|
78
|
+
return new ActionDeadline(this.input, "effects")
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Release the run's deadline timer. */
|
|
82
|
+
dispose(): void {
|
|
83
|
+
this.deadline.dispose()
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** A signal that aborts with `action.timeout` once its scope's deadline elapses. */
|
|
88
|
+
export class ActionDeadline {
|
|
89
|
+
readonly signal: AbortSignal
|
|
90
|
+
private readonly timer: ReturnType<typeof setTimeout>
|
|
91
|
+
|
|
92
|
+
constructor(
|
|
93
|
+
input: Pick<ActionRunSignalsInput, "actionId" | "runId" | "timeoutMs">,
|
|
94
|
+
scope: "run" | "effects"
|
|
95
|
+
) {
|
|
96
|
+
const controller = new AbortController()
|
|
97
|
+
const timeoutMs = input.timeoutMs ?? ACTION_TIMEOUT_MS
|
|
98
|
+
this.signal = controller.signal
|
|
99
|
+
this.timer = setTimeout(() => {
|
|
100
|
+
controller.abort(
|
|
101
|
+
createSixbError(
|
|
102
|
+
"action.timeout",
|
|
103
|
+
`[Sixb] Action run '${input.runId}' exceeded its ${timeoutMs} ms ${scope} deadline.`,
|
|
104
|
+
{ details: { actionId: input.actionId, runId: input.runId } }
|
|
105
|
+
)
|
|
106
|
+
)
|
|
107
|
+
}, timeoutMs)
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** Release the deadline timer. */
|
|
111
|
+
dispose(): void {
|
|
112
|
+
clearTimeout(this.timer)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function isActionTimeout(error: unknown): boolean {
|
|
117
|
+
return isSixbError(error) && error.code === "action.timeout"
|
|
118
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { JsonValue } from "../../json"
|
|
2
|
+
import type {
|
|
3
|
+
ActionRunFailure,
|
|
4
|
+
ActionRunPhase,
|
|
5
|
+
ActionRunWritebackRecord,
|
|
6
|
+
RecordActionRunInput,
|
|
7
|
+
} from "../../storage"
|
|
8
|
+
import type { PendingActionRun } from "./types"
|
|
9
|
+
|
|
10
|
+
export type SucceededActionRunRecord = Extract<
|
|
11
|
+
RecordActionRunInput,
|
|
12
|
+
{ readonly status: "succeeded" }
|
|
13
|
+
>
|
|
14
|
+
export type FailedActionRunRecord = Extract<RecordActionRunInput, { readonly status: "failed" }>
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* What a run has done so far: the phase it reached and how its writeback ended.
|
|
18
|
+
*
|
|
19
|
+
* It lives in memory while the run executes, and nothing about the run is stored before it ends:
|
|
20
|
+
* its terminal record is built from this state once, when it succeeds or fails.
|
|
21
|
+
*/
|
|
22
|
+
export class ActionRunState {
|
|
23
|
+
private reached: ActionRunPhase = "validation"
|
|
24
|
+
private writebackRecord: ActionRunWritebackRecord | undefined
|
|
25
|
+
|
|
26
|
+
constructor(
|
|
27
|
+
readonly run: PendingActionRun,
|
|
28
|
+
/** When the run started executing, as its handlers and its record see it. */
|
|
29
|
+
readonly startedAt: Date
|
|
30
|
+
) {}
|
|
31
|
+
|
|
32
|
+
/** The last phase the run reached. */
|
|
33
|
+
get phase(): ActionRunPhase {
|
|
34
|
+
return this.reached
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
get writeback(): ActionRunWritebackRecord | undefined {
|
|
38
|
+
return this.writebackRecord
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** The value a succeeded writeback returned, which edits and effects receive. */
|
|
42
|
+
get writebackValue(): JsonValue | undefined {
|
|
43
|
+
return this.writebackRecord?.status === "succeeded" ? this.writebackRecord.result : undefined
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Whether the run's deadline and caller no longer apply to it.
|
|
48
|
+
*
|
|
49
|
+
* True once its writeback succeeded, or once its commit started for an Action without one: from
|
|
50
|
+
* there the run either commits or fails on its own merits.
|
|
51
|
+
*/
|
|
52
|
+
get pastBoundary(): boolean {
|
|
53
|
+
return this.writebackRecord?.status === "succeeded" || this.reached === "commit"
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** Enter a phase before the commit. The run is recorded before its effects run. */
|
|
57
|
+
enter(phase: Exclude<ActionRunPhase, "effects">): void {
|
|
58
|
+
this.reached = phase
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** Keep how the writeback ended. A run calls its writeback once, so this is set once. */
|
|
62
|
+
recordWriteback(writeback: ActionRunWritebackRecord): void {
|
|
63
|
+
if (this.writebackRecord) {
|
|
64
|
+
throw new Error(`[Sixb] Action run '${this.run.id}' already ended its writeback.`)
|
|
65
|
+
}
|
|
66
|
+
this.writebackRecord = writeback
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** The record of the run succeeding in the phase it reached. */
|
|
70
|
+
succeeded(finishedAt: Date = new Date()): SucceededActionRunRecord {
|
|
71
|
+
return { ...this.recordFields(this.reached, finishedAt), status: "succeeded" }
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The record of the run failing with `error`, in the phase the failure names. */
|
|
75
|
+
failed(error: ActionRunFailure, finishedAt: Date = new Date()): FailedActionRunRecord {
|
|
76
|
+
return { ...this.recordFields(error.details.phase, finishedAt), status: "failed", error }
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private recordFields(phase: ActionRunPhase, finishedAt: Date) {
|
|
80
|
+
const { id, projectId, executionId, actionId, subject, params, idempotencyKey } = this.run
|
|
81
|
+
return {
|
|
82
|
+
id,
|
|
83
|
+
projectId,
|
|
84
|
+
executionId,
|
|
85
|
+
actionId,
|
|
86
|
+
subject,
|
|
87
|
+
params,
|
|
88
|
+
idempotencyKey,
|
|
89
|
+
phase,
|
|
90
|
+
startedAt: this.startedAt,
|
|
91
|
+
finishedAt,
|
|
92
|
+
...(this.writebackRecord === undefined ? {} : { writeback: this.writebackRecord }),
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import type { BlobsRuntime } from "../../blob-storage/execution"
|
|
2
|
+
import type { ConnectorRuntime } from "../../connectors/execution"
|
|
3
|
+
import type { LoggingService } from "../../logging/service"
|
|
4
|
+
import type { ModelsRuntime } from "../../models/generation-types"
|
|
5
|
+
import type { ObjectsRuntime } from "../../objects/execution"
|
|
6
|
+
import type { SixbDefinitions } from "../../runtime/definitions"
|
|
7
|
+
import type { OntologyMutationRuntime } from "../../runtime/ontology-mutations"
|
|
8
|
+
import type { ActionRunRecord, ActionRunStorage, Storage } from "../../storage"
|
|
9
|
+
import type { ActionsRuntime } from "../execution"
|
|
10
|
+
import type { ActionRunSignals } from "./signals"
|
|
11
|
+
|
|
12
|
+
/** Execution-bound primitives exposed to Action phase handlers. */
|
|
13
|
+
export interface ActionExecutionFacade {
|
|
14
|
+
readonly models: ModelsRuntime
|
|
15
|
+
readonly objects: ObjectsRuntime
|
|
16
|
+
readonly actions: ActionsRuntime
|
|
17
|
+
readonly connector: ConnectorRuntime
|
|
18
|
+
readonly blobs: BlobsRuntime
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ActionRunContext {
|
|
22
|
+
readonly id: string
|
|
23
|
+
readonly errorReporterHost: object
|
|
24
|
+
readonly logging?: LoggingService
|
|
25
|
+
readonly storage: Storage
|
|
26
|
+
readonly actionRunsStorage: ActionRunStorage
|
|
27
|
+
readonly ontologyMutations: OntologyMutationRuntime
|
|
28
|
+
readonly sixb: ActionExecutionFacade
|
|
29
|
+
readonly actions: Pick<SixbDefinitions["actions"], "getById">
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* A requested run that has not ended: the request it executes, under the durable execution created
|
|
34
|
+
* for it. Nothing else about it is stored until its terminal record is written.
|
|
35
|
+
*/
|
|
36
|
+
export type PendingActionRun = Pick<
|
|
37
|
+
ActionRunRecord,
|
|
38
|
+
"id" | "projectId" | "executionId" | "actionId" | "subject" | "params" | "idempotencyKey"
|
|
39
|
+
>
|
|
40
|
+
|
|
41
|
+
export interface RunActionInput {
|
|
42
|
+
readonly runtime: ActionRunContext
|
|
43
|
+
readonly run: PendingActionRun
|
|
44
|
+
readonly signals: ActionRunSignals
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** How a request's run ended. */
|
|
48
|
+
export interface ActionRunOutcome {
|
|
49
|
+
readonly record: ActionRunRecord
|
|
50
|
+
/**
|
|
51
|
+
* Whether this request wrote the record. When it did not, a concurrent request for the same run
|
|
52
|
+
* id recorded the run first, and the record is that request's, whatever it asked for.
|
|
53
|
+
*/
|
|
54
|
+
readonly recorded: boolean
|
|
55
|
+
/**
|
|
56
|
+
* Runs the run's effects and records their outcome. The request starts it once it returns the
|
|
57
|
+
* record, and does not wait for it. An effects failure does not reject it: it is recorded on the
|
|
58
|
+
* run.
|
|
59
|
+
*/
|
|
60
|
+
readonly effects?: () => Promise<void>
|
|
61
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { JsonValue } from "../../json"
|
|
2
|
+
import { assertJsonValue, cloneJsonValue } from "../../json"
|
|
3
|
+
import type { ActionReadRecorder } from "../read-facade"
|
|
4
|
+
import { isObjectActionDefinition } from "../validation"
|
|
5
|
+
import {
|
|
6
|
+
type BasePhaseContext,
|
|
7
|
+
requireObjectTarget,
|
|
8
|
+
toActionReadFacade,
|
|
9
|
+
toActionRuntimeFacade,
|
|
10
|
+
} from "./context"
|
|
11
|
+
import { toActionRunFailure, translateActionPhaseError } from "./normalize"
|
|
12
|
+
import type { LoadedObjectTarget, PhaseExecutionBase, RuntimePhaseHandler } from "./phase-types"
|
|
13
|
+
import type { ActionRunState } from "./state"
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Calls the Action's writeback, when it has one, and keeps how it ended on the run's state.
|
|
17
|
+
*
|
|
18
|
+
* A failed writeback fails the run with the writeback's own failure; a succeeded one is the run's
|
|
19
|
+
* irreversible boundary.
|
|
20
|
+
*/
|
|
21
|
+
export async function runWritebackPhase(
|
|
22
|
+
input: PhaseExecutionBase & {
|
|
23
|
+
readonly state: ActionRunState
|
|
24
|
+
readonly baseContext: BasePhaseContext
|
|
25
|
+
readonly objectTarget: LoadedObjectTarget | null
|
|
26
|
+
readonly reads: ActionReadRecorder
|
|
27
|
+
}
|
|
28
|
+
): Promise<void> {
|
|
29
|
+
const handler = input.action.phases.writeback as RuntimePhaseHandler | undefined
|
|
30
|
+
if (!handler) return
|
|
31
|
+
|
|
32
|
+
const { state } = input
|
|
33
|
+
const ids = { actionId: input.action.id, runId: state.run.id }
|
|
34
|
+
state.enter("writeback")
|
|
35
|
+
|
|
36
|
+
let result: JsonValue
|
|
37
|
+
try {
|
|
38
|
+
// Reads are side-effect-free, so the writeback phase can safely enrich its external payload
|
|
39
|
+
// before the edit batch exists. Object, link-scope, and returned query/list rows share the
|
|
40
|
+
// edits phase's recorder and are fenced by the same CAS. Query membership and telemetry
|
|
41
|
+
// history remain call-level snapshots.
|
|
42
|
+
const context = {
|
|
43
|
+
...input.baseContext,
|
|
44
|
+
signal: input.signal,
|
|
45
|
+
sixb: toActionRuntimeFacade(input.runtime),
|
|
46
|
+
read: toActionReadFacade(input.runtime, input.reads),
|
|
47
|
+
}
|
|
48
|
+
const rawResult = isObjectActionDefinition(input.action)
|
|
49
|
+
? await handler({
|
|
50
|
+
...context,
|
|
51
|
+
target: requireObjectTarget(input.objectTarget, ids).snapshot,
|
|
52
|
+
})
|
|
53
|
+
: await handler(context)
|
|
54
|
+
result = normalizeWritebackResult(rawResult)
|
|
55
|
+
} catch (error) {
|
|
56
|
+
const completedAt = new Date()
|
|
57
|
+
const phaseError = translateActionPhaseError(error, "writeback", {
|
|
58
|
+
...ids,
|
|
59
|
+
signal: input.signal,
|
|
60
|
+
})
|
|
61
|
+
state.recordWriteback({
|
|
62
|
+
status: "failed",
|
|
63
|
+
completedAt,
|
|
64
|
+
error: toActionRunFailure(phaseError, "writeback", { ...ids, at: completedAt }),
|
|
65
|
+
})
|
|
66
|
+
throw error
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
state.recordWriteback({ status: "succeeded", completedAt: new Date(), result })
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function normalizeWritebackResult(result: unknown): JsonValue {
|
|
73
|
+
if (result === undefined) {
|
|
74
|
+
return null
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
assertJsonValue(result, "Action writeback result")
|
|
78
|
+
return cloneJsonValue(result)
|
|
79
|
+
}
|
|
@@ -35,7 +35,7 @@ export async function canDelegationAccessActionRun(input: {
|
|
|
35
35
|
export async function actionRunBelongsToShareGrant(input: {
|
|
36
36
|
readonly storage: Storage
|
|
37
37
|
readonly projectId: string
|
|
38
|
-
readonly run: ActionRunRecord
|
|
38
|
+
readonly run: Pick<ActionRunRecord, "id" | "actionId" | "executionId">
|
|
39
39
|
readonly grantId: string
|
|
40
40
|
}): Promise<boolean> {
|
|
41
41
|
const parent = await findPrimitiveParentRequestExecution({
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto"
|
|
2
|
+
import type { ActionRunParams, ActionRunRecord, CreateExecutionInput, Storage } from "../storage"
|
|
3
|
+
import { ActionRunError } from "../storage"
|
|
4
|
+
import { actionRunRequestsEqual } from "../storage/action-runs/idempotency"
|
|
5
|
+
import type { ExecutionRecord } from "../storage/executions"
|
|
6
|
+
import type { PendingActionRun } from "./run/types"
|
|
7
|
+
import { createActionRunIdempotencyKey } from "./run-id"
|
|
8
|
+
import type { ActionSubject } from "./types"
|
|
9
|
+
|
|
10
|
+
/** What a request asks its run id to run. */
|
|
11
|
+
export interface ActionRunRequestPayload {
|
|
12
|
+
readonly actionId: string
|
|
13
|
+
readonly subject: ActionSubject
|
|
14
|
+
readonly params: ActionRunParams
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/** A run that already exists under a requested run id, recorded or still executing. */
|
|
18
|
+
export type ExistingActionRun = Pick<
|
|
19
|
+
ActionRunRecord,
|
|
20
|
+
"id" | "executionId" | "actionId" | "subject" | "params"
|
|
21
|
+
>
|
|
22
|
+
|
|
23
|
+
/** Refuses an existing run the requesting caller may not have. */
|
|
24
|
+
export type AssertCanReuseActionRun = (run: ExistingActionRun) => void | Promise<void>
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Answer a request with the run that already exists under its run id only when its caller may have
|
|
28
|
+
* that run, and only for the same request.
|
|
29
|
+
*
|
|
30
|
+
* The caller's right to the run is checked first, so that a refused caller learns nothing about it,
|
|
31
|
+
* not even whether it carries the same request.
|
|
32
|
+
*/
|
|
33
|
+
export async function assertCanReuseActionRun(
|
|
34
|
+
run: ExistingActionRun,
|
|
35
|
+
request: {
|
|
36
|
+
readonly payload: ActionRunRequestPayload
|
|
37
|
+
readonly assertCanReuse: AssertCanReuseActionRun
|
|
38
|
+
}
|
|
39
|
+
): Promise<void> {
|
|
40
|
+
await request.assertCanReuse(run)
|
|
41
|
+
if (!actionRunRequestsEqual(run, request.payload)) {
|
|
42
|
+
throw new ActionRunError(
|
|
43
|
+
`[Sixb] Action run '${run.id}' already exists with a different request payload.`
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface PersistActionRunInput {
|
|
49
|
+
readonly projectId: string
|
|
50
|
+
readonly storage: Storage
|
|
51
|
+
readonly runId: string
|
|
52
|
+
readonly payload: ActionRunRequestPayload
|
|
53
|
+
readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>
|
|
54
|
+
readonly assertCanReuse: AssertCanReuseActionRun
|
|
55
|
+
/** Checks that hold only for a run this call creates; a replayed run keeps its accepted params. */
|
|
56
|
+
readonly assertNewRun?: () => Promise<void>
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** A run this request is to execute, or the record of an earlier request with the same run id. */
|
|
60
|
+
export type PersistedActionRun =
|
|
61
|
+
| {
|
|
62
|
+
readonly kind: "new"
|
|
63
|
+
readonly run: PendingActionRun
|
|
64
|
+
readonly execution: ExecutionRecord
|
|
65
|
+
}
|
|
66
|
+
| { readonly kind: "recorded"; readonly run: ActionRunRecord }
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Persist what a requested run needs before it executes: the durable execution it runs under.
|
|
70
|
+
*
|
|
71
|
+
* Nothing else is stored before the run ends. A run id that is already recorded must carry the same
|
|
72
|
+
* request, and its record answers this request without running anything.
|
|
73
|
+
*/
|
|
74
|
+
export async function persistActionRun(input: PersistActionRunInput): Promise<PersistedActionRun> {
|
|
75
|
+
const { projectId, runId, payload } = input
|
|
76
|
+
if (!input.storage.actionRuns) {
|
|
77
|
+
throw new ActionRunError("[Sixb] Action run storage is not configured.")
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const recorded = await input.storage.actionRuns.getById({ projectId, id: runId })
|
|
81
|
+
if (recorded) {
|
|
82
|
+
await assertCanReuseActionRun(recorded, input)
|
|
83
|
+
return { kind: "recorded", run: recorded }
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
await input.assertNewRun?.()
|
|
87
|
+
// The execution is immutable provenance, created before the run executes: its record references
|
|
88
|
+
// it, and so do the commit of its edits and the model calls it makes.
|
|
89
|
+
const execution = await input.storage.executions.create(
|
|
90
|
+
await input.createExecution(`exec_${randomUUID()}`, runId)
|
|
91
|
+
)
|
|
92
|
+
return {
|
|
93
|
+
kind: "new",
|
|
94
|
+
run: {
|
|
95
|
+
id: runId,
|
|
96
|
+
projectId,
|
|
97
|
+
executionId: execution.id,
|
|
98
|
+
actionId: payload.actionId,
|
|
99
|
+
subject: payload.subject,
|
|
100
|
+
params: payload.params,
|
|
101
|
+
idempotencyKey: createActionRunIdempotencyKey(projectId, runId),
|
|
102
|
+
},
|
|
103
|
+
execution,
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -61,6 +61,10 @@ export type ActionBinding<TObjectType extends ObjectType = ObjectType> =
|
|
|
61
61
|
export interface ActionRunPhaseInfo {
|
|
62
62
|
readonly id: string
|
|
63
63
|
readonly startedAt: Date
|
|
64
|
+
/**
|
|
65
|
+
* Identifies this run to external systems. Send it as the idempotency key of the external call a
|
|
66
|
+
* writeback makes, so that call applies once even when it is retried.
|
|
67
|
+
*/
|
|
64
68
|
readonly idempotencyKey: string
|
|
65
69
|
}
|
|
66
70
|
|
|
@@ -180,6 +184,12 @@ export interface BaseActionPhaseContext<TParams extends Record<string, unknown>>
|
|
|
180
184
|
readonly run: ActionRunPhaseInfo
|
|
181
185
|
readonly params: TParams
|
|
182
186
|
readonly subject: ActionSubject
|
|
187
|
+
/**
|
|
188
|
+
* Aborts when the caller cancels the run or it runs out of time: a run has 30 seconds until its
|
|
189
|
+
* writeback succeeds or its edits commit, and its effects have 30 more after the commit. Forward
|
|
190
|
+
* it to every call the handler awaits. Edits that follow a succeeded writeback always complete, so
|
|
191
|
+
* their signal never aborts.
|
|
192
|
+
*/
|
|
183
193
|
readonly signal: AbortSignal
|
|
184
194
|
readonly logger: Logger
|
|
185
195
|
}
|