@camstack/server 1.2.940 → 1.2.942

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 (154) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/api/trpc/generated-cap-mounts.js +19 -1
  3. package/dist/api/trpc/generated-cap-routers.js +676 -596
  4. package/package.json +27 -12
  5. package/system/dist/action-index-B1fgpQBt.mjs +9925 -0
  6. package/system/dist/action-index-B_cLRwXJ.js +9972 -0
  7. package/system/dist/alert-episode-Be--PngO.mjs +64 -0
  8. package/system/dist/alert-episode-Bqktmt-i.js +93 -0
  9. package/system/dist/{base-addon-Md14i7pe.mjs → base-addon-BcS6r1cT.mjs} +20 -7
  10. package/system/dist/{base-addon-DD5dIfcZ.js → base-addon-CRsXtYFG.js} +20 -7
  11. package/system/dist/{base-device-CH8rfD9j.js → base-device-DAdWzDOl.js} +138 -34
  12. package/system/dist/{base-device-BcGO6LTT.mjs → base-device-DJXF5eDN.mjs} +138 -34
  13. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  14. package/system/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  15. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  16. package/system/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  17. package/system/dist/builtins/alerts/alert-episode-policy.d.ts +9 -5
  18. package/system/dist/builtins/alerts/alerts.addon.js +30 -80
  19. package/system/dist/builtins/alerts/alerts.addon.mjs +18 -68
  20. package/system/dist/builtins/autotrack/index.js +2 -2
  21. package/system/dist/builtins/autotrack/index.mjs +2 -2
  22. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +1 -1
  23. package/system/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +1 -1
  24. package/system/dist/builtins/calendars/calendars.addon.js +1 -1
  25. package/system/dist/builtins/calendars/calendars.addon.mjs +1 -1
  26. package/system/dist/builtins/camera-grid/index.js +9 -9
  27. package/system/dist/builtins/camera-grid/index.mjs +6 -6
  28. package/system/dist/builtins/composer/composer.addon.js +99 -99
  29. package/system/dist/builtins/composer/composer.addon.mjs +11 -11
  30. package/system/dist/builtins/console-logging/index.js +1 -1
  31. package/system/dist/builtins/console-logging/index.mjs +1 -1
  32. package/system/dist/builtins/core-blocks/automation-template-instances.d.ts +14 -1
  33. package/system/dist/builtins/core-blocks/core-blocks.addon.d.ts +6 -0
  34. package/system/dist/builtins/core-blocks/core-blocks.addon.js +296 -193
  35. package/system/dist/builtins/core-blocks/core-blocks.addon.mjs +237 -134
  36. package/system/dist/builtins/core-blocks/link-contributions.d.ts +2 -0
  37. package/system/dist/builtins/core-notifier/core-notifier.addon.js +91 -18
  38. package/system/dist/builtins/core-notifier/core-notifier.addon.mjs +91 -18
  39. package/system/dist/builtins/core-notifier/group-notification-output.d.ts +8 -16
  40. package/system/dist/builtins/device-history/device-history.addon.d.ts +8 -0
  41. package/system/dist/builtins/device-history/device-history.addon.js +580 -60
  42. package/system/dist/builtins/device-history/device-history.addon.mjs +569 -49
  43. package/system/dist/builtins/device-history/retention/device-raw-overrides.d.ts +16 -0
  44. package/system/dist/builtins/device-history/retention/retention-knobs.d.ts +14 -0
  45. package/system/dist/builtins/device-history/retention/retention.d.ts +21 -1
  46. package/system/dist/builtins/device-history/transitions/change-coalescing.d.ts +48 -0
  47. package/system/dist/builtins/device-history/transitions/derived-changes.d.ts +49 -0
  48. package/system/dist/builtins/device-history/transitions/history-change-port.d.ts +20 -0
  49. package/system/dist/builtins/device-history/transitions/transitions-service.d.ts +18 -3
  50. package/system/dist/builtins/device-manager/device-identity-index.d.ts +2 -2
  51. package/system/dist/builtins/device-manager/device-manager.addon.js +177 -479
  52. package/system/dist/builtins/device-manager/device-manager.addon.mjs +169 -471
  53. package/system/dist/builtins/device-manager/device-state-mirror.d.ts +0 -5
  54. package/system/dist/builtins/device-manager/identity-link-reconciler.d.ts +5 -0
  55. package/system/dist/builtins/device-manager/transitions/command-recorder.d.ts +38 -0
  56. package/system/dist/builtins/device-manager/transitions/transitions-wiring.d.ts +8 -9
  57. package/system/dist/builtins/hub-forwarder/index.js +1 -1
  58. package/system/dist/builtins/hub-forwarder/index.mjs +1 -1
  59. package/system/dist/builtins/keychain/index.js +2 -2
  60. package/system/dist/builtins/keychain/index.mjs +2 -2
  61. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.js +2 -2
  62. package/system/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +2 -2
  63. package/system/dist/builtins/local-auth/local-auth.addon.js +2 -2
  64. package/system/dist/builtins/local-auth/local-auth.addon.mjs +2 -2
  65. package/system/dist/builtins/local-network/address-book.d.ts +3 -1
  66. package/system/dist/builtins/local-network/local-network.addon.d.ts +26 -1
  67. package/system/dist/builtins/local-network/local-network.addon.js +66 -11
  68. package/system/dist/builtins/local-network/local-network.addon.mjs +66 -11
  69. package/system/dist/builtins/loki-logging/index.js +1 -1
  70. package/system/dist/builtins/loki-logging/index.mjs +1 -1
  71. package/system/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  72. package/system/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  73. package/system/dist/builtins/platform-probe/index.js +1 -1
  74. package/system/dist/builtins/platform-probe/index.mjs +1 -1
  75. package/system/dist/builtins/record-entries/index.js +1 -1
  76. package/system/dist/builtins/record-entries/index.mjs +1 -1
  77. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  78. package/system/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  79. package/system/dist/builtins/snapshot/index.js +4 -4
  80. package/system/dist/builtins/snapshot/index.mjs +4 -4
  81. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  82. package/system/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  83. package/system/dist/builtins/sqlite-storage/index.js +1 -1
  84. package/system/dist/builtins/sqlite-storage/index.mjs +1 -1
  85. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.js +3 -3
  86. package/system/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +3 -3
  87. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +1 -1
  88. package/system/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +1 -1
  89. package/system/dist/builtins/system-config/system-config.addon.js +1 -1
  90. package/system/dist/builtins/system-config/system-config.addon.mjs +1 -1
  91. package/system/dist/builtins/winston-logging/index.js +1 -1
  92. package/system/dist/builtins/winston-logging/index.mjs +1 -1
  93. package/system/dist/{capture-engine-CUZ3W0oZ.mjs → capture-engine-B2MmoNND.mjs} +1 -1
  94. package/system/dist/{capture-engine-mtDXEBAq.js → capture-engine-D_1IJmMs.js} +1 -1
  95. package/system/dist/command-catalog-C29hVOOg.js +210 -0
  96. package/system/dist/command-catalog-xAeqxbZk.mjs +169 -0
  97. package/system/dist/{error.cap-DCwbIGEF.mjs → compile-OBMHlqD-.mjs} +97 -100
  98. package/system/dist/{error.cap-BxLEHP6z.js → compile-SpeAhaZ6.js} +107 -116
  99. package/system/dist/{composition-sources-B56CU8hi.mjs → composition-sources-C327LGFn.mjs} +2 -2
  100. package/system/dist/{composition-sources-D_Bfwji0.js → composition-sources-Do5qM6EB.js} +17 -17
  101. package/system/dist/{core-blocks.cap-xt5_fK5Z.js → core-blocks.cap-CdTGUKtr.js} +194 -10110
  102. package/system/dist/{core-blocks.cap-DDECcMeI.mjs → core-blocks.cap-DLkEfV5b.mjs} +54 -9910
  103. package/system/dist/{device-kind-BJ2pfsjw.mjs → device-kind-C37Ra2wd.mjs} +4 -2
  104. package/system/dist/{device-kind-CsSiv_YF.js → device-kind-FMhJg8uC.js} +4 -2
  105. package/system/dist/{device-manager.cap-DyHOIh5T.js → device-manager.cap-DJs8izI6.js} +13 -4
  106. package/system/dist/{device-manager.cap-DIBK62-r.mjs → device-manager.cap-eYrj1Ezp.mjs} +13 -4
  107. package/system/dist/{device-provider.cap-BKUGJSo0.js → device-provider.cap-CNlYBQ5D.js} +1 -1
  108. package/system/dist/{device-provider.cap-DU6HMUXH.mjs → device-provider.cap-D8mJllVM.mjs} +1 -1
  109. package/system/dist/{device-row-store-O4mNbp5q.js → device-row-store-C0P2H18h.js} +2 -2
  110. package/system/dist/{device-row-store-C-_R-h1Z.mjs → device-row-store-CTocYKqC.mjs} +2 -2
  111. package/system/dist/{device-type-CbQsnFdC.js → device-type-Cnc0NiSX.js} +13 -0
  112. package/system/dist/{device-type-DgEvK3ch.mjs → device-type-TUGqGmaI.mjs} +13 -0
  113. package/system/dist/error.cap-BuKbL3Ac.js +125 -0
  114. package/system/dist/error.cap-CU1FB6uE.mjs +102 -0
  115. package/system/dist/file-host-worker.js +1 -1
  116. package/system/dist/file-host-worker.mjs +1 -1
  117. package/system/dist/{history-catalog-BwTeQ4Mr.mjs → history-catalog-A_dzXNpv.mjs} +98 -3
  118. package/system/dist/{history-catalog-BKRarIL_.js → history-catalog-CiTMP3-E.js} +98 -3
  119. package/system/dist/index.js +28 -6
  120. package/system/dist/index.mjs +28 -6
  121. package/system/dist/kernel/addon-version-policy.d.ts +10 -0
  122. package/system/dist/{legacy-integration-rows-door-B1nzxxr5.js → legacy-integration-rows-door-CdqYAj-o.js} +1 -1
  123. package/system/dist/{legacy-integration-rows-door-nTvo_6jQ.mjs → legacy-integration-rows-door-LSgpClpX.mjs} +1 -1
  124. package/system/dist/{low-power-sleep.cap-B6mz6ojP.js → low-power-sleep.cap-BJWyAuUQ.js} +1 -1
  125. package/system/dist/{low-power-sleep.cap-C3Vi8Vxj.mjs → low-power-sleep.cap-D9Orx3LS.mjs} +1 -1
  126. package/system/dist/migrations/hub/2026-11-22-device-transitions-commands-only.d.ts +10 -0
  127. package/system/dist/{network-access.cap-BEN_uRVb.js → network-access.cap-CTQ2WQoi.js} +38 -12
  128. package/system/dist/{network-access.cap-Dy8FNNVs.mjs → network-access.cap-Dx5K0I5i.mjs} +33 -13
  129. package/system/dist/{notification-rules.cap-Drwz-A4n.js → notification-rules.cap-BJKUjizS.js} +45 -9
  130. package/system/dist/{notification-rules.cap-0vVvsxQ1.mjs → notification-rules.cap-BUIuYPlQ.mjs} +45 -9
  131. package/system/dist/{notification-targets-DR-D-vIt.mjs → notification-targets-4bGYH5J7.mjs} +2 -2
  132. package/system/dist/{notification-targets-Cc_3OBH9.js → notification-targets-DMW7xgR2.js} +2 -2
  133. package/system/dist/{prefix-walk-CCO_VZVo.js → prefix-walk-BFnw8NBu.js} +5 -5
  134. package/system/dist/{prefix-walk-BhT0ZoKl.mjs → prefix-walk-Mtij0NNT.mjs} +2 -2
  135. package/system/dist/{ptz-autotrack.cap-DOz0xL0O.js → ptz-autotrack.cap-B9eyZU8w.js} +1 -1
  136. package/system/dist/{ptz-autotrack.cap-CDF6FeTK.mjs → ptz-autotrack.cap-Dw2k-po9.mjs} +1 -1
  137. package/system/dist/{recording-archive.cap-RHAN45fa.mjs → recording-archive.cap-CTlm86R8.mjs} +1 -1
  138. package/system/dist/{recording-archive.cap-BPJ7kvnd.js → recording-archive.cap-Wo-hEZhz.js} +1 -1
  139. package/system/dist/{rename-composition-block-DWUkrazx.mjs → rename-composition-block-Cdh-dRmY.mjs} +395 -20
  140. package/system/dist/{rename-composition-block-CH2vRIW7.js → rename-composition-block-D9Uc1AF7.js} +406 -31
  141. package/system/dist/{retention-CUOVI1p7.mjs → retention-CQs8QR1B.mjs} +33 -3
  142. package/system/dist/{device-transitions.cap-DCXP3zwY.mjs → retention-source.cap-550kkyp5.mjs} +98 -21
  143. package/system/dist/{device-transitions.cap-zOGvAIHz.js → retention-source.cap-C6Hy0hlM.js} +103 -20
  144. package/system/dist/{retention-BcOSL6b9.js → retention-xcjk_k1w.js} +33 -3
  145. package/system/dist/{snapshot.cap-Cis6JRwn.js → snapshot.cap-CHm29hBs.js} +1 -1
  146. package/system/dist/{snapshot.cap-BkfHpJVO.mjs → snapshot.cap-CO68YvJU.mjs} +1 -1
  147. package/system/dist/{stream-catalog.cap-D8Y-uXcy.js → stream-catalog.cap-CjEQFknc.js} +2 -2
  148. package/system/dist/{stream-catalog.cap-D1Hy19Yc.mjs → stream-catalog.cap-DVniDdRD.mjs} +2 -2
  149. package/system/dist/{user-management.cap-Ctd4c_im.mjs → user-management.cap-4IEUCSdL.mjs} +2 -2
  150. package/system/dist/{user-management.cap-DyVb68rY.js → user-management.cap-DV9Jfsj3.js} +2 -2
  151. package/system/dist/{wal-maintenance-CjpslZUL.mjs → wal-maintenance-Bey5ChBb.mjs} +0 -0
  152. package/system/dist/{wal-maintenance-DKTXQ7UF.js → wal-maintenance-BgYiAy5b.js} +0 -0
  153. package/system/package.json +4 -1
  154. package/system/dist/builtins/device-manager/transitions/transition-correlator.d.ts +0 -81
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Per-device raw windows live in the addon's standard per-device store (D865):
3
+ * `rawDays` and `rawDiscreteDays`, a positive number of days. Anything else stored
4
+ * under those keys (a cleared override is `null`) means the device follows the cluster.
5
+ */
6
+ import type { RawDeviceOverride } from "./retention.js";
7
+ interface DeviceStoreReader {
8
+ listDeviceStoreIds(): Promise<readonly number[]>;
9
+ readDeviceStoreBatch(deviceIds: readonly number[]): Promise<ReadonlyMap<number, Record<string, unknown>>>;
10
+ }
11
+ /** The keys a device may override; `updateDeviceSettings` refuses every other. */
12
+ export declare const RAW_OVERRIDE_KEYS: readonly string[];
13
+ export declare function parseRawOverride(record: Readonly<Record<string, unknown>>): RawDeviceOverride;
14
+ /** Every device with an override, one read for the ids and one batch for the values. Throws when the store cannot be asked. */
15
+ export declare function readRawOverrides(settings: DeviceStoreReader): Promise<ReadonlyMap<number, RawDeviceOverride>>;
16
+ export {};
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The retention knobs device-history owns, as the `retention-source` capability lists
3
+ * them (D1084). A read of the policy the addon already resolves — nothing is stored
4
+ * here. The two raw windows can be overridden per device (the addon's per-device store);
5
+ * the rest are cluster-wide.
6
+ */
7
+ import type { RetentionKnob } from "@camstack/types";
8
+ import { type RawDeviceOverride, type RetentionPolicy } from "./retention.js";
9
+ export declare const DEVICE_HISTORY_ADDON_ID = "device-history";
10
+ /**
11
+ * Without a device: every knob, a raw window listed with the cluster value it defaults to.
12
+ * With one: only the device-scoped knobs, each saying whether the device follows the cluster.
13
+ */
14
+ export declare function deviceHistoryKnobs(policy: RetentionPolicy, deviceId: number | undefined, override: RawDeviceOverride | undefined): readonly RetentionKnob[];
@@ -19,13 +19,16 @@
19
19
  * the device is perfectly alive. An OPTED-OUT device keeps its history until
20
20
  * retention ages it out: stopping capture is the switch; deleting history is not.
21
21
  */
22
- import type { IScopedLogger } from "@camstack/types";
22
+ import type { DeviceHistoryKind, IScopedLogger } from "@camstack/types";
23
23
  import type { DepartureTracker } from "./departure-tracker.js";
24
24
  import type { HistoryCounters } from "../status/counters.js";
25
25
  import type { HistoryStore, StoredTier } from "../store/history-store.js";
26
26
  import type { SeriesRegistry } from "../store/series-registry.js";
27
27
  export interface RetentionPolicy {
28
+ /** Raw points of a continuous series (`gauge`, `counter`). */
28
29
  readonly rawDays: number;
30
+ /** Raw points of a discrete series (`boolean`, `enum`): the change points the Interactions view reads. */
31
+ readonly rawDiscreteDays: number;
29
32
  readonly fiveMinuteDays: number;
30
33
  readonly hourDays: number;
31
34
  /** `null` (or 0) keeps the daily tier forever. */
@@ -34,6 +37,15 @@ export interface RetentionPolicy {
34
37
  readonly transitionDays: number;
35
38
  }
36
39
  export declare const DEFAULT_RETENTION: RetentionPolicy;
40
+ /** A device's own raw windows; a field left out inherits the cluster value. */
41
+ export interface RawDeviceOverride {
42
+ readonly rawDays?: number;
43
+ readonly rawDiscreteDays?: number;
44
+ }
45
+ /** The overrides by device id, read once per retention pass. */
46
+ export type DeviceOverrideReader = () => Promise<ReadonlyMap<number, RawDeviceOverride>>;
47
+ /** Days one series keeps its raw points: its device's override, else the cluster value for its kind. */
48
+ export declare function rawDaysFor(kind: DeviceHistoryKind | undefined, policy: RetentionPolicy, override: RawDeviceOverride | undefined): number;
37
49
  /** Rows of the transition ledger strictly older than this are deleted; the row AT it is kept. */
38
50
  export declare function transitionCutoff(policy: RetentionPolicy, now: number): number;
39
51
  /** What the retention pass needs of the transition ledger. */
@@ -57,11 +69,19 @@ export declare class RetentionJob {
57
69
  private readonly appliedUpTo;
58
70
  private running;
59
71
  private transitions;
72
+ private deviceOverrides;
60
73
  constructor(deps: RetentionDeps);
61
74
  /** The ledger opens after the history runtime does; the pass sweeps it from then on. */
62
75
  attachTransitions(sweeper: TransitionSweeper): void;
76
+ /** Per-device raw windows (the addon's per-device store); read once per pass. */
77
+ attachDeviceOverrides(reader: DeviceOverrideReader): void;
63
78
  run(policy: RetentionPolicy, now: number): Promise<void>;
64
79
  private doRun;
80
+ /**
81
+ * `null` when the read failed: a longer override must not be judged by the cluster
82
+ * window, so the raw tier waits for the next pass (D49) — it never deletes blind.
83
+ */
84
+ private readOverrides;
65
85
  /** The fifth step: the transition ledger, under its own failure so the tiers never wait on it. */
66
86
  private sweepTransitions;
67
87
  /** Drop the visit markers of a purged series. */
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The ONE burst rule of the device transitions read (D1084).
3
+ *
4
+ * A device reports one real change as several raw points: a cover goes `open`, `position 6`,
5
+ * `opening`, then `open` and `position 100`. The Interactions view shows it as one change per
6
+ * field (`state closed -> open`, `position 0 -> 100`), so the points of ONE capability are
7
+ * grouped into a burst and each field of the burst is written from its value before the first
8
+ * change to its last. A field that ended where it began shows nothing.
9
+ *
10
+ * A burst ends when the capability has been quiet for `SETTLE_QUIET_MS`, or `SETTLE_MAX_HOLD_MS`
11
+ * after it began (a flapping sensor). The row is stamped with the burst's last change. A burst
12
+ * that has not yet gone quiet is NOT returned: it is still being written by the device, and a
13
+ * page read now and again a moment later must agree.
14
+ *
15
+ * Pure. Nothing else in the repository implements this rule; the write-time correlator that
16
+ * held it before was removed with the confirmation machinery.
17
+ */
18
+ import type { TransitionValue } from "@camstack/types";
19
+ /** A capability's changes closer together than this are one burst. */
20
+ export declare const SETTLE_QUIET_MS = 5e3;
21
+ /** A burst never lasts longer than this, however busy the capability stays. */
22
+ export declare const SETTLE_MAX_HOLD_MS = 6e4;
23
+ /** One recorded value of an audited field, as device-history holds it. */
24
+ export interface FieldPoint {
25
+ readonly capName: string;
26
+ readonly field: string;
27
+ readonly at: number;
28
+ readonly value: TransitionValue;
29
+ }
30
+ /** One change of an audited field, after the burst rule. `from` is never unknown here. */
31
+ export interface FieldChange {
32
+ readonly capName: string;
33
+ readonly field: string;
34
+ readonly at: number;
35
+ readonly from: TransitionValue;
36
+ readonly to: TransitionValue;
37
+ }
38
+ export interface CoalesceInput {
39
+ /** Every point of the window, in any order. */
40
+ readonly points: readonly FieldPoint[];
41
+ /** The value each `capName|field` held before the window; absent = never seen. */
42
+ readonly before: ReadonlyMap<string, TransitionValue>;
43
+ /** The clock: a burst quiet for less than `SETTLE_QUIET_MS` is still open and not returned. */
44
+ readonly now: number;
45
+ }
46
+ export declare function fieldKey(capName: string, field: string): string;
47
+ /** Group the points of each capability into bursts and answer the net change of each field. */
48
+ export declare function coalesceChanges(input: CoalesceInput): readonly FieldChange[];
@@ -0,0 +1,49 @@
1
+ /**
2
+ * The device's own changes, read back from device-history (D1084). The audited fields are the
3
+ * ones a vocabulary action effect names (`auditedFields`); a field with a history block has a
4
+ * raw series, a field without one has none and no derived row: a documented blind spot.
5
+ *
6
+ * What this module knows of history is one port (`ChangeSeriesPort`), so the read is specified
7
+ * without a store. Boolean and enum series are change-only; a gauge is as dense as its capture
8
+ * interval, and the burst rule (`change-coalescing.ts`) nets it to one change per field.
9
+ */
10
+ import type { DeviceHistoryKind } from "@camstack/types";
11
+ import { type FieldChange } from "./change-coalescing.js";
12
+ /** One audited field of a device that has a raw series. */
13
+ export interface AuditedSeries {
14
+ readonly capName: string;
15
+ readonly field: string;
16
+ readonly kind: DeviceHistoryKind;
17
+ }
18
+ /** One raw point of a series: the stored ordinal or number, and its state name for an enum. */
19
+ export interface RawChangePoint {
20
+ readonly t: number;
21
+ readonly value: number | null;
22
+ readonly state: string | null;
23
+ }
24
+ export interface RawChangeRead {
25
+ /** The newest point before the window; `null` when the series had none. */
26
+ readonly before: RawChangePoint | null;
27
+ /** Oldest first. */
28
+ readonly points: readonly RawChangePoint[];
29
+ }
30
+ /** What the reader needs of device-history. */
31
+ export interface ChangeSeriesPort {
32
+ /** The audited fields of `deviceId` that have a series. */
33
+ auditedSeries(deviceId: number): readonly AuditedSeries[];
34
+ readRaw(deviceId: number, series: AuditedSeries, from: number, to: number): Promise<RawChangeRead>;
35
+ }
36
+ export interface DerivedWindow {
37
+ readonly from: number;
38
+ readonly to: number;
39
+ readonly capName?: string | undefined;
40
+ }
41
+ /** The most raw points read for one series; the newest are kept past it. */
42
+ export declare const DERIVED_POINTS_MAX = 1e4;
43
+ export declare class DerivedChanges {
44
+ private readonly port;
45
+ private readonly clock;
46
+ constructor(port: ChangeSeriesPort, clock: () => number);
47
+ /** The settled changes of the device's audited fields in `window`, newest first. */
48
+ read(deviceId: number, window: DerivedWindow): Promise<readonly FieldChange[]>;
49
+ }
@@ -0,0 +1,20 @@
1
+ /**
2
+ * The derived-changes reader's view of device-history (D1084): which audited fields of a device
3
+ * have a series, and their raw points. A field with no series (its cap has no `history` block)
4
+ * has no derived row.
5
+ */
6
+ import { type IScopedLogger } from "@camstack/types";
7
+ import type { HistoryQuery } from "../query/history-query.js";
8
+ import type { SeriesRegistry } from "../store/series-registry.js";
9
+ import { type AuditedSeries, type ChangeSeriesPort, type RawChangeRead } from "./derived-changes.js";
10
+ export interface HistoryChangePortDeps {
11
+ readonly registry: Pick<SeriesRegistry, "forSubject" | "metric">;
12
+ readonly query: Pick<HistoryQuery, "query">;
13
+ readonly logger: IScopedLogger;
14
+ }
15
+ export declare class HistoryChangePort implements ChangeSeriesPort {
16
+ private readonly deps;
17
+ constructor(deps: HistoryChangePortDeps);
18
+ auditedSeries(deviceId: number): readonly AuditedSeries[];
19
+ readRaw(deviceId: number, series: AuditedSeries, from: number, to: number): Promise<RawChangeRead>;
20
+ }
@@ -1,19 +1,23 @@
1
1
  /**
2
- * The transition ledger as the device-history addon sees it (D1022): the
3
- * declared kind, the kernel-only writer, the paged reads, the retention sweep
4
- * and the device-removal hook body (D865).
2
+ * The transition ledger as the device-history addon sees it (D1022, D1084): the
3
+ * declared kind of stored COMMAND rows, the kernel-only writer, the paged reads, the
4
+ * retention sweep and the device-removal hook body (D865). A device read merges the
5
+ * stored commands with the device's own changes derived from its raw history series.
5
6
  *
6
7
  * Reads go to the store: an answered empty page is "no transitions". The
7
8
  * ledger is not a second copy of any device fact - the hub mirror stays the
8
9
  * one authority, and nothing here is read back to decide a device's state.
9
10
  */
10
11
  import { type DeviceTransition, type IScopedLogger, type RecordsAccess, type TransitionActorKind, type TransitionOutcome, type TransitionRecordResult, type TransitionsStatus } from "@camstack/types";
12
+ import type { DerivedChanges } from "./derived-changes.js";
11
13
  /** The only caller `record` accepts: the hub kernel's device-manager states its own id. */
12
14
  export declare const KERNEL_CALLER = "device-manager";
13
15
  export interface TransitionsServiceDeps {
14
16
  readonly records: RecordsAccess;
15
17
  readonly logger: IScopedLogger;
16
18
  readonly clock: () => number;
19
+ /** The device's own changes, read from device-history. */
20
+ readonly derived: Pick<DerivedChanges, "read">;
17
21
  /** Gives the thread back between delete slices; a spec counts it. */
18
22
  readonly yieldNow?: () => Promise<void>;
19
23
  }
@@ -56,7 +60,18 @@ export declare class TransitionsService {
56
60
  * so the sender keeps the batch (D49).
57
61
  */
58
62
  record(callerAddonId: string | null, transitions: readonly DeviceTransition[]): Promise<TransitionRecordResult>;
63
+ /**
64
+ * One time-ordered page of a device's commands and its own changes, newest first. The cursor
65
+ * is the sort key of the last row returned (time, source, id), so a page boundary is the same
66
+ * whichever source the last row came from. `outcome` and every actor kind but `device` select
67
+ * commands; `actorKind: 'device'` selects the derived changes.
68
+ */
59
69
  list(input: ListTransitionsInput): Promise<TransitionPage>;
70
+ /** Stored commands, newest first, strictly after the cursor. */
71
+ private commandRows;
72
+ /** The device's derived changes, newest first, strictly after the cursor. */
73
+ private changeRows;
74
+ /** The fleet page: stored commands only. A device's own changes are derived per device. */
60
75
  listRecent(input: ListRecentInput): Promise<TransitionPage>;
61
76
  get(input: {
62
77
  readonly deviceId: number;
@@ -102,8 +102,8 @@ export declare class DeviceIdentityIndex implements DeviceRowObserver {
102
102
  * {@link candidates}, plus each device's attached identifiers paired with
103
103
  * another integration's device identifiers (`poe-power`).
104
104
  *
105
- * One link per port: when a port's attached keys reach several devices, or a
106
- * device is reached by several ports, every one of those attached pairs is
105
+ * A port reaching several devices (a PoE splitter) links every one of them. A
106
+ * device reached by several ports is ambiguous: each of those attached pairs is
107
107
  * graded a `proposal` at most — the operator picks.
108
108
  *
109
109
  * Freshness first: a pair whose shared keys the port only RETAINS (declared