@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
@@ -1,23 +1,33 @@
1
1
  /**
2
- * Reads: `listSeries` and `query` (plan §5.1).
2
+ * Reads: `listSeries`, `query` and `queryMany` (plan §5.1).
3
3
  *
4
4
  * `auto` resolution picks the finest tier whose retention covers `from` and
5
5
  * whose point count fits `maxPoints`: a rollup tier fits when
6
6
  * `ceil(range / bucket) <= maxPoints`, raw fits when a read of `maxPoints + 1`
7
7
  * rows comes back short. The coarsest covering tier is the last resort and is
8
8
  * truncated to its newest `maxPoints` points (`truncated: true`) rather than
9
- * answering nothing.
9
+ * answering nothing. A series fed by closed buckets has NO raw rows, so raw is
10
+ * never a candidate for it: an empty raw read "fits" every window.
10
11
  *
11
12
  * `before` is the last point strictly before the window in the chosen tier, so a
12
13
  * step chart can start at the value in force when the window opens — a quiet
13
14
  * bucket has no row, and the held value is otherwise invisible.
15
+ *
16
+ * {@link DEVICE_HISTORY_ENERGY_KEY} is computed here at read time, never stored:
17
+ * the device's `kwhTotal` meter when it has one (per-bucket growth), else the
18
+ * time-weighted integral of its `watts` (`tw_sum`, already in every rollup).
19
+ * One place makes that choice, so two charts of one device cannot disagree, and
20
+ * it covers every hour of history recorded before the key existed.
14
21
  */
15
- import type { DeviceHistoryQueryPoint, DeviceHistoryResolution, DeviceHistorySeriesInfo, DeviceHistorySubject } from "@camstack/types";
22
+ import { type DeviceHistoryQueryManyEntry, type DeviceHistoryQueryManyItem, type DeviceHistoryQueryPoint, type DeviceHistoryResolution, type DeviceHistorySeriesInfo, type DeviceHistorySubject } from "@camstack/types";
16
23
  import { type RetentionPolicy } from "../retention/retention.js";
17
24
  import type { HistoryStore } from "../store/history-store.js";
18
25
  import { type SeriesRegistry } from "../store/series-registry.js";
19
26
  import { type HistoryCatalog } from "../capture/capture-engine.js";
20
27
  type Tier = DeviceHistoryResolution;
