@kici-dev/orchestrator 0.12.0 → 0.13.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.
Files changed (46) hide show
  1. package/dist/agent/dispatcher.d.ts +22 -0
  2. package/dist/agent/registry.d.ts +31 -0
  3. package/dist/app.d.ts +6 -0
  4. package/dist/cache/cache-upload-settle.d.ts +75 -0
  5. package/dist/cache/pending-inits.d.ts +9 -0
  6. package/dist/cancel/cancel-run.d.ts +22 -4
  7. package/dist/cancel/peer-job-cancel.d.ts +50 -0
  8. package/dist/cancel/sweep-stuck-cancelling.d.ts +3 -1
  9. package/dist/cli/commands/local-hook.d.ts +3 -2
  10. package/dist/cli/commands/local-trigger.d.ts +7 -0
  11. package/dist/cli.js +983 -683
  12. package/dist/cluster/coordinator-credential.d.ts +45 -0
  13. package/dist/cluster/coordinator.d.ts +18 -2
  14. package/dist/cluster/index.d.ts +1 -0
  15. package/dist/cluster/instance-heartbeat.d.ts +6 -1
  16. package/dist/cluster/join-token.d.ts +2 -0
  17. package/dist/cluster/peer-auth-coordinator.d.ts +13 -0
  18. package/dist/cluster/peer-client.d.ts +4 -0
  19. package/dist/cluster/peer-credentials.d.ts +31 -0
  20. package/dist/config.d.ts +3 -0
  21. package/dist/db/migrations/152_org_settings_cache_upload_settle_timeout.d.ts +15 -0
  22. package/dist/db/migrations/153_execution_runs_cancel_force.d.ts +16 -0
  23. package/dist/db/types.d.ts +15 -0
  24. package/dist/index.js +192 -53
  25. package/dist/pipeline/changed-files.d.ts +51 -0
  26. package/dist/pipeline/cross-source-tally.d.ts +21 -0
  27. package/dist/pipeline/degraded-reason.d.ts +8 -0
  28. package/dist/pipeline/dispatch-matched-workflow.d.ts +10 -0
  29. package/dist/pipeline/global-eval-round.d.ts +3 -2
  30. package/dist/pipeline/processor.d.ts +9 -1
  31. package/dist/pipeline/rerun-inputs.d.ts +16 -7
  32. package/dist/providers/github/changed-files.d.ts +14 -4
  33. package/dist/providers/universal-git/changed-files.d.ts +6 -0
  34. package/dist/providers/universal-git/config.d.ts +4 -0
  35. package/dist/scaler/container-backend.d.ts +2 -0
  36. package/dist/scaler/container-runtime.d.ts +9 -0
  37. package/dist/scaler/manager.d.ts +26 -2
  38. package/dist/server.js +2710 -1486
  39. package/dist/stale-detector/workflow-deadline-detector.d.ts +7 -1
  40. package/dist/standalone.js +11527 -10302
  41. package/dist/storage/s3.d.ts +36 -0
  42. package/dist/ws/agent-handler.d.ts +24 -3
  43. package/dist/ws/agent-heartbeat.d.ts +2 -2
  44. package/installer-image-digests.json +3 -3
  45. package/package.json +5 -5
  46. package/sbom.spdx.json +53 -53
package/dist/cli.js CHANGED
@@ -1122,13 +1122,13 @@ async function loadAccessLogRange(args) {
1122
1122
  }
