@camstack/addon-provider-homeassistant 1.2.24 → 1.2.26

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.
@@ -7323,8 +7323,31 @@ var AdoptionJobSchema = object({
7323
7323
  error: string().nullable()
7324
7324
  });
7325
7325
  /**
7326
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7327
- * pipeline functions an operator thinks in terms of.
7326
+ * Per-camera FUNCTION SWITCHES.
7327
+ *
7328
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7329
+ *
7330
+ * This file shipped as "the one coherent on/off surface over the pipeline
7331
+ * functions an operator thinks in terms of". The operator's verdict on
7332
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7333
+ * every function already had a settings page of its own, and a second place to
7334
+ * turn it off is a second place to look. Each switch is going back to its own
7335
+ * component's original options — detection to the detection-pipeline wrapper
7336
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7337
+ * (which was always first-class; the switch was a veneer over
7338
+ * `recording.setDeviceConfig`), notifications to a notification-center
7339
+ * per-device setting, the two camera planes to their own components.
7340
+ *
7341
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7342
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7343
+ * straight from the authorities with no group in the middle. That rule was
7344
+ * never about a control panel.
7345
+ *
7346
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7347
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7348
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7349
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7350
+ * stop; nothing new may be built on it.
7328
7351
  *
7329
7352
  * ## This file adds no state
7330
7353
  *
@@ -7675,7 +7698,15 @@ var RecordingConfigSchema = object({
7675
7698
  * Each completed/failed run also lands one durable ops-log row on its owning
7676
7699
  * addon surface.
7677
7700
  */
