@camstack/system 1.2.425 → 1.2.426

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 (78) 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/autotrack/index.js +1 -1
  8. package/dist/builtins/autotrack/index.mjs +1 -1
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +6 -0
  10. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +22 -2
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +22 -2
  12. package/dist/builtins/calendars/calendars.addon.js +1 -1
  13. package/dist/builtins/calendars/calendars.addon.mjs +1 -1
  14. package/dist/builtins/camera-grid/index.js +1 -1
  15. package/dist/builtins/camera-grid/index.mjs +1 -1
  16. package/dist/builtins/composer/composer.addon.js +2 -2
  17. package/dist/builtins/composer/composer.addon.mjs +2 -2
  18. package/dist/builtins/console-logging/index.js +1 -1
  19. package/dist/builtins/console-logging/index.mjs +1 -1
  20. package/dist/builtins/core-blocks/core-blocks.addon.js +2 -2
  21. package/dist/builtins/core-blocks/core-blocks.addon.mjs +2 -2
  22. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  23. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  24. package/dist/builtins/hub-forwarder/index.js +1 -1
  25. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  26. package/dist/builtins/keychain/index.js +3 -3
  27. package/dist/builtins/keychain/index.mjs +3 -3
  28. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  29. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  30. package/dist/builtins/local-auth/local-auth.addon.js +2 -2
  31. package/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  32. package/dist/builtins/local-network/address-book.d.ts +21 -0
  33. package/dist/builtins/local-network/local-network.addon.d.ts +6 -0
  34. package/dist/builtins/local-network/local-network.addon.js +48 -7
  35. package/dist/builtins/local-network/local-network.addon.mjs +48 -7
  36. package/dist/builtins/loki-logging/index.js +1 -1
  37. package/dist/builtins/loki-logging/index.mjs +1 -1
  38. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  39. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  40. package/dist/builtins/platform-probe/index.js +1 -1
  41. package/dist/builtins/platform-probe/index.mjs +1 -1
  42. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  43. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  44. package/dist/builtins/snapshot/index.js +1 -1
  45. package/dist/builtins/snapshot/index.mjs +1 -1
  46. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  47. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  48. package/dist/builtins/sqlite-storage/index.js +1 -1
  49. package/dist/builtins/sqlite-storage/index.mjs +1 -1
  50. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  51. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  52. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  53. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  54. package/dist/builtins/system-config/system-config.addon.js +2 -2
  55. package/dist/builtins/system-config/system-config.addon.mjs +2 -2
  56. package/dist/builtins/winston-logging/index.js +1 -1
  57. package/dist/builtins/winston-logging/index.mjs +1 -1
  58. package/dist/{composition-sources-197keifF.js → composition-sources-60tuHQ9N.js} +1 -1
  59. package/dist/{composition-sources-DmzTSy26.mjs → composition-sources-gxVpghXh.mjs} +1 -1
  60. package/dist/{constants-CkNLi-XW.mjs → constants-B6YTf0v2.mjs} +1 -1
  61. package/dist/{constants-B5Jd8Zch.js → constants-CO5zpJQY.js} +1 -1
  62. package/dist/{dist-DMWeqeTF.mjs → dist-CGz9u2HD.mjs} +37 -1
  63. package/dist/{dist-DnALrQF-.js → dist-K3WFop9Q.js} +37 -1
  64. package/dist/file-host-worker.js +1 -1
  65. package/dist/file-host-worker.mjs +1 -1
  66. package/dist/index.js +272 -198
  67. package/dist/index.mjs +272 -198
  68. package/dist/{jwt-signing-key-DeqG7LD9.js → jwt-signing-key-BdDy9ZJN.js} +1 -1
  69. package/dist/{jwt-signing-key-CCHXAtrs.mjs → jwt-signing-key-C_w5ielw.mjs} +1 -1
  70. package/dist/kernel/moleculer/process-service.d.ts +1 -110
  71. package/dist/kernel/moleculer/runner-heap-flags.d.ts +228 -0
  72. package/dist/{restore-archive-C4UhQOsg.js → restore-archive-BJp4Llea.js} +1 -1
  73. package/dist/{restore-archive-GevpOHw8.mjs → restore-archive-CZyUM8Qf.mjs} +1 -1
  74. package/dist/{retired-settings-keys-0FOsnzIE.js → retired-settings-keys-Dr2AyhsD.js} +1 -1
  75. package/dist/{retired-settings-keys-CdVFl7m2.mjs → retired-settings-keys-Dut6QWh6.mjs} +1 -1
  76. package/dist/{wal-maintenance-BtfyfuT5.mjs → wal-maintenance-BZhzoxqA.mjs} +0 -0
  77. package/dist/{wal-maintenance-DJV1rde2.js → wal-maintenance-Bzm3O2Nj.js} +0 -0
  78. package/package.json +1 -1
