@camstack/addon-provider-velux 0.2.13 → 0.2.15

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
@@ -7219,8 +7219,31 @@ var AdoptionJobSchema = object({
7219
7219
  error: string().nullable()
7220
7220
  });
7221
7221
  /**
7222
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7223
- * pipeline functions an operator thinks in terms of.
7222
+ * Per-camera FUNCTION SWITCHES.
7223
+ *
7224
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7225
+ *
7226
+ * This file shipped as "the one coherent on/off surface over the pipeline
7227
+ * functions an operator thinks in terms of". The operator's verdict on
7228
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7229
+ * every function already had a settings page of its own, and a second place to
7230
+ * turn it off is a second place to look. Each switch is going back to its own
7231
+ * component's original options — detection to the detection-pipeline wrapper
7232
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7233
+ * (which was always first-class; the switch was a veneer over
7234
+ * `recording.setDeviceConfig`), notifications to a notification-center
7235
+ * per-device setting, the two camera planes to their own components.
7236
+ *
7237
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7238
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7239
+ * straight from the authorities with no group in the middle. That rule was
7240
+ * never about a control panel.
7241
+ *
7242
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7243
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7244
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7245
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7246
+ * stop; nothing new may be built on it.
7224
7247
  *
7225
7248
  * ## This file adds no state
7226
7249
  *
@@ -7571,7 +7594,15 @@ var RecordingConfigSchema = object({
7571
7594
  * Each completed/failed run also lands one durable ops-log row on its owning
7572
7595
  * addon surface.
7573
7596
  */
