@stigmer/server 3.24.0 → 3.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authorization/authorizer.d.ts +10 -4
- package/dist/authorization/authorizer.d.ts.map +1 -1
- package/dist/authorization/authorizer.js +11 -4
- package/dist/authorization/authorizer.js.map +1 -1
- package/dist/authorization/model/index.d.ts +4 -4
- package/dist/authorization/model/index.d.ts.map +1 -1
- package/dist/authorization/model/index.js +2 -0
- package/dist/authorization/model/index.js.map +1 -1
- package/dist/authorization/model/oauth_app.d.ts.map +1 -1
- package/dist/authorization/model/oauth_app.js +3 -2
- package/dist/authorization/model/oauth_app.js.map +1 -1
- package/dist/authorization/model/platform_client.d.ts +2 -0
- package/dist/authorization/model/platform_client.d.ts.map +1 -0
- package/dist/authorization/model/platform_client.js +31 -0
- package/dist/authorization/model/platform_client.js.map +1 -0
- package/dist/boot/compose.d.ts.map +1 -1
- package/dist/boot/compose.js +99 -13
- package/dist/boot/compose.js.map +1 -1
- package/dist/boot/list-indexes.d.ts +3 -0
- package/dist/boot/list-indexes.d.ts.map +1 -0
- package/dist/boot/list-indexes.js +24 -0
- package/dist/boot/list-indexes.js.map +1 -0
- package/dist/boot/route-shadowing.d.ts +25 -0
- package/dist/boot/route-shadowing.d.ts.map +1 -0
- package/dist/boot/route-shadowing.js +17 -0
- package/dist/boot/route-shadowing.js.map +1 -0
- package/dist/domain/agentexecution/controller.d.ts.map +1 -1
- package/dist/domain/agentexecution/controller.js +6 -8
- package/dist/domain/agentexecution/controller.js.map +1 -1
- package/dist/domain/agentexecution/list-index.d.ts +2 -0
- package/dist/domain/agentexecution/list-index.d.ts.map +1 -0
- package/dist/domain/agentexecution/list-index.js +23 -0
- package/dist/domain/agentexecution/list-index.js.map +1 -0
- package/dist/domain/agentexecution/steps.d.ts +17 -33
- package/dist/domain/agentexecution/steps.d.ts.map +1 -1
- package/dist/domain/agentexecution/steps.js +94 -95
- package/dist/domain/agentexecution/steps.js.map +1 -1
- package/dist/domain/agentexecution/usage.d.ts.map +1 -1
- package/dist/domain/agentexecution/usage.js +37 -14
- package/dist/domain/agentexecution/usage.js.map +1 -1
- package/dist/domain/artifact/controller.d.ts.map +1 -1
- package/dist/domain/artifact/controller.js +27 -15
- package/dist/domain/artifact/controller.js.map +1 -1
- package/dist/domain/artifact/list-index.d.ts +2 -0
- package/dist/domain/artifact/list-index.d.ts.map +1 -0
- package/dist/domain/artifact/list-index.js +21 -0
- package/dist/domain/artifact/list-index.js.map +1 -0
- package/dist/domain/iampolicy/membership.d.ts +6 -1
- package/dist/domain/iampolicy/membership.d.ts.map +1 -1
- package/dist/domain/iampolicy/membership.js +8 -2
- package/dist/domain/iampolicy/membership.js.map +1 -1
- package/dist/domain/identityaccount/constants.d.ts +13 -0
- package/dist/domain/identityaccount/constants.d.ts.map +1 -1
- package/dist/domain/identityaccount/constants.js +17 -0
- package/dist/domain/identityaccount/constants.js.map +1 -1
- package/dist/domain/identityaccount/controller.d.ts +3 -1
- package/dist/domain/identityaccount/controller.d.ts.map +1 -1
- package/dist/domain/identityaccount/controller.js +15 -6
- package/dist/domain/identityaccount/controller.js.map +1 -1
- package/dist/domain/identityaccount/operator.d.ts.map +1 -1
- package/dist/domain/identityaccount/operator.js +1 -0
- package/dist/domain/identityaccount/operator.js.map +1 -1
- package/dist/domain/identityaccount/provisioning.d.ts +18 -0
- package/dist/domain/identityaccount/provisioning.d.ts.map +1 -1
- package/dist/domain/identityaccount/provisioning.js +1 -0
- package/dist/domain/identityaccount/provisioning.js.map +1 -1
- package/dist/domain/identityaccount/resource-store.js +9 -5
- package/dist/domain/identityaccount/resource-store.js.map +1 -1
- package/dist/domain/identityaccount/steps.d.ts +11 -2
- package/dist/domain/identityaccount/steps.d.ts.map +1 -1
- package/dist/domain/identityaccount/steps.js +42 -4
- package/dist/domain/identityaccount/steps.js.map +1 -1
- package/dist/domain/identityaccount/store-contract.d.ts.map +1 -1
- package/dist/domain/identityaccount/store-contract.js +33 -0
- package/dist/domain/identityaccount/store-contract.js.map +1 -1
- package/dist/domain/identityaccount/store.d.ts +7 -5
- package/dist/domain/identityaccount/store.d.ts.map +1 -1
- package/dist/domain/identityaccount/store.js.map +1 -1
- package/dist/domain/platform/controller.d.ts +10 -0
- package/dist/domain/platform/controller.d.ts.map +1 -1
- package/dist/domain/platform/controller.js +2 -1
- package/dist/domain/platform/controller.js.map +1 -1
- package/dist/domain/platformclient/constants.d.ts +60 -0
- package/dist/domain/platformclient/constants.d.ts.map +1 -0
- package/dist/domain/platformclient/constants.js +78 -0
- package/dist/domain/platformclient/constants.js.map +1 -0
- package/dist/domain/platformclient/controller.d.ts +59 -0
- package/dist/domain/platformclient/controller.d.ts.map +1 -0
- package/dist/domain/platformclient/controller.js +191 -0
- package/dist/domain/platformclient/controller.js.map +1 -0
- package/dist/domain/platformclient/credentials.d.ts +13 -0
- package/dist/domain/platformclient/credentials.d.ts.map +1 -0
- package/dist/domain/platformclient/credentials.js +56 -0
- package/dist/domain/platformclient/credentials.js.map +1 -0
- package/dist/domain/platformclient/mint.d.ts +23 -0
- package/dist/domain/platformclient/mint.d.ts.map +1 -0
- package/dist/domain/platformclient/mint.js +254 -0
- package/dist/domain/platformclient/mint.js.map +1 -0
- package/dist/domain/platformclient/origin-guard.d.ts +9 -0
- package/dist/domain/platformclient/origin-guard.d.ts.map +1 -0
- package/dist/domain/platformclient/origin-guard.js +81 -0
- package/dist/domain/platformclient/origin-guard.js.map +1 -0
- package/dist/domain/platformclient/resource-store.d.ts +4 -0
- package/dist/domain/platformclient/resource-store.d.ts.map +1 -0
- package/dist/domain/platformclient/resource-store.js +117 -0
- package/dist/domain/platformclient/resource-store.js.map +1 -0
- package/dist/domain/platformclient/steps.d.ts +51 -0
- package/dist/domain/platformclient/steps.d.ts.map +1 -0
- package/dist/domain/platformclient/steps.js +339 -0
- package/dist/domain/platformclient/steps.js.map +1 -0
- package/dist/domain/platformclient/store-contract.d.ts +8 -0
- package/dist/domain/platformclient/store-contract.d.ts.map +1 -0
- package/dist/domain/platformclient/store-contract.js +208 -0
- package/dist/domain/platformclient/store-contract.js.map +1 -0
- package/dist/domain/platformclient/store.d.ts +58 -0
- package/dist/domain/platformclient/store.d.ts.map +1 -0
- package/dist/domain/platformclient/store.js +13 -0
- package/dist/domain/platformclient/store.js.map +1 -0
- package/dist/domain/platformclient/system-managed.d.ts +18 -0
- package/dist/domain/platformclient/system-managed.d.ts.map +1 -0
- package/dist/domain/platformclient/system-managed.js +80 -0
- package/dist/domain/platformclient/system-managed.js.map +1 -0
- package/dist/domain/platformclient/token-controller.d.ts +11 -0
- package/dist/domain/platformclient/token-controller.d.ts.map +1 -0
- package/dist/domain/platformclient/token-controller.js +32 -0
- package/dist/domain/platformclient/token-controller.js.map +1 -0
- package/dist/domain/platformclient/verifier.d.ts +10 -0
- package/dist/domain/platformclient/verifier.d.ts.map +1 -0
- package/dist/domain/platformclient/verifier.js +76 -0
- package/dist/domain/platformclient/verifier.js.map +1 -0
- package/dist/domain/session/list-index.d.ts +4 -0
- package/dist/domain/session/list-index.d.ts.map +1 -0
- package/dist/domain/session/list-index.js +26 -0
- package/dist/domain/session/list-index.js.map +1 -0
- package/dist/domain/session/steps.d.ts +7 -8
- package/dist/domain/session/steps.d.ts.map +1 -1
- package/dist/domain/session/steps.js +76 -78
- package/dist/domain/session/steps.js.map +1 -1
- package/dist/domain/workflowexecution/controller.d.ts.map +1 -1
- package/dist/domain/workflowexecution/controller.js +53 -55
- package/dist/domain/workflowexecution/controller.js.map +1 -1
- package/dist/domain/workflowexecution/execution-filter.d.ts +4 -0
- package/dist/domain/workflowexecution/execution-filter.d.ts.map +1 -1
- package/dist/domain/workflowexecution/execution-filter.js +11 -5
- package/dist/domain/workflowexecution/execution-filter.js.map +1 -1
- package/dist/domain/workflowexecution/get-execution-summary.d.ts.map +1 -1
- package/dist/domain/workflowexecution/get-execution-summary.js +23 -17
- package/dist/domain/workflowexecution/get-execution-summary.js.map +1 -1
- package/dist/domain/workflowexecution/list-index.d.ts +2 -0
- package/dist/domain/workflowexecution/list-index.d.ts.map +1 -0
- package/dist/domain/workflowexecution/list-index.js +21 -0
- package/dist/domain/workflowexecution/list-index.js.map +1 -0
- package/dist/domain/workflowexecution/list-pending-approvals.d.ts.map +1 -1
- package/dist/domain/workflowexecution/list-pending-approvals.js +69 -32
- package/dist/domain/workflowexecution/list-pending-approvals.js.map +1 -1
- package/dist/domain/workflowexecution/queries.d.ts +30 -4
- package/dist/domain/workflowexecution/queries.d.ts.map +1 -1
- package/dist/domain/workflowexecution/queries.js +76 -22
- package/dist/domain/workflowexecution/queries.js.map +1 -1
- package/dist/encryption/key-manager.d.ts +20 -3
- package/dist/encryption/key-manager.d.ts.map +1 -1
- package/dist/encryption/key-manager.js +64 -42
- package/dist/encryption/key-manager.js.map +1 -1
- package/dist/extensions/caller-guards.d.ts +8 -3
- package/dist/extensions/caller-guards.d.ts.map +1 -1
- package/dist/extensions/drivers.d.ts +37 -0
- package/dist/extensions/drivers.d.ts.map +1 -1
- package/dist/extensions/guest-token-minting.d.ts +26 -0
- package/dist/extensions/guest-token-minting.d.ts.map +1 -0
- package/dist/extensions/guest-token-minting.js +2 -0
- package/dist/extensions/guest-token-minting.js.map +1 -0
- package/dist/extensions/identity.d.ts +6 -4
- package/dist/extensions/identity.d.ts.map +1 -1
- package/dist/extensions/identity.js.map +1 -1
- package/dist/extensions/list-read-scope.d.ts +9 -12
- package/dist/extensions/list-read-scope.d.ts.map +1 -1
- package/dist/extensions/list-read-scope.js.map +1 -1
- package/dist/extensions/registry.d.ts +30 -1
- package/dist/extensions/registry.d.ts.map +1 -1
- package/dist/extensions/registry.js +34 -1
- package/dist/extensions/registry.js.map +1 -1
- package/dist/index.d.ts +15 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/pipeline/interceptors/auth.d.ts +14 -0
- package/dist/pipeline/interceptors/auth.d.ts.map +1 -1
- package/dist/pipeline/interceptors/auth.js +24 -0
- package/dist/pipeline/interceptors/auth.js.map +1 -1
- package/dist/pipeline/steps/build-update-state.d.ts +11 -1
- package/dist/pipeline/steps/build-update-state.d.ts.map +1 -1
- package/dist/pipeline/steps/build-update-state.js +5 -2
- package/dist/pipeline/steps/build-update-state.js.map +1 -1
- package/dist/pipeline/steps/list-page.d.ts +63 -0
- package/dist/pipeline/steps/list-page.d.ts.map +1 -0
- package/dist/pipeline/steps/list-page.js +187 -0
- package/dist/pipeline/steps/list-page.js.map +1 -0
- package/dist/platformtoken/envelope.d.ts +100 -0
- package/dist/platformtoken/envelope.d.ts.map +1 -0
- package/dist/platformtoken/envelope.js +184 -0
- package/dist/platformtoken/envelope.js.map +1 -0
- package/dist/platformtoken/key-ring.d.ts +85 -0
- package/dist/platformtoken/key-ring.d.ts.map +1 -0
- package/dist/platformtoken/key-ring.js +164 -0
- package/dist/platformtoken/key-ring.js.map +1 -0
- package/dist/query/activity/handler.d.ts +6 -7
- package/dist/query/activity/handler.d.ts.map +1 -1
- package/dist/query/activity/handler.js +42 -59
- package/dist/query/activity/handler.js.map +1 -1
- package/dist/store/interface.d.ts +29 -0
- package/dist/store/interface.d.ts.map +1 -1
- package/dist/store/interface.js.map +1 -1
- package/dist/store/list-index.d.ts +123 -0
- package/dist/store/list-index.d.ts.map +1 -0
- package/dist/store/list-index.js +277 -0
- package/dist/store/list-index.js.map +1 -0
- package/dist/store/logger.d.ts +3 -0
- package/dist/store/logger.d.ts.map +1 -1
- package/dist/store/logger.js +5 -1
- package/dist/store/logger.js.map +1 -1
- package/dist/store/postgres/migrations.d.ts +10 -6
- package/dist/store/postgres/migrations.d.ts.map +1 -1
- package/dist/store/postgres/migrations.js +64 -6
- package/dist/store/postgres/migrations.js.map +1 -1
- package/dist/store/postgres/store.d.ts +26 -5
- package/dist/store/postgres/store.d.ts.map +1 -1
- package/dist/store/postgres/store.js +377 -22
- package/dist/store/postgres/store.js.map +1 -1
- package/dist/store/sqlite/migrations.d.ts +11 -5
- package/dist/store/sqlite/migrations.d.ts.map +1 -1
- package/dist/store/sqlite/migrations.js +50 -4
- package/dist/store/sqlite/migrations.js.map +1 -1
- package/dist/store/sqlite/store.d.ts +18 -3
- package/dist/store/sqlite/store.d.ts.map +1 -1
- package/dist/store/sqlite/store.js +321 -15
- package/dist/store/sqlite/store.js.map +1 -1
- package/package.json +6 -6
- package/src/authorization/README.md +1 -1
- package/src/authorization/__tests__/authorizer.test.ts +6 -2
- package/src/authorization/__tests__/drivers.ts +6 -1
- package/src/authorization/__tests__/wire-permissions.test.ts +1 -0
- package/src/authorization/authorizer.ts +11 -4
- package/src/authorization/model/__tests__/registry.test.ts +8 -1
- package/src/authorization/model/index.ts +6 -4
- package/src/authorization/model/oauth_app.ts +3 -2
- package/src/authorization/model/platform_client.ts +43 -0
- package/src/boot/__tests__/auth-enabled-composition.test.ts +2 -1
- package/src/boot/__tests__/list-indexes.test.ts +65 -0
- package/src/boot/__tests__/route-shadowing.test.ts +67 -0
- package/src/boot/compose.ts +113 -18
- package/src/boot/list-indexes.ts +25 -0
- package/src/boot/route-shadowing.ts +47 -0
- package/src/domain/agentexecution/__tests__/agentexecution.test.ts +85 -3
- package/src/domain/agentexecution/controller.ts +8 -10
- package/src/domain/agentexecution/list-index.ts +24 -0
- package/src/domain/agentexecution/steps.ts +118 -115
- package/src/domain/agentexecution/usage.ts +38 -17
- package/src/domain/artifact/controller.ts +28 -18
- package/src/domain/artifact/list-index.ts +22 -0
- package/src/domain/iampolicy/__tests__/membership.test.ts +7 -0
- package/src/domain/iampolicy/membership.ts +8 -2
- package/src/domain/identityaccount/__tests__/platform-client-accounts.test.ts +124 -0
- package/src/domain/identityaccount/__tests__/resource-store.test.ts +1 -0
- package/src/domain/identityaccount/constants.ts +20 -0
- package/src/domain/identityaccount/controller.ts +16 -4
- package/src/domain/identityaccount/operator.ts +1 -0
- package/src/domain/identityaccount/provisioning.ts +17 -0
- package/src/domain/identityaccount/resource-store.ts +9 -5
- package/src/domain/identityaccount/steps.ts +58 -3
- package/src/domain/identityaccount/store-contract.ts +51 -0
- package/src/domain/identityaccount/store.ts +7 -5
- package/src/domain/platform/__tests__/platform.test.ts +7 -1
- package/src/domain/platform/controller.ts +12 -1
- package/src/domain/platformclient/__tests__/controller.test.ts +397 -0
- package/src/domain/platformclient/__tests__/credentials.test.ts +46 -0
- package/src/domain/platformclient/__tests__/mint.test.ts +415 -0
- package/src/domain/platformclient/__tests__/resource-store.test.ts +140 -0
- package/src/domain/platformclient/__tests__/system-managed.test.ts +101 -0
- package/src/domain/platformclient/__tests__/verifier-and-guard.test.ts +207 -0
- package/src/domain/platformclient/constants.ts +120 -0
- package/src/domain/platformclient/controller.ts +449 -0
- package/src/domain/platformclient/credentials.ts +68 -0
- package/src/domain/platformclient/mint.ts +412 -0
- package/src/domain/platformclient/origin-guard.ts +117 -0
- package/src/domain/platformclient/resource-store.ts +150 -0
- package/src/domain/platformclient/steps.ts +472 -0
- package/src/domain/platformclient/store-contract.ts +318 -0
- package/src/domain/platformclient/store.ts +63 -0
- package/src/domain/platformclient/system-managed.ts +115 -0
- package/src/domain/platformclient/token-controller.ts +49 -0
- package/src/domain/platformclient/verifier.ts +106 -0
- package/src/domain/session/list-index.ts +28 -0
- package/src/domain/session/steps.ts +108 -123
- package/src/domain/workflowexecution/__tests__/list-read-scope-summaries.test.ts +155 -99
- package/src/domain/workflowexecution/__tests__/workflowexecution.test.ts +193 -31
- package/src/domain/workflowexecution/controller.ts +54 -82
- package/src/domain/workflowexecution/execution-filter.ts +20 -7
- package/src/domain/workflowexecution/get-execution-summary.ts +31 -24
- package/src/domain/workflowexecution/list-index.ts +22 -0
- package/src/domain/workflowexecution/list-pending-approvals.ts +82 -25
- package/src/domain/workflowexecution/queries.ts +134 -23
- package/src/encryption/key-manager.ts +87 -44
- package/src/extensions/__tests__/extension-composition.test.ts +3 -2
- package/src/extensions/__tests__/platform-client-composed.test.ts +288 -0
- package/src/extensions/__tests__/registry.test.ts +4 -1
- package/src/extensions/__tests__/tier-truthfulness.test.ts +8 -0
- package/src/extensions/caller-guards.ts +8 -3
- package/src/extensions/drivers.ts +37 -0
- package/src/extensions/guest-token-minting.ts +32 -0
- package/src/extensions/identity.ts +6 -4
- package/src/extensions/list-read-scope.ts +9 -12
- package/src/extensions/registry.ts +77 -3
- package/src/index.ts +65 -1
- package/src/pipeline/interceptors/auth.ts +27 -0
- package/src/pipeline/steps/__tests__/list-page.test.ts +186 -0
- package/src/pipeline/steps/__tests__/references.test.ts +2 -0
- package/src/pipeline/steps/build-update-state.ts +5 -2
- package/src/pipeline/steps/list-page.ts +284 -0
- package/src/platformtoken/__tests__/envelope.test.ts +277 -0
- package/src/platformtoken/__tests__/key-ring.test.ts +205 -0
- package/src/platformtoken/envelope.ts +276 -0
- package/src/platformtoken/key-ring.ts +266 -0
- package/src/query/activity/handler.ts +57 -78
- package/src/runnerauth/__tests__/runner-subject-composed.test.ts +9 -3
- package/src/store/README.md +51 -32
- package/src/store/__tests__/list-index.measure.test.ts +293 -0
- package/src/store/__tests__/list-index.test.ts +328 -0
- package/src/store/__tests__/store-contract.ts +346 -3
- package/src/store/interface.ts +39 -0
- package/src/store/list-index.ts +465 -0
- package/src/store/logger.ts +8 -1
- package/src/store/postgres/__tests__/list-index-repair.test.ts +133 -0
- package/src/store/postgres/__tests__/migrations.test.ts +27 -19
- package/src/store/postgres/__tests__/store-contract.test.ts +50 -3
- package/src/store/postgres/migrations.ts +69 -7
- package/src/store/postgres/store.ts +485 -29
- package/src/store/sqlite/__tests__/migrations.test.ts +51 -7
- package/src/store/sqlite/__tests__/store-contract.test.ts +70 -16
- package/src/store/sqlite/__tests__/support.ts +12 -3
- package/src/store/sqlite/migrations.ts +57 -6
- package/src/store/sqlite/store.ts +462 -21
|
@@ -9,7 +9,9 @@
|
|
|
9
9
|
* (< 6) runs nothing. v10, the chain's first row-decoding step, moves
|
|
10
10
|
* every row of the seven kinds that held the retired public level to org
|
|
11
11
|
* and leaves every other row's bytes as they were; a row it cannot decode
|
|
12
|
-
* fails the step and leaves the database at v9.
|
|
12
|
+
* fails the step and leaves the database at v9. v11 adds the list index's
|
|
13
|
+
* schema only, and a Go-written row of a declared kind is derived by the
|
|
14
|
+
* store's reconciliation at open and read through the index.
|
|
13
15
|
*/
|
|
14
16
|
import { mkdtempSync, rmSync } from "node:fs";
|
|
15
17
|
import { tmpdir } from "node:os";
|
|
@@ -22,8 +24,13 @@ import { create, fromBinary, fromJson, toBinary } from "@bufbuild/protobuf";
|
|
|
22
24
|
import type { DescMessage } from "@bufbuild/protobuf";
|
|
23
25
|
|
|
24
26
|
import { AgentSchema } from "@stigmer/protos/ai/stigmer/agentic/agent/v1/api_pb";
|
|
27
|
+
import { SessionSchema } from "@stigmer/protos/ai/stigmer/agentic/session/v1/api_pb";
|
|
25
28
|
import { ApiResourceVisibility } from "@stigmer/protos/ai/stigmer/commons/apiresource/enum_pb";
|
|
26
29
|
|
|
30
|
+
import {
|
|
31
|
+
CONTRACT_SESSION_INDEX,
|
|
32
|
+
CONTRACT_STORE_OPTIONS,
|
|
33
|
+
} from "../../__tests__/store-contract.js";
|
|
27
34
|
import { SqliteStore } from "../store.js";
|
|
28
35
|
import {
|
|
29
36
|
CURRENT_SCHEMA_VERSION,
|
|
@@ -93,7 +100,7 @@ describe("fresh database", () => {
|
|
|
93
100
|
.prepare(`SELECT version FROM schema_version ORDER BY version`)
|
|
94
101
|
.all() as Array<{ version: number }>;
|
|
95
102
|
expect(rows.map((row) => row.version)).toEqual([
|
|
96
|
-
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
|
103
|
+
1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
|
|
97
104
|
]);
|
|
98
105
|
});
|
|
99
106
|
|
|
@@ -218,6 +225,46 @@ describe("Go-created v6 database adoption (DD-002 fixture)", () => {
|
|
|
218
225
|
expect(hits).toEqual([{ resource_id: "acme" }]);
|
|
219
226
|
});
|
|
220
227
|
|
|
228
|
+
it("derives the list facts of a Go-written row of a declared kind at open", async () => {
|
|
229
|
+
const fixture = materializeGoFixture();
|
|
230
|
+
cleanups.push(() => fixture.cleanup());
|
|
231
|
+
|
|
232
|
+
// A session as the Go server wrote it: four columns, no list facts.
|
|
233
|
+
const session = create(SessionSchema, {
|
|
234
|
+
metadata: { id: "ses_go", org: "acme" },
|
|
235
|
+
spec: { agentInstanceId: "ain_go" },
|
|
236
|
+
});
|
|
237
|
+
const before = new DatabaseSync(fixture.dbPath);
|
|
238
|
+
before
|
|
239
|
+
.prepare(
|
|
240
|
+
`INSERT INTO resources VALUES ('session', 'ses_go', ?, '2026-08-23 11:43:54')`,
|
|
241
|
+
)
|
|
242
|
+
.run(toBinary(SessionSchema, session));
|
|
243
|
+
before.close();
|
|
244
|
+
|
|
245
|
+
const store = SqliteStore.open(
|
|
246
|
+
fixture.dbPath,
|
|
247
|
+
undefined,
|
|
248
|
+
CONTRACT_STORE_OPTIONS,
|
|
249
|
+
);
|
|
250
|
+
cleanups.push(() => store.close());
|
|
251
|
+
|
|
252
|
+
const db = new DatabaseSync(fixture.dbPath);
|
|
253
|
+
cleanups.push(() => db.close());
|
|
254
|
+
const unproven = db
|
|
255
|
+
.prepare(
|
|
256
|
+
`SELECT count(*) AS count FROM resources WHERE list_indexed_at IS NOT updated_at`,
|
|
257
|
+
)
|
|
258
|
+
.get() as { count: number };
|
|
259
|
+
expect(unproven.count, "every adopted row derived or stamped at open").toBe(
|
|
260
|
+
0,
|
|
261
|
+
);
|
|
262
|
+
const rows = await store.queryResources(CONTRACT_SESSION_INDEX, {
|
|
263
|
+
anyKey: [{ name: "agent_instance", value: "ain_go" }],
|
|
264
|
+
});
|
|
265
|
+
expect(rows.map((row) => row.id)).toEqual(["ses_go"]);
|
|
266
|
+
});
|
|
267
|
+
|
|
221
268
|
it("reads a Go-marshaled resource blob through the TS driver (wire-format continuity)", async () => {
|
|
222
269
|
const fixture = materializeGoFixture();
|
|
223
270
|
cleanups.push(() => fixture.cleanup());
|
|
@@ -349,14 +396,11 @@ describe("rollback safety (DD-006)", () => {
|
|
|
349
396
|
});
|
|
350
397
|
|
|
351
398
|
describe("v10: the retired public level leaves every row", () => {
|
|
352
|
-
/** A v9 database: the chain replayed
|
|
399
|
+
/** A v9 database: the chain replayed up to the step before v10. */
|
|
353
400
|
function v9Database(): { dbPath: string; db: DatabaseSync } {
|
|
354
401
|
const dbPath = tempDbPath();
|
|
355
402
|
const setup = new DatabaseSync(dbPath);
|
|
356
|
-
runMigrations(setup);
|
|
357
|
-
setup
|
|
358
|
-
.prepare(`DELETE FROM schema_version WHERE version = ?`)
|
|
359
|
-
.run(SCHEMA_VERSION_10);
|
|
403
|
+
runMigrations(setup, SCHEMA_VERSION_10 - 1);
|
|
360
404
|
expect(getSchemaVersion(setup)).toBe(SCHEMA_VERSION_10 - 1);
|
|
361
405
|
return { dbPath, db: setup };
|
|
362
406
|
}
|
|
@@ -3,39 +3,93 @@
|
|
|
3
3
|
* store-contract.ts) against the sqlite driver — the extraction target of
|
|
4
4
|
* the Phase-1 store.test.ts/substores.test.ts interface-shaped cases (T01
|
|
5
5
|
* D-4). sqlite-physical pins stay in store.test.ts; the engine-specific
|
|
6
|
-
* search half stays in fts5.test.ts.
|
|
6
|
+
* search half stays in fts5.test.ts. The escape hatches ride a second
|
|
7
|
+
* connection: the store's own is busy being the subject.
|
|
7
8
|
*/
|
|
8
9
|
import { DatabaseSync } from "node:sqlite";
|
|
9
10
|
|
|
10
11
|
import { describe } from "vitest";
|
|
11
12
|
|
|
13
|
+
import type { Store } from "../../interface.js";
|
|
14
|
+
import { apiResourceKindName } from "../../proto-fields.js";
|
|
12
15
|
import type { StoreContractFixture } from "../../__tests__/store-contract.js";
|
|
13
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
CONTRACT_STORE_OPTIONS,
|
|
18
|
+
describeStoreContract,
|
|
19
|
+
} from "../../__tests__/store-contract.js";
|
|
20
|
+
import { SqliteStore } from "../store.js";
|
|
14
21
|
import { tempStore } from "./support.js";
|
|
15
22
|
|
|
16
23
|
describe("sqlite store contract", () => {
|
|
17
24
|
describeStoreContract(async (): Promise<StoreContractFixture> => {
|
|
18
|
-
const temp = tempStore();
|
|
25
|
+
const temp = tempStore(CONTRACT_STORE_OPTIONS);
|
|
26
|
+
const others: Store[] = [];
|
|
27
|
+
const withConnection = <T>(work: (db: DatabaseSync) => T): T => {
|
|
28
|
+
const db = new DatabaseSync(temp.dbPath);
|
|
29
|
+
try {
|
|
30
|
+
return work(db);
|
|
31
|
+
} finally {
|
|
32
|
+
db.close();
|
|
33
|
+
}
|
|
34
|
+
};
|
|
19
35
|
return {
|
|
20
36
|
store: temp.store,
|
|
21
37
|
async forceDedupeExpiry(id, expiresAtIso) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
id,
|
|
38
|
+
withConnection((db) =>
|
|
39
|
+
db
|
|
40
|
+
.prepare(`UPDATE signal_dedupe SET expires_at = ? WHERE id = ?`)
|
|
41
|
+
.run(expiresAtIso, id),
|
|
27
42
|
);
|
|
28
|
-
db.close();
|
|
29
43
|
},
|
|
30
44
|
async countPendingOAuthStates() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
45
|
+
return withConnection(
|
|
46
|
+
(db) =>
|
|
47
|
+
(
|
|
48
|
+
db
|
|
49
|
+
.prepare(`SELECT COUNT(*) AS count FROM pending_oauth_state`)
|
|
50
|
+
.get() as {
|
|
51
|
+
count: number;
|
|
52
|
+
}
|
|
53
|
+
).count,
|
|
54
|
+
);
|
|
55
|
+
},
|
|
56
|
+
async writeAsOlderBinary(kind, id, data) {
|
|
57
|
+
// The statement this driver ran before the list index existed.
|
|
58
|
+
withConnection((db) =>
|
|
59
|
+
db
|
|
60
|
+
.prepare(
|
|
61
|
+
`INSERT OR REPLACE INTO resources (kind, id, data, updated_at) VALUES (?, ?, ?, datetime('now'))`,
|
|
62
|
+
)
|
|
63
|
+
.run(apiResourceKindName(kind), id, data),
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
async countUnproven(kind, revision) {
|
|
67
|
+
return withConnection((db) => {
|
|
68
|
+
const revisionArm =
|
|
69
|
+
revision === undefined
|
|
70
|
+
? ""
|
|
71
|
+
: ` OR list_index_revision IS NULL OR list_index_revision <> ${revision}`;
|
|
72
|
+
return (
|
|
73
|
+
db
|
|
74
|
+
.prepare(
|
|
75
|
+
`SELECT COUNT(*) AS count FROM resources
|
|
76
|
+
WHERE kind = ? AND (list_indexed_at IS NOT updated_at${revisionArm})`,
|
|
77
|
+
)
|
|
78
|
+
.get(apiResourceKindName(kind)) as { count: number }
|
|
79
|
+
).count;
|
|
80
|
+
});
|
|
81
|
+
},
|
|
82
|
+
async openAnother(options) {
|
|
83
|
+
const other = SqliteStore.open(temp.dbPath, undefined, options);
|
|
84
|
+
others.push(other);
|
|
85
|
+
return other;
|
|
86
|
+
},
|
|
87
|
+
async cleanup() {
|
|
88
|
+
for (const other of others) {
|
|
89
|
+
await other.close();
|
|
90
|
+
}
|
|
91
|
+
await temp.cleanup();
|
|
37
92
|
},
|
|
38
|
-
cleanup: () => temp.cleanup(),
|
|
39
93
|
};
|
|
40
94
|
});
|
|
41
95
|
});
|
|
@@ -9,6 +9,8 @@ import { tmpdir } from "node:os";
|
|
|
9
9
|
import path from "node:path";
|
|
10
10
|
import { DatabaseSync } from "node:sqlite";
|
|
11
11
|
|
|
12
|
+
import { LIST_INDEXES } from "../../../boot/list-indexes.js";
|
|
13
|
+
import type { StoreOpenOptions } from "../../interface.js";
|
|
12
14
|
import { SqliteStore } from "../store.js";
|
|
13
15
|
|
|
14
16
|
export { makeOrganization } from "../../__tests__/support.js";
|
|
@@ -19,11 +21,18 @@ export interface TempStore {
|
|
|
19
21
|
cleanup(): Promise<void>;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
|
-
/**
|
|
23
|
-
|
|
24
|
+
/**
|
|
25
|
+
* A fresh store on a throwaway database file, opened with the server's
|
|
26
|
+
* list indexes (boot/list-indexes.ts) the way the composition root opens
|
|
27
|
+
* one, so a lane under test reads through the index it reads in
|
|
28
|
+
* production. `options` replaces them for a test that declares its own.
|
|
29
|
+
*/
|
|
30
|
+
export function tempStore(
|
|
31
|
+
options: StoreOpenOptions = { listIndexes: LIST_INDEXES },
|
|
32
|
+
): TempStore {
|
|
24
33
|
const dir = mkdtempSync(path.join(tmpdir(), "stigmer-store-test-"));
|
|
25
34
|
const dbPath = path.join(dir, "stigmer.db");
|
|
26
|
-
const store = SqliteStore.open(dbPath);
|
|
35
|
+
const store = SqliteStore.open(dbPath, undefined, options);
|
|
27
36
|
return {
|
|
28
37
|
store,
|
|
29
38
|
dbPath,
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Versioned schema migrations — ports the inline chain in
|
|
3
3
|
* backend/libs/go/store/sqlite/store.go (v1–v6, DDL character-faithful),
|
|
4
|
-
* adds v7, the OD-3 consolidation (D2 §3),
|
|
5
|
-
* oauth_grant index (the channel teardown's query pattern, C3 Stage 6)
|
|
4
|
+
* adds v7, the OD-3 consolidation (D2 §3), v8, the by-resource
|
|
5
|
+
* oauth_grant index (the channel teardown's query pattern, C3 Stage 6),
|
|
6
|
+
* and the later steps each named at its constant below.
|
|
6
7
|
*
|
|
7
8
|
* Schema continuity across cutover is the design point: a database the Go
|
|
8
9
|
* server created at any version migrates forward through the SAME steps Go
|
|
@@ -51,12 +52,20 @@ export const SCHEMA_VERSION_8 = 8;
|
|
|
51
52
|
export const SCHEMA_VERSION_9 = 9;
|
|
52
53
|
/** v10: every row holding the retired public visibility level moved to org. */
|
|
53
54
|
export const SCHEMA_VERSION_10 = 10;
|
|
55
|
+
/** v11: the list index's columns, key table and indexes (DDL only). */
|
|
56
|
+
export const SCHEMA_VERSION_11 = 11;
|
|
54
57
|
|
|
55
58
|
/** Target version for new databases. */
|
|
56
|
-
export const CURRENT_SCHEMA_VERSION =
|
|
59
|
+
export const CURRENT_SCHEMA_VERSION = SCHEMA_VERSION_11;
|
|
57
60
|
|
|
58
|
-
/**
|
|
59
|
-
|
|
61
|
+
/**
|
|
62
|
+
* Applies every pending migration up to `targetVersion` in order — all of
|
|
63
|
+
* them unless a test builds the database a given step starts from.
|
|
64
|
+
*/
|
|
65
|
+
export function runMigrations(
|
|
66
|
+
db: DatabaseSync,
|
|
67
|
+
targetVersion: number = CURRENT_SCHEMA_VERSION,
|
|
68
|
+
): void {
|
|
60
69
|
db.exec(`
|
|
61
70
|
CREATE TABLE IF NOT EXISTS schema_version (
|
|
62
71
|
version INTEGER PRIMARY KEY,
|
|
@@ -77,10 +86,11 @@ export function runMigrations(db: DatabaseSync): void {
|
|
|
77
86
|
[SCHEMA_VERSION_8, migrateToV8],
|
|
78
87
|
[SCHEMA_VERSION_9, migrateToV9],
|
|
79
88
|
[SCHEMA_VERSION_10, migrateToV10],
|
|
89
|
+
[SCHEMA_VERSION_11, migrateToV11],
|
|
80
90
|
];
|
|
81
91
|
|
|
82
92
|
for (const [version, migrate] of chain) {
|
|
83
|
-
if (currentVersion < version) {
|
|
93
|
+
if (currentVersion < version && version <= targetVersion) {
|
|
84
94
|
applyInTransaction(db, version, migrate);
|
|
85
95
|
}
|
|
86
96
|
}
|
|
@@ -423,3 +433,44 @@ function migrateToV10(db: DatabaseSync): void {
|
|
|
423
433
|
}
|
|
424
434
|
}
|
|
425
435
|
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* v11: the list index (../list-index.ts) — schema only, the Postgres
|
|
439
|
+
* driver's v6 in this engine's terms (postgres/migrations.ts gives the
|
|
440
|
+
* reasons for every column and index). Existing rows, a Go-era database's
|
|
441
|
+
* included, arrive unproven and are derived by the store's reconciliation
|
|
442
|
+
* at open. sqlite compares text as bytes (BINARY) by default, the order
|
|
443
|
+
* list-index.ts merges in, so no collation is spelled here. The store now
|
|
444
|
+
* writes `updated_at` to the millisecond and the stamp from the same
|
|
445
|
+
* expression in the same statement; a writer that does not know the index
|
|
446
|
+
* writes `datetime('now')`, whole seconds, which can never equal a stamp.
|
|
447
|
+
*/
|
|
448
|
+
function migrateToV11(db: DatabaseSync): void {
|
|
449
|
+
db.exec(`
|
|
450
|
+
ALTER TABLE resources ADD COLUMN list_org TEXT;
|
|
451
|
+
ALTER TABLE resources ADD COLUMN list_created_at TEXT;
|
|
452
|
+
ALTER TABLE resources ADD COLUMN list_index_revision INTEGER;
|
|
453
|
+
ALTER TABLE resources ADD COLUMN list_indexed_at TEXT;
|
|
454
|
+
|
|
455
|
+
CREATE INDEX idx_resources_list_org
|
|
456
|
+
ON resources (kind, list_org, list_created_at, id);
|
|
457
|
+
CREATE INDEX idx_resources_list_created
|
|
458
|
+
ON resources (kind, list_created_at, id);
|
|
459
|
+
CREATE INDEX idx_resources_list_revision
|
|
460
|
+
ON resources (kind, list_index_revision);
|
|
461
|
+
CREATE INDEX idx_resources_list_unproven
|
|
462
|
+
ON resources (kind, id) WHERE list_indexed_at IS NOT updated_at;
|
|
463
|
+
|
|
464
|
+
CREATE TABLE resource_list_keys (
|
|
465
|
+
kind TEXT NOT NULL,
|
|
466
|
+
id TEXT NOT NULL,
|
|
467
|
+
key TEXT NOT NULL,
|
|
468
|
+
value TEXT NOT NULL,
|
|
469
|
+
created_at TEXT NOT NULL,
|
|
470
|
+
PRIMARY KEY (kind, id, key)
|
|
471
|
+
) WITHOUT ROWID;
|
|
472
|
+
|
|
473
|
+
CREATE INDEX idx_resource_list_keys_lookup
|
|
474
|
+
ON resource_list_keys (kind, key, value, created_at, id);
|
|
475
|
+
`);
|
|
476
|
+
}
|