@camstack/system 1.2.136 → 1.2.137

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 (53) hide show
  1. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  2. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  3. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/alerts/alerts.addon.js +1 -1
  6. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  7. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  8. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  9. package/dist/builtins/console-logging/index.js +1 -1
  10. package/dist/builtins/console-logging/index.mjs +1 -1
  11. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  12. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  13. package/dist/builtins/device-manager/device-bindings-store.d.ts +10 -4
  14. package/dist/builtins/device-manager/device-manager.addon.js +72 -24
  15. package/dist/builtins/device-manager/device-manager.addon.mjs +72 -24
  16. package/dist/builtins/device-manager/device-row-store.d.ts +15 -0
  17. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  18. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  19. package/dist/builtins/hub-forwarder/index.js +1 -1
  20. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  21. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  22. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  23. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  24. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  25. package/dist/builtins/local-network/local-network.addon.js +1 -1
  26. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  27. package/dist/builtins/loki-logging/index.js +1 -1
  28. package/dist/builtins/loki-logging/index.mjs +1 -1
  29. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  30. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  31. package/dist/builtins/platform-probe/index.js +1 -1
  32. package/dist/builtins/platform-probe/index.mjs +1 -1
  33. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  34. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  35. package/dist/builtins/snapshot/index.js +1 -1
  36. package/dist/builtins/snapshot/index.mjs +1 -1
  37. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  38. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  39. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  40. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  41. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  42. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  43. package/dist/builtins/system-config/system-config.addon.js +1 -1
  44. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  45. package/dist/builtins/winston-logging/index.js +1 -1
  46. package/dist/builtins/winston-logging/index.mjs +1 -1
  47. package/dist/{dist-Bh25kEUH.mjs → dist-DMOTtKH8.mjs} +310 -63
  48. package/dist/{dist-D-R0SuP-.js → dist-mQ3BkrJd.js} +310 -63
  49. package/dist/index.js +1 -1
  50. package/dist/index.mjs +1 -1
  51. package/dist/{retired-settings-keys-BZbOXqch.mjs → retired-settings-keys-CPRvyt-E.mjs} +1 -1
  52. package/dist/{retired-settings-keys-CqD6rSQx.js → retired-settings-keys-Dvkcu_zf.js} +1 -1
  53. package/package.json +1 -1
