@intx/db 0.2.2 → 0.3.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/README.md +2 -2
- package/dist/approval-store.d.ts +52 -0
- package/dist/approval-store.js +79 -0
- package/dist/asset-resolution.d.ts +2 -2
- package/dist/client.d.ts +10 -0
- package/dist/connection.js +11 -8
- package/dist/credential-resolution.d.ts +130 -18
- package/dist/credential-resolution.js +142 -3
- package/dist/grant-store.js +35 -13
- package/dist/index.d.ts +13 -4
- package/dist/index.js +11 -3
- package/dist/model-source-resolution.d.ts +52 -6
- package/dist/model-source-resolution.js +145 -19
- package/dist/parse-row.d.ts +212 -32
- package/dist/parse-row.js +109 -18
- package/dist/rekey-credential-secrets.d.ts +13 -0
- package/dist/rekey-credential-secrets.js +61 -0
- package/dist/schema/approvals.d.ts +245 -0
- package/dist/schema/approvals.js +52 -0
- package/dist/schema/catalog.d.ts +17 -0
- package/dist/schema/catalog.js +7 -1
- package/dist/schema/credentials.d.ts +1 -1
- package/dist/schema/git-tokens.js +1 -1
- package/dist/schema/grants.js +8 -2
- package/dist/schema/index.d.ts +8 -4
- package/dist/schema/index.js +8 -4
- package/dist/schema/messages.d.ts +5 -5
- package/dist/schema/messages.js +20 -9
- package/dist/schema/offerings.js +8 -2
- package/dist/schema/principals.d.ts +2 -2
- package/dist/schema/principals.js +7 -5
- package/dist/schema/providers.d.ts +17 -0
- package/dist/schema/providers.js +5 -0
- package/dist/schema/roles.js +6 -2
- package/dist/schema/session-assets.d.ts +1 -38
- package/dist/schema/session-assets.js +36 -19
- package/dist/schema/sessions.js +7 -2
- package/dist/schema/sidecar-allocation.d.ts +406 -0
- package/dist/schema/sidecar-allocation.js +57 -0
- package/dist/schema/sidecar.d.ts +19 -2
- package/dist/schema/sidecar.js +13 -3
- package/dist/schema/signal-correlations.d.ts +177 -0
- package/dist/schema/signal-correlations.js +31 -0
- package/dist/schema/wallets.d.ts +3 -3
- package/dist/schema/wallets.js +4 -2
- package/dist/schema/{agents.d.ts → workflow-definitions.d.ts} +79 -113
- package/dist/schema/workflow-definitions.js +97 -0
- package/dist/schema/workflow-run-dispatch.d.ts +328 -0
- package/dist/schema/workflow-run-dispatch.js +56 -0
- package/dist/schema/{workflow-deployments.d.ts → workflow-run-execution.d.ts} +43 -46
- package/dist/schema/workflow-run-execution.js +48 -0
- package/dist/schema/workflow-run-launch-spec.d.ts +200 -0
- package/dist/schema/workflow-run-launch-spec.js +26 -0
- package/dist/schema/{instances.d.ts → workflow-run.d.ts} +39 -71
- package/dist/schema/workflow-run.js +102 -0
- package/dist/sidecar-allocation-store.d.ts +171 -0
- package/dist/sidecar-allocation-store.js +512 -0
- package/dist/signal-correlation-store.d.ts +36 -0
- package/dist/signal-correlation-store.js +63 -0
- package/dist/tenant-hierarchy.d.ts +2 -1
- package/dist/tenant-hierarchy.js +10 -5
- package/dist/workflow-definition-store.d.ts +55 -0
- package/dist/workflow-definition-store.js +93 -0
- package/dist/workflow-run-dispatch-store.d.ts +80 -0
- package/dist/workflow-run-dispatch-store.js +298 -0
- package/dist/workflow-run-launch-spec-store.d.ts +13 -0
- package/dist/workflow-run-launch-spec-store.js +30 -0
- package/dist/workflow-run-store.d.ts +54 -0
- package/dist/workflow-run-store.js +85 -0
- package/migrations/0037_credential_use_backfill.sql +39 -0
- package/migrations/0038_chilly_blacklash.sql +37 -0
- package/migrations/0039_quick_carnage.sql +2 -0
- package/migrations/0040_reshape_approval_origin.sql +24 -0
- package/migrations/0041_make_approval_timeout_at_nullable.sql +1 -0
- package/migrations/0042_youthful_mantis.sql +2 -0
- package/migrations/0043_signal_correlation_deployment_fk.sql +1 -0
- package/migrations/0044_model_offering_quirks.sql +1 -0
- package/migrations/0045_create_workflow_run.sql +13 -0
- package/migrations/0046_approval_signal_correlation_run_fk.sql +2 -0
- package/migrations/0047_create_workflow_definition.sql +30 -0
- package/migrations/0048_workflow_definition_origin_agent_id.sql +2 -0
- package/migrations/0049_curly_omega_flight.sql +2 -0
- package/migrations/0050_late_crystal.sql +10 -0
- package/migrations/0051_funny_madelyne_pryor.sql +1 -0
- package/migrations/0052_drop_inference_turn_instance_fk.sql +1 -0
- package/migrations/0053_session_mail_session_id_index.sql +1 -0
- package/migrations/0054_rekey_instance_grants_to_workflow_run.sql +10 -0
- package/migrations/0055_backfill_anchor_workflow_runs.sql +69 -0
- package/migrations/0056_repoint_deployment_fks_to_anchor_run.sql +32 -0
- package/migrations/0057_drop_workflow_deployment_projection.sql +22 -0
- package/migrations/0058_repoint_offering_fk_to_definition.sql +41 -0
- package/migrations/0059_repoint_transaction_fk_to_run.sql +10 -0
- package/migrations/0060_drop_session_mail_instance_fk.sql +6 -0
- package/migrations/0061_drop_session_asset_instance_fk.sql +7 -0
- package/migrations/0062_drop_agent_asset_table.sql +11 -0
- package/migrations/0063_repoint_agent_role_fk_to_definition.sql +39 -0
- package/migrations/0064_repoint_agent_session_fk_to_definition.sql +47 -0
- package/migrations/0065_add_workflow_definition_model_requirements.sql +37 -0
- package/migrations/0066_rekey_agent_definition_principals_to_workflow.sql +27 -0
- package/migrations/0067_add_workflow_definition_kind.sql +10 -0
- package/migrations/0068_drop_agent_tables_and_origin_agent_id.sql +31 -0
- package/migrations/0069_drop_workflow_definition_kind.sql +10 -0
- package/migrations/0070_flashy_proteus.sql +13 -0
- package/migrations/0072_add_workflow_definition_credential_bindings.sql +1 -0
- package/migrations/0073_grant_target_exactly_one_check.sql +13 -0
- package/migrations/0074_add_provider_api_base_url.sql +1 -0
- package/migrations/0075_workflow_run_launch_spec.sql +17 -0
- package/migrations/0076_sidecar_allocation.sql +40 -0
- package/migrations/0077_workflow_run_dispatch.sql +29 -0
- package/migrations/0078_workflow_run_dispatch_kind.sql +2 -0
- package/migrations/0079_rename_workflow_run_deployment_id_to_anchor_run_id.sql +4 -0
- package/migrations/0080_rename_correlation_approval_deployment_id_to_anchor_run_id.sql +9 -0
- package/migrations/0081_workflow_definition_content_hash_and_approved_wire_hash.sql +4 -0
- package/migrations/0082_blue_black_queen.sql +1 -0
- package/migrations/0083_replace_launch_spec_snapshot_with_frozen_bundle.sql +3 -0
- package/migrations/0084_delete_orphaned_credential_grants.sql +22 -0
- package/migrations/meta/0037_snapshot.json +3237 -0
- package/migrations/meta/0038_snapshot.json +3470 -0
- package/migrations/meta/0039_snapshot.json +3470 -0
- package/migrations/meta/0040_snapshot.json +3489 -0
- package/migrations/meta/0041_snapshot.json +3489 -0
- package/migrations/meta/0042_snapshot.json +3489 -0
- package/migrations/meta/0043_snapshot.json +3498 -0
- package/migrations/meta/0044_snapshot.json +3504 -0
- package/migrations/meta/0045_snapshot.json +3589 -0
- package/migrations/meta/0046_snapshot.json +3607 -0
- package/migrations/meta/0047_snapshot.json +3832 -0
- package/migrations/meta/0048_snapshot.json +3853 -0
- package/migrations/meta/0049_snapshot.json +3854 -0
- package/migrations/meta/0050_snapshot.json +3924 -0
- package/migrations/meta/0051_snapshot.json +3940 -0
- package/migrations/meta/0052_snapshot.json +3931 -0
- package/migrations/meta/0053_snapshot.json +3952 -0
- package/migrations/meta/0054_snapshot.json +3952 -0
- package/migrations/meta/0055_snapshot.json +3952 -0
- package/migrations/meta/0056_snapshot.json +3952 -0
- package/migrations/meta/0057_snapshot.json +3839 -0
- package/migrations/meta/0058_snapshot.json +3839 -0
- package/migrations/meta/0059_snapshot.json +3839 -0
- package/migrations/meta/0060_snapshot.json +3830 -0
- package/migrations/meta/0061_snapshot.json +3821 -0
- package/migrations/meta/0062_snapshot.json +3723 -0
- package/migrations/meta/0063_snapshot.json +3723 -0
- package/migrations/meta/0064_snapshot.json +3723 -0
- package/migrations/meta/0065_snapshot.json +3729 -0
- package/migrations/meta/0066_snapshot.json +3729 -0
- package/migrations/meta/0067_snapshot.json +3736 -0
- package/migrations/meta/0068_snapshot.json +3347 -0
- package/migrations/meta/0069_snapshot.json +3340 -0
- package/migrations/meta/0070_snapshot.json +3444 -0
- package/migrations/meta/0072_snapshot.json +3450 -0
- package/migrations/meta/0073_snapshot.json +3455 -0
- package/migrations/meta/0074_snapshot.json +3461 -0
- package/migrations/meta/0075_snapshot.json +3567 -0
- package/migrations/meta/0076_snapshot.json +3851 -0
- package/migrations/meta/0077_snapshot.json +4067 -0
- package/migrations/meta/0078_snapshot.json +4078 -0
- package/migrations/meta/0079_snapshot.json +4078 -0
- package/migrations/meta/0080_snapshot.json +4078 -0
- package/migrations/meta/0081_snapshot.json +4096 -0
- package/migrations/meta/0082_snapshot.json +4102 -0
- package/migrations/meta/0083_snapshot.json +4096 -0
- package/migrations/meta/0084_snapshot.json +4096 -0
- package/migrations/meta/_journal.json +329 -0
- package/package.json +6 -3
- package/dist/schema/agent-assets.d.ts +0 -109
- package/dist/schema/agent-assets.js +0 -15
- package/dist/schema/agents.js +0 -57
- package/dist/schema/instances.js +0 -39
- package/dist/schema/workflow-deployments.js +0 -37
package/dist/schema/roles.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { boolean, pgTable, primaryKey, text, timestamp, } from "drizzle-orm/pg-core";
|
|
2
|
-
import { agent } from "./agents.js";
|
|
3
2
|
import { principal } from "./principals.js";
|
|
4
3
|
import { tenant } from "./tenants.js";
|
|
4
|
+
import { workflowDefinition } from "./workflow-definitions.js";
|
|
5
5
|
export const role = pgTable("role", {
|
|
6
6
|
id: text("id").primaryKey(),
|
|
7
7
|
tenantId: text("tenant_id")
|
|
@@ -14,9 +14,13 @@ export const role = pgTable("role", {
|
|
|
14
14
|
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
15
15
|
});
|
|
16
16
|
export const agentRole = pgTable("agent_role", {
|
|
17
|
+
// Retains the agent_id column name, but its values are workflow_definition
|
|
18
|
+
// ids: every agent was folded to exactly one definition, and role
|
|
19
|
+
// assignments follow the definition so they survived the agent table's
|
|
20
|
+
// retirement.
|
|
17
21
|
agentId: text("agent_id")
|
|
18
22
|
.notNull()
|
|
19
|
-
.references(() =>
|
|
23
|
+
.references(() => workflowDefinition.id, { onDelete: "cascade" }),
|
|
20
24
|
roleId: text("role_id")
|
|
21
25
|
.notNull()
|
|
22
26
|
.references(() => role.id, { onDelete: "cascade" }),
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
export type SessionAssetSource = "direct" | "resolved";
|
|
2
1
|
export declare const sessionAsset: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
3
2
|
name: "session_asset";
|
|
4
3
|
schema: undefined;
|
|
5
4
|
columns: {
|
|
6
|
-
|
|
5
|
+
runId: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
6
|
name: "instance_id";
|
|
8
7
|
tableName: "session_asset";
|
|
9
8
|
dataType: "string";
|
|
@@ -20,23 +19,6 @@ export declare const sessionAsset: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
20
19
|
identity: undefined;
|
|
21
20
|
generated: undefined;
|
|
22
21
|
}, {}, {}>;
|
|
23
|
-
agentAssetId: import("drizzle-orm/pg-core").PgColumn<{
|
|
24
|
-
name: "agent_asset_id";
|
|
25
|
-
tableName: "session_asset";
|
|
26
|
-
dataType: "string";
|
|
27
|
-
columnType: "PgText";
|
|
28
|
-
data: string;
|
|
29
|
-
driverParam: string;
|
|
30
|
-
notNull: false;
|
|
31
|
-
hasDefault: false;
|
|
32
|
-
isPrimaryKey: false;
|
|
33
|
-
isAutoincrement: false;
|
|
34
|
-
hasRuntimeDefault: false;
|
|
35
|
-
enumValues: [string, ...string[]];
|
|
36
|
-
baseColumn: never;
|
|
37
|
-
identity: undefined;
|
|
38
|
-
generated: undefined;
|
|
39
|
-
}, {}, {}>;
|
|
40
22
|
mountPath: import("drizzle-orm/pg-core").PgColumn<{
|
|
41
23
|
name: "mount_path";
|
|
42
24
|
tableName: "session_asset";
|
|
@@ -88,25 +70,6 @@ export declare const sessionAsset: import("drizzle-orm/pg-core").PgTableWithColu
|
|
|
88
70
|
identity: undefined;
|
|
89
71
|
generated: undefined;
|
|
90
72
|
}, {}, {}>;
|
|
91
|
-
source: import("drizzle-orm/pg-core").PgColumn<{
|
|
92
|
-
name: "source";
|
|
93
|
-
tableName: "session_asset";
|
|
94
|
-
dataType: "string";
|
|
95
|
-
columnType: "PgText";
|
|
96
|
-
data: SessionAssetSource;
|
|
97
|
-
driverParam: string;
|
|
98
|
-
notNull: true;
|
|
99
|
-
hasDefault: false;
|
|
100
|
-
isPrimaryKey: false;
|
|
101
|
-
isAutoincrement: false;
|
|
102
|
-
hasRuntimeDefault: false;
|
|
103
|
-
enumValues: [string, ...string[]];
|
|
104
|
-
baseColumn: never;
|
|
105
|
-
identity: undefined;
|
|
106
|
-
generated: undefined;
|
|
107
|
-
}, {}, {
|
|
108
|
-
$type: SessionAssetSource;
|
|
109
|
-
}>;
|
|
110
73
|
materializedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
111
74
|
name: "materialized_at";
|
|
112
75
|
tableName: "session_asset";
|
|
@@ -1,28 +1,45 @@
|
|
|
1
1
|
import { index, pgTable, primaryKey, text, timestamp, } from "drizzle-orm/pg-core";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
// session_asset rows record per-(instance, materialization) pack
|
|
3
|
+
// acknowledgments. A row exists iff the sidecar acked the pack that
|
|
4
|
+
// materialized that asset for that instance. The launchSession flow
|
|
5
|
+
// inserts each row before the corresponding pack send and rolls it
|
|
6
|
+
// back if that single send fails, so each row reflects an ack the
|
|
7
|
+
// hub actually observed for that attachment.
|
|
8
|
+
//
|
|
9
|
+
// Assets reach an instance through the tool-package resolver: it picks
|
|
10
|
+
// package-registry assets out of the tenant-visible set, and the launch
|
|
11
|
+
// fan-out materializes each into the workspace. The mount path and
|
|
12
|
+
// source commit are recorded so forensic queries can trace every
|
|
13
|
+
// materialization.
|
|
14
|
+
//
|
|
15
|
+
// Caveat on multi-attachment partial-success: when a session attaches
|
|
16
|
+
// N assets and the fan-out succeeds for attachments 1..k-1 and fails
|
|
17
|
+
// on attachment k, only attachment k's row is rolled back. Rows
|
|
18
|
+
// 1..k-1 stay. The session as a whole never reached the running
|
|
19
|
+
// state -- attemptCleanup runs sendAgentUndeploy -- but the per-
|
|
20
|
+
// attachment ack invariant holds for the rows that remain.
|
|
21
|
+
// Forensics queries should treat row count as "packs the sidecar
|
|
22
|
+
// acked during this instance's launch," not "sessions that ran with
|
|
23
|
+
// assets." Pairing with agent_instance.status (or its successor
|
|
24
|
+
// session-lifecycle signal) is necessary to distinguish a row left
|
|
25
|
+
// behind by a partially-successful failed launch from one belonging
|
|
26
|
+
// to a fully-running session.
|
|
4
27
|
export const sessionAsset = pgTable("session_asset", {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}),
|
|
28
|
+
// The endpoint this materialization is for: a legacy agent_instance id or a
|
|
29
|
+
// folded workflow_run id, from one shared id space. A polymorphic reference
|
|
30
|
+
// carrying no foreign key (mirroring inference_turn.runId); the launch
|
|
31
|
+
// layer owns the invariant. NOT NULL -- a materialization always names its
|
|
32
|
+
// endpoint -- and part of the (instance_id, mount_path) key. A folded run
|
|
33
|
+
// writes its run id here, which the dropped agent_instance FK would reject.
|
|
34
|
+
runId: text("instance_id").notNull(),
|
|
13
35
|
mountPath: text("mount_path").notNull(),
|
|
14
36
|
assetPackSha: text("asset_pack_sha").notNull(),
|
|
15
37
|
sourceCommitSha: text("source_commit_sha").notNull(),
|
|
16
|
-
source: text("source").$type().notNull(),
|
|
17
38
|
materializedAt: timestamp("materialized_at").notNull().defaultNow(),
|
|
18
39
|
}, (t) => [
|
|
19
|
-
// (
|
|
20
|
-
// asset lands at a distinct mount path inside one
|
|
21
|
-
//
|
|
22
|
-
|
|
23
|
-
// package-registry pick. Pre-split the PK was (instanceId,
|
|
24
|
-
// agentAssetId), but that column is now nullable for the
|
|
25
|
-
// resolved-source rows and Postgres rejects nullable PK columns.
|
|
26
|
-
primaryKey({ columns: [t.instanceId, t.mountPath] }),
|
|
40
|
+
// (runId, mountPath) is the natural key: every materialized
|
|
41
|
+
// asset lands at a distinct mount path inside one run, so this
|
|
42
|
+
// pair uniquely identifies a row.
|
|
43
|
+
primaryKey({ columns: [t.runId, t.mountPath] }),
|
|
27
44
|
index("session_asset_pack_sha_idx").on(t.assetPackSha),
|
|
28
45
|
]);
|
package/dist/schema/sessions.js
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
import { pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
2
|
-
import { agent } from "./agents.js";
|
|
3
2
|
import { principal } from "./principals.js";
|
|
4
3
|
import { tenant } from "./tenants.js";
|
|
4
|
+
import { workflowDefinition } from "./workflow-definitions.js";
|
|
5
5
|
export const agentSession = pgTable("agent_session", {
|
|
6
6
|
id: text("id").primaryKey(),
|
|
7
7
|
tenantId: text("tenant_id")
|
|
8
8
|
.notNull()
|
|
9
9
|
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
10
|
+
// Retains the agent_id column name, but its values are workflow_definition
|
|
11
|
+
// ids: a launched session is keyed to the folded definition it runs, so it
|
|
12
|
+
// survives the agent table's retirement. ON DELETE restrict -- session
|
|
13
|
+
// history is an audit record, so a definition with live sessions cannot be
|
|
14
|
+
// dropped out from under them.
|
|
10
15
|
agentId: text("agent_id")
|
|
11
16
|
.notNull()
|
|
12
|
-
.references(() =>
|
|
17
|
+
.references(() => workflowDefinition.id, { onDelete: "restrict" }),
|
|
13
18
|
principalId: text("principal_id")
|
|
14
19
|
.notNull()
|
|
15
20
|
.references(() => principal.id),
|
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
export declare const sidecarAllocation: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "sidecar_allocation";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
|
+
name: "id";
|
|
7
|
+
tableName: "sidecar_allocation";
|
|
8
|
+
dataType: "string";
|
|
9
|
+
columnType: "PgText";
|
|
10
|
+
data: string;
|
|
11
|
+
driverParam: string;
|
|
12
|
+
notNull: true;
|
|
13
|
+
hasDefault: false;
|
|
14
|
+
isPrimaryKey: true;
|
|
15
|
+
isAutoincrement: false;
|
|
16
|
+
hasRuntimeDefault: false;
|
|
17
|
+
enumValues: [string, ...string[]];
|
|
18
|
+
baseColumn: never;
|
|
19
|
+
identity: undefined;
|
|
20
|
+
generated: undefined;
|
|
21
|
+
}, {}, {}>;
|
|
22
|
+
anchorRunId: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "anchor_run_id";
|
|
24
|
+
tableName: "sidecar_allocation";
|
|
25
|
+
dataType: "string";
|
|
26
|
+
columnType: "PgText";
|
|
27
|
+
data: string;
|
|
28
|
+
driverParam: string;
|
|
29
|
+
notNull: true;
|
|
30
|
+
hasDefault: false;
|
|
31
|
+
isPrimaryKey: false;
|
|
32
|
+
isAutoincrement: false;
|
|
33
|
+
hasRuntimeDefault: false;
|
|
34
|
+
enumValues: [string, ...string[]];
|
|
35
|
+
baseColumn: never;
|
|
36
|
+
identity: undefined;
|
|
37
|
+
generated: undefined;
|
|
38
|
+
}, {}, {}>;
|
|
39
|
+
tenantId: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "tenant_id";
|
|
41
|
+
tableName: "sidecar_allocation";
|
|
42
|
+
dataType: "string";
|
|
43
|
+
columnType: "PgText";
|
|
44
|
+
data: string;
|
|
45
|
+
driverParam: string;
|
|
46
|
+
notNull: true;
|
|
47
|
+
hasDefault: false;
|
|
48
|
+
isPrimaryKey: false;
|
|
49
|
+
isAutoincrement: false;
|
|
50
|
+
hasRuntimeDefault: false;
|
|
51
|
+
enumValues: [string, ...string[]];
|
|
52
|
+
baseColumn: never;
|
|
53
|
+
identity: undefined;
|
|
54
|
+
generated: undefined;
|
|
55
|
+
}, {}, {}>;
|
|
56
|
+
provisionerId: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "provisioner_id";
|
|
58
|
+
tableName: "sidecar_allocation";
|
|
59
|
+
dataType: "string";
|
|
60
|
+
columnType: "PgText";
|
|
61
|
+
data: string;
|
|
62
|
+
driverParam: string;
|
|
63
|
+
notNull: true;
|
|
64
|
+
hasDefault: false;
|
|
65
|
+
isPrimaryKey: false;
|
|
66
|
+
isAutoincrement: false;
|
|
67
|
+
hasRuntimeDefault: false;
|
|
68
|
+
enumValues: [string, ...string[]];
|
|
69
|
+
baseColumn: never;
|
|
70
|
+
identity: undefined;
|
|
71
|
+
generated: undefined;
|
|
72
|
+
}, {}, {}>;
|
|
73
|
+
provisionerApiVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "provisioner_api_version";
|
|
75
|
+
tableName: "sidecar_allocation";
|
|
76
|
+
dataType: "number";
|
|
77
|
+
columnType: "PgInteger";
|
|
78
|
+
data: 1;
|
|
79
|
+
driverParam: string | number;
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: false;
|
|
82
|
+
isPrimaryKey: false;
|
|
83
|
+
isAutoincrement: false;
|
|
84
|
+
hasRuntimeDefault: false;
|
|
85
|
+
enumValues: undefined;
|
|
86
|
+
baseColumn: never;
|
|
87
|
+
identity: undefined;
|
|
88
|
+
generated: undefined;
|
|
89
|
+
}, {}, {
|
|
90
|
+
$type: 1;
|
|
91
|
+
}>;
|
|
92
|
+
provisionerBindingFingerprint: import("drizzle-orm/pg-core").PgColumn<{
|
|
93
|
+
name: "provisioner_binding_fingerprint";
|
|
94
|
+
tableName: "sidecar_allocation";
|
|
95
|
+
dataType: "string";
|
|
96
|
+
columnType: "PgText";
|
|
97
|
+
data: string;
|
|
98
|
+
driverParam: string;
|
|
99
|
+
notNull: true;
|
|
100
|
+
hasDefault: false;
|
|
101
|
+
isPrimaryKey: false;
|
|
102
|
+
isAutoincrement: false;
|
|
103
|
+
hasRuntimeDefault: false;
|
|
104
|
+
enumValues: [string, ...string[]];
|
|
105
|
+
baseColumn: never;
|
|
106
|
+
identity: undefined;
|
|
107
|
+
generated: undefined;
|
|
108
|
+
}, {}, {}>;
|
|
109
|
+
sidecarId: import("drizzle-orm/pg-core").PgColumn<{
|
|
110
|
+
name: "sidecar_id";
|
|
111
|
+
tableName: "sidecar_allocation";
|
|
112
|
+
dataType: "string";
|
|
113
|
+
columnType: "PgText";
|
|
114
|
+
data: string;
|
|
115
|
+
driverParam: string;
|
|
116
|
+
notNull: false;
|
|
117
|
+
hasDefault: false;
|
|
118
|
+
isPrimaryKey: false;
|
|
119
|
+
isAutoincrement: false;
|
|
120
|
+
hasRuntimeDefault: false;
|
|
121
|
+
enumValues: [string, ...string[]];
|
|
122
|
+
baseColumn: never;
|
|
123
|
+
identity: undefined;
|
|
124
|
+
generated: undefined;
|
|
125
|
+
}, {}, {}>;
|
|
126
|
+
placementSharing: import("drizzle-orm/pg-core").PgColumn<{
|
|
127
|
+
name: "placement_sharing";
|
|
128
|
+
tableName: "sidecar_allocation";
|
|
129
|
+
dataType: "string";
|
|
130
|
+
columnType: "PgText";
|
|
131
|
+
data: "exclusive";
|
|
132
|
+
driverParam: string;
|
|
133
|
+
notNull: true;
|
|
134
|
+
hasDefault: false;
|
|
135
|
+
isPrimaryKey: false;
|
|
136
|
+
isAutoincrement: false;
|
|
137
|
+
hasRuntimeDefault: false;
|
|
138
|
+
enumValues: [string, ...string[]];
|
|
139
|
+
baseColumn: never;
|
|
140
|
+
identity: undefined;
|
|
141
|
+
generated: undefined;
|
|
142
|
+
}, {}, {
|
|
143
|
+
$type: "exclusive";
|
|
144
|
+
}>;
|
|
145
|
+
sidecarReuse: import("drizzle-orm/pg-core").PgColumn<{
|
|
146
|
+
name: "sidecar_reuse";
|
|
147
|
+
tableName: "sidecar_allocation";
|
|
148
|
+
dataType: "string";
|
|
149
|
+
columnType: "PgText";
|
|
150
|
+
data: "never" | "same-deployment";
|
|
151
|
+
driverParam: string;
|
|
152
|
+
notNull: true;
|
|
153
|
+
hasDefault: true;
|
|
154
|
+
isPrimaryKey: false;
|
|
155
|
+
isAutoincrement: false;
|
|
156
|
+
hasRuntimeDefault: false;
|
|
157
|
+
enumValues: [string, ...string[]];
|
|
158
|
+
baseColumn: never;
|
|
159
|
+
identity: undefined;
|
|
160
|
+
generated: undefined;
|
|
161
|
+
}, {}, {
|
|
162
|
+
$type: "never" | "same-deployment";
|
|
163
|
+
}>;
|
|
164
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
165
|
+
name: "status";
|
|
166
|
+
tableName: "sidecar_allocation";
|
|
167
|
+
dataType: "string";
|
|
168
|
+
columnType: "PgText";
|
|
169
|
+
data: "failed" | "allocated" | "pending" | "provisioning" | "replacing" | "releasing" | "released";
|
|
170
|
+
driverParam: string;
|
|
171
|
+
notNull: true;
|
|
172
|
+
hasDefault: true;
|
|
173
|
+
isPrimaryKey: false;
|
|
174
|
+
isAutoincrement: false;
|
|
175
|
+
hasRuntimeDefault: false;
|
|
176
|
+
enumValues: [string, ...string[]];
|
|
177
|
+
baseColumn: never;
|
|
178
|
+
identity: undefined;
|
|
179
|
+
generated: undefined;
|
|
180
|
+
}, {}, {
|
|
181
|
+
$type: "failed" | "allocated" | "pending" | "provisioning" | "replacing" | "releasing" | "released";
|
|
182
|
+
}>;
|
|
183
|
+
generation: import("drizzle-orm/pg-core").PgColumn<{
|
|
184
|
+
name: "generation";
|
|
185
|
+
tableName: "sidecar_allocation";
|
|
186
|
+
dataType: "number";
|
|
187
|
+
columnType: "PgInteger";
|
|
188
|
+
data: number;
|
|
189
|
+
driverParam: string | number;
|
|
190
|
+
notNull: true;
|
|
191
|
+
hasDefault: true;
|
|
192
|
+
isPrimaryKey: false;
|
|
193
|
+
isAutoincrement: false;
|
|
194
|
+
hasRuntimeDefault: false;
|
|
195
|
+
enumValues: undefined;
|
|
196
|
+
baseColumn: never;
|
|
197
|
+
identity: undefined;
|
|
198
|
+
generated: undefined;
|
|
199
|
+
}, {}, {}>;
|
|
200
|
+
ensureAcceptedGeneration: import("drizzle-orm/pg-core").PgColumn<{
|
|
201
|
+
name: "ensure_accepted_generation";
|
|
202
|
+
tableName: "sidecar_allocation";
|
|
203
|
+
dataType: "number";
|
|
204
|
+
columnType: "PgInteger";
|
|
205
|
+
data: number;
|
|
206
|
+
driverParam: string | number;
|
|
207
|
+
notNull: false;
|
|
208
|
+
hasDefault: false;
|
|
209
|
+
isPrimaryKey: false;
|
|
210
|
+
isAutoincrement: false;
|
|
211
|
+
hasRuntimeDefault: false;
|
|
212
|
+
enumValues: undefined;
|
|
213
|
+
baseColumn: never;
|
|
214
|
+
identity: undefined;
|
|
215
|
+
generated: undefined;
|
|
216
|
+
}, {}, {}>;
|
|
217
|
+
externalRef: import("drizzle-orm/pg-core").PgColumn<{
|
|
218
|
+
name: "external_ref";
|
|
219
|
+
tableName: "sidecar_allocation";
|
|
220
|
+
dataType: "string";
|
|
221
|
+
columnType: "PgText";
|
|
222
|
+
data: string;
|
|
223
|
+
driverParam: string;
|
|
224
|
+
notNull: false;
|
|
225
|
+
hasDefault: false;
|
|
226
|
+
isPrimaryKey: false;
|
|
227
|
+
isAutoincrement: false;
|
|
228
|
+
hasRuntimeDefault: false;
|
|
229
|
+
enumValues: [string, ...string[]];
|
|
230
|
+
baseColumn: never;
|
|
231
|
+
identity: undefined;
|
|
232
|
+
generated: undefined;
|
|
233
|
+
}, {}, {}>;
|
|
234
|
+
nextAttemptAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
235
|
+
name: "next_attempt_at";
|
|
236
|
+
tableName: "sidecar_allocation";
|
|
237
|
+
dataType: "date";
|
|
238
|
+
columnType: "PgTimestamp";
|
|
239
|
+
data: Date;
|
|
240
|
+
driverParam: string;
|
|
241
|
+
notNull: false;
|
|
242
|
+
hasDefault: false;
|
|
243
|
+
isPrimaryKey: false;
|
|
244
|
+
isAutoincrement: false;
|
|
245
|
+
hasRuntimeDefault: false;
|
|
246
|
+
enumValues: undefined;
|
|
247
|
+
baseColumn: never;
|
|
248
|
+
identity: undefined;
|
|
249
|
+
generated: undefined;
|
|
250
|
+
}, {}, {}>;
|
|
251
|
+
reconciliationLeaseId: import("drizzle-orm/pg-core").PgColumn<{
|
|
252
|
+
name: "reconciliation_lease_id";
|
|
253
|
+
tableName: "sidecar_allocation";
|
|
254
|
+
dataType: "string";
|
|
255
|
+
columnType: "PgText";
|
|
256
|
+
data: string;
|
|
257
|
+
driverParam: string;
|
|
258
|
+
notNull: false;
|
|
259
|
+
hasDefault: false;
|
|
260
|
+
isPrimaryKey: false;
|
|
261
|
+
isAutoincrement: false;
|
|
262
|
+
hasRuntimeDefault: false;
|
|
263
|
+
enumValues: [string, ...string[]];
|
|
264
|
+
baseColumn: never;
|
|
265
|
+
identity: undefined;
|
|
266
|
+
generated: undefined;
|
|
267
|
+
}, {}, {}>;
|
|
268
|
+
reconciliationLeaseExpiresAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
269
|
+
name: "reconciliation_lease_expires_at";
|
|
270
|
+
tableName: "sidecar_allocation";
|
|
271
|
+
dataType: "date";
|
|
272
|
+
columnType: "PgTimestamp";
|
|
273
|
+
data: Date;
|
|
274
|
+
driverParam: string;
|
|
275
|
+
notNull: false;
|
|
276
|
+
hasDefault: false;
|
|
277
|
+
isPrimaryKey: false;
|
|
278
|
+
isAutoincrement: false;
|
|
279
|
+
hasRuntimeDefault: false;
|
|
280
|
+
enumValues: undefined;
|
|
281
|
+
baseColumn: never;
|
|
282
|
+
identity: undefined;
|
|
283
|
+
generated: undefined;
|
|
284
|
+
}, {}, {}>;
|
|
285
|
+
ensureAttempts: import("drizzle-orm/pg-core").PgColumn<{
|
|
286
|
+
name: "ensure_attempts";
|
|
287
|
+
tableName: "sidecar_allocation";
|
|
288
|
+
dataType: "number";
|
|
289
|
+
columnType: "PgInteger";
|
|
290
|
+
data: number;
|
|
291
|
+
driverParam: string | number;
|
|
292
|
+
notNull: true;
|
|
293
|
+
hasDefault: true;
|
|
294
|
+
isPrimaryKey: false;
|
|
295
|
+
isAutoincrement: false;
|
|
296
|
+
hasRuntimeDefault: false;
|
|
297
|
+
enumValues: undefined;
|
|
298
|
+
baseColumn: never;
|
|
299
|
+
identity: undefined;
|
|
300
|
+
generated: undefined;
|
|
301
|
+
}, {}, {}>;
|
|
302
|
+
destroyAttempts: import("drizzle-orm/pg-core").PgColumn<{
|
|
303
|
+
name: "destroy_attempts";
|
|
304
|
+
tableName: "sidecar_allocation";
|
|
305
|
+
dataType: "number";
|
|
306
|
+
columnType: "PgInteger";
|
|
307
|
+
data: number;
|
|
308
|
+
driverParam: string | number;
|
|
309
|
+
notNull: true;
|
|
310
|
+
hasDefault: true;
|
|
311
|
+
isPrimaryKey: false;
|
|
312
|
+
isAutoincrement: false;
|
|
313
|
+
hasRuntimeDefault: false;
|
|
314
|
+
enumValues: undefined;
|
|
315
|
+
baseColumn: never;
|
|
316
|
+
identity: undefined;
|
|
317
|
+
generated: undefined;
|
|
318
|
+
}, {}, {}>;
|
|
319
|
+
connectDeadline: import("drizzle-orm/pg-core").PgColumn<{
|
|
320
|
+
name: "connect_deadline";
|
|
321
|
+
tableName: "sidecar_allocation";
|
|
322
|
+
dataType: "date";
|
|
323
|
+
columnType: "PgTimestamp";
|
|
324
|
+
data: Date;
|
|
325
|
+
driverParam: string;
|
|
326
|
+
notNull: false;
|
|
327
|
+
hasDefault: false;
|
|
328
|
+
isPrimaryKey: false;
|
|
329
|
+
isAutoincrement: false;
|
|
330
|
+
hasRuntimeDefault: false;
|
|
331
|
+
enumValues: undefined;
|
|
332
|
+
baseColumn: never;
|
|
333
|
+
identity: undefined;
|
|
334
|
+
generated: undefined;
|
|
335
|
+
}, {}, {}>;
|
|
336
|
+
failureCode: import("drizzle-orm/pg-core").PgColumn<{
|
|
337
|
+
name: "failure_code";
|
|
338
|
+
tableName: "sidecar_allocation";
|
|
339
|
+
dataType: "string";
|
|
340
|
+
columnType: "PgText";
|
|
341
|
+
data: string;
|
|
342
|
+
driverParam: string;
|
|
343
|
+
notNull: false;
|
|
344
|
+
hasDefault: false;
|
|
345
|
+
isPrimaryKey: false;
|
|
346
|
+
isAutoincrement: false;
|
|
347
|
+
hasRuntimeDefault: false;
|
|
348
|
+
enumValues: [string, ...string[]];
|
|
349
|
+
baseColumn: never;
|
|
350
|
+
identity: undefined;
|
|
351
|
+
generated: undefined;
|
|
352
|
+
}, {}, {}>;
|
|
353
|
+
failureMessage: import("drizzle-orm/pg-core").PgColumn<{
|
|
354
|
+
name: "failure_message";
|
|
355
|
+
tableName: "sidecar_allocation";
|
|
356
|
+
dataType: "string";
|
|
357
|
+
columnType: "PgText";
|
|
358
|
+
data: string;
|
|
359
|
+
driverParam: string;
|
|
360
|
+
notNull: false;
|
|
361
|
+
hasDefault: false;
|
|
362
|
+
isPrimaryKey: false;
|
|
363
|
+
isAutoincrement: false;
|
|
364
|
+
hasRuntimeDefault: false;
|
|
365
|
+
enumValues: [string, ...string[]];
|
|
366
|
+
baseColumn: never;
|
|
367
|
+
identity: undefined;
|
|
368
|
+
generated: undefined;
|
|
369
|
+
}, {}, {}>;
|
|
370
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
371
|
+
name: "created_at";
|
|
372
|
+
tableName: "sidecar_allocation";
|
|
373
|
+
dataType: "date";
|
|
374
|
+
columnType: "PgTimestamp";
|
|
375
|
+
data: Date;
|
|
376
|
+
driverParam: string;
|
|
377
|
+
notNull: true;
|
|
378
|
+
hasDefault: true;
|
|
379
|
+
isPrimaryKey: false;
|
|
380
|
+
isAutoincrement: false;
|
|
381
|
+
hasRuntimeDefault: false;
|
|
382
|
+
enumValues: undefined;
|
|
383
|
+
baseColumn: never;
|
|
384
|
+
identity: undefined;
|
|
385
|
+
generated: undefined;
|
|
386
|
+
}, {}, {}>;
|
|
387
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
388
|
+
name: "updated_at";
|
|
389
|
+
tableName: "sidecar_allocation";
|
|
390
|
+
dataType: "date";
|
|
391
|
+
columnType: "PgTimestamp";
|
|
392
|
+
data: Date;
|
|
393
|
+
driverParam: string;
|
|
394
|
+
notNull: true;
|
|
395
|
+
hasDefault: true;
|
|
396
|
+
isPrimaryKey: false;
|
|
397
|
+
isAutoincrement: false;
|
|
398
|
+
hasRuntimeDefault: false;
|
|
399
|
+
enumValues: undefined;
|
|
400
|
+
baseColumn: never;
|
|
401
|
+
identity: undefined;
|
|
402
|
+
generated: undefined;
|
|
403
|
+
}, {}, {}>;
|
|
404
|
+
};
|
|
405
|
+
dialect: "pg";
|
|
406
|
+
}>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { check, index, integer, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
3
|
+
import { sidecar } from "./sidecar.js";
|
|
4
|
+
import { tenant } from "./tenants.js";
|
|
5
|
+
import { workflowRun } from "./workflow-run.js";
|
|
6
|
+
export const sidecarAllocation = pgTable("sidecar_allocation", {
|
|
7
|
+
id: text("id").primaryKey(),
|
|
8
|
+
anchorRunId: text("anchor_run_id")
|
|
9
|
+
.notNull()
|
|
10
|
+
.references(() => workflowRun.id, { onDelete: "cascade" }),
|
|
11
|
+
tenantId: text("tenant_id")
|
|
12
|
+
.notNull()
|
|
13
|
+
.references(() => tenant.id, { onDelete: "restrict" }),
|
|
14
|
+
provisionerId: text("provisioner_id").notNull(),
|
|
15
|
+
provisionerApiVersion: integer("provisioner_api_version")
|
|
16
|
+
.$type()
|
|
17
|
+
.notNull(),
|
|
18
|
+
provisionerBindingFingerprint: text("provisioner_binding_fingerprint").notNull(),
|
|
19
|
+
sidecarId: text("sidecar_id").references(() => sidecar.id, {
|
|
20
|
+
onDelete: "restrict",
|
|
21
|
+
}),
|
|
22
|
+
placementSharing: text("placement_sharing").$type().notNull(),
|
|
23
|
+
sidecarReuse: text("sidecar_reuse")
|
|
24
|
+
.$type()
|
|
25
|
+
.notNull()
|
|
26
|
+
.default("never"),
|
|
27
|
+
status: text("status")
|
|
28
|
+
.$type()
|
|
29
|
+
.notNull()
|
|
30
|
+
.default("pending"),
|
|
31
|
+
generation: integer("generation").notNull().default(0),
|
|
32
|
+
ensureAcceptedGeneration: integer("ensure_accepted_generation"),
|
|
33
|
+
externalRef: text("external_ref"),
|
|
34
|
+
nextAttemptAt: timestamp("next_attempt_at"),
|
|
35
|
+
reconciliationLeaseId: text("reconciliation_lease_id"),
|
|
36
|
+
reconciliationLeaseExpiresAt: timestamp("reconciliation_lease_expires_at"),
|
|
37
|
+
ensureAttempts: integer("ensure_attempts").notNull().default(0),
|
|
38
|
+
destroyAttempts: integer("destroy_attempts").notNull().default(0),
|
|
39
|
+
connectDeadline: timestamp("connect_deadline"),
|
|
40
|
+
failureCode: text("failure_code"),
|
|
41
|
+
failureMessage: text("failure_message"),
|
|
42
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
43
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
44
|
+
}, (t) => [
|
|
45
|
+
uniqueIndex("sidecar_allocation_anchor_run_idx").on(t.anchorRunId),
|
|
46
|
+
uniqueIndex("sidecar_allocation_active_sidecar_idx")
|
|
47
|
+
.on(t.sidecarId)
|
|
48
|
+
.where(sql `${t.status} in ('provisioning', 'allocated', 'replacing', 'releasing')`),
|
|
49
|
+
index("sidecar_allocation_sidecar_idx").on(t.sidecarId),
|
|
50
|
+
index("sidecar_allocation_reconciliation_idx")
|
|
51
|
+
.on(t.nextAttemptAt, t.createdAt)
|
|
52
|
+
.where(sql `${t.status} in ('pending', 'provisioning', 'allocated', 'replacing', 'releasing') and ${t.nextAttemptAt} is not null`),
|
|
53
|
+
check("sidecar_allocation_status_check", sql `${t.status} in ('pending', 'provisioning', 'allocated', 'replacing', 'releasing', 'released', 'failed')`),
|
|
54
|
+
check("sidecar_allocation_placement_check", sql `${t.placementSharing} = 'exclusive'`),
|
|
55
|
+
check("sidecar_allocation_generation_check", sql `${t.generation} >= 0`),
|
|
56
|
+
check("sidecar_allocation_accepted_generation_check", sql `${t.ensureAcceptedGeneration} is null or ${t.ensureAcceptedGeneration} <= ${t.generation}`),
|
|
57
|
+
]);
|
package/dist/schema/sidecar.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare const sidecar: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
26
26
|
columnType: "PgText";
|
|
27
27
|
data: string;
|
|
28
28
|
driverParam: string;
|
|
29
|
-
notNull:
|
|
29
|
+
notNull: false;
|
|
30
30
|
hasDefault: false;
|
|
31
31
|
isPrimaryKey: false;
|
|
32
32
|
isAutoincrement: false;
|
|
@@ -55,12 +55,29 @@ export declare const sidecar: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
|
55
55
|
}, {}, {
|
|
56
56
|
pgColumnBuilderBrand: "PgCustomColumnBuilderBrand";
|
|
57
57
|
}>;
|
|
58
|
+
credentialScope: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
|
+
name: "credential_scope";
|
|
60
|
+
tableName: "sidecar";
|
|
61
|
+
dataType: "string";
|
|
62
|
+
columnType: "PgText";
|
|
63
|
+
data: "shared" | "allocated";
|
|
64
|
+
driverParam: string;
|
|
65
|
+
notNull: true;
|
|
66
|
+
hasDefault: true;
|
|
67
|
+
isPrimaryKey: false;
|
|
68
|
+
isAutoincrement: false;
|
|
69
|
+
hasRuntimeDefault: false;
|
|
70
|
+
enumValues: ["shared", "allocated"];
|
|
71
|
+
baseColumn: never;
|
|
72
|
+
identity: undefined;
|
|
73
|
+
generated: undefined;
|
|
74
|
+
}, {}, {}>;
|
|
58
75
|
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
59
76
|
name: "status";
|
|
60
77
|
tableName: "sidecar";
|
|
61
78
|
dataType: "string";
|
|
62
79
|
columnType: "PgText";
|
|
63
|
-
data: "
|
|
80
|
+
data: "online" | "offline" | "error";
|
|
64
81
|
driverParam: string;
|
|
65
82
|
notNull: true;
|
|
66
83
|
hasDefault: true;
|