@camstack/system 1.2.218 → 1.2.220

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 (97) hide show
  1. package/dist/addon-runner.js +2 -2
  2. package/dist/addon-runner.mjs +2 -2
  3. package/dist/addon-utils.js +2 -2
  4. package/dist/addon-utils.mjs +2 -2
  5. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  8. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  9. package/dist/builtins/alerts/alerts.addon.js +1 -1
  10. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  12. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  13. package/dist/builtins/console-logging/index.js +1 -1
  14. package/dist/builtins/console-logging/index.mjs +1 -1
  15. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  16. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  17. package/dist/builtins/device-manager/device-manager.addon.js +2 -2
  18. package/dist/builtins/device-manager/device-manager.addon.mjs +2 -2
  19. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  20. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  21. package/dist/builtins/hub-forwarder/index.js +1 -1
  22. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  23. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  24. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  25. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  26. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  27. package/dist/builtins/local-network/local-network.addon.js +2 -2
  28. package/dist/builtins/local-network/local-network.addon.mjs +2 -2
  29. package/dist/builtins/loki-logging/index.js +1 -1
  30. package/dist/builtins/loki-logging/index.mjs +1 -1
  31. package/dist/builtins/native-metrics/gpu-probe.d.ts +18 -0
  32. package/dist/builtins/native-metrics/native-metrics-provider.d.ts +1 -1
  33. package/dist/builtins/native-metrics/native-metrics.addon.d.ts +26 -3
  34. package/dist/builtins/native-metrics/native-metrics.addon.js +1320 -1093
  35. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1320 -1096
  36. package/dist/builtins/native-metrics/proc-process-table.d.ts +25 -0
  37. package/dist/builtins/platform-probe/index.js +3 -3
  38. package/dist/builtins/platform-probe/index.mjs +3 -3
  39. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  40. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  41. package/dist/builtins/snapshot/index.js +1 -1
  42. package/dist/builtins/snapshot/index.mjs +1 -1
  43. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  44. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  45. package/dist/builtins/sqlite-storage/sqlite-pragmas.d.ts +23 -0
  46. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +1 -1
  47. package/dist/builtins/sqlite-storage/sqlite-settings.addon.d.ts +1 -0
  48. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  49. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  50. package/dist/builtins/sqlite-storage/wal-checkpoint-policy.d.ts +115 -0
  51. package/dist/builtins/sqlite-storage/wal-checkpoint-worker.d.ts +1 -0
  52. package/dist/builtins/sqlite-storage/wal-checkpointer.d.ts +70 -0
  53. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  54. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  55. package/dist/builtins/system-config/system-config.addon.js +1 -1
  56. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  57. package/dist/builtins/winston-logging/index.js +1 -1
  58. package/dist/builtins/winston-logging/index.mjs +1 -1
  59. package/dist/{custom-action-registry-BDwM5qAK.js → custom-action-registry-B42MC_Pv.js} +1 -1
  60. package/dist/{custom-action-registry-CsONUlhC.mjs → custom-action-registry-CpR58DXT.mjs} +1 -1
  61. package/dist/{dist-DigmGsQS.mjs → dist-Ca_jaxXs.mjs} +232 -4
  62. package/dist/{dist-BOlMCOeT.js → dist-CllKpcTd.js} +232 -4
  63. package/dist/index.d.ts +6 -1
  64. package/dist/index.js +99 -65
  65. package/dist/index.mjs +84 -67
  66. package/dist/kernel/gc-census.d.ts +144 -0
  67. package/dist/kernel/heap-watch.d.ts +32 -1
  68. package/dist/kernel/moleculer/mesh-queue-report.d.ts +51 -0
  69. package/dist/kernel/outbound-queue-watch.d.ts +94 -0
  70. package/dist/kernel/socket-plane-report.d.ts +112 -4
  71. package/dist/kernel/transport/cap-action-census.d.ts +218 -0
  72. package/dist/kernel/transport/cap-child-index.d.ts +49 -0
  73. package/dist/kernel/transport/cap-routing-hints.d.ts +21 -0
  74. package/dist/kernel/transport/child-cap-protocol.d.ts +28 -2
  75. package/dist/kernel/transport/frame-codec.d.ts +49 -0
  76. package/dist/kernel/transport/index.d.ts +2 -0
  77. package/dist/kernel/transport/local-child-client.d.ts +7 -0
  78. package/dist/kernel/transport/local-child-registry.d.ts +99 -5
  79. package/dist/kernel/transport/local-transport.d.ts +54 -2
  80. package/dist/kernel/transport/socket-channel.d.ts +40 -1
  81. package/dist/{manifest-system-deps-Bo92lg5u.js → manifest-system-deps-DfpwaXkh.js} +1725 -614
  82. package/dist/{manifest-system-deps-D--wyMD9.mjs → manifest-system-deps-iadzxSBr.mjs} +1850 -841
  83. package/dist/process/proc-stat.d.ts +75 -0
  84. package/dist/process/resource-monitor.d.ts +9 -1
  85. package/dist/{resource-monitor-CdnzxBLP.js → resource-monitor-LVE1BoLs.js} +42 -23
  86. package/dist/{resource-monitor-BWmQ5i-o.mjs → resource-monitor-Vp0bPV3U.mjs} +42 -22
  87. package/dist/{retired-settings-keys-xEAlYnv7.js → retired-settings-keys-7iEsSzmD.js} +1 -1
  88. package/dist/{retired-settings-keys-vK_U-CG2.mjs → retired-settings-keys-DQnfr__p.mjs} +1 -1
  89. package/dist/wal-checkpoint-policy-CAcg63o-.mjs +92 -0
  90. package/dist/wal-checkpoint-policy-CCJZngds.js +127 -0
  91. package/dist/wal-checkpoint-worker.js +138 -0
  92. package/dist/wal-checkpoint-worker.mjs +137 -0
  93. package/package.json +1 -1
  94. package/dist/{event-loop-stall-monitor-DM9OAzy8.js → event-loop-stall-monitor-CAsHdMwP.js} +1 -1
  95. package/dist/{event-loop-stall-monitor-B3CFd9tM.mjs → event-loop-stall-monitor-GPrVvx14.mjs} +1 -1
  96. package/dist/{tls-DOTmtLCW.mjs → tls-2xbgg78V.mjs} +2 -2
  97. package/dist/{tls-BxQlomxd.js → tls-BFs4PzoW.js} +2 -2