28
+ /** The power-meter series the energy key is derived from, meter first. */
29
+ export declare const ENERGY_METER_KEY: string;
30
+ export declare const ENERGY_POWER_KEY: string;
21
31
  export interface QueryInput {
22
32
  readonly key: string;
23
33
  readonly subject: DeviceHistorySubject;
@@ -27,19 +37,29 @@ export interface QueryInput {
27
37
  readonly resolution: Tier | "auto";
28
38
  readonly maxPoints: number;
29
39
  }
40
+ export interface QueryBefore {
41
+ readonly t: number;
42
+ readonly value: number | null;
43
+ readonly state: string | null;
44
+ }
30
45
  export interface QuerySeries {
31
46
  readonly scope: string;
32
- readonly before: {
33
- readonly t: number;
34
- readonly value: number | null;
35
- } | null;
47
+ readonly before: QueryBefore | null;
36
48
  readonly points: readonly DeviceHistoryQueryPoint[];
49
+ readonly derivedFrom: string | null;
37
50
  }
38
51
  export interface QueryOutput {
39
52
  readonly resolution: Tier;
40
53
  readonly series: readonly QuerySeries[];
41
54
  readonly truncated: boolean;
42
55
  }
56
+ export interface QueryManyInput {
57
+ readonly items: readonly DeviceHistoryQueryManyItem[];
58
+ readonly from: number;
59
+ readonly to: number;
60
+ readonly resolution: Tier | "auto";
61
+ readonly maxPoints: number;
62
+ }
43
63
  export interface QueryDeps {
44
64
  readonly registry: SeriesRegistry;
45
65
  readonly store: HistoryStore;
@@ -53,14 +73,20 @@ export declare class HistoryQuery {
53
73
  private readonly deps;
54
74
  constructor(deps: QueryDeps);
55
75
  query(input: QueryInput): Promise<QueryOutput>;
76
+ /** Several reads over one window; one failing item answers its error, not the batch's. */
77
+ queryMany(input: QueryManyInput): Promise<readonly DeviceHistoryQueryManyEntry[]>;
78
+ private seriesOf;
79
+ /** The tier to answer from and its reads. `noRaw`: the series has no raw rows to read. */
80
+ private choose;
56
81
  /** Tiers whose retention covers `from`, finest first; the coarsest is always present. */
57
82
  private coveringTiers;
58
83
  /** Cheap fit test for rollup tiers; raw is decided by the read itself. */
59
84
  private fits;
60
85
  private readTier;
61
- /** Rows arrive newest first and one over the bound; keep the newest `maxPoints`, oldest first. */
62
- private shape;
63
86
  private before;
87
+ /** The series energy is derived from for a device: the meter when it has one, else its power. */
88
+ private energySource;
89
+ private queryEnergy;
64
90
  listSeries(subject: DeviceHistorySubject): Promise<readonly DeviceHistorySeriesInfo[]>;
65
91
  /** The metric's fixed unit, else the device's own (a `unitFrom` field), else unknown. */
66
92
  private unitOf;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Stored rows → the wire points of a query (PURE). What a point MEANS depends on
3
+ * the series' kind:
4
+ *
5
+ * - `gauge` / `boolean`: the stored numbers as they are (`twMean` of a boolean
6
+ * is the fraction of time true);
7
+ * - `counter`: plus `delta`, the growth since the previous point or bucket. A
8
+ * reading LOWER than the previous one is a reset (a replaced meter, a
9
+ * firmware wipe): the growth is counted from zero, never negative. With no
10
+ * previous reading, a bucket's own growth is `last - min`;
11
+ * - `enum`: the stored number is an ordinal, so `mean` / `twMean` mean nothing
12
+ * and are `null`; `state` names the ordinal and a rollup's `states` gives the
13
+ * milliseconds spent in each state, by name.
14
+ */
15
+ import type { DeviceHistoryKind, DeviceHistoryQueryPoint } from "@camstack/types";
16
+ import type { RawPoint, RollupRow } from "../rollup/rollup-math.js";
17
+ export interface SeriesMeaning {
18
+ readonly kind: DeviceHistoryKind;
19
+ /** `enum`: the value of each ordinal; `null` otherwise. */
20
+ readonly values: readonly string[] | null;
21
+ }
22
+ /** kWh in one W·ms: 1 kWh = 1 000 W × 3 600 000 ms. */
23
+ export declare const KWH_PER_WATT_MS: number;
24
+ /** Growth from `prev` to `cur`; a drop is a reset counted from zero. `fallback` when `prev` is unknown. */
25
+ export declare function counterDelta(prev: number | null, cur: number | null, fallback: number | null): number | null;
26
+ /** The name of an ordinal, or `null` when the series is not an enum or the ordinal is unknown. */
27
+ export declare function stateName(meaning: SeriesMeaning, ordinal: number | null): string | null;
28
+ /** Raw points, oldest first; `prev` is the value of the point before the first one. */
29
+ export declare function rawPoints(rows: readonly RawPoint[], meaning: SeriesMeaning, prev: number | null): readonly DeviceHistoryQueryPoint[];
30
+ /** Rollup rows, oldest first; `prevLast` is the `last` of the bucket before the first one. */
31
+ export declare function rollupPoints(rows: readonly RollupRow[], meaning: SeriesMeaning, prevLast: number | null): readonly DeviceHistoryQueryPoint[];
32
+ /** Energy used in each bucket of a `watts` gauge: its time-weighted integral, in kWh. */
33
+ export declare function integratedEnergyPoints(rows: readonly RollupRow[]): readonly DeviceHistoryQueryPoint[];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Retention (plan §5.5, operator answer §13): raw 7 days, 5m 14 days, 1h 1 year,
2
+ * Retention (plan §5.5, operator answer §13): raw 7 days, 5m 30 days, 1h 1 year,
3
3
  * 1d forever — global addon settings.
4
4
  *
5
5
  * Per series and per tier the delete is a PRIMARY KEY range
@@ -58,6 +58,8 @@ export declare class RollupEngine {
58
58
  private tickFiveMinute;
59
59
  private tickHour;
60
60
  private tickDay;
61
+ /** An `enum` series keeps the time spent in each state in its rollups. */
62
+ private isEnum;
61
63
  /** Raw → 5m rows for buckets in `[from, toExclusive)`; writes them and marks their hours. */
62
64
  recomputeFiveMinute(seriesId: number, from: number, toExclusive: number, horizon: number): Promise<number>;
63
65
  private recomputeHour;
@@ -12,6 +12,8 @@ export interface RollupRow {
12
12
  readonly twSum: number | null;
13
13
  /** Milliseconds `twSum` covers. */
14
14
  readonly twMs: number | null;
15
+ /** `enum` series: ms spent in each state (keyed by ordinal) over the covered time; `null` otherwise. */
16
+ readonly states: Readonly<Record<string, number>> | null;
15
17
  }
16
18
  export interface RawPoint {
17
19
  readonly ts: number;
@@ -25,6 +27,8 @@ export interface RawToFiveMinuteInput {
25
27
  readonly carryIn: RawPoint | null;
26
28
  /** Time-weighting stops here for a bucket that has not closed yet. */
27
29
  readonly horizon: number;
30
+ /** An `enum` series: also keep the ms spent in each state (keyed by ordinal). */
31
+ readonly trackStates?: boolean;
28
32
  }
29
33
  /** One row per 5-minute bucket that has at least one point. */
30
34
  export declare function rawToFiveMinuteRows(input: RawToFiveMinuteInput): readonly RollupRow[];
@@ -39,6 +43,8 @@ export interface CombineInput {
39
43
  readonly carryIn: number | null;
40
44
  /** Time-weighting stops here for a window that has not closed yet. */
41
45
  readonly horizon: number;
46
+ /** An `enum` series: also sum the time in each state, gaps credited to the held state. */
47
+ readonly trackStates?: boolean;
42
48
  }
43
49
  /** One row of the next tier from the child rows of its window; `null` when there are none. */
44
50
  export declare function combineRows(input: CombineInput): RollupRow | null;
@@ -22,6 +22,8 @@ export interface MetricRecord {
22
22
  readonly displayName: string;
23
23
  readonly ingest: "points" | "buckets";
24
24
  readonly declaredAt: number;
25
+ /** `enum`: the value of each ordinal (index = ordinal), append-only; `null` for every other kind. */
26
+ readonly values: readonly string[] | null;
25
27
  }
26
28
  export interface SeriesRecord {
27
29
  readonly id: number;
@@ -52,6 +54,11 @@ export declare class HistoryStore {
52
54
  constructor(door: HistoryDoor);
53
55
  declare(): Promise<void>;
54
56
  loadMetrics(): Promise<readonly MetricRecord[]>;
57
+ /**
58
+ * Delete metric rows no lookup can reach: rows an earlier build wrote under an
59
+ * engine-minted random key (every metric key is `cap:` / `addon:` prefixed).
60
+ */
61
+ deleteMetrics(keys: readonly string[]): Promise<void>;
55
62
  upsertMetric(metric: MetricRecord): Promise<void>;
56
63
  /** Series with `id > afterId`, ascending — the boot load pages with this. */
57
64
  loadSeriesPage(afterId: number, limit: number): Promise<readonly SeriesRecord[]>;
@@ -8,21 +8,46 @@ import type { DeviceHistorySubject } from "@camstack/types";
8
8
  import { HistoryStore, type MetricRecord, type SeriesRecord } from "./history-store.js";
9
9
  export declare function subjectIdOf(subject: DeviceHistorySubject): string;
10
10
  export declare function deviceIdOf(subject: DeviceHistorySubject): number | null;
11
+ /** Every metric key is a cap field (`cap:`), an addon's series (`addon:`) or derived. */
12
+ export declare function isMetricKey(key: string): boolean;
11
13
  export declare function identityOf(key: string, subjectId: string, scope: string): string;
14
+ /**
15
+ * Values one `enum` key may learn. A field that keeps producing new values is
16
+ * free text, not a state: past this its new values are refused (counted), never
17
+ * allowed to grow the dictionary — and so every stored row — without bound.
18
+ */
19
+ export declare const MAX_ENUM_VALUES = 1024;
20
+ /** Append what `next` names that `stored` lacks, in `next`'s order: an ordinal never moves. */
21
+ export declare function mergeEnumValues(stored: readonly string[] | null, next: readonly string[] | null): readonly string[] | null;
12
22
  export declare class SeriesRegistry {
13
23
  private readonly store;
14
24
  private readonly metrics;
15
25
  private readonly byIdentity;
16
26
  private readonly byId;
17
27
  private readonly inflight;
28
+ /** Enum metrics whose value list grew in memory and is not stored yet. */
29
+ private readonly dirtyMetrics;
18
30
  private readonly removeListeners;
19
31
  constructor(store: HistoryStore);
20
32
  load(): Promise<void>;
21
33
  private index;
22
34
  metric(key: string): MetricRecord | undefined;
23
35
  allMetrics(): readonly MetricRecord[];
24
- /** Persist and remember a metric; idempotent. */
36
+ /**
37
+ * Persist and remember a metric; idempotent. An `enum` value list is MERGED
38
+ * append-only with the stored one, so reordering a `z.enum` never changes
39
+ * what a stored ordinal means.
40
+ */
25
41
  declareMetric(metric: MetricRecord): Promise<void>;
42
+ /**
43
+ * The ordinal of `value` in an `enum` metric's list, learning (appending) a
44
+ * value seen for the first time. `null` when the key is not an enum metric or
45
+ * its list is full ({@link MAX_ENUM_VALUES}). A learned value is stored by
46
+ * {@link persistDirtyMetrics} BEFORE any point that uses it.
47
+ */
48
+ ordinalOf(key: string, value: string): number | null;
49
+ /** Store every value list that grew in memory. Throws (and keeps them dirty) on a failed write. */
50
+ persistDirtyMetrics(): Promise<void>;
26
51
  find(key: string, subjectId: string, scope: string): SeriesRecord | undefined;
27
52
  byIdOf(id: number): SeriesRecord | undefined;
28
53
  all(): readonly SeriesRecord[];
@@ -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
  const require_read_all_rows$1 = require("../../read-all-rows-CVoO1ONM.js");
8
8
  const require_prefix_range = require("../../prefix-range-D_KueXbQ.js");
9
9
  const require_prefix_walk = require("../../prefix-walk-Dv6MLZlM.js");
@@ -1,4 +1,4 @@
1
- import { Bn as normalizeUnit, Ci as WELL_KNOWN_TAB_MAP, Gi as isKeychainStoredField, Gr as DeviceType, I as FieldClaimModeSchema, Ji as isSecretMarkerLike, Ki as isSecretClear, Kr as errMsg, L as FieldClaimSchema, Li as defineRecordKinds, Mi as collectZodSecretPaths, N as DeviceStatusSchema, Ot as canonicalIconKey, P as DeviceTombstoneSchema, Qt as deviceStatusCapability, Rt as createDeviceExtensionProvider, Tn as legacyAutoLinkIds, Tt as buildStreamParamsConfigSchema, Ui as isDeviceConfigCap, Un as parseStreamParamsFormPatch, Ur as DeviceFeature, Ut as defineExtensionSlotProvider, Wr as DeviceRole, Yt as deviceManagerCapability, Zt as deviceStateCapability, _a as userError, bi as SECRET_CLEAR, c as CAMERA_SWITCH_ORDER, da as secretTreeFromPaths, en as enumerateItemArrayFields, ga as transformSecretWrite, ha as toSecretFieldView, in as expandContainer, kn as locationIconKey, la as resolveSecretMarkers, pa as sleep$1, pr as siteZoneKey, q as MINUTES_PER_DAY, qi as isSecretMarker, qr as BaseAddon, qt as deviceExtensionCapability, r as ALL_CAPABILITY_DEFINITIONS, sr as runtimeStatePolicyFor, tn as enumerateSchemaFields, tt as STREAM_PROFILE_META, u as CAP_NAMES_WITH_STATUS, un as formatMinutes, w as DAY_NAMES, ya as EventCategory } from "../../dist-BpSENkRJ.mjs";
1
+ import { $r as DeviceRole, Ea as userError, F as DeviceStatusSchema, I as DeviceTombstoneSchema, It as canonicalIconKey, Ki as defineRecordKinds, Kt as createDeviceExtensionProvider, Mi as WELL_KNOWN_TAB_MAP, Nt as buildStreamParamsConfigSchema, Oa as EventCategory, Pn as legacyAutoLinkIds, Qi as isDeviceConfigCap, Qn as parseStreamParamsFormPatch, Qr as DeviceFeature, R as FieldClaimModeSchema, Rn as locationIconKey, Sa as sleep$1, Sr as siteZoneKey, T as DAY_NAMES, Ta as transformSecretWrite, Vi as collectZodSecretPaths, Y as MINUTES_PER_DAY, Yn as normalizeUnit, Zt as defineExtensionSlotProvider, an as deviceStateCapability, ba as secretTreeFromPaths, c as CAMERA_SWITCH_ORDER, cn as enumerateItemArrayFields, ct as STREAM_PROFILE_META, ea as isKeychainStoredField, ei as DeviceType, fn as expandContainer, gr as runtimeStatePolicyFor, ki as SECRET_CLEAR, ln as enumerateSchemaFields, na as isSecretMarker, ni as BaseAddon, on as deviceStatusCapability, r as ALL_CAPABILITY_DEFINITIONS, ra as isSecretMarkerLike, rn as deviceManagerCapability, ta as isSecretClear, ti as errMsg, tn as deviceExtensionCapability, u as CAP_NAMES_WITH_STATUS, va as resolveSecretMarkers, vn as formatMinutes, wa as toSecretFieldView, z as FieldClaimSchema } from "../../dist-Dhux90yB.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
3
  import { t as prefixRange } from "../../prefix-range-Dl0znowN.mjs";
4
4
  import { t as loadPrefixed } from "../../prefix-walk-DAOBSyH1.mjs";
@@ -1,4 +1,4 @@
1
- import type { IClusterBroker, ILogDestination, IScopedLogger, LogEntry, LogFilter } from "@camstack/types";
1
+ import type { IClusterBroker, ILogDestination, IScopedLogger, LogEntry } from "@camstack/types";
2
2
  /**
3
3
  * Log destination for agent mode.
4
4
  *
@@ -36,7 +36,6 @@ export declare class HubForwarderDestination implements ILogDestination {
36
36
  */
37
37
  connectBroker(broker: IClusterBroker): void;
38
38
  write(entry: LogEntry): void;
39
- query(_filter: LogFilter): Promise<readonly LogEntry[]>;
40
39
  shutdown(): Promise<void>;
41
40
  private bufferOutbound;
42
41
  private flushOutbound;
@@ -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
  const require_formatter = require("../../formatter-DqAKDlvN.js");
8
8
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
9
9
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -82,9 +82,6 @@ var HubForwarderDestination = class {
82
82
  else if (entry.level === "warn") console.warn(line);
83
83
  else console.log(line);
84
84
  }
85
- async query(_filter) {
86
- return [];
87
- }
88
85
  async shutdown() {
89
86
  this.hubConnected = false;
90
87
  this.broker = null;
@@ -1,4 +1,4 @@
1
- import { An as logDestinationCapability, qr as BaseAddon } from "../../dist-BpSENkRJ.mjs";
1
+ import { ni as BaseAddon, zn as logDestinationCapability } from "../../dist-Dhux90yB.mjs";
2
2
  import { t as formatLogLine } from "../../formatter-B7qW8bPJ.mjs";
3
3
  //#region src/builtins/hub-forwarder/hub-forwarder-destination.ts
4
4
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
@@ -77,9 +77,6 @@ var HubForwarderDestination = class {
77
77
  else if (entry.level === "warn") console.warn(line);
78
78
  else console.log(line);
79
79
  }
80
- async query(_filter) {
81
- return [];
82
- }
83
80
  async shutdown() {
84
81
  this.hubConnected = false;
85
82
  this.broker = null;
@@ -3,11 +3,11 @@ 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
- const require_device_ca = require("../../device-ca-QPBgfqVY.js");
9
- const require_phase6_declare_gate = require("../../phase6-declare-gate-DrmTtz7F.js");
10
- const require_constants = require("../../constants-DruwCkfp.js");
8
+ const require_device_ca = require("../../device-ca-CVK3YcR_.js");
9
+ const require_phase6_declare_gate = require("../../phase6-declare-gate-BO-_jLh_.js");
10
+ const require_constants = require("../../constants-B_X9cWEK.js");
11
11
  const require_platform_key_source = require("../../platform-key-source-Di7HrlGR.js");
12
12
  let node_crypto = require("node:crypto");
13
13
  let _camstack_types_node = require("@camstack/types/node");
@@ -1,8 +1,8 @@
1
- import { Cn as keychainAdminCapability, H as KeychainAuditEntrySchema, Li as defineRecordKinds, U as KeychainResetRecordSchema, V as KEYCHAIN_RESET_TRIGGER_ACTOR, Vi as formatSecretScope, ea as normalizeSecretOwner, qr as BaseAddon, ra as parseSecretRef, wn as keychainCapability, ya as EventCategory } from "../../dist-BpSENkRJ.mjs";
1
+ import { G as KeychainResetRecordSchema, Ki as defineRecordKinds, Mn as keychainAdminCapability, Nn as keychainCapability, Oa as EventCategory, U as KEYCHAIN_RESET_TRIGGER_ACTOR, W as KeychainAuditEntrySchema, Xi as formatSecretScope, fa as parseSecretRef, la as normalizeSecretOwner, ni as BaseAddon } from "../../dist-Dhux90yB.mjs";
2
2
  import { t as require_read_all_rows } from "../../read-all-rows-TaPqdWNF.mjs";
3
- import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-uFbTyY_o.mjs";
4
- import { t as resolvePhase6UseRecordsPathForHub } from "../../phase6-declare-gate-JQUqgQgq.mjs";
5
- import { a as MESH_CA_KEY_REF } from "../../constants-DOlYt1t1.mjs";
3
+ import { d as JWT_SIGNING_KEY_REF, n as DEVICE_CA_KEY_REF, p as SYSTEM_SECRET_OWNER } from "../../device-ca-BB6nHAL5.mjs";
4
+ import { t as resolvePhase6UseRecordsPathForHub } from "../../phase6-declare-gate-x9ZCbQJP.mjs";
5
+ import { a as MESH_CA_KEY_REF } from "../../constants-cxKcZRMi.mjs";
6
6
  import { n as getPlatformKeychainKey } from "../../platform-key-source-BWlq0jjn.mjs";
7
7
  import { createCipheriv, createDecipheriv, createHmac, randomBytes, randomUUID, timingSafeEqual } from "node:crypto";
8
8
  import { restrictDirToOwnerSync, restrictFileToOwnerSync, writeOwnerOnlyFileSync } from "@camstack/types/node";
@@ -1,6 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
2
  require("../../chunk-Cek0wNdY.js");
3
- const require_dist = require("../../dist-DjQ8C-ku.js");
3
+ const require_dist = require("../../dist-C89nqNnn.js");
4
4
  //#region src/builtins/liveness-monitor/liveness-checks.ts
5
5
  var NO_DEVICES = "liveness:no-devices";
6
6
  var ALL_OFFLINE = "liveness:all-devices-offline";
@@ -1,4 +1,4 @@
1
- import { Kr as errMsg, Ni as createEvent, X as RECORDING_SOURCE_CAMSTACK_ADDON, Z as RecordingStatusSchema, qr as BaseAddon, ya as EventCategory } from "../../dist-BpSENkRJ.mjs";
1
+ import { Hi as createEvent, Oa as EventCategory, it as RecordingStatusSchema, ni as BaseAddon, nt as RECORDING_SOURCE_CAMSTACK_ADDON, ti as errMsg } from "../../dist-Dhux90yB.mjs";
2
2
  //#region src/builtins/liveness-monitor/liveness-checks.ts
3
3
  var NO_DEVICES = "liveness:no-devices";
4
4
  var ALL_OFFLINE = "liveness:all-devices-offline";
@@ -12,7 +12,7 @@
12
12
  * - scoped_tokens
13
13
  * - oauth_sessions
14
14
  * - login_sessions, login_session_cutoffs (`login-session-manager.ts`)
15
- * - admin_tokens (`admin-token-manager.ts`), auth_audit (`auth-audit-log.ts`)
15
+ * - admin_tokens (`legacy-token-tables.ts`, read by nothing since D895), auth_audit (`auth-audit-log.ts`)
16
16
  *
17
17
  * Schema migration: when the backend receives `declareCollection` for
18
18
  * a name that already exists with a legacy `(id, data)` KV shape, the
@@ -44,12 +44,9 @@ export declare const USERS_COLLECTION = "users";
44
44
  export declare const API_KEYS_COLLECTION = "api_keys";
45
45
  /**
46
46
  * @durable class=config owner=local-auth
47
- * write="an operator or the CLI mints a scoped token; `validate` fires
48
- * `updateLastUsed` on every accepted call"
49
- * retention="`revoke` deletes one. The daily sweep `reapExpired` drops rows past
50
- * `expiresAt` — a NULL expiry is a deliberate never-expires token and BETWEEN
51
- * never matches it. `cleanupOrphans` drops tokens owned by the legacy 'system'
52
- * id or by a user that no longer exists."
47
+ * write="none since D895 — the pre-D892 scoped-token rows are kept on disk,
48
+ * read by nothing (a scoped token is a `credential-tokens` row)"
49
+ * retention="the operator drops the table by hand"
53
50
  */
54
51
  export declare const SCOPED_TOKENS_COLLECTION = "scoped_tokens";
55
52
  /**
@@ -4,17 +4,16 @@ export declare class LocalAuthAddon extends BaseAddon {
4
4
  private authManager;
5
5
  private userManager;
6
6
  private apiKeyManager;
7
- private scopedTokenManager;
8
7
  private oauthSessionManager;
9
8
  private reapTimer;
10
9
  private totpManager;
11
10
  private externalIdentities;
12
11
  private signingKeyKeeper;
13
12
  private loginSessions;
14
- private adminTokens;
15
13
  private auditLog;
16
14
  private deviceCredentials;
17
15
  private deviceCa;
16
+ private preferences;
18
17
  constructor();
19
18
  protected onInitialize(): Promise<ProviderRegistration[]>;
20
19
  private readDeviceCertificateSettings;
@@ -35,13 +34,13 @@ export declare class LocalAuthAddon extends BaseAddon {
35
34
  */
36
35
  private endAllAccess;
37
36
  /**
38
- * Drop auth rows that are dead but were never removed: scoped tokens past
39
- * their expiry, and OAuth sessions revoked longer ago than
40
- * {@link OAUTH_REVOKED_RETENTION_MS}.
37
+ * Drop auth rows that are dead but were never removed: OAuth sessions
38
+ * revoked longer ago than {@link OAUTH_REVOKED_RETENTION_MS}, dead login
39
+ * sessions, old audit rows, dead device credentials. (Tokens are the hub's
40
+ * `credential-tokens` rows, reaped there.)
41
41
  *
42
- * Neither row could authorise anything — `validate` rejects an expired
43
- * token, and every consumer treats a missing session exactly like a revoked
44
- * one. So this is hygiene, and it is best-effort: a failed sweep is logged
42
+ * No such row could authorise anything — every consumer treats a missing
43
+ * session exactly like a revoked one. So this is hygiene, and it is best-effort: a failed sweep is logged
45
44
  * and the next tick tries again. It must never be able to fail boot.
46
45
  */
47
46
  private reapAuthRows;