@@ -0,0 +1,228 @@
1
+ import type { AddonHeapProfile } from "@camstack/types";
2
+ /** One addon hosted inside a runner subprocess. */
3
+ export interface RunnerAddonSpec {
4
+ readonly addonId: string;
5
+ readonly addonDir: string;
6
+ }
7
+ /** The memory declarations one addon's manifest makes about its own runner. */
8
+ export interface AddonHeapDeclaration {
9
+ readonly profile: AddonHeapProfile | undefined;
10
+ /** `execution.maxOldSpaceMb`, when declared. `0` means "this addon opts out of a ceiling". */
11
+ readonly maxOldSpaceMb: number | undefined;
12
+ /**
13
+ * `execution.rssBudgetMb`, when declared — the whole-process footprint the addon's role
14
+ * considers legitimate. `undefined` means the addon declares no budget, which is NOT a
15
+ * request for a default: a runner where nobody declares one reports itself UNWATCHED.
16
+ */
17
+ readonly rssBudgetMb: number | undefined;
18
+ /**
19
+ * `execution.semiSpaceMb`, when declared and inside {@link SEMI_SPACE_MB_RANGE} — the
20
+ * young-generation semi-space the addon measured its runner needs. See `AddonExecution`.
21
+ */
22
+ readonly semiSpaceMb: number | undefined;
23
+ /**
24
+ * `execution.initialOldSpaceMb`, when declared and inside {@link INITIAL_OLD_SPACE_MB_RANGE}
25
+ * — the old-space headroom the runner starts with. See `AddonExecution`.
26
+ */
27
+ readonly initialOldSpaceMb: number | undefined;
28
+ }
29
+ /** Inclusive MB bounds a manifest value must sit in to be a declaration at all. */
30
+ export interface ManifestMbRange {
31
+ readonly min: number;
32
+ readonly max: number;
33
+ }
34
+ /**
35
+ * `execution.semiSpaceMb` is accepted in `[1, 256]` MB. V8 itself clamps the flag to its
36
+ * own limits (the 64-bit default is 64 MB after Node 24's scavenger change, a 256 MB
37
+ * semi-space is three times anything measured useful here); below 1 MB the flag is
38
+ * meaningless. Outside the range the declaration is IGNORED (the runner keeps its class
39
+ * default) rather than clamped: a clamped number silently becomes a different setting from
40
+ * the one in the file, and the spawn log would then say something the manifest does not.
41
+ */
42
+ export declare const SEMI_SPACE_MB_RANGE: ManifestMbRange;
43
+ /**
44
+ * `execution.initialOldSpaceMb` is accepted in `[16, 65536]` MB. Below 16 MB V8's default
45
+ * already starts larger; 64 GB clears any runner in this fleet. The accepted value is then
46
+ * clamped at spawn to the runner's old-space CEILING (`runnerHeapFlags`) — V8 refuses an
47
+ * initial size above `--max-old-space-size`, and the ceiling is the one number that belongs
48
+ * to the runner as a whole.
49
+ */
50
+ export declare const INITIAL_OLD_SPACE_MB_RANGE: ManifestMbRange;
51
+ export declare function readAddonHeapDeclaration(spec: RunnerAddonSpec): AddonHeapDeclaration;
52
+ /**
53
+ * Drop the cached heap declaration for each addon so the NEXT `readAddonHeapDeclaration`
54
+ * re-reads the manifest from disk. Called on operator-driven spawns / restarts
55
+ * (a deploy may have changed `execution.heapProfile` / `execution.maxOldSpaceMb`); the
56
+ * crash-respawn fast path deliberately does NOT invalidate — a crashing runner
57
+ * has the same on-disk manifest, so re-reading it is pure overhead.
58
+ */
59
+ export declare function invalidateHeapProfiles(addons: readonly RunnerAddonSpec[]): void;
60
+ /**
61
+ * A runner is heavy if ANY co-located addon declares `heapProfile: 'heavy'` in its manifest.
62
+ * Everything else (the un-annotated default) is a light control-plane runner. No hard-coded names.
63
+ */
64
+ export declare function isHeavyRunner(addons: readonly RunnerAddonSpec[]): boolean;
65
+ /**
66
+ * Default old-space ceiling for a HEAVY runner, in MB.
67
+ *
68
+ * ## Why a heavy runner needs a ceiling at all
69
+ *
70
+ * `heapProfile: 'heavy'` used to mean "V8 defaults", i.e. no `--max-old-space-size` — which on this
71
+ * host is V8's own memory-derived default (multiple GB). Nothing then bounds a burst, and V8 does
72
+ * not hand committed pages back (the long argument for that is in `kernel/heap-watch.ts`), so a
73
+ * one-off burst becomes the runner's permanent RSS.
74
+ *
75
+ * Measured on the live hub, 2026-08-17: the `recorder` runner reaches **2122 MB RSS** and stays
76
+ * there. The same addon on two agent nodes carrying the same code and a smaller archive sits at
77
+ * **58 MB**.
78
+ *
79
+ * ⚠ This paragraph used to attribute that ~2 GB to "walk garbage" from the deferred archive walk,
80
+ * and to argue from a ~21 MB `RecordingIndex`. Both were wrong, and the error cost a session on
81
+ * 2026-08-27. The deferred walk had NO CALLER and never ran (it has since been deleted). And the
82
+ * index is not 21 MB: a 2026-08-27 profile of the live recorder read `heapUsed = 1606 MB` against
83
+ * `external = 8 MB`, with an `smaps` census putting 1510 MB in V8's 256 KB page ranges against
84
+ * 54 MB of native heap — LIVE JavaScript retainers, not high-water garbage. The retained set is
85
+ * ~7.1 M `SegmentRow`s plus their path strings and Map entries (13 cameras x 2 profiles x 8 640
86
+ * segments/day x ~30 days), reseeded at boot by `SegmentHourLedger.hydrateIndex`.
87
+ *
88
+ * The lesson for anyone sizing this flag: a heap number needs a RETAINER, and "garbage the GC has
89
+ * no reason to collect" is the explanation to reach for last, not first.
90
+ *
91
+ * ## Why 1024
92
+ *
93
+ * From the same live topology snapshot, every heavy runner's FULL RSS — which is a strict
94
+ * over-estimate of its old space, since it also contains native allocations, `external` and
95
+ * `arrayBuffers`, none of which `--max-old-space-size` bounds:
96
+ *
97
+ * detection 471 MB · provider-reolink 507 MB · pipeline-orchestrator 238 MB · ml 218 MB ·
98
+ * snapshot 185 MB · decoder-nodeav 174 MB · audio-analyzer 170 MB
99
+ *
100
+ * 1024 MB clears the largest of those by ~2x while cutting the recorder's observed ratchet by
101
+ * more than half. It is a CEILING, not a target: a runner that fits today keeps behaving exactly
102
+ * as it does now, because V8 only collects harder as it approaches the limit.
103
+ *
104
+ * A runner whose working set genuinely does not fit declares its own number in its manifest
105
+ * (`execution.maxOldSpaceMb`) — the number belongs next to the addon that knows its working set.
106
+ * `recorder` (3072 MB; peak 2341 MB heapTotal) is the one shipped addon that does. `stream-broker` does NOT, despite 1585 MB peak RSS: ~1 GB of that is
107
+ * `arrayBuffers` (47 RTP rings), which this flag does not bound and never will — its actual old
108
+ * space peaks at 224 MB. Size the declaration from `heapTotal` in the `[mem]` heartbeat, never
109
+ * from RSS.
110
+ *
111
+ * ## What this flag CANNOT do
112
+ *
113
+ * It bounds old space and nothing else — not `external`, not `arrayBuffers`, not what a native
114
+ * addon mallocs. `hub/pipeline-analytics` reached 7334 MB RSS with this flag set to 1024 the
115
+ * whole time, because 96% of it was native. That half is bounded in `runner-native-allocator.ts`.
116
+ * Reaching for a bigger number here when RSS is the complaint is the standard wrong move.
117
+ */
118
+ export declare const HEAVY_MAX_OLD_MB_DEFAULT = 1024;
119
+ /**
120
+ * V8 platform worker threads for a LIGHT runner (`--v8-pool-size`).
121
+ *
122
+ * ## What this bounds
123
+ *
124
+ * Node gives every process a V8 platform thread pool — background compilation,
125
+ * parallel marking and sweeping — defaulted to 4. It is not the libuv pool
126
+ * (`UV_THREADPOOL_SIZE`, which serves `fs`/`dns`/`zlib`/`crypto`) and it is
127
+ * deliberately not touched here; see below.
128
+ *
129
+ * ## Why it is worth a flag
130
+ *
131
+ * A container cgroup counts THREADS, not processes, and this cluster forks a
132
+ * runner per addon (D2). Measured on the live hub 2026-09-18 (20 cores,
133
+ * `pids.max=2048`), after 22 fork refusals in 45 minutes earlier that day:
134
+ *
135
+ * pids.current 991 · 47 node processes holding 469 threads
136
+ * of those, 29 LIGHT runners holding 274 (mean 9.4 threads each)
137
+ *
138
+ * A light runner is a control-plane addon with a 2 MB young generation. It does
139
+ * not generate the background GC work four marking threads exist for, and it
140
+ * pays 4 threads of the cgroup's pid budget for them anyway. Two returns ~58
141
+ * threads — ~6% of the container's live thread count — for background GC that
142
+ * is, on these heaps, a few milliseconds a cycle.
143
+ *
144
+ * ## Why TWO and never ZERO
145
+ *
146
+ * `--v8-pool-size=0` does not disable the pool: it tells V8 to size it from the
147
+ * detected parallelism. Measured locally 2026-09-18 on a node process holding
148
+ * the libuv pool open:
149
+ *
150
+ * default 11 threads
151
+ * --v8-pool-size=2 9 threads
152
+ * --v8-pool-size=0 18 threads
153
+ *
154
+ * So the flag is only ever passed with a value of at least 1 — the same trap as
155
+ * `MALLOC_ARENA_MAX=0` in `runner-native-allocator.ts`.
156
+ *
157
+ * ## What is deliberately NOT bounded
158
+ *
159
+ * HEAVY runners keep V8's default: they hold real heaps (the recorder declares
160
+ * 3072 MB) where parallel marking is the difference between a pause and a stall.
161
+ *
162
+ * `UV_THREADPOOL_SIZE` is left alone on every runner. Its 4 threads are lazily
163
+ * spawned, and the measurement above says most light runners have spawned all
164
+ * four — i.e. they really do run concurrent `fs` work. Halving that would trade
165
+ * ~58 more threads for serialized filesystem I/O in runners whose I/O profile
166
+ * has not been measured, on a media system. A thread saving is not worth a
167
+ * media gap.
168
+ */
169
+ export declare const LIGHT_V8_POOL_SIZE_DEFAULT = 2;
170
+ /** Light runners' young-generation semi-space, in MB. */
171
+ export declare const LIGHT_SEMI_SPACE_MB = 2;
172
+ /**
173
+ * The runner's old-space ceiling in MB, or 0 for "uncapped".
174
+ *
175
+ * The runner takes the MAXIMUM ceiling any co-located addon declares — co-location must never
176
+ * silence the hungriest member (D2/D29: a runner is respawned as a whole, so an OOM caused by
177
+ * under-sizing one member kills every addon in the group). An addon declaring `0` therefore lifts
178
+ * the cap for the whole runner, which is the intended escape hatch.
179
+ */
180
+ export declare function runnerMaxOldSpaceMb(addons: readonly RunnerAddonSpec[], heavy: boolean): number;
181
+ /**
182
+ * The runner's declared RSS budget in MB, or `undefined` when NOBODY declared one.
183
+ *
184
+ * Same rule as the old-space ceiling, for the same reason (D2/D29): the runner takes the MAXIMUM
185
+ * any co-located addon declares, because a runner is respawned as a whole and co-location must
186
+ * never silence the hungriest member. It would be strictly worse here than for a heap ceiling —
187
+ * an under-sized budget does not kill anything, it just cries wolf, and a watchdog that cries
188
+ * wolf is a watchdog that gets muted.
189
+ *
190
+ * `undefined` propagates as an ABSENT env var, and the child then announces itself unwatched.
191
+ * There is deliberately no class default: see `AddonExecution.rssBudgetMb`.
192
+ */
193
+ export declare function runnerRssBudgetMb(addons: readonly RunnerAddonSpec[]): number | undefined;
194
+ /**
195
+ * Per-placement V8 flags (Block D). LIGHT runners cap their young generation
196
+ * (`--max-semi-space-size`) to reclaim V8's over-reservation — a measured ~15 MB/runner win — bound
197
+ * V8's platform thread pool (`--v8-pool-size`, see {@link LIGHT_V8_POOL_SIZE_DEFAULT}: a measured
198
+ * ~58 threads across the hub's 29 light runners, against a cgroup `pids.max` this host has already
199
+ * hit) and carry no old-space cap unless a manifest declares one. HEAVY
200
+ * runners keep V8's default young generation but ALWAYS carry an old-space ceiling; see
201
+ * {@link HEAVY_MAX_OLD_MB_DEFAULT} for why, and how a runner declares its own.
202
+ *
203
+ * The per-addon overrides are the manifest's declared `maxOldSpaceMb` (`0` = uncapped),
204
+ * `semiSpaceMb` (`--max-semi-space-size`, replacing the class default) and
205
+ * `initialOldSpaceMb` (`--initial-old-space-size`, clamped to the ceiling) — each the MAXIMUM
206
+ * across a runner's co-located addons. Shipped for `stream-broker` alone (8 / 512): with the
207
+ * heavy class default the hub's broker ran ~166 major GCs a minute and not one scavenge, at
208
+ * 45–60 % of a core. The environment overrides and the `CAMSTACK_RUNNER_HEAP_TUNING=off` kill
209
+ * switch were removed on 2026-10-06 — nothing had set them since the rollout. The flags must
210
+ * be on the spawn command line: `v8.setFlagsFromString` at runtime changes neither space.
211
+ */
212
+ export declare function runnerHeapFlags(addons: readonly RunnerAddonSpec[]): string[];
213
+ /**
214
+ * The runner's declared young-generation semi-space in MB, or `undefined` when no
215
+ * co-located addon declares one (→ the class default applies).
216
+ *
217
+ * The MAXIMUM across the group, like every other declaration here (D2/D29): the
218
+ * member that measured its churn away must not be handed a smaller young
219
+ * generation because a quieter co-tenant declared one.
220
+ */
221
+ export declare function runnerSemiSpaceMb(addons: readonly RunnerAddonSpec[]): number | undefined;
222
+ /**
223
+ * The runner's declared initial old space in MB, or `undefined` when nobody declares
224
+ * one (→ V8 grows it from the live set). MAXIMUM across the group, same rule and same
225
+ * reason as {@link runnerSemiSpaceMb}; the clamp to the runner's ceiling happens in
226
+ * {@link runnerHeapFlags}, where the ceiling is known.
227
+ */
228
+ export declare function runnerInitialOldSpaceMb(addons: readonly RunnerAddonSpec[]): number | undefined;
@@ -1,5 +1,5 @@
1
1
  const require_chunk = require("./chunk-Cek0wNdY.js");
