@camstack/addon-post-analysis 1.2.309 → 1.2.310

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.
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- //#region ../types/dist/event-category-C5xZWqz6.mjs
2
+ //#region ../types/dist/event-category-BGmz_oxW.mjs
3
3
  var EventCategory = /* @__PURE__ */ function(EventCategory) {
4
4
  EventCategory["SystemBoot"] = "system.boot";
5
5
  EventCategory["SystemAddonsReady"] = "system.addons-ready";
@@ -532,6 +532,15 @@ var EventCategory = /* @__PURE__ */ function(EventCategory) {
532
532
  */
533
533
  EventCategory["PipelineAudioInferenceResult"] = "pipeline.audio-inference-result";
534
534
  EventCategory["DetectionPhaseTransition"] = "detection.phase-transition";
535
+ /**
536
+ * A camera provider's RAW onboard motion push (D673): the `MotionOnMotionChanged`
537
+ * data shape without `triggeredBy`, built by `providerMotionEvent`. Its one
538
+ * consumer is the orchestrator's camera-sensors bridge, which re-emits the
539
+ * camera's EFFECTIVE onboard motion as `MotionOnMotionChanged` (a pass-through
540
+ * for a camera with no attached sensor). Providers must not emit
541
+ * `MotionOnMotionChanged` themselves; `scripts/check-onboard-motion-emitters.ts`
542
+ * keeps it so (camera-grid is a named, deferred exception).
543
+ */
535
544
  EventCategory["ProviderMotion"] = "provider.motion";
536
545
  EventCategory["ProviderDetection"] = "provider.detection";
537
546
  EventCategory["EnrichmentEmbeddingStored"] = "enrichment.embedding.stored";
@@ -5378,7 +5387,7 @@ var ZodIssueCode = {
5378
5387
  var ZodFirstPartyTypeKind;
5379
5388
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5380
5389
  //#endregion
5381
- //#region ../types/dist/sleep-gU6hqv4_.mjs
5390
+ //#region ../types/dist/sleep-CDCONfkt.mjs
5382
5391
  /**
5383
5392
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5384
5393
  * window to float samples (D455).
@@ -7637,7 +7646,7 @@ function errMsg(err) {
7637
7646
  return String(err);
7638
7647
  }
7639
7648
  //#endregion
7640
- //#region ../types/dist/composition-Dq42XWp0.mjs
7649
+ //#region ../types/dist/composition-43aqsZQj.mjs
7641
7650
  /**
7642
7651
  * Deterministic SHA-256 hash of an arbitrary serialisable value. The
7643
7652
  * canonical form sorts object keys alphabetically at every depth so two
@@ -7725,13 +7734,12 @@ portable("linux64"), portable("linuxarm64"), portable("macarm64"), portable("mac
7725
7734
  * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
7726
7735
  * valutatore puro del suo FRONTE.
7727
7736
  *
7728
- * Viveva dentro il builtin virtual-doorbell
7729
- * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
7730
- * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
7731
- * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
7732
- * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
7733
- * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
7734
- * SPOSTA qui e il doorbell la ri-esporta.
7737
+ * UNA tabella per tutti quelli che chiedono "questo device è ALTO?": il
7738
+ * trigger `RecordingTriggers.sensorDeviceIds` del recorder, i marker dei
7739
+ * sensori della post-analysis, il bridge camera-sensors dell'orchestratore e
7740
+ * le sorgenti di un campanello composto (`doorbellFeatureSources`, D671).
7741
+ * Una seconda copia divergerebbe alla prima cap aggiunta, e il sintomo — "il
7742
+ * sensore fa suonare il campanello ma non registra" — è esattamente D62.
7735
7743
  *
7736
7744
  * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
7737
7745
  * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
@@ -7781,8 +7789,6 @@ var SOURCE_CAP_CHANGED_AT_FIELD = {
7781
7789
  vibration: "lastChangedAt",
7782
7790
  tamper: "lastChangedAt"
7783
7791
  };
7784
- /** Cap names whose presence in a device's bindings qualify it as a source. */
7785
- var SOURCE_CAPS = Object.keys(SOURCE_CAP_ACTIVE_FIELD);
7786
7792
  /** True when a cap is a recognised binary/switch source. */
7787
7793
  function isSourceCap(capName) {
7788
7794
  return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
@@ -9863,7 +9869,7 @@ var RecordingTriggersSchema = object({
9863
9869
  *
9864
9870
  * Cosa vuol dire "alto" dipende dal TIPO di device e non è deciso qui:
9865
9871
  * `SOURCE_CAP_ACTIVE_FIELD` (`catalogs/sensor-active-state.ts`) è LA tabella,
9866
- * la stessa che il virtual-doorbell usa dal 2026-08-05. Ed è il FRONTE, non
9872
+ * la stessa del campanello composto (D671). Ed è il FRONTE, non
9867
9873
  * il livello: un contatto trovato già aperto al riavvio del runner non fa
9868
9874
  * registrare.
9869
9875
  */
@@ -16423,109 +16429,10 @@ method(object({
16423
16429
  deviceIds: array(number()).readonly(),
16424
16430
  caps: array(string()).readonly().optional()
16425
16431
  }), record(string(), record(string(), unknown().nullable())));
16426
- /**
16427
- * Doorbell button cap. Two kinds of providers coexist behind this cap
16428
- * name (same pattern as `snapshot`):
16429
- *
16430
- * - **Native** providers: registered per-device by device-driver
16431
- * addons via `ctx.registerNativeCap` — either on a
16432
- * `DeviceType.Button` accessory with `role: DeviceRole.Doorbell`,
16433
- * or directly on the camera (Reolink registers at camera level).
16434
- * Emits an `onPressed` event every time the firmware pushes a
16435
- * ring; status tracks the last press and a pressCount since start
16436
- * (diagnostic).
16437
- *
16438
- * - **Wrapper** provider: the `virtual-doorbell` system builtin
16439
- * (`@camstack/system/builtins/doorbell`). Turns ANY binary-ish
16440
- * device (contact / switch / event-emitter …) into a doorbell for
16441
- * a camera. `defaultActive: false` — the operator explicitly binds
16442
- * it per camera in the device-bindings UI, then picks the source
16443
- * device + trigger in the per-device settings.
16444
- *
16445
- * The DeviceEventPropagator re-emits `onPressed` on the camera parent
16446
- * — subscribers listening at the camera level receive ring events
16447
- * with `via[]` populated. No code on the parent needed.
16448
- */
16449
- var DoorbellStatusSchema = object({
16450
- /** Ms epoch of the last press. null = never observed since this provider started. */
16451
- lastPressedAt: number().nullable(),
16452
- /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
16453
- pressCountSinceStart: number()
16454
- });
16455
- var DoorbellPressEventSchema = object({
16456
- deviceId: number(),
16457
- timestamp: number()
16458
- });
16459
- /**
16460
- * The `doorbell-source` extension slot's editable value (D648): the camera's
16461
- * virtual-doorbell trigger devices, exactly what the wrapper's
16462
- * `doorbellSources` persists (as `{ deviceId }` records).
16463
- */
16464
- var DoorbellSourceSlotValueSchema = object({ deviceIds: array(number().int().positive()) });
16465
- /**
16466
- * The `doorbell-source` slot — which devices ring this camera's VIRTUAL
16467
- * doorbell, owned by the `virtual-doorbell` wrapper over its
16468
- * `doorbellSources` store (D648). A source rings when one of its
16469
- * `SOURCE_CAPS` rises. Whether the wrapper is bound to the camera at all is a
16470
- * different authority (`deviceManager.setWrapperActive`, D62) — the slot
16471
- * reports it, it never writes it.
16472
- */
16473
- var DOORBELL_SOURCE_SLOT = {
16474
- id: "doorbell-source",
16475
- label: "Doorbell trigger devices",
16476
- description: "Any of these becoming active rings this camera's virtual doorbell: a binary sensor when it goes active, a switch when it turns on.",
16477
- shape: "association",
16478
- hostDeviceTypes: [DeviceType.Camera],
16479
- sourceCaps: SOURCE_CAPS,
16480
- cardinality: "many",
16481
- value: DoorbellSourceSlotValueSchema
16482
- };
16483
- var doorbellCapability = {
16484
- name: "doorbell",
16485
- scope: "device",
16486
- deviceNative: true,
16487
- mode: "singleton",
16488
- kind: "wrapper",
16489
- defaultActive: false,
16490
- deviceTypes: [DeviceType.Button, DeviceType.Camera],
16491
- extensionSlots: [DOORBELL_SOURCE_SLOT],
16492
- methods: {},
16493
- events: {
16494
- /**
16495
- * Fires once per physical press. Reolink delivers via Baichuan
16496
- * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
16497
- * release/duration — it's a pulse.
16498
- */
16499
- onPressed: {
16500
- data: DoorbellPressEventSchema,
16501
- fromState: {
16502
- field: "lastPressedAt",
16503
- on: "advance"
16504
- }
16505
- } },
16506
- status: {
16507
- schema: DoorbellStatusSchema,
16508
- kind: "push"
16509
- },
16510
- /**
16511
- * Runtime-state slice — last press timestamp + lifetime press count.
16512
- * Mirrored by the kernel and readable via
16513
- * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
16514
- * without subscribing.
16515
- */
16516
- runtimeState: DoorbellStatusSchema,
16517
- /**
16518
- * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
16519
- *
16520
- * See `RuntimeStateDurability`. Enforced by
16521
- * `scripts/check-runtime-state-durability.ts`.
16522
- */
16523
- durability: "restored"
16524
- };
16525
- var ExtensionSlotIdSchema = _enum(["doorbell-source", "linked-devices"]);
16526
- DeviceType.Camera, DeviceType.Camera;
16432
+ var ExtensionSlotIdSchema = _enum(["linked-devices"]);
16433
+ DeviceType.Camera;
16527
16434
  /** A slot's editable value, discriminated on `slot`. */
16528
- var ExtensionSlotValueSchema = discriminatedUnion("slot", [DoorbellSourceSlotValueSchema.extend({ slot: literal("doorbell-source") }), LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16435
+ var ExtensionSlotValueSchema = discriminatedUnion("slot", [LinkedDevicesSlotValueSchema.extend({ slot: literal("linked-devices") })]);
16529
16436
  DeviceType.Camera;
16530
16437
  var ExtensionSourceAvailabilitySchema = discriminatedUnion("state", [object({ state: literal("ok") }), object({
16531
16438
  state: literal("unreachable"),
@@ -16562,10 +16469,11 @@ var ExtensionSlotSourceSchema = object({
16562
16469
  });
16563
16470
  /**
16564
16471
  * A DIFFERENT authority that gates whether the slot's sources do anything —
16565
- * reported read-only, named, never written through this contract (D62). The
16566
- * virtual doorbell's sources ring only while the wrapper is bound to the
16567
- * camera, and that binding belongs to `deviceManager.setWrapperActive`.
16568
- * `unknown` means the gate could not be read; it is not "inactive" (D315).
16472
+ * reported read-only, named, never written through this contract (D62) — e.g.
16473
+ * a slot whose sources act only while a wrapper is bound to the host, a
16474
+ * binding that belongs to `deviceManager.setWrapperActive`. No slot reports
16475
+ * one today (`linked-devices` answers `null`). `unknown` means the gate could
16476
+ * not be read; it is not "inactive" (D315).
16569
16477
  */
16570
16478
  var ExtensionSlotActivationSchema = object({
16571
16479
  state: _enum([
@@ -16581,7 +16489,7 @@ var ExtensionSlotRowSchema = discriminatedUnion("state", [object({
16581
16489
  /** `<source>:<slotId>` — the routing key for `listCandidates` / `setSlot`. */
16582
16490
  slotRef: string(),
16583
16491
  slot: ExtensionSlotIdSchema,
16584
- /** Names the store written (D62), e.g. `virtual-doorbell:doorbellSources`. */
16492
+ /** Names the store written (D62), e.g. `device-manager:_linkedDeviceIds`. */
16585
16493
  authority: string(),
16586
16494
  activation: ExtensionSlotActivationSchema.nullable(),
16587
16495
  value: ExtensionSlotValueSchema,
@@ -22613,12 +22521,26 @@ var CameraSensorRefSchema = object({
22613
22521
  function cameraSensorRefKey(ref) {
22614
22522
  return `${ref.addonId}/${ref.stableId}`;
22615
22523
  }
22616
- /** CS-1 accepts exactly one mode; CS-2 (D673) widens it to confirm / replace. */
22617
- var CameraSensorsModeSchema = _enum(["in-addition"]);
22618
- var CameraSensorsConfigSchema = object({
22619
- mode: CameraSensorsModeSchema,
22620
- sensors: array(CameraSensorRefSchema).min(1).max(8)
22621
- }).superRefine((value, ctx) => {
22524
+ /**
22525
+ * A sensor's mode (D673). `in-addition`: its motion is the camera's motion too.
22526
+ * `replace`: its motion is the camera's, and while one is READY the camera's
22527
+ * own motion no longer counts on its own. `confirm`: while one is READY the
22528
+ * camera's own motion counts only while a confirm sensor is active — with or
22529
+ * without a replace sensor (spec C2, the controller's ruling on Q1).
22530
+ */
22531
+ var CameraSensorModeSchema = _enum([
22532
+ "in-addition",
22533
+ "confirm",
22534
+ "replace"
22535
+ ]);
22536
+ /** A stored sensor with no mode — every CS-1 row — is in addition. */
22537
+ var DEFAULT_CAMERA_SENSOR_MODE = "in-addition";
22538
+ /**
22539
+ * A camera's attached sensors. A CS-1 row carried an envelope
22540
+ * `mode: 'in-addition'`: `z.object` drops it on parse, and the PARSED value is
22541
+ * what the write stores (D672 rule 3), so it is never written again.
22542
+ */
22543
+ var CameraSensorsConfigSchema = object({ sensors: array(CameraSensorRefSchema.extend({ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE) })).min(1).max(8) }).superRefine((value, ctx) => {
22622
22544
  const seen = /* @__PURE__ */ new Set();
22623
22545
  value.sensors.forEach((ref, index) => {
22624
22546
  const key = cameraSensorRefKey(ref);
@@ -22630,39 +22552,41 @@ var CameraSensorsConfigSchema = object({
22630
22552
  seen.add(key);
22631
22553
  });
22632
22554
  });
22633
- var RefFields = {
22555
+ /** Every attachment names its mode; an older orchestrator that does not is in addition. */
22556
+ var AttachmentFields = {
22634
22557
  addonId: string(),
22635
- stableId: string()
22558
+ stableId: string(),
22559
+ mode: CameraSensorModeSchema.default(DEFAULT_CAMERA_SENSOR_MODE)
22636
22560
  };
22637
22561
  var CameraSensorAttachmentSchema = discriminatedUnion("state", [
22638
22562
  object({
22639
- ...RefFields,
22563
+ ...AttachmentFields,
22640
22564
  state: literal("ready"),
22641
22565
  deviceId: number(),
22642
22566
  name: string(),
22643
22567
  caps: array(string()).readonly()
22644
22568
  }),
22645
22569
  object({
22646
- ...RefFields,
22570
+ ...AttachmentFields,
22647
22571
  state: literal("offline"),
22648
22572
  deviceId: number(),
22649
22573
  name: string(),
22650
22574
  reason: _enum(["offline", "disabled"])
22651
22575
  }),
22652
22576
  object({
22653
- ...RefFields,
22577
+ ...AttachmentFields,
22654
22578
  state: literal("missing"),
22655
22579
  reason: string()
22656
22580
  }),
22657
22581
  object({
22658
- ...RefFields,
22582
+ ...AttachmentFields,
22659
22583
  state: literal("unsupported"),
22660
22584
  deviceId: number(),
22661
22585
  name: string(),
22662
22586
  reason: string()
22663
22587
  }),
22664
22588
  object({
22665
- ...RefFields,
22589
+ ...AttachmentFields,
22666
22590
  state: literal("unreadable"),
22667
22591
  reason: string()
22668
22592
  })
@@ -22675,17 +22599,49 @@ var CameraSensorAttachmentSchema = discriminatedUnion("state", [
22675
22599
  * say.
22676
22600
  */
22677
22601
  var CameraSensorsNotForwardedSchema = _enum(["onboard-not-listed", "no-active-detection"]);
22602
+ /** Whether the camera's OWN motion counts on its own (D673 C2), from its READY sensors (C3). */
22603
+ var CameraOwnMotionSchema = _enum([
22604
+ "always",
22605
+ "when-confirmed",
22606
+ "never"
22607
+ ]);
22608
+ /** Confirm / Replace cannot suppress this camera's motion: its provider still emits it directly (D673 C13). */
22609
+ var CameraSensorsNotEnforcedSchema = _enum(["provider-not-split"]);
22610
+ /**
22611
+ * The camera's OWN onboard motion (D696): the raw input the bridge combines,
22612
+ * never the effective value. The camera's `motion` slice is the effective one,
22613
+ * so a view of the camera's own row reads this.
22614
+ * - `atMs`: when the bridge received the camera's last own edge.
22615
+ * - `detected`: evaluated WHEN THE STATUS IS ASKED — the last edge said `true`
22616
+ * AND it is younger than the window the bridge counts the camera's own motion
22617
+ * for (`motionCooldownMs`, floored at two sustain ticks). A camera that never
22618
+ * sends a clear (heartbeats only) therefore reads `false` once no push came
22619
+ * within the window; a status read is a snapshot, so a live view re-asks.
22620
+ * Absent = this orchestrator has not received the camera's own motion since it
22621
+ * started (unknown, never "quiet"), or an orchestrator older than D696.
22622
+ */
22623
+ var CameraRawLevelSchema = object({
22624
+ detected: boolean(),
22625
+ atMs: number()
22626
+ });
22678
22627
  var CameraSensorsStatusSchema = discriminatedUnion("state", [
22679
- object({ state: literal("not-configured") }),
22628
+ object({
22629
+ state: literal("not-configured"),
22630
+ cameraLevel: CameraRawLevelSchema.optional()
22631
+ }),
22680
22632
  object({
22681
22633
  state: literal("unreadable"),
22682
- reason: string()
22634
+ reason: string(),
22635
+ cameraLevel: CameraRawLevelSchema.optional()
22683
22636
  }),
22684
22637
  object({
22685
22638
  state: literal("configured"),
22686
- mode: CameraSensorsModeSchema,
22639
+ cameraLevel: CameraRawLevelSchema.optional(),
22687
22640
  sensors: array(CameraSensorAttachmentSchema).readonly(),
22688
- notForwarded: CameraSensorsNotForwardedSchema.optional()
22641
+ /** Absent = an orchestrator older than CS-2: it does not say (D315). */
22642
+ cameraMotion: CameraOwnMotionSchema.optional(),
22643
+ notForwarded: CameraSensorsNotForwardedSchema.optional(),
22644
+ notEnforced: CameraSensorsNotEnforcedSchema.optional()
22689
22645
  })
22690
22646
  ]);
22691
22647
  Object.freeze({
@@ -26678,8 +26634,10 @@ var RunnerCameraConfigSchema = object({
26678
26634
  * - `analyzer`: ML/frame-diff motion detection (motion-wasm or other
26679
26635
  * analyzer providers) running on decoded frames in this runner.
26680
26636
  * - `onboard`: camera-native motion pushes (Reolink Baichuan, ONVIF
26681
- * analytics). The provider emits ProviderMotion
26682
- * events; the orchestrator forwards to `reportMotion`.
26637
+ * analytics). The provider emits its raw push as `ProviderMotion`
26638
+ * (D673); the orchestrator's camera-sensors bridge re-emits the camera's
26639
+ * effective motion as `MotionOnMotionChanged`, which is what reaches
26640
+ * `reportMotion`.
26683
26641
  */
26684
26642
  motionSources: MotionSourcesSchema.default(["analyzer"]),
26685
26643
  /**
@@ -26856,7 +26814,15 @@ var RunnerLocalLoadSchema = object({
26856
26814
  hasGpu: boolean(),
26857
26815
  inferenceBackend: string().optional(),
26858
26816
  cpuCores: number().optional()
26859
- })
26817
+ }),
26818
+ /**
26819
+ * Who writes a camera's `motion` runtime slice (D696). `'orchestrator'`: this
26820
+ * runner never writes it. ABSENT = a runner older than D696, which still
26821
+ * writes the slice from its phase machine; the orchestrator does not write
26822
+ * while any runner node is absent-or-unanswered, so one slice never has two
26823
+ * writers.
26824
+ */
26825
+ motionSliceWriter: literal("orchestrator").optional()
26860
26826
  });
26861
26827
  /**
26862
26828
  * Aggregate runtime metrics for the runner's whole local pool. Mirrors the
@@ -32461,6 +32427,70 @@ onStatusChanged: { data: object({
32461
32427
  * whether persisting is worth a SQLite commit. */
32462
32428
  volatileStateFields: ["lastChangedAt"]
32463
32429
  };
32430
+ var DoorbellStatusSchema = object({
32431
+ /** Ms epoch of the last press. null = never observed since this provider started. */
32432
+ lastPressedAt: number().nullable(),
32433
+ /** Counter since provider start. Resets on reboot. Useful for metrics/debug. */
32434
+ pressCountSinceStart: number()
32435
+ });
32436
+ var DoorbellPressEventSchema = object({
32437
+ deviceId: number(),
32438
+ timestamp: number()
32439
+ });
32440
+ /**
32441
+ * Doorbell button cap. Two kinds of provider serve it, and to every consumer
32442
+ * they are the same cap:
32443
+ *
32444
+ * - **Native** providers, registered per device by a driver addon through
32445
+ * `ctx.registerNativeCap` — a `DeviceType.Button` accessory with
32446
+ * `role: DeviceRole.Doorbell`, or the camera itself (Reolink registers at
32447
+ * camera level). They emit `onPressed` on every firmware ring.
32448
+ * - **A composed doorbell** (D670, D671): a camera's customization gives it
32449
+ * the cap, its `lastPressedAt` rising from the sources the operator
32450
+ * assigned in Customize → Doorbell, and the composer emits `onPressed`
32451
+ * from that field's advance (`fromState`).
32452
+ *
32453
+ * The DeviceEventPropagator re-emits `onPressed` on the camera parent.
32454
+ */
32455
+ var doorbellCapability = {
32456
+ name: "doorbell",
32457
+ scope: "device",
32458
+ deviceNative: true,
32459
+ mode: "singleton",
32460
+ deviceTypes: [DeviceType.Button, DeviceType.Camera],
32461
+ methods: {},
32462
+ events: {
32463
+ /**
32464
+ * Fires once per physical press. Reolink delivers via Baichuan
32465
+ * push (`ReolinkSimpleEvent.type === 'doorbell'`). There is no
32466
+ * release/duration — it's a pulse.
32467
+ */
32468
+ onPressed: {
32469
+ data: DoorbellPressEventSchema,
32470
+ fromState: {
32471
+ field: "lastPressedAt",
32472
+ on: "advance"
32473
+ }
32474
+ } },
32475
+ status: {
32476
+ schema: DoorbellStatusSchema,
32477
+ kind: "push"
32478
+ },
32479
+ /**
32480
+ * Runtime-state slice — last press timestamp + lifetime press count.
32481
+ * Mirrored by the kernel and readable via
32482
+ * `device.state.doorbell.value`. UIs can show "last ring 5m ago"
32483
+ * without subscribing.
32484
+ */
32485
+ runtimeState: DoorbellStatusSchema,
32486
+ /**
32487
+ * Runtime-state durability: **restored** — a monotonic accumulator: the slice IS the record. `lastPressedAt` is content here, not a clock, so it is deliberately NOT volatile.
32488
+ *
32489
+ * See `RuntimeStateDurability`. Enforced by
32490
+ * `scripts/check-runtime-state-durability.ts`.
32491
+ */
32492
+ durability: "restored"
32493
+ };
32464
32494
  /**
32465
32495
  * Enum-state sensor — a string value picked from a finite option set.
32466
32496
  * Drives HA `sensor` entries with `state_class: enum` (HVAC action
@@ -34675,11 +34705,11 @@ authKey: string().optional() }), object({
34675
34705
  /**
34676
34706
  * How long after a camera's last rising edge `pipeline-analytics` closes the
34677
34707
  * motion EPISODE row it kept open for it (D475) — "il delay della cap", in
34678
- * the operator's words. One authority for the whole system: every provider
34679
- * that seeds `autoClearAfterMs` on a `Camera` device writes this SAME
34680
- * constant while `detected: true` (never its own number — Hikvision used to
34681
- * seed its internal 3 s inactivity timer here, which is a different clock for
34682
- * a different purpose), and `MotionEpisodeTracker` imports it directly rather
34708
+ * the operator's words. One authority for the whole system: the writer of a
34709
+ * `Camera` device's slice (the orchestrator, D696) writes this SAME constant
34710
+ * in `autoClearAfterMs` while `detected: true` (never a camera's own clock —
34711
+ * Hikvision used to seed its internal 3 s inactivity timer here, a different
34712
+ * clock for a different purpose), and `MotionEpisodeTracker` imports it directly rather
34683
34713
  * than reading the live cap value on the hot path. A `Sensor` device (HA
34684
34714
  * binary sensor, Homematic) gets a genuine push both ways and has no episode
34685
34715
  * to close on a timer, so it writes `null`, never this constant.
@@ -34690,9 +34720,9 @@ var MotionStatusSchema = object({
34690
34720
  /** Ms epoch of the last detected-true observation. Null if never detected. */
34691
34721
  lastDetectedAt: number().nullable(),
34692
34722
  /**
34693
- * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device,
34694
- * `null` while false and on every `Sensor` device (D475) — see that
34695
- * constant's doc for the one-authority rule.
34723
+ * `MOTION_CLOSE_AFTER_MS` while `detected: true` on a `Camera` device (the
34724
+ * orchestrator writes it, D696), `null` while false and on every `Sensor`
34725
+ * device (D475) — see that constant's doc for the one-authority rule.
34696
34726
  *
34697
34727
  * ## Reading this field still arms nothing
34698
34728
  *
@@ -34710,34 +34740,31 @@ var MotionStatusSchema = object({
34710
34740
  * `addon-export-alexa/src/motion-clear-hold.ts` and
34711
34741
  * `addon-export-hap`'s `RESET_DEBOUNCE_MS` both do.
34712
34742
  *
34713
- * ## Who writes it
34714
- *
34715
- * - **Cameras** — the runner's phase machine, `active → watching` on
34716
- * `cooldown_expired`, which then writes this slice with
34717
- * `detected: false` (`handlePhaseChanged` in
34718
- * `pipeline-runner/index.ts`). It produces the FALLING edge, which
34719
- * matters most for the sources that only ever push a rising one:
34720
- * Reolink emits `MotionOnMotionChanged { detected: true }` and never
34721
- * a false.
34722
- * - **Sensors** (Home Assistant binary sensors, Homematic) — the
34723
- * provider pushes the false itself, from the upstream system's own
34724
- * state change. No phase machine is involved.
34725
- *
34726
- * ### The phase machine is CANONICAL, not sole — and that is a defect
34727
- *
34728
- * An earlier revision of this docblock (mine, 2026-09-12) claimed the
34729
- * phase machine is the sole writer for a camera. It is not.
34730
- * `hikvision-camera.ts:3464` and `amcrest-camera.ts:445` both call
34731
- * `setCapSlice(motionCapability, …)` on their own rising edge, and
34732
- * Hikvision's comment says why: it read THIS docblock, agreed the
34733
- * runner is canonical, and wrote anyway to avoid per-tick churn. So
34734
- * two authorities can disagree about one slice, which this repo
34735
- * forbids, and the doc said otherwise — which is worse than saying
34736
- * nothing, because it reads as verification.
34737
- *
34738
- * This predates D475 and is not fixed there: the fix touches every
34739
- * camera provider. Recorded in D475's Consequences. Do not restore the
34740
- * "sole writer" wording without also removing the other writers.
34743
+ * ## Who writes it (D696)
34744
+ *
34745
+ * - **Cameras** — the orchestrator, and nothing else. It writes the camera's
34746
+ * EFFECTIVE motion (`addon-pipeline-orchestrator`
34747
+ * `camera-sensors/motion-slice.ts`), alongside the effective
34748
+ * `MotionOnMotionChanged` it emits or receives: the camera-sensors bridge
34749
+ * for a split camera, an unsplit emitter's direct event, the analyzer and
34750
+ * device activity, as the camera's `motionSources` counts them. A source
34751
+ * that never sends a clear falls one window after its last `true`.
34752
+ * `lastDetectedAt` moves only on an effective rise. No camera provider
34753
+ * writes this slice (not even a boot seed), and neither does the runner's
34754
+ * phase machine: its phase is "a session is attached" for every on-motion
34755
+ * session, not motion, and it now has its own `DetectionPhaseTransition`.
34756
+ * A provider's `isDetected` answers from the hub's slice.
34757
+ * - **Sensors** (Home Assistant binary sensors, Homematic, Matter, Alexa
34758
+ * imports) — the provider pushes both edges itself, from the upstream
34759
+ * system's own state change. That is the sensor's own fact.
34760
+ *
34761
+ * `scripts/check-onboard-motion-emitters.ts` refuses any other writer of a
34762
+ * `motion` slice; each sensor writer is a named exemption.
34763
+ *
34764
+ * This replaces the D475 §4 rule ("the phase machine is the sole writer").
34765
+ * That rule was never true: Hikvision and Amcrest wrote the slice raw beside
34766
+ * it, every provider seeded it at boot, and every session left it
34767
+ * `detected: true` after its detach.
34741
34768
  */
34742
34769
  autoClearAfterMs: number().nullable()
34743
34770
  });
@@ -34809,11 +34836,12 @@ onMotionChanged: { data: MotionOnMotionChangedDataSchema } },
34809
34836
  */
34810
34837
  runtimeState: MotionStatusSchema,
34811
34838
  /**
34812
- * Runtime-state durability: **session** — every writer of this slice
34839
+ * Runtime-state durability: **session** — the writer of this slice
34813
34840
  * writes only on an EDGE, so a restored `detected: true` would stay
34814
34841
  * frozen until the next one instead of being corrected. The next edge
34815
- * re-publishes the real state. (On who the writers are, and why there
34816
- * is more than one, see `autoClearAfterMs` above.)
34842
+ * re-publishes the real state, and the orchestrator re-publishes every
34843
+ * camera when it starts writing (D696; on who writes it, see
34844
+ * `autoClearAfterMs` above).
34817
34845
  *
34818
34846
  * See `RuntimeStateDurability`. Enforced by
34819
34847
  * `scripts/check-runtime-state-durability.ts`.
@@ -37230,8 +37258,7 @@ var ptzAutotrackCapability = {
37230
37258
  deviceNative: true,
37231
37259
  mode: "singleton",
37232
37260
  /**
37233
- * Two kinds of provider behind one name, the same shape `snapshot` and
37234
- * `doorbell` use:
37261
+ * Two kinds of provider behind one name, the same shape `snapshot` uses:
37235
37262
  *
37236
37263
  * - **Native**: the camera's own firmware autotrack, registered per device by
37237
37264
  * the driver when the probe says it exists (Reolink: yes; Hikvision:
@@ -37239,7 +37266,7 @@ var ptzAutotrackCapability = {
37239
37266
  * - **Wrapper**: the emulated implementation (`@camstack/system`'s `autotrack` builtin),
37240
37267
  * which follows a subject with `ptz.move` pulses driven by the detection
37241
37268
  * pipeline. `defaultActive: false` — the operator binds it per camera in
37242
- * the bindings UI, exactly as `virtual-doorbell` is bound.
37269
+ * the bindings UI.
37243
37270
  *
37244
37271
  * The binding chooses WHICH implementation answers; `setEnabled` stays the
37245
37272
  * one switch for the function either way. A camera never has both driving its
@@ -55114,6 +55141,7 @@ function readTimelapseGeneratedAt(rule, deviceId) {
55114
55141
  if (map !== void 0) return map[String(deviceId)] ?? 0;
55115
55142
  return rule.lastGeneratedAt ?? 0;
55116
55143
  }
55144
+ MotionOnMotionChangedDataSchema.omit({ triggeredBy: true });
55117
55145
  object({
55118
55146
  /**
55119
55147
  * Fraction of the box's own size added on EACH side before cutting.