@@ -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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.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 { Gt as EventCategory, v as addonPagesCapability, vt as errMsg, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { Gt as EventCategory, v as addonPagesCapability, vt as errMsg, yt as BaseAddon } from "../../dist-DMOTtKH8.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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.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 { Gt as EventCategory, b as addonWidgetsCapability, vt as errMsg, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { Gt as EventCategory, b as addonWidgetsCapability, vt as errMsg, yt as BaseAddon } from "../../dist-DMOTtKH8.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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
7
  //#region src/builtins/alerts/prune-policy.ts
8
8
  /**
9
9
  * Ids older than `cutoffMs`, oldest first.
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, Mt as createEvent, n as AlertSchema, vt as errMsg, x as alertsCapability, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { Gt as EventCategory, Mt as createEvent, n as AlertSchema, vt as errMsg, x as alertsCapability, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  //#region src/builtins/alerts/prune-policy.ts
3
3
  /**
4
4
  * Ids older than `cutoffMs`, oldest first.
@@ -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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let buffer = require("buffer");
9
9
  let node_fs_promises = require("node:fs/promises");
@@ -1,4 +1,4 @@
1
- import { C as backupCapability, Gt as EventCategory, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { C as backupCapability, Gt as EventCategory, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  import { randomBytes, randomUUID } from "node:crypto";
3
3
  import { Buffer as Buffer$1 } from "buffer";
4
4
  import * as fsp from "node:fs/promises";
@@ -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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  //#region src/builtins/console-logging/console-destination.ts
9
9
  var LEVEL_RANK = {
@@ -1,4 +1,4 @@
1
- import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  //#region src/builtins/console-logging/console-destination.ts
4
4
  var LEVEL_RANK = {
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-D-R0SuP-.js");
3
+ const require_dist = require("../../dist-mQ3BkrJd.js");
4
4
  let node_crypto = require("node:crypto");
5
5
  let node_fs_promises = require("node:fs/promises");
6
6
  node_fs_promises = require_chunk.__toESM(node_fs_promises);
@@ -1,4 +1,4 @@
1
- import { D as coreBlockAddonId, O as coreBlockIdFromAddonId, c as CoreBlockSchema, k as coreBlocksCapability, l as DeclaredDevices, o as CORE_BLOCKS_ADDON_ID, s as CORE_BLOCK_ADDON_PREFIX, vt as errMsg, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { D as coreBlockAddonId, O as coreBlockIdFromAddonId, c as CoreBlockSchema, k as coreBlocksCapability, l as DeclaredDevices, o as CORE_BLOCKS_ADDON_ID, s as CORE_BLOCK_ADDON_PREFIX, vt as errMsg, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import * as fs from "node:fs/promises";
4
4
  import * as path$1 from "node:path";
@@ -137,10 +137,16 @@ export declare function getBindings(deps: BindingsDeps, input: {
137
137
  * caller needing seventy-five paid either 75 round-trips (1211 ms / 118 KB) or
138
138
  * `getAllBindings` (511 ms / 679 KB of mostly-unwanted rows).
139
139
  *
140
- * Sequential on purpose, like `getAllBindings`: `getBindings` is a pair of
141
- * store reads on this process's own event loop, so concurrency buys nothing
142
- * and a fan-out of `Promise.all` over hundreds of ids only makes the queue
143
- * less fair to everything else on it.
140
+ * Sequential on purpose, like `getAllBindings`: `resolveBindingsForDevice`'s
141
+ * remaining per-device work (the bindings-store read, the routing rules) runs
142
+ * on this process's own event loop, so concurrency buys nothing there and a
143
+ * fan-out of `Promise.all` over hundreds of ids only makes the queue less fair
144
+ * to everything else on it. The one part that DOES amortise across the whole
145
+ * set — the device row lookup — is fetched ONCE, ahead of the loop
146
+ * ({@link DeviceRowStore.getMany}), rather than once per iteration: measured
147
+ * on the live hub 2026-08-25, `get device-manager:devices` ran 1 656
148
+ * calls/min steady-state, one row per call, which is exactly what looping
149
+ * `getBindings`'s own `rows.get(deviceId)` here produced.
144
150
  */
145
151
  export declare function getBindingsBatch(deps: BindingsDeps, input: {
146
152
  deviceIds: readonly number[];
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-D-R0SuP-.js");
7
- const require_retired_settings_keys = require("../../retired-settings-keys-CqD6rSQx.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
+ const require_retired_settings_keys = require("../../retired-settings-keys-Dvkcu_zf.js");
8
8
  let node_crypto = require("node:crypto");
9
9
  let _camstack_types_node = require("@camstack/types/node");
10
10
  //#region src/builtins/device-manager/adoption-job-engine.ts
@@ -594,16 +594,33 @@ function capAppliesToDeviceType(def, deviceType) {
594
594
  return declared.some((t) => t === deviceType);
595
595
  }
596
596
  async function getBindings(deps, input) {
597
- const storeKey = String(input.deviceId);
598
- const perDevice = (await readBindingsStore(deps)).deviceBindings[storeKey] ?? {};
599
597
  const row = await deps.rows.get(input.deviceId);
600
- const deviceType = resolveDeviceType(deps, row, input.deviceId);
601
- const presence = await resolveDevicePresence(deps, row, input.deviceId);
598
+ return resolveBindingsForDevice(deps, input.deviceId, row);
599
+ }
600
+ /**
601
+ * The `getBindings` resolver, taking the device's row as a PARAMETER instead
602
+ * of fetching it.
603
+ *
604
+ * `getBindings` (one device) and `getBindingsBatch` / `getAllBindings` (many)
605
+ * share this — the routing rules and the per-device shape stay identical by
606
+ * construction. The split exists so the batch callers can resolve every row
607
+ * they need in ONE store round trip ({@link DeviceRowStore.getMany} /
608
+ * {@link DeviceRowStore.listAll}) instead of looping this function's own
609
+ * `deps.rows.get(deviceId)`, which is the primary-key-lookup-per-loop-
610
+ * iteration shape measured on the live hub 2026-08-25: `get
611
+ * device-manager:devices` at 1 656 calls/min steady-state and 17 687 during
612
+ * boot, one row per call.
613
+ */
614
+ async function resolveBindingsForDevice(deps, deviceId, row) {
615
+ const storeKey = String(deviceId);
616
+ const perDevice = (await readBindingsStore(deps)).deviceBindings[storeKey] ?? {};
617
+ const deviceType = resolveDeviceType(deps, row, deviceId);
618
+ const presence = await resolveDevicePresence(deps, row, deviceId);
602
619
  const entries = [];
603
620
  const seenCaps = /* @__PURE__ */ new Set();
604
- const resolveRemote = (capName) => deps.remoteNativeCaps.get(input.deviceId)?.get(capName) ?? resolveRemoteNativeCapFromRegistry(deps, capName, input.deviceId);
621
+ const resolveRemote = (capName) => deps.remoteNativeCaps.get(deviceId)?.get(capName) ?? resolveRemoteNativeCapFromRegistry(deps, capName, deviceId);
605
622
  for (const [capName, { wrapperAddonId }] of Object.entries(perDevice)) {
606
- const hubLocalNative = deps.capabilityRegistry?.getNativeAddonId(capName, input.deviceId) ?? null;
623
+ const hubLocalNative = deps.capabilityRegistry?.getNativeAddonId(capName, deviceId) ?? null;
607
624
  const remoteNative = resolveRemote(capName);
608
625
  const nativeAddonId = hubLocalNative ?? remoteNative?.addonId ?? "";
609
626
  const nativeNodeId = hubLocalNative ? deps.ctx.kernel.localNodeId ?? "hub" : remoteNative?.nodeId ?? deps.ctx.kernel.localNodeId ?? "hub";
@@ -620,7 +637,7 @@ async function getBindings(deps, input) {
620
637
  });
621
638
  seenCaps.add(capName);
622
639
  }
623
- if (presence === "absent") deps.ctx.logger.debug("bindings requested for absent device — returning none", { tags: { deviceId: input.deviceId } });
640
+ if (presence === "absent") deps.ctx.logger.debug("bindings requested for absent device — returning none", { tags: { deviceId } });
624
641
  else if (deps.capabilityRegistry) {
625
642
  const skippedForType = [];
626
643
  for (const capName of deps.capabilityRegistry.getCapsWithDefaultWrapper()) {
@@ -631,7 +648,7 @@ async function getBindings(deps, input) {
631
648
  }
632
649
  const defaultWrapperAddonId = deps.capabilityRegistry.getDefaultWrapperForCap(capName);
633
650
  if (!defaultWrapperAddonId) continue;
634
- const hubLocalNative = deps.capabilityRegistry.getNativeAddonId(capName, input.deviceId) ?? null;
651
+ const hubLocalNative = deps.capabilityRegistry.getNativeAddonId(capName, deviceId) ?? null;
635
652
  const remoteNative = resolveRemote(capName);
636
653
  const nativeAddonId = hubLocalNative ?? remoteNative?.addonId ?? "";
637
654
  entries.push({
@@ -644,16 +661,16 @@ async function getBindings(deps, input) {
644
661
  seenCaps.add(capName);
645
662
  }
646
663
  if (skippedForType.length > 0) deps.ctx.logger.debug("getBindings: default wrappers skipped — deviceTypes mismatch", {
647
- tags: { deviceId: input.deviceId },
664
+ tags: { deviceId },
648
665
  meta: {
649
666
  deviceType,
650
667
  skipped: skippedForType
651
668
  }
652
669
  });
653
670
  }
654
- if (deps.capabilityRegistry) for (const capName of deps.capabilityRegistry.getNativeCapsForDevice(input.deviceId)) {
671
+ if (deps.capabilityRegistry) for (const capName of deps.capabilityRegistry.getNativeCapsForDevice(deviceId)) {
655
672
  if (seenCaps.has(capName)) continue;
656
- const nativeAddonId = deps.capabilityRegistry.getNativeAddonId(capName, input.deviceId) ?? "";
673
+ const nativeAddonId = deps.capabilityRegistry.getNativeAddonId(capName, deviceId) ?? "";
657
674
  entries.push({
658
675
  capName,
659
676
  kind: "native",
@@ -663,7 +680,7 @@ async function getBindings(deps, input) {
663
680
  });
664
681
  seenCaps.add(capName);
665
682
  }
666
- const pushFed = deps.remoteNativeCaps.get(input.deviceId);
683
+ const pushFed = deps.remoteNativeCaps.get(deviceId);
667
684
  if (pushFed) for (const [capName, info] of pushFed) {
668
685
  if (seenCaps.has(capName)) continue;
669
686
  entries.push({
@@ -675,9 +692,9 @@ async function getBindings(deps, input) {
675
692
  });
676
693
  seenCaps.add(capName);
677
694
  }
678
- const clusterCaps = deps.ctx.kernel.listClusterNativeCapsForDevice?.(input.deviceId) ?? deps.ctx.kernel.listClusterNativeCaps?.();
695
+ const clusterCaps = deps.ctx.kernel.listClusterNativeCapsForDevice?.(deviceId) ?? deps.ctx.kernel.listClusterNativeCaps?.();
679
696
  if (clusterCaps) for (const entry of clusterCaps) {
680
- if (entry.deviceId !== input.deviceId) continue;
697
+ if (entry.deviceId !== deviceId) continue;
681
698
  if (seenCaps.has(entry.capName)) continue;
682
699
  if (!entry.addonId) continue;
683
700
  const localNodeId = deps.ctx.kernel.localNodeId ?? "hub";
@@ -692,7 +709,7 @@ async function getBindings(deps, input) {
692
709
  seenCaps.add(entry.capName);
693
710
  }
694
711
  return {
695
- deviceId: input.deviceId,
712
+ deviceId,
696
713
  entries
697
714
  };
698
715
  }
@@ -705,14 +722,22 @@ async function getBindings(deps, input) {
705
722
  * caller needing seventy-five paid either 75 round-trips (1211 ms / 118 KB) or
706
723
  * `getAllBindings` (511 ms / 679 KB of mostly-unwanted rows).
707
724
  *
708
- * Sequential on purpose, like `getAllBindings`: `getBindings` is a pair of
709
- * store reads on this process's own event loop, so concurrency buys nothing
710
- * and a fan-out of `Promise.all` over hundreds of ids only makes the queue
711
- * less fair to everything else on it.
725
+ * Sequential on purpose, like `getAllBindings`: `resolveBindingsForDevice`'s
726
+ * remaining per-device work (the bindings-store read, the routing rules) runs
727
+ * on this process's own event loop, so concurrency buys nothing there and a
728
+ * fan-out of `Promise.all` over hundreds of ids only makes the queue less fair
729
+ * to everything else on it. The one part that DOES amortise across the whole
730
+ * set — the device row lookup — is fetched ONCE, ahead of the loop
731
+ * ({@link DeviceRowStore.getMany}), rather than once per iteration: measured
732
+ * on the live hub 2026-08-25, `get device-manager:devices` ran 1 656
733
+ * calls/min steady-state, one row per call, which is exactly what looping
734
+ * `getBindings`'s own `rows.get(deviceId)` here produced.
712
735
  */
713
736
  async function getBindingsBatch(deps, input) {
737
+ const ids = [...new Set(input.deviceIds)];
738
+ const rows = await deps.rows.getMany(ids);
714
739
  const out = [];
715
- for (const deviceId of new Set(input.deviceIds)) out.push(await getBindings(deps, { deviceId }));
740
+ for (const deviceId of ids) out.push(await resolveBindingsForDevice(deps, deviceId, rows.get(deviceId) ?? null));
716
741
  return out;
717
742
  }
718
743
  /**
@@ -727,8 +752,13 @@ async function getBindingsBatch(deps, input) {
727
752
  * payload periodically.
728
753
  */
729
754
  async function getAllBindings(deps) {
755
+ const fleet = await deps.rows.listAll();
756
+ const rowById = /* @__PURE__ */ new Map();
730
757
  const ids = /* @__PURE__ */ new Set();
731
- for (const row of await deps.rows.listAll()) ids.add(row.meta.id);
758
+ for (const row of fleet) {
759
+ rowById.set(row.meta.id, row);
760
+ ids.add(row.meta.id);
761
+ }
732
762
  const registered = deps.ctx.kernel?.deviceRegistry?.getAll() ?? [];
733
763
  for (const device of registered) ids.add(device.id);
734
764
  if (ids.size === 0) {
@@ -736,7 +766,7 @@ async function getAllBindings(deps) {
736
766
  return [];
737
767
  }
738
768
  const out = [];
739
- for (const deviceId of [...ids].sort((a, b) => a - b)) out.push(await getBindings(deps, { deviceId }));
769
+ for (const deviceId of [...ids].sort((a, b) => a - b)) out.push(await resolveBindingsForDevice(deps, deviceId, rowById.get(deviceId) ?? null));
740
770
  return out;
741
771
  }
742
772
  /**
@@ -4329,6 +4359,24 @@ var DeviceRowStore = class {
4329
4359
  }, opts.slim === true ? DEVICE_ROWS_SLIM_COLUMNS : void 0);
4330
4360
  }
4331
4361
  /**
4362
+ * Many devices, by numeric id, in ONE query.
4363
+ *
4364
+ * `get(id)` called once per id in a loop is the primary-key lookup this
4365
+ * store exists to make cheap, repeated until it isn't — measured on the
4366
+ * live hub 2026-08-25: `get device-manager:devices` at 1 656 calls/min
4367
+ * steady-state and 17 687 during boot, exactly one row per call. This
4368
+ * collapses that into the same `whereIn` {@link listFleet} already does for
4369
+ * a fleet read, keyed by id.
4370
+ *
4371
+ * A requested id the fleet does not know is simply ABSENT from the map —
4372
+ * never a fabricated row, matching {@link get}'s `null`. An empty `ids`
4373
+ * reads nothing at all, same as `listFleet({ deviceIds: [] })`.
4374
+ */
4375
+ async getMany(ids) {
4376
+ const rows = await this.listFleet({ deviceIds: ids });
4377
+ return new Map(rows.map((row) => [row.meta.id, row]));
4378
+ }
4379
+ /**
4332
4380
  * The device an addon knows as `stableId`, or `null`.
4333
4381
  *
4334
4382
  * `(addonId, stableId)` is the addon-facing identity — unique by
@@ -1,5 +1,5 @@
1
- import { Ct as DeviceFeature, E as buildStreamParamsConfigSchema, F as deviceStatusCapability, Gt as EventCategory, Lt as isDeviceConfigCap, N as deviceManagerCapability, Ot as WELL_KNOWN_TAB_MAP, P as deviceStateCapability, R as enumerateItemArrayFields, Tt as DeviceType, Wt as sleep, a as CAP_NAMES_WITH_STATUS, at as runtimeStatePolicyFor, et as normalizeUnit, nt as parseStreamParamsFormPatch, p as STREAM_PROFILE_META, t as ALL_CAPABILITY_DEFINITIONS, u as DeviceStatusSchema, vt as errMsg, wt as DeviceRole, yt as BaseAddon, z as enumerateSchemaFields } from "../../dist-Bh25kEUH.mjs";
2
- import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-BZbOXqch.mjs";
1
+ import { Ct as DeviceFeature, E as buildStreamParamsConfigSchema, F as deviceStatusCapability, Gt as EventCategory, Lt as isDeviceConfigCap, N as deviceManagerCapability, Ot as WELL_KNOWN_TAB_MAP, P as deviceStateCapability, R as enumerateItemArrayFields, Tt as DeviceType, Wt as sleep, a as CAP_NAMES_WITH_STATUS, at as runtimeStatePolicyFor, et as normalizeUnit, nt as parseStreamParamsFormPatch, p as STREAM_PROFILE_META, t as ALL_CAPABILITY_DEFINITIONS, u as DeviceStatusSchema, vt as errMsg, wt as DeviceRole, yt as BaseAddon, z as enumerateSchemaFields } from "../../dist-DMOTtKH8.mjs";
2
+ import { n as purgeRetiredSettingsRows } from "../../retired-settings-keys-CPRvyt-E.mjs";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { canonicalDeviceFingerprint } from "@camstack/types/node";
5
5
  //#region src/builtins/device-manager/adoption-job-engine.ts
@@ -589,16 +589,33 @@ function capAppliesToDeviceType(def, deviceType) {
589
589
  return declared.some((t) => t === deviceType);
590
590
  }
591
591
  async function getBindings(deps, input) {
592
- const storeKey = String(input.deviceId);
593
- const perDevice = (await readBindingsStore(deps)).deviceBindings[storeKey] ?? {};
594
592
  const row = await deps.rows.get(input.deviceId);
595
- const deviceType = resolveDeviceType(deps, row, input.deviceId);
596
- const presence = await resolveDevicePresence(deps, row, input.deviceId);
593
+ return resolveBindingsForDevice(deps, input.deviceId, row);
594
+ }
595
+ /**
596
+ * The `getBindings` resolver, taking the device's row as a PARAMETER instead
597
+ * of fetching it.
598
+ *
599
+ * `getBindings` (one device) and `getBindingsBatch` / `getAllBindings` (many)
600
+ * share this — the routing rules and the per-device shape stay identical by
601
+ * construction. The split exists so the batch callers can resolve every row
602
+ * they need in ONE store round trip ({@link DeviceRowStore.getMany} /
603
+ * {@link DeviceRowStore.listAll}) instead of looping this function's own
604
+ * `deps.rows.get(deviceId)`, which is the primary-key-lookup-per-loop-
605
+ * iteration shape measured on the live hub 2026-08-25: `get
606
+ * device-manager:devices` at 1 656 calls/min steady-state and 17 687 during
607
+ * boot, one row per call.
608
+ */
609
+ async function resolveBindingsForDevice(deps, deviceId, row) {
610
+ const storeKey = String(deviceId);
611
+ const perDevice = (await readBindingsStore(deps)).deviceBindings[storeKey] ?? {};
612
+ const deviceType = resolveDeviceType(deps, row, deviceId);
613
+ const presence = await resolveDevicePresence(deps, row, deviceId);
597
614
  const entries = [];
598
615
  const seenCaps = /* @__PURE__ */ new Set();
599
- const resolveRemote = (capName) => deps.remoteNativeCaps.get(input.deviceId)?.get(capName) ?? resolveRemoteNativeCapFromRegistry(deps, capName, input.deviceId);
616
+ const resolveRemote = (capName) => deps.remoteNativeCaps.get(deviceId)?.get(capName) ?? resolveRemoteNativeCapFromRegistry(deps, capName, deviceId);
600
617
  for (const [capName, { wrapperAddonId }] of Object.entries(perDevice)) {
601
- const hubLocalNative = deps.capabilityRegistry?.getNativeAddonId(capName, input.deviceId) ?? null;
618
+ const hubLocalNative = deps.capabilityRegistry?.getNativeAddonId(capName, deviceId) ?? null;
602
619
  const remoteNative = resolveRemote(capName);
603
620
  const nativeAddonId = hubLocalNative ?? remoteNative?.addonId ?? "";
604
621
  const nativeNodeId = hubLocalNative ? deps.ctx.kernel.localNodeId ?? "hub" : remoteNative?.nodeId ?? deps.ctx.kernel.localNodeId ?? "hub";
@@ -615,7 +632,7 @@ async function getBindings(deps, input) {
615
632
  });
616
633
  seenCaps.add(capName);
617
634
  }
618
- if (presence === "absent") deps.ctx.logger.debug("bindings requested for absent device — returning none", { tags: { deviceId: input.deviceId } });
635
+ if (presence === "absent") deps.ctx.logger.debug("bindings requested for absent device — returning none", { tags: { deviceId } });
619
636
  else if (deps.capabilityRegistry) {
620
637
  const skippedForType = [];
621
638
  for (const capName of deps.capabilityRegistry.getCapsWithDefaultWrapper()) {
@@ -626,7 +643,7 @@ async function getBindings(deps, input) {
626
643
  }
627
644
  const defaultWrapperAddonId = deps.capabilityRegistry.getDefaultWrapperForCap(capName);
628
645
  if (!defaultWrapperAddonId) continue;
629
- const hubLocalNative = deps.capabilityRegistry.getNativeAddonId(capName, input.deviceId) ?? null;
646
+ const hubLocalNative = deps.capabilityRegistry.getNativeAddonId(capName, deviceId) ?? null;
630
647
  const remoteNative = resolveRemote(capName);
631
648
  const nativeAddonId = hubLocalNative ?? remoteNative?.addonId ?? "";
632
649
  entries.push({
@@ -639,16 +656,16 @@ async function getBindings(deps, input) {
639
656
  seenCaps.add(capName);
640
657
  }
641
658
  if (skippedForType.length > 0) deps.ctx.logger.debug("getBindings: default wrappers skipped — deviceTypes mismatch", {
642
- tags: { deviceId: input.deviceId },
659
+ tags: { deviceId },
643
660
  meta: {
644
661
  deviceType,
645
662
  skipped: skippedForType
646
663
  }
647
664
  });
648
665
  }
649
- if (deps.capabilityRegistry) for (const capName of deps.capabilityRegistry.getNativeCapsForDevice(input.deviceId)) {
666
+ if (deps.capabilityRegistry) for (const capName of deps.capabilityRegistry.getNativeCapsForDevice(deviceId)) {
650
667
  if (seenCaps.has(capName)) continue;
651
- const nativeAddonId = deps.capabilityRegistry.getNativeAddonId(capName, input.deviceId) ?? "";
668
+ const nativeAddonId = deps.capabilityRegistry.getNativeAddonId(capName, deviceId) ?? "";
652
669
  entries.push({
653
670
  capName,
654
671
  kind: "native",
@@ -658,7 +675,7 @@ async function getBindings(deps, input) {
658
675
  });
659
676
  seenCaps.add(capName);
660
677
  }
661
- const pushFed = deps.remoteNativeCaps.get(input.deviceId);
678
+ const pushFed = deps.remoteNativeCaps.get(deviceId);
662
679
  if (pushFed) for (const [capName, info] of pushFed) {
663
680
  if (seenCaps.has(capName)) continue;
664
681
  entries.push({
@@ -670,9 +687,9 @@ async function getBindings(deps, input) {
670
687
  });
671
688
  seenCaps.add(capName);
672
689
  }
673
- const clusterCaps = deps.ctx.kernel.listClusterNativeCapsForDevice?.(input.deviceId) ?? deps.ctx.kernel.listClusterNativeCaps?.();
690
+ const clusterCaps = deps.ctx.kernel.listClusterNativeCapsForDevice?.(deviceId) ?? deps.ctx.kernel.listClusterNativeCaps?.();
674
691
  if (clusterCaps) for (const entry of clusterCaps) {
675
- if (entry.deviceId !== input.deviceId) continue;
692
+ if (entry.deviceId !== deviceId) continue;
676
693
  if (seenCaps.has(entry.capName)) continue;
677
694
  if (!entry.addonId) continue;
678
695
  const localNodeId = deps.ctx.kernel.localNodeId ?? "hub";
@@ -687,7 +704,7 @@ async function getBindings(deps, input) {
687
704
  seenCaps.add(entry.capName);
688
705
  }
689
706
  return {
690
- deviceId: input.deviceId,
707
+ deviceId,
691
708
  entries
692
709
  };
693
710
  }
@@ -700,14 +717,22 @@ async function getBindings(deps, input) {
700
717
  * caller needing seventy-five paid either 75 round-trips (1211 ms / 118 KB) or
701
718
  * `getAllBindings` (511 ms / 679 KB of mostly-unwanted rows).
702
719
  *
703
- * Sequential on purpose, like `getAllBindings`: `getBindings` is a pair of
704
- * store reads on this process's own event loop, so concurrency buys nothing
705
- * and a fan-out of `Promise.all` over hundreds of ids only makes the queue
706
- * less fair to everything else on it.
720
+ * Sequential on purpose, like `getAllBindings`: `resolveBindingsForDevice`'s
721
+ * remaining per-device work (the bindings-store read, the routing rules) runs
722
+ * on this process's own event loop, so concurrency buys nothing there and a
723
+ * fan-out of `Promise.all` over hundreds of ids only makes the queue less fair
724
+ * to everything else on it. The one part that DOES amortise across the whole
725
+ * set — the device row lookup — is fetched ONCE, ahead of the loop
726
+ * ({@link DeviceRowStore.getMany}), rather than once per iteration: measured
727
+ * on the live hub 2026-08-25, `get device-manager:devices` ran 1 656
728
+ * calls/min steady-state, one row per call, which is exactly what looping
729
+ * `getBindings`'s own `rows.get(deviceId)` here produced.
707
730
  */
708
731
  async function getBindingsBatch(deps, input) {
732
+ const ids = [...new Set(input.deviceIds)];
733
+ const rows = await deps.rows.getMany(ids);
709
734
  const out = [];
710
- for (const deviceId of new Set(input.deviceIds)) out.push(await getBindings(deps, { deviceId }));
735
+ for (const deviceId of ids) out.push(await resolveBindingsForDevice(deps, deviceId, rows.get(deviceId) ?? null));
711
736
  return out;
712
737
  }
713
738
  /**
@@ -722,8 +747,13 @@ async function getBindingsBatch(deps, input) {
722
747
  * payload periodically.
723
748
  */
724
749
  async function getAllBindings(deps) {
750
+ const fleet = await deps.rows.listAll();
751
+ const rowById = /* @__PURE__ */ new Map();
725
752
  const ids = /* @__PURE__ */ new Set();
726
- for (const row of await deps.rows.listAll()) ids.add(row.meta.id);
753
+ for (const row of fleet) {
754
+ rowById.set(row.meta.id, row);
755
+ ids.add(row.meta.id);
756
+ }
727
757
  const registered = deps.ctx.kernel?.deviceRegistry?.getAll() ?? [];
728
758
  for (const device of registered) ids.add(device.id);
729
759
  if (ids.size === 0) {
@@ -731,7 +761,7 @@ async function getAllBindings(deps) {
731
761
  return [];
732
762
  }
733
763
  const out = [];
734
- for (const deviceId of [...ids].sort((a, b) => a - b)) out.push(await getBindings(deps, { deviceId }));
764
+ for (const deviceId of [...ids].sort((a, b) => a - b)) out.push(await resolveBindingsForDevice(deps, deviceId, rowById.get(deviceId) ?? null));
735
765
  return out;
736
766
  }
737
767
  /**
@@ -4324,6 +4354,24 @@ var DeviceRowStore = class {
4324
4354
  }, opts.slim === true ? DEVICE_ROWS_SLIM_COLUMNS : void 0);
4325
4355
  }
4326
4356
  /**
4357
+ * Many devices, by numeric id, in ONE query.
4358
+ *
4359
+ * `get(id)` called once per id in a loop is the primary-key lookup this
4360
+ * store exists to make cheap, repeated until it isn't — measured on the
4361
+ * live hub 2026-08-25: `get device-manager:devices` at 1 656 calls/min
4362
+ * steady-state and 17 687 during boot, exactly one row per call. This
4363
+ * collapses that into the same `whereIn` {@link listFleet} already does for
4364
+ * a fleet read, keyed by id.
4365
+ *
4366
+ * A requested id the fleet does not know is simply ABSENT from the map —
4367
+ * never a fabricated row, matching {@link get}'s `null`. An empty `ids`
4368
+ * reads nothing at all, same as `listFleet({ deviceIds: [] })`.
4369
+ */
4370
+ async getMany(ids) {
4371
+ const rows = await this.listFleet({ deviceIds: ids });
4372
+ return new Map(rows.map((row) => [row.meta.id, row]));
4373
+ }
4374
+ /**
4327
4375
  * The device an addon knows as `stableId`, or `null`.
4328
4376
  *
4329
4377
  * `(addonId, stableId)` is the addon-facing identity — unique by
@@ -243,6 +243,21 @@ export declare class DeviceRowStore {
243
243
  readonly deviceIds?: readonly number[];
244
244
  readonly slim?: boolean;
245
245
  }): Promise<readonly DeviceRow[]>;
246
+ /**
247
+ * Many devices, by numeric id, in ONE query.
248
+ *
249
+ * `get(id)` called once per id in a loop is the primary-key lookup this
250
+ * store exists to make cheap, repeated until it isn't — measured on the
251
+ * live hub 2026-08-25: `get device-manager:devices` at 1 656 calls/min
252
+ * steady-state and 17 687 during boot, exactly one row per call. This
253
+ * collapses that into the same `whereIn` {@link listFleet} already does for
254
+ * a fleet read, keyed by id.
255
+ *
256
+ * A requested id the fleet does not know is simply ABSENT from the map —
257
+ * never a fabricated row, matching {@link get}'s `null`. An empty `ids`
258
+ * reads nothing at all, same as `listFleet({ deviceIds: [] })`.
259
+ */
260
+ getMany(ids: readonly number[]): Promise<ReadonlyMap<number, DeviceRow>>;
246
261
  /**
247
262
  * The device an addon knows as `stableId`, or `null`.
248
263
  *
@@ -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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
7
  //#region src/builtins/doorbell/trigger-engine.ts
8
8
  /**
9
9
  * Pure trigger logic for the virtual-doorbell builtin — edge detection over
@@ -1,4 +1,4 @@
1
- import { G as isSameAddonId, Gt as EventCategory, I as doorbellCapability, Mt as createEvent, Tt as DeviceType, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { G as isSameAddonId, Gt as EventCategory, I as doorbellCapability, Mt as createEvent, Tt as DeviceType, vt as errMsg, w as bareAddonId, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  //#region src/builtins/doorbell/trigger-engine.ts
3
3
  /**
4
4
  * Pure trigger logic for the virtual-doorbell builtin — edge detection over
@@ -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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
9
9
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -1,4 +1,4 @@
1
- import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { X as logDestinationCapability, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
4
4
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-D-R0SuP-.js");
3
+ const require_dist = require("../../dist-mQ3BkrJd.js");
4
4
  //#region src/builtins/liveness-monitor/liveness-checks.ts
5
5
  var NO_DEVICES = "liveness:no-devices";
6
6
  var ALL_OFFLINE = "liveness:all-devices-offline";
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, Mt as createEvent, vt as errMsg, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { Gt as EventCategory, Mt as createEvent, vt as errMsg, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  //#region src/builtins/liveness-monitor/liveness-checks.ts
3
3
  var NO_DEVICES = "liveness:no-devices";
4
4
  var ALL_OFFLINE = "liveness:all-devices-offline";
@@ -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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  node_crypto = require_chunk.__toESM(node_crypto);
9
9
  let crypto$1 = require("crypto");
@@ -1,5 +1,5 @@
1
1
  import { i as __require, o as __toESM, t as __commonJSMin } from "../../chunk-CNf5ZN-e.mjs";
2
- import { S as authProviderCapability, _ as UserRecordSchema, ht as userManagementCapability, m as ScopedTokenSchema, r as ApiKeyRecordSchema, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
2
+ import { S as authProviderCapability, _ as UserRecordSchema, ht as userManagementCapability, m as ScopedTokenSchema, r as ApiKeyRecordSchema, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
3
3
  import * as crypto$2 from "node:crypto";
4
4
  import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
5
5
  import nodeCrypto from "crypto";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  const require_chunk = require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-D-R0SuP-.js");
3
+ const require_dist = require("../../dist-mQ3BkrJd.js");
4
4
  const require_tls = require("../../tls-u8QCJCFE.js");
5
5
  let node_fs_promises = require("node:fs/promises");
6
6
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Gt as EventCategory, Y as localNetworkCapability, yt as BaseAddon } from "../../dist-Bh25kEUH.mjs";
1
+ import { Gt as EventCategory, Y as localNetworkCapability, yt as BaseAddon } from "../../dist-DMOTtKH8.mjs";
2
2
  import { S as readLanHttpState, _ as DEFAULT_LAN_HTTP_PORT, a as writeTlsMode, i as writeExtraSans, l as reissueTlsLeaf, n as readTlsAccessStatus, o as validateUploadedTls, r as readTlsMode, s as ensureTlsCert, t as readExtraSans, y as applyLanHttp } from "../../tls-CQhPGSJm.mjs";
3
3
  import { mkdir, writeFile } from "node:fs/promises";
4
4
  import { join } 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-D-R0SuP-.js");
6
+ const require_dist = require("../../dist-mQ3BkrJd.js");
7
7
  //#region src/builtins/loki-logging/loki-payload.ts
8
8
  /**
9
9
  * Loki rejects a label name that is not a valid Prometheus label