@kici-dev/orchestrator 0.19.0 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -1874,8 +1874,8 @@ var init_client = __esmMin((() => {
1874
1874
  //#region src/db/migrations/001_initial.ts
1875
1875
  init_client();
1876
1876
  var _001_initial_exports = /* @__PURE__ */ __exportAll({
1877
- down: () => down$158,
1878
- up: () => up$158
1877
+ down: () => down$159,
1878
+ up: () => up$159
1879
1879
  });
1880
1880
  /**
1881
1881
  * Squashed initial migration: the complete Orchestrator baseline schema, replacing the original
@@ -2559,7 +2559,7 @@ const DDL_STATEMENTS = [
2559
2559
  `ALTER TABLE ONLY public.held_runs
2560
2560
  ADD CONSTRAINT held_runs_environment_id_fkey FOREIGN KEY (environment_id) REFERENCES public.environments(id);`
2561
2561
  ];
2562
- async function up$158(db) {
2562
+ async function up$159(db) {
2563
2563
  for (const stmt of DDL_STATEMENTS) await sql.raw(stmt).execute(db);
2564
2564
  await sql`
2565
2565
  INSERT INTO cluster_meta (key, value)
@@ -2578,7 +2578,7 @@ async function up$158(db) {
2578
2578
  `.execute(db);
2579
2579
  }
2580
2580
  /** Drops everything `up` created; CASCADE cuts the FK graph without a topological order. */
2581
- async function down$158(db) {
2581
+ async function down$159(db) {
2582
2582
  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);
2583
2583
  for (const table of [
2584
2584
  "workflow_registrations",
@@ -2625,8 +2625,8 @@ async function down$158(db) {
2625
2625
  //#endregion
2626
2626
  //#region src/db/migrations/002_config_versions_key_version.ts
2627
2627
  var _002_config_versions_key_version_exports = /* @__PURE__ */ __exportAll({
2628
- down: () => down$157,
2629
- up: () => up$157
2628
+ down: () => down$158,
2629
+ up: () => up$158
2630
2630
  });
2631
2631
  /**
2632
2632
  * `config_versions.key_version`, so `kici-admin rotate-key` can rotate sensitive-field encryption.
@@ -2637,13 +2637,13 @@ var _002_config_versions_key_version_exports = /* @__PURE__ */ __exportAll({
2637
2637
  *
2638
2638
  * No index: rotation full-scans; reads go by the `version` primary key.
2639
2639
  */
2640
- async function up$157(db) {
2640
+ async function up$158(db) {
2641
2641
  await sql`
2642
2642
  ALTER TABLE public.config_versions
2643
2643
  ADD COLUMN key_version integer NOT NULL DEFAULT 1
2644
2644
  `.execute(db);
2645
2645
  }
2646
- async function down$157(db) {
2646
+ async function down$158(db) {
2647
2647
  await sql`
2648
2648
  ALTER TABLE public.config_versions
2649
2649
  DROP COLUMN key_version
@@ -2652,8 +2652,8 @@ async function down$157(db) {
2652
2652
  //#endregion
2653
2653
  //#region src/db/migrations/003_access_log.ts
2654
2654
  var _003_access_log_exports = /* @__PURE__ */ __exportAll({
2655
- down: () => down$156,
2656
- up: () => up$156
2655
+ down: () => down$157,
2656
+ up: () => up$157
2657
2657
  });
2658
2658
  /**
2659
2659
  * Access log: one row per read or orchestrator-admin mutation attributable
@@ -2672,7 +2672,7 @@ var _003_access_log_exports = /* @__PURE__ */ __exportAll({
2672
2672
  *
2673
2673
  * Retention is TTL-based via expires_at; queue/cleanup.ts prunes.
2674
2674
  */
2675
- async function up$156(db) {
2675
+ async function up$157(db) {
2676
2676
  await sql`
2677
2677
  CREATE TABLE public.access_log (
2678
2678
  id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
@@ -2710,28 +2710,28 @@ async function up$156(db) {
2710
2710
  ON public.access_log (actor_type, actor_id, created_at DESC)
2711
2711
  `.execute(db);
2712
2712
  }
2713
- async function down$156(db) {
2713
+ async function down$157(db) {
2714
2714
  await sql`DROP TABLE IF EXISTS public.access_log`.execute(db);
2715
2715
  }
2716
2716
  //#endregion
2717
2717
  //#region src/db/migrations/004_rename_bundle_to_source.ts
2718
2718
  var _004_rename_bundle_to_source_exports = /* @__PURE__ */ __exportAll({
2719
- down: () => down$155,
2720
- up: () => up$155
2719
+ down: () => down$156,
2720
+ up: () => up$156
2721
2721
  });
2722
- async function up$155(db) {
2722
+ async function up$156(db) {
2723
2723
  await db.schema.alterTable("dispatch_queue").renameColumn("bundle_url", "source_tar_url").execute();
2724
2724
  await db.schema.alterTable("dispatch_queue").renameColumn("bundle_hash", "source_tar_hash").execute();
2725
2725
  }
2726
- async function down$155(db) {
2726
+ async function down$156(db) {
2727
2727
  await db.schema.alterTable("dispatch_queue").renameColumn("source_tar_url", "bundle_url").execute();
2728
2728
  await db.schema.alterTable("dispatch_queue").renameColumn("source_tar_hash", "bundle_hash").execute();
2729
2729
  }
2730
2730
  //#endregion
2731
2731
  //#region src/db/migrations/005_cold_store_chunk_counter.ts
2732
2732
  var _005_cold_store_chunk_counter_exports = /* @__PURE__ */ __exportAll({
2733
- down: () => down$154,
2734
- up: () => up$154
2733
+ down: () => down$155,
2734
+ up: () => up$155
2735
2735
  });
2736
2736
  /**
2737
2737
  * Per-(db, table, tenant) archived-chunk totals, so the `cold_store_chunks_total` gauge and
@@ -2740,7 +2740,7 @@ var _005_cold_store_chunk_counter_exports = /* @__PURE__ */ __exportAll({
2740
2740
  * Starts empty; the archiver upserts it in the same transaction as every successful chunk
2741
2741
  * write (`INSERT ... ON CONFLICT (db, table_name, tenant_id) DO UPDATE ...`).
2742
2742
  */
2743
- async function up$154(db) {
2743
+ async function up$155(db) {
2744
2744
  await sql`
2745
2745
  CREATE TABLE public.cold_store_chunk_counts (
2746
2746
  db TEXT NOT NULL,
@@ -2758,14 +2758,14 @@ async function up$154(db) {
2758
2758
  ON public.cold_store_chunk_counts (db, table_name)
2759
2759
  `.execute(db);
2760
2760
  }
2761
- async function down$154(db) {
2761
+ async function down$155(db) {
2762
2762
  await sql`DROP TABLE IF EXISTS public.cold_store_chunk_counts`.execute(db);
2763
2763
  }
2764
2764
  //#endregion
2765
2765
  //#region src/db/migrations/006_runs_jobs_steps_archived_at.ts
2766
2766
  var _006_runs_jobs_steps_archived_at_exports = /* @__PURE__ */ __exportAll({
2767
- down: () => down$153,
2768
- up: () => up$153
2767
+ down: () => down$154,
2768
+ up: () => up$154
2769
2769
  });
2770
2770
  /**
2771
2771
  * Cold-store columns for `execution_runs` / `execution_jobs` / `execution_steps`.
@@ -2781,7 +2781,7 @@ var _006_runs_jobs_steps_archived_at_exports = /* @__PURE__ */ __exportAll({
2781
2781
  * The `(routing_key, created_at)` indexes serve the archiver's `listEligiblePartitions` query
2782
2782
  * (`GROUP BY routing_key, DATE(created_at)`).
2783
2783
  */
2784
- async function up$153(db) {
2784
+ async function up$154(db) {
2785
2785
  await sql`
2786
2786
  ALTER TABLE public.execution_runs
2787
2787
  ADD COLUMN archived_at TIMESTAMPTZ NULL,
@@ -2826,7 +2826,7 @@ async function up$153(db) {
2826
2826
  ON public.execution_steps (routing_key, created_at)
2827
2827
  `.execute(db);
2828
2828
  }
2829
- async function down$153(db) {
2829
+ async function down$154(db) {
2830
2830
  await sql`DROP INDEX IF EXISTS public.idx_execution_steps_routing_key_created`.execute(db);
2831
2831
  await sql`
2832
2832
  ALTER TABLE public.execution_steps
@@ -2851,8 +2851,8 @@ async function down$153(db) {
2851
2851
  //#endregion
2852
2852
  //#region src/db/migrations/007_audit_logs_archived_at.ts
2853
2853
  var _007_audit_logs_archived_at_exports = /* @__PURE__ */ __exportAll({
2854
- down: () => down$152,
2855
- up: () => up$152
2854
+ down: () => down$153,
2855
+ up: () => up$153
2856
2856
  });
2857
2857
  /**
2858
2858
  * Cold-store columns for `secret_audit_log` and `access_log`, and removal of `access_log`'s
@@ -2870,7 +2870,7 @@ var _007_audit_logs_archived_at_exports = /* @__PURE__ */ __exportAll({
2870
2870
  * contract. `down()` recreates it with a `now() + 90 days` default, best effort: rows inserted
2871
2871
  * after `up()` get no meaningful retention bound.
2872
2872
  */
2873
- async function up$152(db) {
2873
+ async function up$153(db) {
2874
2874
  await sql`
2875
2875
  ALTER TABLE public.secret_audit_log
2876
2876
  ADD COLUMN archived_at TIMESTAMPTZ NULL,
@@ -2891,7 +2891,7 @@ async function up$152(db) {
2891
2891
  DROP COLUMN IF EXISTS expires_at
2892
2892
  `.execute(db);
2893
2893
  }
2894
- async function down$152(db) {
2894
+ async function down$153(db) {
2895
2895
  await sql`
2896
2896
  ALTER TABLE public.access_log
2897
2897
  ADD COLUMN expires_at TIMESTAMPTZ NOT NULL DEFAULT (now() + INTERVAL '90 days')
@@ -2919,8 +2919,8 @@ async function down$152(db) {
2919
2919
  //#endregion
2920
2920
  //#region src/db/migrations/008_event_log_archived_at.ts
2921
2921
  var _008_event_log_archived_at_exports = /* @__PURE__ */ __exportAll({
2922
- down: () => down$151,
2923
- up: () => up$151
2922
+ down: () => down$152,
2923
+ up: () => up$152
2924
2924
  });
2925
2925
  /**
2926
2926
  * `event_log` cold-store schema: adds the `archived_at` /
@@ -2941,7 +2941,7 @@ var _008_event_log_archived_at_exports = /* @__PURE__ */ __exportAll({
2941
2941
  * effort; rows inserted between `up()` and `down()` get no meaningful
2942
2942
  * retention bound.
2943
2943
  */
2944
- async function up$151(db) {
2944
+ async function up$152(db) {
2945
2945
  await sql`
2946
2946
  ALTER TABLE public.event_log
2947
2947
  ADD COLUMN archived_at TIMESTAMPTZ NULL,
@@ -2957,7 +2957,7 @@ async function up$151(db) {
2957
2957
  DROP COLUMN IF EXISTS expires_at
2958
2958
  `.execute(db);
2959
2959
  }
2960
- async function down$151(db) {
2960
+ async function down$152(db) {
2961
2961
  await sql`
2962
2962
  ALTER TABLE public.event_log
2963
2963
  ADD COLUMN expires_at TIMESTAMPTZ NOT NULL DEFAULT (now() + INTERVAL '30 days')
@@ -2976,8 +2976,8 @@ async function down$151(db) {
2976
2976
  //#endregion
2977
2977
  //#region src/db/migrations/009_access_log_trigram.ts
2978
2978
  var _009_access_log_trigram_exports = /* @__PURE__ */ __exportAll({
2979
- down: () => down$150,
2980
- up: () => up$150
2979
+ down: () => down$151,
2980
+ up: () => up$151
2981
2981
  });
2982
2982
  /**
2983
2983
  * pg_trgm index on access_log.error_message for the Activity page's `q` search; matches the
@@ -2986,7 +2986,7 @@ var _009_access_log_trigram_exports = /* @__PURE__ */ __exportAll({
2986
2986
  * Idempotent. No CONCURRENTLY because Kysely runs migrations inside a transaction; the lock is
2987
2987
  * brief on a sampled table.
2988
2988
  */
2989
- async function up$150(db) {
2989
+ async function up$151(db) {
2990
2990
  await sql`CREATE EXTENSION IF NOT EXISTS pg_trgm`.execute(db);
2991
2991
  await sql`
2992
2992
  CREATE INDEX IF NOT EXISTS access_log_error_message_trgm_idx
@@ -2995,14 +2995,14 @@ async function up$150(db) {
2995
2995
  WHERE error_message IS NOT NULL
2996
2996
  `.execute(db);
2997
2997
  }
2998
- async function down$150(db) {
2998
+ async function down$151(db) {
2999
2999
  await sql`DROP INDEX IF EXISTS public.access_log_error_message_trgm_idx`.execute(db);
3000
3000
  }
3001
3001
  //#endregion
3002
3002
  //#region src/db/migrations/010_cold_store_chunks.ts
3003
3003
  var _010_cold_store_chunks_exports = /* @__PURE__ */ __exportAll({
3004
- down: () => down$149,
3005
- up: () => up$149
3004
+ down: () => down$150,
3005
+ up: () => up$150
3006
3006
  });
3007
3007
  /**
3008
3008
  * Cold-store chunk index: one row per archived chunk the GC sweep can later
@@ -3024,7 +3024,7 @@ var _010_cold_store_chunks_exports = /* @__PURE__ */ __exportAll({
3024
3024
  * V1-manifest chunks are NOT here — they live forever — nor are chunks from
3025
3025
  * adapters that do not opt into per-bucket archival via `coldTtlDays`.
3026
3026
  */
3027
- async function up$149(db) {
3027
+ async function up$150(db) {
3028
3028
  await sql`
3029
3029
  CREATE TABLE public.cold_store_chunks (
3030
3030
  db TEXT NOT NULL,
@@ -3051,14 +3051,14 @@ async function up$149(db) {
3051
3051
  ON public.cold_store_chunks (db, table_name, tenant_id, archived_at DESC)
3052
3052
  `.execute(db);
3053
3053
  }
3054
- async function down$149(db) {
3054
+ async function down$150(db) {
3055
3055
  await sql`DROP TABLE IF EXISTS public.cold_store_chunks`.execute(db);
3056
3056
  }
3057
3057
  //#endregion
3058
3058
  //#region src/db/migrations/011_drop_source_secrets_notify.ts
3059
3059
  var _011_drop_source_secrets_notify_exports = /* @__PURE__ */ __exportAll({
3060
- down: () => down$148,
3061
- up: () => up$148
3060
+ down: () => down$149,
3061
+ up: () => up$149
3062
3062
  });
3063
3063
  /**
3064
3064
  * Drops `source_secrets_change_trigger` and `notify_source_secrets_change()`. Their only
@@ -3069,11 +3069,11 @@ var _011_drop_source_secrets_notify_exports = /* @__PURE__ */ __exportAll({
3069
3069
  * `down` re-creates both as defined in `001_initial.ts`; they wake no consumer, so the
3070
3070
  * rollback is safe.
3071
3071
  */
3072
- async function up$148(db) {
3072
+ async function up$149(db) {
3073
3073
  await sql`DROP TRIGGER IF EXISTS source_secrets_change_trigger ON public.scoped_secrets`.execute(db);
3074
3074
  await sql`DROP FUNCTION IF EXISTS public.notify_source_secrets_change() CASCADE`.execute(db);
3075
3075
  }
3076
- async function down$148(db) {
3076
+ async function down$149(db) {
3077
3077
  await sql`
3078
3078
  CREATE OR REPLACE FUNCTION public.notify_source_secrets_change() RETURNS trigger
3079
3079
  LANGUAGE plpgsql
@@ -3112,8 +3112,8 @@ async function down$148(db) {
3112
3112
  //#endregion
3113
3113
  //#region src/db/migrations/012_peer_credentials_active_uniq.ts
3114
3114
  var _012_peer_credentials_active_uniq_exports = /* @__PURE__ */ __exportAll({
3115
- down: () => down$147,
3116
- up: () => up$147
3115
+ down: () => down$148,
3116
+ up: () => up$148
3117
3117
  });
3118
3118
  /**
3119
3119
  * Add a partial unique index on `peer_credentials (instance_id) WHERE
@@ -3132,7 +3132,7 @@ var _012_peer_credentials_active_uniq_exports = /* @__PURE__ */ __exportAll({
3132
3132
  * `down()` only drops the index; it does NOT undo the dedupe (revoked rows
3133
3133
  * cannot be safely recreated, and the dedupe is monotonic).
3134
3134
  */
3135
- async function up$147(db) {
3135
+ async function up$148(db) {
3136
3136
  await sql`
3137
3137
  UPDATE public.peer_credentials
3138
3138
  SET revoked_at = NOW()
@@ -3150,14 +3150,14 @@ async function up$147(db) {
3150
3150
  WHERE revoked_at IS NULL
3151
3151
  `.execute(db);
3152
3152
  }
3153
- async function down$147(db) {
3153
+ async function down$148(db) {
3154
3154
  await sql`DROP INDEX IF EXISTS public.peer_credentials_active_uniq`.execute(db);
3155
3155
  }
3156
3156
  //#endregion
3157
3157
  //#region src/db/migrations/013_execution_log_bytes.ts
3158
3158
  var _013_execution_log_bytes_exports = /* @__PURE__ */ __exportAll({
3159
- down: () => down$146,
3160
- up: () => up$146
3159
+ down: () => down$147,
3160
+ up: () => up$147
3161
3161
  });
3162
3162
  /**
3163
3163
  * Per-run and per-job raw log byte totals, reported by agents on terminal `step.status`.
@@ -3168,7 +3168,7 @@ var _013_execution_log_bytes_exports = /* @__PURE__ */ __exportAll({
3168
3168
  * Default 0 needs no backfill: older runs never had the agent telemetry, so zero is correct.
3169
3169
  * Idempotent.
3170
3170
  */
3171
- async function up$146(db) {
3171
+ async function up$147(db) {
3172
3172
  await sql`
3173
3173
  ALTER TABLE public.execution_runs
3174
3174
  ADD COLUMN IF NOT EXISTS log_bytes BIGINT NOT NULL DEFAULT 0
@@ -3178,15 +3178,15 @@ async function up$146(db) {
3178
3178
  ADD COLUMN IF NOT EXISTS log_bytes BIGINT NOT NULL DEFAULT 0
3179
3179
  `.execute(db);
3180
3180
  }
3181
- async function down$146(db) {
3181
+ async function down$147(db) {
3182
3182
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS log_bytes`.execute(db);
3183
3183
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS log_bytes`.execute(db);
3184
3184
  }
3185
3185
  //#endregion
3186
3186
  //#region src/db/migrations/014_kici_events_lease_retry.ts
3187
3187
  var _014_kici_events_lease_retry_exports = /* @__PURE__ */ __exportAll({
3188
- down: () => down$145,
3189
- up: () => up$145
3188
+ down: () => down$146,
3189
+ up: () => up$146
3190
3190
  });
3191
3191
  /**
3192
3192
  * Lease + retry + DLQ columns on `kici_events`, so the EventRouter delivers
@@ -3207,7 +3207,7 @@ var _014_kici_events_lease_retry_exports = /* @__PURE__ */ __exportAll({
3207
3207
  *
3208
3208
  * Partial indexes skip the hot-path processed=true rows. Idempotent.
3209
3209
  */
3210
- async function up$145(db) {
3210
+ async function up$146(db) {
3211
3211
  await sql`
3212
3212
  ALTER TABLE public.kici_events
3213
3213
  ADD COLUMN IF NOT EXISTS claimed_at TIMESTAMPTZ,
@@ -3238,7 +3238,7 @@ async function up$145(db) {
3238
3238
  WHERE dlq_at IS NOT NULL
3239
3239
  `.execute(db);
3240
3240
  }
3241
- async function down$145(db) {
3241
+ async function down$146(db) {
3242
3242
  await sql`DROP INDEX IF EXISTS public.idx_kici_events_dlq`.execute(db);
3243
3243
  await sql`DROP INDEX IF EXISTS public.idx_kici_events_lease_expired`.execute(db);
3244
3244
  await sql`DROP INDEX IF EXISTS public.idx_kici_events_retry_due`.execute(db);
@@ -3256,8 +3256,8 @@ async function down$145(db) {
3256
3256
  //#endregion
3257
3257
  //#region src/db/migrations/015_org_settings_customer_scoped.ts
3258
3258
  var _015_org_settings_customer_scoped_exports = /* @__PURE__ */ __exportAll({
3259
- down: () => down$144,
3260
- up: () => up$144
3259
+ down: () => down$145,
3260
+ up: () => up$145
3261
3261
  });
3262
3262
  /**
3263
3263
  * Org-scope `org_settings` and qualify each glob entry by source.
@@ -3280,7 +3280,7 @@ var _015_org_settings_customer_scoped_exports = /* @__PURE__ */ __exportAll({
3280
3280
  *
3281
3281
  * Idempotent: an existing `customer_id` column makes a re-run a no-op.
3282
3282
  */
3283
- async function up$144(db) {
3283
+ async function up$145(db) {
3284
3284
  if ((await sql`
3285
3285
  SELECT EXISTS (
3286
3286
  SELECT 1 FROM information_schema.columns
@@ -3405,7 +3405,7 @@ async function up$144(db) {
3405
3405
  await sql`DROP TABLE _org_settings_merged`.execute(db);
3406
3406
  await sql`DROP TABLE _org_settings_stage`.execute(db);
3407
3407
  }
3408
- async function down$144(db) {
3408
+ async function down$145(db) {
3409
3409
  if (!(await sql`
3410
3410
  SELECT EXISTS (
3411
3411
  SELECT 1 FROM information_schema.columns
@@ -3430,8 +3430,8 @@ async function down$144(db) {
3430
3430
  //#endregion
3431
3431
  //#region src/db/migrations/016_org_settings_allow_http_npm.ts
3432
3432
  var _016_org_settings_allow_http_npm_exports = /* @__PURE__ */ __exportAll({
3433
- down: () => down$143,
3434
- up: () => up$143
3433
+ down: () => down$144,
3434
+ up: () => up$144
3435
3435
  });
3436
3436
  /**
3437
3437
  * Add `org_settings.allow_http_npm_registries boolean NOT NULL DEFAULT false`.
@@ -3442,7 +3442,7 @@ var _016_org_settings_allow_http_npm_exports = /* @__PURE__ */ __exportAll({
3442
3442
  *
3443
3443
  * Idempotent.
3444
3444
  */
3445
- async function up$143(db) {
3445
+ async function up$144(db) {
3446
3446
  if ((await sql`
3447
3447
  SELECT EXISTS (
3448
3448
  SELECT 1 FROM information_schema.columns
@@ -3456,7 +3456,7 @@ async function up$143(db) {
3456
3456
  ADD COLUMN allow_http_npm_registries boolean NOT NULL DEFAULT false
3457
3457
  `.execute(db);
3458
3458
  }
3459
- async function down$143(db) {
3459
+ async function down$144(db) {
3460
3460
  await sql`
3461
3461
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS allow_http_npm_registries
3462
3462
  `.execute(db);
@@ -3464,8 +3464,8 @@ async function down$143(db) {
3464
3464
  //#endregion
3465
3465
  //#region src/db/migrations/017_org_id_widen.ts
3466
3466
  var _017_org_id_widen_exports = /* @__PURE__ */ __exportAll({
3467
- down: () => down$142,
3468
- up: () => up$142
3467
+ down: () => down$143,
3468
+ up: () => up$143
3469
3469
  });
3470
3470
  /**
3471
3471
  * Widen orchestrator `org_id varchar(12)` columns to `varchar(16)` for the Platform's prefixed
@@ -3488,17 +3488,17 @@ const ORG_ID_TABLES$3 = [
3488
3488
  "held_runs",
3489
3489
  "scoped_secrets"
3490
3490
  ];
3491
- async function up$142(db) {
3491
+ async function up$143(db) {
3492
3492
  for (const table of ORG_ID_TABLES$3) await sql.raw(`ALTER TABLE public.${table} ALTER COLUMN org_id TYPE varchar(16)`).execute(db);
3493
3493
  }
3494
- async function down$142(db) {
3494
+ async function down$143(db) {
3495
3495
  for (const table of ORG_ID_TABLES$3) await sql.raw(`ALTER TABLE public.${table} ALTER COLUMN org_id TYPE varchar(12)`).execute(db);
3496
3496
  }
3497
3497
  //#endregion
3498
3498
  //#region src/db/migrations/018_org_id_prefix_backfill.ts
3499
3499
  var _018_org_id_prefix_backfill_exports = /* @__PURE__ */ __exportAll({
3500
- down: () => down$141,
3501
- up: () => up$141
3500
+ down: () => down$142,
3501
+ up: () => up$142
3502
3502
  });
3503
3503
  /**
3504
3504
  * Prefix every orchestrator-side tenant string with `org_` to align
@@ -3534,19 +3534,19 @@ const CUSTOMER_ID_TABLES = [
3534
3534
  "workflow_registrations",
3535
3535
  "org_settings"
3536
3536
  ];
3537
- async function up$141(db) {
3537
+ async function up$142(db) {
3538
3538
  for (const table of ORG_ID_TABLES$2) 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);
3539
3539
  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);
3540
3540
  }
3541
- async function down$141(db) {
3541
+ async function down$142(db) {
3542
3542
  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);
3543
3543
  for (const table of ORG_ID_TABLES$2) await sql.raw(`UPDATE public.${table} SET org_id = substring(org_id from 5) WHERE org_id LIKE 'org\\_%' ESCAPE '\\'`).execute(db);
3544
3544
  }
3545
3545
  //#endregion
3546
3546
  //#region src/db/migrations/019_generic_sources_change_notify.ts
3547
3547
  var _019_generic_sources_change_notify_exports = /* @__PURE__ */ __exportAll({
3548
- down: () => down$140,
3549
- up: () => up$140
3548
+ down: () => down$141,
3549
+ up: () => up$141
3550
3550
  });
3551
3551
  /**
3552
3552
  * Add a trigger on `generic_webhook_sources` that emits
@@ -3565,7 +3565,7 @@ var _019_generic_sources_change_notify_exports = /* @__PURE__ */ __exportAll({
3565
3565
  * Mirrors the GitHub-app `sources` trigger (`notify_sources_change()` +
3566
3566
  * `sources_change_trigger` in `001_initial.ts`).
3567
3567
  */
3568
- async function up$140(db) {
3568
+ async function up$141(db) {
3569
3569
  await sql`
3570
3570
  CREATE FUNCTION public.notify_generic_sources_change() RETURNS trigger
3571
3571
  LANGUAGE plpgsql
@@ -3586,15 +3586,15 @@ async function up$140(db) {
3586
3586
  FOR EACH ROW EXECUTE FUNCTION public.notify_generic_sources_change()
3587
3587
  `.execute(db);
3588
3588
  }
3589
- async function down$140(db) {
3589
+ async function down$141(db) {
3590
3590
  await sql`DROP TRIGGER IF EXISTS generic_sources_change_trigger ON public.generic_webhook_sources`.execute(db);
3591
3591
  await sql`DROP FUNCTION IF EXISTS public.notify_generic_sources_change()`.execute(db);
3592
3592
  }
3593
3593
  //#endregion
3594
3594
  //#region src/db/migrations/020_org_settings_dashboard_write_policy.ts
3595
3595
  var _020_org_settings_dashboard_write_policy_exports = /* @__PURE__ */ __exportAll({
3596
- down: () => down$139,
3597
- up: () => up$139
3596
+ down: () => down$140,
3597
+ up: () => up$140
3598
3598
  });
3599
3599
  /**
3600
3600
  * Add `org_settings.dashboard_write_policy jsonb NOT NULL DEFAULT '{}'`.
@@ -3606,7 +3606,7 @@ var _020_org_settings_dashboard_write_policy_exports = /* @__PURE__ */ __exportA
3606
3606
  *
3607
3607
  * Idempotent.
3608
3608
  */
3609
- async function up$139(db) {
3609
+ async function up$140(db) {
3610
3610
  if ((await sql`
3611
3611
  SELECT EXISTS (
3612
3612
  SELECT 1 FROM information_schema.columns
@@ -3620,7 +3620,7 @@ async function up$139(db) {
3620
3620
  ADD COLUMN dashboard_write_policy jsonb NOT NULL DEFAULT '{}'::jsonb
3621
3621
  `.execute(db);
3622
3622
  }
3623
- async function down$139(db) {
3623
+ async function down$140(db) {
3624
3624
  await sql`
3625
3625
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS dashboard_write_policy
3626
3626
  `.execute(db);
@@ -3628,8 +3628,8 @@ async function down$139(db) {
3628
3628
  //#endregion
3629
3629
  //#region src/db/migrations/021_check_run_tracking.ts
3630
3630
  var _021_check_run_tracking_exports = /* @__PURE__ */ __exportAll({
3631
- down: () => down$138,
3632
- up: () => up$138
3631
+ down: () => down$139,
3632
+ up: () => up$139
3633
3633
  });
3634
3634
  /**
3635
3635
  * `check_run_tracking`: `CheckRunReporter` state keyed per (provider, owner, repo, sha,
@@ -3641,7 +3641,7 @@ var _021_check_run_tracking_exports = /* @__PURE__ */ __exportAll({
3641
3641
  *
3642
3642
  * Idempotent: a re-run on a DB that already has the table is a no-op.
3643
3643
  */
3644
- async function up$138(db) {
3644
+ async function up$139(db) {
3645
3645
  if ((await sql`
3646
3646
  SELECT EXISTS (
3647
3647
  SELECT 1 FROM information_schema.tables
@@ -3672,14 +3672,14 @@ async function up$138(db) {
3672
3672
  WHERE run_id IS NOT NULL
3673
3673
  `.execute(db);
3674
3674
  }
3675
- async function down$138(db) {
3675
+ async function down$139(db) {
3676
3676
  await sql`DROP TABLE IF EXISTS public.check_run_tracking`.execute(db);
3677
3677
  }
3678
3678
  //#endregion
3679
3679
  //#region src/db/migrations/022_scaler_manager_state.ts
3680
3680
  var _022_scaler_manager_state_exports = /* @__PURE__ */ __exportAll({
3681
- down: () => down$137,
3682
- up: () => up$137
3681
+ down: () => down$138,
3682
+ up: () => up$138
3683
3683
  });
3684
3684
  /**
3685
3685
  * Persists `ScalerManager` per-coord state:
@@ -3696,7 +3696,7 @@ var _022_scaler_manager_state_exports = /* @__PURE__ */ __exportAll({
3696
3696
  *
3697
3697
  * Idempotent: an existing table is left alone.
3698
3698
  */
3699
- async function up$137(db) {
3699
+ async function up$138(db) {
3700
3700
  const tableExists = async (name) => {
3701
3701
  return (await sql`
3702
3702
  SELECT EXISTS (
@@ -3746,7 +3746,7 @@ async function up$137(db) {
3746
3746
  `.execute(db);
3747
3747
  }
3748
3748
  }
3749
- async function down$137(db) {
3749
+ async function down$138(db) {
3750
3750
  await sql`DROP TABLE IF EXISTS public.scaler_reservations`.execute(db);
3751
3751
  await sql`DROP TABLE IF EXISTS public.scaler_agent_jobs`.execute(db);
3752
3752
  await sql`DROP TABLE IF EXISTS public.scaler_spawning_agents`.execute(db);
@@ -3754,8 +3754,8 @@ async function down$137(db) {
3754
3754
  //#endregion
3755
3755
  //#region src/db/migrations/023_dispatch_queue_recovery_deadline.ts
3756
3756
  var _023_dispatch_queue_recovery_deadline_exports = /* @__PURE__ */ __exportAll({
3757
- down: () => down$136,
3758
- up: () => up$136
3757
+ down: () => down$137,
3758
+ up: () => up$137
3759
3759
  });
3760
3760
  /**
3761
3761
  * Persists per-job agent-disconnect recovery state, so a coord crash between starting the
@@ -3768,7 +3768,7 @@ var _023_dispatch_queue_recovery_deadline_exports = /* @__PURE__ */ __exportAll(
3768
3768
  *
3769
3769
  * Idempotent: an existing column is a no-op.
3770
3770
  */
3771
- async function up$136(db) {
3771
+ async function up$137(db) {
3772
3772
  const colExists = async (name) => {
3773
3773
  return (await sql`
3774
3774
  SELECT EXISTS (
@@ -3793,7 +3793,7 @@ async function up$136(db) {
3793
3793
  WHERE recovery_deadline IS NOT NULL
3794
3794
  `.execute(db);
3795
3795
  }
3796
- async function down$136(db) {
3796
+ async function down$137(db) {
3797
3797
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_recovery_deadline`.execute(db);
3798
3798
  await sql`
3799
3799
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS recovery_agent_id
@@ -3805,8 +3805,8 @@ async function down$136(db) {
3805
3805
  //#endregion
3806
3806
  //#region src/db/migrations/024_dispatch_queue_provisioning_error.ts
3807
3807
  var _024_dispatch_queue_provisioning_error_exports = /* @__PURE__ */ __exportAll({
3808
- down: () => down$135,
3809
- up: () => up$135
3808
+ down: () => down$136,
3809
+ up: () => up$136
3810
3810
  });
3811
3811
  /**
3812
3812
  * `dispatch_queue.last_provisioning_error`: the latest scaler spawn-failure detail for a queued
@@ -3816,7 +3816,7 @@ var _024_dispatch_queue_provisioning_error_exports = /* @__PURE__ */ __exportAll
3816
3816
  *
3817
3817
  * Idempotent: an existing column is a no-op.
3818
3818
  */
3819
- async function up$135(db) {
3819
+ async function up$136(db) {
3820
3820
  const colExists = async (name) => {
3821
3821
  return (await sql`
3822
3822
  SELECT EXISTS (
@@ -3832,7 +3832,7 @@ async function up$135(db) {
3832
3832
  ADD COLUMN last_provisioning_error TEXT
3833
3833
  `.execute(db);
3834
3834
  }
3835
- async function down$135(db) {
3835
+ async function down$136(db) {
3836
3836
  await sql`
3837
3837
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS last_provisioning_error
3838
3838
  `.execute(db);
@@ -3840,8 +3840,8 @@ async function down$135(db) {
3840
3840
  //#endregion
3841
3841
  //#region src/db/migrations/025_init_failure.ts
3842
3842
  var _025_init_failure_exports = /* @__PURE__ */ __exportAll({
3843
- down: () => down$134,
3844
- up: () => up$134
3843
+ down: () => down$135,
3844
+ up: () => up$135
3845
3845
  });
3846
3846
  /**
3847
3847
  * `init_failure` on `execution_runs` / `execution_jobs`: non-NULL means the run/job never
@@ -3851,7 +3851,7 @@ var _025_init_failure_exports = /* @__PURE__ */ __exportAll({
3851
3851
  *
3852
3852
  * Idempotent per column.
3853
3853
  */
3854
- async function up$134(db) {
3854
+ async function up$135(db) {
3855
3855
  const colExists = async (table, name) => {
3856
3856
  return (await sql`
3857
3857
  SELECT EXISTS (
@@ -3871,7 +3871,7 @@ async function up$134(db) {
3871
3871
  ADD COLUMN init_failure JSONB DEFAULT NULL
3872
3872
  `.execute(db);
3873
3873
  }
3874
- async function down$134(db) {
3874
+ async function down$135(db) {
3875
3875
  await sql`
3876
3876
  ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS init_failure
3877
3877
  `.execute(db);
@@ -3882,8 +3882,8 @@ async function down$134(db) {
3882
3882
  //#endregion
3883
3883
  //#region src/db/migrations/026_event_log_lockfile_corrupt.ts
3884
3884
  var _026_event_log_lockfile_corrupt_exports = /* @__PURE__ */ __exportAll({
3885
- down: () => down$133,
3886
- up: () => up$133
3885
+ down: () => down$134,
3886
+ up: () => up$134
3887
3887
  });
3888
3888
  /**
3889
3889
  * Extend the event_log.status CHECK constraint with 'lockfile_corrupt' so the
@@ -3892,7 +3892,7 @@ var _026_event_log_lockfile_corrupt_exports = /* @__PURE__ */ __exportAll({
3892
3892
  *
3893
3893
  * Idempotent: the DROP ... IF EXISTS / re-ADD pair re-runs cleanly.
3894
3894
  */
3895
- async function up$133(db) {
3895
+ async function up$134(db) {
3896
3896
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
3897
3897
  await sql`
3898
3898
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -3902,7 +3902,7 @@ async function up$133(db) {
3902
3902
  ])))
3903
3903
  `.execute(db);
3904
3904
  }
3905
- async function down$133(db) {
3905
+ async function down$134(db) {
3906
3906
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
3907
3907
  await sql`
3908
3908
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -3915,8 +3915,8 @@ async function down$133(db) {
3915
3915
  //#endregion
3916
3916
  //#region src/db/migrations/027_workflow_timeout.ts
3917
3917
  var _027_workflow_timeout_exports = /* @__PURE__ */ __exportAll({
3918
- down: () => down$132,
3919
- up: () => up$132
3918
+ down: () => down$133,
3919
+ up: () => up$133
3920
3920
  });
3921
3921
  /**
3922
3922
  * Add `execution_runs.workflow_timeout_ms`: the lock workflow's wall-clock timeout (ms), read at
@@ -3926,13 +3926,13 @@ var _027_workflow_timeout_exports = /* @__PURE__ */ __exportAll({
3926
3926
  * INTEGER like the other `*_ms` columns, so pg reads a plain number rather than a BIGINT string;
3927
3927
  * it caps the timeout at ~24.8 days. Idempotent.
3928
3928
  */
3929
- async function up$132(db) {
3929
+ async function up$133(db) {
3930
3930
  await sql`
3931
3931
  ALTER TABLE public.execution_runs
3932
3932
  ADD COLUMN IF NOT EXISTS workflow_timeout_ms INTEGER DEFAULT NULL
3933
3933
  `.execute(db);
3934
3934
  }
3935
- async function down$132(db) {
3935
+ async function down$133(db) {
3936
3936
  await sql`
3937
3937
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_timeout_ms
3938
3938
  `.execute(db);
@@ -3940,8 +3940,8 @@ async function down$132(db) {
3940
3940
  //#endregion
3941
3941
  //#region src/db/migrations/028_org_settings_user_cache.ts
3942
3942
  var _028_org_settings_user_cache_exports = /* @__PURE__ */ __exportAll({
3943
- down: () => down$131,
3944
- up: () => up$131
3943
+ down: () => down$132,
3944
+ up: () => up$132
3945
3945
  });
3946
3946
  /**
3947
3947
  * Add `org_settings.user_cache_quota_bytes bigint` and
@@ -3967,7 +3967,7 @@ async function columnExists$16(db, column) {
3967
3967
  ) AS exists
3968
3968
  `.execute(db)).rows[0]?.exists ?? false;
3969
3969
  }
3970
- async function up$131(db) {
3970
+ async function up$132(db) {
3971
3971
  if (!await columnExists$16(db, "user_cache_quota_bytes")) await sql`
3972
3972
  ALTER TABLE public.org_settings
3973
3973
  ADD COLUMN user_cache_quota_bytes bigint
@@ -3977,7 +3977,7 @@ async function up$131(db) {
3977
3977
  ADD COLUMN user_cache_ttl_ms bigint
3978
3978
  `.execute(db);
3979
3979
  }
3980
- async function down$131(db) {
3980
+ async function down$132(db) {
3981
3981
  await sql`
3982
3982
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS user_cache_quota_bytes
3983
3983
  `.execute(db);
@@ -3988,8 +3988,8 @@ async function down$131(db) {
3988
3988
  //#endregion
3989
3989
  //#region src/db/migrations/029_dispatch_queue_attempts.ts
3990
3990
  var _029_dispatch_queue_attempts_exports = /* @__PURE__ */ __exportAll({
3991
- down: () => down$130,
3992
- up: () => up$130
3991
+ down: () => down$131,
3992
+ up: () => up$131
3993
3993
  });
3994
3994
  /**
3995
3995
  * Add `dispatch_queue.dispatch_attempts`: how often a job returned to `pending` after a failed
@@ -3997,7 +3997,7 @@ var _029_dispatch_queue_attempts_exports = /* @__PURE__ */ __exportAll({
3997
3997
  * fails the job at MAX_DISPATCH_ATTEMPTS, bounding requeue loops; `expires_at` stays the
3998
3998
  * time-based backstop. Idempotent.
3999
3999
  */
4000
- async function up$130(db) {
4000
+ async function up$131(db) {
4001
4001
  if (!((await sql`
4002
4002
  SELECT EXISTS (
4003
4003
  SELECT 1 FROM information_schema.columns
@@ -4010,7 +4010,7 @@ async function up$130(db) {
4010
4010
  ADD COLUMN dispatch_attempts INT NOT NULL DEFAULT 0
4011
4011
  `.execute(db);
4012
4012
  }
4013
- async function down$130(db) {
4013
+ async function down$131(db) {
4014
4014
  await sql`
4015
4015
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS dispatch_attempts
4016
4016
  `.execute(db);
@@ -4018,8 +4018,8 @@ async function down$130(db) {
4018
4018
  //#endregion
4019
4019
  //#region src/db/migrations/030_held_runs_env_set_null.ts
4020
4020
  var _030_held_runs_env_set_null_exports = /* @__PURE__ */ __exportAll({
4021
- down: () => down$129,
4022
- up: () => up$129
4021
+ down: () => down$130,
4022
+ up: () => up$130
4023
4023
  });
4024
4024
  /**
4025
4025
  * held_runs.environment_id becomes nullable with ON DELETE SET NULL, so
@@ -4029,14 +4029,14 @@ var _030_held_runs_env_set_null_exports = /* @__PURE__ */ __exportAll({
4029
4029
  * Idempotent: both drops are no-ops on a re-run, and the constraint is
4030
4030
  * re-created with the SET NULL action.
4031
4031
  */
4032
- async function up$129(db) {
4032
+ async function up$130(db) {
4033
4033
  await sql`ALTER TABLE public.held_runs ALTER COLUMN environment_id DROP NOT NULL`.execute(db);
4034
4034
  await sql`ALTER TABLE public.held_runs DROP CONSTRAINT IF EXISTS held_runs_environment_id_fkey`.execute(db);
4035
4035
  await sql`ALTER TABLE public.held_runs
4036
4036
  ADD CONSTRAINT held_runs_environment_id_fkey
4037
4037
  FOREIGN KEY (environment_id) REFERENCES public.environments(id) ON DELETE SET NULL`.execute(db);
4038
4038
  }
4039
- async function down$129(db) {
4039
+ async function down$130(db) {
4040
4040
  await sql`ALTER TABLE public.held_runs DROP CONSTRAINT IF EXISTS held_runs_environment_id_fkey`.execute(db);
4041
4041
  await sql`ALTER TABLE public.held_runs
4042
4042
  ADD CONSTRAINT held_runs_environment_id_fkey
@@ -4046,8 +4046,8 @@ async function down$129(db) {
4046
4046
  //#endregion
4047
4047
  //#region src/db/migrations/031_dispatch_queue_ack_deadline.ts
4048
4048
  var _031_dispatch_queue_ack_deadline_exports = /* @__PURE__ */ __exportAll({
4049
- down: () => down$128,
4050
- up: () => up$128
4049
+ down: () => down$129,
4050
+ up: () => up$129
4051
4051
  });
4052
4052
  /**
4053
4053
  * Add `dispatch_queue.ack_deadline` / `ack_agent_id`: the persisted per-dispatch ack deadline
@@ -4058,7 +4058,7 @@ var _031_dispatch_queue_ack_deadline_exports = /* @__PURE__ */ __exportAll({
4058
4058
  * the leader-gated `Dispatcher.sweepExpiredAckDeadlines` when that coord crashed;
4059
4059
  * `Dispatcher.recoverState()` re-arms timers on coord boot. Idempotent.
4060
4060
  */
4061
- async function up$128(db) {
4061
+ async function up$129(db) {
4062
4062
  const colExists = async (name) => {
4063
4063
  return (await sql`
4064
4064
  SELECT EXISTS (
@@ -4083,7 +4083,7 @@ async function up$128(db) {
4083
4083
  WHERE ack_deadline IS NOT NULL
4084
4084
  `.execute(db);
4085
4085
  }
4086
- async function down$128(db) {
4086
+ async function down$129(db) {
4087
4087
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_ack_deadline`.execute(db);
4088
4088
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS ack_agent_id`.execute(db);
4089
4089
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS ack_deadline`.execute(db);
@@ -4091,8 +4091,8 @@ async function down$128(db) {
4091
4091
  //#endregion
4092
4092
  //#region src/db/migrations/032_org_settings_dispatch_ack_timeout.ts
4093
4093
  var _032_org_settings_dispatch_ack_timeout_exports = /* @__PURE__ */ __exportAll({
4094
- down: () => down$127,
4095
- up: () => up$127
4094
+ down: () => down$128,
4095
+ up: () => up$128
4096
4096
  });
4097
4097
  /**
4098
4098
  * Add `org_settings.dispatch_ack_timeout_ms BIGINT` (nullable).
@@ -4104,7 +4104,7 @@ var _032_org_settings_dispatch_ack_timeout_exports = /* @__PURE__ */ __exportAll
4104
4104
  *
4105
4105
  * Idempotent: a re-run on a DB that already has the column is a no-op.
4106
4106
  */
4107
- async function up$127(db) {
4107
+ async function up$128(db) {
4108
4108
  if ((await sql`
4109
4109
  SELECT EXISTS (
4110
4110
  SELECT 1 FROM information_schema.columns
@@ -4118,7 +4118,7 @@ async function up$127(db) {
4118
4118
  ADD COLUMN dispatch_ack_timeout_ms BIGINT
4119
4119
  `.execute(db);
4120
4120
  }
4121
- async function down$127(db) {
4121
+ async function down$128(db) {
4122
4122
  await sql`
4123
4123
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS dispatch_ack_timeout_ms
4124
4124
  `.execute(db);
@@ -4126,8 +4126,8 @@ async function down$127(db) {
4126
4126
  //#endregion
4127
4127
  //#region src/db/migrations/033_org_settings_approval.ts
4128
4128
  var _033_org_settings_approval_exports = /* @__PURE__ */ __exportAll({
4129
- down: () => down$126,
4130
- up: () => up$126
4129
+ down: () => down$127,
4130
+ up: () => up$127
4131
4131
  });
4132
4132
  /**
4133
4133
  * Add the approval-policy columns to `org_settings`:
@@ -4141,7 +4141,7 @@ var _033_org_settings_approval_exports = /* @__PURE__ */ __exportAll({
4141
4141
  * Set per org via `kici-admin org-settings approval` and the orchestrator admin
4142
4142
  * route. Idempotent: each column is guarded independently.
4143
4143
  */
4144
- async function up$126(db) {
4144
+ async function up$127(db) {
4145
4145
  const colExists = async (column) => {
4146
4146
  return (await sql`
4147
4147
  SELECT EXISTS (
@@ -4161,7 +4161,7 @@ async function up$126(db) {
4161
4161
  ADD COLUMN allow_self_approval BOOLEAN NOT NULL DEFAULT true
4162
4162
  `.execute(db);
4163
4163
  }
4164
- async function down$126(db) {
4164
+ async function down$127(db) {
4165
4165
  await sql`
4166
4166
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS approval_expiry_seconds
4167
4167
  `.execute(db);
@@ -4172,8 +4172,8 @@ async function down$126(db) {
4172
4172
  //#endregion
4173
4173
  //#region src/db/migrations/034_held_runs_generalize.ts
4174
4174
  var _034_held_runs_generalize_exports = /* @__PURE__ */ __exportAll({
4175
- down: () => down$125,
4176
- up: () => up$125
4175
+ down: () => down$126,
4176
+ up: () => up$126
4177
4177
  });
4178
4178
  /**
4179
4179
  * Generalize `held_runs` from an environment-only hold into the "held element" model behind
@@ -4187,7 +4187,7 @@ var _034_held_runs_generalize_exports = /* @__PURE__ */ __exportAll({
4187
4187
  * - `approval_requirement` — the normalized `ApprovalRequirement` (clauses + expiresAt +
4188
4188
  * reason); NULL on rows that predate the approval model.
4189
4189
  */
4190
- async function up$125(db) {
4190
+ async function up$126(db) {
4191
4191
  const colExists = async (column) => {
4192
4192
  return (await sql`
4193
4193
  SELECT EXISTS (
@@ -4220,7 +4220,7 @@ async function up$125(db) {
4220
4220
  ON public.held_run_approvals USING btree (held_run_id)
4221
4221
  `.execute(db);
4222
4222
  }
4223
- async function down$125(db) {
4223
+ async function down$126(db) {
4224
4224
  await sql`DROP TABLE IF EXISTS public.held_run_approvals`.execute(db);
4225
4225
  await sql`ALTER TABLE public.held_runs DROP COLUMN IF EXISTS approval_requirement`.execute(db);
4226
4226
  await sql`ALTER TABLE public.held_runs DROP COLUMN IF EXISTS trigger_source`.execute(db);
@@ -4230,8 +4230,8 @@ async function down$125(db) {
4230
4230
  //#endregion
4231
4231
  //#region src/db/migrations/035_pending_workflow_contexts.ts
4232
4232
  var _035_pending_workflow_contexts_exports = /* @__PURE__ */ __exportAll({
4233
- down: () => down$124,
4234
- up: () => up$124
4233
+ down: () => down$125,
4234
+ up: () => up$125
4235
4235
  });
4236
4236
  /**
4237
4237
  * Pending workflow dispatch context, for resuming a workflow whose install gate
@@ -4239,7 +4239,7 @@ var _035_pending_workflow_contexts_exports = /* @__PURE__ */ __exportAll({
4239
4239
  * WorkflowDispatchContext when the hold releases (reviewer approve, wait-timer
4240
4240
  * expiry, free concurrency slot); it is deleted once the resume dispatch starts.
4241
4241
  */
4242
- async function up$124(db) {
4242
+ async function up$125(db) {
4243
4243
  await sql`
4244
4244
  CREATE TABLE IF NOT EXISTS public.pending_workflow_contexts (
4245
4245
  run_id text PRIMARY KEY,
@@ -4249,14 +4249,14 @@ async function up$124(db) {
4249
4249
  )
4250
4250
  `.execute(db);
4251
4251
  }
4252
- async function down$124(db) {
4252
+ async function down$125(db) {
4253
4253
  await sql`DROP TABLE IF EXISTS public.pending_workflow_contexts`.execute(db);
4254
4254
  }
4255
4255
  //#endregion
4256
4256
  //#region src/db/migrations/036_attestations.ts
4257
4257
  var _036_attestations_exports = /* @__PURE__ */ __exportAll({
4258
- down: () => down$123,
4259
- up: () => up$123
4258
+ down: () => down$124,
4259
+ up: () => up$124
4260
4260
  });
4261
4261
  /**
4262
4262
  * Add the `attestations` table for build-provenance bundles.
@@ -4269,7 +4269,7 @@ var _036_attestations_exports = /* @__PURE__ */ __exportAll({
4269
4269
  *
4270
4270
  * Idempotent: a re-run on a DB that already has the table is a no-op.
4271
4271
  */
4272
- async function up$123(db) {
4272
+ async function up$124(db) {
4273
4273
  if ((await sql`
4274
4274
  SELECT EXISTS (
4275
4275
  SELECT 1 FROM information_schema.tables
@@ -4295,14 +4295,14 @@ async function up$123(db) {
4295
4295
  ON public.attestations (run_id, job_id)
4296
4296
  `.execute(db);
4297
4297
  }
4298
- async function down$123(db) {
4298
+ async function down$124(db) {
4299
4299
  await sql`DROP TABLE IF EXISTS public.attestations`.execute(db);
4300
4300
  }
4301
4301
  //#endregion
4302
4302
  //#region src/db/migrations/037_generic_sources_provider_type_local.ts
4303
4303
  var _037_generic_sources_provider_type_local_exports = /* @__PURE__ */ __exportAll({
4304
- down: () => down$122,
4305
- up: () => up$122
4304
+ down: () => down$123,
4305
+ up: () => up$123
4306
4306
  });
4307
4307
  /**
4308
4308
  * Replace the `generic_webhook_sources.provider_type` CHECK constraint so it
@@ -4318,7 +4318,7 @@ var _037_generic_sources_provider_type_local_exports = /* @__PURE__ */ __exportA
4318
4318
  * Idempotent: the constraint is dropped IF EXISTS and recreated; the data
4319
4319
  * backfill is a plain UPDATE that is a no-op once no `'internal'` rows remain.
4320
4320
  */
4321
- async function up$122(db) {
4321
+ async function up$123(db) {
4322
4322
  await sql`
4323
4323
  ALTER TABLE public.generic_webhook_sources
4324
4324
  DROP CONSTRAINT IF EXISTS generic_webhook_sources_provider_type_check
@@ -4334,7 +4334,7 @@ async function up$122(db) {
4334
4334
  CHECK (provider_type = ANY (ARRAY['generic'::text, 'local'::text]))
4335
4335
  `.execute(db);
4336
4336
  }
4337
- async function down$122(db) {
4337
+ async function down$123(db) {
4338
4338
  await sql`
4339
4339
  ALTER TABLE public.generic_webhook_sources
4340
4340
  DROP CONSTRAINT IF EXISTS generic_webhook_sources_provider_type_check
@@ -4353,8 +4353,8 @@ async function down$122(db) {
4353
4353
  //#endregion
4354
4354
  //#region src/db/migrations/038_remote_sources.ts
4355
4355
  var _038_remote_sources_exports = /* @__PURE__ */ __exportAll({
4356
- down: () => down$121,
4357
- up: () => up$121
4356
+ down: () => down$122,
4357
+ up: () => up$122
4358
4358
  });
4359
4359
  /**
4360
4360
  * `remote_sources` anchors a Platform-relayed `kici run remote` to its real org: one row per
@@ -4364,7 +4364,7 @@ var _038_remote_sources_exports = /* @__PURE__ */ __exportAll({
4364
4364
  *
4365
4365
  * Idempotent: an existing table is a no-op.
4366
4366
  */
4367
- async function up$121(db) {
4367
+ async function up$122(db) {
4368
4368
  if ((await sql`
4369
4369
  SELECT EXISTS (
4370
4370
  SELECT 1 FROM information_schema.tables
@@ -4383,14 +4383,14 @@ async function up$121(db) {
4383
4383
  )
4384
4384
  `.execute(db);
4385
4385
  }
4386
- async function down$121(db) {
4386
+ async function down$122(db) {
4387
4387
  await sql`DROP TABLE IF EXISTS public.remote_sources`.execute(db);
4388
4388
  }
4389
4389
  //#endregion
4390
4390
  //#region src/db/migrations/039_host_roster.ts
4391
4391
  var _039_host_roster_exports = /* @__PURE__ */ __exportAll({
4392
- down: () => down$120,
4393
- up: () => up$120
4392
+ down: () => down$121,
4393
+ up: () => up$121
4394
4394
  });
4395
4395
  /**
4396
4396
  * `host_roster` is KiCI's declared inventory: one durable row per agent the
@@ -4407,7 +4407,7 @@ var _039_host_roster_exports = /* @__PURE__ */ __exportAll({
4407
4407
  *
4408
4408
  * Idempotent: a re-run on a DB that already has the table is a no-op.
4409
4409
  */
4410
- async function up$120(db) {
4410
+ async function up$121(db) {
4411
4411
  if ((await sql`
4412
4412
  SELECT EXISTS (
4413
4413
  SELECT 1 FROM information_schema.tables
@@ -4437,14 +4437,14 @@ async function up$120(db) {
4437
4437
  await sql`CREATE INDEX idx_host_roster_reap
4438
4438
  ON public.host_roster (lifecycle_class, last_seen)`.execute(db);
4439
4439
  }
4440
- async function down$120(db) {
4440
+ async function down$121(db) {
4441
4441
  await sql`DROP TABLE IF EXISTS public.host_roster`.execute(db);
4442
4442
  }
4443
4443
  //#endregion
4444
4444
  //#region src/db/migrations/040_runsonall_pin.ts
4445
4445
  var _040_runsonall_pin_exports = /* @__PURE__ */ __exportAll({
4446
- down: () => down$119,
4447
- up: () => up$119
4446
+ down: () => down$120,
4447
+ up: () => up$120
4448
4448
  });
4449
4449
  /**
4450
4450
  * Add the `runsOnAll` host fan-out columns:
@@ -4468,7 +4468,7 @@ async function colExists$22(db, table, name) {
4468
4468
  ) AS exists
4469
4469
  `.execute(db)).rows[0]?.exists ?? false;
4470
4470
  }
4471
- async function up$119(db) {
4471
+ async function up$120(db) {
4472
4472
  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);
4473
4473
  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);
4474
4474
  if (!await colExists$22(db, "execution_jobs", "variant_kind")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN variant_kind TEXT`.execute(db);
@@ -4479,7 +4479,7 @@ async function up$119(db) {
4479
4479
  WHERE pinned_agent_id IS NOT NULL
4480
4480
  `.execute(db);
4481
4481
  }
4482
- async function down$119(db) {
4482
+ async function down$120(db) {
4483
4483
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_pinned_agent`.execute(db);
4484
4484
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS pinned_agent_id`.execute(db);
4485
4485
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS variant_label`.execute(db);
@@ -4489,8 +4489,8 @@ async function down$119(db) {
4489
4489
  //#endregion
4490
4490
  //#region src/db/migrations/041_wave_gated.ts
4491
4491
  var _041_wave_gated_exports = /* @__PURE__ */ __exportAll({
4492
- down: () => down$118,
4493
- up: () => up$118
4492
+ down: () => down$119,
4493
+ up: () => up$119
4494
4494
  });
4495
4495
  /**
4496
4496
  * Add the rolling fan-out wave-gate columns:
@@ -4519,7 +4519,7 @@ async function colExists$21(db, table, name) {
4519
4519
  ) AS exists
4520
4520
  `.execute(db)).rows[0]?.exists ?? false;
4521
4521
  }
4522
- async function up$118(db) {
4522
+ async function up$119(db) {
4523
4523
  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);
4524
4524
  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);
4525
4525
  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);
@@ -4528,7 +4528,7 @@ async function up$118(db) {
4528
4528
  ON public.execution_jobs (run_id, base_job_name, wave_gated)
4529
4529
  `.execute(db);
4530
4530
  }
4531
- async function down$118(db) {
4531
+ async function down$119(db) {
4532
4532
  await sql`DROP INDEX IF EXISTS public.idx_execution_jobs_wave`.execute(db);
4533
4533
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS wave_fail_fast`.execute(db);
4534
4534
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS wave_max_parallel`.execute(db);
@@ -4537,8 +4537,8 @@ async function down$118(db) {
4537
4537
  //#endregion
4538
4538
  //#region src/db/migrations/042_dispatch_queue_patterns.ts
4539
4539
  var _042_dispatch_queue_patterns_exports = /* @__PURE__ */ __exportAll({
4540
- down: () => down$117,
4541
- up: () => up$117
4540
+ down: () => down$118,
4541
+ up: () => up$118
4542
4542
  });
4543
4543
  /**
4544
4544
  * Add dispatch_queue `runs_on_patterns` (regex matchers the agent's labels must satisfy) and
@@ -4557,19 +4557,19 @@ async function colExists$20(db, table, name) {
4557
4557
  ) AS exists
4558
4558
  `.execute(db)).rows[0]?.exists ?? false;
4559
4559
  }
4560
- async function up$117(db) {
4560
+ async function up$118(db) {
4561
4561
  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);
4562
4562
  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);
4563
4563
  }
4564
- async function down$117(db) {
4564
+ async function down$118(db) {
4565
4565
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS exclude_patterns`.execute(db);
4566
4566
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS runs_on_patterns`.execute(db);
4567
4567
  }
4568
4568
  //#endregion
4569
4569
  //#region src/db/migrations/043_rerouted_to_peer.ts
4570
4570
  var _043_rerouted_to_peer_exports = /* @__PURE__ */ __exportAll({
4571
- down: () => down$116,
4572
- up: () => up$116
4571
+ down: () => down$117,
4572
+ up: () => up$117
4573
4573
  });
4574
4574
  /**
4575
4575
  * Add a nullable `rerouted_to_peer text` marker to execution_jobs. Non-null
@@ -4590,17 +4590,17 @@ async function colExists$19(db, table, name) {
4590
4590
  ) AS exists
4591
4591
  `.execute(db)).rows[0]?.exists ?? false;
4592
4592
  }
4593
- async function up$116(db) {
4593
+ async function up$117(db) {
4594
4594
  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);
4595
4595
  }
4596
- async function down$116(db) {
4596
+ async function down$117(db) {
4597
4597
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS rerouted_to_peer`.execute(db);
4598
4598
  }
4599
4599
  //#endregion
4600
4600
  //#region src/db/migrations/044_check_mode.ts
4601
4601
  var _044_check_mode_exports = /* @__PURE__ */ __exportAll({
4602
- down: () => down$115,
4603
- up: () => up$115
4602
+ down: () => down$116,
4603
+ up: () => up$116
4604
4604
  });
4605
4605
  /**
4606
4606
  * Add the check-mode columns, all nullable. Idempotent.
@@ -4622,13 +4622,13 @@ async function colExists$18(db, table, name) {
4622
4622
  ) AS exists
4623
4623
  `.execute(db)).rows[0]?.exists ?? false;
4624
4624
  }
4625
- async function up$115(db) {
4625
+ async function up$116(db) {
4626
4626
  if (!await colExists$18(db, "execution_runs", "check_mode")) await sql`ALTER TABLE public.execution_runs ADD COLUMN check_mode text`.execute(db);
4627
4627
  if (!await colExists$18(db, "execution_steps", "check_outcome")) await sql`ALTER TABLE public.execution_steps ADD COLUMN check_outcome text`.execute(db);
4628
4628
  if (!await colExists$18(db, "execution_steps", "drift_summary")) await sql`ALTER TABLE public.execution_steps ADD COLUMN drift_summary text`.execute(db);
4629
4629
  if (!await colExists$18(db, "execution_steps", "drift")) await sql`ALTER TABLE public.execution_steps ADD COLUMN drift jsonb`.execute(db);
4630
4630
  }
4631
- async function down$115(db) {
4631
+ async function down$116(db) {
4632
4632
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS drift`.execute(db);
4633
4633
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS drift_summary`.execute(db);
4634
4634
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS check_outcome`.execute(db);
@@ -4637,8 +4637,8 @@ async function down$115(db) {
4637
4637
  //#endregion
4638
4638
  //#region src/db/migrations/045_host_properties.ts
4639
4639
  var _045_host_properties_exports = /* @__PURE__ */ __exportAll({
4640
- down: () => down$114,
4641
- up: () => up$114
4640
+ down: () => down$115,
4641
+ up: () => up$115
4642
4642
  });
4643
4643
  /**
4644
4644
  * `host_roster.host_properties jsonb NOT NULL DEFAULT '{}'`: the typed host-vars
@@ -4648,18 +4648,18 @@ var _045_host_properties_exports = /* @__PURE__ */ __exportAll({
4648
4648
  *
4649
4649
  * Idempotent and additive.
4650
4650
  */
4651
- async function up$114(db) {
4651
+ async function up$115(db) {
4652
4652
  await sql`ALTER TABLE public.host_roster
4653
4653
  ADD COLUMN IF NOT EXISTS host_properties jsonb NOT NULL DEFAULT '{}'::jsonb`.execute(db);
4654
4654
  }
4655
- async function down$114(db) {
4655
+ async function down$115(db) {
4656
4656
  await sql`ALTER TABLE public.host_roster DROP COLUMN IF EXISTS host_properties`.execute(db);
4657
4657
  }
4658
4658
  //#endregion
4659
4659
  //#region src/db/migrations/046_join_token_consumed_by_instance.ts
4660
4660
  var _046_join_token_consumed_by_instance_exports = /* @__PURE__ */ __exportAll({
4661
- down: () => down$113,
4662
- up: () => up$113
4661
+ down: () => down$114,
4662
+ up: () => up$114
4663
4663
  });
4664
4664
  /**
4665
4665
  * `join_tokens.consumed_by_instance`: the joining peer's `instanceId` at first consumption
@@ -4669,18 +4669,18 @@ var _046_join_token_consumed_by_instance_exports = /* @__PURE__ */ __exportAll({
4669
4669
  * credential self-heals by re-presenting the join token in its env, with no operator action.
4670
4670
  * Idempotent and additive.
4671
4671
  */
4672
- async function up$113(db) {
4672
+ async function up$114(db) {
4673
4673
  await sql`ALTER TABLE public.join_tokens
4674
4674
  ADD COLUMN IF NOT EXISTS consumed_by_instance text`.execute(db);
4675
4675
  }
4676
- async function down$113(db) {
4676
+ async function down$114(db) {
4677
4677
  await sql`ALTER TABLE public.join_tokens DROP COLUMN IF EXISTS consumed_by_instance`.execute(db);
4678
4678
  }
4679
4679
  //#endregion
4680
4680
  //#region src/db/migrations/047_needs_run_on.ts
4681
4681
  var _047_needs_run_on_exports = /* @__PURE__ */ __exportAll({
4682
- down: () => down$112,
4683
- up: () => up$112
4682
+ down: () => down$113,
4683
+ up: () => up$113
4684
4684
  });
4685
4685
  /**
4686
4686
  * Migrate `execution_job_needs` from the binary `if_failed` policy to a
@@ -4714,7 +4714,7 @@ async function colExists$17(db, table, name) {
4714
4714
  `.execute(db)).rows[0]?.exists ?? false;
4715
4715
  }
4716
4716
  const SUCCESS_ONLY_DEFAULT = `'${SUCCESS_ONLY_JSON}'`;
4717
- async function up$112(db) {
4717
+ async function up$113(db) {
4718
4718
  if (!await colExists$17(db, "execution_job_needs", "run_on")) await sql`
4719
4719
  ALTER TABLE public.execution_job_needs
4720
4720
  ADD COLUMN run_on text NOT NULL DEFAULT ${sql.raw(SUCCESS_ONLY_DEFAULT)}
@@ -4733,7 +4733,7 @@ async function up$112(db) {
4733
4733
  await sql`ALTER TABLE public.execution_job_needs DROP COLUMN if_failed`.execute(db);
4734
4734
  }
4735
4735
  }
4736
- async function down$112(db) {
4736
+ async function down$113(db) {
4737
4737
  if (!await colExists$17(db, "execution_job_needs", "if_failed")) await sql`
4738
4738
  ALTER TABLE public.execution_job_needs
4739
4739
  ADD COLUMN if_failed text NOT NULL DEFAULT 'skip'
@@ -4749,8 +4749,8 @@ async function down$112(db) {
4749
4749
  //#endregion
4750
4750
  //#region src/db/migrations/048_host_reboot_pending.ts
4751
4751
  var _048_host_reboot_pending_exports = /* @__PURE__ */ __exportAll({
4752
- down: () => down$111,
4753
- up: () => up$111
4752
+ down: () => down$112,
4753
+ up: () => up$112
4754
4754
  });
4755
4755
  /**
4756
4756
  * `host_roster.reboot_pending_until`: the persisted reboot-pending flag (NULL = none), set when
@@ -4761,36 +4761,36 @@ var _048_host_reboot_pending_exports = /* @__PURE__ */ __exportAll({
4761
4761
  * rebooting box, and (3) clears on the next reconnect, releasing the held job.
4762
4762
  * Idempotent and additive.
4763
4763
  */
4764
- async function up$111(db) {
4764
+ async function up$112(db) {
4765
4765
  await sql`ALTER TABLE public.host_roster
4766
4766
  ADD COLUMN IF NOT EXISTS reboot_pending_until timestamptz`.execute(db);
4767
4767
  }
4768
- async function down$111(db) {
4768
+ async function down$112(db) {
4769
4769
  await sql`ALTER TABLE public.host_roster DROP COLUMN IF EXISTS reboot_pending_until`.execute(db);
4770
4770
  }
4771
4771
  //#endregion
4772
4772
  //#region src/db/migrations/049_held_runs_payload.ts
4773
4773
  var _049_held_runs_payload_exports = /* @__PURE__ */ __exportAll({
4774
- down: () => down$110,
4775
- up: () => up$110
4774
+ down: () => down$111,
4775
+ up: () => up$111
4776
4776
  });
4777
4777
  /**
4778
4778
  * Add `held_runs.payload`: the `{ summaryMarkdown, drift }` captured when a `when: 'drift'`
4779
4779
  * step-approval gate fires, so the dashboard approval queue and the CLI render the diff the
4780
4780
  * operator approves. NULL for every non-drift hold. Idempotent and additive.
4781
4781
  */
4782
- async function up$110(db) {
4782
+ async function up$111(db) {
4783
4783
  await sql`ALTER TABLE public.held_runs
4784
4784
  ADD COLUMN IF NOT EXISTS payload jsonb`.execute(db);
4785
4785
  }
4786
- async function down$110(db) {
4786
+ async function down$111(db) {
4787
4787
  await sql`ALTER TABLE public.held_runs DROP COLUMN IF EXISTS payload`.execute(db);
4788
4788
  }
4789
4789
  //#endregion
4790
4790
  //#region src/db/migrations/050_sources_slug.ts
4791
4791
  var _050_sources_slug_exports = /* @__PURE__ */ __exportAll({
4792
- down: () => down$109,
4793
- up: () => up$109
4792
+ down: () => down$110,
4793
+ up: () => up$110
4794
4794
  });
4795
4795
  /**
4796
4796
  * Add `sources.slug TEXT NULL` — the GitHub App slug (the URL-safe identifier
@@ -4804,18 +4804,18 @@ var _050_sources_slug_exports = /* @__PURE__ */ __exportAll({
4804
4804
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive, so existing data is
4805
4805
  * preserved.
4806
4806
  */
4807
- async function up$109(db) {
4807
+ async function up$110(db) {
4808
4808
  await sql`ALTER TABLE public.sources
4809
4809
  ADD COLUMN IF NOT EXISTS slug text`.execute(db);
4810
4810
  }
4811
- async function down$109(db) {
4811
+ async function down$110(db) {
4812
4812
  await sql`ALTER TABLE public.sources DROP COLUMN IF EXISTS slug`.execute(db);
4813
4813
  }
4814
4814
  //#endregion
4815
4815
  //#region src/db/migrations/051_binding_host_pattern.ts
4816
4816
  var _051_binding_host_pattern_exports = /* @__PURE__ */ __exportAll({
4817
- down: () => down$108,
4818
- up: () => up$108
4817
+ down: () => down$109,
4818
+ up: () => up$109
4819
4819
  });
4820
4820
  /**
4821
4821
  * Per-host environment secret bindings:
@@ -4828,7 +4828,7 @@ var _051_binding_host_pattern_exports = /* @__PURE__ */ __exportAll({
4828
4828
  *
4829
4829
  * Idempotent and additive.
4830
4830
  */
4831
- async function up$108(db) {
4831
+ async function up$109(db) {
4832
4832
  await sql`ALTER TABLE public.environment_bindings
4833
4833
  ADD COLUMN IF NOT EXISTS host_pattern text NOT NULL DEFAULT '**'`.execute(db);
4834
4834
  await sql`ALTER TABLE public.environment_bindings
@@ -4836,7 +4836,7 @@ async function up$108(db) {
4836
4836
  await sql`CREATE UNIQUE INDEX IF NOT EXISTS environment_bindings_env_scope_host_uniq
4837
4837
  ON public.environment_bindings (environment_id, scope_pattern, host_pattern)`.execute(db);
4838
4838
  }
4839
- async function down$108(db) {
4839
+ async function down$109(db) {
4840
4840
  await sql`DROP INDEX IF EXISTS public.environment_bindings_env_scope_host_uniq`.execute(db);
4841
4841
  await sql`ALTER TABLE public.environment_bindings
4842
4842
  DROP COLUMN IF EXISTS host_pattern`.execute(db);
@@ -4846,8 +4846,8 @@ async function down$108(db) {
4846
4846
  //#endregion
4847
4847
  //#region src/db/migrations/052_host_reach_metadata.ts
4848
4848
  var _052_host_reach_metadata_exports = /* @__PURE__ */ __exportAll({
4849
- down: () => down$107,
4850
- up: () => up$107
4849
+ down: () => down$108,
4850
+ up: () => up$108
4851
4851
  });
4852
4852
  /**
4853
4853
  * Add SSH reach metadata so a declared host with no agent yet can be bootstrapped:
@@ -4861,14 +4861,14 @@ var _052_host_reach_metadata_exports = /* @__PURE__ */ __exportAll({
4861
4861
  * All nullable: a host without them cannot be bootstrapped and is otherwise unaffected.
4862
4862
  * Idempotent and additive.
4863
4863
  */
4864
- async function up$107(db) {
4864
+ async function up$108(db) {
4865
4865
  await sql`ALTER TABLE public.host_roster
4866
4866
  ADD COLUMN IF NOT EXISTS address text,
4867
4867
  ADD COLUMN IF NOT EXISTS ssh_user text,
4868
4868
  ADD COLUMN IF NOT EXISTS ssh_port integer,
4869
4869
  ADD COLUMN IF NOT EXISTS ssh_key_secret text`.execute(db);
4870
4870
  }
4871
- async function down$107(db) {
4871
+ async function down$108(db) {
4872
4872
  await sql`ALTER TABLE public.host_roster
4873
4873
  DROP COLUMN IF EXISTS address,
4874
4874
  DROP COLUMN IF EXISTS ssh_user,
@@ -4878,8 +4878,8 @@ async function down$107(db) {
4878
4878
  //#endregion
4879
4879
  //#region src/db/migrations/053_agent_token_single_use.ts
4880
4880
  var _053_agent_token_single_use_exports = /* @__PURE__ */ __exportAll({
4881
- down: () => down$106,
4882
- up: () => up$106
4881
+ down: () => down$107,
4882
+ up: () => up$107
4883
4883
  });
4884
4884
  /**
4885
4885
  * `agent_tokens.consumed_at timestamptz NULL`: the single-use marker for the
@@ -4890,19 +4890,19 @@ var _053_agent_token_single_use_exports = /* @__PURE__ */ __exportAll({
4890
4890
  *
4891
4891
  * Idempotent and additive.
4892
4892
  */
4893
- async function up$106(db) {
4893
+ async function up$107(db) {
4894
4894
  await sql`ALTER TABLE public.agent_tokens
4895
4895
  ADD COLUMN IF NOT EXISTS consumed_at timestamptz`.execute(db);
4896
4896
  }
4897
- async function down$106(db) {
4897
+ async function down$107(db) {
4898
4898
  await sql`ALTER TABLE public.agent_tokens
4899
4899
  DROP COLUMN IF EXISTS consumed_at`.execute(db);
4900
4900
  }
4901
4901
  //#endregion
4902
4902
  //#region src/db/migrations/054_local_working_tree.ts
4903
4903
  var _054_local_working_tree_exports = /* @__PURE__ */ __exportAll({
4904
- down: () => down$105,
4905
- up: () => up$105
4904
+ down: () => down$106,
4905
+ up: () => up$106
4906
4906
  });
4907
4907
  /**
4908
4908
  * Add `execution_runs.local_working_tree boolean NOT NULL DEFAULT false`: true
@@ -4913,19 +4913,19 @@ var _054_local_working_tree_exports = /* @__PURE__ */ __exportAll({
4913
4913
  * Idempotent (`ADD COLUMN IF NOT EXISTS`); additive with a default, so existing
4914
4914
  * data is preserved.
4915
4915
  */
4916
- async function up$105(db) {
4916
+ async function up$106(db) {
4917
4917
  await sql`ALTER TABLE public.execution_runs
4918
4918
  ADD COLUMN IF NOT EXISTS local_working_tree boolean NOT NULL DEFAULT false`.execute(db);
4919
4919
  }
4920
- async function down$105(db) {
4920
+ async function down$106(db) {
4921
4921
  await sql`ALTER TABLE public.execution_runs
4922
4922
  DROP COLUMN IF EXISTS local_working_tree`.execute(db);
4923
4923
  }
4924
4924
  //#endregion
4925
4925
  //#region src/db/migrations/055_agent_token_mandatory_labels.ts
4926
4926
  var _055_agent_token_mandatory_labels_exports = /* @__PURE__ */ __exportAll({
4927
- down: () => down$104,
4928
- up: () => up$104
4927
+ down: () => down$105,
4928
+ up: () => up$105
4929
4929
  });
4930
4930
  /**
4931
4931
  * `agent_tokens.mandatory_labels text NULL`: a JSON-encoded `string[]` of
@@ -4936,19 +4936,19 @@ var _055_agent_token_mandatory_labels_exports = /* @__PURE__ */ __exportAll({
4936
4936
  *
4937
4937
  * Idempotent and additive.
4938
4938
  */
4939
- async function up$104(db) {
4939
+ async function up$105(db) {
4940
4940
  await sql`ALTER TABLE public.agent_tokens
4941
4941
  ADD COLUMN IF NOT EXISTS mandatory_labels text`.execute(db);
4942
4942
  }
4943
- async function down$104(db) {
4943
+ async function down$105(db) {
4944
4944
  await sql`ALTER TABLE public.agent_tokens
4945
4945
  DROP COLUMN IF EXISTS mandatory_labels`.execute(db);
4946
4946
  }
4947
4947
  //#endregion
4948
4948
  //#region src/db/migrations/056_execution_jobs_environments.ts
4949
4949
  var _056_execution_jobs_environments_exports = /* @__PURE__ */ __exportAll({
4950
- down: () => down$103,
4951
- up: () => up$103
4950
+ down: () => down$104,
4951
+ up: () => up$104
4952
4952
  });
4953
4953
  /**
4954
4954
  * Add `execution_jobs.environments`: a JSON-encoded `string[]` of the environment names a job
@@ -4956,19 +4956,19 @@ var _056_execution_jobs_environments_exports = /* @__PURE__ */ __exportAll({
4956
4956
  * `(dynamic)` placeholder), then overwritten with the full list when a deferred-init agent eval
4957
4957
  * resolves them. NULL = no environment. Idempotent and additive.
4958
4958
  */
4959
- async function up$103(db) {
4959
+ async function up$104(db) {
4960
4960
  await sql`ALTER TABLE public.execution_jobs
4961
4961
  ADD COLUMN IF NOT EXISTS environments text`.execute(db);
4962
4962
  }
4963
- async function down$103(db) {
4963
+ async function down$104(db) {
4964
4964
  await sql`ALTER TABLE public.execution_jobs
4965
4965
  DROP COLUMN IF EXISTS environments`.execute(db);
4966
4966
  }
4967
4967
  //#endregion
4968
4968
  //#region src/db/migrations/057_step_concurrency.ts
4969
4969
  var _057_step_concurrency_exports = /* @__PURE__ */ __exportAll({
4970
- down: () => down$102,
4971
- up: () => up$102
4970
+ down: () => down$103,
4971
+ up: () => up$103
4972
4972
  });
4973
4973
  /**
4974
4974
  * Add parallel step-group concurrency columns to `execution_steps`:
@@ -4991,19 +4991,19 @@ async function colExists$16(db, table, name) {
4991
4991
  ) AS exists
4992
4992
  `.execute(db)).rows[0]?.exists ?? false;
4993
4993
  }
4994
- async function up$102(db) {
4994
+ async function up$103(db) {
4995
4995
  if (!await colExists$16(db, "execution_steps", "concurrency_kind")) await sql`ALTER TABLE public.execution_steps ADD COLUMN concurrency_kind text`.execute(db);
4996
4996
  if (!await colExists$16(db, "execution_steps", "group_id")) await sql`ALTER TABLE public.execution_steps ADD COLUMN group_id text`.execute(db);
4997
4997
  }
4998
- async function down$102(db) {
4998
+ async function down$103(db) {
4999
4999
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS group_id`.execute(db);
5000
5000
  await sql`ALTER TABLE public.execution_steps DROP COLUMN IF EXISTS concurrency_kind`.execute(db);
5001
5001
  }
5002
5002
  //#endregion
5003
5003
  //#region src/db/migrations/058_access_log_agent_label.ts
5004
5004
  var _058_access_log_agent_label_exports = /* @__PURE__ */ __exportAll({
5005
- down: () => down$101,
5006
- up: () => up$101
5005
+ down: () => down$102,
5006
+ up: () => up$102
5007
5007
  });
5008
5008
  /**
5009
5009
  * Add `access_log.agent_label text` — the human-set name of the agent that
@@ -5023,17 +5023,17 @@ async function colExists$15(db, table, name) {
5023
5023
  ) AS exists
5024
5024
  `.execute(db)).rows[0]?.exists ?? false;
5025
5025
  }
5026
- async function up$101(db) {
5026
+ async function up$102(db) {
5027
5027
  if (!await colExists$15(db, "access_log", "agent_label")) await sql`ALTER TABLE public.access_log ADD COLUMN agent_label text`.execute(db);
5028
5028
  }
5029
- async function down$101(db) {
5029
+ async function down$102(db) {
5030
5030
  await sql`ALTER TABLE public.access_log DROP COLUMN IF EXISTS agent_label`.execute(db);
5031
5031
  }
5032
5032
  //#endregion
5033
5033
  //#region src/db/migrations/059_attestation_verdict.ts
5034
5034
  var _059_attestation_verdict_exports = /* @__PURE__ */ __exportAll({
5035
- down: () => down$100,
5036
- up: () => up$100
5035
+ down: () => down$101,
5036
+ up: () => up$101
5037
5037
  });
5038
5038
  /**
5039
5039
  * Add server-side verification verdict columns to `attestations`, plus the
@@ -5060,7 +5060,7 @@ async function colExists$14(db, table, name) {
5060
5060
  ) AS exists
5061
5061
  `.execute(db)).rows[0]?.exists ?? false;
5062
5062
  }
5063
- async function up$100(db) {
5063
+ async function up$101(db) {
5064
5064
  if (await colExists$14(db, "attestations", "verify_status")) return;
5065
5065
  await sql`
5066
5066
  ALTER TABLE public.attestations
@@ -5073,7 +5073,7 @@ async function up$100(db) {
5073
5073
  await sql`CREATE INDEX idx_attestations_verify_status ON public.attestations (verify_status)`.execute(db);
5074
5074
  await sql`CREATE INDEX idx_attestations_created_at ON public.attestations (created_at)`.execute(db);
5075
5075
  }
5076
- async function down$100(db) {
5076
+ async function down$101(db) {
5077
5077
  await sql`DROP INDEX IF EXISTS idx_attestations_created_at`.execute(db);
5078
5078
  await sql`DROP INDEX IF EXISTS idx_attestations_verify_status`.execute(db);
5079
5079
  await sql`DROP INDEX IF EXISTS idx_attestations_subject_name`.execute(db);
@@ -5088,8 +5088,8 @@ async function down$100(db) {
5088
5088
  //#endregion
5089
5089
  //#region src/db/migrations/060_run_trigger_actor.ts
5090
5090
  var _060_run_trigger_actor_exports = /* @__PURE__ */ __exportAll({
5091
- down: () => down$99,
5092
- up: () => up$99
5091
+ down: () => down$100,
5092
+ up: () => up$100
5093
5093
  });
5094
5094
  /**
5095
5095
  * Triggering-actor columns on `execution_runs`:
@@ -5115,12 +5115,12 @@ async function colExists$13(db, table, name) {
5115
5115
  ) AS exists
5116
5116
  `.execute(db)).rows[0]?.exists ?? false;
5117
5117
  }
5118
- async function up$99(db) {
5118
+ async function up$100(db) {
5119
5119
  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);
5120
5120
  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);
5121
5121
  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);
5122
5122
  }
5123
- async function down$99(db) {
5123
+ async function down$100(db) {
5124
5124
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_actor_provider`.execute(db);
5125
5125
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_actor_username`.execute(db);
5126
5126
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_actor_user_id`.execute(db);
@@ -5128,8 +5128,8 @@ async function down$99(db) {
5128
5128
  //#endregion
5129
5129
  //#region src/db/migrations/061_execution_runs_environment_id.ts
5130
5130
  var _061_execution_runs_environment_id_exports = /* @__PURE__ */ __exportAll({
5131
- down: () => down$98,
5132
- up: () => up$98
5131
+ down: () => down$99,
5132
+ up: () => up$99
5133
5133
  });
5134
5134
  /**
5135
5135
  * `execution_runs.environment_id`, so environment run-history keys off the matched
@@ -5157,7 +5157,7 @@ async function colExists$12(db, table, name) {
5157
5157
  ) AS exists
5158
5158
  `.execute(db)).rows[0]?.exists ?? false;
5159
5159
  }
5160
- async function up$98(db) {
5160
+ async function up$99(db) {
5161
5161
  if (!await colExists$12(db, "execution_runs", "environment_id")) await sql`
5162
5162
  ALTER TABLE public.execution_runs
5163
5163
  ADD COLUMN environment_id uuid
@@ -5179,15 +5179,15 @@ async function up$98(db) {
5179
5179
  WHERE e2.type = 'fixed' AND e2.name = er.environment) = 1
5180
5180
  `.execute(db);
5181
5181
  }
5182
- async function down$98(db) {
5182
+ async function down$99(db) {
5183
5183
  await sql`DROP INDEX IF EXISTS idx_execution_runs_environment_id`.execute(db);
5184
5184
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS environment_id`.execute(db);
5185
5185
  }
5186
5186
  //#endregion
5187
5187
  //#region src/db/migrations/062_execution_runs_agent_label.ts
5188
5188
  var _062_execution_runs_agent_label_exports = /* @__PURE__ */ __exportAll({
5189
- down: () => down$97,
5190
- up: () => up$97
5189
+ down: () => down$98,
5190
+ up: () => up$98
5191
5191
  });
5192
5192
  /**
5193
5193
  * Agent provenance on `execution_runs`: `triggered_by_agent_label` / `cancelled_by_agent_label`
@@ -5207,19 +5207,19 @@ async function colExists$11(db, table, name) {
5207
5207
  ) AS exists
5208
5208
  `.execute(db)).rows[0]?.exists ?? false;
5209
5209
  }
5210
- async function up$97(db) {
5210
+ async function up$98(db) {
5211
5211
  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);
5212
5212
  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);
5213
5213
  }
5214
- async function down$97(db) {
5214
+ async function down$98(db) {
5215
5215
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS triggered_by_agent_label`.execute(db);
5216
5216
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS cancelled_by_agent_label`.execute(db);
5217
5217
  }
5218
5218
  //#endregion
5219
5219
  //#region src/db/migrations/063_access_log_agent_label_index.ts
5220
5220
  var _063_access_log_agent_label_index_exports = /* @__PURE__ */ __exportAll({
5221
- down: () => down$96,
5222
- up: () => up$96
5221
+ down: () => down$97,
5222
+ up: () => up$97
5223
5223
  });
5224
5224
  /**
5225
5225
  * Index `access_log.agent_label` (column added by migration 058) so the
@@ -5227,17 +5227,17 @@ var _063_access_log_agent_label_index_exports = /* @__PURE__ */ __exportAll({
5227
5227
  * the dashboard "agent name" filter) does an indexed exact-match lookup
5228
5228
  * instead of a scan. Idempotent.
5229
5229
  */
5230
- async function up$96(db) {
5230
+ async function up$97(db) {
5231
5231
  await sql`CREATE INDEX IF NOT EXISTS access_log_agent_label_idx ON public.access_log (agent_label)`.execute(db);
5232
5232
  }
5233
- async function down$96(db) {
5233
+ async function down$97(db) {
5234
5234
  await sql`DROP INDEX IF EXISTS access_log_agent_label_idx`.execute(db);
5235
5235
  }
5236
5236
  //#endregion
5237
5237
  //#region src/db/migrations/064_execution_jobs_skipped_environments.ts
5238
5238
  var _064_execution_jobs_skipped_environments_exports = /* @__PURE__ */ __exportAll({
5239
- down: () => down$95,
5240
- up: () => up$95
5239
+ down: () => down$96,
5240
+ up: () => up$96
5241
5241
  });
5242
5242
  /**
5243
5243
  * Test-run skipped environments on `execution_jobs`:
@@ -5249,13 +5249,13 @@ var _064_execution_jobs_skipped_environments_exports = /* @__PURE__ */ __exportA
5249
5249
  *
5250
5250
  * Idempotent and additive.
5251
5251
  */
5252
- async function up$95(db) {
5252
+ async function up$96(db) {
5253
5253
  await sql`ALTER TABLE public.execution_jobs
5254
5254
  ADD COLUMN IF NOT EXISTS skipped_environments text`.execute(db);
5255
5255
  await sql`ALTER TABLE public.execution_jobs
5256
5256
  ADD COLUMN IF NOT EXISTS env_warning text`.execute(db);
5257
5257
  }
5258
- async function down$95(db) {
5258
+ async function down$96(db) {
5259
5259
  await sql`ALTER TABLE public.execution_jobs
5260
5260
  DROP COLUMN IF EXISTS skipped_environments`.execute(db);
5261
5261
  await sql`ALTER TABLE public.execution_jobs
@@ -5264,8 +5264,8 @@ async function down$95(db) {
5264
5264
  //#endregion
5265
5265
  //#region src/db/migrations/065_pending_attestations.ts
5266
5266
  var _065_pending_attestations_exports = /* @__PURE__ */ __exportAll({
5267
- down: () => down$94,
5268
- up: () => up$94
5267
+ down: () => down$95,
5268
+ up: () => up$95
5269
5269
  });
5270
5270
  /**
5271
5271
  * The `pending_attestations` deferred-attestation outbox, plus an idempotency unique index on
@@ -5282,7 +5282,7 @@ var _065_pending_attestations_exports = /* @__PURE__ */ __exportAll({
5282
5282
  *
5283
5283
  * Idempotent: guarded on table existence.
5284
5284
  */
5285
- async function up$94(db) {
5285
+ async function up$95(db) {
5286
5286
  if ((await sql`
5287
5287
  SELECT EXISTS (
5288
5288
  SELECT 1 FROM information_schema.tables
@@ -5321,15 +5321,15 @@ async function up$94(db) {
5321
5321
  ON public.attestations (run_id, job_id, subject_digest)
5322
5322
  `.execute(db);
5323
5323
  }
5324
- async function down$94(db) {
5324
+ async function down$95(db) {
5325
5325
  await sql`DROP INDEX IF EXISTS uq_attestations_run_job_subject`.execute(db);
5326
5326
  await sql`DROP TABLE IF EXISTS public.pending_attestations`.execute(db);
5327
5327
  }
5328
5328
  //#endregion
5329
5329
  //#region src/db/migrations/066_pending_attestations_rejected.ts
5330
5330
  var _066_pending_attestations_rejected_exports = /* @__PURE__ */ __exportAll({
5331
- down: () => down$93,
5332
- up: () => up$93
5331
+ down: () => down$94,
5332
+ up: () => up$94
5333
5333
  });
5334
5334
  /**
5335
5335
  * Add `pending_attestations.rejected_at`: marks a deferred attestation the Platform definitively
@@ -5337,14 +5337,14 @@ var _066_pending_attestations_rejected_exports = /* @__PURE__ */ __exportAll({
5337
5337
  * pending-attestations gauge; `kici-admin attestations retry --include-rejected` re-arms it.
5338
5338
  * Idempotent.
5339
5339
  */
5340
- async function up$93(db) {
5340
+ async function up$94(db) {
5341
5341
  if (await columnExists$15(db, "pending_attestations", "rejected_at")) return;
5342
5342
  await sql`
5343
5343
  ALTER TABLE public.pending_attestations
5344
5344
  ADD COLUMN rejected_at TIMESTAMPTZ
5345
5345
  `.execute(db);
5346
5346
  }
5347
- async function down$93(db) {
5347
+ async function down$94(db) {
5348
5348
  if (!await columnExists$15(db, "pending_attestations", "rejected_at")) return;
5349
5349
  await sql`
5350
5350
  ALTER TABLE public.pending_attestations
@@ -5362,8 +5362,8 @@ async function columnExists$15(db, table, column) {
5362
5362
  //#endregion
5363
5363
  //#region src/db/migrations/067_environments_to_contexts.ts
5364
5364
  var _067_environments_to_contexts_exports = /* @__PURE__ */ __exportAll({
5365
- down: () => down$92,
5366
- up: () => up$92
5365
+ down: () => down$93,
5366
+ up: () => up$93
5367
5367
  });
5368
5368
  /**
5369
5369
  * Rename the named-policy object from "environment" to "context" across the
@@ -5397,7 +5397,7 @@ var _067_environments_to_contexts_exports = /* @__PURE__ */ __exportAll({
5397
5397
  * columns automatically (Postgres references them by identity, not name), so
5398
5398
  * only the one hand-named index above needs an explicit rename.
5399
5399
  */
5400
- async function up$92(db) {
5400
+ async function up$93(db) {
5401
5401
  await sql`ALTER TABLE public.environments RENAME TO contexts`.execute(db);
5402
5402
  await sql`ALTER TABLE public.environment_bindings RENAME TO context_bindings`.execute(db);
5403
5403
  await sql`ALTER TABLE public.environment_variables RENAME TO context_variables`.execute(db);
@@ -5416,7 +5416,7 @@ async function up$92(db) {
5416
5416
  await sql`ALTER TABLE public.held_runs ALTER COLUMN queue_type SET DEFAULT 'context'`.execute(db);
5417
5417
  await sql`ALTER TABLE public.held_runs ALTER COLUMN trigger_source SET DEFAULT 'context'`.execute(db);
5418
5418
  }
5419
- async function down$92(db) {
5419
+ async function down$93(db) {
5420
5420
  await sql`ALTER TABLE public.held_runs ALTER COLUMN trigger_source SET DEFAULT 'environment'`.execute(db);
5421
5421
  await sql`ALTER TABLE public.held_runs ALTER COLUMN queue_type SET DEFAULT 'environment'`.execute(db);
5422
5422
  await sql`UPDATE public.held_runs SET trigger_source = 'environment' WHERE trigger_source = 'context'`.execute(db);
@@ -5438,8 +5438,8 @@ async function down$92(db) {
5438
5438
  //#endregion
5439
5439
  //#region src/db/migrations/068_request_idempotency.ts
5440
5440
  var _068_request_idempotency_exports = /* @__PURE__ */ __exportAll({
5441
- down: () => down$91,
5442
- up: () => up$91
5441
+ down: () => down$92,
5442
+ up: () => up$92
5443
5443
  });
5444
5444
  /**
5445
5445
  * Add the `request_idempotency` claim table, making run-minting dashboard
@@ -5452,12 +5452,12 @@ var _068_request_idempotency_exports = /* @__PURE__ */ __exportAll({
5452
5452
  *
5453
5453
  * Idempotent: guarded on table existence.
5454
5454
  */
5455
- async function up$91(db) {
5455
+ async function up$92(db) {
5456
5456
  if (await tableExists$5(db, "request_idempotency")) return;
5457
5457
  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();
5458
5458
  await db.schema.createIndex("idx_request_idempotency_created_at").on("request_idempotency").column("created_at").execute();
5459
5459
  }
5460
- async function down$91(db) {
5460
+ async function down$92(db) {
5461
5461
  await db.schema.dropTable("request_idempotency").ifExists().execute();
5462
5462
  }
5463
5463
  async function tableExists$5(db, table) {
@@ -5471,8 +5471,8 @@ async function tableExists$5(db, table) {
5471
5471
  //#endregion
5472
5472
  //#region src/db/migrations/069_reroute_tunables.ts
5473
5473
  var _069_reroute_tunables_exports = /* @__PURE__ */ __exportAll({
5474
- down: () => down$90,
5475
- up: () => up$90
5474
+ down: () => down$91,
5475
+ up: () => up$91
5476
5476
  });
5477
5477
  /**
5478
5478
  * Add the per-org reroute tunables to `org_settings` (nullable; NULL is the cluster default; set
@@ -5483,12 +5483,12 @@ var _069_reroute_tunables_exports = /* @__PURE__ */ __exportAll({
5483
5483
  * - `reroute_ack_timeout_ms` — the reroute `sendAndWaitAck` deadline (`rerouteAckTimeoutMs`, 15s).
5484
5484
  * - `reroute_max_hops` — max peer hops for a rerouted job (`rerouteMaxHops`, 3).
5485
5485
  */
5486
- async function up$90(db) {
5486
+ async function up$91(db) {
5487
5487
  await addColumnIfMissing$1(db, "reroute_spawn_window_ms", "BIGINT");
5488
5488
  await addColumnIfMissing$1(db, "reroute_ack_timeout_ms", "BIGINT");
5489
5489
  await addColumnIfMissing$1(db, "reroute_max_hops", "INTEGER");
5490
5490
  }
5491
- async function down$90(db) {
5491
+ async function down$91(db) {
5492
5492
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_spawn_window_ms`.execute(db);
5493
5493
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_ack_timeout_ms`.execute(db);
5494
5494
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_max_hops`.execute(db);
@@ -5507,8 +5507,8 @@ async function addColumnIfMissing$1(db, column, type) {
5507
5507
  //#endregion
5508
5508
  //#region src/db/migrations/070_execution_runs_failure_class.ts
5509
5509
  var _070_execution_runs_failure_class_exports = /* @__PURE__ */ __exportAll({
5510
- down: () => down$89,
5511
- up: () => up$89
5510
+ down: () => down$90,
5511
+ up: () => up$90
5512
5512
  });
5513
5513
  /**
5514
5514
  * `execution_runs.failure_class` (`RunFailureClass`: never_started / timed_out /
@@ -5527,17 +5527,17 @@ async function colExists$10(db, table, name) {
5527
5527
  ) AS exists
5528
5528
  `.execute(db)).rows[0]?.exists ?? false;
5529
5529
  }
5530
- async function up$89(db) {
5530
+ async function up$90(db) {
5531
5531
  if (!await colExists$10(db, "execution_runs", "failure_class")) await sql`ALTER TABLE public.execution_runs ADD COLUMN failure_class text`.execute(db);
5532
5532
  }
5533
- async function down$89(db) {
5533
+ async function down$90(db) {
5534
5534
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS failure_class`.execute(db);
5535
5535
  }
5536
5536
  //#endregion
5537
5537
  //#region src/db/migrations/071_batch_accumulation.ts
5538
5538
  var _071_batch_accumulation_exports = /* @__PURE__ */ __exportAll({
5539
- down: () => down$88,
5540
- up: () => up$88
5539
+ down: () => down$89,
5540
+ up: () => up$89
5541
5541
  });
5542
5542
  /**
5543
5543
  * Batch-accumulation tables behind the `workflows_failed_batch` trigger.
@@ -5553,7 +5553,7 @@ var _071_batch_accumulation_exports = /* @__PURE__ */ __exportAll({
5553
5553
  *
5554
5554
  * Idempotent: guarded on table existence.
5555
5555
  */
5556
- async function up$88(db) {
5556
+ async function up$89(db) {
5557
5557
  if ((await sql`
5558
5558
  SELECT EXISTS (
5559
5559
  SELECT 1 FROM information_schema.tables
@@ -5598,35 +5598,35 @@ async function up$88(db) {
5598
5598
  ON public.batch_accumulation_items (window_id)
5599
5599
  `.execute(db);
5600
5600
  }
5601
- async function down$88(db) {
5601
+ async function down$89(db) {
5602
5602
  await sql`DROP TABLE IF EXISTS public.batch_accumulation_items`.execute(db);
5603
5603
  await sql`DROP TABLE IF EXISTS public.batch_accumulation_windows`.execute(db);
5604
5604
  }
5605
5605
  //#endregion
5606
5606
  //#region src/db/migrations/072_dispatch_queue_run_id_index.ts
5607
5607
  var _072_dispatch_queue_run_id_index_exports = /* @__PURE__ */ __exportAll({
5608
- down: () => down$87,
5609
- up: () => up$87
5608
+ down: () => down$88,
5609
+ up: () => up$88
5610
5610
  });
5611
5611
  /**
5612
5612
  * `failByRunId`, `cancelByRunId` and `getDispatchedJobIdsByRunId` filter on `run_id`; without
5613
5613
  * this index each run-failure cascade and cancel full-scans the dispatch history while holding
5614
5614
  * a pooled connection. `pruneTerminalDispatchRows` also uses it. Idempotent.
5615
5615
  */
5616
- async function up$87(db) {
5616
+ async function up$88(db) {
5617
5617
  await sql`
5618
5618
  CREATE INDEX IF NOT EXISTS idx_dispatch_queue_run_id
5619
5619
  ON public.dispatch_queue (run_id)
5620
5620
  `.execute(db);
5621
5621
  }
5622
- async function down$87(db) {
5622
+ async function down$88(db) {
5623
5623
  await sql`DROP INDEX IF EXISTS public.idx_dispatch_queue_run_id`.execute(db);
5624
5624
  }
5625
5625
  //#endregion
5626
5626
  //#region src/db/migrations/073_org_settings_ingest_concurrency.ts
5627
5627
  var _073_org_settings_ingest_concurrency_exports = /* @__PURE__ */ __exportAll({
5628
- down: () => down$86,
5629
- up: () => up$86
5628
+ down: () => down$87,
5629
+ up: () => up$87
5630
5630
  });
5631
5631
  /**
5632
5632
  * Add `org_settings.ingest_max_concurrency BIGINT` (nullable).
@@ -5637,7 +5637,7 @@ var _073_org_settings_ingest_concurrency_exports = /* @__PURE__ */ __exportAll({
5637
5637
  *
5638
5638
  * Idempotent: a re-run on a DB that already has the column is a no-op.
5639
5639
  */
5640
- async function up$86(db) {
5640
+ async function up$87(db) {
5641
5641
  if ((await sql`
5642
5642
  SELECT EXISTS (
5643
5643
  SELECT 1 FROM information_schema.columns
@@ -5651,7 +5651,7 @@ async function up$86(db) {
5651
5651
  ADD COLUMN ingest_max_concurrency BIGINT
5652
5652
  `.execute(db);
5653
5653
  }
5654
- async function down$86(db) {
5654
+ async function down$87(db) {
5655
5655
  await sql`
5656
5656
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS ingest_max_concurrency
5657
5657
  `.execute(db);
@@ -5659,8 +5659,8 @@ async function down$86(db) {
5659
5659
  //#endregion
5660
5660
  //#region src/db/migrations/074_normalize_zero_concurrency_limit.ts
5661
5661
  var _074_normalize_zero_concurrency_limit_exports = /* @__PURE__ */ __exportAll({
5662
- down: () => down$85,
5663
- up: () => up$85
5662
+ down: () => down$86,
5663
+ up: () => up$86
5664
5664
  });
5665
5665
  /**
5666
5666
  * Normalize non-positive `concurrency_limit` values, which wedge the workflow-install gate in
@@ -5668,15 +5668,15 @@ var _074_normalize_zero_concurrency_limit_exports = /* @__PURE__ */ __exportAll(
5668
5668
  * integer. The write boundary rejects them and the gate treats them as unlimited.
5669
5669
  * Idempotent; down() is a no-op.
5670
5670
  */
5671
- async function up$85(db) {
5671
+ async function up$86(db) {
5672
5672
  await sql`UPDATE public.contexts SET concurrency_limit = NULL WHERE concurrency_limit <= 0`.execute(db);
5673
5673
  }
5674
- async function down$85(_db) {}
5674
+ async function down$86(_db) {}
5675
5675
  //#endregion
5676
5676
  //#region src/db/migrations/075_ingest_overflow_buffer.ts
5677
5677
  var _075_ingest_overflow_buffer_exports = /* @__PURE__ */ __exportAll({
5678
- down: () => down$84,
5679
- up: () => up$84
5678
+ down: () => down$85,
5679
+ up: () => up$85
5680
5680
  });
5681
5681
  /**
5682
5682
  * Durable overflow buffer for shed webhook-ingest deliveries.
@@ -5690,7 +5690,7 @@ var _075_ingest_overflow_buffer_exports = /* @__PURE__ */ __exportAll({
5690
5690
  *
5691
5691
  * Idempotent: a re-run on a DB that already has the table is a no-op.
5692
5692
  */
5693
- async function up$84(db) {
5693
+ async function up$85(db) {
5694
5694
  if ((await sql`
5695
5695
  SELECT EXISTS (
5696
5696
  SELECT 1 FROM information_schema.tables
@@ -5723,14 +5723,14 @@ async function up$84(db) {
5723
5723
  ON public.ingest_overflow_buffer (delivery_id)
5724
5724
  `.execute(db);
5725
5725
  }
5726
- async function down$84(db) {
5726
+ async function down$85(db) {
5727
5727
  await sql`DROP TABLE IF EXISTS public.ingest_overflow_buffer`.execute(db);
5728
5728
  }
5729
5729
  //#endregion
5730
5730
  //#region src/db/migrations/076_artifacts.ts
5731
5731
  var _076_artifacts_exports = /* @__PURE__ */ __exportAll({
5732
- down: () => down$83,
5733
- up: () => up$83
5732
+ down: () => down$84,
5733
+ up: () => up$84
5734
5734
  });
5735
5735
  /**
5736
5736
  * Add the `artifacts` table for user-facing build artifacts and the per-org
@@ -5746,7 +5746,7 @@ var _076_artifacts_exports = /* @__PURE__ */ __exportAll({
5746
5746
  *
5747
5747
  * Idempotent.
5748
5748
  */
5749
- async function up$83(db) {
5749
+ async function up$84(db) {
5750
5750
  if (!(await sql`
5751
5751
  SELECT EXISTS (
5752
5752
  SELECT 1 FROM information_schema.tables
@@ -5782,7 +5782,7 @@ async function up$83(db) {
5782
5782
  ADD COLUMN IF NOT EXISTS artifact_ttl_ms BIGINT
5783
5783
  `.execute(db);
5784
5784
  }
5785
- async function down$83(db) {
5785
+ async function down$84(db) {
5786
5786
  await sql`DROP TABLE IF EXISTS public.artifacts`.execute(db);
5787
5787
  await sql`
5788
5788
  ALTER TABLE public.org_settings
@@ -5793,8 +5793,8 @@ async function down$83(db) {
5793
5793
  //#endregion
5794
5794
  //#region src/db/migrations/077_backup_runs.ts
5795
5795
  var _077_backup_runs_exports = /* @__PURE__ */ __exportAll({
5796
- down: () => down$82,
5797
- up: () => up$82
5796
+ down: () => down$83,
5797
+ up: () => up$83
5798
5798
  });
5799
5799
  /**
5800
5800
  * Add the `backup_runs` table: one row per successful `kici-admin db backup`,
@@ -5805,12 +5805,12 @@ var _077_backup_runs_exports = /* @__PURE__ */ __exportAll({
5805
5805
  *
5806
5806
  * Idempotent: guarded on table existence.
5807
5807
  */
5808
- async function up$82(db) {
5808
+ async function up$83(db) {
5809
5809
  if (await tableExists$4(db, "backup_runs")) return;
5810
5810
  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();
5811
5811
  await db.schema.createIndex("idx_backup_runs_created_at").on("backup_runs").column("created_at").execute();
5812
5812
  }
5813
- async function down$82(db) {
5813
+ async function down$83(db) {
5814
5814
  await db.schema.dropTable("backup_runs").ifExists().execute();
5815
5815
  }
5816
5816
  async function tableExists$4(db, table) {
@@ -5824,15 +5824,15 @@ async function tableExists$4(db, table) {
5824
5824
  //#endregion
5825
5825
  //#region src/db/migrations/078_org_settings_backup_staleness.ts
5826
5826
  var _078_org_settings_backup_staleness_exports = /* @__PURE__ */ __exportAll({
5827
- down: () => down$81,
5828
- up: () => up$81
5827
+ down: () => down$82,
5828
+ up: () => up$82
5829
5829
  });
5830
5830
  /**
5831
5831
  * Add `org_settings.backup_staleness_warn_hours`: the per-org WARN threshold for the DB-backup
5832
5832
  * freshness diagnostic, set via `kici-admin org-settings backup-freshness`. NULL is the cluster
5833
5833
  * default (`config.backupStalenessWarnHours`, 24h). Idempotent.
5834
5834
  */
5835
- async function up$81(db) {
5835
+ async function up$82(db) {
5836
5836
  if ((await sql`
5837
5837
  SELECT EXISTS (
5838
5838
  SELECT 1 FROM information_schema.columns
@@ -5846,7 +5846,7 @@ async function up$81(db) {
5846
5846
  ADD COLUMN backup_staleness_warn_hours INTEGER
5847
5847
  `.execute(db);
5848
5848
  }
5849
- async function down$81(db) {
5849
+ async function down$82(db) {
5850
5850
  await sql`
5851
5851
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS backup_staleness_warn_hours
5852
5852
  `.execute(db);
@@ -5854,8 +5854,8 @@ async function down$81(db) {
5854
5854
  //#endregion
5855
5855
  //#region src/db/migrations/079_org_settings_scaler_spawn_timeout.ts
5856
5856
  var _079_org_settings_scaler_spawn_timeout_exports = /* @__PURE__ */ __exportAll({
5857
- down: () => down$80,
5858
- up: () => up$80
5857
+ down: () => down$81,
5858
+ up: () => up$81
5859
5859
  });
5860
5860
  /**
5861
5861
  * `org_settings.scaler_spawn_timeout_ms BIGINT` (nullable): per-org deadline
@@ -5863,7 +5863,7 @@ var _079_org_settings_scaler_spawn_timeout_exports = /* @__PURE__ */ __exportAll
5863
5863
  * falls back to `KICI_SCALER_SPAWN_TIMEOUT_MS` (default 300s). Tuned per tenant
5864
5864
  * via `kici-admin org-settings scaler-spawn-timeout`. Idempotent.
5865
5865
  */
5866
- async function up$80(db) {
5866
+ async function up$81(db) {
5867
5867
  if ((await sql`
5868
5868
  SELECT EXISTS (
5869
5869
  SELECT 1 FROM information_schema.columns
@@ -5877,7 +5877,7 @@ async function up$80(db) {
5877
5877
  ADD COLUMN scaler_spawn_timeout_ms BIGINT
5878
5878
  `.execute(db);
5879
5879
  }
5880
- async function down$80(db) {
5880
+ async function down$81(db) {
5881
5881
  await sql`
5882
5882
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS scaler_spawn_timeout_ms
5883
5883
  `.execute(db);
@@ -5885,8 +5885,8 @@ async function down$80(db) {
5885
5885
  //#endregion
5886
5886
  //#region src/db/migrations/080_cluster_settings.ts
5887
5887
  var _080_cluster_settings_exports = /* @__PURE__ */ __exportAll({
5888
- down: () => down$79,
5889
- up: () => up$79
5888
+ down: () => down$80,
5889
+ up: () => up$80
5890
5890
  });
5891
5891
  /**
5892
5892
  * Create `cluster_settings`: a single-row (id='default') table of fleet-wide operator tunables;
@@ -5897,7 +5897,7 @@ var _080_cluster_settings_exports = /* @__PURE__ */ __exportAll({
5897
5897
  * Read via ClusterSettingsReader (whole-row, short-TTL cache); written via
5898
5898
  * `/api/v1/admin/cluster-settings` and `kici-admin cluster-settings`. Idempotent.
5899
5899
  */
5900
- async function up$79(db) {
5900
+ async function up$80(db) {
5901
5901
  if ((await sql`
5902
5902
  SELECT EXISTS (
5903
5903
  SELECT 1 FROM information_schema.tables
@@ -5921,14 +5921,14 @@ async function up$79(db) {
5921
5921
  )
5922
5922
  `.execute(db);
5923
5923
  }
5924
- async function down$79(db) {
5924
+ async function down$80(db) {
5925
5925
  await sql`DROP TABLE IF EXISTS public.cluster_settings`.execute(db);
5926
5926
  }
5927
5927
  //#endregion
5928
5928
  //#region src/db/migrations/081_org_settings_queue_timeout.ts
5929
5929
  var _081_org_settings_queue_timeout_exports = /* @__PURE__ */ __exportAll({
5930
- down: () => down$78,
5931
- up: () => up$78
5930
+ down: () => down$79,
5931
+ up: () => up$79
5932
5932
  });
5933
5933
  /**
5934
5934
  * `org_settings.queue_timeout_ms BIGINT` (nullable): per-org dispatch-queue job
@@ -5941,7 +5941,7 @@ var _081_org_settings_queue_timeout_exports = /* @__PURE__ */ __exportAll({
5941
5941
  * `cacheOrgId` in scope; fleet-wide tunables live on `cluster_settings`
5942
5942
  * (migration 080). Idempotent.
5943
5943
  */
5944
- async function up$78(db) {
5944
+ async function up$79(db) {
5945
5945
  if ((await sql`
5946
5946
  SELECT EXISTS (
5947
5947
  SELECT 1 FROM information_schema.columns
@@ -5955,7 +5955,7 @@ async function up$78(db) {
5955
5955
  ADD COLUMN queue_timeout_ms BIGINT
5956
5956
  `.execute(db);
5957
5957
  }
5958
- async function down$78(db) {
5958
+ async function down$79(db) {
5959
5959
  await sql`
5960
5960
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS queue_timeout_ms
5961
5961
  `.execute(db);
@@ -5963,8 +5963,8 @@ async function down$78(db) {
5963
5963
  //#endregion
5964
5964
  //#region src/db/migrations/082_host_s3_reachable.ts
5965
5965
  var _082_host_s3_reachable_exports = /* @__PURE__ */ __exportAll({
5966
- down: () => down$77,
5967
- up: () => up$77
5966
+ down: () => down$78,
5967
+ up: () => up$78
5968
5968
  });
5969
5969
  /**
5970
5970
  * Add `host_roster.s3_reachable`, a fresh-box bring-up delivery hint set via
@@ -5973,7 +5973,7 @@ var _082_host_s3_reachable_exports = /* @__PURE__ */ __exportAll({
5973
5973
  * through the ops agent). NULL / false: the `ssh-push` fallback (the ops agent fetches the
5974
5974
  * payload and scp's it to the box). Idempotent.
5975
5975
  */
5976
- async function up$77(db) {
5976
+ async function up$78(db) {
5977
5977
  if ((await sql`
5978
5978
  SELECT EXISTS (
5979
5979
  SELECT 1 FROM information_schema.columns
@@ -5987,7 +5987,7 @@ async function up$77(db) {
5987
5987
  ADD COLUMN s3_reachable BOOLEAN
5988
5988
  `.execute(db);
5989
5989
  }
5990
- async function down$77(db) {
5990
+ async function down$78(db) {
5991
5991
  await sql`
5992
5992
  ALTER TABLE public.host_roster DROP COLUMN IF EXISTS s3_reachable
5993
5993
  `.execute(db);
@@ -5995,8 +5995,8 @@ async function down$77(db) {
5995
5995
  //#endregion
5996
5996
  //#region src/db/migrations/083_org_settings_artifact_caps.ts
5997
5997
  var _083_org_settings_artifact_caps_exports = /* @__PURE__ */ __exportAll({
5998
- down: () => down$76,
5999
- up: () => up$76
5998
+ down: () => down$77,
5999
+ up: () => up$77
6000
6000
  });
6001
6001
  /**
6002
6002
  * Add `org_settings.artifact_max_bytes` + `artifact_max_per_run` (both nullable
@@ -6010,7 +6010,7 @@ var _083_org_settings_artifact_caps_exports = /* @__PURE__ */ __exportAll({
6010
6010
  *
6011
6011
  * Idempotent: guarded on column existence.
6012
6012
  */
6013
- async function up$76(db) {
6013
+ async function up$77(db) {
6014
6014
  for (const col of ["artifact_max_bytes", "artifact_max_per_run"]) {
6015
6015
  if ((await sql`
6016
6016
  SELECT EXISTS (
@@ -6023,15 +6023,15 @@ async function up$76(db) {
6023
6023
  await sql`ALTER TABLE public.org_settings ADD COLUMN ${sql.ref(col)} BIGINT`.execute(db);
6024
6024
  }
6025
6025
  }
6026
- async function down$76(db) {
6026
+ async function down$77(db) {
6027
6027
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS artifact_max_bytes`.execute(db);
6028
6028
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS artifact_max_per_run`.execute(db);
6029
6029
  }
6030
6030
  //#endregion
6031
6031
  //#region src/db/migrations/084_orchestrator_signing_keys.ts
6032
6032
  var _084_orchestrator_signing_keys_exports = /* @__PURE__ */ __exportAll({
6033
- down: () => down$75,
6034
- up: () => up$75
6033
+ down: () => down$76,
6034
+ up: () => up$76
6035
6035
  });
6036
6036
  /**
6037
6037
  * Add `orchestrator_signing_keys`: the cluster-scoped, long-lived ES256 keys that sign the
@@ -6044,12 +6044,12 @@ var _084_orchestrator_signing_keys_exports = /* @__PURE__ */ __exportAll({
6044
6044
  * `scoped_secrets`), NULL for `aws-kms` / `command` custody where the private key never lives in
6045
6045
  * the DB; `key_ref` then locates the external key (KMS ARN / signer command). Idempotent.
6046
6046
  */
6047
- async function up$75(db) {
6047
+ async function up$76(db) {
6048
6048
  if (await tableExists$3(db, "orchestrator_signing_keys")) return;
6049
6049
  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();
6050
6050
  await db.schema.createIndex("idx_orch_signing_keys_status").on("orchestrator_signing_keys").column("status").execute();
6051
6051
  }
6052
- async function down$75(db) {
6052
+ async function down$76(db) {
6053
6053
  await db.schema.dropTable("orchestrator_signing_keys").ifExists().execute();
6054
6054
  }
6055
6055
  async function tableExists$3(db, table) {
@@ -6063,8 +6063,8 @@ async function tableExists$3(db, table) {
6063
6063
  //#endregion
6064
6064
  //#region src/db/migrations/085_cluster_settings_reroute_flap_grace_ms.ts
6065
6065
  var _085_cluster_settings_reroute_flap_grace_ms_exports = /* @__PURE__ */ __exportAll({
6066
- down: () => down$74,
6067
- up: () => up$74
6066
+ down: () => down$75,
6067
+ up: () => up$75
6068
6068
  });
6069
6069
  /**
6070
6070
  * Fleet-wide grace window (ms) in which the recovery sweepers defer a rerouted job while its
@@ -6073,7 +6073,7 @@ var _085_cluster_settings_reroute_flap_grace_ms_exports = /* @__PURE__ */ __expo
6073
6073
  *
6074
6074
  * Idempotent: guarded on column existence.
6075
6075
  */
6076
- async function up$74(db) {
6076
+ async function up$75(db) {
6077
6077
  if ((await sql`
6078
6078
  SELECT EXISTS (
6079
6079
  SELECT 1 FROM information_schema.columns
@@ -6084,14 +6084,14 @@ async function up$74(db) {
6084
6084
  `.execute(db)).rows[0]?.exists) return;
6085
6085
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN reroute_flap_grace_ms BIGINT`.execute(db);
6086
6086
  }
6087
- async function down$74(db) {
6087
+ async function down$75(db) {
6088
6088
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS reroute_flap_grace_ms`.execute(db);
6089
6089
  }
6090
6090
  //#endregion
6091
6091
  //#region src/db/migrations/086_cluster_settings_max_fanout_hosts.ts
6092
6092
  var _086_cluster_settings_max_fanout_hosts_exports = /* @__PURE__ */ __exportAll({
6093
- down: () => down$73,
6094
- up: () => up$73
6093
+ down: () => down$74,
6094
+ up: () => up$74
6095
6095
  });
6096
6096
  /**
6097
6097
  * Add `cluster_settings.max_fanout_hosts` (nullable INTEGER).
@@ -6101,7 +6101,7 @@ var _086_cluster_settings_max_fanout_hosts_exports = /* @__PURE__ */ __exportAll
6101
6101
  *
6102
6102
  * Idempotent: guarded on column existence.
6103
6103
  */
6104
- async function up$73(db) {
6104
+ async function up$74(db) {
6105
6105
  if ((await sql`
6106
6106
  SELECT EXISTS (
6107
6107
  SELECT 1 FROM information_schema.columns
@@ -6112,14 +6112,14 @@ async function up$73(db) {
6112
6112
  `.execute(db)).rows[0]?.exists) return;
6113
6113
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN max_fanout_hosts INTEGER`.execute(db);
6114
6114
  }
6115
- async function down$73(db) {
6115
+ async function down$74(db) {
6116
6116
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS max_fanout_hosts`.execute(db);
6117
6117
  }
6118
6118
  //#endregion
6119
6119
  //#region src/db/migrations/087_cluster_settings_event_router_rate_limit.ts
6120
6120
  var _087_cluster_settings_event_router_rate_limit_exports = /* @__PURE__ */ __exportAll({
6121
- down: () => down$72,
6122
- up: () => up$72
6121
+ down: () => down$73,
6122
+ up: () => up$73
6123
6123
  });
6124
6124
  /**
6125
6125
  * Add `cluster_settings.event_router_rate_limit_per_workflow_per_minute` (nullable INTEGER).
@@ -6131,7 +6131,7 @@ var _087_cluster_settings_event_router_rate_limit_exports = /* @__PURE__ */ __ex
6131
6131
  *
6132
6132
  * Idempotent: guarded on column existence.
6133
6133
  */
6134
- async function up$72(db) {
6134
+ async function up$73(db) {
6135
6135
  if ((await sql`
6136
6136
  SELECT EXISTS (
6137
6137
  SELECT 1 FROM information_schema.columns
@@ -6142,14 +6142,14 @@ async function up$72(db) {
6142
6142
  `.execute(db)).rows[0]?.exists) return;
6143
6143
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN event_router_rate_limit_per_workflow_per_minute INTEGER`.execute(db);
6144
6144
  }
6145
- async function down$72(db) {
6145
+ async function down$73(db) {
6146
6146
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS event_router_rate_limit_per_workflow_per_minute`.execute(db);
6147
6147
  }
6148
6148
  //#endregion
6149
6149
  //#region src/db/migrations/088_cluster_settings_cache_max_tarball_bytes.ts
6150
6150
  var _088_cluster_settings_cache_max_tarball_bytes_exports = /* @__PURE__ */ __exportAll({
6151
- down: () => down$71,
6152
- up: () => up$71
6151
+ down: () => down$72,
6152
+ up: () => up$72
6153
6153
  });
6154
6154
  /**
6155
6155
  * Add `cluster_settings.cache_max_tarball_bytes` (nullable BIGINT).
@@ -6159,7 +6159,7 @@ var _088_cluster_settings_cache_max_tarball_bytes_exports = /* @__PURE__ */ __ex
6159
6159
  *
6160
6160
  * Idempotent: guarded on column existence.
6161
6161
  */
6162
- async function up$71(db) {
6162
+ async function up$72(db) {
6163
6163
  if ((await sql`
6164
6164
  SELECT EXISTS (
6165
6165
  SELECT 1 FROM information_schema.columns
@@ -6170,14 +6170,14 @@ async function up$71(db) {
6170
6170
  `.execute(db)).rows[0]?.exists) return;
6171
6171
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN cache_max_tarball_bytes BIGINT`.execute(db);
6172
6172
  }
6173
- async function down$71(db) {
6173
+ async function down$72(db) {
6174
6174
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS cache_max_tarball_bytes`.execute(db);
6175
6175
  }
6176
6176
  //#endregion
6177
6177
  //#region src/db/migrations/089_cluster_settings_cache_ttl_days.ts
6178
6178
  var _089_cluster_settings_cache_ttl_days_exports = /* @__PURE__ */ __exportAll({
6179
- down: () => down$70,
6180
- up: () => up$70
6179
+ down: () => down$71,
6180
+ up: () => up$71
6181
6181
  });
6182
6182
  /**
6183
6183
  * Fleet-wide dependency-cache entry TTL (days): an entry unread for longer expires on the next
@@ -6185,7 +6185,7 @@ var _089_cluster_settings_cache_ttl_days_exports = /* @__PURE__ */ __exportAll({
6185
6185
  *
6186
6186
  * Idempotent: guarded on column existence.
6187
6187
  */
6188
- async function up$70(db) {
6188
+ async function up$71(db) {
6189
6189
  if ((await sql`
6190
6190
  SELECT EXISTS (
6191
6191
  SELECT 1 FROM information_schema.columns
@@ -6196,21 +6196,21 @@ async function up$70(db) {
6196
6196
  `.execute(db)).rows[0]?.exists) return;
6197
6197
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN cache_ttl_days INTEGER`.execute(db);
6198
6198
  }
6199
- async function down$70(db) {
6199
+ async function down$71(db) {
6200
6200
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS cache_ttl_days`.execute(db);
6201
6201
  }
6202
6202
  //#endregion
6203
6203
  //#region src/db/migrations/090_cluster_settings_concurrency_wait_timeout_ms.ts
6204
6204
  var _090_cluster_settings_concurrency_wait_timeout_ms_exports = /* @__PURE__ */ __exportAll({
6205
- down: () => down$69,
6206
- up: () => up$69
6205
+ down: () => down$70,
6206
+ up: () => up$70
6207
6207
  });
6208
6208
  /**
6209
6209
  * Add `cluster_settings.concurrency_wait_timeout_ms`: the fleet-wide agent concurrency-slot wait
6210
6210
  * timeout (ms), pushed to the agent on `job.dispatch`. NULL is the cluster default
6211
6211
  * (`config.concurrencyWaitTimeoutMs`, `KICI_CONCURRENCY_WAIT_TIMEOUT_MS`). Idempotent.
6212
6212
  */
6213
- async function up$69(db) {
6213
+ async function up$70(db) {
6214
6214
  if ((await sql`
6215
6215
  SELECT EXISTS (
6216
6216
  SELECT 1 FROM information_schema.columns
@@ -6221,21 +6221,21 @@ async function up$69(db) {
6221
6221
  `.execute(db)).rows[0]?.exists) return;
6222
6222
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN concurrency_wait_timeout_ms BIGINT`.execute(db);
6223
6223
  }
6224
- async function down$69(db) {
6224
+ async function down$70(db) {
6225
6225
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS concurrency_wait_timeout_ms`.execute(db);
6226
6226
  }
6227
6227
  //#endregion
6228
6228
  //#region src/db/migrations/091_cluster_settings_agent_token_ttl_ms.ts
6229
6229
  var _091_cluster_settings_agent_token_ttl_ms_exports = /* @__PURE__ */ __exportAll({
6230
- down: () => down$68,
6231
- up: () => up$68
6230
+ down: () => down$69,
6231
+ up: () => up$69
6232
6232
  });
6233
6233
  /**
6234
6234
  * `cluster_settings.agent_token_ttl_ms` (nullable BIGINT): fleet-wide ephemeral
6235
6235
  * agent-token TTL (ms), resolved by the leader at spawn. NULL → cluster default
6236
6236
  * (`config.agentTokenTtlMs`, `KICI_AGENT_TOKEN_TTL_MS`). Idempotent.
6237
6237
  */
6238
- async function up$68(db) {
6238
+ async function up$69(db) {
6239
6239
  if ((await sql`
6240
6240
  SELECT EXISTS (
6241
6241
  SELECT 1 FROM information_schema.columns
@@ -6246,14 +6246,14 @@ async function up$68(db) {
6246
6246
  `.execute(db)).rows[0]?.exists) return;
6247
6247
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN agent_token_ttl_ms BIGINT`.execute(db);
6248
6248
  }
6249
- async function down$68(db) {
6249
+ async function down$69(db) {
6250
6250
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS agent_token_ttl_ms`.execute(db);
6251
6251
  }
6252
6252
  //#endregion
6253
6253
  //#region src/db/migrations/092_cluster_settings_version.ts
6254
6254
  var _092_cluster_settings_version_exports = /* @__PURE__ */ __exportAll({
6255
- down: () => down$67,
6256
- up: () => up$67
6255
+ down: () => down$68,
6256
+ up: () => up$68
6257
6257
  });
6258
6258
  /**
6259
6259
  * `cluster_settings.version`, monotonic and bumped on each settings change. The leader
@@ -6263,7 +6263,7 @@ var _092_cluster_settings_version_exports = /* @__PURE__ */ __exportAll({
6263
6263
  *
6264
6264
  * Idempotent: guarded on column existence.
6265
6265
  */
6266
- async function up$67(db) {
6266
+ async function up$68(db) {
6267
6267
  if ((await sql`
6268
6268
  SELECT EXISTS (
6269
6269
  SELECT 1 FROM information_schema.columns
@@ -6274,14 +6274,14 @@ async function up$67(db) {
6274
6274
  `.execute(db)).rows[0]?.exists) return;
6275
6275
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN version BIGINT NOT NULL DEFAULT 0`.execute(db);
6276
6276
  }
6277
- async function down$67(db) {
6277
+ async function down$68(db) {
6278
6278
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS version`.execute(db);
6279
6279
  }
6280
6280
  //#endregion
6281
6281
  //#region src/db/migrations/093_org_settings_sandbox_allowlist.ts
6282
6282
  var _093_org_settings_sandbox_allowlist_exports = /* @__PURE__ */ __exportAll({
6283
- down: () => down$66,
6284
- up: () => up$66
6283
+ down: () => down$67,
6284
+ up: () => up$67
6285
6285
  });
6286
6286
  /**
6287
6287
  * Add the per-org container-sandbox escape-hatch allow-list to `org_settings`:
@@ -6308,7 +6308,7 @@ async function columnExists$14(db, column) {
6308
6308
  ) AS exists
6309
6309
  `.execute(db)).rows[0]?.exists ?? false;
6310
6310
  }
6311
- async function up$66(db) {
6311
+ async function up$67(db) {
6312
6312
  if (!await columnExists$14(db, "sandbox_allowed_capabilities")) await sql`
6313
6313
  ALTER TABLE public.org_settings
6314
6314
  ADD COLUMN sandbox_allowed_capabilities TEXT[]
@@ -6318,7 +6318,7 @@ async function up$66(db) {
6318
6318
  ADD COLUMN sandbox_allow_host_network BOOLEAN
6319
6319
  `.execute(db);
6320
6320
  }
6321
- async function down$66(db) {
6321
+ async function down$67(db) {
6322
6322
  await sql`
6323
6323
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS sandbox_allowed_capabilities
6324
6324
  `.execute(db);
@@ -6329,8 +6329,8 @@ async function down$66(db) {
6329
6329
  //#endregion
6330
6330
  //#region src/db/migrations/094_dashboard_encryption_keys.ts
6331
6331
  var _094_dashboard_encryption_keys_exports = /* @__PURE__ */ __exportAll({
6332
- down: () => down$65,
6333
- up: () => up$65
6332
+ down: () => down$66,
6333
+ up: () => up$66
6334
6334
  });
6335
6335
  /**
6336
6336
  * Add `dashboard_encryption_keys`: the cluster-scoped, long-lived X25519 keypair for
@@ -6344,12 +6344,12 @@ var _094_dashboard_encryption_keys_exports = /* @__PURE__ */ __exportAll({
6344
6344
  * `revoked` and leaves the JWKS, but its row stays so already-sealed envelopes decrypt.
6345
6345
  * Idempotent.
6346
6346
  */
6347
- async function up$65(db) {
6347
+ async function up$66(db) {
6348
6348
  if (await tableExists$2(db, "dashboard_encryption_keys")) return;
6349
6349
  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();
6350
6350
  await db.schema.createIndex("idx_dashboard_encryption_keys_status").on("dashboard_encryption_keys").column("status").execute();
6351
6351
  }
6352
- async function down$65(db) {
6352
+ async function down$66(db) {
6353
6353
  await db.schema.dropTable("dashboard_encryption_keys").ifExists().execute();
6354
6354
  }
6355
6355
  async function tableExists$2(db, table) {
@@ -6363,8 +6363,8 @@ async function tableExists$2(db, table) {
6363
6363
  //#endregion
6364
6364
  //#region src/db/migrations/095_dashboard_write_policy_tristate.ts
6365
6365
  var _095_dashboard_write_policy_tristate_exports = /* @__PURE__ */ __exportAll({
6366
- down: () => down$64,
6367
- up: () => up$64
6366
+ down: () => down$65,
6367
+ up: () => up$65
6368
6368
  });
6369
6369
  /**
6370
6370
  * Migrate stored `org_settings.dashboard_write_policy` JSONB from the legacy
@@ -6378,7 +6378,7 @@ var _095_dashboard_write_policy_tristate_exports = /* @__PURE__ */ __exportAll({
6378
6378
  * Runtime reads also coerce booleans, so an un-migrated row is never mis-read;
6379
6379
  * this normalizes the at-rest shape to what the tri-state writer produces.
6380
6380
  */
6381
- async function up$64(db) {
6381
+ async function up$65(db) {
6382
6382
  await sql`
6383
6383
  UPDATE org_settings
6384
6384
  SET dashboard_write_policy = COALESCE(
@@ -6405,12 +6405,12 @@ async function up$64(db) {
6405
6405
  )
6406
6406
  `.execute(db);
6407
6407
  }
6408
- async function down$64() {}
6408
+ async function down$65() {}
6409
6409
  //#endregion
6410
6410
  //#region src/db/migrations/096_multi_schedule_cron_last_fired.ts
6411
6411
  var _096_multi_schedule_cron_last_fired_exports = /* @__PURE__ */ __exportAll({
6412
- down: () => down$63,
6413
- up: () => up$63
6412
+ down: () => down$64,
6413
+ up: () => up$64
6414
6414
  });
6415
6415
  /**
6416
6416
  * Keys cron last-fired per (registration, schedule), so a workflow with several schedule()
@@ -6443,7 +6443,7 @@ async function primaryKeyColumns(db) {
6443
6443
  ORDER BY a.attnum
6444
6444
  `.execute(db)).rows.map((row) => row.attname);
6445
6445
  }
6446
- async function up$63(db) {
6446
+ async function up$64(db) {
6447
6447
  if (!await columnExists$13(db, "schedule_key")) await sql`ALTER TABLE public.cron_last_fired ADD COLUMN schedule_key text`.execute(db);
6448
6448
  await sql`
6449
6449
  UPDATE public.cron_last_fired clf
@@ -6470,7 +6470,7 @@ async function up$63(db) {
6470
6470
  `.execute(db);
6471
6471
  }
6472
6472
  }
6473
- async function down$63(db) {
6473
+ async function down$64(db) {
6474
6474
  await sql`
6475
6475
  DELETE FROM public.cron_last_fired a
6476
6476
  USING public.cron_last_fired b
@@ -6487,8 +6487,8 @@ async function down$63(db) {
6487
6487
  //#endregion
6488
6488
  //#region src/db/migrations/097_execution_runs_pr_number.ts
6489
6489
  var _097_execution_runs_pr_number_exports = /* @__PURE__ */ __exportAll({
6490
- down: () => down$62,
6491
- up: () => up$62
6490
+ down: () => down$63,
6491
+ up: () => up$63
6492
6492
  });
6493
6493
  /**
6494
6494
  * `execution_runs.pr_number` lets `/kici approve|reject` scope hold selection to the comment's
@@ -6507,13 +6507,13 @@ async function columnExists$12(db, column) {
6507
6507
  ) AS exists
6508
6508
  `.execute(db)).rows[0]?.exists ?? false;
6509
6509
  }
6510
- async function up$62(db) {
6510
+ async function up$63(db) {
6511
6511
  if (!await columnExists$12(db, "pr_number")) await sql`
6512
6512
  ALTER TABLE public.execution_runs
6513
6513
  ADD COLUMN pr_number INTEGER
6514
6514
  `.execute(db);
6515
6515
  }
6516
- async function down$62(db) {
6516
+ async function down$63(db) {
6517
6517
  await sql`
6518
6518
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS pr_number
6519
6519
  `.execute(db);
@@ -6521,8 +6521,8 @@ async function down$62(db) {
6521
6521
  //#endregion
6522
6522
  //#region src/db/migrations/098_execution_runs_customer_id.ts
6523
6523
  var _098_execution_runs_customer_id_exports = /* @__PURE__ */ __exportAll({
6524
- down: () => down$61,
6525
- up: () => up$61
6524
+ down: () => down$62,
6525
+ up: () => up$62
6526
6526
  });
6527
6527
  /**
6528
6528
  * Denormalize the owning org onto `execution_runs` so the concurrency-gate
@@ -6550,7 +6550,7 @@ async function columnExists$11(db, column) {
6550
6550
  ) AS exists
6551
6551
  `.execute(db)).rows[0]?.exists ?? false;
6552
6552
  }
6553
- async function up$61(db) {
6553
+ async function up$62(db) {
6554
6554
  if (!await columnExists$11(db, "customer_id")) {
6555
6555
  await sql`
6556
6556
  ALTER TABLE public.execution_runs
@@ -6574,7 +6574,7 @@ async function up$61(db) {
6574
6574
  ON public.execution_runs (customer_id, context)
6575
6575
  `.execute(db);
6576
6576
  }
6577
- async function down$61(db) {
6577
+ async function down$62(db) {
6578
6578
  await sql`DROP INDEX IF EXISTS execution_runs_customer_id_context_idx`.execute(db);
6579
6579
  await sql`
6580
6580
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS customer_id
@@ -6583,8 +6583,8 @@ async function down$61(db) {
6583
6583
  //#endregion
6584
6584
  //#region src/db/migrations/099_cluster_settings_dashboard_verified_issuer.ts
6585
6585
  var _099_cluster_settings_dashboard_verified_issuer_exports = /* @__PURE__ */ __exportAll({
6586
- down: () => down$60,
6587
- up: () => up$60
6586
+ down: () => down$61,
6587
+ up: () => up$61
6588
6588
  });
6589
6589
  /**
6590
6590
  * Add `cluster_settings.dashboard_verified_issuer` (nullable text).
@@ -6600,7 +6600,7 @@ var _099_cluster_settings_dashboard_verified_issuer_exports = /* @__PURE__ */ __
6600
6600
  *
6601
6601
  * Idempotent: guarded on column existence.
6602
6602
  */
6603
- async function up$60(db) {
6603
+ async function up$61(db) {
6604
6604
  if ((await sql`
6605
6605
  SELECT EXISTS (
6606
6606
  SELECT 1 FROM information_schema.columns
@@ -6611,14 +6611,14 @@ async function up$60(db) {
6611
6611
  `.execute(db)).rows[0]?.exists) return;
6612
6612
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN dashboard_verified_issuer TEXT`.execute(db);
6613
6613
  }
6614
- async function down$60(db) {
6614
+ async function down$61(db) {
6615
6615
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS dashboard_verified_issuer`.execute(db);
6616
6616
  }
6617
6617
  //#endregion
6618
6618
  //#region src/db/migrations/100_held_runs_hold_type_vocabulary.ts
6619
6619
  var _100_held_runs_hold_type_vocabulary_exports = /* @__PURE__ */ __exportAll({
6620
- down: () => down$59,
6621
- up: () => up$59
6620
+ down: () => down$60,
6621
+ up: () => up$60
6622
6622
  });
6623
6623
  /**
6624
6624
  * Realign `held_runs.hold_type` onto the engine's `HoldType` vocabulary.
@@ -6635,7 +6635,7 @@ var _100_held_runs_hold_type_vocabulary_exports = /* @__PURE__ */ __exportAll({
6635
6635
  *
6636
6636
  * Idempotent: a second run matches no rows.
6637
6637
  */
6638
- async function up$59(db) {
6638
+ async function up$60(db) {
6639
6639
  await sql`UPDATE public.held_runs SET hold_type = 'reviewer' WHERE hold_type = 'approval'`.execute(db);
6640
6640
  await sql`UPDATE public.held_runs SET hold_type = 'timer' WHERE hold_type = 'wait_timer'`.execute(db);
6641
6641
  }
@@ -6649,15 +6649,15 @@ async function up$59(db) {
6649
6649
  * `wait_timer` alone, so leaving those rows spelled `timer` would strand them
6650
6650
  * in the expire-and-fail path.
6651
6651
  */
6652
- async function down$59(db) {
6652
+ async function down$60(db) {
6653
6653
  await sql`UPDATE public.held_runs SET hold_type = 'approval' WHERE hold_type = 'reviewer'`.execute(db);
6654
6654
  await sql`UPDATE public.held_runs SET hold_type = 'wait_timer' WHERE hold_type = 'timer'`.execute(db);
6655
6655
  }
6656
6656
  //#endregion
6657
6657
  //#region src/db/migrations/101_contexts_hold_expiry_drop_default.ts
6658
6658
  var _101_contexts_hold_expiry_drop_default_exports = /* @__PURE__ */ __exportAll({
6659
- down: () => down$58,
6660
- up: () => up$58
6659
+ down: () => down$59,
6660
+ up: () => up$59
6661
6661
  });
6662
6662
  /**
6663
6663
  * Give the context hold expiry a single default, and retire the stored zeroes.
@@ -6674,7 +6674,7 @@ var _101_contexts_hold_expiry_drop_default_exports = /* @__PURE__ */ __exportAll
6674
6674
  * Idempotent: dropping an absent default is a no-op and the UPDATE matches no
6675
6675
  * rows on a second run.
6676
6676
  */
6677
- async function up$58(db) {
6677
+ async function up$59(db) {
6678
6678
  await sql`ALTER TABLE public.contexts ALTER COLUMN hold_expiry_seconds DROP DEFAULT`.execute(db);
6679
6679
  await sql`UPDATE public.contexts SET hold_expiry_seconds = NULL WHERE hold_expiry_seconds = 0`.execute(db);
6680
6680
  }
@@ -6684,14 +6684,14 @@ async function up$58(db) {
6684
6684
  * Deliberately asymmetric: zeroed rows are NOT recreated. They now look like a
6685
6685
  * deliberate NULL, and a `0` would resume cancelling every hold on its context.
6686
6686
  */
6687
- async function down$58(db) {
6687
+ async function down$59(db) {
6688
6688
  await sql`ALTER TABLE public.contexts ALTER COLUMN hold_expiry_seconds SET DEFAULT 86400`.execute(db);
6689
6689
  }
6690
6690
  //#endregion
6691
6691
  //#region src/db/migrations/102_dispatch_queue_agent_id.ts
6692
6692
  var _102_dispatch_queue_agent_id_exports = /* @__PURE__ */ __exportAll({
6693
- down: () => down$57,
6694
- up: () => up$57
6693
+ down: () => down$58,
6694
+ up: () => up$58
6695
6695
  });
6696
6696
  /**
6697
6697
  * Add `dispatch_queue.agent_id` (nullable text).
@@ -6704,7 +6704,7 @@ var _102_dispatch_queue_agent_id_exports = /* @__PURE__ */ __exportAll({
6704
6704
  * No backfill: older rows keep a NULL owner and resolve to "not owned", as before.
6705
6705
  * Idempotent: guarded on column existence.
6706
6706
  */
6707
- async function up$57(db) {
6707
+ async function up$58(db) {
6708
6708
  if ((await sql`
6709
6709
  SELECT EXISTS (
6710
6710
  SELECT 1 FROM information_schema.columns
@@ -6715,14 +6715,14 @@ async function up$57(db) {
6715
6715
  `.execute(db)).rows[0]?.exists) return;
6716
6716
  await sql`ALTER TABLE public.dispatch_queue ADD COLUMN agent_id TEXT`.execute(db);
6717
6717
  }
6718
- async function down$57(db) {
6718
+ async function down$58(db) {
6719
6719
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS agent_id`.execute(db);
6720
6720
  }
6721
6721
  //#endregion
6722
6722
  //#region src/db/migrations/103_cluster_settings_ownership_db_check_timeout_ms.ts
6723
6723
  var _103_cluster_settings_ownership_db_check_timeout_ms_exports = /* @__PURE__ */ __exportAll({
6724
- down: () => down$56,
6725
- up: () => up$56
6724
+ down: () => down$57,
6725
+ up: () => up$57
6726
6726
  });
6727
6727
  /**
6728
6728
  * Deadline for one DB-backed agent-ownership lookup, which runs inbound on every job-scoped
@@ -6734,7 +6734,7 @@ var _103_cluster_settings_ownership_db_check_timeout_ms_exports = /* @__PURE__ *
6734
6734
  *
6735
6735
  * Idempotent: guarded on column existence.
6736
6736
  */
6737
- async function up$56(db) {
6737
+ async function up$57(db) {
6738
6738
  if ((await sql`
6739
6739
  SELECT EXISTS (
6740
6740
  SELECT 1 FROM information_schema.columns
@@ -6745,14 +6745,14 @@ async function up$56(db) {
6745
6745
  `.execute(db)).rows[0]?.exists) return;
6746
6746
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN ownership_db_check_timeout_ms BIGINT`.execute(db);
6747
6747
  }
6748
- async function down$56(db) {
6748
+ async function down$57(db) {
6749
6749
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ownership_db_check_timeout_ms`.execute(db);
6750
6750
  }
6751
6751
  //#endregion
6752
6752
  //#region src/db/migrations/104_check_run_terminal_sent.ts
6753
6753
  var _104_check_run_terminal_sent_exports = /* @__PURE__ */ __exportAll({
6754
- down: () => down$55,
6755
- up: () => up$55
6754
+ down: () => down$56,
6755
+ up: () => up$56
6756
6756
  });
6757
6757
  /**
6758
6758
  * Add `check_run_tracking.terminal_sent_at`.
@@ -6766,7 +6766,7 @@ var _104_check_run_terminal_sent_exports = /* @__PURE__ */ __exportAll({
6766
6766
  * this table (a tracking write must never break check-run reporting), so NULL means "no record
6767
6767
  * of sending it", not "never sent". Idempotent.
6768
6768
  */
6769
- async function up$55(db) {
6769
+ async function up$56(db) {
6770
6770
  if ((await sql`
6771
6771
  SELECT EXISTS (
6772
6772
  SELECT 1 FROM information_schema.columns
@@ -6777,14 +6777,14 @@ async function up$55(db) {
6777
6777
  `.execute(db)).rows[0]?.exists) return;
6778
6778
  await sql`ALTER TABLE public.check_run_tracking ADD COLUMN terminal_sent_at TIMESTAMPTZ`.execute(db);
6779
6779
  }
6780
- async function down$55(db) {
6780
+ async function down$56(db) {
6781
6781
  await sql`ALTER TABLE public.check_run_tracking DROP COLUMN IF EXISTS terminal_sent_at`.execute(db);
6782
6782
  }
6783
6783
  //#endregion
6784
6784
  //#region src/db/migrations/105_org_trust_policy.ts
6785
6785
  var _105_org_trust_policy_exports = /* @__PURE__ */ __exportAll({
6786
- down: () => down$54,
6787
- up: () => up$54
6786
+ down: () => down$55,
6787
+ up: () => up$55
6788
6788
  });
6789
6789
  /**
6790
6790
  * Create `org_trust_policy` — the orchestrator's cache of the Platform-owned org
@@ -6799,7 +6799,7 @@ var _105_org_trust_policy_exports = /* @__PURE__ */ __exportAll({
6799
6799
  *
6800
6800
  * Idempotent: guarded by IF NOT EXISTS, so a re-run is a no-op.
6801
6801
  */
6802
- async function up$54(db) {
6802
+ async function up$55(db) {
6803
6803
  await sql`
6804
6804
  CREATE TABLE IF NOT EXISTS public.org_trust_policy (
6805
6805
  customer_id TEXT PRIMARY KEY,
@@ -6812,14 +6812,14 @@ async function up$54(db) {
6812
6812
  )
6813
6813
  `.execute(db);
6814
6814
  }
6815
- async function down$54(db) {
6815
+ async function down$55(db) {
6816
6816
  await sql`DROP TABLE IF EXISTS public.org_trust_policy`.execute(db);
6817
6817
  }
6818
6818
  //#endregion
6819
6819
  //#region src/db/migrations/106_cluster_settings_check_run_tracking_ttl_days.ts
6820
6820
  var _106_cluster_settings_check_run_tracking_ttl_days_exports = /* @__PURE__ */ __exportAll({
6821
- down: () => down$53,
6822
- up: () => up$53
6821
+ down: () => down$54,
6822
+ up: () => up$54
6823
6823
  });
6824
6824
  /**
6825
6825
  * Add `cluster_settings.check_run_tracking_ttl_days`: the hourly cleanup sweep deletes
@@ -6827,7 +6827,7 @@ var _106_cluster_settings_check_run_tracking_ttl_days_exports = /* @__PURE__ */
6827
6827
  * orchestrator's configured default. Cluster-global, not `org_settings`, because the sweep runs
6828
6828
  * fleet-wide with no tenant in scope at the read site. Idempotent.
6829
6829
  */
6830
- async function up$53(db) {
6830
+ async function up$54(db) {
6831
6831
  if ((await sql`
6832
6832
  SELECT EXISTS (
6833
6833
  SELECT 1 FROM information_schema.columns
@@ -6838,14 +6838,14 @@ async function up$53(db) {
6838
6838
  `.execute(db)).rows[0]?.exists) return;
6839
6839
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN check_run_tracking_ttl_days INTEGER`.execute(db);
6840
6840
  }
6841
- async function down$53(db) {
6841
+ async function down$54(db) {
6842
6842
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS check_run_tracking_ttl_days`.execute(db);
6843
6843
  }
6844
6844
  //#endregion
6845
6845
  //#region src/db/migrations/107_check_run_tracking_updated_at_index.ts
6846
6846
  var _107_check_run_tracking_updated_at_index_exports = /* @__PURE__ */ __exportAll({
6847
- down: () => down$52,
6848
- up: () => up$52
6847
+ down: () => down$53,
6848
+ up: () => up$53
6849
6849
  });
6850
6850
  /**
6851
6851
  * Add `idx_check_run_tracking_updated_at` on `check_run_tracking (updated_at)`.
@@ -6860,20 +6860,20 @@ var _107_check_run_tracking_updated_at_index_exports = /* @__PURE__ */ __exportA
6860
6860
  * Mirrors `idx_dispatch_queue_run_id` (072) and `idx_request_idempotency_created_at` (068), which
6861
6861
  * also index a TTL sweep's prune predicate. Idempotent (`IF NOT EXISTS`).
6862
6862
  */
6863
- async function up$52(db) {
6863
+ async function up$53(db) {
6864
6864
  await sql`
6865
6865
  CREATE INDEX IF NOT EXISTS idx_check_run_tracking_updated_at
6866
6866
  ON public.check_run_tracking (updated_at)
6867
6867
  `.execute(db);
6868
6868
  }
6869
- async function down$52(db) {
6869
+ async function down$53(db) {
6870
6870
  await sql`DROP INDEX IF EXISTS public.idx_check_run_tracking_updated_at`.execute(db);
6871
6871
  }
6872
6872
  //#endregion
6873
6873
  //#region src/db/migrations/108_unroutable_fast_fail.ts
6874
6874
  var _108_unroutable_fast_fail_exports = /* @__PURE__ */ __exportAll({
6875
- down: () => down$51,
6876
- up: () => up$51
6875
+ down: () => down$52,
6876
+ up: () => up$52
6877
6877
  });
6878
6878
  /**
6879
6879
  * Fast-fail support for jobs nothing in the fleet can run.
@@ -6904,12 +6904,12 @@ async function columnExists$10(db, table, column) {
6904
6904
  ) AS exists
6905
6905
  `.execute(db)).rows[0]?.exists === true;
6906
6906
  }
6907
- async function up$51(db) {
6907
+ async function up$52(db) {
6908
6908
  if (!await columnExists$10(db, "cluster_settings", "unroutable_grace_ms")) await sql`ALTER TABLE public.cluster_settings ADD COLUMN unroutable_grace_ms INTEGER`.execute(db);
6909
6909
  if (!await columnExists$10(db, "dispatch_queue", "unroutable_since")) await sql`ALTER TABLE public.dispatch_queue ADD COLUMN unroutable_since TIMESTAMPTZ`.execute(db);
6910
6910
  if (!await columnExists$10(db, "execution_jobs", "routing_reason")) await sql`ALTER TABLE public.execution_jobs ADD COLUMN routing_reason TEXT`.execute(db);
6911
6911
  }
6912
- async function down$51(db) {
6912
+ async function down$52(db) {
6913
6913
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS routing_reason`.execute(db);
6914
6914
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS unroutable_since`.execute(db);
6915
6915
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS unroutable_grace_ms`.execute(db);
@@ -6917,8 +6917,8 @@ async function down$51(db) {
6917
6917
  //#endregion
6918
6918
  //#region src/db/migrations/109_cluster_settings_cache_knobs.ts
6919
6919
  var _109_cluster_settings_cache_knobs_exports = /* @__PURE__ */ __exportAll({
6920
- down: () => down$50,
6921
- up: () => up$50
6920
+ down: () => down$51,
6921
+ up: () => up$51
6922
6922
  });
6923
6923
  /**
6924
6924
  * Cluster-global tunables for the lock-file cache and the Tier-1 content-requirements cache.
@@ -6950,17 +6950,17 @@ const COLUMNS$7 = [
6950
6950
  "content_cache_max_bytes",
6951
6951
  "content_cache_ttl_ms"
6952
6952
  ];
6953
- async function up$50(db) {
6953
+ async function up$51(db) {
6954
6954
  for (const column of COLUMNS$7) if (!await columnExists$9(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
6955
6955
  }
6956
- async function down$50(db) {
6956
+ async function down$51(db) {
6957
6957
  for (const column of COLUMNS$7) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
6958
6958
  }
6959
6959
  //#endregion
6960
6960
  //#region src/db/migrations/110_cluster_settings_global_eval_knobs.ts
6961
6961
  var _110_cluster_settings_global_eval_knobs_exports = /* @__PURE__ */ __exportAll({
6962
- down: () => down$49,
6963
- up: () => up$49
6962
+ down: () => down$50,
6963
+ up: () => up$50
6964
6964
  });
6965
6965
  /**
6966
6966
  * Cluster-global tunables for the Tier-2 global eval round — the pre-run job
@@ -6993,17 +6993,17 @@ const COLUMNS$6 = [
6993
6993
  "global_eval_candidate_timeout_ms",
6994
6994
  "global_eval_cache_max"
6995
6995
  ];
6996
- async function up$49(db) {
6996
+ async function up$50(db) {
6997
6997
  for (const column of COLUMNS$6) if (!await columnExists$8(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
6998
6998
  }
6999
- async function down$49(db) {
6999
+ async function down$50(db) {
7000
7000
  for (const column of COLUMNS$6) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
7001
7001
  }
7002
7002
  //#endregion
7003
7003
  //#region src/db/migrations/111_cluster_settings_global_eval_wait.ts
7004
7004
  var _111_cluster_settings_global_eval_wait_exports = /* @__PURE__ */ __exportAll({
7005
- down: () => down$48,
7006
- up: () => up$48
7005
+ down: () => down$49,
7006
+ up: () => up$49
7007
7007
  });
7008
7008
  /**
7009
7009
  * Cluster-global ceiling on how long webhook processing waits for a Tier-2
@@ -7027,17 +7027,17 @@ async function columnExists$7(db, table, column) {
7027
7027
  `.execute(db)).rows[0]?.exists === true;
7028
7028
  }
7029
7029
  const COLUMNS$5 = ["global_eval_wait_timeout_ms"];
7030
- async function up$48(db) {
7030
+ async function up$49(db) {
7031
7031
  for (const column of COLUMNS$5) if (!await columnExists$7(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
7032
7032
  }
7033
- async function down$48(db) {
7033
+ async function down$49(db) {
7034
7034
  for (const column of COLUMNS$5) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
7035
7035
  }
7036
7036
  //#endregion
7037
7037
  //#region src/db/migrations/112_execution_runs_workflow_repo.ts
7038
7038
  var _112_execution_runs_workflow_repo_exports = /* @__PURE__ */ __exportAll({
7039
- down: () => down$47,
7040
- up: () => up$47
7039
+ down: () => down$48,
7040
+ up: () => up$48
7041
7041
  });
7042
7042
  /**
7043
7043
  * Record which repository DEFINED the workflow a run executed.
@@ -7067,13 +7067,13 @@ async function colExists$9(db, table, name) {
7067
7067
  ) AS exists
7068
7068
  `.execute(db)).rows[0]?.exists ?? false;
7069
7069
  }
7070
- async function up$47(db) {
7070
+ async function up$48(db) {
7071
7071
  if (!await colExists$9(db, "execution_runs", "workflow_repo_identifier")) await sql`
7072
7072
  ALTER TABLE public.execution_runs
7073
7073
  ADD COLUMN workflow_repo_identifier text
7074
7074
  `.execute(db);
7075
7075
  }
7076
- async function down$47(db) {
7076
+ async function down$48(db) {
7077
7077
  await sql`
7078
7078
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_repo_identifier
7079
7079
  `.execute(db);
@@ -7081,8 +7081,8 @@ async function down$47(db) {
7081
7081
  //#endregion
7082
7082
  //#region src/db/migrations/113_execution_runs_workflow_repo_index.ts
7083
7083
  var _113_execution_runs_workflow_repo_index_exports = /* @__PURE__ */ __exportAll({
7084
- down: () => down$46,
7085
- up: () => up$46
7084
+ down: () => down$47,
7085
+ up: () => up$47
7086
7086
  });
7087
7087
  /**
7088
7088
  * Add the partial index `idx_execution_runs_workflow_repo` on
@@ -7101,21 +7101,21 @@ var _113_execution_runs_workflow_repo_index_exports = /* @__PURE__ */ __exportAl
7101
7101
  *
7102
7102
  * Idempotent: `IF NOT EXISTS`.
7103
7103
  */
7104
- async function up$46(db) {
7104
+ async function up$47(db) {
7105
7105
  await sql`
7106
7106
  CREATE INDEX IF NOT EXISTS idx_execution_runs_workflow_repo
7107
7107
  ON public.execution_runs (workflow_repo_identifier)
7108
7108
  WHERE workflow_repo_identifier IS NOT NULL
7109
7109
  `.execute(db);
7110
7110
  }
7111
- async function down$46(db) {
7111
+ async function down$47(db) {
7112
7112
  await sql`DROP INDEX IF EXISTS public.idx_execution_runs_workflow_repo`.execute(db);
7113
7113
  }
7114
7114
  //#endregion
7115
7115
  //#region src/db/migrations/114_ingest_queue_claim.ts
7116
7116
  var _114_ingest_queue_claim_exports = /* @__PURE__ */ __exportAll({
7117
- down: () => down$45,
7118
- up: () => up$45
7117
+ down: () => down$46,
7118
+ up: () => up$46
7119
7119
  });
7120
7120
  /**
7121
7121
  * Claim bookkeeping for the durable ingest queue.
@@ -7140,13 +7140,13 @@ async function columnExists$6(db, table, column) {
7140
7140
  ) AS exists
7141
7141
  `.execute(db)).rows[0]?.exists === true;
7142
7142
  }
7143
- async function up$45(db) {
7143
+ async function up$46(db) {
7144
7144
  if (!await columnExists$6(db, "ingest_overflow_buffer", "claimed_at")) await sql`ALTER TABLE public.ingest_overflow_buffer ADD COLUMN claimed_at TIMESTAMPTZ`.execute(db);
7145
7145
  if (!await columnExists$6(db, "cluster_settings", "ingest_overflow_claim_timeout_ms")) await sql`
7146
7146
  ALTER TABLE public.cluster_settings ADD COLUMN ingest_overflow_claim_timeout_ms INTEGER
7147
7147
  `.execute(db);
7148
7148
  }
7149
- async function down$45(db) {
7149
+ async function down$46(db) {
7150
7150
  await sql`
7151
7151
  ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ingest_overflow_claim_timeout_ms
7152
7152
  `.execute(db);
@@ -7157,8 +7157,8 @@ async function down$45(db) {
7157
7157
  //#endregion
7158
7158
  //#region src/db/migrations/115_global_workflows_cluster_switch.ts
7159
7159
  var _115_global_workflows_cluster_switch_exports = /* @__PURE__ */ __exportAll({
7160
- down: () => down$44,
7161
- up: () => up$44
7160
+ down: () => down$45,
7161
+ up: () => up$45
7162
7162
  });
7163
7163
  /**
7164
7164
  * Moves the global-workflows master switch from `org_settings` to `cluster_settings`. Whether
@@ -7186,7 +7186,7 @@ async function columnExists$5(db, table, column) {
7186
7186
  ) AS exists
7187
7187
  `.execute(db)).rows[0]?.exists === true;
7188
7188
  }
7189
- async function up$44(db) {
7189
+ async function up$45(db) {
7190
7190
  if (!await columnExists$5(db, "cluster_settings", "global_workflows_enabled")) await sql`ALTER TABLE public.cluster_settings ADD COLUMN global_workflows_enabled BOOLEAN`.execute(db);
7191
7191
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS global_workflows_enabled`.execute(db);
7192
7192
  }
@@ -7194,7 +7194,7 @@ async function up$44(db) {
7194
7194
  * Restores the org column as NOT NULL DEFAULT false. The per-org values `up` dropped are
7195
7195
  * unrecoverable, so every org comes back at the opt-in default.
7196
7196
  */
7197
- async function down$44(db) {
7197
+ async function down$45(db) {
7198
7198
  if (!await columnExists$5(db, "org_settings", "global_workflows_enabled")) await sql`
7199
7199
  ALTER TABLE public.org_settings
7200
7200
  ADD COLUMN global_workflows_enabled BOOLEAN NOT NULL DEFAULT false
@@ -7204,20 +7204,20 @@ async function down$44(db) {
7204
7204
  //#endregion
7205
7205
  //#region src/db/migrations/116_org_plan_headroom.ts
7206
7206
  var _116_org_plan_headroom_exports = /* @__PURE__ */ __exportAll({
7207
- down: () => down$43,
7208
- up: () => up$43
7207
+ down: () => down$44,
7208
+ up: () => up$44
7209
7209
  });
7210
- async function up$43(db) {
7210
+ async function up$44(db) {
7211
7211
  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();
7212
7212
  }
7213
- async function down$43(db) {
7213
+ async function down$44(db) {
7214
7214
  await db.schema.dropTable("org_plan_headroom").ifExists().execute();
7215
7215
  }
7216
7216
  //#endregion
7217
7217
  //#region src/db/migrations/117_invoke_gate_proxy_jobs.ts
7218
7218
  var _117_invoke_gate_proxy_jobs_exports = /* @__PURE__ */ __exportAll({
7219
- down: () => down$42,
7220
- up: () => up$42
7219
+ down: () => down$43,
7220
+ up: () => up$43
7221
7221
  });
7222
7222
  /**
7223
7223
  * An invoke gate summons the source repo's opt-in workflows and tracks each spawned run as a
@@ -7244,7 +7244,7 @@ async function colExists$8(db, table, name) {
7244
7244
  ) AS exists
7245
7245
  `.execute(db)).rows[0]?.exists ?? false;
7246
7246
  }
7247
- async function up$42(db) {
7247
+ async function up$43(db) {
7248
7248
  if (!await colExists$8(db, "execution_jobs", "job_kind")) await sql`
7249
7249
  ALTER TABLE public.execution_jobs
7250
7250
  ADD COLUMN job_kind text NOT NULL DEFAULT 'standard'
@@ -7262,7 +7262,7 @@ async function up$42(db) {
7262
7262
  ADD COLUMN summoned_by_proxy_job text
7263
7263
  `.execute(db);
7264
7264
  }
7265
- async function down$42(db) {
7265
+ async function down$43(db) {
7266
7266
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS job_kind`.execute(db);
7267
7267
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS summoned_run_id`.execute(db);
7268
7268
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS summoned_by_run_id`.execute(db);
@@ -7271,8 +7271,8 @@ async function down$42(db) {
7271
7271
  //#endregion
7272
7272
  //#region src/db/migrations/118_invoke_gate_scheduling.ts
7273
7273
  var _118_invoke_gate_scheduling_exports = /* @__PURE__ */ __exportAll({
7274
- down: () => down$41,
7275
- up: () => up$41
7274
+ down: () => down$42,
7275
+ up: () => up$42
7276
7276
  });
7277
7277
  /**
7278
7278
  * Scheduling columns for the invoke gate: the pieces the orchestrator needs to
@@ -7304,7 +7304,7 @@ async function colExists$7(db, table, name) {
7304
7304
  ) AS exists
7305
7305
  `.execute(db)).rows[0]?.exists ?? false;
7306
7306
  }
7307
- async function up$41(db) {
7307
+ async function up$42(db) {
7308
7308
  if (!await colExists$7(db, "execution_jobs", "timeout_ms")) await sql`
7309
7309
  ALTER TABLE public.execution_jobs
7310
7310
  ADD COLUMN timeout_ms integer
@@ -7318,7 +7318,7 @@ async function up$41(db) {
7318
7318
  ADD COLUMN invoke_config text
7319
7319
  `.execute(db);
7320
7320
  }
7321
- async function down$41(db) {
7321
+ async function down$42(db) {
7322
7322
  await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS timeout_ms`.execute(db);
7323
7323
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS chain_depth`.execute(db);
7324
7324
  await sql`ALTER TABLE public.pending_job_contexts DROP COLUMN IF EXISTS invoke_config`.execute(db);
@@ -7326,8 +7326,8 @@ async function down$41(db) {
7326
7326
  //#endregion
7327
7327
  //#region src/db/migrations/119_scaler_ha_ownership.ts
7328
7328
  var _119_scaler_ha_ownership_exports = /* @__PURE__ */ __exportAll({
7329
- down: () => down$40,
7330
- up: () => up$40
7329
+ down: () => down$41,
7330
+ up: () => up$41
7331
7331
  });
7332
7332
  /**
7333
7333
  * HA ownership for event-scaler provisions.
@@ -7372,7 +7372,7 @@ const SPAWNING_COLUMNS = [
7372
7372
  ["roles", "JSONB"],
7373
7373
  ["backend_type", "TEXT"]
7374
7374
  ];
7375
- async function up$40(db) {
7375
+ async function up$41(db) {
7376
7376
  if (!await tableExists$1(db, "scaler_pending_claims")) {
7377
7377
  await sql`
7378
7378
  CREATE TABLE public.scaler_pending_claims (
@@ -7418,7 +7418,7 @@ async function up$40(db) {
7418
7418
  ON public.scaler_reservations (owner_instance_id)
7419
7419
  `.execute(db);
7420
7420
  }
7421
- async function down$40(db) {
7421
+ async function down$41(db) {
7422
7422
  await sql`DROP TABLE IF EXISTS public.scaler_pending_claims`.execute(db);
7423
7423
  await sql`DROP INDEX IF EXISTS public.idx_scaler_spawning_agents_scaler_name`.execute(db);
7424
7424
  for (const [name] of SPAWNING_COLUMNS) await sql`
@@ -7431,8 +7431,8 @@ async function down$40(db) {
7431
7431
  //#endregion
7432
7432
  //#region src/db/migrations/120_cluster_settings_scaler_reaper.ts
7433
7433
  var _120_cluster_settings_scaler_reaper_exports = /* @__PURE__ */ __exportAll({
7434
- down: () => down$39,
7435
- up: () => up$39
7434
+ down: () => down$40,
7435
+ up: () => up$40
7436
7436
  });
7437
7437
  /**
7438
7438
  * Cluster-global tunables for the leader-gated event-scaler provision reaper: additive, nullable
@@ -7466,17 +7466,17 @@ const COLUMNS$4 = [
7466
7466
  "scaler_reap_reattempt_interval_ms",
7467
7467
  "scaler_claim_retention_ms"
7468
7468
  ];
7469
- async function up$39(db) {
7469
+ async function up$40(db) {
7470
7470
  for (const column of COLUMNS$4) if (!await columnExists$4(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
7471
7471
  }
7472
- async function down$39(db) {
7472
+ async function down$40(db) {
7473
7473
  for (const column of COLUMNS$4) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
7474
7474
  }
7475
7475
  //#endregion
7476
7476
  //#region src/db/migrations/121_org_settings_allow_untrusted_dockerfile_builds.ts
7477
7477
  var _121_org_settings_allow_untrusted_dockerfile_builds_exports = /* @__PURE__ */ __exportAll({
7478
- down: () => down$38,
7479
- up: () => up$38
7478
+ down: () => down$39,
7479
+ up: () => up$39
7480
7480
  });
7481
7481
  /**
7482
7482
  * Add `org_settings.allow_untrusted_dockerfile_builds boolean NOT NULL DEFAULT false`.
@@ -7492,7 +7492,7 @@ var _121_org_settings_allow_untrusted_dockerfile_builds_exports = /* @__PURE__ *
7492
7492
  *
7493
7493
  * Idempotent: a re-run on a DB that already has the column is a no-op.
7494
7494
  */
7495
- async function up$38(db) {
7495
+ async function up$39(db) {
7496
7496
  if ((await sql`
7497
7497
  SELECT EXISTS (
7498
7498
  SELECT 1 FROM information_schema.columns
@@ -7506,7 +7506,7 @@ async function up$38(db) {
7506
7506
  ADD COLUMN allow_untrusted_dockerfile_builds boolean NOT NULL DEFAULT false
7507
7507
  `.execute(db);
7508
7508
  }
7509
- async function down$38(db) {
7509
+ async function down$39(db) {
7510
7510
  await sql`
7511
7511
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS allow_untrusted_dockerfile_builds
7512
7512
  `.execute(db);
@@ -7514,8 +7514,8 @@ async function down$38(db) {
7514
7514
  //#endregion
7515
7515
  //#region src/db/migrations/122_host_roster_scaler_managed.ts
7516
7516
  var _122_host_roster_scaler_managed_exports = /* @__PURE__ */ __exportAll({
7517
- down: () => down$37,
7518
- up: () => up$37
7517
+ down: () => down$38,
7518
+ up: () => up$38
7519
7519
  });
7520
7520
  /**
7521
7521
  * Add `host_roster.scaler_managed`: whether a scaler backend spawned the agent.
@@ -7531,7 +7531,7 @@ var _122_host_roster_scaler_managed_exports = /* @__PURE__ */ __exportAll({
7531
7531
  * DEFAULT false is load-bearing: a pre-existing row reads as not-scaler-managed, so an existing
7532
7532
  * fleet host stays a fan-out target without re-registering. Idempotent.
7533
7533
  */
7534
- async function up$37(db) {
7534
+ async function up$38(db) {
7535
7535
  if ((await sql`
7536
7536
  SELECT EXISTS (
7537
7537
  SELECT 1 FROM information_schema.columns
@@ -7545,7 +7545,7 @@ async function up$37(db) {
7545
7545
  ADD COLUMN scaler_managed boolean NOT NULL DEFAULT false
7546
7546
  `.execute(db);
7547
7547
  }
7548
- async function down$37(db) {
7548
+ async function down$38(db) {
7549
7549
  await sql`
7550
7550
  ALTER TABLE public.host_roster DROP COLUMN IF EXISTS scaler_managed
7551
7551
  `.execute(db);
@@ -7553,8 +7553,8 @@ async function down$37(db) {
7553
7553
  //#endregion
7554
7554
  //#region src/db/migrations/123_workflow_registrations_default_branch.ts
7555
7555
  var _123_workflow_registrations_default_branch_exports = /* @__PURE__ */ __exportAll({
7556
- down: () => down$36,
7557
- up: () => up$36
7556
+ down: () => down$37,
7557
+ up: () => up$37
7558
7558
  });
7559
7559
  /**
7560
7560
  * Add `workflow_registrations.default_branch`.
@@ -7568,7 +7568,7 @@ var _123_workflow_registrations_default_branch_exports = /* @__PURE__ */ __expor
7568
7568
  * Dispatch reads NULL as "no branch" and the context branch gate rejects with its named cause; a
7569
7569
  * DEFAULT would invent a branch the registration never proved. Idempotent.
7570
7570
  */
7571
- async function up$36(db) {
7571
+ async function up$37(db) {
7572
7572
  if ((await sql`
7573
7573
  SELECT EXISTS (
7574
7574
  SELECT 1 FROM information_schema.columns
@@ -7582,7 +7582,7 @@ async function up$36(db) {
7582
7582
  ADD COLUMN default_branch text
7583
7583
  `.execute(db);
7584
7584
  }
7585
- async function down$36(db) {
7585
+ async function down$37(db) {
7586
7586
  await sql`
7587
7587
  ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS default_branch
7588
7588
  `.execute(db);
@@ -7590,8 +7590,8 @@ async function down$36(db) {
7590
7590
  //#endregion
7591
7591
  //#region src/db/migrations/124_cluster_settings_provision_backoff.ts
7592
7592
  var _124_cluster_settings_provision_backoff_exports = /* @__PURE__ */ __exportAll({
7593
- down: () => down$35,
7594
- up: () => up$35
7593
+ down: () => down$36,
7594
+ up: () => up$36
7595
7595
  });
7596
7596
  /**
7597
7597
  * Cluster-global tunables for backing off a repeatedly failing external (event) scaler.
@@ -7627,17 +7627,17 @@ const COLUMNS$3 = [
7627
7627
  "scaler_provision_backoff_max_ms",
7628
7628
  "scaler_provision_max_consecutive_failures"
7629
7629
  ];
7630
- async function up$35(db) {
7630
+ async function up$36(db) {
7631
7631
  for (const column of COLUMNS$3) if (!await columnExists$3(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
7632
7632
  }
7633
- async function down$35(db) {
7633
+ async function down$36(db) {
7634
7634
  for (const column of COLUMNS$3) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
7635
7635
  }
7636
7636
  //#endregion
7637
7637
  //#region src/db/migrations/125_org_trust_directory.ts
7638
7638
  var _125_org_trust_directory_exports = /* @__PURE__ */ __exportAll({
7639
- down: () => down$34,
7640
- up: () => up$34
7639
+ down: () => down$35,
7640
+ up: () => up$35
7641
7641
  });
7642
7642
  /**
7643
7643
  * Create `org_trust_directory`: the orchestrator's cache of the Platform-owned approval directory
@@ -7657,7 +7657,7 @@ var _125_org_trust_directory_exports = /* @__PURE__ */ __exportAll({
7657
7657
  * when a Platform is attached, so there is one writer and no counterpart to
7658
7658
  * `org_trust_policy.source`. Idempotent (IF NOT EXISTS).
7659
7659
  */
7660
- async function up$34(db) {
7660
+ async function up$35(db) {
7661
7661
  await sql`
7662
7662
  CREATE TABLE IF NOT EXISTS public.org_trust_directory (
7663
7663
  customer_id TEXT PRIMARY KEY,
@@ -7668,14 +7668,14 @@ async function up$34(db) {
7668
7668
  )
7669
7669
  `.execute(db);
7670
7670
  }
7671
- async function down$34(db) {
7671
+ async function down$35(db) {
7672
7672
  await sql`DROP TABLE IF EXISTS public.org_trust_directory`.execute(db);
7673
7673
  }
7674
7674
  //#endregion
7675
7675
  //#region src/db/migrations/126_held_runs_posted_pending_check.ts
7676
7676
  var _126_held_runs_posted_pending_check_exports = /* @__PURE__ */ __exportAll({
7677
- down: () => down$33,
7678
- up: () => up$33
7677
+ down: () => down$34,
7678
+ up: () => up$34
7679
7679
  });
7680
7680
  /**
7681
7681
  * Add `held_runs.posted_pending_check boolean` — whether this hold's pending
@@ -7695,7 +7695,7 @@ var _126_held_runs_posted_pending_check_exports = /* @__PURE__ */ __exportAll({
7695
7695
  *
7696
7696
  * Idempotent.
7697
7697
  */
7698
- async function up$33(db) {
7698
+ async function up$34(db) {
7699
7699
  if ((await sql`
7700
7700
  SELECT EXISTS (
7701
7701
  SELECT 1 FROM information_schema.columns
@@ -7709,7 +7709,7 @@ async function up$33(db) {
7709
7709
  ADD COLUMN posted_pending_check boolean
7710
7710
  `.execute(db);
7711
7711
  }
7712
- async function down$33(db) {
7712
+ async function down$34(db) {
7713
7713
  await sql`
7714
7714
  ALTER TABLE public.held_runs DROP COLUMN IF EXISTS posted_pending_check
7715
7715
  `.execute(db);
@@ -7717,8 +7717,8 @@ async function down$33(db) {
7717
7717
  //#endregion
7718
7718
  //#region src/db/migrations/127_org_trust_policy_approval_expiry_seconds.ts
7719
7719
  var _127_org_trust_policy_approval_expiry_seconds_exports = /* @__PURE__ */ __exportAll({
7720
- down: () => down$32,
7721
- up: () => up$32
7720
+ down: () => down$33,
7721
+ up: () => up$33
7722
7722
  });
7723
7723
  /**
7724
7724
  * Add `org_trust_policy.approval_expiry_seconds` (nullable INTEGER).
@@ -7734,7 +7734,7 @@ var _127_org_trust_policy_approval_expiry_seconds_exports = /* @__PURE__ */ __ex
7734
7734
  *
7735
7735
  * Idempotent: guarded on column existence.
7736
7736
  */
7737
- async function up$32(db) {
7737
+ async function up$33(db) {
7738
7738
  if ((await sql`
7739
7739
  SELECT EXISTS (
7740
7740
  SELECT 1 FROM information_schema.columns
@@ -7745,14 +7745,14 @@ async function up$32(db) {
7745
7745
  `.execute(db)).rows[0]?.exists) return;
7746
7746
  await sql`ALTER TABLE public.org_trust_policy ADD COLUMN approval_expiry_seconds INTEGER`.execute(db);
7747
7747
  }
7748
- async function down$32(db) {
7748
+ async function down$33(db) {
7749
7749
  await sql`ALTER TABLE public.org_trust_policy DROP COLUMN IF EXISTS approval_expiry_seconds`.execute(db);
7750
7750
  }
7751
7751
  //#endregion
7752
7752
  //#region src/db/migrations/128_execution_runs_global_eval_round.ts
7753
7753
  var _128_execution_runs_global_eval_round_exports = /* @__PURE__ */ __exportAll({
7754
- down: () => down$31,
7755
- up: () => up$31
7754
+ down: () => down$32,
7755
+ up: () => up$32
7756
7756
  });
7757
7757
  /**
7758
7758
  * Add `execution_runs.is_global_eval_round boolean NOT NULL DEFAULT false` —
@@ -7768,7 +7768,7 @@ var _128_execution_runs_global_eval_round_exports = /* @__PURE__ */ __exportAll(
7768
7768
  * `NOT NULL DEFAULT false`: every pre-existing row is an ordinary run, and no
7769
7769
  * third "unknown" answer exists for a null to carry. Idempotent.
7770
7770
  */
7771
- async function up$31(db) {
7771
+ async function up$32(db) {
7772
7772
  if ((await sql`
7773
7773
  SELECT EXISTS (
7774
7774
  SELECT 1 FROM information_schema.columns
@@ -7782,7 +7782,7 @@ async function up$31(db) {
7782
7782
  ADD COLUMN is_global_eval_round BOOLEAN NOT NULL DEFAULT FALSE
7783
7783
  `.execute(db);
7784
7784
  }
7785
- async function down$31(db) {
7785
+ async function down$32(db) {
7786
7786
  await sql`
7787
7787
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS is_global_eval_round
7788
7788
  `.execute(db);
@@ -7790,8 +7790,8 @@ async function down$31(db) {
7790
7790
  //#endregion
7791
7791
  //#region src/db/migrations/129_execution_runs_dispatch_routing_key.ts
7792
7792
  var _129_execution_runs_dispatch_routing_key_exports = /* @__PURE__ */ __exportAll({
7793
- down: () => down$30,
7794
- up: () => up$30
7793
+ down: () => down$31,
7794
+ up: () => up$31
7795
7795
  });
7796
7796
  /**
7797
7797
  * Add `execution_runs.dispatch_routing_key TEXT NULL` — the source whose
@@ -7810,7 +7810,7 @@ var _129_execution_runs_dispatch_routing_key_exports = /* @__PURE__ */ __exportA
7810
7810
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
7811
7811
  * re-run is a no-op.
7812
7812
  */
7813
- async function up$30(db) {
7813
+ async function up$31(db) {
7814
7814
  if ((await sql`
7815
7815
  SELECT EXISTS (
7816
7816
  SELECT 1 FROM information_schema.columns
@@ -7824,7 +7824,7 @@ async function up$30(db) {
7824
7824
  ADD COLUMN dispatch_routing_key TEXT
7825
7825
  `.execute(db);
7826
7826
  }
7827
- async function down$30(db) {
7827
+ async function down$31(db) {
7828
7828
  await sql`
7829
7829
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS dispatch_routing_key
7830
7830
  `.execute(db);
@@ -7832,8 +7832,8 @@ async function down$30(db) {
7832
7832
  //#endregion
7833
7833
  //#region src/db/migrations/130_scaler_provision_outcomes.ts
7834
7834
  var _130_scaler_provision_outcomes_exports = /* @__PURE__ */ __exportAll({
7835
- down: () => down$29,
7836
- up: () => up$29
7835
+ down: () => down$30,
7836
+ up: () => up$30
7837
7837
  });
7838
7838
  /**
7839
7839
  * Durable per-provision outcome, keyed by agent id.
@@ -7856,7 +7856,7 @@ var _130_scaler_provision_outcomes_exports = /* @__PURE__ */ __exportAll({
7856
7856
  * Idempotent: each statement is IF NOT EXISTS, covering a database with the table but not the
7857
7857
  * index, which a table-existence probe would skip.
7858
7858
  */
7859
- async function up$29(db) {
7859
+ async function up$30(db) {
7860
7860
  await sql`
7861
7861
  CREATE TABLE IF NOT EXISTS public.scaler_provision_outcomes (
7862
7862
  agent_id TEXT PRIMARY KEY,
@@ -7874,14 +7874,14 @@ async function up$29(db) {
7874
7874
  ON public.scaler_provision_outcomes (updated_at)
7875
7875
  `.execute(db);
7876
7876
  }
7877
- async function down$29(db) {
7877
+ async function down$30(db) {
7878
7878
  await sql`DROP TABLE IF EXISTS public.scaler_provision_outcomes`.execute(db);
7879
7879
  }
7880
7880
  //#endregion
7881
7881
  //#region src/db/migrations/131_execution_jobs_git_credentials.ts
7882
7882
  var _131_execution_jobs_git_credentials_exports = /* @__PURE__ */ __exportAll({
7883
- down: () => down$28,
7884
- up: () => up$28
7883
+ down: () => down$29,
7884
+ up: () => up$29
7885
7885
  });
7886
7886
  /**
7887
7887
  * Add `execution_jobs.git_credentials`: the job lock entry's `gitCredentials` map, as server
@@ -7899,7 +7899,7 @@ var _131_execution_jobs_git_credentials_exports = /* @__PURE__ */ __exportAll({
7899
7899
  * dispatch loop, so NULL also covers "not written yet", which the relay resolves against the
7900
7900
  * job's dispatch record (`git/job-context.ts`). Idempotent.
7901
7901
  */
7902
- async function up$28(db) {
7902
+ async function up$29(db) {
7903
7903
  if ((await sql`
7904
7904
  SELECT EXISTS (
7905
7905
  SELECT 1 FROM information_schema.columns
@@ -7913,7 +7913,7 @@ async function up$28(db) {
7913
7913
  ADD COLUMN git_credentials JSONB
7914
7914
  `.execute(db);
7915
7915
  }
7916
- async function down$28(db) {
7916
+ async function down$29(db) {
7917
7917
  await sql`
7918
7918
  ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS git_credentials
7919
7919
  `.execute(db);
@@ -7921,8 +7921,8 @@ async function down$28(db) {
7921
7921
  //#endregion
7922
7922
  //#region src/db/migrations/132_execution_runs_trigger_event.ts
7923
7923
  var _132_execution_runs_trigger_event_exports = /* @__PURE__ */ __exportAll({
7924
- down: () => down$27,
7925
- up: () => up$27
7924
+ down: () => down$28,
7925
+ up: () => up$28
7926
7926
  });
7927
7927
  /**
7928
7928
  * Add `execution_runs.trigger_event`: the event type that started the run (`push`, `pr:open`,
@@ -7933,7 +7933,7 @@ var _132_execution_runs_trigger_event_exports = /* @__PURE__ */ __exportAll({
7933
7933
  * in. An unknown trigger fails a `triggerTypeFilters` rule closed, withholding the credential.
7934
7934
  * Idempotent.
7935
7935
  */
7936
- async function up$27(db) {
7936
+ async function up$28(db) {
7937
7937
  if ((await sql`
7938
7938
  SELECT EXISTS (
7939
7939
  SELECT 1 FROM information_schema.columns
@@ -7947,7 +7947,7 @@ async function up$27(db) {
7947
7947
  ADD COLUMN trigger_event TEXT
7948
7948
  `.execute(db);
7949
7949
  }
7950
- async function down$27(db) {
7950
+ async function down$28(db) {
7951
7951
  await sql`
7952
7952
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS trigger_event
7953
7953
  `.execute(db);
@@ -7955,8 +7955,8 @@ async function down$27(db) {
7955
7955
  //#endregion
7956
7956
  //#region src/db/migrations/133_dispatch_queue_source_tar_digest.ts
7957
7957
  var _133_dispatch_queue_source_tar_digest_exports = /* @__PURE__ */ __exportAll({
7958
- down: () => down$26,
7959
- up: () => up$26
7958
+ down: () => down$27,
7959
+ up: () => up$27
7960
7960
  });
7961
7961
  /**
7962
7962
  * Add `dispatch_queue.source_tar_digest TEXT NULL` — the SHA-256 of the source
@@ -7974,7 +7974,7 @@ var _133_dispatch_queue_source_tar_digest_exports = /* @__PURE__ */ __exportAll(
7974
7974
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS, so a
7975
7975
  * re-run is a no-op.
7976
7976
  */
7977
- async function up$26(db) {
7977
+ async function up$27(db) {
7978
7978
  if ((await sql`
7979
7979
  SELECT EXISTS (
7980
7980
  SELECT 1 FROM information_schema.columns
@@ -7988,7 +7988,7 @@ async function up$26(db) {
7988
7988
  ADD COLUMN source_tar_digest TEXT
7989
7989
  `.execute(db);
7990
7990
  }
7991
- async function down$26(db) {
7991
+ async function down$27(db) {
7992
7992
  await sql`
7993
7993
  ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS source_tar_digest
7994
7994
  `.execute(db);
@@ -7996,8 +7996,8 @@ async function down$26(db) {
7996
7996
  //#endregion
7997
7997
  //#region src/db/migrations/134_dispatch_queue_ownership.ts
7998
7998
  var _134_dispatch_queue_ownership_exports = /* @__PURE__ */ __exportAll({
7999
- down: () => down$25,
8000
- up: () => up$25
7999
+ down: () => down$26,
8000
+ up: () => up$26
8001
8001
  });
8002
8002
  /**
8003
8003
  * Coordinator ownership for the job-dispatch plane.
@@ -8040,7 +8040,7 @@ async function colExists$5(db, table, name) {
8040
8040
  `.execute(db)).rows[0]?.exists ?? false;
8041
8041
  }
8042
8042
  const DISPATCH_QUEUE_COLUMNS = [["owner_instance_id", "TEXT"], ["dispatched_at", "TIMESTAMPTZ"]];
8043
- async function up$25(db) {
8043
+ async function up$26(db) {
8044
8044
  for (const [name, type] of DISPATCH_QUEUE_COLUMNS) if (!await colExists$5(db, "dispatch_queue", name)) await sql`
8045
8045
  ALTER TABLE public.dispatch_queue
8046
8046
  ADD COLUMN ${sql.raw(name)} ${sql.raw(type)}
@@ -8101,7 +8101,7 @@ async function up$25(db) {
8101
8101
  WHERE status = 'active'
8102
8102
  `.execute(db);
8103
8103
  }
8104
- async function down$25(db) {
8104
+ async function down$26(db) {
8105
8105
  await sql`DROP INDEX IF EXISTS public.idx_concurrency_groups_active_unique`.execute(db);
8106
8106
  await sql`DROP TABLE IF EXISTS public.cluster_instances`.execute(db);
8107
8107
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS cancelling_at`.execute(db);
@@ -8112,8 +8112,8 @@ async function down$25(db) {
8112
8112
  //#endregion
8113
8113
  //#region src/db/migrations/135_cluster_settings_retention_days.ts
8114
8114
  var _135_cluster_settings_retention_days_exports = /* @__PURE__ */ __exportAll({
8115
- down: () => down$24,
8116
- up: () => up$24
8115
+ down: () => down$25,
8116
+ up: () => up$25
8117
8117
  });
8118
8118
  /**
8119
8119
  * Database-side retention windows on `cluster_settings`. Cold-store
@@ -8167,20 +8167,20 @@ async function columnExists$2(db, column) {
8167
8167
  ) AS exists
8168
8168
  `.execute(db)).rows[0]?.exists === true;
8169
8169
  }
8170
- async function up$24(db) {
8170
+ async function up$25(db) {
8171
8171
  for (const { name, type } of COLUMNS$2) {
8172
8172
  if (await columnExists$2(db, name)) continue;
8173
8173
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.raw(name)} ${sql.raw(type)}`.execute(db);
8174
8174
  }
8175
8175
  }
8176
- async function down$24(db) {
8176
+ async function down$25(db) {
8177
8177
  for (const { name } of COLUMNS$2) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.raw(name)}`.execute(db);
8178
8178
  }
8179
8179
  //#endregion
8180
8180
  //#region src/db/migrations/136_master_key_wrapped_tables_key_version.ts
8181
8181
  var _136_master_key_wrapped_tables_key_version_exports = /* @__PURE__ */ __exportAll({
8182
- down: () => down$23,
8183
- up: () => up$23
8182
+ down: () => down$24,
8183
+ up: () => up$24
8184
8184
  });
8185
8185
  /**
8186
8186
  * `key_version` on the master-key-wrapped tables that lacked it (`orchestrator_signing_keys`
@@ -8198,7 +8198,7 @@ const TABLES = [
8198
8198
  "run_ephemeral_keys",
8199
8199
  "run_secret_outputs"
8200
8200
  ];
8201
- async function up$23(db) {
8201
+ async function up$24(db) {
8202
8202
  for (const table of TABLES) {
8203
8203
  if ((await sql`
8204
8204
  SELECT EXISTS (
@@ -8214,7 +8214,7 @@ async function up$23(db) {
8214
8214
  `.execute(db);
8215
8215
  }
8216
8216
  }
8217
- async function down$23(db) {
8217
+ async function down$24(db) {
8218
8218
  for (const table of TABLES) await sql`
8219
8219
  ALTER TABLE public.${sql.raw(table)} DROP COLUMN IF EXISTS key_version
8220
8220
  `.execute(db);
@@ -8222,8 +8222,8 @@ async function down$23(db) {
8222
8222
  //#endregion
8223
8223
  //#region src/db/migrations/137_execution_runs_pr_head_context.ts
8224
8224
  var _137_execution_runs_pr_head_context_exports = /* @__PURE__ */ __exportAll({
8225
- down: () => down$22,
8226
- up: () => up$22
8225
+ down: () => down$23,
8226
+ up: () => up$23
8227
8227
  });
8228
8228
  /**
8229
8229
  * Add the pull-request head context to `execution_runs`: `head_ref TEXT`,
@@ -8251,7 +8251,7 @@ const COLUMNS$1 = [
8251
8251
  ["head_repository", "TEXT"],
8252
8252
  ["is_fork", "BOOLEAN"]
8253
8253
  ];
8254
- async function up$22(db) {
8254
+ async function up$23(db) {
8255
8255
  for (const [name, type] of COLUMNS$1) {
8256
8256
  if ((await sql`
8257
8257
  SELECT EXISTS (
@@ -8267,7 +8267,7 @@ async function up$22(db) {
8267
8267
  `.execute(db);
8268
8268
  }
8269
8269
  }
8270
- async function down$22(db) {
8270
+ async function down$23(db) {
8271
8271
  for (const [name] of COLUMNS$1) await sql`
8272
8272
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS ${sql.raw(name)}
8273
8273
  `.execute(db);
@@ -8275,8 +8275,8 @@ async function down$22(db) {
8275
8275
  //#endregion
8276
8276
  //#region src/db/migrations/138_execution_runs_subject_trigger_event.ts
8277
8277
  var _138_execution_runs_subject_trigger_event_exports = /* @__PURE__ */ __exportAll({
8278
- down: () => down$21,
8279
- up: () => up$21
8278
+ down: () => down$22,
8279
+ up: () => up$22
8280
8280
  });
8281
8281
  /**
8282
8282
  * Add `execution_runs.subject_trigger_event`.
@@ -8295,7 +8295,7 @@ var _138_execution_runs_subject_trigger_event_exports = /* @__PURE__ */ __export
8295
8295
  * policy pins. Idempotent.
8296
8296
  */
8297
8297
  const COLUMN$1 = "subject_trigger_event";
8298
- async function up$21(db) {
8298
+ async function up$22(db) {
8299
8299
  if ((await sql`
8300
8300
  SELECT EXISTS (
8301
8301
  SELECT 1 FROM information_schema.columns
@@ -8309,7 +8309,7 @@ async function up$21(db) {
8309
8309
  ADD COLUMN ${sql.raw(COLUMN$1)} TEXT
8310
8310
  `.execute(db);
8311
8311
  }
8312
- async function down$21(db) {
8312
+ async function down$22(db) {
8313
8313
  await sql`
8314
8314
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS ${sql.raw(COLUMN$1)}
8315
8315
  `.execute(db);
@@ -8317,8 +8317,8 @@ async function down$21(db) {
8317
8317
  //#endregion
8318
8318
  //#region src/db/migrations/139_admin_token_subject.ts
8319
8319
  var _139_admin_token_subject_exports = /* @__PURE__ */ __exportAll({
8320
- down: () => down$20,
8321
- up: () => up$20
8320
+ down: () => down$21,
8321
+ up: () => up$21
8322
8322
  });
8323
8323
  /**
8324
8324
  * Add `admin_tokens.subject TEXT`, nullable.
@@ -8338,7 +8338,7 @@ var _139_admin_token_subject_exports = /* @__PURE__ */ __exportAll({
8338
8338
  * recorded holder. Idempotent.
8339
8339
  */
8340
8340
  const COLUMN = "subject";
8341
- async function up$20(db) {
8341
+ async function up$21(db) {
8342
8342
  if ((await sql`
8343
8343
  SELECT EXISTS (
8344
8344
  SELECT 1 FROM information_schema.columns
@@ -8352,7 +8352,7 @@ async function up$20(db) {
8352
8352
  ADD COLUMN ${sql.raw(COLUMN)} TEXT
8353
8353
  `.execute(db);
8354
8354
  }
8355
- async function down$20(db) {
8355
+ async function down$21(db) {
8356
8356
  await sql`
8357
8357
  ALTER TABLE public.admin_tokens DROP COLUMN IF EXISTS ${sql.raw(COLUMN)}
8358
8358
  `.execute(db);
@@ -8360,8 +8360,8 @@ async function down$20(db) {
8360
8360
  //#endregion
8361
8361
  //#region src/db/migrations/140_dispatch_queue_canonical_labels.ts
8362
8362
  var _140_dispatch_queue_canonical_labels_exports = /* @__PURE__ */ __exportAll({
8363
- down: () => down$19,
8364
- up: () => up$19
8363
+ down: () => down$20,
8364
+ up: () => up$20
8365
8365
  });
8366
8366
  /**
8367
8367
  * The whitespace `btrim` strips, matching the `String.prototype.trim` that `canonicalizeLabel`
@@ -8399,7 +8399,7 @@ const TRIM_CHARS = String.raw`E' \t\n\r\f\x0B'`;
8399
8399
  *
8400
8400
  * Idempotent: each `UPDATE` selects only rows with a non-canonical element.
8401
8401
  */
8402
- async function up$19(db) {
8402
+ async function up$20(db) {
8403
8403
  const trim = sql.raw(TRIM_CHARS);
8404
8404
  await sql`
8405
8405
  UPDATE public.dispatch_queue
@@ -8434,12 +8434,12 @@ async function up$19(db) {
8434
8434
  * compares agent labels verbatim against canonicalized rows, so a fleet with non-lowercase
8435
8435
  * labels strands those rows until they expire, drain, or are re-enqueued.
8436
8436
  */
8437
- async function down$19() {}
8437
+ async function down$20() {}
8438
8438
  //#endregion
8439
8439
  //#region src/db/migrations/141_event_log_shed.ts
8440
8440
  var _141_event_log_shed_exports = /* @__PURE__ */ __exportAll({
8441
- down: () => down$18,
8442
- up: () => up$18
8441
+ down: () => down$19,
8442
+ up: () => up$19
8443
8443
  });
8444
8444
  /**
8445
8445
  * Extend the event_log.status CHECK constraint with 'shed' so the orchestrator
@@ -8452,7 +8452,7 @@ var _141_event_log_shed_exports = /* @__PURE__ */ __exportAll({
8452
8452
  *
8453
8453
  * Idempotent: the DROP ... IF EXISTS / re-ADD pair re-runs cleanly.
8454
8454
  */
8455
- async function up$18(db) {
8455
+ async function up$19(db) {
8456
8456
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
8457
8457
  await sql`
8458
8458
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -8462,7 +8462,7 @@ async function up$18(db) {
8462
8462
  ])))
8463
8463
  `.execute(db);
8464
8464
  }
8465
- async function down$18(db) {
8465
+ async function down$19(db) {
8466
8466
  await sql`ALTER TABLE event_log DROP CONSTRAINT IF EXISTS event_log_status_check`.execute(db);
8467
8467
  await sql`
8468
8468
  ALTER TABLE event_log ADD CONSTRAINT event_log_status_check
@@ -8475,8 +8475,8 @@ async function down$18(db) {
8475
8475
  //#endregion
8476
8476
  //#region src/db/migrations/142_sweep_deprecated_columns.ts
8477
8477
  var _142_sweep_deprecated_columns_exports = /* @__PURE__ */ __exportAll({
8478
- down: () => down$17,
8479
- up: () => up$17
8478
+ down: () => down$18,
8479
+ up: () => up$18
8480
8480
  });
8481
8481
  /**
8482
8482
  * Sweep the columns and stored values no code path reads or writes. Data first, then schema:
@@ -8497,7 +8497,7 @@ var _142_sweep_deprecated_columns_exports = /* @__PURE__ */ __exportAll({
8497
8497
  * Idempotent: every UPDATE matches nothing on a re-run and every DROP is IF EXISTS.
8498
8498
  */
8499
8499
  const BATCH_SIZE$1 = 5e3;
8500
- async function up$17(db) {
8500
+ async function up$18(db) {
8501
8501
  for (;;) if (((await sql`
8502
8502
  UPDATE public.execution_runs
8503
8503
  SET trust_tier = 'unknown'
@@ -8523,12 +8523,12 @@ async function up$17(db) {
8523
8523
  await sql`ALTER TABLE public.org_trust_policy DROP COLUMN IF EXISTS workflow_change_policy`.execute(db);
8524
8524
  await sql`ALTER TABLE public.dispatch_queue DROP COLUMN IF EXISTS source_tar_hash`.execute(db);
8525
8525
  }
8526
- async function down$17() {}
8526
+ async function down$18() {}
8527
8527
  //#endregion
8528
8528
  //#region src/db/migrations/143_execution_jobs_precursor_result.ts
8529
8529
  var _143_execution_jobs_precursor_result_exports = /* @__PURE__ */ __exportAll({
8530
- down: () => down$16,
8531
- up: () => up$16
8530
+ down: () => down$17,
8531
+ up: () => up$17
8532
8532
  });
8533
8533
  /**
8534
8534
  * Add `execution_jobs.precursor_result`: the payload a precursor job (source-pack build, init,
@@ -8543,7 +8543,7 @@ var _143_execution_jobs_precursor_result_exports = /* @__PURE__ */ __exportAll({
8543
8543
  * Nullable, no default: NULL means "no precursor payload" (every ordinary job and older row).
8544
8544
  * Idempotent.
8545
8545
  */
8546
- async function up$16(db) {
8546
+ async function up$17(db) {
8547
8547
  if ((await sql`
8548
8548
  SELECT EXISTS (
8549
8549
  SELECT 1 FROM information_schema.columns
@@ -8557,7 +8557,7 @@ async function up$16(db) {
8557
8557
  ADD COLUMN precursor_result JSONB
8558
8558
  `.execute(db);
8559
8559
  }
8560
- async function down$16(db) {
8560
+ async function down$17(db) {
8561
8561
  await sql`
8562
8562
  ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS precursor_result
8563
8563
  `.execute(db);
@@ -8565,8 +8565,8 @@ async function down$16(db) {
8565
8565
  //#endregion
8566
8566
  //#region src/db/migrations/144_execution_runs_registration_window.ts
8567
8567
  var _144_execution_runs_registration_window_exports = /* @__PURE__ */ __exportAll({
8568
- down: () => down$15,
8569
- up: () => up$15
8568
+ down: () => down$16,
8569
+ up: () => up$16
8570
8570
  });
8571
8571
  /**
8572
8572
  * Add `execution_runs.registration_window_instance_id TEXT NULL` — the
@@ -8588,7 +8588,7 @@ var _144_execution_runs_registration_window_exports = /* @__PURE__ */ __exportAl
8588
8588
  *
8589
8589
  * Idempotent: the add is guarded on existence and the drop uses IF EXISTS.
8590
8590
  */
8591
- async function up$15(db) {
8591
+ async function up$16(db) {
8592
8592
  if ((await sql`
8593
8593
  SELECT EXISTS (
8594
8594
  SELECT 1 FROM information_schema.columns
@@ -8602,7 +8602,7 @@ async function up$15(db) {
8602
8602
  ADD COLUMN registration_window_instance_id TEXT
8603
8603
  `.execute(db);
8604
8604
  }
8605
- async function down$15(db) {
8605
+ async function down$16(db) {
8606
8606
  await sql`
8607
8607
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS registration_window_instance_id
8608
8608
  `.execute(db);
@@ -8610,8 +8610,8 @@ async function down$15(db) {
8610
8610
  //#endregion
8611
8611
  //#region src/db/migrations/145_execution_runs_workflow_provenance.ts
8612
8612
  var _145_execution_runs_workflow_provenance_exports = /* @__PURE__ */ __exportAll({
8613
- down: () => down$14,
8614
- up: () => up$14
8613
+ down: () => down$15,
8614
+ up: () => up$15
8615
8615
  });
8616
8616
  /**
8617
8617
  * Record the workflow repository's commit and registered branch for a run whose
@@ -8638,19 +8638,19 @@ async function colExists$4(db, name) {
8638
8638
  ) AS exists
8639
8639
  `.execute(db)).rows[0]?.exists ?? false;
8640
8640
  }
8641
- async function up$14(db) {
8641
+ async function up$15(db) {
8642
8642
  if (!await colExists$4(db, "workflow_sha")) await sql`ALTER TABLE public.execution_runs ADD COLUMN workflow_sha text`.execute(db);
8643
8643
  if (!await colExists$4(db, "workflow_branch")) await sql`ALTER TABLE public.execution_runs ADD COLUMN workflow_branch text`.execute(db);
8644
8644
  }
8645
- async function down$14(db) {
8645
+ async function down$15(db) {
8646
8646
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_branch`.execute(db);
8647
8647
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS workflow_sha`.execute(db);
8648
8648
  }
8649
8649
  //#endregion
8650
8650
  //#region src/db/migrations/146_pending_job_contexts_context_resolution.ts
8651
8651
  var _146_pending_job_contexts_context_resolution_exports = /* @__PURE__ */ __exportAll({
8652
- down: () => down$13,
8653
- up: () => up$13
8652
+ down: () => down$14,
8653
+ up: () => up$14
8654
8654
  });
8655
8655
  /**
8656
8656
  * Record, with a held job's pending dispatch context, what the release path
@@ -8676,18 +8676,18 @@ async function colExists$3(db) {
8676
8676
  ) AS exists
8677
8677
  `.execute(db)).rows[0]?.exists ?? false;
8678
8678
  }
8679
- async function up$13(db) {
8679
+ async function up$14(db) {
8680
8680
  if (!await colExists$3(db)) await sql`ALTER TABLE public.pending_job_contexts ADD COLUMN context_resolution jsonb`.execute(db);
8681
8681
  }
8682
- async function down$13(db) {
8682
+ async function down$14(db) {
8683
8683
  await sql`ALTER TABLE public.pending_job_contexts DROP COLUMN IF EXISTS context_resolution`.execute(db);
8684
8684
  }
8685
8685
  //#endregion
8686
8686
  //#region src/db/migrations/147_sealed_job_secrets.ts
8687
8687
  var _147_sealed_job_secrets_exports = /* @__PURE__ */ __exportAll({
8688
8688
  SEALED_SECRETS_TABLES: () => SEALED_SECRETS_TABLES,
8689
- down: () => down$12,
8690
- up: () => up$12
8689
+ down: () => down$13,
8690
+ up: () => up$13
8691
8691
  });
8692
8692
  /**
8693
8693
  * `sealed_secrets` holds a stored job's secret fields under the orchestrator master key, beside
@@ -8714,17 +8714,17 @@ async function colExists$2(db, table) {
8714
8714
  ) AS exists
8715
8715
  `.execute(db)).rows[0]?.exists ?? false;
8716
8716
  }
8717
- async function up$12(db) {
8717
+ async function up$13(db) {
8718
8718
  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);
8719
8719
  }
8720
- async function down$12(db) {
8720
+ async function down$13(db) {
8721
8721
  for (const table of SEALED_SECRETS_TABLES) await sql`ALTER TABLE ${sql.table(`public.${table}`)} DROP COLUMN IF EXISTS sealed_secrets`.execute(db);
8722
8722
  }
8723
8723
  //#endregion
8724
8724
  //#region src/db/migrations/148_cluster_settings_sealed_secrets_retry_backoff_ms.ts
8725
8725
  var _148_cluster_settings_sealed_secrets_retry_backoff_ms_exports = /* @__PURE__ */ __exportAll({
8726
- down: () => down$11,
8727
- up: () => up$11
8726
+ down: () => down$12,
8727
+ up: () => up$12
8728
8728
  });
8729
8729
  /**
8730
8730
  * How long a coordinator leaves a queued job alone after failing to open its sealed secrets
@@ -8737,7 +8737,7 @@ var _148_cluster_settings_sealed_secrets_retry_backoff_ms_exports = /* @__PURE__
8737
8737
  *
8738
8738
  * Idempotent: guarded on column existence.
8739
8739
  */
8740
- async function up$11(db) {
8740
+ async function up$12(db) {
8741
8741
  if ((await sql`
8742
8742
  SELECT EXISTS (
8743
8743
  SELECT 1 FROM information_schema.columns
@@ -8748,14 +8748,14 @@ async function up$11(db) {
8748
8748
  `.execute(db)).rows[0]?.exists) return;
8749
8749
  await sql`ALTER TABLE public.cluster_settings ADD COLUMN sealed_secrets_retry_backoff_ms BIGINT`.execute(db);
8750
8750
  }
8751
- async function down$11(db) {
8751
+ async function down$12(db) {
8752
8752
  await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS sealed_secrets_retry_backoff_ms`.execute(db);
8753
8753
  }
8754
8754
  //#endregion
8755
8755
  //#region src/db/migrations/149_workflow_registrations_dep_cache_key.ts
8756
8756
  var _149_workflow_registrations_dep_cache_key_exports = /* @__PURE__ */ __exportAll({
8757
- down: () => down$10,
8758
- up: () => up$10
8757
+ down: () => down$11,
8758
+ up: () => up$11
8759
8759
  });
8760
8760
  /**
8761
8761
  * The registering lock file's dependency-cache key: `lockfile_hash` (`lockfileHash`, the
@@ -8779,19 +8779,19 @@ async function colExists$1(db, name) {
8779
8779
  ) AS exists
8780
8780
  `.execute(db)).rows[0]?.exists ?? false;
8781
8781
  }
8782
- async function up$10(db) {
8782
+ async function up$11(db) {
8783
8783
  if (!await colExists$1(db, "lockfile_hash")) await sql`ALTER TABLE public.workflow_registrations ADD COLUMN lockfile_hash text`.execute(db);
8784
8784
  if (!await colExists$1(db, "siblings_digest")) await sql`ALTER TABLE public.workflow_registrations ADD COLUMN siblings_digest text`.execute(db);
8785
8785
  }
8786
- async function down$10(db) {
8786
+ async function down$11(db) {
8787
8787
  await sql`ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS siblings_digest`.execute(db);
8788
8788
  await sql`ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS lockfile_hash`.execute(db);
8789
8789
  }
8790
8790
  //#endregion
8791
8791
  //#region src/db/migrations/150_execution_runs_status_epoch.ts
8792
8792
  var _150_execution_runs_status_epoch_exports = /* @__PURE__ */ __exportAll({
8793
- down: () => down$9,
8794
- up: () => up$9
8793
+ down: () => down$10,
8794
+ up: () => up$10
8795
8795
  });
8796
8796
  /**
8797
8797
  * Add `execution_runs.status_epoch`: the run's status generation. The tracker raises it each time
@@ -8802,7 +8802,7 @@ var _150_execution_runs_status_epoch_exports = /* @__PURE__ */ __exportAll({
8802
8802
  * The constant default 0 adds the column without a table rewrite; no existing row was reopened
8803
8803
  * under this counter. Idempotent.
8804
8804
  */
8805
- async function up$9(db) {
8805
+ async function up$10(db) {
8806
8806
  if ((await sql`
8807
8807
  SELECT EXISTS (
8808
8808
  SELECT 1 FROM information_schema.columns
@@ -8813,14 +8813,14 @@ async function up$9(db) {
8813
8813
  `.execute(db)).rows[0]?.exists) return;
8814
8814
  await sql`ALTER TABLE public.execution_runs ADD COLUMN status_epoch INTEGER NOT NULL DEFAULT 0`.execute(db);
8815
8815
  }
8816
- async function down$9(db) {
8816
+ async function down$10(db) {
8817
8817
  await sql`ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS status_epoch`.execute(db);
8818
8818
  }
8819
8819
  //#endregion
8820
8820
  //#region src/db/migrations/151_workflow_registrations_dep_cache_key_sha.ts
8821
8821
  var _151_workflow_registrations_dep_cache_key_sha_exports = /* @__PURE__ */ __exportAll({
8822
- down: () => down$8,
8823
- up: () => up$8
8822
+ down: () => down$9,
8823
+ up: () => up$9
8824
8824
  });
8825
8825
  /**
8826
8826
  * `dep_cache_key_sha`: the `commit_sha` stored with `lockfile_hash` and `siblings_digest`. A run
@@ -8844,18 +8844,18 @@ async function colExists(db) {
8844
8844
  ) AS exists
8845
8845
  `.execute(db)).rows[0]?.exists ?? false;
8846
8846
  }
8847
- async function up$8(db) {
8847
+ async function up$9(db) {
8848
8848
  if (await colExists(db)) return;
8849
8849
  await sql`ALTER TABLE public.workflow_registrations ADD COLUMN dep_cache_key_sha text`.execute(db);
8850
8850
  }
8851
- async function down$8(db) {
8851
+ async function down$9(db) {
8852
8852
  await sql`ALTER TABLE public.workflow_registrations DROP COLUMN IF EXISTS dep_cache_key_sha`.execute(db);
8853
8853
  }
8854
8854
  //#endregion
8855
8855
  //#region src/db/migrations/152_org_settings_cache_upload_settle_timeout.ts
8856
8856
  var _152_org_settings_cache_upload_settle_timeout_exports = /* @__PURE__ */ __exportAll({
8857
- down: () => down$7,
8858
- up: () => up$7
8857
+ down: () => down$8,
8858
+ up: () => up$8
8859
8859
  });
8860
8860
  /**
8861
8861
  * Per-org bound on how long a build job's `job.status success` waits for the cache publish
@@ -8865,7 +8865,7 @@ var _152_org_settings_cache_upload_settle_timeout_exports = /* @__PURE__ */ __ex
8865
8865
  *
8866
8866
  * Idempotent.
8867
8867
  */
8868
- async function up$7(db) {
8868
+ async function up$8(db) {
8869
8869
  if ((await sql`
8870
8870
  SELECT EXISTS (
8871
8871
  SELECT 1 FROM information_schema.columns
@@ -8879,7 +8879,7 @@ async function up$7(db) {
8879
8879
  ADD COLUMN cache_upload_settle_timeout_ms BIGINT
8880
8880
  `.execute(db);
8881
8881
  }
8882
- async function down$7(db) {
8882
+ async function down$8(db) {
8883
8883
  await sql`
8884
8884
  ALTER TABLE public.org_settings DROP COLUMN IF EXISTS cache_upload_settle_timeout_ms
8885
8885
  `.execute(db);
@@ -8887,8 +8887,8 @@ async function down$7(db) {
8887
8887
  //#endregion
8888
8888
  //#region src/db/migrations/153_execution_runs_cancel_force.ts
8889
8889
  var _153_execution_runs_cancel_force_exports = /* @__PURE__ */ __exportAll({
8890
- down: () => down$6,
8891
- up: () => up$6
8890
+ down: () => down$7,
8891
+ up: () => up$7
8892
8892
  });
8893
8893
  /**
8894
8894
  * Add `execution_runs.cancel_force BOOLEAN` (nullable, no default).
@@ -8902,7 +8902,7 @@ var _153_execution_runs_cancel_force_exports = /* @__PURE__ */ __exportAll({
8902
8902
  *
8903
8903
  * Idempotent: a re-run on a DB that already has the column is a no-op.
8904
8904
  */
8905
- async function up$6(db) {
8905
+ async function up$7(db) {
8906
8906
  if ((await sql`
8907
8907
  SELECT EXISTS (
8908
8908
  SELECT 1 FROM information_schema.columns
@@ -8916,7 +8916,7 @@ async function up$6(db) {
8916
8916
  ADD COLUMN cancel_force BOOLEAN
8917
8917
  `.execute(db);
8918
8918
  }
8919
- async function down$6(db) {
8919
+ async function down$7(db) {
8920
8920
  await sql`
8921
8921
  ALTER TABLE public.execution_runs DROP COLUMN IF EXISTS cancel_force
8922
8922
  `.execute(db);
@@ -8924,8 +8924,8 @@ async function down$6(db) {
8924
8924
  //#endregion
8925
8925
  //#region src/db/migrations/154_cluster_settings_firecracker_api_socket_wait.ts
8926
8926
  var _154_cluster_settings_firecracker_api_socket_wait_exports = /* @__PURE__ */ __exportAll({
8927
- down: () => down$5,
8928
- up: () => up$5
8927
+ down: () => down$6,
8928
+ up: () => up$6
8929
8929
  });
8930
8930
  /**
8931
8931
  * Cluster-global wait for a Firecracker VM's API socket after the jailer starts.
@@ -8947,17 +8947,17 @@ async function columnExists$1(db, table, column) {
8947
8947
  `.execute(db)).rows[0]?.exists === true;
8948
8948
  }
8949
8949
  const COLUMNS = ["firecracker_api_socket_wait_ms"];
8950
- async function up$5(db) {
8950
+ async function up$6(db) {
8951
8951
  for (const column of COLUMNS) if (!await columnExists$1(db, "cluster_settings", column)) await sql`ALTER TABLE public.cluster_settings ADD COLUMN ${sql.ref(column)} BIGINT`.execute(db);
8952
8952
  }
8953
- async function down$5(db) {
8953
+ async function down$6(db) {
8954
8954
  for (const column of COLUMNS) await sql`ALTER TABLE public.cluster_settings DROP COLUMN IF EXISTS ${sql.ref(column)}`.execute(db);
8955
8955
  }
8956
8956
  //#endregion
8957
8957
  //#region src/db/migrations/155_org_settings_reroute_spawn_retry.ts
8958
8958
  var _155_org_settings_reroute_spawn_retry_exports = /* @__PURE__ */ __exportAll({
8959
- down: () => down$4,
8960
- up: () => up$4
8959
+ down: () => down$5,
8960
+ up: () => up$5
8961
8961
  });
8962
8962
  /**
8963
8963
  * Add the two per-org spawn-retry columns a worker applies to a rerouted job (both nullable):
@@ -8972,11 +8972,11 @@ var _155_org_settings_reroute_spawn_retry_exports = /* @__PURE__ */ __exportAll(
8972
8972
  *
8973
8973
  * Idempotent: each add is guarded on column existence.
8974
8974
  */
8975
- async function up$4(db) {
8975
+ async function up$5(db) {
8976
8976
  await addColumnIfMissing(db, "reroute_spawn_max_attempts", "INTEGER");
8977
8977
  await addColumnIfMissing(db, "reroute_spawn_retry_backoff_ms", "BIGINT");
8978
8978
  }
8979
- async function down$4(db) {
8979
+ async function down$5(db) {
8980
8980
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_spawn_max_attempts`.execute(db);
8981
8981
  await sql`ALTER TABLE public.org_settings DROP COLUMN IF EXISTS reroute_spawn_retry_backoff_ms`.execute(db);
8982
8982
  }
@@ -8994,8 +8994,8 @@ async function addColumnIfMissing(db, column, type) {
8994
8994
  //#endregion
8995
8995
  //#region src/db/migrations/156_kici_events_match_outcome.ts
8996
8996
  var _156_kici_events_match_outcome_exports = /* @__PURE__ */ __exportAll({
8997
- down: () => down$3,
8998
- up: () => up$3
8997
+ down: () => down$4,
8998
+ up: () => up$4
8999
8999
  });
9000
9000
  /**
9001
9001
  * Record how the event router resolved each internal event:
@@ -9010,12 +9010,12 @@ var _156_kici_events_match_outcome_exports = /* @__PURE__ */ __exportAll({
9010
9010
  *
9011
9011
  * Idempotent: `ADD COLUMN IF NOT EXISTS`.
9012
9012
  */
9013
- async function up$3(db) {
9013
+ async function up$4(db) {
9014
9014
  await sql`ALTER TABLE public.kici_events
9015
9015
  ADD COLUMN IF NOT EXISTS match_outcome TEXT,
9016
9016
  ADD COLUMN IF NOT EXISTS matched_count INTEGER`.execute(db);
9017
9017
  }
9018
- async function down$3(db) {
9018
+ async function down$4(db) {
9019
9019
  await sql`ALTER TABLE public.kici_events
9020
9020
  DROP COLUMN IF EXISTS match_outcome,
9021
9021
  DROP COLUMN IF EXISTS matched_count`.execute(db);
@@ -9023,8 +9023,8 @@ async function down$3(db) {
9023
9023
  //#endregion
9024
9024
  //#region src/db/migrations/157_host_roster_identity_source.ts
9025
9025
  var _157_host_roster_identity_source_exports = /* @__PURE__ */ __exportAll({
9026
- down: () => down$2,
9027
- up: () => up$2
9026
+ down: () => down$3,
9027
+ up: () => up$3
9028
9028
  });
9029
9029
  /**
9030
9030
  * `host_roster.identity_source` (`agent` | `operator` | `platform`): who last set a host's
@@ -9039,7 +9039,7 @@ var _157_host_roster_identity_source_exports = /* @__PURE__ */ __exportAll({
9039
9039
  *
9040
9040
  * Idempotent.
9041
9041
  */
9042
- async function up$2(db) {
9042
+ async function up$3(db) {
9043
9043
  if ((await sql`
9044
9044
  SELECT EXISTS (
9045
9045
  SELECT 1 FROM information_schema.columns
@@ -9058,14 +9058,14 @@ async function up$2(db) {
9058
9058
  UPDATE public.host_roster SET identity_source = 'agent' WHERE platform IS NOT NULL
9059
9059
  `.execute(db);
9060
9060
  }
9061
- async function down$2(db) {
9061
+ async function down$3(db) {
9062
9062
  await sql`ALTER TABLE public.host_roster DROP COLUMN IF EXISTS identity_source`.execute(db);
9063
9063
  }
9064
9064
  //#endregion
9065
9065
  //#region src/db/migrations/158_normalize_legacy_values.ts
9066
9066
  var _158_normalize_legacy_values_exports = /* @__PURE__ */ __exportAll({
9067
- down: () => down$1,
9068
- up: () => up$1
9067
+ down: () => down$2,
9068
+ up: () => up$2
9069
9069
  });
9070
9070
  /**
9071
9071
  * Rewrite every stored legacy value the readers no longer accept, then drop
@@ -9108,7 +9108,7 @@ async function columnExists(db, table, column) {
9108
9108
  ) AS exists
9109
9109
  `.execute(db)).rows[0]?.exists ?? false;
9110
9110
  }
9111
- async function up$1(db) {
9111
+ async function up$2(db) {
9112
9112
  await sql`UPDATE public.held_runs SET hold_type = 'reviewer' WHERE hold_type = 'approval'`.execute(db);
9113
9113
  await sql`UPDATE public.held_runs SET hold_type = 'timer' WHERE hold_type = 'wait_timer'`.execute(db);
9114
9114
  for (const table of STATUS_TABLES) {
@@ -9126,12 +9126,12 @@ async function up$1(db) {
9126
9126
  await sql`ALTER TABLE public.org_trust_policy ALTER COLUMN approval_expiry_seconds SET NOT NULL`.execute(db);
9127
9127
  await sql`ALTER TABLE public.org_trust_policy DROP COLUMN IF EXISTS approval_expiry_hours`.execute(db);
9128
9128
  }
9129
- async function down$1() {}
9129
+ async function down$2() {}
9130
9130
  //#endregion
9131
9131
  //#region src/db/migrations/159_org_id_widen_to_source_width.ts
9132
9132
  var _159_org_id_widen_to_source_width_exports = /* @__PURE__ */ __exportAll({
9133
- down: () => down,
9134
- up: () => up
9133
+ down: () => down$1,
9134
+ up: () => up$1
9135
9135
  });
9136
9136
  /**
9137
9137
  * Widen every `org_id varchar(16)` column to `varchar(255)`, the width of the `customer_id`
@@ -9158,14 +9158,40 @@ const ORG_ID_TABLES$1 = [
9158
9158
  "held_runs",
9159
9159
  "scoped_secrets"
9160
9160
  ];
9161
- async function up(db) {
9161
+ async function up$1(db) {
9162
9162
  for (const table of ORG_ID_TABLES$1) await sql.raw(`ALTER TABLE public.${table} ALTER COLUMN org_id TYPE varchar(255)`).execute(db);
9163
9163
  }
9164
9164
  /** Fails when a row holds an org id longer than 16 characters, rather than truncating it. */
9165
- async function down(db) {
9165
+ async function down$1(db) {
9166
9166
  for (const table of ORG_ID_TABLES$1) await sql.raw(`ALTER TABLE public.${table} ALTER COLUMN org_id TYPE varchar(16)`).execute(db);
9167
9167
  }
9168
9168
  //#endregion
9169
+ //#region src/db/migrations/160_execution_jobs_workflow_name.ts
9170
+ var _160_execution_jobs_workflow_name_exports = /* @__PURE__ */ __exportAll({
9171
+ down: () => down,
9172
+ up: () => up
9173
+ });
9174
+ /**
9175
+ * `execution_jobs.workflow_name`: the workflow that defines the job. A fixture
9176
+ * run with no `--workflow` runs every matched workflow under one run id, so
9177
+ * `execution_runs.workflow_name` (the first matched workflow) does not say
9178
+ * which workflow a job belongs to.
9179
+ *
9180
+ * Nullable, with no backfill: a row written before this column reads as
9181
+ * unknown, and the readers fall back to the run's workflow for a run that can
9182
+ * span only one.
9183
+ *
9184
+ * Idempotent.
9185
+ */
9186
+ async function up(db) {
9187
+ await sql`
9188
+ ALTER TABLE public.execution_jobs ADD COLUMN IF NOT EXISTS workflow_name text
9189
+ `.execute(db);
9190
+ }
9191
+ async function down(db) {
9192
+ await sql`ALTER TABLE public.execution_jobs DROP COLUMN IF EXISTS workflow_name`.execute(db);
9193
+ }
9194
+ //#endregion
9169
9195
  //#region src/db/migration-provider.ts
9170
9196
  function createMigrationProvider() {
9171
9197
  return { async getMigrations() {
@@ -9328,7 +9354,8 @@ function createMigrationProvider() {
9328
9354
  "156_kici_events_match_outcome": _156_kici_events_match_outcome_exports,
9329
9355
  "157_host_roster_identity_source": _157_host_roster_identity_source_exports,
9330
9356
  "158_normalize_legacy_values": _158_normalize_legacy_values_exports,
9331
- "159_org_id_widen_to_source_width": _159_org_id_widen_to_source_width_exports
9357
+ "159_org_id_widen_to_source_width": _159_org_id_widen_to_source_width_exports,
9358
+ "160_execution_jobs_workflow_name": _160_execution_jobs_workflow_name_exports
9332
9359
  };
9333
9360
  } };
9334
9361
  }
@@ -11162,6 +11189,11 @@ const SCHEMA_SNAPSHOT = {
11162
11189
  nullable: true,
11163
11190
  default: null
11164
11191
  },
11192
+ "execution_jobs.workflow_name": {
11193
+ type: "text",
11194
+ nullable: true,
11195
+ default: null
11196
+ },
11165
11197
  "execution_runs.archive_object_key": {
11166
11198
  type: "text",
11167
11199
  nullable: true,
@@ -19593,6 +19625,25 @@ function formatDuration(ms) {
19593
19625
  if (secs < 60) return `${secs}s`;
19594
19626
  return `${Math.floor(secs / 60)}m${secs % 60}s`;
19595
19627
  }
19628
+ /** Every workflow a run spans; an older orchestrator reports only the first. */
19629
+ function runWorkflows(run) {
19630
+ return run.workflowNames?.length ? run.workflowNames : [run.workflowName];
19631
+ }
19632
+ /**
19633
+ * The `workflow` cell of `runs list`: the run's workflow, plus how many more it
19634
+ * spans (`hello-world +3`), so a run of several workflows never reads as one.
19635
+ */
19636
+ function workflowListCell(run) {
19637
+ const names = runWorkflows(run);
19638
+ return names.length > 1 ? `${names[0]} +${names.length - 1}` : names[0];
19639
+ }
19640
+ /**
19641
+ * A job's label in the per-job lines: qualified with its workflow when the run
19642
+ * spans several, where two jobs can share a name.
19643
+ */
19644
+ function jobLabel(job, spansWorkflows) {
19645
+ return spansWorkflows && job.workflowName ? `${job.workflowName} / ${job.jobName}` : job.jobName;
19646
+ }
19596
19647
  /**
19597
19648
  * Header lines naming where an organization-wide run's workflow is defined.
19598
19649
  * "Defined in" prints only when the workflow repository differs from the run's
@@ -19620,7 +19671,7 @@ function emptyStepLogNote(stepIndex, logs) {
19620
19671
  }
19621
19672
  function registerRunsCommands(program, getClient) {
19622
19673
  const runs = program.command("runs").description("Inspect execution runs, jobs, and steps");
19623
- runs.command("list").description("List execution runs (admin API: /api/v1/admin/runs)").option("--status <statuses>", "Filter by run status. Accepts a single value or a comma-separated list (e.g. success,failed)").option("--workflow-name <name>", "Filter by workflow name").option("--repo <ownerRepo>", "Filter by repo identifier (owner/repo)").option("--since <iso8601>", "Only include runs with created_at strictly later than this ISO-8601 timestamp").option("--count", "Return only the count of matching runs, skipping the row listing").option("--limit <n>", "Max results (default 20, max 100)", "20").option("--offset <n>", "Skip first N results", "0").option("--json", "Emit raw JSON instead of a table").action(cliAction(async (opts) => {
19674
+ runs.command("list").description("List execution runs (admin API: /api/v1/admin/runs)").option("--status <statuses>", "Filter by run status. Accepts a single value or a comma-separated list (e.g. success,failed)").option("--workflow-name <name>", "Filter by workflow name. A run that spans several workflows matches any of them").option("--repo <ownerRepo>", "Filter by repo identifier (owner/repo)").option("--since <iso8601>", "Only include runs with created_at strictly later than this ISO-8601 timestamp").option("--count", "Return only the count of matching runs, skipping the row listing").option("--limit <n>", "Max results (default 20, max 100)", "20").option("--offset <n>", "Skip first N results", "0").option("--json", "Emit raw JSON instead of a table").action(cliAction(async (opts) => {
19624
19675
  if (opts.count) {
19625
19676
  const data = await getClient().countRuns({
19626
19677
  status: opts.status,
@@ -19660,7 +19711,7 @@ function registerRunsCommands(program, getClient) {
19660
19711
  ];
19661
19712
  const rows = data.runs.map((r) => [
19662
19713
  r.runId,
19663
- r.workflowName,
19714
+ workflowListCell(r),
19664
19715
  r.status,
19665
19716
  r.repoIdentifier,
19666
19717
  r.ref,
@@ -19686,8 +19737,11 @@ function registerRunsCommands(program, getClient) {
19686
19737
  return;
19687
19738
  }
19688
19739
  const { run, jobs } = data;
19740
+ const workflows = runWorkflows(run);
19741
+ const spansWorkflows = workflows.length > 1;
19689
19742
  console.log(`Run: ${run.runId}`);
19690
- console.log(` Workflow: ${run.workflowName}`);
19743
+ if (spansWorkflows) console.log(` Workflows: ${workflows.join(", ")}`);
19744
+ else console.log(` Workflow: ${run.workflowName}`);
19691
19745
  console.log(` Status: ${run.status}`);
19692
19746
  console.log(` Repo: ${run.repoIdentifier}`);
19693
19747
  console.log(` Ref: ${run.ref}`);
@@ -19713,6 +19767,7 @@ function registerRunsCommands(program, getClient) {
19713
19767
  const jobHeaders = [
19714
19768
  "job_id",
19715
19769
  "name",
19770
+ "workflow",
19716
19771
  "status",
19717
19772
  "agent",
19718
19773
  "duration",
@@ -19721,6 +19776,7 @@ function registerRunsCommands(program, getClient) {
19721
19776
  const jobRows = jobs.map((j) => [
19722
19777
  j.jobId,
19723
19778
  j.jobName,
19779
+ j.workflowName ?? "-",
19724
19780
  j.status,
19725
19781
  j.agentId ?? "-",
19726
19782
  formatDuration(j.durationMs),
@@ -19730,12 +19786,12 @@ function registerRunsCommands(program, getClient) {
19730
19786
  const unroutableJobs = jobs.filter((j) => j.routingReason && (j.status === ExecutionJobStatus.enum.pending || j.status === ExecutionJobStatus.enum.queued));
19731
19787
  if (unroutableJobs.length > 0) {
19732
19788
  console.log("");
19733
- for (const job of unroutableJobs) console.log(` ! ${job.jobName}: ${job.routingReason}`);
19789
+ for (const job of unroutableJobs) console.log(` ! ${jobLabel(job, spansWorkflows)}: ${job.routingReason}`);
19734
19790
  }
19735
19791
  const jobsWithSteps = jobs.filter((j) => (j.steps?.length ?? 0) > 0);
19736
19792
  if (jobsWithSteps.length > 0) for (const job of jobsWithSteps) {
19737
19793
  console.log("");
19738
- console.log(`Steps for ${job.jobName} (${job.jobId}):`);
19794
+ console.log(`Steps for ${jobLabel(job, spansWorkflows)} (${job.jobId}):`);
19739
19795
  const stepHeaders = [
19740
19796
  "#",
19741
19797
  "name",
@@ -19821,6 +19877,7 @@ function registerRunsCommands(program, getClient) {
19821
19877
  const headers = [
19822
19878
  "job_id",
19823
19879
  "name",
19880
+ "workflow",
19824
19881
  "status",
19825
19882
  "agent",
19826
19883
  "duration",
@@ -19829,32 +19886,36 @@ function registerRunsCommands(program, getClient) {
19829
19886
  const rows = response.jobs.map((j) => [
19830
19887
  j.jobId,
19831
19888
  j.jobName,
19889
+ j.workflowName ?? "-",
19832
19890
  j.status,
19833
19891
  j.agentId ?? "-",
19834
19892
  formatDuration(j.durationMs),
19835
19893
  j.startedAt ?? "-"
19836
19894
  ]);
19837
19895
  console.log(renderTable(headers, rows));
19838
- if (opts.includeSteps) for (const job of response.jobs) {
19839
- const steps = job.steps ?? [];
19840
- if (steps.length === 0) continue;
19841
- console.log("");
19842
- console.log(`Steps for ${job.jobName} (${job.jobId}):`);
19843
- const stepHeaders = [
19844
- "#",
19845
- "name",
19846
- "status",
19847
- "exit",
19848
- "duration"
19849
- ];
19850
- const stepRows = steps.map((s) => [
19851
- String(s.stepIndex),
19852
- s.stepName,
19853
- s.status,
19854
- s.exitCode != null ? String(s.exitCode) : "-",
19855
- formatDuration(s.durationMs)
19856
- ]);
19857
- console.log(renderTable(stepHeaders, stepRows));
19896
+ if (opts.includeSteps) {
19897
+ const spansWorkflows = new Set(response.jobs.map((j) => j.workflowName).filter(Boolean)).size > 1;
19898
+ for (const job of response.jobs) {
19899
+ const steps = job.steps ?? [];
19900
+ if (steps.length === 0) continue;
19901
+ console.log("");
19902
+ console.log(`Steps for ${jobLabel(job, spansWorkflows)} (${job.jobId}):`);
19903
+ const stepHeaders = [
19904
+ "#",
19905
+ "name",
19906
+ "status",
19907
+ "exit",
19908
+ "duration"
19909
+ ];
19910
+ const stepRows = steps.map((s) => [
19911
+ String(s.stepIndex),
19912
+ s.stepName,
19913
+ s.status,
19914
+ s.exitCode != null ? String(s.exitCode) : "-",
19915
+ formatDuration(s.durationMs)
19916
+ ]);
19917
+ console.log(renderTable(stepHeaders, stepRows));
19918
+ }
19858
19919
  }
19859
19920
  }));
19860
19921
  runs.command("logs <runId>").description("Print a page of a step log (admin API: /api/v1/admin/runs/:runId/jobs/:jobId/steps/:i/logs)").requiredOption("--job <jobId>", "Job id (the dispatch_queue row id for an eval round)").option("--step <n>", "Step index (default 0; -1 is the job setup log)", "0").option("--limit <n>", "Max lines to return (default 500, server caps at 2000)", "500").option("--cursor <c>", "Line-offset cursor from a previous page").option("--json", "Emit raw JSON instead of plain lines").action(cliAction(async (runId, opts) => {
@@ -22341,6 +22402,25 @@ function encryptPrivateKey(privateKey, secretKey) {
22341
22402
  return encrypt(privateKey.toString("base64"), key, 1, PRIVATE_KEY_AAD).data;
22342
22403
  }
22343
22404
  createLogger({ prefix: "job-secret-seal" });
22405
+ //#endregion
22406
+ //#region src/agent/agent-version.ts
22407
+ /**
22408
+ * Parse `MAJOR.MINOR.PATCH`, or `null` for a non-version. The `-prerelease`
22409
+ * suffix is dropped rather than ordered: it is a build counter (`0.5.0-9159`),
22410
+ * and strict semver would order it BELOW `0.5.0`, reading every prerelease
22411
+ * agent as too old for a feature it carries.
22412
+ */
22413
+ function parseVersionBase(version) {
22414
+ const parts = version.trim().split("-")[0].split(".");
22415
+ if (parts.length !== 3) return null;
22416
+ const nums = parts.map((part) => /^\d+$/.test(part) ? Number(part) : NaN);
22417
+ if (nums.some((n) => Number.isNaN(n))) return null;
22418
+ return [
22419
+ nums[0],
22420
+ nums[1],
22421
+ nums[2]
22422
+ ];
22423
+ }
22344
22424
  runtimeLabel(RuntimeFact.enum.docker), runtimeLabel(RuntimeFact.enum.podman);
22345
22425
  //#endregion
22346
22426
  //#region src/helpers/run-detached.ts
@@ -24132,6 +24212,117 @@ async function preflightBareMetalBinaryPaths(args) {
24132
24212
  Nothing was installed and the service was not restarted. Fix binaryPath and run the upgrade again, or pass ${SKIP_BINARY_PATH_CHECK_FLAG} to upgrade anyway.`);
24133
24213
  }
24134
24214
  //#endregion
24215
+ //#region src/cli/commands/shared/container-agent-image-check.ts
24216
+ /**
24217
+ * The container-scaler agent image check `kici-admin orchestrator upgrade`
24218
+ * runs before it restarts the service.
24219
+ *
24220
+ * A container scaler spawns each agent from the image its label set names, not
24221
+ * from the upgraded orchestrator. So an upgrade leaves container agents on the
24222
+ * old release when a label set pins an older `kici-agent:<version>`, or names
24223
+ * the moving `:latest` tag with the default `imagePullPolicy: IfNotPresent`: a
24224
+ * host that already pulled `:latest` keeps that image. The check only warns:
24225
+ * it never rewrites the operator's scaler config and never stops the upgrade.
24226
+ */
24227
+ /** The repository name of the published agent image, under any registry or mirror. */
24228
+ const AGENT_IMAGE_NAME = "kici-agent";
24229
+ /** The moving tag an untagged image reference resolves to. */
24230
+ const LATEST_TAG = "latest";
24231
+ /**
24232
+ * Split `[registry/]path/name[:tag][@digest]`. A `:` before the last `/` is a
24233
+ * registry port, not a tag.
24234
+ */
24235
+ function parseImageRef(image) {
24236
+ const at = image.indexOf("@");
24237
+ const named = at === -1 ? image : image.slice(0, at);
24238
+ const digest = at === -1 ? null : image.slice(at + 1);
24239
+ const colon = named.lastIndexOf(":");
24240
+ if (colon > named.lastIndexOf("/")) return {
24241
+ repository: named.slice(0, colon),
24242
+ tag: named.slice(colon + 1),
24243
+ digest
24244
+ };
24245
+ return {
24246
+ repository: named,
24247
+ tag: null,
24248
+ digest
24249
+ };
24250
+ }
24251
+ /** True when the repository is the KiCI agent image, from quay.io or a mirror. */
24252
+ function isAgentImage(repository) {
24253
+ return repository.slice(repository.lastIndexOf("/") + 1) === AGENT_IMAGE_NAME;
24254
+ }
24255
+ /** -1, 0 or 1 as `a` is an older, the same or a newer release than `b`; null for a non-version. */
24256
+ function compareReleases(a, b) {
24257
+ const left = parseVersionBase(a.replace(/^v/, ""));
24258
+ const right = parseVersionBase(b.replace(/^v/, ""));
24259
+ if (!left || !right) return null;
24260
+ for (let i = 0; i < 3; i++) if (left[i] !== right[i]) return left[i] < right[i] ? -1 : 1;
24261
+ return 0;
24262
+ }
24263
+ /**
24264
+ * Every container-scaler label set whose agent image an upgrade to
24265
+ * `targetVersion` leaves unchanged. An empty result means each agent image is
24266
+ * pinned to the target (or newer), pulled on every spawn, or not a KiCI agent.
24267
+ */
24268
+ function checkContainerAgentImages(args) {
24269
+ const { config } = args;
24270
+ const bare = args.targetVersion?.trim().replace(/^v/, "") ?? null;
24271
+ const targetVersion = bare && parseVersionBase(bare) ? bare : null;
24272
+ const where = args.scalerConfigDir ? `${args.scalerConfigPath} (or the file under ${args.scalerConfigDir} that declares it)` : args.scalerConfigPath;
24273
+ const findings = [];
24274
+ for (const entry of config.scalers) {
24275
+ if (entry.type !== ScalerBackendType.enum.container) continue;
24276
+ for (const ls of entry.labelSets) {
24277
+ if (!ls.image) continue;
24278
+ const ref = parseImageRef(ls.image);
24279
+ if (!isAgentImage(ref.repository)) continue;
24280
+ const pinned = targetVersion ? `${ref.repository}:${targetVersion}` : null;
24281
+ const prefix = `container scaler "${entry.name}", label set [${ls.labels.join(", ")}]: image ${ls.image}`;
24282
+ const finding = (issue, message) => ({
24283
+ issue,
24284
+ scaler: entry.name,
24285
+ labels: ls.labels,
24286
+ image: ls.image,
24287
+ message: `${prefix} ${message}`
24288
+ });
24289
+ const policy = ls.imagePullPolicy ?? ImagePullPolicy.enum.IfNotPresent;
24290
+ if ((ref.tag === null || ref.tag === LATEST_TAG) && ref.digest === null && policy === ImagePullPolicy.enum.IfNotPresent) {
24291
+ const pin = pinned ? `set "image: ${pinned}"` : `set image to the kici-agent release you upgrade to (${ref.repository}:<version>)`;
24292
+ findings.push(finding("moving-tag", `with imagePullPolicy IfNotPresent keeps the agent image this host already pulled, so the upgrade does not change the container agents. In ${where}, ${pin} on this label set, or set "imagePullPolicy: Always" to pull ${LATEST_TAG} on every spawn.`));
24293
+ continue;
24294
+ }
24295
+ if (!targetVersion || ref.tag === null) continue;
24296
+ if (compareReleases(ref.tag, targetVersion) === -1) findings.push(finding("older-pin", `is older than the upgrade target ${targetVersion}, so the container agents keep running ${ref.tag}. In ${where}, set "image: ${pinned}" on this label set.`));
24297
+ }
24298
+ }
24299
+ return findings;
24300
+ }
24301
+ /**
24302
+ * Print one warning per container label set whose agent image the upgrade
24303
+ * leaves unchanged. Never throws, and stays silent when the env file or the
24304
+ * scaler config cannot be read: the bare-metal `binaryPath` check, which runs
24305
+ * first on the same files, already reports that.
24306
+ */
24307
+ async function warnAboutContainerAgentImages(args) {
24308
+ let location;
24309
+ let config;
24310
+ try {
24311
+ location = scalerConfigLocation(fs.readFileSync(args.envFilePath, "utf-8"), args.workingDirectory);
24312
+ if (!location) return;
24313
+ config = await loadScalerConfig(location.configPath, location.configDir);
24314
+ } catch {
24315
+ return;
24316
+ }
24317
+ const findings = checkContainerAgentImages({
24318
+ config,
24319
+ targetVersion: args.targetVersion,
24320
+ scalerConfigPath: location.configPath,
24321
+ ...location.configDir ? { scalerConfigDir: location.configDir } : {}
24322
+ });
24323
+ for (const f of findings) args.warn(`Warning: ${f.message}`);
24324
+ }
24325
+ //#endregion
24135
24326
  //#region src/cli/commands/shared/versioned-upgrade.ts
24136
24327
  /**
24137
24328
  * Versioned-directory upgrade shared by the kici-admin upgrade commands: each
@@ -24141,14 +24332,16 @@ Nothing was installed and the service was not restarted. Fix binaryPath and run
24141
24332
  */
24142
24333
  init_service();
24143
24334
  /**
24144
- * Check every bare-metal `binaryPath` of an orchestrator before the upgrade
24145
- * installs or restarts anything. `spec` is the unit's launch command: the
24146
- * `kici-agent` installed with its runtime is the one each `binaryPath` should
24335
+ * Check an orchestrator's scaler config before the upgrade installs or
24336
+ * restarts anything. `spec` is the unit's launch command: the `kici-agent`
24337
+ * installed with its runtime is the one each bare-metal `binaryPath` should
24147
24338
  * name. `expectedVersion` is what that agent runs after the upgrade, when the
24148
24339
  * caller knows it. Throws when a `binaryPath` would stop the restarted service,
24149
- * unless `skip` is set: then every finding is a warning.
24340
+ * unless `skip` is set: then every finding is a warning. Then warns about each
24341
+ * container label set whose agent image stays behind `targetVersion`, the
24342
+ * release the service runs after the upgrade.
24150
24343
  */
24151
- async function checkBareMetalBinaryPathsBeforeUpgrade(args) {
24344
+ async function checkScalersBeforeUpgrade(args) {
24152
24345
  if (args.component !== "orchestrator" || args.platform === "compose") return;
24153
24346
  const expectedAgent = args.spec ? agentBinaryFromLaunch(args.spec, isWindows(args.platform)) : null;
24154
24347
  await preflightBareMetalBinaryPaths({
@@ -24161,6 +24354,12 @@ async function checkBareMetalBinaryPathsBeforeUpgrade(args) {
24161
24354
  skip: args.skip,
24162
24355
  warn: (line) => console.warn(line)
24163
24356
  });
24357
+ await warnAboutContainerAgentImages({
24358
+ envFilePath: args.config.envFilePath,
24359
+ workingDirectory: args.config.workingDirectory,
24360
+ targetVersion: args.targetVersion,
24361
+ warn: (line) => console.warn(line)
24362
+ });
24164
24363
  }
24165
24364
  /**
24166
24365
  * Resolve the upgrade target through {@link resolveInstanceTarget}: `instanceDir`,
@@ -24748,12 +24947,13 @@ async function performVersionedUpgrade(component, opts, hooks = {}) {
24748
24947
  console.error(`Error: service "${config.name}" is not installed`);
24749
24948
  process.exit(1);
24750
24949
  }
24751
- await checkBareMetalBinaryPathsBeforeUpgrade({
24950
+ await checkScalersBeforeUpgrade({
24752
24951
  component,
24753
24952
  config,
24754
24953
  platform,
24755
24954
  spec: await manager.readLaunchSpec(config),
24756
24955
  expectedVersion: null,
24956
+ targetVersion: version,
24757
24957
  willInstall: false,
24758
24958
  skip: opts.skipBinaryPathCheck ?? false
24759
24959
  });
@@ -24909,12 +25109,13 @@ async function restartOnlyUpgrade(args) {
24909
25109
  console.error(`Error: ${verdict.reason}`);
24910
25110
  process.exit(1);
24911
25111
  }
24912
- await checkBareMetalBinaryPathsBeforeUpgrade({
25112
+ await checkScalersBeforeUpgrade({
24913
25113
  component: args.component,
24914
25114
  config,
24915
25115
  platform,
24916
25116
  spec,
24917
25117
  expectedVersion: null,
25118
+ targetVersion: verdict.version,
24918
25119
  willInstall: false,
24919
25120
  skip: opts.skipBinaryPathCheck ?? false
24920
25121
  });
@@ -24945,12 +25146,13 @@ async function restartOnlyUpgrade(args) {
24945
25146
  async function performSelfDrivingInstall(args) {
24946
25147
  const { component, config, resolvedInstance, manager, action, opts, platform, spec } = args;
24947
25148
  const { target, version } = action;
24948
- await checkBareMetalBinaryPathsBeforeUpgrade({
25149
+ await checkScalersBeforeUpgrade({
24949
25150
  component,
24950
25151
  config,
24951
25152
  platform,
24952
25153
  spec,
24953
25154
  expectedVersion: `${target.owningPackage}@${version}`,
25155
+ targetVersion: version,
24954
25156
  willInstall: true,
24955
25157
  skip: opts.skipBinaryPathCheck ?? false
24956
25158
  });
@@ -25108,7 +25310,7 @@ async function switchToInstalledVersion(args) {
25108
25310
  action: `switch "${config.name}" to ${targetVersion}`,
25109
25311
  config
25110
25312
  });
25111
- await warnAboutBareMetalBinaryPaths(args);
25313
+ await warnAboutScalers(args);
25112
25314
  if (!await assertSchemaAllowsSwitch({
25113
25315
  component,
25114
25316
  targetVersion,
@@ -25142,18 +25344,20 @@ async function switchToInstalledVersion(args) {
25142
25344
  });
25143
25345
  }
25144
25346
  /**
25145
- * Print the bare-metal `binaryPath` diagnosis before `--rollback` or `--pick`
25146
- * restarts the service. Never refuses and never throws: both are recovery
25147
- * paths, and a check that cannot run must not block a recovery.
25347
+ * Print the bare-metal `binaryPath` and container agent image diagnoses before
25348
+ * `--rollback` or `--pick` restarts the service. Never refuses and never
25349
+ * throws: both are recovery paths, and a check that cannot run must not block
25350
+ * a recovery.
25148
25351
  */
25149
- async function warnAboutBareMetalBinaryPaths(args) {
25352
+ async function warnAboutScalers(args) {
25150
25353
  try {
25151
- await checkBareMetalBinaryPathsBeforeUpgrade({
25354
+ await checkScalersBeforeUpgrade({
25152
25355
  component: args.component,
25153
25356
  config: args.config,
25154
25357
  platform: args.platform,
25155
25358
  spec: await args.manager.readLaunchSpec(args.config).catch(() => null),
25156
25359
  expectedVersion: null,
25360
+ targetVersion: args.targetVersion,
25157
25361
  willInstall: false,
25158
25362
  skip: true
25159
25363
  });
@@ -26677,7 +26881,7 @@ init_manifest();
26677
26881
  const ALL_PLATFORMS = AgentPlatform.options;
26678
26882
  /** The orchestrator's own version (single-version invariant) = the packaged agent version. */
26679
26883
  function resolveKiciVersion() {
26680
- return "0.19.0";
26884
+ return "0.20.1";
26681
26885
  }
26682
26886
  /** Parse the --platform value: default set | single | CSV | `all`. */
26683
26887
  function parsePlatforms(raw) {
@@ -36926,7 +37130,7 @@ function routeRootArgs(root, args) {
36926
37130
  * build entry; the fallback covers a source run (tests, `tsx`), the same shape
36927
37131
  * `server.ts` and `standalone.ts` use for `ORCHESTRATOR_VERSION`.
36928
37132
  */
36929
- const CLI_VERSION = "0.19.0";
37133
+ const CLI_VERSION = "0.20.1";
36930
37134
  /**
36931
37135
  * Root command whose option parsing first routes argv through
36932
37136
  * {@link routeRootArgs}: a leading `--version` prints the CLI version, and an