@camstack/system 1.2.455 → 1.2.457

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 (133) hide show
  1. package/dist/addon-runner.js +96 -10
  2. package/dist/addon-runner.mjs +96 -10
  3. package/dist/{agent-https-CLWrOO3o.mjs → agent-https-CK9Z4sSR.mjs} +32 -5
  4. package/dist/{agent-https-CCvlRQKV.js → agent-https-CoyOZ3pC.js} +37 -4
  5. package/dist/auth/auth-manager.d.ts +9 -0
  6. package/dist/auth/legacy-token-tables.d.ts +16 -0
  7. package/dist/auth/user-management-internal.d.ts +9 -28
  8. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  9. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  10. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  11. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  12. package/dist/builtins/alerts/alerts.addon.js +2 -2
  13. package/dist/builtins/alerts/alerts.addon.mjs +2 -2
  14. package/dist/builtins/autotrack/index.js +1 -1
  15. package/dist/builtins/autotrack/index.mjs +1 -1
  16. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +2 -2
  17. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +2 -2
  18. package/dist/builtins/calendars/calendars.addon.js +1 -1
  19. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  20. package/dist/builtins/camera-grid/index.js +1 -1
  21. package/dist/builtins/camera-grid/index.mjs +1 -1
  22. package/dist/builtins/composer/composer.addon.js +2 -2
  23. package/dist/builtins/composer/composer.addon.mjs +2 -2
  24. package/dist/builtins/console-logging/console-destination.d.ts +1 -2
  25. package/dist/builtins/console-logging/index.js +1 -4
  26. package/dist/builtins/console-logging/index.mjs +1 -4
  27. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  28. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  29. package/dist/builtins/device-history/capture/capture-engine.d.ts +6 -0
  30. package/dist/builtins/device-history/device-history.addon.js +441 -83
  31. package/dist/builtins/device-history/device-history.addon.mjs +441 -83
  32. package/dist/builtins/device-history/query/history-query.d.ts +35 -9
  33. package/dist/builtins/device-history/query/point-shape.d.ts +33 -0
  34. package/dist/builtins/device-history/retention/retention.d.ts +1 -1
  35. package/dist/builtins/device-history/rollup/rollup-engine.d.ts +2 -0
  36. package/dist/builtins/device-history/rollup/rollup-math.d.ts +6 -0
  37. package/dist/builtins/device-history/store/history-store.d.ts +7 -0
  38. package/dist/builtins/device-history/store/series-registry.d.ts +26 -1
  39. package/dist/builtins/device-manager/device-manager.addon.js +1 -1
  40. package/dist/builtins/device-manager/device-manager.addon.mjs +1 -1
  41. package/dist/builtins/hub-forwarder/hub-forwarder-destination.d.ts +1 -2
  42. package/dist/builtins/hub-forwarder/index.js +1 -4
  43. package/dist/builtins/hub-forwarder/index.mjs +1 -4
  44. package/dist/builtins/keychain/index.js +4 -4
  45. package/dist/builtins/keychain/index.mjs +4 -4
  46. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  47. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  48. package/dist/builtins/local-auth/auth-schema.d.ts +4 -7
  49. package/dist/builtins/local-auth/local-auth.addon.d.ts +7 -8
  50. package/dist/builtins/local-auth/local-auth.addon.js +1086 -1329
  51. package/dist/builtins/local-auth/local-auth.addon.mjs +1085 -1326
  52. package/dist/builtins/local-auth/preferences-record-kinds.d.ts +27 -0
  53. package/dist/builtins/local-auth/record-kinds.d.ts +4 -3
  54. package/dist/builtins/local-auth/user-preferences-store.d.ts +56 -0
  55. package/dist/builtins/local-network/local-network.addon.d.ts +8 -0
  56. package/dist/builtins/local-network/local-network.addon.js +30 -5
  57. package/dist/builtins/local-network/local-network.addon.mjs +30 -5
  58. package/dist/builtins/loki-logging/index.js +323 -7
  59. package/dist/builtins/loki-logging/index.mjs +323 -7
  60. package/dist/builtins/loki-logging/loki-destination.d.ts +20 -3
  61. package/dist/builtins/loki-logging/loki-read.d.ts +51 -0
  62. package/dist/builtins/native-metrics/native-metrics.addon.js +290 -112
  63. package/dist/builtins/native-metrics/native-metrics.addon.mjs +290 -112
  64. package/dist/builtins/native-metrics/node-metrics-history-recorder.d.ts +106 -35
  65. package/dist/builtins/platform-probe/index.js +1 -1
  66. package/dist/builtins/platform-probe/index.mjs +1 -1
  67. package/dist/builtins/record-entries/index.js +1 -1
  68. package/dist/builtins/record-entries/index.mjs +1 -1
  69. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  70. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  71. package/dist/builtins/snapshot/index.js +1 -1
  72. package/dist/builtins/snapshot/index.mjs +1 -1
  73. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  74. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  75. package/dist/builtins/sqlite-storage/index.js +1 -1
  76. package/dist/builtins/sqlite-storage/index.mjs +1 -1
  77. package/dist/builtins/sqlite-storage/records/records-engine-types.d.ts +1 -0
  78. package/dist/builtins/sqlite-storage/records/records-provider.d.ts +13 -0
  79. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +52 -6
  80. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +52 -6
  81. package/dist/builtins/storage-orchestrator/location-history-recorder.d.ts +76 -0
  82. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.d.ts +9 -0
  83. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +144 -1
  84. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +144 -1
  85. package/dist/builtins/system-config/system-config.addon.js +3 -3
  86. package/dist/builtins/system-config/system-config.addon.mjs +3 -3
  87. package/dist/builtins/winston-logging/index.js +165 -3
  88. package/dist/builtins/winston-logging/index.mjs +165 -3
  89. package/dist/builtins/winston-logging/log-file-cursor.d.ts +12 -0
  90. package/dist/builtins/winston-logging/log-file-index-store.d.ts +11 -0
  91. package/dist/builtins/winston-logging/log-file-index.d.ts +77 -0
  92. package/dist/builtins/winston-logging/log-file-read-client.d.ts +44 -0
  93. package/dist/builtins/winston-logging/log-file-read-protocol.d.ts +41 -0
  94. package/dist/builtins/winston-logging/log-file-read-worker.d.ts +1 -0
  95. package/dist/builtins/winston-logging/log-file-reader.d.ts +51 -0
  96. package/dist/builtins/winston-logging/winston-destination.d.ts +20 -2
  97. package/dist/{composition-sources-CSzD5_qX.mjs → composition-sources-B_jeZDRJ.mjs} +1 -1
  98. package/dist/{composition-sources-BxUkLNSo.js → composition-sources-qKyvMAvc.js} +1 -1
  99. package/dist/{constants-DruwCkfp.js → constants-B_X9cWEK.js} +1 -1
  100. package/dist/{constants-DOlYt1t1.mjs → constants-cxKcZRMi.mjs} +1 -1
  101. package/dist/{device-ca-uFbTyY_o.mjs → device-ca-BB6nHAL5.mjs} +1 -1
  102. package/dist/{device-ca-QPBgfqVY.js → device-ca-CVK3YcR_.js} +1 -1
  103. package/dist/{dist-DjQ8C-ku.js → dist-C89nqNnn.js} +721 -154
  104. package/dist/{dist-BpSENkRJ.mjs → dist-Dhux90yB.mjs} +668 -155
  105. package/dist/file-host-worker.js +1 -1
  106. package/dist/file-host-worker.mjs +1 -1
  107. package/dist/{hub-mdns-ciao-DlgkFJVY.mjs → hub-mdns-ciao-B8olZqqd.mjs} +20 -13
  108. package/dist/{hub-mdns-ciao-Bkrvgnma.js → hub-mdns-ciao-DB1Y9agt.js} +20 -13
  109. package/dist/index.d.ts +3 -4
  110. package/dist/index.js +145 -24
  111. package/dist/index.mjs +138 -22
  112. package/dist/kernel/config-schema.d.ts +5 -0
  113. package/dist/kernel/moleculer/accessory-prune-gate.d.ts +55 -0
  114. package/dist/log-file-read-protocol-B7M3X3bT.mjs +785 -0
  115. package/dist/log-file-read-protocol-D0WcLbIV.js +817 -0
  116. package/dist/log-file-read-worker.js +64 -0
  117. package/dist/log-file-read-worker.mjs +64 -0
  118. package/dist/log-read-filter-Bi066jwU.js +134 -0
  119. package/dist/log-read-filter-D7Ev3zm-.mjs +93 -0
  120. package/dist/logging/log-manager.d.ts +10 -6
  121. package/dist/logging/log-read-filter.d.ts +43 -0
  122. package/dist/{phase6-declare-gate-DrmTtz7F.js → phase6-declare-gate-BO-_jLh_.js} +1 -1
  123. package/dist/{phase6-declare-gate-JQUqgQgq.mjs → phase6-declare-gate-x9ZCbQJP.mjs} +1 -1
  124. package/dist/{restore-archive-4OP0EYg6.js → restore-archive-4DOUR5Gu.js} +1 -1
  125. package/dist/{restore-archive-YFSJRtKy.mjs → restore-archive-DyOaPeAr.mjs} +1 -1
  126. package/dist/tls/cert-issue.d.ts +16 -1
  127. package/dist/tls/cert-manager.d.ts +6 -0
  128. package/dist/tls/index.d.ts +1 -1
  129. package/dist/{wal-maintenance-TyuOEVy1.mjs → wal-maintenance-BMiX6UIa.mjs} +0 -0
  130. package/dist/{wal-maintenance-Bl0ZKjVR.js → wal-maintenance-DVN-DiVP.js} +0 -0
  131. package/package.json +1 -1
  132. package/dist/auth/admin-token-manager.d.ts +0 -51
  133. package/dist/auth/scoped-token-manager.d.ts +0 -25
