@sixb/core 0.2.0 → 0.2.2
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 -30
- package/dist/agents/cancel.d.ts.map +1 -1
- package/dist/agents/index.d.ts +5 -3
- package/dist/agents/index.d.ts.map +1 -1
- package/dist/agents/index.js +39 -33
- package/dist/agents/index.js.map +1 -1
- package/dist/agents/run-plan.d.ts +15 -1
- package/dist/agents/run-plan.d.ts.map +1 -1
- package/dist/agents/run-session-http.d.ts.map +1 -1
- package/dist/agents/run-session-serve.d.ts.map +1 -1
- package/dist/agents/run-session.d.ts +14 -2
- package/dist/agents/run-session.d.ts.map +1 -1
- package/dist/agents/skills.d.ts +3 -0
- package/dist/agents/skills.d.ts.map +1 -1
- package/dist/agents/step-limits.d.ts +6 -0
- package/dist/agents/step-limits.d.ts.map +1 -1
- package/dist/agents/streams/index.js +1 -1
- package/dist/agents/streams/internal.js +1 -1
- package/dist/agents/streams/protocol.d.ts +8 -2
- package/dist/agents/streams/protocol.d.ts.map +1 -1
- package/dist/agents/tool-files.d.ts +3 -1
- package/dist/agents/tool-files.d.ts.map +1 -1
- package/dist/agents/validation.d.ts +1 -1
- package/dist/agents/validation.d.ts.map +1 -1
- package/dist/agents/web.d.ts +47 -0
- package/dist/agents/web.d.ts.map +1 -0
- package/dist/artifacts/publish/index.js +17 -17
- package/dist/auth/index.js +3 -3
- package/dist/authorization/index.js +2 -2
- package/dist/authorization/resolve.d.ts +4 -3
- package/dist/authorization/resolve.d.ts.map +1 -1
- package/dist/authorization/types.d.ts +5 -5
- package/dist/authorization/types.d.ts.map +1 -1
- package/dist/bootstrap/index.js +38 -38
- package/dist/{chunk-neftrg0n.js → chunk-0j3crh1w.js} +2 -2
- package/dist/{chunk-8dcfj58k.js → chunk-2ajw5rz0.js} +14 -10
- package/dist/chunk-2ajw5rz0.js.map +18 -0
- package/dist/{chunk-23s66j86.js → chunk-31kcqmhf.js} +1 -1
- package/dist/{chunk-nghc7eq0.js → chunk-3723kgba.js} +1 -1
- package/dist/{chunk-fdkpkkpw.js → chunk-3sqqhpr7.js} +5 -5
- package/dist/{chunk-m3qe54bb.js → chunk-4bm0caep.js} +1 -1
- package/dist/{chunk-ztf5vtmp.js → chunk-4s753g3k.js} +41 -10
- package/dist/chunk-4s753g3k.js.map +12 -0
- package/dist/{chunk-fntqb7qy.js → chunk-57g0215c.js} +1 -1
- package/dist/{chunk-8wsjr52f.js → chunk-5wtnmpze.js} +1 -1
- package/dist/{chunk-edx8xcsm.js → chunk-7z5rkf0m.js} +29 -6
- package/dist/chunk-7z5rkf0m.js.map +13 -0
- package/dist/{chunk-2pk5hjj9.js → chunk-80gym75n.js} +1 -1
- package/dist/{chunk-qbrmpgvv.js → chunk-9whfmsfk.js} +1 -1
- package/dist/{chunk-qya541bk.js → chunk-a5v4gjdx.js} +31 -28
- package/dist/{chunk-qya541bk.js.map → chunk-a5v4gjdx.js.map} +4 -4
- package/dist/{chunk-he7g39e5.js → chunk-a7aa0nzj.js} +7 -7
- package/dist/{chunk-tvefbgvw.js → chunk-az95tsh3.js} +4 -2
- package/dist/chunk-az95tsh3.js.map +11 -0
- package/dist/{chunk-7hd2ez3q.js → chunk-c4nrycdy.js} +1 -1
- package/dist/{chunk-ekkpzcka.js → chunk-c706qvyc.js} +36 -9
- package/dist/chunk-c706qvyc.js.map +11 -0
- package/dist/{chunk-n54k068r.js → chunk-c7cfe31p.js} +7 -7
- package/dist/{chunk-qsg8rw04.js → chunk-d04g36fw.js} +1 -1
- package/dist/{chunk-hjy3dsws.js → chunk-dsv783c3.js} +305 -32
- package/dist/{chunk-hjy3dsws.js.map → chunk-dsv783c3.js.map} +12 -10
- package/dist/{chunk-peggaard.js → chunk-e6xgz4h4.js} +20 -2
- package/dist/{chunk-peggaard.js.map → chunk-e6xgz4h4.js.map} +5 -3
- package/dist/{chunk-e99kp9jh.js → chunk-eqgr6nsa.js} +86 -30
- package/dist/{chunk-e99kp9jh.js.map → chunk-eqgr6nsa.js.map} +10 -9
- package/dist/{chunk-f2w6328x.js → chunk-f1h34y3r.js} +6 -6
- package/dist/{chunk-9rh8ncs5.js → chunk-fwsvshr5.js} +1 -1
- package/dist/{chunk-c78jjzhy.js → chunk-ga63a3dz.js} +6 -6
- package/dist/{chunk-c78jjzhy.js.map → chunk-ga63a3dz.js.map} +2 -2
- package/dist/{chunk-cgznz22f.js → chunk-gkv8r794.js} +2 -2
- package/dist/{chunk-d3t26vah.js → chunk-j1ny5fwh.js} +35 -11
- package/dist/chunk-j1ny5fwh.js.map +15 -0
- package/dist/{chunk-8hvfs0fr.js → chunk-j8thxj7w.js} +4 -4
- package/dist/{chunk-855n80en.js → chunk-jjmggm9a.js} +1 -1
- package/dist/{chunk-31khg3g0.js → chunk-kkjfve0t.js} +73 -2
- package/dist/{chunk-31khg3g0.js.map → chunk-kkjfve0t.js.map} +3 -3
- package/dist/{chunk-fb3m4sa1.js → chunk-m2vh8gh0.js} +8 -14
- package/dist/{chunk-fb3m4sa1.js.map → chunk-m2vh8gh0.js.map} +3 -3
- package/dist/{chunk-vkweppkw.js → chunk-mbc5hvnj.js} +3 -3
- package/dist/{chunk-jk97v21j.js → chunk-n4zzaf6q.js} +3 -2
- package/dist/chunk-n4zzaf6q.js.map +10 -0
- package/dist/{chunk-y2x2935j.js → chunk-nh26e7c5.js} +2 -2
- package/dist/{chunk-jhbk10wf.js → chunk-q9nkpr8k.js} +1 -1
- package/dist/{chunk-47e09r7z.js → chunk-qttqe1ah.js} +86 -6
- package/dist/{chunk-47e09r7z.js.map → chunk-qttqe1ah.js.map} +5 -4
- package/dist/{chunk-9mab3dvg.js → chunk-s038wa5v.js} +9 -1
- package/dist/{chunk-9mab3dvg.js.map → chunk-s038wa5v.js.map} +3 -3
- package/dist/{chunk-3x3bebz7.js → chunk-s7j8ewqv.js} +161 -62
- package/dist/{chunk-3x3bebz7.js.map → chunk-s7j8ewqv.js.map} +7 -6
- package/dist/{chunk-dz7a4t3a.js → chunk-twfreyxr.js} +5 -10
- package/dist/{chunk-dz7a4t3a.js.map → chunk-twfreyxr.js.map} +4 -4
- package/dist/{chunk-semf1yqn.js → chunk-w1btn96n.js} +51 -26
- package/dist/{chunk-semf1yqn.js.map → chunk-w1btn96n.js.map} +6 -6
- package/dist/{chunk-fg1db9xx.js → chunk-wkq3kvzd.js} +5 -5
- package/dist/chunk-wkq3kvzd.js.map +10 -0
- package/dist/{chunk-xj97s5js.js → chunk-wrjx1fqz.js} +6 -6
- package/dist/{chunk-agn8d8ys.js → chunk-xtztwpkh.js} +1 -1
- package/dist/{chunk-0g5nyx0k.js → chunk-zeykm8my.js} +2 -2
- package/dist/connectors/connections/runs.d.ts +7 -0
- package/dist/connectors/connections/runs.d.ts.map +1 -1
- package/dist/datasets/execution.d.ts.map +1 -1
- package/dist/events/index.js +1 -1
- package/dist/events/selectors/index.js +1 -1
- package/dist/events/selectors/predicate.d.ts.map +1 -1
- package/dist/events/types/datasets.d.ts +6 -0
- package/dist/events/types/datasets.d.ts.map +1 -1
- package/dist/execution/agent.js +30 -30
- package/dist/execution/object-reader-security.d.ts.map +1 -1
- package/dist/execution/primitive.js +30 -30
- package/dist/execution/request.js +31 -31
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +42 -42
- package/dist/lake-storage/in-memory.d.ts.map +1 -1
- package/dist/lake-storage/index.d.ts +2 -2
- package/dist/lake-storage/index.d.ts.map +1 -1
- package/dist/lake-storage/index.js +6 -2
- package/dist/lake-storage/index.js.map +1 -1
- package/dist/lake-storage/source-ordering.d.ts +7 -0
- package/dist/lake-storage/source-ordering.d.ts.map +1 -1
- package/dist/lake-storage/types.d.ts +18 -0
- package/dist/lake-storage/types.d.ts.map +1 -1
- package/dist/lake-storage/version-inputs.d.ts +11 -3
- package/dist/lake-storage/version-inputs.d.ts.map +1 -1
- package/dist/materializer/index.js +16 -16
- package/dist/models/catalog.d.ts +16 -0
- 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/execution/index.js +18 -18
- package/dist/models/execution/model-call-recorder.d.ts +1 -1
- package/dist/models/execution/model-call-recorder.d.ts.map +1 -1
- package/dist/models/execution/web-search.d.ts +7 -0
- package/dist/models/execution/web-search.d.ts.map +1 -0
- package/dist/models/index.d.ts +3 -1
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +5 -3
- package/dist/models/index.js.map +1 -1
- package/dist/models/language-model.d.ts +12 -0
- package/dist/models/language-model.d.ts.map +1 -1
- package/dist/models/web-search-model.d.ts +66 -0
- package/dist/models/web-search-model.d.ts.map +1 -0
- package/dist/objects/index.js +30 -30
- package/dist/objects/query/executor.d.ts.map +1 -1
- package/dist/objects/query/index.d.ts +1 -0
- package/dist/objects/query/index.d.ts.map +1 -1
- package/dist/objects/query/index.js +19 -16
- package/dist/objects/query/index.js.map +1 -1
- package/dist/objects/query/sort-ties.d.ts +11 -0
- package/dist/objects/query/sort-ties.d.ts.map +1 -0
- package/dist/pipelines/index.js +19 -19
- package/dist/pipelines/run-dispatch.d.ts +2 -0
- package/dist/pipelines/run-dispatch.d.ts.map +1 -1
- package/dist/projections/internal.js +16 -16
- package/dist/runtime/create.d.ts +1 -1
- package/dist/runtime/create.d.ts.map +1 -1
- package/dist/runtime/internal.js +22 -22
- package/dist/runtime/resolve-definitions.d.ts.map +1 -1
- package/dist/schedules/index.js +2 -2
- package/dist/security/index.d.ts +1 -0
- package/dist/security/index.d.ts.map +1 -1
- package/dist/security/registry.d.ts +2 -0
- package/dist/security/registry.d.ts.map +1 -1
- package/dist/security/view-conditions.d.ts.map +1 -1
- package/dist/security/visibility-keys.d.ts +19 -0
- package/dist/security/visibility-keys.d.ts.map +1 -0
- package/dist/shares/internal.js +16 -16
- package/dist/storage/agents/in-memory.d.ts +8 -2
- package/dist/storage/agents/in-memory.d.ts.map +1 -1
- package/dist/storage/agents/index.d.ts +1 -1
- package/dist/storage/agents/index.d.ts.map +1 -1
- package/dist/storage/agents/provider.d.ts +8 -2
- package/dist/storage/agents/provider.d.ts.map +1 -1
- package/dist/storage/agents/provider.js +12 -6
- package/dist/storage/agents/provider.js.map +1 -1
- package/dist/storage/agents/types.d.ts +42 -2
- package/dist/storage/agents/types.d.ts.map +1 -1
- package/dist/storage/ai-cost/provider.js +4 -4
- package/dist/storage/ai-limits/enforcement.js +3 -3
- package/dist/storage/ai-limits/provider.js +2 -2
- package/dist/storage/connector-connections/provider.js +3 -3
- package/dist/storage/connector-connections/provider.js.map +3 -3
- package/dist/storage/file-upload-sessions/provider.js +4 -4
- package/dist/storage/index.d.ts +2 -2
- package/dist/storage/index.d.ts.map +1 -1
- package/dist/storage/index.js +15 -15
- package/dist/storage/internal.d.ts +2 -0
- package/dist/storage/internal.d.ts.map +1 -1
- package/dist/storage/internal.js +8 -4
- package/dist/storage/internal.js.map +1 -1
- package/dist/storage/migrations/types.d.ts +6 -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/index.d.ts +1 -1
- package/dist/storage/objects/index.d.ts.map +1 -1
- package/dist/storage/objects/query-preparation.d.ts +13 -0
- package/dist/storage/objects/query-preparation.d.ts.map +1 -1
- package/dist/storage/objects/read-scope.d.ts.map +1 -1
- package/dist/storage/objects/types.d.ts +52 -0
- package/dist/storage/objects/types.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/pipeline-runs/transitions.d.ts +7 -0
- package/dist/storage/pipeline-runs/transitions.d.ts.map +1 -0
- package/dist/storage/share-grants/provider.js +2 -2
- package/dist/storage/sync-runs/in-memory.d.ts.map +1 -1
- package/dist/storage/sync-runs/transitions.d.ts +7 -0
- package/dist/storage/sync-runs/transitions.d.ts.map +1 -0
- package/dist/storage/workflow-runs/provider.js +4 -4
- package/dist/syncs/index.js +20 -20
- package/dist/syncs/run-dispatch.d.ts +2 -0
- package/dist/syncs/run-dispatch.d.ts.map +1 -1
- package/dist/testing/agent-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/connector-connection-storage-contract.d.ts.map +1 -1
- package/dist/testing/dataset-sequence-contract.d.ts.map +1 -1
- package/dist/testing/index.js +552 -61
- package/dist/testing/index.js.map +11 -11
- package/dist/testing/lake-changes-contract.d.ts.map +1 -1
- package/dist/testing/lake-storage-contract.d.ts.map +1 -1
- package/dist/testing/object-conditional-read-scope-contract.d.ts.map +1 -1
- package/dist/testing/object-query-contract.d.ts.map +1 -1
- package/dist/webhooks/internal.js +16 -16
- package/dist/workers/index.d.ts +1 -0
- package/dist/workers/index.d.ts.map +1 -1
- package/dist/workers/index.js +12 -2
- package/dist/workers/index.js.map +5 -4
- package/dist/workers/unstarted-run.d.ts +10 -0
- package/dist/workers/unstarted-run.d.ts.map +1 -0
- package/dist/workflows/index.js +34 -34
- package/package.json +1 -1
- package/src/agents/README.md +2 -1
- package/src/agents/cancel.ts +7 -1
- package/src/agents/index.ts +9 -1
- package/src/agents/run-plan.ts +31 -0
- package/src/agents/run-session-http.ts +15 -12
- package/src/agents/run-session-serve.ts +8 -2
- package/src/agents/run-session.ts +31 -11
- package/src/agents/skills.ts +3 -0
- package/src/agents/step-limits.ts +6 -0
- package/src/agents/streams/protocol.ts +9 -4
- package/src/agents/tool-files.ts +11 -3
- package/src/agents/validation.ts +9 -0
- package/src/agents/web.ts +218 -0
- package/src/authorization/resolve.ts +9 -11
- package/src/authorization/types.ts +5 -5
- package/src/connectors/connections/runs.ts +42 -5
- package/src/datasets/execution.ts +2 -0
- package/src/events/selectors/predicate.ts +15 -0
- package/src/events/types/datasets.ts +6 -0
- package/src/execution/object-reader-security.ts +4 -9
- package/src/index.ts +2 -0
- package/src/lake-storage/in-memory.ts +30 -20
- package/src/lake-storage/index.ts +2 -1
- package/src/lake-storage/source-ordering.ts +31 -4
- package/src/lake-storage/types.ts +18 -0
- package/src/lake-storage/version-inputs.ts +21 -5
- package/src/models/catalog.ts +52 -3
- package/src/models/definitions.ts +2 -0
- package/src/models/execution/README.md +22 -2
- package/src/models/execution/model-call-recorder.ts +1 -1
- package/src/models/execution/web-search.ts +186 -0
- package/src/models/index.ts +12 -0
- package/src/models/language-model.ts +12 -0
- package/src/models/web-search-model.ts +152 -0
- package/src/objects/query/executor.ts +7 -3
- package/src/objects/query/index.ts +1 -0
- package/src/objects/query/sort-ties.ts +16 -0
- package/src/pipelines/run-dispatch.ts +53 -6
- package/src/runtime/create.ts +3 -2
- package/src/runtime/resolve-definitions.ts +4 -0
- package/src/security/index.ts +1 -0
- package/src/security/registry.ts +2 -0
- package/src/security/view-conditions.ts +4 -3
- package/src/security/visibility-keys.ts +144 -0
- package/src/storage/agents/in-memory.ts +29 -2
- package/src/storage/agents/index.ts +2 -0
- package/src/storage/agents/provider.ts +57 -1
- package/src/storage/agents/types.ts +45 -2
- package/src/storage/connector-connections/in-memory.ts +2 -2
- package/src/storage/connector-connections/provider/connections.ts +2 -2
- package/src/storage/index.ts +4 -0
- package/src/storage/internal.ts +2 -0
- package/src/storage/migrations/types.ts +6 -0
- package/src/storage/objects/in-memory/query.ts +5 -2
- package/src/storage/objects/index.ts +2 -0
- package/src/storage/objects/query-preparation.ts +59 -1
- package/src/storage/objects/read-scope.ts +108 -2
- package/src/storage/objects/types.ts +43 -0
- package/src/storage/pipeline-runs/in-memory.ts +2 -5
- package/src/storage/pipeline-runs/transitions.ts +14 -0
- package/src/storage/sync-runs/in-memory.ts +2 -5
- package/src/storage/sync-runs/transitions.ts +11 -0
- package/src/syncs/run-dispatch.ts +68 -13
- package/src/testing/agent-storage-contract.ts +70 -0
- package/src/testing/ai-limit-storage-contract.ts +11 -1
- package/src/testing/ai-usage-storage-contract.ts +15 -2
- package/src/testing/connector-connection-storage-contract.ts +23 -0
- package/src/testing/dataset-sequence-contract.ts +81 -0
- package/src/testing/lake-changes-contract.ts +2 -1
- package/src/testing/lake-storage-contract.ts +112 -0
- package/src/testing/object-conditional-read-scope-contract.ts +267 -5
- package/src/testing/object-query-contract.ts +75 -0
- package/src/workers/index.ts +1 -0
- package/src/workers/unstarted-run.ts +18 -0
- package/dist/chunk-8dcfj58k.js.map +0 -18
- package/dist/chunk-d3t26vah.js.map +0 -15
- package/dist/chunk-edx8xcsm.js.map +0 -13
- package/dist/chunk-ekkpzcka.js.map +0 -11
- package/dist/chunk-fg1db9xx.js.map +0 -10
- package/dist/chunk-jk97v21j.js.map +0 -10
- package/dist/chunk-tvefbgvw.js.map +0 -11
- package/dist/chunk-ztf5vtmp.js.map +0 -12
- /package/dist/{chunk-neftrg0n.js.map → chunk-0j3crh1w.js.map} +0 -0
- /package/dist/{chunk-23s66j86.js.map → chunk-31kcqmhf.js.map} +0 -0
- /package/dist/{chunk-nghc7eq0.js.map → chunk-3723kgba.js.map} +0 -0
- /package/dist/{chunk-fdkpkkpw.js.map → chunk-3sqqhpr7.js.map} +0 -0
- /package/dist/{chunk-m3qe54bb.js.map → chunk-4bm0caep.js.map} +0 -0
- /package/dist/{chunk-fntqb7qy.js.map → chunk-57g0215c.js.map} +0 -0
- /package/dist/{chunk-8wsjr52f.js.map → chunk-5wtnmpze.js.map} +0 -0
- /package/dist/{chunk-2pk5hjj9.js.map → chunk-80gym75n.js.map} +0 -0
- /package/dist/{chunk-qbrmpgvv.js.map → chunk-9whfmsfk.js.map} +0 -0
- /package/dist/{chunk-he7g39e5.js.map → chunk-a7aa0nzj.js.map} +0 -0
- /package/dist/{chunk-7hd2ez3q.js.map → chunk-c4nrycdy.js.map} +0 -0
- /package/dist/{chunk-n54k068r.js.map → chunk-c7cfe31p.js.map} +0 -0
- /package/dist/{chunk-qsg8rw04.js.map → chunk-d04g36fw.js.map} +0 -0
- /package/dist/{chunk-f2w6328x.js.map → chunk-f1h34y3r.js.map} +0 -0
- /package/dist/{chunk-9rh8ncs5.js.map → chunk-fwsvshr5.js.map} +0 -0
- /package/dist/{chunk-cgznz22f.js.map → chunk-gkv8r794.js.map} +0 -0
- /package/dist/{chunk-8hvfs0fr.js.map → chunk-j8thxj7w.js.map} +0 -0
- /package/dist/{chunk-855n80en.js.map → chunk-jjmggm9a.js.map} +0 -0
- /package/dist/{chunk-vkweppkw.js.map → chunk-mbc5hvnj.js.map} +0 -0
- /package/dist/{chunk-y2x2935j.js.map → chunk-nh26e7c5.js.map} +0 -0
- /package/dist/{chunk-jhbk10wf.js.map → chunk-q9nkpr8k.js.map} +0 -0
- /package/dist/{chunk-xj97s5js.js.map → chunk-wrjx1fqz.js.map} +0 -0
- /package/dist/{chunk-agn8d8ys.js.map → chunk-xtztwpkh.js.map} +0 -0
- /package/dist/{chunk-0g5nyx0k.js.map → chunk-zeykm8my.js.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { compareStrings, getInvalidJsonValueReason } from "../../json"
|
|
2
2
|
import type { ObjectQueryPredicate, QueryScalarKind } from "../../objects/query"
|
|
3
|
-
import { isCurrentUser } from "../../ontology/user-ref"
|
|
3
|
+
import { isCurrentUser, type UserRef } from "../../ontology/user-ref"
|
|
4
4
|
import type {
|
|
5
5
|
CompiledConditionalObjectReadScope,
|
|
6
6
|
CompiledObjectReadObjectSelection,
|
|
@@ -14,6 +14,8 @@ import type {
|
|
|
14
14
|
ObjectReadNode,
|
|
15
15
|
ObjectReadObjectSelection,
|
|
16
16
|
ObjectReadRoot,
|
|
17
|
+
ObjectReadVisibility,
|
|
18
|
+
ObjectVisibilityKeys,
|
|
17
19
|
SelectedObjectReadScope,
|
|
18
20
|
} from "./types"
|
|
19
21
|
|
|
@@ -560,7 +562,13 @@ export function compileConditionalObjectReadScope(
|
|
|
560
562
|
objectTypeIds.add(objectTypeId)
|
|
561
563
|
|
|
562
564
|
const predicate = capturePredicate(condition.predicate, `${path}.predicate`, 0, budget)
|
|
563
|
-
|
|
565
|
+
const visibility =
|
|
566
|
+
condition.visibility === undefined
|
|
567
|
+
? undefined
|
|
568
|
+
: captureVisibility(condition.visibility, `${path}.visibility`, budget)
|
|
569
|
+
conditions.push(
|
|
570
|
+
Object.freeze({ objectTypeId, predicate, ...(visibility ? { visibility } : {}) })
|
|
571
|
+
)
|
|
564
572
|
}
|
|
565
573
|
|
|
566
574
|
conditions.sort((left, right) => compareStrings(left.objectTypeId, right.objectTypeId))
|
|
@@ -571,6 +579,104 @@ export function compileConditionalObjectReadScope(
|
|
|
571
579
|
}) as CompiledConditionalObjectReadScope
|
|
572
580
|
}
|
|
573
581
|
|
|
582
|
+
/** The reader's keys, user and remainder: shaped as providers read them, every predicate bound. */
|
|
583
|
+
function captureVisibility(
|
|
584
|
+
value: unknown,
|
|
585
|
+
path: string,
|
|
586
|
+
budget: { nodes: number }
|
|
587
|
+
): ObjectReadVisibility {
|
|
588
|
+
if (!isRecord(value)) throw invalidScope(`${path} must hold keys`)
|
|
589
|
+
|
|
590
|
+
const source = captureArray(value.keys, `${path}.keys`)
|
|
591
|
+
if (source.length === 0) throw invalidScope(`${path}.keys must not be empty`)
|
|
592
|
+
|
|
593
|
+
const keys: ObjectVisibilityKeys[] = []
|
|
594
|
+
for (let index = 0; index < source.length; index += 1) {
|
|
595
|
+
keys.push(captureKeys(source.value[index], `${path}.keys[${index}]`, 0, budget))
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
let user: UserRef | undefined
|
|
599
|
+
if (value.user !== undefined) {
|
|
600
|
+
const ref = value.user
|
|
601
|
+
if (!isRecord(ref) || ref.type !== "user" || Object.keys(ref).length !== 2) {
|
|
602
|
+
throw invalidScope(`${path}.user must be a user reference`)
|
|
603
|
+
}
|
|
604
|
+
if (typeof ref.id !== "string" || ref.id.length === 0) {
|
|
605
|
+
throw invalidScope(`${path}.user.id must be a non-empty string`)
|
|
606
|
+
}
|
|
607
|
+
user = Object.freeze({ type: "user", id: ref.id })
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
const remainder =
|
|
611
|
+
value.remainder === undefined
|
|
612
|
+
? undefined
|
|
613
|
+
: capturePredicate(value.remainder, `${path}.remainder`, 0, budget)
|
|
614
|
+
|
|
615
|
+
return Object.freeze({
|
|
616
|
+
keys: Object.freeze(keys),
|
|
617
|
+
...(user ? { user } : {}),
|
|
618
|
+
...(remainder ? { remainder } : {}),
|
|
619
|
+
})
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
function captureKeys(
|
|
623
|
+
value: unknown,
|
|
624
|
+
path: string,
|
|
625
|
+
depth: number,
|
|
626
|
+
budget: { nodes: number }
|
|
627
|
+
): ObjectVisibilityKeys {
|
|
628
|
+
if (depth > CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateDepth) {
|
|
629
|
+
throw invalidScope(
|
|
630
|
+
`${path} exceeds the maximum predicate depth of ${CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateDepth}`
|
|
631
|
+
)
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
budget.nodes += 1
|
|
635
|
+
if (budget.nodes > CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateNodes) {
|
|
636
|
+
throw invalidScope(
|
|
637
|
+
`scope exceeds the maximum of ${CONDITIONAL_READ_SCOPE_LIMITS.maxPredicateNodes} predicate nodes`
|
|
638
|
+
)
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
if (!isRecord(value)) throw invalidScope(`${path} must be visibility keys`)
|
|
642
|
+
|
|
643
|
+
switch (value.kind) {
|
|
644
|
+
case "everyone":
|
|
645
|
+
return Object.freeze({
|
|
646
|
+
kind: "everyone",
|
|
647
|
+
when: capturePredicate(value.when, `${path}.when`, depth + 1, budget),
|
|
648
|
+
})
|
|
649
|
+
|
|
650
|
+
case "user":
|
|
651
|
+
case "users":
|
|
652
|
+
return Object.freeze({
|
|
653
|
+
kind: value.kind,
|
|
654
|
+
propertyId: nonEmptyString(value.propertyId, `${path}.propertyId`),
|
|
655
|
+
})
|
|
656
|
+
|
|
657
|
+
case "union": {
|
|
658
|
+
const items = captureArray(value.items, `${path}.items`)
|
|
659
|
+
if (items.length === 0) throw invalidScope(`${path}.items must not be empty`)
|
|
660
|
+
|
|
661
|
+
const captured: ObjectVisibilityKeys[] = []
|
|
662
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
663
|
+
captured.push(captureKeys(items.value[index], `${path}.items[${index}]`, depth + 1, budget))
|
|
664
|
+
}
|
|
665
|
+
return Object.freeze({ kind: "union", items: Object.freeze(captured) })
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
case "when":
|
|
669
|
+
return Object.freeze({
|
|
670
|
+
kind: "when",
|
|
671
|
+
when: capturePredicate(value.when, `${path}.when`, depth + 1, budget),
|
|
672
|
+
keys: captureKeys(value.keys, `${path}.keys`, depth + 1, budget),
|
|
673
|
+
})
|
|
674
|
+
|
|
675
|
+
default:
|
|
676
|
+
throw invalidScope(`${path}.kind must be a kind of visibility keys`)
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
|
|
574
680
|
function capturePredicate(
|
|
575
681
|
value: unknown,
|
|
576
682
|
path: string,
|
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
ObjectQuerySortField,
|
|
7
7
|
QueryScalarKind,
|
|
8
8
|
} from "../../objects/query"
|
|
9
|
+
import type { UserRef } from "../../ontology/user-ref"
|
|
9
10
|
import type { Redactions } from "../../security/types"
|
|
10
11
|
import type { UserProfile } from "../../users"
|
|
11
12
|
import type { UniqueValueRef } from "../ontology/materializations"
|
|
@@ -203,8 +204,50 @@ export interface ObjectReadCondition {
|
|
|
203
204
|
* bound to the reader. Providers compile it with their own predicate compiler.
|
|
204
205
|
*/
|
|
205
206
|
readonly predicate: ObjectQueryPredicate
|
|
207
|
+
/**
|
|
208
|
+
* The same condition read from visibility keys, for a provider that indexes them. Absent when
|
|
209
|
+
* none of the reader's conditions on the type has keys.
|
|
210
|
+
*/
|
|
211
|
+
readonly visibility?: ObjectReadVisibility
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* `predicate` read from keys: it matches an object exactly when one of `keys` shows it to everyone
|
|
216
|
+
* or to `user`, or when `remainder` matches it.
|
|
217
|
+
*/
|
|
218
|
+
export interface ObjectReadVisibility {
|
|
219
|
+
/** One per condition of the reader's roles that has keys, the same for every reader. */
|
|
220
|
+
readonly keys: readonly ObjectVisibilityKeys[]
|
|
221
|
+
/** The user reading; without one, an object is only shown by keys for everyone. */
|
|
222
|
+
readonly user?: UserRef
|
|
223
|
+
/** The reader's other conditions, bound to its user: an object either matches is shown. */
|
|
224
|
+
readonly remainder?: ObjectQueryPredicate
|
|
206
225
|
}
|
|
207
226
|
|
|
227
|
+
/**
|
|
228
|
+
* Who a view condition shows an object to, read from the object alone: everyone holding the
|
|
229
|
+
* condition, or the users some of its properties name.
|
|
230
|
+
*
|
|
231
|
+
* `currentUser()` only appears where a condition compares user references, so a condition has
|
|
232
|
+
* keys unless it negates such a comparison, or needs two of them to hold at once. Unlike the
|
|
233
|
+
* condition bound to a reader, keys are the same for every reader, so a provider can index them
|
|
234
|
+
* once per condition. A reader sees an object when its keys show it to everyone or to the reader.
|
|
235
|
+
*/
|
|
236
|
+
export type ObjectVisibilityKeys =
|
|
237
|
+
/** Everyone, when `when` matches. `when` never reads `currentUser()`. */
|
|
238
|
+
| { readonly kind: "everyone"; readonly when: ObjectQueryPredicate }
|
|
239
|
+
/** The user a `ref.user()` property holds, as `eq(property, currentUser())` compares it. */
|
|
240
|
+
| { readonly kind: "user"; readonly propertyId: string }
|
|
241
|
+
/** Each user a list holds, as `contains(property, currentUser())` compares them. */
|
|
242
|
+
| { readonly kind: "users"; readonly propertyId: string }
|
|
243
|
+
| { readonly kind: "union"; readonly items: readonly ObjectVisibilityKeys[] }
|
|
244
|
+
/** `keys`, when `when` matches. `when` never reads `currentUser()`. */
|
|
245
|
+
| {
|
|
246
|
+
readonly kind: "when"
|
|
247
|
+
readonly when: ObjectQueryPredicate
|
|
248
|
+
readonly keys: ObjectVisibilityKeys
|
|
249
|
+
}
|
|
250
|
+
|
|
208
251
|
/**
|
|
209
252
|
* Detached and deeply immutable conditions, one per concrete type, ordered by type id.
|
|
210
253
|
*
|
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
import { PipelineRunError } from "./errors"
|
|
15
15
|
import { canRequeuePipelineRunAfterEnqueueFailure } from "./idempotency"
|
|
16
16
|
import { assertPipelineRunExecution } from "./provider"
|
|
17
|
+
import { canFinishPipelineRun } from "./transitions"
|
|
17
18
|
import type {
|
|
18
19
|
FinishPipelineRunInput,
|
|
19
20
|
FinishPipelineStepRunInput,
|
|
@@ -152,11 +153,7 @@ export class InMemoryPipelineRunStorage implements PipelineRunStorage {
|
|
|
152
153
|
|
|
153
154
|
async finish(input: FinishPipelineRunInput): Promise<PipelineRunRecord> {
|
|
154
155
|
const existing = this.requireExistingPipelineRun(input.projectId, input.id)
|
|
155
|
-
|
|
156
|
-
if (
|
|
157
|
-
(enqueueFailure && existing.status !== "queued") ||
|
|
158
|
-
(!enqueueFailure && existing.status !== "running")
|
|
159
|
-
) {
|
|
156
|
+
if (!canFinishPipelineRun(existing.status, input)) {
|
|
160
157
|
throw new PipelineRunError(
|
|
161
158
|
`[Sixb] Pipeline run '${input.id}' cannot finish from status '${existing.status}'.`
|
|
162
159
|
)
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FinishPipelineRunInput, PipelineRunStatus } from "./types"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A run finishes from `running`. One that never started can only fail: its job could not be
|
|
5
|
+
* published (`queue.enqueue_failed`), or the job ended before starting it.
|
|
6
|
+
*/
|
|
7
|
+
export function canFinishPipelineRun(
|
|
8
|
+
status: PipelineRunStatus,
|
|
9
|
+
input: FinishPipelineRunInput
|
|
10
|
+
): boolean {
|
|
11
|
+
if (input.status !== "failed") return status === "running"
|
|
12
|
+
if (input.error.code === "queue.enqueue_failed") return status === "queued"
|
|
13
|
+
return status === "queued" || status === "running"
|
|
14
|
+
}
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
import { SyncRunError } from "./errors"
|
|
14
14
|
import { canRequeueSyncRunAfterEnqueueFailure } from "./idempotency"
|
|
15
15
|
import { assertSyncRunExecution } from "./provider"
|
|
16
|
+
import { canFinishSyncRun } from "./transitions"
|
|
16
17
|
import type {
|
|
17
18
|
FinishSyncRunInput,
|
|
18
19
|
ListLatestSyncRunsInput,
|
|
@@ -157,11 +158,7 @@ export class InMemorySyncRunStorage implements SyncRunStorage {
|
|
|
157
158
|
)
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
|
|
161
|
-
if (
|
|
162
|
-
(enqueueFailure && existing.status !== "queued") ||
|
|
163
|
-
(!enqueueFailure && existing.status !== "running")
|
|
164
|
-
) {
|
|
161
|
+
if (!canFinishSyncRun(existing.status, input)) {
|
|
165
162
|
throw new SyncRunError(
|
|
166
163
|
`[Sixb] Sync run '${input.id}' cannot finish from status '${existing.status}'.`
|
|
167
164
|
)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FinishSyncRunInput, SyncRunStatus } from "./types"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A run finishes from `running`. One that never started can only fail: its job could not be
|
|
5
|
+
* published (`queue.enqueue_failed`), or the job ended before starting it.
|
|
6
|
+
*/
|
|
7
|
+
export function canFinishSyncRun(status: SyncRunStatus, input: FinishSyncRunInput): boolean {
|
|
8
|
+
if (input.status !== "failed") return status === "running"
|
|
9
|
+
if (input.error.code === "queue.enqueue_failed") return status === "queued"
|
|
10
|
+
return status === "queued" || status === "running"
|
|
11
|
+
}
|
|
@@ -42,6 +42,8 @@ interface DispatchSyncRunInput extends SyncRunRequestOptions {
|
|
|
42
42
|
readonly metadata?: Readonly<Record<string, string>>
|
|
43
43
|
readonly createExecution: (executionId: string, runId: string) => Promise<CreateExecutionInput>
|
|
44
44
|
readonly validateExistingRun?: (run: SyncRunRecord, storage: Storage) => Promise<void>
|
|
45
|
+
/** Return a matching run of this Sync that has not started yet instead of queueing another one. */
|
|
46
|
+
readonly joinQueuedRun?: boolean
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
type PersistedSyncRun =
|
|
@@ -49,9 +51,10 @@ type PersistedSyncRun =
|
|
|
49
51
|
| {
|
|
50
52
|
readonly publish: true
|
|
51
53
|
readonly run: SyncRunRecord
|
|
52
|
-
readonly execution: CreateExecutionInput
|
|
53
54
|
readonly queuedAt: Date
|
|
54
55
|
readonly created: boolean
|
|
56
|
+
/** Defaults to the run id. A trigger that joins a run publishes its own job for it. */
|
|
57
|
+
readonly jobId?: string
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
/** Core-owned durable dispatch boundary used by automatic Sync triggers. */
|
|
@@ -75,6 +78,7 @@ export class SyncRunDispatcher implements SyncRunDispatchPort {
|
|
|
75
78
|
metadata: input.metadata,
|
|
76
79
|
validateExistingRun: (run, storage) =>
|
|
77
80
|
assertAutomaticExecutionIdentity(storage, this.dependencies.id, input, run),
|
|
81
|
+
joinQueuedRun: true,
|
|
78
82
|
createExecution: async (executionId, runId) =>
|
|
79
83
|
createPrimitiveExecutionRecord({
|
|
80
84
|
id: executionId,
|
|
@@ -122,6 +126,19 @@ async function persistSyncRun(
|
|
|
122
126
|
return { publish: false, run: raced }
|
|
123
127
|
}
|
|
124
128
|
|
|
129
|
+
if (input.joinQueuedRun) {
|
|
130
|
+
const waiting = await findQueuedSyncRun(transactionalRuns, input)
|
|
131
|
+
if (waiting) {
|
|
132
|
+
return {
|
|
133
|
+
publish: true,
|
|
134
|
+
run: waiting,
|
|
135
|
+
queuedAt: waiting.queuedAt,
|
|
136
|
+
created: false,
|
|
137
|
+
jobId: joinJobId(waiting, runId),
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
125
142
|
await tx.executions.create(execution)
|
|
126
143
|
const run = await transactionalRuns.queue({
|
|
127
144
|
projectId: input.projectId,
|
|
@@ -134,7 +151,7 @@ async function persistSyncRun(
|
|
|
134
151
|
expectedLatestVersionId: input.expectedLatestVersionId,
|
|
135
152
|
commitMessage: input.commitMessage,
|
|
136
153
|
})
|
|
137
|
-
return { publish: true, run,
|
|
154
|
+
return { publish: true, run, queuedAt, created: true }
|
|
138
155
|
},
|
|
139
156
|
{ isolation: "serializable" }
|
|
140
157
|
)
|
|
@@ -148,6 +165,35 @@ async function persistSyncRun(
|
|
|
148
165
|
}
|
|
149
166
|
}
|
|
150
167
|
|
|
168
|
+
/**
|
|
169
|
+
* A run that has not started reads its source when it starts, so it already covers a trigger that
|
|
170
|
+
* arrives now. The oldest one starts first; one queued with another request payload is not joined.
|
|
171
|
+
*/
|
|
172
|
+
async function findQueuedSyncRun(
|
|
173
|
+
syncRuns: NonNullable<Storage["syncRuns"]>,
|
|
174
|
+
input: DispatchSyncRunInput
|
|
175
|
+
): Promise<SyncRunRecord | undefined> {
|
|
176
|
+
const { runs } = await syncRuns.list({
|
|
177
|
+
projectId: input.projectId,
|
|
178
|
+
syncId: input.sync.id,
|
|
179
|
+
statuses: ["queued"],
|
|
180
|
+
order: "asc",
|
|
181
|
+
limit: 1,
|
|
182
|
+
})
|
|
183
|
+
const [waiting] = runs
|
|
184
|
+
return waiting && runMatchesRequest(waiting, input) ? waiting : undefined
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* The job a trigger publishes for the run it joins. The run's own job may be gone (a provider
|
|
189
|
+
* keeps a settled job id, and ignores a new job under it), so each joining trigger brings a job
|
|
190
|
+
* that can start the run; once it has started, the others complete without doing anything. The id
|
|
191
|
+
* derives from the trigger's run id, so a redelivered trigger publishes the same job.
|
|
192
|
+
*/
|
|
193
|
+
function joinJobId(waiting: SyncRunRecord, triggerRunId: string): string {
|
|
194
|
+
return `${waiting.id}:join:${triggerRunId}`
|
|
195
|
+
}
|
|
196
|
+
|
|
151
197
|
async function reuseSyncRun(
|
|
152
198
|
input: DispatchSyncRunInput,
|
|
153
199
|
existing: SyncRunRecord
|
|
@@ -161,7 +207,7 @@ async function reuseSyncRun(
|
|
|
161
207
|
})
|
|
162
208
|
if (!execution)
|
|
163
209
|
throw new SyncRunError(`[Sixb] Execution '${existing.executionId}' was not found.`)
|
|
164
|
-
return { publish: true, run: existing,
|
|
210
|
+
return { publish: true, run: existing, queuedAt: existing.queuedAt, created: false }
|
|
165
211
|
}
|
|
166
212
|
if (
|
|
167
213
|
existing.status !== "failed" ||
|
|
@@ -193,26 +239,28 @@ async function reuseSyncRun(
|
|
|
193
239
|
expectedLatestVersionId: existing.expectedLatestVersionId,
|
|
194
240
|
commitMessage: existing.commitMessage,
|
|
195
241
|
})
|
|
196
|
-
return { publish: true, run,
|
|
242
|
+
return { publish: true, run, queuedAt, created: false }
|
|
197
243
|
}
|
|
198
244
|
|
|
199
245
|
async function publishSyncRun(
|
|
200
246
|
input: DispatchSyncRunInput,
|
|
201
247
|
persisted: Extract<PersistedSyncRun, { readonly publish: true }>
|
|
202
248
|
): Promise<SyncRunRequestResult> {
|
|
249
|
+
const jobId = persisted.jobId ?? persisted.run.id
|
|
250
|
+
|
|
203
251
|
try {
|
|
204
252
|
const [job] = await input.queue.enqueue({
|
|
205
253
|
projectId: input.projectId,
|
|
206
254
|
jobs: [
|
|
207
255
|
{
|
|
208
|
-
id:
|
|
256
|
+
id: jobId,
|
|
209
257
|
type: "sync.run.requested",
|
|
210
258
|
payload: { runId: persisted.run.id },
|
|
211
259
|
...(input.metadata === undefined ? {} : { metadata: input.metadata }),
|
|
212
260
|
},
|
|
213
261
|
],
|
|
214
262
|
})
|
|
215
|
-
if (!job || job.id !==
|
|
263
|
+
if (!job || job.id !== jobId) {
|
|
216
264
|
throw new SyncRunError(`[Sixb] Queue did not acknowledge Sync run '${persisted.run.id}'.`)
|
|
217
265
|
}
|
|
218
266
|
return {
|
|
@@ -249,19 +297,26 @@ function assertExistingRunMatchesRequest(
|
|
|
249
297
|
existing: SyncRunRecord,
|
|
250
298
|
input: Pick<DispatchSyncRunInput, "sync" | "expectedLatestVersionId" | "commitMessage">
|
|
251
299
|
): void {
|
|
252
|
-
if (
|
|
253
|
-
existing.syncId !== input.sync.id ||
|
|
254
|
-
existing.datasetId !== input.sync.target.dataset.id ||
|
|
255
|
-
existing.mode !== input.sync.config.mode ||
|
|
256
|
-
existing.expectedLatestVersionId !== input.expectedLatestVersionId ||
|
|
257
|
-
existing.commitMessage !== input.commitMessage
|
|
258
|
-
) {
|
|
300
|
+
if (!runMatchesRequest(existing, input)) {
|
|
259
301
|
throw new SyncRunError(
|
|
260
302
|
`[Sixb] Sync run '${existing.id}' already exists with a different request payload.`
|
|
261
303
|
)
|
|
262
304
|
}
|
|
263
305
|
}
|
|
264
306
|
|
|
307
|
+
function runMatchesRequest(
|
|
308
|
+
existing: SyncRunRecord,
|
|
309
|
+
input: Pick<DispatchSyncRunInput, "sync" | "expectedLatestVersionId" | "commitMessage">
|
|
310
|
+
): boolean {
|
|
311
|
+
return (
|
|
312
|
+
existing.syncId === input.sync.id &&
|
|
313
|
+
existing.datasetId === input.sync.target.dataset.id &&
|
|
314
|
+
existing.mode === input.sync.config.mode &&
|
|
315
|
+
existing.expectedLatestVersionId === input.expectedLatestVersionId &&
|
|
316
|
+
existing.commitMessage === input.commitMessage
|
|
317
|
+
)
|
|
318
|
+
}
|
|
319
|
+
|
|
265
320
|
function existingSyncRunResult(existing: SyncRunRecord): SyncRunRequestResult {
|
|
266
321
|
return {
|
|
267
322
|
syncId: existing.syncId,
|
|
@@ -1159,6 +1159,76 @@ export function runAgentStorageContractSuite<TStorage extends AgentStorageContra
|
|
|
1159
1159
|
})
|
|
1160
1160
|
})
|
|
1161
1161
|
|
|
1162
|
+
// Removal proofs: have a renewal write no stop requests (those asked are lost); drop the check
|
|
1163
|
+
// that a request is not kept yet (a second click lists it twice).
|
|
1164
|
+
test("keeps what an open sixb reports of its background commands, and the stops asked", async () => {
|
|
1165
|
+
await withStorage(async (storage) => {
|
|
1166
|
+
const live = at("2026-06-23T12:01:00.000Z")
|
|
1167
|
+
const session = (overrides: Partial<AgentComputerSessionRecord> = {}) => ({
|
|
1168
|
+
projectId,
|
|
1169
|
+
id: "s_1",
|
|
1170
|
+
ownerPrincipal: owner,
|
|
1171
|
+
computer: laptop,
|
|
1172
|
+
expiresAt: live,
|
|
1173
|
+
...overrides,
|
|
1174
|
+
})
|
|
1175
|
+
const running = {
|
|
1176
|
+
threadId: "thr_1",
|
|
1177
|
+
id: "bg_1",
|
|
1178
|
+
command: "bun dev",
|
|
1179
|
+
status: "running" as const,
|
|
1180
|
+
startedAt: "2026-06-23T11:59:00.000Z",
|
|
1181
|
+
}
|
|
1182
|
+
const ref = { threadId: "thr_1", id: "bg_1", startedAt: running.startedAt }
|
|
1183
|
+
const stop = (command = ref, ownerPrincipal: Principal = owner) =>
|
|
1184
|
+
storage.computers.requestStop({ projectId, id: "s_1", ownerPrincipal, command })
|
|
1185
|
+
|
|
1186
|
+
await storage.computers.hold(session({ backgroundCommands: [running] }))
|
|
1187
|
+
await expect(stop()).resolves.toEqual(
|
|
1188
|
+
session({ backgroundCommands: [running], stopRequests: [ref] })
|
|
1189
|
+
)
|
|
1190
|
+
await expect(stop()).resolves.toEqual(
|
|
1191
|
+
session({ backgroundCommands: [running], stopRequests: [ref] })
|
|
1192
|
+
)
|
|
1193
|
+
await expect(stop(ref, otherUser)).resolves.toBeNull()
|
|
1194
|
+
|
|
1195
|
+
// A renewal reports the commands anew, and keeps what was asked of them.
|
|
1196
|
+
const stopped = {
|
|
1197
|
+
...running,
|
|
1198
|
+
status: "stopped" as const,
|
|
1199
|
+
exitCode: 143,
|
|
1200
|
+
endedAt: "2026-06-23T12:00:30.000Z",
|
|
1201
|
+
}
|
|
1202
|
+
await storage.computers.hold(session({ backgroundCommands: [stopped] }))
|
|
1203
|
+
await expect(
|
|
1204
|
+
storage.computers.listLive({
|
|
1205
|
+
projectId,
|
|
1206
|
+
ownerPrincipal: owner,
|
|
1207
|
+
now: at(running.startedAt),
|
|
1208
|
+
})
|
|
1209
|
+
).resolves.toEqual([session({ backgroundCommands: [stopped], stopRequests: [ref] })])
|
|
1210
|
+
|
|
1211
|
+
// The newest requests are kept.
|
|
1212
|
+
for (let index = 2; index <= 65; index += 1) await stop({ ...ref, id: `bg_${index}` })
|
|
1213
|
+
const [kept] = await storage.computers.listLive({
|
|
1214
|
+
projectId,
|
|
1215
|
+
ownerPrincipal: owner,
|
|
1216
|
+
now: at(running.startedAt),
|
|
1217
|
+
})
|
|
1218
|
+
expect(kept?.stopRequests?.length).toBe(64)
|
|
1219
|
+
expect(kept?.stopRequests?.[0]?.id).toBe("bg_2")
|
|
1220
|
+
expect(kept?.stopRequests?.at(-1)?.id).toBe("bg_65")
|
|
1221
|
+
|
|
1222
|
+
await expectAgentError(stop({ ...ref, id: "" }), "invalid_input")
|
|
1223
|
+
await expectAgentError(
|
|
1224
|
+
storage.computers.hold(
|
|
1225
|
+
session({ backgroundCommands: [{ ...running, status: "lost" as "running" }] })
|
|
1226
|
+
),
|
|
1227
|
+
"invalid_input"
|
|
1228
|
+
)
|
|
1229
|
+
})
|
|
1230
|
+
})
|
|
1231
|
+
|
|
1162
1232
|
test("reads several threads at once, in the order asked", async () => {
|
|
1163
1233
|
await withStorage(async (storage) => {
|
|
1164
1234
|
const first = await storage.threads.create(threadInput())
|
|
@@ -570,7 +570,7 @@ export function runAiLimitStorageContractSuite<TStorage extends AiLimitStorageCo
|
|
|
570
570
|
meter: "cost.catalogEstimated",
|
|
571
571
|
amount: { currency: "USD", amountNanos: "100" },
|
|
572
572
|
}
|
|
573
|
-
for (const modelKind of ["reranking", "image", "speech"] as const) {
|
|
573
|
+
for (const modelKind of ["reranking", "web-search", "image", "speech"] as const) {
|
|
574
574
|
await expect(
|
|
575
575
|
storage.aiLimits.reserveModelCall(
|
|
576
576
|
reservation(modelKind, 0, { estimates: [cost], modelKind })
|
|
@@ -591,6 +591,16 @@ export function runAiLimitStorageContractSuite<TStorage extends AiLimitStorageCo
|
|
|
591
591
|
projectId,
|
|
592
592
|
usageRecordId: "usage-reranking",
|
|
593
593
|
})
|
|
594
|
+
await recordUsageInput(storage.aiUsage, {
|
|
595
|
+
id: "usage-web-search",
|
|
596
|
+
callId: "web-search",
|
|
597
|
+
modelKind: "web-search",
|
|
598
|
+
usage: {},
|
|
599
|
+
})
|
|
600
|
+
await storage.aiLimits.recordModelCallActuals({
|
|
601
|
+
projectId,
|
|
602
|
+
usageRecordId: "usage-web-search",
|
|
603
|
+
})
|
|
594
604
|
expect(await status()).toMatchObject({
|
|
595
605
|
accountingStatus: "complete",
|
|
596
606
|
consumption: { actual: { amount: 4 } },
|
|
@@ -71,8 +71,9 @@ export function runAiUsageStorageContractSuite<TStorage extends AiUsageStorage>(
|
|
|
71
71
|
|
|
72
72
|
describe(label, () => {
|
|
73
73
|
// Removal proof: omit audioDurationMs from a row codec; this round trip fails.
|
|
74
|
-
// Removal proof: omit 'reranking' from a storage migration's model_kind check;
|
|
75
|
-
|
|
74
|
+
// Removal proof: omit 'reranking' or 'web-search' from a storage migration's model_kind check;
|
|
75
|
+
// the write fails.
|
|
76
|
+
test("persists transcription, reranking and web search usage kinds without invented token totals", async () => {
|
|
76
77
|
await withStorage(async (storage) => {
|
|
77
78
|
const latest = () =>
|
|
78
79
|
storage.getLatestForExecution({ projectId, executionId: agentExecutionId })
|
|
@@ -102,6 +103,18 @@ export function runAiUsageStorageContractSuite<TStorage extends AiUsageStorage>(
|
|
|
102
103
|
})
|
|
103
104
|
)
|
|
104
105
|
expect((await latest())?.modelKind).toBe("reranking")
|
|
106
|
+
|
|
107
|
+
await storage.recordModelCall(
|
|
108
|
+
modelCallInput({
|
|
109
|
+
id: "usage_web_search",
|
|
110
|
+
callId: "call_web_search",
|
|
111
|
+
responseId: "response_web_search",
|
|
112
|
+
modelKind: "web-search",
|
|
113
|
+
usage: {},
|
|
114
|
+
occurredAt: at("2026-06-23T10:02:00.000Z"),
|
|
115
|
+
})
|
|
116
|
+
)
|
|
117
|
+
expect((await latest())?.modelKind).toBe("web-search")
|
|
105
118
|
})
|
|
106
119
|
})
|
|
107
120
|
// Removal proof: omit a media count from a row codec, or 'speech' from a storage migration's
|
|
@@ -454,6 +454,29 @@ export function runConnectorConnectionStorageContractSuite<
|
|
|
454
454
|
})
|
|
455
455
|
})
|
|
456
456
|
|
|
457
|
+
test("connects another account to a disconnected slot without replacement", async () => {
|
|
458
|
+
await withStorage(async (storage) => {
|
|
459
|
+
const first = await createAuthorization(storage, "authorization-a", "account-a")
|
|
460
|
+
const connected = await connect(storage, first, "connection-a", "account-a")
|
|
461
|
+
await storage.disconnectConnection({
|
|
462
|
+
projectId,
|
|
463
|
+
connectorId,
|
|
464
|
+
connectionId: connected.connection.id,
|
|
465
|
+
})
|
|
466
|
+
|
|
467
|
+
const second = await createAuthorization(storage, "authorization-b", "account-b")
|
|
468
|
+
const reconnected = await connect(storage, second, "ignored-new-id", "account-b")
|
|
469
|
+
|
|
470
|
+
expect(reconnected.connection).toMatchObject({
|
|
471
|
+
id: connected.connection.id,
|
|
472
|
+
authorizationId: second.id,
|
|
473
|
+
account: { id: "account-b" },
|
|
474
|
+
status: "connected",
|
|
475
|
+
})
|
|
476
|
+
expect(reconnected.replaced).toBe(false)
|
|
477
|
+
})
|
|
478
|
+
})
|
|
479
|
+
|
|
457
480
|
test("keeps pending selection untouched when connection validation fails", async () => {
|
|
458
481
|
await withStorage(async (storage) => {
|
|
459
482
|
const active = await createAuthorization(storage, "authorization-a", "account-a")
|