@intx/db 0.2.2 → 0.4.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 +13 -2
- package/dist/approval-store.d.ts +59 -0
- package/dist/approval-store.js +92 -0
- package/dist/asset-resolution.d.ts +2 -2
- package/dist/backfill-principal-keys.d.ts +9 -0
- package/dist/backfill-principal-keys.js +51 -0
- package/dist/client.d.ts +37 -2
- package/dist/client.js +6 -0
- package/dist/config.d.ts +1 -0
- package/dist/config.js +2 -0
- package/dist/connection.js +12 -8
- package/dist/credential-resolution.d.ts +181 -20
- package/dist/credential-resolution.js +251 -3
- package/dist/grant-store.js +35 -13
- package/dist/index.d.ts +20 -5
- package/dist/index.js +19 -5
- package/dist/model-source-resolution.d.ts +54 -7
- package/dist/model-source-resolution.js +177 -22
- package/dist/parse-row.d.ts +245 -34
- package/dist/parse-row.js +117 -18
- package/dist/principal-key-store.d.ts +51 -0
- package/dist/principal-key-store.js +82 -0
- package/dist/principal-store.d.ts +44 -0
- package/dist/principal-store.js +67 -0
- 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 +57 -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 +10 -4
- package/dist/schema/index.js +10 -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/{workflow-deployments.d.ts → principal-keys.d.ts} +29 -32
- package/dist/schema/principal-keys.js +28 -0
- 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 +385 -0
- package/dist/schema/sidecar-allocation.js +53 -0
- package/dist/schema/sidecar.d.ts +2 -2
- package/dist/schema/sidecar.js +3 -1
- package/dist/schema/signal-correlations.d.ts +177 -0
- package/dist/schema/signal-correlations.js +31 -0
- package/dist/schema/tenants.js +13 -3
- 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-probe.d.ts +358 -0
- package/dist/schema/workflow-probe.js +51 -0
- package/dist/schema/workflow-run-dispatch.d.ts +345 -0
- package/dist/schema/workflow-run-dispatch.js +63 -0
- package/dist/schema/{agent-assets.d.ts → workflow-run-execution.d.ts} +44 -27
- 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} +61 -66
- package/dist/schema/workflow-run.js +110 -0
- package/dist/sender-key-resolver.d.ts +91 -0
- package/dist/sender-key-resolver.js +184 -0
- package/dist/sidecar-allocation-store.d.ts +206 -0
- package/dist/sidecar-allocation-store.js +714 -0
- package/dist/signal-correlation-store.d.ts +36 -0
- package/dist/signal-correlation-store.js +63 -0
- package/dist/signer-identity.d.ts +12 -0
- package/dist/signer-identity.js +15 -0
- package/dist/tenant-hierarchy.d.ts +4 -1
- package/dist/tenant-hierarchy.js +37 -5
- package/dist/workflow-definition-store.d.ts +55 -0
- package/dist/workflow-definition-store.js +93 -0
- package/dist/workflow-probe-store.d.ts +47 -0
- package/dist/workflow-probe-store.js +124 -0
- package/dist/workflow-run-dispatch-store.d.ts +83 -0
- package/dist/workflow-run-dispatch-store.js +308 -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/0085_add_approval_run_idx.sql +1 -0
- package/migrations/0086_cool_human_cannonball.sql +1 -0
- package/migrations/0087_drop_sidecar_placement.sql +3 -0
- package/migrations/0088_thick_sprite.sql +32 -0
- package/migrations/0089_tense_selene.sql +13 -0
- package/migrations/0090_tenant_domain_lower_unique.sql +2 -0
- package/migrations/0091_workflow_run_dispatch_sender_address.sql +21 -0
- package/migrations/0092_sidecar_destroy_failed.sql +4 -0
- package/migrations/0093_sidecar_initialization.sql +2 -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/0085_snapshot.json +4111 -0
- package/migrations/meta/0086_snapshot.json +4117 -0
- package/migrations/meta/0087_snapshot.json +4100 -0
- package/migrations/meta/0088_snapshot.json +4286 -0
- package/migrations/meta/0089_snapshot.json +4376 -0
- package/migrations/meta/0090_snapshot.json +4387 -0
- package/migrations/meta/0091_snapshot.json +4397 -0
- package/migrations/meta/0092_snapshot.json +4397 -0
- package/migrations/meta/0093_snapshot.json +4407 -0
- package/migrations/meta/_journal.json +392 -0
- package/package.json +7 -3
- 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,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Immutable inputs required to recreate an exclusively placed workflow on a
|
|
3
|
+
* replacement sidecar. Secrets are deliberately excluded: source offering
|
|
4
|
+
* ids are resolved against the current catalog and principal authority when a
|
|
5
|
+
* generation is launched.
|
|
6
|
+
*/
|
|
7
|
+
export declare const workflowRunLaunchSpec: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
8
|
+
name: "workflow_run_launch_spec";
|
|
9
|
+
schema: undefined;
|
|
10
|
+
columns: {
|
|
11
|
+
anchorRunId: import("drizzle-orm/pg-core").PgColumn<{
|
|
12
|
+
name: "anchor_run_id";
|
|
13
|
+
tableName: "workflow_run_launch_spec";
|
|
14
|
+
dataType: "string";
|
|
15
|
+
columnType: "PgText";
|
|
16
|
+
data: string;
|
|
17
|
+
driverParam: string;
|
|
18
|
+
notNull: true;
|
|
19
|
+
hasDefault: false;
|
|
20
|
+
isPrimaryKey: true;
|
|
21
|
+
isAutoincrement: false;
|
|
22
|
+
hasRuntimeDefault: false;
|
|
23
|
+
enumValues: [string, ...string[]];
|
|
24
|
+
baseColumn: never;
|
|
25
|
+
identity: undefined;
|
|
26
|
+
generated: undefined;
|
|
27
|
+
}, {}, {}>;
|
|
28
|
+
schemaVersion: import("drizzle-orm/pg-core").PgColumn<{
|
|
29
|
+
name: "schema_version";
|
|
30
|
+
tableName: "workflow_run_launch_spec";
|
|
31
|
+
dataType: "number";
|
|
32
|
+
columnType: "PgInteger";
|
|
33
|
+
data: number;
|
|
34
|
+
driverParam: string | number;
|
|
35
|
+
notNull: true;
|
|
36
|
+
hasDefault: true;
|
|
37
|
+
isPrimaryKey: false;
|
|
38
|
+
isAutoincrement: false;
|
|
39
|
+
hasRuntimeDefault: false;
|
|
40
|
+
enumValues: undefined;
|
|
41
|
+
baseColumn: never;
|
|
42
|
+
identity: undefined;
|
|
43
|
+
generated: undefined;
|
|
44
|
+
}, {}, {}>;
|
|
45
|
+
sessionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
46
|
+
name: "session_id";
|
|
47
|
+
tableName: "workflow_run_launch_spec";
|
|
48
|
+
dataType: "string";
|
|
49
|
+
columnType: "PgText";
|
|
50
|
+
data: string;
|
|
51
|
+
driverParam: string;
|
|
52
|
+
notNull: true;
|
|
53
|
+
hasDefault: false;
|
|
54
|
+
isPrimaryKey: false;
|
|
55
|
+
isAutoincrement: false;
|
|
56
|
+
hasRuntimeDefault: false;
|
|
57
|
+
enumValues: [string, ...string[]];
|
|
58
|
+
baseColumn: never;
|
|
59
|
+
identity: undefined;
|
|
60
|
+
generated: undefined;
|
|
61
|
+
}, {}, {}>;
|
|
62
|
+
deploymentDomain: import("drizzle-orm/pg-core").PgColumn<{
|
|
63
|
+
name: "deployment_domain";
|
|
64
|
+
tableName: "workflow_run_launch_spec";
|
|
65
|
+
dataType: "string";
|
|
66
|
+
columnType: "PgText";
|
|
67
|
+
data: string;
|
|
68
|
+
driverParam: string;
|
|
69
|
+
notNull: true;
|
|
70
|
+
hasDefault: false;
|
|
71
|
+
isPrimaryKey: false;
|
|
72
|
+
isAutoincrement: false;
|
|
73
|
+
hasRuntimeDefault: false;
|
|
74
|
+
enumValues: [string, ...string[]];
|
|
75
|
+
baseColumn: never;
|
|
76
|
+
identity: undefined;
|
|
77
|
+
generated: undefined;
|
|
78
|
+
}, {}, {}>;
|
|
79
|
+
sourceAuthorityPrincipalId: import("drizzle-orm/pg-core").PgColumn<{
|
|
80
|
+
name: "source_authority_principal_id";
|
|
81
|
+
tableName: "workflow_run_launch_spec";
|
|
82
|
+
dataType: "string";
|
|
83
|
+
columnType: "PgText";
|
|
84
|
+
data: string;
|
|
85
|
+
driverParam: string;
|
|
86
|
+
notNull: true;
|
|
87
|
+
hasDefault: false;
|
|
88
|
+
isPrimaryKey: false;
|
|
89
|
+
isAutoincrement: false;
|
|
90
|
+
hasRuntimeDefault: false;
|
|
91
|
+
enumValues: [string, ...string[]];
|
|
92
|
+
baseColumn: never;
|
|
93
|
+
identity: undefined;
|
|
94
|
+
generated: undefined;
|
|
95
|
+
}, {}, {}>;
|
|
96
|
+
frozenApprovalBundle: import("drizzle-orm/pg-core").PgColumn<{
|
|
97
|
+
name: "frozen_approval_bundle";
|
|
98
|
+
tableName: "workflow_run_launch_spec";
|
|
99
|
+
dataType: "json";
|
|
100
|
+
columnType: "PgJsonb";
|
|
101
|
+
data: unknown;
|
|
102
|
+
driverParam: unknown;
|
|
103
|
+
notNull: true;
|
|
104
|
+
hasDefault: false;
|
|
105
|
+
isPrimaryKey: false;
|
|
106
|
+
isAutoincrement: false;
|
|
107
|
+
hasRuntimeDefault: false;
|
|
108
|
+
enumValues: undefined;
|
|
109
|
+
baseColumn: never;
|
|
110
|
+
identity: undefined;
|
|
111
|
+
generated: undefined;
|
|
112
|
+
}, {}, {}>;
|
|
113
|
+
sourceOfferingIds: import("drizzle-orm/pg-core").PgColumn<{
|
|
114
|
+
name: "source_offering_ids";
|
|
115
|
+
tableName: "workflow_run_launch_spec";
|
|
116
|
+
dataType: "json";
|
|
117
|
+
columnType: "PgJsonb";
|
|
118
|
+
data: unknown;
|
|
119
|
+
driverParam: unknown;
|
|
120
|
+
notNull: true;
|
|
121
|
+
hasDefault: false;
|
|
122
|
+
isPrimaryKey: false;
|
|
123
|
+
isAutoincrement: false;
|
|
124
|
+
hasRuntimeDefault: false;
|
|
125
|
+
enumValues: undefined;
|
|
126
|
+
baseColumn: never;
|
|
127
|
+
identity: undefined;
|
|
128
|
+
generated: undefined;
|
|
129
|
+
}, {}, {}>;
|
|
130
|
+
defaultSourceOfferingId: import("drizzle-orm/pg-core").PgColumn<{
|
|
131
|
+
name: "default_source_offering_id";
|
|
132
|
+
tableName: "workflow_run_launch_spec";
|
|
133
|
+
dataType: "string";
|
|
134
|
+
columnType: "PgText";
|
|
135
|
+
data: string;
|
|
136
|
+
driverParam: string;
|
|
137
|
+
notNull: true;
|
|
138
|
+
hasDefault: false;
|
|
139
|
+
isPrimaryKey: false;
|
|
140
|
+
isAutoincrement: false;
|
|
141
|
+
hasRuntimeDefault: false;
|
|
142
|
+
enumValues: [string, ...string[]];
|
|
143
|
+
baseColumn: never;
|
|
144
|
+
identity: undefined;
|
|
145
|
+
generated: undefined;
|
|
146
|
+
}, {}, {}>;
|
|
147
|
+
deployContent: import("drizzle-orm/pg-core").PgColumn<{
|
|
148
|
+
name: "deploy_content";
|
|
149
|
+
tableName: "workflow_run_launch_spec";
|
|
150
|
+
dataType: "json";
|
|
151
|
+
columnType: "PgJsonb";
|
|
152
|
+
data: unknown;
|
|
153
|
+
driverParam: unknown;
|
|
154
|
+
notNull: true;
|
|
155
|
+
hasDefault: false;
|
|
156
|
+
isPrimaryKey: false;
|
|
157
|
+
isAutoincrement: false;
|
|
158
|
+
hasRuntimeDefault: false;
|
|
159
|
+
enumValues: undefined;
|
|
160
|
+
baseColumn: never;
|
|
161
|
+
identity: undefined;
|
|
162
|
+
generated: undefined;
|
|
163
|
+
}, {}, {}>;
|
|
164
|
+
toolPackagePins: import("drizzle-orm/pg-core").PgColumn<{
|
|
165
|
+
name: "tool_package_pins";
|
|
166
|
+
tableName: "workflow_run_launch_spec";
|
|
167
|
+
dataType: "json";
|
|
168
|
+
columnType: "PgJsonb";
|
|
169
|
+
data: unknown;
|
|
170
|
+
driverParam: unknown;
|
|
171
|
+
notNull: false;
|
|
172
|
+
hasDefault: false;
|
|
173
|
+
isPrimaryKey: false;
|
|
174
|
+
isAutoincrement: false;
|
|
175
|
+
hasRuntimeDefault: false;
|
|
176
|
+
enumValues: undefined;
|
|
177
|
+
baseColumn: never;
|
|
178
|
+
identity: undefined;
|
|
179
|
+
generated: undefined;
|
|
180
|
+
}, {}, {}>;
|
|
181
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
182
|
+
name: "created_at";
|
|
183
|
+
tableName: "workflow_run_launch_spec";
|
|
184
|
+
dataType: "date";
|
|
185
|
+
columnType: "PgTimestamp";
|
|
186
|
+
data: Date;
|
|
187
|
+
driverParam: string;
|
|
188
|
+
notNull: true;
|
|
189
|
+
hasDefault: true;
|
|
190
|
+
isPrimaryKey: false;
|
|
191
|
+
isAutoincrement: false;
|
|
192
|
+
hasRuntimeDefault: false;
|
|
193
|
+
enumValues: undefined;
|
|
194
|
+
baseColumn: never;
|
|
195
|
+
identity: undefined;
|
|
196
|
+
generated: undefined;
|
|
197
|
+
}, {}, {}>;
|
|
198
|
+
};
|
|
199
|
+
dialect: "pg";
|
|
200
|
+
}>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { integer, jsonb, pgTable, text, timestamp } from "drizzle-orm/pg-core";
|
|
2
|
+
import { principal } from "./principals.js";
|
|
3
|
+
import { workflowRun } from "./workflow-run.js";
|
|
4
|
+
/**
|
|
5
|
+
* Immutable inputs required to recreate an exclusively placed workflow on a
|
|
6
|
+
* replacement sidecar. Secrets are deliberately excluded: source offering
|
|
7
|
+
* ids are resolved against the current catalog and principal authority when a
|
|
8
|
+
* generation is launched.
|
|
9
|
+
*/
|
|
10
|
+
export const workflowRunLaunchSpec = pgTable("workflow_run_launch_spec", {
|
|
11
|
+
anchorRunId: text("anchor_run_id")
|
|
12
|
+
.primaryKey()
|
|
13
|
+
.references(() => workflowRun.id, { onDelete: "cascade" }),
|
|
14
|
+
schemaVersion: integer("schema_version").notNull().default(1),
|
|
15
|
+
sessionId: text("session_id").notNull(),
|
|
16
|
+
deploymentDomain: text("deployment_domain").notNull(),
|
|
17
|
+
sourceAuthorityPrincipalId: text("source_authority_principal_id")
|
|
18
|
+
.notNull()
|
|
19
|
+
.references(() => principal.id, { onDelete: "restrict" }),
|
|
20
|
+
frozenApprovalBundle: jsonb("frozen_approval_bundle").notNull(),
|
|
21
|
+
sourceOfferingIds: jsonb("source_offering_ids").notNull(),
|
|
22
|
+
defaultSourceOfferingId: text("default_source_offering_id").notNull(),
|
|
23
|
+
deployContent: jsonb("deploy_content").notNull(),
|
|
24
|
+
toolPackagePins: jsonb("tool_package_pins"),
|
|
25
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
26
|
+
});
|
|
@@ -1,10 +1,18 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
1
|
+
export type WorkflowRunCredentialRefs = {
|
|
2
|
+
credentialIds: string[];
|
|
3
|
+
bindings: {
|
|
4
|
+
handle: string;
|
|
5
|
+
credentialId: string;
|
|
6
|
+
consumer: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
export declare const workflowRun: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
10
|
+
name: "workflow_run";
|
|
3
11
|
schema: undefined;
|
|
4
12
|
columns: {
|
|
5
13
|
id: import("drizzle-orm/pg-core").PgColumn<{
|
|
6
14
|
name: "id";
|
|
7
|
-
tableName: "
|
|
15
|
+
tableName: "workflow_run";
|
|
8
16
|
dataType: "string";
|
|
9
17
|
columnType: "PgText";
|
|
10
18
|
data: string;
|
|
@@ -19,9 +27,9 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
19
27
|
identity: undefined;
|
|
20
28
|
generated: undefined;
|
|
21
29
|
}, {}, {}>;
|
|
22
|
-
|
|
23
|
-
name: "
|
|
24
|
-
tableName: "
|
|
30
|
+
definitionId: import("drizzle-orm/pg-core").PgColumn<{
|
|
31
|
+
name: "definition_id";
|
|
32
|
+
tableName: "workflow_run";
|
|
25
33
|
dataType: "string";
|
|
26
34
|
columnType: "PgText";
|
|
27
35
|
data: string;
|
|
@@ -36,14 +44,14 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
36
44
|
identity: undefined;
|
|
37
45
|
generated: undefined;
|
|
38
46
|
}, {}, {}>;
|
|
39
|
-
|
|
40
|
-
name: "
|
|
41
|
-
tableName: "
|
|
47
|
+
anchorRunId: import("drizzle-orm/pg-core").PgColumn<{
|
|
48
|
+
name: "anchor_run_id";
|
|
49
|
+
tableName: "workflow_run";
|
|
42
50
|
dataType: "string";
|
|
43
51
|
columnType: "PgText";
|
|
44
52
|
data: string;
|
|
45
53
|
driverParam: string;
|
|
46
|
-
notNull:
|
|
54
|
+
notNull: false;
|
|
47
55
|
hasDefault: false;
|
|
48
56
|
isPrimaryKey: false;
|
|
49
57
|
isAutoincrement: false;
|
|
@@ -53,9 +61,9 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
53
61
|
identity: undefined;
|
|
54
62
|
generated: undefined;
|
|
55
63
|
}, {}, {}>;
|
|
56
|
-
|
|
57
|
-
name: "
|
|
58
|
-
tableName: "
|
|
64
|
+
tenantId: import("drizzle-orm/pg-core").PgColumn<{
|
|
65
|
+
name: "tenant_id";
|
|
66
|
+
tableName: "workflow_run";
|
|
59
67
|
dataType: "string";
|
|
60
68
|
columnType: "PgText";
|
|
61
69
|
data: string;
|
|
@@ -70,14 +78,14 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
70
78
|
identity: undefined;
|
|
71
79
|
generated: undefined;
|
|
72
80
|
}, {}, {}>;
|
|
73
|
-
|
|
74
|
-
name: "
|
|
75
|
-
tableName: "
|
|
81
|
+
principalId: import("drizzle-orm/pg-core").PgColumn<{
|
|
82
|
+
name: "principal_id";
|
|
83
|
+
tableName: "workflow_run";
|
|
76
84
|
dataType: "string";
|
|
77
85
|
columnType: "PgText";
|
|
78
86
|
data: string;
|
|
79
87
|
driverParam: string;
|
|
80
|
-
notNull:
|
|
88
|
+
notNull: false;
|
|
81
89
|
hasDefault: false;
|
|
82
90
|
isPrimaryKey: false;
|
|
83
91
|
isAutoincrement: false;
|
|
@@ -87,26 +95,26 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
87
95
|
identity: undefined;
|
|
88
96
|
generated: undefined;
|
|
89
97
|
}, {}, {}>;
|
|
90
|
-
|
|
91
|
-
name: "
|
|
92
|
-
tableName: "
|
|
98
|
+
status: import("drizzle-orm/pg-core").PgColumn<{
|
|
99
|
+
name: "status";
|
|
100
|
+
tableName: "workflow_run";
|
|
93
101
|
dataType: "string";
|
|
94
102
|
columnType: "PgText";
|
|
95
|
-
data:
|
|
103
|
+
data: "deployed" | "failed" | "running" | "completed" | "cancelled";
|
|
96
104
|
driverParam: string;
|
|
97
|
-
notNull:
|
|
98
|
-
hasDefault:
|
|
105
|
+
notNull: true;
|
|
106
|
+
hasDefault: true;
|
|
99
107
|
isPrimaryKey: false;
|
|
100
108
|
isAutoincrement: false;
|
|
101
109
|
hasRuntimeDefault: false;
|
|
102
|
-
enumValues: [
|
|
110
|
+
enumValues: ["deployed", "running", "completed", "failed", "cancelled"];
|
|
103
111
|
baseColumn: never;
|
|
104
112
|
identity: undefined;
|
|
105
113
|
generated: undefined;
|
|
106
114
|
}, {}, {}>;
|
|
107
|
-
|
|
108
|
-
name: "
|
|
109
|
-
tableName: "
|
|
115
|
+
address: import("drizzle-orm/pg-core").PgColumn<{
|
|
116
|
+
name: "address";
|
|
117
|
+
tableName: "workflow_run";
|
|
110
118
|
dataType: "string";
|
|
111
119
|
columnType: "PgText";
|
|
112
120
|
data: string;
|
|
@@ -121,26 +129,9 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
121
129
|
identity: undefined;
|
|
122
130
|
generated: undefined;
|
|
123
131
|
}, {}, {}>;
|
|
124
|
-
|
|
125
|
-
name: "
|
|
126
|
-
tableName: "
|
|
127
|
-
dataType: "string";
|
|
128
|
-
columnType: "PgText";
|
|
129
|
-
data: "deployed" | "stopped" | "error" | "running" | "updating";
|
|
130
|
-
driverParam: string;
|
|
131
|
-
notNull: true;
|
|
132
|
-
hasDefault: true;
|
|
133
|
-
isPrimaryKey: false;
|
|
134
|
-
isAutoincrement: false;
|
|
135
|
-
hasRuntimeDefault: false;
|
|
136
|
-
enumValues: ["deployed", "running", "updating", "error", "stopped"];
|
|
137
|
-
baseColumn: never;
|
|
138
|
-
identity: undefined;
|
|
139
|
-
generated: undefined;
|
|
140
|
-
}, {}, {}>;
|
|
141
|
-
sidecarId: import("drizzle-orm/pg-core").PgColumn<{
|
|
142
|
-
name: "sidecar_id";
|
|
143
|
-
tableName: "agent_instance";
|
|
132
|
+
publicKey: import("drizzle-orm/pg-core").PgColumn<{
|
|
133
|
+
name: "public_key";
|
|
134
|
+
tableName: "workflow_run";
|
|
144
135
|
dataType: "string";
|
|
145
136
|
columnType: "PgText";
|
|
146
137
|
data: string;
|
|
@@ -155,9 +146,9 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
155
146
|
identity: undefined;
|
|
156
147
|
generated: undefined;
|
|
157
148
|
}, {}, {}>;
|
|
158
|
-
|
|
159
|
-
name: "
|
|
160
|
-
tableName: "
|
|
149
|
+
sidecarId: import("drizzle-orm/pg-core").PgColumn<{
|
|
150
|
+
name: "sidecar_id";
|
|
151
|
+
tableName: "workflow_run";
|
|
161
152
|
dataType: "string";
|
|
162
153
|
columnType: "PgText";
|
|
163
154
|
data: string;
|
|
@@ -174,7 +165,7 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
174
165
|
}, {}, {}>;
|
|
175
166
|
kernelId: import("drizzle-orm/pg-core").PgColumn<{
|
|
176
167
|
name: "kernel_id";
|
|
177
|
-
tableName: "
|
|
168
|
+
tableName: "workflow_run";
|
|
178
169
|
dataType: "string";
|
|
179
170
|
columnType: "PgText";
|
|
180
171
|
data: string;
|
|
@@ -191,7 +182,7 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
191
182
|
}, {}, {}>;
|
|
192
183
|
modelPreferences: import("drizzle-orm/pg-core").PgColumn<{
|
|
193
184
|
name: "model_preferences";
|
|
194
|
-
tableName: "
|
|
185
|
+
tableName: "workflow_run";
|
|
195
186
|
dataType: "json";
|
|
196
187
|
columnType: "PgJsonb";
|
|
197
188
|
data: unknown;
|
|
@@ -206,15 +197,15 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
206
197
|
identity: undefined;
|
|
207
198
|
generated: undefined;
|
|
208
199
|
}, {}, {}>;
|
|
209
|
-
|
|
210
|
-
name: "
|
|
211
|
-
tableName: "
|
|
212
|
-
dataType: "
|
|
213
|
-
columnType: "
|
|
214
|
-
data:
|
|
215
|
-
driverParam:
|
|
216
|
-
notNull:
|
|
217
|
-
hasDefault:
|
|
200
|
+
credentialRefs: import("drizzle-orm/pg-core").PgColumn<{
|
|
201
|
+
name: "credential_refs";
|
|
202
|
+
tableName: "workflow_run";
|
|
203
|
+
dataType: "json";
|
|
204
|
+
columnType: "PgJsonb";
|
|
205
|
+
data: WorkflowRunCredentialRefs;
|
|
206
|
+
driverParam: unknown;
|
|
207
|
+
notNull: false;
|
|
208
|
+
hasDefault: false;
|
|
218
209
|
isPrimaryKey: false;
|
|
219
210
|
isAutoincrement: false;
|
|
220
211
|
hasRuntimeDefault: false;
|
|
@@ -222,10 +213,12 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
222
213
|
baseColumn: never;
|
|
223
214
|
identity: undefined;
|
|
224
215
|
generated: undefined;
|
|
225
|
-
}, {}, {
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
216
|
+
}, {}, {
|
|
217
|
+
$type: WorkflowRunCredentialRefs;
|
|
218
|
+
}>;
|
|
219
|
+
createdAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
220
|
+
name: "created_at";
|
|
221
|
+
tableName: "workflow_run";
|
|
229
222
|
dataType: "date";
|
|
230
223
|
columnType: "PgTimestamp";
|
|
231
224
|
data: Date;
|
|
@@ -242,7 +235,7 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
242
235
|
}, {}, {}>;
|
|
243
236
|
endedAt: import("drizzle-orm/pg-core").PgColumn<{
|
|
244
237
|
name: "ended_at";
|
|
245
|
-
tableName: "
|
|
238
|
+
tableName: "workflow_run";
|
|
246
239
|
dataType: "date";
|
|
247
240
|
columnType: "PgTimestamp";
|
|
248
241
|
data: Date;
|
|
@@ -260,3 +253,5 @@ export declare const agentInstance: import("drizzle-orm/pg-core").PgTableWithCol
|
|
|
260
253
|
};
|
|
261
254
|
dialect: "pg";
|
|
262
255
|
}>;
|
|
256
|
+
export declare const liveWorkflowRunStatuses: readonly ["deployed", "running"];
|
|
257
|
+
export declare function isLiveWorkflowRunStatus(status: string): boolean;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { sql } from "drizzle-orm";
|
|
2
|
+
import { index, jsonb, pgTable, text, timestamp, uniqueIndex, } from "drizzle-orm/pg-core";
|
|
3
|
+
import { principal } from "./principals.js";
|
|
4
|
+
import { sidecar } from "./sidecar.js";
|
|
5
|
+
import { tenant } from "./tenants.js";
|
|
6
|
+
import { workflowDefinition } from "./workflow-definitions.js";
|
|
7
|
+
// workflow_run is the per-run authorization subject: one row per run of a
|
|
8
|
+
// workflow deployment. It gives "this approval belongs to a real run of this
|
|
9
|
+
// deployment" a database referent, so approvals and signal correlations anchor
|
|
10
|
+
// to a run row rather than a bare run id string.
|
|
11
|
+
//
|
|
12
|
+
// The id is opaque and heterogeneous: a deployment's addressable top-level
|
|
13
|
+
// run uses its stable mail address, while internal body-child runs use freshly
|
|
14
|
+
// minted synthetic ids. Both are run identifiers, so no format is enforced on
|
|
15
|
+
// the column.
|
|
16
|
+
export const workflowRun = pgTable("workflow_run", {
|
|
17
|
+
id: text("id").primaryKey(),
|
|
18
|
+
// The definition a run belongs to, carried by every run: a folded
|
|
19
|
+
// agent-origin run sets it at launch, and a deployment's anchor run and its
|
|
20
|
+
// child runs carry the deployment's definition. It is the run's anchor to a
|
|
21
|
+
// first-class definition. `cascade` matches `anchorRunId`'s onDelete, so
|
|
22
|
+
// deleting the definition removes its runs.
|
|
23
|
+
definitionId: text("definition_id")
|
|
24
|
+
.notNull()
|
|
25
|
+
.references(() => workflowDefinition.id, { onDelete: "cascade" }),
|
|
26
|
+
// Nullable as of the fold: a folded agent-origin run carries a
|
|
27
|
+
// `definitionId` and no deployment, while a deployment's anchor run sets
|
|
28
|
+
// this to its own id and a child run sets it to its anchor's id. It
|
|
29
|
+
// references the anchor `workflow_run` -- the run whose id equals the
|
|
30
|
+
// deployment id -- so an anchor row is self-referential. The only runtime
|
|
31
|
+
// read of the column (`resolveWorkflowPrincipalNames`) degrades gracefully
|
|
32
|
+
// when it is null.
|
|
33
|
+
anchorRunId: text("anchor_run_id").references(() => workflowRun.id, { onDelete: "cascade" }),
|
|
34
|
+
tenantId: text("tenant_id")
|
|
35
|
+
.notNull()
|
|
36
|
+
.references(() => tenant.id, { onDelete: "cascade" }),
|
|
37
|
+
// Nullable by design: an internal, workflow-spawned run has no principal of
|
|
38
|
+
// its own -- it inherits the deployment's grants at read time -- so null is
|
|
39
|
+
// the honest signal for "this run has no own principal." `onDelete: "set
|
|
40
|
+
// null"` is deliberate (unlike agent_instance's principal, which uses the
|
|
41
|
+
// implicit default): deleting a run's principal nulls the column rather than
|
|
42
|
+
// wedging the run row.
|
|
43
|
+
principalId: text("principal_id").references(() => principal.id, {
|
|
44
|
+
onDelete: "set null",
|
|
45
|
+
}),
|
|
46
|
+
// A deployment's anchor run is born "deployed": the deploy->first-trigger
|
|
47
|
+
// window is live but not yet running. The first trigger reconciles the
|
|
48
|
+
// anchor and flips this column "deployed" -> "running" (see
|
|
49
|
+
// `anchorWithPrincipal`). A child run has no such window -- it exists only
|
|
50
|
+
// once execution spawns it -- so it is born "running". A run settles into a
|
|
51
|
+
// terminal status when its terminal event lands on the workflow-run ref:
|
|
52
|
+
// the hub's pack-receive path flips this column under a live-status guard so
|
|
53
|
+
// a redelivered terminal event does not re-terminate the run.
|
|
54
|
+
status: text("status", {
|
|
55
|
+
enum: ["deployed", "running", "completed", "failed", "cancelled"],
|
|
56
|
+
})
|
|
57
|
+
.notNull()
|
|
58
|
+
.default("running"),
|
|
59
|
+
// Runtime bindings a folded run carries, mirroring `agent_instance`: a
|
|
60
|
+
// folded run IS the launched instance, so it owns its routing endpoint.
|
|
61
|
+
// `address` is that endpoint -- nullable because an address-less child run
|
|
62
|
+
// routes via its deployment (a deployment's anchor run instead carries a
|
|
63
|
+
// workflow-derived address), but unique among the runs that set it (the
|
|
64
|
+
// partial unique index below). The folded launch writes `address` and
|
|
65
|
+
// `modelPreferences`; `publicKey` is persisted when the sidecar acks the
|
|
66
|
+
// deploy; no code populates `sidecarId`/`kernelId`.
|
|
67
|
+
address: text("address"),
|
|
68
|
+
publicKey: text("public_key"),
|
|
69
|
+
sidecarId: text("sidecar_id").references(() => sidecar.id, {
|
|
70
|
+
onDelete: "set null",
|
|
71
|
+
}),
|
|
72
|
+
kernelId: text("kernel_id"),
|
|
73
|
+
modelPreferences: jsonb("model_preferences"),
|
|
74
|
+
// The non-secret shape of the credential delivery this deployment resolved
|
|
75
|
+
// at deploy: the credentialIds it references and the tool binding
|
|
76
|
+
// descriptors. Set on a deployment anchor run; null for runs that carry no
|
|
77
|
+
// credential delivery. Secrets are NEVER stored here -- only ids and
|
|
78
|
+
// descriptors -- so the reconnect resync can re-resolve each id's CURRENT
|
|
79
|
+
// material from the credential table (dropping a revoked or deleted id,
|
|
80
|
+
// picking up a rotated secret) and reconcile the reconnecting child.
|
|
81
|
+
credentialRefs: jsonb("credential_refs").$type(),
|
|
82
|
+
createdAt: timestamp("created_at").notNull().defaultNow(),
|
|
83
|
+
// Nullable: a run has no end time until it reaches a terminal state.
|
|
84
|
+
endedAt: timestamp("ended_at"),
|
|
85
|
+
}, (t) => [
|
|
86
|
+
// Supports lookups of a definition's runs, the read path folded runs use
|
|
87
|
+
// once `definitionId` is the anchor.
|
|
88
|
+
index("workflow_run_definition_idx").on(t.definitionId),
|
|
89
|
+
// A folded run owns a unique routing address, exactly like the agent
|
|
90
|
+
// instance it stands in for; a run that anchors on a deployment instead
|
|
91
|
+
// leaves `address` null and is not indexed. Partial so the many null-address
|
|
92
|
+
// rows never collide and are kept out of the index.
|
|
93
|
+
uniqueIndex("workflow_run_address_idx")
|
|
94
|
+
.on(t.address)
|
|
95
|
+
.where(sql `${t.address} is not null`),
|
|
96
|
+
]);
|
|
97
|
+
// The statuses a run holds while live -- not yet settled into a terminal state.
|
|
98
|
+
// A deployment anchor is born "deployed" and flips to "running" on its first
|
|
99
|
+
// trigger; a child run is born "running". Every status gate that must treat a
|
|
100
|
+
// live run as live tests membership here, so "which statuses count as live" has
|
|
101
|
+
// a single definition rather than a `status !== "running"` scattered across the
|
|
102
|
+
// workflow-run domain. The `satisfies` bound makes a drift from the column enum
|
|
103
|
+
// a compile error.
|
|
104
|
+
export const liveWorkflowRunStatuses = [
|
|
105
|
+
"deployed",
|
|
106
|
+
"running",
|
|
107
|
+
];
|
|
108
|
+
export function isLiveWorkflowRunStatus(status) {
|
|
109
|
+
return liveWorkflowRunStatuses.some((live) => live === status);
|
|
110
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import type { DBExecutor } from "./client.js";
|
|
2
|
+
import type { PrincipalKeyStore } from "./principal-key-store.js";
|
|
3
|
+
/**
|
|
4
|
+
* The durable public key that authenticates a signed mail sender, resolved from
|
|
5
|
+
* the hub's own storage. `source` records which store the key came from -- a
|
|
6
|
+
* run sender's key is the sidecar-minted key recorded on the deployment anchor,
|
|
7
|
+
* a user sender's key is the hub-custodied principal key -- so a consumer can
|
|
8
|
+
* bucket a resolution without re-parsing the address.
|
|
9
|
+
*/
|
|
10
|
+
export type SenderKeyResolution = {
|
|
11
|
+
source: "run";
|
|
12
|
+
publicKey: string;
|
|
13
|
+
} | {
|
|
14
|
+
source: "user";
|
|
15
|
+
publicKey: string;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Resolve the durable public key a signed mail sender must verify against,
|
|
19
|
+
* unioning the two existing durable-key sources: a run address
|
|
20
|
+
* (`run_<id>@<domain>`) resolves to the run's `workflow_run.public_key`; any
|
|
21
|
+
* other address (`<refId>@<domain>`) is treated as a user sender and resolves
|
|
22
|
+
* to that principal's hub-custodied key.
|
|
23
|
+
*
|
|
24
|
+
* Read-only. Returns `null` when the sender has no durable key to resolve -- a
|
|
25
|
+
* malformed address, an unknown run, a run whose deploy has not been acked yet,
|
|
26
|
+
* or an address that matches no user principal. A `null` is a legitimate
|
|
27
|
+
* "unresolvable sender" answer the caller acts on; it is NOT an error.
|
|
28
|
+
*
|
|
29
|
+
* Addresses are matched case-insensitively. Inbound `From` addresses are
|
|
30
|
+
* lowercased when parsed (see `@intx/mime` `extractAddrSpec`), so the address is
|
|
31
|
+
* normalized here and stored values are compared under `lower(...)`. Tenant
|
|
32
|
+
* domains are `lower(domain)`-unique (`tenant_domain_lower_idx`), so a
|
|
33
|
+
* normalized domain matches at most one tenant. A user `refId` is a
|
|
34
|
+
* case-sensitively-unique betterAuth id that can carry uppercase; lowercasing it
|
|
35
|
+
* to reconcile with the parser is lossy, so the resolver prefers the exact
|
|
36
|
+
* (already-lowercase) row and falls back to a case-insensitive match to find a
|
|
37
|
+
* mixed-case-stored refId. When two principals in one tenant hold case-variant
|
|
38
|
+
* refIds the case-insensitive match is not unique and no exact row disambiguates
|
|
39
|
+
* it: the resolver throws rather than silently return one, which would attribute
|
|
40
|
+
* the sender to the wrong principal.
|
|
41
|
+
*/
|
|
42
|
+
export declare function resolveSenderKey(db: DBExecutor, principalKeyStore: PrincipalKeyStore, address: string): Promise<SenderKeyResolution | null>;
|
|
43
|
+
/**
|
|
44
|
+
* Resolve the hex-encoded public key to stamp on an outbound mail frame, as a
|
|
45
|
+
* BEST-EFFORT value that never blocks delivery. Returns the key, or `null` when
|
|
46
|
+
* the sender has no resolvable key -- OR when resolution FAILS.
|
|
47
|
+
*
|
|
48
|
+
* {@link resolveSenderKey} throws on a genuine fault (an ambiguous user address,
|
|
49
|
+
* or a principal with no active key -- an INTR-164 invariant break). Those
|
|
50
|
+
* throws must fail loud for {@link auditSenderKeys}, but they must not break
|
|
51
|
+
* the send path: the frame key is nullable, so a recipient with no co-delivered
|
|
52
|
+
* key resolves the sender as `unknown`, which its admission policy rejects by
|
|
53
|
+
* default (a workflow may relax `unknown` to admit).
|
|
54
|
+
* Coupling delivery to key resolution would let a data-integrity fault strand a
|
|
55
|
+
* run or drop mail. So a throw here degrades to `null` and is logged at ERROR
|
|
56
|
+
* with its cause -- a degraded fault, kept distinct from the ordinary
|
|
57
|
+
* unresolvable-sender `null`, which stays silent.
|
|
58
|
+
*
|
|
59
|
+
* The principal key store is real in production (INTR-164 mints every principal
|
|
60
|
+
* a key), so the throw path is a defensive safety net, not the common case: the
|
|
61
|
+
* normal outcome is a resolved, populated key.
|
|
62
|
+
*/
|
|
63
|
+
export declare function resolveFrameSenderKey(db: DBExecutor, principalKeyStore: PrincipalKeyStore, address: string): Promise<string | null>;
|
|
64
|
+
/**
|
|
65
|
+
* The outcome of sweeping every sender that could sign a piece of mail: how many
|
|
66
|
+
* of each kind were checked, and any whose address did not resolve to a durable
|
|
67
|
+
* key. An empty `unresolved` is the "no unresolvable signed senders" state a
|
|
68
|
+
* durable-signature verifier depends on.
|
|
69
|
+
*/
|
|
70
|
+
export type SenderKeyAuditReport = {
|
|
71
|
+
runsChecked: number;
|
|
72
|
+
usersChecked: number;
|
|
73
|
+
unresolved: {
|
|
74
|
+
address: string;
|
|
75
|
+
kind: "run" | "user";
|
|
76
|
+
}[];
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* Sweep every mail sender that could sign and confirm each resolves to a durable
|
|
80
|
+
* public key via {@link resolveSenderKey}. Read-only.
|
|
81
|
+
*
|
|
82
|
+
* The senders that can sign are every workflow run that holds a signing key or
|
|
83
|
+
* is live ("running") and carries a sending address, plus every active user
|
|
84
|
+
* principal. A never-signed run -- deployed-but-not-yet-acked, or failed or
|
|
85
|
+
* cancelled before ack (address set, key null) -- is excluded. Any checked
|
|
86
|
+
* sender that does not resolve is collected in `unresolved`. A keyless user
|
|
87
|
+
* principal is an INTR-164 invariant break, so `resolveSenderKey` throws and the
|
|
88
|
+
* sweep fails loudly rather than folding it into `unresolved` -- it is a
|
|
89
|
+
* different, more serious fault than an unresolvable address.
|
|
90
|
+
*/
|
|
91
|
+
export declare function auditSenderKeys(db: DBExecutor, principalKeyStore: PrincipalKeyStore): Promise<SenderKeyAuditReport>;
|