@camstack/addon-matter-broker 0.2.12 → 0.2.14

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 (3) hide show
  1. package/dist/addon.js +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -7231,8 +7231,31 @@ var AdoptionJobSchema = object({
7231
7231
  error: string$2().nullable()
7232
7232
  });
7233
7233
  /**
7234
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7235
- * pipeline functions an operator thinks in terms of.
7234
+ * Per-camera FUNCTION SWITCHES.
7235
+ *
7236
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7237
+ *
7238
+ * This file shipped as "the one coherent on/off surface over the pipeline
7239
+ * functions an operator thinks in terms of". The operator's verdict on
7240
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7241
+ * every function already had a settings page of its own, and a second place to
7242
+ * turn it off is a second place to look. Each switch is going back to its own
7243
+ * component's original options — detection to the detection-pipeline wrapper
7244
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7245
+ * (which was always first-class; the switch was a veneer over
7246
+ * `recording.setDeviceConfig`), notifications to a notification-center
7247
+ * per-device setting, the two camera planes to their own components.
7248
+ *
7249
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7250
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7251
+ * straight from the authorities with no group in the middle. That rule was
7252
+ * never about a control panel.
7253
+ *
7254
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7255
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7256
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7257
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7258
+ * stop; nothing new may be built on it.
7236
7259
  *
7237
7260
  * ## This file adds no state
7238
7261
  *
@@ -7583,7 +7606,15 @@ var RecordingConfigSchema = object({
7583
7606
  * Each completed/failed run also lands one durable ops-log row on its owning
7584
7607
  * addon surface.
7585
7608
  */