@@ -0,0 +1,25 @@
1
+ import { ProcReader } from '../../process/proc-stat.js';
2
+ import { PsProcessRow } from './process-classification.js';
3
+ /** Every process in `/proc`, as the rows `ps -eo …` would have printed. */
4
+ export declare function readProcProcessTable(reader?: ProcReader): Promise<readonly PsProcessRow[]>;
5
+ /**
6
+ * Parse `ps etime` → seconds. `MM:SS`, `HH:MM:SS`, `DD-HH:MM:SS`.
7
+ * Only the `ps` path needs this; `/proc` gives the number directly.
8
+ */
9
+ export declare function parseEtime(etime: string): number;
10
+ /** Parse the output of `ps -eo pid=,ppid=,pgid=,pcpu=,rss=,etime=,command=`. */
11
+ export declare function parsePsTable(stdout: string): readonly PsProcessRow[];
12
+ /** The fork. Only reached on a platform without `/proc`. */
13
+ export declare function spawnPsTable(): Promise<readonly PsProcessRow[]>;
14
+ /** What decides the source. Injectable so the choice is pinned by a test, not by the CI host. */
15
+ export interface ProcessTableDeps {
16
+ readonly platform: NodeJS.Platform;
17
+ readonly reader: ProcReader;
18
+ readonly spawnPs: () => Promise<readonly PsProcessRow[]>;
19
+ }
20
+ /**
21
+ * The process table, from `/proc` where it exists and from `ps` elsewhere.
22
+ * Throws only when the chosen source cannot answer at all; the caller logs it
23
+ * as a skipped interval.
24
+ */
25
+ export declare function readProcessTable(deps?: ProcessTableDeps): Promise<readonly PsProcessRow[]>;
@@ -3,13 +3,13 @@ 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-BOlMCOeT.js");
7
- let node_child_process = require("node:child_process");
8
- let node_util = require("node:util");
6
+ const require_dist = require("../../dist-CllKpcTd.js");
9
7
  let node_fs = require("node:fs");
10
8
  node_fs = require_chunk.__toESM(node_fs);
