@camstack/server 1.2.722 → 1.2.723

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.
@@ -25803,6 +25803,65 @@ var CrashSupervisor = class {
25803
25803
  }
25804
25804
  };
25805
25805
  //#endregion
25806
+ //#region src/kernel/moleculer/failed-runner-retry.ts
25807
+ /**
25808
+ * One retry for a runner the crash breaker parked as `failed`, when the package
25809
+ * it hosts changed version (#346).
25810
+ *
25811
+ * The D6 breaker is terminal on purpose. But a runner that tripped because its
25812
+ * package was stale for the server (an update landed before the addon's new
25813
+ * version) is not broken for good: the reconcile that follows installs the
25814
+ * version that works. The ledger remembers the package versions at the moment
25815
+ * of the trip and allows ONE restart when the versions on disk differ. The
25816
+ * restart consumes the snapshot, so a runner that trips again records a fresh
25817
+ * one and needs another version change: one retry per new version, never a loop.
25818
+ */
25819
+ var FailedRunnerRetryLedger = class {
25820
+ atTrip = /* @__PURE__ */ new Map();
25821
+ /** The breaker tripped for `runnerId`; remember what it was running. */
25822
+ recordTrip(runnerId, versions) {
25823
+ this.atTrip.set(runnerId, versions);
25824
+ }
25825
+ /**
25826
+ * Is a restart owed for `runnerId`, given the versions now on disk? An
25827
+ * unreadable current version is never a change (a failed read changes
25828
+ * nothing). A positive answer consumes the snapshot.
25829
+ */
25830
+ decide(runnerId, current) {
25831
+ const from = this.atTrip.get(runnerId);
25832
+ if (from === void 0) return {
25833
+ retry: false,
25834
+ reason: "no-trip-recorded"
25835
+ };
25836
+ if (!Object.entries(current).some(([dir, version]) => version !== null && version !== from[dir])) return {
25837
+ retry: false,
25838
+ reason: "version-unchanged"
25839
+ };
25840
+ this.atTrip.delete(runnerId);
25841
+ return {
25842
+ retry: true,
25843
+ from,
25844
+ to: current
25845
+ };
25846
+ }
25847
+ /** Forget a runner (stop / operator restart). */
25848
+ forget(runnerId) {
25849
+ this.atTrip.delete(runnerId);
25850
+ }
25851
+ };
25852
+ /** The package.json version of each addon dir; `null` when unreadable. */
25853
+ function readRunnerPackageVersions(addonDirs) {
25854
+ const out = {};
25855
+ for (const dir of addonDirs) try {
25856
+ const raw = JSON.parse(node_fs.readFileSync(node_path.join(dir, "package.json"), "utf-8"));
25857
+ const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
25858
+ out[dir] = typeof version === "string" && version.length > 0 ? version : null;
25859
+ } catch {
25860
+ out[dir] = null;
25861
+ }
25862
+ return out;
25863
+ }
25864
+ //#endregion
25806
25865
  //#region src/kernel/moleculer/runner-heap-flags.ts
25807
25866
  var EMPTY_HEAP_DECLARATION = {
25808
25867
  profile: void 0,
@@ -26441,6 +26500,7 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26441
26500
  maxCrashes: MAX_CRASHES_IN_WINDOW,
26442
26501
  maxBackoffMs: MAX_BACKOFF_MS
26443
26502
  });
26503
+ const failedRetryLedger = new FailedRunnerRetryLedger();
26444
26504
  let capturedBroker = null;
26445
26505
  function buildNodeId(name) {
26446
26506
  return `${parentNodeId}/${name}`;
@@ -26651,6 +26711,7 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26651
26711
  });
26652
26712
  if (decision.action === "failed") {
26653
26713
  entry.state = "failed";
26714
+ failedRetryLedger.recordTrip(runnerId, readRunnerPackageVersions(entry.runnerAddons.map((a) => a.addonDir)));
26654
26715
  emitStateChange(entry);
26655
26716
  capturedBroker?.logger.error(`[${runnerId}] Crash circuit-breaker tripped — ${decision.crashesInWindow} crashes in ${CRASH_WINDOW_MS}ms. Not respawning.`);
26656
26717
  processes.set(runnerId, entry);
@@ -26738,6 +26799,7 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26738
26799
  }