7609
+ /**
7610
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7611
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7612
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7613
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7614
+ * runs at all.
7615
+ */
7586
7616
  var RelocateJobStateSchema = _enum([
7617
+ "queued",
7587
7618
  "running",
7588
7619
  "done",
7589
7620
  "failed",
@@ -7618,6 +7649,15 @@ var RelocateFootageInputSchema = object({
7618
7649
  /** Limits relocation to the logical profile class. Omit only for the
7619
7650
  * pre-orchestration compatibility path. */
7620
7651
  footageClass: RelocateFootageClassSchema.optional(),
7652
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7653
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7654
+ * unit is a (camera, profile) pile, not a disk. */
7655
+ deviceId: number().int().optional(),
7656
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7657
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7658
+ * placement plan assigns those two independently, so a rebalance that could
7659
+ * only say "recordings" would move footage the plan never asked to move. */
7660
+ profiles: array(string$2()).optional(),
7621
7661
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7622
7662
  * never allowed to starve live writers. */
7623
7663
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7753,6 +7793,21 @@ var StorageLocationSchema = object({
7753
7793
  nodeId: string$2().optional(),
7754
7794
  isDefault: boolean().default(false),
7755
7795
  isSystem: boolean().default(false),
7796
+ /**
7797
+ * Operator opt-in: whether consumers that BALANCE across several locations
7798
+ * of a type may write here. Recordings reads it today; event media and
7799
+ * backups are the next consumers, which is why the flag lives on the
7800
+ * location rather than in any one addon's store — nothing has to be
7801
+ * extended to add the next consumer.
7802
+ *
7803
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7804
+ * flag existed reads back with no flag and keeps working exactly as before;
7805
+ * that is the whole compat story, and it is why no migration ships with it.
7806
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7807
+ * disk must not silently start writing to it); the default of a type is
7808
+ * always stamped `true`.
7809
+ */
7810
+ enabled: boolean().optional(),
7756
7811
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7757
7812
  * for node-local locations it can reach) — never persisted, absent when the
7758
7813
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12371,7 +12426,8 @@ method(object({
12371
12426
  }), EmbeddingResultSchema), method(object({ text: string$2() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12372
12427
  /**
12373
12428
  * filesystem-browse — per-node capability for browsing the node's local
12374
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12429
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12430
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12375
12431
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12376
12432
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12377
12433
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14212,6 +14268,13 @@ var MaskGridDimsSchema = object({
14212
14268
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14213
14269
  * this one field keeps the schema additive — a rule still declares exactly
14214
14270
  * one trigger.
14271
+ *
14272
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14273
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14274
+ * mirror.ts` fails the build on a member the app cannot render) and every
14275
+ * member costs a release train. A sustained-sound rule is therefore an
14276
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14277
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14215
14278
  */
14216
14279
  var NcDeliverySchema = _enum([
14217
14280
  "immediate",
@@ -14226,15 +14289,32 @@ var NcDeliverySchema = _enum([
14226
14289
  * depend on a provider's raw event name or payload shape.
14227
14290
  */
14228
14291
  var NcSystemEventKindSchema = _enum([
14229
- "camera-online",
14230
- "camera-offline",
14292
+ "device-online",
14293
+ "device-offline",
14294
+ "device-disabled",
14295
+ "device-enabled",
14231
14296
  "stream-online",
14232
14297
  "stream-offline",
14233
14298
  "node-online",
14234
14299
  "node-offline",
14235
14300
  "addon-update-available",
14236
- "server-update-available"
14301
+ "server-update-available",
14302
+ "alarm-triggered",
14303
+ "alarm-armed",
14304
+ "alarm-disarmed",
14305
+ "camera-online",
14306
+ "camera-offline",
14307
+ "camera-disabled",
14308
+ "camera-enabled"
14309
+ ]);
14310
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14311
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14312
+ "camera-online",
14313
+ "camera-offline",
14314
+ "camera-disabled",
14315
+ "camera-enabled"
14237
14316
  ]);
14317
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14238
14318
  /**
14239
14319
  * One coherent system-event condition. `kinds` is the required opt-in safety
14240
14320
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14243,6 +14323,18 @@ var NcSystemEventKindSchema = _enum([
14243
14323
  var NcSystemEventConditionSchema = object({
14244
14324
  kinds: array(NcSystemEventKindSchema).min(1),
14245
14325
  deviceIds: array(number().int()).min(1).optional(),
14326
+ /**
14327
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14328
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14329
+ * is what a liveness rule means when nobody said otherwise.
14330
+ *
14331
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14332
+ * one reason: the intake cannot know which devices this household cares
14333
+ * about, and a producer-side filter is one no operator can change. Fails
14334
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14335
+ * does not carry) matches no `deviceTypes` list.
14336
+ */
14337
+ deviceTypes: array(string$2().min(1)).min(1).optional(),
14246
14338
  nodeIds: array(string$2().min(1)).min(1).optional(),
14247
14339
  packageNames: array(string$2().min(1)).min(1).optional()
14248
14340
  });
@@ -14293,6 +14385,47 @@ var NcOccupancyConditionSchema = object({
14293
14385
  sustainSeconds: number().int().min(0).max(3600).default(15)
14294
14386
  });
14295
14387
  /**
14388
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14389
+ *
14390
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14391
+ * reference notifier uses, so an operator moving between them re-uses what
14392
+ * they already know): a rule matches when, over a sampling window of
14393
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14394
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14395
+ *
14396
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14397
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14398
+ * - `labels` — the classifier put at least one of these labels on it.
14399
+ *
14400
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14401
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14402
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14403
+ * is given** — a window in which every sample is trivially a hit would fire on
14404
+ * silence, so the engine refuses such a condition rather than notifying on
14405
+ * nothing (the schema cannot express "at least one of" without becoming a
14406
+ * ZodEffects the cap path would have to special-case).
14407
+ *
14408
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14409
+ * must be FULL before it can match — a window that has been open for two
14410
+ * seconds of its ten is 100% of nothing, and firing on it would make
14411
+ * `samplingSeconds` decorative.
14412
+ *
14413
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14414
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14415
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14416
+ * an operator who typed `dog` mean the same thing.
14417
+ */
14418
+ var NcAudioConditionSchema = object({
14419
+ /** Audio macro labels; absent = any sound (level-only rule). */
14420
+ labels: array(string$2().min(1)).min(1).optional(),
14421
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14422
+ dbThreshold: number().min(-96).max(0).optional(),
14423
+ /** Percentage of the window's samples that must be hits (1–100). */
14424
+ hitPercent: number().int().min(1).max(100).default(60),
14425
+ /** Length of the sampling window in seconds. */
14426
+ samplingSeconds: number().int().min(1).max(300).default(10)
14427
+ });
14428
+ /**
14296
14429
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14297
14430
  *
14298
14431
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14565,7 +14698,33 @@ var NcConditionsSchema = object({
14565
14698
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14566
14699
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14567
14700
  */
14568
- occupancy: NcOccupancyConditionSchema.optional()
14701
+ occupancy: NcOccupancyConditionSchema.optional(),
14702
+ /**
14703
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14704
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14705
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14706
+ * a window that is not full yet, neither filter given). See
14707
+ * {@link NcAudioCondition}.
14708
+ *
14709
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14710
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14711
+ * a detection, a track or a device event (the same fail-closed pairing
14712
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14713
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14714
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14715
+ * classified sample) stays exactly as it was for rules that already use it.
14716
+ *
14717
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14718
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14719
+ * (`camstack/src/data/notification-center.ts`, guarded by
14720
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14721
+ * condition fields it does not know when a rule is saved from the phone.
14722
+ * Publishing an editor for a condition the app cannot round-trip is how an
14723
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14724
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14725
+ * does an audio rule become authorable.
14726
+ */
14727
+ audio: NcAudioConditionSchema.optional()
14569
14728
  });
14570
14729
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14571
14730
  var NcRuleTargetSchema = object({
@@ -14679,6 +14838,73 @@ var NcThrottleSchema = object({
14679
14838
  */
14680
14839
  granularity: NcThrottleGranularitySchema.optional()
14681
14840
  });
14841
+ /**
14842
+ * How long the confirm gate may hold ONE notification, and how big the picture
14843
+ * it judges may be.
14844
+ *
14845
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14846
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14847
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14848
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14849
+ * tokens for pixels the model pools away.
14850
+ */
14851
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14852
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14853
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14854
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14855
+ var NcConfirmExpectSchema = object({
14856
+ op: _enum([
14857
+ ">=",
14858
+ ">",
14859
+ "<=",
14860
+ "<",
14861
+ "=="
14862
+ ]),
14863
+ count: number().int().min(0).max(1e3)
14864
+ });
14865
+ /**
14866
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14867
+ * to ship and says whether it agrees with the rule.
14868
+ *
14869
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14870
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14871
+ * on the operator's phone is not a verdict about this notification.
14872
+ *
14873
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14874
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14875
+ * the default and every fail-open is COUNTED, because a gate that always fails
14876
+ * open looks in the log exactly like a gate that works.
14877
+ *
14878
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14879
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14880
+ * production failures in one day), so the gate reads absent as the constant
14881
+ * above rather than trusting a parse it may never have seen.
14882
+ */
14883
+ var NcConfirmSchema = object({
14884
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14885
+ * same thing, and both mean "deliver exactly as before". */
14886
+ enabled: boolean().default(false),
14887
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14888
+ profileId: string$2().optional(),
14889
+ /**
14890
+ * The operator's question, in his own words. Absent = a question derived
14891
+ * from the rule (its class and its expectation).
14892
+ *
14893
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14894
+ * banners, signage and plates as instructions if you let them reach the
14895
+ * prompt — proven live — so the authoritative contract stays in the system
14896
+ * turn and only rule-authored words land here.
14897
+ */
14898
+ prompt: string$2().max(1e3).optional(),
14899
+ /** Fire only when the model's count satisfies this. Absent = the model's
14900
+ * own boolean verdict decides. */
14901
+ expect: NcConfirmExpectSchema.optional(),
14902
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14903
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14904
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14905
+ /** Longest edge the judged image is downscaled to before it is sent. */
14906
+ maxImagePx: number().int().min(64).max(2048).default(448)
14907
+ });
14682
14908
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14683
14909
  var NcRuleInputSchema = object({
14684
14910
  name: string$2().min(1).max(200),
@@ -14739,7 +14965,13 @@ var NcRuleInputSchema = object({
14739
14965
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14740
14966
  * shape as every other actuation.
14741
14967
  */
14742
- actions: NcRuleActionsSchema.optional()
14968
+ actions: NcRuleActionsSchema.optional(),
14969
+ /**
14970
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14971
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14972
+ * did, and absent is the only way to say that without a migration.
14973
+ */
14974
+ confirm: NcConfirmSchema.optional()
14743
14975
  });
14744
14976
  /**
14745
14977
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14750,7 +14982,37 @@ var NcRuleInputSchema = object({
14750
14982
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14751
14983
  * `updateRule` patch.
14752
14984
  */
14753
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string$2()).optional() });
14985
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14986
+ disabledTargetIds: array(string$2()).optional(),
14987
+ /**
14988
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14989
+ *
14990
+ * It makes the key optional to SUPPLY; the parse still materialises the
14991
+ * default when the key is absent. And `NcRuleStore.update` merges with
14992
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14993
+ * one — which made every partial edit destructive:
14994
+ *
14995
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14996
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14997
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14998
+ *
14999
+ * A rule scoped to one camera and one zone silently became a rule that
15000
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15001
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15002
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15003
+ * within a minute of a two-field patch.
15004
+ *
15005
+ * So every defaulted field is re-declared here WITHOUT its default. The
15006
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15007
+ * conditions remains a real instruction ("clear them") — and only the
15008
+ * absent key is now genuinely absent.
15009
+ */
15010
+ enabled: boolean().optional(),
15011
+ conditions: NcConditionsSchema.optional(),
15012
+ media: NcMediaPolicySchema.optional(),
15013
+ throttle: NcThrottleSchema.optional(),
15014
+ priority: number().int().min(1).max(5).optional()
15015
+ });
14754
15016
  /** A persisted rule. */
14755
15017
  var NcRuleSchema = NcRuleInputSchema.extend({
14756
15018
  id: string$2(),
@@ -15051,6 +15313,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15051
15313
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15052
15314
  * copy would lie the first time a rule is disabled.
15053
15315
  */
15316
+ /**
15317
+ * Why a device a mode NAMES is nonetheless not armed by it.
15318
+ *
15319
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15320
+ * per-camera notification switch the Notification Center already owns,
15321
+ * `detection-off` is the device's own detection binding being inactive, and
15322
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15323
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15324
+ * with the switches the operator actually used.
15325
+ */
15326
+ var NcAlarmSkipReasonSchema = _enum([
15327
+ "muted",
15328
+ "detection-off",
15329
+ "offline"
15330
+ ]);
15331
+ var NcAlarmSkippedDeviceSchema = object({
15332
+ deviceId: number().int(),
15333
+ reason: NcAlarmSkipReasonSchema
15334
+ });
15054
15335
  var NcAlarmModeCoverageSchema = object({
15055
15336
  mode: AlarmArmModeSchema,
15056
15337
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15058,7 +15339,18 @@ var NcAlarmModeCoverageSchema = object({
15058
15339
  /** At least one covering rule has no device scope, so the mode covers all. */
15059
15340
  allDevices: boolean(),
15060
15341
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15061
- deviceIds: array(number().int())
15342
+ deviceIds: array(number().int()),
15343
+ /**
15344
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15345
+ * excludes it.
15346
+ *
15347
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15348
+ * twelve makes it false in exactly the way nobody notices until an incident.
15349
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15350
+ * still parses as "nothing known to be skipped" rather than failing the whole
15351
+ * alarm tab.
15352
+ */
15353
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15062
15354
  });
15063
15355
  var NcAlarmConfigSchema = object({
15064
15356
  /**
@@ -17890,9 +18182,16 @@ var CameraStatusSchema = object({
17890
18182
  audio: CameraAudioStatusSchema.nullable(),
17891
18183
  recording: CameraRecordingStatusSchema.nullable(),
17892
18184
  /**
17893
- * Per-camera function switches an OPERATOR has turned off
18185
+ * Per-camera functions an OPERATOR has turned off
17894
18186
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17895
18187
  *
18188
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18189
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18190
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18191
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18192
+ * The badge outlives the control panel: the panel was a convenience, this is
18193
+ * the difference between a camera being off and a camera being dead.
18194
+ *
17896
18195
  * This is the difference between DISABLED and BROKEN. A camera whose
17897
18196
  * `detection` block reports zero fps and whose `switchedOff` contains
17898
18197
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24651,7 +24950,19 @@ var RecordingManifestSchema = object({
24651
24950
  * profiles/subtrees/locations on this node). */
24652
24951
  var RecordingDeviceUsageSchema = object({
24653
24952
  deviceId: number(),
24654
- usedBytes: number()
24953
+ usedBytes: number(),
24954
+ /**
24955
+ * Start of this camera's OLDEST indexed segment, across every profile and
24956
+ * location — the "Oldest footage" column in Recordings → Storage, and the
24957
+ * only honest answer to "is retention actually holding?" per camera.
24958
+ *
24959
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
24960
+ * predates this field omits it entirely, and a hub whose types carry the
24961
+ * field must keep validating that older provider's payload: the framework
24962
+ * (types) and the addon ship on different trains, and the addon is usually
24963
+ * the later of the two.
24964
+ */
24965
+ oldestMs: number().nullable().optional()
24655
24966
  });
24656
24967
  /** Recording storage usage + capacity for one storage location. */
24657
24968
  var RecordingLocationUsageSchema = object({
@@ -24679,6 +24990,57 @@ var RecordingStorageUsageSchema = object({
24679
24990
  locations: array(RecordingLocationUsageSchema)
24680
24991
  });
24681
24992
  /**
24993
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
24994
+ *
24995
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
24996
+ * is the operator asking for the EXISTING archive to be brought into line with
24997
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
24998
+ * location, run FIFO behind the single-flight mover.
24999
+ *
25000
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25001
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25002
+ * (empty on the plan).
25003
+ */
25004
+ var RecordingRebalanceMoveSchema = object({
25005
+ deviceId: number(),
25006
+ profile: string$2(),
25007
+ fromLocationId: string$2(),
25008
+ toLocationId: string$2(),
25009
+ bytes: number(),
25010
+ files: number().int()
25011
+ });
25012
+ /** Why a pile that is out of place is staying there. Every refusal is
25013
+ * reported: a rebalance that silently drops a camera reads exactly like one
25014
+ * that had nothing to do. */
25015
+ var RecordingRebalanceSkipReasonSchema = _enum([
25016
+ "unassigned",
25017
+ "target-not-writable",
25018
+ "below-threshold",
25019
+ "no-headroom"
25020
+ ]);
25021
+ var RecordingRebalanceSkipSchema = object({
25022
+ deviceId: number(),
25023
+ profile: string$2(),
25024
+ fromLocationId: string$2(),
25025
+ /** The location the plan wants; null when the camera has no assignment. */
25026
+ toLocationId: string$2().nullable(),
25027
+ bytes: number(),
25028
+ reason: RecordingRebalanceSkipReasonSchema
25029
+ });
25030
+ var RecordingRebalancePlanSchema = object({
25031
+ moves: array(RecordingRebalanceMoveSchema),
25032
+ skipped: array(RecordingRebalanceSkipSchema),
25033
+ bytesToMove: number(),
25034
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25035
+ jobIds: array(string$2())
25036
+ });
25037
+ var RecordingRebalanceInputSchema = object({
25038
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25039
+ throttleMbps: number().min(1).max(1e3).optional(),
25040
+ /** Ignore piles smaller than this (default 1 GB). */
25041
+ minMoveGb: number().min(0).optional()
25042
+ });
25043
+ /**
24682
25044
  * Result of locating footage at a wall-clock instant for one device/profile.
24683
25045
  * `segment` carries the covering segment's window; `gap` reports the forward
24684
25046
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24841,9 +25203,24 @@ method(object({
24841
25203
  }), method(object({ jobId: string$2() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
24842
25204
  kind: "mutation",
24843
25205
  auth: "admin"
25206
+ }), method(RelocateFootageInputSchema, object({ jobId: string$2() }), {
25207
+ kind: "mutation",
25208
+ auth: "admin"
25209
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25210
+ kind: "query",
25211
+ auth: "admin"
25212
+ }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
25213
+ kind: "mutation",
25214
+ auth: "admin"
25215
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25216
+ kind: "query",
25217
+ auth: "admin"
25218
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25219
+ kind: "mutation",
25220
+ auth: "admin"
24844
25221
  });
24845
25222
  /**
24846
- * `recordingExport` cap — render a footage time range into a single downloadable
25223
+ * `recording-export` cap — render a footage time range into a single downloadable
24847
25224
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24848
25225
  * bounded lifetime with a durable history, auto-expiry, and optional
24849
25226
  * delete-after-download.
@@ -24858,10 +25235,53 @@ method(object({
24858
25235
  */
24859
25236
  /** Playback-speed multiplier for the render (1 = realtime). */
24860
25237
  var ExportSpeedSchema = number().min(.25).max(32);
25238
+ /**
25239
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25240
+ *
25241
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25242
+ * derives these bounds from things that happened at a TIME (a track's
25243
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25244
+ * every segment present for the range, with each recording GAP removed. The
25245
+ * two agree only on a window that recorded without one interruption, and only
25246
+ * the render side knows the segments, so the translation lives there
25247
+ * (`export-dense-map.ts`, addon-pipeline).
25248
+ *
25249
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25250
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25251
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25252
+ * the video was a uniform timelapse, and the log line reported the five ranges
25253
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25254
+ *
25255
+ * Relative and not absolute epoch, because an absolute epoch would make every
25256
+ * call site responsible for the same subtraction.
25257
+ */
25258
+ var ExportDenseRangeSchema = object({
25259
+ fromSec: number().nonnegative(),
25260
+ toSec: number().nonnegative()
25261
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25262
+ /**
25263
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25264
+ * listed ranges and at the base `everyMs` everywhere else.
25265
+ *
25266
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25267
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25268
+ */
25269
+ var ExportDenseSchema = object({
25270
+ everyMs: number().int().positive(),
25271
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25272
+ });
24861
25273
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24862
25274
  var ExportTimelapseSchema = object({
24863
25275
  everyMs: number().int().positive(),
24864
- outputFps: number().int().min(1).max(60).optional()
25276
+ outputFps: number().int().min(1).max(60).optional(),
25277
+ /** Optional second, FASTER rate over the intervals that matter. */
25278
+ dense: ExportDenseSchema.optional()
25279
+ }).superRefine((v, ctx) => {
25280
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25281
+ code: ZodIssueCode.custom,
25282
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25283
+ path: ["dense", "everyMs"]
25284
+ });
24865
25285
  });
24866
25286
  /**
24867
25287
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24919,6 +25339,19 @@ var ExportDownloadSchema = object({
24919
25339
  url: string$2(),
24920
25340
  endpoints: array(string$2())
24921
25341
  });
25342
+ /**
25343
+ * A finished export's bytes, inline.
25344
+ *
25345
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25346
+ * against, so nobody has to infer it from the base64 length.
25347
+ */
25348
+ var ExportBytesSchema = object({
25349
+ base64: string$2(),
25350
+ contentType: string$2(),
25351
+ /** Suggested filename, extension included. */
25352
+ name: string$2(),
25353
+ bytes: number().int().nonnegative()
25354
+ });
24922
25355
  method(object({
24923
25356
  deviceId: number(),
24924
25357
  profile: string$2(),
@@ -24943,6 +25376,9 @@ method(object({
24943
25376
  }), method(object({ exportId: string$2() }), ExportDownloadSchema, {
24944
25377
  kind: "query",
24945
25378
  auth: "protected"
25379
+ }), method(object({ exportId: string$2() }), ExportBytesSchema, {
25380
+ kind: "query",
25381
+ auth: "protected"
24946
25382
  });
24947
25383
  /**
24948
25384
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31620,6 +32056,12 @@ Object.freeze({
31620
32056
  addonId: null,
31621
32057
  access: "create"
31622
32058
  },
32059
+ "recording.cancelRelocateJob": {
32060
+ capName: "recording",
32061
+ capScope: "system",
32062
+ addonId: null,
32063
+ access: "create"
32064
+ },
31623
32065
  "recording.cancelStorageMigrationMove": {
31624
32066
  capName: "recording",
31625
32067
  capScope: "system",
@@ -31674,6 +32116,12 @@ Object.freeze({
31674
32116
  addonId: null,
31675
32117
  access: "view"
31676
32118
  },
32119
+ "recording.listRelocateJobs": {
32120
+ capName: "recording",
32121
+ capScope: "system",
32122
+ addonId: null,
32123
+ access: "view"
32124
+ },
31677
32125
  "recording.locateSegment": {
31678
32126
  capName: "recording",
31679
32127
  capScope: "system",
@@ -31686,6 +32134,12 @@ Object.freeze({
31686
32134
  addonId: null,
31687
32135
  access: "create"
31688
32136
  },
32137
+ "recording.planStorageRebalance": {
32138
+ capName: "recording",
32139
+ capScope: "system",
32140
+ addonId: null,
32141
+ access: "view"
32142
+ },
31689
32143
  "recording.pruneFootage": {
31690
32144
  capName: "recording",
31691
32145
  capScope: "system",
@@ -31710,6 +32164,12 @@ Object.freeze({
31710
32164
  addonId: null,
31711
32165
  access: "create"
31712
32166
  },
32167
+ "recording.relocateFootage": {
32168
+ capName: "recording",
32169
+ capScope: "system",
32170
+ addonId: null,
32171
+ access: "create"
32172
+ },
31713
32173
  "recording.renderClip": {
31714
32174
  capName: "recording",
31715
32175
  capScope: "system",
@@ -31746,38 +32206,50 @@ Object.freeze({
31746
32206
  addonId: null,
31747
32207
  access: "create"
31748
32208
  },
32209
+ "recording.startStorageRebalance": {
32210
+ capName: "recording",
32211
+ capScope: "system",
32212
+ addonId: null,
32213
+ access: "create"
32214
+ },
31749
32215
  "recordingExport.cancelExport": {
31750
- capName: "recordingExport",
32216
+ capName: "recording-export",
31751
32217
  capScope: "system",
31752
32218
  addonId: null,
31753
32219
  access: "create"
31754
32220
  },
31755
32221
  "recordingExport.createExport": {
31756
- capName: "recordingExport",
32222
+ capName: "recording-export",
31757
32223
  capScope: "system",
31758
32224
  addonId: null,
31759
32225
  access: "create"
31760
32226
  },
31761
32227
  "recordingExport.deleteExport": {
31762
- capName: "recordingExport",
32228
+ capName: "recording-export",
31763
32229
  capScope: "system",
31764
32230
  addonId: null,
31765
32231
  access: "delete"
31766
32232
  },
31767
32233
  "recordingExport.getDownloadUrl": {
31768
- capName: "recordingExport",
32234
+ capName: "recording-export",
31769
32235
  capScope: "system",
31770
32236
  addonId: null,
31771
32237
  access: "view"
31772
32238
  },
31773
32239
  "recordingExport.getExport": {
31774
- capName: "recordingExport",
32240
+ capName: "recording-export",
31775
32241
  capScope: "system",
31776
32242
  addonId: null,
31777
32243
  access: "view"
31778
32244
  },
31779
32245
  "recordingExport.listExports": {
31780
- capName: "recordingExport",
32246
+ capName: "recording-export",
32247
+ capScope: "system",
32248
+ addonId: null,
32249
+ access: "view"
32250
+ },
32251
+ "recordingExport.readExportBytes": {
32252
+ capName: "recording-export",
31781
32253
  capScope: "system",
31782
32254
  addonId: null,
31783
32255
  access: "view"
@@ -33154,6 +33626,104 @@ var FramerateField = number().int().min(1).max(60);
33154
33626
  var TargetsField = array(NcRuleTargetSchema).min(1);
33155
33627
  var PriorityField = number().int().min(1).max(5);
33156
33628
  /**
33629
+ * Explicit override of the DENSE sampling cadence, seconds.
33630
+ *
33631
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33632
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33633
+ * made that same base 3 s and rendered a person pass as two frames.)
33634
+ *
33635
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33636
+ * `denseCadenceSec` and played at `framerate` occupies
33637
+ *
33638
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33639
+ *
33640
+ * so a 7 s pass at 1 s / 12 fps is 0.58 s of video, and at 0.5 s it is 1.17 s.
33641
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33642
+ * and therefore the length of a quiet night, does not move.
33643
+ *
33644
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33645
+ * the recording has them returns the same frames, requested twice. Must be
33646
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33647
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33648
+ * rather than letting the export cap reject the render hours after the window.
33649
+ */
33650
+ var DenseCadenceSecField = number().min(.1).max(3600);
33651
+ /**
33652
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33653
+ *
33654
+ * The operator-facing form of the arithmetic above: instead of solving for a
33655
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33656
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33657
+ * that range every ~583 ms.
33658
+ *
33659
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33660
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33661
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33662
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33663
+ * schema change and are the tracked follow-up.
33664
+ *
33665
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33666
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33667
+ * by real footage, never met by duplicating frames into motion that never
33668
+ * happened.
33669
+ */
33670
+ var MinDwellSecField = number().min(0).max(60);
33671
+ /**
33672
+ * Caption burned into the notification's preview frame.
33673
+ *
33674
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33675
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33676
+ * templating dialect for one field would be a second thing to explain.
33677
+ *
33678
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33679
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33680
+ * the reason this is not `.min(1)`.
33681
+ */
33682
+ var PreviewTextField = string$2().max(200);
33683
+ /**
33684
+ * Whether the notification's preview is a STILL or a short animation.
33685
+ *
33686
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33687
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33688
+ * night reads better as three seconds of motion than as one frame of it. Both
33689
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33690
+ * simply applies it to a dozen frames sampled across the render and assembles
33691
+ * them.
33692
+ *
33693
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33694
+ * seeks and a palette pass, and no rule that never asked for one should start
33695
+ * paying that on the deploy that shipped it.
33696
+ *
33697
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33698
+ */
33699
+ var PreviewModeField = _enum(["image", "gif"]);
33700
+ /**
33701
+ * Which detection classes the notification reports counts for.
33702
+ *
33703
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33704
+ * plan — no second query — aggregated per class. Absent or empty means "every
33705
+ * class the window actually contained", which is what an operator who never
33706
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33707
+ * counts cars all night).
33708
+ *
33709
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33710
+ * …). An unknown name simply never matches and reports nothing — it is not an
33711
+ * error, because a rule may legitimately name a class this camera's model does
33712
+ * not emit.
33713
+ *
33714
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33715
+ * - `{{detections}}` — total over the reported classes
33716
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33717
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33718
+ * one per class, `count_` + the class name
33719
+ *
33720
+ * With NO custom body template the summary is appended to the derived body, and
33721
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33722
+ * reads. With a custom template the operator owns every word — nothing is
33723
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33724
+ */
33725
+ var ReportClassesField = array(string$2().min(1).max(40)).max(20);
33726
+ /**
33157
33727
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33158
33728
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33159
33729
  * here (see the ownership note above).
@@ -33173,9 +33743,30 @@ var TimelapseRuleInputSchema = object({
33173
33743
  cadenceSec: CadenceSecField.default(15),
33174
33744
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33175
33745
  framerate: FramerateField.default(10),
33746
+ /**
33747
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33748
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33749
+ * field gets.
33750
+ */
33751
+ denseCadenceSec: DenseCadenceSecField.optional(),
33752
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33753
+ minDwellSec: MinDwellSecField.optional(),
33176
33754
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33177
33755
  targets: TargetsField,
33178
33756
  template: TimelapseTemplateSchema.optional(),
33757
+ /**
33758
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33759
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33760
+ *
33761
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33762
+ * the notification's title/body, and clearing it (`template: null`) must not
33763
+ * silently clear the caption too.
33764
+ */
33765
+ previewText: PreviewTextField.optional(),
33766
+ /** Still or animation — see {@link PreviewModeField}. */
33767
+ previewMode: PreviewModeField.default("image"),
33768
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33769
+ reportClasses: ReportClassesField.optional(),
33179
33770
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33180
33771
  priority: PriorityField.default(3)
33181
33772
  });
@@ -33186,8 +33777,13 @@ object({
33186
33777
  schedule: NcScheduleSchema.optional(),
33187
33778
  cadenceSec: CadenceSecField.optional(),
33188
33779
  framerate: FramerateField.optional(),
33780
+ denseCadenceSec: DenseCadenceSecField.optional(),
33781
+ minDwellSec: MinDwellSecField.optional(),
33189
33782
  targets: TargetsField.optional(),
33190
33783
  template: TimelapseTemplateSchema.nullable().optional(),
33784
+ previewText: PreviewTextField.optional(),
33785
+ previewMode: PreviewModeField.optional(),
33786
+ reportClasses: ReportClassesField.optional(),
33191
33787
  priority: PriorityField.optional()
33192
33788
  });
33193
33789
  TimelapseRuleInputSchema.extend({
@@ -33199,10 +33795,28 @@ TimelapseRuleInputSchema.extend({
33199
33795
  */
33200
33796
  ownerUserId: string$2().optional(),
33201
33797
  /**
33202
- * Epoch-ms of the last successful generation — the 1-hour re-generation
33203
- * guard's durable state (predecessor parity). Absent = never generated.
33798
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33799
+ * rule. What a UI shows, and the compatibility floor for
33800
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33204
33801
  */
33205
33802
  lastGeneratedAt: number().optional(),
33803
+ /**
33804
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33805
+ * re-generation guard's real durable state.
33806
+ *
33807
+ * One rule covers several cameras and each renders its own video, so a rule
33808
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33809
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33810
+ * already done — and B's night is gone for good, because the window will not
33811
+ * come back.
33812
+ *
33813
+ * ADDITIVE, so the migration is free: a row written before this field simply
33814
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33815
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33816
+ * "never generated" would re-render and re-notify every camera of every rule
33817
+ * once, on the deploy that shipped the map.
33818
+ */
33819
+ generatedByDevice: record(string$2(), number()).optional(),
33206
33820
  /** userId of the caller who created the rule (server-stamped). */
33207
33821
  createdBy: string$2(),
33208
33822
  createdAt: number(),
@@ -33253,25 +33867,32 @@ object({
33253
33867
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33254
33868
  object({
33255
33869
  /**
33256
- * How long a retained native frame is served before it counts as a miss.
33870
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33871
+ * detection result.
33872
+ *
33873
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33874
+ * a time window was never related to the event the pixels were waiting for.
33875
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33876
+ * — at which moment the runner cuts the subject tiles it actually wanted and
33877
+ * releases the frame. The bound exists only so a runner that stops answering
33878
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33257
33879
  *
33258
- * Must cover the FULL late-crop horizon: detection inference + the
33259
- * cross-process inference-result hop to hub post-analysis + tracking + the
33260
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33261
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33262
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33880
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33881
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33882
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33883
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
33884
+ * `holdOverflow` on the metrics line is what says you need it.
33263
33885
  */
33264
- ttlMs: number().int().min(250).max(1e4),
33886
+ holdFrames: number().int().min(1).max(64),
33265
33887
  /**
33266
33888
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33267
33889
  *
33268
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33269
- * which one is actually binding before reasoning from that. At the shipped
33270
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33271
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33272
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33273
- * change that admits fewer frames buys retention WINDOW at constant RAM
33274
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33890
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33891
+ * is what decides how much is held, and the ceiling is the number above which
33892
+ * something is wrong. Before that it was the effective cap — at 1024 MB with
33893
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33894
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33895
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33275
33896
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33276
33897
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33277
33898
  * to replace).
@@ -33297,22 +33918,45 @@ object({
33297
33918
  * there is the signal that some caller names frames outside the inference set
33298
33919
  * and that this must go back to `all`.
33299
33920
  */
33300
- admission: NativeLeaseAdmissionSchema
33921
+ admission: NativeLeaseAdmissionSchema,
33922
+ /**
33923
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
33924
+ * compressed native crops the worker cuts at the moment a frame's detection
33925
+ * result arrives, and keeps long after the frame itself is freed.
33926
+ *
33927
+ * This is the knob that replaced the old retention window, and it buys about
33928
+ * three orders of magnitude more of it: a tile is one subject at native
33929
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
33930
+ * the frame it was cut from. A frame on which nothing was detected costs
33931
+ * nothing at all, which is the real change — the old lease paid per FRAME and
33932
+ * was interrogated per SUBJECT.
33933
+ *
33934
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
33935
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
33936
+ * reproduce that.
33937
+ */
33938
+ tileBudgetMb: number().int().min(0).max(1024)
33301
33939
  });
33302
33940
  /**
33303
- * The values in force when the operator has set nothing — byte-for-byte the
33304
- * constants the decode worker shipped with as env-var defaults, so making these
33305
- * settings changed no behaviour on the day it landed.
33941
+ * The values in force when the operator has set nothing.
33942
+ *
33943
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
33944
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
33945
+ * in the same change that redefines it would make a regression and a retune
33946
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
33947
+ * live traffic.
33306
33948
  */
33307
33949
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33308
- ttlMs: 1200,
33950
+ holdFrames: 8,
33309
33951
  budgetMb: 1024,
33310
33952
  activityMs: 15e3,
33953
+ tileBudgetMb: 64,
33311
33954
  admission: "inferred"
33312
33955
  };
33313
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
33956
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33314
33957
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33315
33958
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33959
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33316
33960
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33317
33961
  //#endregion
33318
33962
  //#region ../../node_modules/@matter/general/dist/esm/net/tcp/TcpConnection.js