@@ -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-DjQ8C-ku.js");
6
+ const require_dist = require("../../dist-C89nqNnn.js");
7
7
  let node_util = require("node:util");
8
8
  let node_os = require("node:os");
9
9
  node_os = require_chunk.__toESM(node_os);
@@ -1,5 +1,5 @@
1
1
  import { o as __toESM, r as __exportAll } from "../../chunk-CNf5ZN-e.mjs";
2
- import { $t as enumerateInferenceDevices, Kn as platformProbeCapability, Kr as errMsg, qr as BaseAddon, ur as scoreRuntimes, ya as EventCategory, zi as emitReadiness } from "../../dist-BpSENkRJ.mjs";
2
+ import { Ji as emitReadiness, Oa as EventCategory, ni as BaseAddon, sn as enumerateInferenceDevices, ti as errMsg, tr as platformProbeCapability, yr as scoreRuntimes } from "../../dist-Dhux90yB.mjs";
3
3
  import { promisify } from "node:util";
4
4
  import * as os$1 from "node:os";
5
5
  import * as fs from "node:fs";
@@ -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-DjQ8C-ku.js");
6
+ const require_dist = require("../../dist-C89nqNnn.js");
7
7
  let zod = require("zod");
8
8
  let node_crypto = require("node:crypto");
9
9
  //#region src/builtins/record-entries/entries-service.ts