7701
+ /**
7702
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7703
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7704
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7705
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7706
+ * runs at all.
7707
+ */
7678
7708
  var RelocateJobStateSchema = _enum([
7709
+ "queued",
7679
7710
  "running",
7680
7711
  "done",
7681
7712
  "failed",
@@ -7710,6 +7741,15 @@ var RelocateFootageInputSchema = object({
7710
7741
  /** Limits relocation to the logical profile class. Omit only for the
7711
7742
  * pre-orchestration compatibility path. */
7712
7743
  footageClass: RelocateFootageClassSchema.optional(),
7744
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7745
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7746
+ * unit is a (camera, profile) pile, not a disk. */
7747
+ deviceId: number().int().optional(),
7748
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7749
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7750
+ * placement plan assigns those two independently, so a rebalance that could
7751
+ * only say "recordings" would move footage the plan never asked to move. */
7752
+ profiles: array(string()).optional(),
7713
7753
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7714
7754
  * never allowed to starve live writers. */
7715
7755
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7845,6 +7885,21 @@ var StorageLocationSchema = object({
7845
7885
  nodeId: string().optional(),
7846
7886
  isDefault: boolean().default(false),
7847
7887
  isSystem: boolean().default(false),
7888
+ /**
7889
+ * Operator opt-in: whether consumers that BALANCE across several locations
7890
+ * of a type may write here. Recordings reads it today; event media and
7891
+ * backups are the next consumers, which is why the flag lives on the
7892
+ * location rather than in any one addon's store — nothing has to be
7893
+ * extended to add the next consumer.
7894
+ *
7895
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7896
+ * flag existed reads back with no flag and keeps working exactly as before;
7897
+ * that is the whole compat story, and it is why no migration ships with it.
7898
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7899
+ * disk must not silently start writing to it); the default of a type is
7900
+ * always stamped `true`.
7901
+ */
7902
+ enabled: boolean().optional(),
7848
7903
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7849
7904
  * for node-local locations it can reach) — never persisted, absent when the
7850
7905
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12552,7 +12607,8 @@ method(object({
12552
12607
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12553
12608
  /**
12554
12609
  * filesystem-browse — per-node capability for browsing the node's local
12555
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12610
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12611
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12556
12612
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12557
12613
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12558
12614
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -14407,6 +14463,13 @@ var MaskGridDimsSchema = object({
14407
14463
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
14408
14464
  * this one field keeps the schema additive — a rule still declares exactly
14409
14465
  * one trigger.
14466
+ *
14467
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14468
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14469
+ * mirror.ts` fails the build on a member the app cannot render) and every
14470
+ * member costs a release train. A sustained-sound rule is therefore an
14471
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14472
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
14410
14473
  */
14411
14474
  var NcDeliverySchema = _enum([
14412
14475
  "immediate",
@@ -14421,15 +14484,32 @@ var NcDeliverySchema = _enum([
14421
14484
  * depend on a provider's raw event name or payload shape.
14422
14485
  */
14423
14486
  var NcSystemEventKindSchema = _enum([
14424
- "camera-online",
14425
- "camera-offline",
14487
+ "device-online",
14488
+ "device-offline",
14489
+ "device-disabled",
14490
+ "device-enabled",
14426
14491
  "stream-online",
14427
14492
  "stream-offline",
14428
14493
  "node-online",
14429
14494
  "node-offline",
14430
14495
  "addon-update-available",
14431
- "server-update-available"
14496
+ "server-update-available",
14497
+ "alarm-triggered",
14498
+ "alarm-armed",
14499
+ "alarm-disarmed",
14500
+ "camera-online",
14501
+ "camera-offline",
14502
+ "camera-disabled",
14503
+ "camera-enabled"
14504
+ ]);
14505
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14506
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14507
+ "camera-online",
14508
+ "camera-offline",
14509
+ "camera-disabled",
14510
+ "camera-enabled"
14432
14511
  ]);
14512
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
14433
14513
  /**
14434
14514
  * One coherent system-event condition. `kinds` is the required opt-in safety
14435
14515
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14438,6 +14518,18 @@ var NcSystemEventKindSchema = _enum([
14438
14518
  var NcSystemEventConditionSchema = object({
14439
14519
  kinds: array(NcSystemEventKindSchema).min(1),
14440
14520
  deviceIds: array(number().int()).min(1).optional(),
14521
+ /**
14522
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14523
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14524
+ * is what a liveness rule means when nobody said otherwise.
14525
+ *
14526
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14527
+ * one reason: the intake cannot know which devices this household cares
14528
+ * about, and a producer-side filter is one no operator can change. Fails
14529
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14530
+ * does not carry) matches no `deviceTypes` list.
14531
+ */
14532
+ deviceTypes: array(string().min(1)).min(1).optional(),
14441
14533
  nodeIds: array(string().min(1)).min(1).optional(),
14442
14534
  packageNames: array(string().min(1)).min(1).optional()
14443
14535
  });
@@ -14488,6 +14580,47 @@ var NcOccupancyConditionSchema = object({
14488
14580
  sustainSeconds: number().int().min(0).max(3600).default(15)
14489
14581
  });
14490
14582
  /**
14583
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14584
+ *
14585
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14586
+ * reference notifier uses, so an operator moving between them re-uses what
14587
+ * they already know): a rule matches when, over a sampling window of
14588
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14589
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14590
+ *
14591
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14592
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14593
+ * - `labels` — the classifier put at least one of these labels on it.
14594
+ *
14595
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14596
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14597
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14598
+ * is given** — a window in which every sample is trivially a hit would fire on
14599
+ * silence, so the engine refuses such a condition rather than notifying on
14600
+ * nothing (the schema cannot express "at least one of" without becoming a
14601
+ * ZodEffects the cap path would have to special-case).
14602
+ *
14603
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14604
+ * must be FULL before it can match — a window that has been open for two
14605
+ * seconds of its ten is 100% of nothing, and firing on it would make
14606
+ * `samplingSeconds` decorative.
14607
+ *
14608
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14609
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14610
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14611
+ * an operator who typed `dog` mean the same thing.
14612
+ */
14613
+ var NcAudioConditionSchema = object({
14614
+ /** Audio macro labels; absent = any sound (level-only rule). */
14615
+ labels: array(string().min(1)).min(1).optional(),
14616
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14617
+ dbThreshold: number().min(-96).max(0).optional(),
14618
+ /** Percentage of the window's samples that must be hits (1–100). */
14619
+ hitPercent: number().int().min(1).max(100).default(60),
14620
+ /** Length of the sampling window in seconds. */
14621
+ samplingSeconds: number().int().min(1).max(300).default(10)
14622
+ });
14623
+ /**
14491
14624
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14492
14625
  *
14493
14626
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14760,7 +14893,33 @@ var NcConditionsSchema = object({
14760
14893
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14761
14894
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14762
14895
  */
14763
- occupancy: NcOccupancyConditionSchema.optional()
14896
+ occupancy: NcOccupancyConditionSchema.optional(),
14897
+ /**
14898
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14899
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14900
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14901
+ * a window that is not full yet, neither filter given). See
14902
+ * {@link NcAudioCondition}.
14903
+ *
14904
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14905
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14906
+ * a detection, a track or a device event (the same fail-closed pairing
14907
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14908
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14909
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14910
+ * classified sample) stays exactly as it was for rules that already use it.
14911
+ *
14912
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14913
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14914
+ * (`camstack/src/data/notification-center.ts`, guarded by
14915
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14916
+ * condition fields it does not know when a rule is saved from the phone.
14917
+ * Publishing an editor for a condition the app cannot round-trip is how an
14918
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14919
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14920
+ * does an audio rule become authorable.
14921
+ */
14922
+ audio: NcAudioConditionSchema.optional()
14764
14923
  });
14765
14924
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14766
14925
  var NcRuleTargetSchema = object({
@@ -14874,6 +15033,73 @@ var NcThrottleSchema = object({
14874
15033
  */
14875
15034
  granularity: NcThrottleGranularitySchema.optional()
14876
15035
  });
15036
+ /**
15037
+ * How long the confirm gate may hold ONE notification, and how big the picture
15038
+ * it judges may be.
15039
+ *
15040
+ * The clamp is the product decision, not a coincidence of the model: p50 was
15041
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
15042
+ * arrives after the visitor has gone is not a notification. 448 px was enough
15043
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
15044
+ * tokens for pixels the model pools away.
15045
+ */
15046
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15047
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15048
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15049
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15050
+ var NcConfirmExpectSchema = object({
15051
+ op: _enum([
15052
+ ">=",
15053
+ ">",
15054
+ "<=",
15055
+ "<",
15056
+ "=="
15057
+ ]),
15058
+ count: number().int().min(0).max(1e3)
15059
+ });
15060
+ /**
15061
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15062
+ * to ship and says whether it agrees with the rule.
15063
+ *
15064
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15065
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15066
+ * on the operator's phone is not a verdict about this notification.
15067
+ *
15068
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15069
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15070
+ * the default and every fail-open is COUNTED, because a gate that always fails
15071
+ * open looks in the log exactly like a gate that works.
15072
+ *
15073
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15074
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15075
+ * production failures in one day), so the gate reads absent as the constant
15076
+ * above rather than trusting a parse it may never have seen.
15077
+ */
15078
+ var NcConfirmSchema = object({
15079
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15080
+ * same thing, and both mean "deliver exactly as before". */
15081
+ enabled: boolean().default(false),
15082
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15083
+ profileId: string().optional(),
15084
+ /**
15085
+ * The operator's question, in his own words. Absent = a question derived
15086
+ * from the rule (its class and its expectation).
15087
+ *
15088
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15089
+ * banners, signage and plates as instructions if you let them reach the
15090
+ * prompt — proven live — so the authoritative contract stays in the system
15091
+ * turn and only rule-authored words land here.
15092
+ */
15093
+ prompt: string().max(1e3).optional(),
15094
+ /** Fire only when the model's count satisfies this. Absent = the model's
15095
+ * own boolean verdict decides. */
15096
+ expect: NcConfirmExpectSchema.optional(),
15097
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15098
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15099
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15100
+ /** Longest edge the judged image is downscaled to before it is sent. */
15101
+ maxImagePx: number().int().min(64).max(2048).default(448)
15102
+ });
14877
15103
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14878
15104
  var NcRuleInputSchema = object({
14879
15105
  name: string().min(1).max(200),
@@ -14934,7 +15160,13 @@ var NcRuleInputSchema = object({
14934
15160
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14935
15161
  * shape as every other actuation.
14936
15162
  */
14937
- actions: NcRuleActionsSchema.optional()
15163
+ actions: NcRuleActionsSchema.optional(),
15164
+ /**
15165
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15166
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15167
+ * did, and absent is the only way to say that without a migration.
15168
+ */
15169
+ confirm: NcConfirmSchema.optional()
14938
15170
  });
14939
15171
  /**
14940
15172
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14945,7 +15177,37 @@ var NcRuleInputSchema = object({
14945
15177
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14946
15178
  * `updateRule` patch.
14947
15179
  */
14948
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15180
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15181
+ disabledTargetIds: array(string()).optional(),
15182
+ /**
15183
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15184
+ *
15185
+ * It makes the key optional to SUPPLY; the parse still materialises the
15186
+ * default when the key is absent. And `NcRuleStore.update` merges with
15187
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15188
+ * one — which made every partial edit destructive:
15189
+ *
15190
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15191
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15192
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15193
+ *
15194
+ * A rule scoped to one camera and one zone silently became a rule that
15195
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15196
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15197
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15198
+ * within a minute of a two-field patch.
15199
+ *
15200
+ * So every defaulted field is re-declared here WITHOUT its default. The
15201
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15202
+ * conditions remains a real instruction ("clear them") — and only the
15203
+ * absent key is now genuinely absent.
15204
+ */
15205
+ enabled: boolean().optional(),
15206
+ conditions: NcConditionsSchema.optional(),
15207
+ media: NcMediaPolicySchema.optional(),
15208
+ throttle: NcThrottleSchema.optional(),
15209
+ priority: number().int().min(1).max(5).optional()
15210
+ });
14949
15211
  /** A persisted rule. */
14950
15212
  var NcRuleSchema = NcRuleInputSchema.extend({
14951
15213
  id: string(),
@@ -15246,6 +15508,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15246
15508
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15247
15509
  * copy would lie the first time a rule is disabled.
15248
15510
  */
15511
+ /**
15512
+ * Why a device a mode NAMES is nonetheless not armed by it.
15513
+ *
15514
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15515
+ * per-camera notification switch the Notification Center already owns,
15516
+ * `detection-off` is the device's own detection binding being inactive, and
15517
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15518
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15519
+ * with the switches the operator actually used.
15520
+ */
15521
+ var NcAlarmSkipReasonSchema = _enum([
15522
+ "muted",
15523
+ "detection-off",
15524
+ "offline"
15525
+ ]);
15526
+ var NcAlarmSkippedDeviceSchema = object({
15527
+ deviceId: number().int(),
15528
+ reason: NcAlarmSkipReasonSchema
15529
+ });
15249
15530
  var NcAlarmModeCoverageSchema = object({
15250
15531
  mode: AlarmArmModeSchema,
15251
15532
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15253,7 +15534,18 @@ var NcAlarmModeCoverageSchema = object({
15253
15534
  /** At least one covering rule has no device scope, so the mode covers all. */
15254
15535
  allDevices: boolean(),
15255
15536
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15256
- deviceIds: array(number().int())
15537
+ deviceIds: array(number().int()),
15538
+ /**
15539
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15540
+ * excludes it.
15541
+ *
15542
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15543
+ * twelve makes it false in exactly the way nobody notices until an incident.
15544
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15545
+ * still parses as "nothing known to be skipped" rather than failing the whole
15546
+ * alarm tab.
15547
+ */
15548
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15257
15549
  });
15258
15550
  var NcAlarmConfigSchema = object({
15259
15551
  /**
@@ -18091,9 +18383,16 @@ var CameraStatusSchema = object({
18091
18383
  audio: CameraAudioStatusSchema.nullable(),
18092
18384
  recording: CameraRecordingStatusSchema.nullable(),
18093
18385
  /**
18094
- * Per-camera function switches an OPERATOR has turned off
18386
+ * Per-camera functions an OPERATOR has turned off
18095
18387
  * ([D61](../../../../docs/decisions/adr-0067.md)).
18096
18388
  *
18389
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
18390
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
18391
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
18392
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
18393
+ * The badge outlives the control panel: the panel was a convenience, this is
18394
+ * the difference between a camera being off and a camera being dead.
18395
+ *
18097
18396
  * This is the difference between DISABLED and BROKEN. A camera whose
18098
18397
  * `detection` block reports zero fps and whose `switchedOff` contains
18099
18398
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -24924,7 +25223,19 @@ var RecordingManifestSchema = object({
24924
25223
  * profiles/subtrees/locations on this node). */
24925
25224
  var RecordingDeviceUsageSchema = object({
24926
25225
  deviceId: number(),
24927
- usedBytes: number()
25226
+ usedBytes: number(),
25227
+ /**
25228
+ * Start of this camera's OLDEST indexed segment, across every profile and
25229
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25230
+ * only honest answer to "is retention actually holding?" per camera.
25231
+ *
25232
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25233
+ * predates this field omits it entirely, and a hub whose types carry the
25234
+ * field must keep validating that older provider's payload: the framework
25235
+ * (types) and the addon ship on different trains, and the addon is usually
25236
+ * the later of the two.
25237
+ */
25238
+ oldestMs: number().nullable().optional()
24928
25239
  });
24929
25240
  /** Recording storage usage + capacity for one storage location. */
24930
25241
  var RecordingLocationUsageSchema = object({
@@ -24952,6 +25263,57 @@ var RecordingStorageUsageSchema = object({
24952
25263
  locations: array(RecordingLocationUsageSchema)
24953
25264
  });
24954
25265
  /**
25266
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25267
+ *
25268
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25269
+ * is the operator asking for the EXISTING archive to be brought into line with
25270
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25271
+ * location, run FIFO behind the single-flight mover.
25272
+ *
25273
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25274
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25275
+ * (empty on the plan).
25276
+ */
25277
+ var RecordingRebalanceMoveSchema = object({
25278
+ deviceId: number(),
25279
+ profile: string(),
25280
+ fromLocationId: string(),
25281
+ toLocationId: string(),
25282
+ bytes: number(),
25283
+ files: number().int()
25284
+ });
25285
+ /** Why a pile that is out of place is staying there. Every refusal is
25286
+ * reported: a rebalance that silently drops a camera reads exactly like one
25287
+ * that had nothing to do. */
25288
+ var RecordingRebalanceSkipReasonSchema = _enum([
25289
+ "unassigned",
25290
+ "target-not-writable",
25291
+ "below-threshold",
25292
+ "no-headroom"
25293
+ ]);
25294
+ var RecordingRebalanceSkipSchema = object({
25295
+ deviceId: number(),
25296
+ profile: string(),
25297
+ fromLocationId: string(),
25298
+ /** The location the plan wants; null when the camera has no assignment. */
25299
+ toLocationId: string().nullable(),
25300
+ bytes: number(),
25301
+ reason: RecordingRebalanceSkipReasonSchema
25302
+ });
25303
+ var RecordingRebalancePlanSchema = object({
25304
+ moves: array(RecordingRebalanceMoveSchema),
25305
+ skipped: array(RecordingRebalanceSkipSchema),
25306
+ bytesToMove: number(),
25307
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25308
+ jobIds: array(string())
25309
+ });
25310
+ var RecordingRebalanceInputSchema = object({
25311
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25312
+ throttleMbps: number().min(1).max(1e3).optional(),
25313
+ /** Ignore piles smaller than this (default 1 GB). */
25314
+ minMoveGb: number().min(0).optional()
25315
+ });
25316
+ /**
24955
25317
  * Result of locating footage at a wall-clock instant for one device/profile.
24956
25318
  * `segment` carries the covering segment's window; `gap` reports the forward
24957
25319
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25114,9 +25476,24 @@ method(object({
25114
25476
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25115
25477
  kind: "mutation",
25116
25478
  auth: "admin"
25479
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
25480
+ kind: "mutation",
25481
+ auth: "admin"
25482
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
25483
+ kind: "query",
25484
+ auth: "admin"
25485
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25486
+ kind: "mutation",
25487
+ auth: "admin"
25488
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25489
+ kind: "query",
25490
+ auth: "admin"
25491
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
25492
+ kind: "mutation",
25493
+ auth: "admin"
25117
25494
  });
25118
25495
  /**
25119
- * `recordingExport` cap — render a footage time range into a single downloadable
25496
+ * `recording-export` cap — render a footage time range into a single downloadable
25120
25497
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
25121
25498
  * bounded lifetime with a durable history, auto-expiry, and optional
25122
25499
  * delete-after-download.
@@ -25131,10 +25508,53 @@ method(object({
25131
25508
  */
25132
25509
  /** Playback-speed multiplier for the render (1 = realtime). */
25133
25510
  var ExportSpeedSchema = number().min(.25).max(32);
25511
+ /**
25512
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25513
+ *
25514
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
25515
+ * derives these bounds from things that happened at a TIME (a track's
25516
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25517
+ * every segment present for the range, with each recording GAP removed. The
25518
+ * two agree only on a window that recorded without one interruption, and only
25519
+ * the render side knows the segments, so the translation lives there
25520
+ * (`export-dense-map.ts`, addon-pipeline).
25521
+ *
25522
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25523
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25524
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25525
+ * the video was a uniform timelapse, and the log line reported the five ranges
25526
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25527
+ *
25528
+ * Relative and not absolute epoch, because an absolute epoch would make every
25529
+ * call site responsible for the same subtraction.
25530
+ */
25531
+ var ExportDenseRangeSchema = object({
25532
+ fromSec: number().nonnegative(),
25533
+ toSec: number().nonnegative()
25534
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
25535
+ /**
25536
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
25537
+ * listed ranges and at the base `everyMs` everywhere else.
25538
+ *
25539
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
25540
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
25541
+ */
25542
+ var ExportDenseSchema = object({
25543
+ everyMs: number().int().positive(),
25544
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
25545
+ });
25134
25546
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
25135
25547
  var ExportTimelapseSchema = object({
25136
25548
  everyMs: number().int().positive(),
25137
- outputFps: number().int().min(1).max(60).optional()
25549
+ outputFps: number().int().min(1).max(60).optional(),
25550
+ /** Optional second, FASTER rate over the intervals that matter. */
25551
+ dense: ExportDenseSchema.optional()
25552
+ }).superRefine((v, ctx) => {
25553
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
25554
+ code: ZodIssueCode.custom,
25555
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
25556
+ path: ["dense", "everyMs"]
25557
+ });
25138
25558
  });
25139
25559
  /**
25140
25560
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25192,6 +25612,19 @@ var ExportDownloadSchema = object({
25192
25612
  url: string(),
25193
25613
  endpoints: array(string())
25194
25614
  });
25615
+ /**
25616
+ * A finished export's bytes, inline.
25617
+ *
25618
+ * `bytes` is the DECODED length — the number the caller bounds and logs
25619
+ * against, so nobody has to infer it from the base64 length.
25620
+ */
25621
+ var ExportBytesSchema = object({
25622
+ base64: string(),
25623
+ contentType: string(),
25624
+ /** Suggested filename, extension included. */
25625
+ name: string(),
25626
+ bytes: number().int().nonnegative()
25627
+ });
25195
25628
  method(object({
25196
25629
  deviceId: number(),
25197
25630
  profile: string(),
@@ -25216,6 +25649,9 @@ method(object({
25216
25649
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25217
25650
  kind: "query",
25218
25651
  auth: "protected"
25652
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
25653
+ kind: "query",
25654
+ auth: "protected"
25219
25655
  });
25220
25656
  /**
25221
25657
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -31893,6 +32329,12 @@ Object.freeze({
31893
32329
  addonId: null,
31894
32330
  access: "create"
31895
32331
  },
32332
+ "recording.cancelRelocateJob": {
32333
+ capName: "recording",
32334
+ capScope: "system",
32335
+ addonId: null,
32336
+ access: "create"
32337
+ },
31896
32338
  "recording.cancelStorageMigrationMove": {
31897
32339
  capName: "recording",
31898
32340
  capScope: "system",
@@ -31947,6 +32389,12 @@ Object.freeze({
31947
32389
  addonId: null,
31948
32390
  access: "view"
31949
32391
  },
32392
+ "recording.listRelocateJobs": {
32393
+ capName: "recording",
32394
+ capScope: "system",
32395
+ addonId: null,
32396
+ access: "view"
32397
+ },
31950
32398
  "recording.locateSegment": {
31951
32399
  capName: "recording",
31952
32400
  capScope: "system",
@@ -31959,6 +32407,12 @@ Object.freeze({
31959
32407
  addonId: null,
31960
32408
  access: "create"
31961
32409
  },
32410
+ "recording.planStorageRebalance": {
32411
+ capName: "recording",
32412
+ capScope: "system",
32413
+ addonId: null,
32414
+ access: "view"
32415
+ },
31962
32416
  "recording.pruneFootage": {
31963
32417
  capName: "recording",
31964
32418
  capScope: "system",
@@ -31983,6 +32437,12 @@ Object.freeze({
31983
32437
  addonId: null,
31984
32438
  access: "create"
31985
32439
  },
32440
+ "recording.relocateFootage": {
32441
+ capName: "recording",
32442
+ capScope: "system",
32443
+ addonId: null,
32444
+ access: "create"
32445
+ },
31986
32446
  "recording.renderClip": {
31987
32447
  capName: "recording",
31988
32448
  capScope: "system",
@@ -32019,38 +32479,50 @@ Object.freeze({
32019
32479
  addonId: null,
32020
32480
  access: "create"
32021
32481
  },
32482
+ "recording.startStorageRebalance": {
32483
+ capName: "recording",
32484
+ capScope: "system",
32485
+ addonId: null,
32486
+ access: "create"
32487
+ },
32022
32488
  "recordingExport.cancelExport": {
32023
- capName: "recordingExport",
32489
+ capName: "recording-export",
32024
32490
  capScope: "system",
32025
32491
  addonId: null,
32026
32492
  access: "create"
32027
32493
  },
32028
32494
  "recordingExport.createExport": {
32029
- capName: "recordingExport",
32495
+ capName: "recording-export",
32030
32496
  capScope: "system",
32031
32497
  addonId: null,
32032
32498
  access: "create"
32033
32499
  },
32034
32500
  "recordingExport.deleteExport": {
32035
- capName: "recordingExport",
32501
+ capName: "recording-export",
32036
32502
  capScope: "system",
32037
32503
  addonId: null,
32038
32504
  access: "delete"
32039
32505
  },
32040
32506
  "recordingExport.getDownloadUrl": {
32041
- capName: "recordingExport",
32507
+ capName: "recording-export",
32042
32508
  capScope: "system",
32043
32509
  addonId: null,
32044
32510
  access: "view"
32045
32511
  },
32046
32512
  "recordingExport.getExport": {
32047
- capName: "recordingExport",
32513
+ capName: "recording-export",
32048
32514
  capScope: "system",
32049
32515
  addonId: null,
32050
32516
  access: "view"
32051
32517
  },
32052
32518
  "recordingExport.listExports": {
32053
- capName: "recordingExport",
32519
+ capName: "recording-export",
32520
+ capScope: "system",
32521
+ addonId: null,
32522
+ access: "view"
32523
+ },
32524
+ "recordingExport.readExportBytes": {
32525
+ capName: "recording-export",
32054
32526
  capScope: "system",
32055
32527
  addonId: null,
32056
32528
  access: "view"
@@ -33634,6 +34106,104 @@ var FramerateField = number().int().min(1).max(60);
33634
34106
  var TargetsField = array(NcRuleTargetSchema).min(1);
33635
34107
  var PriorityField = number().int().min(1).max(5);
33636
34108
  /**
34109
+ * Explicit override of the DENSE sampling cadence, seconds.
34110
+ *
34111
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34112
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34113
+ * made that same base 3 s and rendered a person pass as two frames.)
34114
+ *
34115
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34116
+ * `denseCadenceSec` and played at `framerate` occupies
34117
+ *
34118
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34119
+ *
34120
+ * 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.
34121
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34122
+ * and therefore the length of a quiet night, does not move.
34123
+ *
34124
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34125
+ * the recording has them returns the same frames, requested twice. Must be
34126
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34127
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34128
+ * rather than letting the export cap reject the render hours after the window.
34129
+ */
34130
+ var DenseCadenceSecField = number().min(.1).max(3600);
34131
+ /**
34132
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34133
+ *
34134
+ * The operator-facing form of the arithmetic above: instead of solving for a
34135
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34136
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34137
+ * that range every ~583 ms.
34138
+ *
34139
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34140
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34141
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34142
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34143
+ * schema change and are the tracked follow-up.
34144
+ *
34145
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34146
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34147
+ * by real footage, never met by duplicating frames into motion that never
34148
+ * happened.
34149
+ */
34150
+ var MinDwellSecField = number().min(0).max(60);
34151
+ /**
34152
+ * Caption burned into the notification's preview frame.
34153
+ *
34154
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34155
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34156
+ * templating dialect for one field would be a second thing to explain.
34157
+ *
34158
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34159
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34160
+ * the reason this is not `.min(1)`.
34161
+ */
34162
+ var PreviewTextField = string().max(200);
34163
+ /**
34164
+ * Whether the notification's preview is a STILL or a short animation.
34165
+ *
34166
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34167
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34168
+ * night reads better as three seconds of motion than as one frame of it. Both
34169
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34170
+ * simply applies it to a dozen frames sampled across the render and assembles
34171
+ * them.
34172
+ *
34173
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34174
+ * seeks and a palette pass, and no rule that never asked for one should start
34175
+ * paying that on the deploy that shipped it.
34176
+ *
34177
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34178
+ */
34179
+ var PreviewModeField = _enum(["image", "gif"]);
34180
+ /**
34181
+ * Which detection classes the notification reports counts for.
34182
+ *
34183
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34184
+ * plan — no second query — aggregated per class. Absent or empty means "every
34185
+ * class the window actually contained", which is what an operator who never
34186
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34187
+ * counts cars all night).
34188
+ *
34189
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34190
+ * …). An unknown name simply never matches and reports nothing — it is not an
34191
+ * error, because a rule may legitimately name a class this camera's model does
34192
+ * not emit.
34193
+ *
34194
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34195
+ * - `{{detections}}` — total over the reported classes
34196
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34197
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34198
+ * one per class, `count_` + the class name
34199
+ *
34200
+ * With NO custom body template the summary is appended to the derived body, and
34201
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34202
+ * reads. With a custom template the operator owns every word — nothing is
34203
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34204
+ */
34205
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34206
+ /**
33637
34207
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
33638
34208
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
33639
34209
  * here (see the ownership note above).
@@ -33653,9 +34223,30 @@ var TimelapseRuleInputSchema = object({
33653
34223
  cadenceSec: CadenceSecField.default(15),
33654
34224
  /** Output frames per second of the assembled mp4 (predecessor parity). */
33655
34225
  framerate: FramerateField.default(10),
34226
+ /**
34227
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34228
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34229
+ * field gets.
34230
+ */
34231
+ denseCadenceSec: DenseCadenceSecField.optional(),
34232
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
34233
+ minDwellSec: MinDwellSecField.optional(),
33656
34234
  /** `notification-output` targets the finished video/thumbnail is sent to. */
33657
34235
  targets: TargetsField,
33658
34236
  template: TimelapseTemplateSchema.optional(),
34237
+ /**
34238
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
34239
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
34240
+ *
34241
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
34242
+ * the notification's title/body, and clearing it (`template: null`) must not
34243
+ * silently clear the caption too.
34244
+ */
34245
+ previewText: PreviewTextField.optional(),
34246
+ /** Still or animation — see {@link PreviewModeField}. */
34247
+ previewMode: PreviewModeField.default("image"),
34248
+ /** Classes the notification counts — see {@link ReportClassesField}. */
34249
+ reportClasses: ReportClassesField.optional(),
33659
34250
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
33660
34251
  priority: PriorityField.default(3)
33661
34252
  });
@@ -33666,8 +34257,13 @@ object({
33666
34257
  schedule: NcScheduleSchema.optional(),
33667
34258
  cadenceSec: CadenceSecField.optional(),
33668
34259
  framerate: FramerateField.optional(),
34260
+ denseCadenceSec: DenseCadenceSecField.optional(),
34261
+ minDwellSec: MinDwellSecField.optional(),
33669
34262
  targets: TargetsField.optional(),
33670
34263
  template: TimelapseTemplateSchema.nullable().optional(),
34264
+ previewText: PreviewTextField.optional(),
34265
+ previewMode: PreviewModeField.optional(),
34266
+ reportClasses: ReportClassesField.optional(),
33671
34267
  priority: PriorityField.optional()
33672
34268
  });
33673
34269
  TimelapseRuleInputSchema.extend({
@@ -33679,10 +34275,28 @@ TimelapseRuleInputSchema.extend({
33679
34275
  */
33680
34276
  ownerUserId: string().optional(),
33681
34277
  /**
33682
- * Epoch-ms of the last successful generation the 1-hour re-generation
33683
- * guard's durable state (predecessor parity). Absent = never generated.
34278
+ * Epoch-ms of the NEWEST successful generation across every camera of this
34279
+ * rule. What a UI shows, and the compatibility floor for
34280
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
33684
34281
  */
33685
34282
  lastGeneratedAt: number().optional(),
34283
+ /**
34284
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
34285
+ * re-generation guard's real durable state.
34286
+ *
34287
+ * One rule covers several cameras and each renders its own video, so a rule
34288
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
34289
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
34290
+ * already done — and B's night is gone for good, because the window will not
34291
+ * come back.
34292
+ *
34293
+ * ADDITIVE, so the migration is free: a row written before this field simply
34294
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
34295
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
34296
+ * "never generated" would re-render and re-notify every camera of every rule
34297
+ * once, on the deploy that shipped the map.
34298
+ */
34299
+ generatedByDevice: record(string(), number()).optional(),
33686
34300
  /** userId of the caller who created the rule (server-stamped). */
33687
34301
  createdBy: string(),
33688
34302
  createdAt: number(),
@@ -33733,25 +34347,32 @@ object({
33733
34347
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33734
34348
  object({
33735
34349
  /**
33736
- * How long a retained native frame is served before it counts as a miss.
34350
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34351
+ * detection result.
34352
+ *
34353
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34354
+ * a time window was never related to the event the pixels were waiting for.
34355
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34356
+ * — at which moment the runner cuts the subject tiles it actually wanted and
34357
+ * releases the frame. The bound exists only so a runner that stops answering
34358
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33737
34359
  *
33738
- * Must cover the FULL late-crop horizon: detection inference + the
33739
- * cross-process inference-result hop to hub post-analysis + tracking + the
33740
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33741
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33742
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34360
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34361
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34362
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34363
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
34364
+ * `holdOverflow` on the metrics line is what says you need it.
33743
34365
  */
33744
- ttlMs: number().int().min(250).max(1e4),
34366
+ holdFrames: number().int().min(1).max(64),
33745
34367
  /**
33746
34368
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33747
34369
  *
33748
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33749
- * which one is actually binding before reasoning from that. At the shipped
33750
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33751
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33752
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33753
- * change that admits fewer frames buys retention WINDOW at constant RAM
33754
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34370
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34371
+ * is what decides how much is held, and the ceiling is the number above which
34372
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34373
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34374
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34375
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33755
34376
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33756
34377
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33757
34378
  * to replace).
@@ -33777,22 +34398,45 @@ object({
33777
34398
  * there is the signal that some caller names frames outside the inference set
33778
34399
  * and that this must go back to `all`.
33779
34400
  */
33780
- admission: NativeLeaseAdmissionSchema
34401
+ admission: NativeLeaseAdmissionSchema,
34402
+ /**
34403
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34404
+ * compressed native crops the worker cuts at the moment a frame's detection
34405
+ * result arrives, and keeps long after the frame itself is freed.
34406
+ *
34407
+ * This is the knob that replaced the old retention window, and it buys about
34408
+ * three orders of magnitude more of it: a tile is one subject at native
34409
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34410
+ * the frame it was cut from. A frame on which nothing was detected costs
34411
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34412
+ * was interrogated per SUBJECT.
34413
+ *
34414
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34415
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34416
+ * reproduce that.
34417
+ */
34418
+ tileBudgetMb: number().int().min(0).max(1024)
33781
34419
  });
33782
34420
  /**
33783
- * The values in force when the operator has set nothing — byte-for-byte the
33784
- * constants the decode worker shipped with as env-var defaults, so making these
33785
- * settings changed no behaviour on the day it landed.
34421
+ * The values in force when the operator has set nothing.
34422
+ *
34423
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34424
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34425
+ * in the same change that redefines it would make a regression and a retune
34426
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34427
+ * live traffic.
33786
34428
  */
33787
34429
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33788
- ttlMs: 1200,
34430
+ holdFrames: 8,
33789
34431
  budgetMb: 1024,
33790
34432
  activityMs: 15e3,
34433
+ tileBudgetMb: 64,
33791
34434
  admission: "inferred"
33792
34435
  };
33793
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34436
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33794
34437
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33795
34438
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34439
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33796
34440
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33797
34441
  /**
33798
34442
  * Pure fuzzy matcher for adoption location import. Normalized