2
- const require_dist = require("./dist-DnALrQF-.js");
2
+ const require_dist = require("./dist-K3WFop9Q.js");
3
3
  let node_crypto = require("node:crypto");
4
4
  let buffer = require("buffer");
5
5
  let node_fs_promises = require("node:fs/promises");
@@ -1,4 +1,4 @@
1
- import { g as DATABASE_SNAPSHOT_SUFFIX } from "./dist-DMWeqeTF.mjs";
1
+ import { g as DATABASE_SNAPSHOT_SUFFIX } from "./dist-CGz9u2HD.mjs";
2
2
  import { createCipheriv, createDecipheriv, createHash, createPrivateKey, createPublicKey, diffieHellman, generateKeyPairSync, hkdfSync, randomBytes } from "node:crypto";
3
3
  import { Buffer as Buffer$1 } from "buffer";
4
4
  import * as fsp from "node:fs/promises";
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-DnALrQF-.js");
1
+ const require_dist = require("./dist-K3WFop9Q.js");
2
2
  //#region src/builtins/sqlite-storage/retired-settings-keys.ts
3
3
  /**
4
4
  * Is THIS node the one whose settings store is the cluster's authority?
@@ -1,4 +1,4 @@
1
- import { yr as asJsonObject } from "./dist-DMWeqeTF.mjs";
1
+ import { yr as asJsonObject } from "./dist-CGz9u2HD.mjs";
2
2
  //#region src/builtins/sqlite-storage/retired-settings-keys.ts
3
3
  /**
4
4
  * Is THIS node the one whose settings store is the cluster's authority?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/system",
3
- "version": "1.2.425",
3
+ "version": "1.2.426",
4
4
  "description": "Core addon for CamStack — builtins, pipeline, process management, auth, logging, events",
5
5
  "keywords": [
6
6
  "camstack",