9
+ let node_child_process = require("node:child_process");
11
10
  let node_os = require("node:os");
12
11
  node_os = require_chunk.__toESM(node_os);
12
+ let node_util = require("node:util");
13
13
  //#region src/builtins/platform-probe/coral-accelerators.ts
14
14
  /**
15
15
  * Coral USB Edge TPU USB identifiers.
@@ -1,9 +1,9 @@
1
1
  import { o as __toESM } from "../../chunk-CNf5ZN-e.mjs";
2
- import { Et as platformProbeCapability, It as scoreRuntimes, Jt as errMsg, X as enumerateInferenceDevices, Yt as BaseAddon, un as emitReadiness, xn as EventCategory } from "../../dist-DigmGsQS.mjs";
3
- import { execFile } from "node:child_process";
4
- import { promisify } from "node:util";
2
+ import { Et as platformProbeCapability, It as scoreRuntimes, Jt as errMsg, X as enumerateInferenceDevices, Yt as BaseAddon, un as emitReadiness, xn as EventCategory } from "../../dist-Ca_jaxXs.mjs";
5
3
  import * as fs from "node:fs";
4
+ import { execFile } from "node:child_process";
6
5
  import * as os from "node:os";
6
+ import { promisify } from "node:util";
7
7
  //#region src/builtins/platform-probe/coral-accelerators.ts
8
8
  /**
9
9
  * Coral USB Edge TPU USB identifiers.
@@ -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-BOlMCOeT.js");
6
+ const require_dist = require("../../dist-CllKpcTd.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 { Yt as BaseAddon, xn as EventCategory } from "../../dist-DigmGsQS.mjs";
1
+ import { Yt as BaseAddon, xn as EventCategory } from "../../dist-Ca_jaxXs.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-BOlMCOeT.js");
6
+ const require_dist = require("../../dist-CllKpcTd.js");
7
7
  let zod = require("zod");
8
8
  let node_crypto = require("node:crypto");
9
9
  let _camstack_types_node = require("@camstack/types/node");
@@ -1,4 +1,4 @@
1
- import { $t as DeviceFeature, F as bareAddonId, I as batteryCapability, Jt as errMsg, Rt as snapshotCapability, Ut as streamQualityLabel, W as deriveBatteryPresence, Yt as BaseAddon, i as BatteryStatusSchema, mn as nodePin, tn as DeviceType, xn as EventCategory } from "../../dist-DigmGsQS.mjs";
1
+ import { $t as DeviceFeature, F as bareAddonId, I as batteryCapability, Jt as errMsg, Rt as snapshotCapability, Ut as streamQualityLabel, W as deriveBatteryPresence, Yt as BaseAddon, i as BatteryStatusSchema, mn as nodePin, tn as DeviceType, xn as EventCategory } from "../../dist-Ca_jaxXs.mjs";
2
2
  import { z } from "zod";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { signExpiringUrl, verifyExpiringUrl } from "@camstack/types/node";
@@ -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-BOlMCOeT.js");
6
+ const require_dist = require("../../dist-CllKpcTd.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 { Ht as storageProviderCapability, Yt as BaseAddon, nt as filesystemBrowseCapability } from "../../dist-DigmGsQS.mjs";
1
+ import { Ht as storageProviderCapability, Yt as BaseAddon, nt as filesystemBrowseCapability } from "../../dist-Ca_jaxXs.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";
@@ -95,6 +95,29 @@ export declare const SQLITE_JOURNAL_SIZE_LIMIT_BYTES = 67108864;
95
95
  * journal mode reports FULL and looks exactly like a regression in this file.
96
96
  */
97
97
  export declare const SQLITE_SYNCHRONOUS_IS_BUILD_DEFAULT = true;
