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