@@ -1,4 +1,4 @@
1
- import { Si as UnknownRecordKindError, Yn as recordEntriesCapability, Zi as mapSecretLeaves, qr as BaseAddon, ri as InvalidRecordError, sa as recordSecretRef } from "../../dist-BpSENkRJ.mjs";
1
+ import { fi as InvalidRecordError, ga as recordSecretRef, ir as recordEntriesCapability, ji as UnknownRecordKindError, ni as BaseAddon, oa as mapSecretLeaves } from "../../dist-Dhux90yB.mjs";
2
2
  import { z } from "zod";
3
3
  import { randomUUID } from "node:crypto";
4
4
  //#region src/builtins/record-entries/entries-service.ts
@@ -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-DjQ8C-ku.js");
6
+ const require_dist = require("../../dist-C89nqNnn.js");
7
7
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
8
8
  /**
9
9
  * Reconcile the durable `enabledProviders` set against authoritative
@@ -1,4 +1,4 @@
1
- import { qr as BaseAddon, ya as EventCategory } from "../../dist-BpSENkRJ.mjs";
1
+ import { Oa as EventCategory, ni as BaseAddon } from "../../dist-Dhux90yB.mjs";
2
2
  //#region src/builtins/remote-access-orchestrator/enabled-providers-reconcile.ts
3
3
  /**
4
4
  * Reconcile the durable `enabledProviders` set against authoritative
@@ -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-DjQ8C-ku.js");
6
+ const require_dist = require("../../dist-C89nqNnn.js");
7
7
  const require_snapshot_courtesy = require("../../snapshot-courtesy-D_C5-nC0.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
@@ -1,4 +1,4 @@
1
- import { Fn as memoizePinnedFfmpeg, Gr as DeviceType, Kr as errMsg, Qi as nodePin, Sr as streamQualityLabel, Ur as DeviceFeature, Wt as deriveBatteryPresence, bt as bareAddonId, mr as snapshotCapability, qr as BaseAddon, s as BatteryStatusSchema, xt as batteryCapability, ya as EventCategory } from "../../dist-BpSENkRJ.mjs";
1
+ import { Cr as snapshotCapability, Oa as EventCategory, Ot as bareAddonId, Qr as DeviceFeature, Qt as deriveBatteryPresence, Wn as memoizePinnedFfmpeg, ei as DeviceType, jr as streamQualityLabel, kt as batteryCapability, ni as BaseAddon, s as BatteryStatusSchema, sa as nodePin, ti as errMsg } from "../../dist-Dhux90yB.mjs";
2
2
  import { i as renderCourtesyOverlayJpeg, n as courtesyCacheKey, r as renderCourtesyJpeg } from "../../snapshot-courtesy-CyFs1M3I.mjs";
3
3
  import { z } from "zod";
4
4
  import { randomUUID } from "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-DjQ8C-ku.js");
6
+ const require_dist = require("../../dist-C89nqNnn.js");
7
7
  let node_crypto = require("node:crypto");
8
8
  let node_fs_promises = require("node:fs/promises");
9
9
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { br as storageProviderCapability, qr as BaseAddon, sn as filesystemBrowseCapability } from "../../dist-BpSENkRJ.mjs";
1
+ import { hn as filesystemBrowseCapability, kr as storageProviderCapability, ni as BaseAddon } from "../../dist-Dhux90yB.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { mkdir, readdir, realpath, statfs } from "node:fs/promises";
4
4
  import * as path$1 from "node:path";
@@ -4,7 +4,7 @@ Object.defineProperties(exports, {
4
4
  });
5
5
  require("../../chunk-Cek0wNdY.js");
6
6
  const require_builtins_sqlite_storage_filesystem_storage_addon = require("./filesystem-storage.addon.js");
7
- const require_wal_maintenance = require("../../wal-maintenance-Bl0ZKjVR.js");
7
+ const require_wal_maintenance = require("../../wal-maintenance-DVN-DiVP.js");
8
8
  const require_builtins_sqlite_storage_sqlite_settings_addon = require("./sqlite-settings.addon.js");
9
9
  //#region src/builtins/sqlite-storage/config-store.ts
10
10
  var ConfigStore = class {
@@ -1,5 +1,5 @@
1
1
  import { FilesystemStorageAddon, t as FilesystemStorageProvider } from "./filesystem-storage.addon.mjs";
2
- import { A as SQLITE_MMAP_CEILING_BYTES, B as SQLITE_SLOW_CALL_MS, F as sqlitePageCacheKibFor, H as sqliteEngineStorm, I as SQLITE_ENGINE_STORM_WALL_SHARE, L as SQLITE_PROFILE_REPORT_FLOOR_MS, M as SQLITE_PAGE_CACHE_CEILING_KIB, N as SQLITE_PAGE_CACHE_FLOOR_KIB, P as sqliteMmapSizeFor, R as SQLITE_PROFILE_REPORT_INTERVAL_MS, V as SqliteOpProfiler, a as WalMaintenance, i as WAL_MAINTENANCE_INTERVAL_MS, j as SQLITE_MMAP_FLOOR_BYTES, k as SQLITE_JOURNAL_SIZE_LIMIT_BYTES, l as SqliteSettingsBackend, n as WAL_HIGH_WATER_BYTES, r as WAL_IDLE_QUIET_MS, t as WAL_CHECKPOINT_BUSY_TIMEOUT_MS, z as SQLITE_PROFILE_TOP_N } from "../../wal-maintenance-TyuOEVy1.mjs";
2
+ import { A as SQLITE_MMAP_CEILING_BYTES, B as SQLITE_SLOW_CALL_MS, F as sqlitePageCacheKibFor, H as sqliteEngineStorm, I as SQLITE_ENGINE_STORM_WALL_SHARE, L as SQLITE_PROFILE_REPORT_FLOOR_MS, M as SQLITE_PAGE_CACHE_CEILING_KIB, N as SQLITE_PAGE_CACHE_FLOOR_KIB, P as sqliteMmapSizeFor, R as SQLITE_PROFILE_REPORT_INTERVAL_MS, V as SqliteOpProfiler, a as WalMaintenance, i as WAL_MAINTENANCE_INTERVAL_MS, j as SQLITE_MMAP_FLOOR_BYTES, k as SQLITE_JOURNAL_SIZE_LIMIT_BYTES, l as SqliteSettingsBackend, n as WAL_HIGH_WATER_BYTES, r as WAL_IDLE_QUIET_MS, t as WAL_CHECKPOINT_BUSY_TIMEOUT_MS, z as SQLITE_PROFILE_TOP_N } from "../../wal-maintenance-BMiX6UIa.mjs";
3
3
  import { SqliteSettingsAddon } from "./sqlite-settings.addon.mjs";
4
4
  //#region src/builtins/sqlite-storage/config-store.ts
5
5
  var ConfigStore = class {
@@ -14,6 +14,7 @@ export interface RecordsEngineOps extends OwnedOps {
14
14
  /** Every kind this file holds, with rows and a size estimate (System -> Data). */