98
+ /**
99
+ * This connection's `wal_autocheckpoint`, in pages. 10 000 = **ten times the
100
+ * engine default**, ~40 MiB of WAL.
101
+ *
102
+ * The checkpoint is no longer this connection's job. Under `synchronous =
103
+ * NORMAL` the fsyncs of a WAL database happen at the checkpoint and nowhere
104
+ * else, and the engine's auto-checkpoint runs INSIDE the commit of whichever
105
+ * writer crosses its threshold — so on the hub every 1000 frames (12–25 s) a
106
+ * one-row `set` paid two fsyncs and a ~1000-page copy on the thread every
107
+ * configuration read in the cluster queues behind, and paid 1–10 s for it
108
+ * whenever the shared QLC drive was saturated (D449, measured in D452). The
109
+ * checkpoint now runs on a worker thread over its own connection at the SAME
110
+ * 1000-frame rule (`wal-checkpoint-policy.ts`), so the disk is asked for
111
+ * the same number of syncs by a thread nobody waits on.
112
+ *
113
+ * Why not `0` (auto-checkpoint off): a worker that dies would leave the WAL
114
+ * unbounded, and reads of a WAL page are `pread64`s the map never covers.
115
+ * Ten times the default is a bound the worker never lets it reach — it is
116
+ * the fallback, and `WalCheckpointer` logs an ERROR naming it the moment it
117
+ * becomes the only checkpoint. `__tests__/sqlite-pragmas.spec.ts` reads the
118
+ * value back.
119
+ */
120
+ export declare const SQLITE_WAL_AUTOCHECKPOINT_BOUND_PAGES = 10000;
98
121
  /**
99
122
  * Hard ceiling on the map, in bytes. 2 GiB.
100
123
  *
@@ -1,4 +1,4 @@
1
- import { BulkRecord, CollectionColumn, CollectionIndex, DataStoreEngineInfo, HistogramBucket, IScopedLogger, ISettingsBackend, QueryFilter, SettingsCountInput, SettingsDeleteInput, SettingsGetInput, SettingsAggregateInput, SettingsAggregateResult, SettingsHistogramInput, SettingsInsertInput, SettingsIsEmptyInput, SettingsQueryInput, SettingsRecord, SettingsSetInput, SettingsUpdateInput } from '@camstack/types';
1
+ import { BulkRecord, CollectionColumn, CollectionIndex, DataStoreEngineInfo, HistogramBucket, IScopedLogger, ISettingsBackend, QueryFilter, SettingsAggregateInput, SettingsAggregateResult, SettingsCountInput, SettingsDeleteInput, SettingsGetInput, SettingsHistogramInput, SettingsInsertInput, SettingsIsEmptyInput, SettingsQueryInput, SettingsRecord, SettingsSetInput, SettingsUpdateInput } from '@camstack/types';
2
2
  import { default as Database } from 'better-sqlite3';
3
3
  import { MutationFilterInput } from './filter-compiler.js';
4
4
  import { SqliteOpProfiler } from './query-profiler.js';
@@ -21,6 +21,7 @@ export declare class SqliteSettingsAddon extends BaseAddon {
21
21
  private backend;
22
22
  private vectorIndex;
23
23
  private walMaintenance;
24
+ private walCheckpointer;
24
25
  constructor();
25
26
  /**
26
27
  * The engine behind `settings-store` cannot read that door during
@@ -0,0 +1,115 @@
1
+ /**
2
+ * When the checkpoint worker folds the WAL — the judgement, pure.
3
+ *
4
+ * ## Why a worker checkpoints at all
5
+ *
6
+ * `hub/sqlite-settings` is one JS thread with a synchronous binding, and every
7
+ * configuration read in the cluster queues behind whatever statement it is
8
+ * inside. With `journal_mode = WAL` and the build default `synchronous =
9
+ * NORMAL`, an ordinary commit is an append to the WAL with NO fsync. The
10
+ * fsyncs — the only thing in a one-row write that can take seconds — happen
11
+ * at the CHECKPOINT: the WAL is synced before the pages are copied, the
12
+ * database file after. And SQLite runs the auto-checkpoint (1000 pages)
13
+ * INSIDE the commit of whichever writer crosses the threshold.
14
+ *
15
+ * Measured on the hub, 2026-09-11 10:45–10:55 CEST, from outside the process
16
+ * (`/proc/<pid>/syscall` at 10 Hz + the wal-index header at 1 Hz, D452): the
17
+ * WAL refilled at ~54 frames/s, the auto-checkpoint fired every 12–25 s (42
18
+ * in 9.5 min), and every D-state run on the settings thread that sat in a
19
+ * syscall sat in `fsync` (74), each within ±2 s of a checkpoint event —
20
+ * 12.6 s of the 569 s window, all of it inside writers' commits. In the two
21
+ * saturated bursts earlier that morning (08:35–08:40, 09:30–09:39) the same
22
+ * fsync took 1–10 s, once per checkpoint, and the profiler filed each as a
23
+ * slow `set`. `synchronous` was never the lever: it was already NORMAL, and
24
+ * `sqlite-pragmas.ts` had said so since 2026-08-08.
25
+ *
26
+ * So the checkpoint runs on a worker thread, over its own connection. The
27
+ * settings thread's commits stay appends. What stays on the settings thread
28
+ * is the WAL-header sync SQLite performs when a WAL is reused after a
29
+ * completed checkpoint — one small fsync per cycle — and that residual is
30
+ * named here so nobody reads "no fsync on the settings thread" into this.
31
+ *
32
+ * ## The rule this file reproduces
33
+ *
34
+ * The auto-checkpoint's own rule: fold when 1000 frames are pending. The
35
+ * point of moving the checkpoint is to change WHO waits on the disk, not how
36
+ * often the disk is asked to sync — a worker that checkpointed every second
37
+ * would multiply the fsync count by ten on a drive the media plane already
38
+ * saturates. The threshold is read from the wal-index header (`mxFrame`,
39
+ * `nBackfill`), which costs a 136-byte read and no lock; when that read is
40
+ * unavailable the worker falls back to a fixed interval, so an unreadable
41
+ * header can never mean "nothing to do".
42
+ */
43
+ /** The engine's own `wal_autocheckpoint` default, in frames. Reproduced, not changed. */
44
+ export declare const WAL_CHECKPOINT_THRESHOLD_FRAMES = 1000;
45
+ /**
46
+ * Longest the worker lets pending frames sit before folding them, in ms. A
47
+ * quiet database (a developer machine, an agent with little to persist) still
48
+ * gets its WAL folded and its pages made durable within a minute.
49
+ */
50
+ export declare const WAL_CHECKPOINT_MAX_INTERVAL_MS = 60000;
51
+ /** How often the worker looks at the wal-index, in ms. A 136-byte read. */
52
+ export declare const WAL_CHECKPOINT_POLL_MS = 1000;
53
+ /**
54
+ * A checkpoint that took this long is reported at WARN with its numbers.
55
+ * Matched to `SQLITE_SLOW_CALL_MS`: it is the same "the disk held us" event
56
+ * the profiler used to file as a slow `set`, now on the thread that paid it.
57
+ */
58
+ export declare const WAL_CHECKPOINT_SLOW_MS = 1000;
59
+ /** The two wal-index counters the judgement reads, or `null` when unreadable. */
60
+ export interface WalIndexCounters {
61
+ /** Frames in the WAL that are valid for the current cycle. */
62
+ readonly mxFrame: number | null;
63
+ /** Frames already copied back into the database file. */
64
+ readonly nBackfill: number | null;
65
+ }
66
+ export interface CheckpointDecisionInput extends WalIndexCounters {
67
+ readonly sinceLastRunMs: number;
68
+ }
69
+ export type CheckpointReason = 'threshold' | 'interval' | 'unknown-interval' | 'below-threshold' | 'unknown-below-interval' | 'nothing-pending';
70
+ export interface CheckpointDecision {
71
+ readonly run: boolean;
72
+ readonly reason: CheckpointReason;
73
+ readonly pendingFrames: number | null;
74
+ }
75
+ /** Should the worker run `wal_checkpoint(PASSIVE)` now? */
76
+ export declare function decideCheckpoint(input: CheckpointDecisionInput): CheckpointDecision;
77
+ /** Bytes needed to read both fields. */
78
+ export declare const WAL_INDEX_HEADER_READ_BYTES: number;
79
+ /**
80
+ * `mxFrame` and `nBackfill` from the first {@link WAL_INDEX_HEADER_READ_BYTES}
81
+ * of the `-shm` file, or `null` when the buffer is short or the two header
82
+ * copies disagree (a writer was updating them — SQLite's own readers retry on
83
+ * exactly that comparison; this caller simply waits for the next poll).
84
+ */
85
+ export declare function parseWalIndexHeader(buffer: Buffer): WalIndexCounters | null;
86
+ /** What the worker tells the parent after one checkpoint. */
87
+ export interface CheckpointReport {
88
+ readonly kind: 'checkpointed';
89
+ readonly reason: CheckpointReason;
90
+ readonly pendingFrames: number | null;
91
+ /** `PRAGMA wal_checkpoint` row: frames in the WAL, frames now backfilled, busy flag. */
92
+ readonly walFrames: number;
93
+ readonly checkpointedFrames: number;
94
+ readonly busy: boolean;
95
+ readonly ms: number;
96
+ }
97
+ export interface WorkerReady {
98
+ readonly kind: 'ready';
99
+ }
100
+ export interface WorkerFailure {
101
+ readonly kind: 'failed';
102
+ readonly error: string;
103
+ }
104
+ export type WorkerMessage = CheckpointReport | WorkerReady | WorkerFailure;
105
+ export interface WorkerStop {
106
+ readonly kind: 'stop';
107
+ }
108
+ /** What the worker is started with. */
109
+ export interface WalCheckpointWorkerData {
110
+ readonly dbPath: string;
111
+ readonly pollMs: number;
112
+ }
113
+ /** Narrow a message off the worker port without a cast. */
114
+ export declare function isWorkerMessage(value: unknown): value is WorkerMessage;
115
+ export declare function isWorkerStop(value: unknown): value is WorkerStop;
@@ -0,0 +1,70 @@
1
+ import { IScopedLogger } from '@camstack/types';
2
+ import { WalCheckpointWorkerData } from './wal-checkpoint-policy.js';
3
+ /** How often the running totals are written as one INFO line, in ms. */
4
+ export declare const WAL_CHECKPOINT_SUMMARY_INTERVAL_MS: number;
5
+ /** Running totals since the last summary. Exposed for tests. */
6
+ export interface WalCheckpointStats {
7
+ readonly checkpoints: number;
8
+ readonly frames: number;
9
+ readonly slow: number;
10
+ readonly maxMs: number;
11
+ readonly totalMs: number;
12
+ readonly busy: number;
13
+ }
14
+ /**
15
+ * The members of a `Worker` this class touches. Structural, so the unit spec
16
+ * drives an `EventEmitter` through the same surface without a cast.
17
+ */
18
+ export interface CheckpointWorkerHandle {
19
+ on(event: 'message', listener: (message: unknown) => void): unknown;
20
+ on(event: 'error', listener: (err: unknown) => void): unknown;
21
+ on(event: 'exit', listener: (code: number) => void): unknown;
22
+ once(event: 'exit', listener: (code: number) => void): unknown;
23
+ postMessage(message: unknown): void;
24
+ }
25
+ /** The one impure step — spawning the thread — injectable for the unit spec. */
26
+ export type WorkerFactory = (workerData: WalCheckpointWorkerData) => CheckpointWorkerHandle;
27
+ /**
28
+ * Where the built worker entry lives: `dist/wal-checkpoint-worker.js` at the
29
+ * package root, next to `addon-runner.js`, found through the package's own
30
+ * `exports["./package.json"]` so it resolves the same way from the workspace
31
+ * and from an installed closure.
32
+ */
33
+ export declare function defaultWorkerPath(): string;
34
+ export interface WalCheckpointerOptions {
35
+ readonly dbPath: string;
36
+ readonly logger: IScopedLogger;
37
+ readonly pollMs?: number;
38
+ readonly slowMs?: number;
39
+ readonly summaryIntervalMs?: number;
40
+ /** Overrides the built entry — a spec points this at the TypeScript source. */
41
+ readonly workerPath?: string;
42
+ /** Extra `execArgv` for the thread — a spec passes a loader here. */
43
+ readonly workerExecArgv?: readonly string[];
44
+ readonly workerFactory?: WorkerFactory;
45
+ }
46
+ export declare class WalCheckpointer {
47
+ private readonly dbPath;
48
+ private readonly logger;
49
+ private readonly pollMs;
50
+ private readonly slowMs;
51
+ private readonly summaryIntervalMs;
52
+ private readonly spawn;
53
+ private worker;
54
+ private summaryTimer;
55
+ private stopping;
56
+ private statsValue;
57
+ constructor(options: WalCheckpointerOptions);
58
+ /** Totals since the last summary line. */
59
+ get stats(): WalCheckpointStats;
60
+ isRunning(): boolean;
61
+ start(): void;
62
+ /** Ask the thread to close its connection and exit; resolves when it has. */
63
+ stop(): Promise<void>;
64
+ /** One message off the port. Public so the spec can feed it directly. */
65
+ onMessage(message: unknown): void;
66
+ private handle;
67
+ private record;
68
+ private logSummary;
69
+ private onExit;
70
+ }
@@ -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-BOlMCOeT.js");
6
+ const require_dist = require("../../dist-CllKpcTd.js");
7
7
  const require_hub_cap_forward = require("../../hub-cap-forward-DmHNjbB0.js");