26739
26800
  await reapRunnerGroup(target);
26740
26801
  processes.delete(name);
26802
+ failedRetryLedger.forget(name);
26741
26803
  crashSupervisor.reset(name);
26742
26804
  forceMoleculerDisconnect(ctx.broker, deadNodeId);
26743
26805
  return { success: true };
@@ -26786,6 +26848,23 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26786
26848
  };
26787
26849
  });
26788
26850
  } },
26851
+ /**
26852
+ * Restart every runner the breaker parked `failed` whose package changed
26853
+ * version since it tripped (#346) — once per new version, never a loop.
26854
+ * Called by the agent after a reconcile delivered bytes.
26855
+ */
26856
+ retryFailedOnVersionChange: { async handler(ctx) {
26857
+ const retried = [];
26858
+ for (const entry of [...processes.values()]) {
26859
+ if (entry.state !== "failed") continue;
26860
+ const decision = failedRetryLedger.decide(entry.name, readRunnerPackageVersions(entry.runnerAddons.map((a) => a.addonDir)));
26861
+ if (!decision.retry) continue;
26862
+ capturedBroker?.logger.warn(`[${entry.name}] package version changed since the crash breaker tripped — retrying once (${JSON.stringify(decision.from)} -> ${JSON.stringify(decision.to)})`, { tags: { runnerId: entry.name } });
26863
+ await ctx.call("$process.restart", { name: entry.name });
26864
+ retried.push(entry.name);
26865
+ }
26866
+ return { retried };
26867
+ } },
26789
26868
  list: { async handler() {
26790
26869
  const entries = [...processes.values(), ...backingOff.values()];
26791
26870
  const stats = await getPidStats$1(entries.filter((p) => p.pid > 0).map((p) => p.pid));
@@ -39,7 +39,7 @@ import { C as isModelDownloaded, E as setHuggingFaceReachabilityObserver, T as r
39
39
  import { A as retirePreviousLocalCa, C as checkUploadedCa, D as loadTlsCert, E as ensureTlsCert, F as closeLanHttp, I as readLanHttpState, L as registerLanHttpHandler, M as allFamiliesListenHost, N as applyLanHttp, O as reissueTlsLeaf, P as bindPendingLanHttp, S as chainsToPublicRoot, T as caReplacementMarkerFile, _ as readTlsMode, a as storeUploadedCertificate, b as writeTlsEnabled, c as leafFingerprintOf, d as servedHttpsLeafFingerprint, f as prepareBootTls, g as readTlsEnabled, h as readTlsAccessStatus, i as revertToGeneratedCertificate, j as DEFAULT_LAN_HTTP_PORT, k as replaceUnconstrainedLocalCa, l as registerHttpsListener, m as readExtraSans, n as applyCertificateToListener, o as useStoredUploadedCertificate, p as UPLOADED_CA_FILE, r as regenerateCertificate, s as clearHttpsListener, t as createCiaoPublisher, u as reloadHttpsListener, v as splitPemCertificates, w as validateUploadedTls, x as writeTlsMode, y as writeExtraSans } from "./hub-mdns-ciao-Czz2ssit.mjs";
40
40
  import { n as getPlatformKeychainKey, r as setPlatformKeychainKey, t as clearPlatformKeychainKey } from "./platform-key-source-BWlq0jjn.mjs";
41
41
  import { n as getSinglePidStats, t as getPidStats } from "./resource-monitor-Di9daRwI.mjs";
42
- import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-DS4nvQ43.mjs";
42
+ import { _ as backupRecordStoresOf, c as BackupDecryptError, f as generateBackupKeyPair, g as backupOrchestratorRecordKinds, h as readBackupEncryptionHeader, l as BackupKeyFormatError, r as prepareRestoreArchive, s as SystemBackupService, t as BackupKeyRequiredError, u as BackupKeyMismatchError } from "./restore-archive-B-SaKSVW.mjs";
43
43
  import { r as nodeCoralFs, t as classifyCoralAccelerator } from "./coral-accelerators-DBlgWB8k.mjs";
44
44
  import { z } from "zod";
45
45
  import * as crypto$1 from "node:crypto";
@@ -25800,6 +25800,65 @@ var CrashSupervisor = class {
25800
25800
  }
25801
25801
  };
25802
25802
  //#endregion
25803
+ //#region src/kernel/moleculer/failed-runner-retry.ts
25804
+ /**
25805
+ * One retry for a runner the crash breaker parked as `failed`, when the package
25806
+ * it hosts changed version (#346).
25807
+ *
25808
+ * The D6 breaker is terminal on purpose. But a runner that tripped because its
25809
+ * package was stale for the server (an update landed before the addon's new
25810
+ * version) is not broken for good: the reconcile that follows installs the
25811
+ * version that works. The ledger remembers the package versions at the moment
25812
+ * of the trip and allows ONE restart when the versions on disk differ. The
25813
+ * restart consumes the snapshot, so a runner that trips again records a fresh
25814
+ * one and needs another version change: one retry per new version, never a loop.
25815
+ */
25816
+ var FailedRunnerRetryLedger = class {
25817
+ atTrip = /* @__PURE__ */ new Map();
25818
+ /** The breaker tripped for `runnerId`; remember what it was running. */
25819
+ recordTrip(runnerId, versions) {
25820
+ this.atTrip.set(runnerId, versions);
25821
+ }
25822
+ /**
25823
+ * Is a restart owed for `runnerId`, given the versions now on disk? An
25824
+ * unreadable current version is never a change (a failed read changes
25825
+ * nothing). A positive answer consumes the snapshot.
25826
+ */
25827
+ decide(runnerId, current) {
25828
+ const from = this.atTrip.get(runnerId);
25829
+ if (from === void 0) return {
25830
+ retry: false,
25831
+ reason: "no-trip-recorded"
25832
+ };
25833
+ if (!Object.entries(current).some(([dir, version]) => version !== null && version !== from[dir])) return {
25834
+ retry: false,
25835
+ reason: "version-unchanged"
25836
+ };
25837
+ this.atTrip.delete(runnerId);
25838
+ return {
25839
+ retry: true,
25840
+ from,
25841
+ to: current
25842
+ };
25843
+ }
25844
+ /** Forget a runner (stop / operator restart). */
25845
+ forget(runnerId) {
25846
+ this.atTrip.delete(runnerId);
25847
+ }
25848
+ };
25849
+ /** The package.json version of each addon dir; `null` when unreadable. */
25850
+ function readRunnerPackageVersions(addonDirs) {
25851
+ const out = {};
25852
+ for (const dir of addonDirs) try {
25853
+ const raw = JSON.parse(fs$1.readFileSync(path$1.join(dir, "package.json"), "utf-8"));
25854
+ const version = typeof raw === "object" && raw !== null ? Reflect.get(raw, "version") : null;
25855
+ out[dir] = typeof version === "string" && version.length > 0 ? version : null;
25856
+ } catch {
25857
+ out[dir] = null;
25858
+ }
25859
+ return out;
25860
+ }
25861
+ //#endregion
25803
25862
  //#region src/kernel/moleculer/runner-heap-flags.ts
25804
25863
  var EMPTY_HEAP_DECLARATION = {
25805
25864
  profile: void 0,
@@ -26438,6 +26497,7 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26438
26497
  maxCrashes: MAX_CRASHES_IN_WINDOW,
26439
26498
  maxBackoffMs: MAX_BACKOFF_MS
26440
26499
  });
26500
+ const failedRetryLedger = new FailedRunnerRetryLedger();
26441
26501
  let capturedBroker = null;
26442
26502
  function buildNodeId(name) {
26443
26503
  return `${parentNodeId}/${name}`;
@@ -26648,6 +26708,7 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26648
26708
  });