7597
+ /**
7598
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7599
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7600
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7601
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7602
+ * runs at all.
7603
+ */
7574
7604
  var RelocateJobStateSchema = _enum([
7605
+ "queued",
7575
7606
  "running",
7576
7607
  "done",
7577
7608
  "failed",
@@ -7606,6 +7637,15 @@ var RelocateFootageInputSchema = object({
7606
7637
  /** Limits relocation to the logical profile class. Omit only for the
7607
7638
  * pre-orchestration compatibility path. */
7608
7639
  footageClass: RelocateFootageClassSchema.optional(),
7640
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7641
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7642
+ * unit is a (camera, profile) pile, not a disk. */
7643
+ deviceId: number().int().optional(),
7644
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7645
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7646
+ * placement plan assigns those two independently, so a rebalance that could
7647
+ * only say "recordings" would move footage the plan never asked to move. */
7648
+ profiles: array(string()).optional(),
7609
7649
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7610
7650
  * never allowed to starve live writers. */
7611
7651
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7741,6 +7781,21 @@ var StorageLocationSchema = object({
7741
7781
  nodeId: string().optional(),
7742
7782
  isDefault: boolean().default(false),
7743
7783
  isSystem: boolean().default(false),
7784
+ /**
7785
+ * Operator opt-in: whether consumers that BALANCE across several locations
7786
+ * of a type may write here. Recordings reads it today; event media and
7787
+ * backups are the next consumers, which is why the flag lives on the
7788
+ * location rather than in any one addon's store — nothing has to be
7789
+ * extended to add the next consumer.
7790
+ *
7791
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7792
+ * flag existed reads back with no flag and keeps working exactly as before;
7793
+ * that is the whole compat story, and it is why no migration ships with it.
7794
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7795
+ * disk must not silently start writing to it); the default of a type is
7796
+ * always stamped `true`.
7797
+ */
7798
+ enabled: boolean().optional(),
7744
7799
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7745
7800
  * for node-local locations it can reach) — never persisted, absent when the
7746
7801
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12293,7 +12348,8 @@ method(object({
12293
12348
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12294
12349
  /**
12295
12350
  * filesystem-browse — per-node capability for browsing the node's local
12296
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12351
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12352
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12297
12353
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12298
12354
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12299
12355
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14134,6 +14190,13 @@ var MaskGridDimsSchema = object({
14134
14190
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14135
14191
  * this one field keeps the schema additive — a rule still declares exactly
14136
14192
  * one trigger.
14193
+ *
14194
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14195
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14196
+ * mirror.ts` fails the build on a member the app cannot render) and every
14197
+ * member costs a release train. A sustained-sound rule is therefore an
14198
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14199
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14137
14200
  */
14138
14201
  var NcDeliverySchema = _enum([
14139
14202
  "immediate",
@@ -14148,15 +14211,32 @@ var NcDeliverySchema = _enum([
14148
14211
  * depend on a provider's raw event name or payload shape.
14149
14212
  */
14150
14213
  var NcSystemEventKindSchema = _enum([
14151
- "camera-online",
14152
- "camera-offline",
14214
+ "device-online",
14215
+ "device-offline",
14216
+ "device-disabled",
14217
+ "device-enabled",
14153
14218
  "stream-online",
14154
14219
  "stream-offline",
14155
14220
  "node-online",
14156
14221
  "node-offline",
14157
14222
  "addon-update-available",
14158
- "server-update-available"
14223
+ "server-update-available",
14224
+ "alarm-triggered",
14225
+ "alarm-armed",
14226
+ "alarm-disarmed",
14227
+ "camera-online",
14228
+ "camera-offline",
14229
+ "camera-disabled",
14230
+ "camera-enabled"
14231
+ ]);
14232
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14233
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14234
+ "camera-online",
14235
+ "camera-offline",
14236
+ "camera-disabled",
14237
+ "camera-enabled"
14159
14238
  ]);
14239
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14160
14240
  /**
14161
14241
  * One coherent system-event condition. `kinds` is the required opt-in safety
14162
14242
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14165,6 +14245,18 @@ var NcSystemEventKindSchema = _enum([
14165
14245
  var NcSystemEventConditionSchema = object({
14166
14246
  kinds: array(NcSystemEventKindSchema).min(1),
14167
14247
  deviceIds: array(number().int()).min(1).optional(),
14248
+ /**
14249
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14250
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14251
+ * is what a liveness rule means when nobody said otherwise.
14252
+ *
14253
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14254
+ * one reason: the intake cannot know which devices this household cares
14255
+ * about, and a producer-side filter is one no operator can change. Fails
14256
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14257
+ * does not carry) matches no `deviceTypes` list.
14258
+ */
14259
+ deviceTypes: array(string().min(1)).min(1).optional(),
14168
14260
  nodeIds: array(string().min(1)).min(1).optional(),
14169
14261
  packageNames: array(string().min(1)).min(1).optional()
14170
14262
  });
@@ -14215,6 +14307,47 @@ var NcOccupancyConditionSchema = object({
14215
14307
  sustainSeconds: number().int().min(0).max(3600).default(15)
14216
14308
  });
14217
14309
  /**
14310
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14311
+ *
14312
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14313
+ * reference notifier uses, so an operator moving between them re-uses what
14314
+ * they already know): a rule matches when, over a sampling window of
14315
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14316
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14317
+ *
14318
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14319
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14320
+ * - `labels` — the classifier put at least one of these labels on it.
14321
+ *
14322
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14323
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14324
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14325
+ * is given** — a window in which every sample is trivially a hit would fire on
14326
+ * silence, so the engine refuses such a condition rather than notifying on
14327
+ * nothing (the schema cannot express "at least one of" without becoming a
14328
+ * ZodEffects the cap path would have to special-case).
14329
+ *
14330
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14331
+ * must be FULL before it can match — a window that has been open for two
14332
+ * seconds of its ten is 100% of nothing, and firing on it would make
14333
+ * `samplingSeconds` decorative.
14334
+ *
14335
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14336
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14337
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14338
+ * an operator who typed `dog` mean the same thing.
14339
+ */
14340
+ var NcAudioConditionSchema = object({
14341
+ /** Audio macro labels; absent = any sound (level-only rule). */
14342
+ labels: array(string().min(1)).min(1).optional(),
14343
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14344
+ dbThreshold: number().min(-96).max(0).optional(),
14345
+ /** Percentage of the window's samples that must be hits (1–100). */
14346
+ hitPercent: number().int().min(1).max(100).default(60),
14347
+ /** Length of the sampling window in seconds. */
14348
+ samplingSeconds: number().int().min(1).max(300).default(10)
14349
+ });
14350
+ /**
14218
14351
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14219
14352
  *
14220
14353
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14487,7 +14620,33 @@ var NcConditionsSchema = object({
14487
14620
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14488
14621
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14489
14622
  */
14490
- occupancy: NcOccupancyConditionSchema.optional()
14623
+ occupancy: NcOccupancyConditionSchema.optional(),
14624
+ /**
14625
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14626
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14627
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14628
+ * a window that is not full yet, neither filter given). See
14629
+ * {@link NcAudioCondition}.
14630
+ *
14631
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14632
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14633
+ * a detection, a track or a device event (the same fail-closed pairing
14634
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14635
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14636
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14637
+ * classified sample) stays exactly as it was for rules that already use it.
14638
+ *
14639
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14640
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14641
+ * (`camstack/src/data/notification-center.ts`, guarded by
14642
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14643
+ * condition fields it does not know when a rule is saved from the phone.
14644
+ * Publishing an editor for a condition the app cannot round-trip is how an
14645
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14646
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14647
+ * does an audio rule become authorable.
14648
+ */
14649
+ audio: NcAudioConditionSchema.optional()
14491
14650
  });
14492
14651
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14493
14652
  var NcRuleTargetSchema = object({
@@ -14601,6 +14760,73 @@ var NcThrottleSchema = object({
14601
14760
  */
14602
14761
  granularity: NcThrottleGranularitySchema.optional()
14603
14762
  });
14763
+ /**
14764
+ * How long the confirm gate may hold ONE notification, and how big the picture
14765
+ * it judges may be.
14766
+ *
14767
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14768
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14769
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14770
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14771
+ * tokens for pixels the model pools away.
14772
+ */
14773
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14774
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14775
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14776
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14777
+ var NcConfirmExpectSchema = object({
14778
+ op: _enum([
14779
+ ">=",
14780
+ ">",
14781
+ "<=",
14782
+ "<",
14783
+ "=="
14784
+ ]),
14785
+ count: number().int().min(0).max(1e3)
14786
+ });
14787
+ /**
14788
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14789
+ * to ship and says whether it agrees with the rule.
14790
+ *
14791
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14792
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14793
+ * on the operator's phone is not a verdict about this notification.
14794
+ *
14795
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14796
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14797
+ * the default and every fail-open is COUNTED, because a gate that always fails
14798
+ * open looks in the log exactly like a gate that works.
14799
+ *
14800
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14801
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14802
+ * production failures in one day), so the gate reads absent as the constant
14803
+ * above rather than trusting a parse it may never have seen.
14804
+ */
14805
+ var NcConfirmSchema = object({
14806
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14807
+ * same thing, and both mean "deliver exactly as before". */
14808
+ enabled: boolean().default(false),
14809
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14810
+ profileId: string().optional(),
14811
+ /**
14812
+ * The operator's question, in his own words. Absent = a question derived
14813
+ * from the rule (its class and its expectation).
14814
+ *
14815
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14816
+ * banners, signage and plates as instructions if you let them reach the
14817
+ * prompt — proven live — so the authoritative contract stays in the system
14818
+ * turn and only rule-authored words land here.
14819
+ */
14820
+ prompt: string().max(1e3).optional(),
14821
+ /** Fire only when the model's count satisfies this. Absent = the model's
14822
+ * own boolean verdict decides. */
14823
+ expect: NcConfirmExpectSchema.optional(),
14824
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14825
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14826
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14827
+ /** Longest edge the judged image is downscaled to before it is sent. */
14828
+ maxImagePx: number().int().min(64).max(2048).default(448)
14829
+ });
14604
14830
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14605
14831
  var NcRuleInputSchema = object({
14606
14832
  name: string().min(1).max(200),
@@ -14661,7 +14887,13 @@ var NcRuleInputSchema = object({
14661
14887
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14662
14888
  * shape as every other actuation.
14663
14889
  */
14664
- actions: NcRuleActionsSchema.optional()
14890
+ actions: NcRuleActionsSchema.optional(),
14891
+ /**
14892
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14893
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14894
+ * did, and absent is the only way to say that without a migration.
14895
+ */
14896
+ confirm: NcConfirmSchema.optional()
14665
14897
  });
14666
14898
  /**
14667
14899
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14672,7 +14904,37 @@ var NcRuleInputSchema = object({
14672
14904
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14673
14905
  * `updateRule` patch.
14674
14906
  */
14675
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14907
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14908
+ disabledTargetIds: array(string()).optional(),
14909
+ /**
14910
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14911
+ *
14912
+ * It makes the key optional to SUPPLY; the parse still materialises the
14913
+ * default when the key is absent. And `NcRuleStore.update` merges with
14914
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14915
+ * one — which made every partial edit destructive:
14916
+ *
14917
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14918
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14919
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14920
+ *
14921
+ * A rule scoped to one camera and one zone silently became a rule that
14922
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14923
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14924
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14925
+ * within a minute of a two-field patch.
14926
+ *
14927
+ * So every defaulted field is re-declared here WITHOUT its default. The
14928
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14929
+ * conditions remains a real instruction ("clear them") — and only the
14930
+ * absent key is now genuinely absent.
14931
+ */
14932
+ enabled: boolean().optional(),
14933
+ conditions: NcConditionsSchema.optional(),
14934
+ media: NcMediaPolicySchema.optional(),
14935
+ throttle: NcThrottleSchema.optional(),
14936
+ priority: number().int().min(1).max(5).optional()
14937
+ });
14676
14938
  /** A persisted rule. */
14677
14939
  var NcRuleSchema = NcRuleInputSchema.extend({
14678
14940
  id: string(),
@@ -14973,6 +15235,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14973
15235
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14974
15236
  * copy would lie the first time a rule is disabled.
14975
15237
  */
15238
+ /**
15239
+ * Why a device a mode NAMES is nonetheless not armed by it.
15240
+ *
15241
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15242
+ * per-camera notification switch the Notification Center already owns,
15243
+ * `detection-off` is the device's own detection binding being inactive, and
15244
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15245
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15246
+ * with the switches the operator actually used.
15247
+ */
15248
+ var NcAlarmSkipReasonSchema = _enum([
15249
+ "muted",
15250
+ "detection-off",
15251
+ "offline"
15252
+ ]);
15253
+ var NcAlarmSkippedDeviceSchema = object({
15254
+ deviceId: number().int(),
15255
+ reason: NcAlarmSkipReasonSchema
15256
+ });
14976
15257
  var NcAlarmModeCoverageSchema = object({
14977
15258
  mode: AlarmArmModeSchema,
14978
15259
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14980,7 +15261,18 @@ var NcAlarmModeCoverageSchema = object({
14980
15261
  /** At least one covering rule has no device scope, so the mode covers all. */
14981
15262
  allDevices: boolean(),
14982
15263
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14983
- deviceIds: array(number().int())
15264
+ deviceIds: array(number().int()),
15265
+ /**
15266
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15267
+ * excludes it.
15268
+ *
15269
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15270
+ * twelve makes it false in exactly the way nobody notices until an incident.
15271
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15272
+ * still parses as "nothing known to be skipped" rather than failing the whole
15273
+ * alarm tab.
15274
+ */
15275
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14984
15276
  });
14985
15277
  var NcAlarmConfigSchema = object({
14986
15278
  /**
@@ -17812,9 +18104,16 @@ var CameraStatusSchema = object({
17812
18104
  audio: CameraAudioStatusSchema.nullable(),
17813
18105
  recording: CameraRecordingStatusSchema.nullable(),
17814
18106
  /**
17815
- * Per-camera function switches an OPERATOR has turned off
18107
+ * Per-camera functions an OPERATOR has turned off
17816
18108
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17817
18109
  *
18110
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18111
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18112
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18113
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18114
+ * The badge outlives the control panel: the panel was a convenience, this is
18115
+ * the difference between a camera being off and a camera being dead.
18116
+ *
17818
18117
  * This is the difference between DISABLED and BROKEN. A camera whose
17819
18118
  * `detection` block reports zero fps and whose `switchedOff` contains
17820
18119
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24556,7 +24855,19 @@ var RecordingManifestSchema = object({
24556
24855
  * profiles/subtrees/locations on this node). */
24557
24856
  var RecordingDeviceUsageSchema = object({
24558
24857
  deviceId: number(),
24559
- usedBytes: number()
24858
+ usedBytes: number(),
24859
+ /**
24860
+ * Start of this camera's OLDEST indexed segment, across every profile and
24861
+ * location — the "Oldest footage" column in Recordings → Storage, and the
24862
+ * only honest answer to "is retention actually holding?" per camera.
24863
+ *
24864
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
24865
+ * predates this field omits it entirely, and a hub whose types carry the
24866
+ * field must keep validating that older provider's payload: the framework
24867
+ * (types) and the addon ship on different trains, and the addon is usually
24868
+ * the later of the two.
24869
+ */
24870
+ oldestMs: number().nullable().optional()
24560
24871
  });
24561
24872
  /** Recording storage usage + capacity for one storage location. */
24562
24873
  var RecordingLocationUsageSchema = object({
@@ -24584,6 +24895,57 @@ var RecordingStorageUsageSchema = object({
24584
24895
  locations: array(RecordingLocationUsageSchema)
24585
24896
  });
24586
24897
  /**
24898
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
24899
+ *
24900
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
24901
+ * is the operator asking for the EXISTING archive to be brought into line with
24902
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
24903
+ * location, run FIFO behind the single-flight mover.
24904
+ *
24905
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
24906
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
24907
+ * (empty on the plan).
24908
+ */
24909
+ var RecordingRebalanceMoveSchema = object({
24910
+ deviceId: number(),
24911
+ profile: string(),
24912
+ fromLocationId: string(),
24913
+ toLocationId: string(),
24914
+ bytes: number(),
24915
+ files: number().int()
24916
+ });
24917
+ /** Why a pile that is out of place is staying there. Every refusal is
24918
+ * reported: a rebalance that silently drops a camera reads exactly like one
24919
+ * that had nothing to do. */
24920
+ var RecordingRebalanceSkipReasonSchema = _enum([
24921
+ "unassigned",
24922
+ "target-not-writable",
24923
+ "below-threshold",
24924
+ "no-headroom"
24925
+ ]);
24926
+ var RecordingRebalanceSkipSchema = object({
24927
+ deviceId: number(),
24928
+ profile: string(),
24929
+ fromLocationId: string(),
24930
+ /** The location the plan wants; null when the camera has no assignment. */
24931
+ toLocationId: string().nullable(),
24932
+ bytes: number(),
24933
+ reason: RecordingRebalanceSkipReasonSchema
24934
+ });
24935
+ var RecordingRebalancePlanSchema = object({
24936
+ moves: array(RecordingRebalanceMoveSchema),
24937
+ skipped: array(RecordingRebalanceSkipSchema),
24938
+ bytesToMove: number(),
24939
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
24940
+ jobIds: array(string())
24941
+ });
24942
+ var RecordingRebalanceInputSchema = object({
24943
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
24944
+ throttleMbps: number().min(1).max(1e3).optional(),
24945
+ /** Ignore piles smaller than this (default 1 GB). */
24946
+ minMoveGb: number().min(0).optional()
24947
+ });
24948
+ /**
24587
24949
  * Result of locating footage at a wall-clock instant for one device/profile.
24588
24950
  * `segment` carries the covering segment's window; `gap` reports the forward
24589
24951
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -24746,9 +25108,24 @@ method(object({
24746
25108
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
24747
25109
  kind: "mutation",
24748
25110
  auth: "admin"
25111
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25112
+ kind: "mutation",
25113
+ auth: "admin"
25114
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25115
+ kind: "query",
25116
+ auth: "admin"
25117
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25118
+ kind: "mutation",
25119
+ auth: "admin"
25120
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25121
+ kind: "query",
25122
+ auth: "admin"
25123
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25124
+ kind: "mutation",
25125
+ auth: "admin"
24749
25126
  });
24750
25127
  /**
24751
- * `recordingExport` cap — render a footage time range into a single downloadable
25128
+ * `recording-export` cap — render a footage time range into a single downloadable
24752
25129
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
24753
25130
  * bounded lifetime with a durable history, auto-expiry, and optional
24754
25131
  * delete-after-download.
@@ -24763,10 +25140,53 @@ method(object({
24763
25140
  */
24764
25141
  /** Playback-speed multiplier for the render (1 = realtime). */
24765
25142
  var ExportSpeedSchema = number().min(.25).max(32);
25143
+ /**
25144
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25145
+ *
25146
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25147
+ * derives these bounds from things that happened at a TIME (a track's
25148
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25149
+ * every segment present for the range, with each recording GAP removed. The
25150
+ * two agree only on a window that recorded without one interruption, and only
25151
+ * the render side knows the segments, so the translation lives there
25152
+ * (`export-dense-map.ts`, addon-pipeline).
25153
+ *
25154
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25155
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25156
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25157
+ * the video was a uniform timelapse, and the log line reported the five ranges
25158
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25159
+ *
25160
+ * Relative and not absolute epoch, because an absolute epoch would make every
25161
+ * call site responsible for the same subtraction.
25162
+ */
25163
+ var ExportDenseRangeSchema = object({
25164
+ fromSec: number().nonnegative(),
25165
+ toSec: number().nonnegative()
25166
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25167
+ /**
25168
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25169
+ * listed ranges and at the base `everyMs` everywhere else.
25170
+ *
25171
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25172
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25173
+ */
25174
+ var ExportDenseSchema = object({
25175
+ everyMs: number().int().positive(),
25176
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25177
+ });
24766
25178
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
24767
25179
  var ExportTimelapseSchema = object({
24768
25180
  everyMs: number().int().positive(),
24769
- outputFps: number().int().min(1).max(60).optional()
25181
+ outputFps: number().int().min(1).max(60).optional(),
25182
+ /** Optional second, FASTER rate over the intervals that matter. */
25183
+ dense: ExportDenseSchema.optional()
25184
+ }).superRefine((v, ctx) => {
25185
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25186
+ code: ZodIssueCode.custom,
25187
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25188
+ path: ["dense", "everyMs"]
25189
+ });
24770
25190
  });
24771
25191
  /**
24772
25192
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -24824,6 +25244,19 @@ var ExportDownloadSchema = object({
24824
25244
  url: string(),
24825
25245
  endpoints: array(string())
24826
25246
  });
25247
+ /**
25248
+ * A finished export's bytes, inline.
25249
+ *
25250
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25251
+ * against, so nobody has to infer it from the base64 length.
25252
+ */
25253
+ var ExportBytesSchema = object({
25254
+ base64: string(),
25255
+ contentType: string(),
25256
+ /** Suggested filename, extension included. */
25257
+ name: string(),
25258
+ bytes: number().int().nonnegative()
25259
+ });
24827
25260
  method(object({
24828
25261
  deviceId: number(),
24829
25262
  profile: string(),
@@ -24848,6 +25281,9 @@ method(object({
24848
25281
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
24849
25282
  kind: "query",
24850
25283
  auth: "protected"
25284
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25285
+ kind: "query",
25286
+ auth: "protected"
24851
25287
  });
24852
25288
  /**
24853
25289
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31525,6 +31961,12 @@ Object.freeze({
31525
31961
  addonId: null,
31526
31962
  access: "create"
31527
31963
  },
31964
+ "recording.cancelRelocateJob": {
31965
+ capName: "recording",
31966
+ capScope: "system",
31967
+ addonId: null,
31968
+ access: "create"
31969
+ },
31528
31970
  "recording.cancelStorageMigrationMove": {
31529
31971
  capName: "recording",
31530
31972
  capScope: "system",
@@ -31579,6 +32021,12 @@ Object.freeze({
31579
32021
  addonId: null,
31580
32022
  access: "view"
31581
32023
  },
32024
+ "recording.listRelocateJobs": {
32025
+ capName: "recording",
32026
+ capScope: "system",
32027
+ addonId: null,
32028
+ access: "view"
32029
+ },
31582
32030
  "recording.locateSegment": {
31583
32031
  capName: "recording",
31584
32032
  capScope: "system",
@@ -31591,6 +32039,12 @@ Object.freeze({
31591
32039
  addonId: null,
31592
32040
  access: "create"
31593
32041
  },
32042
+ "recording.planStorageRebalance": {
32043
+ capName: "recording",
32044
+ capScope: "system",
32045
+ addonId: null,
32046
+ access: "view"
32047
+ },
31594
32048
  "recording.pruneFootage": {
31595
32049
  capName: "recording",
31596
32050
  capScope: "system",
@@ -31615,6 +32069,12 @@ Object.freeze({
31615
32069
  addonId: null,
31616
32070
  access: "create"
31617
32071
  },
32072
+ "recording.relocateFootage": {
32073
+ capName: "recording",
32074
+ capScope: "system",
32075
+ addonId: null,
32076
+ access: "create"
32077
+ },
31618
32078
  "recording.renderClip": {
31619
32079
  capName: "recording",
31620
32080
  capScope: "system",
@@ -31651,38 +32111,50 @@ Object.freeze({
31651
32111
  addonId: null,
31652
32112
  access: "create"
31653
32113
  },
32114
+ "recording.startStorageRebalance": {
32115
+ capName: "recording",
32116
+ capScope: "system",
32117
+ addonId: null,
32118
+ access: "create"
32119
+ },
31654
32120
  "recordingExport.cancelExport": {
31655
- capName: "recordingExport",
32121
+ capName: "recording-export",
31656
32122
  capScope: "system",
31657
32123
  addonId: null,
31658
32124
  access: "create"
31659
32125
  },
31660
32126
  "recordingExport.createExport": {
31661
- capName: "recordingExport",
32127
+ capName: "recording-export",
31662
32128
  capScope: "system",
31663
32129
  addonId: null,
31664
32130
  access: "create"
31665
32131
  },
31666
32132
  "recordingExport.deleteExport": {
31667
- capName: "recordingExport",
32133
+ capName: "recording-export",
31668
32134
  capScope: "system",
31669
32135
  addonId: null,
31670
32136
  access: "delete"
31671
32137
  },
31672
32138
  "recordingExport.getDownloadUrl": {
31673
- capName: "recordingExport",
32139
+ capName: "recording-export",
31674
32140
  capScope: "system",
31675
32141
  addonId: null,
31676
32142
  access: "view"
31677
32143
  },
31678
32144
  "recordingExport.getExport": {
31679
- capName: "recordingExport",
32145
+ capName: "recording-export",
31680
32146
  capScope: "system",
31681
32147
  addonId: null,
31682
32148
  access: "view"
31683
32149
  },
31684
32150
  "recordingExport.listExports": {
31685
- capName: "recordingExport",
32151
+ capName: "recording-export",
32152
+ capScope: "system",
32153
+ addonId: null,
32154
+ access: "view"
32155
+ },
32156
+ "recordingExport.readExportBytes": {
32157
+ capName: "recording-export",
31686
32158
  capScope: "system",
31687
32159
  addonId: null,
31688
32160
  access: "view"
@@ -33059,6 +33531,104 @@ var FramerateField = number().int().min(1).max(60);
33059
33531
  var TargetsField = array(NcRuleTargetSchema).min(1);
33060
33532
  var PriorityField = number().int().min(1).max(5);
33061
33533
  /**
33534
+ * Explicit override of the DENSE sampling cadence, seconds.
33535
+ *
33536
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
33537
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
33538
+ * made that same base 3 s and rendered a person pass as two frames.)
33539
+ *
33540
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
33541
+ * `denseCadenceSec` and played at `framerate` occupies
33542
+ *
33543
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
33544
+ *
33545
+ * 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.
33546
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
33547
+ * and therefore the length of a quiet night, does not move.
33548
+ *
33549
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
33550
+ * the recording has them returns the same frames, requested twice. Must be
33551
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
33552
+ * a uniform video the operator believes is two-rate — and upsert refuses it
33553
+ * rather than letting the export cap reject the render hours after the window.
33554
+ */
33555
+ var DenseCadenceSecField = number().min(.1).max(3600);
33556
+ /**
33557
+ * Minimum seconds of OUTPUT video each detection range must occupy.
33558
+ *
33559
+ * The operator-facing form of the arithmetic above: instead of solving for a
33560
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
33561
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
33562
+ * that range every ~583 ms.
33563
+ *
33564
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
33565
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
33566
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
33567
+ * ranges are sampled denser than they need. Per-range cadences require a cap
33568
+ * schema change and are the tracked follow-up.
33569
+ *
33570
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
33571
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
33572
+ * by real footage, never met by duplicating frames into motion that never
33573
+ * happened.
33574
+ */
33575
+ var MinDwellSecField = number().min(0).max(60);
33576
+ /**
33577
+ * Caption burned into the notification's preview frame.
33578
+ *
33579
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
33580
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
33581
+ * templating dialect for one field would be a second thing to explain.
33582
+ *
33583
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
33584
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
33585
+ * the reason this is not `.min(1)`.
33586
+ */
33587
+ var PreviewTextField = string().max(200);
33588
+ /**
33589
+ * Whether the notification's preview is a STILL or a short animation.
33590
+ *
33591
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
33592
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
33593
+ * night reads better as three seconds of motion than as one frame of it. Both
33594
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
33595
+ * simply applies it to a dozen frames sampled across the render and assembles
33596
+ * them.
33597
+ *
33598
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
33599
+ * seeks and a palette pass, and no rule that never asked for one should start
33600
+ * paying that on the deploy that shipped it.
33601
+ *
33602
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
33603
+ */
33604
+ var PreviewModeField = _enum(["image", "gif"]);
33605
+ /**
33606
+ * Which detection classes the notification reports counts for.
33607
+ *
33608
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
33609
+ * plan — no second query — aggregated per class. Absent or empty means "every
33610
+ * class the window actually contained", which is what an operator who never
33611
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
33612
+ * counts cars all night).
33613
+ *
33614
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
33615
+ * …). An unknown name simply never matches and reports nothing — it is not an
33616
+ * error, because a rule may legitimately name a class this camera's model does
33617
+ * not emit.
33618
+ *
33619
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
33620
+ * - `{{detections}}` — total over the reported classes
33621
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
33622
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
33623
+ * one per class, `count_` + the class name
33624
+ *
33625
+ * With NO custom body template the summary is appended to the derived body, and
33626
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
33627
+ * reads. With a custom template the operator owns every word — nothing is
33628
+ * appended, so `{{detectionSummary}}` is how he asks for it.
33629
+ */
33630
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
33631
+ /**
33062
33632
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33063
33633
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33064
33634
  * here (see the ownership note above).
@@ -33078,9 +33648,30 @@ var TimelapseRuleInputSchema = object({
33078
33648
  cadenceSec: CadenceSecField.default(15),
33079
33649
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33080
33650
  framerate: FramerateField.default(10),
33651
+ /**
33652
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
33653
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
33654
+ * field gets.
33655
+ */
33656
+ denseCadenceSec: DenseCadenceSecField.optional(),
33657
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
33658
+ minDwellSec: MinDwellSecField.optional(),
33081
33659
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33082
33660
  targets: TargetsField,
33083
33661
  template: TimelapseTemplateSchema.optional(),
33662
+ /**
33663
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
33664
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
33665
+ *
33666
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
33667
+ * the notification's title/body, and clearing it (`template: null`) must not
33668
+ * silently clear the caption too.
33669
+ */
33670
+ previewText: PreviewTextField.optional(),
33671
+ /** Still or animation — see {@link PreviewModeField}. */
33672
+ previewMode: PreviewModeField.default("image"),
33673
+ /** Classes the notification counts — see {@link ReportClassesField}. */
33674
+ reportClasses: ReportClassesField.optional(),
33084
33675
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33085
33676
  priority: PriorityField.default(3)
33086
33677
  });
@@ -33091,8 +33682,13 @@ object({
33091
33682
  schedule: NcScheduleSchema.optional(),
33092
33683
  cadenceSec: CadenceSecField.optional(),
33093
33684
  framerate: FramerateField.optional(),
33685
+ denseCadenceSec: DenseCadenceSecField.optional(),
33686
+ minDwellSec: MinDwellSecField.optional(),
33094
33687
  targets: TargetsField.optional(),
33095
33688
  template: TimelapseTemplateSchema.nullable().optional(),
33689
+ previewText: PreviewTextField.optional(),
33690
+ previewMode: PreviewModeField.optional(),
33691
+ reportClasses: ReportClassesField.optional(),
33096
33692
  priority: PriorityField.optional()
33097
33693
  });
33098
33694
  TimelapseRuleInputSchema.extend({
@@ -33104,10 +33700,28 @@ TimelapseRuleInputSchema.extend({
33104
33700
  */
33105
33701
  ownerUserId: string().optional(),
33106
33702
  /**
33107
- * Epoch-ms of the last successful generation — the 1-hour re-generation
33108
- * guard's durable state (predecessor parity). Absent = never generated.
33703
+ * Epoch-ms of the NEWEST successful generation across every camera of this
33704
+ * rule. What a UI shows, and the compatibility floor for
33705
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33109
33706
  */
33110
33707
  lastGeneratedAt: number().optional(),
33708
+ /**
33709
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
33710
+ * re-generation guard's real durable state.
33711
+ *
33712
+ * One rule covers several cameras and each renders its own video, so a rule
33713
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
33714
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
33715
+ * already done — and B's night is gone for good, because the window will not
33716
+ * come back.
33717
+ *
33718
+ * ADDITIVE, so the migration is free: a row written before this field simply
33719
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
33720
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
33721
+ * "never generated" would re-render and re-notify every camera of every rule
33722
+ * once, on the deploy that shipped the map.
33723
+ */
33724
+ generatedByDevice: record(string(), number()).optional(),
33111
33725
  /** userId of the caller who created the rule (server-stamped). */
33112
33726
  createdBy: string(),
33113
33727
  createdAt: number(),
@@ -33158,25 +33772,32 @@ object({
33158
33772
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33159
33773
  object({
33160
33774
  /**
33161
- * How long a retained native frame is served before it counts as a miss.
33775
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33776
+ * detection result.
33777
+ *
33778
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33779
+ * a time window was never related to the event the pixels were waiting for.
33780
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33781
+ * — at which moment the runner cuts the subject tiles it actually wanted and
33782
+ * releases the frame. The bound exists only so a runner that stops answering
33783
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33162
33784
  *
33163
- * Must cover the FULL late-crop horizon: detection inference + the
33164
- * cross-process inference-result hop to hub post-analysis + tracking + the
33165
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33166
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33167
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33785
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33786
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33787
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33788
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
33789
+ * `holdOverflow` on the metrics line is what says you need it.
33168
33790
  */
33169
- ttlMs: number().int().min(250).max(1e4),
33791
+ holdFrames: number().int().min(1).max(64),
33170
33792
  /**
33171
33793
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33172
33794
  *
33173
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33174
- * which one is actually binding before reasoning from that. At the shipped
33175
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33176
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33177
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33178
- * change that admits fewer frames buys retention WINDOW at constant RAM
33179
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33795
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33796
+ * is what decides how much is held, and the ceiling is the number above which
33797
+ * something is wrong. Before that it was the effective cap — at 1024 MB with
33798
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33799
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33800
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33180
33801
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33181
33802
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33182
33803
  * to replace).
@@ -33202,22 +33823,45 @@ object({
33202
33823
  * there is the signal that some caller names frames outside the inference set
33203
33824
  * and that this must go back to `all`.
33204
33825
  */
33205
- admission: NativeLeaseAdmissionSchema
33826
+ admission: NativeLeaseAdmissionSchema,
33827
+ /**
33828
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
33829
+ * compressed native crops the worker cuts at the moment a frame's detection
33830
+ * result arrives, and keeps long after the frame itself is freed.
33831
+ *
33832
+ * This is the knob that replaced the old retention window, and it buys about
33833
+ * three orders of magnitude more of it: a tile is one subject at native
33834
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
33835
+ * the frame it was cut from. A frame on which nothing was detected costs
33836
+ * nothing at all, which is the real change — the old lease paid per FRAME and
33837
+ * was interrogated per SUBJECT.
33838
+ *
33839
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
33840
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
33841
+ * reproduce that.
33842
+ */
33843
+ tileBudgetMb: number().int().min(0).max(1024)
33206
33844
  });
33207
33845
  /**
33208
- * The values in force when the operator has set nothing — byte-for-byte the
33209
- * constants the decode worker shipped with as env-var defaults, so making these
33210
- * settings changed no behaviour on the day it landed.
33846
+ * The values in force when the operator has set nothing.
33847
+ *
33848
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
33849
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
33850
+ * in the same change that redefines it would make a regression and a retune
33851
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
33852
+ * live traffic.
33211
33853
  */
33212
33854
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33213
- ttlMs: 1200,
33855
+ holdFrames: 8,
33214
33856
  budgetMb: 1024,
33215
33857
  activityMs: 15e3,
33858
+ tileBudgetMb: 64,
33216
33859
  admission: "inferred"
33217
33860
  };
33218
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
33861
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33219
33862
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33220
33863
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33864
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33221
33865
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33222
33866
  //#endregion
33223
33867
  //#region src/config.ts