15
15
  listKinds(input: {
16
16
  readonly owner?: string | undefined;
17
+ readonly counts?: boolean | undefined;
17
18
  }): Promise<readonly StorageKind[]>;
18
19
  /** Delete rows past `expires_at`, in batches. */
19
20
  sweepExpired(input: {
@@ -29,6 +29,19 @@ export declare class RecordsProvider implements IRecordsProvider, AdminRecords {
29
29
  init(): Promise<void>;
30
30
  private fileOf;
31
31
  declareKinds(input: Parameters<IRecordsProvider["declareKinds"]>[0]): ReturnType<IRecordsProvider["declareKinds"]>;
32
+ /**
33
+ * Rows of a legacy table in EVERY open records-capable file. A legacy table lives
34
+ * in one file, but which one is the layout's business: the phase-3 NC ledgers moved
35
+ * to `events.db` with the P5 split, and a guard that asked `camstack.db` alone
36
+ * answered "no legacy rows" for 522 outbox rows (2026-10-20 audit).
37
+ */
38
+ private legacyRowsAnywhere;
39
+ /**
40
+ * `transactFamily` (plan risk 8): kinds that must agree through one `transact` sit
41
+ * in ONE file. A family split across files is refused whole, whether the split is
42
+ * inside this declaration or against a kind of the same owner declared before.
43
+ */
44
+ private assertFamiliesInOneFile;
32
45
  /** The boot guard: empty kind + a legacy table that still has rows = adoption pending. */
33
46
  private withAdoption;
34
47
  get(input: Parameters<IRecordsProvider["get"]>[0]): ReturnType<IRecordsProvider["get"]>;
@@ -3,9 +3,9 @@ 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-DjQ8C-ku.js");
6
+ const require_dist = require("../../dist-C89nqNnn.js");
7
7
  const require_retired_settings_keys = require("../../retired-settings-keys-D_VwZiDt.js");
8
- const require_wal_maintenance = require("../../wal-maintenance-Bl0ZKjVR.js");
8
+ const require_wal_maintenance = require("../../wal-maintenance-DVN-DiVP.js");
9
9
  const require_sqlite_snapshot_protocol = require("../../sqlite-snapshot-protocol-B9OndqZv.js");
10
10
  const require_wal_checkpoint_policy = require("../../wal-checkpoint-policy-d2z2qPqx.js");
11
11
  let node_fs_promises = require("node:fs/promises");
@@ -1349,8 +1349,10 @@ var RecordsProvider = class {
1349
1349
  async declareKinds(input) {
1350
1350
  const owner = recordsCallerOf(input);
1351
1351
  const byDatabase = /* @__PURE__ */ new Map();
1352
- for (const [kind, raw] of Object.entries(input.kinds)) {
1353
- const declaration = require_dist.RecordKindDeclarationSchema.parse(raw);
1352
+ const parsed = /* @__PURE__ */ new Map();
1353
+ for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, require_dist.RecordKindDeclarationSchema.parse(raw));
1354
+ await this.assertFamiliesInOneFile(owner, parsed);
1355
+ for (const [kind, declaration] of parsed) {
1354
1356
  const known = this.placement.get(keyOf(owner, kind));
1355
1357
  if (known !== void 0 && known !== declaration.database) throw new require_dist.DeclarationRefusedError(`kind "${kind}" of "${owner}" lives in "${known}", declared for "${declaration.database}" - the engine never moves data`);
1356
1358
  const group = byDatabase.get(declaration.database) ?? {};
@@ -1372,6 +1374,50 @@ var RecordsProvider = class {
1372
1374
  }
1373
1375
  return { kinds: await this.withAdoption(owner, input.kinds, merged) };
1374
1376
  }
1377
+ /**
1378
+ * Rows of a legacy table in EVERY open records-capable file. A legacy table lives
1379
+ * in one file, but which one is the layout's business: the phase-3 NC ledgers moved
1380
+ * to `events.db` with the P5 split, and a guard that asked `camstack.db` alone
1381
+ * answered "no legacy rows" for 522 outbox rows (2026-10-20 audit).
1382
+ */
1383
+ async legacyRowsAnywhere(table) {
1384
+ let total = 0;
1385
+ for (const file of this.router.openFiles()) {
1386
+ if (file.databaseId === "history") continue;
1387
+ const rows = await file.records("legacyRowCount", { table });
1388
+ if (rows !== null) total += rows;
1389
+ }
1390
+ return total;
1391
+ }
1392
+ /**
1393
+ * `transactFamily` (plan risk 8): kinds that must agree through one `transact` sit
1394
+ * in ONE file. A family split across files is refused whole, whether the split is
1395
+ * inside this declaration or against a kind of the same owner declared before.
1396
+ */
1397
+ async assertFamiliesInOneFile(owner, declared) {
1398
+ const families = /* @__PURE__ */ new Map();
1399
+ const note = (family, kind, database) => {
1400
+ const members = families.get(family) ?? /* @__PURE__ */ new Map();
1401
+ members.set(kind, database);
1402
+ families.set(family, members);
1403
+ };
1404
+ for (const file of this.router.openFiles()) {
1405
+ if (file.databaseId === "history") continue;
1406
+ for (const k of await file.records("listKinds", {
1407
+ owner,
1408
+ counts: false
1409
+ })) {
1410
+ if (k.state === "dropped" || declared.has(k.kind)) continue;
1411
+ const family = k.declaration.transactFamily;
1412
+ if (family !== void 0) note(family, k.kind, file.databaseId);
1413
+ }
1414
+ }
1415
+ for (const [kind, declaration] of declared) if (declaration.transactFamily !== void 0) note(declaration.transactFamily, kind, declaration.database);
1416
+ for (const [family, members] of families) {
1417
+ if (new Set(members.values()).size <= 1) continue;
1418
+ throw new require_dist.DeclarationRefusedError(`transactFamily "${family}" of "${owner}" is split across files (${[...members.entries()].map(([k, db]) => `${k}@${db}`).join(", ")}); a family lives in ONE file`);
1419
+ }
1420
+ }
1375
1421
  /** The boot guard: empty kind + a legacy table that still has rows = adoption pending. */
1376
1422
  async withAdoption(owner, declared, results) {
1377
1423
  const out = { ...results };
@@ -1407,8 +1453,8 @@ var RecordsProvider = class {
1407
1453
  };
1408
1454
  continue;
1409
1455
  }
1410
- const legacyRows = await (await this.router.recordsFileFor("settings")).records("legacyRowCount", { table: legacy });
1411
- if (legacyRows !== null && legacyRows > 0) out[kind] = {
1456
+ const legacyRows = await this.legacyRowsAnywhere(legacy);
1457
+ if (legacyRows > 0) out[kind] = {
1412
1458
  ...result,
1413
1459
  adoptionPending: {
1414
1460
  legacyTable: legacy,
@@ -1,6 +1,6 @@
1
- import { $ as STORAGE_ADMIN_MOVED_COLLECTIONS, $r as DeclarationRefusedError, Bt as databaseSnapshotCapability, C as DATA_STORE_DATABASES, Kr as errMsg, S as DATABASE_SNAPSHOT_TIMEOUT_MS, Si as UnknownRecordKindError, Xn as recordsCapability, aa as parseSettingsBrokersAdoptsFrom, b as DATABASE_SNAPSHOT_PARTIAL_SUFFIX, bt as bareAddonId, ea as normalizeSecretOwner, et as STORAGE_ADMIN_SCOPED_BASES, fi as RUNTIME_DEFAULTS, gr as storageAdminCapability, hi as RecordKindDeclarationSchema, ia as parseSettingsArrayAdoptsFrom, ii as NoCallerError, kr as vectorStoreCapability, li as RECORD_SWEEP_INTERVAL_MS, qr as BaseAddon, x as DATABASE_SNAPSHOT_SUFFIX, zt as dataStoreProviderCapability } from "../../dist-BpSENkRJ.mjs";
1
+ import { C as DATABASE_SNAPSHOT_TIMEOUT_MS, Jt as databaseSnapshotCapability, Ot as bareAddonId, Rr as vectorStoreCapability, S as DATABASE_SNAPSHOT_SUFFIX, Tr as storageAdminCapability, ar as recordsCapability, ci as DeclarationRefusedError, ji as UnknownRecordKindError, la as normalizeSecretOwner, ma as parseSettingsBrokersAdoptsFrom, ni as BaseAddon, ot as STORAGE_ADMIN_MOVED_COLLECTIONS, pa as parseSettingsArrayAdoptsFrom, pi as NoCallerError, qt as dataStoreProviderCapability, st as STORAGE_ADMIN_SCOPED_BASES, ti as errMsg, vi as RECORD_SWEEP_INTERVAL_MS, w as DATA_STORE_DATABASES, wi as RecordKindDeclarationSchema, x as DATABASE_SNAPSHOT_PARTIAL_SUFFIX, xi as RUNTIME_DEFAULTS } from "../../dist-Dhux90yB.mjs";
2
2
  import { i as retiredKeyStoreOf, n as purgeRetiredSettingsKeys } from "../../retired-settings-keys-Bhwe4ymb.mjs";
3
- import { C as RecordsEngine, D as callVector, E as callRecords, O as controlTargetOf, S as trustResult, T as callData, _ as collectTransferables, a as WalMaintenance, c as vectorProviderOfOwnedFile, d as CrossDatabaseTransactError, f as DatabaseBusyError, l as SqliteSettingsBackend, m as rehydrateError, o as createVectorIndex, p as DuplicatePlacementError, s as vectorProviderOf, u as CollectionPlacementError, v as isFileHostMessage, w as callControl } from "../../wal-maintenance-TyuOEVy1.mjs";
3
+ import { C as RecordsEngine, D as callVector, E as callRecords, O as controlTargetOf, S as trustResult, T as callData, _ as collectTransferables, a as WalMaintenance, c as vectorProviderOfOwnedFile, d as CrossDatabaseTransactError, f as DatabaseBusyError, l as SqliteSettingsBackend, m as rehydrateError, o as createVectorIndex, p as DuplicatePlacementError, s as vectorProviderOf, u as CollectionPlacementError, v as isFileHostMessage, w as callControl } from "../../wal-maintenance-BMiX6UIa.mjs";
4
4
  import { r as isSnapshotWorkerMessage } from "../../sqlite-snapshot-protocol-2QaTouWV.mjs";
5
5
  import { a as isWorkerMessage, t as WAL_CHECKPOINT_LARGE_PASS_FRAMES } from "../../wal-checkpoint-policy-BahrTtyD.mjs";
6
6
  import { createRequire } from "node:module";
@@ -1343,8 +1343,10 @@ var RecordsProvider = class {
1343
1343
  async declareKinds(input) {
1344
1344
  const owner = recordsCallerOf(input);
1345
1345
  const byDatabase = /* @__PURE__ */ new Map();
1346
- for (const [kind, raw] of Object.entries(input.kinds)) {
1347
- const declaration = RecordKindDeclarationSchema.parse(raw);
1346
+ const parsed = /* @__PURE__ */ new Map();
1347
+ for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, RecordKindDeclarationSchema.parse(raw));
1348
+ await this.assertFamiliesInOneFile(owner, parsed);
1349
+ for (const [kind, declaration] of parsed) {
1348
1350
  const known = this.placement.get(keyOf(owner, kind));
1349
1351
  if (known !== void 0 && known !== declaration.database) throw new DeclarationRefusedError(`kind "${kind}" of "${owner}" lives in "${known}", declared for "${declaration.database}" - the engine never moves data`);
1350
1352
  const group = byDatabase.get(declaration.database) ?? {};
@@ -1366,6 +1368,50 @@ var RecordsProvider = class {
1366
1368
  }
1367
1369
  return { kinds: await this.withAdoption(owner, input.kinds, merged) };
1368
1370
  }
1371
+ /**
1372
+ * Rows of a legacy table in EVERY open records-capable file. A legacy table lives
1373
+ * in one file, but which one is the layout's business: the phase-3 NC ledgers moved
1374
+ * to `events.db` with the P5 split, and a guard that asked `camstack.db` alone
1375
+ * answered "no legacy rows" for 522 outbox rows (2026-10-20 audit).
1376
+ */
1377
+ async legacyRowsAnywhere(table) {
1378
+ let total = 0;
1379
+ for (const file of this.router.openFiles()) {
1380
+ if (file.databaseId === "history") continue;
1381
+ const rows = await file.records("legacyRowCount", { table });
1382
+ if (rows !== null) total += rows;
1383
+ }
1384
+ return total;
1385
+ }
1386
+ /**
1387
+ * `transactFamily` (plan risk 8): kinds that must agree through one `transact` sit
1388
+ * in ONE file. A family split across files is refused whole, whether the split is
1389
+ * inside this declaration or against a kind of the same owner declared before.
1390
+ */
1391
+ async assertFamiliesInOneFile(owner, declared) {
1392
+ const families = /* @__PURE__ */ new Map();
1393
+ const note = (family, kind, database) => {
1394
+ const members = families.get(family) ?? /* @__PURE__ */ new Map();
1395
+ members.set(kind, database);
1396
+ families.set(family, members);
1397
+ };
1398
+ for (const file of this.router.openFiles()) {
1399
+ if (file.databaseId === "history") continue;
1400
+ for (const k of await file.records("listKinds", {
1401
+ owner,
1402
+ counts: false
1403
+ })) {
1404
+ if (k.state === "dropped" || declared.has(k.kind)) continue;
1405
+ const family = k.declaration.transactFamily;
1406
+ if (family !== void 0) note(family, k.kind, file.databaseId);
1407
+ }
1408
+ }
1409
+ for (const [kind, declaration] of declared) if (declaration.transactFamily !== void 0) note(declaration.transactFamily, kind, declaration.database);
1410
+ for (const [family, members] of families) {
1411
+ if (new Set(members.values()).size <= 1) continue;
1412
+ throw new DeclarationRefusedError(`transactFamily "${family}" of "${owner}" is split across files (${[...members.entries()].map(([k, db]) => `${k}@${db}`).join(", ")}); a family lives in ONE file`);
1413
+ }
1414
+ }
1369
1415
  /** The boot guard: empty kind + a legacy table that still has rows = adoption pending. */
1370
1416
  async withAdoption(owner, declared, results) {
1371
1417
  const out = { ...results };
@@ -1401,8 +1447,8 @@ var RecordsProvider = class {
1401
1447
  };
1402
1448
  continue;
1403
1449
  }
1404
- const legacyRows = await (await this.router.recordsFileFor("settings")).records("legacyRowCount", { table: legacy });
1405
- if (legacyRows !== null && legacyRows > 0) out[kind] = {
1450
+ const legacyRows = await this.legacyRowsAnywhere(legacy);
1451
+ if (legacyRows > 0) out[kind] = {
1406
1452
  ...result,
1407
1453
  adoptionPending: {
1408
1454
  legacyTable: legacy,
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Storage-location occupancy over time, through device-history (D850).
3
+ *
4
+ * The figures are the ones `listLocations` already serves, from their own
5
+ * authorities — nothing is measured twice:
6
+ * - the VOLUME (`location-used-percent`, `location-free-bytes`) from the same
7
+ * statfs probe the UI's capacity reads (`readLocalVolumeCapacity`), which
8
+ * answers only for a location THIS node can measure;
9
+ * - what CamStack HOLDS there (`location-owned-bytes`) from the
10
+ * `storage-occupancy` slice (D388).
11
+ *
12
+ * A figure that is unknown is NO point, never 0 (D393, D315): a failed statfs,
13
+ * a remote provider, a location nobody reports owned bytes for.
14
+ *
15
+ * Subject: the node the location lives on (`nodeId`), else the node that
16
+ * measured it. Scope: the location id, so a location keeps one series for life.
17
+ */
18
+ import type { DeviceHistoryIngestResult, IScopedLogger } from "@camstack/types";
19
+ export declare const LOCATION_HISTORY_NAMES: {
20
+ readonly usedPercent: "location-used-percent";
21
+ readonly freeBytes: "location-free-bytes";
22
+ readonly ownedBytes: "location-owned-bytes";
23
+ };
24
+ /** One location's sweep reading. */
25
+ export interface LocationReading {
26
+ readonly locationId: string;
27
+ readonly nodeId: string;
28
+ /** `null` when this node cannot take a measurement that is about the location. */
29
+ readonly capacity: {
30
+ readonly totalBytes: number;
31
+ readonly availableBytes: number;
32
+ } | null;
33
+ /** `undefined` when no provider reports what CamStack holds there. */
34
+ readonly ownedBytes: number | undefined;
35
+ }
36
+ export interface LocationHistoryPoint {
37
+ readonly key: string;
38
+ readonly subject: {
39
+ readonly kind: "node";
40
+ readonly nodeId: string;
41
+ };
42
+ readonly scope: string;
43
+ readonly ts: number;
44
+ readonly value: number;
45
+ }
46
+ export interface LocationHistoryClient {
47
+ declareSeries(input: {
48
+ name: string;
49
+ subjectKind: "node";
50
+ kind: "gauge";
51
+ displayName: string;
52
+ ingest: "points";
53
+ unit: string;
54
+ }): Promise<{
55
+ key: string;
56
+ }>;
57
+ record(input: {
58
+ points: readonly LocationHistoryPoint[];
59
+ }): Promise<DeviceHistoryIngestResult>;
60
+ }
61
+ export interface LocationHistoryRecorderDeps {
62
+ readonly deviceHistory: LocationHistoryClient;
63
+ readonly logger: IScopedLogger;
64
+ }
65
+ /** One reading per location per this many ms at most (the sweep runs every minute). */
66
+ export declare const LOCATION_HISTORY_MIN_INTERVAL_MS = 6e4;
67
+ export declare class LocationHistoryRecorder {
68
+ private readonly deps;
69
+ private readonly keys;
70
+ private readonly lastAt;
71
+ constructor(deps: LocationHistoryRecorderDeps);
72
+ private ensureDeclared;
73
+ /** The points of one sweep; pure apart from the per-location rate memory. */
74
+ pointsOf(readings: readonly LocationReading[], at: number): readonly LocationHistoryPoint[];
75
+ record(readings: readonly LocationReading[], at: number): Promise<void>;
76
+ }
@@ -18,6 +18,9 @@ export declare class StorageOrchestratorAddon extends BaseAddon<StorageOrchestra
18
18
  private occupancySlice;
19
19
  private get occupancy();
20
20
  private pressureTimer;
21
+ /** Occupancy over time (device-history). Created with the timer that feeds it. */
22
+ private locationHistory;
23
+ private locationHistoryInFlight;
21
24
  private pressureSweepInFlight;
22
25
  private migration;
23
26
  /** Guards every single-location repoint and arbitrates movers per physical root. */
@@ -108,6 +111,12 @@ export declare class StorageOrchestratorAddon extends BaseAddon<StorageOrchestra
108
111
  /** Single-flighted pressure sweep — never overlaps a slow eviction round. */
109
112
  private runPressureSweep;
110
113
  /**
114
+ * One occupancy reading per location this node can read, into device-history.
115
+ * The volume figures come from the same probe `listLocations` serves, the
116
+ * held bytes from the occupancy slice; an unknown figure is no point (D393).
117
+ */
118
+ private recordLocationHistory;
119
+ /**
111
120
  * Sample free space for every managed location and emit NC band edges.
112
121
  * A failed capacity read stays `null` and changes no band — never folded to 0 (D393).
113
122
  */
@@ -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-DjQ8C-ku.js");
6
+ const require_dist = require("../../dist-C89nqNnn.js");
7
7
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
@@ -3957,6 +3957,107 @@ var StorageLocationBandMonitor = class {
3957
3957
  }
3958
3958
  };
3959
3959
  //#endregion
3960
+ //#region src/builtins/storage-orchestrator/location-history-recorder.ts
3961
+ var LOCATION_HISTORY_NAMES = {
3962
+ usedPercent: "location-used-percent",
3963
+ freeBytes: "location-free-bytes",
3964
+ ownedBytes: "location-owned-bytes"
3965
+ };
3966
+ var DECLARATIONS = [
3967
+ {
3968
+ name: LOCATION_HISTORY_NAMES.usedPercent,
3969
+ displayName: "Location volume used %",
3970
+ unit: "%"
3971
+ },
3972
+ {
3973
+ name: LOCATION_HISTORY_NAMES.freeBytes,
3974
+ displayName: "Location volume free",
3975
+ unit: "bytes"
3976
+ },
3977
+ {
3978
+ name: LOCATION_HISTORY_NAMES.ownedBytes,
3979
+ displayName: "Location held by CamStack",
3980
+ unit: "bytes"
3981
+ }
3982
+ ];
3983
+ var LocationHistoryRecorder = class {
3984
+ deps;
3985
+ keys = /* @__PURE__ */ new Map();
3986
+ lastAt = /* @__PURE__ */ new Map();
3987
+ constructor(deps) {
3988
+ this.deps = deps;
3989
+ }
3990
+ async ensureDeclared() {
3991
+ if (this.keys.size === DECLARATIONS.length) return true;
3992
+ try {
3993
+ for (const d of DECLARATIONS) {
3994
+ const { key } = await this.deps.deviceHistory.declareSeries({
3995
+ name: d.name,
3996
+ subjectKind: "node",
3997
+ kind: "gauge",
3998
+ displayName: d.displayName,
3999
+ ingest: "points",
4000
+ unit: d.unit
4001
+ });
4002
+ this.keys.set(d.name, key);
4003
+ }
4004
+ return true;
4005
+ } catch (err) {
4006
+ this.keys.clear();
4007
+ this.deps.logger.warn("storage: location history declare failed — retried next sweep", { meta: { error: err instanceof Error ? err.message : String(err) } });
4008
+ return false;
4009
+ }
4010
+ }
4011
+ /** The points of one sweep; pure apart from the per-location rate memory. */
4012
+ pointsOf(readings, at) {
4013
+ const points = [];
4014
+ for (const r of readings) {
4015
+ const last = this.lastAt.get(r.locationId);
4016
+ if (last !== void 0 && at >= last && at - last < 6e4) continue;
4017
+ const add = (name, value) => {
4018
+ const key = this.keys.get(name);
4019
+ if (key === void 0 || !Number.isFinite(value)) return;
4020
+ points.push({
4021
+ key,
4022
+ subject: {
4023
+ kind: "node",
4024
+ nodeId: r.nodeId
4025
+ },
4026
+ scope: r.locationId,
4027
+ ts: at,
4028
+ value
4029
+ });
4030
+ };
4031
+ const before = points.length;
4032
+ if (r.capacity !== null && r.capacity.totalBytes > 0) {
4033
+ const used = r.capacity.totalBytes - r.capacity.availableBytes;
4034
+ add(LOCATION_HISTORY_NAMES.usedPercent, Math.round(used / r.capacity.totalBytes * 1e3) / 10);
4035
+ add(LOCATION_HISTORY_NAMES.freeBytes, r.capacity.availableBytes);
4036
+ }
4037
+ if (r.ownedBytes !== void 0) add(LOCATION_HISTORY_NAMES.ownedBytes, r.ownedBytes);
4038
+ if (points.length > before) this.lastAt.set(r.locationId, at);
4039
+ }
4040
+ return points;
4041
+ }
4042
+ async record(readings, at) {
4043
+ if (readings.length === 0 || !await this.ensureDeclared()) return;
4044
+ const points = this.pointsOf(readings, at);
4045
+ if (points.length === 0) return;
4046
+ try {
4047
+ const result = await this.deps.deviceHistory.record({ points });
4048
+ if (result.refused.length > 0) {
4049
+ if (result.refused.some((r) => r.reason === "undeclared")) this.keys.clear();
4050
+ this.deps.logger.warn("storage: location history points refused", { meta: {
4051
+ accepted: result.accepted,
4052
+ refused: result.refused
4053
+ } });
4054
+ }
4055
+ } catch (err) {
4056
+ this.deps.logger.warn("storage: location history not stored", { meta: { error: err instanceof Error ? err.message : String(err) } });
4057
+ }
4058
+ }
4059
+ };
4060
+ //#endregion
3960
4061
  //#region src/builtins/storage-orchestrator/storage-orchestrator.addon.ts
3961
4062
  /**
3962
4063
  * `storage-orchestrator` builtin — singleton owner of the consumer-
@@ -4024,6 +4125,9 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
4024
4125
  return this.occupancySlice;
4025
4126
  }
4026
4127
  pressureTimer = null;
4128
+ /** Occupancy over time (device-history). Created with the timer that feeds it. */
4129
+ locationHistory = null;
4130
+ locationHistoryInFlight = false;
4027
4131
  pressureSweepInFlight = false;
4028
4132
  migration = null;
4029
4133
  /** Guards every single-location repoint and arbitrates movers per physical root. */
@@ -4440,8 +4544,16 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
4440
4544
  }
4441
4545
  }
4442
4546
  });
4547
+ this.locationHistory = new LocationHistoryRecorder({
4548
+ deviceHistory: {
4549
+ declareSeries: (input) => this.ctx.api.deviceHistory.declareSeries.mutate(input),
4550
+ record: (input) => this.ctx.api.deviceHistory.record.mutate({ points: [...input.points] })
4551
+ },
4552
+ logger: this.ctx.logger
4553
+ });
4443
4554
  this.pressureTimer = setInterval(() => {
4444
4555
  this.runPressureSweep();
4556
+ this.recordLocationHistory();
4445
4557
  }, PRESSURE_SWEEP_INTERVAL_MS);
4446
4558
  this.ctx.logger.info("Storage orchestrator initialized");
4447
4559
  return [
@@ -4588,6 +4700,37 @@ var StorageOrchestratorAddon = class extends require_dist.BaseAddon {
4588
4700
  }
4589
4701
  }
4590
4702
  /**
4703
+ * One occupancy reading per location this node can read, into device-history.
4704
+ * The volume figures come from the same probe `listLocations` serves, the
4705
+ * held bytes from the occupancy slice; an unknown figure is no point (D393).
4706
+ */
4707
+ async recordLocationHistory() {
4708
+ const svc = this.service;
4709
+ const recorder = this.locationHistory;
4710
+ if (!svc || !recorder || this.locationHistoryInFlight) return;
4711
+ this.locationHistoryInFlight = true;
4712
+ try {
4713
+ this.occupancy.serveAndRevalidate();
4714
+ const localNode = svc.getLocalNodeId();
4715
+ const readings = [];
4716
+ for (const loc of svc.listLocations()) {
4717
+ if (!require_dist.mayReadLocation(loc) || (loc.nodeId ?? HUB_NODE_ID) !== localNode) continue;
4718
+ const capacity = await this.localCapacityOf(loc).catch(() => null);
4719
+ readings.push({
4720
+ locationId: loc.id,
4721
+ nodeId: localNode,
4722
+ capacity,
4723
+ ownedBytes: this.occupancy.ownedFor(loc.id)?.bytes
4724
+ });
4725
+ }
4726
+ await recorder.record(readings, Date.now());
4727
+ } catch (err) {
4728
+ this.ctxIfReady?.logger.warn("storage: location history pass failed", { meta: { error: err instanceof Error ? err.message : String(err) } });
4729
+ } finally {
4730
+ this.locationHistoryInFlight = false;
4731
+ }
4732
+ }
4733
+ /**
4591
4734
  * Sample free space for every managed location and emit NC band edges.
4592
4735
  * A failed capacity read stays `null` and changes no band — never folded to 0 (D393).
4593
4736
  */