gencow 0.1.222 → 0.1.223

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.
@@ -17,6 +17,7 @@ import {
17
17
  import { pollAppDeleteOperation } from "./app-delete-operation.mjs";
18
18
  import { appResponseError } from "./app-response-error.mjs";
19
19
  import { readJsonObjectResponse, readJsonValueResponse } from "./http-response-json.mjs";
20
+ import { runWithAbortDeadline } from "./request-deadline.mjs";
20
21
  import { BOLD, CYAN, DIM, GREEN, RED, RESET, error, info, log, success, warn } from "./output.mjs";
21
22
  import { loadCreds, rpcMutation, rpcQuery, saveCreds, requireCreds } from "./platform-client.mjs";
22
23
  import { resolveProjectMetadataPath, resolveProjectSelection } from "./project-context.mjs";
@@ -27,6 +28,7 @@ import { updateEnvLocalUrl } from "./cli-project-runtime.mjs";
27
28
  const DEFAULT_DELETE_POLL_ATTEMPTS = 120;
28
29
  const DELETE_POLL_INTERVAL_MS = 1_000;
29
30
  const DEFAULT_APP_CREATE_TIMEOUT_MS = 60_000;
31
+ const DEFAULT_APP_DELETE_REQUEST_TIMEOUT_MS = 20_000;
30
32
 
31
33
  function resolveAppCreateTimeoutMs(value) {
32
34
  const parsed = Number(value);
@@ -35,6 +37,13 @@ function resolveAppCreateTimeoutMs(value) {
35
37
  : DEFAULT_APP_CREATE_TIMEOUT_MS;
36
38
  }
37
39
 
40
+ function resolveAppDeleteRequestTimeoutMs(value) {
41
+ const parsed = Number(value);
42
+ return Number.isSafeInteger(parsed) && parsed >= 100 && parsed <= 600_000
43
+ ? parsed
44
+ : DEFAULT_APP_DELETE_REQUEST_TIMEOUT_MS;
45
+ }
46
+
38
47
  function appResponseStatus(response) {
39
48
  return Number.isSafeInteger(response?.status) ? `HTTP ${response.status}` : "unknown HTTP status";
40
49
  }
@@ -137,6 +146,9 @@ async function confirmDelete(name) {
137
146
 
138
147
  export function createAppCommand({
139
148
  appCreateTimeoutMs = resolveAppCreateTimeoutMs(process.env.GENCOW_APP_CREATE_TIMEOUT_MS),
149
+ appDeleteRequestTimeoutMs = resolveAppDeleteRequestTimeoutMs(
150
+ process.env.GENCOW_APP_DELETE_REQUEST_TIMEOUT_MS,
151
+ ),
140
152
  clearTimeoutImpl = clearTimeout,
141
153
  confirmDeleteImpl = confirmDelete,
142
154
  createAbortControllerImpl = () => new AbortController(),
@@ -159,28 +171,38 @@ export function createAppCommand({
159
171
  warnImpl = warn,
160
172
  }) {
161
173
  const boundedAppCreateTimeoutMs = resolveAppCreateTimeoutMs(appCreateTimeoutMs);
174
+ const boundedAppDeleteRequestTimeoutMs = resolveAppDeleteRequestTimeoutMs(appDeleteRequestTimeoutMs);
162
175
 
163
176
  async function requestAppCreate(creds, name) {
164
- const controller = createAbortControllerImpl();
165
177
  const timeoutError = new Error(
166
178
  `App creation request timed out after ${boundedAppCreateTimeoutMs}ms. Please try again.`,
167
179
  );
168
- let timeoutHandle;
169
- const timeoutPromise = new Promise((_resolve, reject) => {
170
- timeoutHandle = setTimeoutImpl(() => {
171
- controller.abort(timeoutError);
172
- reject(timeoutError);
173
- }, boundedAppCreateTimeoutMs);
180
+ return runWithAbortDeadline({
181
+ clearTimeoutImpl,
182
+ createAbortControllerImpl,
183
+ request: async (signal) => {
184
+ const response = await rpcMutationImpl(creds, "apps.create", { name }, { signal });
185
+ return { response, data: await readJsonObjectResponse(response) };
186
+ },
187
+ setTimeoutImpl,
188
+ timeoutError,
189
+ timeoutMs: boundedAppCreateTimeoutMs,
174
190
  });
175
- try {
176
- const request = (async () => {
177
- const response = await rpcMutationImpl(creds, "apps.create", { name }, { signal: controller.signal });
191
+ }
192
+
193
+ async function requestAppDelete(creds, name, requestId) {
194
+ const timeoutError = new Error("App deletion request timed out");
195
+ return runWithAbortDeadline({
196
+ clearTimeoutImpl,
197
+ createAbortControllerImpl,
198
+ request: async (signal) => {
199
+ const response = await rpcMutationImpl(creds, "apps.delete", { name, requestId }, { signal });
178
200
  return { response, data: await readJsonObjectResponse(response) };
179
- })();
180
- return await Promise.race([request, timeoutPromise]);
181
- } finally {
182
- clearTimeoutImpl(timeoutHandle);
183
- }
201
+ },
202
+ setTimeoutImpl,
203
+ timeoutError,
204
+ timeoutMs: boundedAppDeleteRequestTimeoutMs,
205
+ });
184
206
  }
185
207
 
186
208
  return async function app(subcmd, ...rest) {
@@ -342,8 +364,16 @@ ${dashboardLine}
342
364
 
343
365
  infoImpl(`Deleting app "${name}"...`);
344
366
  const requestId = createDeleteRequestIdImpl();
345
- const delRes = await rpcMutationImpl(creds, "apps.delete", { name, requestId });
346
- let delData = await readJsonObjectResponse(delRes);
367
+ let delRes;
368
+ let delData;
369
+ try {
370
+ ({ response: delRes, data: delData } = await requestAppDelete(creds, name, requestId));
371
+ } catch {
372
+ errorImpl(
373
+ "App deletion request did not complete. Its operation outcome is unknown; retry the same app delete to inspect it.\nCode: APP_DELETE_REQUEST_UNAVAILABLE",
374
+ );
375
+ return 1;
376
+ }
347
377
  if (!isExactAppDeleteResponse(delData, name)) {
348
378
  const operationResult = await pollAppDeleteOperation({
349
379
  creds,
@@ -1,6 +1,7 @@
1
1
  import { isExactAppDeleteResponse } from "./app-response-contract.mjs";
2
2
  import { APP_DELETE_OPERATION_PATTERN } from "./app-response-error.mjs";
3
3
  import { readJsonObjectResponse } from "./http-response-json.mjs";
4
+ import { runWithAbortDeadline } from "./request-deadline.mjs";
4
5
 
5
6
  const APP_DELETE_ACTIVE_STATES = new Set([
6
7
  "accepted",
@@ -26,6 +27,38 @@ const APP_DELETE_RESPONSE_STATES = new Set([
26
27
  const CORRELATION_ID_PATTERN = /^[A-Za-z0-9_-]{8,128}$/u;
27
28
  const DIAGNOSTIC_CODE_PATTERN = /^[A-Za-z][A-Za-z0-9_]{2,127}$/u;
28
29
  const APP_ID_PATTERN = /^(?=.{3,63}$)[a-z][a-z0-9]*(?:-[a-z0-9]+){2,7}$/u;
30
+ const DEFAULT_DELETE_OPERATION_TIMEOUT_MS = 120_000;
31
+ const DEFAULT_DELETE_STATUS_REQUEST_TIMEOUT_MS = 10_000;
32
+
33
+ function resolveTimeoutMs(value, fallback) {
34
+ const parsed = Number(value);
35
+ return Number.isSafeInteger(parsed) && parsed >= 1 && parsed <= 600_000 ? parsed : fallback;
36
+ }
37
+
38
+ async function requestDeleteStatus({
39
+ clearTimeoutImpl,
40
+ createAbortControllerImpl,
41
+ creds,
42
+ name,
43
+ operationId,
44
+ requestTimeoutMs,
45
+ rpcQueryImpl,
46
+ setTimeoutImpl,
47
+ }) {
48
+ const timeoutError = new Error("App deletion status request timed out");
49
+ timeoutError.name = "AbortError";
50
+ return runWithAbortDeadline({
51
+ clearTimeoutImpl,
52
+ createAbortControllerImpl,
53
+ request: async (signal) => {
54
+ const statusRes = await rpcQueryImpl(creds, "apps.deleteStatus", { name, operationId }, { signal });
55
+ return { statusRes, statusData: await readJsonObjectResponse(statusRes) };
56
+ },
57
+ setTimeoutImpl,
58
+ timeoutError,
59
+ timeoutMs: requestTimeoutMs,
60
+ });
61
+ }
29
62
 
30
63
  function isAllowedStatusPath(value, operationId, expectedAppId) {
31
64
  if (value === undefined) return true;
@@ -104,12 +137,18 @@ function isMatchingTerminalFailureResponse(value, accepted, expectedAppId) {
104
137
  }
105
138
 
106
139
  export async function pollAppDeleteOperation({
140
+ clearTimeoutImpl = clearTimeout,
141
+ createAbortControllerImpl = () => new AbortController(),
107
142
  creds,
108
143
  initialBody,
109
144
  name,
145
+ nowImpl = Date.now,
146
+ operationTimeoutMs = DEFAULT_DELETE_OPERATION_TIMEOUT_MS,
110
147
  pollAttempts,
111
148
  pollIntervalMs,
149
+ requestTimeoutMs = DEFAULT_DELETE_STATUS_REQUEST_TIMEOUT_MS,
112
150
  rpcQueryImpl,
151
+ setTimeoutImpl = setTimeout,
113
152
  sleepImpl,
114
153
  }) {
115
154
  const accepted = parseAppDeleteOperationEnvelope(initialBody, name);
@@ -121,13 +160,25 @@ export async function pollAppDeleteOperation({
121
160
  let latest = accepted;
122
161
  let successfulPollResponses = 0;
123
162
  let transportFailures = 0;
163
+ const deadlineAt = nowImpl() + resolveTimeoutMs(operationTimeoutMs, DEFAULT_DELETE_OPERATION_TIMEOUT_MS);
164
+ const boundedRequestTimeoutMs = resolveTimeoutMs(
165
+ requestTimeoutMs,
166
+ DEFAULT_DELETE_STATUS_REQUEST_TIMEOUT_MS,
167
+ );
124
168
  for (let attempt = 0; attempt < pollAttempts; attempt += 1) {
169
+ const remainingMs = deadlineAt - nowImpl();
170
+ if (remainingMs <= 0) break;
125
171
  try {
126
- const statusRes = await rpcQueryImpl(creds, "apps.deleteStatus", {
172
+ const { statusData, statusRes } = await requestDeleteStatus({
173
+ clearTimeoutImpl,
174
+ createAbortControllerImpl,
175
+ creds,
127
176
  name,
128
177
  operationId: accepted.operationId,
178
+ requestTimeoutMs: Math.min(boundedRequestTimeoutMs, remainingMs),
179
+ rpcQueryImpl,
180
+ setTimeoutImpl,
129
181
  });
130
- const statusData = await readJsonObjectResponse(statusRes);
131
182
  // A lifecycle operation is durable. A transient 5xx while the status
132
183
  // query is being served must not turn that durable receipt into a client
133
184
  // contract failure or abandon the operation's correlation identity.
@@ -157,7 +208,10 @@ export async function pollAppDeleteOperation({
157
208
  transportFailures += 1;
158
209
  // The durable receipt remains authoritative across transient polling failures.
159
210
  }
160
- if (attempt + 1 < pollAttempts) await sleepImpl(pollIntervalMs);
211
+ if (attempt + 1 < pollAttempts) {
212
+ const remainingAfterRequestMs = deadlineAt - nowImpl();
213
+ if (remainingAfterRequestMs > 0) await sleepImpl(Math.min(pollIntervalMs, remainingAfterRequestMs));
214
+ }
161
215
  }
162
216
 
163
217
  const pollingUnavailable = successfulPollResponses === 0 && transportFailures > 0;
@@ -96,10 +96,11 @@ export async function platformFetch(creds, path, opts = {}) {
96
96
  });
97
97
  }
98
98
 
99
- export async function rpcQuery(creds, queryName, args = {}) {
99
+ export async function rpcQuery(creds, queryName, args = {}, requestOptions = {}) {
100
100
  return platformFetch(creds, "/api/query", {
101
+ ...requestOptions,
101
102
  method: "POST",
102
- headers: { "Content-Type": "application/json" },
103
+ headers: { ...requestOptions.headers, "Content-Type": "application/json" },
103
104
  body: JSON.stringify({ name: queryName, args }),
104
105
  });
105
106
  }
@@ -0,0 +1,22 @@
1
+ export async function runWithAbortDeadline({
2
+ clearTimeoutImpl = clearTimeout,
3
+ createAbortControllerImpl = () => new AbortController(),
4
+ request,
5
+ setTimeoutImpl = setTimeout,
6
+ timeoutError,
7
+ timeoutMs,
8
+ }) {
9
+ const controller = createAbortControllerImpl();
10
+ let timeoutHandle;
11
+ const deadline = new Promise((_resolve, reject) => {
12
+ timeoutHandle = setTimeoutImpl(() => {
13
+ controller.abort(timeoutError);
14
+ reject(timeoutError);
15
+ }, timeoutMs);
16
+ });
17
+ try {
18
+ return await Promise.race([request(controller.signal), deadline]);
19
+ } finally {
20
+ clearTimeoutImpl(timeoutHandle);
21
+ }
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gencow",
3
- "version": "0.1.222",
3
+ "version": "0.1.223",
4
4
  "description": "Gencow — AI Backend Engine",
5
5
  "type": "module",
6
6
  "bin": {
@@ -6640,17 +6640,17 @@ var require_compose_node = __commonJS({
6640
6640
  return node;
6641
6641
  }
6642
6642
  function composeAlias({ options }, { offset, source, end }, onError) {
6643
- const alias = new Alias.Alias(source.substring(1));
6644
- if (alias.source === "")
6643
+ const alias2 = new Alias.Alias(source.substring(1));
6644
+ if (alias2.source === "")
6645
6645
  onError(offset, "BAD_ALIAS", "Alias cannot be an empty string");
6646
- if (alias.source.endsWith(":"))
6646
+ if (alias2.source.endsWith(":"))
6647
6647
  onError(offset + source.length - 1, "BAD_ALIAS", "Alias ending in : is ambiguous", true);
6648
6648
  const valueEnd = offset + source.length;
6649
6649
  const re3 = resolveEnd.resolveEnd(end, valueEnd, options.strict, onError);
6650
- alias.range = [offset, valueEnd, re3.offset];
6650
+ alias2.range = [offset, valueEnd, re3.offset];
6651
6651
  if (re3.comment)
6652
- alias.comment = re3.comment;
6653
- return alias;
6652
+ alias2.comment = re3.comment;
6653
+ return alias2;
6654
6654
  }
6655
6655
  exports2.composeEmptyNode = composeEmptyNode;
6656
6656
  exports2.composeNode = composeNode;
@@ -143454,8 +143454,8 @@ var require_ALIASADD = __commonJS({
143454
143454
  exports2.default = {
143455
143455
  NOT_KEYED_COMMAND: true,
143456
143456
  IS_READ_ONLY: true,
143457
- parseCommand(parser, alias, index22) {
143458
- parser.push("FT.ALIASADD", alias, index22);
143457
+ parseCommand(parser, alias2, index22) {
143458
+ parser.push("FT.ALIASADD", alias2, index22);
143459
143459
  },
143460
143460
  transformReply: void 0
143461
143461
  };
@@ -143470,8 +143470,8 @@ var require_ALIASDEL = __commonJS({
143470
143470
  exports2.default = {
143471
143471
  NOT_KEYED_COMMAND: true,
143472
143472
  IS_READ_ONLY: true,
143473
- parseCommand(parser, alias) {
143474
- parser.push("FT.ALIASDEL", alias);
143473
+ parseCommand(parser, alias2) {
143474
+ parser.push("FT.ALIASDEL", alias2);
143475
143475
  },
143476
143476
  transformReply: void 0
143477
143477
  };
@@ -143486,8 +143486,8 @@ var require_ALIASUPDATE = __commonJS({
143486
143486
  exports2.default = {
143487
143487
  NOT_KEYED_COMMAND: true,
143488
143488
  IS_READ_ONLY: true,
143489
- parseCommand(parser, alias, index22) {
143490
- parser.push("FT.ALIASUPDATE", alias, index22);
143489
+ parseCommand(parser, alias2, index22) {
143490
+ parser.push("FT.ALIASUPDATE", alias2, index22);
143491
143491
  },
143492
143492
  transformReply: void 0
143493
143493
  };
@@ -184543,6 +184543,7 @@ var init_deployment_candidate_failure = __esm({
184543
184543
  "BACKEND_CAPABILITY_EMPTY",
184544
184544
  "BACKEND_CAPABILITY_MISMATCH",
184545
184545
  "APP_DEPENDENCY_INSTALL_FAILED",
184546
+ "APP_DEPENDENCY_INSTALL_TIMEOUT",
184546
184547
  "CANDIDATE_PREPARATION_FAILED",
184547
184548
  "RUNTIME_CANDIDATE_MODULE_RESOLUTION_FAILED",
184548
184549
  "RUNTIME_CANDIDATE_PORT_BIND_FAILED",
@@ -184711,6 +184712,12 @@ function resolveGenericDeploymentFailurePolicy(input) {
184711
184712
  userAction: "EDIT_AND_CHECK"
184712
184713
  };
184713
184714
  }
184715
+ if (code === "APP_DEPENDENCY_INSTALL_TIMEOUT") {
184716
+ return retry(
184717
+ code,
184718
+ "Platform dependency installer timed out before runtime activation; retry the same deployment"
184719
+ );
184720
+ }
184714
184721
  if (code === "APP_DEPENDENCY_INSTALL_FAILED") {
184715
184722
  return retry(
184716
184723
  code,
@@ -186232,7 +186239,8 @@ var init_app_release_store = __esm({
186232
186239
  });
186233
186240
 
186234
186241
  // ../platform/src/deployment-executor-store.ts
186235
- import { and as and14, asc as asc3, eq as eq17, gt as gt4, inArray as inArray8, lte as lte4, or as or7, sql as sql70 } from "drizzle-orm";
186242
+ import { and as and14, asc as asc3, eq as eq17, gt as gt4, inArray as inArray8, lte as lte4, ne as ne8, notExists, or as or7, sql as sql70 } from "drizzle-orm";
186243
+ import { alias } from "drizzle-orm/pg-core";
186236
186244
  function attemptConditions(attempt) {
186237
186245
  return and14(
186238
186246
  eq17(deployments.id, attempt.deploymentId),
@@ -187008,7 +187016,7 @@ var init_deployment_executor_http_presentation = __esm({
187008
187016
 
187009
187017
  // ../platform/src/app-delete-operation-store.ts
187010
187018
  import { createHash as createHash42 } from "node:crypto";
187011
- import { and as and16, desc as desc6, eq as eq19, inArray as inArray9, lt as lt5, lte as lte5, notExists, or as or8, sql as sql71 } from "drizzle-orm";
187019
+ import { and as and16, desc as desc6, eq as eq19, inArray as inArray9, lt as lt5, lte as lte5, notExists as notExists2, or as or8, sql as sql71 } from "drizzle-orm";
187012
187020
  function isAppDeleteTerminalState(state2) {
187013
187021
  return APP_DELETE_TERMINAL_STATES.includes(state2);
187014
187022
  }
@@ -251698,8 +251706,8 @@ ${lanes.join("\n")}
251698
251706
  }
251699
251707
  const propertyAccessRequire = (_e2 = symbol2.declarations) == null ? void 0 : _e2.find(isPropertyAccessExpression);
251700
251708
  if (propertyAccessRequire && isBinaryExpression(propertyAccessRequire.parent) && isIdentifier2(propertyAccessRequire.parent.right) && ((_f = type.symbol) == null ? void 0 : _f.valueDeclaration) && isSourceFile(type.symbol.valueDeclaration)) {
251701
- const alias = localName === propertyAccessRequire.parent.right.escapedText ? void 0 : propertyAccessRequire.parent.right;
251702
- context2.approximateLength += 12 + (((_g = alias == null ? void 0 : alias.escapedText) == null ? void 0 : _g.length) ?? 0);
251709
+ const alias2 = localName === propertyAccessRequire.parent.right.escapedText ? void 0 : propertyAccessRequire.parent.right;
251710
+ context2.approximateLength += 12 + (((_g = alias2 == null ? void 0 : alias2.escapedText) == null ? void 0 : _g.length) ?? 0);
251703
251711
  addResult(
251704
251712
  factory.createExportDeclaration(
251705
251713
  /*modifiers*/
@@ -251709,7 +251717,7 @@ ${lanes.join("\n")}
251709
251717
  factory.createNamedExports([factory.createExportSpecifier(
251710
251718
  /*isTypeOnly*/
251711
251719
  false,
251712
- alias,
251720
+ alias2,
251713
251721
  localName
251714
251722
  )])
251715
251723
  ),
@@ -274630,8 +274638,8 @@ ${lanes.join("\n")}
274630
274638
  return candidateName;
274631
274639
  }
274632
274640
  if (candidate.flags & 2097152) {
274633
- const alias = tryResolveAlias(candidate);
274634
- if (alias && alias.flags & meaning) {
274641
+ const alias2 = tryResolveAlias(candidate);
274642
+ if (alias2 && alias2.flags & meaning) {
274635
274643
  return candidateName;
274636
274644
  }
274637
274645
  }
@@ -297493,10 +297501,10 @@ ${lanes.join("\n")}
297493
297501
  )
297494
297502
  ));
297495
297503
  }
297496
- const alias = getClassLexicalEnvironment().classConstructor;
297497
- if (isClassWithConstructorReference && alias) {
297504
+ const alias2 = getClassLexicalEnvironment().classConstructor;
297505
+ if (isClassWithConstructorReference && alias2) {
297498
297506
  enableSubstitutionForClassAliases();
297499
- classAliases[getOriginalNodeId(node)] = alias;
297507
+ classAliases[getOriginalNodeId(node)] = alias2;
297500
297508
  }
297501
297509
  const classDecl = factory2.updateClassDeclaration(
297502
297510
  node,
@@ -297587,9 +297595,9 @@ ${lanes.join("\n")}
297587
297595
  temp ?? (temp = createClassTempVar());
297588
297596
  if (isClassWithConstructorReference) {
297589
297597
  enableSubstitutionForClassAliases();
297590
- const alias = factory2.cloneNode(temp);
297591
- alias.emitNode.autoGenerate.flags &= ~8;
297592
- classAliases[getOriginalNodeId(node)] = alias;
297598
+ const alias2 = factory2.cloneNode(temp);
297599
+ alias2.emitNode.autoGenerate.flags &= ~8;
297600
+ classAliases[getOriginalNodeId(node)] = alias2;
297593
297601
  }
297594
297602
  expressions.push(factory2.createAssignment(temp, classExpression));
297595
297603
  addRange(expressions, pendingExpressions);
@@ -378134,7 +378142,7 @@ ${content}
378134
378142
  }
378135
378143
  return modifiers.size > 0 ? arrayFrom(modifiers.values()).join(",") : "";
378136
378144
  }
378137
- function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol2, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias, maximumLength, verbosityLevel) {
378145
+ function getSymbolDisplayPartsDocumentationAndSymbolKindWorker(typeChecker, symbol2, sourceFile, enclosingDeclaration, location, type, semanticMeaning, alias2, maximumLength, verbosityLevel) {
378138
378146
  var _a3;
378139
378147
  const displayParts = [];
378140
378148
  let documentation = [];
@@ -378754,7 +378762,7 @@ ${content}
378754
378762
  addAliasPrefixIfNecessary();
378755
378763
  }
378756
378764
  function addAliasPrefixIfNecessary() {
378757
- if (alias) {
378765
+ if (alias2) {
378758
378766
  pushSymbolKind(
378759
378767
  "alias"
378760
378768
  /* alias */
@@ -378829,8 +378837,8 @@ ${content}
378829
378837
  }
378830
378838
  function addFullSymbolName(symbolToDisplay, enclosingDeclaration2) {
378831
378839
  let indexInfos;
378832
- if (alias && symbolToDisplay === symbol2) {
378833
- symbolToDisplay = alias;
378840
+ if (alias2 && symbolToDisplay === symbol2) {
378841
+ symbolToDisplay = alias2;
378834
378842
  }
378835
378843
  if (symbolKind === "index") {
378836
378844
  indexInfos = typeChecker.getIndexInfosOfIndexSymbol(symbolToDisplay);
@@ -378951,7 +378959,7 @@ ${content}
378951
378959
  addRange(displayParts, typeParameterParts);
378952
378960
  }
378953
378961
  }
378954
- function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol2, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias, maximumLength, verbosityLevel) {
378962
+ function getSymbolDisplayPartsDocumentationAndSymbolKind(typeChecker, symbol2, sourceFile, enclosingDeclaration, location, semanticMeaning = getMeaningFromLocation(location), alias2, maximumLength, verbosityLevel) {
378955
378963
  return getSymbolDisplayPartsDocumentationAndSymbolKindWorker(
378956
378964
  typeChecker,
378957
378965
  symbol2,
@@ -378961,7 +378969,7 @@ ${content}
378961
378969
  /*type*/
378962
378970
  void 0,
378963
378971
  semanticMeaning,
378964
- alias,
378972
+ alias2,
378965
378973
  maximumLength,
378966
378974
  verbosityLevel
378967
378975
  );
@@ -402301,10 +402309,10 @@ var init_runner_session_log_store = __esm({
402301
402309
  );
402302
402310
  }
402303
402311
  if (!this.isCurrent(appName, session2)) return false;
402304
- for (const [alias, activeSession] of this.active) {
402312
+ for (const [alias2, activeSession] of this.active) {
402305
402313
  if (activeSession.sessionId !== session2.sessionId) continue;
402306
- this.active.delete(alias);
402307
- this.last.set(alias, session2);
402314
+ this.active.delete(alias2);
402315
+ this.last.set(alias2, session2);
402308
402316
  }
402309
402317
  return true;
402310
402318
  }
@@ -404871,10 +404879,10 @@ var init_bun_runner = __esm({
404871
404879
  appendLog(appName, `process exited with code ${code}`, session2.sessionId);
404872
404880
  processes.delete(appName);
404873
404881
  processIdentities.delete(appName);
404874
- for (const [alias, activeSession] of sessions2) {
404882
+ for (const [alias2, activeSession] of sessions2) {
404875
404883
  if (activeSession.sessionId !== session2.sessionId) continue;
404876
- sessions2.delete(alias);
404877
- lastSessions.set(alias, session2);
404884
+ sessions2.delete(alias2);
404885
+ lastSessions.set(alias2, session2);
404878
404886
  }
404879
404887
  const cb2 = exitCallbacks3.get(appName);
404880
404888
  if (cb2) {
@@ -407688,6 +407696,16 @@ function classifyDependencyInstallFailure(output) {
407688
407696
  function redactDependencyInstallOutput(output) {
407689
407697
  return output.replace(/https?:\/\/[^\s"']+/giu, "[url]").replace(/\b(token|password|secret|authorization)\s*[=:]\s*[^\s"']+/giu, "$1=[redacted]").replace(/\/(?:Users|home|opt|tmp|var)\/[^\s:"']+/gu, "[path]");
407690
407698
  }
407699
+ function terminateDependencyInstallProcessGroup(processId) {
407700
+ if (!Number.isSafeInteger(processId) || processId <= 1) return;
407701
+ try {
407702
+ process.kill(-processId, "SIGKILL");
407703
+ } catch (error51) {
407704
+ if (!(error51 instanceof Error) || !/ESRCH/u.test(String(error51.code))) {
407705
+ throw error51;
407706
+ }
407707
+ }
407708
+ }
407691
407709
  async function readBoundedDependencyInstallOutput(stream) {
407692
407710
  if (!stream || typeof stream !== "object" || !("getReader" in stream)) return "";
407693
407711
  const reader = stream.getReader();
@@ -407708,10 +407726,26 @@ async function readBoundedDependencyInstallOutput(stream) {
407708
407726
  return redactDependencyInstallOutput(new TextDecoder().decode(captured));
407709
407727
  }
407710
407728
  async function runAppDependencyInstaller(input) {
407711
- let child;
407729
+ const installTimeoutMs = input.timeoutMs ?? 6e4;
407730
+ const timeoutSignal = AbortSignal.timeout(installTimeoutMs);
407731
+ const signal = input.signal ? AbortSignal.any([input.signal, timeoutSignal]) : timeoutSignal;
407732
+ let timedOut = timeoutSignal.aborted;
407733
+ let cancelled = input.signal?.aborted ?? false;
407734
+ const onTimeout = () => {
407735
+ timedOut = true;
407736
+ if (child) terminateDependencyInstallProcessGroup(child.pid);
407737
+ };
407738
+ const onAbort = () => {
407739
+ cancelled = true;
407740
+ if (child) terminateDependencyInstallProcessGroup(child.pid);
407741
+ };
407742
+ let child = null;
407743
+ timeoutSignal.addEventListener("abort", onTimeout, { once: true });
407744
+ input.signal?.addEventListener("abort", onAbort, { once: true });
407712
407745
  try {
407713
407746
  child = Bun.spawn(
407714
407747
  [
407748
+ DEPENDENCY_INSTALL_SESSION_COMMAND,
407715
407749
  "pnpm",
407716
407750
  "install",
407717
407751
  "--prod",
@@ -407726,34 +407760,23 @@ async function runAppDependencyInstaller(input) {
407726
407760
  }
407727
407761
  );
407728
407762
  } catch {
407763
+ timeoutSignal.removeEventListener("abort", onTimeout);
407764
+ input.signal?.removeEventListener("abort", onAbort);
407729
407765
  throw new AppDependencyInstallError("spawn_failed");
407730
407766
  }
407731
- let timedOut = false;
407732
- let cancelled = input.signal?.aborted ?? false;
407733
- let forceKill;
407734
- const stop = () => {
407735
- child.kill("SIGTERM");
407736
- forceKill ??= setTimeout(() => child.kill("SIGKILL"), 2e3);
407737
- };
407738
- const timeout = setTimeout(() => {
407739
- timedOut = true;
407740
- stop();
407741
- }, input.timeoutMs ?? 6e4);
407742
407767
  const progress = setInterval(() => input.onProgress?.("dependency_install_running"), 1e4);
407743
- const onAbort = () => {
407744
- cancelled = true;
407745
- stop();
407746
- };
407747
- input.signal?.addEventListener("abort", onAbort, { once: true });
407748
- if (cancelled) stop();
407768
+ if (signal.aborted) {
407769
+ if (timeoutSignal.aborted) timedOut = true;
407770
+ if (input.signal?.aborted) cancelled = true;
407771
+ terminateDependencyInstallProcessGroup(child.pid);
407772
+ }
407749
407773
  const output = Promise.all([
407750
407774
  readBoundedDependencyInstallOutput(child.stdout).catch(() => ""),
407751
407775
  readBoundedDependencyInstallOutput(child.stderr).catch(() => "")
407752
407776
  ]).then((parts) => parts.join("\n"));
407753
407777
  const exitCode = await child.exited.finally(() => {
407754
- clearTimeout(timeout);
407755
407778
  clearInterval(progress);
407756
- if (forceKill) clearTimeout(forceKill);
407779
+ timeoutSignal.removeEventListener("abort", onTimeout);
407757
407780
  input.signal?.removeEventListener("abort", onAbort);
407758
407781
  });
407759
407782
  const diagnosticOutput = await output;
@@ -407764,11 +407787,12 @@ async function runAppDependencyInstaller(input) {
407764
407787
  throw new AppDependencyInstallError(classifyDependencyInstallFailure(diagnosticOutput), exitCode);
407765
407788
  }
407766
407789
  }
407767
- var DEPENDENCY_INSTALL_OUTPUT_LIMIT_BYTES, AppDependencyInstallError;
407790
+ var DEPENDENCY_INSTALL_OUTPUT_LIMIT_BYTES, DEPENDENCY_INSTALL_SESSION_COMMAND, AppDependencyInstallError;
407768
407791
  var init_app_dependency_installer = __esm({
407769
407792
  "../platform/src/app-dependency-installer.ts"() {
407770
407793
  "use strict";
407771
407794
  DEPENDENCY_INSTALL_OUTPUT_LIMIT_BYTES = 32 * 1024;
407795
+ DEPENDENCY_INSTALL_SESSION_COMMAND = "setsid";
407772
407796
  AppDependencyInstallError = class extends Error {
407773
407797
  constructor(reason, exitCode = null, signalCode = null) {
407774
407798
  super("APP_DEPENDENCY_INSTALL_FAILED");
@@ -407776,11 +407800,12 @@ var init_app_dependency_installer = __esm({
407776
407800
  this.exitCode = exitCode;
407777
407801
  this.signalCode = signalCode;
407778
407802
  this.name = "AppDependencyInstallError";
407803
+ this.code = reason === "timed_out" ? "APP_DEPENDENCY_INSTALL_TIMEOUT" : "APP_DEPENDENCY_INSTALL_FAILED";
407779
407804
  }
407780
407805
  reason;
407781
407806
  exitCode;
407782
407807
  signalCode;
407783
- code = "APP_DEPENDENCY_INSTALL_FAILED";
407808
+ code;
407784
407809
  };
407785
407810
  }
407786
407811
  });
@@ -412279,10 +412304,10 @@ import { resolve as resolve93 } from "path";
412279
412304
  function isRecord7(value) {
412280
412305
  return !!value && typeof value === "object" && !Array.isArray(value);
412281
412306
  }
412282
- function shouldDropDeployWorkspaceAlias(alias, targets) {
412283
- if (alias === "gencow" || alias.startsWith("gencow/")) return true;
412284
- if (alias === "drizzle-orm" || alias.startsWith("drizzle-orm/")) return true;
412285
- if (alias === "@gencow" || alias.startsWith("@gencow/")) return true;
412307
+ function shouldDropDeployWorkspaceAlias(alias2, targets) {
412308
+ if (alias2 === "gencow" || alias2.startsWith("gencow/")) return true;
412309
+ if (alias2 === "drizzle-orm" || alias2.startsWith("drizzle-orm/")) return true;
412310
+ if (alias2 === "@gencow" || alias2.startsWith("@gencow/")) return true;
412286
412311
  const targetList = Array.isArray(targets) ? targets : [];
412287
412312
  return targetList.some((target) => {
412288
412313
  if (typeof target !== "string") return false;
@@ -412306,7 +412331,7 @@ function buildDrizzleRuntimeTsconfig(existingTsconfigText) {
412306
412331
  };
412307
412332
  const sourcePaths = isRecord7(sourceCompilerOptions.paths) ? sourceCompilerOptions.paths : {};
412308
412333
  const paths = Object.fromEntries(
412309
- Object.entries(sourcePaths).filter(([alias, targets]) => !shouldDropDeployWorkspaceAlias(alias, targets))
412334
+ Object.entries(sourcePaths).filter(([alias2, targets]) => !shouldDropDeployWorkspaceAlias(alias2, targets))
412310
412335
  );
412311
412336
  if (Object.keys(paths).length > 0) {
412312
412337
  compilerOptions.paths = paths;
@@ -413942,7 +413967,7 @@ __export(provisioner_exports, {
413942
413967
  import { randomUUID as randomUUID28 } from "node:crypto";
413943
413968
  import { resolve as resolve99, dirname as dirname25 } from "path";
413944
413969
  import { fileURLToPath as fileURLToPath8 } from "url";
413945
- import { and as and23, desc as desc10, eq as eq27, ne as ne8 } from "drizzle-orm";
413970
+ import { and as and23, desc as desc10, eq as eq27, ne as ne9 } from "drizzle-orm";
413946
413971
  function setDatabasePreflightRawSql(rawSql) {
413947
413972
  configureDatabasePreflightRawSql(rawSql);
413948
413973
  }
@@ -414583,7 +414608,7 @@ async function checkRuntimeCompatibilityForStart(params) {
414583
414608
  and23(
414584
414609
  eq27(deployments.appId, params.appDbId),
414585
414610
  eq27(deployments.status, "running"),
414586
- ne8(deployments.env, "static")
414611
+ ne9(deployments.env, "static")
414587
414612
  )
414588
414613
  ).orderBy(desc10(deployments.deployedAt)).limit(1);
414589
414614
  }
@@ -416390,7 +416415,7 @@ var init_candidate_failure_reconciliation = __esm({
416390
416415
  });
416391
416416
 
416392
416417
  // ../platform/src/route-activation-adapter.ts
416393
- import { and as and26, eq as eq30, inArray as inArray15, ne as ne9, sql as sql84 } from "drizzle-orm";
416418
+ import { and as and26, eq as eq30, inArray as inArray15, ne as ne10, sql as sql84 } from "drizzle-orm";
416394
416419
  function fail17(code) {
416395
416420
  throw new Error(code);
416396
416421
  }
@@ -416510,7 +416535,7 @@ async function applyCommittedActivationRoute(input) {
416510
416535
  and26(
416511
416536
  eq30(deployments.appId, input.committed.appId),
416512
416537
  eq30(deployments.env, input.committed.environment),
416513
- ne9(deployments.id, input.committed.deploymentId),
416538
+ ne10(deployments.id, input.committed.deploymentId),
416514
416539
  inArray15(deployments.status, ["running", "success"])
416515
416540
  )
416516
416541
  );
@@ -416719,7 +416744,7 @@ var init_runtime_desired_state_bootstrap = __esm({
416719
416744
  });
416720
416745
 
416721
416746
  // ../platform/src/runtime-candidate-cleanup.ts
416722
- import { and as and27, eq as eq31, inArray as inArray16, isNull as isNull8, ne as ne10, or as or10, sql as sql85 } from "drizzle-orm";
416747
+ import { and as and27, eq as eq31, inArray as inArray16, isNull as isNull8, ne as ne11, or as or10, sql as sql85 } from "drizzle-orm";
416723
416748
  import { createConnection as createConnection2 } from "node:net";
416724
416749
  function incompleteCandidatePredicate() {
416725
416750
  return or10(
@@ -416967,7 +416992,7 @@ async function assertNoIncompleteRuntimeCandidateCleanup(input) {
416967
416992
  ).where(
416968
416993
  and27(
416969
416994
  eq31(appRuntimeInstances.appId, input.appId),
416970
- input.allowedActivationId ? ne10(appRuntimeInstances.activationId, input.allowedActivationId) : void 0,
416995
+ input.allowedActivationId ? ne11(appRuntimeInstances.activationId, input.allowedActivationId) : void 0,
416971
416996
  incompleteCandidatePredicate()
416972
416997
  )
416973
416998
  ).limit(1);
@@ -422704,7 +422729,7 @@ var init_runtime_crash_recovery_store = __esm({
422704
422729
 
422705
422730
  // ../platform/src/runtime-absence-proof-store.ts
422706
422731
  import { createHash as createHash74, randomUUID as randomUUID32 } from "node:crypto";
422707
- import { and as and44, eq as eq48, isNull as isNull18, ne as ne11 } from "drizzle-orm";
422732
+ import { and as and44, eq as eq48, isNull as isNull18, ne as ne12 } from "drizzle-orm";
422708
422733
  function hash4(value) {
422709
422734
  return createHash74("sha256").update(JSON.stringify(value)).digest("hex");
422710
422735
  }
@@ -422738,7 +422763,7 @@ async function claimRuntimeAbsenceObservation(input) {
422738
422763
  and44(
422739
422764
  eq48(runtimeLifecycleRemediations.appId, input.appId),
422740
422765
  eq48(runtimeLifecycleRemediations.code, RUNTIME_ABSENCE_PROOF_REMEDIATION_CODE),
422741
- ne11(runtimeLifecycleRemediations.evidenceHash, evidenceHash),
422766
+ ne12(runtimeLifecycleRemediations.evidenceHash, evidenceHash),
422742
422767
  isNull18(runtimeLifecycleRemediations.resolvedAt)
422743
422768
  )
422744
422769
  );
@@ -425165,8 +425190,8 @@ function cowboxSupervisorMatchesCandidate(input) {
425165
425190
  const command = input.readFile(`/proc/${input.pid}/cmdline`).split("\0").filter(Boolean);
425166
425191
  const executable = input.readLink(`/proc/${input.pid}/exe`);
425167
425192
  const expectedAppDir = `/var/gencow/deployments/.control-plane/generations/v1/${sourceMatch[1]}/workspace`;
425168
- const expectedTmpDir = `/tmp/gcp-${input.candidate.instanceId.replace(/^instance_/u, "instance-")}`;
425169
- return processParentId(input.readFile(`/proc/${input.pid}/stat`)) === 1 && COWBOX_EXECUTABLE.test(executable) && command[0] === executable && command.includes(`APP_DIR=${expectedAppDir}`) && command.includes(`APP_PORT=${input.candidate.port}`) && command.includes(`TMP_DIR=${expectedTmpDir}`);
425193
+ const expectedTmpDir = `/tmp/${input.appName}`;
425194
+ return COWBOX_EXECUTABLE.test(executable) && command[0] === executable && command.includes(`APP_DIR=${expectedAppDir}`) && command.includes(`APP_PORT=${input.candidate.port}`) && command.includes(`TMP_DIR=${expectedTmpDir}`);
425170
425195
  }
425171
425196
  async function stopExactUnrecordedCandidateCgroup(input) {
425172
425197
  const port = input.candidate.port;
@@ -425207,6 +425232,7 @@ async function stopExactUnrecordedCandidateCgroup(input) {
425207
425232
  (pid) => !Number.isSafeInteger(pid) || (pid === cgroupLeaderPid ? !cowboxSupervisorMatchesCandidate({
425208
425233
  pid,
425209
425234
  cgroupLeaderPid,
425235
+ appName: input.appName,
425210
425236
  candidate: input.candidate,
425211
425237
  readFile: readFile10,
425212
425238
  readLink
@@ -429379,7 +429405,7 @@ var init_app_delete_terminal_evidence = __esm({
429379
429405
  });
429380
429406
 
429381
429407
  // ../platform/src/app-delete-catalog-finalizer.ts
429382
- import { and as and74, eq as eq79, gt as gt17, inArray as inArray45, isNotNull as isNotNull7, ne as ne12, or as or20, sql as sql110 } from "drizzle-orm";
429408
+ import { and as and74, eq as eq79, gt as gt17, inArray as inArray45, isNotNull as isNotNull7, ne as ne13, or as or20, sql as sql110 } from "drizzle-orm";
429383
429409
  var init_app_delete_catalog_finalizer = __esm({
429384
429410
  "../platform/src/app-delete-catalog-finalizer.ts"() {
429385
429411
  "use strict";
@@ -429399,7 +429425,7 @@ var init_app_delete_operation_controller = __esm({
429399
429425
  });
429400
429426
 
429401
429427
  // ../platform/src/app-delete-preconditions.ts
429402
- import { and as and75, eq as eq80, gt as gt18, inArray as inArray46, isNotNull as isNotNull8, isNull as isNull31, ne as ne13 } from "drizzle-orm";
429428
+ import { and as and75, eq as eq80, gt as gt18, inArray as inArray46, isNotNull as isNotNull8, isNull as isNull31, ne as ne14 } from "drizzle-orm";
429403
429429
  var init_app_delete_preconditions = __esm({
429404
429430
  "../platform/src/app-delete-preconditions.ts"() {
429405
429431
  "use strict";