1123
1123
  } catch (err) {
1124
1124
  if (cursor?.source === "cold") {
1125
- logger$25.error("cold-store fetchRange failed during cold-resume; propagating", {
1125
+ logger$26.error("cold-store fetchRange failed during cold-resume; propagating", {
1126
1126
  tenantId: tenantToScan,
1127
1127
  error: toErrorMessage(err)
1128
1128
  });
1129
1129
  throw err;
1130
1130
  }
1131
- logger$25.warn("cold-store fetchRange failed; returning hot rows only", {
1131
+ logger$26.warn("cold-store fetchRange failed; returning hot rows only", {
1132
1132
  tenantId: tenantToScan,
1133
1133
  error: toErrorMessage(err)
1134
1134
  });
@@ -1205,9 +1205,9 @@ function parseCursor(cursor) {
1205
1205
  return null;
1206
1206
  }
1207
1207
  }
1208
- var logger$25, SYNTHETIC_ORCH_TENANT;
1208
+ var logger$26, SYNTHETIC_ORCH_TENANT;
1209
1209
  var init_load_access_log_range = __esmMin((() => {
1210
- logger$25 = createLogger({ prefix: "load-access-log-range" });
1210
+ logger$26 = createLogger({ prefix: "load-access-log-range" });
1211
1211
  SYNTHETIC_ORCH_TENANT = "__orchestrator__";
1212
1212
  }));
1213
1213
  //#endregion
@@ -1230,7 +1230,7 @@ var init_load_access_log_range = __esmMin((() => {
1230
1230
  * partitioned by `(routing_key, day)`, not by the secondary filters.
1231
1231
  */
1232
1232
  init_load_access_log_range();
1233
- const logger$24 = createLogger({ prefix: "load-secret-audit-log-range" });
1233
+ const logger$25 = createLogger({ prefix: "load-secret-audit-log-range" });
1234
1234
  async function loadSecretAuditLogRange(args) {
1235
1235
  const { db, coldStore, contextName, routingKey, action, fromTs, toTs, limit, offset, includeArchived } = args;
1236
1236
  let hotQuery = db.selectFrom("secret_audit_log").selectAll().orderBy("timestamp", "desc");
@@ -1276,10 +1276,10 @@ async function loadSecretAuditLogRange(args) {
1276
1276
  }
1277
1277
  } catch (err) {
1278
1278
  if (hotRows.length === 0) {
1279
- logger$24.error("cold-store fetchRange failed with no hot fallback; propagating", { error: toErrorMessage(err) });
1279
+ logger$25.error("cold-store fetchRange failed with no hot fallback; propagating", { error: toErrorMessage(err) });
1280
1280
  throw err;
1281
1281
  }
1282
- logger$24.warn("cold-store fetchRange failed; returning hot rows only", { error: toErrorMessage(err) });
1282
+ logger$25.warn("cold-store fetchRange failed; returning hot rows only", { error: toErrorMessage(err) });
1283
1283
  return hotRows;
1284
1284
  }
1285
1285
  const coldSlice = coldRows.slice(coldOffset, coldOffset + remaining);
@@ -2859,8 +2859,8 @@ server:
2859
2859
  //#endregion
2860
2860
  //#region src/db/migrations/001_initial.ts
2861
2861
  var _001_initial_exports = /* @__PURE__ */ __exportAll({
2862
- down: () => down$150,
2863
- up: () => up$150
2862
+ down: () => down$152,
2863
+ up: () => up$152
2864
2864
  });
2865
2865
  /**
2866
2866
  * Squashed initial migration -- creates the complete Orchestrator database schema.
@@ -3552,7 +3552,7 @@ const DDL_STATEMENTS = [
3552
3552
  `ALTER TABLE ONLY public.held_runs
3553
3553
  ADD CONSTRAINT held_runs_environment_id_fkey FOREIGN KEY (environment_id) REFERENCES public.environments(id);`
3554
3554
  ];
3555
- async function up$150(db) {
3555
+ async function up$152(db) {
3556
3556
  for (const stmt of DDL_STATEMENTS) await sql.raw(stmt).execute(db);
3557
3557
  await sql`
3558
3558
  INSERT INTO cluster_meta (key, value)
@@ -3574,7 +3574,7 @@ async function up$150(db) {
3574
3574
  * Rollback drops everything created above. Uses CASCADE on table drops to cut
3575
3575
  * through the FK graph without relying on exact topological order.
3576
3576
  */
3577
- async function down$150(db) {
3577
+ async function down$152(db) {
3578
3578
  for (const [trig, tbl] of [["source_secrets_change_trigger", "scoped_secrets"], ["sources_change_trigger", "sources"]]) await sql.raw(`DROP TRIGGER IF EXISTS ${trig} ON public.${tbl}`).execute(db);
3579
3579
  for (const table of [
3580
3580
  "workflow_registrations",
@@ -3621,8 +3621,8 @@ async function down$150(db) {
3621
3621
  //#endregion
3622
3622
  //#region src/db/migrations/002_config_versions_key_version.ts
3623
3623
  var _002_config_versions_key_version_exports = /* @__PURE__ */ __exportAll({
3624
- down: () => down$149,
3625
- up: () => up$149
3624
+ down: () => down$151,
3625
+ up: () => up$151
3626
3626
  });
3627
3627
  /**
3628
3628
  * Add key_version column to config_versions so that sensitive-field encryption
@@ -3636,13 +3636,13 @@ var _002_config_versions_key_version_exports = /* @__PURE__ */ __exportAll({
3636
3636
  * No index is needed: rotation does a full-table scan; reads are by
3637
3637
  * `version` primary key and never filter on `key_version`.
3638
3638
  */
3639
- async function up$149(db) {
3639
+ async function up$151(db) {
3640
3640
  await sql`
3641
3641
  ALTER TABLE public.config_versions
3642
3642
  ADD COLUMN key_version integer NOT NULL DEFAULT 1
3643
3643
  `.execute(db);
3644
3644
  }
3645
- async function down$149(db) {
3645
+ async function down$151(db) {
3646
3646
  await sql`
3647
3647
  ALTER TABLE public.config_versions
3648
3648
  DROP COLUMN key_version
@@ -3651,8 +3651,8 @@ async function down$149(db) {
3651
3651
  //#endregion
3652
3652
  //#region src/db/migrations/003_access_log.ts
3653
3653
  var _003_access_log_exports = /* @__PURE__ */ __exportAll({
3654
- down: () => down$148,
3655
- up: () => up$148
3654
+ down: () => down$150,
3655
+ up: () => up$150
3656
3656
  });
3657
3657
  /**
3658
3658
  * Access log: one row per read or orchestrator-admin mutation attributable
@@ -3676,7 +3676,7 @@ var _003_access_log_exports = /* @__PURE__ */ __exportAll({
3676
3676
  * Retention is TTL-based via expires_at; packages/orchestrator/src/queue/
3677
3677
  * cleanup.ts picks up the prune pass.
3678
3678
  */
3679
- async function up$148(db) {
3679
+ async function up$150(db) {
3680
3680
  await sql`
3681
3681
  CREATE TABLE public.access_log (
3682
3682
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
@@ -3714,28 +3714,28 @@ async function up$148(db) {
3714
3714
  ON public.access_log (actor_type, actor_id, created_at DESC)
3715
3715
  `.execute(db);
3716
3716
  }
3717
- async function down$148(db) {
3717
+ async function down$150(db) {
3718
3718
  await sql`DROP TABLE IF EXISTS public.access_log`.execute(db);
3719
3719
  }
3720
3720
  //#endregion
3721
3721
  //#region src/db/migrations/004_rename_bundle_to_source.ts
3722
3722
  var _004_rename_bundle_to_source_exports = /* @__PURE__ */ __exportAll({
3723
- down: () => down$147,
3724
- up: () => up$147
3723
+ down: () => down$149,
3724
+ up: () => up$149
3725
3725
  });
3726
- async function up$147(db) {
3726
+ async function up$149(db) {
3727
3727
  await db.schema.alterTable("dispatch_queue").renameColumn("bundle_url", "source_tar_url").execute();
3728
3728
  await db.schema.alterTable("dispatch_queue").renameColumn("bundle_hash", "source_tar_hash").execute();
3729
3729
  }
3730
- async function down$147(db) {
3730
+ async function down$149(db) {
3731
3731
  await db.schema.alterTable("dispatch_queue").renameColumn("source_tar_url", "bundle_url").execute();
3732
3732
  await db.schema.alterTable("dispatch_queue").renameColumn("source_tar_hash", "bundle_hash").execute();
3733
3733
  }
3734
3734
  //#endregion
3735
3735
  //#region src/db/migrations/005_cold_store_chunk_counter.ts
3736
3736
  var _005_cold_store_chunk_counter_exports = /* @__PURE__ */ __exportAll({
3737
- down: () => down$146,
3738
- up: () => up$146
3737
+ down: () => down$148,
3738
+ up: () => up$148
3739
3739
  });
3740
3740
  /**
3741
3741
  * Cold-store chunk counter table.
@@ -3750,7 +3750,7 @@ var _005_cold_store_chunk_counter_exports = /* @__PURE__ */ __exportAll({
3750
3750
  * write via `INSERT ... ON CONFLICT (db, table_name, tenant_id) DO
3751
3751
  * UPDATE SET chunk_count = chunk_count + EXCLUDED.chunk_count, ...`.
3752
3752
  */
3753
- async function up$146(db) {
3753
+ async function up$148(db) {
3754
3754
  await sql`
3755
3755
  CREATE TABLE public.cold_store_chunk_counts (
3756
3756
  db TEXT NOT NULL,
@@ -3768,14 +3768,14 @@ async function up$146(db) {
3768
3768
  ON public.cold_store_chunk_counts (db, table_name)
3769
3769
  `.execute(db);
3770
3770
  }
3771
- async function down$146(db) {
3771
+ async function down$148(db) {
3772
3772
  await sql`DROP TABLE IF EXISTS public.cold_store_chunk_counts`.execute(db);
3773
3773
  }
3774
3774
  //#endregion
3775
3775
  //#region src/db/migrations/006_runs_jobs_steps_archived_at.ts
3776
3776
  var _006_runs_jobs_steps_archived_at_exports = /* @__PURE__ */ __exportAll({
3777
- down: () => down$145,
3778
- up: () => up$145
3777
+ down: () => down$147,
3778
+ up: () => up$147
3779
3779
  });
3780
3780
  /**
3781
3781
  * `execution_runs` / `execution_jobs` / `execution_steps` cold-store
@@ -3811,7 +3811,7 @@ var _006_runs_jobs_steps_archived_at_exports = /* @__PURE__ */ __exportAll({
3811
3811
  * - `idx_execution_jobs_routing_key_created (routing_key, created_at)`
3812
3812
  * - `idx_execution_steps_routing_key_created (routing_key, created_at)`
3813
3813
  */
3814
- async function up$145(db) {
3814
+ async function up$147(db) {
3815
3815
  await sql`
3816
3816
  ALTER TABLE public.execution_runs
3817
3817
  ADD COLUMN archived_at TIMESTAMPTZ NULL,
@@ -3856,7 +3856,7 @@ async function up$145(db) {
3856
3856
  ON public.execution_steps (routing_key, created_at)
3857
3857
  `.execute(db);
3858
3858
  }
3859
- async function down$145(db) {
3859
+ async function down$147(db) {
3860
3860
  await sql`DROP INDEX IF EXISTS public.idx_execution_steps_routing_key_created`.execute(db);
3861
3861
  await sql`
3862
3862
  ALTER TABLE public.execution_steps
@@ -3881,8 +3881,8 @@ async function down$145(db) {
3881
3881
  //#endregion
3882
3882
  //#region src/db/migrations/007_audit_logs_archived_at.ts
3883
3883
  var _007_audit_logs_archived_at_exports = /* @__PURE__ */ __exportAll({
3884
- down: () => down$144,
3885
- up: () => up$144
3884
+ down: () => down$146,
3885
+ up: () => up$146
3886
3886
  });
3887
3887
  /**
3888
3888
  * `secret_audit_log` and `access_log` cold-store schema additions, plus
@@ -3919,7 +3919,7 @@ var _007_audit_logs_archived_at_exports = /* @__PURE__ */ __exportAll({
3919
3919
  * — best effort; rows inserted between `up()` and a hypothetical
3920
3920
  * `down()` would not have meaningful retention bounds.
3921
3921
  */
3922
- async function up$144(db) {
3922
+ async function up$146(db) {
3923
3923
  await sql`
3924
3924
  ALTER TABLE public.secret_audit_log
3925
3925
  ADD COLUMN archived_at TIMESTAMPTZ NULL,
@@ -3940,7 +3940,7 @@ async function up$144(db) {
3940
3940
  DROP COLUMN IF EXISTS expires_at
3941
3941
  `.execute(db);
3942
3942
  }
3943
- async function down$144(db) {
3943
+ async function down$146(db) {
3944
3944
  await sql`
3945
3945
  ALTER TABLE public.access_log
3946
3946
  ADD COLUMN expires_at TIMESTAMPTZ NOT NULL DEFAULT (now() + INTERVAL '90 days')
@@ -3968,8 +3968,8 @@ async function down$144(db) {
3968
3968
  //#endregion
3969
3969
  //#region src/db/migrations/008_event_log_archived_at.ts
3970
3970
  var _008_event_log_archived_at_exports = /* @__PURE__ */ __exportAll({
3971
- down: () => down$143,
3972
- up: () => up$143
3971
+ down: () => down$145,
3972
+ up: () => up$145
3973
3973
  });
3974
3974
  /**
3975
3975
  * `event_log` cold-store schema additions plus removal of the
@@ -4005,7 +4005,7 @@ var _008_event_log_archived_at_exports = /* @__PURE__ */ __exportAll({
4005
4005
  * — best effort; rows inserted between `up()` and a hypothetical
4006
4006
  * `down()` would not have meaningful retention bounds.
4007
4007
  */
4008
- async function up$143(db) {
4008
+ async function up$145(db) {
4009
4009
  await sql`
4010
4010
  ALTER TABLE public.event_log
4011
4011
  ADD COLUMN archived_at TIMESTAMPTZ NULL,
@@ -4021,7 +4021,7 @@ async function up$143(db) {
4021
4021
  DROP COLUMN IF EXISTS expires_at
4022
4022
  `.execute(db);
4023
4023
  }
4024
- async function down$143(db) {
4024
+ async function down$145(db) {
4025
4025
  await sql`
4026
4026
  ALTER TABLE public.event_log
4027
4027
  ADD COLUMN expires_at TIMESTAMPTZ NOT NULL DEFAULT (now() + INTERVAL '30 days')
@@ -4040,8 +4040,8 @@ async function down$143(db) {
4040
4040
  //#endregion
4041
4041
  //#region src/db/migrations/009_access_log_trigram.ts
4042
4042
  var _009_access_log_trigram_exports = /* @__PURE__ */ __exportAll({
4043
- down: () => down$142,
4044
- up: () => up$142
4043
+ down: () => down$144,
4044
+ up: () => up$144
4045
4045
  });
4046
4046
  /**
4047
4047
  * Trigram (pg_trgm) index on access_log.error_message for the federated
@@ -4054,7 +4054,7 @@ var _009_access_log_trigram_exports = /* @__PURE__ */ __exportAll({
4054
4054
  * EXISTS` are both safe to re-run. No CONCURRENTLY because Kysely runs
4055
4055
  * migrations inside a transaction; the lock is brief on a sampled table.
4056
4056
  */
4057
- async function up$142(db) {
4057
+ async function up$144(db) {
4058
4058
  await sql`CREATE EXTENSION IF NOT EXISTS pg_trgm`.execute(db);
4059
4059
  await sql`
4060
4060
  CREATE INDEX IF NOT EXISTS access_log_error_message_trgm_idx
@@ -4063,14 +4063,14 @@ async function up$142(db) {
4063
4063
  WHERE error_message IS NOT NULL
4064
4064
  `.execute(db);
4065
4065
  }
4066
- async function down$142(db) {
4066
+ async function down$144(db) {
4067
4067
  await sql`DROP INDEX IF EXISTS public.access_log_error_message_trgm_idx`.execute(db);
4068
4068
  }
4069
4069
  //#endregion
4070
4070
  //#region src/db/migrations/010_cold_store_chunks.ts
4071
4071
  var _010_cold_store_chunks_exports = /* @__PURE__ */ __exportAll({
4072
- down: () => down$141,
4073
- up: () => up$141
4072
+ down: () => down$143,
4073
+ up: () => up$143
4074
4074
  });
4075
4075
  /**
4076
4076
  * Cold-store chunk index (cold-store purge).
@@ -4102,7 +4102,7 @@ var _010_cold_store_chunks_exports = /* @__PURE__ */ __exportAll({
4102
4102
  * forever. Adapters that don't opt into per-bucket archival via
4103
4103
  * `coldTtlDays` don't insert here either.
4104
4104
  */
4105
- async function up$141(db) {
4105
+ async function up$143(db) {
4106
4106
  await sql`
4107
4107
  CREATE TABLE public.cold_store_chunks (
4108
4108
  db TEXT NOT NULL,
@@ -4129,14 +4129,14 @@ async function up$141(db) {
4129
4129
  ON public.cold_store_chunks (db, table_name, tenant_id, archived_at DESC)
4130
4130
  `.execute(db);
4131
4131
  }
4132
- async function down$141(db) {
4132
+ async function down$143(db) {
4133
4133
  await sql`DROP TABLE IF EXISTS public.cold_store_chunks`.execute(db);
4134
4134
  }
4135
4135
  //#endregion
4136
4136
  //#region src/db/migrations/011_drop_source_secrets_notify.ts
4137
4137
  var _011_drop_source_secrets_notify_exports = /* @__PURE__ */ __exportAll({
4138
- down: () => down$140,
4139
- up: () => up$140
4138
+ down: () => down$142,
4139
+ up: () => up$142
4140
4140
  });
4141
4141
  /**
4142
4142
  * Drop the `source_secrets_change_trigger` and the
@@ -4155,11 +4155,11 @@ var _011_drop_source_secrets_notify_exports = /* @__PURE__ */ __exportAll({
4155
4155
  * in `001_initial.ts`. They wake up no consumer until the `WebhookSecretManager`
4156
4156
  * is restored, so this migration is safe to roll back.
4157
4157
  */
4158
- async function up$140(db) {
4158
+ async function up$142(db) {
4159
4159
  await sql`DROP TRIGGER IF EXISTS source_secrets_change_trigger ON public.scoped_secrets`.execute(db);
4160
4160
  await sql`DROP FUNCTION IF EXISTS public.notify_source_secrets_change() CASCADE`.execute(db);
4161
4161
  }
4162
- async function down$140(db) {
4162
+ async function down$142(db) {
4163
4163
  await sql`
4164
4164
  CREATE OR REPLACE FUNCTION public.notify_source_secrets_change() RETURNS trigger
4165
4165
  LANGUAGE plpgsql
@@ -4198,8 +4198,8 @@ async function down$140(db) {
4198
4198
  //#endregion
4199
4199
  //#region src/db/migrations/012_peer_credentials_active_uniq.ts
4200
4200
  var _012_peer_credentials_active_uniq_exports = /* @__PURE__ */ __exportAll({
4201
- down: () => down$139,
4202
- up: () => up$139
4201
+ down: () => down$141,
4202
+ up: () => up$141
4203
4203
  });
4204
4204
  /**
4205
4205
  * Add a partial unique index on `peer_credentials (instance_id) WHERE
@@ -4223,7 +4223,7 @@ var _012_peer_credentials_active_uniq_exports = /* @__PURE__ */ __exportAll({
4223
4223
  * `down()` only drops the index; it does NOT undo the dedupe (there's no
4224
4224
  * safe way to recreate revoked rows, and the dedupe is monotonic).
4225
4225
  */
4226
- async function up$139(db) {
4226
+ async function up$141(db) {
4227
4227
  await sql`
4228
4228
  UPDATE public.peer_credentials
4229
4229
  SET revoked_at = NOW()
@@ -4241,14 +4241,14 @@ async function up$139(db) {
4241
4241
  WHERE revoked_at IS NULL
4242
4242
  `.execute(db);
4243
4243
  }
4244
- async function down$139(db) {
4244
+ async function down$141(db) {
4245
4245
  await sql`DROP INDEX IF EXISTS public.peer_credentials_active_uniq`.execute(db);
4246
4246
  }
4247
4247
  //#endregion
4248
4248
  //#region src/db/migrations/013_execution_log_bytes.ts
4249
4249
  var _013_execution_log_bytes_exports = /* @__PURE__ */ __exportAll({
4250
- down: () => down$138,
4251
- up: () => up$138
4250
+ down: () => down$140,
4251
+ up: () => up$140
4252
4252
  });
4253
4253
  /**
4254
4254
  * Add `log_bytes BIGINT NOT NULL DEFAULT 0` columns to `execution_runs` and
@@ -4267,7 +4267,7 @@ var _013_execution_log_bytes_exports = /* @__PURE__ */ __exportAll({
4267
4267
  *
4268
4268
  * Idempotent (`ADD COLUMN IF NOT EXISTS`).
4269
4269
  */
4270
- async function up$138(db) {
4270
+ async function up$140(db) {
4271
4271
  await sql`
4272
4272
  ALTER TABLE public.execution_runs
4273
4273
  ADD COLUMN IF NOT EXISTS log_bytes BIGINT NOT NULL DEFAULT 0
@@ -4277,15 +4277,15 @@ async function up$138(db) {
4277
4277
  ADD COLUMN IF NOT EXISTS log_bytes BIGINT NOT NULL DEFAULT 0
4278
4278
  `.execute(db);
4279
4279
  }
4280
- async function down$138(db) {
4280
+ async function down$140(db) {
4281
4281
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS log_bytes`.execute(db);
4282
4282
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS log_bytes`.execute(db);
4283
4283
  }
4284
4284
  //#endregion
4285
4285
  //#region src/db/migrations/014_kici_events_lease_retry.ts
4286
4286
  var _014_kici_events_lease_retry_exports = /* @__PURE__ */ __exportAll({
4287
- down: () => down$137,
4288
- up: () => up$137
4287
+ down: () => down$139,
4288
+ up: () => up$139
4289
4289
  });
4290
4290
  /**
4291
4291
  * Add lease + retry + DLQ columns to `kici_events` so the EventRouter can
@@ -4319,7 +4319,7 @@ var _014_kici_events_lease_retry_exports = /* @__PURE__ */ __exportAll({
4319
4319
  *
4320
4320
  * Idempotent (`ADD COLUMN IF NOT EXISTS` + `CREATE INDEX IF NOT EXISTS`).
4321
4321
  */
4322
- async function up$137(db) {
4322
+ async function up$139(db) {
4323
4323
  await sql`
4324
4324
  ALTER TABLE public.kici_events
4325
4325
  ADD COLUMN IF NOT EXISTS claimed_at TIMESTAMPTZ,
@@ -4350,7 +4350,7 @@ async function up$137(db) {
4350
4350
  WHERE dlq_at IS NOT NULL
4351
4351
  `.execute(db);
4352
4352
  }
4353
- async function down$137(db) {
4353
+ async function down$139(db) {
4354
4354
  await sql`DROP INDEX IF EXISTS public.idx_kici_events_dlq`.execute(db);
4355
4355
  await sql`DROP INDEX IF EXISTS public.idx_kici_events_lease_expired`.execute(db);
4356
4356
  await sql`DROP INDEX IF EXISTS public.idx_kici_events_retry_due`.execute(db);
@@ -4368,8 +4368,8 @@ async function down$137(db) {
4368
4368
  //#endregion
4369
4369
  //#region src/db/migrations/015_org_settings_customer_scoped.ts
4370
4370
  var _015_org_settings_customer_scoped_exports = /* @__PURE__ */ __exportAll({
4371
- down: () => down$136,
4372
- up: () => up$136
4371
+ down: () => down$138,
4372
+ up: () => up$138
4373
4373
  });
4374
4374
  /**
4375
4375
  * Org-scope `org_settings` and qualify each glob entry by source.
@@ -4397,7 +4397,7 @@ var _015_org_settings_customer_scoped_exports = /* @__PURE__ */ __exportAll({
4397
4397
  * Idempotent: a re-run on an already-migrated DB sees `customer_id` exists
4398
4398
  * and the list columns are already jsonb, so it is a no-op.
4399
4399
  */
4400
- async function up$136(db) {
4400
+ async function up$138(db) {
4401
4401
  if ((await sql`
4402
4402
  SELECT EXISTS (
4403
4403
  SELECT 1 FROM information_schema.columns
@@ -4522,7 +4522,7 @@ async function up$136(db) {
4522
4522
  await sql`DROP TABLE _org_settings_merged`.execute(db);
4523
4523
  await sql`DROP TABLE _org_settings_stage`.execute(db);
4524
4524
  }
4525
- async function down$136(db) {
4525
+ async function down$138(db) {
4526
4526
  if (!(await sql`
4527
4527
  SELECT EXISTS (
4528
4528
  SELECT 1 FROM information_schema.columns
@@ -4547,8 +4547,8 @@ async function down$136(db) {
4547
4547
  //#endregion
4548
4548
  //#region src/db/migrations/016_org_settings_allow_http_npm.ts
4549
4549
  var _016_org_settings_allow_http_npm_exports = /* @__PURE__ */ __exportAll({
4550
- down: () => down$135,
4551
- up: () => up$135
4550
+ down: () => down$137,
4551
+ up: () => up$137
4552
4552
  });
4553
4553
  /**
4554
4554
  * Add `org_settings.allow_http_npm_registries boolean NOT NULL DEFAULT false`.
@@ -4561,7 +4561,7 @@ var _016_org_settings_allow_http_npm_exports = /* @__PURE__ */ __exportAll({
4561
4561
  *
4562
4562
  * Idempotent: a re-run on a DB that already has the column is a no-op.
4563
4563
  */
4564
- async function up$135(db) {
4564
+ async function up$137(db) {
4565
4565
  if ((await sql`
4566
4566
  SELECT EXISTS (
4567
4567
  SELECT 1 FROM information_schema.columns
@@ -4575,7 +4575,7 @@ async function up$135(db) {
4575
4575
  ADD COLUMN allow_http_npm_registries boolean NOT NULL DEFAULT false
4576
4576
  `.execute(db);
4577
4577
  }
4578
- async function down$135(db) {
4578
+ async function down$137(db) {
4579
4579
  await sql`
4580
4580
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS allow_http_npm_registries
4581
4581
  `.execute(db);
@@ -4583,8 +4583,8 @@ async function down$135(db) {
4583
4583
  //#endregion
4584
4584
  //#region src/db/migrations/017_org_id_widen.ts
4585
4585
  var _017_org_id_widen_exports = /* @__PURE__ */ __exportAll({
4586
- down: () => down$134,
4587
- up: () => up$134
4586
+ down: () => down$136,
4587
+ up: () => up$136
4588
4588
  });
4589
4589
  /**
4590
4590
  * Widen every orchestrator-side `org_id varchar(12)` column to
@@ -4623,17 +4623,17 @@ const ORG_ID_TABLES$1 = [
4623
4623
  "held_runs",
4624
4624
  "scoped_secrets"
4625
4625
  ];
4626
- async function up$134(db) {
4626
+ async function up$136(db) {
4627
4627
  for (const table of ORG_ID_TABLES$1) await sql.raw(`ALTER TABLE public.${table} ALTER COLUMN org_id TYPE varchar(16)`).execute(db);
4628
4628
  }
4629
- async function down$134(db) {
4629
+ async function down$136(db) {
4630
4630
  for (const table of ORG_ID_TABLES$1) await sql.raw(`ALTER TABLE public.${table} ALTER COLUMN org_id TYPE varchar(12)`).execute(db);
4631
4631
  }
4632
4632
  //#endregion
4633
4633
  //#region src/db/migrations/018_org_id_prefix_backfill.ts
4634
4634
  var _018_org_id_prefix_backfill_exports = /* @__PURE__ */ __exportAll({
4635
- down: () => down$133,
4636
- up: () => up$133
4635
+ down: () => down$135,
4636
+ up: () => up$135
4637
4637
  });
4638
4638
  /**
4639
4639
  * Prefix every orchestrator-side tenant string with `org_` to align
@@ -4678,19 +4678,19 @@ const CUSTOMER_ID_TABLES = [
4678
4678
  "workflow_registrations",
4679
4679
  "org_settings"
4680
4680
  ];
4681
- async function up$133(db) {
4681
+ async function up$135(db) {
4682
4682
  for (const table of ORG_ID_TABLES) await sql.raw(`UPDATE public.${table} SET org_id = 'org_' || org_id WHERE org_id <> 'kici-admin' AND org_id NOT LIKE 'org\\_%' ESCAPE '\\'`).execute(db);
4683
4683
  for (const table of CUSTOMER_ID_TABLES) await sql.raw(`UPDATE public.${table} SET customer_id = 'org_' || customer_id WHERE customer_id <> 'kici-admin' AND customer_id NOT LIKE 'org\\_%' ESCAPE '\\'`).execute(db);
4684
4684
  }
4685
- async function down$133(db) {
4685
+ async function down$135(db) {
4686
4686
  for (const table of CUSTOMER_ID_TABLES) await sql.raw(`UPDATE public.${table} SET customer_id = substring(customer_id from 5) WHERE customer_id LIKE 'org\\_%' ESCAPE '\\'`).execute(db);
4687
4687
  for (const table of ORG_ID_TABLES) await sql.raw(`UPDATE public.${table} SET org_id = substring(org_id from 5) WHERE org_id LIKE 'org\\_%' ESCAPE '\\'`).execute(db);
4688
4688
  }
4689
4689
  //#endregion
4690
4690
  //#region src/db/migrations/019_generic_sources_change_notify.ts
4691
4691
  var _019_generic_sources_change_notify_exports = /* @__PURE__ */ __exportAll({
4692
- down: () => down$132,
4693
- up: () => up$132
4692
+ down: () => down$134,
4693
+ up: () => up$134
4694
4694
  });
4695
4695
  /**
4696
4696
  * Add a Postgres trigger on `generic_webhook_sources` that emits
@@ -4713,7 +4713,7 @@ var _019_generic_sources_change_notify_exports = /* @__PURE__ */ __exportAll({
4713
4713
  * (`notify_sources_change()` + `sources_change_trigger`, defined in
4714
4714
  * `001_initial.ts`).
4715
4715
  */
4716
- async function up$132(db) {
4716
+ async function up$134(db) {
4717
4717
  await sql`
4718
4718
  CREATE FUNCTION public.notify_generic_sources_change() RETURNS trigger
4719
4719
  LANGUAGE plpgsql
@@ -4734,15 +4734,15 @@ async function up$132(db) {
4734
4734
  FOR EACH ROW EXECUTE FUNCTION public.notify_generic_sources_change()
4735
4735
  `.execute(db);
4736
4736
  }
4737
- async function down$132(db) {
4737
+ async function down$134(db) {
4738
4738
  await sql`DROP TRIGGER IF EXISTS generic_sources_change_trigger ON public.generic_webhook_sources`.execute(db);
4739
4739
  await sql`DROP FUNCTION IF EXISTS public.notify_generic_sources_change()`.execute(db);
4740
4740
  }
4741
4741
  //#endregion
4742
4742
  //#region src/db/migrations/020_org_settings_dashboard_write_policy.ts
4743
4743
  var _020_org_settings_dashboard_write_policy_exports = /* @__PURE__ */ __exportAll({
4744
- down: () => down$131,
4745
- up: () => up$131
4744
+ down: () => down$133,
4745
+ up: () => up$133
4746
4746
  });
4747
4747
  /**
4748
4748
  * Add `org_settings.dashboard_write_policy jsonb NOT NULL DEFAULT '{}'`.
@@ -4757,7 +4757,7 @@ var _020_org_settings_dashboard_write_policy_exports = /* @__PURE__ */ __exportA
4757
4757
  *
4758
4758
  * Idempotent: a re-run on a DB that already has the column is a no-op.
4759
4759
  */
4760
- async function up$131(db) {
4760
+ async function up$133(db) {
4761
4761
  if ((await sql`
4762
4762
  SELECT EXISTS (
4763
4763
  SELECT 1 FROM information_schema.columns
@@ -4771,7 +4771,7 @@ async function up$131(db) {
4771
4771
  ADD COLUMN dashboard_write_policy jsonb NOT NULL DEFAULT '{}'::jsonb
4772
4772
  `.execute(db);
4773
4773
  }
4774
- async function down$131(db) {
4774
+ async function down$133(db) {
4775
4775
  await sql`
4776
4776
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS dashboard_write_policy
4777
4777
  `.execute(db);
@@ -4779,8 +4779,8 @@ async function down$131(db) {
4779
4779
  //#endregion
4780
4780
  //#region src/db/migrations/021_check_run_tracking.ts
4781
4781
  var _021_check_run_tracking_exports = /* @__PURE__ */ __exportAll({
4782
- down: () => down$130,
4783
- up: () => up$130
4782
+ down: () => down$132,
4783
+ up: () => up$132
4784
4784
  });
4785
4785
  /**
4786
4786
  * Add `check_run_tracking` table for HA-safe check-run state persistence.
@@ -4804,7 +4804,7 @@ var _021_check_run_tracking_exports = /* @__PURE__ */ __exportAll({
4804
4804
  *
4805
4805
  * Idempotent: a re-run on a DB that already has the table is a no-op.
4806
4806
  */
4807
- async function up$130(db) {
4807
+ async function up$132(db) {
4808
4808
  if ((await sql`
4809
4809
  SELECT EXISTS (
4810
4810
  SELECT 1 FROM information_schema.tables
@@ -4835,14 +4835,14 @@ async function up$130(db) {
4835
4835
  WHERE run_id IS NOT NULL
4836
4836
  `.execute(db);
4837
4837
  }
4838
- async function down$130(db) {
4838
+ async function down$132(db) {
4839
4839
  await sql`DROP TABLE IF EXISTS public.check_run_tracking`.execute(db);
4840
4840
  }
4841
4841
  //#endregion
4842
4842
  //#region src/db/migrations/022_scaler_manager_state.ts
4843
4843
  var _022_scaler_manager_state_exports = /* @__PURE__ */ __exportAll({
4844
- down: () => down$129,
4845
- up: () => up$129
4844
+ down: () => down$131,
4845
+ up: () => up$131
4846
4846
  });
4847
4847
  /**
4848
4848
  * Add three tables persisting `ScalerManager` per-coord state:
@@ -4869,7 +4869,7 @@ var _022_scaler_manager_state_exports = /* @__PURE__ */ __exportAll({
4869
4869
  * Idempotent: a re-run on a DB that already has any of these tables
4870
4870
  * leaves the existing one alone.
4871
4871
  */
4872
- async function up$129(db) {
4872
+ async function up$131(db) {
4873
4873
  const tableExists = async (name) => {
4874
4874
  return (await sql`
4875
4875
  SELECT EXISTS (
@@ -4919,7 +4919,7 @@ async function up$129(db) {
4919
4919
  `.execute(db);
4920
4920
  }
4921
4921
  }
4922
- async function down$129(db) {
4922
+ async function down$131(db) {
4923
4923
  await sql`DROP TABLE IF EXISTS public.scaler_reservations`.execute(db);
4924
4924
  await sql`DROP TABLE IF EXISTS public.scaler_agent_jobs`.execute(db);
4925
4925
  await sql`DROP TABLE IF EXISTS public.scaler_spawning_agents`.execute(db);
@@ -4927,8 +4927,8 @@ async function down$129(db) {
4927
4927
  //#endregion
4928
4928
  //#region src/db/migrations/023_dispatch_queue_recovery_deadline.ts
4929
4929
  var _023_dispatch_queue_recovery_deadline_exports = /* @__PURE__ */ __exportAll({
4930
- down: () => down$128,
4931
- up: () => up$128
4930
+ down: () => down$130,
4931
+ up: () => up$130
4932
4932
  });
4933
4933
  /**
4934
4934
  * Add `dispatch_queue.recovery_deadline TIMESTAMPTZ` and
@@ -4952,7 +4952,7 @@ var _023_dispatch_queue_recovery_deadline_exports = /* @__PURE__ */ __exportAll(
4952
4952
  * Idempotent: re-running on a DB that already has either column is a
4953
4953
  * no-op.
4954
4954
  */
4955
- async function up$128(db) {
4955
+ async function up$130(db) {
4956
4956
  const colExists = async (name) => {
4957
4957
  return (await sql`
4958
4958
  SELECT EXISTS (
@@ -4977,7 +4977,7 @@ async function up$128(db) {
4977
4977
  WHERE recovery_deadline IS NOT NULL
4978
4978
  `.execute(db);
4979
4979
  }
4980
- async function down$128(db) {
4980
+ async function down$130(db) {
4981
4981
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_recovery_deadline`.execute(db);
4982
4982
  await sql`
4983
4983
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS recovery_agent_id
@@ -4989,8 +4989,8 @@ async function down$128(db) {
4989
4989
  //#endregion
4990
4990
  //#region src/db/migrations/024_dispatch_queue_provisioning_error.ts
4991
4991
  var _024_dispatch_queue_provisioning_error_exports = /* @__PURE__ */ __exportAll({
4992
- down: () => down$127,
4993
- up: () => up$127
4992
+ down: () => down$129,
4993
+ up: () => up$129
4994
4994
  });
4995
4995
  /**
4996
4996
  * Add `dispatch_queue.last_provisioning_error TEXT` recording the most
@@ -5006,7 +5006,7 @@ var _024_dispatch_queue_provisioning_error_exports = /* @__PURE__ */ __exportAll
5006
5006
  *
5007
5007
  * Idempotent: re-running on a DB that already has the column is a no-op.
5008
5008
  */
5009
- async function up$127(db) {
5009
+ async function up$129(db) {
5010
5010
  const colExists = async (name) => {
5011
5011
  return (await sql`
5012
5012
  SELECT EXISTS (
@@ -5022,7 +5022,7 @@ async function up$127(db) {
5022
5022
  ADD COLUMN last_provisioning_error TEXT
5023
5023
  `.execute(db);
5024
5024
  }
5025
- async function down$127(db) {
5025
+ async function down$129(db) {
5026
5026
  await sql`
5027
5027
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS last_provisioning_error
5028
5028
  `.execute(db);
@@ -5030,8 +5030,8 @@ async function down$127(db) {
5030
5030
  //#endregion
5031
5031
  //#region src/db/migrations/025_init_failure.ts
5032
5032
  var _025_init_failure_exports = /* @__PURE__ */ __exportAll({
5033
- down: () => down$126,
5034
- up: () => up$126
5033
+ down: () => down$128,
5034
+ up: () => up$128
5035
5035
  });
5036
5036
  /**
5037
5037
  * Add `init_failure jsonb` columns to `execution_runs` and `execution_jobs`.
@@ -5045,7 +5045,7 @@ var _025_init_failure_exports = /* @__PURE__ */ __exportAll({
5045
5045
  * Idempotent: re-running on a DB that already has either column is a no-op
5046
5046
  * for that column.
5047
5047
  */
5048
- async function up$126(db) {
5048
+ async function up$128(db) {
5049
5049
  const colExists = async (table, name) => {
5050
5050
  return (await sql`
5051
5051
  SELECT EXISTS (
@@ -5065,7 +5065,7 @@ async function up$126(db) {
5065
5065
  ADD COLUMN init_failure JSONB DEFAULT NULL
5066
5066
  `.execute(db);
5067
5067
  }
5068
- async function down$126(db) {
5068
+ async function down$128(db) {
5069
5069
  await sql`
5070
5070
  ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS init_failure
5071
5071
  `.execute(db);
@@ -5076,8 +5076,8 @@ async function down$126(db) {
5076
5076
  //#endregion
5077
5077
  //#region src/db/migrations/026_event_log_lockfile_corrupt.ts
5078
5078
  var _026_event_log_lockfile_corrupt_exports = /* @__PURE__ */ __exportAll({
5079
- down: () => down$125,
5080
- up: () => up$125
5079
+ down: () => down$127,
5080
+ up: () => up$127
5081
5081
  });
5082
5082
  /**
5083
5083
  * Extend the event_log.status CHECK constraint with 'lockfile_corrupt' so the
@@ -5086,7 +5086,7 @@ var _026_event_log_lockfile_corrupt_exports = /* @__PURE__ */ __exportAll({
5086
5086
  *
5087
5087
  * Idempotent: the DROP ... IF EXISTS / re-ADD pair re-runs cleanly.
5088
5088
  */
5089
- async function up$125(db) {
5089
+ async function up$127(db) {
5090
5090
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
5091
5091
  await sql`
5092
5092
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -5096,7 +5096,7 @@ async function up$125(db) {
5096
5096
  ])))
5097
5097
  `.execute(db);
5098
5098
  }
5099
- async function down$125(db) {
5099
+ async function down$127(db) {
5100
5100
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
5101
5101
  await sql`
5102
5102
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -5109,8 +5109,8 @@ async function down$125(db) {
5109
5109
  //#endregion
5110
5110
  //#region src/db/migrations/027_workflow_timeout.ts
5111
5111
  var _027_workflow_timeout_exports = /* @__PURE__ */ __exportAll({
5112
- down: () => down$124,
5113
- up: () => up$124
5112
+ down: () => down$126,
5113
+ up: () => up$126
5114
5114
  });
5115
5115
  /**
5116
5116
  * Add `workflow_timeout_ms integer` to `execution_runs`.
@@ -5128,13 +5128,13 @@ var _027_workflow_timeout_exports = /* @__PURE__ */ __exportAll({
5128
5128
  *
5129
5129
  * Idempotent: re-running on a DB that already has the column is a no-op.
5130
5130
  */
5131
- async function up$124(db) {
5131
+ async function up$126(db) {
5132
5132
  await sql`
5133
5133
  ALTER TABLE public.execution_runs
5134
5134
  ADD COLUMN IF NOT EXISTS workflow_timeout_ms INTEGER DEFAULT NULL
5135
5135
  `.execute(db);
5136
5136
  }
5137
- async function down$124(db) {
5137
+ async function down$126(db) {
5138
5138
  await sql`
5139
5139
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_timeout_ms
5140
5140
  `.execute(db);
@@ -5142,8 +5142,8 @@ async function down$124(db) {
5142
5142
  //#endregion
5143
5143
  //#region src/db/migrations/028_org_settings_user_cache.ts
5144
5144
  var _028_org_settings_user_cache_exports = /* @__PURE__ */ __exportAll({
5145
- down: () => down$123,
5146
- up: () => up$123
5145
+ down: () => down$125,
5146
+ up: () => up$125
5147
5147
  });
5148
5148
  /**
5149
5149
  * Add `org_settings.user_cache_quota_bytes bigint` and
@@ -5172,7 +5172,7 @@ async function columnExists$14(db, column) {
5172
5172
  ) AS exists
5173
5173
  `.execute(db)).rows[0]?.exists ?? false;
5174
5174
  }
5175
- async function up$123(db) {
5175
+ async function up$125(db) {
5176
5176
  if (!await columnExists$14(db, "user_cache_quota_bytes")) await sql`
5177
5177
  ALTER TABLE public.org_settings
5178
5178
  ADD COLUMN user_cache_quota_bytes bigint
@@ -5182,7 +5182,7 @@ async function up$123(db) {
5182
5182
  ADD COLUMN user_cache_ttl_ms bigint
5183
5183
  `.execute(db);
5184
5184
  }
5185
- async function down$123(db) {
5185
+ async function down$125(db) {
5186
5186
  await sql`
5187
5187
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS user_cache_quota_bytes
5188
5188
  `.execute(db);
@@ -5193,8 +5193,8 @@ async function down$123(db) {
5193
5193
  //#endregion
5194
5194
  //#region src/db/migrations/029_dispatch_queue_attempts.ts
5195
5195
  var _029_dispatch_queue_attempts_exports = /* @__PURE__ */ __exportAll({
5196
- down: () => down$122,
5197
- up: () => up$122
5196
+ down: () => down$124,
5197
+ up: () => up$124
5198
5198
  });
5199
5199
  /**
5200
5200
  * Add `dispatch_queue.dispatch_attempts INT NOT NULL DEFAULT 0`.
@@ -5208,7 +5208,7 @@ var _029_dispatch_queue_attempts_exports = /* @__PURE__ */ __exportAll({
5208
5208
  *
5209
5209
  * Idempotent: re-running on a DB that already has the column is a no-op.
5210
5210
  */
5211
- async function up$122(db) {
5211
+ async function up$124(db) {
5212
5212
  if (!((await sql`
5213
5213
  SELECT EXISTS (
5214
5214
  SELECT 1 FROM information_schema.columns
@@ -5221,7 +5221,7 @@ async function up$122(db) {
5221
5221
  ADD COLUMN dispatch_attempts INT NOT NULL DEFAULT 0
5222
5222
  `.execute(db);
5223
5223
  }
5224
- async function down$122(db) {
5224
+ async function down$124(db) {
5225
5225
  await sql`
5226
5226
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS dispatch_attempts
5227
5227
  `.execute(db);
@@ -5229,8 +5229,8 @@ async function down$122(db) {
5229
5229
  //#endregion
5230
5230
  //#region src/db/migrations/030_held_runs_env_set_null.ts
5231
5231
  var _030_held_runs_env_set_null_exports = /* @__PURE__ */ __exportAll({
5232
- down: () => down$121,
5233
- up: () => up$121
5232
+ down: () => down$123,
5233
+ up: () => up$123
5234
5234
  });
5235
5235
  /**
5236
5236
  * held_runs.environment_id becomes nullable with ON DELETE SET NULL so
@@ -5241,14 +5241,14 @@ var _030_held_runs_env_set_null_exports = /* @__PURE__ */ __exportAll({
5241
5241
  * Idempotent: dropping the NOT NULL and the constraint are both no-ops on a
5242
5242
  * re-run, and the constraint is re-created with the SET NULL action.
5243
5243
  */
5244
- async function up$121(db) {
5244
+ async function up$123(db) {
5245
5245
  await sql`ALTER TABLE public.held_runs ALTER COLUMN environment_id DROP NOT NULL`.execute(db);
5246
5246
  await sql`ALTER TABLE public.held_runs DROP CONSTRAINT IF EXISTS held_runs_environment_id_fkey`.execute(db);
5247
5247
  await sql`ALTER TABLE public.held_runs
5248
5248
  ADD CONSTRAINT held_runs_environment_id_fkey
5249
5249
  FOREIGN KEY (environment_id) REFERENCES public.environments(id) ON DELETE SET NULL`.execute(db);
5250
5250
  }
5251
- async function down$121(db) {
5251
+ async function down$123(db) {
5252
5252
  await sql`ALTER TABLE public.held_runs DROP CONSTRAINT IF EXISTS held_runs_environment_id_fkey`.execute(db);
5253
5253
  await sql`ALTER TABLE public.held_runs
5254
5254
  ADD CONSTRAINT held_runs_environment_id_fkey
@@ -5258,8 +5258,8 @@ async function down$121(db) {
5258
5258
  //#endregion
5259
5259
  //#region src/db/migrations/031_dispatch_queue_ack_deadline.ts
5260
5260
  var _031_dispatch_queue_ack_deadline_exports = /* @__PURE__ */ __exportAll({
5261
- down: () => down$120,
5262
- up: () => up$120
5261
+ down: () => down$122,
5262
+ up: () => up$122
5263
5263
  });
5264
5264
  /**
5265
5265
  * Add `dispatch_queue.ack_deadline TIMESTAMPTZ` and
@@ -5276,7 +5276,7 @@ var _031_dispatch_queue_ack_deadline_exports = /* @__PURE__ */ __exportAll({
5276
5276
  *
5277
5277
  * Idempotent: re-running on a DB that already has either column is a no-op.
5278
5278
  */
5279
- async function up$120(db) {
5279
+ async function up$122(db) {
5280
5280
  const colExists = async (name) => {
5281
5281
  return (await sql`
5282
5282
  SELECT EXISTS (
@@ -5301,7 +5301,7 @@ async function up$120(db) {
5301
5301
  WHERE ack_deadline IS NOT NULL
5302
5302
  `.execute(db);
5303
5303
  }
5304
- async function down$120(db) {
5304
+ async function down$122(db) {
5305
5305
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_ack_deadline`.execute(db);
5306
5306
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS ack_agent_id`.execute(db);
5307
5307
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS ack_deadline`.execute(db);
@@ -5309,8 +5309,8 @@ async function down$120(db) {
5309
5309
  //#endregion
5310
5310
  //#region src/db/migrations/032_org_settings_dispatch_ack_timeout.ts
5311
5311
  var _032_org_settings_dispatch_ack_timeout_exports = /* @__PURE__ */ __exportAll({
5312
- down: () => down$119,
5313
- up: () => up$119
5312
+ down: () => down$121,
5313
+ up: () => up$121
5314
5314
  });
5315
5315
  /**
5316
5316
  * Add `org_settings.dispatch_ack_timeout_ms BIGINT` (nullable).
@@ -5322,7 +5322,7 @@ var _032_org_settings_dispatch_ack_timeout_exports = /* @__PURE__ */ __exportAll
5322
5322
  *
5323
5323
  * Idempotent: a re-run on a DB that already has the column is a no-op.
5324
5324
  */
5325
- async function up$119(db) {
5325
+ async function up$121(db) {
5326
5326
  if ((await sql`
5327
5327
  SELECT EXISTS (
5328
5328
  SELECT 1 FROM information_schema.columns
@@ -5336,7 +5336,7 @@ async function up$119(db) {
5336
5336
  ADD COLUMN dispatch_ack_timeout_ms BIGINT
5337
5337
  `.execute(db);
5338
5338
  }
5339
- async function down$119(db) {
5339
+ async function down$121(db) {
5340
5340
  await sql`
5341
5341
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS dispatch_ack_timeout_ms
5342
5342
  `.execute(db);
@@ -5344,8 +5344,8 @@ async function down$119(db) {
5344
5344
  //#endregion
5345
5345
  //#region src/db/migrations/033_org_settings_approval.ts
5346
5346
  var _033_org_settings_approval_exports = /* @__PURE__ */ __exportAll({
5347
- down: () => down$118,
5348
- up: () => up$118
5347
+ down: () => down$120,
5348
+ up: () => up$120
5349
5349
  });
5350
5350
  /**
5351
5351
  * Add the two approval-policy columns to `org_settings`:
@@ -5362,7 +5362,7 @@ var _033_org_settings_approval_exports = /* @__PURE__ */ __exportAll({
5362
5362
  * and the orchestrator admin route. Idempotent: a re-run on a DB that already
5363
5363
  * has the columns is a no-op (each column is guarded independently).
5364
5364
  */
5365
- async function up$118(db) {
5365
+ async function up$120(db) {
5366
5366
  const colExists = async (column) => {
5367
5367
  return (await sql`
5368
5368
  SELECT EXISTS (
@@ -5382,7 +5382,7 @@ async function up$118(db) {
5382
5382
  ADD COLUMN allow_self_approval BOOLEAN NOT NULL DEFAULT true
5383
5383
  `.execute(db);
5384
5384
  }
5385
- async function down$118(db) {
5385
+ async function down$120(db) {
5386
5386
  await sql`
5387
5387
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS approval_expiry_seconds
5388
5388
  `.execute(db);
@@ -5393,8 +5393,8 @@ async function down$118(db) {
5393
5393
  //#endregion
5394
5394
  //#region src/db/migrations/034_held_runs_generalize.ts
5395
5395
  var _034_held_runs_generalize_exports = /* @__PURE__ */ __exportAll({
5396
- down: () => down$117,
5397
- up: () => up$117
5396
+ down: () => down$119,
5397
+ up: () => up$119
5398
5398
  });
5399
5399
  /**
5400
5400
  * Generalize `held_runs` from an environment-only hold into the unified
@@ -5416,7 +5416,7 @@ var _034_held_runs_generalize_exports = /* @__PURE__ */ __exportAll({
5416
5416
  * New `held_run_approvals` table: one row per approver decision, FK to
5417
5417
  * `held_runs.id` (uuid) with ON DELETE CASCADE.
5418
5418
  */
5419
- async function up$117(db) {
5419
+ async function up$119(db) {
5420
5420
  const colExists = async (column) => {
5421
5421
  return (await sql`
5422
5422
  SELECT EXISTS (
@@ -5449,7 +5449,7 @@ async function up$117(db) {
5449
5449
  ON public.held_run_approvals USING btree (held_run_id)
5450
5450
  `.execute(db);
5451
5451
  }
5452
- async function down$117(db) {
5452
+ async function down$119(db) {
5453
5453
  await sql`DROP TABLE IF EXISTS public.held_run_approvals`.execute(db);
5454
5454
  await sql`ALTER TABLE public.held_runs DROP COLUMN IF EXISTS approval_requirement`.execute(db);
5455
5455
  await sql`ALTER TABLE public.held_runs DROP COLUMN IF EXISTS trigger_source`.execute(db);
@@ -5459,8 +5459,8 @@ async function down$117(db) {
5459
5459
  //#endregion
5460
5460
  //#region src/db/migrations/035_pending_workflow_contexts.ts
5461
5461
  var _035_pending_workflow_contexts_exports = /* @__PURE__ */ __exportAll({
5462
- down: () => down$116,
5463
- up: () => up$116
5462
+ down: () => down$118,
5463
+ up: () => up$118
5464
5464
  });
5465
5465
  /**
5466
5466
  * Pending workflow dispatch context — backs resume of a workflow whose install
@@ -5469,7 +5469,7 @@ var _035_pending_workflow_contexts_exports = /* @__PURE__ */ __exportAll({
5469
5469
  * wait-timer expiry, concurrency slot free). The row is deleted once the resume
5470
5470
  * dispatch has been kicked off.
5471
5471
  */
5472
- async function up$116(db) {
5472
+ async function up$118(db) {
5473
5473
  await sql`
5474
5474
  CREATE TABLE IF NOT EXISTS public.pending_workflow_contexts (
5475
5475
  run_id text PRIMARY KEY,
@@ -5479,14 +5479,14 @@ async function up$116(db) {
5479
5479
  )
5480
5480
  `.execute(db);
5481
5481
  }
5482
- async function down$116(db) {
5482
+ async function down$118(db) {
5483
5483
  await sql`DROP TABLE IF EXISTS public.pending_workflow_contexts`.execute(db);
5484
5484
  }
5485
5485
  //#endregion
5486
5486
  //#region src/db/migrations/036_attestations.ts
5487
5487
  var _036_attestations_exports = /* @__PURE__ */ __exportAll({
5488
- down: () => down$115,
5489
- up: () => up$115
5488
+ down: () => down$117,
5489
+ up: () => up$117
5490
5490
  });
5491
5491
  /**
5492
5492
  * Add the `attestations` table for build-provenance bundles.
@@ -5499,7 +5499,7 @@ var _036_attestations_exports = /* @__PURE__ */ __exportAll({
5499
5499
  *
5500
5500
  * Idempotent: a re-run on a DB that already has the table is a no-op.
5501
5501
  */
5502
- async function up$115(db) {
5502
+ async function up$117(db) {
5503
5503
  if ((await sql`
5504
5504
  SELECT EXISTS (
5505
5505
  SELECT 1 FROM information_schema.tables
@@ -5525,14 +5525,14 @@ async function up$115(db) {
5525
5525
  ON public.attestations (run_id, job_id)
5526
5526
  `.execute(db);
5527
5527
  }
5528
- async function down$115(db) {
5528
+ async function down$117(db) {
5529
5529
  await sql`DROP TABLE IF EXISTS public.attestations`.execute(db);
5530
5530
  }
5531
5531
  //#endregion
5532
5532
  //#region src/db/migrations/037_generic_sources_provider_type_local.ts
5533
5533
  var _037_generic_sources_provider_type_local_exports = /* @__PURE__ */ __exportAll({
5534
- down: () => down$114,
5535
- up: () => up$114
5534
+ down: () => down$116,
5535
+ up: () => up$116
5536
5536
  });
5537
5537
  /**
5538
5538
  * Replace the `generic_webhook_sources.provider_type` CHECK constraint so it
@@ -5549,7 +5549,7 @@ var _037_generic_sources_provider_type_local_exports = /* @__PURE__ */ __exportA
5549
5549
  * Idempotent: the constraint is dropped IF EXISTS and recreated; the data
5550
5550
  * backfill is a plain UPDATE that is a no-op once no `'internal'` rows remain.
5551
5551
  */
5552
- async function up$114(db) {
5552
+ async function up$116(db) {
5553
5553
  await sql`
5554
5554
  ALTER TABLE public.generic_webhook_sources
5555
5555
  DROP CONSTRAINT IF EXISTS generic_webhook_sources_provider_type_check
@@ -5565,7 +5565,7 @@ async function up$114(db) {
5565
5565
  CHECK (provider_type = ANY (ARRAY['generic'::text, 'local'::text]))
5566
5566
  `.execute(db);
5567
5567
  }
5568
- async function down$114(db) {
5568
+ async function down$116(db) {
5569
5569
  await sql`
5570
5570
  ALTER TABLE public.generic_webhook_sources
5571
5571
  DROP CONSTRAINT IF EXISTS generic_webhook_sources_provider_type_check
@@ -5584,8 +5584,8 @@ async function down$114(db) {
5584
5584
  //#endregion
5585
5585
  //#region src/db/migrations/038_remote_sources.ts
5586
5586
  var _038_remote_sources_exports = /* @__PURE__ */ __exportAll({
5587
- down: () => down$113,
5588
- up: () => up$113
5587
+ down: () => down$115,
5588
+ up: () => up$115
5589
5589
  });
5590
5590
  /**
5591
5591
  * `remote_sources` anchors a Platform-relayed `kici run remote` to its real
@@ -5597,7 +5597,7 @@ var _038_remote_sources_exports = /* @__PURE__ */ __exportAll({
5597
5597
  *
5598
5598
  * Idempotent: a re-run on a DB that already has the table is a no-op.
5599
5599
  */
5600
- async function up$113(db) {
5600
+ async function up$115(db) {
5601
5601
  if ((await sql`
5602
5602
  SELECT EXISTS (
5603
5603
  SELECT 1 FROM information_schema.tables
@@ -5616,14 +5616,14 @@ async function up$113(db) {
5616
5616
  )
5617
5617
  `.execute(db);
5618
5618
  }
5619
- async function down$113(db) {
5619
+ async function down$115(db) {
5620
5620
  await sql`DROP TABLE IF EXISTS public.remote_sources`.execute(db);
5621
5621
  }
5622
5622
  //#endregion
5623
5623
  //#region src/db/migrations/039_host_roster.ts
5624
5624
  var _039_host_roster_exports = /* @__PURE__ */ __exportAll({
5625
- down: () => down$112,
5626
- up: () => up$112
5625
+ down: () => down$114,
5626
+ up: () => up$114
5627
5627
  });
5628
5628
  /**
5629
5629
  * `host_roster` is KiCI's declared inventory: one durable row per agent the
@@ -5640,7 +5640,7 @@ var _039_host_roster_exports = /* @__PURE__ */ __exportAll({
5640
5640
  *
5641
5641
  * Idempotent: a re-run on a DB that already has the table is a no-op.
5642
5642
  */
5643
- async function up$112(db) {
5643
+ async function up$114(db) {
5644
5644
  if ((await sql`
5645
5645
  SELECT EXISTS (
5646
5646
  SELECT 1 FROM information_schema.tables
@@ -5670,14 +5670,14 @@ async function up$112(db) {
5670
5670
  await sql`CREATE INDEX idx_host_roster_reap
5671
5671
  ON public.host_roster (lifecycle_class, last_seen)`.execute(db);
5672
5672
  }
5673
- async function down$112(db) {
5673
+ async function down$114(db) {
5674
5674
  await sql`DROP TABLE IF EXISTS public.host_roster`.execute(db);
5675
5675
  }
5676
5676
  //#endregion
5677
5677
  //#region src/db/migrations/040_runsonall_pin.ts
5678
5678
  var _040_runsonall_pin_exports = /* @__PURE__ */ __exportAll({
5679
- down: () => down$111,
5680
- up: () => up$111
5679
+ down: () => down$113,
5680
+ up: () => up$113
5681
5681
  });
5682
5682
  /**
5683
5683
  * Add the `runsOnAll` host fan-out columns:
@@ -5704,7 +5704,7 @@ async function colExists$22(db, table, name) {
5704
5704
  ) AS exists
5705
5705
  `.execute(db)).rows[0]?.exists ?? false;
5706
5706
  }
5707
- async function up$111(db) {
5707
+ async function up$113(db) {
5708
5708
  if (!await colExists$22(db, "dispatch_queue", "pinned_agent_id")) await sql`ALTER TABLE public.dispatch_queue ADD COLUMN pinned_agent_id TEXT`.execute(db);
5709
5709
  if (!await colExists$22(db, "execution_jobs", "base_job_name")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN base_job_name TEXT`.execute(db);
5710
5710
  if (!await colExists$22(db, "execution_jobs", "variant_kind")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN variant_kind TEXT`.execute(db);
@@ -5715,7 +5715,7 @@ async function up$111(db) {
5715
5715
  WHERE pinned_agent_id IS NOT NULL
5716
5716
  `.execute(db);
5717
5717
  }
5718
- async function down$111(db) {
5718
+ async function down$113(db) {
5719
5719
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_pinned_agent`.execute(db);
5720
5720
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS pinned_agent_id`.execute(db);
5721
5721
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS variant_label`.execute(db);
@@ -5725,8 +5725,8 @@ async function down$111(db) {
5725
5725
  //#endregion
5726
5726
  //#region src/db/migrations/041_wave_gated.ts
5727
5727
  var _041_wave_gated_exports = /* @__PURE__ */ __exportAll({
5728
- down: () => down$110,
5729
- up: () => up$110
5728
+ down: () => down$112,
5729
+ up: () => up$112
5730
5730
  });
5731
5731
  /**
5732
5732
  * Add the rolling fan-out wave-gate columns:
@@ -5756,7 +5756,7 @@ async function colExists$21(db, table, name) {
5756
5756
  ) AS exists
5757
5757
  `.execute(db)).rows[0]?.exists ?? false;
5758
5758
  }
5759
- async function up$110(db) {
5759
+ async function up$112(db) {
5760
5760
  if (!await colExists$21(db, "execution_jobs", "wave_gated")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN wave_gated boolean NOT NULL DEFAULT false`.execute(db);
5761
5761
  if (!await colExists$21(db, "execution_jobs", "wave_max_parallel")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN wave_max_parallel integer`.execute(db);
5762
5762
  if (!await colExists$21(db, "execution_jobs", "wave_fail_fast")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN wave_fail_fast boolean`.execute(db);
@@ -5765,7 +5765,7 @@ async function up$110(db) {
5765
5765
  ON public.execution_jobs (run_id, base_job_name, wave_gated)
5766
5766
  `.execute(db);
5767
5767
  }
5768
- async function down$110(db) {
5768
+ async function down$112(db) {
5769
5769
  await sql`DROP INDEX IF EXISTS public.idx_execution_jobs_wave`.execute(db);
5770
5770
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS wave_fail_fast`.execute(db);
5771
5771
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS wave_max_parallel`.execute(db);
@@ -5774,8 +5774,8 @@ async function down$110(db) {
5774
5774
  //#endregion
5775
5775
  //#region src/db/migrations/042_dispatch_queue_patterns.ts
5776
5776
  var _042_dispatch_queue_patterns_exports = /* @__PURE__ */ __exportAll({
5777
- down: () => down$109,
5778
- up: () => up$109
5777
+ down: () => down$111,
5778
+ up: () => up$111
5779
5779
  });
5780
5780
  /**
5781
5781
  * Add pattern columns to dispatch_queue. Exact labels stay in runs_on_labels /
@@ -5801,19 +5801,19 @@ async function colExists$20(db, table, name) {
5801
5801
  ) AS exists
5802
5802
  `.execute(db)).rows[0]?.exists ?? false;
5803
5803
  }
5804
- async function up$109(db) {
5804
+ async function up$111(db) {
5805
5805
  if (!await colExists$20(db, "dispatch_queue", "runs_on_patterns")) await sql`ALTER TABLE public.dispatch_queue ADD COLUMN runs_on_patterns jsonb NOT NULL DEFAULT '[]'::jsonb`.execute(db);
5806
5806
  if (!await colExists$20(db, "dispatch_queue", "exclude_patterns")) await sql`ALTER TABLE public.dispatch_queue ADD COLUMN exclude_patterns jsonb NOT NULL DEFAULT '[]'::jsonb`.execute(db);
5807
5807
  }
5808
- async function down$109(db) {
5808
+ async function down$111(db) {
5809
5809
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS exclude_patterns`.execute(db);
5810
5810
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS runs_on_patterns`.execute(db);
5811
5811
  }
5812
5812
  //#endregion
5813
5813
  //#region src/db/migrations/043_rerouted_to_peer.ts
5814
5814
  var _043_rerouted_to_peer_exports = /* @__PURE__ */ __exportAll({
5815
- down: () => down$108,
5816
- up: () => up$108
5815
+ down: () => down$110,
5816
+ up: () => up$110
5817
5817
  });
5818
5818
  /**
5819
5819
  * Add a nullable `rerouted_to_peer text` marker to execution_jobs. Non-null
@@ -5834,17 +5834,17 @@ async function colExists$19(db, table, name) {
5834
5834
  ) AS exists
5835
5835
  `.execute(db)).rows[0]?.exists ?? false;
5836
5836
  }
5837
- async function up$108(db) {
5837
+ async function up$110(db) {
5838
5838
  if (!await colExists$19(db, "execution_jobs", "rerouted_to_peer")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN rerouted_to_peer text`.execute(db);
5839
5839
  }
5840
- async function down$108(db) {
5840
+ async function down$110(db) {
5841
5841
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS rerouted_to_peer`.execute(db);
5842
5842
  }
5843
5843
  //#endregion
5844
5844
  //#region src/db/migrations/044_check_mode.ts
5845
5845
  var _044_check_mode_exports = /* @__PURE__ */ __exportAll({
5846
- down: () => down$107,
5847
- up: () => up$107
5846
+ down: () => down$109,
5847
+ up: () => up$109
5848
5848
  });
5849
5849
  /**
5850
5850
  * Add idempotent check-mode columns:
@@ -5871,13 +5871,13 @@ async function colExists$18(db, table, name) {
5871
5871
  ) AS exists
5872
5872
  `.execute(db)).rows[0]?.exists ?? false;
5873
5873
  }
5874
- async function up$107(db) {
5874
+ async function up$109(db) {
5875
5875
  if (!await colExists$18(db, "execution_runs", "check_mode")) await sql`ALTER TABLE public.execution_runs ADD COLUMN check_mode text`.execute(db);
5876
5876
  if (!await colExists$18(db, "execution_steps", "check_outcome")) await sql`ALTER TABLE public.execution_steps ADD COLUMN check_outcome text`.execute(db);
5877
5877
  if (!await colExists$18(db, "execution_steps", "drift_summary")) await sql`ALTER TABLE public.execution_steps ADD COLUMN drift_summary text`.execute(db);
5878
5878
  if (!await colExists$18(db, "execution_steps", "drift")) await sql`ALTER TABLE public.execution_steps ADD COLUMN drift jsonb`.execute(db);
5879
5879
  }
5880
- async function down$107(db) {
5880
+ async function down$109(db) {
5881
5881
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS drift`.execute(db);
5882
5882
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS drift_summary`.execute(db);
5883
5883
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS check_outcome`.execute(db);
@@ -5886,8 +5886,8 @@ async function down$107(db) {
5886
5886
  //#endregion
5887
5887
  //#region src/db/migrations/045_host_properties.ts
5888
5888
  var _045_host_properties_exports = /* @__PURE__ */ __exportAll({
5889
- down: () => down$106,
5890
- up: () => up$106
5889
+ down: () => down$108,
5890
+ up: () => up$108
5891
5891
  });
5892
5892
  /**
5893
5893
  * Add the typed host-vars dimension to the host roster:
@@ -5901,18 +5901,18 @@ var _045_host_properties_exports = /* @__PURE__ */ __exportAll({
5901
5901
  * Idempotent (`ADD COLUMN IF NOT EXISTS`): re-running on a DB that already has
5902
5902
  * the column is a no-op. Existing data is preserved (additive column).
5903
5903
  */
5904
- async function up$106(db) {
5904
+ async function up$108(db) {
5905
5905
  await sql`ALTER TABLE public.host_roster
5906
5906
  ADD COLUMN IF NOT EXISTS host_properties jsonb NOT NULL DEFAULT '{}'::jsonb`.execute(db);
5907
5907
  }
5908
- async function down$106(db) {
5908
+ async function down$108(db) {
5909
5909
  await sql`ALTER TABLE public.host_roster DROP COLUMN IF EXISTS host_properties`.execute(db);
5910
5910
  }
5911
5911
  //#endregion
5912
5912
  //#region src/db/migrations/046_join_token_consumed_by_instance.ts
5913
5913
  var _046_join_token_consumed_by_instance_exports = /* @__PURE__ */ __exportAll({
5914
- down: () => down$105,
5915
- up: () => up$105
5914
+ down: () => down$107,
5915
+ up: () => up$107
5916
5916
  });
5917
5917
  /**
5918
5918
  * Record the joining peer's instanceId at first consumption of a join token:
@@ -5927,18 +5927,18 @@ var _046_join_token_consumed_by_instance_exports = /* @__PURE__ */ __exportAll({
5927
5927
  * Idempotent (`ADD COLUMN IF NOT EXISTS`): re-running on a DB that already has
5928
5928
  * the column is a no-op. Existing data is preserved (additive nullable column).
5929
5929
  */
5930
- async function up$105(db) {
5930
+ async function up$107(db) {
5931
5931
  await sql`ALTER TABLE public.join_tokens
5932
5932
  ADD COLUMN IF NOT EXISTS consumed_by_instance text`.execute(db);
5933
5933
  }
5934
- async function down$105(db) {
5934
+ async function down$107(db) {
5935
5935
  await sql`ALTER TABLE public.join_tokens DROP COLUMN IF EXISTS consumed_by_instance`.execute(db);
5936
5936
  }
5937
5937
  //#endregion
5938
5938
  //#region src/db/migrations/047_needs_run_on.ts
5939
5939
  var _047_needs_run_on_exports = /* @__PURE__ */ __exportAll({
5940
- down: () => down$104,
5941
- up: () => up$104
5940
+ down: () => down$106,
5941
+ up: () => up$106
5942
5942
  });
5943
5943
  /**
5944
5944
  * Migrate `execution_job_needs` from the binary `if_failed` policy to a
@@ -5973,7 +5973,7 @@ async function colExists$17(db, table, name) {
5973
5973
  `.execute(db)).rows[0]?.exists ?? false;
5974
5974
  }
5975
5975
  const SUCCESS_ONLY_DEFAULT = `'${SUCCESS_ONLY_JSON}'`;
5976
- async function up$104(db) {
5976
+ async function up$106(db) {
5977
5977
  if (!await colExists$17(db, "execution_job_needs", "run_on")) await sql`
5978
5978
  ALTER TABLE public.execution_job_needs
5979
5979
  ADD COLUMN run_on text NOT NULL DEFAULT ${sql.raw(SUCCESS_ONLY_DEFAULT)}
@@ -5992,7 +5992,7 @@ async function up$104(db) {
5992
5992
  await sql`ALTER TABLE public.execution_job_needs DROP COLUMN if_failed`.execute(db);
5993
5993
  }
5994
5994
  }
5995
- async function down$104(db) {
5995
+ async function down$106(db) {
5996
5996
  if (!await colExists$17(db, "execution_job_needs", "if_failed")) await sql`
5997
5997
  ALTER TABLE public.execution_job_needs
5998
5998
  ADD COLUMN if_failed text NOT NULL DEFAULT 'skip'
@@ -6008,8 +6008,8 @@ async function down$104(db) {
6008
6008
  //#endregion
6009
6009
  //#region src/db/migrations/048_host_reboot_pending.ts
6010
6010
  var _048_host_reboot_pending_exports = /* @__PURE__ */ __exportAll({
6011
- down: () => down$103,
6012
- up: () => up$103
6011
+ down: () => down$105,
6012
+ up: () => up$105
6013
6013
  });
6014
6014
  /**
6015
6015
  * Add `host_roster.reboot_pending_until timestamptz NULL` — the persisted
@@ -6026,18 +6026,18 @@ var _048_host_reboot_pending_exports = /* @__PURE__ */ __exportAll({
6026
6026
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
6027
6027
  * preserved.
6028
6028
  */
6029
- async function up$103(db) {
6029
+ async function up$105(db) {
6030
6030
  await sql`ALTER TABLE public.host_roster
6031
6031
  ADD COLUMN IF NOT EXISTS reboot_pending_until timestamptz`.execute(db);
6032
6032
  }
6033
- async function down$103(db) {
6033
+ async function down$105(db) {
6034
6034
  await sql`ALTER TABLE public.host_roster DROP COLUMN IF EXISTS reboot_pending_until`.execute(db);
6035
6035
  }
6036
6036
  //#endregion
6037
6037
  //#region src/db/migrations/049_held_runs_payload.ts
6038
6038
  var _049_held_runs_payload_exports = /* @__PURE__ */ __exportAll({
6039
- down: () => down$102,
6040
- up: () => up$102
6039
+ down: () => down$104,
6040
+ up: () => up$104
6041
6041
  });
6042
6042
  /**
6043
6043
  * Add `held_runs.payload jsonb NULL` — the drift payload captured when a
@@ -6049,18 +6049,18 @@ var _049_held_runs_payload_exports = /* @__PURE__ */ __exportAll({
6049
6049
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
6050
6050
  * preserved.
6051
6051
  */
6052
- async function up$102(db) {
6052
+ async function up$104(db) {
6053
6053
  await sql`ALTER TABLE public.held_runs
6054
6054
  ADD COLUMN IF NOT EXISTS payload jsonb`.execute(db);
6055
6055
  }
6056
- async function down$102(db) {
6056
+ async function down$104(db) {
6057
6057
  await sql`ALTER TABLE public.held_runs DROP COLUMN IF EXISTS payload`.execute(db);
6058
6058
  }
6059
6059
  //#endregion
6060
6060
  //#region src/db/migrations/050_sources_slug.ts
6061
6061
  var _050_sources_slug_exports = /* @__PURE__ */ __exportAll({
6062
- down: () => down$101,
6063
- up: () => up$101
6062
+ down: () => down$103,
6063
+ up: () => up$103
6064
6064
  });
6065
6065
  /**
6066
6066
  * Add `sources.slug TEXT NULL` — the GitHub App slug (the URL-safe identifier
@@ -6075,18 +6075,18 @@ var _050_sources_slug_exports = /* @__PURE__ */ __exportAll({
6075
6075
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
6076
6076
  * preserved.
6077
6077
  */
6078
- async function up$101(db) {
6078
+ async function up$103(db) {
6079
6079
  await sql`ALTER TABLE public.sources
6080
6080
  ADD COLUMN IF NOT EXISTS slug text`.execute(db);
6081
6081
  }
6082
- async function down$101(db) {
6082
+ async function down$103(db) {
6083
6083
  await sql`ALTER TABLE public.sources DROP COLUMN IF EXISTS slug`.execute(db);
6084
6084
  }
6085
6085
  //#endregion
6086
6086
  //#region src/db/migrations/051_binding_host_pattern.ts
6087
6087
  var _051_binding_host_pattern_exports = /* @__PURE__ */ __exportAll({
6088
- down: () => down$100,
6089
- up: () => up$100
6088
+ down: () => down$102,
6089
+ up: () => up$102
6090
6090
  });
6091
6091
  /**
6092
6092
  * Add a per-host dimension to environment secret bindings:
@@ -6102,7 +6102,7 @@ var _051_binding_host_pattern_exports = /* @__PURE__ */ __exportAll({
6102
6102
  * Idempotent: re-running on a DB that already has the column / index is a no-op.
6103
6103
  * Additive — existing data is preserved.
6104
6104
  */
6105
- async function up$100(db) {
6105
+ async function up$102(db) {
6106
6106
  await sql`ALTER TABLE public.environment_bindings
6107
6107
  ADD COLUMN IF NOT EXISTS host_pattern text NOT NULL DEFAULT '**'`.execute(db);
6108
6108
  await sql`ALTER TABLE public.environment_bindings
@@ -6110,7 +6110,7 @@ async function up$100(db) {
6110
6110
  await sql`CREATE UNIQUE INDEX IF NOT EXISTS environment_bindings_env_scope_host_uniq
6111
6111
  ON public.environment_bindings (environment_id, scope_pattern, host_pattern)`.execute(db);
6112
6112
  }
6113
- async function down$100(db) {
6113
+ async function down$102(db) {
6114
6114
  await sql`DROP INDEX IF EXISTS public.environment_bindings_env_scope_host_uniq`.execute(db);
6115
6115
  await sql`ALTER TABLE public.environment_bindings
6116
6116
  DROP COLUMN IF EXISTS host_pattern`.execute(db);
@@ -6120,8 +6120,8 @@ async function down$100(db) {
6120
6120
  //#endregion
6121
6121
  //#region src/db/migrations/052_host_reach_metadata.ts
6122
6122
  var _052_host_reach_metadata_exports = /* @__PURE__ */ __exportAll({
6123
- down: () => down$99,
6124
- up: () => up$99
6123
+ down: () => down$101,
6124
+ up: () => up$101
6125
6125
  });
6126
6126
  /**
6127
6127
  * Add pre-agent reach metadata to the host roster so a declared host (no agent
@@ -6138,14 +6138,14 @@ var _052_host_reach_metadata_exports = /* @__PURE__ */ __exportAll({
6138
6138
  * behaves exactly as before. Idempotent (`ADD COLUMN IF NOT EXISTS`); additive,
6139
6139
  * so existing data is preserved.
6140
6140
  */
6141
- async function up$99(db) {
6141
+ async function up$101(db) {
6142
6142
  await sql`ALTER TABLE public.host_roster
6143
6143
  ADD COLUMN IF NOT EXISTS address text,
6144
6144
  ADD COLUMN IF NOT EXISTS ssh_user text,
6145
6145
  ADD COLUMN IF NOT EXISTS ssh_port integer,
6146
6146
  ADD COLUMN IF NOT EXISTS ssh_key_secret text`.execute(db);
6147
6147
  }
6148
- async function down$99(db) {
6148
+ async function down$101(db) {
6149
6149
  await sql`ALTER TABLE public.host_roster
6150
6150
  DROP COLUMN IF EXISTS address,
6151
6151
  DROP COLUMN IF EXISTS ssh_user,
@@ -6155,8 +6155,8 @@ async function down$99(db) {
6155
6155
  //#endregion
6156
6156
  //#region src/db/migrations/053_agent_token_single_use.ts
6157
6157
  var _053_agent_token_single_use_exports = /* @__PURE__ */ __exportAll({
6158
- down: () => down$98,
6159
- up: () => up$98
6158
+ down: () => down$100,
6159
+ up: () => up$100
6160
6160
  });
6161
6161
  /**
6162
6162
  * Add a single-use marker to agent tokens for the bootstrap (init-runner)
@@ -6171,19 +6171,19 @@ var _053_agent_token_single_use_exports = /* @__PURE__ */ __exportAll({
6171
6171
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
6172
6172
  * preserved.
6173
6173
  */
6174
- async function up$98(db) {
6174
+ async function up$100(db) {
6175
6175
  await sql`ALTER TABLE public.agent_tokens
6176
6176
  ADD COLUMN IF NOT EXISTS consumed_at timestamptz`.execute(db);
6177
6177
  }
6178
- async function down$98(db) {
6178
+ async function down$100(db) {
6179
6179
  await sql`ALTER TABLE public.agent_tokens
6180
6180
  DROP COLUMN IF EXISTS consumed_at`.execute(db);
6181
6181
  }
6182
6182
  //#endregion
6183
6183
  //#region src/db/migrations/054_local_working_tree.ts
6184
6184
  var _054_local_working_tree_exports = /* @__PURE__ */ __exportAll({
6185
- down: () => down$97,
6186
- up: () => up$97
6185
+ down: () => down$99,
6186
+ up: () => up$99
6187
6187
  });
6188
6188
  /**
6189
6189
  * Mark runs that executed an uploaded local working tree (`kici run remote`):
@@ -6196,19 +6196,19 @@ var _054_local_working_tree_exports = /* @__PURE__ */ __exportAll({
6196
6196
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive with a default, so existing
6197
6197
  * data is preserved.
6198
6198
  */
6199
- async function up$97(db) {
6199
+ async function up$99(db) {
6200
6200
  await sql`ALTER TABLE public.execution_runs
6201
6201
  ADD COLUMN IF NOT EXISTS local_working_tree boolean NOT NULL DEFAULT false`.execute(db);
6202
6202
  }
6203
- async function down$97(db) {
6203
+ async function down$99(db) {
6204
6204
  await sql`ALTER TABLE public.execution_runs
6205
6205
  DROP COLUMN IF EXISTS local_working_tree`.execute(db);
6206
6206
  }
6207
6207
  //#endregion
6208
6208
  //#region src/db/migrations/055_agent_token_mandatory_labels.ts
6209
6209
  var _055_agent_token_mandatory_labels_exports = /* @__PURE__ */ __exportAll({
6210
- down: () => down$96,
6211
- up: () => up$96
6210
+ down: () => down$98,
6211
+ up: () => up$98
6212
6212
  });
6213
6213
  /**
6214
6214
  * Add a token-bound mandatory-label taint to agent tokens:
@@ -6224,19 +6224,19 @@ var _055_agent_token_mandatory_labels_exports = /* @__PURE__ */ __exportAll({
6224
6224
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
6225
6225
  * preserved.
6226
6226
  */
6227
- async function up$96(db) {
6227
+ async function up$98(db) {
6228
6228
  await sql`ALTER TABLE public.agent_tokens
6229
6229
  ADD COLUMN IF NOT EXISTS mandatory_labels text`.execute(db);
6230
6230
  }
6231
- async function down$96(db) {
6231
+ async function down$98(db) {
6232
6232
  await sql`ALTER TABLE public.agent_tokens
6233
6233
  DROP COLUMN IF EXISTS mandatory_labels`.execute(db);
6234
6234
  }
6235
6235
  //#endregion
6236
6236
  //#region src/db/migrations/056_execution_jobs_environments.ts
6237
6237
  var _056_execution_jobs_environments_exports = /* @__PURE__ */ __exportAll({
6238
- down: () => down$95,
6239
- up: () => up$95
6238
+ down: () => down$97,
6239
+ up: () => up$97
6240
6240
  });
6241
6241
  /**
6242
6242
  * Add a per-job bound deployment-environment list to `execution_jobs`:
@@ -6251,19 +6251,19 @@ var _056_execution_jobs_environments_exports = /* @__PURE__ */ __exportAll({
6251
6251
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
6252
6252
  * preserved.
6253
6253
  */
6254
- async function up$95(db) {
6254
+ async function up$97(db) {
6255
6255
  await sql`ALTER TABLE public.execution_jobs
6256
6256
  ADD COLUMN IF NOT EXISTS environments text`.execute(db);
6257
6257
  }
6258
- async function down$95(db) {
6258
+ async function down$97(db) {
6259
6259
  await sql`ALTER TABLE public.execution_jobs
6260
6260
  DROP COLUMN IF EXISTS environments`.execute(db);
6261
6261
  }
6262
6262
  //#endregion
6263
6263
  //#region src/db/migrations/057_step_concurrency.ts
6264
6264
  var _057_step_concurrency_exports = /* @__PURE__ */ __exportAll({
6265
- down: () => down$94,
6266
- up: () => up$94
6265
+ down: () => down$96,
6266
+ up: () => up$96
6267
6267
  });
6268
6268
  /**
6269
6269
  * Add parallel step-group concurrency columns to `execution_steps`:
@@ -6286,19 +6286,19 @@ async function colExists$16(db, table, name) {
6286
6286
  ) AS exists
6287
6287
  `.execute(db)).rows[0]?.exists ?? false;
6288
6288
  }
6289
- async function up$94(db) {
6289
+ async function up$96(db) {
6290
6290
  if (!await colExists$16(db, "execution_steps", "concurrency_kind")) await sql`ALTER TABLE public.execution_steps ADD COLUMN concurrency_kind text`.execute(db);
6291
6291
  if (!await colExists$16(db, "execution_steps", "group_id")) await sql`ALTER TABLE public.execution_steps ADD COLUMN group_id text`.execute(db);
6292
6292
  }
6293
- async function down$94(db) {
6293
+ async function down$96(db) {
6294
6294
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS group_id`.execute(db);
6295
6295
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS concurrency_kind`.execute(db);
6296
6296
  }
6297
6297
  //#endregion
6298
6298
  //#region src/db/migrations/058_access_log_agent_label.ts
6299
6299
  var _058_access_log_agent_label_exports = /* @__PURE__ */ __exportAll({
6300
- down: () => down$93,
6301
- up: () => up$93
6300
+ down: () => down$95,
6301
+ up: () => up$95
6302
6302
  });
6303
6303
  /**
6304
6304
  * Add `access_log.agent_label text` — the human-set name of the agent that
@@ -6318,17 +6318,17 @@ async function colExists$15(db, table, name) {
6318
6318
  ) AS exists
6319
6319
  `.execute(db)).rows[0]?.exists ?? false;
6320
6320
  }
6321
- async function up$93(db) {
6321
+ async function up$95(db) {
6322
6322
  if (!await colExists$15(db, "access_log", "agent_label")) await sql`ALTER TABLE public.access_log ADD COLUMN agent_label text`.execute(db);
6323
6323
  }
6324
- async function down$93(db) {
6324
+ async function down$95(db) {
6325
6325
  await sql`ALTER TABLE public.access_log DROP COLUMN IF EXISTS agent_label`.execute(db);
6326
6326
  }
6327
6327
  //#endregion
6328
6328
  //#region src/db/migrations/059_attestation_verdict.ts
6329
6329
  var _059_attestation_verdict_exports = /* @__PURE__ */ __exportAll({
6330
- down: () => down$92,
6331
- up: () => up$92
6330
+ down: () => down$94,
6331
+ up: () => up$94
6332
6332
  });
6333
6333
  /**
6334
6334
  * Add server-side verification verdict columns to `attestations`, plus the
@@ -6355,7 +6355,7 @@ async function colExists$14(db, table, name) {
6355
6355
  ) AS exists
6356
6356
  `.execute(db)).rows[0]?.exists ?? false;
6357
6357
  }
6358
- async function up$92(db) {
6358
+ async function up$94(db) {
6359
6359
  if (await colExists$14(db, "attestations", "verify_status")) return;
6360
6360
  await sql`
6361
6361
  ALTER TABLE public.attestations
@@ -6368,7 +6368,7 @@ async function up$92(db) {
6368
6368
  await sql`CREATE INDEX idx_attestations_verify_status ON public.attestations (verify_status)`.execute(db);
6369
6369
  await sql`CREATE INDEX idx_attestations_created_at ON public.attestations (created_at)`.execute(db);
6370
6370
  }
6371
- async function down$92(db) {
6371
+ async function down$94(db) {
6372
6372
  await sql`DROP INDEX IF EXISTS idx_attestations_created_at`.execute(db);
6373
6373
  await sql`DROP INDEX IF EXISTS idx_attestations_verify_status`.execute(db);
6374
6374
  await sql`DROP INDEX IF EXISTS idx_attestations_subject_name`.execute(db);
@@ -6383,8 +6383,8 @@ async function down$92(db) {
6383
6383
  //#endregion
6384
6384
  //#region src/db/migrations/060_run_trigger_actor.ts
6385
6385
  var _060_run_trigger_actor_exports = /* @__PURE__ */ __exportAll({
6386
- down: () => down$91,
6387
- up: () => up$91
6386
+ down: () => down$93,
6387
+ up: () => up$93
6388
6388
  });
6389
6389
  /**
6390
6390
  * Add the triggering-actor columns to `execution_runs`:
@@ -6412,12 +6412,12 @@ async function colExists$13(db, table, name) {
6412
6412
  ) AS exists
6413
6413
  `.execute(db)).rows[0]?.exists ?? false;
6414
6414
  }
6415
- async function up$91(db) {
6415
+ async function up$93(db) {
6416
6416
  if (!await colExists$13(db, "execution_runs", "trigger_actor_provider")) await sql`ALTER TABLE public.execution_runs ADD COLUMN trigger_actor_provider text`.execute(db);
6417
6417
  if (!await colExists$13(db, "execution_runs", "trigger_actor_username")) await sql`ALTER TABLE public.execution_runs ADD COLUMN trigger_actor_username text`.execute(db);
6418
6418
  if (!await colExists$13(db, "execution_runs", "trigger_actor_user_id")) await sql`ALTER TABLE public.execution_runs ADD COLUMN trigger_actor_user_id text`.execute(db);
6419
6419
  }
6420
- async function down$91(db) {
6420
+ async function down$93(db) {
6421
6421
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_actor_provider`.execute(db);
6422
6422
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_actor_username`.execute(db);
6423
6423
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_actor_user_id`.execute(db);
@@ -6425,8 +6425,8 @@ async function down$91(db) {
6425
6425
  //#endregion
6426
6426
  //#region src/db/migrations/061_execution_runs_environment_id.ts
6427
6427
  var _061_execution_runs_environment_id_exports = /* @__PURE__ */ __exportAll({
6428
- down: () => down$90,
6429
- up: () => up$90
6428
+ down: () => down$92,
6429
+ up: () => up$92
6430
6430
  });
6431
6431
  /**
6432
6432
  * Add `environment_id` to `execution_runs` so environment run-history can be
@@ -6462,7 +6462,7 @@ async function colExists$12(db, table, name) {
6462
6462
  ) AS exists
6463
6463
  `.execute(db)).rows[0]?.exists ?? false;
6464
6464
  }
6465
- async function up$90(db) {
6465
+ async function up$92(db) {
6466
6466
  if (!await colExists$12(db, "execution_runs", "environment_id")) await sql`
6467
6467
  ALTER TABLE public.execution_runs
6468
6468
  ADD COLUMN environment_id uuid
@@ -6484,15 +6484,15 @@ async function up$90(db) {
6484
6484
  WHERE e2.type = 'fixed' AND e2.name = er.environment) = 1
6485
6485
  `.execute(db);
6486
6486
  }
6487
- async function down$90(db) {
6487
+ async function down$92(db) {
6488
6488
  await sql`DROP INDEX IF EXISTS idx_execution_runs_environment_id`.execute(db);
6489
6489
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS environment_id`.execute(db);
6490
6490
  }
6491
6491
  //#endregion
6492
6492
  //#region src/db/migrations/062_execution_runs_agent_label.ts
6493
6493
  var _062_execution_runs_agent_label_exports = /* @__PURE__ */ __exportAll({
6494
- down: () => down$89,
6495
- up: () => up$89
6494
+ down: () => down$91,
6495
+ up: () => up$91
6496
6496
  });
6497
6497
  /**
6498
6498
  * Add the agent-provenance columns to `execution_runs`:
@@ -6517,19 +6517,19 @@ async function colExists$11(db, table, name) {
6517
6517
  ) AS exists
6518
6518
  `.execute(db)).rows[0]?.exists ?? false;
6519
6519
  }
6520
- async function up$89(db) {
6520
+ async function up$91(db) {
6521
6521
  if (!await colExists$11(db, "execution_runs", "triggered_by_agent_label")) await sql`ALTER TABLE public.execution_runs ADD COLUMN triggered_by_agent_label text`.execute(db);
6522
6522
  if (!await colExists$11(db, "execution_runs", "cancelled_by_agent_label")) await sql`ALTER TABLE public.execution_runs ADD COLUMN cancelled_by_agent_label text`.execute(db);
6523
6523
  }
6524
- async function down$89(db) {
6524
+ async function down$91(db) {
6525
6525
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS triggered_by_agent_label`.execute(db);
6526
6526
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS cancelled_by_agent_label`.execute(db);
6527
6527
  }
6528
6528
  //#endregion
6529
6529
  //#region src/db/migrations/063_access_log_agent_label_index.ts
6530
6530
  var _063_access_log_agent_label_index_exports = /* @__PURE__ */ __exportAll({
6531
- down: () => down$88,
6532
- up: () => up$88
6531
+ down: () => down$90,
6532
+ up: () => up$90
6533
6533
  });
6534
6534
  /**
6535
6535
  * Index `access_log.agent_label` (column added by migration 058) so the
@@ -6537,17 +6537,17 @@ var _063_access_log_agent_label_index_exports = /* @__PURE__ */ __exportAll({
6537
6537
  * the dashboard "agent name" filter) does an indexed exact-match lookup
6538
6538
  * instead of a scan. Idempotent.
6539
6539
  */
6540
- async function up$88(db) {
6540
+ async function up$90(db) {
6541
6541
  await sql`CREATE INDEX IF NOT EXISTS access_log_agent_label_idx ON public.access_log (agent_label)`.execute(db);
6542
6542
  }
6543
- async function down$88(db) {
6543
+ async function down$90(db) {
6544
6544
  await sql`DROP INDEX IF EXISTS access_log_agent_label_idx`.execute(db);
6545
6545
  }
6546
6546
  //#endregion
6547
6547
  //#region src/db/migrations/064_execution_jobs_skipped_environments.ts
6548
6548
  var _064_execution_jobs_skipped_environments_exports = /* @__PURE__ */ __exportAll({
6549
- down: () => down$87,
6550
- up: () => up$87
6549
+ down: () => down$89,
6550
+ up: () => up$89
6551
6551
  });
6552
6552
  /**
6553
6553
  * Add the test-run skipped-environment columns to `execution_jobs`:
@@ -6562,13 +6562,13 @@ var _064_execution_jobs_skipped_environments_exports = /* @__PURE__ */ __exportA
6562
6562
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
6563
6563
  * preserved.
6564
6564
  */
6565
- async function up$87(db) {
6565
+ async function up$89(db) {
6566
6566
  await sql`ALTER TABLE public.execution_jobs
6567
6567
  ADD COLUMN IF NOT EXISTS skipped_environments text`.execute(db);
6568
6568
  await sql`ALTER TABLE public.execution_jobs
6569
6569
  ADD COLUMN IF NOT EXISTS env_warning text`.execute(db);
6570
6570
  }
6571
- async function down$87(db) {
6571
+ async function down$89(db) {
6572
6572
  await sql`ALTER TABLE public.execution_jobs
6573
6573
  DROP COLUMN IF EXISTS skipped_environments`.execute(db);
6574
6574
  await sql`ALTER TABLE public.execution_jobs
@@ -6577,8 +6577,8 @@ async function down$87(db) {
6577
6577
  //#endregion
6578
6578
  //#region src/db/migrations/065_pending_attestations.ts
6579
6579
  var _065_pending_attestations_exports = /* @__PURE__ */ __exportAll({
6580
- down: () => down$86,
6581
- up: () => up$86
6580
+ down: () => down$88,
6581
+ up: () => up$88
6582
6582
  });
6583
6583
  /**
6584
6584
  * Add the `pending_attestations` deferred-attestation outbox and an idempotency
@@ -6598,7 +6598,7 @@ var _065_pending_attestations_exports = /* @__PURE__ */ __exportAll({
6598
6598
  *
6599
6599
  * Idempotent: guarded on table existence.
6600
6600
  */
6601
- async function up$86(db) {
6601
+ async function up$88(db) {
6602
6602
  if ((await sql`
6603
6603
  SELECT EXISTS (
6604
6604
  SELECT 1 FROM information_schema.tables
@@ -6637,15 +6637,15 @@ async function up$86(db) {
6637
6637
  ON public.attestations (run_id, job_id, subject_digest)
6638
6638
  `.execute(db);
6639
6639
  }
6640
- async function down$86(db) {
6640
+ async function down$88(db) {
6641
6641
  await sql`DROP INDEX IF EXISTS uq_attestations_run_job_subject`.execute(db);
6642
6642
  await sql`DROP TABLE IF EXISTS public.pending_attestations`.execute(db);
6643
6643
  }
6644
6644
  //#endregion
6645
6645
  //#region src/db/migrations/066_pending_attestations_rejected.ts
6646
6646
  var _066_pending_attestations_rejected_exports = /* @__PURE__ */ __exportAll({
6647
- down: () => down$85,
6648
- up: () => up$85
6647
+ down: () => down$87,
6648
+ up: () => up$87
6649
6649
  });
6650
6650
  /**
6651
6651
  * Add `rejected_at` to `pending_attestations`: the terminal-rejection marker for
@@ -6656,14 +6656,14 @@ var _066_pending_attestations_rejected_exports = /* @__PURE__ */ __exportAll({
6656
6656
  *
6657
6657
  * Idempotent: guarded on column existence.
6658
6658
  */
6659
- async function up$85(db) {
6659
+ async function up$87(db) {
6660
6660
  if (await columnExists$13(db, "pending_attestations", "rejected_at")) return;
6661
6661
  await sql`
6662
6662
  ALTER TABLE public.pending_attestations
6663
6663
  ADD COLUMN rejected_at TIMESTAMPTZ
6664
6664
  `.execute(db);
6665
6665
  }
6666
- async function down$85(db) {
6666
+ async function down$87(db) {
6667
6667
  if (!await columnExists$13(db, "pending_attestations", "rejected_at")) return;
6668
6668
  await sql`
6669
6669
  ALTER TABLE public.pending_attestations
@@ -6681,8 +6681,8 @@ async function columnExists$13(db, table, column) {
6681
6681
  //#endregion
6682
6682
  //#region src/db/migrations/067_environments_to_contexts.ts
6683
6683
  var _067_environments_to_contexts_exports = /* @__PURE__ */ __exportAll({
6684
- down: () => down$84,
6685
- up: () => up$84
6684
+ down: () => down$86,
6685
+ up: () => up$86
6686
6686
  });
6687
6687
  /**
6688
6688
  * Rename the named-policy object from "environment" to "context" across the
@@ -6716,7 +6716,7 @@ var _067_environments_to_contexts_exports = /* @__PURE__ */ __exportAll({
6716
6716
  * columns automatically (Postgres references them by identity, not name), so
6717
6717
  * only the one hand-named index above needs an explicit rename.
6718
6718
  */
6719
- async function up$84(db) {
6719
+ async function up$86(db) {
6720
6720
  await sql`ALTER TABLE public.environments RENAME TO contexts`.execute(db);
6721
6721
  await sql`ALTER TABLE public.environment_bindings RENAME TO context_bindings`.execute(db);
6722
6722
  await sql`ALTER TABLE public.environment_variables RENAME TO context_variables`.execute(db);
@@ -6735,7 +6735,7 @@ async function up$84(db) {
6735
6735
  await sql`ALTER TABLE public.held_runs ALTER COLUMN queue_type SET DEFAULT 'context'`.execute(db);
6736
6736
  await sql`ALTER TABLE public.held_runs ALTER COLUMN trigger_source SET DEFAULT 'context'`.execute(db);
6737
6737
  }
6738
- async function down$84(db) {
6738
+ async function down$86(db) {
6739
6739
  await sql`ALTER TABLE public.held_runs ALTER COLUMN trigger_source SET DEFAULT 'environment'`.execute(db);
6740
6740
  await sql`ALTER TABLE public.held_runs ALTER COLUMN queue_type SET DEFAULT 'environment'`.execute(db);
6741
6741
  await sql`UPDATE public.held_runs SET trigger_source = 'environment' WHERE trigger_source = 'context'`.execute(db);
@@ -6757,8 +6757,8 @@ async function down$84(db) {
6757
6757
  //#endregion
6758
6758
  //#region src/db/migrations/068_request_idempotency.ts
6759
6759
  var _068_request_idempotency_exports = /* @__PURE__ */ __exportAll({
6760
- down: () => down$83,
6761
- up: () => up$83
6760
+ down: () => down$85,
6761
+ up: () => up$85
6762
6762
  });
6763
6763
  /**
6764
6764
  * Add the `request_idempotency` claim table: a `request_id`-keyed record that
@@ -6773,12 +6773,12 @@ var _068_request_idempotency_exports = /* @__PURE__ */ __exportAll({
6773
6773
  *
6774
6774
  * Idempotent: guarded on table existence.
6775
6775
  */
6776
- async function up$83(db) {
6776
+ async function up$85(db) {
6777
6777
  if (await tableExists$5(db, "request_idempotency")) return;
6778
6778
  await db.schema.createTable("request_idempotency").addColumn("request_id", "text", (c) => c.primaryKey()).addColumn("new_run_id", "text", (c) => c.notNull()).addColumn("created_at", "timestamptz", (c) => c.notNull().defaultTo(sql`now()`)).execute();
6779
6779
  await db.schema.createIndex("idx_request_idempotency_created_at").on("request_idempotency").column("created_at").execute();
6780
6780
  }
6781
- async function down$83(db) {
6781
+ async function down$85(db) {
6782
6782
  await db.schema.dropTable("request_idempotency").ifExists().execute();
6783
6783
  }
6784
6784
  async function tableExists$5(db, table) {
@@ -6792,8 +6792,8 @@ async function tableExists$5(db, table) {
6792
6792
  //#endregion
6793
6793
  //#region src/db/migrations/069_reroute_tunables.ts
6794
6794
  var _069_reroute_tunables_exports = /* @__PURE__ */ __exportAll({
6795
- down: () => down$82,
6796
- up: () => up$82
6795
+ down: () => down$84,
6796
+ up: () => up$84
6797
6797
  });
6798
6798
  /**
6799
6799
  * Add the three reroute-tunable columns to `org_settings` (all nullable):
@@ -6812,12 +6812,12 @@ var _069_reroute_tunables_exports = /* @__PURE__ */ __exportAll({
6812
6812
  * Idempotent: each column add is guarded on column existence, so a re-run on a
6813
6813
  * DB that already has a column is a no-op for that column.
6814
6814
  */
6815
- async function up$82(db) {
6815
+ async function up$84(db) {
6816
6816
  await addColumnIfMissing(db, "reroute_spawn_window_ms", "BIGINT");
6817
6817
  await addColumnIfMissing(db, "reroute_ack_timeout_ms", "BIGINT");
6818
6818
  await addColumnIfMissing(db, "reroute_max_hops", "INTEGER");
6819
6819
  }
6820
- async function down$82(db) {
6820
+ async function down$84(db) {
6821
6821
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_spawn_window_ms`.execute(db);
6822
6822
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_ack_timeout_ms`.execute(db);
6823
6823
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_max_hops`.execute(db);
@@ -6836,8 +6836,8 @@ async function addColumnIfMissing(db, column, type) {
6836
6836
  //#endregion
6837
6837
  //#region src/db/migrations/070_execution_runs_failure_class.ts
6838
6838
  var _070_execution_runs_failure_class_exports = /* @__PURE__ */ __exportAll({
6839
- down: () => down$81,
6840
- up: () => up$81
6839
+ down: () => down$83,
6840
+ up: () => up$83
6841
6841
  });
6842
6842
  /**
6843
6843
  * Add `execution_runs.failure_class` — the reason a terminal run failed
@@ -6858,17 +6858,17 @@ async function colExists$10(db, table, name) {
6858
6858
  ) AS exists
6859
6859
  `.execute(db)).rows[0]?.exists ?? false;
6860
6860
  }
6861
- async function up$81(db) {
6861
+ async function up$83(db) {
6862
6862
  if (!await colExists$10(db, "execution_runs", "failure_class")) await sql`ALTER TABLE public.execution_runs ADD COLUMN failure_class text`.execute(db);
6863
6863
  }
6864
- async function down$81(db) {
6864
+ async function down$83(db) {
6865
6865
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS failure_class`.execute(db);
6866
6866
  }
6867
6867
  //#endregion
6868
6868
  //#region src/db/migrations/071_batch_accumulation.ts
6869
6869
  var _071_batch_accumulation_exports = /* @__PURE__ */ __exportAll({
6870
- down: () => down$80,
6871
- up: () => up$80
6870
+ down: () => down$82,
6871
+ up: () => up$82
6872
6872
  });
6873
6873
  /**
6874
6874
  * Add the batch-accumulation tables that back the `workflows_failed_batch`
@@ -6892,7 +6892,7 @@ var _071_batch_accumulation_exports = /* @__PURE__ */ __exportAll({
6892
6892
  *
6893
6893
  * Idempotent: guarded on table existence.
6894
6894
  */
6895
- async function up$80(db) {
6895
+ async function up$82(db) {
6896
6896
  if ((await sql`
6897
6897
  SELECT EXISTS (
6898
6898
  SELECT 1 FROM information_schema.tables
@@ -6937,15 +6937,15 @@ async function up$80(db) {
6937
6937
  ON public.batch_accumulation_items (window_id)
6938
6938
  `.execute(db);
6939
6939
  }
6940
- async function down$80(db) {
6940
+ async function down$82(db) {
6941
6941
  await sql`DROP TABLE IF EXISTS public.batch_accumulation_items`.execute(db);
6942
6942
  await sql`DROP TABLE IF EXISTS public.batch_accumulation_windows`.execute(db);
6943
6943
  }
6944
6944
  //#endregion
6945
6945
  //#region src/db/migrations/072_dispatch_queue_run_id_index.ts
6946
6946
  var _072_dispatch_queue_run_id_index_exports = /* @__PURE__ */ __exportAll({
6947
- down: () => down$79,
6948
- up: () => up$79
6947
+ down: () => down$81,
6948
+ up: () => up$81
6949
6949
  });
6950
6950
  /**
6951
6951
  * Add `idx_dispatch_queue_run_id` on `dispatch_queue (run_id)`.
@@ -6958,20 +6958,20 @@ var _072_dispatch_queue_run_id_index_exports = /* @__PURE__ */ __exportAll({
6958
6958
  *
6959
6959
  * Idempotent: `IF NOT EXISTS` makes a re-run a no-op.
6960
6960
  */
6961
- async function up$79(db) {
6961
+ async function up$81(db) {
6962
6962
  await sql`
6963
6963
  CREATE INDEX IF NOT EXISTS idx_dispatch_queue_run_id
6964
6964
  ON public.dispatch_queue (run_id)
6965
6965
  `.execute(db);
6966
6966
  }
6967
- async function down$79(db) {
6967
+ async function down$81(db) {
6968
6968
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_run_id`.execute(db);
6969
6969
  }
6970
6970
  //#endregion
6971
6971
  //#region src/db/migrations/073_org_settings_ingest_concurrency.ts
6972
6972
  var _073_org_settings_ingest_concurrency_exports = /* @__PURE__ */ __exportAll({
6973
- down: () => down$78,
6974
- up: () => up$78
6973
+ down: () => down$80,
6974
+ up: () => up$80
6975
6975
  });
6976
6976
  /**
6977
6977
  * Add `org_settings.ingest_max_concurrency BIGINT` (nullable).
@@ -6982,7 +6982,7 @@ var _073_org_settings_ingest_concurrency_exports = /* @__PURE__ */ __exportAll({
6982
6982
  *
6983
6983
  * Idempotent: a re-run on a DB that already has the column is a no-op.
6984
6984
  */
6985
- async function up$78(db) {
6985
+ async function up$80(db) {
6986
6986
  if ((await sql`
6987
6987
  SELECT EXISTS (
6988
6988
  SELECT 1 FROM information_schema.columns
@@ -6996,7 +6996,7 @@ async function up$78(db) {
6996
6996
  ADD COLUMN ingest_max_concurrency BIGINT
6997
6997
  `.execute(db);
6998
6998
  }
6999
- async function down$78(db) {
6999
+ async function down$80(db) {
7000
7000
  await sql`
7001
7001
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS ingest_max_concurrency
7002
7002
  `.execute(db);
@@ -7004,8 +7004,8 @@ async function down$78(db) {
7004
7004
  //#endregion
7005
7005
  //#region src/db/migrations/074_normalize_zero_concurrency_limit.ts
7006
7006
  var _074_normalize_zero_concurrency_limit_exports = /* @__PURE__ */ __exportAll({
7007
- down: () => down$77,
7008
- up: () => up$77
7007
+ down: () => down$79,
7008
+ up: () => up$79
7009
7009
  });
7010
7010
  /**
7011
7011
  * Normalize degenerate context concurrency limits. A `concurrency_limit` of 0
@@ -7016,15 +7016,15 @@ var _074_normalize_zero_concurrency_limit_exports = /* @__PURE__ */ __exportAll(
7016
7016
  * Idempotent; down() is a no-op (a normalized 0 cannot — and should not — be
7017
7017
  * restored).
7018
7018
  */
7019
- async function up$77(db) {
7019
+ async function up$79(db) {
7020
7020
  await sql`UPDATE public.contexts SET concurrency_limit = NULL WHERE concurrency_limit <= 0`.execute(db);
7021
7021
  }
7022
- async function down$77(_db) {}
7022
+ async function down$79(_db) {}
7023
7023
  //#endregion
7024
7024
  //#region src/db/migrations/075_ingest_overflow_buffer.ts
7025
7025
  var _075_ingest_overflow_buffer_exports = /* @__PURE__ */ __exportAll({
7026
- down: () => down$76,
7027
- up: () => up$76
7026
+ down: () => down$78,
7027
+ up: () => up$78
7028
7028
  });
7029
7029
  /**
7030
7030
  * Durable overflow buffer for shed webhook-ingest deliveries.
@@ -7038,7 +7038,7 @@ var _075_ingest_overflow_buffer_exports = /* @__PURE__ */ __exportAll({
7038
7038
  *
7039
7039
  * Idempotent: a re-run on a DB that already has the table is a no-op.
7040
7040
  */
7041
- async function up$76(db) {
7041
+ async function up$78(db) {
7042
7042
  if ((await sql`
7043
7043
  SELECT EXISTS (
7044
7044
  SELECT 1 FROM information_schema.tables
@@ -7071,14 +7071,14 @@ async function up$76(db) {
7071
7071
  ON public.ingest_overflow_buffer (delivery_id)
7072
7072
  `.execute(db);
7073
7073
  }
7074
- async function down$76(db) {
7074
+ async function down$78(db) {
7075
7075
  await sql`DROP TABLE IF EXISTS public.ingest_overflow_buffer`.execute(db);
7076
7076
  }
7077
7077
  //#endregion
7078
7078
  //#region src/db/migrations/076_artifacts.ts
7079
7079
  var _076_artifacts_exports = /* @__PURE__ */ __exportAll({
7080
- down: () => down$75,
7081
- up: () => up$75
7080
+ down: () => down$77,
7081
+ up: () => up$77
7082
7082
  });
7083
7083
  /**
7084
7084
  * Add the `artifacts` table for user-facing build artifacts and the per-org
@@ -7095,7 +7095,7 @@ var _076_artifacts_exports = /* @__PURE__ */ __exportAll({
7095
7095
  *
7096
7096
  * Idempotent: a re-run on a DB that already has the table / columns is a no-op.
7097
7097
  */
7098
- async function up$75(db) {
7098
+ async function up$77(db) {
7099
7099
  if (!(await sql`
7100
7100
  SELECT EXISTS (
7101
7101
  SELECT 1 FROM information_schema.tables
@@ -7131,7 +7131,7 @@ async function up$75(db) {
7131
7131
  ADD COLUMN IF NOT EXISTS artifact_ttl_ms BIGINT
7132
7132
  `.execute(db);
7133
7133
  }
7134
- async function down$75(db) {
7134
+ async function down$77(db) {
7135
7135
  await sql`DROP TABLE IF EXISTS public.artifacts`.execute(db);
7136
7136
  await sql`
7137
7137
  ALTER TABLE public.org_settings
@@ -7142,8 +7142,8 @@ async function down$75(db) {
7142
7142
  //#endregion
7143
7143
  //#region src/db/migrations/077_backup_runs.ts
7144
7144
  var _077_backup_runs_exports = /* @__PURE__ */ __exportAll({
7145
- down: () => down$74,
7146
- up: () => up$74
7145
+ down: () => down$76,
7146
+ up: () => up$76
7147
7147
  });
7148
7148
  /**
7149
7149
  * Add the `backup_runs` table: one row per successful `kici-admin db backup`,
@@ -7154,12 +7154,12 @@ var _077_backup_runs_exports = /* @__PURE__ */ __exportAll({
7154
7154
  *
7155
7155
  * Idempotent: guarded on table existence.
7156
7156
  */
7157
- async function up$74(db) {
7157
+ async function up$76(db) {
7158
7158
  if (await tableExists$4(db, "backup_runs")) return;
7159
7159
  await db.schema.createTable("backup_runs").addColumn("id", "bigserial", (c) => c.primaryKey()).addColumn("created_at", "timestamptz", (c) => c.notNull().defaultTo(sql`now()`)).addColumn("dump_path", "text", (c) => c.notNull()).addColumn("byte_size", "bigint", (c) => c.notNull()).addColumn("secret_key_version", "integer").addColumn("pg_server_version", "text", (c) => c.notNull()).addColumn("migrations_hash", "text", (c) => c.notNull()).addColumn("hostname", "text", (c) => c.notNull()).execute();
7160
7160
  await db.schema.createIndex("idx_backup_runs_created_at").on("backup_runs").column("created_at").execute();
7161
7161
  }
7162
- async function down$74(db) {
7162
+ async function down$76(db) {
7163
7163
  await db.schema.dropTable("backup_runs").ifExists().execute();
7164
7164
  }
7165
7165
  async function tableExists$4(db, table) {
@@ -7173,8 +7173,8 @@ async function tableExists$4(db, table) {
7173
7173
  //#endregion
7174
7174
  //#region src/db/migrations/078_org_settings_backup_staleness.ts
7175
7175
  var _078_org_settings_backup_staleness_exports = /* @__PURE__ */ __exportAll({
7176
- down: () => down$73,
7177
- up: () => up$73
7176
+ down: () => down$75,
7177
+ up: () => up$75
7178
7178
  });
7179
7179
  /**
7180
7180
  * Add the nullable `org_settings.backup_staleness_warn_hours INTEGER` column:
@@ -7184,7 +7184,7 @@ var _078_org_settings_backup_staleness_exports = /* @__PURE__ */ __exportAll({
7184
7184
  *
7185
7185
  * Idempotent: guarded on column existence.
7186
7186
  */
7187
- async function up$73(db) {
7187
+ async function up$75(db) {
7188
7188
  if ((await sql`
7189
7189
  SELECT EXISTS (
7190
7190
  SELECT 1 FROM information_schema.columns
@@ -7198,7 +7198,7 @@ async function up$73(db) {
7198
7198
  ADD COLUMN backup_staleness_warn_hours INTEGER
7199
7199
  `.execute(db);
7200
7200
  }
7201
- async function down$73(db) {
7201
+ async function down$75(db) {
7202
7202
  await sql`
7203
7203
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS backup_staleness_warn_hours
7204
7204
  `.execute(db);
@@ -7206,8 +7206,8 @@ async function down$73(db) {
7206
7206
  //#endregion
7207
7207
  //#region src/db/migrations/079_org_settings_scaler_spawn_timeout.ts
7208
7208
  var _079_org_settings_scaler_spawn_timeout_exports = /* @__PURE__ */ __exportAll({
7209
- down: () => down$72,
7210
- up: () => up$72
7209
+ down: () => down$74,
7210
+ up: () => up$74
7211
7211
  });
7212
7212
  /**
7213
7213
  * Add `org_settings.scaler_spawn_timeout_ms BIGINT` (nullable).
@@ -7219,7 +7219,7 @@ var _079_org_settings_scaler_spawn_timeout_exports = /* @__PURE__ */ __exportAll
7219
7219
  *
7220
7220
  * Idempotent: a re-run on a DB that already has the column is a no-op.
7221
7221
  */
7222
- async function up$72(db) {
7222
+ async function up$74(db) {
7223
7223
  if ((await sql`
7224
7224
  SELECT EXISTS (
7225
7225
  SELECT 1 FROM information_schema.columns
@@ -7233,7 +7233,7 @@ async function up$72(db) {
7233
7233
  ADD COLUMN scaler_spawn_timeout_ms BIGINT
7234
7234
  `.execute(db);
7235
7235
  }
7236
- async function down$72(db) {
7236
+ async function down$74(db) {
7237
7237
  await sql`
7238
7238
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS scaler_spawn_timeout_ms
7239
7239
  `.execute(db);
@@ -7241,8 +7241,8 @@ async function down$72(db) {
7241
7241
  //#endregion
7242
7242
  //#region src/db/migrations/080_cluster_settings.ts
7243
7243
  var _080_cluster_settings_exports = /* @__PURE__ */ __exportAll({
7244
- down: () => down$71,
7245
- up: () => up$71
7244
+ down: () => down$73,
7245
+ up: () => up$73
7246
7246
  });
7247
7247
  /**
7248
7248
  * Create `cluster_settings`: a single-row (id='default') table of fleet-wide
@@ -7257,7 +7257,7 @@ var _080_cluster_settings_exports = /* @__PURE__ */ __exportAll({
7257
7257
  *
7258
7258
  * Idempotent: a re-run on a DB that already has the table is a no-op.
7259
7259
  */
7260
- async function up$71(db) {
7260
+ async function up$73(db) {
7261
7261
  if ((await sql`
7262
7262
  SELECT EXISTS (
7263
7263
  SELECT 1 FROM information_schema.tables
@@ -7281,14 +7281,14 @@ async function up$71(db) {
7281
7281
  )
7282
7282
  `.execute(db);
7283
7283
  }
7284
- async function down$71(db) {
7284
+ async function down$73(db) {
7285
7285
  await sql`DROP TABLE IF EXISTS public.cluster_settings`.execute(db);
7286
7286
  }
7287
7287
  //#endregion
7288
7288
  //#region src/db/migrations/081_org_settings_queue_timeout.ts
7289
7289
  var _081_org_settings_queue_timeout_exports = /* @__PURE__ */ __exportAll({
7290
- down: () => down$70,
7291
- up: () => up$70
7290
+ down: () => down$72,
7291
+ up: () => up$72
7292
7292
  });
7293
7293
  /**
7294
7294
  * Add `org_settings.queue_timeout_ms BIGINT` (nullable).
@@ -7305,7 +7305,7 @@ var _081_org_settings_queue_timeout_exports = /* @__PURE__ */ __exportAll({
7305
7305
  *
7306
7306
  * Idempotent: a re-run on a DB that already has the column is a no-op.
7307
7307
  */
7308
- async function up$70(db) {
7308
+ async function up$72(db) {
7309
7309
  if ((await sql`
7310
7310
  SELECT EXISTS (
7311
7311
  SELECT 1 FROM information_schema.columns
@@ -7319,7 +7319,7 @@ async function up$70(db) {
7319
7319
  ADD COLUMN queue_timeout_ms BIGINT
7320
7320
  `.execute(db);
7321
7321
  }
7322
- async function down$70(db) {
7322
+ async function down$72(db) {
7323
7323
  await sql`
7324
7324
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS queue_timeout_ms
7325
7325
  `.execute(db);
@@ -7327,8 +7327,8 @@ async function down$70(db) {
7327
7327
  //#endregion
7328
7328
  //#region src/db/migrations/082_host_s3_reachable.ts
7329
7329
  var _082_host_s3_reachable_exports = /* @__PURE__ */ __exportAll({
7330
- down: () => down$69,
7331
- up: () => up$69
7330
+ down: () => down$71,
7331
+ up: () => up$71
7332
7332
  });
7333
7333
  /**
7334
7334
  * Add `host_roster.s3_reachable BOOLEAN` (nullable).
@@ -7342,7 +7342,7 @@ var _082_host_s3_reachable_exports = /* @__PURE__ */ __exportAll({
7342
7342
  *
7343
7343
  * Idempotent: a re-run on a DB that already has the column is a no-op.
7344
7344
  */
7345
- async function up$69(db) {
7345
+ async function up$71(db) {
7346
7346
  if ((await sql`
7347
7347
  SELECT EXISTS (
7348
7348
  SELECT 1 FROM information_schema.columns
@@ -7356,7 +7356,7 @@ async function up$69(db) {
7356
7356
  ADD COLUMN s3_reachable BOOLEAN
7357
7357
  `.execute(db);
7358
7358
  }
7359
- async function down$69(db) {
7359
+ async function down$71(db) {
7360
7360
  await sql`
7361
7361
  ALTER TABLE public.host_roster DROP COLUMN IF EXISTS s3_reachable
7362
7362
  `.execute(db);
@@ -7364,8 +7364,8 @@ async function down$69(db) {
7364
7364
  //#endregion
7365
7365
  //#region src/db/migrations/083_org_settings_artifact_caps.ts
7366
7366
  var _083_org_settings_artifact_caps_exports = /* @__PURE__ */ __exportAll({
7367
- down: () => down$68,
7368
- up: () => up$68
7367
+ down: () => down$70,
7368
+ up: () => up$70
7369
7369
  });
7370
7370
  /**
7371
7371
  * Add `org_settings.artifact_max_bytes` + `artifact_max_per_run` (both nullable
@@ -7381,7 +7381,7 @@ var _083_org_settings_artifact_caps_exports = /* @__PURE__ */ __exportAll({
7381
7381
  * Idempotent: guarded on column existence; a re-run on a DB that already has a
7382
7382
  * column is a no-op.
7383
7383
  */
7384
- async function up$68(db) {
7384
+ async function up$70(db) {
7385
7385
  for (const col of ["artifact_max_bytes", "artifact_max_per_run"]) {
7386
7386
  if ((await sql`
7387
7387
  SELECT EXISTS (
@@ -7394,15 +7394,15 @@ async function up$68(db) {
7394
7394
  await sql`ALTER TABLE public.org_settings ADD COLUMN ${sql.ref(col)} BIGINT`.execute(db);
7395
7395
  }
7396
7396
  }
7397
- async function down$68(db) {
7397
+ async function down$70(db) {
7398
7398
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS artifact_max_bytes`.execute(db);
7399
7399
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS artifact_max_per_run`.execute(db);
7400
7400
  }
7401
7401
  //#endregion
7402
7402
  //#region src/db/migrations/084_orchestrator_signing_keys.ts
7403
7403
  var _084_orchestrator_signing_keys_exports = /* @__PURE__ */ __exportAll({
7404
- down: () => down$67,
7405
- up: () => up$67
7404
+ down: () => down$69,
7405
+ up: () => up$69
7406
7406
  });
7407
7407
  /**
7408
7408
  * Add the `orchestrator_signing_keys` table: the cluster-scoped, long-lived
@@ -7420,12 +7420,12 @@ var _084_orchestrator_signing_keys_exports = /* @__PURE__ */ __exportAll({
7420
7420
  *
7421
7421
  * Idempotent: guarded on table existence.
7422
7422
  */
7423
- async function up$67(db) {
7423
+ async function up$69(db) {
7424
7424
  if (await tableExists$3(db, "orchestrator_signing_keys")) return;
7425
7425
  await db.schema.createTable("orchestrator_signing_keys").addColumn("kid", "text", (c) => c.primaryKey()).addColumn("public_jwk", "jsonb", (c) => c.notNull()).addColumn("encrypted_private_jwk", "text").addColumn("key_version", "integer", (c) => c.notNull().defaultTo(1)).addColumn("alg", "text", (c) => c.notNull()).addColumn("signer_kind", "text", (c) => c.notNull()).addColumn("key_ref", "text").addColumn("status", "text", (c) => c.notNull().defaultTo("active")).addColumn("revocation_reason", "text").addColumn("created_at", "timestamptz", (c) => c.notNull().defaultTo(sql`now()`)).addColumn("activated_at", "timestamptz").addColumn("retired_at", "timestamptz").addColumn("revoked_at", "timestamptz").execute();
7426
7426
  await db.schema.createIndex("idx_orch_signing_keys_status").on("orchestrator_signing_keys").column("status").execute();
7427
7427
  }
7428
- async function down$67(db) {
7428
+ async function down$69(db) {
7429
7429
  await db.schema.dropTable("orchestrator_signing_keys").ifExists().execute();
7430
7430
  }
7431
7431
  async function tableExists$3(db, table) {
@@ -7439,8 +7439,8 @@ async function tableExists$3(db, table) {
7439
7439
  //#endregion
7440
7440
  //#region src/db/migrations/085_cluster_settings_reroute_flap_grace_ms.ts
7441
7441
  var _085_cluster_settings_reroute_flap_grace_ms_exports = /* @__PURE__ */ __exportAll({
7442
- down: () => down$66,
7443
- up: () => up$66
7442
+ down: () => down$68,
7443
+ up: () => up$68
7444
7444
  });
7445
7445
  /**
7446
7446
  * Add `cluster_settings.reroute_flap_grace_ms` (nullable BIGINT).
@@ -7450,7 +7450,7 @@ var _085_cluster_settings_reroute_flap_grace_ms_exports = /* @__PURE__ */ __expo
7450
7450
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7451
7451
  * the column is a no-op.
7452
7452
  */
7453
- async function up$66(db) {
7453
+ async function up$68(db) {
7454
7454
  if ((await sql`
7455
7455
  SELECT EXISTS (
7456
7456
  SELECT 1 FROM information_schema.columns
@@ -7461,14 +7461,14 @@ async function up$66(db) {
7461
7461
  `.execute(db)).rows[0]?.exists) return;
7462
7462
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN reroute_flap_grace_ms BIGINT`.execute(db);
7463
7463
  }
7464
- async function down$66(db) {
7464
+ async function down$68(db) {
7465
7465
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS reroute_flap_grace_ms`.execute(db);
7466
7466
  }
7467
7467
  //#endregion
7468
7468
  //#region src/db/migrations/086_cluster_settings_max_fanout_hosts.ts
7469
7469
  var _086_cluster_settings_max_fanout_hosts_exports = /* @__PURE__ */ __exportAll({
7470
- down: () => down$65,
7471
- up: () => up$65
7470
+ down: () => down$67,
7471
+ up: () => up$67
7472
7472
  });
7473
7473
  /**
7474
7474
  * Add `cluster_settings.max_fanout_hosts` (nullable INTEGER).
@@ -7478,7 +7478,7 @@ var _086_cluster_settings_max_fanout_hosts_exports = /* @__PURE__ */ __exportAll
7478
7478
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7479
7479
  * the column is a no-op.
7480
7480
  */
7481
- async function up$65(db) {
7481
+ async function up$67(db) {
7482
7482
  if ((await sql`
7483
7483
  SELECT EXISTS (
7484
7484
  SELECT 1 FROM information_schema.columns
@@ -7489,14 +7489,14 @@ async function up$65(db) {
7489
7489
  `.execute(db)).rows[0]?.exists) return;
7490
7490
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN max_fanout_hosts INTEGER`.execute(db);
7491
7491
  }
7492
- async function down$65(db) {
7492
+ async function down$67(db) {
7493
7493
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS max_fanout_hosts`.execute(db);
7494
7494
  }
7495
7495
  //#endregion
7496
7496
  //#region src/db/migrations/087_cluster_settings_event_router_rate_limit.ts
7497
7497
  var _087_cluster_settings_event_router_rate_limit_exports = /* @__PURE__ */ __exportAll({
7498
- down: () => down$64,
7499
- up: () => up$64
7498
+ down: () => down$66,
7499
+ up: () => up$66
7500
7500
  });
7501
7501
  /**
7502
7502
  * Add `cluster_settings.event_router_rate_limit_per_workflow_per_minute` (nullable INTEGER).
@@ -7506,7 +7506,7 @@ var _087_cluster_settings_event_router_rate_limit_exports = /* @__PURE__ */ __ex
7506
7506
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7507
7507
  * the column is a no-op.
7508
7508
  */
7509
- async function up$64(db) {
7509
+ async function up$66(db) {
7510
7510
  if ((await sql`
7511
7511
  SELECT EXISTS (
7512
7512
  SELECT 1 FROM information_schema.columns
@@ -7517,14 +7517,14 @@ async function up$64(db) {
7517
7517
  `.execute(db)).rows[0]?.exists) return;
7518
7518
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN event_router_rate_limit_per_workflow_per_minute INTEGER`.execute(db);
7519
7519
  }
7520
- async function down$64(db) {
7520
+ async function down$66(db) {
7521
7521
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS event_router_rate_limit_per_workflow_per_minute`.execute(db);
7522
7522
  }
7523
7523
  //#endregion
7524
7524
  //#region src/db/migrations/088_cluster_settings_cache_max_tarball_bytes.ts
7525
7525
  var _088_cluster_settings_cache_max_tarball_bytes_exports = /* @__PURE__ */ __exportAll({
7526
- down: () => down$63,
7527
- up: () => up$63
7526
+ down: () => down$65,
7527
+ up: () => up$65
7528
7528
  });
7529
7529
  /**
7530
7530
  * Add `cluster_settings.cache_max_tarball_bytes` (nullable BIGINT).
@@ -7534,7 +7534,7 @@ var _088_cluster_settings_cache_max_tarball_bytes_exports = /* @__PURE__ */ __ex
7534
7534
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7535
7535
  * the column is a no-op.
7536
7536
  */
7537
- async function up$63(db) {
7537
+ async function up$65(db) {
7538
7538
  if ((await sql`
7539
7539
  SELECT EXISTS (
7540
7540
  SELECT 1 FROM information_schema.columns
@@ -7545,14 +7545,14 @@ async function up$63(db) {
7545
7545
  `.execute(db)).rows[0]?.exists) return;
7546
7546
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN cache_max_tarball_bytes BIGINT`.execute(db);
7547
7547
  }
7548
- async function down$63(db) {
7548
+ async function down$65(db) {
7549
7549
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS cache_max_tarball_bytes`.execute(db);
7550
7550
  }
7551
7551
  //#endregion
7552
7552
  //#region src/db/migrations/089_cluster_settings_cache_ttl_days.ts
7553
7553
  var _089_cluster_settings_cache_ttl_days_exports = /* @__PURE__ */ __exportAll({
7554
- down: () => down$62,
7555
- up: () => up$62
7554
+ down: () => down$64,
7555
+ up: () => up$64
7556
7556
  });
7557
7557
  /**
7558
7558
  * Add `cluster_settings.cache_ttl_days` (nullable INTEGER).
@@ -7562,7 +7562,7 @@ var _089_cluster_settings_cache_ttl_days_exports = /* @__PURE__ */ __exportAll({
7562
7562
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7563
7563
  * the column is a no-op.
7564
7564
  */
7565
- async function up$62(db) {
7565
+ async function up$64(db) {
7566
7566
  if ((await sql`
7567
7567
  SELECT EXISTS (
7568
7568
  SELECT 1 FROM information_schema.columns
@@ -7573,14 +7573,14 @@ async function up$62(db) {
7573
7573
  `.execute(db)).rows[0]?.exists) return;
7574
7574
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN cache_ttl_days INTEGER`.execute(db);
7575
7575
  }
7576
- async function down$62(db) {
7576
+ async function down$64(db) {
7577
7577
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS cache_ttl_days`.execute(db);
7578
7578
  }
7579
7579
  //#endregion
7580
7580
  //#region src/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.ts
7581
7581
  var _090_cluster_settings_concurrency_wait_timeout_ms_exports = /* @__PURE__ */ __exportAll({
7582
- down: () => down$61,
7583
- up: () => up$61
7582
+ down: () => down$63,
7583
+ up: () => up$63
7584
7584
  });
7585
7585
  /**
7586
7586
  * Add `cluster_settings.concurrency_wait_timeout_ms` (nullable BIGINT).
@@ -7590,7 +7590,7 @@ var _090_cluster_settings_concurrency_wait_timeout_ms_exports = /* @__PURE__ */
7590
7590
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7591
7591
  * the column is a no-op.
7592
7592
  */
7593
- async function up$61(db) {
7593
+ async function up$63(db) {
7594
7594
  if ((await sql`
7595
7595
  SELECT EXISTS (
7596
7596
  SELECT 1 FROM information_schema.columns
@@ -7601,14 +7601,14 @@ async function up$61(db) {
7601
7601
  `.execute(db)).rows[0]?.exists) return;
7602
7602
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN concurrency_wait_timeout_ms BIGINT`.execute(db);
7603
7603
  }
7604
- async function down$61(db) {
7604
+ async function down$63(db) {
7605
7605
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS concurrency_wait_timeout_ms`.execute(db);
7606
7606
  }
7607
7607
  //#endregion
7608
7608
  //#region src/db/migrations/091_cluster_settings_agent_token_ttl_ms.ts
7609
7609
  var _091_cluster_settings_agent_token_ttl_ms_exports = /* @__PURE__ */ __exportAll({
7610
- down: () => down$60,
7611
- up: () => up$60
7610
+ down: () => down$62,
7611
+ up: () => up$62
7612
7612
  });
7613
7613
  /**
7614
7614
  * Add `cluster_settings.agent_token_ttl_ms` (nullable BIGINT).
@@ -7618,7 +7618,7 @@ var _091_cluster_settings_agent_token_ttl_ms_exports = /* @__PURE__ */ __exportA
7618
7618
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7619
7619
  * the column is a no-op.
7620
7620
  */
7621
- async function up$60(db) {
7621
+ async function up$62(db) {
7622
7622
  if ((await sql`
7623
7623
  SELECT EXISTS (
7624
7624
  SELECT 1 FROM information_schema.columns
@@ -7629,14 +7629,14 @@ async function up$60(db) {
7629
7629
  `.execute(db)).rows[0]?.exists) return;
7630
7630
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN agent_token_ttl_ms BIGINT`.execute(db);
7631
7631
  }
7632
- async function down$60(db) {
7632
+ async function down$62(db) {
7633
7633
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS agent_token_ttl_ms`.execute(db);
7634
7634
  }
7635
7635
  //#endregion
7636
7636
  //#region src/db/migrations/092_cluster_settings_version.ts
7637
7637
  var _092_cluster_settings_version_exports = /* @__PURE__ */ __exportAll({
7638
- down: () => down$59,
7639
- up: () => up$59
7638
+ down: () => down$61,
7639
+ up: () => up$61
7640
7640
  });
7641
7641
  /**
7642
7642
  * Add `cluster_settings.version` (monotonic BIGINT, bumped on each settings
@@ -7650,7 +7650,7 @@ var _092_cluster_settings_version_exports = /* @__PURE__ */ __exportAll({
7650
7650
  * Idempotent: guarded on column existence; a re-run on a DB that already has
7651
7651
  * the column is a no-op.
7652
7652
  */
7653
- async function up$59(db) {
7653
+ async function up$61(db) {
7654
7654
  if ((await sql`
7655
7655
  SELECT EXISTS (
7656
7656
  SELECT 1 FROM information_schema.columns
@@ -7661,14 +7661,14 @@ async function up$59(db) {
7661
7661
  `.execute(db)).rows[0]?.exists) return;
7662
7662
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN version BIGINT NOT NULL DEFAULT 0`.execute(db);
7663
7663
  }
7664
- async function down$59(db) {
7664
+ async function down$61(db) {
7665
7665
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS version`.execute(db);
7666
7666
  }
7667
7667
  //#endregion
7668
7668
  //#region src/db/migrations/093_org_settings_sandbox_allowlist.ts
7669
7669
  var _093_org_settings_sandbox_allowlist_exports = /* @__PURE__ */ __exportAll({
7670
- down: () => down$58,
7671
- up: () => up$58
7670
+ down: () => down$60,
7671
+ up: () => up$60
7672
7672
  });
7673
7673
  /**
7674
7674
  * Add the per-org container-sandbox escape-hatch allow-list to `org_settings`:
@@ -7696,7 +7696,7 @@ async function columnExists$12(db, column) {
7696
7696
  ) AS exists
7697
7697
  `.execute(db)).rows[0]?.exists ?? false;
7698
7698
  }
7699
- async function up$58(db) {
7699
+ async function up$60(db) {
7700
7700
  if (!await columnExists$12(db, "sandbox_allowed_capabilities")) await sql`
7701
7701
  ALTER TABLE public.org_settings
7702
7702
  ADD COLUMN sandbox_allowed_capabilities TEXT[]
@@ -7706,7 +7706,7 @@ async function up$58(db) {
7706
7706
  ADD COLUMN sandbox_allow_host_network BOOLEAN
7707
7707
  `.execute(db);
7708
7708
  }
7709
- async function down$58(db) {
7709
+ async function down$60(db) {
7710
7710
  await sql`
7711
7711
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS sandbox_allowed_capabilities
7712
7712
  `.execute(db);
@@ -7717,8 +7717,8 @@ async function down$58(db) {
7717
7717
  //#endregion
7718
7718
  //#region src/db/migrations/094_dashboard_encryption_keys.ts
7719
7719
  var _094_dashboard_encryption_keys_exports = /* @__PURE__ */ __exportAll({
7720
- down: () => down$57,
7721
- up: () => up$57
7720
+ down: () => down$59,
7721
+ up: () => up$59
7722
7722
  });
7723
7723
  /**
7724
7724
  * Add the `dashboard_encryption_keys` table: the cluster-scoped, long-lived
@@ -7737,12 +7737,12 @@ var _094_dashboard_encryption_keys_exports = /* @__PURE__ */ __exportAll({
7737
7737
  *
7738
7738
  * Idempotent: guarded on table existence.
7739
7739
  */
7740
- async function up$57(db) {
7740
+ async function up$59(db) {
7741
7741
  if (await tableExists$2(db, "dashboard_encryption_keys")) return;
7742
7742
  await db.schema.createTable("dashboard_encryption_keys").addColumn("kid", "text", (c) => c.primaryKey()).addColumn("public_jwk", "jsonb", (c) => c.notNull()).addColumn("encrypted_private_key", "text", (c) => c.notNull()).addColumn("status", "text", (c) => c.notNull().defaultTo("active")).addColumn("revocation_reason", "text").addColumn("created_at", "timestamptz", (c) => c.notNull().defaultTo(sql`now()`)).addColumn("activated_at", "timestamptz").addColumn("revoked_at", "timestamptz").execute();
7743
7743
  await db.schema.createIndex("idx_dashboard_encryption_keys_status").on("dashboard_encryption_keys").column("status").execute();
7744
7744
  }
7745
- async function down$57(db) {
7745
+ async function down$59(db) {
7746
7746
  await db.schema.dropTable("dashboard_encryption_keys").ifExists().execute();
7747
7747
  }
7748
7748
  async function tableExists$2(db, table) {
@@ -7756,8 +7756,8 @@ async function tableExists$2(db, table) {
7756
7756
  //#endregion
7757
7757
  //#region src/db/migrations/095_dashboard_write_policy_tristate.ts
7758
7758
  var _095_dashboard_write_policy_tristate_exports = /* @__PURE__ */ __exportAll({
7759
- down: () => down$56,
7760
- up: () => up$56
7759
+ down: () => down$58,
7760
+ up: () => up$58
7761
7761
  });
7762
7762
  /**
7763
7763
  * Migrate stored `org_settings.dashboard_write_policy` JSONB from the legacy
@@ -7775,7 +7775,7 @@ var _095_dashboard_write_policy_tristate_exports = /* @__PURE__ */ __exportAll({
7775
7775
  * Pure SQL rewrite: for each row, rebuild the object keeping only non-`true`
7776
7776
  * entries and mapping `false` → `'disabled'`, leaving existing string values.
7777
7777
  */
7778
- async function up$56(db) {
7778
+ async function up$58(db) {
7779
7779
  await sql`
7780
7780
  UPDATE org_settings
7781
7781
  SET dashboard_write_policy = COALESCE(
@@ -7802,12 +7802,12 @@ async function up$56(db) {
7802
7802
  )
7803
7803
  `.execute(db);
7804
7804
  }
7805
- async function down$56() {}
7805
+ async function down$58() {}
7806
7806
  //#endregion
7807
7807
  //#region src/db/migrations/096_multi_schedule_cron_last_fired.ts
7808
7808
  var _096_multi_schedule_cron_last_fired_exports = /* @__PURE__ */ __exportAll({
7809
- down: () => down$55,
7810
- up: () => up$55
7809
+ down: () => down$57,
7810
+ up: () => up$57
7811
7811
  });
7812
7812
  /**
7813
7813
  * Track cron last-fired per (registration, schedule) instead of per
@@ -7842,7 +7842,7 @@ async function primaryKeyColumns(db) {
7842
7842
  ORDER BY a.attnum
7843
7843
  `.execute(db)).rows.map((row) => row.attname);
7844
7844
  }
7845
- async function up$55(db) {
7845
+ async function up$57(db) {
7846
7846
  if (!await columnExists$11(db, "schedule_key")) await sql`ALTER TABLE public.cron_last_fired ADD COLUMN schedule_key text`.execute(db);
7847
7847
  await sql`
7848
7848
  UPDATE public.cron_last_fired clf
@@ -7869,7 +7869,7 @@ async function up$55(db) {
7869
7869
  `.execute(db);
7870
7870
  }
7871
7871
  }
7872
- async function down$55(db) {
7872
+ async function down$57(db) {
7873
7873
  await sql`
7874
7874
  DELETE FROM public.cron_last_fired a
7875
7875
  USING public.cron_last_fired b
@@ -7886,8 +7886,8 @@ async function down$55(db) {
7886
7886
  //#endregion
7887
7887
  //#region src/db/migrations/097_execution_runs_pr_number.ts
7888
7888
  var _097_execution_runs_pr_number_exports = /* @__PURE__ */ __exportAll({
7889
- down: () => down$54,
7890
- up: () => up$54
7889
+ down: () => down$56,
7890
+ up: () => up$56
7891
7891
  });
7892
7892
  /**
7893
7893
  * Add `pr_number INTEGER NULL` to `execution_runs`.
@@ -7910,13 +7910,13 @@ async function columnExists$10(db, column) {
7910
7910
  ) AS exists
7911
7911
  `.execute(db)).rows[0]?.exists ?? false;
7912
7912
  }
7913
- async function up$54(db) {
7913
+ async function up$56(db) {
7914
7914
  if (!await columnExists$10(db, "pr_number")) await sql`
7915
7915
  ALTER TABLE public.execution_runs
7916
7916
  ADD COLUMN pr_number INTEGER
7917
7917
  `.execute(db);
7918
7918
  }
7919
- async function down$54(db) {
7919
+ async function down$56(db) {
7920
7920
  await sql`
7921
7921
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS pr_number
7922
7922
  `.execute(db);
@@ -7924,8 +7924,8 @@ async function down$54(db) {
7924
7924
  //#endregion
7925
7925
  //#region src/db/migrations/098_execution_runs_customer_id.ts
7926
7926
  var _098_execution_runs_customer_id_exports = /* @__PURE__ */ __exportAll({
7927
- down: () => down$53,
7928
- up: () => up$53
7927
+ down: () => down$55,
7928
+ up: () => up$55
7929
7929
  });
7930
7930
  /**
7931
7931
  * Denormalize the owning org onto `execution_runs` so the concurrency-gate
@@ -7953,7 +7953,7 @@ async function columnExists$9(db, column) {
7953
7953
  ) AS exists
7954
7954
  `.execute(db)).rows[0]?.exists ?? false;
7955
7955
  }
7956
- async function up$53(db) {
7956
+ async function up$55(db) {
7957
7957
  if (!await columnExists$9(db, "customer_id")) {
7958
7958
  await sql`
7959
7959
  ALTER TABLE public.execution_runs
@@ -7977,7 +7977,7 @@ async function up$53(db) {
7977
7977
  ON public.execution_runs (customer_id, context)
7978
7978
  `.execute(db);
7979
7979
  }
7980
- async function down$53(db) {
7980
+ async function down$55(db) {
7981
7981
  await sql`DROP INDEX IF EXISTS execution_runs_customer_id_context_idx`.execute(db);
7982
7982
  await sql`
7983
7983
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS customer_id
@@ -7986,8 +7986,8 @@ async function down$53(db) {
7986
7986
  //#endregion
7987
7987
  //#region src/db/migrations/099_cluster_settings_dashboard_verified_issuer.ts
7988
7988
  var _099_cluster_settings_dashboard_verified_issuer_exports = /* @__PURE__ */ __exportAll({
7989
- down: () => down$52,
7990
- up: () => up$52
7989
+ down: () => down$54,
7990
+ up: () => up$54
7991
7991
  });
7992
7992
  /**
7993
7993
  * Add `cluster_settings.dashboard_verified_issuer` (nullable text).
@@ -8006,7 +8006,7 @@ var _099_cluster_settings_dashboard_verified_issuer_exports = /* @__PURE__ */ __
8006
8006
  * Idempotent: guarded on column existence; a re-run on a DB that already has the
8007
8007
  * column is a no-op.
8008
8008
  */
8009
- async function up$52(db) {
8009
+ async function up$54(db) {
8010
8010
  if ((await sql`
8011
8011
  SELECT EXISTS (
8012
8012
  SELECT 1 FROM information_schema.columns
@@ -8017,14 +8017,14 @@ async function up$52(db) {
8017
8017
  `.execute(db)).rows[0]?.exists) return;
8018
8018
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN dashboard_verified_issuer TEXT`.execute(db);
8019
8019
  }
8020
- async function down$52(db) {
8020
+ async function down$54(db) {
8021
8021
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS dashboard_verified_issuer`.execute(db);
8022
8022
  }
8023
8023
  //#endregion
8024
8024
  //#region src/db/migrations/100_held_runs_hold_type_vocabulary.ts
8025
8025
  var _100_held_runs_hold_type_vocabulary_exports = /* @__PURE__ */ __exportAll({
8026
- down: () => down$51,
8027
- up: () => up$51
8026
+ down: () => down$53,
8027
+ up: () => up$53
8028
8028
  });
8029
8029
  /**
8030
8030
  * Realign `held_runs.hold_type` onto the engine's `HoldType` vocabulary.
@@ -8043,7 +8043,7 @@ var _100_held_runs_hold_type_vocabulary_exports = /* @__PURE__ */ __exportAll({
8043
8043
  *
8044
8044
  * Idempotent: a second run matches no rows.
8045
8045
  */
8046
- async function up$51(db) {
8046
+ async function up$53(db) {
8047
8047
  await sql`UPDATE public.held_runs SET hold_type = 'reviewer' WHERE hold_type = 'approval'`.execute(db);
8048
8048
  await sql`UPDATE public.held_runs SET hold_type = 'timer' WHERE hold_type = 'wait_timer'`.execute(db);
8049
8049
  }
@@ -8057,15 +8057,15 @@ async function up$51(db) {
8057
8057
  * `wait_timer` alone, so leaving those rows spelled `timer` would strand them
8058
8058
  * in the expire-and-fail path.
8059
8059
  */
8060
- async function down$51(db) {
8060
+ async function down$53(db) {
8061
8061
  await sql`UPDATE public.held_runs SET hold_type = 'approval' WHERE hold_type = 'reviewer'`.execute(db);
8062
8062
  await sql`UPDATE public.held_runs SET hold_type = 'wait_timer' WHERE hold_type = 'timer'`.execute(db);
8063
8063
  }
8064
8064
  //#endregion
8065
8065
  //#region src/db/migrations/101_contexts_hold_expiry_drop_default.ts
8066
8066
  var _101_contexts_hold_expiry_drop_default_exports = /* @__PURE__ */ __exportAll({
8067
- down: () => down$50,
8068
- up: () => up$50
8067
+ down: () => down$52,
8068
+ up: () => up$52
8069
8069
  });
8070
8070
  /**
8071
8071
  * Give the context hold expiry a single default, and retire the stored zeroes.
@@ -8086,7 +8086,7 @@ var _101_contexts_hold_expiry_drop_default_exports = /* @__PURE__ */ __exportAll
8086
8086
  * Idempotent: dropping an absent default is a no-op and the UPDATE matches no
8087
8087
  * rows on a second run.
8088
8088
  */
8089
- async function up$50(db) {
8089
+ async function up$52(db) {
8090
8090
  await sql`ALTER TABLE public.contexts ALTER COLUMN hold_expiry_seconds DROP DEFAULT`.execute(db);
8091
8091
  await sql`UPDATE public.contexts SET hold_expiry_seconds = NULL WHERE hold_expiry_seconds = 0`.execute(db);
8092
8092
  }
@@ -8098,14 +8098,14 @@ async function up$50(db) {
8098
8098
  * back to `0` would resume cancelling every hold on its context — so a
8099
8099
  * rollback keeps them on the fallback rather than re-breaking them.
8100
8100
  */
8101
- async function down$50(db) {
8101
+ async function down$52(db) {
8102
8102
  await sql`ALTER TABLE public.contexts ALTER COLUMN hold_expiry_seconds SET DEFAULT 86400`.execute(db);
8103
8103
  }
8104
8104
  //#endregion
8105
8105
  //#region src/db/migrations/102_dispatch_queue_agent_id.ts
8106
8106
  var _102_dispatch_queue_agent_id_exports = /* @__PURE__ */ __exportAll({
8107
- down: () => down$49,
8108
- up: () => up$49
8107
+ down: () => down$51,
8108
+ up: () => up$51
8109
8109
  });
8110
8110
  /**
8111
8111
  * Add `dispatch_queue.agent_id` (nullable text).
@@ -8123,7 +8123,7 @@ var _102_dispatch_queue_agent_id_exports = /* @__PURE__ */ __exportAll({
8123
8123
  * Idempotent: guarded on column existence; a re-run on a DB that already has the
8124
8124
  * column is a no-op.
8125
8125
  */
8126
- async function up$49(db) {
8126
+ async function up$51(db) {
8127
8127
  if ((await sql`
8128
8128
  SELECT EXISTS (
8129
8129
  SELECT 1 FROM information_schema.columns
@@ -8134,14 +8134,14 @@ async function up$49(db) {
8134
8134
  `.execute(db)).rows[0]?.exists) return;
8135
8135
  await sql`ALTER TABLE public.dispatch_queue ADD COLUMN agent_id TEXT`.execute(db);
8136
8136
  }
8137
- async function down$49(db) {
8137
+ async function down$51(db) {
8138
8138
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS agent_id`.execute(db);
8139
8139
  }
8140
8140
  //#endregion
8141
8141
  //#region src/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.ts
8142
8142
  var _103_cluster_settings_ownership_db_check_timeout_ms_exports = /* @__PURE__ */ __exportAll({
8143
- down: () => down$48,
8144
- up: () => up$48
8143
+ down: () => down$50,
8144
+ up: () => up$50
8145
8145
  });
8146
8146
  /**
8147
8147
  * Add `cluster_settings.ownership_db_check_timeout_ms` (nullable bigint).
@@ -8159,7 +8159,7 @@ var _103_cluster_settings_ownership_db_check_timeout_ms_exports = /* @__PURE__ *
8159
8159
  * Idempotent: guarded on column existence; a re-run on a DB that already has the
8160
8160
  * column is a no-op.
8161
8161
  */
8162
- async function up$48(db) {
8162
+ async function up$50(db) {
8163
8163
  if ((await sql`
8164
8164
  SELECT EXISTS (
8165
8165
  SELECT 1 FROM information_schema.columns
@@ -8170,14 +8170,14 @@ async function up$48(db) {
8170
8170
  `.execute(db)).rows[0]?.exists) return;
8171
8171
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN ownership_db_check_timeout_ms BIGINT`.execute(db);
8172
8172
  }
8173
- async function down$48(db) {
8173
+ async function down$50(db) {
8174
8174
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ownership_db_check_timeout_ms`.execute(db);
8175
8175
  }
8176
8176
  //#endregion
8177
8177
  //#region src/db/migrations/104_check_run_terminal_sent.ts
8178
8178
  var _104_check_run_terminal_sent_exports = /* @__PURE__ */ __exportAll({
8179
- down: () => down$47,
8180
- up: () => up$47
8179
+ down: () => down$49,
8180
+ up: () => up$49
8181
8181
  });
8182
8182
  /**
8183
8183
  * Add `check_run_tracking.terminal_sent_at` (nullable timestamptz).
@@ -8197,7 +8197,7 @@ var _104_check_run_terminal_sent_exports = /* @__PURE__ */ __exportAll({
8197
8197
  * Idempotent: guarded on column existence; a re-run on a DB that already has
8198
8198
  * the column is a no-op.
8199
8199
  */
8200
- async function up$47(db) {
8200
+ async function up$49(db) {
8201
8201
  if ((await sql`
8202
8202
  SELECT EXISTS (
8203
8203
  SELECT 1 FROM information_schema.columns
@@ -8208,14 +8208,14 @@ async function up$47(db) {
8208
8208
  `.execute(db)).rows[0]?.exists) return;
8209
8209
  await sql`ALTER TABLE public.check_run_tracking ADD COLUMN terminal_sent_at TIMESTAMPTZ`.execute(db);
8210
8210
  }
8211
- async function down$47(db) {
8211
+ async function down$49(db) {
8212
8212
  await sql`ALTER TABLE public.check_run_tracking DROP COLUMN IF EXISTS terminal_sent_at`.execute(db);
8213
8213
  }
8214
8214
  //#endregion
8215
8215
  //#region src/db/migrations/105_org_trust_policy.ts
8216
8216
  var _105_org_trust_policy_exports = /* @__PURE__ */ __exportAll({
8217
- down: () => down$46,
8218
- up: () => up$46
8217
+ down: () => down$48,
8218
+ up: () => up$48
8219
8219
  });
8220
8220
  /**
8221
8221
  * Create `org_trust_policy` — the orchestrator's cache of the Platform-owned org
@@ -8232,7 +8232,7 @@ var _105_org_trust_policy_exports = /* @__PURE__ */ __exportAll({
8232
8232
  *
8233
8233
  * Idempotent: guarded by IF NOT EXISTS, so a re-run is a no-op.
8234
8234
  */
8235
- async function up$46(db) {
8235
+ async function up$48(db) {
8236
8236
  await sql`
8237
8237
  CREATE TABLE IF NOT EXISTS public.org_trust_policy (
8238
8238
  customer_id TEXT PRIMARY KEY,
@@ -8245,14 +8245,14 @@ async function up$46(db) {
8245
8245
  )
8246
8246
  `.execute(db);
8247
8247
  }
8248
- async function down$46(db) {
8248
+ async function down$48(db) {
8249
8249
  await sql`DROP TABLE IF EXISTS public.org_trust_policy`.execute(db);
8250
8250
  }
8251
8251
  //#endregion
8252
8252
  //#region src/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.ts
8253
8253
  var _106_cluster_settings_check_run_tracking_ttl_days_exports = /* @__PURE__ */ __exportAll({
8254
- down: () => down$45,
8255
- up: () => up$45
8254
+ down: () => down$47,
8255
+ up: () => up$47
8256
8256
  });
8257
8257
  /**
8258
8258
  * Add `cluster_settings.check_run_tracking_ttl_days` (nullable integer).
@@ -8268,7 +8268,7 @@ var _106_cluster_settings_check_run_tracking_ttl_days_exports = /* @__PURE__ */
8268
8268
  * Idempotent: guarded on column existence; a re-run on a database that already
8269
8269
  * has the column is a no-op.
8270
8270
  */
8271
- async function up$45(db) {
8271
+ async function up$47(db) {
8272
8272
  if ((await sql`
8273
8273
  SELECT EXISTS (
8274
8274
  SELECT 1 FROM information_schema.columns
@@ -8279,14 +8279,14 @@ async function up$45(db) {
8279
8279
  `.execute(db)).rows[0]?.exists) return;
8280
8280
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN check_run_tracking_ttl_days INTEGER`.execute(db);
8281
8281
  }
8282
- async function down$45(db) {
8282
+ async function down$47(db) {
8283
8283
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS check_run_tracking_ttl_days`.execute(db);
8284
8284
  }
8285
8285
  //#endregion
8286
8286
  //#region src/db/migrations/107_check_run_tracking_updated_at_index.ts
8287
8287
  var _107_check_run_tracking_updated_at_index_exports = /* @__PURE__ */ __exportAll({
8288
- down: () => down$44,
8289
- up: () => up$44
8288
+ down: () => down$46,
8289
+ up: () => up$46
8290
8290
  });
8291
8291
  /**
8292
8292
  * Add `idx_check_run_tracking_updated_at` on `check_run_tracking (updated_at)`.
@@ -8307,20 +8307,20 @@ var _107_check_run_tracking_updated_at_index_exports = /* @__PURE__ */ __exportA
8307
8307
  *
8308
8308
  * Idempotent: `IF NOT EXISTS` makes a re-run a no-op.
8309
8309
  */
8310
- async function up$44(db) {
8310
+ async function up$46(db) {
8311
8311
  await sql`
8312
8312
  CREATE INDEX IF NOT EXISTS idx_check_run_tracking_updated_at
8313
8313
  ON public.check_run_tracking (updated_at)
8314
8314
  `.execute(db);
8315
8315
  }
8316
- async function down$44(db) {
8316
+ async function down$46(db) {
8317
8317
  await sql`DROP INDEX IF EXISTS public.idx_check_run_tracking_updated_at`.execute(db);
8318
8318
  }
8319
8319
  //#endregion
8320
8320
  //#region src/db/migrations/108_unroutable_fast_fail.ts
8321
8321
  var _108_unroutable_fast_fail_exports = /* @__PURE__ */ __exportAll({
8322
- down: () => down$43,
8323
- up: () => up$43
8322
+ down: () => down$45,
8323
+ up: () => up$45
8324
8324
  });
8325
8325
  /**
8326
8326
  * Fast-fail support for jobs nothing in the fleet can run.
@@ -8351,12 +8351,12 @@ async function columnExists$8(db, table, column) {
8351
8351
  ) AS exists
8352
8352
  `.execute(db)).rows[0]?.exists === true;
8353
8353
  }
8354
- async function up$43(db) {
8354
+ async function up$45(db) {
8355
8355
  if (!await columnExists$8(db, "cluster_settings", "unroutable_grace_ms")) await sql`ALTER TABLE public.cluster_settings ADD COLUMN unroutable_grace_ms INTEGER`.execute(db);
8356
8356
  if (!await columnExists$8(db, "dispatch_queue", "unroutable_since")) await sql`ALTER TABLE public.dispatch_queue ADD COLUMN unroutable_since TIMESTAMPTZ`.execute(db);
8357
8357
  if (!await columnExists$8(db, "execution_jobs", "routing_reason")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN routing_reason TEXT`.execute(db);
8358
8358
  }
8359
- async function down$43(db) {
8359
+ async function down$45(db) {
8360
8360
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS routing_reason`.execute(db);
8361
8361
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS unroutable_since`.execute(db);
8362
8362
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS unroutable_grace_ms`.execute(db);
@@ -8364,8 +8364,8 @@ async function down$43(db) {
8364
8364
  //#endregion
8365
8365
  //#region src/db/migrations/109_cluster_settings_cache_knobs.ts
8366
8366
  var _109_cluster_settings_cache_knobs_exports = /* @__PURE__ */ __exportAll({
8367
- down: () => down$42,
8368
- up: () => up$42
8367
+ down: () => down$44,
8368
+ up: () => up$44
8369
8369
  });
8370
8370
  /**
8371
8371
  * Cluster-global cache tunables for the lock-file cache and the Tier-1
@@ -8400,17 +8400,17 @@ const COLUMNS$6 = [
8400
8400
  "content_cache_max_bytes",
8401
8401
  "content_cache_ttl_ms"
8402
8402
  ];
8403
- async function up$42(db) {
8403
+ async function up$44(db) {
8404
8404
  for (const column of COLUMNS$6) if (!await columnExists$7(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
8405
8405
  }
8406
- async function down$42(db) {
8406
+ async function down$44(db) {
8407
8407
  for (const column of COLUMNS$6) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
8408
8408
  }
8409
8409
  //#endregion
8410
8410
  //#region src/db/migrations/110_cluster_settings_global_eval_knobs.ts
8411
8411
  var _110_cluster_settings_global_eval_knobs_exports = /* @__PURE__ */ __exportAll({
8412
- down: () => down$41,
8413
- up: () => up$41
8412
+ down: () => down$43,
8413
+ up: () => up$43
8414
8414
  });
8415
8415
  /**
8416
8416
  * Cluster-global tunables for the Tier-2 global eval round — the pre-run job
@@ -8443,17 +8443,17 @@ const COLUMNS$5 = [
8443
8443
  "global_eval_candidate_timeout_ms",
8444
8444
  "global_eval_cache_max"
8445
8445
  ];
8446
- async function up$41(db) {
8446
+ async function up$43(db) {
8447
8447
  for (const column of COLUMNS$5) if (!await columnExists$6(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
8448
8448
  }
8449
- async function down$41(db) {
8449
+ async function down$43(db) {
8450
8450
  for (const column of COLUMNS$5) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
8451
8451
  }
8452
8452
  //#endregion
8453
8453
  //#region src/db/migrations/111_cluster_settings_global_eval_wait.ts
8454
8454
  var _111_cluster_settings_global_eval_wait_exports = /* @__PURE__ */ __exportAll({
8455
- down: () => down$40,
8456
- up: () => up$40
8455
+ down: () => down$42,
8456
+ up: () => up$42
8457
8457
  });
8458
8458
  /**
8459
8459
  * Cluster-global ceiling on how long webhook processing waits for a Tier-2
@@ -8481,17 +8481,17 @@ async function columnExists$5(db, table, column) {
8481
8481
  `.execute(db)).rows[0]?.exists === true;
8482
8482
  }
8483
8483
  const COLUMNS$4 = ["global_eval_wait_timeout_ms"];
8484
- async function up$40(db) {
8484
+ async function up$42(db) {
8485
8485
  for (const column of COLUMNS$4) if (!await columnExists$5(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
8486
8486
  }
8487
- async function down$40(db) {
8487
+ async function down$42(db) {
8488
8488
  for (const column of COLUMNS$4) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
8489
8489
  }
8490
8490
  //#endregion
8491
8491
  //#region src/db/migrations/112_execution_runs_workflow_repo.ts
8492
8492
  var _112_execution_runs_workflow_repo_exports = /* @__PURE__ */ __exportAll({
8493
- down: () => down$39,
8494
- up: () => up$39
8493
+ down: () => down$41,
8494
+ up: () => up$41
8495
8495
  });
8496
8496
  /**
8497
8497
  * Record which repository DEFINED the workflow a run executed.
@@ -8525,13 +8525,13 @@ async function colExists$9(db, table, name) {
8525
8525
  ) AS exists
8526
8526
  `.execute(db)).rows[0]?.exists ?? false;
8527
8527
  }
8528
- async function up$39(db) {
8528
+ async function up$41(db) {
8529
8529
  if (!await colExists$9(db, "execution_runs", "workflow_repo_identifier")) await sql`
8530
8530
  ALTER TABLE public.execution_runs
8531
8531
  ADD COLUMN workflow_repo_identifier text
8532
8532
  `.execute(db);
8533
8533
  }
8534
- async function down$39(db) {
8534
+ async function down$41(db) {
8535
8535
  await sql`
8536
8536
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_repo_identifier
8537
8537
  `.execute(db);
@@ -8539,8 +8539,8 @@ async function down$39(db) {
8539
8539
  //#endregion
8540
8540
  //#region src/db/migrations/113_execution_runs_workflow_repo_index.ts
8541
8541
  var _113_execution_runs_workflow_repo_index_exports = /* @__PURE__ */ __exportAll({
8542
- down: () => down$38,
8543
- up: () => up$38
8542
+ down: () => down$40,
8543
+ up: () => up$40
8544
8544
  });
8545
8545
  /**
8546
8546
  * Add the partial index `idx_execution_runs_workflow_repo` on
@@ -8568,21 +8568,21 @@ var _113_execution_runs_workflow_repo_index_exports = /* @__PURE__ */ __exportAl
8568
8568
  *
8569
8569
  * Idempotent: `IF NOT EXISTS` makes a re-run a no-op.
8570
8570
  */
8571
- async function up$38(db) {
8571
+ async function up$40(db) {
8572
8572
  await sql`
8573
8573
  CREATE INDEX IF NOT EXISTS idx_execution_runs_workflow_repo
8574
8574
  ON public.execution_runs (workflow_repo_identifier)
8575
8575
  WHERE workflow_repo_identifier IS NOT NULL
8576
8576
  `.execute(db);
8577
8577
  }
8578
- async function down$38(db) {
8578
+ async function down$40(db) {
8579
8579
  await sql`DROP INDEX IF EXISTS public.idx_execution_runs_workflow_repo`.execute(db);
8580
8580
  }
8581
8581
  //#endregion
8582
8582
  //#region src/db/migrations/114_ingest_queue_claim.ts
8583
8583
  var _114_ingest_queue_claim_exports = /* @__PURE__ */ __exportAll({
8584
- down: () => down$37,
8585
- up: () => up$37
8584
+ down: () => down$39,
8585
+ up: () => up$39
8586
8586
  });
8587
8587
  /**
8588
8588
  * Claim bookkeeping for the durable ingest queue.
@@ -8613,13 +8613,13 @@ async function columnExists$4(db, table, column) {
8613
8613
  ) AS exists
8614
8614
  `.execute(db)).rows[0]?.exists === true;
8615
8615
  }
8616
- async function up$37(db) {
8616
+ async function up$39(db) {
8617
8617
  if (!await columnExists$4(db, "ingest_overflow_buffer", "claimed_at")) await sql`ALTER TABLE public.ingest_overflow_buffer ADD COLUMN claimed_at TIMESTAMPTZ`.execute(db);
8618
8618
  if (!await columnExists$4(db, "cluster_settings", "ingest_overflow_claim_timeout_ms")) await sql`
8619
8619
  ALTER TABLE public.cluster_settings ADD COLUMN ingest_overflow_claim_timeout_ms INTEGER
8620
8620
  `.execute(db);
8621
8621
  }
8622
- async function down$37(db) {
8622
+ async function down$39(db) {
8623
8623
  await sql`
8624
8624
  ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ingest_overflow_claim_timeout_ms
8625
8625
  `.execute(db);
@@ -8630,8 +8630,8 @@ async function down$37(db) {
8630
8630
  //#endregion
8631
8631
  //#region src/db/migrations/115_global_workflows_cluster_switch.ts
8632
8632
  var _115_global_workflows_cluster_switch_exports = /* @__PURE__ */ __exportAll({
8633
- down: () => down$36,
8634
- up: () => up$36
8633
+ down: () => down$38,
8634
+ up: () => up$38
8635
8635
  });
8636
8636
  /**
8637
8637
  * Move the global-workflows master switch from `org_settings` to
@@ -8669,7 +8669,7 @@ async function columnExists$3(db, table, column) {
8669
8669
  ) AS exists
8670
8670
  `.execute(db)).rows[0]?.exists === true;
8671
8671
  }
8672
- async function up$36(db) {
8672
+ async function up$38(db) {
8673
8673
  if (!await columnExists$3(db, "cluster_settings", "global_workflows_enabled")) await sql`ALTER TABLE public.cluster_settings ADD COLUMN global_workflows_enabled BOOLEAN`.execute(db);
8674
8674
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS global_workflows_enabled`.execute(db);
8675
8675
  }
@@ -8678,7 +8678,7 @@ async function up$36(db) {
8678
8678
  * cannot recover the per-org values the up-migration dropped — they are gone —
8679
8679
  * so every org comes back at the opt-in default.
8680
8680
  */
8681
- async function down$36(db) {
8681
+ async function down$38(db) {
8682
8682
  if (!await columnExists$3(db, "org_settings", "global_workflows_enabled")) await sql`
8683
8683
  ALTER TABLE public.org_settings
8684
8684
  ADD COLUMN global_workflows_enabled BOOLEAN NOT NULL DEFAULT false
@@ -8688,20 +8688,20 @@ async function down$36(db) {
8688
8688
  //#endregion
8689
8689
  //#region src/db/migrations/116_org_plan_headroom.ts
8690
8690
  var _116_org_plan_headroom_exports = /* @__PURE__ */ __exportAll({
8691
- down: () => down$35,
8692
- up: () => up$35
8691
+ down: () => down$37,
8692
+ up: () => up$37
8693
8693
  });
8694
- async function up$35(db) {
8694
+ async function up$37(db) {
8695
8695
  await db.schema.createTable("org_plan_headroom").ifNotExists().addColumn("id", "varchar(16)", (col) => col.primaryKey()).addColumn("max_worker_peers", "integer", (col) => col.notNull()).addColumn("org_limit", "integer", (col) => col.notNull()).addColumn("org_total", "integer", (col) => col.notNull()).addColumn("evict_excess", "boolean", (col) => col.notNull().defaultTo(false)).addColumn("updated_at", sql`timestamptz`, (col) => col.notNull()).execute();
8696
8696
  }
8697
- async function down$35(db) {
8697
+ async function down$37(db) {
8698
8698
  await db.schema.dropTable("org_plan_headroom").ifExists().execute();
8699
8699
  }
8700
8700
  //#endregion
8701
8701
  //#region src/db/migrations/117_invoke_gate_proxy_jobs.ts
8702
8702
  var _117_invoke_gate_proxy_jobs_exports = /* @__PURE__ */ __exportAll({
8703
- down: () => down$34,
8704
- up: () => up$34
8703
+ down: () => down$36,
8704
+ up: () => up$36
8705
8705
  });
8706
8706
  /**
8707
8707
  * Proxy-job + summon-correlation columns for the invoke gate.
@@ -8732,7 +8732,7 @@ async function colExists$8(db, table, name) {
8732
8732
  ) AS exists
8733
8733
  `.execute(db)).rows[0]?.exists ?? false;
8734
8734
  }
8735
- async function up$34(db) {
8735
+ async function up$36(db) {
8736
8736
  if (!await colExists$8(db, "execution_jobs", "job_kind")) await sql`
8737
8737
  ALTER TABLE public.execution_jobs
8738
8738
  ADD COLUMN job_kind text NOT NULL DEFAULT 'standard'
@@ -8750,7 +8750,7 @@ async function up$34(db) {
8750
8750
  ADD COLUMN summoned_by_proxy_job text
8751
8751
  `.execute(db);
8752
8752
  }
8753
- async function down$34(db) {
8753
+ async function down$36(db) {
8754
8754
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS job_kind`.execute(db);
8755
8755
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS summoned_run_id`.execute(db);
8756
8756
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS summoned_by_run_id`.execute(db);
@@ -8759,8 +8759,8 @@ async function down$34(db) {
8759
8759
  //#endregion
8760
8760
  //#region src/db/migrations/118_invoke_gate_scheduling.ts
8761
8761
  var _118_invoke_gate_scheduling_exports = /* @__PURE__ */ __exportAll({
8762
- down: () => down$33,
8763
- up: () => up$33
8762
+ down: () => down$35,
8763
+ up: () => up$35
8764
8764
  });
8765
8765
  /**
8766
8766
  * Scheduling columns for the invoke gate: the pieces the orchestrator needs to
@@ -8792,7 +8792,7 @@ async function colExists$7(db, table, name) {
8792
8792
  ) AS exists
8793
8793
  `.execute(db)).rows[0]?.exists ?? false;
8794
8794
  }
8795
- async function up$33(db) {
8795
+ async function up$35(db) {
8796
8796
  if (!await colExists$7(db, "execution_jobs", "timeout_ms")) await sql`
8797
8797
  ALTER TABLE public.execution_jobs
8798
8798
  ADD COLUMN timeout_ms integer
@@ -8806,7 +8806,7 @@ async function up$33(db) {
8806
8806
  ADD COLUMN invoke_config text
8807
8807
  `.execute(db);
8808
8808
  }
8809
- async function down$33(db) {
8809
+ async function down$35(db) {
8810
8810
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS timeout_ms`.execute(db);
8811
8811
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS chain_depth`.execute(db);
8812
8812
  await sql`ALTER TABLE public.pending_job_contexts DROP COLUMN IF EXISTS invoke_config`.execute(db);
@@ -8814,8 +8814,8 @@ async function down$33(db) {
8814
8814
  //#endregion
8815
8815
  //#region src/db/migrations/119_scaler_ha_ownership.ts
8816
8816
  var _119_scaler_ha_ownership_exports = /* @__PURE__ */ __exportAll({
8817
- down: () => down$32,
8818
- up: () => up$32
8817
+ down: () => down$34,
8818
+ up: () => up$34
8819
8819
  });
8820
8820
  /**
8821
8821
  * HA ownership for event-scaler provisions.
@@ -8862,7 +8862,7 @@ const SPAWNING_COLUMNS = [
8862
8862
  ["roles", "JSONB"],
8863
8863
  ["backend_type", "TEXT"]
8864
8864
  ];
8865
- async function up$32(db) {
8865
+ async function up$34(db) {
8866
8866
  if (!await tableExists$1(db, "scaler_pending_claims")) {
8867
8867
  await sql`
8868
8868
  CREATE TABLE public.scaler_pending_claims (
@@ -8908,7 +8908,7 @@ async function up$32(db) {
8908
8908
  ON public.scaler_reservations (owner_instance_id)
8909
8909
  `.execute(db);
8910
8910
  }
8911
- async function down$32(db) {
8911
+ async function down$34(db) {
8912
8912
  await sql`DROP TABLE IF EXISTS public.scaler_pending_claims`.execute(db);
8913
8913
  await sql`DROP INDEX IF EXISTS public.idx_scaler_spawning_agents_scaler_name`.execute(db);
8914
8914
  for (const [name] of SPAWNING_COLUMNS) await sql`
@@ -8921,8 +8921,8 @@ async function down$32(db) {
8921
8921
  //#endregion
8922
8922
  //#region src/db/migrations/120_cluster_settings_scaler_reaper.ts
8923
8923
  var _120_cluster_settings_scaler_reaper_exports = /* @__PURE__ */ __exportAll({
8924
- down: () => down$31,
8925
- up: () => up$31
8924
+ down: () => down$33,
8925
+ up: () => up$33
8926
8926
  });
8927
8927
  /**
8928
8928
  * Cluster-global tunables for the leader-gated event-scaler provision reaper.
@@ -8964,17 +8964,17 @@ const COLUMNS$3 = [
8964
8964
  "scaler_reap_reattempt_interval_ms",
8965
8965
  "scaler_claim_retention_ms"
8966
8966
  ];
8967
- async function up$31(db) {
8967
+ async function up$33(db) {
8968
8968
  for (const column of COLUMNS$3) if (!await columnExists$2(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
8969
8969
  }
8970
- async function down$31(db) {
8970
+ async function down$33(db) {
8971
8971
  for (const column of COLUMNS$3) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
8972
8972
  }
8973
8973
  //#endregion
8974
8974
  //#region src/db/migrations/121_org_settings_allow_untrusted_dockerfile_builds.ts
8975
8975
  var _121_org_settings_allow_untrusted_dockerfile_builds_exports = /* @__PURE__ */ __exportAll({
8976
- down: () => down$30,
8977
- up: () => up$30
8976
+ down: () => down$32,
8977
+ up: () => up$32
8978
8978
  });
8979
8979
  /**
8980
8980
  * Add `org_settings.allow_untrusted_dockerfile_builds boolean NOT NULL DEFAULT false`.
@@ -8991,7 +8991,7 @@ var _121_org_settings_allow_untrusted_dockerfile_builds_exports = /* @__PURE__ *
8991
8991
  *
8992
8992
  * Idempotent: a re-run on a DB that already has the column is a no-op.
8993
8993
  */
8994
- async function up$30(db) {
8994
+ async function up$32(db) {
8995
8995
  if ((await sql`
8996
8996
  SELECT EXISTS (
8997
8997
  SELECT 1 FROM information_schema.columns
@@ -9005,7 +9005,7 @@ async function up$30(db) {
9005
9005
  ADD COLUMN allow_untrusted_dockerfile_builds boolean NOT NULL DEFAULT false
9006
9006
  `.execute(db);
9007
9007
  }
9008
- async function down$30(db) {
9008
+ async function down$32(db) {
9009
9009
  await sql`
9010
9010
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS allow_untrusted_dockerfile_builds
9011
9011
  `.execute(db);
@@ -9013,8 +9013,8 @@ async function down$30(db) {
9013
9013
  //#endregion
9014
9014
  //#region src/db/migrations/122_host_roster_scaler_managed.ts
9015
9015
  var _122_host_roster_scaler_managed_exports = /* @__PURE__ */ __exportAll({
9016
- down: () => down$29,
9017
- up: () => up$29
9016
+ down: () => down$31,
9017
+ up: () => up$31
9018
9018
  });
9019
9019
  /**
9020
9020
  * Add `host_roster.scaler_managed boolean NOT NULL DEFAULT false`.
@@ -9037,7 +9037,7 @@ var _122_host_roster_scaler_managed_exports = /* @__PURE__ */ __exportAll({
9037
9037
  *
9038
9038
  * Idempotent: a re-run on a DB that already has the column is a no-op.
9039
9039
  */
9040
- async function up$29(db) {
9040
+ async function up$31(db) {
9041
9041
  if ((await sql`
9042
9042
  SELECT EXISTS (
9043
9043
  SELECT 1 FROM information_schema.columns
@@ -9051,7 +9051,7 @@ async function up$29(db) {
9051
9051
  ADD COLUMN scaler_managed boolean NOT NULL DEFAULT false
9052
9052
  `.execute(db);
9053
9053
  }
9054
- async function down$29(db) {
9054
+ async function down$31(db) {
9055
9055
  await sql`
9056
9056
  ALTER TABLE public.host_roster DROP COLUMN IF EXISTS scaler_managed
9057
9057
  `.execute(db);
@@ -9059,8 +9059,8 @@ async function down$29(db) {
9059
9059
  //#endregion
9060
9060
  //#region src/db/migrations/123_workflow_registrations_default_branch.ts
9061
9061
  var _123_workflow_registrations_default_branch_exports = /* @__PURE__ */ __exportAll({
9062
- down: () => down$28,
9063
- up: () => up$28
9062
+ down: () => down$30,
9063
+ up: () => up$30
9064
9064
  });
9065
9065
  /**
9066
9066
  * Add `workflow_registrations.default_branch text` (nullable).
@@ -9082,7 +9082,7 @@ var _123_workflow_registrations_default_branch_exports = /* @__PURE__ */ __expor
9082
9082
  *
9083
9083
  * Idempotent: a re-run on a DB that already has the column is a no-op.
9084
9084
  */
9085
- async function up$28(db) {
9085
+ async function up$30(db) {
9086
9086
  if ((await sql`
9087
9087
  SELECT EXISTS (
9088
9088
  SELECT 1 FROM information_schema.columns
@@ -9096,7 +9096,7 @@ async function up$28(db) {
9096
9096
  ADD COLUMN default_branch text
9097
9097
  `.execute(db);
9098
9098
  }
9099
- async function down$28(db) {
9099
+ async function down$30(db) {
9100
9100
  await sql`
9101
9101
  ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS default_branch
9102
9102
  `.execute(db);
@@ -9104,8 +9104,8 @@ async function down$28(db) {
9104
9104
  //#endregion
9105
9105
  //#region src/db/migrations/124_cluster_settings_provision_backoff.ts
9106
9106
  var _124_cluster_settings_provision_backoff_exports = /* @__PURE__ */ __exportAll({
9107
- down: () => down$27,
9108
- up: () => up$27
9107
+ down: () => down$29,
9108
+ up: () => up$29
9109
9109
  });
9110
9110
  /**
9111
9111
  * Cluster-global tunables for backing off a repeatedly failing external
@@ -9154,17 +9154,17 @@ const COLUMNS$2 = [
9154
9154
  "scaler_provision_backoff_max_ms",
9155
9155
  "scaler_provision_max_consecutive_failures"
9156
9156
  ];
9157
- async function up$27(db) {
9157
+ async function up$29(db) {
9158
9158
  for (const column of COLUMNS$2) if (!await columnExists$1(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
9159
9159
  }
9160
- async function down$27(db) {
9160
+ async function down$29(db) {
9161
9161
  for (const column of COLUMNS$2) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
9162
9162
  }
9163
9163
  //#endregion
9164
9164
  //#region src/db/migrations/125_org_trust_directory.ts
9165
9165
  var _125_org_trust_directory_exports = /* @__PURE__ */ __exportAll({
9166
- down: () => down$26,
9167
- up: () => up$26
9166
+ down: () => down$28,
9167
+ up: () => up$28
9168
9168
  });
9169
9169
  /**
9170
9170
  * Create `org_trust_directory` — the orchestrator's cache of the Platform-owned
@@ -9192,7 +9192,7 @@ var _125_org_trust_directory_exports = /* @__PURE__ */ __exportAll({
9192
9192
  *
9193
9193
  * Idempotent: guarded by IF NOT EXISTS, so a re-run is a no-op.
9194
9194
  */
9195
- async function up$26(db) {
9195
+ async function up$28(db) {
9196
9196
  await sql`
9197
9197
  CREATE TABLE IF NOT EXISTS public.org_trust_directory (
9198
9198
  customer_id TEXT PRIMARY KEY,
@@ -9203,14 +9203,14 @@ async function up$26(db) {
9203
9203
  )
9204
9204
  `.execute(db);
9205
9205
  }
9206
- async function down$26(db) {
9206
+ async function down$28(db) {
9207
9207
  await sql`DROP TABLE IF EXISTS public.org_trust_directory`.execute(db);
9208
9208
  }
9209
9209
  //#endregion
9210
9210
  //#region src/db/migrations/126_held_runs_posted_pending_check.ts
9211
9211
  var _126_held_runs_posted_pending_check_exports = /* @__PURE__ */ __exportAll({
9212
- down: () => down$25,
9213
- up: () => up$25
9212
+ down: () => down$27,
9213
+ up: () => up$27
9214
9214
  });
9215
9215
  /**
9216
9216
  * Add `held_runs.posted_pending_check boolean` — whether this hold's pending
@@ -9236,7 +9236,7 @@ var _126_held_runs_posted_pending_check_exports = /* @__PURE__ */ __exportAll({
9236
9236
  *
9237
9237
  * Idempotent: a re-run on a DB that already has the column is a no-op.
9238
9238
  */
9239
- async function up$25(db) {
9239
+ async function up$27(db) {
9240
9240
  if ((await sql`
9241
9241
  SELECT EXISTS (
9242
9242
  SELECT 1 FROM information_schema.columns
@@ -9250,7 +9250,7 @@ async function up$25(db) {
9250
9250
  ADD COLUMN posted_pending_check boolean
9251
9251
  `.execute(db);
9252
9252
  }
9253
- async function down$25(db) {
9253
+ async function down$27(db) {
9254
9254
  await sql`
9255
9255
  ALTER TABLE public.held_runs DROP COLUMN IF EXISTS posted_pending_check
9256
9256
  `.execute(db);
@@ -9258,8 +9258,8 @@ async function down$25(db) {
9258
9258
  //#endregion
9259
9259
  //#region src/db/migrations/127_org_trust_policy_approval_expiry_seconds.ts
9260
9260
  var _127_org_trust_policy_approval_expiry_seconds_exports = /* @__PURE__ */ __exportAll({
9261
- down: () => down$24,
9262
- up: () => up$24
9261
+ down: () => down$26,
9262
+ up: () => up$26
9263
9263
  });
9264
9264
  /**
9265
9265
  * Add `org_trust_policy.approval_expiry_seconds` (nullable INTEGER).
@@ -9283,7 +9283,7 @@ var _127_org_trust_policy_approval_expiry_seconds_exports = /* @__PURE__ */ __ex
9283
9283
  * Idempotent: guarded on column existence; a re-run on a DB that already has
9284
9284
  * the column is a no-op.
9285
9285
  */
9286
- async function up$24(db) {
9286
+ async function up$26(db) {
9287
9287
  if ((await sql`
9288
9288
  SELECT EXISTS (
9289
9289
  SELECT 1 FROM information_schema.columns
@@ -9294,14 +9294,14 @@ async function up$24(db) {
9294
9294
  `.execute(db)).rows[0]?.exists) return;
9295
9295
  await sql`ALTER TABLE public.org_trust_policy ADD COLUMN approval_expiry_seconds INTEGER`.execute(db);
9296
9296
  }
9297
- async function down$24(db) {
9297
+ async function down$26(db) {
9298
9298
  await sql`ALTER TABLE public.org_trust_policy DROP COLUMN IF EXISTS approval_expiry_seconds`.execute(db);
9299
9299
  }
9300
9300
  //#endregion
9301
9301
  //#region src/db/migrations/128_execution_runs_global_eval_round.ts
9302
9302
  var _128_execution_runs_global_eval_round_exports = /* @__PURE__ */ __exportAll({
9303
- down: () => down$23,
9304
- up: () => up$23
9303
+ down: () => down$25,
9304
+ up: () => up$25
9305
9305
  });
9306
9306
  /**
9307
9307
  * Add `execution_runs.is_global_eval_round boolean NOT NULL DEFAULT false` —
@@ -9322,7 +9322,7 @@ var _128_execution_runs_global_eval_round_exports = /* @__PURE__ */ __exportAll(
9322
9322
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
9323
9323
  * re-run is a no-op.
9324
9324
  */
9325
- async function up$23(db) {
9325
+ async function up$25(db) {
9326
9326
  if ((await sql`
9327
9327
  SELECT EXISTS (
9328
9328
  SELECT 1 FROM information_schema.columns
@@ -9336,7 +9336,7 @@ async function up$23(db) {
9336
9336
  ADD COLUMN is_global_eval_round BOOLEAN NOT NULL DEFAULT FALSE
9337
9337
  `.execute(db);
9338
9338
  }
9339
- async function down$23(db) {
9339
+ async function down$25(db) {
9340
9340
  await sql`
9341
9341
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS is_global_eval_round
9342
9342
  `.execute(db);
@@ -9344,8 +9344,8 @@ async function down$23(db) {
9344
9344
  //#endregion
9345
9345
  //#region src/db/migrations/129_execution_runs_dispatch_routing_key.ts
9346
9346
  var _129_execution_runs_dispatch_routing_key_exports = /* @__PURE__ */ __exportAll({
9347
- down: () => down$22,
9348
- up: () => up$22
9347
+ down: () => down$24,
9348
+ up: () => up$24
9349
9349
  });
9350
9350
  /**
9351
9351
  * Add `execution_runs.dispatch_routing_key TEXT NULL` — the source whose
@@ -9367,7 +9367,7 @@ var _129_execution_runs_dispatch_routing_key_exports = /* @__PURE__ */ __exportA
9367
9367
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
9368
9368
  * re-run is a no-op.
9369
9369
  */
9370
- async function up$22(db) {
9370
+ async function up$24(db) {
9371
9371
  if ((await sql`
9372
9372
  SELECT EXISTS (
9373
9373
  SELECT 1 FROM information_schema.columns
@@ -9381,7 +9381,7 @@ async function up$22(db) {
9381
9381
  ADD COLUMN dispatch_routing_key TEXT
9382
9382
  `.execute(db);
9383
9383
  }
9384
- async function down$22(db) {
9384
+ async function down$24(db) {
9385
9385
  await sql`
9386
9386
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS dispatch_routing_key
9387
9387
  `.execute(db);
@@ -9389,8 +9389,8 @@ async function down$22(db) {
9389
9389
  //#endregion
9390
9390
  //#region src/db/migrations/130_scaler_provision_outcomes.ts
9391
9391
  var _130_scaler_provision_outcomes_exports = /* @__PURE__ */ __exportAll({
9392
- down: () => down$21,
9393
- up: () => up$21
9392
+ down: () => down$23,
9393
+ up: () => up$23
9394
9394
  });
9395
9395
  /**
9396
9396
  * Durable per-provision outcome, keyed by agent id.
@@ -9420,7 +9420,7 @@ var _130_scaler_provision_outcomes_exports = /* @__PURE__ */ __exportAll({
9420
9420
  * no-op — including a re-run over a database that has the table but not the
9421
9421
  * index, which an existence probe over the table alone would skip.
9422
9422
  */
9423
- async function up$21(db) {
9423
+ async function up$23(db) {
9424
9424
  await sql`
9425
9425
  CREATE TABLE IF NOT EXISTS public.scaler_provision_outcomes (
9426
9426
  agent_id TEXT PRIMARY KEY,
@@ -9438,14 +9438,14 @@ async function up$21(db) {
9438
9438
  ON public.scaler_provision_outcomes (updated_at)
9439
9439
  `.execute(db);
9440
9440
  }
9441
- async function down$21(db) {
9441
+ async function down$23(db) {
9442
9442
  await sql`DROP TABLE IF EXISTS public.scaler_provision_outcomes`.execute(db);
9443
9443
  }
9444
9444
  //#endregion
9445
9445
  //#region src/db/migrations/131_execution_jobs_git_credentials.ts
9446
9446
  var _131_execution_jobs_git_credentials_exports = /* @__PURE__ */ __exportAll({
9447
- down: () => down$20,
9448
- up: () => up$20
9447
+ down: () => down$22,
9448
+ up: () => up$22
9449
9449
  });
9450
9450
  /**
9451
9451
  * Add `execution_jobs.git_credentials JSONB NULL` — the `gitCredentials` map the
@@ -9473,7 +9473,7 @@ var _131_execution_jobs_git_credentials_exports = /* @__PURE__ */ __exportAll({
9473
9473
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
9474
9474
  * re-run is a no-op.
9475
9475
  */
9476
- async function up$20(db) {
9476
+ async function up$22(db) {
9477
9477
  if ((await sql`
9478
9478
  SELECT EXISTS (
9479
9479
  SELECT 1 FROM information_schema.columns
@@ -9487,7 +9487,7 @@ async function up$20(db) {
9487
9487
  ADD COLUMN git_credentials JSONB
9488
9488
  `.execute(db);
9489
9489
  }
9490
- async function down$20(db) {
9490
+ async function down$22(db) {
9491
9491
  await sql`
9492
9492
  ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS git_credentials
9493
9493
  `.execute(db);
@@ -9495,8 +9495,8 @@ async function down$20(db) {
9495
9495
  //#endregion
9496
9496
  //#region src/db/migrations/132_execution_runs_trigger_event.ts
9497
9497
  var _132_execution_runs_trigger_event_exports = /* @__PURE__ */ __exportAll({
9498
- down: () => down$19,
9499
- up: () => up$19
9498
+ down: () => down$21,
9499
+ up: () => up$21
9500
9500
  });
9501
9501
  /**
9502
9502
  * Add `execution_runs.trigger_event TEXT NULL` — the event type that started
@@ -9517,7 +9517,7 @@ var _132_execution_runs_trigger_event_exports = /* @__PURE__ */ __exportAll({
9517
9517
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
9518
9518
  * re-run is a no-op.
9519
9519
  */
9520
- async function up$19(db) {
9520
+ async function up$21(db) {
9521
9521
  if ((await sql`
9522
9522
  SELECT EXISTS (
9523
9523
  SELECT 1 FROM information_schema.columns
@@ -9531,7 +9531,7 @@ async function up$19(db) {
9531
9531
  ADD COLUMN trigger_event TEXT
9532
9532
  `.execute(db);
9533
9533
  }
9534
- async function down$19(db) {
9534
+ async function down$21(db) {
9535
9535
  await sql`
9536
9536
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_event
9537
9537
  `.execute(db);
@@ -9539,8 +9539,8 @@ async function down$19(db) {
9539
9539
  //#endregion
9540
9540
  //#region src/db/migrations/133_dispatch_queue_source_tar_digest.ts
9541
9541
  var _133_dispatch_queue_source_tar_digest_exports = /* @__PURE__ */ __exportAll({
9542
- down: () => down$18,
9543
- up: () => up$18
9542
+ down: () => down$20,
9543
+ up: () => up$20
9544
9544
  });
9545
9545
  /**
9546
9546
  * Add `dispatch_queue.source_tar_digest TEXT NULL` — the SHA-256 of the source
@@ -9561,7 +9561,7 @@ var _133_dispatch_queue_source_tar_digest_exports = /* @__PURE__ */ __exportAll(
9561
9561
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
9562
9562
  * re-run is a no-op.
9563
9563
  */
9564
- async function up$18(db) {
9564
+ async function up$20(db) {
9565
9565
  if ((await sql`
9566
9566
  SELECT EXISTS (
9567
9567
  SELECT 1 FROM information_schema.columns
@@ -9575,7 +9575,7 @@ async function up$18(db) {
9575
9575
  ADD COLUMN source_tar_digest TEXT
9576
9576
  `.execute(db);
9577
9577
  }
9578
- async function down$18(db) {
9578
+ async function down$20(db) {
9579
9579
  await sql`
9580
9580
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS source_tar_digest
9581
9581
  `.execute(db);
@@ -9583,8 +9583,8 @@ async function down$18(db) {
9583
9583
  //#endregion
9584
9584
  //#region src/db/migrations/134_dispatch_queue_ownership.ts
9585
9585
  var _134_dispatch_queue_ownership_exports = /* @__PURE__ */ __exportAll({
9586
- down: () => down$17,
9587
- up: () => up$17
9586
+ down: () => down$19,
9587
+ up: () => up$19
9588
9588
  });
9589
9589
  /**
9590
9590
  * Coordinator ownership for the job-dispatch plane.
@@ -9637,7 +9637,7 @@ async function colExists$5(db, table, name) {
9637
9637
  `.execute(db)).rows[0]?.exists ?? false;
9638
9638
  }
9639
9639
  const DISPATCH_QUEUE_COLUMNS = [["owner_instance_id", "TEXT"], ["dispatched_at", "TIMESTAMPTZ"]];
9640
- async function up$17(db) {
9640
+ async function up$19(db) {
9641
9641
  for (const [name, type] of DISPATCH_QUEUE_COLUMNS) if (!await colExists$5(db, "dispatch_queue", name)) await sql`
9642
9642
  ALTER TABLE public.dispatch_queue
9643
9643
  ADD COLUMN ${sql.raw(name)} ${sql.raw(type)}
@@ -9698,7 +9698,7 @@ async function up$17(db) {
9698
9698
  WHERE status = 'active'
9699
9699
  `.execute(db);
9700
9700
  }
9701
- async function down$17(db) {
9701
+ async function down$19(db) {
9702
9702
  await sql`DROP INDEX IF EXISTS public.idx_concurrency_groups_active_unique`.execute(db);
9703
9703
  await sql`DROP TABLE IF EXISTS public.cluster_instances`.execute(db);
9704
9704
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS cancelling_at`.execute(db);
@@ -9709,8 +9709,8 @@ async function down$17(db) {
9709
9709
  //#endregion
9710
9710
  //#region src/db/migrations/135_cluster_settings_retention_days.ts
9711
9711
  var _135_cluster_settings_retention_days_exports = /* @__PURE__ */ __exportAll({
9712
- down: () => down$16,
9713
- up: () => up$16
9712
+ down: () => down$18,
9713
+ up: () => up$18
9714
9714
  });
9715
9715
  /**
9716
9716
  * Add the database-side retention windows to `cluster_settings`.
@@ -9772,20 +9772,20 @@ async function columnExists(db, column) {
9772
9772
  ) AS exists
9773
9773
  `.execute(db)).rows[0]?.exists === true;
9774
9774
  }
9775
- async function up$16(db) {
9775
+ async function up$18(db) {
9776
9776
  for (const { name, type } of COLUMNS$1) {
9777
9777
  if (await columnExists(db, name)) continue;
9778
9778
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.raw(name)} ${sql.raw(type)}`.execute(db);
9779
9779
  }
9780
9780
  }
9781
- async function down$16(db) {
9781
+ async function down$18(db) {
9782
9782
  for (const { name } of COLUMNS$1) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.raw(name)}`.execute(db);
9783
9783
  }
9784
9784
  //#endregion
9785
9785
  //#region src/db/migrations/136_master_key_wrapped_tables_key_version.ts
9786
9786
  var _136_master_key_wrapped_tables_key_version_exports = /* @__PURE__ */ __exportAll({
9787
- down: () => down$15,
9788
- up: () => up$15
9787
+ down: () => down$17,
9788
+ up: () => up$17
9789
9789
  });
9790
9790
  /**
9791
9791
  * Add `key_version INTEGER NOT NULL DEFAULT 1` to the three master-key-wrapped
@@ -9811,7 +9811,7 @@ const TABLES = [
9811
9811
  "run_ephemeral_keys",
9812
9812
  "run_secret_outputs"
9813
9813
  ];
9814
- async function up$15(db) {
9814
+ async function up$17(db) {
9815
9815
  for (const table of TABLES) {
9816
9816
  if ((await sql`
9817
9817
  SELECT EXISTS (
@@ -9827,7 +9827,7 @@ async function up$15(db) {
9827
9827
  `.execute(db);
9828
9828
  }
9829
9829
  }
9830
- async function down$15(db) {
9830
+ async function down$17(db) {
9831
9831
  for (const table of TABLES) await sql`
9832
9832
  ALTER TABLE public.${sql.raw(table)} DROP COLUMN IF EXISTS key_version
9833
9833
  `.execute(db);
@@ -9835,8 +9835,8 @@ async function down$15(db) {
9835
9835
  //#endregion
9836
9836
  //#region src/db/migrations/137_execution_runs_pr_head_context.ts
9837
9837
  var _137_execution_runs_pr_head_context_exports = /* @__PURE__ */ __exportAll({
9838
- down: () => down$14,
9839
- up: () => up$14
9838
+ down: () => down$16,
9839
+ up: () => up$16
9840
9840
  });
9841
9841
  /**
9842
9842
  * Add the pull-request head context to `execution_runs`: `head_ref TEXT`,
@@ -9872,7 +9872,7 @@ const COLUMNS = [
9872
9872
  ["head_repository", "TEXT"],
9873
9873
  ["is_fork", "BOOLEAN"]
9874
9874
  ];
9875
- async function up$14(db) {
9875
+ async function up$16(db) {
9876
9876
  for (const [name, type] of COLUMNS) {
9877
9877
  if ((await sql`
9878
9878
  SELECT EXISTS (
@@ -9888,7 +9888,7 @@ async function up$14(db) {
9888
9888
  `.execute(db);
9889
9889
  }
9890
9890
  }
9891
- async function down$14(db) {
9891
+ async function down$16(db) {
9892
9892
  for (const [name] of COLUMNS) await sql`
9893
9893
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS ${sql.raw(name)}
9894
9894
  `.execute(db);
@@ -9896,8 +9896,8 @@ async function down$14(db) {
9896
9896
  //#endregion
9897
9897
  //#region src/db/migrations/138_execution_runs_subject_trigger_event.ts
9898
9898
  var _138_execution_runs_subject_trigger_event_exports = /* @__PURE__ */ __exportAll({
9899
- down: () => down$13,
9900
- up: () => up$13
9899
+ down: () => down$15,
9900
+ up: () => up$15
9901
9901
  });
9902
9902
  /**
9903
9903
  * Add `execution_runs.subject_trigger_event TEXT`, nullable.
@@ -9923,7 +9923,7 @@ var _138_execution_runs_subject_trigger_event_exports = /* @__PURE__ */ __export
9923
9923
  * a re-run is a no-op.
9924
9924
  */
9925
9925
  const COLUMN$1 = "subject_trigger_event";
9926
- async function up$13(db) {
9926
+ async function up$15(db) {
9927
9927
  if ((await sql`
9928
9928
  SELECT EXISTS (
9929
9929
  SELECT 1 FROM information_schema.columns
@@ -9937,7 +9937,7 @@ async function up$13(db) {
9937
9937
  ADD COLUMN ${sql.raw(COLUMN$1)} TEXT
9938
9938
  `.execute(db);
9939
9939
  }
9940
- async function down$13(db) {
9940
+ async function down$15(db) {
9941
9941
  await sql`
9942
9942
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS ${sql.raw(COLUMN$1)}
9943
9943
  `.execute(db);
@@ -9945,8 +9945,8 @@ async function down$13(db) {
9945
9945
  //#endregion
9946
9946
  //#region src/db/migrations/139_admin_token_subject.ts
9947
9947
  var _139_admin_token_subject_exports = /* @__PURE__ */ __exportAll({
9948
- down: () => down$12,
9949
- up: () => up$12
9948
+ down: () => down$14,
9949
+ up: () => up$14
9950
9950
  });
9951
9951
  /**
9952
9952
  * Add `admin_tokens.subject TEXT`, nullable.
@@ -9971,7 +9971,7 @@ var _139_admin_token_subject_exports = /* @__PURE__ */ __exportAll({
9971
9971
  * a re-run is a no-op.
9972
9972
  */
9973
9973
  const COLUMN = "subject";
9974
- async function up$12(db) {
9974
+ async function up$14(db) {
9975
9975
  if ((await sql`
9976
9976
  SELECT EXISTS (
9977
9977
  SELECT 1 FROM information_schema.columns
@@ -9985,7 +9985,7 @@ async function up$12(db) {
9985
9985
  ADD COLUMN ${sql.raw(COLUMN)} TEXT
9986
9986
  `.execute(db);
9987
9987
  }
9988
- async function down$12(db) {
9988
+ async function down$14(db) {
9989
9989
  await sql`
9990
9990
  ALTER TABLE public.admin_tokens DROP COLUMN IF EXISTS ${sql.raw(COLUMN)}
9991
9991
  `.execute(db);
@@ -9993,8 +9993,8 @@ async function down$12(db) {
9993
9993
  //#endregion
9994
9994
  //#region src/db/migrations/140_dispatch_queue_canonical_labels.ts
9995
9995
  var _140_dispatch_queue_canonical_labels_exports = /* @__PURE__ */ __exportAll({
9996
- down: () => down$11,
9997
- up: () => up$11
9996
+ down: () => down$13,
9997
+ up: () => up$13
9998
9998
  });
9999
9999
  /**
10000
10000
  * The whitespace `btrim` strips, chosen to match `String.prototype.trim`, which
@@ -10050,7 +10050,7 @@ const TRIM_CHARS = String.raw`E' \t\n\r\f\x0B'`;
10050
10050
  * Idempotent: each `UPDATE` selects only rows holding an element that is not
10051
10051
  * already its own canonical form, so a re-run touches nothing.
10052
10052
  */
10053
- async function up$11(db) {
10053
+ async function up$13(db) {
10054
10054
  const trim = sql.raw(TRIM_CHARS);
10055
10055
  await sql`
10056
10056
  UPDATE public.dispatch_queue
@@ -10088,12 +10088,12 @@ async function up$11(db) {
10088
10088
  * migration canonicalized, so a fleet whose configured labels are not already
10089
10089
  * lowercase strands those rows until they expire, drain, or are re-enqueued.
10090
10090
  */
10091
- async function down$11() {}
10091
+ async function down$13() {}
10092
10092
  //#endregion
10093
10093
  //#region src/db/migrations/141_event_log_shed.ts
10094
10094
  var _141_event_log_shed_exports = /* @__PURE__ */ __exportAll({
10095
- down: () => down$10,
10096
- up: () => up$10
10095
+ down: () => down$12,
10096
+ up: () => up$12
10097
10097
  });
10098
10098
  /**
10099
10099
  * Extend the event_log.status CHECK constraint with 'shed' so the orchestrator
@@ -10106,7 +10106,7 @@ var _141_event_log_shed_exports = /* @__PURE__ */ __exportAll({
10106
10106
  *
10107
10107
  * Idempotent: the DROP ... IF EXISTS / re-ADD pair re-runs cleanly.
10108
10108
  */
10109
- async function up$10(db) {
10109
+ async function up$12(db) {
10110
10110
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
10111
10111
  await sql`
10112
10112
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -10116,7 +10116,7 @@ async function up$10(db) {
10116
10116
  ])))
10117
10117
  `.execute(db);
10118
10118
  }
10119
- async function down$10(db) {
10119
+ async function down$12(db) {
10120
10120
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
10121
10121
  await sql`
10122
10122
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -10129,8 +10129,8 @@ async function down$10(db) {
10129
10129
  //#endregion
10130
10130
  //#region src/db/migrations/142_sweep_deprecated_columns.ts
10131
10131
  var _142_sweep_deprecated_columns_exports = /* @__PURE__ */ __exportAll({
10132
- down: () => down$9,
10133
- up: () => up$9
10132
+ down: () => down$11,
10133
+ up: () => up$11
10134
10134
  });
10135
10135
  /**
10136
10136
  * Sweep the columns and stored values that no code path reads or writes any
@@ -10164,7 +10164,7 @@ var _142_sweep_deprecated_columns_exports = /* @__PURE__ */ __exportAll({
10164
10164
  * guarded by IF EXISTS.
10165
10165
  */
10166
10166
  const BATCH_SIZE = 5e3;
10167
- async function up$9(db) {
10167
+ async function up$11(db) {
10168
10168
  for (;;) if (((await sql`
10169
10169
  UPDATE public.execution_runs
10170
10170
  SET trust_tier = 'unknown'
@@ -10190,12 +10190,12 @@ async function up$9(db) {
10190
10190
  await sql`ALTER TABLE public.org_trust_policy DROP COLUMN IF EXISTS workflow_change_policy`.execute(db);
10191
10191
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS source_tar_hash`.execute(db);
10192
10192
  }
10193
- async function down$9() {}
10193
+ async function down$11() {}
10194
10194
  //#endregion
10195
10195
  //#region src/db/migrations/143_execution_jobs_precursor_result.ts
10196
10196
  var _143_execution_jobs_precursor_result_exports = /* @__PURE__ */ __exportAll({
10197
- down: () => down$8,
10198
- up: () => up$8
10197
+ down: () => down$10,
10198
+ up: () => up$10
10199
10199
  });
10200
10200
  /**
10201
10201
  * Add `execution_jobs.precursor_result JSONB NULL` — the payload a precursor
@@ -10219,7 +10219,7 @@ var _143_execution_jobs_precursor_result_exports = /* @__PURE__ */ __exportAll({
10219
10219
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
10220
10220
  * re-run is a no-op.
10221
10221
  */
10222
- async function up$8(db) {
10222
+ async function up$10(db) {
10223
10223
  if ((await sql`
10224
10224
  SELECT EXISTS (
10225
10225
  SELECT 1 FROM information_schema.columns
@@ -10233,7 +10233,7 @@ async function up$8(db) {
10233
10233
  ADD COLUMN precursor_result JSONB
10234
10234
  `.execute(db);
10235
10235
  }
10236
- async function down$8(db) {
10236
+ async function down$10(db) {
10237
10237
  await sql`
10238
10238
  ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS precursor_result
10239
10239
  `.execute(db);
@@ -10241,8 +10241,8 @@ async function down$8(db) {
10241
10241
  //#endregion
10242
10242
  //#region src/db/migrations/144_execution_runs_registration_window.ts
10243
10243
  var _144_execution_runs_registration_window_exports = /* @__PURE__ */ __exportAll({
10244
- down: () => down$7,
10245
- up: () => up$7
10244
+ down: () => down$9,
10245
+ up: () => up$9
10246
10246
  });
10247
10247
  /**
10248
10248
  * Add `execution_runs.registration_window_instance_id TEXT NULL` — the
@@ -10272,7 +10272,7 @@ var _144_execution_runs_registration_window_exports = /* @__PURE__ */ __exportAl
10272
10272
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
10273
10273
  * re-run is a no-op.
10274
10274
  */
10275
- async function up$7(db) {
10275
+ async function up$9(db) {
10276
10276
  if ((await sql`
10277
10277
  SELECT EXISTS (
10278
10278
  SELECT 1 FROM information_schema.columns
@@ -10286,7 +10286,7 @@ async function up$7(db) {
10286
10286
  ADD COLUMN registration_window_instance_id TEXT
10287
10287
  `.execute(db);
10288
10288
  }
10289
- async function down$7(db) {
10289
+ async function down$9(db) {
10290
10290
  await sql`
10291
10291
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS registration_window_instance_id
10292
10292
  `.execute(db);
@@ -10294,8 +10294,8 @@ async function down$7(db) {
10294
10294
  //#endregion
10295
10295
  //#region src/db/migrations/145_execution_runs_workflow_provenance.ts
10296
10296
  var _145_execution_runs_workflow_provenance_exports = /* @__PURE__ */ __exportAll({
10297
- down: () => down$6,
10298
- up: () => up$6
10297
+ down: () => down$8,
10298
+ up: () => up$8
10299
10299
  });
10300
10300
  /**
10301
10301
  * Record the workflow repository's commit and registered branch for a run whose
@@ -10322,19 +10322,19 @@ async function colExists$4(db, name) {
10322
10322
  ) AS exists
10323
10323
  `.execute(db)).rows[0]?.exists ?? false;
10324
10324
  }
10325
- async function up$6(db) {
10325
+ async function up$8(db) {
10326
10326
  if (!await colExists$4(db, "workflow_sha")) await sql`ALTER TABLE public.execution_runs ADD COLUMN workflow_sha text`.execute(db);
10327
10327
  if (!await colExists$4(db, "workflow_branch")) await sql`ALTER TABLE public.execution_runs ADD COLUMN workflow_branch text`.execute(db);
10328
10328
  }
10329
- async function down$6(db) {
10329
+ async function down$8(db) {
10330
10330
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_branch`.execute(db);
10331
10331
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_sha`.execute(db);
10332
10332
  }
10333
10333
  //#endregion
10334
10334
  //#region src/db/migrations/146_pending_job_contexts_context_resolution.ts
10335
10335
  var _146_pending_job_contexts_context_resolution_exports = /* @__PURE__ */ __exportAll({
10336
- down: () => down$5,
10337
- up: () => up$5
10336
+ down: () => down$7,
10337
+ up: () => up$7
10338
10338
  });
10339
10339
  /**
10340
10340
  * Record, with a held job's pending dispatch context, what the release path
@@ -10360,18 +10360,18 @@ async function colExists$3(db) {
10360
10360
  ) AS exists
10361
10361
  `.execute(db)).rows[0]?.exists ?? false;
10362
10362
  }
10363
- async function up$5(db) {
10363
+ async function up$7(db) {
10364
10364
  if (!await colExists$3(db)) await sql`ALTER TABLE public.pending_job_contexts ADD COLUMN context_resolution jsonb`.execute(db);
10365
10365
  }
10366
- async function down$5(db) {
10366
+ async function down$7(db) {
10367
10367
  await sql`ALTER TABLE public.pending_job_contexts DROP COLUMN IF EXISTS context_resolution`.execute(db);
10368
10368
  }
10369
10369
  //#endregion
10370
10370
  //#region src/db/migrations/147_sealed_job_secrets.ts
10371
10371
  var _147_sealed_job_secrets_exports = /* @__PURE__ */ __exportAll({
10372
10372
  SEALED_SECRETS_TABLES: () => SEALED_SECRETS_TABLES,
10373
- down: () => down$4,
10374
- up: () => up$4
10373
+ down: () => down$6,
10374
+ up: () => up$6
10375
10375
  });
10376
10376
  /**
10377
10377
  * Hold the secret fields of a stored job encrypted under the orchestrator
@@ -10402,17 +10402,17 @@ async function colExists$2(db, table) {
10402
10402
  ) AS exists
10403
10403
  `.execute(db)).rows[0]?.exists ?? false;
10404
10404
  }
10405
- async function up$4(db) {
10405
+ async function up$6(db) {
10406
10406
  for (const table of SEALED_SECRETS_TABLES) if (!await colExists$2(db, table)) await sql`ALTER TABLE ${sql.table(`public.${table}`)} ADD COLUMN sealed_secrets text`.execute(db);
10407
10407
  }
10408
- async function down$4(db) {
10408
+ async function down$6(db) {
10409
10409
  for (const table of SEALED_SECRETS_TABLES) await sql`ALTER TABLE ${sql.table(`public.${table}`)} DROP COLUMN IF EXISTS sealed_secrets`.execute(db);
10410
10410
  }
10411
10411
  //#endregion
10412
10412
  //#region src/db/migrations/148_cluster_settings_sealed_secrets_retry_backoff_ms.ts
10413
10413
  var _148_cluster_settings_sealed_secrets_retry_backoff_ms_exports = /* @__PURE__ */ __exportAll({
10414
- down: () => down$3,
10415
- up: () => up$3
10414
+ down: () => down$5,
10415
+ up: () => up$5
10416
10416
  });
10417
10417
  /**
10418
10418
  * Add `cluster_settings.sealed_secrets_retry_backoff_ms` (nullable bigint).
@@ -10431,7 +10431,7 @@ var _148_cluster_settings_sealed_secrets_retry_backoff_ms_exports = /* @__PURE__
10431
10431
  * Idempotent: guarded on column existence; a re-run on a DB that already has the
10432
10432
  * column is a no-op.
10433
10433
  */
10434
- async function up$3(db) {
10434
+ async function up$5(db) {
10435
10435
  if ((await sql`
10436
10436
  SELECT EXISTS (
10437
10437
  SELECT 1 FROM information_schema.columns
@@ -10442,14 +10442,14 @@ async function up$3(db) {
10442
10442
  `.execute(db)).rows[0]?.exists) return;
10443
10443
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN sealed_secrets_retry_backoff_ms BIGINT`.execute(db);
10444
10444
  }
10445
- async function down$3(db) {
10445
+ async function down$5(db) {
10446
10446
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS sealed_secrets_retry_backoff_ms`.execute(db);
10447
10447
  }
10448
10448
  //#endregion
10449
10449
  //#region src/db/migrations/149_workflow_registrations_dep_cache_key.ts
10450
10450
  var _149_workflow_registrations_dep_cache_key_exports = /* @__PURE__ */ __exportAll({
10451
- down: () => down$2,
10452
- up: () => up$2
10451
+ down: () => down$4,
10452
+ up: () => up$4
10453
10453
  });
10454
10454
  /**
10455
10455
  * Record the dependency-cache key of the lock file that registered a workflow.
@@ -10477,19 +10477,19 @@ async function colExists$1(db, name) {
10477
10477
  ) AS exists
10478
10478
  `.execute(db)).rows[0]?.exists ?? false;
10479
10479
  }
10480
- async function up$2(db) {
10480
+ async function up$4(db) {
10481
10481
  if (!await colExists$1(db, "lockfile_hash")) await sql`ALTER TABLE public.workflow_registrations ADD COLUMN lockfile_hash text`.execute(db);
10482
10482
  if (!await colExists$1(db, "siblings_digest")) await sql`ALTER TABLE public.workflow_registrations ADD COLUMN siblings_digest text`.execute(db);
10483
10483
  }
10484
- async function down$2(db) {
10484
+ async function down$4(db) {
10485
10485
  await sql`ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS siblings_digest`.execute(db);
10486
10486
  await sql`ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS lockfile_hash`.execute(db);
10487
10487
  }
10488
10488
  //#endregion
10489
10489
  //#region src/db/migrations/150_execution_runs_status_epoch.ts
10490
10490
  var _150_execution_runs_status_epoch_exports = /* @__PURE__ */ __exportAll({
10491
- down: () => down$1,
10492
- up: () => up$1
10491
+ down: () => down$3,
10492
+ up: () => up$3
10493
10493
  });
10494
10494
  /**
10495
10495
  * Add `execution_runs.status_epoch` (integer, NOT NULL, default 0).
@@ -10505,7 +10505,7 @@ var _150_execution_runs_status_epoch_exports = /* @__PURE__ */ __exportAll({
10505
10505
  *
10506
10506
  * Idempotent: guarded on the column's existence, so re-running is a no-op.
10507
10507
  */
10508
- async function up$1(db) {
10508
+ async function up$3(db) {
10509
10509
  if ((await sql`
10510
10510
  SELECT EXISTS (
10511
10511
  SELECT 1 FROM information_schema.columns
@@ -10516,14 +10516,14 @@ async function up$1(db) {
10516
10516
  `.execute(db)).rows[0]?.exists) return;
10517
10517
  await sql`ALTER TABLE public.execution_runs ADD COLUMN status_epoch INTEGER NOT NULL DEFAULT 0`.execute(db);
10518
10518
  }
10519
- async function down$1(db) {
10519
+ async function down$3(db) {
10520
10520
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS status_epoch`.execute(db);
10521
10521
  }
10522
10522
  //#endregion
10523
10523
  //#region src/db/migrations/151_workflow_registrations_dep_cache_key_sha.ts
10524
10524
  var _151_workflow_registrations_dep_cache_key_sha_exports = /* @__PURE__ */ __exportAll({
10525
- down: () => down,
10526
- up: () => up
10525
+ down: () => down$2,
10526
+ up: () => up$2
10527
10527
  });
10528
10528
  /**
10529
10529
  * Record the commit a workflow registration's dependency-cache key was written for.
@@ -10553,14 +10553,87 @@ async function colExists(db) {
10553
10553
  ) AS exists
10554
10554
  `.execute(db)).rows[0]?.exists ?? false;
10555
10555
  }
10556
- async function up(db) {
10556
+ async function up$2(db) {
10557
10557
  if (await colExists(db)) return;
10558
10558
  await sql`ALTER TABLE public.workflow_registrations ADD COLUMN dep_cache_key_sha text`.execute(db);
10559
10559
  }
10560
- async function down(db) {
10560
+ async function down$2(db) {
10561
10561
  await sql`ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS dep_cache_key_sha`.execute(db);
10562
10562
  }
10563
10563
  //#endregion
10564
+ //#region src/db/migrations/152_org_settings_cache_upload_settle_timeout.ts
10565
+ var _152_org_settings_cache_upload_settle_timeout_exports = /* @__PURE__ */ __exportAll({
10566
+ down: () => down$1,
10567
+ up: () => up$1
10568
+ });
10569
+ /**
10570
+ * Add `org_settings.cache_upload_settle_timeout_ms BIGINT` (nullable).
10571
+ *
10572
+ * Per-org bound on how long a build job's `job.status success` waits for the
10573
+ * cache publish (object metadata plus pointer) its agent reported just before
10574
+ * it. NULL falls back to the cluster default
10575
+ * (`KICI_CACHE_UPLOAD_SETTLE_TIMEOUT_MS`, 10s); 0 turns the wait off. Operators
10576
+ * tune it via `kici-admin org-settings cache-upload-settle`.
10577
+ *
10578
+ * Idempotent: a re-run on a DB that already has the column is a no-op.
10579
+ */
10580
+ async function up$1(db) {
10581
+ if ((await sql`
10582
+ SELECT EXISTS (
10583
+ SELECT 1 FROM information_schema.columns
10584
+ WHERE table_schema = 'public'
10585
+ AND table_name = 'org_settings'
10586
+ AND column_name = 'cache_upload_settle_timeout_ms'
10587
+ ) AS exists
10588
+ `.execute(db)).rows[0]?.exists) return;
10589
+ await sql`
10590
+ ALTER TABLE public.org_settings
10591
+ ADD COLUMN cache_upload_settle_timeout_ms BIGINT
10592
+ `.execute(db);
10593
+ }
10594
+ async function down$1(db) {
10595
+ await sql`
10596
+ ALTER TABLE public.org_settings DROP COLUMN IF EXISTS cache_upload_settle_timeout_ms
10597
+ `.execute(db);
10598
+ }
10599
+ //#endregion
10600
+ //#region src/db/migrations/153_execution_runs_cancel_force.ts
10601
+ var _153_execution_runs_cancel_force_exports = /* @__PURE__ */ __exportAll({
10602
+ down: () => down,
10603
+ up: () => up
10604
+ });
10605
+ /**
10606
+ * Add `execution_runs.cancel_force BOOLEAN` (nullable, no default).
10607
+ *
10608
+ * TRUE once a forced cancel reached the run. The leader's stuck-cancelling
10609
+ * sweep reads it to re-send a cancel that did not complete with `force` set,
10610
+ * so a forced cancel whose first forward to a sibling coordinator was lost is
10611
+ * not re-sent as a graceful one. NULL (every existing row, and every run no
10612
+ * forced cancel reached) re-sends gracefully. No backfill: nothing recorded
10613
+ * whether an earlier cancel was forced.
10614
+ *
10615
+ * Idempotent: a re-run on a DB that already has the column is a no-op.
10616
+ */
10617
+ async function up(db) {
10618
+ if ((await sql`
10619
+ SELECT EXISTS (
10620
+ SELECT 1 FROM information_schema.columns
10621
+ WHERE table_schema = 'public'
10622
+ AND table_name = 'execution_runs'
10623
+ AND column_name = 'cancel_force'
10624
+ ) AS exists
10625
+ `.execute(db)).rows[0]?.exists) return;
10626
+ await sql`
10627
+ ALTER TABLE public.execution_runs
10628
+ ADD COLUMN cancel_force BOOLEAN
10629
+ `.execute(db);
10630
+ }
10631
+ async function down(db) {
10632
+ await sql`
10633
+ ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS cancel_force
10634
+ `.execute(db);
10635
+ }
10636
+ //#endregion
10564
10637
  //#region src/db/migration-provider.ts
10565
10638
  function createMigrationProvider() {
10566
10639
  return { async getMigrations() {
@@ -10715,7 +10788,9 @@ function createMigrationProvider() {
10715
10788
  "148_cluster_settings_sealed_secrets_retry_backoff_ms": _148_cluster_settings_sealed_secrets_retry_backoff_ms_exports,
10716
10789
  "149_workflow_registrations_dep_cache_key": _149_workflow_registrations_dep_cache_key_exports,
10717
10790
  "150_execution_runs_status_epoch": _150_execution_runs_status_epoch_exports,
10718
- "151_workflow_registrations_dep_cache_key_sha": _151_workflow_registrations_dep_cache_key_sha_exports
10791
+ "151_workflow_registrations_dep_cache_key_sha": _151_workflow_registrations_dep_cache_key_sha_exports,
10792
+ "152_org_settings_cache_upload_settle_timeout": _152_org_settings_cache_upload_settle_timeout_exports,
10793
+ "153_execution_runs_cancel_force": _153_execution_runs_cancel_force_exports
10719
10794
  };
10720
10795
  } };
10721
10796
  }
@@ -10728,7 +10803,7 @@ function createMigrationProvider() {
10728
10803
  * migrations at a time, preventing conflicts in multi-instance deployments.
10729
10804
  */
10730
10805
  init_client();
10731
- const logger$23 = createLogger({ prefix: "migrate" });
10806
+ const logger$24 = createLogger({ prefix: "migrate" });
10732
10807
  const ADVISORY_LOCK_KEY = 543210001;
10733
10808
  /**
10734
10809
  * Wrap every migration's `up` so each one's own elapsed time is measured,
@@ -10775,9 +10850,9 @@ function describeMigrationFailure(message, migrationName) {
10775
10850
  async function runMigrations(opts) {
10776
10851
  const client = await opts.pool.connect();
10777
10852
  try {
10778
- logger$23.info("Acquiring migration lock...");
10853
+ logger$24.info("Acquiring migration lock...");
10779
10854
  await client.query("SELECT pg_advisory_lock($1)", [ADVISORY_LOCK_KEY]);
10780
- logger$23.info("Migration lock acquired");
10855
+ logger$24.info("Migration lock acquired");
10781
10856
  const elapsedMs = /* @__PURE__ */ new Map();
10782
10857
  const { results, error } = await new Migrator({
10783
10858
  db: opts.db,
@@ -10786,18 +10861,18 @@ async function runMigrations(opts) {
10786
10861
  for (const result of results ?? []) {
10787
10862
  const took = elapsedMs.get(result.migrationName);
10788
10863
  const suffix = took === void 0 ? "" : ` (${took}ms)`;
10789
- if (result.status === "Success") logger$23.info(`${result.migrationName} ... OK${suffix}`);
10790
- else if (result.status === "Error") logger$23.error(`${result.migrationName} ... FAILED${suffix}`);
10864
+ if (result.status === "Success") logger$24.info(`${result.migrationName} ... OK${suffix}`);
10865
+ else if (result.status === "Error") logger$24.error(`${result.migrationName} ... FAILED${suffix}`);
10791
10866
  }
10792
10867
  if (error) {
10793
10868
  const failed = (results ?? []).find((r) => r.status === "Error")?.migrationName;
10794
10869
  const described = describeMigrationFailure(error instanceof Error ? error.message : String(error), failed);
10795
- logger$23.error(described);
10870
+ logger$24.error(described);
10796
10871
  throw new Error(described, { cause: error });
10797
10872
  }
10798
10873
  const applied = (results ?? []).filter((r) => r.status === "Success");
10799
- if (applied.length === 0) logger$23.info("Database schema is up to date");
10800
- else logger$23.info(`Applied ${applied.length} migration(s)`);
10874
+ if (applied.length === 0) logger$24.info("Database schema is up to date");
10875
+ else logger$24.info(`Applied ${applied.length} migration(s)`);
10801
10876
  const hash = await computeMigrationsHash(createMigrationProvider());
10802
10877
  await storeMigrationContentHash(opts.pool, hash);
10803
10878
  return results ?? [];
@@ -10859,7 +10934,7 @@ var SamplingRateLimiter = class {
10859
10934
  //#endregion
10860
10935
  //#region src/audit/access-log.ts
10861
10936
  init_load_access_log_range();
10862
- const logger$22 = createLogger({ prefix: "access-log" });
10937
+ const logger$23 = createLogger({ prefix: "access-log" });
10863
10938
  /**
10864
10939
  * Best-effort writer for the orchestrator `access_log` table. Records one
10865
10940
  * row per read / orchestrator-admin mutation attributable to an
@@ -10892,7 +10967,7 @@ var AccessLogWriter = class {
10892
10967
  try {
10893
10968
  await this.insert(this.db, entry);
10894
10969
  } catch (err) {
10895
- logger$22.error("access_log record failed", {
10970
+ logger$23.error("access_log record failed", {
10896
10971
  error: toErrorMessage(err),
10897
10972
  action: entry.action,
10898
10973
  source: entry.source
@@ -11002,7 +11077,7 @@ var AccessLogWriter = class {
11002
11077
  fromTs: /* @__PURE__ */ new Date(0)
11003
11078
  })) if (String(row.id) === id) return toAccessLogItem(row);
11004
11079
  } catch (err) {
11005
- logger$22.warn("cold-store fetchRange failed for access-log getById", {
11080
+ logger$23.warn("cold-store fetchRange failed for access-log getById", {
11006
11081
  id,
11007
11082
  tenantId,
11008
11083
  error: toErrorMessage(err)
@@ -11029,7 +11104,7 @@ var AccessLogWriter = class {
11029
11104
  * down an admin command. This recorder inherits that contract.
11030
11105
  */
11031
11106
  init_client();
11032
- const logger$21 = createLogger({ prefix: "admin-cli-access-log" });
11107
+ const logger$22 = createLogger({ prefix: "admin-cli-access-log" });
11033
11108
  /**
11034
11109
  * The actor for a bare-metal CLI operator. There is no Keycloak sub on the
11035
11110
  * box, so we attribute to a service_account keyed on the OS identity — the
@@ -11063,7 +11138,7 @@ async function recordAdminCliAccessOnDb(db, entry) {
11063
11138
  meta: entry.meta
11064
11139
  });
11065
11140
  } catch (err) {
11066
- logger$21.warn("admin_cli access-log record failed", {
11141
+ logger$22.warn("admin_cli access-log record failed", {
11067
11142
  action: entry.action,
11068
11143
  error: toErrorMessage(err)
11069
11144
  });
@@ -14799,7 +14874,18 @@ const UniversalGitPayloadPathsSchema = z.object({
14799
14874
  * config written before this field stays valid; when unset, a `commitMessage`
14800
14875
  * trigger filter is INDETERMINATE and the workflow does not run.
14801
14876
  */
14802
- commitMessage: z.string().min(1).optional()
14877
+ commitMessage: z.string().min(1).optional(),
14878
+ /**
14879
+ * Path to the forge's total commit count on a push. When the total exceeds
14880
+ * the commits listed, the payload was truncated and its file list is not
14881
+ * authoritative.
14882
+ */
14883
+ commitsTotal: z.string().min(1).optional(),
14884
+ /**
14885
+ * The most commits the forge lists in a push payload, for a forge that sends
14886
+ * no total. A push listing this many may be truncated.
14887
+ */
14888
+ commitsCap: z.number().int().positive().optional()
14803
14889
  });
14804
14890
  /**
14805
14891
  * Header-to-event-name mapping. Most forges send an `X-Event-Type`-style
@@ -14899,7 +14985,8 @@ const UNIVERSAL_GIT_PRESETS = {
14899
14985
  commitsAdded: "$.commits[*].added[*]",
14900
14986
  commitsModified: "$.commits[*].modified[*]",
14901
14987
  commitsRemoved: "$.commits[*].removed[*]",
14902
- commitMessage: "$.head_commit.message"
14988
+ commitMessage: "$.head_commit.message",
14989
+ commitsTotal: "$.total_commits"
14903
14990
  },
14904
14991
  eventMapping: {
14905
14992
  push: ["push"],
@@ -14916,7 +15003,8 @@ const UNIVERSAL_GIT_PRESETS = {
14916
15003
  commitsAdded: "$.commits[*].added[*]",
14917
15004
  commitsModified: "$.commits[*].modified[*]",
14918
15005
  commitsRemoved: "$.commits[*].removed[*]",
14919
- commitMessage: "$.head_commit.message"
15006
+ commitMessage: "$.head_commit.message",
15007
+ commitsTotal: "$.total_commits"
14920
15008
  },
14921
15009
  eventMapping: {
14922
15010
  push: ["push"],
@@ -14950,7 +15038,8 @@ const UNIVERSAL_GIT_PRESETS = {
14950
15038
  commitsAdded: "$.commits[*].added[*]",
14951
15039
  commitsModified: "$.commits[*].modified[*]",
14952
15040
  commitsRemoved: "$.commits[*].removed[*]",
14953
- commitMessage: "$.commits[-1:].message"
15041
+ commitMessage: "$.commits[-1:].message",
15042
+ commitsTotal: "$.total_commits_count"
14954
15043
  },
14955
15044
  eventMapping: {
14956
15045
  push: ["Push Hook", "push"],
@@ -14967,7 +15056,8 @@ const UNIVERSAL_GIT_PRESETS = {
14967
15056
  commitsAdded: "$.commits[*].added[*]",
14968
15057
  commitsModified: "$.commits[*].modified[*]",
14969
15058
  commitsRemoved: "$.commits[*].removed[*]",
14970
- commitMessage: "$.head_commit.message"
15059
+ commitMessage: "$.head_commit.message",
15060
+ commitsCap: 2048
14971
15061
  },
14972
15062
  eventMapping: {
14973
15063
  push: ["push"],
@@ -15022,7 +15112,7 @@ const LocalSourceConfigSchema = z.object({
15022
15112
  * the generic_webhook_sources table. Each source defines verification method,
15023
15113
  * event type extraction rules, rate limits, and header filtering.
15024
15114
  */
15025
- const logger$20 = createLogger({ prefix: "generic-sources" });
15115
+ const logger$21 = createLogger({ prefix: "generic-sources" });
15026
15116
  /**
15027
15117
  * Generic webhook source manager.
15028
15118
  *
@@ -15075,7 +15165,7 @@ var GenericSourceManager = class {
15075
15165
  git_config: gitConfigJson
15076
15166
  };
15077
15167
  const result = await this.db.insertInto("generic_webhook_sources").values(row).returningAll().executeTakeFirstOrThrow();
15078
- logger$20.info("Generic webhook source created", {
15168
+ logger$21.info("Generic webhook source created", {
15079
15169
  id: result.id,
15080
15170
  orgId: input.orgId,
15081
15171
  name: input.name,
@@ -15185,7 +15275,7 @@ var GenericSourceManager = class {
15185
15275
  ...updates,
15186
15276
  updated_at: sql`now()`
15187
15277
  }).where("id", "=", id).where("deleted_at", "is", null).returningAll().executeTakeFirst();
15188
- if (result) logger$20.info("Generic webhook source updated", {
15278
+ if (result) logger$21.info("Generic webhook source updated", {
15189
15279
  id,
15190
15280
  fields: Object.keys(updates)
15191
15281
  });
@@ -15196,14 +15286,14 @@ var GenericSourceManager = class {
15196
15286
  */
15197
15287
  async softDelete(id) {
15198
15288
  await this.db.updateTable("generic_webhook_sources").set({ deleted_at: sql`now()` }).where("id", "=", id).where("deleted_at", "is", null).execute();
15199
- logger$20.info("Generic webhook source soft-deleted", { id });
15289
+ logger$21.info("Generic webhook source soft-deleted", { id });
15200
15290
  }
15201
15291
  /**
15202
15292
  * Hard delete a source (removes the row entirely).
15203
15293
  */
15204
15294
  async hardDelete(id) {
15205
15295
  await this.db.deleteFrom("generic_webhook_sources").where("id", "=", id).execute();
15206
- logger$20.info("Generic webhook source hard-deleted", { id });
15296
+ logger$21.info("Generic webhook source hard-deleted", { id });
15207
15297
  }
15208
15298
  /**
15209
15299
  * Enable a source.
@@ -15213,7 +15303,7 @@ var GenericSourceManager = class {
15213
15303
  enabled: true,
15214
15304
  updated_at: sql`now()`
15215
15305
  }).where("id", "=", id).where("deleted_at", "is", null).execute();
15216
- logger$20.info("Generic webhook source enabled", { id });
15306
+ logger$21.info("Generic webhook source enabled", { id });
15217
15307
  }
15218
15308
  /**
15219
15309
  * Disable a source.
@@ -15223,7 +15313,7 @@ var GenericSourceManager = class {
15223
15313
  enabled: false,
15224
15314
  updated_at: sql`now()`
15225
15315
  }).where("id", "=", id).where("deleted_at", "is", null).execute();
15226
- logger$20.info("Generic webhook source disabled", { id });
15316
+ logger$21.info("Generic webhook source disabled", { id });
15227
15317
  }
15228
15318
  /**
15229
15319
  * Check if a request is a duplicate within the dedup window.
@@ -15301,6 +15391,7 @@ createLogger({ prefix: "universal-git:clone-token" });
15301
15391
  function buildLocalTriggerRequest(input) {
15302
15392
  const body = JSON.stringify({
15303
15393
  ref: input.ref,
15394
+ ...input.before && { before: input.before },
15304
15395
  after: input.sha,
15305
15396
  repository: {
15306
15397
  full_name: input.repoFullName,
@@ -15336,6 +15427,28 @@ function readRepoHead(repoPath) {
15336
15427
  sha
15337
15428
  };
15338
15429
  }
15430
+ /** The parent of `sha` in a local repo, or undefined for a root commit or an unreadable repo. */
15431
+ function readParentSha(repoPath, sha) {
15432
+ try {
15433
+ return execFileSync("git", [
15434
+ "-C",
15435
+ repoPath,
15436
+ "rev-parse",
15437
+ "--verify",
15438
+ "--quiet",
15439
+ `${sha}^`
15440
+ ], {
15441
+ encoding: "utf8",
15442
+ stdio: [
15443
+ "ignore",
15444
+ "pipe",
15445
+ "ignore"
15446
+ ]
15447
+ }).trim() || void 0;
15448
+ } catch {
15449
+ return;
15450
+ }
15451
+ }
15339
15452
  /** POST the trigger request to the orchestrator base URL. Returns the HTTP status. */
15340
15453
  async function sendLocalTrigger(baseUrl, req) {
15341
15454
  return (await fetch(`${baseUrl.replace(/\/$/, "")}${req.path}`, {
@@ -15353,8 +15466,9 @@ async function sendLocalTrigger(baseUrl, req) {
15353
15466
  */
15354
15467
  /**
15355
15468
  * Render the post-receive hook script. For each pushed ref the hook calls
15356
- * `kici-admin source trigger-local <id> --ref <ref> --sha <new> --base-url <url>`,
15357
- * so a push to any branch dispatches a run for that ref.
15469
+ * `kici-admin source trigger-local <id> --ref <ref> --before <old> --sha <new> --base-url <url>`,
15470
+ * so a push to any branch dispatches a run for that ref, and its changed files
15471
+ * are the commits the push added (`<old>..<new>`).
15358
15472
  */
15359
15473
  function renderPostReceiveHook(opts) {
15360
15474
  return `#!/usr/bin/env bash
@@ -15362,7 +15476,7 @@ function renderPostReceiveHook(opts) {
15362
15476
  # Triggers a run for each pushed branch ref.
15363
15477
  set -euo pipefail
15364
15478
  while read -r _old _new ref; do
15365
- kici-admin source trigger-local ${opts.sourceId} --ref "$ref" --sha "$_new" --base-url ${opts.baseUrl}
15479
+ kici-admin source trigger-local ${opts.sourceId} --ref "$ref" --before "$_old" --sha "$_new" --base-url ${opts.baseUrl}
15366
15480
  done
15367
15481
  `;
15368
15482
  }
@@ -16617,7 +16731,7 @@ function registerSourceCommands(program, getClient) {
16617
16731
  process.exit(1);
16618
16732
  }
16619
16733
  });
16620
- src.command("trigger-local <id>").description("Trigger a run against a local source (reads HEAD when --ref/--sha omitted)").option("--event <event>", "push | pull_request", "push").option("--ref <ref>", "Git ref (default: repo HEAD branch)").option("--sha <sha>", "Commit SHA (default: repo HEAD)").option("--repo-full-name <name>", "owner/name identifier used in the payload", "local/repo").option("--base-url <url>", "Orchestrator base URL", DEFAULT_ORCH_URL).action(async (id, opts) => {
16734
+ src.command("trigger-local <id>").description("Trigger a run against a local source (reads HEAD when --ref/--sha omitted)").option("--event <event>", "push | pull_request", "push").option("--ref <ref>", "Git ref (default: repo HEAD branch)").option("--sha <sha>", "Commit SHA (default: repo HEAD)").option("--before <sha>", "Commit before the push; the changed files are before..sha (default: parent of --sha)").option("--repo-full-name <name>", "owner/name identifier used in the payload", "local/repo").option("--base-url <url>", "Orchestrator base URL", DEFAULT_ORCH_URL).action(async (id, opts) => {
16621
16735
  try {
16622
16736
  const { source } = await getClient().getGenericSource(id);
16623
16737
  const cfg = parseLocalConfig(source);
@@ -16638,6 +16752,7 @@ function registerSourceCommands(program, getClient) {
16638
16752
  event: opts.event === "pull_request" ? "pull_request" : "push",
16639
16753
  ref: head.ref,
16640
16754
  sha: head.sha,
16755
+ before: opts.before ?? readParentSha(cfg.repoBasePath, head.sha),
16641
16756
  defaultBranch: head.ref.replace("refs/heads/", "")
16642
16757
  });
16643
16758
  const status = await sendLocalTrigger(opts.baseUrl, req);
@@ -17489,6 +17604,7 @@ const baseSchema = z.object({
17489
17604
  reconnectReplayWindowHours: z.coerce.number().positive().default(24),
17490
17605
  cacheBuildTimeoutMs: z.coerce.number().default(6e5),
17491
17606
  cacheMaxTarballBytes: z.coerce.number().default(524288e3),
17607
+ cacheUploadSettleTimeoutMs: z.coerce.number().int().min(0).default(1e4),
17492
17608
  userCacheQuotaBytes: z.coerce.number().int().positive().default(5368709120).describe("Cluster-wide default per-org byte quota for the user-facing cache (ctx.cache). A per-org override in org_settings.user_cache_quota_bytes (set via `kici-admin org-settings user-cache set-quota`) takes precedence when present."),
17493
17609
  userCacheTtlMs: z.coerce.number().int().positive().default(6048e5).describe("Cluster-wide default per-entry TTL (ms) for the user-facing cache. A per-org override in org_settings.user_cache_ttl_ms (set via `kici-admin org-settings user-cache set-ttl`) takes precedence when present."),
17494
17610
  artifactQuotaBytes: z.coerce.number().int().positive().default(21474836480).describe("Cluster-wide default per-org byte quota for user-facing artifacts (ctx.artifacts). A per-org override in org_settings.artifact_quota_bytes (set via `kici-admin org-settings artifacts set-quota`) takes precedence when present."),
@@ -17737,6 +17853,7 @@ const envDef = defineEnv({
17737
17853
  reconnectReplayWindowHours: "KICI_ORCH_RECONNECT_REPLAY_WINDOW_HOURS",
17738
17854
  cacheBuildTimeoutMs: "KICI_CACHE_BUILD_TIMEOUT_MS",
17739
17855
  cacheMaxTarballBytes: "KICI_CACHE_MAX_TARBALL_BYTES",
17856
+ cacheUploadSettleTimeoutMs: "KICI_CACHE_UPLOAD_SETTLE_TIMEOUT_MS",
17740
17857
  userCacheQuotaBytes: "KICI_USER_CACHE_QUOTA_BYTES",
17741
17858
  userCacheTtlMs: "KICI_USER_CACHE_TTL_MS",
17742
17859
  artifactQuotaBytes: "KICI_ARTIFACT_QUOTA_BYTES",
@@ -18039,6 +18156,7 @@ function loadConfig(scope = ConfigScope.enum.runtime) {
18039
18156
  * TTL is enforced lazily: expired items are deleted on access.
18040
18157
  * Pre-signed URLs are generated for getUrl() with 15-minute expiry.
18041
18158
  */
18159
+ const logger$17 = createLogger({ prefix: "s3-cache" });
18042
18160
  /** Pre-signed download URL expiry in seconds (15 minutes) */
18043
18161
  const PRESIGNED_URL_EXPIRY_SECONDS = 900;
18044
18162
  /** Pre-signed upload URL expiry in seconds (30 minutes -- uploads take longer) */
@@ -18052,6 +18170,11 @@ var S3CacheStorage = class {
18052
18170
  bucket;
18053
18171
  prefix;
18054
18172
  ttlMs;
18173
+ /**
18174
+ * False once the backend answered a conditional self-copy with
18175
+ * `501 NotImplemented`. From then on `updateMeta` copies unconditionally.
18176
+ */
18177
+ conditionalCopySupported = true;
18055
18178
  constructor(options) {
18056
18179
  this.bucket = options.bucket;
18057
18180
  this.prefix = options.prefix;
@@ -18083,6 +18206,13 @@ var S3CacheStorage = class {
18083
18206
  * Returns null if the object doesn't exist (NoSuchKey/NotFound).
18084
18207
  */
18085
18208
  async readMeta(key) {
18209
+ return (await this.readHead(key))?.meta ?? null;
18210
+ }
18211
+ /**
18212
+ * Read an object's TTL metadata together with the ETag of the version it
18213
+ * belongs to. Returns null if the object doesn't exist (NoSuchKey/NotFound).
18214
+ */
18215
+ async readHead(key) {
18086
18216
  try {
18087
18217
  const head = await this.client.send(new HeadObjectCommand({
18088
18218
  Bucket: this.bucket,
@@ -18092,8 +18222,11 @@ var S3CacheStorage = class {
18092
18222
  const lastAccessedAt = head.Metadata?.["last-accessed-at"] ?? "";
18093
18223
  if (!createdAt || !lastAccessedAt) return null;
18094
18224
  return {
18095
- createdAt,
18096
- lastAccessedAt
18225
+ meta: {
18226
+ createdAt,
18227
+ lastAccessedAt
18228
+ },
18229
+ ...head.ETag && { etag: head.ETag }
18097
18230
  };
18098
18231
  } catch (err) {
18099
18232
  if (this.isNotFoundError(err)) return null;
@@ -18103,8 +18236,41 @@ var S3CacheStorage = class {
18103
18236
  /**
18104
18237
  * Update metadata on an S3 object by copying it to itself.
18105
18238
  * This is the standard S3 pattern for updating metadata without re-uploading data.
18239
+ *
18240
+ * The copy is conditional on `etag`, the version whose metadata the caller
18241
+ * read. A self-copy is a whole-object write: without the condition, one that
18242
+ * races a `put()` of the same key can land after it and write the older body
18243
+ * back. Cache pointers are rewritten in place while builds publish them, so a
18244
+ * touch-on-read racing a publish reverted the pointer to a tarball that no
18245
+ * longer exists. `CopySourceIfMatch` pins the bytes copied to that version and
18246
+ * `IfMatch` refuses the write unless the key still holds it.
18247
+ *
18248
+ * Returns false when the object was replaced since the read (`412`), or is
18249
+ * being replaced right now (`409 ConditionalRequestConflict`): the newer
18250
+ * write stamps metadata of its own, so there is nothing left to refresh.
18251
+ *
18252
+ * An S3-compatible backend that does not implement conditional copies
18253
+ * answers `501 NotImplemented`. The copy then runs again without the
18254
+ * condition, and later copies skip it, as on a backend that ignores the
18255
+ * headers.
18106
18256
  */
18107
- async updateMeta(key, meta) {
18257
+ async updateMeta(key, meta, etag) {
18258
+ const condition = this.conditionalCopySupported ? etag : void 0;
18259
+ try {
18260
+ await this.copyOntoItself(key, meta, condition);
18261
+ return true;
18262
+ } catch (err) {
18263
+ if (!condition) throw err;
18264
+ if (this.isPreconditionFailedError(err) || this.isConditionalConflictError(err)) return false;
18265
+ if (!this.isNotImplementedError(err)) throw err;
18266
+ this.conditionalCopySupported = false;
18267
+ logger$17.warn("The object store does not implement conditional copies; refreshing cache metadata unconditionally", { bucket: this.bucket });
18268
+ await this.copyOntoItself(key, meta, void 0);
18269
+ return true;
18270
+ }
18271
+ }
18272
+ /** Copy an object onto itself with new TTL metadata, conditional on `etag` when given. */
18273
+ async copyOntoItself(key, meta, etag) {
18108
18274
  const objectKey = this.objectKey(key);
18109
18275
  await this.client.send(new CopyObjectCommand({
18110
18276
  Bucket: this.bucket,
@@ -18114,9 +18280,30 @@ var S3CacheStorage = class {
18114
18280
  Metadata: {
18115
18281
  "created-at": meta.createdAt,
18116
18282
  "last-accessed-at": meta.lastAccessedAt
18283
+ },
18284
+ ...etag && {
18285
+ CopySourceIfMatch: etag,
18286
+ IfMatch: etag
18117
18287
  }
18118
18288
  }));
18119
18289
  }
18290
+ /** Check if an error is a failed conditional request (PreconditionFailed, 412). */
18291
+ isPreconditionFailedError(err) {
18292
+ return this.hasErrorShape(err, "PreconditionFailed", 412);
18293
+ }
18294
+ /** Check if an error is a conditional write that raced another write (ConditionalRequestConflict, 409). */
18295
+ isConditionalConflictError(err) {
18296
+ return this.hasErrorShape(err, "ConditionalRequestConflict", 409);
18297
+ }
18298
+ /** Check if an error is a request the backend does not implement (NotImplemented, 501). */
18299
+ isNotImplementedError(err) {
18300
+ return this.hasErrorShape(err, "NotImplemented", 501);
18301
+ }
18302
+ hasErrorShape(err, name, status) {
18303
+ if (typeof err !== "object" || err === null) return false;
18304
+ if (err.name === name) return true;
18305
+ return err.$metadata?.httpStatusCode === status;
18306
+ }
18120
18307
  /** Check if an error is a "not found" error (NoSuchKey, NotFound, 404). */
18121
18308
  isNotFoundError(err) {
18122
18309
  if (typeof err !== "object" || err === null) return false;
@@ -18141,8 +18328,9 @@ var S3CacheStorage = class {
18141
18328
  }).done();
18142
18329
  }
18143
18330
  async get(key, ttlMsOverride) {
18144
- const meta = await this.readMeta(key);
18145
- if (!meta) return null;
18331
+ const head = await this.readHead(key);
18332
+ if (!head) return null;
18333
+ const { meta, etag } = head;
18146
18334
  if (this.isExpired(meta, ttlMsOverride)) {
18147
18335
  await this.deleteObject(key);
18148
18336
  return null;
@@ -18161,7 +18349,7 @@ var S3CacheStorage = class {
18161
18349
  }
18162
18350
  try {
18163
18351
  meta.lastAccessedAt = (/* @__PURE__ */ new Date()).toISOString();
18164
- await this.updateMeta(key, meta);
18352
+ await this.updateMeta(key, meta, etag);
18165
18353
  } catch {}
18166
18354
  return data;
18167
18355
  }
@@ -18180,10 +18368,10 @@ var S3CacheStorage = class {
18180
18368
  return existed;
18181
18369
  }
18182
18370
  async touch(key) {
18183
- const meta = await this.readMeta(key);
18184
- if (!meta) return;
18185
- meta.lastAccessedAt = (/* @__PURE__ */ new Date()).toISOString();
18186
- await this.updateMeta(key, meta);
18371
+ const head = await this.readHead(key);
18372
+ if (!head) return;
18373
+ head.meta.lastAccessedAt = (/* @__PURE__ */ new Date()).toISOString();
18374
+ await this.updateMeta(key, head.meta, head.etag);
18187
18375
  }
18188
18376
  async getUrl(key, ttlMsOverride) {
18189
18377
  const meta = await this.readMeta(key);
@@ -23671,7 +23859,7 @@ init_manifest();
23671
23859
  const ALL_PLATFORMS = AgentPlatform.options;
23672
23860
  /** The orchestrator's own version (single-version invariant) = the packaged agent version. */
23673
23861
  function resolveKiciVersion() {
23674
- return "0.12.0";
23862
+ return "0.13.0";
23675
23863
  }
23676
23864
  /** Parse the --platform value: default set | single | CSV | `all`. */
23677
23865
  function parsePlatforms(raw) {
@@ -24406,7 +24594,8 @@ function silenceJoinTokenLogger() {
24406
24594
  }
24407
24595
  const TOKEN_PREFIX = "kici_join_v1";
24408
24596
  const DEFAULT_EXPIRY_MS = 36e5;
24409
- const TOKEN_ALREADY_USED_MESSAGE = "Join token has already been used. Generate a new token with: kici admin create-join-token";
24597
+ const TOKEN_ALREADY_USED_MESSAGE = "Join token has already been used. Create a new token with: kici-admin peer create-token";
24598
+ const TOKEN_EXPIRED_MESSAGE = "Join token has expired. Create a new token with: kici-admin peer create-token";
24410
24599
  var JoinTokenManager = class {
24411
24600
  deps;
24412
24601
  constructor(deps) {
@@ -24491,7 +24680,7 @@ var JoinTokenManager = class {
24491
24680
  }
24492
24681
  const row = await this.deps.db.selectFrom("join_tokens").selectAll().where("token_hash", "=", keys.validationHash).executeTakeFirst();
24493
24682
  if (!row) throw new Error("Invalid join token");
24494
- if (new Date(row.expires_at).getTime() <= Date.now()) throw new Error("Join token has expired. Generate a new token with: kici admin create-join-token");
24683
+ if (new Date(row.expires_at).getTime() <= Date.now()) throw new Error(TOKEN_EXPIRED_MESSAGE);
24495
24684
  if (row.consumed_at) {
24496
24685
  if (row.consumed_by_instance === peerInstanceId) {
24497
24686
  joinTokenLogger.info("Re-validated join token for returning instance", {
@@ -24548,18 +24737,12 @@ function decryptBundle(data, encryptionKey) {
24548
24737
  const decrypted = Buffer.concat([decipher.update(ciphertext), decipher.final()]);
24549
24738
  return JSON.parse(decrypted.toString("utf-8"));
24550
24739
  }
24551
- //#endregion
24552
- //#region src/cluster/peer-credentials.ts
24553
24740
  /**
24554
- * Peer credential management for cluster authentication.
24555
- *
24556
- * Provides two persistence layers:
24557
- * 1. DB CRUD (PeerCredentialStore) — coordinator stores credentials for all peers
24558
- * 2. File I/O (readCredentialFile/writeCredentialFile) — workers persist their
24559
- * credential locally for reconnection after restart
24560
- *
24561
- * Credential files are written with 0600 permissions to protect the secret.
24741
+ * `metadata` key set when a coordinator retires the self-issued credential its
24742
+ * previous run left behind. An operator revoke never sets it, which is how a
24743
+ * retirement is told apart from a revoke.
24562
24744
  */
24745
+ const RETIRED_BY_INSTANCE_KEY = "retiredByInstance";
24563
24746
  /** Default credential expiry: 90 days. */
24564
24747
  const DEFAULT_EXPIRY_DAYS = 90;
24565
24748
  /**
@@ -24596,7 +24779,8 @@ var PeerCredentialStore = class {
24596
24779
  role: opts.role,
24597
24780
  routing_keys: sql`${sql.val(opts.routingKeys)}`,
24598
24781
  source_token_hash: opts.sourceTokenHash ?? null,
24599
- expires_at: expiresAt
24782
+ expires_at: expiresAt,
24783
+ ...opts.metadata && { metadata: sql`${JSON.stringify(opts.metadata)}::jsonb` }
24600
24784
  }).execute();
24601
24785
  return Number(revokeResult?.numUpdatedRows ?? 0n);
24602
24786
  });
@@ -24623,6 +24807,33 @@ var PeerCredentialStore = class {
24623
24807
  return row ? mapRow(row) : null;
24624
24808
  }
24625
24809
  /**
24810
+ * The credential row for `instanceId` that nobody revoked, expired or not.
24811
+ * `peer_credentials_active_uniq` allows at most one.
24812
+ */
24813
+ async findUnrevokedByInstanceId(instanceId) {
24814
+ const row = await this.db.selectFrom("peer_credentials").selectAll().where("instance_id", "=", instanceId).where("revoked_at", "is", null).executeTakeFirst();
24815
+ return row ? mapRow(row) : null;
24816
+ }
24817
+ /** The most recently revoked credential row for `instanceId`, or null. */
24818
+ async findLatestRevokedByInstanceId(instanceId) {
24819
+ const row = await this.db.selectFrom("peer_credentials").selectAll().where("instance_id", "=", instanceId).where("revoked_at", "is not", null).orderBy("revoked_at", "desc").executeTakeFirst();
24820
+ return row ? mapRow(row) : null;
24821
+ }
24822
+ /**
24823
+ * Revoke `instanceId`'s unrevoked, self-issued row whose hash is
24824
+ * `credentialHash`, recording who retired it. Every condition sits in the
24825
+ * WHERE clause, so a row that changed meanwhile is left alone.
24826
+ * Returns whether a row was retired.
24827
+ */
24828
+ async retireSelfIssued(opts) {
24829
+ const marker = JSON.stringify({ [RETIRED_BY_INSTANCE_KEY]: opts.retiredByInstance });
24830
+ const result = await this.db.updateTable("peer_credentials").set({
24831
+ revoked_at: /* @__PURE__ */ new Date(),
24832
+ metadata: sql`COALESCE(metadata, '{}'::jsonb) || ${marker}::jsonb`
24833
+ }).where("instance_id", "=", opts.instanceId).where("credential_hash", "=", opts.credentialHash).where("revoked_at", "is", null).where(sql`metadata->>'issuance'`, "=", "self").executeTakeFirst();
24834
+ return Number(result?.numUpdatedRows ?? 0n) > 0;
24835
+ }
24836
+ /**
24626
24837
  * Update the last_seen_at timestamp for a credential.
24627
24838
  * Optionally records which coordinator validated it.
24628
24839
  */
@@ -24667,7 +24878,8 @@ function mapRow(row) {
24667
24878
  lastSeenAt: row.last_seen_at ? new Date(row.last_seen_at) : null,
24668
24879
  lastValidatedBy: row.last_validated_by ?? null,
24669
24880
  expiresAt: new Date(row.expires_at),
24670
- revokedAt: row.revoked_at ? new Date(row.revoked_at) : null
24881
+ revokedAt: row.revoked_at ? new Date(row.revoked_at) : null,
24882
+ metadata: row.metadata ?? {}
24671
24883
  };
24672
24884
  }
24673
24885
  //#endregion
@@ -24691,6 +24903,23 @@ function formatPeerTable(peers) {
24691
24903
  })
24692
24904
  ].join("\n");
24693
24905
  }
24906
+ /**
24907
+ * The `peer list --json` record. The credential hash is the HMAC key of every
24908
+ * proof, so it, the source-token hash and the raw metadata never leave the
24909
+ * database.
24910
+ */
24911
+ function toPeerListEntry(p) {
24912
+ return {
24913
+ id: p.id,
24914
+ instanceId: p.instanceId,
24915
+ role: p.role,
24916
+ selfIssued: p.metadata?.issuance === "self",
24917
+ createdAt: p.createdAt.toISOString(),
24918
+ lastSeenAt: p.lastSeenAt ? p.lastSeenAt.toISOString() : null,
24919
+ lastValidatedBy: p.lastValidatedBy,
24920
+ expiresAt: p.expiresAt.toISOString()
24921
+ };
24922
+ }
24694
24923
  function registerPeerCommands(program, _getClient) {
24695
24924
  const peer = program.command("peer").description("Manage peer tokens and credentials");
24696
24925
  peer.command("create-token").description("Create a join token for a new peer").option("--role <role>", "Peer role (worker or coordinator)", "coordinator").option("--expiry-hours <hours>", "Token expiry in hours", "1").option("--org-id <id>", "Organization ID", "default").option("--routing-key <key>", "Routing key", "default").option("--created-by <actor>", "Attribution written to join_tokens.created_by", "cli").option("--json", "Emit JSON { token, role, expiresAt, orgId, routingKey } on stdout", false).action(async (opts) => {
@@ -24736,11 +24965,15 @@ function registerPeerCommands(program, _getClient) {
24736
24965
  process.exit(1);
24737
24966
  }
24738
24967
  });
24739
- peer.command("list").description("List active peer credentials").action(async () => {
24968
+ peer.command("list").description("List active peer credentials").option("--json", "Emit JSON { peers: [{ id, instanceId, role, selfIssued, createdAt, lastSeenAt, lastValidatedBy, expiresAt }] } on stdout", false).action(async (opts) => {
24740
24969
  try {
24741
24970
  const peers = await withDb(async (db) => {
24742
24971
  return new PeerCredentialStore(db).listActive();
24743
24972
  });
24973
+ if (opts.json) {
24974
+ console.log(JSON.stringify({ peers: peers.map(toPeerListEntry) }, null, 2));
24975
+ return;
24976
+ }
24744
24977
  console.log(formatPeerTable(peers));
24745
24978
  } catch (err) {
24746
24979
  console.error(`Error: ${toErrorMessage(err)}`);
@@ -24752,7 +24985,7 @@ function registerPeerCommands(program, _getClient) {
24752
24985
  await withDb(async (db) => {
24753
24986
  await new PeerCredentialStore(db).revoke(opts.instanceId);
24754
24987
  });
24755
- console.log(`Peer ${opts.instanceId} credential revoked. It will be disconnected on next heartbeat.`);
24988
+ console.log(`Peer ${opts.instanceId} credential revoked. Its next connection attempt is refused; its open connections stay up.`);
24756
24989
  } catch (err) {
24757
24990
  console.error(`Error: ${toErrorMessage(err)}`);
24758
24991
  process.exit(1);
@@ -25362,6 +25595,7 @@ function formatSettings$1(s, format) {
25362
25595
  lines.push(`Reroute max hops: ${s.rerouteMaxHops === null ? "(cluster default)" : `${s.rerouteMaxHops}`}`);
25363
25596
  lines.push(`Backup staleness warn: ${s.backupStalenessWarnHours === null ? "(cluster default)" : `${s.backupStalenessWarnHours} h`}`);
25364
25597
  lines.push(`Queue timeout: ${s.queueTimeoutMs === null ? "(cluster default)" : `${s.queueTimeoutMs} ms`}`);
25598
+ lines.push(`Cache upload settle: ${s.cacheUploadSettleTimeoutMs == null ? "(cluster default)" : `${s.cacheUploadSettleTimeoutMs} ms`}`);
25365
25599
  lines.push(`Approval expiry: ${s.approvalExpirySeconds} s`);
25366
25600
  lines.push(`Allow self-approval: ${s.allowSelfApproval}`);
25367
25601
  const sandboxCaps = s.sandboxAllowedCapabilities ?? [];
@@ -25449,6 +25683,7 @@ function registerOrgSettingsCommands(program, getClient) {
25449
25683
  registerRerouteCommands(orgSettings, getClient);
25450
25684
  registerBackupFreshnessCommands(orgSettings, getClient);
25451
25685
  registerQueueTimeoutCommands(orgSettings, getClient);
25686
+ registerCacheUploadSettleCommands(orgSettings, getClient);
25452
25687
  registerApprovalCommands(orgSettings, getClient);
25453
25688
  }
25454
25689
  /**
@@ -25602,6 +25837,54 @@ function registerQueueTimeoutCommands(orgSettings, getClient) {
25602
25837
  }
25603
25838
  });
25604
25839
  }
25840
+ /**
25841
+ * `kici-admin org-settings cache-upload-settle <show|set|reset>`.
25842
+ *
25843
+ * The per-org bound (`org_settings.cache_upload_settle_timeout_ms`) on how long
25844
+ * a build job's success waits for the cache publish its agent reported just
25845
+ * before it. null clears the override → cluster default; `set 0` turns the
25846
+ * wait off.
25847
+ */
25848
+ function registerCacheUploadSettleCommands(orgSettings, getClient) {
25849
+ const cs = orgSettings.command("cache-upload-settle").description("Manage how long a build success waits for its cache upload to publish (null = cluster default)");
25850
+ cs.command("show").description("Print the current per-org cache upload settle timeout").option("--customer-id <id>", "Customer / org id (alias: --org)").option("--org <id>", "Alias for --customer-id").option("--format <format>", "Output format: json|table", "table").action(async (opts) => {
25851
+ const customerId = resolveCustomerId(opts);
25852
+ try {
25853
+ const settings = await fetchSettings$1(getClient(), customerId);
25854
+ console.log(formatSettings$1(settings, opts.format));
25855
+ } catch (err) {
25856
+ console.error(`Error: ${toErrorMessage(err)}`);
25857
+ process.exit(1);
25858
+ }
25859
+ });
25860
+ cs.command("set").description("Set the per-org cache upload settle timeout in milliseconds (0 = no wait)").argument("<ms>", "Settle timeout in milliseconds (integer >= 0)").option("--customer-id <id>", "Customer / org id (alias: --org)").option("--org <id>", "Alias for --customer-id").option("--format <format>", "Output format: json|table", "table").action(async (ms, opts) => {
25861
+ const customerId = resolveCustomerId(opts);
25862
+ const cacheUploadSettleTimeoutMs = parseIntFlag(ms, 0, "ms (milliseconds)");
25863
+ try {
25864
+ const updated = await patchSettings$1(getClient(), {
25865
+ customerId,
25866
+ cacheUploadSettleTimeoutMs
25867
+ });
25868
+ console.log(formatSettings$1(updated, opts.format));
25869
+ } catch (err) {
25870
+ console.error(`Error: ${toErrorMessage(err)}`);
25871
+ process.exit(1);
25872
+ }
25873
+ });
25874
+ cs.command("reset").description("Clear the per-org cache upload settle override (fall back to the cluster default)").option("--customer-id <id>", "Customer / org id (alias: --org)").option("--org <id>", "Alias for --customer-id").option("--format <format>", "Output format: json|table", "table").action(async (opts) => {
25875
+ const customerId = resolveCustomerId(opts);
25876
+ try {
25877
+ const updated = await patchSettings$1(getClient(), {
25878
+ customerId,
25879
+ cacheUploadSettleTimeoutMs: null
25880
+ });
25881
+ console.log(formatSettings$1(updated, opts.format));
25882
+ } catch (err) {
25883
+ console.error(`Error: ${toErrorMessage(err)}`);
25884
+ process.exit(1);
25885
+ }
25886
+ });
25887
+ }
25605
25888
  /** Parse an integer CLI flag with a minimum, exiting with an error on failure. */
25606
25889
  function parseIntFlag(value, min, fieldLabel) {
25607
25890
  const n = Number(value);
@@ -33956,6 +34239,18 @@ function buildAgentContainerHostConfig(input) {
33956
34239
  };
33957
34240
  }
33958
34241
  //#endregion
34242
+ //#region src/scaler/container-runtime.ts
34243
+ /**
34244
+ * The container runtime behind a configured socket path.
34245
+ *
34246
+ * A path containing `podman` is Podman; any other path is Docker. The container
34247
+ * backend reads a configured `socketPath` this way, and the runtime it picks
34248
+ * only labels the agents' log source and the scaler diagnostics.
34249
+ */
34250
+ function containerRuntimeForSocketPath(socketPath) {
34251
+ return socketPath.includes("podman") ? "podman" : "docker";
34252
+ }
34253
+ //#endregion
33959
34254
  //#region src/scaler/container-backend.ts
33960
34255
  /**
33961
34256
  * Container scaler backend implementation.
@@ -34187,7 +34482,7 @@ var ContainerScalerBackend = class ContainerScalerBackend {
34187
34482
  const runtime = options.runtime === "podman" ? "podman" : "docker";
34188
34483
  backend = new ContainerScalerBackend(options, "", runtime);
34189
34484
  } else if (options.socketPath) {
34190
- const runtime = options.socketPath.includes("podman") ? "podman" : "docker";
34485
+ const runtime = containerRuntimeForSocketPath(options.socketPath);
34191
34486
  logger$1.info(`Using configured socket at ${options.socketPath}`, { runtime });
34192
34487
  backend = new ContainerScalerBackend(options, options.socketPath, runtime);
34193
34488
  } else {
@@ -34502,24 +34797,29 @@ var ContainerScalerBackend = class ContainerScalerBackend {
34502
34797
  all: true,
34503
34798
  filters: { label: ["kici-managed=true", `kici-scaler-name=${this.name}`] }
34504
34799
  });
34505
- let cleaned = 0;
34506
34800
  const liveIps = new Set(this.containerIps.values());
34507
- for (const info of containers) {
34801
+ const orphans = containers.filter((info) => {
34508
34802
  const agentId = info.Labels?.["kici-agent-id"];
34509
- if (agentId && this.agents.has(agentId)) continue;
34510
- if (info.State === "running" && (!agentId || this.isRegistered(agentId))) continue;
34511
- const container = this.docker.getContainer(info.Id);
34512
- try {
34513
- await container.stop({ t: 5 });
34514
- } catch {}
34515
- try {
34516
- await container.remove({ force: true });
34517
- cleaned++;
34518
- } catch {}
34519
- }
34803
+ if (agentId && this.agents.has(agentId)) return false;
34804
+ return !(info.State === "running" && (!agentId || this.isRegistered(agentId)));
34805
+ });
34806
+ let cleaned = (await Promise.all(orphans.map((info) => this.removeOrphan(info.Id)))).filter(Boolean).length;
34520
34807
  cleaned += await this.reapUnownedIsolationRules(liveIps);
34521
34808
  return cleaned;
34522
34809
  }
34810
+ /** Stop and remove one orphaned agent container; true when it was removed. */
34811
+ async removeOrphan(containerId) {
34812
+ const container = this.docker.getContainer(containerId);
34813
+ try {
34814
+ await container.stop({ t: 5 });
34815
+ } catch {}
34816
+ try {
34817
+ await container.remove({ force: true });
34818
+ return true;
34819
+ } catch {
34820
+ return false;
34821
+ }
34822
+ }
34523
34823
  /**
34524
34824
  * Remove containers this backend spawned for one agent id.
34525
34825
  *
@@ -35064,7 +35364,7 @@ Token vocabulary:
35064
35364
  * where no bundler substituted the constant — the same shape `server.ts` and
35065
35365
  * `standalone.ts` use for `ORCHESTRATOR_VERSION`.
35066
35366
  */
35067
- const CLI_VERSION = "0.12.0";
35367
+ const CLI_VERSION = "0.13.0";
35068
35368
  /**
35069
35369
  * Build the kici-admin Commander program with every command group registered.
35070
35370
  * Exported so the surface registry can walk the real command tree without