8
8
  let zod = require("zod");
9
9
  let node_crypto = require("node:crypto");
@@ -1,4 +1,4 @@
1
- import { Bt as storageMigrationCapability, D as StorageMigrationJobSchema, E as StorageLocationTypeSchema, Lt as settingsStoreCapability, R as collectSecretConfigKeys, St as modeMayWrite, T as StorageLocationModeSchema, Yt as BaseAddon, bt as mayWriteToLocation, et as evictionPolicyOfLocation, g as REDACTED_SECRET, hn as parseJsonObject, it as gbToBytes, jt as resolveLocationMode, m as LegacyStorageLocationDefaultSchema, pt as legacyModeOf, qt as withLocationMode, st as isLocationEnabled, w as StorageCleanupJobSchema, xn as EventCategory, yt as mayReadLocation, zt as storageCapability } from "../../dist-DigmGsQS.mjs";
1
+ import { Bt as storageMigrationCapability, D as StorageMigrationJobSchema, E as StorageLocationTypeSchema, Lt as settingsStoreCapability, R as collectSecretConfigKeys, St as modeMayWrite, T as StorageLocationModeSchema, Yt as BaseAddon, bt as mayWriteToLocation, et as evictionPolicyOfLocation, g as REDACTED_SECRET, hn as parseJsonObject, it as gbToBytes, jt as resolveLocationMode, m as LegacyStorageLocationDefaultSchema, pt as legacyModeOf, qt as withLocationMode, st as isLocationEnabled, w as StorageCleanupJobSchema, xn as EventCategory, yt as mayReadLocation, zt as storageCapability } from "../../dist-Ca_jaxXs.mjs";
2
2
  import { t as HUB_CAP_FWD_ACTION } from "../../hub-cap-forward-BdT320dq.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
  require("../../chunk-Cek0wNdY.js");
