@bettercms-ai/db 0.4.4 → 0.4.6

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/index.js CHANGED
@@ -11654,18 +11654,18 @@ var require_common = __commonJS({
11654
11654
  if (typeof args[0] !== "string") {
11655
11655
  args.unshift("%O");
11656
11656
  }
11657
- let index106 = 0;
11657
+ let index108 = 0;
11658
11658
  args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
11659
11659
  if (match === "%%") {
11660
11660
  return "%";
11661
11661
  }
11662
- index106++;
11662
+ index108++;
11663
11663
  const formatter = createDebug.formatters[format];
11664
11664
  if (typeof formatter === "function") {
11665
- const val = args[index106];
11665
+ const val = args[index108];
11666
11666
  match = formatter.call(self2, val);
11667
- args.splice(index106, 1);
11668
- index106--;
11667
+ args.splice(index108, 1);
11668
+ index108--;
11669
11669
  }
11670
11670
  return match;
11671
11671
  });
@@ -11901,15 +11901,15 @@ var require_browser = __commonJS({
11901
11901
  }
11902
11902
  const c = "color: " + this.color;
11903
11903
  args.splice(1, 0, c, "color: inherit");
11904
- let index106 = 0;
11904
+ let index108 = 0;
11905
11905
  let lastC = 0;
11906
11906
  args[0].replace(/%[a-zA-Z%]/g, (match) => {
11907
11907
  if (match === "%%") {
11908
11908
  return;
11909
11909
  }
11910
- index106++;
11910
+ index108++;
11911
11911
  if (match === "%c") {
11912
- lastC = index106;
11912
+ lastC = index108;
11913
11913
  }
11914
11914
  });
11915
11915
  args.splice(lastC, 0, c);
@@ -14470,10 +14470,10 @@ var require_axios = __commonJS({
14470
14470
  value = stringifyWithDepthLimit(value, 1);
14471
14471
  } else if (utils$1.isArray(value) && isFlatArray(value) || (utils$1.isFileList(value) || utils$1.endsWith(key, "[]")) && (arr = utils$1.toArray(value))) {
14472
14472
  key = removeBrackets(key);
14473
- arr.forEach(function each(el, index106) {
14473
+ arr.forEach(function each(el, index108) {
14474
14474
  !(utils$1.isUndefined(el) || el === null) && formData.append(
14475
14475
  // eslint-disable-next-line no-nested-ternary
14476
- indexes === true ? renderKey([key], index106, dots) : indexes === null ? key : key + "[]",
14476
+ indexes === true ? renderKey([key], index108, dots) : indexes === null ? key : key + "[]",
14477
14477
  convertValue(el)
14478
14478
  );
14479
14479
  });
@@ -14774,9 +14774,9 @@ var require_axios = __commonJS({
14774
14774
  });
14775
14775
  }
14776
14776
  var MAX_DEPTH = DEFAULT_FORM_DATA_MAX_DEPTH;
14777
- function throwIfDepthExceeded(index106) {
14778
- if (index106 > MAX_DEPTH) {
14779
- throw new AxiosError("FormData field is too deeply nested (" + index106 + " levels). Max depth: " + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
14777
+ function throwIfDepthExceeded(index108) {
14778
+ if (index108 > MAX_DEPTH) {
14779
+ throw new AxiosError("FormData field is too deeply nested (" + index108 + " levels). Max depth: " + MAX_DEPTH, AxiosError.ERR_FORM_DATA_DEPTH_EXCEEDED);
14780
14780
  }
14781
14781
  }
14782
14782
  function parsePropPath(name) {
@@ -14802,12 +14802,12 @@ var require_axios = __commonJS({
14802
14802
  return obj;
14803
14803
  }
14804
14804
  function formDataToJSON(formData) {
14805
- function buildPath(path2, value, target, index106) {
14806
- throwIfDepthExceeded(index106);
14807
- let name = path2[index106++];
14805
+ function buildPath(path2, value, target, index108) {
14806
+ throwIfDepthExceeded(index108);
14807
+ let name = path2[index108++];
14808
14808
  if (name === "__proto__") return true;
14809
14809
  const isNumericKey = Number.isFinite(+name);
14810
- const isLast = index106 >= path2.length;
14810
+ const isLast = index108 >= path2.length;
14811
14811
  name = !name && utils$1.isArray(target) ? target.length : name;
14812
14812
  if (isLast) {
14813
14813
  if (utils$1.hasOwnProp(target, name)) {
@@ -14820,7 +14820,7 @@ var require_axios = __commonJS({
14820
14820
  if (!utils$1.hasOwnProp(target, name) || !utils$1.isObject(target[name])) {
14821
14821
  target[name] = [];
14822
14822
  }
14823
- const result = buildPath(path2, value, target[name], index106);
14823
+ const result = buildPath(path2, value, target[name], index108);
14824
14824
  if (result && utils$1.isArray(target[name])) {
14825
14825
  target[name] = arrayToObject(target[name]);
14826
14826
  }
@@ -15489,20 +15489,20 @@ var require_axios = __commonJS({
15489
15489
  if (parts[0] !== "127") return false;
15490
15490
  return parts.every((p) => /^\d+$/.test(p) && Number(p) >= 0 && Number(p) <= 255);
15491
15491
  };
15492
- var parseIPv4Octet = (text122) => {
15493
- if (/^0[xX][0-9a-fA-F]+$/.test(text122)) {
15494
- const n = parseInt(text122.slice(2), 16);
15492
+ var parseIPv4Octet = (text125) => {
15493
+ if (/^0[xX][0-9a-fA-F]+$/.test(text125)) {
15494
+ const n = parseInt(text125.slice(2), 16);
15495
15495
  return Number.isFinite(n) ? n : null;
15496
15496
  }
15497
- if (text122.length > 1 && /^0[0-7]+$/.test(text122)) {
15498
- const n = parseInt(text122, 8);
15497
+ if (text125.length > 1 && /^0[0-7]+$/.test(text125)) {
15498
+ const n = parseInt(text125, 8);
15499
15499
  return Number.isFinite(n) ? n : null;
15500
15500
  }
15501
- if (text122.length > 1 && /^0[0-9]+$/.test(text122)) {
15501
+ if (text125.length > 1 && /^0[0-9]+$/.test(text125)) {
15502
15502
  return null;
15503
15503
  }
15504
- if (/^[0-9]+$/.test(text122)) {
15505
- const n = parseInt(text122, 10);
15504
+ if (/^[0-9]+$/.test(text125)) {
15505
+ const n = parseInt(text125, 10);
15506
15506
  return Number.isFinite(n) ? n : null;
15507
15507
  }
15508
15508
  return null;
@@ -15840,12 +15840,12 @@ var require_axios = __commonJS({
15840
15840
  };
15841
15841
  }
15842
15842
  function throttle(fn, freq) {
15843
- let timestamp113 = 0;
15843
+ let timestamp116 = 0;
15844
15844
  let threshold = 1e3 / freq;
15845
15845
  let lastArgs;
15846
15846
  let timer;
15847
15847
  const invoke = (args, now = Date.now()) => {
15848
- timestamp113 = now;
15848
+ timestamp116 = now;
15849
15849
  lastArgs = null;
15850
15850
  if (timer) {
15851
15851
  clearTimeout(timer);
@@ -15855,7 +15855,7 @@ var require_axios = __commonJS({
15855
15855
  };
15856
15856
  const throttled = (...args) => {
15857
15857
  const now = Date.now();
15858
- const passed = now - timestamp113;
15858
+ const passed = now - timestamp116;
15859
15859
  if (passed >= threshold) {
15860
15860
  invoke(args, now);
15861
15861
  } else {
@@ -18242,9 +18242,9 @@ var require_axios = __commonJS({
18242
18242
  if (!this._listeners) {
18243
18243
  return;
18244
18244
  }
18245
- const index106 = this._listeners.indexOf(listener);
18246
- if (index106 !== -1) {
18247
- this._listeners.splice(index106, 1);
18245
+ const index108 = this._listeners.indexOf(listener);
18246
+ if (index108 !== -1) {
18247
+ this._listeners.splice(index108, 1);
18248
18248
  }
18249
18249
  }
18250
18250
  toAbortSignal() {
@@ -21986,6 +21986,7 @@ __export(index_exports, {
21986
21986
  branchColumns: () => branchColumns,
21987
21987
  branchPreviewGrants: () => branchPreviewGrants,
21988
21988
  branchPreviewShares: () => branchPreviewShares,
21989
+ branchRowSyncs: () => branchRowSyncs,
21989
21990
  brandKitVersions: () => brandKitVersions,
21990
21991
  buildTriggerRuns: () => buildTriggerRuns,
21991
21992
  buildTriggers: () => buildTriggers,
@@ -22087,6 +22088,10 @@ __export(index_exports, {
22087
22088
  pendingInvites: () => pendingInvites,
22088
22089
  planChanges: () => planChanges,
22089
22090
  planLimits: () => planLimits,
22091
+ platformIncidentUpdates: () => platformIncidentUpdates,
22092
+ platformIncidents: () => platformIncidents,
22093
+ platformTasks: () => platformTasks,
22094
+ platformVendors: () => platformVendors,
22090
22095
  previewTokenRevocations: () => previewTokenRevocations,
22091
22096
  projectBranches: () => projectBranches,
22092
22097
  projectEnvVars: () => projectEnvVars,
@@ -22197,11 +22202,11 @@ import {
22197
22202
  boolean as boolean7,
22198
22203
  integer as integer8,
22199
22204
  index as index10,
22200
- uniqueIndex as uniqueIndex3,
22205
+ uniqueIndex as uniqueIndex4,
22201
22206
  unique
22202
22207
  } from "drizzle-orm/pg-core";
22203
22208
  import { relations as relations9 } from "drizzle-orm/relations";
22204
- import { sql as sql5 } from "drizzle-orm";
22209
+ import { sql as sql6 } from "drizzle-orm";
22205
22210
 
22206
22211
  // src/schema/workspaces.ts
22207
22212
  import {
@@ -22321,9 +22326,11 @@ import {
22321
22326
  timestamp as timestamp5,
22322
22327
  jsonb as jsonb5,
22323
22328
  integer as integer4,
22324
- index as index4
22329
+ index as index4,
22330
+ uniqueIndex
22325
22331
  } from "drizzle-orm/pg-core";
22326
22332
  import { relations as relations3 } from "drizzle-orm/relations";
22333
+ import { sql as sql2 } from "drizzle-orm";
22327
22334
 
22328
22335
  // src/schema/content_entries.ts
22329
22336
  import {
@@ -22770,7 +22777,10 @@ var contentModels = pgTable4(
22770
22777
  // Soft-delete filtering
22771
22778
  index4("content_models_deleted_at_idx").on(table.deletedAt),
22772
22779
  // FLO-735: the Collections list filters on `page_id IS NULL` on every project load.
22773
- index4("content_models_page_id_idx").on(table.pageId)
22780
+ index4("content_models_page_id_idx").on(table.pageId),
22781
+ // 0356 + 0371: one Accounts / Proof collection per project PER BRANCH — ensureAbmModels
22782
+ // relies on it for idempotence, and a branch copy needs its own row under the same slug.
22783
+ uniqueIndex("content_models_project_abm_slug_idx").on(table.projectId, table.branchId, table.slug).where(sql2`deleted_at IS NULL AND slug IN ('abm-accounts', 'proof')`)
22774
22784
  ]
22775
22785
  );
22776
22786
  var contentModelsRelations = relations3(contentModels, ({ one, many }) => ({
@@ -22795,10 +22805,10 @@ import {
22795
22805
  real,
22796
22806
  boolean as boolean3,
22797
22807
  index as index6,
22798
- uniqueIndex as uniqueIndex2
22808
+ uniqueIndex as uniqueIndex3
22799
22809
  } from "drizzle-orm/pg-core";
22800
22810
  import { relations as relations5 } from "drizzle-orm/relations";
22801
- import { sql as sql3 } from "drizzle-orm";
22811
+ import { sql as sql4 } from "drizzle-orm";
22802
22812
 
22803
22813
  // src/schema/folders.ts
22804
22814
  import {
@@ -22807,9 +22817,9 @@ import {
22807
22817
  varchar as varchar5,
22808
22818
  timestamp as timestamp6,
22809
22819
  index as index5,
22810
- uniqueIndex
22820
+ uniqueIndex as uniqueIndex2
22811
22821
  } from "drizzle-orm/pg-core";
22812
- import { sql as sql2 } from "drizzle-orm";
22822
+ import { sql as sql3 } from "drizzle-orm";
22813
22823
  import { relations as relations4 } from "drizzle-orm/relations";
22814
22824
  var folders = pgTable5(
22815
22825
  "folders",
@@ -22835,7 +22845,7 @@ var folders = pgTable5(
22835
22845
  // Raw migration 0341 adds NULLS NOT DISTINCT; Drizzle's IndexBuilder cannot express it.
22836
22846
  // Without it this constrained nothing at the ROOT (parent_id IS NULL), where every folder the
22837
22847
  // Assets lane creates lives — so duplicate root folders were creatable through the API.
22838
- uniqueIndex("folders_sibling_name_uq").on(table.projectId, table.parentId, sql2`lower(${table.name})`).where(sql2`${table.deletedAt} IS NULL`)
22848
+ uniqueIndex2("folders_sibling_name_uq").on(table.projectId, table.parentId, sql3`lower(${table.name})`).where(sql3`${table.deletedAt} IS NULL`)
22839
22849
  ]
22840
22850
  );
22841
22851
  var foldersRelations = relations4(folders, ({ one, many }) => ({
@@ -22902,7 +22912,7 @@ var mediaAssets = pgTable6(
22902
22912
  //
22903
22913
  // NOT NULL DEFAULT [] rather than nullable: `tags @> ARRAY[…]` and `unnest(tags)` are both
22904
22914
  // wrong for a NULL, and "no tags" is genuinely an empty list, not an unknown one.
22905
- tags: text7("tags").array().notNull().$type().default(sql3`'{}'::text[]`),
22915
+ tags: text7("tags").array().notNull().$type().default(sql4`'{}'::text[]`),
22906
22916
  folderId: text7("folder_id"),
22907
22917
  // FK → folders.id; NULL = project root
22908
22918
  // The site-relative path a release-lane adoption came from (`/img/hero.png`), NULL for
@@ -22959,7 +22969,7 @@ var mediaAssets = pgTable6(
22959
22969
  // "Bookmarked" rail entry — PARTIAL index (only the starred minority). The
22960
22970
  // .where() must match migration 0157 exactly, or db:generate emits a spurious
22961
22971
  // diff for an index that already exists with a different definition.
22962
- index6("media_assets_bookmarked_idx").on(table.projectId).where(sql3`${table.bookmarked} = true`),
22972
+ index6("media_assets_bookmarked_idx").on(table.projectId).where(sql4`${table.bookmarked} = true`),
22963
22973
  // Tag filtering + the tag facet. GIN's default text[] opclass indexes containment (@>),
22964
22974
  // which is the operator the list route uses — a btree here would index nothing useful.
22965
22975
  index6("media_assets_tags_idx").using("gin", table.tags),
@@ -22967,7 +22977,7 @@ var mediaAssets = pgTable6(
22967
22977
  // up: PARTIAL (uploads are all NULL and must not collide) and UNIQUE, so two releases racing
22968
22978
  // the same path end with one row. Soft-deleted rows keep the key, so an asset the user
22969
22979
  // trashed is not re-adopted while it sits in Trash. Must match migration 0314 exactly.
22970
- uniqueIndex2("media_assets_project_source_path_idx").on(table.projectId, table.sourcePath).where(sql3`${table.sourcePath} IS NOT NULL`)
22980
+ uniqueIndex3("media_assets_project_source_path_idx").on(table.projectId, table.sourcePath).where(sql4`${table.sourcePath} IS NOT NULL`)
22971
22981
  ]
22972
22982
  );
22973
22983
  var mediaAssetsRelations = relations5(mediaAssets, ({ one }) => ({
@@ -23110,7 +23120,7 @@ import {
23110
23120
  index as index8
23111
23121
  } from "drizzle-orm/pg-core";
23112
23122
  import { relations as relations7 } from "drizzle-orm/relations";
23113
- import { sql as sql4 } from "drizzle-orm";
23123
+ import { sql as sql5 } from "drizzle-orm";
23114
23124
  var apiKeys = pgTable8(
23115
23125
  "api_keys",
23116
23126
  {
@@ -23132,7 +23142,7 @@ var apiKeys = pgTable8(
23132
23142
  // SHA-256 of the plaintext key
23133
23143
  keyPrefix: varchar8("key_prefix", { length: 16 }).notNull(),
23134
23144
  // first 12 chars for identification
23135
- permissions: text9("permissions").array().notNull().$type().default(sql4`ARRAY['content:read']`),
23145
+ permissions: text9("permissions").array().notNull().$type().default(sql5`ARRAY['content:read']`),
23136
23146
  tokenType: varchar8("token_type", { length: 20 }).notNull().default("read_only"),
23137
23147
  // Which front door minted this management key (0150): "device" | "authorization_code" |
23138
23148
  // "studio". Load-bearing for the workspace "External agents" switch — it is the ONLY thing
@@ -23613,13 +23623,13 @@ var projects = pgTable10(
23613
23623
  // Unique slug per workspace — partial on deleted_at IS NULL so a soft-deleted
23614
23624
  // project frees its slug (delete then recreate/re-import works). See migration
23615
23625
  // 0051; the create handler's conflict check also excludes soft-deleted rows.
23616
- uniqueIndex3("projects_workspace_slug_idx").on(table.workspaceId, table.slug).where(sql5`${table.deletedAt} IS NULL`),
23626
+ uniqueIndex4("projects_workspace_slug_idx").on(table.workspaceId, table.slug).where(sql6`${table.deletedAt} IS NULL`),
23617
23627
  // Workspace filtering
23618
23628
  index10("projects_workspace_idx").on(table.workspaceId),
23619
23629
  // Archive: every archive-aware list filters on this, so it earns an index like deletedAt.
23620
23630
  index10("projects_archived_at_idx").on(table.archivedAt),
23621
23631
  // Only the purge drain's rows: switch-archived and not yet deleted.
23622
- index10("projects_purge_after_idx").on(table.purgeAfter).where(sql5`${table.purgeAfter} IS NOT NULL AND ${table.deletedAt} IS NULL`)
23632
+ index10("projects_purge_after_idx").on(table.purgeAfter).where(sql6`${table.purgeAfter} IS NOT NULL AND ${table.deletedAt} IS NULL`)
23623
23633
  ]
23624
23634
  );
23625
23635
  var projectFolders = pgTable10("project_folders", {
@@ -23800,7 +23810,7 @@ import {
23800
23810
  varchar as varchar13,
23801
23811
  timestamp as timestamp15,
23802
23812
  index as index13,
23803
- uniqueIndex as uniqueIndex4
23813
+ uniqueIndex as uniqueIndex5
23804
23814
  } from "drizzle-orm/pg-core";
23805
23815
  var workspaceMembers = pgTable14(
23806
23816
  "workspace_members",
@@ -23822,7 +23832,7 @@ var workspaceMembers = pgTable14(
23822
23832
  },
23823
23833
  (table) => [
23824
23834
  // Unique membership: a user can only join a workspace once
23825
- uniqueIndex4("workspace_members_workspace_user_idx").on(
23835
+ uniqueIndex5("workspace_members_workspace_user_idx").on(
23826
23836
  table.workspaceId,
23827
23837
  table.userId
23828
23838
  ),
@@ -23844,7 +23854,7 @@ import {
23844
23854
  jsonb as jsonb10,
23845
23855
  boolean as boolean9,
23846
23856
  index as index14,
23847
- uniqueIndex as uniqueIndex5
23857
+ uniqueIndex as uniqueIndex6
23848
23858
  } from "drizzle-orm/pg-core";
23849
23859
  var workspaceRoles = pgTable15(
23850
23860
  "workspace_roles",
@@ -23867,7 +23877,7 @@ var workspaceRoles = pgTable15(
23867
23877
  updatedAt: timestamp16("updated_at").notNull().defaultNow()
23868
23878
  },
23869
23879
  (table) => [
23870
- uniqueIndex5("workspace_roles_workspace_key_idx").on(
23880
+ uniqueIndex6("workspace_roles_workspace_key_idx").on(
23871
23881
  table.workspaceId,
23872
23882
  table.key
23873
23883
  ),
@@ -23884,7 +23894,7 @@ import {
23884
23894
  boolean as boolean10,
23885
23895
  integer as integer9,
23886
23896
  index as index15,
23887
- uniqueIndex as uniqueIndex6
23897
+ uniqueIndex as uniqueIndex7
23888
23898
  } from "drizzle-orm/pg-core";
23889
23899
  var workflowStages = pgTable16(
23890
23900
  "workflow_stages",
@@ -23911,7 +23921,7 @@ var workflowStages = pgTable16(
23911
23921
  updatedAt: timestamp17("updated_at").notNull().defaultNow()
23912
23922
  },
23913
23923
  (table) => [
23914
- uniqueIndex6("workflow_stages_project_key_idx").on(table.projectId, table.key),
23924
+ uniqueIndex7("workflow_stages_project_key_idx").on(table.projectId, table.key),
23915
23925
  index15("workflow_stages_project_idx").on(table.projectId)
23916
23926
  ]
23917
23927
  );
@@ -23988,7 +23998,7 @@ import {
23988
23998
  text as text20,
23989
23999
  timestamp as timestamp20,
23990
24000
  unique as unique2,
23991
- uniqueIndex as uniqueIndex7,
24001
+ uniqueIndex as uniqueIndex8,
23992
24002
  varchar as varchar16
23993
24003
  } from "drizzle-orm/pg-core";
23994
24004
  var projectLayouts = pgTable19(
@@ -24009,7 +24019,7 @@ var projectLayouts = pgTable19(
24009
24019
  },
24010
24020
  (table) => [
24011
24021
  unique2("project_layouts_id_project_unique").on(table.id, table.projectId),
24012
- uniqueIndex7("project_layouts_project_unique").on(table.projectId),
24022
+ uniqueIndex8("project_layouts_project_unique").on(table.projectId),
24013
24023
  index18("project_layouts_workspace_idx").on(table.workspaceId)
24014
24024
  ]
24015
24025
  );
@@ -24031,14 +24041,14 @@ var projectLayoutVersions = pgTable19(
24031
24041
  foreignColumns: [projectLayouts.id, projectLayouts.projectId],
24032
24042
  name: "project_layout_versions_layout_project_fkey"
24033
24043
  }).onDelete("cascade"),
24034
- uniqueIndex7("project_layout_versions_layout_version_unique").on(table.layoutId, table.version),
24044
+ uniqueIndex8("project_layout_versions_layout_version_unique").on(table.layoutId, table.version),
24035
24045
  index18("project_layout_versions_project_idx").on(table.projectId, table.version)
24036
24046
  ]
24037
24047
  );
24038
24048
 
24039
24049
  // src/schema/page_folders.ts
24040
- import { pgTable as pgTable20, text as text21, varchar as varchar17, boolean as boolean11, index as index19, uniqueIndex as uniqueIndex8 } from "drizzle-orm/pg-core";
24041
- import { relations as relations10, sql as sql6 } from "drizzle-orm";
24050
+ import { pgTable as pgTable20, text as text21, varchar as varchar17, boolean as boolean11, index as index19, uniqueIndex as uniqueIndex9 } from "drizzle-orm/pg-core";
24051
+ import { relations as relations10, sql as sql7 } from "drizzle-orm";
24042
24052
  var pageFolders = pgTable20(
24043
24053
  "page_folders",
24044
24054
  {
@@ -24067,7 +24077,7 @@ var pageFolders = pgTable20(
24067
24077
  (t) => [
24068
24078
  index19("page_folders_project_idx").on(t.projectId),
24069
24079
  index19("page_folders_parent_idx").on(t.parentId),
24070
- uniqueIndex8("page_folders_project_slug_uniq").on(t.projectId, t.branchId, t.slug).where(sql6`deleted_at IS NULL`)
24080
+ uniqueIndex9("page_folders_project_slug_uniq").on(t.projectId, t.branchId, t.slug).where(sql7`deleted_at IS NULL`)
24071
24081
  ]
24072
24082
  );
24073
24083
  var pageFoldersRelations = relations10(pageFolders, ({ many }) => ({
@@ -24244,7 +24254,7 @@ import {
24244
24254
  integer as integer15,
24245
24255
  timestamp as timestamp26,
24246
24256
  index as index24,
24247
- uniqueIndex as uniqueIndex9
24257
+ uniqueIndex as uniqueIndex10
24248
24258
  } from "drizzle-orm/pg-core";
24249
24259
  import { relations as relations11 } from "drizzle-orm/relations";
24250
24260
  var formContacts = pgTable26(
@@ -24265,7 +24275,7 @@ var formContacts = pgTable26(
24265
24275
  },
24266
24276
  (t) => [
24267
24277
  // Dedup: one contact per email per workspace (also serves workspace lookups)
24268
- uniqueIndex9("form_contacts_workspace_email_uq").on(t.workspaceId, t.email),
24278
+ uniqueIndex10("form_contacts_workspace_email_uq").on(t.workspaceId, t.email),
24269
24279
  // Listing newest-first
24270
24280
  index24("form_contacts_workspace_seen_idx").on(t.workspaceId, t.lastSeenAt)
24271
24281
  ]
@@ -24521,7 +24531,7 @@ var auditLogs = pgTable31(
24521
24531
  );
24522
24532
 
24523
24533
  // src/schema/accounts.ts
24524
- import { pgTable as pgTable32, text as text33, timestamp as timestamp31, uniqueIndex as uniqueIndex10 } from "drizzle-orm/pg-core";
24534
+ import { pgTable as pgTable32, text as text33, timestamp as timestamp31, uniqueIndex as uniqueIndex11 } from "drizzle-orm/pg-core";
24525
24535
  var accounts = pgTable32(
24526
24536
  "accounts",
24527
24537
  {
@@ -24542,7 +24552,7 @@ var accounts = pgTable32(
24542
24552
  updatedAt: timestamp31("updated_at").notNull().defaultNow()
24543
24553
  },
24544
24554
  (table) => [
24545
- uniqueIndex10("accounts_user_id_provider_idx").on(table.userId, table.providerId)
24555
+ uniqueIndex11("accounts_user_id_provider_idx").on(table.userId, table.providerId)
24546
24556
  ]
24547
24557
  );
24548
24558
 
@@ -24579,7 +24589,7 @@ import {
24579
24589
  boolean as boolean15,
24580
24590
  timestamp as timestamp33,
24581
24591
  index as index31,
24582
- uniqueIndex as uniqueIndex11
24592
+ uniqueIndex as uniqueIndex12
24583
24593
  } from "drizzle-orm/pg-core";
24584
24594
  var pendingInvites = pgTable34(
24585
24595
  "pending_invites",
@@ -24611,7 +24621,7 @@ var pendingInvites = pgTable34(
24611
24621
  // Fast lookup by workspace (list pending invites)
24612
24622
  index31("pending_invites_workspace_idx").on(table.workspaceId),
24613
24623
  // Unique token for magic-link lookup
24614
- uniqueIndex11("pending_invites_token_idx").on(table.token),
24624
+ uniqueIndex12("pending_invites_token_idx").on(table.token),
24615
24625
  // Expiry cleanup queries
24616
24626
  index31("pending_invites_expires_idx").on(table.expiresAt)
24617
24627
  ]
@@ -24653,7 +24663,7 @@ var twoFactor = pgTable36(
24653
24663
  );
24654
24664
 
24655
24665
  // src/schema/passkeys.ts
24656
- import { pgTable as pgTable37, text as text38, boolean as boolean17, integer as integer18, timestamp as timestamp35, index as index34, uniqueIndex as uniqueIndex12 } from "drizzle-orm/pg-core";
24666
+ import { pgTable as pgTable37, text as text38, boolean as boolean17, integer as integer18, timestamp as timestamp35, index as index34, uniqueIndex as uniqueIndex13 } from "drizzle-orm/pg-core";
24657
24667
  var passkeys = pgTable37(
24658
24668
  "passkey",
24659
24669
  {
@@ -24678,13 +24688,13 @@ var passkeys = pgTable37(
24678
24688
  // what the database actually enforces. A plain index here plus a unique
24679
24689
  // constraint in the migration is exactly the drift that makes a later
24680
24690
  // `db:generate` propose dropping the constraint.
24681
- uniqueIndex12("passkey_credential_id_key").on(table.credentialID)
24691
+ uniqueIndex13("passkey_credential_id_key").on(table.credentialID)
24682
24692
  ]
24683
24693
  );
24684
24694
 
24685
24695
  // src/schema/sso.ts
24686
- import { pgTable as pgTable38, text as text39, boolean as boolean18, timestamp as timestamp36, index as index35, uniqueIndex as uniqueIndex13 } from "drizzle-orm/pg-core";
24687
- import { sql as sql7 } from "drizzle-orm";
24696
+ import { pgTable as pgTable38, text as text39, boolean as boolean18, timestamp as timestamp36, index as index35, uniqueIndex as uniqueIndex14 } from "drizzle-orm/pg-core";
24697
+ import { sql as sql8 } from "drizzle-orm";
24688
24698
  var ssoProviders = pgTable38(
24689
24699
  "sso_provider",
24690
24700
  {
@@ -24706,7 +24716,7 @@ var ssoProviders = pgTable38(
24706
24716
  // UNIQUE because the plugin declares `providerId` unique and generates the provider's
24707
24717
  // redirect URL from it. A plain index here plus a unique constraint in the migration is
24708
24718
  // exactly the drift that makes a later `db:generate` propose dropping the constraint.
24709
- uniqueIndex13("sso_provider_provider_id_key").on(table.providerId),
24719
+ uniqueIndex14("sso_provider_provider_id_key").on(table.providerId),
24710
24720
  // Sign-in resolves a provider by the email's domain, on every SSO login.
24711
24721
  index35("sso_provider_domain_idx").on(table.domain),
24712
24722
  // 🔴 GLOBAL, not partial on domain_verified. Sign-in resolves with
@@ -24714,10 +24724,10 @@ var ssoProviders = pgTable38(
24714
24724
  // an unverified row can be the one lookup returns — a partial index would let any
24715
24725
  // workspace shadow another tenant's verified domain and break their live logins.
24716
24726
  // The cost is squatting, which fails closed at onboarding instead of breaking working auth.
24717
- uniqueIndex13("sso_provider_domain_key").on(table.domain),
24727
+ uniqueIndex14("sso_provider_domain_key").on(table.domain),
24718
24728
  // One provider per workspace, enforced by the database — two concurrent PUTs would
24719
24729
  // otherwise both see "none", both register, and both bind.
24720
- uniqueIndex13("sso_provider_organization_key").on(table.organizationId).where(sql7`"organization_id" IS NOT NULL`),
24730
+ uniqueIndex14("sso_provider_organization_key").on(table.organizationId).where(sql8`"organization_id" IS NOT NULL`),
24721
24731
  // The gated wrapper lists and scopes by workspace on every read.
24722
24732
  index35("sso_provider_organization_idx").on(table.organizationId)
24723
24733
  ]
@@ -24813,7 +24823,7 @@ import {
24813
24823
  jsonb as jsonb23,
24814
24824
  timestamp as timestamp39,
24815
24825
  index as index38,
24816
- uniqueIndex as uniqueIndex14
24826
+ uniqueIndex as uniqueIndex15
24817
24827
  } from "drizzle-orm/pg-core";
24818
24828
  var collectionGrants = pgTable41(
24819
24829
  "collection_grants",
@@ -24832,7 +24842,7 @@ var collectionGrants = pgTable41(
24832
24842
  },
24833
24843
  (table) => [
24834
24844
  // One grant row per user per collection per workspace.
24835
- uniqueIndex14("collection_grants_ws_user_model_idx").on(
24845
+ uniqueIndex15("collection_grants_ws_user_model_idx").on(
24836
24846
  table.workspaceId,
24837
24847
  table.userId,
24838
24848
  table.contentModelId
@@ -24850,7 +24860,7 @@ import {
24850
24860
  boolean as boolean20,
24851
24861
  timestamp as timestamp40,
24852
24862
  index as index39,
24853
- uniqueIndex as uniqueIndex15
24863
+ uniqueIndex as uniqueIndex16
24854
24864
  } from "drizzle-orm/pg-core";
24855
24865
  var projectMembers = pgTable42(
24856
24866
  "project_members",
@@ -24879,7 +24889,7 @@ var projectMembers = pgTable42(
24879
24889
  },
24880
24890
  (table) => [
24881
24891
  // One role per user per project.
24882
- uniqueIndex15("project_members_project_user_idx").on(table.projectId, table.userId),
24892
+ uniqueIndex16("project_members_project_user_idx").on(table.projectId, table.userId),
24883
24893
  // Fast "members of this project" + "projects for this user" lookups.
24884
24894
  index39("project_members_project_idx").on(table.projectId),
24885
24895
  index39("project_members_user_idx").on(table.workspaceId, table.userId),
@@ -24896,10 +24906,10 @@ import {
24896
24906
  pgTable as pgTable43,
24897
24907
  text as text44,
24898
24908
  timestamp as timestamp41,
24899
- uniqueIndex as uniqueIndex16,
24909
+ uniqueIndex as uniqueIndex17,
24900
24910
  varchar as varchar27
24901
24911
  } from "drizzle-orm/pg-core";
24902
- import { sql as sql8 } from "drizzle-orm";
24912
+ import { sql as sql9 } from "drizzle-orm";
24903
24913
  var SUGGESTION_KINDS = ["chat", "pass", "link"];
24904
24914
  var projectSuggestions = pgTable43(
24905
24915
  "project_suggestions",
@@ -24932,12 +24942,12 @@ var projectSuggestions = pgTable43(
24932
24942
  (table) => [
24933
24943
  // One live suggestion per rule per project. Partial, so dismissing does not bar the rule
24934
24944
  // from firing again later.
24935
- uniqueIndex16("project_suggestions_live_uidx").on(table.projectId, table.ruleId).where(sql8`${table.dismissedAt} IS NULL`),
24945
+ uniqueIndex17("project_suggestions_live_uidx").on(table.projectId, table.ruleId).where(sql9`${table.dismissedAt} IS NULL`),
24936
24946
  // The read path: active suggestions for one project, best first.
24937
- index40("project_suggestions_project_rank_idx").on(table.projectId, table.rank).where(sql8`${table.dismissedAt} IS NULL`),
24947
+ index40("project_suggestions_project_rank_idx").on(table.projectId, table.rank).where(sql9`${table.dismissedAt} IS NULL`),
24938
24948
  check(
24939
24949
  "project_suggestions_kind_check",
24940
- sql8`${table.kind} IN ('chat','pass','link')`
24950
+ sql9`${table.kind} IN ('chat','pass','link')`
24941
24951
  )
24942
24952
  ]
24943
24953
  );
@@ -24951,7 +24961,7 @@ import {
24951
24961
  integer as integer20,
24952
24962
  boolean as boolean21,
24953
24963
  index as index41,
24954
- uniqueIndex as uniqueIndex17
24964
+ uniqueIndex as uniqueIndex18
24955
24965
  } from "drizzle-orm/pg-core";
24956
24966
  var deviceAuthorizations = pgTable44(
24957
24967
  "device_authorizations",
@@ -25026,8 +25036,8 @@ var deviceAuthorizations = pgTable44(
25026
25036
  createdAt: timestamp42("created_at").notNull().defaultNow()
25027
25037
  },
25028
25038
  (table) => [
25029
- uniqueIndex17("device_authorizations_device_code_hash_idx").on(table.deviceCodeHash),
25030
- uniqueIndex17("device_authorizations_user_code_idx").on(table.userCode),
25039
+ uniqueIndex18("device_authorizations_device_code_hash_idx").on(table.deviceCodeHash),
25040
+ uniqueIndex18("device_authorizations_user_code_idx").on(table.userCode),
25031
25041
  index41("device_authorizations_refresh_token_hash_idx").on(table.refreshTokenHash),
25032
25042
  index41("device_authorizations_prev_refresh_token_hash_idx").on(table.previousRefreshTokenHash),
25033
25043
  index41("device_authorizations_workspace_idx").on(table.workspaceId)
@@ -25261,7 +25271,7 @@ var githubInstallations = pgTable49("github_installations", {
25261
25271
  });
25262
25272
 
25263
25273
  // src/schema/custom_domains.ts
25264
- import { pgTable as pgTable50, text as text51, varchar as varchar34, boolean as boolean23, timestamp as timestamp46, index as index44, uniqueIndex as uniqueIndex18, jsonb as jsonb26 } from "drizzle-orm/pg-core";
25274
+ import { pgTable as pgTable50, text as text51, varchar as varchar34, boolean as boolean23, timestamp as timestamp46, index as index44, uniqueIndex as uniqueIndex19, jsonb as jsonb26 } from "drizzle-orm/pg-core";
25265
25275
  var customDomains = pgTable50(
25266
25276
  "custom_domains",
25267
25277
  {
@@ -25303,7 +25313,7 @@ var customDomains = pgTable50(
25303
25313
  ...auditColumns
25304
25314
  },
25305
25315
  (t) => [
25306
- uniqueIndex18("custom_domains_hostname_unique").on(t.hostname),
25316
+ uniqueIndex19("custom_domains_hostname_unique").on(t.hostname),
25307
25317
  index44("custom_domains_project_idx").on(t.projectId),
25308
25318
  // Mirrors the partial unique index from 0237. Drizzle cannot express the WHERE clause
25309
25319
  // here, so the DB is the source of truth for the constraint; this is the read hint.
@@ -25312,8 +25322,8 @@ var customDomains = pgTable50(
25312
25322
  );
25313
25323
 
25314
25324
  // src/schema/storage_configs.ts
25315
- import { pgTable as pgTable51, text as text52, varchar as varchar35, boolean as boolean24, timestamp as timestamp47, uniqueIndex as uniqueIndex19, index as index45 } from "drizzle-orm/pg-core";
25316
- import { sql as sql9 } from "drizzle-orm";
25325
+ import { pgTable as pgTable51, text as text52, varchar as varchar35, boolean as boolean24, timestamp as timestamp47, uniqueIndex as uniqueIndex20, index as index45 } from "drizzle-orm/pg-core";
25326
+ import { sql as sql10 } from "drizzle-orm";
25317
25327
  var storageConfigs = pgTable51(
25318
25328
  "storage_configs",
25319
25329
  {
@@ -25349,7 +25359,7 @@ var storageConfigs = pgTable51(
25349
25359
  index45("storage_configs_project_idx").on(t.projectId),
25350
25360
  index45("storage_configs_workspace_idx").on(t.workspaceId),
25351
25361
  // At most one active config per project.
25352
- uniqueIndex19("storage_configs_active_project_unique").on(t.projectId).where(sql9`deleted_at IS NULL`)
25362
+ uniqueIndex20("storage_configs_active_project_unique").on(t.projectId).where(sql10`deleted_at IS NULL`)
25353
25363
  ]
25354
25364
  );
25355
25365
 
@@ -25497,8 +25507,8 @@ var publishDeliveries = pgTable53(
25497
25507
  );
25498
25508
 
25499
25509
  // src/schema/hosting_connections.ts
25500
- import { pgTable as pgTable54, text as text55, varchar as varchar38, timestamp as timestamp50, index as index48, uniqueIndex as uniqueIndex20 } from "drizzle-orm/pg-core";
25501
- import { sql as sql10 } from "drizzle-orm";
25510
+ import { pgTable as pgTable54, text as text55, varchar as varchar38, timestamp as timestamp50, index as index48, uniqueIndex as uniqueIndex21 } from "drizzle-orm/pg-core";
25511
+ import { sql as sql11 } from "drizzle-orm";
25502
25512
  var hostingConnections = pgTable54(
25503
25513
  "hosting_connections",
25504
25514
  {
@@ -25536,13 +25546,13 @@ var hostingConnections = pgTable54(
25536
25546
  (t) => [
25537
25547
  index48("hosting_connections_workspace_idx").on(t.workspaceId),
25538
25548
  // Reconnecting the same account UPDATEs rather than accumulating a second live credential.
25539
- uniqueIndex20("hosting_connections_account_unique").on(t.workspaceId, t.provider, t.accountId).where(sql10`deleted_at IS NULL`)
25549
+ uniqueIndex21("hosting_connections_account_unique").on(t.workspaceId, t.provider, t.accountId).where(sql11`deleted_at IS NULL`)
25540
25550
  ]
25541
25551
  );
25542
25552
 
25543
25553
  // src/schema/external_deployments.ts
25544
- import { pgTable as pgTable55, text as text56, varchar as varchar39, integer as integer23, timestamp as timestamp51, index as index49, uniqueIndex as uniqueIndex21 } from "drizzle-orm/pg-core";
25545
- import { sql as sql11 } from "drizzle-orm";
25554
+ import { pgTable as pgTable55, text as text56, varchar as varchar39, integer as integer23, timestamp as timestamp51, index as index49, uniqueIndex as uniqueIndex22 } from "drizzle-orm/pg-core";
25555
+ import { sql as sql12 } from "drizzle-orm";
25546
25556
  var externalDeployments = pgTable55(
25547
25557
  "external_deployments",
25548
25558
  {
@@ -25578,7 +25588,7 @@ var externalDeployments = pgTable55(
25578
25588
  updatedAt: timestamp51("updated_at").notNull().defaultNow()
25579
25589
  },
25580
25590
  (t) => [
25581
- index49("external_deployments_claim_idx").on(t.state, t.createdAt).where(sql11`state IN ('queued', 'deploying')`),
25591
+ index49("external_deployments_claim_idx").on(t.state, t.createdAt).where(sql12`state IN ('queued', 'deploying')`),
25582
25592
  index49("external_deployments_workspace_idx").on(t.workspaceId),
25583
25593
  index49("external_deployments_project_idx").on(t.projectId, t.createdAt.desc()),
25584
25594
  /**
@@ -25588,12 +25598,12 @@ var externalDeployments = pgTable55(
25588
25598
  * Git-mode rows have sha NULL and are therefore NOT covered — NULLs never conflict — which is
25589
25599
  * correct: a git deploy carries no artifact identity, so two publishes are two real builds.
25590
25600
  */
25591
- uniqueIndex21("external_deployments_inflight_unique").on(t.targetId, t.sha).where(sql11`state IN ('queued', 'deploying')`)
25601
+ uniqueIndex22("external_deployments_inflight_unique").on(t.targetId, t.sha).where(sql12`state IN ('queued', 'deploying')`)
25592
25602
  ]
25593
25603
  );
25594
25604
 
25595
25605
  // src/schema/page_types.ts
25596
- import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as jsonb27, index as index50, uniqueIndex as uniqueIndex22 } from "drizzle-orm/pg-core";
25606
+ import { pgTable as pgTable56, text as text57, varchar as varchar40, jsonb as jsonb27, index as index50, uniqueIndex as uniqueIndex23 } from "drizzle-orm/pg-core";
25597
25607
  var pageTypes = pgTable56(
25598
25608
  "page_types",
25599
25609
  {
@@ -25613,12 +25623,12 @@ var pageTypes = pgTable56(
25613
25623
  (t) => [
25614
25624
  index50("page_types_project_idx").on(t.projectId),
25615
25625
  index50("page_types_workspace_idx").on(t.workspaceId),
25616
- uniqueIndex22("page_types_project_slug_unique").on(t.projectId, t.branchId, t.slug)
25626
+ uniqueIndex23("page_types_project_slug_unique").on(t.projectId, t.branchId, t.slug)
25617
25627
  ]
25618
25628
  );
25619
25629
 
25620
25630
  // src/schema/build_triggers.ts
25621
- import { pgTable as pgTable57, text as text58, varchar as varchar41, boolean as boolean26, timestamp as timestamp53, integer as integer24, jsonb as jsonb28, index as index51, uniqueIndex as uniqueIndex23 } from "drizzle-orm/pg-core";
25631
+ import { pgTable as pgTable57, text as text58, varchar as varchar41, boolean as boolean26, timestamp as timestamp53, integer as integer24, jsonb as jsonb28, index as index51, uniqueIndex as uniqueIndex24 } from "drizzle-orm/pg-core";
25622
25632
  var BUILD_TRIGGER_KINDS = ["webhook", "content", "schedule"];
25623
25633
  var buildTriggers = pgTable57(
25624
25634
  "build_triggers",
@@ -25653,7 +25663,7 @@ var buildTriggers = pgTable57(
25653
25663
  (t) => [
25654
25664
  index51("build_triggers_project_idx").on(t.projectId),
25655
25665
  index51("build_triggers_workspace_idx").on(t.workspaceId),
25656
- uniqueIndex23("build_triggers_project_name_unique").on(t.projectId, t.name)
25666
+ uniqueIndex24("build_triggers_project_name_unique").on(t.projectId, t.name)
25657
25667
  ]
25658
25668
  );
25659
25669
  var buildTriggerRuns = pgTable57(
@@ -25716,7 +25726,7 @@ var generatedTypes = pgTable59("generated_types", {
25716
25726
  });
25717
25727
 
25718
25728
  // src/schema/agent_keys.ts
25719
- import { pgTable as pgTable60, text as text61, uniqueIndex as uniqueIndex24 } from "drizzle-orm/pg-core";
25729
+ import { pgTable as pgTable60, text as text61, uniqueIndex as uniqueIndex25 } from "drizzle-orm/pg-core";
25720
25730
  var agentKeys = pgTable60(
25721
25731
  "agent_keys",
25722
25732
  {
@@ -25728,11 +25738,11 @@ var agentKeys = pgTable60(
25728
25738
  // AES-256-GCM encrypted
25729
25739
  ...auditColumns
25730
25740
  },
25731
- (t) => [uniqueIndex24("agent_keys_workspace_unique").on(t.workspaceId)]
25741
+ (t) => [uniqueIndex25("agent_keys_workspace_unique").on(t.workspaceId)]
25732
25742
  );
25733
25743
 
25734
25744
  // src/schema/ai_provider_keys.ts
25735
- import { pgTable as pgTable61, text as text62, varchar as varchar44, uniqueIndex as uniqueIndex25 } from "drizzle-orm/pg-core";
25745
+ import { pgTable as pgTable61, text as text62, varchar as varchar44, uniqueIndex as uniqueIndex26 } from "drizzle-orm/pg-core";
25736
25746
  var aiProviderKeys = pgTable61(
25737
25747
  "ai_provider_keys",
25738
25748
  {
@@ -25746,7 +25756,7 @@ var aiProviderKeys = pgTable61(
25746
25756
  keyHint: varchar44("key_hint", { length: 8 }).notNull(),
25747
25757
  ...auditColumns
25748
25758
  },
25749
- (t) => [uniqueIndex25("ai_provider_keys_workspace_provider_key").on(t.workspaceId, t.provider)]
25759
+ (t) => [uniqueIndex26("ai_provider_keys_workspace_provider_key").on(t.workspaceId, t.provider)]
25750
25760
  );
25751
25761
 
25752
25762
  // src/schema/agent_sessions.ts
@@ -25800,7 +25810,7 @@ var agentMessages = pgTable62(
25800
25810
 
25801
25811
  // src/schema/agent_instructions.ts
25802
25812
  import { pgTable as pgTable63, text as text64, varchar as varchar46, boolean as boolean27, jsonb as jsonb30, timestamp as timestamp57, index as index53, check as check2 } from "drizzle-orm/pg-core";
25803
- import { sql as sql12 } from "drizzle-orm";
25813
+ import { sql as sql13 } from "drizzle-orm";
25804
25814
  var INSTRUCTION_KINDS = ["skill", "rule"];
25805
25815
  var INSTRUCTION_SOURCES = ["template", "manual", "import"];
25806
25816
  var INSTRUCTION_BODY_MAX = 8e3;
@@ -25835,9 +25845,9 @@ var agentInstructions = pgTable63(
25835
25845
  // creates the table from THIS file, after which 0167's `CREATE TABLE IF NOT EXISTS` no-ops —
25836
25846
  // so the CHECKs defined only in the SQL would never exist in a dev database. Names match 0167
25837
25847
  // exactly; a mismatch would have push and setup-db each try to own the constraint.
25838
- check2("agent_instructions_kind_check", sql12`${table.kind} IN ('skill', 'rule')`),
25839
- check2("agent_instructions_source_check", sql12`${table.source} IN ('template', 'manual', 'import')`),
25840
- check2("agent_instructions_body_len_check", sql12`char_length(${table.body}) <= 8000`)
25848
+ check2("agent_instructions_kind_check", sql13`${table.kind} IN ('skill', 'rule')`),
25849
+ check2("agent_instructions_source_check", sql13`${table.source} IN ('template', 'manual', 'import')`),
25850
+ check2("agent_instructions_body_len_check", sql13`char_length(${table.body}) <= 8000`)
25841
25851
  ]
25842
25852
  );
25843
25853
 
@@ -25851,10 +25861,10 @@ import {
25851
25861
  pgTable as pgTable64,
25852
25862
  text as text65,
25853
25863
  timestamp as timestamp58,
25854
- uniqueIndex as uniqueIndex26,
25864
+ uniqueIndex as uniqueIndex27,
25855
25865
  varchar as varchar47
25856
25866
  } from "drizzle-orm/pg-core";
25857
- import { sql as sql13 } from "drizzle-orm";
25867
+ import { sql as sql14 } from "drizzle-orm";
25858
25868
  var CUSTOM_AGENT_INSTRUCTIONS_MAX = 8e3;
25859
25869
  var CUSTOM_AGENT_CAPABILITIES = [
25860
25870
  "content-read",
@@ -25881,11 +25891,11 @@ var customAgents = pgTable64(
25881
25891
  archivedAt: timestamp58("archived_at", { withTimezone: true })
25882
25892
  },
25883
25893
  (table) => [
25884
- uniqueIndex26("custom_agents_workspace_slug_unique").on(table.workspaceId, table.slug),
25894
+ uniqueIndex27("custom_agents_workspace_slug_unique").on(table.workspaceId, table.slug),
25885
25895
  index54("custom_agents_workspace_status_idx").on(table.workspaceId, table.status, table.updatedAt),
25886
25896
  index54("custom_agents_project_status_idx").on(table.projectId, table.status, table.updatedAt),
25887
- check3("custom_agents_status_check", sql13`${table.status} IN ('active', 'archived')`),
25888
- check3("custom_agents_version_check", sql13`${table.optimisticVersion} > 0`)
25897
+ check3("custom_agents_status_check", sql14`${table.status} IN ('active', 'archived')`),
25898
+ check3("custom_agents_version_check", sql14`${table.optimisticVersion} > 0`)
25889
25899
  ]
25890
25900
  );
25891
25901
  var customAgentRevisions = pgTable64(
@@ -25905,16 +25915,16 @@ var customAgentRevisions = pgTable64(
25905
25915
  createdAt: timestamp58("created_at", { withTimezone: true }).notNull().defaultNow()
25906
25916
  },
25907
25917
  (table) => [
25908
- uniqueIndex26("custom_agent_revisions_agent_version_unique").on(table.agentId, table.version),
25918
+ uniqueIndex27("custom_agent_revisions_agent_version_unique").on(table.agentId, table.version),
25909
25919
  index54("custom_agent_revisions_workspace_agent_idx").on(table.workspaceId, table.agentId),
25910
- check3("custom_agent_revisions_version_check", sql13`${table.version} > 0`),
25911
- check3("custom_agent_revisions_speed_check", sql13`${table.speed} IN ('lite', 'balanced', 'max')`),
25912
- check3("custom_agent_revisions_review_check", sql13`${table.reviewPolicy} = 'draft_only'`),
25920
+ check3("custom_agent_revisions_version_check", sql14`${table.version} > 0`),
25921
+ check3("custom_agent_revisions_speed_check", sql14`${table.speed} IN ('lite', 'balanced', 'max')`),
25922
+ check3("custom_agent_revisions_review_check", sql14`${table.reviewPolicy} = 'draft_only'`),
25913
25923
  check3(
25914
25924
  "custom_agent_revisions_instructions_len_check",
25915
- sql13`char_length(${table.instructions}) BETWEEN 1 AND 8000`
25925
+ sql14`char_length(${table.instructions}) BETWEEN 1 AND 8000`
25916
25926
  ),
25917
- check3("custom_agent_revisions_capabilities_array_check", sql13`jsonb_typeof(${table.capabilities}) = 'array'`)
25927
+ check3("custom_agent_revisions_capabilities_array_check", sql14`jsonb_typeof(${table.capabilities}) = 'array'`)
25918
25928
  ]
25919
25929
  );
25920
25930
  var customAgentRuns = pgTable64(
@@ -25944,17 +25954,17 @@ var customAgentRuns = pgTable64(
25944
25954
  updatedAt: timestamp58("updated_at", { withTimezone: true }).notNull().defaultNow()
25945
25955
  },
25946
25956
  (table) => [
25947
- uniqueIndex26("custom_agent_runs_agent_idempotency_unique").on(table.agentId, table.idempotencyKey),
25957
+ uniqueIndex27("custom_agent_runs_agent_idempotency_unique").on(table.agentId, table.idempotencyKey),
25948
25958
  index54("custom_agent_runs_agent_created_idx").on(table.agentId, table.createdAt),
25949
25959
  index54("custom_agent_runs_workspace_status_idx").on(table.workspaceId, table.status, table.createdAt),
25950
25960
  index54("custom_agent_runs_project_status_idx").on(table.projectId, table.status, table.createdAt),
25951
- check3("custom_agent_runs_trigger_check", sql13`${table.trigger} = 'manual'`),
25952
- check3("custom_agent_runs_speed_check", sql13`${table.effectiveSpeed} IN ('lite', 'balanced', 'max')`),
25961
+ check3("custom_agent_runs_trigger_check", sql14`${table.trigger} = 'manual'`),
25962
+ check3("custom_agent_runs_speed_check", sql14`${table.effectiveSpeed} IN ('lite', 'balanced', 'max')`),
25953
25963
  check3(
25954
25964
  "custom_agent_runs_status_check",
25955
- sql13`${table.status} IN ('queued', 'running', 'stopping', 'completed', 'failed', 'stopped')`
25965
+ sql14`${table.status} IN ('queued', 'running', 'stopping', 'completed', 'failed', 'stopped')`
25956
25966
  ),
25957
- check3("custom_agent_runs_credits_check", sql13`${table.creditsQuoted} >= 0 AND ${table.creditsCharged} >= 0`)
25967
+ check3("custom_agent_runs_credits_check", sql14`${table.creditsQuoted} >= 0 AND ${table.creditsCharged} >= 0`)
25958
25968
  ]
25959
25969
  );
25960
25970
 
@@ -26096,8 +26106,8 @@ var abmShareTokens = pgTable68(
26096
26106
  );
26097
26107
 
26098
26108
  // src/schema/mcp_tasks.ts
26099
- import { check as check4, index as index58, integer as integer30, jsonb as jsonb34, pgTable as pgTable69, text as text70, timestamp as timestamp63, uniqueIndex as uniqueIndex27, varchar as varchar51 } from "drizzle-orm/pg-core";
26100
- import { sql as sql14 } from "drizzle-orm";
26109
+ import { check as check4, index as index58, integer as integer30, jsonb as jsonb34, pgTable as pgTable69, text as text70, timestamp as timestamp63, uniqueIndex as uniqueIndex28, varchar as varchar51 } from "drizzle-orm/pg-core";
26110
+ import { sql as sql15 } from "drizzle-orm";
26101
26111
  var MCP_TASK_STATUSES = [
26102
26112
  "working",
26103
26113
  "input_required",
@@ -26127,7 +26137,7 @@ var mcpTasks = pgTable69(
26127
26137
  updatedAt: timestamp63("updated_at").notNull().defaultNow()
26128
26138
  },
26129
26139
  (table) => [
26130
- uniqueIndex27("mcp_tasks_ai_job_uidx").on(table.aiJobId).where(sql14`${table.aiJobId} IS NOT NULL`),
26140
+ uniqueIndex28("mcp_tasks_ai_job_uidx").on(table.aiJobId).where(sql15`${table.aiJobId} IS NOT NULL`),
26131
26141
  index58("mcp_tasks_principal_idx").on(
26132
26142
  table.workspaceId,
26133
26143
  table.projectId,
@@ -26136,14 +26146,14 @@ var mcpTasks = pgTable69(
26136
26146
  table.createdAt
26137
26147
  ),
26138
26148
  index58("mcp_tasks_status_idx").on(table.workspaceId, table.status, table.updatedAt),
26139
- check4("mcp_tasks_status_check", sql14`${table.status} IN ('working','input_required','completed','failed','cancelled')`),
26140
- check4("mcp_tasks_principal_kind_check", sql14`${table.principalKind} IN ('api_key','device')`),
26141
- check4("mcp_tasks_ai_job_handle_check", sql14`${table.aiJobId} IS NULL OR ${table.aiJobId} = ${table.id}`),
26142
- check4("mcp_tasks_terminal_shape_check", sql14`
26149
+ check4("mcp_tasks_status_check", sql15`${table.status} IN ('working','input_required','completed','failed','cancelled')`),
26150
+ check4("mcp_tasks_principal_kind_check", sql15`${table.principalKind} IN ('api_key','device')`),
26151
+ check4("mcp_tasks_ai_job_handle_check", sql15`${table.aiJobId} IS NULL OR ${table.aiJobId} = ${table.id}`),
26152
+ check4("mcp_tasks_terminal_shape_check", sql15`
26143
26153
  (${table.status} IN ('completed','failed','cancelled') AND ${table.terminalAt} IS NOT NULL AND ${table.finalResult} IS NOT NULL)
26144
26154
  OR (${table.status} IN ('working','input_required') AND ${table.terminalAt} IS NULL AND ${table.finalResult} IS NULL)
26145
26155
  `),
26146
- check4("mcp_tasks_terminal_payload_check", sql14`
26156
+ check4("mcp_tasks_terminal_payload_check", sql15`
26147
26157
  (${table.status} IN ('completed','cancelled')
26148
26158
  AND ${table.finalResult}->>'resultType' = 'complete'
26149
26159
  AND jsonb_typeof(${table.finalResult}->'content') = 'array')
@@ -26152,13 +26162,13 @@ var mcpTasks = pgTable69(
26152
26162
  AND jsonb_typeof(${table.finalResult}->'message') = 'string')
26153
26163
  OR (${table.status} IN ('working','input_required') AND ${table.finalResult} IS NULL)
26154
26164
  `),
26155
- check4("mcp_tasks_ttl_check", sql14`${table.ttlMs} IS NULL OR ${table.ttlMs} > 0`),
26156
- check4("mcp_tasks_poll_interval_check", sql14`${table.pollIntervalMs} > 0`)
26165
+ check4("mcp_tasks_ttl_check", sql15`${table.ttlMs} IS NULL OR ${table.ttlMs} > 0`),
26166
+ check4("mcp_tasks_poll_interval_check", sql15`${table.pollIntervalMs} > 0`)
26157
26167
  ]
26158
26168
  );
26159
26169
 
26160
26170
  // src/schema/seo_reports.ts
26161
- import { pgTable as pgTable70, text as text71, date, jsonb as jsonb35, timestamp as timestamp64, uniqueIndex as uniqueIndex28, index as index59 } from "drizzle-orm/pg-core";
26171
+ import { pgTable as pgTable70, text as text71, date, jsonb as jsonb35, timestamp as timestamp64, uniqueIndex as uniqueIndex29, index as index59 } from "drizzle-orm/pg-core";
26162
26172
  var seoReports = pgTable70(
26163
26173
  "seo_reports",
26164
26174
  {
@@ -26174,7 +26184,7 @@ var seoReports = pgTable70(
26174
26184
  },
26175
26185
  (t) => [
26176
26186
  // Idempotency guard: one report per period (matches the per-minute cron).
26177
- uniqueIndex28("seo_reports_project_period_idx").on(t.projectId, t.periodStart, t.periodEnd),
26187
+ uniqueIndex29("seo_reports_project_period_idx").on(t.projectId, t.periodStart, t.periodEnd),
26178
26188
  index59("seo_reports_project_created_idx").on(t.projectId, t.createdAt)
26179
26189
  ]
26180
26190
  );
@@ -26285,10 +26295,10 @@ import {
26285
26295
  bigint as bigint3,
26286
26296
  smallint,
26287
26297
  index as index64,
26288
- uniqueIndex as uniqueIndex29,
26298
+ uniqueIndex as uniqueIndex30,
26289
26299
  primaryKey as primaryKey4
26290
26300
  } from "drizzle-orm/pg-core";
26291
- import { sql as sql15 } from "drizzle-orm";
26301
+ import { sql as sql16 } from "drizzle-orm";
26292
26302
  var analyticsEventsRaw = pgTable75(
26293
26303
  "analytics_events_raw",
26294
26304
  {
@@ -26323,7 +26333,7 @@ var analyticsEventsRaw = pgTable75(
26323
26333
  index64("analytics_events_raw_project_ts_idx").on(t.projectId, t.ts),
26324
26334
  index64("analytics_events_raw_ts_idx").on(t.ts),
26325
26335
  // Partial, so the nginx path (event_id NULL) is unconstrained and unchanged.
26326
- uniqueIndex29("analytics_events_raw_event_id_uidx").on(t.eventId).where(sql15`${t.eventId} IS NOT NULL`)
26336
+ uniqueIndex30("analytics_events_raw_event_id_uidx").on(t.eventId).where(sql16`${t.eventId} IS NOT NULL`)
26327
26337
  ]
26328
26338
  );
26329
26339
  var analyticsDailyTotals = pgTable75(
@@ -26400,7 +26410,7 @@ var analyticsCursor = pgTable75("analytics_cursor", {
26400
26410
  });
26401
26411
 
26402
26412
  // src/schema/site_files.ts
26403
- import { pgTable as pgTable76, text as text77, varchar as varchar56, integer as integer34, timestamp as timestamp70, uniqueIndex as uniqueIndex30 } from "drizzle-orm/pg-core";
26413
+ import { pgTable as pgTable76, text as text77, varchar as varchar56, integer as integer34, timestamp as timestamp70, uniqueIndex as uniqueIndex31 } from "drizzle-orm/pg-core";
26404
26414
  var SITE_FILE_KINDS = ["llms.txt", "llms-full.txt"];
26405
26415
  var siteFiles = pgTable76(
26406
26416
  "site_files",
@@ -26418,7 +26428,7 @@ var siteFiles = pgTable76(
26418
26428
  createdAt: timestamp70("created_at").notNull().defaultNow(),
26419
26429
  updatedAt: timestamp70("updated_at").notNull().defaultNow()
26420
26430
  },
26421
- (t) => [uniqueIndex30("site_files_project_kind_idx").on(t.projectId, t.kind)]
26431
+ (t) => [uniqueIndex31("site_files_project_kind_idx").on(t.projectId, t.kind)]
26422
26432
  );
26423
26433
 
26424
26434
  // src/schema/indexnow_submissions.ts
@@ -26502,7 +26512,7 @@ var webhookDeliveries = pgTable79(
26502
26512
  );
26503
26513
 
26504
26514
  // src/schema/markdown_files.ts
26505
- import { pgTable as pgTable80, text as text81, varchar as varchar59, timestamp as timestamp74, uniqueIndex as uniqueIndex31 } from "drizzle-orm/pg-core";
26515
+ import { pgTable as pgTable80, text as text81, varchar as varchar59, timestamp as timestamp74, uniqueIndex as uniqueIndex32 } from "drizzle-orm/pg-core";
26506
26516
  var MARKDOWN_FILE_STATUSES = ["draft", "published"];
26507
26517
  var markdownFiles = pgTable80(
26508
26518
  "markdown_files",
@@ -26521,7 +26531,7 @@ var markdownFiles = pgTable80(
26521
26531
  createdAt: timestamp74("created_at").notNull().defaultNow(),
26522
26532
  updatedAt: timestamp74("updated_at").notNull().defaultNow()
26523
26533
  },
26524
- (t) => [uniqueIndex31("markdown_files_project_path_idx").on(t.projectId, t.path)]
26534
+ (t) => [uniqueIndex32("markdown_files_project_path_idx").on(t.projectId, t.path)]
26525
26535
  );
26526
26536
  var DEFAULT_AEO_CONFIG = {
26527
26537
  llmsTxtEnabled: true,
@@ -26539,10 +26549,10 @@ import {
26539
26549
  integer as integer39,
26540
26550
  foreignKey as foreignKey4,
26541
26551
  index as index70,
26542
- uniqueIndex as uniqueIndex34
26552
+ uniqueIndex as uniqueIndex35
26543
26553
  } from "drizzle-orm/pg-core";
26544
26554
  import { relations as relations14 } from "drizzle-orm/relations";
26545
- import { sql as sql18 } from "drizzle-orm";
26555
+ import { sql as sql19 } from "drizzle-orm";
26546
26556
 
26547
26557
  // src/schema/component_variant_groups.ts
26548
26558
  import {
@@ -26553,10 +26563,10 @@ import {
26553
26563
  pgTable as pgTable81,
26554
26564
  text as text82,
26555
26565
  timestamp as timestamp75,
26556
- uniqueIndex as uniqueIndex32,
26566
+ uniqueIndex as uniqueIndex33,
26557
26567
  varchar as varchar60
26558
26568
  } from "drizzle-orm/pg-core";
26559
- import { sql as sql16 } from "drizzle-orm";
26569
+ import { sql as sql17 } from "drizzle-orm";
26560
26570
  var componentVariantGroups = pgTable81(
26561
26571
  "component_variant_groups",
26562
26572
  {
@@ -26582,7 +26592,7 @@ var componentVariantGroups = pgTable81(
26582
26592
  }).onDelete("cascade"),
26583
26593
  index68("component_variant_groups_workspace_idx").on(table.workspaceId),
26584
26594
  index68("component_variant_groups_project_idx").on(table.projectId),
26585
- uniqueIndex32("component_variant_groups_scope_slug_unique").on(table.workspaceId, table.projectId, table.slug).where(sql16`${table.deletedAt} IS NULL`)
26595
+ uniqueIndex33("component_variant_groups_scope_slug_unique").on(table.workspaceId, table.projectId, table.slug).where(sql17`${table.deletedAt} IS NULL`)
26586
26596
  ]
26587
26597
  );
26588
26598
 
@@ -26592,10 +26602,10 @@ import {
26592
26602
  index as index69,
26593
26603
  pgTable as pgTable82,
26594
26604
  text as text83,
26595
- uniqueIndex as uniqueIndex33,
26605
+ uniqueIndex as uniqueIndex34,
26596
26606
  varchar as varchar61
26597
26607
  } from "drizzle-orm/pg-core";
26598
- import { sql as sql17 } from "drizzle-orm";
26608
+ import { sql as sql18 } from "drizzle-orm";
26599
26609
  var componentGroups = pgTable82(
26600
26610
  "component_groups",
26601
26611
  {
@@ -26616,7 +26626,7 @@ var componentGroups = pgTable82(
26616
26626
  }).onDelete("cascade"),
26617
26627
  index69("component_groups_workspace_idx").on(table.workspaceId),
26618
26628
  index69("component_groups_project_idx").on(table.projectId),
26619
- uniqueIndex33("component_groups_project_slug_unique").on(table.projectId, table.slug).where(sql17`${table.deletedAt} IS NULL`)
26629
+ uniqueIndex34("component_groups_project_slug_unique").on(table.projectId, table.slug).where(sql18`${table.deletedAt} IS NULL`)
26620
26630
  ]
26621
26631
  );
26622
26632
 
@@ -26698,7 +26708,7 @@ var components = pgTable83(
26698
26708
  * application code to set a value the trigger overwrites. Do not conflate the two.
26699
26709
  */
26700
26710
  managedBy: text84("managed_by").notNull().default("dashboard").$type(),
26701
- allowedOn: text84("allowed_on").array().notNull().default(sql18`ARRAY[]::text[]`),
26711
+ allowedOn: text84("allowed_on").array().notNull().default(sql19`ARRAY[]::text[]`),
26702
26712
  description: text84("description"),
26703
26713
  // Organisational ownership only. Nullable for legacy rows; every new Component authored
26704
26714
  // through the canonical Content surface must choose or explicitly create a Group.
@@ -26769,15 +26779,15 @@ var components = pgTable83(
26769
26779
  * src/lib/sections/registry.ts, which is handed every candidate and applies precedence
26770
26780
  * itself. DB uniqueness here is data hygiene, not verdict correctness.
26771
26781
  */
26772
- uniqueIndex34("components_ws_proj_slug_managed_idx").on(table.workspaceId, table.projectId, table.branchId, table.slug, table.managedBy).where(sql18`${table.deletedAt} IS NULL`),
26773
- index70("components_managed_by_idx").on(table.managedBy).where(sql18`${table.deletedAt} IS NULL`),
26782
+ uniqueIndex35("components_ws_proj_slug_managed_idx").on(table.workspaceId, table.projectId, table.branchId, table.slug, table.managedBy).where(sql19`${table.deletedAt} IS NULL`),
26783
+ index70("components_managed_by_idx").on(table.managedBy).where(sql19`${table.deletedAt} IS NULL`),
26774
26784
  // Partial: the section library only reads live sections. Mirrors migration 0156 —
26775
26785
  // keep the two in step, or `drizzle-kit push` will want to drop the index it can't see.
26776
- index70("components_section_type_idx").on(table.sectionType).where(sql18`${table.sectionType} IS NOT NULL AND ${table.deletedAt} IS NULL`),
26786
+ index70("components_section_type_idx").on(table.sectionType).where(sql19`${table.sectionType} IS NOT NULL AND ${table.deletedAt} IS NULL`),
26777
26787
  // Migration 0342. Deliberately NOT unique: one band can produce several components when its
26778
26788
  // shape differs between pages (`hero`, `hero-2`), so this is a lookup hint the planner uses
26779
26789
  // only when exactly one row carries the key — not a key.
26780
- index70("components_ws_proj_source_key_idx").on(table.workspaceId, table.projectId, table.branchId, table.sourceKey).where(sql18`${table.sourceKey} IS NOT NULL AND ${table.deletedAt} IS NULL`)
26790
+ index70("components_ws_proj_source_key_idx").on(table.workspaceId, table.projectId, table.branchId, table.sourceKey).where(sql19`${table.sourceKey} IS NOT NULL AND ${table.deletedAt} IS NULL`)
26781
26791
  ]
26782
26792
  );
26783
26793
  var componentsRelations = relations14(components, ({ one }) => ({
@@ -26828,10 +26838,10 @@ import {
26828
26838
  integer as integer41,
26829
26839
  index as index72,
26830
26840
  unique as unique4,
26831
- uniqueIndex as uniqueIndex35
26841
+ uniqueIndex as uniqueIndex36
26832
26842
  } from "drizzle-orm/pg-core";
26833
26843
  import { relations as relations15 } from "drizzle-orm/relations";
26834
- import { sql as sql19 } from "drizzle-orm";
26844
+ import { sql as sql20 } from "drizzle-orm";
26835
26845
  var componentVariants = pgTable85(
26836
26846
  "component_variants",
26837
26847
  {
@@ -26865,7 +26875,7 @@ var componentVariants = pgTable85(
26865
26875
  ),
26866
26876
  index72("component_variants_workspace_idx").on(table.workspaceId),
26867
26877
  index72("component_variants_component_idx").on(table.componentId),
26868
- uniqueIndex35("component_variants_component_key_unique").on(table.componentId, table.key).where(sql19`${table.deletedAt} IS NULL`)
26878
+ uniqueIndex36("component_variants_component_key_unique").on(table.componentId, table.key).where(sql20`${table.deletedAt} IS NULL`)
26869
26879
  ]
26870
26880
  );
26871
26881
  var componentVariantsRelations = relations15(componentVariants, ({ one }) => ({
@@ -26890,11 +26900,11 @@ import {
26890
26900
  text as text87,
26891
26901
  timestamp as timestamp79,
26892
26902
  unique as unique5,
26893
- uniqueIndex as uniqueIndex36,
26903
+ uniqueIndex as uniqueIndex37,
26894
26904
  uuid as uuid2,
26895
26905
  varchar as varchar64
26896
26906
  } from "drizzle-orm/pg-core";
26897
- import { sql as sql20 } from "drizzle-orm";
26907
+ import { sql as sql21 } from "drizzle-orm";
26898
26908
  var componentImplementationCandidates = pgTable86(
26899
26909
  "component_implementation_candidates",
26900
26910
  {
@@ -26924,13 +26934,13 @@ var componentImplementationCandidates = pgTable86(
26924
26934
  // v1 candidates (created before 0263) have no exact family-contract bytes. They must not
26925
26935
  // occupy the v2 tuple: validation needs to append an exact candidate beside the legacy
26926
26936
  // row instead of either mutating it or selecting it by matching hashes alone.
26927
- uniqueIndex36("component_implementation_candidate_exact_tuple_unique").on(
26937
+ uniqueIndex37("component_implementation_candidate_exact_tuple_unique").on(
26928
26938
  table.projectId,
26929
26939
  table.componentId,
26930
26940
  table.schemaHash,
26931
26941
  table.brandContractHash,
26932
26942
  table.familyContractHash
26933
- ).where(sql20`${table.familyContract} IS NOT NULL`),
26943
+ ).where(sql21`${table.familyContract} IS NOT NULL`),
26934
26944
  unique5("component_implementation_candidate_scope_unique").on(table.id, table.projectId, table.componentId),
26935
26945
  index73("component_implementation_candidates_component_idx").on(table.projectId, table.componentId)
26936
26946
  ]
@@ -26962,7 +26972,7 @@ var componentFamilyManifests = pgTable86(
26962
26972
  unique5("component_family_manifests_scope_unique").on(table.id, table.projectId, table.familyKey),
26963
26973
  unique5("component_family_manifests_id_project_unique").on(table.id, table.projectId),
26964
26974
  unique5("component_family_manifests_evidence_unique").on(table.id, table.projectId, table.manifestHash),
26965
- uniqueIndex36("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
26975
+ uniqueIndex37("component_family_manifest_tuple_unique").on(table.projectId, table.familyKey, table.manifestHash),
26966
26976
  index73("component_family_manifests_family_idx").on(table.projectId, table.familyKey, table.createdAt)
26967
26977
  ]
26968
26978
  );
@@ -27017,7 +27027,7 @@ var componentImplementationRequests = pgTable86(
27017
27027
  name: "component_implementation_requests_candidate_fkey"
27018
27028
  }).onDelete("cascade"),
27019
27029
  unique5("component_implementation_requests_scope_unique").on(table.id, table.projectId, table.componentId),
27020
- uniqueIndex36("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql20`${table.status} IN ('pending', 'claimed')`),
27030
+ uniqueIndex37("component_implementation_requests_active_unique").on(table.projectId, table.componentId).where(sql21`${table.status} IN ('pending', 'claimed')`),
27021
27031
  index73("component_implementation_requests_claimable_idx").on(table.projectId, table.status, table.expiresAt, table.createdAt)
27022
27032
  ]
27023
27033
  );
@@ -27069,8 +27079,8 @@ var componentImplementationEvidence = pgTable86(
27069
27079
  foreignColumns: [componentImplementationRequests.id, componentImplementationRequests.projectId, componentImplementationRequests.componentId],
27070
27080
  name: "component_implementation_evidence_request_fkey"
27071
27081
  }).onDelete("restrict"),
27072
- uniqueIndex36("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
27073
- uniqueIndex36("component_implementation_evidence_request_unique").on(table.requestId).where(sql20`${table.requestId} IS NOT NULL`),
27082
+ uniqueIndex37("component_implementation_evidence_digest_unique").on(table.projectId, table.componentId, table.evidenceDigest),
27083
+ uniqueIndex37("component_implementation_evidence_request_unique").on(table.requestId).where(sql21`${table.requestId} IS NOT NULL`),
27074
27084
  unique5("component_implementation_evidence_scope_unique").on(table.id, table.projectId, table.componentId),
27075
27085
  index73("component_implementation_evidence_candidate_idx").on(table.candidateId, table.createdAt)
27076
27086
  ]
@@ -27103,7 +27113,7 @@ var componentImplementationApprovals = pgTable86(
27103
27113
  foreignColumns: [componentImplementationEvidence.id, componentImplementationEvidence.projectId, componentImplementationEvidence.componentId],
27104
27114
  name: "component_implementation_approvals_evidence_fkey"
27105
27115
  }).onDelete("cascade"),
27106
- uniqueIndex36("component_implementation_approval_evidence_unique").on(table.evidenceId),
27116
+ uniqueIndex37("component_implementation_approval_evidence_unique").on(table.evidenceId),
27107
27117
  unique5("component_implementation_approval_scope_unique").on(table.id, table.projectId, table.componentId),
27108
27118
  index73("component_implementation_approvals_component_idx").on(table.projectId, table.componentId)
27109
27119
  ]
@@ -27164,7 +27174,7 @@ var componentImplementationStates = pgTable86(
27164
27174
  foreignColumns: [projects.id, projects.workspaceId],
27165
27175
  name: "component_implementation_states_project_workspace_fkey"
27166
27176
  }).onDelete("cascade"),
27167
- uniqueIndex36("component_implementation_states_component_unique").on(table.projectId, table.componentId),
27177
+ uniqueIndex37("component_implementation_states_component_unique").on(table.projectId, table.componentId),
27168
27178
  index73("component_implementation_states_workspace_idx").on(table.workspaceId)
27169
27179
  ]
27170
27180
  );
@@ -27226,7 +27236,7 @@ var componentPreviewBundles = pgTable86(
27226
27236
  );
27227
27237
 
27228
27238
  // src/schema/orchestration.ts
27229
- import { sql as sql21 } from "drizzle-orm";
27239
+ import { sql as sql22 } from "drizzle-orm";
27230
27240
  import {
27231
27241
  check as check5,
27232
27242
  foreignKey as foreignKey7,
@@ -27238,7 +27248,7 @@ import {
27238
27248
  text as text88,
27239
27249
  timestamp as timestamp80,
27240
27250
  unique as unique6,
27241
- uniqueIndex as uniqueIndex37,
27251
+ uniqueIndex as uniqueIndex38,
27242
27252
  uuid as uuid3,
27243
27253
  varchar as varchar65
27244
27254
  } from "drizzle-orm/pg-core";
@@ -27267,7 +27277,7 @@ var projectOrchestrationStates = pgTable87(
27267
27277
  name: "project_orchestration_states_project_workspace_fkey"
27268
27278
  }).onDelete("cascade"),
27269
27279
  unique6("project_orchestration_states_scope_unique").on(table.projectId, table.workspaceId),
27270
- check5("project_orchestration_states_generation_check", sql21`${table.generation} >= 2`),
27280
+ check5("project_orchestration_states_generation_check", sql22`${table.generation} >= 2`),
27271
27281
  index74("project_orchestration_states_workspace_idx").on(table.workspaceId)
27272
27282
  ]
27273
27283
  );
@@ -27315,7 +27325,7 @@ var orchestrationRuns = pgTable87(
27315
27325
  table.projectId,
27316
27326
  table.startIdempotencyKey
27317
27327
  ),
27318
- uniqueIndex37("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql21`${table.status} IN ('open', 'paused', 'cancelling')`),
27328
+ uniqueIndex38("orchestration_runs_nonterminal_project_unique").on(table.projectId).where(sql22`${table.status} IN ('open', 'paused', 'cancelling')`),
27319
27329
  index74("orchestration_runs_project_target_idx").on(
27320
27330
  table.projectId,
27321
27331
  table.targetKind,
@@ -27328,17 +27338,17 @@ var orchestrationRuns = pgTable87(
27328
27338
  table.status,
27329
27339
  table.updatedAt
27330
27340
  ),
27331
- check5("orchestration_runs_generation_check", sql21`${table.projectGeneration} >= 2`),
27341
+ check5("orchestration_runs_generation_check", sql22`${table.projectGeneration} >= 2`),
27332
27342
  check5(
27333
27343
  "orchestration_runs_start_idempotency_key_check",
27334
- sql21`length(btrim(${table.startIdempotencyKey})) BETWEEN 1 AND 255`
27344
+ sql22`length(btrim(${table.startIdempotencyKey})) BETWEEN 1 AND 255`
27335
27345
  ),
27336
- check5("orchestration_runs_target_kind_check", sql21`${table.targetKind} = 'component-variant'`),
27346
+ check5("orchestration_runs_target_kind_check", sql22`${table.targetKind} = 'component-variant'`),
27337
27347
  check5(
27338
27348
  "orchestration_runs_target_metadata_check",
27339
27349
  // The one-key branch preserves truthful pre-0269 provenance. The INSERT trigger
27340
27350
  // accepts only the fully bound branch and recomputes it from locked authoritative rows.
27341
- sql21`jsonb_typeof(${table.targetMetadata}) = 'object'
27351
+ sql22`jsonb_typeof(${table.targetMetadata}) = 'object'
27342
27352
  AND ${table.targetMetadata} ->> 'intent' = 'implementation-validation'
27343
27353
  AND (
27344
27354
  (${table.targetMetadata} - ARRAY['intent']::text[]) = '{}'::jsonb
@@ -27399,15 +27409,15 @@ var orchestrationRuns = pgTable87(
27399
27409
  ),
27400
27410
  check5(
27401
27411
  "orchestration_runs_status_check",
27402
- sql21`${table.status} IN ('open', 'paused', 'cancelling', 'cancelled', 'completed', 'abandoned')`
27412
+ sql22`${table.status} IN ('open', 'paused', 'cancelling', 'cancelled', 'completed', 'abandoned')`
27403
27413
  ),
27404
- check5("orchestration_runs_active_stage_check", sql21`length(btrim(${table.activeStage})) > 0`),
27405
- check5("orchestration_runs_version_check", sql21`${table.version} >= 1`),
27414
+ check5("orchestration_runs_active_stage_check", sql22`length(btrim(${table.activeStage})) > 0`),
27415
+ check5("orchestration_runs_version_check", sql22`${table.version} >= 1`),
27406
27416
  check5(
27407
27417
  "orchestration_runs_cancellation_check",
27408
- sql21`${table.status} NOT IN ('cancelling', 'cancelled') OR ${table.cancellationRequestedAt} IS NOT NULL`
27418
+ sql22`${table.status} NOT IN ('cancelling', 'cancelled') OR ${table.cancellationRequestedAt} IS NOT NULL`
27409
27419
  ),
27410
- check5("orchestration_runs_timestamps_check", sql21`${table.updatedAt} >= ${table.createdAt}`)
27420
+ check5("orchestration_runs_timestamps_check", sql22`${table.updatedAt} >= ${table.createdAt}`)
27411
27421
  ]
27412
27422
  );
27413
27423
  var orchestrationRunStartKeys = pgTable87(
@@ -27429,7 +27439,7 @@ var orchestrationRunStartKeys = pgTable87(
27429
27439
  index74("orchestration_run_start_keys_run_created_idx").on(table.runId, table.createdAt),
27430
27440
  check5(
27431
27441
  "orchestration_run_start_keys_idempotency_key_check",
27432
- sql21`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27442
+ sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27433
27443
  )
27434
27444
  ]
27435
27445
  );
@@ -27450,7 +27460,7 @@ var orchestrationRunEvents = pgTable87(
27450
27460
  correlationId: text88("correlation_id"),
27451
27461
  payload: jsonb47("payload").$type().notNull().default({}),
27452
27462
  payloadDigest: varchar65("payload_digest", { length: 71 }).generatedAlwaysAs(
27453
- sql21`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
27463
+ sql22`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
27454
27464
  ),
27455
27465
  createdAt: timestamp80("created_at", { withTimezone: true }).notNull().defaultNow()
27456
27466
  },
@@ -27463,18 +27473,18 @@ var orchestrationRunEvents = pgTable87(
27463
27473
  unique6("orchestration_run_events_sequence_unique").on(table.runId, table.sequence),
27464
27474
  unique6("orchestration_run_events_idempotency_unique").on(table.runId, table.idempotencyKey),
27465
27475
  index74("orchestration_run_events_project_created_idx").on(table.projectId, table.createdAt),
27466
- check5("orchestration_run_events_sequence_check", sql21`${table.sequence} >= 1`),
27467
- check5("orchestration_run_events_schema_version_check", sql21`${table.schemaVersion} >= 1`),
27476
+ check5("orchestration_run_events_sequence_check", sql22`${table.sequence} >= 1`),
27477
+ check5("orchestration_run_events_schema_version_check", sql22`${table.schemaVersion} >= 1`),
27468
27478
  check5(
27469
27479
  "orchestration_run_events_idempotency_key_check",
27470
- sql21`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27480
+ sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27471
27481
  ),
27472
- check5("orchestration_run_events_type_check", sql21`length(btrim(${table.type})) > 0`),
27473
- check5("orchestration_run_events_actor_type_check", sql21`length(btrim(${table.actorType})) > 0`),
27474
- check5("orchestration_run_events_actor_id_check", sql21`length(btrim(${table.actorId})) > 0`),
27482
+ check5("orchestration_run_events_type_check", sql22`length(btrim(${table.type})) > 0`),
27483
+ check5("orchestration_run_events_actor_type_check", sql22`length(btrim(${table.actorType})) > 0`),
27484
+ check5("orchestration_run_events_actor_id_check", sql22`length(btrim(${table.actorId})) > 0`),
27475
27485
  check5(
27476
27486
  "orchestration_run_events_payload_check",
27477
- sql21`jsonb_typeof(${table.payload}) = 'object'`
27487
+ sql22`jsonb_typeof(${table.payload}) = 'object'`
27478
27488
  )
27479
27489
  ]
27480
27490
  );
@@ -27506,29 +27516,29 @@ var orchestrationRunCommandResults = pgTable87(
27506
27516
  ),
27507
27517
  check5(
27508
27518
  "orchestration_run_command_results_command_check",
27509
- sql21`${table.command} IN ('pause', 'resume', 'cancel')`
27519
+ sql22`${table.command} IN ('pause', 'resume', 'cancel')`
27510
27520
  ),
27511
27521
  check5(
27512
27522
  "orchestration_run_command_results_expected_version_check",
27513
- sql21`${table.expectedVersion} >= 1`
27523
+ sql22`${table.expectedVersion} >= 1`
27514
27524
  ),
27515
27525
  check5(
27516
27526
  "orchestration_run_command_results_resulting_version_check",
27517
- sql21`${table.resultingVersion} = ${table.expectedVersion} + 1`
27527
+ sql22`${table.resultingVersion} = ${table.expectedVersion} + 1`
27518
27528
  ),
27519
27529
  check5(
27520
27530
  "orchestration_run_command_results_actor_id_check",
27521
- sql21`length(btrim(${table.actorId})) > 0`
27531
+ sql22`length(btrim(${table.actorId})) > 0`
27522
27532
  ),
27523
27533
  check5(
27524
27534
  "orchestration_run_command_results_payload_check",
27525
- sql21`jsonb_typeof(${table.resultPayload}) = 'object'`
27535
+ sql22`jsonb_typeof(${table.resultPayload}) = 'object'`
27526
27536
  )
27527
27537
  ]
27528
27538
  );
27529
27539
 
27530
27540
  // src/schema/orchestration_executors.ts
27531
- import { sql as sql22 } from "drizzle-orm";
27541
+ import { sql as sql23 } from "drizzle-orm";
27532
27542
  import {
27533
27543
  bigint as bigint5,
27534
27544
  boolean as boolean30,
@@ -27541,7 +27551,7 @@ import {
27541
27551
  text as text89,
27542
27552
  timestamp as timestamp81,
27543
27553
  unique as unique7,
27544
- uniqueIndex as uniqueIndex38,
27554
+ uniqueIndex as uniqueIndex39,
27545
27555
  uuid as uuid4,
27546
27556
  varchar as varchar66
27547
27557
  } from "drizzle-orm/pg-core";
@@ -27614,36 +27624,36 @@ var orchestrationExecutorInstallations = pgTable88(
27614
27624
  table.projectId,
27615
27625
  table.status
27616
27626
  ),
27617
- uniqueIndex38("orchestration_executor_installations_grant_unique").on(table.projectId, table.grantId).where(sql22`${table.grantId} IS NOT NULL AND ${table.status} = 'active'`),
27618
- uniqueIndex38("orchestration_executor_installations_dashboard_unique").on(table.projectId).where(sql22`${table.kind} = 'dashboard-agent' AND ${table.status} = 'active'`),
27627
+ uniqueIndex39("orchestration_executor_installations_grant_unique").on(table.projectId, table.grantId).where(sql23`${table.grantId} IS NOT NULL AND ${table.status} = 'active'`),
27628
+ uniqueIndex39("orchestration_executor_installations_dashboard_unique").on(table.projectId).where(sql23`${table.kind} = 'dashboard-agent' AND ${table.status} = 'active'`),
27619
27629
  check6(
27620
27630
  "orchestration_executor_installations_kind_check",
27621
- sql22`${table.kind} IN ('dashboard-agent', 'native-bridge')`
27631
+ sql23`${table.kind} IN ('dashboard-agent', 'native-bridge')`
27622
27632
  ),
27623
27633
  check6(
27624
27634
  "orchestration_executor_installations_status_check",
27625
- sql22`${table.status} IN ('active', 'revoked', 'incompatible')`
27635
+ sql23`${table.status} IN ('active', 'revoked', 'incompatible')`
27626
27636
  ),
27627
27637
  // A native bridge executor must carry an external grant; the Dashboard Agent must not.
27628
27638
  check6(
27629
27639
  "orchestration_executor_installations_grant_required_check",
27630
- sql22`(${table.kind} = 'native-bridge') = (${table.grantId} IS NOT NULL)`
27640
+ sql23`(${table.kind} = 'native-bridge') = (${table.grantId} IS NOT NULL)`
27631
27641
  ),
27632
27642
  check6(
27633
27643
  "orchestration_executor_installations_capability_digest_check",
27634
- sql22`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
27644
+ sql23`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
27635
27645
  ),
27636
27646
  check6(
27637
27647
  "orchestration_executor_installations_protocol_version_check",
27638
- sql22`length(btrim(${table.protocolVersion})) > 0`
27648
+ sql23`length(btrim(${table.protocolVersion})) > 0`
27639
27649
  ),
27640
27650
  check6(
27641
27651
  "orchestration_executor_installations_repository_claim_check",
27642
- sql22`jsonb_typeof(${table.repositoryClaim}) = 'object'`
27652
+ sql23`jsonb_typeof(${table.repositoryClaim}) = 'object'`
27643
27653
  ),
27644
27654
  check6(
27645
27655
  "orchestration_executor_installations_updated_at_check",
27646
- sql22`${table.updatedAt} >= ${table.createdAt}`
27656
+ sql23`${table.updatedAt} >= ${table.createdAt}`
27647
27657
  )
27648
27658
  ]
27649
27659
  );
@@ -27689,27 +27699,27 @@ var orchestrationExecutorSessions = pgTable88(
27689
27699
  table.installationId,
27690
27700
  table.state
27691
27701
  ),
27692
- index75("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql22`${table.state} = 'open'`),
27693
- check6("orchestration_executor_sessions_epoch_check", sql22`${table.sessionEpoch} >= 1`),
27702
+ index75("orchestration_executor_sessions_liveness_idx").on(table.serverReceivedAt).where(sql23`${table.state} = 'open'`),
27703
+ check6("orchestration_executor_sessions_epoch_check", sql23`${table.sessionEpoch} >= 1`),
27694
27704
  check6(
27695
27705
  "orchestration_executor_sessions_state_check",
27696
- sql22`${table.state} IN ('open', 'fenced', 'closed')`
27706
+ sql23`${table.state} IN ('open', 'fenced', 'closed')`
27697
27707
  ),
27698
27708
  check6(
27699
27709
  "orchestration_executor_sessions_cursor_check",
27700
- sql22`${table.clientCursor} >= 0 AND ${table.serverCursor} >= 0`
27710
+ sql23`${table.clientCursor} >= 0 AND ${table.serverCursor} >= 0`
27701
27711
  ),
27702
27712
  check6(
27703
27713
  "orchestration_executor_sessions_credential_audience_check",
27704
- sql22`length(btrim(${table.credentialAudience})) > 0`
27714
+ sql23`length(btrim(${table.credentialAudience})) > 0`
27705
27715
  ),
27706
27716
  check6(
27707
27717
  "orchestration_executor_sessions_closed_state_check",
27708
- sql22`(${table.state} = 'closed') = (${table.closedAt} IS NOT NULL)`
27718
+ sql23`(${table.state} = 'closed') = (${table.closedAt} IS NOT NULL)`
27709
27719
  ),
27710
27720
  check6(
27711
27721
  "orchestration_executor_sessions_updated_at_check",
27712
- sql22`${table.updatedAt} >= ${table.createdAt}`
27722
+ sql23`${table.updatedAt} >= ${table.createdAt}`
27713
27723
  )
27714
27724
  ]
27715
27725
  );
@@ -27784,30 +27794,30 @@ var orchestrationImplementationAttempts = pgTable88(
27784
27794
  table.runId,
27785
27795
  table.createdAt
27786
27796
  ),
27787
- check6("orchestration_implementation_attempts_number_check", sql22`${table.attemptNumber} >= 1`),
27797
+ check6("orchestration_implementation_attempts_number_check", sql23`${table.attemptNumber} >= 1`),
27788
27798
  check6(
27789
27799
  "orchestration_implementation_attempts_target_kind_check",
27790
- sql22`${table.targetKind} = 'component-variant'`
27800
+ sql23`${table.targetKind} = 'component-variant'`
27791
27801
  ),
27792
27802
  check6(
27793
27803
  "orchestration_implementation_attempts_status_check",
27794
- sql22`${table.status} IN ('preflight', 'proposed', 'approved', 'implementing', 'suspended', 'superseded', 'cancelled', 'failed', 'completed')`
27804
+ sql23`${table.status} IN ('preflight', 'proposed', 'approved', 'implementing', 'suspended', 'superseded', 'cancelled', 'failed', 'completed')`
27795
27805
  ),
27796
27806
  check6(
27797
27807
  "orchestration_implementation_attempts_base_sha_check",
27798
- sql22`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
27808
+ sql23`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
27799
27809
  ),
27800
27810
  check6(
27801
27811
  "orchestration_implementation_attempts_superseded_check",
27802
- sql22`${table.supersededBy} IS NULL OR ${table.supersededBy} <> ${table.id}`
27812
+ sql23`${table.supersededBy} IS NULL OR ${table.supersededBy} <> ${table.id}`
27803
27813
  ),
27804
27814
  check6(
27805
27815
  "orchestration_implementation_attempts_binding_digest_check",
27806
- sql22`length(btrim(${table.targetBindingDigest})) BETWEEN 1 AND 255`
27816
+ sql23`length(btrim(${table.targetBindingDigest})) BETWEEN 1 AND 255`
27807
27817
  ),
27808
27818
  check6(
27809
27819
  "orchestration_implementation_attempts_updated_at_check",
27810
- sql22`${table.updatedAt} >= ${table.createdAt}`
27820
+ sql23`${table.updatedAt} >= ${table.createdAt}`
27811
27821
  )
27812
27822
  ]
27813
27823
  );
@@ -27979,47 +27989,47 @@ var orchestrationExecutionApprovals = pgTable88(
27979
27989
  index75("orchestration_execution_approvals_run_created_idx").on(table.runId, table.createdAt),
27980
27990
  check6(
27981
27991
  "orchestration_execution_approvals_idempotency_key_check",
27982
- sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27992
+ sql23`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
27983
27993
  ),
27984
27994
  check6(
27985
27995
  "orchestration_execution_approvals_approved_by_check",
27986
- sql22`length(btrim(${table.approvedBy})) > 0`
27996
+ sql23`length(btrim(${table.approvedBy})) > 0`
27987
27997
  ),
27988
27998
  check6(
27989
27999
  "orchestration_execution_approvals_target_kind_check",
27990
- sql22`${table.targetKind} = 'component-variant'`
28000
+ sql23`${table.targetKind} = 'component-variant'`
27991
28001
  ),
27992
28002
  check6(
27993
28003
  "orchestration_execution_approvals_base_sha_check",
27994
- sql22`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
28004
+ sql23`${table.baseSha} IS NULL OR ${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
27995
28005
  ),
27996
28006
  check6(
27997
28007
  "orchestration_execution_approvals_path_policy_check",
27998
- sql22`jsonb_typeof(${table.pathPolicy}) = 'object'`
28008
+ sql23`jsonb_typeof(${table.pathPolicy}) = 'object'`
27999
28009
  ),
28000
28010
  check6(
28001
28011
  "orchestration_execution_approvals_operation_classes_check",
28002
- sql22`jsonb_typeof(${table.operationClasses}) = 'array'`
28012
+ sql23`jsonb_typeof(${table.operationClasses}) = 'array'`
28003
28013
  ),
28004
28014
  check6(
28005
28015
  "orchestration_execution_approvals_mutation_budget_check",
28006
- sql22`jsonb_typeof(${table.mutationBudget}) = 'object'`
28016
+ sql23`jsonb_typeof(${table.mutationBudget}) = 'object'`
28007
28017
  ),
28008
28018
  check6(
28009
28019
  "orchestration_execution_approvals_plan_digest_check",
28010
- sql22`length(btrim(${table.planDigest})) BETWEEN 1 AND 255`
28020
+ sql23`length(btrim(${table.planDigest})) BETWEEN 1 AND 255`
28011
28021
  ),
28012
28022
  check6(
28013
28023
  "orchestration_execution_approvals_capability_digest_check",
28014
- sql22`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
28024
+ sql23`length(btrim(${table.capabilityDigest})) BETWEEN 1 AND 255`
28015
28025
  ),
28016
28026
  check6(
28017
28027
  "orchestration_execution_approvals_validation_digest_check",
28018
- sql22`length(btrim(${table.validationDigest})) BETWEEN 1 AND 255`
28028
+ sql23`length(btrim(${table.validationDigest})) BETWEEN 1 AND 255`
28019
28029
  ),
28020
28030
  check6(
28021
28031
  "orchestration_execution_approvals_expiry_check",
28022
- sql22`${table.expiresAt} > ${table.createdAt}`
28032
+ sql23`${table.expiresAt} > ${table.createdAt}`
28023
28033
  )
28024
28034
  ]
28025
28035
  );
@@ -28076,24 +28086,24 @@ var orchestrationExecutorLeases = pgTable88(
28076
28086
  ),
28077
28087
  unique7("orchestration_executor_leases_epoch_unique").on(table.attemptId, table.leaseEpoch),
28078
28088
  // Plan invariant 6, enforced in the database: a run has at most one active executor lease.
28079
- uniqueIndex38("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql22`${table.state} = 'active'`),
28080
- index75("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql22`${table.state} = 'active'`),
28081
- check6("orchestration_executor_leases_epoch_check", sql22`${table.leaseEpoch} >= 1`),
28089
+ uniqueIndex39("orchestration_executor_leases_one_active_per_run").on(table.runId).where(sql23`${table.state} = 'active'`),
28090
+ index75("orchestration_executor_leases_deadline_idx").on(table.heartbeatDeadline).where(sql23`${table.state} = 'active'`),
28091
+ check6("orchestration_executor_leases_epoch_check", sql23`${table.leaseEpoch} >= 1`),
28082
28092
  check6(
28083
28093
  "orchestration_executor_leases_state_check",
28084
- sql22`${table.state} IN ('active', 'paused', 'revoked', 'released')`
28094
+ sql23`${table.state} IN ('active', 'paused', 'revoked', 'released')`
28085
28095
  ),
28086
28096
  check6(
28087
28097
  "orchestration_executor_leases_release_consistency_check",
28088
- sql22`(${table.state} IN ('revoked', 'released')) = (${table.releasedAt} IS NOT NULL)`
28098
+ sql23`(${table.state} IN ('revoked', 'released')) = (${table.releasedAt} IS NOT NULL)`
28089
28099
  ),
28090
28100
  check6(
28091
28101
  "orchestration_executor_leases_release_reason_check",
28092
- sql22`${table.releaseReason} IS NULL OR ${table.releaseReason} IN ('handoff', 'heartbeat-lost', 'cancelled', 'completed', 'superseded', 'revoked')`
28102
+ sql23`${table.releaseReason} IS NULL OR ${table.releaseReason} IN ('handoff', 'heartbeat-lost', 'cancelled', 'completed', 'superseded', 'revoked')`
28093
28103
  ),
28094
28104
  check6(
28095
28105
  "orchestration_executor_leases_updated_at_check",
28096
- sql22`${table.updatedAt} >= ${table.createdAt}`
28106
+ sql23`${table.updatedAt} >= ${table.createdAt}`
28097
28107
  )
28098
28108
  ]
28099
28109
  );
@@ -28118,7 +28128,7 @@ var orchestrationExecutorCommands = pgTable88(
28118
28128
  expectedRunVersion: integer44("expected_run_version").notNull(),
28119
28129
  payload: jsonb48("payload").$type().notNull().default({}),
28120
28130
  payloadDigest: varchar66("payload_digest", { length: 71 }).generatedAlwaysAs(
28121
- sql22`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
28131
+ sql23`'sha256:' || encode(digest(payload::text, 'sha256'), 'hex')`
28122
28132
  ),
28123
28133
  deliveredAt: timestamp81("delivered_at", { withTimezone: true }),
28124
28134
  acknowledgedAt: timestamp81("acknowledged_at", { withTimezone: true }),
@@ -28150,32 +28160,32 @@ var orchestrationExecutorCommands = pgTable88(
28150
28160
  ),
28151
28161
  index75("orchestration_executor_commands_run_sequence_idx").on(table.runId, table.sequence),
28152
28162
  // The long-poll cursor read: unacknowledged commands for a run, in order.
28153
- index75("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql22`${table.acknowledgedAt} IS NULL`),
28154
- check6("orchestration_executor_commands_sequence_check", sql22`${table.sequence} >= 1`),
28163
+ index75("orchestration_executor_commands_pending_idx").on(table.runId, table.sequence).where(sql23`${table.acknowledgedAt} IS NULL`),
28164
+ check6("orchestration_executor_commands_sequence_check", sql23`${table.sequence} >= 1`),
28155
28165
  check6(
28156
28166
  "orchestration_executor_commands_kind_check",
28157
- sql22`${table.kind} IN ('offer', 'inspect', 'propose', 'implement', 'suspend', 'resume', 'cancel', 'handoff')`
28167
+ sql23`${table.kind} IN ('offer', 'inspect', 'propose', 'implement', 'suspend', 'resume', 'cancel', 'handoff')`
28158
28168
  ),
28159
28169
  check6(
28160
28170
  "orchestration_executor_commands_idempotency_key_check",
28161
- sql22`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
28171
+ sql23`length(btrim(${table.idempotencyKey})) BETWEEN 1 AND 255`
28162
28172
  ),
28163
28173
  check6(
28164
28174
  "orchestration_executor_commands_expected_run_version_check",
28165
- sql22`${table.expectedRunVersion} >= 1`
28175
+ sql23`${table.expectedRunVersion} >= 1`
28166
28176
  ),
28167
28177
  check6(
28168
28178
  "orchestration_executor_commands_payload_check",
28169
- sql22`jsonb_typeof(${table.payload}) = 'object'`
28179
+ sql23`jsonb_typeof(${table.payload}) = 'object'`
28170
28180
  ),
28171
28181
  check6(
28172
28182
  "orchestration_executor_commands_lease_epoch_check",
28173
- sql22`(${table.leaseId} IS NULL) = (${table.leaseEpoch} IS NULL)`
28183
+ sql23`(${table.leaseId} IS NULL) = (${table.leaseEpoch} IS NULL)`
28174
28184
  ),
28175
28185
  // Acknowledgement implies delivery. The reverse is not true and must not be assumed.
28176
28186
  check6(
28177
28187
  "orchestration_executor_commands_ack_implies_delivery_check",
28178
- sql22`${table.acknowledgedAt} IS NULL OR ${table.deliveredAt} IS NOT NULL`
28188
+ sql23`${table.acknowledgedAt} IS NULL OR ${table.deliveredAt} IS NOT NULL`
28179
28189
  )
28180
28190
  ]
28181
28191
  );
@@ -28222,29 +28232,29 @@ var orchestrationPatchManifests = pgTable88(
28222
28232
  unique7("orchestration_patch_manifests_sequence_unique").on(table.attemptId, table.sequence),
28223
28233
  unique7("orchestration_patch_manifests_path_unique").on(table.attemptId, table.path),
28224
28234
  index75("orchestration_patch_manifests_attempt_sequence_idx").on(table.attemptId, table.sequence),
28225
- check6("orchestration_patch_manifests_sequence_check", sql22`${table.sequence} >= 1`),
28235
+ check6("orchestration_patch_manifests_sequence_check", sql23`${table.sequence} >= 1`),
28226
28236
  check6(
28227
28237
  "orchestration_patch_manifests_operation_check",
28228
- sql22`${table.operation} IN ('create', 'update', 'delete')`
28238
+ sql23`${table.operation} IN ('create', 'update', 'delete')`
28229
28239
  ),
28230
28240
  check6(
28231
28241
  "orchestration_patch_manifests_mode_check",
28232
- sql22`${table.fileMode} IN ('100644', '100755')`
28242
+ sql23`${table.fileMode} IN ('100644', '100755')`
28233
28243
  ),
28234
28244
  check6(
28235
28245
  "orchestration_patch_manifests_path_check",
28236
- sql22`length(btrim(${table.path})) BETWEEN 1 AND 2048`
28246
+ sql23`length(btrim(${table.path})) BETWEEN 1 AND 2048`
28237
28247
  ),
28238
28248
  // A create must not claim a predecessor; a delete must not claim a result.
28239
28249
  check6(
28240
28250
  "orchestration_patch_manifests_create_check",
28241
- sql22`${table.operation} <> 'create' OR ${table.expectedBefore} IS NULL`
28251
+ sql23`${table.operation} <> 'create' OR ${table.expectedBefore} IS NULL`
28242
28252
  ),
28243
28253
  check6(
28244
28254
  "orchestration_patch_manifests_delete_check",
28245
- sql22`${table.operation} <> 'delete' OR ${table.resultingBlobSha} IS NULL`
28255
+ sql23`${table.operation} <> 'delete' OR ${table.resultingBlobSha} IS NULL`
28246
28256
  ),
28247
- check6("orchestration_patch_manifests_byte_count_check", sql22`${table.byteCount} >= 0`)
28257
+ check6("orchestration_patch_manifests_byte_count_check", sql23`${table.byteCount} >= 0`)
28248
28258
  ]
28249
28259
  );
28250
28260
  var orchestrationPullRequestReceipts = pgTable88(
@@ -28300,34 +28310,34 @@ var orchestrationPullRequestReceipts = pgTable88(
28300
28310
  table.generation
28301
28311
  ),
28302
28312
  index75("orchestration_pull_request_receipts_head_idx").on(table.repositoryId, table.headSha),
28303
- check6("orchestration_pull_request_receipts_generation_check", sql22`${table.generation} >= 1`),
28304
- check6("orchestration_pull_request_receipts_number_check", sql22`${table.pullRequestNumber} >= 1`),
28313
+ check6("orchestration_pull_request_receipts_generation_check", sql23`${table.generation} >= 1`),
28314
+ check6("orchestration_pull_request_receipts_number_check", sql23`${table.pullRequestNumber} >= 1`),
28305
28315
  check6(
28306
28316
  "orchestration_pull_request_receipts_base_sha_check",
28307
- sql22`${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
28317
+ sql23`${table.baseSha} ~ '^[0-9a-f]{7,64}$'`
28308
28318
  ),
28309
28319
  check6(
28310
28320
  "orchestration_pull_request_receipts_head_sha_check",
28311
- sql22`${table.headSha} ~ '^[0-9a-f]{7,64}$'`
28321
+ sql23`${table.headSha} ~ '^[0-9a-f]{7,64}$'`
28312
28322
  ),
28313
28323
  // Same-repository PR only: a fork head is not a branch the adapter can own or advance.
28314
28324
  check6(
28315
28325
  "orchestration_pull_request_receipts_refs_check",
28316
- sql22`length(btrim(${table.baseRef})) > 0 AND length(btrim(${table.headRef})) > 0 AND ${table.baseRef} <> ${table.headRef}`
28326
+ sql23`length(btrim(${table.baseRef})) > 0 AND length(btrim(${table.headRef})) > 0 AND ${table.baseRef} <> ${table.headRef}`
28317
28327
  ),
28318
28328
  check6(
28319
28329
  "orchestration_pull_request_receipts_url_check",
28320
- sql22`${table.pullRequestUrl} ~ '^https://'`
28330
+ sql23`${table.pullRequestUrl} ~ '^https://'`
28321
28331
  ),
28322
28332
  check6(
28323
28333
  "orchestration_pull_request_receipts_updated_at_check",
28324
- sql22`${table.updatedAt} >= ${table.createdAt}`
28334
+ sql23`${table.updatedAt} >= ${table.createdAt}`
28325
28335
  )
28326
28336
  ]
28327
28337
  );
28328
28338
 
28329
28339
  // src/schema/conversion_proposals.ts
28330
- import { sql as sql23 } from "drizzle-orm";
28340
+ import { sql as sql24 } from "drizzle-orm";
28331
28341
  import { check as check7, foreignKey as foreignKey9, index as index76, integer as integer45, jsonb as jsonb49, pgTable as pgTable89, text as text90, timestamp as timestamp82, unique as unique8, uuid as uuid5, varchar as varchar67 } from "drizzle-orm/pg-core";
28332
28342
  var CONVERSION_PROPOSAL_STATUSES = ["draft", "approved", "superseded"];
28333
28343
  var conversionProposals = pgTable89(
@@ -28343,9 +28353,9 @@ var conversionProposals = pgTable89(
28343
28353
  baseHeadOid: varchar67("base_head_oid", { length: 64 }).notNull(),
28344
28354
  baseBranch: text90("base_branch").notNull(),
28345
28355
  /** Brief paths whose `original` was not found in any source file. */
28346
- unlocated: jsonb49("unlocated").notNull().default(sql23`'[]'::jsonb`),
28356
+ unlocated: jsonb49("unlocated").notNull().default(sql24`'[]'::jsonb`),
28347
28357
  /** Files that matched a brief original but fell outside the acquisition caps. */
28348
- omittedByCap: jsonb49("omitted_by_cap").notNull().default(sql23`'[]'::jsonb`),
28358
+ omittedByCap: jsonb49("omitted_by_cap").notNull().default(sql24`'[]'::jsonb`),
28349
28359
  /**
28350
28360
  * The codemod's receipt (migration 0296) — every path it bound, and every one it could not.
28351
28361
  *
@@ -28378,17 +28388,17 @@ var conversionProposals = pgTable89(
28378
28388
  foreignColumns: [projects.id, projects.workspaceId],
28379
28389
  name: "conversion_proposals_project_workspace_fkey"
28380
28390
  }).onDelete("cascade"),
28381
- check7("conversion_proposals_status_check", sql23`${table.status} IN ('draft', 'approved', 'superseded')`),
28382
- check7("conversion_proposals_version_check", sql23`${table.version} >= 1`),
28391
+ check7("conversion_proposals_status_check", sql24`${table.status} IN ('draft', 'approved', 'superseded')`),
28392
+ check7("conversion_proposals_version_check", sql24`${table.version} >= 1`),
28383
28393
  check7(
28384
28394
  "conversion_proposals_receipt_object_check",
28385
- sql23`${table.receipt} IS NULL OR jsonb_typeof(${table.receipt}) = 'object'`
28395
+ sql24`${table.receipt} IS NULL OR jsonb_typeof(${table.receipt}) = 'object'`
28386
28396
  )
28387
28397
  ]
28388
28398
  );
28389
28399
 
28390
28400
  // src/schema/conversion_briefs_issued.ts
28391
- import { sql as sql24 } from "drizzle-orm";
28401
+ import { sql as sql25 } from "drizzle-orm";
28392
28402
  import { check as check8, foreignKey as foreignKey10, index as index77, jsonb as jsonb50, pgTable as pgTable90, text as text91, timestamp as timestamp83, unique as unique9, uuid as uuid6 } from "drizzle-orm/pg-core";
28393
28403
  var conversionBriefsIssued = pgTable90(
28394
28404
  "conversion_briefs_issued",
@@ -28399,7 +28409,7 @@ var conversionBriefsIssued = pgTable90(
28399
28409
  /** sha256 of the canonical brief — `briefDigest`, computed identically by the codemod. */
28400
28410
  briefDigest: text91("brief_digest").notNull(),
28401
28411
  /** `[{ route, scope, path, kind, locator? }]` — every bindable path the brief listed. */
28402
- paths: jsonb50("paths").notNull().default(sql24`'[]'::jsonb`),
28412
+ paths: jsonb50("paths").notNull().default(sql25`'[]'::jsonb`),
28403
28413
  /**
28404
28414
  * The codemod's account of the run against THIS digest (`submit_conversion_receipt`): which
28405
28415
  * paths it rewrote, which it could not, and why. Null until one is submitted — a hand
@@ -28417,13 +28427,13 @@ var conversionBriefsIssued = pgTable90(
28417
28427
  foreignColumns: [projects.id, projects.workspaceId],
28418
28428
  name: "conversion_briefs_issued_project_workspace_fkey"
28419
28429
  }).onDelete("cascade"),
28420
- check8("conversion_briefs_issued_brief_digest_check", sql24`${table.briefDigest} ~ '^sha256:[0-9a-f]{64}$'`),
28421
- check8("conversion_briefs_issued_paths_array_check", sql24`jsonb_typeof(${table.paths}) = 'array'`)
28430
+ check8("conversion_briefs_issued_brief_digest_check", sql25`${table.briefDigest} ~ '^sha256:[0-9a-f]{64}$'`),
28431
+ check8("conversion_briefs_issued_paths_array_check", sql25`jsonb_typeof(${table.paths}) = 'array'`)
28422
28432
  ]
28423
28433
  );
28424
28434
 
28425
28435
  // src/schema/orchestration_validation.ts
28426
- import { sql as sql25 } from "drizzle-orm";
28436
+ import { sql as sql26 } from "drizzle-orm";
28427
28437
  import {
28428
28438
  bigint as bigint6,
28429
28439
  check as check9,
@@ -28435,7 +28445,7 @@ import {
28435
28445
  text as text92,
28436
28446
  timestamp as timestamp84,
28437
28447
  unique as unique10,
28438
- uniqueIndex as uniqueIndex39,
28448
+ uniqueIndex as uniqueIndex40,
28439
28449
  uuid as uuid7,
28440
28450
  varchar as varchar68
28441
28451
  } from "drizzle-orm/pg-core";
@@ -28518,15 +28528,15 @@ var orchestrationValidationEnvelopes = pgTable91(
28518
28528
  }).onDelete("set null"),
28519
28529
  // One live envelope per (attempt, head): two validators can never both be authoritative for
28520
28530
  // the same commit. The index arbitrates, so no read-then-write can lose the race.
28521
- uniqueIndex39("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql25`status IN ('queued', 'dispatched', 'action_required')`),
28531
+ uniqueIndex40("orchestration_validation_envelopes_one_live_per_head").on(table.attemptId, table.headSha).where(sql26`status IN ('queued', 'dispatched', 'action_required')`),
28522
28532
  index78("orchestration_validation_envelopes_attempt_idx").on(
28523
28533
  table.attemptId,
28524
28534
  table.createdAt.desc()
28525
28535
  ),
28526
- index78("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql25`status IN ('queued', 'dispatched')`),
28536
+ index78("orchestration_validation_envelopes_sweep_idx").on(table.status, table.nonceExpiresAt).where(sql26`status IN ('queued', 'dispatched')`),
28527
28537
  check9(
28528
28538
  "orchestration_validation_envelopes_status_check",
28529
- sql25`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
28539
+ sql26`${table.status} IN ('queued', 'dispatched', 'action_required', 'passed', 'failed', 'superseded', 'timed_out', 'cancelled')`
28530
28540
  ),
28531
28541
  // Passing is not assignable. It requires evidence that was ingested, an attestation that was
28532
28542
  // written, and a nonce that was consumed — so executor success alone cannot spell it.
@@ -28535,7 +28545,7 @@ var orchestrationValidationEnvelopes = pgTable91(
28535
28545
  // evidence, which is exactly what an honest failing result is.
28536
28546
  check9(
28537
28547
  "orchestration_validation_envelopes_passed_requires_evidence",
28538
- sql25`${table.status} <> 'passed' OR (${table.evidenceId} IS NOT NULL AND ${table.attestationDigest} IS NOT NULL AND ${table.nonceConsumedAt} IS NOT NULL)`
28548
+ sql26`${table.status} <> 'passed' OR (${table.evidenceId} IS NOT NULL AND ${table.attestationDigest} IS NOT NULL AND ${table.nonceConsumedAt} IS NOT NULL)`
28539
28549
  )
28540
28550
  ]
28541
28551
  );
@@ -28590,19 +28600,19 @@ var orchestrationValidationEvidence = pgTable91(
28590
28600
  index78("orchestration_validation_evidence_envelope_idx").on(table.envelopeId),
28591
28601
  check9(
28592
28602
  "orchestration_validation_evidence_status_check",
28593
- sql25`${table.status} IN ('passed', 'failed')`
28603
+ sql26`${table.status} IN ('passed', 'failed')`
28594
28604
  )
28595
28605
  ]
28596
28606
  );
28597
28607
 
28598
28608
  // src/schema/orchestration_executor_grants.ts
28599
- import { sql as sql26 } from "drizzle-orm";
28600
- import { check as check10, foreignKey as foreignKey12, index as index79, integer as integer47, pgTable as pgTable92, text as text93, timestamp as timestamp85, unique as unique11, uniqueIndex as uniqueIndex40, uuid as uuid8, varchar as varchar69 } from "drizzle-orm/pg-core";
28609
+ import { sql as sql27 } from "drizzle-orm";
28610
+ import { check as check10, foreignKey as foreignKey12, index as index79, integer as integer47, pgTable as pgTable92, text as text93, timestamp as timestamp85, unique as unique11, uniqueIndex as uniqueIndex41, uuid as uuid8, varchar as varchar69 } from "drizzle-orm/pg-core";
28601
28611
  var EXECUTOR_GRANT_STATUSES = ["active", "revoked", "expired"];
28602
28612
  var orchestrationExecutorGrants = pgTable92(
28603
28613
  "orchestration_executor_grants",
28604
28614
  {
28605
- id: text93("id").primaryKey().default(sql26`gen_random_uuid()`),
28615
+ id: text93("id").primaryKey().default(sql27`gen_random_uuid()`),
28606
28616
  workspaceId: text93("workspace_id").notNull().references(() => workspaces.id, { onDelete: "cascade" }),
28607
28617
  projectId: text93("project_id").notNull().references(() => projects.id, { onDelete: "cascade" }),
28608
28618
  installationId: uuid8("installation_id").notNull().references(() => orchestrationExecutorInstallations.id, { onDelete: "cascade" }),
@@ -28636,21 +28646,21 @@ var orchestrationExecutorGrants = pgTable92(
28636
28646
  }).onDelete("cascade"),
28637
28647
  // One live credential per installation. Two would mean two processes can each present a valid
28638
28648
  // one, and the exclusion argument collapses before the lease layer is reached.
28639
- uniqueIndex40("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql26`status = 'active'`),
28640
- index79("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql26`status = 'active'`),
28649
+ uniqueIndex41("orchestration_executor_grants_one_active_per_installation").on(table.installationId).where(sql27`status = 'active'`),
28650
+ index79("orchestration_executor_grants_credential_idx").on(table.workspaceId, table.credentialHash).where(sql27`status = 'active'`),
28641
28651
  check10(
28642
28652
  "orchestration_executor_grants_status_check",
28643
- sql26`${table.status} IN ('active', 'revoked', 'expired')`
28653
+ sql27`${table.status} IN ('active', 'revoked', 'expired')`
28644
28654
  ),
28645
28655
  check10(
28646
28656
  "orchestration_executor_grants_revocation_paired",
28647
- sql26`(${table.status} = 'revoked') = (${table.revokedAt} IS NOT NULL)`
28657
+ sql27`(${table.status} = 'revoked') = (${table.revokedAt} IS NOT NULL)`
28648
28658
  )
28649
28659
  ]
28650
28660
  );
28651
28661
 
28652
28662
  // src/schema/component_presets.ts
28653
- import { pgTable as pgTable93, text as text94, varchar as varchar70, timestamp as timestamp86, jsonb as jsonb52, integer as integer48, index as index80, uniqueIndex as uniqueIndex41 } from "drizzle-orm/pg-core";
28663
+ import { pgTable as pgTable93, text as text94, varchar as varchar70, timestamp as timestamp86, jsonb as jsonb52, integer as integer48, index as index80, uniqueIndex as uniqueIndex42 } from "drizzle-orm/pg-core";
28654
28664
  import { relations as relations16 } from "drizzle-orm";
28655
28665
  var componentPresets = pgTable93(
28656
28666
  "component_presets",
@@ -28671,7 +28681,7 @@ var componentPresets = pgTable93(
28671
28681
  },
28672
28682
  (t) => [
28673
28683
  index80("component_presets_component_position_idx").on(t.componentId, t.position, t.createdAt, t.id),
28674
- uniqueIndex41("component_presets_component_slug_key").on(t.componentId, t.slug)
28684
+ uniqueIndex42("component_presets_component_slug_key").on(t.componentId, t.slug)
28675
28685
  ]
28676
28686
  );
28677
28687
  var componentPresetsRelations = relations16(componentPresets, ({ one }) => ({
@@ -28691,10 +28701,10 @@ import {
28691
28701
  text as text95,
28692
28702
  timestamp as timestamp87,
28693
28703
  unique as unique12,
28694
- uniqueIndex as uniqueIndex42,
28704
+ uniqueIndex as uniqueIndex43,
28695
28705
  varchar as varchar71
28696
28706
  } from "drizzle-orm/pg-core";
28697
- import { sql as sql27 } from "drizzle-orm";
28707
+ import { sql as sql28 } from "drizzle-orm";
28698
28708
  var SECTION_IMPLEMENTATION_REQUEST_STATUSES = [
28699
28709
  "queued",
28700
28710
  "dispatching",
@@ -28721,7 +28731,7 @@ var sectionDefinitions = pgTable94(
28721
28731
  name: "section_definitions_project_workspace_fkey"
28722
28732
  }).onDelete("cascade").onUpdate("cascade"),
28723
28733
  unique12("section_definitions_id_project_unique").on(table.id, table.projectId),
28724
- uniqueIndex42("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
28734
+ uniqueIndex43("section_definitions_project_api_id_unique").on(table.projectId, table.apiId),
28725
28735
  index81("section_definitions_workspace_idx").on(table.workspaceId),
28726
28736
  index81("section_definitions_project_idx").on(table.projectId)
28727
28737
  ]
@@ -28780,7 +28790,7 @@ var sectionZones = pgTable94(
28780
28790
  name: "section_zones_project_workspace_fkey"
28781
28791
  }).onDelete("cascade").onUpdate("cascade"),
28782
28792
  unique12("section_zones_id_project_unique").on(table.id, table.projectId),
28783
- uniqueIndex42("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
28793
+ uniqueIndex43("section_zones_schema_owner_unique").on(table.projectId, table.schemaKind, table.schemaId),
28784
28794
  index81("section_zones_workspace_idx").on(table.workspaceId)
28785
28795
  ]
28786
28796
  );
@@ -28831,7 +28841,7 @@ var sectionZoneAttachments = pgTable94(
28831
28841
  ],
28832
28842
  name: "section_zone_attachments_published_version_fkey"
28833
28843
  }).onDelete("restrict"),
28834
- uniqueIndex42("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
28844
+ uniqueIndex43("section_zone_attachments_zone_definition_unique").on(table.zoneId, table.sectionDefinitionId),
28835
28845
  index81("section_zone_attachments_zone_position_idx").on(table.zoneId, table.position, table.id)
28836
28846
  ]
28837
28847
  );
@@ -29010,7 +29020,7 @@ var sectionImplementationRequests = pgTable94(
29010
29020
  name: "section_implementation_requests_validation_project_fkey"
29011
29021
  }).onDelete("restrict"),
29012
29022
  unique12("section_implementation_requests_id_project_unique").on(table.id, table.projectId),
29013
- uniqueIndex42("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql27`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
29023
+ uniqueIndex43("section_implementation_requests_one_active_unique").on(table.projectId, table.sectionDefinitionId, table.sectionVersion, table.schemaHash).where(sql28`${table.status} IN ('queued', 'dispatching', 'dispatched', 'running')`),
29014
29024
  index81("section_implementation_requests_project_created_idx").on(table.projectId, table.createdAt)
29015
29025
  ]
29016
29026
  );
@@ -29044,7 +29054,7 @@ var sectionZoneReleases = pgTable94(
29044
29054
 
29045
29055
  // src/schema/content_locks.ts
29046
29056
  import { check as check11, index as index82, jsonb as jsonb54, pgTable as pgTable95, text as text96, timestamp as timestamp88 } from "drizzle-orm/pg-core";
29047
- import { sql as sql28 } from "drizzle-orm";
29057
+ import { sql as sql29 } from "drizzle-orm";
29048
29058
  var CONTENT_LOCK_TARGET_KINDS = [
29049
29059
  "page",
29050
29060
  "content_entry",
@@ -29075,9 +29085,9 @@ var contentLocks = pgTable95(
29075
29085
  (table) => [
29076
29086
  index82("content_locks_workspace_idx").on(table.workspaceId),
29077
29087
  index82("content_locks_project_idx").on(table.projectId),
29078
- index82("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql28`${table.releasedAt} IS NULL`),
29079
- check11("content_locks_target_kind_check", sql28`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
29080
- check11("content_locks_mode_check", sql28`${table.mode} IN ('all','agents')`)
29088
+ index82("content_locks_target_idx").on(table.targetKind, table.targetId).where(sql29`${table.releasedAt} IS NULL`),
29089
+ check11("content_locks_target_kind_check", sql29`${table.targetKind} IN ('page','content_entry','singleton_entry','component_definition')`),
29090
+ check11("content_locks_mode_check", sql29`${table.mode} IN ('all','agents')`)
29081
29091
  // `content_locks_shape_check` lives in migration 0192 ONLY: it calls
29082
29092
  // content_lock_field_path_valid(), which that migration creates. Declared here it went into
29083
29093
  // `drizzle-kit push`'s CREATE TABLE on an empty database, where the function does not exist
@@ -29096,9 +29106,9 @@ import {
29096
29106
  varchar as varchar72,
29097
29107
  timestamp as timestamp89,
29098
29108
  index as index83,
29099
- uniqueIndex as uniqueIndex43
29109
+ uniqueIndex as uniqueIndex44
29100
29110
  } from "drizzle-orm/pg-core";
29101
- import { sql as sql29 } from "drizzle-orm";
29111
+ import { sql as sql30 } from "drizzle-orm";
29102
29112
  var projectTransfers = pgTable96(
29103
29113
  "project_transfers",
29104
29114
  {
@@ -29134,7 +29144,7 @@ var projectTransfers = pgTable96(
29134
29144
  (table) => [
29135
29145
  // At most one OPEN transfer per project. Partial-unique so completed/declined/
29136
29146
  // cancelled/expired/failed rows never wedge a re-initiation.
29137
- uniqueIndex43("project_transfers_one_pending_idx").on(table.projectId).where(sql29`${table.status} = 'pending'`),
29147
+ uniqueIndex44("project_transfers_one_pending_idx").on(table.projectId).where(sql30`${table.status} = 'pending'`),
29138
29148
  // Recipient inbox lookup (GET /me/transfers by email + status).
29139
29149
  index83("project_transfers_recipient_idx").on(
29140
29150
  table.recipientEmail,
@@ -29144,9 +29154,9 @@ var projectTransfers = pgTable96(
29144
29154
  index83("project_transfers_from_ws_idx").on(table.fromWorkspaceId),
29145
29155
  index83("project_transfers_project_idx").on(table.projectId),
29146
29156
  // Magic-link resolution.
29147
- uniqueIndex43("project_transfers_token_idx").on(table.token),
29157
+ uniqueIndex44("project_transfers_token_idx").on(table.token),
29148
29158
  // Expiry sweep — only pending rows are ever candidates.
29149
- index83("project_transfers_expires_idx").on(table.expiresAt).where(sql29`${table.status} = 'pending'`)
29159
+ index83("project_transfers_expires_idx").on(table.expiresAt).where(sql30`${table.status} = 'pending'`)
29150
29160
  ]
29151
29161
  );
29152
29162
 
@@ -29271,8 +29281,8 @@ var cloneLinks = pgTable99(
29271
29281
  );
29272
29282
 
29273
29283
  // src/schema/clone_jobs.ts
29274
- import { pgTable as pgTable100, text as text101, varchar as varchar75, integer as integer52, jsonb as jsonb58, timestamp as timestamp93, index as index87, uniqueIndex as uniqueIndex44 } from "drizzle-orm/pg-core";
29275
- import { sql as sql30 } from "drizzle-orm";
29284
+ import { pgTable as pgTable100, text as text101, varchar as varchar75, integer as integer52, jsonb as jsonb58, timestamp as timestamp93, index as index87, uniqueIndex as uniqueIndex45 } from "drizzle-orm/pg-core";
29285
+ import { sql as sql31 } from "drizzle-orm";
29276
29286
  var cloneJobs = pgTable100(
29277
29287
  "clone_jobs",
29278
29288
  {
@@ -29306,20 +29316,21 @@ var cloneJobs = pgTable100(
29306
29316
  index87("clone_jobs_workspace_idx").on(t.workspaceId),
29307
29317
  // One unfinished hybrid→headless switch per source (0343). The route maps its 23505 to
29308
29318
  // SWITCH_ALREADY_PENDING.
29309
- uniqueIndex44("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql30`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
29319
+ uniqueIndex45("clone_jobs_mode_switch_active_uniq").on(t.sourceProjectId).where(sql31`${t.purpose} = 'mode_switch' AND ${t.status} IN ('pending', 'working')`)
29310
29320
  ]
29311
29321
  );
29312
29322
 
29313
29323
  // src/schema/project_branches.ts
29314
29324
  import {
29325
+ primaryKey as primaryKey7,
29315
29326
  pgTable as pgTable101,
29316
29327
  text as text102,
29317
29328
  varchar as varchar76,
29318
29329
  timestamp as timestamp94,
29319
29330
  index as index88,
29320
- uniqueIndex as uniqueIndex45
29331
+ uniqueIndex as uniqueIndex46
29321
29332
  } from "drizzle-orm/pg-core";
29322
- import { sql as sql31 } from "drizzle-orm";
29333
+ import { sql as sql32 } from "drizzle-orm";
29323
29334
  var projectBranches = pgTable101(
29324
29335
  "project_branches",
29325
29336
  {
@@ -29332,16 +29343,33 @@ var projectBranches = pgTable101(
29332
29343
  status: varchar76("status", { length: 16 }).$type().notNull().default("open"),
29333
29344
  appliedAt: timestamp94("applied_at"),
29334
29345
  abandonedAt: timestamp94("abandoned_at"),
29346
+ /** Set while an Apply/Pull runs (0374); a second one is refused. Stale after five minutes. */
29347
+ applyingAt: timestamp94("applying_at"),
29335
29348
  ...auditColumns
29336
29349
  },
29337
29350
  (t) => [
29338
29351
  index88("project_branches_project_idx").on(t.projectId),
29339
- uniqueIndex45("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql31`${t.status} = 'open'`)
29352
+ uniqueIndex46("project_branches_project_slug_open_idx").on(t.projectId, t.slug).where(sql32`${t.status} = 'open'`)
29353
+ ]
29354
+ );
29355
+ var branchRowSyncs = pgTable101(
29356
+ "branch_row_syncs",
29357
+ {
29358
+ workspaceId: text102("workspace_id").notNull(),
29359
+ projectId: text102("project_id").notNull(),
29360
+ branchId: text102("branch_id").notNull(),
29361
+ kind: text102("kind").notNull(),
29362
+ parentRowId: text102("parent_row_id").notNull(),
29363
+ syncedAt: timestamp94("synced_at").notNull().defaultNow()
29364
+ },
29365
+ (t) => [
29366
+ primaryKey7({ columns: [t.branchId, t.kind, t.parentRowId] }),
29367
+ index88("branch_row_syncs_project_idx").on(t.projectId)
29340
29368
  ]
29341
29369
  );
29342
29370
 
29343
29371
  // src/schema/branch_preview_share.ts
29344
- import { pgTable as pgTable102, text as text103, boolean as boolean32, timestamp as timestamp95, index as index89, uniqueIndex as uniqueIndex46 } from "drizzle-orm/pg-core";
29372
+ import { pgTable as pgTable102, text as text103, boolean as boolean32, timestamp as timestamp95, index as index89, uniqueIndex as uniqueIndex47 } from "drizzle-orm/pg-core";
29345
29373
  var branchPreviewShares = pgTable102(
29346
29374
  "branch_preview_shares",
29347
29375
  {
@@ -29356,8 +29384,8 @@ var branchPreviewShares = pgTable102(
29356
29384
  updatedAt: timestamp95("updated_at").notNull().defaultNow()
29357
29385
  },
29358
29386
  (t) => [
29359
- uniqueIndex46("branch_preview_shares_branch_idx").on(t.branchId),
29360
- uniqueIndex46("branch_preview_shares_active_token_idx").on(t.publicToken),
29387
+ uniqueIndex47("branch_preview_shares_branch_idx").on(t.branchId),
29388
+ uniqueIndex47("branch_preview_shares_active_token_idx").on(t.publicToken),
29361
29389
  index89("branch_preview_shares_project_idx").on(t.projectId),
29362
29390
  index89("branch_preview_shares_workspace_idx").on(t.workspaceId)
29363
29391
  ]
@@ -29374,7 +29402,7 @@ var branchPreviewGrants = pgTable102(
29374
29402
  createdAt: timestamp95("created_at").notNull().defaultNow()
29375
29403
  },
29376
29404
  (t) => [
29377
- uniqueIndex46("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
29405
+ uniqueIndex47("branch_preview_grants_branch_email_idx").on(t.branchId, t.email),
29378
29406
  index89("branch_preview_grants_project_idx").on(t.projectId)
29379
29407
  ]
29380
29408
  );
@@ -29415,10 +29443,10 @@ import {
29415
29443
  jsonb as jsonb59,
29416
29444
  integer as integer53,
29417
29445
  index as index91,
29418
- uniqueIndex as uniqueIndex47
29446
+ uniqueIndex as uniqueIndex48
29419
29447
  } from "drizzle-orm/pg-core";
29420
29448
  import { relations as relations17 } from "drizzle-orm/relations";
29421
- import { sql as sql32 } from "drizzle-orm";
29449
+ import { sql as sql33 } from "drizzle-orm";
29422
29450
  var templates = pgTable104(
29423
29451
  "templates",
29424
29452
  {
@@ -29456,9 +29484,9 @@ var templates = pgTable104(
29456
29484
  index91("templates_workspace_idx").on(table.workspaceId),
29457
29485
  // Partial: only live rows. A soft-deleted template frees its slug (mirrors
29458
29486
  // components_ws_proj_slug_idx / migration 0114).
29459
- uniqueIndex47("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql32`${table.deletedAt} IS NULL`),
29487
+ uniqueIndex48("templates_ws_slug_idx").on(table.workspaceId, table.slug).where(sql33`${table.deletedAt} IS NULL`),
29460
29488
  // Public gallery scan (created_at DESC over live public rows).
29461
- index91("templates_public_idx").on(table.visibility).where(sql32`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
29489
+ index91("templates_public_idx").on(table.visibility).where(sql33`${table.visibility} = 'public' AND ${table.deletedAt} IS NULL`)
29462
29490
  ]
29463
29491
  );
29464
29492
  var templatesRelations = relations17(templates, ({ one }) => ({
@@ -29551,7 +29579,7 @@ var billingAddons = pgTable107(
29551
29579
  );
29552
29580
 
29553
29581
  // src/schema/billing_customers.ts
29554
- import { pgTable as pgTable108, text as text109, varchar as varchar80, timestamp as timestamp100, uniqueIndex as uniqueIndex48 } from "drizzle-orm/pg-core";
29582
+ import { pgTable as pgTable108, text as text109, varchar as varchar80, timestamp as timestamp100, uniqueIndex as uniqueIndex49 } from "drizzle-orm/pg-core";
29555
29583
  var billingCustomers = pgTable108(
29556
29584
  "billing_customers",
29557
29585
  {
@@ -29565,14 +29593,14 @@ var billingCustomers = pgTable108(
29565
29593
  updatedAt: timestamp100("updated_at").notNull().defaultNow()
29566
29594
  },
29567
29595
  (t) => [
29568
- uniqueIndex48("billing_customers_workspace_idx").on(t.workspaceId),
29569
- uniqueIndex48("billing_customers_dodo_idx").on(t.dodoCustomerId)
29596
+ uniqueIndex49("billing_customers_workspace_idx").on(t.workspaceId),
29597
+ uniqueIndex49("billing_customers_dodo_idx").on(t.dodoCustomerId)
29570
29598
  ]
29571
29599
  );
29572
29600
 
29573
29601
  // src/schema/subscriptions.ts
29574
- import { pgTable as pgTable109, text as text110, varchar as varchar81, boolean as boolean35, timestamp as timestamp101, index as index95, uniqueIndex as uniqueIndex49 } from "drizzle-orm/pg-core";
29575
- import { sql as sql33 } from "drizzle-orm";
29602
+ import { pgTable as pgTable109, text as text110, varchar as varchar81, boolean as boolean35, timestamp as timestamp101, index as index95, uniqueIndex as uniqueIndex50 } from "drizzle-orm/pg-core";
29603
+ import { sql as sql34 } from "drizzle-orm";
29576
29604
  var subscriptions = pgTable109(
29577
29605
  "subscriptions",
29578
29606
  {
@@ -29599,17 +29627,17 @@ var subscriptions = pgTable109(
29599
29627
  },
29600
29628
  (t) => [
29601
29629
  index95("subscriptions_workspace_idx").on(t.workspaceId),
29602
- uniqueIndex49("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql33`${t.dodoSubscriptionId} IS NOT NULL`),
29630
+ uniqueIndex50("subscriptions_dodo_idx").on(t.dodoSubscriptionId).where(sql34`${t.dodoSubscriptionId} IS NOT NULL`),
29603
29631
  // At most one workspace-level subscription per workspace.
29604
- uniqueIndex49("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql33`${t.projectId} IS NULL`),
29632
+ uniqueIndex50("subscriptions_workspace_plan_unique").on(t.workspaceId).where(sql34`${t.projectId} IS NULL`),
29605
29633
  // At most one subscription per site.
29606
- uniqueIndex49("subscriptions_project_unique").on(t.projectId).where(sql33`${t.projectId} IS NOT NULL`)
29634
+ uniqueIndex50("subscriptions_project_unique").on(t.projectId).where(sql34`${t.projectId} IS NOT NULL`)
29607
29635
  ]
29608
29636
  );
29609
29637
 
29610
29638
  // src/schema/subscription_addons.ts
29611
- import { pgTable as pgTable110, text as text111, varchar as varchar82, integer as integer56, timestamp as timestamp102, index as index96, uniqueIndex as uniqueIndex50 } from "drizzle-orm/pg-core";
29612
- import { sql as sql34 } from "drizzle-orm";
29639
+ import { pgTable as pgTable110, text as text111, varchar as varchar82, integer as integer56, timestamp as timestamp102, index as index96, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
29640
+ import { sql as sql35 } from "drizzle-orm";
29613
29641
  var subscriptionAddons = pgTable110(
29614
29642
  "subscription_addons",
29615
29643
  {
@@ -29629,12 +29657,12 @@ var subscriptionAddons = pgTable110(
29629
29657
  },
29630
29658
  (t) => [
29631
29659
  index96("subscription_addons_workspace_idx").on(t.workspaceId),
29632
- uniqueIndex50("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql34`${t.dodoSubscriptionId} IS NOT NULL`)
29660
+ uniqueIndex51("subscription_addons_dodo_idx").on(t.dodoSubscriptionId).where(sql35`${t.dodoSubscriptionId} IS NOT NULL`)
29633
29661
  ]
29634
29662
  );
29635
29663
 
29636
29664
  // src/schema/billing_alerts.ts
29637
- import { pgTable as pgTable111, text as text112, varchar as varchar83, timestamp as timestamp103, index as index97, uniqueIndex as uniqueIndex51 } from "drizzle-orm/pg-core";
29665
+ import { pgTable as pgTable111, text as text112, varchar as varchar83, timestamp as timestamp103, index as index97, uniqueIndex as uniqueIndex52 } from "drizzle-orm/pg-core";
29638
29666
  var billingAlerts = pgTable111(
29639
29667
  "billing_alerts",
29640
29668
  {
@@ -29654,14 +29682,14 @@ var billingAlerts = pgTable111(
29654
29682
  sentAt: timestamp103("sent_at", { withTimezone: true }).notNull().defaultNow()
29655
29683
  },
29656
29684
  (t) => [
29657
- uniqueIndex51("billing_alerts_dedupe_idx").on(t.dedupeKey),
29685
+ uniqueIndex52("billing_alerts_dedupe_idx").on(t.dedupeKey),
29658
29686
  index97("billing_alerts_workspace_idx").on(t.workspaceId, t.sentAt)
29659
29687
  ]
29660
29688
  );
29661
29689
 
29662
29690
  // src/schema/ai_credit_ledger.ts
29663
- import { pgTable as pgTable112, text as text113, varchar as varchar84, integer as integer57, timestamp as timestamp104, index as index98, uniqueIndex as uniqueIndex52 } from "drizzle-orm/pg-core";
29664
- import { sql as sql35 } from "drizzle-orm";
29691
+ import { pgTable as pgTable112, text as text113, varchar as varchar84, integer as integer57, timestamp as timestamp104, index as index98, uniqueIndex as uniqueIndex53 } from "drizzle-orm/pg-core";
29692
+ import { sql as sql36 } from "drizzle-orm";
29665
29693
  var aiCreditLedger = pgTable112(
29666
29694
  "ai_credit_ledger",
29667
29695
  {
@@ -29680,7 +29708,7 @@ var aiCreditLedger = pgTable112(
29680
29708
  },
29681
29709
  (t) => [
29682
29710
  index98("ai_credit_ledger_workspace_idx").on(t.workspaceId, t.createdAt),
29683
- uniqueIndex52("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql35`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
29711
+ uniqueIndex53("ai_credit_ledger_custom_agent_run_unique").on(t.note).where(sql36`${t.reason} = 'consume' AND ${t.note} LIKE 'custom-agent-run:%'`)
29684
29712
  ]
29685
29713
  );
29686
29714
 
@@ -29889,7 +29917,7 @@ import {
29889
29917
  varchar as varchar90,
29890
29918
  timestamp as timestamp110,
29891
29919
  index as index104,
29892
- uniqueIndex as uniqueIndex53
29920
+ uniqueIndex as uniqueIndex54
29893
29921
  } from "drizzle-orm/pg-core";
29894
29922
  var ENV_VAR_SCOPES = ["production", "preview", "development"];
29895
29923
  var projectEnvVars = pgTable118(
@@ -29912,7 +29940,7 @@ var projectEnvVars = pgTable118(
29912
29940
  },
29913
29941
  (table) => [
29914
29942
  // One value per key per scope — the same key MAY exist in production and preview.
29915
- uniqueIndex53("project_env_vars_project_key_scope_idx").on(
29943
+ uniqueIndex54("project_env_vars_project_key_scope_idx").on(
29916
29944
  table.projectId,
29917
29945
  table.key,
29918
29946
  table.scope
@@ -29922,8 +29950,8 @@ var projectEnvVars = pgTable118(
29922
29950
  );
29923
29951
 
29924
29952
  // src/schema/mcp_connections.ts
29925
- import { pgTable as pgTable119, text as text120, varchar as varchar91, jsonb as jsonb63, timestamp as timestamp111, index as index105, uniqueIndex as uniqueIndex54 } from "drizzle-orm/pg-core";
29926
- import { sql as sql36 } from "drizzle-orm";
29953
+ import { pgTable as pgTable119, text as text120, varchar as varchar91, jsonb as jsonb63, timestamp as timestamp111, index as index105, uniqueIndex as uniqueIndex55 } from "drizzle-orm/pg-core";
29954
+ import { sql as sql37 } from "drizzle-orm";
29927
29955
  var mcpConnections = pgTable119(
29928
29956
  "mcp_connections",
29929
29957
  {
@@ -29986,7 +30014,7 @@ var mcpConnections = pgTable119(
29986
30014
  index105("mcp_connections_project_idx").on(t.projectId),
29987
30015
  // Reconnecting a catalog provider UPDATEs rather than accumulating a second live credential.
29988
30016
  // Custom connectors are excluded: a project may legitimately add many distinct MCP servers.
29989
- uniqueIndex54("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql36`deleted_at IS NULL AND provider_slug <> 'custom'`)
30017
+ uniqueIndex55("mcp_connections_project_provider_unique").on(t.projectId, t.providerSlug).where(sql37`deleted_at IS NULL AND provider_slug <> 'custom'`)
29990
30018
  ]
29991
30019
  );
29992
30020
 
@@ -29998,7 +30026,7 @@ import {
29998
30026
  boolean as boolean38,
29999
30027
  jsonb as jsonb64,
30000
30028
  integer as integer59,
30001
- uniqueIndex as uniqueIndex55
30029
+ uniqueIndex as uniqueIndex56
30002
30030
  } from "drizzle-orm/pg-core";
30003
30031
  var crmConnections = pgTable120(
30004
30032
  "crm_connections",
@@ -30018,7 +30046,7 @@ var crmConnections = pgTable120(
30018
30046
  updatedAt: timestamp112("updated_at").notNull().defaultNow()
30019
30047
  },
30020
30048
  (t) => [
30021
- uniqueIndex55("crm_connection_account_uq").on(
30049
+ uniqueIndex56("crm_connection_account_uq").on(
30022
30050
  t.workspaceId,
30023
30051
  t.provider,
30024
30052
  t.accountId
@@ -30056,7 +30084,7 @@ var formIntegrationDeliveries = pgTable120(
30056
30084
  updatedAt: timestamp112("updated_at").notNull().defaultNow()
30057
30085
  },
30058
30086
  (t) => [
30059
- uniqueIndex55("crm_delivery_event_uq").on(
30087
+ uniqueIndex56("crm_delivery_event_uq").on(
30060
30088
  t.workspaceId,
30061
30089
  t.eventId,
30062
30090
  t.integrationId
@@ -30064,6 +30092,109 @@ var formIntegrationDeliveries = pgTable120(
30064
30092
  ]
30065
30093
  );
30066
30094
 
30095
+ // src/schema/platform_incidents.ts
30096
+ import { check as check12, integer as integer60, pgTable as pgTable121, smallint as smallint2, text as text122, timestamp as timestamp113, index as index106 } from "drizzle-orm/pg-core";
30097
+ import { sql as sql38 } from "drizzle-orm";
30098
+ var STATUS_IN = sql38.raw("('investigating', 'identified', 'monitoring', 'resolved')");
30099
+ var platformIncidents = pgTable121(
30100
+ "platform_incidents",
30101
+ {
30102
+ id: text122("id").primaryKey(),
30103
+ number: integer60("number").generatedAlwaysAsIdentity().notNull().unique("platform_incidents_number_key"),
30104
+ title: text122("title").notNull(),
30105
+ severity: smallint2("severity").notNull(),
30106
+ // 1 (worst) … 4
30107
+ status: text122("status").notNull().default("investigating"),
30108
+ // investigating | identified | monitoring | resolved
30109
+ services: text122("services").array().notNull().default([]),
30110
+ commanderId: text122("commander_id"),
30111
+ startedAt: timestamp113("started_at", { withTimezone: true }).notNull().defaultNow(),
30112
+ resolvedAt: timestamp113("resolved_at", { withTimezone: true }),
30113
+ createdBy: text122("created_by"),
30114
+ createdAt: timestamp113("created_at", { withTimezone: true }).notNull().defaultNow(),
30115
+ updatedAt: timestamp113("updated_at", { withTimezone: true }).notNull().defaultNow()
30116
+ },
30117
+ // Mirrors 0375 exactly: drizzle-kit push builds fresh DBs before the migration runs.
30118
+ (t) => [
30119
+ index106("platform_incidents_started_idx").on(t.startedAt.desc()),
30120
+ check12("platform_incidents_severity_check", sql38`${t.severity} BETWEEN 1 AND 4`),
30121
+ check12("platform_incidents_status_check", sql38`${t.status} IN ${STATUS_IN}`)
30122
+ ]
30123
+ );
30124
+ var platformIncidentUpdates = pgTable121(
30125
+ "platform_incident_updates",
30126
+ {
30127
+ id: text122("id").primaryKey(),
30128
+ incidentId: text122("incident_id").notNull().references(() => platformIncidents.id, { onDelete: "cascade" }),
30129
+ status: text122("status").notNull(),
30130
+ note: text122("note").notNull(),
30131
+ createdBy: text122("created_by"),
30132
+ createdAt: timestamp113("created_at", { withTimezone: true }).notNull().defaultNow()
30133
+ },
30134
+ (t) => [
30135
+ index106("platform_incident_updates_incident_idx").on(t.incidentId, t.createdAt),
30136
+ check12("platform_incident_updates_status_check", sql38`${t.status} IN ${STATUS_IN}`)
30137
+ ]
30138
+ );
30139
+
30140
+ // src/schema/platform_vendors.ts
30141
+ import { date as date3, integer as integer61, pgTable as pgTable122, text as text123, timestamp as timestamp114, varchar as varchar92 } from "drizzle-orm/pg-core";
30142
+ var platformVendors = pgTable122("platform_vendors", {
30143
+ id: text123("id").primaryKey(),
30144
+ name: text123("name").notNull(),
30145
+ category: text123("category").notNull(),
30146
+ billingCycle: text123("billing_cycle").notNull().default("monthly"),
30147
+ // monthly | yearly | usage
30148
+ monthlyCents: integer61("monthly_cents").notNull().default(0),
30149
+ // normalised monthly cost
30150
+ currency: varchar92("currency", { length: 3 }).notNull().default("usd"),
30151
+ renewsOn: date3("renews_on"),
30152
+ // YYYY-MM-DD
30153
+ status: text123("status").notNull().default("active"),
30154
+ // active | trial | cancelling | unused
30155
+ ownerEmail: text123("owner_email"),
30156
+ notes: text123("notes"),
30157
+ createdBy: text123("created_by"),
30158
+ createdAt: timestamp114("created_at", { withTimezone: true }).notNull().defaultNow(),
30159
+ updatedAt: timestamp114("updated_at", { withTimezone: true }).notNull().defaultNow()
30160
+ });
30161
+
30162
+ // src/schema/platform_tasks.ts
30163
+ import { check as check13, date as date4, pgTable as pgTable123, text as text124, timestamp as timestamp115, index as index107 } from "drizzle-orm/pg-core";
30164
+ import { sql as sql39 } from "drizzle-orm";
30165
+ var platformTasks = pgTable123(
30166
+ "platform_tasks",
30167
+ {
30168
+ id: text124("id").primaryKey(),
30169
+ title: text124("title").notNull(),
30170
+ description: text124("description"),
30171
+ status: text124("status").notNull().default("open"),
30172
+ // open | in_progress | done
30173
+ priority: text124("priority").notNull().default("medium"),
30174
+ // low | medium | high | urgent
30175
+ assigneeId: text124("assignee_id"),
30176
+ dueOn: date4("due_on"),
30177
+ // YYYY-MM-DD
30178
+ entityType: text124("entity_type"),
30179
+ // user | workspace | incident | deal
30180
+ entityId: text124("entity_id"),
30181
+ entityLabel: text124("entity_label"),
30182
+ completedAt: timestamp115("completed_at", { withTimezone: true }),
30183
+ createdBy: text124("created_by"),
30184
+ createdAt: timestamp115("created_at", { withTimezone: true }).notNull().defaultNow(),
30185
+ updatedAt: timestamp115("updated_at", { withTimezone: true }).notNull().defaultNow()
30186
+ },
30187
+ // Mirrors 0377 exactly: drizzle-kit push builds fresh DBs before the migration runs.
30188
+ (t) => [
30189
+ index107("platform_tasks_open_idx").on(t.status, t.dueOn),
30190
+ index107("platform_tasks_entity_idx").on(t.entityType, t.entityId),
30191
+ check13("platform_tasks_status_check", sql39`${t.status} IN ('open', 'in_progress', 'done')`),
30192
+ check13("platform_tasks_priority_check", sql39`${t.priority} IN ('low', 'medium', 'high', 'urgent')`),
30193
+ check13("platform_tasks_entity_type_check", sql39`${t.entityType} IN ('user', 'workspace', 'incident', 'deal')`),
30194
+ check13("platform_tasks_entity_pair_check", sql39`(${t.entityType} IS NULL) = (${t.entityId} IS NULL)`)
30195
+ ]
30196
+ );
30197
+
30067
30198
  // src/lib/request-context.ts
30068
30199
  import { AsyncLocalStorage } from "async_hooks";
30069
30200
  import { drizzle } from "drizzle-orm/postgres-js";
@@ -30128,7 +30259,7 @@ async function reserveWithDeadline() {
30128
30259
  })
30129
30260
  ]);
30130
30261
  } catch (err) {
30131
- void pending.then((sql38) => sql38.release()).catch((cause) => console.error("[db-pool] orphaned acquire failed:", cause));
30262
+ void pending.then((sql41) => sql41.release()).catch((cause) => console.error("[db-pool] orphaned acquire failed:", cause));
30132
30263
  throw err;
30133
30264
  } finally {
30134
30265
  clearTimeout(timer);
@@ -30338,7 +30469,7 @@ var queries = {
30338
30469
  };
30339
30470
 
30340
30471
  // src/lib/workspace-context.ts
30341
- import { sql as sql37 } from "drizzle-orm";
30472
+ import { sql as sql40 } from "drizzle-orm";
30342
30473
  import { eq as eq2 } from "drizzle-orm";
30343
30474
  import { nanoid } from "nanoid";
30344
30475
  var writeOrigins = new Set(WRITE_ORIGINS);
@@ -30372,7 +30503,7 @@ async function getWorkspaceSlugById(workspaceId) {
30372
30503
  }
30373
30504
  async function lookupApiKeyByHash(keyHash) {
30374
30505
  const rows = await db.execute(
30375
- sql37`SELECT * FROM lookup_api_key_by_hash(${keyHash})`
30506
+ sql40`SELECT * FROM lookup_api_key_by_hash(${keyHash})`
30376
30507
  );
30377
30508
  const r = rows[0];
30378
30509
  if (!r) return null;
@@ -30403,7 +30534,7 @@ async function lookupApiKeyByHash(keyHash) {
30403
30534
  }
30404
30535
  async function publicWorkspaceBySlug(slug) {
30405
30536
  const rows = await db.execute(
30406
- sql37`SELECT id, slug FROM public_workspace_by_slug(${slug})`
30537
+ sql40`SELECT id, slug FROM public_workspace_by_slug(${slug})`
30407
30538
  );
30408
30539
  const r = rows[0];
30409
30540
  return r?.id ? { id: r.id, slug: r.slug ?? slug } : null;
@@ -30413,7 +30544,7 @@ async function getDefaultWorkspaceId(userId) {
30413
30544
  return row?.id ?? null;
30414
30545
  }
30415
30546
  async function resolveUserWorkspace(userId, workspaceId) {
30416
- const rows = await db.execute(sql37`
30547
+ const rows = await db.execute(sql40`
30417
30548
  SELECT workspace_id, role
30418
30549
  FROM resolve_user_workspace(${userId}, ${workspaceId ?? null})
30419
30550
  `);
@@ -30449,7 +30580,7 @@ async function ensureDefaultWorkspace(userId, name = "My Workspace", slug) {
30449
30580
  for (let attempt = 1; attempt <= MAX_SLUG_ATTEMPTS; attempt++) {
30450
30581
  console.log("[ensureDefaultWorkspace] Creating workspace + owner membership:", { workspaceId, slug: candidateSlug, attempt });
30451
30582
  try {
30452
- await db.execute(sql37`
30583
+ await db.execute(sql40`
30453
30584
  SELECT create_default_workspace(${workspaceId}, ${userId}, ${memberId}, ${name}, ${candidateSlug})
30454
30585
  `);
30455
30586
  console.log("[ensureDefaultWorkspace] Workspace + owner membership created with slug:", candidateSlug);
@@ -30656,6 +30787,7 @@ export {
30656
30787
  branchColumns,
30657
30788
  branchPreviewGrants,
30658
30789
  branchPreviewShares,
30790
+ branchRowSyncs,
30659
30791
  brandKitVersions,
30660
30792
  buildTriggerRuns,
30661
30793
  buildTriggers,
@@ -30770,6 +30902,10 @@ export {
30770
30902
  pendingInvites,
30771
30903
  planChanges,
30772
30904
  planLimits,
30905
+ platformIncidentUpdates,
30906
+ platformIncidents,
30907
+ platformTasks,
30908
+ platformVendors,
30773
30909
  poolStats,
30774
30910
  previewTokenRevocations,
30775
30911
  projectBranches,