26649
26709
  if (decision.action === "failed") {
26650
26710
  entry.state = "failed";
26711
+ failedRetryLedger.recordTrip(runnerId, readRunnerPackageVersions(entry.runnerAddons.map((a) => a.addonDir)));
26651
26712
  emitStateChange(entry);
26652
26713
  capturedBroker?.logger.error(`[${runnerId}] Crash circuit-breaker tripped — ${decision.crashesInWindow} crashes in ${CRASH_WINDOW_MS}ms. Not respawning.`);
26653
26714
  processes.set(runnerId, entry);
@@ -26735,6 +26796,7 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26735
26796
  }
26736
26797
  await reapRunnerGroup(target);
26737
26798
  processes.delete(name);
26799
+ failedRetryLedger.forget(name);
26738
26800
  crashSupervisor.reset(name);
26739
26801
  forceMoleculerDisconnect(ctx.broker, deadNodeId);
26740
26802
  return { success: true };
@@ -26783,6 +26845,23 @@ function createProcessService(parentNodeId, dataDir, deps, parentTcpPort, parent
26783
26845
  };
26784
26846
  });
26785
26847
  } },
26848
+ /**
26849
+ * Restart every runner the breaker parked `failed` whose package changed
26850
+ * version since it tripped (#346) — once per new version, never a loop.
26851
+ * Called by the agent after a reconcile delivered bytes.
26852
+ */
26853
+ retryFailedOnVersionChange: { async handler(ctx) {
26854
+ const retried = [];
26855
+ for (const entry of [...processes.values()]) {
26856
+ if (entry.state !== "failed") continue;
26857
+ const decision = failedRetryLedger.decide(entry.name, readRunnerPackageVersions(entry.runnerAddons.map((a) => a.addonDir)));
26858
+ if (!decision.retry) continue;
26859
+ capturedBroker?.logger.warn(`[${entry.name}] package version changed since the crash breaker tripped — retrying once (${JSON.stringify(decision.from)} -> ${JSON.stringify(decision.to)})`, { tags: { runnerId: entry.name } });
26860
+ await ctx.call("$process.restart", { name: entry.name });
26861
+ retried.push(entry.name);
26862
+ }
26863
+ return { retried };
26864
+ } },
26786
26865
  list: { async handler() {
26787
26866
  const entries = [...processes.values(), ...backingOff.values()];
26788
26867
  const stats = await getPidStats$1(entries.filter((p) => p.pid > 0).map((p) => p.pid));
@@ -0,0 +1,25 @@
1
+ /** `addonDir -> package version` (`null` when unreadable). */
2
+ export type RunnerPackageVersions = Readonly<Record<string, string | null>>;
3
+ export type FailedRetryDecision = {
4
+ readonly retry: true;
5
+ readonly from: RunnerPackageVersions;
6
+ readonly to: RunnerPackageVersions;
7
+ } | {
8
+ readonly retry: false;
9
+ readonly reason: "no-trip-recorded" | "version-unchanged";
10
+ };
11
+ export declare class FailedRunnerRetryLedger {
12
+ private readonly atTrip;
13
+ /** The breaker tripped for `runnerId`; remember what it was running. */
14
+ recordTrip(runnerId: string, versions: RunnerPackageVersions): void;
15
+ /**
16
+ * Is a restart owed for `runnerId`, given the versions now on disk? An
17
+ * unreadable current version is never a change (a failed read changes
18
+ * nothing). A positive answer consumes the snapshot.
19
+ */
20
+ decide(runnerId: string, current: RunnerPackageVersions): FailedRetryDecision;
21
+ /** Forget a runner (stop / operator restart). */
22
+ forget(runnerId: string): void;
23
+ }
24
+ /** The package.json version of each addon dir; `null` when unreadable. */
25
+ export declare function readRunnerPackageVersions(addonDirs: readonly string[]): RunnerPackageVersions;