6
- const require_dist = require("../../dist-BOlMCOeT.js");
6
+ const require_dist = require("../../dist-CllKpcTd.js");
7
7
  //#region src/builtins/system-config/system-config.addon.ts
8
8
  /**
9
9
  * Built-in `system-config` addon — Phase 4 of the settings redesign.
@@ -1,4 +1,4 @@
1
- import { Jt as errMsg, Yt as BaseAddon, fn as hydrateSchema } from "../../dist-DigmGsQS.mjs";
1
+ import { Jt as errMsg, Yt as BaseAddon, fn as hydrateSchema } from "../../dist-Ca_jaxXs.mjs";
2
2
  //#region src/builtins/system-config/system-config.addon.ts
3
3
  /**
4
4
  * Built-in `system-config` addon — Phase 4 of the settings redesign.
@@ -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-BOlMCOeT.js");
6
+ const require_dist = require("../../dist-CllKpcTd.js");
7
7
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  let node_path = require("node:path");
9
9
  node_path = require_chunk.__toESM(node_path);
@@ -1,4 +1,4 @@
1
- import { Yt as BaseAddon, gt as logDestinationCapability } from "../../dist-DigmGsQS.mjs";
1
+ import { Yt as BaseAddon, gt as logDestinationCapability } from "../../dist-Ca_jaxXs.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  import * as path$1 from "node:path";
4
4
  import path from "node:path";
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-BOlMCOeT.js");
1
+ const require_dist = require("./dist-CllKpcTd.js");
2
2
  //#region src/kernel/custom-action-registry.ts
3
3
  /**
4
4
  * CustomActionRegistry — per-process registry of addon custom actions.
@@ -1,4 +1,4 @@
1
- import { G as describeCustomActions } from "./dist-DigmGsQS.mjs";
1
+ import { G as describeCustomActions } from "./dist-Ca_jaxXs.mjs";
2
2
  //#region src/kernel/custom-action-registry.ts
3
3
  /**
4
4
  * CustomActionRegistry — per-process registry of addon custom actions.