@camstack/server 1.2.770 → 1.2.772

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/api/core/site-location.js +12 -10
  3. package/dist/core/addon/addon-registry.service.js +100 -65
  4. package/dist/core/addon/group-respawn-ledger.js +59 -0
  5. package/dist/core/addon/runner-convergence.js +36 -0
  6. package/dist/server-root/index.js +6 -0
  7. package/package.json +4 -31
  8. package/system/dist/{agent-https-BGRPCKwT.mjs → agent-https-CyrCmRxJ.mjs} +1 -1
  9. package/system/dist/{agent-https-mq6d71iq.js → agent-https-DOsuGpqh.js} +1 -1
  10. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  11. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  12. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  13. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  14. package/system/dist/builtins/alerts/alerts.addon.js +1 -1
  15. package/system/dist/builtins/alerts/alerts.addon.mjs +1 -1
  16. package/system/dist/builtins/autotrack/index.js +1 -1
  17. package/system/dist/builtins/autotrack/index.mjs +1 -1
  18. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  19. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  20. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  21. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  22. package/system/dist/builtins/camera-grid/index.js +1 -1
  23. package/system/dist/builtins/camera-grid/index.mjs +1 -1
  24. package/system/dist/builtins/composer/composer.addon.js +9 -5
  25. package/system/dist/builtins/composer/composer.addon.mjs +9 -5
  26. package/system/dist/builtins/composer/composer.d.ts +2 -0
  27. package/system/dist/builtins/console-logging/index.js +1 -1
  28. package/system/dist/builtins/console-logging/index.mjs +1 -1
  29. package/system/dist/builtins/core-blocks/core-blocks.addon.js +3 -3
  30. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +3 -3
  31. package/system/dist/builtins/device-history/device-history.addon.js +2 -2
  32. package/system/dist/builtins/device-history/device-history.addon.mjs +2 -2
  33. package/system/dist/builtins/device-manager/device-manager.addon.js +1 -1
  34. package/system/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  35. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  36. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  37. package/system/dist/builtins/keychain/index.js +4 -4
  38. package/system/dist/builtins/keychain/index.mjs +4 -4
  39. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  40. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  41. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  42. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  43. package/system/dist/builtins/local-network/local-network.addon.js +2 -2
  44. package/system/dist/builtins/local-network/local-network.addon.mjs +2 -2
  45. package/system/dist/builtins/loki-logging/index.js +1 -1
  46. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  47. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  48. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  49. package/system/dist/builtins/platform-probe/index.js +1 -1
  50. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  51. package/system/dist/builtins/record-entries/index.js +1 -1
  52. package/system/dist/builtins/record-entries/index.mjs +1 -1
  53. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  54. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  55. package/system/dist/builtins/snapshot/index.js +1 -1
  56. package/system/dist/builtins/snapshot/index.mjs +1 -1
  57. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  58. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  59. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  60. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  61. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  62. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  63. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  64. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  65. package/system/dist/builtins/system-config/system-config.addon.js +3 -3
  66. package/system/dist/builtins/system-config/system-config.addon.mjs +284 -284
  67. package/system/dist/builtins/winston-logging/index.js +1 -1
  68. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  69. package/system/dist/{capture-engine--FQ8NUHh.js → capture-engine-DfJefQzh.js} +1 -1
  70. package/system/dist/{capture-engine-Cmx7DIzV.mjs → capture-engine-J4EdEUb-.mjs} +1 -1
  71. package/system/dist/{composition-sources-cvZAN87H.js → composition-sources--RXFM6JO.js} +1 -1
  72. package/system/dist/{composition-sources-Bd09D5f4.mjs → composition-sources-CAIR3OwR.mjs} +1 -1
  73. package/system/dist/{constants-Dce28BAx.mjs → constants-DrfuDfO3.mjs} +1 -1
  74. package/system/dist/{constants-gM9xHjyj.js → constants-JeT80ws5.js} +1 -1
  75. package/system/dist/{device-ca-DcMuT-Yp.mjs → device-ca-CTrahP2b.mjs} +1 -1
  76. package/system/dist/{device-ca-BmeH6Y9E.js → device-ca-DdIoGE_e.js} +1 -1
  77. package/system/dist/{dist-Dtw1sIeQ.js → dist-BPFZFbaX.js} +37 -0
  78. package/system/dist/{dist-C3WXy3Ix.mjs → dist-nYcZlEKK.mjs} +32 -1
  79. package/system/dist/file-host-worker.js +1 -1
  80. package/system/dist/file-host-worker.mjs +1 -1
  81. package/system/dist/{hub-mdns-ciao-C49eqyby.js → hub-mdns-ciao-DMT5fohb.js} +2 -2
  82. package/system/dist/{hub-mdns-ciao-Dfue_0kR.mjs → hub-mdns-ciao-wztymuRC.mjs} +2 -2
  83. package/system/dist/index.js +8 -8
  84. package/system/dist/index.mjs +8 -8
  85. package/system/dist/{legacy-integration-rows-door-B8_XCqUX.js → legacy-integration-rows-door-BBY9d3Ge.js} +1 -1
  86. package/system/dist/{legacy-integration-rows-door-DK42Bh2Q.mjs → legacy-integration-rows-door-D9tflm8o.mjs} +1 -1
  87. package/system/dist/{restore-archive-C0YDO-qd.mjs → restore-archive-Ja54S11H.mjs} +82 -82
  88. package/system/dist/{restore-archive-DuktQtye.js → restore-archive-NtX8oJFn.js} +1 -1
  89. package/system/dist/{wal-maintenance-DhuvKiGK.mjs → wal-maintenance-CLcPsCoy.mjs} +0 -0
  90. package/system/dist/{wal-maintenance-BEo-y-cQ.js → wal-maintenance-CbDxJRRy.js} +0 -0
  91. package/system/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.772] - 2026-11-05
