@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
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { index, jsonb, pgTable, text, timestamp, unique, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
2
|
+
import { asset } from "./assets.js";
|
|
3
|
+
import { principal } from "./principals.js";
|
|
4
|
+
import { tenant } from "./tenants.js";
|
|
5
|
+
// workflow_definition is the first-class definition entity for the workflow
|
|
6
|
+
// model: one row per deployable definition, with a version table alongside it.
|
|
7
|
+
//
|
|
8
|
+
// The definition body (system prompt, context/model config, tool packages) is
|
|
9
|
+
// not stored on this row -- it lives in the `workflow`-kind asset the row
|
|
10
|
+
// points at, and the run reads it back from there. `asset_id` is nullable at
|
|
11
|
+
// the schema level, but a runnable definition points at a materialized asset.
|
|
12
|
+
//
|
|
13
|
+
// Identity is selector-keyed on the wire-projection hash, not one definition
|
|
14
|
+
// per asset: a single asset (e.g. a monorepo package) backs many definitions
|
|
15
|
+
// distinguished by the content hash of their wire projection. `wire_hash` is
|
|
16
|
+
// that content handle; the unique index over `(asset_id, wire_hash)` keys
|
|
17
|
+
// identity so definitions sharing an asset but carrying different wire hashes
|
|
18
|
+
// resolve independently. `wire_hash` is nullable so definitions predating this
|
|
19
|
+
// key carry none; Postgres treats those NULLs as distinct.
|
|
20
|
+
export const workflowDefinition = pgTable("workflow_definition", {
|
|
21
|
+
id: text("id").primaryKey(),
|
|
22
|
+
tenantId: text("tenant_id")
|
|
23
|
+
.notNull()
|
|
24
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
25
|
+
// Nullable to match the weaker of the two definition sources: `asset`'s
|
|
26
|
+
// creator principal is `onDelete: "set null"`, so a workflow asset whose
|
|
27
|
+
// creator principal was removed carries no creator onto the definition.
|
|
28
|
+
creatorPrincipalId: text("creator_principal_id").references(() => principal.id),
|
|
29
|
+
// The asset holding this definition's body. `restrict`: the definition is
|
|
30
|
+
// the first-class entity, so deleting the asset must not cascade into
|
|
31
|
+
// deleting it.
|
|
32
|
+
assetId: text("asset_id").references(() => asset.id, {
|
|
33
|
+
onDelete: "restrict",
|
|
34
|
+
}),
|
|
35
|
+
// Content hash of this definition's wire projection: the selector that
|
|
36
|
+
// keys identity within an asset. Nullable so definitions predating the
|
|
37
|
+
// selector-keyed key carry none.
|
|
38
|
+
wireHash: text("wire_hash"),
|
|
39
|
+
name: text("name").notNull(),
|
|
40
|
+
description: text("description"),
|
|
41
|
+
// Grant requirements manifest, resolved at launch into materialized grants.
|
|
42
|
+
// Validated as GrantRequirement[] at parse time.
|
|
43
|
+
grantRequirements: jsonb("grant_requirements"),
|
|
44
|
+
// Model requirements manifest: the canonical model names + provider
|
|
45
|
+
// preferences a definition launched as a single interactive run resolves
|
|
46
|
+
// against the live tenant catalog into credential-bearing inference
|
|
47
|
+
// sources, fresh each launch. Non-null marks such a definition and gates
|
|
48
|
+
// the interactive-launch path; null for a definition deployed as a workflow,
|
|
49
|
+
// which supplies its sources at deploy time. Validated as ModelRequirements
|
|
50
|
+
// at parse time.
|
|
51
|
+
modelRequirements: jsonb("model_requirements"),
|
|
52
|
+
// Credential bindings manifest: maps a tool package's declared credential
|
|
53
|
+
// handle (package, handle) to a concrete credential resolved fresh at
|
|
54
|
+
// launch (by locator + provider + name against the tenant walk-up).
|
|
55
|
+
// Validated as CredentialBinding[] at parse time. A binding is a request
|
|
56
|
+
// the launch-time grant gate authorizes; it consents to nothing on its own.
|
|
57
|
+
credentialBindings: jsonb("credential_bindings"),
|
|
58
|
+
currentVersion: text("current_version").notNull().default("1"),
|
|
59
|
+
status: text("status", {
|
|
60
|
+
enum: ["deployed", "stopped"],
|
|
61
|
+
})
|
|
62
|
+
.notNull()
|
|
63
|
+
.default("deployed"),
|
|
64
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
65
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
66
|
+
}, (t) => [
|
|
67
|
+
index("workflow_definition_tenant_idx").on(t.tenantId, t.createdAt),
|
|
68
|
+
uniqueIndex("workflow_definition_asset_wire_hash_idx").on(t.assetId, t.wireHash),
|
|
69
|
+
]);
|
|
70
|
+
export const workflowDefinitionVersion = pgTable("workflow_definition_version", {
|
|
71
|
+
id: text("id").primaryKey(),
|
|
72
|
+
definitionId: text("definition_id")
|
|
73
|
+
.notNull()
|
|
74
|
+
.references(() => workflowDefinition.id, { onDelete: "cascade" }),
|
|
75
|
+
version: text("version").notNull(),
|
|
76
|
+
status: text("status", {
|
|
77
|
+
enum: ["active", "inactive", "failed"],
|
|
78
|
+
})
|
|
79
|
+
.notNull()
|
|
80
|
+
.default("active"),
|
|
81
|
+
// Hash of the wire bytes approved for this version, recorded at approval
|
|
82
|
+
// and read back during re-verify to detect drift. Null before approval is
|
|
83
|
+
// a legitimate state, so the column takes no NOT NULL constraint.
|
|
84
|
+
approvedWireHash: text("approved_wire_hash"),
|
|
85
|
+
// Serializable projection of the deploy-time capability walk, recorded
|
|
86
|
+
// at approval so a run materializes grants from it instead of re-reading
|
|
87
|
+
// and re-walking a workflow.json blob. Validated as GrantWalkSnapshot at
|
|
88
|
+
// parse time. Null before approval is a legitimate state, so the column
|
|
89
|
+
// takes no NOT NULL constraint.
|
|
90
|
+
grantSnapshot: jsonb("grant_snapshot"),
|
|
91
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
92
|
+
}, (t) => [
|
|
93
|
+
// Unique per definition so rollback-by-version resolves to one row. The
|
|
94
|
+
// mirror source `agent_version` omits this; the fresh table constrains it.
|
|
95
|
+
unique("workflow_definition_version_definition_version").on(t.definitionId, t.version),
|
|
96
|
+
index("workflow_definition_version_definition_idx").on(t.definitionId),
|
|
97
|
+
]);
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
export declare const workflowRunDispatchStatuses: readonly ["pending", "acknowledged", "settled", "failed"];
|
|
2
|
+
export type WorkflowRunDispatchStatus = (typeof workflowRunDispatchStatuses)[number];
|
|
3
|
+
export declare const workflowRunDispatchKinds: readonly ["mail", "signal"];
|
|
4
|
+
export type WorkflowRunDispatchKind = (typeof workflowRunDispatchKinds)[number];
|
|
5
|
+
/**
|
|
6
|
+
* Hub-owned delivery state for one inbound workflow message. The raw payload
|
|
7
|
+
* remains durable until the workflow-run Git claim-check reaches `consumed`;
|
|
8
|
+
* a sidecar-local enqueue acknowledgement alone does not settle the row.
|
|
9
|
+
*/
|
|
10
|
+
export declare const workflowRunDispatch: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
11
|
+
name: "workflow_run_dispatch";
|
|
12
|
+
schema: undefined;
|
|
13
|
+
columns: {
|
|
14
|
+
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
15
|
+
name: "id";
|
|
16
|
+
tableName: "workflow_run_dispatch";
|
|
17
|
+
dataType: "string";
|
|
18
|
+
columnType: "PgText";
|
|
19
|
+
data: string;
|
|
20
|
+
driverParam: string;
|
|
21
|
+
notNull: true;
|
|
22
|
+
hasDefault: false;
|
|
23
|
+
isPrimaryKey: true;
|
|
24
|
+
isAutoincrement: false;
|
|
25
|
+
hasRuntimeDefault: false;
|
|
26
|
+
enumValues: [string, ...string[]];
|
|
27
|
+
baseColumn: never;
|
|
28
|
+
identity: undefined;
|
|
29
|
+
generated: undefined;
|
|
30
|
+
}, {}, {}>;
|
|
31
|
+
anchorRunId: import("drizzle-orm/pg-core").PgColumn<{
|
|
32
|
+
name: "anchor_run_id";
|
|
33
|
+
tableName: "workflow_run_dispatch";
|
|
34
|
+
dataType: "string";
|
|
35
|
+
columnType: "PgText";
|
|
36
|
+
data: string;
|
|
37
|
+
driverParam: string;
|
|
38
|
+
notNull: true;
|
|
39
|
+
hasDefault: false;
|
|
40
|
+
isPrimaryKey: false;
|
|
41
|
+
isAutoincrement: false;
|
|
42
|
+
hasRuntimeDefault: false;
|
|
43
|
+
enumValues: [string, ...string[]];
|
|
44
|
+
baseColumn: never;
|
|
45
|
+
identity: undefined;
|
|
46
|
+
generated: undefined;
|
|
47
|
+
}, {}, {}>;
|
|
48
|
+
messageId: import("drizzle-orm/pg-core").PgColumn<{
|
|
49
|
+
name: "message_id";
|
|
50
|
+
tableName: "workflow_run_dispatch";
|
|
51
|
+
dataType: "string";
|
|
52
|
+
columnType: "PgText";
|
|
53
|
+
data: string;
|
|
54
|
+
driverParam: string;
|
|
55
|
+
notNull: true;
|
|
56
|
+
hasDefault: false;
|
|
57
|
+
isPrimaryKey: false;
|
|
58
|
+
isAutoincrement: false;
|
|
59
|
+
hasRuntimeDefault: false;
|
|
60
|
+
enumValues: [string, ...string[]];
|
|
61
|
+
baseColumn: never;
|
|
62
|
+
identity: undefined;
|
|
63
|
+
generated: undefined;
|
|
64
|
+
}, {}, {}>;
|
|
65
|
+
kind: import("drizzle-orm/pg-core").PgColumn<{
|
|
66
|
+
name: "kind";
|
|
67
|
+
tableName: "workflow_run_dispatch";
|
|
68
|
+
dataType: "string";
|
|
69
|
+
columnType: "PgText";
|
|
70
|
+
data: "signal" | "mail";
|
|
71
|
+
driverParam: string;
|
|
72
|
+
notNull: true;
|
|
73
|
+
hasDefault: true;
|
|
74
|
+
isPrimaryKey: false;
|
|
75
|
+
isAutoincrement: false;
|
|
76
|
+
hasRuntimeDefault: false;
|
|
77
|
+
enumValues: [string, ...string[]];
|
|
78
|
+
baseColumn: never;
|
|
79
|
+
identity: undefined;
|
|
80
|
+
generated: undefined;
|
|
81
|
+
}, {}, {
|
|
82
|
+
$type: "signal" | "mail";
|
|
83
|
+
}>;
|
|
84
|
+
rawMessage: import("drizzle-orm/pg-core").PgColumn<{
|
|
85
|
+
name: "raw_message";
|
|
86
|
+
tableName: "workflow_run_dispatch";
|
|
87
|
+
dataType: "custom";
|
|
88
|
+
columnType: "PgCustomColumn";
|
|
89
|
+
data: Uint8Array<ArrayBufferLike>;
|
|
90
|
+
driverParam: Uint8Array<ArrayBufferLike>;
|
|
91
|
+
notNull: true;
|
|
92
|
+
hasDefault: false;
|
|
93
|
+
isPrimaryKey: false;
|
|
94
|
+
isAutoincrement: false;
|
|
95
|
+
hasRuntimeDefault: false;
|
|
96
|
+
enumValues: undefined;
|
|
97
|
+
baseColumn: never;
|
|
98
|
+
identity: undefined;
|
|
99
|
+
generated: undefined;
|
|
100
|
+
}, {}, {
|
|
101
|
+
pgColumnBuilderBrand: "PgCustomColumnBuilderBrand";
|
|
102
|
+
}>;
|
|
103
|
+
stepGrants: import("drizzle-orm/pg-core").PgColumn<{
|
|
104
|
+
name: "step_grants";
|
|
105
|
+
tableName: "workflow_run_dispatch";
|
|
106
|
+
dataType: "json";
|
|
107
|
+
columnType: "PgJsonb";
|
|
108
|
+
data: unknown;
|
|
109
|
+
driverParam: unknown;
|
|
110
|
+
notNull: true;
|
|
111
|
+
hasDefault: false;
|
|
112
|
+
isPrimaryKey: false;
|
|
113
|
+
isAutoincrement: false;
|
|
114
|
+
hasRuntimeDefault: false;
|
|
115
|
+
enumValues: undefined;
|
|
116
|
+
baseColumn: never;
|
|
117
|
+
identity: undefined;
|
|
118
|
+
generated: undefined;
|
|
119
|
+
}, {}, {}>;
|
|
120
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
121
|
+
name: "status";
|
|
122
|
+
tableName: "workflow_run_dispatch";
|
|
123
|
+
dataType: "string";
|
|
124
|
+
columnType: "PgText";
|
|
125
|
+
data: "failed" | "pending" | "acknowledged" | "settled";
|
|
126
|
+
driverParam: string;
|
|
127
|
+
notNull: true;
|
|
128
|
+
hasDefault: true;
|
|
129
|
+
isPrimaryKey: false;
|
|
130
|
+
isAutoincrement: false;
|
|
131
|
+
hasRuntimeDefault: false;
|
|
132
|
+
enumValues: [string, ...string[]];
|
|
133
|
+
baseColumn: never;
|
|
134
|
+
identity: undefined;
|
|
135
|
+
generated: undefined;
|
|
136
|
+
}, {}, {
|
|
137
|
+
$type: "failed" | "pending" | "acknowledged" | "settled";
|
|
138
|
+
}>;
|
|
139
|
+
acknowledgedGeneration: import("drizzle-orm/pg-core").PgColumn<{
|
|
140
|
+
name: "acknowledged_generation";
|
|
141
|
+
tableName: "workflow_run_dispatch";
|
|
142
|
+
dataType: "number";
|
|
143
|
+
columnType: "PgInteger";
|
|
144
|
+
data: number;
|
|
145
|
+
driverParam: string | number;
|
|
146
|
+
notNull: false;
|
|
147
|
+
hasDefault: false;
|
|
148
|
+
isPrimaryKey: false;
|
|
149
|
+
isAutoincrement: false;
|
|
150
|
+
hasRuntimeDefault: false;
|
|
151
|
+
enumValues: undefined;
|
|
152
|
+
baseColumn: never;
|
|
153
|
+
identity: undefined;
|
|
154
|
+
generated: undefined;
|
|
155
|
+
}, {}, {}>;
|
|
156
|
+
attemptCount: import("drizzle-orm/pg-core").PgColumn<{
|
|
157
|
+
name: "attempt_count";
|
|
158
|
+
tableName: "workflow_run_dispatch";
|
|
159
|
+
dataType: "number";
|
|
160
|
+
columnType: "PgInteger";
|
|
161
|
+
data: number;
|
|
162
|
+
driverParam: string | number;
|
|
163
|
+
notNull: true;
|
|
164
|
+
hasDefault: true;
|
|
165
|
+
isPrimaryKey: false;
|
|
166
|
+
isAutoincrement: false;
|
|
167
|
+
hasRuntimeDefault: false;
|
|
168
|
+
enumValues: undefined;
|
|
169
|
+
baseColumn: never;
|
|
170
|
+
identity: undefined;
|
|
171
|
+
generated: undefined;
|
|
172
|
+
}, {}, {}>;
|
|
173
|
+
nextAttemptAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
174
|
+
name: "next_attempt_at";
|
|
175
|
+
tableName: "workflow_run_dispatch";
|
|
176
|
+
dataType: "date";
|
|
177
|
+
columnType: "PgTimestamp";
|
|
178
|
+
data: Date;
|
|
179
|
+
driverParam: string;
|
|
180
|
+
notNull: false;
|
|
181
|
+
hasDefault: true;
|
|
182
|
+
isPrimaryKey: false;
|
|
183
|
+
isAutoincrement: false;
|
|
184
|
+
hasRuntimeDefault: false;
|
|
185
|
+
enumValues: undefined;
|
|
186
|
+
baseColumn: never;
|
|
187
|
+
identity: undefined;
|
|
188
|
+
generated: undefined;
|
|
189
|
+
}, {}, {}>;
|
|
190
|
+
deliveryLeaseId: import("drizzle-orm/pg-core").PgColumn<{
|
|
191
|
+
name: "delivery_lease_id";
|
|
192
|
+
tableName: "workflow_run_dispatch";
|
|
193
|
+
dataType: "string";
|
|
194
|
+
columnType: "PgText";
|
|
195
|
+
data: string;
|
|
196
|
+
driverParam: string;
|
|
197
|
+
notNull: false;
|
|
198
|
+
hasDefault: false;
|
|
199
|
+
isPrimaryKey: false;
|
|
200
|
+
isAutoincrement: false;
|
|
201
|
+
hasRuntimeDefault: false;
|
|
202
|
+
enumValues: [string, ...string[]];
|
|
203
|
+
baseColumn: never;
|
|
204
|
+
identity: undefined;
|
|
205
|
+
generated: undefined;
|
|
206
|
+
}, {}, {}>;
|
|
207
|
+
deliveryLeaseExpiresAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
208
|
+
name: "delivery_lease_expires_at";
|
|
209
|
+
tableName: "workflow_run_dispatch";
|
|
210
|
+
dataType: "date";
|
|
211
|
+
columnType: "PgTimestamp";
|
|
212
|
+
data: Date;
|
|
213
|
+
driverParam: string;
|
|
214
|
+
notNull: false;
|
|
215
|
+
hasDefault: false;
|
|
216
|
+
isPrimaryKey: false;
|
|
217
|
+
isAutoincrement: false;
|
|
218
|
+
hasRuntimeDefault: false;
|
|
219
|
+
enumValues: undefined;
|
|
220
|
+
baseColumn: never;
|
|
221
|
+
identity: undefined;
|
|
222
|
+
generated: undefined;
|
|
223
|
+
}, {}, {}>;
|
|
224
|
+
failureCode: import("drizzle-orm/pg-core").PgColumn<{
|
|
225
|
+
name: "failure_code";
|
|
226
|
+
tableName: "workflow_run_dispatch";
|
|
227
|
+
dataType: "string";
|
|
228
|
+
columnType: "PgText";
|
|
229
|
+
data: string;
|
|
230
|
+
driverParam: string;
|
|
231
|
+
notNull: false;
|
|
232
|
+
hasDefault: false;
|
|
233
|
+
isPrimaryKey: false;
|
|
234
|
+
isAutoincrement: false;
|
|
235
|
+
hasRuntimeDefault: false;
|
|
236
|
+
enumValues: [string, ...string[]];
|
|
237
|
+
baseColumn: never;
|
|
238
|
+
identity: undefined;
|
|
239
|
+
generated: undefined;
|
|
240
|
+
}, {}, {}>;
|
|
241
|
+
failureMessage: import("drizzle-orm/pg-core").PgColumn<{
|
|
242
|
+
name: "failure_message";
|
|
243
|
+
tableName: "workflow_run_dispatch";
|
|
244
|
+
dataType: "string";
|
|
245
|
+
columnType: "PgText";
|
|
246
|
+
data: string;
|
|
247
|
+
driverParam: string;
|
|
248
|
+
notNull: false;
|
|
249
|
+
hasDefault: false;
|
|
250
|
+
isPrimaryKey: false;
|
|
251
|
+
isAutoincrement: false;
|
|
252
|
+
hasRuntimeDefault: false;
|
|
253
|
+
enumValues: [string, ...string[]];
|
|
254
|
+
baseColumn: never;
|
|
255
|
+
identity: undefined;
|
|
256
|
+
generated: undefined;
|
|
257
|
+
}, {}, {}>;
|
|
258
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
259
|
+
name: "created_at";
|
|
260
|
+
tableName: "workflow_run_dispatch";
|
|
261
|
+
dataType: "date";
|
|
262
|
+
columnType: "PgTimestamp";
|
|
263
|
+
data: Date;
|
|
264
|
+
driverParam: string;
|
|
265
|
+
notNull: true;
|
|
266
|
+
hasDefault: true;
|
|
267
|
+
isPrimaryKey: false;
|
|
268
|
+
isAutoincrement: false;
|
|
269
|
+
hasRuntimeDefault: false;
|
|
270
|
+
enumValues: undefined;
|
|
271
|
+
baseColumn: never;
|
|
272
|
+
identity: undefined;
|
|
273
|
+
generated: undefined;
|
|
274
|
+
}, {}, {}>;
|
|
275
|
+
updatedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
276
|
+
name: "updated_at";
|
|
277
|
+
tableName: "workflow_run_dispatch";
|
|
278
|
+
dataType: "date";
|
|
279
|
+
columnType: "PgTimestamp";
|
|
280
|
+
data: Date;
|
|
281
|
+
driverParam: string;
|
|
282
|
+
notNull: true;
|
|
283
|
+
hasDefault: true;
|
|
284
|
+
isPrimaryKey: false;
|
|
285
|
+
isAutoincrement: false;
|
|
286
|
+
hasRuntimeDefault: false;
|
|
287
|
+
enumValues: undefined;
|
|
288
|
+
baseColumn: never;
|
|
289
|
+
identity: undefined;
|
|
290
|
+
generated: undefined;
|
|
291
|
+
}, {}, {}>;
|
|
292
|
+
acknowledgedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
293
|
+
name: "acknowledged_at";
|
|
294
|
+
tableName: "workflow_run_dispatch";
|
|
295
|
+
dataType: "date";
|
|
296
|
+
columnType: "PgTimestamp";
|
|
297
|
+
data: Date;
|
|
298
|
+
driverParam: string;
|
|
299
|
+
notNull: false;
|
|
300
|
+
hasDefault: false;
|
|
301
|
+
isPrimaryKey: false;
|
|
302
|
+
isAutoincrement: false;
|
|
303
|
+
hasRuntimeDefault: false;
|
|
304
|
+
enumValues: undefined;
|
|
305
|
+
baseColumn: never;
|
|
306
|
+
identity: undefined;
|
|
307
|
+
generated: undefined;
|
|
308
|
+
}, {}, {}>;
|
|
309
|
+
settledAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
310
|
+
name: "settled_at";
|
|
311
|
+
tableName: "workflow_run_dispatch";
|
|
312
|
+
dataType: "date";
|
|
313
|
+
columnType: "PgTimestamp";
|
|
314
|
+
data: Date;
|
|
315
|
+
driverParam: string;
|
|
316
|
+
notNull: false;
|
|
317
|
+
hasDefault: false;
|
|
318
|
+
isPrimaryKey: false;
|
|
319
|
+
isAutoincrement: false;
|
|
320
|
+
hasRuntimeDefault: false;
|
|
321
|
+
enumValues: undefined;
|
|
322
|
+
baseColumn: never;
|
|
323
|
+
identity: undefined;
|
|
324
|
+
generated: undefined;
|
|
325
|
+
}, {}, {}>;
|
|
326
|
+
};
|
|
327
|
+
dialect: "pg";
|
|
328
|
+
}>;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { check, index, integer, jsonb, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
3
|
+
import { bytea } from "./column-types.js";
|
|
4
|
+
import { workflowRun } from "./workflow-run.js";
|
|
5
|
+
export const workflowRunDispatchStatuses = [
|
|
6
|
+
"pending",
|
|
7
|
+
"acknowledged",
|
|
8
|
+
"settled",
|
|
9
|
+
"failed",
|
|
10
|
+
];
|
|
11
|
+
export const workflowRunDispatchKinds = ["mail", "signal"];
|
|
12
|
+
/**
|
|
13
|
+
* Hub-owned delivery state for one inbound workflow message. The raw payload
|
|
14
|
+
* remains durable until the workflow-run Git claim-check reaches `consumed`;
|
|
15
|
+
* a sidecar-local enqueue acknowledgement alone does not settle the row.
|
|
16
|
+
*/
|
|
17
|
+
export const workflowRunDispatch = pgTable("workflow_run_dispatch", {
|
|
18
|
+
id: text("id").primaryKey(),
|
|
19
|
+
anchorRunId: text("anchor_run_id")
|
|
20
|
+
.notNull()
|
|
21
|
+
.references(() => workflowRun.id, { onDelete: "cascade" }),
|
|
22
|
+
messageId: text("message_id").notNull(),
|
|
23
|
+
kind: text("kind")
|
|
24
|
+
.$type()
|
|
25
|
+
.notNull()
|
|
26
|
+
.default("mail"),
|
|
27
|
+
rawMessage: bytea("raw_message").notNull(),
|
|
28
|
+
stepGrants: jsonb("step_grants").notNull(),
|
|
29
|
+
status: text("status")
|
|
30
|
+
.$type()
|
|
31
|
+
.notNull()
|
|
32
|
+
.default("pending"),
|
|
33
|
+
acknowledgedGeneration: integer("acknowledged_generation"),
|
|
34
|
+
attemptCount: integer("attempt_count").notNull().default(0),
|
|
35
|
+
nextAttemptAt: timestamp("next_attempt_at").defaultNow(),
|
|
36
|
+
deliveryLeaseId: text("delivery_lease_id"),
|
|
37
|
+
deliveryLeaseExpiresAt: timestamp("delivery_lease_expires_at"),
|
|
38
|
+
failureCode: text("failure_code"),
|
|
39
|
+
failureMessage: text("failure_message"),
|
|
40
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
41
|
+
updatedAt: timestamp("updated_at").notNull().defaultNow(),
|
|
42
|
+
acknowledgedAt: timestamp("acknowledged_at"),
|
|
43
|
+
settledAt: timestamp("settled_at"),
|
|
44
|
+
}, (t) => [
|
|
45
|
+
uniqueIndex("workflow_run_dispatch_anchor_message_idx").on(t.anchorRunId, t.messageId),
|
|
46
|
+
index("workflow_run_dispatch_delivery_idx")
|
|
47
|
+
.on(t.nextAttemptAt, t.createdAt)
|
|
48
|
+
.where(sql `${t.status} = 'pending'`),
|
|
49
|
+
index("workflow_run_dispatch_anchor_status_idx").on(t.anchorRunId, t.status),
|
|
50
|
+
check("workflow_run_dispatch_status_check", sql `${t.status} in ('pending', 'acknowledged', 'settled', 'failed')`),
|
|
51
|
+
check("workflow_run_dispatch_kind_check", sql `${t.kind} in ('mail', 'signal')`),
|
|
52
|
+
check("workflow_run_dispatch_attempt_count_check", sql `${t.attemptCount} >= 0`),
|
|
53
|
+
check("workflow_run_dispatch_acknowledged_generation_check", sql `${t.acknowledgedGeneration} is null or ${t.acknowledgedGeneration} >= 0`),
|
|
54
|
+
check("workflow_run_dispatch_acknowledged_state_check", sql `${t.status} <> 'acknowledged' or ${t.acknowledgedGeneration} is not null`),
|
|
55
|
+
check("workflow_run_dispatch_pending_schedule_check", sql `${t.status} <> 'pending' or ${t.nextAttemptAt} is not null`),
|
|
56
|
+
]);
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
name: "workflow_deployment";
|
|
1
|
+
export declare const workflowRunExecution: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "workflow_run_execution";
|
|
4
3
|
schema: undefined;
|
|
5
4
|
columns: {
|
|
6
5
|
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
7
6
|
name: "id";
|
|
8
|
-
tableName: "
|
|
7
|
+
tableName: "workflow_run_execution";
|
|
9
8
|
dataType: "string";
|
|
10
9
|
columnType: "PgText";
|
|
11
10
|
data: string;
|
|
@@ -20,9 +19,9 @@ export declare const workflowDeployment: import("drizzle-orm/pg-core").PgTableWi
|
|
|
20
19
|
identity: undefined;
|
|
21
20
|
generated: undefined;
|
|
22
21
|
}, {}, {}>;
|
|
23
|
-
|
|
24
|
-
name: "
|
|
25
|
-
tableName: "
|
|
22
|
+
runId: import("drizzle-orm/pg-core").PgColumn<{
|
|
23
|
+
name: "run_id";
|
|
24
|
+
tableName: "workflow_run_execution";
|
|
26
25
|
dataType: "string";
|
|
27
26
|
columnType: "PgText";
|
|
28
27
|
data: string;
|
|
@@ -37,9 +36,9 @@ export declare const workflowDeployment: import("drizzle-orm/pg-core").PgTableWi
|
|
|
37
36
|
identity: undefined;
|
|
38
37
|
generated: undefined;
|
|
39
38
|
}, {}, {}>;
|
|
40
|
-
|
|
41
|
-
name: "
|
|
42
|
-
tableName: "
|
|
39
|
+
messageId: import("drizzle-orm/pg-core").PgColumn<{
|
|
40
|
+
name: "message_id";
|
|
41
|
+
tableName: "workflow_run_execution";
|
|
43
42
|
dataType: "string";
|
|
44
43
|
columnType: "PgText";
|
|
45
44
|
data: string;
|
|
@@ -54,72 +53,70 @@ export declare const workflowDeployment: import("drizzle-orm/pg-core").PgTableWi
|
|
|
54
53
|
identity: undefined;
|
|
55
54
|
generated: undefined;
|
|
56
55
|
}, {}, {}>;
|
|
57
|
-
|
|
58
|
-
name: "
|
|
59
|
-
tableName: "
|
|
56
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
57
|
+
name: "status";
|
|
58
|
+
tableName: "workflow_run_execution";
|
|
60
59
|
dataType: "string";
|
|
61
60
|
columnType: "PgText";
|
|
62
|
-
data:
|
|
61
|
+
data: "failed" | "running" | "completed";
|
|
63
62
|
driverParam: string;
|
|
64
63
|
notNull: true;
|
|
65
|
-
hasDefault:
|
|
64
|
+
hasDefault: true;
|
|
66
65
|
isPrimaryKey: false;
|
|
67
66
|
isAutoincrement: false;
|
|
68
67
|
hasRuntimeDefault: false;
|
|
69
|
-
enumValues: [
|
|
68
|
+
enumValues: ["running", "completed", "failed"];
|
|
70
69
|
baseColumn: never;
|
|
71
70
|
identity: undefined;
|
|
72
71
|
generated: undefined;
|
|
73
72
|
}, {}, {}>;
|
|
74
|
-
|
|
75
|
-
name: "
|
|
76
|
-
tableName: "
|
|
77
|
-
dataType: "
|
|
78
|
-
columnType: "
|
|
79
|
-
data:
|
|
73
|
+
startedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
74
|
+
name: "started_at";
|
|
75
|
+
tableName: "workflow_run_execution";
|
|
76
|
+
dataType: "date";
|
|
77
|
+
columnType: "PgTimestamp";
|
|
78
|
+
data: Date;
|
|
80
79
|
driverParam: string;
|
|
81
|
-
notNull:
|
|
82
|
-
hasDefault:
|
|
80
|
+
notNull: true;
|
|
81
|
+
hasDefault: true;
|
|
83
82
|
isPrimaryKey: false;
|
|
84
83
|
isAutoincrement: false;
|
|
85
84
|
hasRuntimeDefault: false;
|
|
86
|
-
enumValues:
|
|
85
|
+
enumValues: undefined;
|
|
87
86
|
baseColumn: never;
|
|
88
87
|
identity: undefined;
|
|
89
88
|
generated: undefined;
|
|
90
89
|
}, {}, {}>;
|
|
91
|
-
|
|
92
|
-
name: "
|
|
93
|
-
tableName: "
|
|
94
|
-
dataType: "
|
|
95
|
-
columnType: "
|
|
96
|
-
data:
|
|
90
|
+
endedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
91
|
+
name: "ended_at";
|
|
92
|
+
tableName: "workflow_run_execution";
|
|
93
|
+
dataType: "date";
|
|
94
|
+
columnType: "PgTimestamp";
|
|
95
|
+
data: Date;
|
|
97
96
|
driverParam: string;
|
|
98
|
-
notNull:
|
|
99
|
-
hasDefault:
|
|
97
|
+
notNull: false;
|
|
98
|
+
hasDefault: false;
|
|
100
99
|
isPrimaryKey: false;
|
|
101
100
|
isAutoincrement: false;
|
|
102
101
|
hasRuntimeDefault: false;
|
|
103
|
-
enumValues:
|
|
102
|
+
enumValues: undefined;
|
|
104
103
|
baseColumn: never;
|
|
105
104
|
identity: undefined;
|
|
106
105
|
generated: undefined;
|
|
107
|
-
}, {}, {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
columnType: "PgTimestamp";
|
|
115
|
-
data: Date;
|
|
106
|
+
}, {}, {}>;
|
|
107
|
+
failureReason: import("drizzle-orm/pg-core").PgColumn<{
|
|
108
|
+
name: "failure_reason";
|
|
109
|
+
tableName: "workflow_run_execution";
|
|
110
|
+
dataType: "string";
|
|
111
|
+
columnType: "PgText";
|
|
112
|
+
data: string;
|
|
116
113
|
driverParam: string;
|
|
117
|
-
notNull:
|
|
118
|
-
hasDefault:
|
|
114
|
+
notNull: false;
|
|
115
|
+
hasDefault: false;
|
|
119
116
|
isPrimaryKey: false;
|
|
120
117
|
isAutoincrement: false;
|
|
121
118
|
hasRuntimeDefault: false;
|
|
122
|
-
enumValues:
|
|
119
|
+
enumValues: [string, ...string[]];
|
|
123
120
|
baseColumn: never;
|
|
124
121
|
identity: undefined;
|
|
125
122
|
generated: undefined;
|