11
+
12
+ ### Fixed
13
+
14
+ - A container with an empty TZ no longer reports the invalid zone Etc/Unknown: the site location falls back to UTC and the starter ignores an empty TZ
15
+
16
+ ## [1.2.771] - 2026-11-05
17
+
18
+ ### Fixed
19
+
20
+ - Updating one addon in a shared runner no longer skips the restart when another member of that runner was restarted moments earlier, so the new code actually loads.
21
+
10
22
  ## [1.2.770] - 2026-11-05
11
23
 
12
24
  ### Removed
@@ -99,10 +99,12 @@ function isUsableCoordinate(lat, lng) {
99
99
  return false;
100
100
  return lat !== 0 || lng !== 0;
101
101
  }
102
- /** The hub's own IANA zone, `UTC` when the runtime cannot name one. */
103
- function hubTimeZone() {
104
- const zone = Intl.DateTimeFormat().resolvedOptions().timeZone;
105
- return typeof zone === 'string' && zone.length > 0 ? zone : 'UTC';
102
+ /**
103
+ * The hub's own IANA zone, `UTC` when the runtime cannot name a usable one
104
+ * (a container with an empty `TZ` reports `Etc/Unknown`).
105
+ */
106
+ function hubTimeZone(logger) {
107
+ return (0, types_1.processTimeZoneOr)('UTC', logger);
106
108
  }
107
109
  /** Project a stored row onto the wire shape. */
108
110
  function toStatus(record, timeZone = hubTimeZone()) {
@@ -296,11 +298,11 @@ class SiteLocationService {
296
298
  async get() {
297
299
  const record = await this.read();
298
300
  if (record !== null && isUsableCoordinate(record.latitude, record.longitude)) {
299
- return toStatus(record);
301
+ return toStatus(record, hubTimeZone(this.deps.logger));
300
302
  }
301
303
  if (record !== null && typeof record.derivationAttemptedAt === 'number') {
302
304
  // Spent. `detectSiteLocation` is the only way back.
303
- return toStatus(record);
305
+ return toStatus(record, hubTimeZone(this.deps.logger));
304
306
  }
305
307
  const existing = SiteLocationService.inFlight;
306
308
  if (existing !== null)
@@ -350,7 +352,7 @@ class SiteLocationService {
350
352
  meta: { error: (0, types_1.errMsg)(err) },
351
353
  });
352
354
  }
353
- return toStatus(failure);
355
+ return toStatus(failure, hubTimeZone(this.deps.logger));
354
356
  }
355
357
  async persist(fix, source) {
356
358
  const record = {
@@ -362,7 +364,7 @@ class SiteLocationService {
362
364
  derivationAttemptedAt: this.now(),
363
365
  };
364
366
  await this.write(record);
365
- return toStatus(record);
367
+ return toStatus(record, hubTimeZone(this.deps.logger));
366
368
  }
367
369
  /** Operator input. Clears the value when `input` is `null`. */
368
370
  async set(input) {
@@ -371,7 +373,7 @@ class SiteLocationService {
371
373
  // not "guess again". Detect is the button for that.
372
374
  const cleared = { derivationAttemptedAt: this.now() };
373
375
  await this.write(cleared);
374
- return toStatus(cleared);
376
+ return toStatus(cleared, hubTimeZone(this.deps.logger));
375
377
  }
376
378
  return this.persist({ latitude: input.latitude, longitude: input.longitude }, 'operator-set');
377
379
  }
@@ -388,7 +390,7 @@ class SiteLocationService {
388
390
  record.source === 'operator-set' &&
389
391
  isUsableCoordinate(record.latitude, record.longitude)) {
390
392
  this.deps.logger?.info('site location detect skipped — an operator-set value already exists');
391
- return toStatus(record);
393
+ return toStatus(record, hubTimeZone(this.deps.logger));
392
394
  }
393
395
  return this.derive();
394
396
  }
@@ -60,6 +60,7 @@ const materialize_route_path_js_1 = require("./materialize-route-path.js");
60
60
  const package_dir_utils_1 = require("./package-dir-utils");
61
61
  const legacy_package_names_1 = require("../../legacy-package-names");
62
62
  const prune_misplaced_addons_js_1 = require("./prune-misplaced-addons.js");
63
+ const group_respawn_ledger_1 = require("./group-respawn-ledger");
63
64
  const runner_convergence_1 = require("./runner-convergence");
64
65
  const runner_serialization_1 = require("./runner-serialization");
65
66
  const runner_spawn_fanout_js_1 = require("./runner-spawn-fanout.js");
@@ -135,15 +136,6 @@ function isSettingsStore(backend) {
135
136
  function isAddonRoutesInvoker(provider) {
136
137
  return typeof Reflect.get(provider, 'invoke') === 'function';
137
138
  }
138
- /**
139
- * Window within which a second `restart:true` respawn of the SAME group runner
140
- * is coalesced to a no-op (a package reload loops `restartAddon` over every
141
- * group member — see `recentGroupRespawns`). Chosen comfortably longer than a
142
- * single group respawn (child fork + init) so all members of one reload pass
143
- * fall inside it, and short enough that a genuinely independent later restart
144
- * still respawns.
145
- */
146
- const GROUP_RESPAWN_COALESCE_MS = 10_000;
147
139
  const ROUTE_METHODS = [
148
140
  'GET',
149
141
  'POST',
@@ -322,16 +314,12 @@ class AddonRegistryService {
322
314
  */
323
315
  restartingAddons = new Map();
324
316
  /**
325
- * `runnerId → last-respawn epoch-ms`, used ONLY to coalesce redundant group
326
- * respawns. A package reload loops `restartAddon` over EVERY addon in the
327
- * package (`tryReloadPackage`); for a co-location group that maps N members
328
- * onto ONE runner, the first member's restart already respawns the whole
329
- * group (all members reboot from fresh on-disk code), so the 2nd..Nth
330
- * restarts must NOT respawn again — that churns the runner N times and risks
331
- * tripping the crash circuit-breaker. Consulted by `ensureForkedRunner`; only
332
- * groups (roster > 1) are coalesced, so solo-addon restart stays byte-identical.
317
+ * Group-runner restart claims. A fork covers only requests that had already
318
+ * been made when it started, so a second member swapped while — or just
319
+ * after — a sibling's respawn still gets a process that loaded its code.
320
+ * Solo runners never enter the ledger (their restart stays one fork).
333
321
  */
334
- recentGroupRespawns = new Map();
322
+ groupRespawns = (0, group_respawn_ledger_1.createGroupRespawnLedger)();
335
323
  logger;
336
324
  addonLoader;
337
325
  healthMonitor;
@@ -1491,17 +1479,23 @@ class AddonRegistryService {
1491
1479
  // InferenceCapabilitiesService removed — now lives in pipeline-executor addon.
1492
1480
  // Use capabilityRegistry.getSingleton('pipeline-executor') instead.
1493
1481
  /** Log a standardized lifecycle line for addon start/restart */
1494
- logAddonLifecycle(event, id, mode) {
1482
+ logAddonLifecycle(event, id, mode, pids) {
1495
1483
  const entry = this.addonEntries.get(id);
1496
1484
  if (!entry)
1497
1485
  return;
1498
1486
  const agentName = process.env.CAMSTACK_AGENT_NAME ?? 'hub';
1499
1487
  const platform = `${os.platform()}/${os.arch()}`;
1500
- const message = `Addon ${event} — v${entry.packageVersion} (${entry.packageName}), ${mode}, ${platform}, agent: ${agentName}`;
1488
+ const runnerPid = pids !== undefined && pids.pidAfter !== null
1489
+ ? `, runner pid ${pids.pidBefore ?? 'none'} -> ${pids.pidAfter}`
1490
+ : '';
1491
+ const message = `Addon ${event} — v${entry.packageVersion} (${entry.packageName}), ${mode}, ${platform}, agent: ${agentName}${runnerPid}`;
1501
1492
  // Log under AddonRegistry scope
1502
1493
  this.logger.info(message, {
1503
1494
  tags: { addonId: id, agentId: agentName },
1504
- meta: { phase: 'lifecycle' },
1495
+ meta: {
1496
+ phase: 'lifecycle',
1497
+ ...(pids !== undefined ? { pidBefore: pids.pidBefore, pidAfter: pids.pidAfter } : {}),
1498
+ },
1505
1499
  });
1506
1500
  // Also log under the addon's own tagged logger so it appears in the per-addon
1507
1501
  // log viewer. No scope — brand bracket shows the addon id.
@@ -1951,7 +1945,23 @@ class AddonRegistryService {
1951
1945
  const preRegistered = new Set(entry.declaredCapabilities
1952
1946
  .map((cap) => cap.name)
1953
1947
  .filter((name) => this.capabilityRegistry.getProviderByAddon(name, addonId) != null));
1954
- await this.ensureForkedRunner(addonId, { restart: true });
1948
+ const outcome = await this.ensureForkedRunner(addonId, { restart: true });
1949
+ // `Addon restarted — vX` is a claim that a process with that version
1950
+ // is up. The registry row's version was refreshed from disk before
1951
+ // this call, so the line is true only when the runner pid changed
1952
+ // (the new child loads disk at fork). A coalesced no-op used to log
1953
+ // the new version against the previous pid.
1954
+ if (!outcome.live) {
1955
+ this.logger.warn('Addon restart did not start a runner process with the swapped code', {
1956
+ tags: { addonId },
1957
+ meta: {
1958
+ pidBefore: outcome.pidBefore,
1959
+ pidAfter: outcome.pidAfter,
1960
+ version: entry.packageVersion,
1961
+ },
1962
+ });
1963
+ return { success: false, error: 'runner process did not change' };
1964
+ }
1955
1965
  // The respawn resolves as soon as the child is up, not when its
1956
1966
  // capabilities are re-registered. Callers (integrations.create, UI forms) may
1957
1967
  // immediately try to route to the provider and hit a transient null. Block here
@@ -2008,7 +2018,7 @@ class AddonRegistryService {
2008
2018
  // every roster member (custom actions live in the hub-side
2009
2019
  // `CustomActionRegistry`, which the process spawn never touches — a
2010
2020
  // hot-update would otherwise silently drop them).
2011
- this.logAddonLifecycle('restarted', addonId, 'isolated');
2021
+ this.logAddonLifecycle('restarted', addonId, 'isolated', outcome);
2012
2022
  this.emitAddonLifecycleEvent('addon.restarted', addonId);
2013
2023
  return { success: true };
2014
2024
  }
@@ -3460,17 +3470,23 @@ class AddonRegistryService {
3460
3470
  }
3461
3471
  /**
3462
3472
  * Snapshot of the live runner subprocesses (`$process.list`), reduced to the
3463
- * `{ runnerId, addonIds }` shape the convergence planner needs. Returns `[]`
3464
- * on any broker error so the caller degrades to a fresh spawn rather than
3465
- * throwing — a missing list can only mean "nothing is running".
3473
+ * `{ runnerId, addonIds, pid }` shape the convergence planner and the
3474
+ * lifecycle log need. Returns `[]` on any broker error so the caller
3475
+ * degrades to a fresh spawn rather than throwing — a missing list can only
3476
+ * mean "nothing is running".
3466
3477
  */
3467
3478
  async listRunnerProcesses() {
3468
3479
  try {
3469
- // `$process.*` is an untyped Moleculer infra boundary (returns `unknown`);
3470
- // the process-service owns the `ProcessInfo` shape. Narrow to the two
3471
- // fields the planner reads.
3472
- const procs = (await this.broker.call('$process.list'));
3473
- return procs.map((p) => ({ name: p.name, addonIds: p.addonIds }));
3480
+ const raw = await this.broker.call('$process.list');
3481
+ if (!Array.isArray(raw))
3482
+ return [];
3483
+ const rows = [];
3484
+ for (const item of raw) {
3485
+ const row = (0, runner_convergence_1.parseListedRunner)(item);
3486
+ if (row)
3487
+ rows.push(row);
3488
+ }
3489
+ return rows;
3474
3490
  }
3475
3491
  catch {
3476
3492
  return [];
@@ -3488,16 +3504,15 @@ class AddonRegistryService {
3488
3504
  * via `buildAddonGroupPlan` (the same authority the boot plan uses), then
3489
3505
  * converges the live process topology onto that roster (see
3490
3506
  * `planRunnerConvergence`): stop stale/mismatched runners, then spawn or
3491
- * restart the group runner. Idempotent — safe to call once per roster member
3492
- * (the 2nd..Nth calls see the correct topology and no-op). A groupless addon
3493
- * keys to a size-1 roster whose runner id is its own id, so its behaviour is
3494
- * byte-identical to the pre-group solo path.
3507
+ * restart the group runner. A groupless addon keys to a size-1 roster whose
3508
+ * runner id is its own id, so its behaviour is byte-identical to the
3509
+ * pre-group solo path.
3495
3510
  *
3496
- * `opts.restart` respawns the group in place even when the roster already
3497
- * matches — the deploy hot-reload path, so the child reboots the WHOLE roster
3498
- * from the freshly-swapped on-disk bundle. This is why updating ONE member of
3499
- * a group respawns the ENTIRE group (they share a process): the operator's
3500
- * "update one → respawn the whole group" invariant.
3511
+ * `opts.restart` respawns even when the roster already matches, so the child
3512
+ * loads the on-disk bundle (D5 — no in-process reload). A second member of
3513
+ * the same group shares that fork only when the fork starts AFTER its
3514
+ * request; a fork already in flight, or one that already finished, does not
3515
+ * — the second swap may have landed since. Solo addons always fork.
3501
3516
  */
3502
3517
  /**
3503
3518
  * One converge at a time per runner. See `runner-serialization.ts` for the
@@ -3514,26 +3529,20 @@ class AddonRegistryService {
3514
3529
  const roster = this.buildAddonGroupPlan([...this.addonEntries.keys()]).get(runnerId) ?? [
3515
3530
  { addonId, addonDir: entry.addonDir },
3516
3531
  ];
3517
- // Coalesce redundant group respawns: a package reload loops `restartAddon`
3518
- // over every member of a co-location group, but the FIRST member's restart
3519
- // already respawned the whole runner (every member rebooted from fresh disk
3520
- // code). For a GROUP (roster > 1) whose runner was respawned inside the
3521
- // coalesce window, downgrade a restart request to a plain topology check so
3522
- // the 2nd..Nth members don't churn the runner. Solo addons (roster == 1) are
3523
- // never coalesced — their behaviour stays byte-identical.
3524
- const effectiveRestart = opts.restart &&
3525
- roster.length > 1 &&
3526
- Date.now() - (this.recentGroupRespawns.get(runnerId) ?? 0) < GROUP_RESPAWN_COALESCE_MS
3527
- ? false
3528
- : opts.restart;
3532
+ // Claim before the queue so a member that arrives while this one is
3533
+ // waiting is visible to the fork that has not started yet. Solo runners
3534
+ // (roster of one) never claim — each of their restarts forks.
3535
+ const epoch = opts.restart && roster.length > 1 ? this.groupRespawns.claim(runnerId) : 0;
3529
3536
  // EVERYTHING from here is one atomic unit per runner. The read decides what
3530
3537
  // to stop and what to spawn, so a second converge that reads before this
3531
3538
  // one has spawned decides to spawn too — and the child nobody tracks keeps
3532
3539
  // running. `process-service`'s own lock cannot see this: it makes each
3533
3540
  // action atomic, and the unit that matters is the sequence.
3534
3541
  return this.serializeRunner(runnerId, async () => {
3542
+ const covered = epoch > 0 && this.groupRespawns.covered(runnerId, epoch);
3535
3543
  const running = await this.listRunnerProcesses();
3536
- const plan = (0, runner_convergence_1.planRunnerConvergence)(runnerId, roster.map((r) => r.addonId), running, { restart: effectiveRestart });
3544
+ const pidBefore = running.find((row) => row.name === runnerId)?.pid ?? null;
3545
+ const plan = (0, runner_convergence_1.planRunnerConvergence)(runnerId, roster.map((r) => r.addonId), running, { restart: opts.restart && !covered });
3537
3546
  // 1. Tear down every stale/mismatched runner that hosts a roster member.
3538
3547
  for (const name of plan.stop) {
3539
3548
  await this.broker.call('$process.stop', { name }).catch((err) => {
@@ -3542,24 +3551,24 @@ class AddonRegistryService {
3542
3551
  });
3543
3552
  });
3544
3553
  }
3545
- // 2. Bring the target runner to the correct roster.
3554
+ // 2. Bring the target runner to the correct roster. The cover snapshot
3555
+ // is the last synchronous read before the fork, so a swap that lands
3556
+ // while the child is starting is NOT credited to this process.
3557
+ let pidAfter = pidBefore;
3546
3558
  if (plan.action === 'spawn') {
3547
- await this.broker
3548
- .call('$process.spawnRunner', { runnerId, addons: roster })
3549
- .catch((err) => {
3550
- // A concurrent path may have won the spawn race — treat "already
3551
- // running" as success (idempotent), rethrow anything else.
3552
- if (!/already running/i.test((0, types_2.errMsg)(err)))
3553
- throw err;
3554
- });
3555
- this.recentGroupRespawns.set(runnerId, Date.now());
3559
+ const coverThrough = epoch > 0 ? this.groupRespawns.coverThrough(runnerId) : 0;
3560
+ pidAfter = await this.spawnGroupRunner(runnerId, roster, pidBefore);
3561
+ this.noteGroupFork(epoch, runnerId, coverThrough, pidBefore, pidAfter);
3556
3562
  }
3557
3563
  else if (plan.action === 'restart') {
3558
- const res = (await this.broker.call('$process.restart', { name: runnerId }));
3564
+ const coverThrough = epoch > 0 ? this.groupRespawns.coverThrough(runnerId) : 0;
3565
+ const raw = await this.broker.call('$process.restart', { name: runnerId });
3566
+ const res = (0, runner_convergence_1.readRestartReply)(raw);
3559
3567
  if (!res.success) {
3560
3568
  throw new Error(`Process restart failed: ${res.reason ?? 'unknown'}`);
3561
3569
  }
3562
- this.recentGroupRespawns.set(runnerId, Date.now());
3570
+ pidAfter = res.pid;
3571
+ this.noteGroupFork(epoch, runnerId, coverThrough, pidBefore, pidAfter);
3563
3572
  }
3564
3573
  // 3. Bookkeeping for EVERY roster member. Mark each member initialized so
3565
3574
  // the in-process core-builtin boot passes skip them. The custom-action
@@ -3571,8 +3580,34 @@ class AddonRegistryService {
3571
3580
  if (memberEntry)
3572
3581
  memberEntry.initialized = true;
3573
3582
  }
3583
+ if (plan.action === 'none' && covered) {
3584
+ const remembered = this.groupRespawns.pids(runnerId);
3585
+ return (0, group_respawn_ledger_1.forkedRunnerOutcome)(remembered.pidBefore, remembered.pidAfter);
3586
+ }
3587
+ return (0, group_respawn_ledger_1.forkedRunnerOutcome)(pidBefore, pidAfter);
3574
3588
  });
3575
3589
  }
3590
+ // Spawn the roster. A lost race ("already running") is the pid already up.
3591
+ async spawnGroupRunner(runnerId, roster, pidBefore) {
3592
+ try {
3593
+ const spawned = await this.broker.call('$process.spawnRunner', {
3594
+ runnerId,
3595
+ addons: roster,
3596
+ });
3597
+ return (0, runner_convergence_1.readProcessPid)(spawned);
3598
+ }
3599
+ catch (err) {
3600
+ if (!/already running/i.test((0, types_2.errMsg)(err)))
3601
+ throw err;
3602
+ const running = await this.listRunnerProcesses();
3603
+ return running.find((row) => row.name === runnerId)?.pid ?? pidBefore;
3604
+ }
3605
+ }
3606
+ noteGroupFork(epoch, runnerId, coverThrough, pidBefore, pidAfter) {
3607
+ if (epoch === 0)
3608
+ return;
3609
+ this.groupRespawns.markForked(runnerId, coverThrough, { pidBefore, pidAfter });
3610
+ }
3576
3611
  /**
3577
3612
  * Apply the custom-action catalogs a UDS child DESCRIBED in its register
3578
3613
  * frame (`RegisteredChild.customActions`, schemas stripped) to the hub-wide
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ /**
3
+ * Which restart requests one group-runner fork may satisfy.
4
+ *
5
+ * The child loads whatever is on disk at the moment it is forked (D5: there
6
+ * is no in-process reload). A request is satisfied only by a fork that starts
7
+ * AFTER the request — the caller's swap is already on disk by then. A fork
8
+ * already in flight does not count; that caller joins the single follow-up
9
+ * which starts when the in-flight fork returns. No clock (D3).
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.forkedRunnerOutcome = forkedRunnerOutcome;
13
+ exports.createGroupRespawnLedger = createGroupRespawnLedger;
14
+ function forkedRunnerOutcome(pidBefore, pidAfter) {
15
+ return {
16
+ live: pidAfter !== null && pidAfter !== pidBefore,
17
+ pidBefore,
18
+ pidAfter,
19
+ };
20
+ }
21
+ function createGroupRespawnLedger() {
22
+ const slots = new Map();
23
+ const slot = (runnerId) => {
24
+ const existing = slots.get(runnerId);
25
+ if (existing)
26
+ return existing;
27
+ const created = {
28
+ requested: 0,
29
+ satisfied: 0,
30
+ pidBefore: null,
31
+ pidAfter: null,
32
+ };
33
+ slots.set(runnerId, created);
34
+ return created;
35
+ };
36
+ return {
37
+ claim(runnerId) {
38
+ const current = slot(runnerId);
39
+ current.requested += 1;
40
+ return current.requested;
41
+ },
42
+ covered(runnerId, epoch) {
43
+ return slot(runnerId).satisfied >= epoch;
44
+ },
45
+ coverThrough(runnerId) {
46
+ return slot(runnerId).requested;
47
+ },
48
+ markForked(runnerId, coverThrough, pids) {
49
+ const current = slot(runnerId);
50
+ current.satisfied = Math.max(current.satisfied, coverThrough);
51
+ current.pidBefore = pids.pidBefore;
52
+ current.pidAfter = pids.pidAfter;
53
+ },
54
+ pids(runnerId) {
55
+ const current = slot(runnerId);
56
+ return { pidBefore: current.pidBefore, pidAfter: current.pidAfter };
57
+ },
58
+ };
59
+ }
@@ -23,7 +23,43 @@
23
23
  * the group spawned fresh — the convergence this planner encodes.
24
24
  */
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.parseListedRunner = parseListedRunner;
27
+ exports.readProcessPid = readProcessPid;
28
+ exports.readRestartReply = readRestartReply;
26
29
  exports.planRunnerConvergence = planRunnerConvergence;
30
+ function parseListedRunner(value) {
31
+ if (typeof value !== 'object' || value === null)
32
+ return null;
33
+ const name = Reflect.get(value, 'name');
34
+ const addonIds = Reflect.get(value, 'addonIds');
35
+ const pid = Reflect.get(value, 'pid');
36
+ if (typeof name !== 'string' || !Array.isArray(addonIds))
37
+ return null;
38
+ const ids = [];
39
+ for (const id of addonIds) {
40
+ if (typeof id !== 'string')
41
+ return null;
42
+ ids.push(id);
43
+ }
44
+ return { name, addonIds: ids, pid: typeof pid === 'number' ? pid : null };
45
+ }
46
+ function readProcessPid(value) {
47
+ if (typeof value !== 'object' || value === null)
48
+ return null;
49
+ const pid = Reflect.get(value, 'pid');
50
+ return typeof pid === 'number' ? pid : null;
51
+ }
52
+ function readRestartReply(value) {
53
+ if (typeof value !== 'object' || value === null) {
54
+ return { success: false, pid: null, reason: null };
55
+ }
56
+ const reason = Reflect.get(value, 'reason');
57
+ return {
58
+ success: Reflect.get(value, 'success') === true,
59
+ pid: readProcessPid(value),
60
+ reason: typeof reason === 'string' ? reason : null,
61
+ };
62
+ }
27
63
  function sameRoster(addonIds, rosterSet) {
28
64
  return addonIds.length === rosterSet.size && addonIds.every((a) => rosterSet.has(a));
29
65
  }
@@ -111,6 +111,7 @@ var require_dist = __commonJS({
111
111
  devUploadManifestPath: /* @__PURE__ */ __name(() => devUploadManifestPath, "devUploadManifestPath"),
112
112
  devUploadVersionDir: /* @__PURE__ */ __name(() => devUploadVersionDir, "devUploadVersionDir"),
113
113
  devUploadsDir: /* @__PURE__ */ __name(() => devUploadsDir, "devUploadsDir"),
114
+ dropEmptyTimeZone: /* @__PURE__ */ __name(() => dropEmptyTimeZone, "dropEmptyTimeZone"),
114
115
  emptyServerRootState: /* @__PURE__ */ __name(() => emptyServerRootState, "emptyServerRootState"),
115
116
  findMissingNativePrebuilds: /* @__PURE__ */ __name(() => findMissingNativePrebuilds, "findMissingNativePrebuilds"),
116
117
  findUnappliedClosurePatches: /* @__PURE__ */ __name(() => findUnappliedClosurePatches, "findUnappliedClosurePatches"),
@@ -1114,8 +1115,13 @@ var require_dist = __commonJS({
1114
1115
  return null;
1115
1116
  }
1116
1117
  __name(readClosureVersion2, "readClosureVersion2");
1118
+ function dropEmptyTimeZone(env) {
1119
+ if (env["TZ"] === "") delete env["TZ"];
1120
+ }
1121
+ __name(dropEmptyTimeZone, "dropEmptyTimeZone");
1117
1122
  function runNodeStarter(options) {
1118
1123
  const env = options.env ?? process.env;
1124
+ dropEmptyTimeZone(env);
1119
1125
  const now = options.now ?? Date.now;
1120
1126
  const registerResolver = options.registerResolver ?? registerActiveRootResolver;
1121
1127
  const nodeMajor = options.nodeMajor ?? Number.parseInt(process.versions.node.split(".")[0] ?? "0", 10);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.770",
3
+ "version": "1.2.772",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -66,34 +66,7 @@
66
66
  ],
67
67
  "requires": {
68
68
  "addons": {
69
- "@camstack/addon-admin-ui": ">=1.2.587",
70
- "@camstack/addon-agent-ui": ">=1.2.327",
71
- "@camstack/addon-import-alexa": ">=0.2.186",
72
- "@camstack/addon-matter-broker": ">=0.2.157",
73
- "@camstack/addon-pipeline-orchestrator": ">=1.2.660",
74
- "@camstack/addon-provider-amcrest": ">=0.2.166",
75
- "@camstack/addon-provider-bosch": ">=0.1.37",
76
- "@camstack/addon-provider-dreame": ">=0.2.165",
77
- "@camstack/addon-provider-dreo": ">=0.2.155",
78
- "@camstack/addon-provider-ecowitt": ">=0.2.156",
79
- "@camstack/addon-provider-enpal": ">=0.1.9",
80
- "@camstack/addon-provider-esphome": ">=0.1.12",
81
- "@camstack/addon-provider-gree": ">=0.2.150",
82
- "@camstack/addon-provider-hikvision": ">=1.2.182",
83
- "@camstack/addon-provider-homeassistant": ">=1.2.661",
84
- "@camstack/addon-provider-homematic": ">=1.2.183",
85
- "@camstack/addon-provider-mqtt-ha": ">=0.1.37",
86
- "@camstack/addon-provider-onvif": ">=1.2.155",
87
- "@camstack/addon-provider-petkit": ">=0.2.160",
88
- "@camstack/addon-provider-rademacher": ">=0.2.159",
89
- "@camstack/addon-provider-reolink": ">=1.2.225",
90
- "@camstack/addon-provider-rtsp": ">=1.2.151",
91
- "@camstack/addon-provider-tuya": ">=0.2.151",
92
- "@camstack/addon-provider-unifi": ">=0.2.156",
93
- "@camstack/addon-provider-unraid": ">=0.2.157",
94
- "@camstack/addon-provider-velux": ">=0.2.159",
95
- "@camstack/addon-provider-vesync": ">=0.2.151",
96
- "@camstack/addon-provider-wyze": ">=0.2.163"
69
+ "@camstack/addon-admin-ui": ">=1.2.588"
97
70
  },
98
71
  "wrapper": {
99
72
  "desktop": ">=0.0.1",
@@ -102,7 +75,7 @@
102
75
  }
103
76
  },
104
77
  "dependencies": {
105
- "@camstack/addon-admin-ui": "1.2.587",
78
+ "@camstack/addon-admin-ui": "1.2.588",
106
79
  "@camstack/addon-agent-ui": "1.2.327",
107
80
  "@camstack/addon-auth": "1.2.175",
108
81
  "@camstack/addon-benchmark": "1.2.311",
@@ -113,7 +86,7 @@
113
86
  "@camstack/addon-post-analysis": "1.2.668",
114
87
  "@camstack/develop": "0.1.45",
115
88
  "@camstack/sdk": "1.2.155",
116
- "@camstack/types": "1.2.501",
89
+ "@camstack/types": "1.2.502",
117
90
  "@camstack/ui-library": "1.2.385",
118
91
  "@fastify/compress": "^9.0.0",
119
92
  "@fastify/cookie": "^11.0.2",
@@ -1,4 +1,4 @@
1
- import { ys as defineRecordKinds } from "./dist-C3WXy3Ix.mjs";
1
+ import { bs as defineRecordKinds } from "./dist-nYcZlEKK.mjs";
2
2
  import { C as backdatedNotBefore, S as withUtcTimeEncoding, _ as NameConstraints, a as KeyUsageFlags, c as Pkcs10CertificateRequest, d as SubjectKeyIdentifierExtension, f as X509Certificate$1, g as GeneralSubtrees, h as GeneralSubtree, i as Extension, l as Pkcs10CertificateRequestGenerator, m as cryptoProvider, n as BasicConstraintsExtension, o as KeyUsagesExtension, p as X509CertificateGenerator, r as ExtendedKeyUsageExtension, s as PemConverter, t as AuthorityKeyIdentifierExtension, u as SubjectAlternativeNameExtension, v as GeneralName, x as AsnConvert } from "./x509.es-BRiJgOvu.mjs";
3
3
  import { z } from "zod";
4
4
  import { X509Certificate, createHash, createPrivateKey, randomBytes, webcrypto } from "node:crypto";
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-Dtw1sIeQ.js");
2
+ const require_dist = require("./dist-BPFZFbaX.js");
3
3
  const require_x509_es = require("./x509.es-WtnRNyYS.js");
4
4
  let zod = require("zod");
5
5
  let node_crypto = require("node:crypto");
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-Dtw1sIeQ.js");
6
+ const require_dist = require("../../dist-BPFZFbaX.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { cn as addonPagesCapability, dc as EventCategory, uc as errMsg, wo as BaseAddon } from "../../dist-C3WXy3Ix.mjs";
1
+ import { To as BaseAddon, cn as addonPagesCapability, dc as errMsg, fc as EventCategory } from "../../dist-nYcZlEKK.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-Dtw1sIeQ.js");
6
+ const require_dist = require("../../dist-BPFZFbaX.js");
7
7
  const require_settle_sources = require("../../settle-sources-Bhsy57y-.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { dc as EventCategory, uc as errMsg, un as addonWidgetsCapability, wo as BaseAddon } from "../../dist-C3WXy3Ix.mjs";
1
+ import { To as BaseAddon, dc as errMsg, fc as EventCategory, un as addonWidgetsCapability } from "../../dist-nYcZlEKK.mjs";
2
2
  import { t as settleSourcesWithTimeout } from "../../settle-sources-CDtNC8ub.mjs";
3
3
  import { createHash, randomUUID } from "node:crypto";
4
4
  import * as path$1 from "node:path";
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-Dtw1sIeQ.js");
6
+ const require_dist = require("../../dist-BPFZFbaX.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
8
  //#region src/builtins/alerts/alert-episode-policy.ts
9
9
  /**
@@ -1,4 +1,4 @@
1
- import { Fr as isAlertEpisodeSeverity, Pr as isAlertEpisodeOpen, d as AlertSchema, dc as EventCategory, dn as alertEpisodeId, fn as alertEpisodePayload, ms as createEvent, pn as alertsCapability, uc as errMsg, wo as BaseAddon, ys as defineRecordKinds } from "../../dist-C3WXy3Ix.mjs";
1
+ import { Fr as isAlertEpisodeSeverity, Pr as isAlertEpisodeOpen, To as BaseAddon, bs as defineRecordKinds, d as AlertSchema, dc as errMsg, dn as alertEpisodeId, fc as EventCategory, fn as alertEpisodePayload, hs as createEvent, pn as alertsCapability } from "../../dist-nYcZlEKK.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
3
  //#region src/builtins/alerts/alert-episode-policy.ts
4
4
  /**
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-Dtw1sIeQ.js");
6
+ const require_dist = require("../../dist-BPFZFbaX.js");
7
7
  //#region src/builtins/autotrack/autotrack-config.ts
8
8
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
9
9
  deadZoneFraction: .5,
@@ -1,4 +1,4 @@
1
- import { As as isEvent, Ri as ptzAutotrackCapability, dc as EventCategory, tt as FIRST_LEVEL_MACRO_CLASSES, uc as errMsg, vn as bareAddonId, wo as BaseAddon } from "../../dist-C3WXy3Ix.mjs";
1
+ import { To as BaseAddon, dc as errMsg, fc as EventCategory, js as isEvent, tt as FIRST_LEVEL_MACRO_CLASSES, vn as bareAddonId, zi as ptzAutotrackCapability } from "../../dist-nYcZlEKK.mjs";
2
2
  //#region src/builtins/autotrack/autotrack-config.ts
3
3
  var DEFAULT_AUTOTRACK_LOOP_CONFIG = {
4
4
  deadZoneFraction: .5,