@camstack/addon-mqtt-broker 1.2.13 → 1.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.
@@ -7229,8 +7229,31 @@ var AdoptionJobSchema = object({
7229
7229
  error: string().nullable()
7230
7230
  });
7231
7231
  /**
7232
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7233
- * pipeline functions an operator thinks in terms of.
7232
+ * Per-camera FUNCTION SWITCHES.
7233
+ *
7234
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7235
+ *
7236
+ * This file shipped as "the one coherent on/off surface over the pipeline
7237
+ * functions an operator thinks in terms of". The operator's verdict on
7238
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7239
+ * every function already had a settings page of its own, and a second place to
7240
+ * turn it off is a second place to look. Each switch is going back to its own
7241
+ * component's original options — detection to the detection-pipeline wrapper
7242
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7243
+ * (which was always first-class; the switch was a veneer over
7244
+ * `recording.setDeviceConfig`), notifications to a notification-center
7245
+ * per-device setting, the two camera planes to their own components.
7246
+ *
7247
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7248
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7249
+ * straight from the authorities with no group in the middle. That rule was
7250
+ * never about a control panel.
7251
+ *
7252
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7253
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7254
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7255
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7256
+ * stop; nothing new may be built on it.
7234
7257
  *
7235
7258
  * ## This file adds no state
7236
7259
  *
@@ -7581,7 +7604,15 @@ var RecordingConfigSchema = object({
7581
7604
  * Each completed/failed run also lands one durable ops-log row on its owning
7582
7605
  * addon surface.
7583
7606
  */
7607
+ /**
7608
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7609
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7610
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7611
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7612
+ * runs at all.
7613
+ */
7584
7614
  var RelocateJobStateSchema = _enum([
7615
+ "queued",
7585
7616
  "running",
7586
7617
  "done",
7587
7618
  "failed",
@@ -7616,6 +7647,15 @@ var RelocateFootageInputSchema = object({
7616
7647
  /** Limits relocation to the logical profile class. Omit only for the
7617
7648
  * pre-orchestration compatibility path. */
7618
7649
  footageClass: RelocateFootageClassSchema.optional(),
7650
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7651
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7652
+ * unit is a (camera, profile) pile, not a disk. */
7653
+ deviceId: number().int().optional(),
7654
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7655
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7656
+ * placement plan assigns those two independently, so a rebalance that could
7657
+ * only say "recordings" would move footage the plan never asked to move. */
7658
+ profiles: array(string()).optional(),
7619
7659
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7620
7660
  * never allowed to starve live writers. */
7621
7661
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7751,6 +7791,21 @@ var StorageLocationSchema = object({
7751
7791
  nodeId: string().optional(),
7752
7792
  isDefault: boolean().default(false),
7753
7793
  isSystem: boolean().default(false),
7794
+ /**
7795
+ * Operator opt-in: whether consumers that BALANCE across several locations
7796
+ * of a type may write here. Recordings reads it today; event media and
7797
+ * backups are the next consumers, which is why the flag lives on the
7798
+ * location rather than in any one addon's store — nothing has to be
7799
+ * extended to add the next consumer.
7800
+ *
7801
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7802
+ * flag existed reads back with no flag and keeps working exactly as before;
7803
+ * that is the whole compat story, and it is why no migration ships with it.
7804
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7805
+ * disk must not silently start writing to it); the default of a type is
7806
+ * always stamped `true`.
7807
+ */
7808
+ enabled: boolean().optional(),
7754
7809
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7755
7810
  * for node-local locations it can reach) — never persisted, absent when the
7756
7811
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12102,7 +12157,8 @@ method(object({
12102
12157
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12103
12158
  /**
12104
12159
  * filesystem-browse — per-node capability for browsing the node's local
12105
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12160
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12161
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12106
12162
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12107
12163
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12108
12164
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13934,6 +13990,13 @@ var MaskGridDimsSchema = object({
13934
13990
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13935
13991
  * this one field keeps the schema additive — a rule still declares exactly
13936
13992
  * one trigger.
13993
+ *
13994
+ * AUDIO rules add no member here, for the reason occupancy added none: the
13995
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
13996
+ * mirror.ts` fails the build on a member the app cannot render) and every
13997
+ * member costs a release train. A sustained-sound rule is therefore an
13998
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
13999
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13937
14000
  */
13938
14001
  var NcDeliverySchema = _enum([
13939
14002
  "immediate",
@@ -13948,15 +14011,32 @@ var NcDeliverySchema = _enum([
13948
14011
  * depend on a provider's raw event name or payload shape.
13949
14012
  */
13950
14013
  var NcSystemEventKindSchema = _enum([
13951
- "camera-online",
13952
- "camera-offline",
14014
+ "device-online",
14015
+ "device-offline",
14016
+ "device-disabled",
14017
+ "device-enabled",
13953
14018
  "stream-online",
13954
14019
  "stream-offline",
13955
14020
  "node-online",
13956
14021
  "node-offline",
13957
14022
  "addon-update-available",
13958
- "server-update-available"
14023
+ "server-update-available",
14024
+ "alarm-triggered",
14025
+ "alarm-armed",
14026
+ "alarm-disarmed",
14027
+ "camera-online",
14028
+ "camera-offline",
14029
+ "camera-disabled",
14030
+ "camera-enabled"
14031
+ ]);
14032
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14033
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14034
+ "camera-online",
14035
+ "camera-offline",
14036
+ "camera-disabled",
14037
+ "camera-enabled"
13959
14038
  ]);
14039
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13960
14040
  /**
13961
14041
  * One coherent system-event condition. `kinds` is the required opt-in safety
13962
14042
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -13965,6 +14045,18 @@ var NcSystemEventKindSchema = _enum([
13965
14045
  var NcSystemEventConditionSchema = object({
13966
14046
  kinds: array(NcSystemEventKindSchema).min(1),
13967
14047
  deviceIds: array(number().int()).min(1).optional(),
14048
+ /**
14049
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14050
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14051
+ * is what a liveness rule means when nobody said otherwise.
14052
+ *
14053
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14054
+ * one reason: the intake cannot know which devices this household cares
14055
+ * about, and a producer-side filter is one no operator can change. Fails
14056
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14057
+ * does not carry) matches no `deviceTypes` list.
14058
+ */
14059
+ deviceTypes: array(string().min(1)).min(1).optional(),
13968
14060
  nodeIds: array(string().min(1)).min(1).optional(),
13969
14061
  packageNames: array(string().min(1)).min(1).optional()
13970
14062
  });
@@ -14015,6 +14107,47 @@ var NcOccupancyConditionSchema = object({
14015
14107
  sustainSeconds: number().int().min(0).max(3600).default(15)
14016
14108
  });
14017
14109
  /**
14110
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14111
+ *
14112
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14113
+ * reference notifier uses, so an operator moving between them re-uses what
14114
+ * they already know): a rule matches when, over a sampling window of
14115
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14116
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14117
+ *
14118
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14119
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14120
+ * - `labels` — the classifier put at least one of these labels on it.
14121
+ *
14122
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14123
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14124
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14125
+ * is given** — a window in which every sample is trivially a hit would fire on
14126
+ * silence, so the engine refuses such a condition rather than notifying on
14127
+ * nothing (the schema cannot express "at least one of" without becoming a
14128
+ * ZodEffects the cap path would have to special-case).
14129
+ *
14130
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14131
+ * must be FULL before it can match — a window that has been open for two
14132
+ * seconds of its ten is 100% of nothing, and firing on it would make
14133
+ * `samplingSeconds` decorative.
14134
+ *
14135
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14136
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14137
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14138
+ * an operator who typed `dog` mean the same thing.
14139
+ */
14140
+ var NcAudioConditionSchema = object({
14141
+ /** Audio macro labels; absent = any sound (level-only rule). */
14142
+ labels: array(string().min(1)).min(1).optional(),
14143
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14144
+ dbThreshold: number().min(-96).max(0).optional(),
14145
+ /** Percentage of the window's samples that must be hits (1–100). */
14146
+ hitPercent: number().int().min(1).max(100).default(60),
14147
+ /** Length of the sampling window in seconds. */
14148
+ samplingSeconds: number().int().min(1).max(300).default(10)
14149
+ });
14150
+ /**
14018
14151
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14019
14152
  *
14020
14153
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14287,7 +14420,33 @@ var NcConditionsSchema = object({
14287
14420
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14288
14421
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14289
14422
  */
14290
- occupancy: NcOccupancyConditionSchema.optional()
14423
+ occupancy: NcOccupancyConditionSchema.optional(),
14424
+ /**
14425
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14426
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14427
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14428
+ * a window that is not full yet, neither filter given). See
14429
+ * {@link NcAudioCondition}.
14430
+ *
14431
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14432
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14433
+ * a detection, a track or a device event (the same fail-closed pairing
14434
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14435
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14436
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14437
+ * classified sample) stays exactly as it was for rules that already use it.
14438
+ *
14439
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14440
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14441
+ * (`camstack/src/data/notification-center.ts`, guarded by
14442
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14443
+ * condition fields it does not know when a rule is saved from the phone.
14444
+ * Publishing an editor for a condition the app cannot round-trip is how an
14445
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14446
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14447
+ * does an audio rule become authorable.
14448
+ */
14449
+ audio: NcAudioConditionSchema.optional()
14291
14450
  });
14292
14451
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14293
14452
  var NcRuleTargetSchema = object({
@@ -14401,6 +14560,73 @@ var NcThrottleSchema = object({
14401
14560
  */
14402
14561
  granularity: NcThrottleGranularitySchema.optional()
14403
14562
  });
14563
+ /**
14564
+ * How long the confirm gate may hold ONE notification, and how big the picture
14565
+ * it judges may be.
14566
+ *
14567
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14568
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14569
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14570
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14571
+ * tokens for pixels the model pools away.
14572
+ */
14573
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14574
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14575
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14576
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14577
+ var NcConfirmExpectSchema = object({
14578
+ op: _enum([
14579
+ ">=",
14580
+ ">",
14581
+ "<=",
14582
+ "<",
14583
+ "=="
14584
+ ]),
14585
+ count: number().int().min(0).max(1e3)
14586
+ });
14587
+ /**
14588
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14589
+ * to ship and says whether it agrees with the rule.
14590
+ *
14591
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14592
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14593
+ * on the operator's phone is not a verdict about this notification.
14594
+ *
14595
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14596
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14597
+ * the default and every fail-open is COUNTED, because a gate that always fails
14598
+ * open looks in the log exactly like a gate that works.
14599
+ *
14600
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14601
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14602
+ * production failures in one day), so the gate reads absent as the constant
14603
+ * above rather than trusting a parse it may never have seen.
14604
+ */
14605
+ var NcConfirmSchema = object({
14606
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14607
+ * same thing, and both mean "deliver exactly as before". */
14608
+ enabled: boolean().default(false),
14609
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14610
+ profileId: string().optional(),
14611
+ /**
14612
+ * The operator's question, in his own words. Absent = a question derived
14613
+ * from the rule (its class and its expectation).
14614
+ *
14615
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14616
+ * banners, signage and plates as instructions if you let them reach the
14617
+ * prompt — proven live — so the authoritative contract stays in the system
14618
+ * turn and only rule-authored words land here.
14619
+ */
14620
+ prompt: string().max(1e3).optional(),
14621
+ /** Fire only when the model's count satisfies this. Absent = the model's
14622
+ * own boolean verdict decides. */
14623
+ expect: NcConfirmExpectSchema.optional(),
14624
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14625
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14626
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14627
+ /** Longest edge the judged image is downscaled to before it is sent. */
14628
+ maxImagePx: number().int().min(64).max(2048).default(448)
14629
+ });
14404
14630
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14405
14631
  var NcRuleInputSchema = object({
14406
14632
  name: string().min(1).max(200),
@@ -14461,7 +14687,13 @@ var NcRuleInputSchema = object({
14461
14687
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14462
14688
  * shape as every other actuation.
14463
14689
  */
14464
- actions: NcRuleActionsSchema.optional()
14690
+ actions: NcRuleActionsSchema.optional(),
14691
+ /**
14692
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14693
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14694
+ * did, and absent is the only way to say that without a migration.
14695
+ */
14696
+ confirm: NcConfirmSchema.optional()
14465
14697
  });
14466
14698
  /**
14467
14699
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14472,7 +14704,37 @@ var NcRuleInputSchema = object({
14472
14704
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14473
14705
  * `updateRule` patch.
14474
14706
  */
14475
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14707
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14708
+ disabledTargetIds: array(string()).optional(),
14709
+ /**
14710
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14711
+ *
14712
+ * It makes the key optional to SUPPLY; the parse still materialises the
14713
+ * default when the key is absent. And `NcRuleStore.update` merges with
14714
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14715
+ * one — which made every partial edit destructive:
14716
+ *
14717
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14718
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14719
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14720
+ *
14721
+ * A rule scoped to one camera and one zone silently became a rule that
14722
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14723
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14724
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14725
+ * within a minute of a two-field patch.
14726
+ *
14727
+ * So every defaulted field is re-declared here WITHOUT its default. The
14728
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14729
+ * conditions remains a real instruction ("clear them") — and only the
14730
+ * absent key is now genuinely absent.
14731
+ */
14732
+ enabled: boolean().optional(),
14733
+ conditions: NcConditionsSchema.optional(),
14734
+ media: NcMediaPolicySchema.optional(),
14735
+ throttle: NcThrottleSchema.optional(),
14736
+ priority: number().int().min(1).max(5).optional()
14737
+ });
14476
14738
  /** A persisted rule. */
14477
14739
  var NcRuleSchema = NcRuleInputSchema.extend({
14478
14740
  id: string(),
@@ -14773,6 +15035,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14773
15035
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14774
15036
  * copy would lie the first time a rule is disabled.
14775
15037
  */
15038
+ /**
15039
+ * Why a device a mode NAMES is nonetheless not armed by it.
15040
+ *
15041
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15042
+ * per-camera notification switch the Notification Center already owns,
15043
+ * `detection-off` is the device's own detection binding being inactive, and
15044
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15045
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15046
+ * with the switches the operator actually used.
15047
+ */
15048
+ var NcAlarmSkipReasonSchema = _enum([
15049
+ "muted",
15050
+ "detection-off",
15051
+ "offline"
15052
+ ]);
15053
+ var NcAlarmSkippedDeviceSchema = object({
15054
+ deviceId: number().int(),
15055
+ reason: NcAlarmSkipReasonSchema
15056
+ });
14776
15057
  var NcAlarmModeCoverageSchema = object({
14777
15058
  mode: AlarmArmModeSchema,
14778
15059
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14780,7 +15061,18 @@ var NcAlarmModeCoverageSchema = object({
14780
15061
  /** At least one covering rule has no device scope, so the mode covers all. */
14781
15062
  allDevices: boolean(),
14782
15063
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14783
- deviceIds: array(number().int())
15064
+ deviceIds: array(number().int()),
15065
+ /**
15066
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15067
+ * excludes it.
15068
+ *
15069
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15070
+ * twelve makes it false in exactly the way nobody notices until an incident.
15071
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15072
+ * still parses as "nothing known to be skipped" rather than failing the whole
15073
+ * alarm tab.
15074
+ */
15075
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14784
15076
  });
14785
15077
  var NcAlarmConfigSchema = object({
14786
15078
  /**
@@ -17579,9 +17871,16 @@ var CameraStatusSchema = object({
17579
17871
  audio: CameraAudioStatusSchema.nullable(),
17580
17872
  recording: CameraRecordingStatusSchema.nullable(),
17581
17873
  /**
17582
- * Per-camera function switches an OPERATOR has turned off
17874
+ * Per-camera functions an OPERATOR has turned off
17583
17875
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17584
17876
  *
17877
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17878
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17879
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17880
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17881
+ * The badge outlives the control panel: the panel was a convenience, this is
17882
+ * the difference between a camera being off and a camera being dead.
17883
+ *
17585
17884
  * This is the difference between DISABLED and BROKEN. A camera whose
17586
17885
  * `detection` block reports zero fps and whose `switchedOff` contains
17587
17886
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23090,7 +23389,19 @@ var RecordingManifestSchema = object({
23090
23389
  * profiles/subtrees/locations on this node). */
23091
23390
  var RecordingDeviceUsageSchema = object({
23092
23391
  deviceId: number(),
23093
- usedBytes: number()
23392
+ usedBytes: number(),
23393
+ /**
23394
+ * Start of this camera's OLDEST indexed segment, across every profile and
23395
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23396
+ * only honest answer to "is retention actually holding?" per camera.
23397
+ *
23398
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23399
+ * predates this field omits it entirely, and a hub whose types carry the
23400
+ * field must keep validating that older provider's payload: the framework
23401
+ * (types) and the addon ship on different trains, and the addon is usually
23402
+ * the later of the two.
23403
+ */
23404
+ oldestMs: number().nullable().optional()
23094
23405
  });
23095
23406
  /** Recording storage usage + capacity for one storage location. */
23096
23407
  var RecordingLocationUsageSchema = object({
@@ -23118,6 +23429,57 @@ var RecordingStorageUsageSchema = object({
23118
23429
  locations: array(RecordingLocationUsageSchema)
23119
23430
  });
23120
23431
  /**
23432
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23433
+ *
23434
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23435
+ * is the operator asking for the EXISTING archive to be brought into line with
23436
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23437
+ * location, run FIFO behind the single-flight mover.
23438
+ *
23439
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23440
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23441
+ * (empty on the plan).
23442
+ */
23443
+ var RecordingRebalanceMoveSchema = object({
23444
+ deviceId: number(),
23445
+ profile: string(),
23446
+ fromLocationId: string(),
23447
+ toLocationId: string(),
23448
+ bytes: number(),
23449
+ files: number().int()
23450
+ });
23451
+ /** Why a pile that is out of place is staying there. Every refusal is
23452
+ * reported: a rebalance that silently drops a camera reads exactly like one
23453
+ * that had nothing to do. */
23454
+ var RecordingRebalanceSkipReasonSchema = _enum([
23455
+ "unassigned",
23456
+ "target-not-writable",
23457
+ "below-threshold",
23458
+ "no-headroom"
23459
+ ]);
23460
+ var RecordingRebalanceSkipSchema = object({
23461
+ deviceId: number(),
23462
+ profile: string(),
23463
+ fromLocationId: string(),
23464
+ /** The location the plan wants; null when the camera has no assignment. */
23465
+ toLocationId: string().nullable(),
23466
+ bytes: number(),
23467
+ reason: RecordingRebalanceSkipReasonSchema
23468
+ });
23469
+ var RecordingRebalancePlanSchema = object({
23470
+ moves: array(RecordingRebalanceMoveSchema),
23471
+ skipped: array(RecordingRebalanceSkipSchema),
23472
+ bytesToMove: number(),
23473
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23474
+ jobIds: array(string())
23475
+ });
23476
+ var RecordingRebalanceInputSchema = object({
23477
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23478
+ throttleMbps: number().min(1).max(1e3).optional(),
23479
+ /** Ignore piles smaller than this (default 1 GB). */
23480
+ minMoveGb: number().min(0).optional()
23481
+ });
23482
+ /**
23121
23483
  * Result of locating footage at a wall-clock instant for one device/profile.
23122
23484
  * `segment` carries the covering segment's window; `gap` reports the forward
23123
23485
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23280,9 +23642,24 @@ method(object({
23280
23642
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23281
23643
  kind: "mutation",
23282
23644
  auth: "admin"
23645
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23646
+ kind: "mutation",
23647
+ auth: "admin"
23648
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23649
+ kind: "query",
23650
+ auth: "admin"
23651
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23652
+ kind: "mutation",
23653
+ auth: "admin"
23654
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23655
+ kind: "query",
23656
+ auth: "admin"
23657
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23658
+ kind: "mutation",
23659
+ auth: "admin"
23283
23660
  });
23284
23661
  /**
23285
- * `recordingExport` cap — render a footage time range into a single downloadable
23662
+ * `recording-export` cap — render a footage time range into a single downloadable
23286
23663
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23287
23664
  * bounded lifetime with a durable history, auto-expiry, and optional
23288
23665
  * delete-after-download.
@@ -23297,10 +23674,53 @@ method(object({
23297
23674
  */
23298
23675
  /** Playback-speed multiplier for the render (1 = realtime). */
23299
23676
  var ExportSpeedSchema = number().min(.25).max(32);
23677
+ /**
23678
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23679
+ *
23680
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23681
+ * derives these bounds from things that happened at a TIME (a track's
23682
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23683
+ * every segment present for the range, with each recording GAP removed. The
23684
+ * two agree only on a window that recorded without one interruption, and only
23685
+ * the render side knows the segments, so the translation lives there
23686
+ * (`export-dense-map.ts`, addon-pipeline).
23687
+ *
23688
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23689
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23690
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23691
+ * the video was a uniform timelapse, and the log line reported the five ranges
23692
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23693
+ *
23694
+ * Relative and not absolute epoch, because an absolute epoch would make every
23695
+ * call site responsible for the same subtraction.
23696
+ */
23697
+ var ExportDenseRangeSchema = object({
23698
+ fromSec: number().nonnegative(),
23699
+ toSec: number().nonnegative()
23700
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23701
+ /**
23702
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23703
+ * listed ranges and at the base `everyMs` everywhere else.
23704
+ *
23705
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23706
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23707
+ */
23708
+ var ExportDenseSchema = object({
23709
+ everyMs: number().int().positive(),
23710
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23711
+ });
23300
23712
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23301
23713
  var ExportTimelapseSchema = object({
23302
23714
  everyMs: number().int().positive(),
23303
- outputFps: number().int().min(1).max(60).optional()
23715
+ outputFps: number().int().min(1).max(60).optional(),
23716
+ /** Optional second, FASTER rate over the intervals that matter. */
23717
+ dense: ExportDenseSchema.optional()
23718
+ }).superRefine((v, ctx) => {
23719
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23720
+ code: ZodIssueCode.custom,
23721
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23722
+ path: ["dense", "everyMs"]
23723
+ });
23304
23724
  });
23305
23725
  /**
23306
23726
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23358,6 +23778,19 @@ var ExportDownloadSchema = object({
23358
23778
  url: string(),
23359
23779
  endpoints: array(string())
23360
23780
  });
23781
+ /**
23782
+ * A finished export's bytes, inline.
23783
+ *
23784
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23785
+ * against, so nobody has to infer it from the base64 length.
23786
+ */
23787
+ var ExportBytesSchema = object({
23788
+ base64: string(),
23789
+ contentType: string(),
23790
+ /** Suggested filename, extension included. */
23791
+ name: string(),
23792
+ bytes: number().int().nonnegative()
23793
+ });
23361
23794
  method(object({
23362
23795
  deviceId: number(),
23363
23796
  profile: string(),
@@ -23382,6 +23815,9 @@ method(object({
23382
23815
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23383
23816
  kind: "query",
23384
23817
  auth: "protected"
23818
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23819
+ kind: "query",
23820
+ auth: "protected"
23385
23821
  });
23386
23822
  /**
23387
23823
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28575,6 +29011,12 @@ Object.freeze({
28575
29011
  addonId: null,
28576
29012
  access: "create"
28577
29013
  },
29014
+ "recording.cancelRelocateJob": {
29015
+ capName: "recording",
29016
+ capScope: "system",
29017
+ addonId: null,
29018
+ access: "create"
29019
+ },
28578
29020
  "recording.cancelStorageMigrationMove": {
28579
29021
  capName: "recording",
28580
29022
  capScope: "system",
@@ -28629,6 +29071,12 @@ Object.freeze({
28629
29071
  addonId: null,
28630
29072
  access: "view"
28631
29073
  },
29074
+ "recording.listRelocateJobs": {
29075
+ capName: "recording",
29076
+ capScope: "system",
29077
+ addonId: null,
29078
+ access: "view"
29079
+ },
28632
29080
  "recording.locateSegment": {
28633
29081
  capName: "recording",
28634
29082
  capScope: "system",
@@ -28641,6 +29089,12 @@ Object.freeze({
28641
29089
  addonId: null,
28642
29090
  access: "create"
28643
29091
  },
29092
+ "recording.planStorageRebalance": {
29093
+ capName: "recording",
29094
+ capScope: "system",
29095
+ addonId: null,
29096
+ access: "view"
29097
+ },
28644
29098
  "recording.pruneFootage": {
28645
29099
  capName: "recording",
28646
29100
  capScope: "system",
@@ -28665,6 +29119,12 @@ Object.freeze({
28665
29119
  addonId: null,
28666
29120
  access: "create"
28667
29121
  },
29122
+ "recording.relocateFootage": {
29123
+ capName: "recording",
29124
+ capScope: "system",
29125
+ addonId: null,
29126
+ access: "create"
29127
+ },
28668
29128
  "recording.renderClip": {
28669
29129
  capName: "recording",
28670
29130
  capScope: "system",
@@ -28701,38 +29161,50 @@ Object.freeze({
28701
29161
  addonId: null,
28702
29162
  access: "create"
28703
29163
  },
29164
+ "recording.startStorageRebalance": {
29165
+ capName: "recording",
29166
+ capScope: "system",
29167
+ addonId: null,
29168
+ access: "create"
29169
+ },
28704
29170
  "recordingExport.cancelExport": {
28705
- capName: "recordingExport",
29171
+ capName: "recording-export",
28706
29172
  capScope: "system",
28707
29173
  addonId: null,
28708
29174
  access: "create"
28709
29175
  },
28710
29176
  "recordingExport.createExport": {
28711
- capName: "recordingExport",
29177
+ capName: "recording-export",
28712
29178
  capScope: "system",
28713
29179
  addonId: null,
28714
29180
  access: "create"
28715
29181
  },
28716
29182
  "recordingExport.deleteExport": {
28717
- capName: "recordingExport",
29183
+ capName: "recording-export",
28718
29184
  capScope: "system",
28719
29185
  addonId: null,
28720
29186
  access: "delete"
28721
29187
  },
28722
29188
  "recordingExport.getDownloadUrl": {
28723
- capName: "recordingExport",
29189
+ capName: "recording-export",
28724
29190
  capScope: "system",
28725
29191
  addonId: null,
28726
29192
  access: "view"
28727
29193
  },
28728
29194
  "recordingExport.getExport": {
28729
- capName: "recordingExport",
29195
+ capName: "recording-export",
28730
29196
  capScope: "system",
28731
29197
  addonId: null,
28732
29198
  access: "view"
28733
29199
  },
28734
29200
  "recordingExport.listExports": {
28735
- capName: "recordingExport",
29201
+ capName: "recording-export",
29202
+ capScope: "system",
29203
+ addonId: null,
29204
+ access: "view"
29205
+ },
29206
+ "recordingExport.readExportBytes": {
29207
+ capName: "recording-export",
28736
29208
  capScope: "system",
28737
29209
  addonId: null,
28738
29210
  access: "view"
@@ -30109,6 +30581,104 @@ var FramerateField = number().int().min(1).max(60);
30109
30581
  var TargetsField = array(NcRuleTargetSchema).min(1);
30110
30582
  var PriorityField = number().int().min(1).max(5);
30111
30583
  /**
30584
+ * Explicit override of the DENSE sampling cadence, seconds.
30585
+ *
30586
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30587
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30588
+ * made that same base 3 s and rendered a person pass as two frames.)
30589
+ *
30590
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30591
+ * `denseCadenceSec` and played at `framerate` occupies
30592
+ *
30593
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30594
+ *
30595
+ * 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.
30596
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30597
+ * and therefore the length of a quiet night, does not move.
30598
+ *
30599
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30600
+ * the recording has them returns the same frames, requested twice. Must be
30601
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30602
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30603
+ * rather than letting the export cap reject the render hours after the window.
30604
+ */
30605
+ var DenseCadenceSecField = number().min(.1).max(3600);
30606
+ /**
30607
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30608
+ *
30609
+ * The operator-facing form of the arithmetic above: instead of solving for a
30610
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30611
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30612
+ * that range every ~583 ms.
30613
+ *
30614
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30615
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30616
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30617
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30618
+ * schema change and are the tracked follow-up.
30619
+ *
30620
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30621
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30622
+ * by real footage, never met by duplicating frames into motion that never
30623
+ * happened.
30624
+ */
30625
+ var MinDwellSecField = number().min(0).max(60);
30626
+ /**
30627
+ * Caption burned into the notification's preview frame.
30628
+ *
30629
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30630
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30631
+ * templating dialect for one field would be a second thing to explain.
30632
+ *
30633
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30634
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30635
+ * the reason this is not `.min(1)`.
30636
+ */
30637
+ var PreviewTextField = string().max(200);
30638
+ /**
30639
+ * Whether the notification's preview is a STILL or a short animation.
30640
+ *
30641
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30642
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30643
+ * night reads better as three seconds of motion than as one frame of it. Both
30644
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30645
+ * simply applies it to a dozen frames sampled across the render and assembles
30646
+ * them.
30647
+ *
30648
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30649
+ * seeks and a palette pass, and no rule that never asked for one should start
30650
+ * paying that on the deploy that shipped it.
30651
+ *
30652
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30653
+ */
30654
+ var PreviewModeField = _enum(["image", "gif"]);
30655
+ /**
30656
+ * Which detection classes the notification reports counts for.
30657
+ *
30658
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30659
+ * plan — no second query — aggregated per class. Absent or empty means "every
30660
+ * class the window actually contained", which is what an operator who never
30661
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30662
+ * counts cars all night).
30663
+ *
30664
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30665
+ * …). An unknown name simply never matches and reports nothing — it is not an
30666
+ * error, because a rule may legitimately name a class this camera's model does
30667
+ * not emit.
30668
+ *
30669
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30670
+ * - `{{detections}}` — total over the reported classes
30671
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30672
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30673
+ * one per class, `count_` + the class name
30674
+ *
30675
+ * With NO custom body template the summary is appended to the derived body, and
30676
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30677
+ * reads. With a custom template the operator owns every word — nothing is
30678
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30679
+ */
30680
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30681
+ /**
30112
30682
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30113
30683
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30114
30684
  * here (see the ownership note above).
@@ -30128,9 +30698,30 @@ var TimelapseRuleInputSchema = object({
30128
30698
  cadenceSec: CadenceSecField.default(15),
30129
30699
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30130
30700
  framerate: FramerateField.default(10),
30701
+ /**
30702
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30703
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30704
+ * field gets.
30705
+ */
30706
+ denseCadenceSec: DenseCadenceSecField.optional(),
30707
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30708
+ minDwellSec: MinDwellSecField.optional(),
30131
30709
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30132
30710
  targets: TargetsField,
30133
30711
  template: TimelapseTemplateSchema.optional(),
30712
+ /**
30713
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30714
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30715
+ *
30716
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30717
+ * the notification's title/body, and clearing it (`template: null`) must not
30718
+ * silently clear the caption too.
30719
+ */
30720
+ previewText: PreviewTextField.optional(),
30721
+ /** Still or animation — see {@link PreviewModeField}. */
30722
+ previewMode: PreviewModeField.default("image"),
30723
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30724
+ reportClasses: ReportClassesField.optional(),
30134
30725
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30135
30726
  priority: PriorityField.default(3)
30136
30727
  });
@@ -30141,8 +30732,13 @@ object({
30141
30732
  schedule: NcScheduleSchema.optional(),
30142
30733
  cadenceSec: CadenceSecField.optional(),
30143
30734
  framerate: FramerateField.optional(),
30735
+ denseCadenceSec: DenseCadenceSecField.optional(),
30736
+ minDwellSec: MinDwellSecField.optional(),
30144
30737
  targets: TargetsField.optional(),
30145
30738
  template: TimelapseTemplateSchema.nullable().optional(),
30739
+ previewText: PreviewTextField.optional(),
30740
+ previewMode: PreviewModeField.optional(),
30741
+ reportClasses: ReportClassesField.optional(),
30146
30742
  priority: PriorityField.optional()
30147
30743
  });
30148
30744
  TimelapseRuleInputSchema.extend({
@@ -30154,10 +30750,28 @@ TimelapseRuleInputSchema.extend({
30154
30750
  */
30155
30751
  ownerUserId: string().optional(),
30156
30752
  /**
30157
- * Epoch-ms of the last successful generation the 1-hour re-generation
30158
- * guard's durable state (predecessor parity). Absent = never generated.
30753
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30754
+ * rule. What a UI shows, and the compatibility floor for
30755
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30159
30756
  */
30160
30757
  lastGeneratedAt: number().optional(),
30758
+ /**
30759
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30760
+ * re-generation guard's real durable state.
30761
+ *
30762
+ * One rule covers several cameras and each renders its own video, so a rule
30763
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30764
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30765
+ * already done — and B's night is gone for good, because the window will not
30766
+ * come back.
30767
+ *
30768
+ * ADDITIVE, so the migration is free: a row written before this field simply
30769
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30770
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30771
+ * "never generated" would re-render and re-notify every camera of every rule
30772
+ * once, on the deploy that shipped the map.
30773
+ */
30774
+ generatedByDevice: record(string(), number()).optional(),
30161
30775
  /** userId of the caller who created the rule (server-stamped). */
30162
30776
  createdBy: string(),
30163
30777
  createdAt: number(),
@@ -30208,25 +30822,32 @@ object({
30208
30822
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30209
30823
  object({
30210
30824
  /**
30211
- * How long a retained native frame is served before it counts as a miss.
30825
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30826
+ * detection result.
30827
+ *
30828
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30829
+ * a time window was never related to the event the pixels were waiting for.
30830
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30831
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30832
+ * releases the frame. The bound exists only so a runner that stops answering
30833
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30212
30834
  *
30213
- * Must cover the FULL late-crop horizon: detection inference + the
30214
- * cross-process inference-result hop to hub post-analysis + tracking + the
30215
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30216
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30217
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30835
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30836
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30837
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30838
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
30839
+ * `holdOverflow` on the metrics line is what says you need it.
30218
30840
  */
30219
- ttlMs: number().int().min(250).max(1e4),
30841
+ holdFrames: number().int().min(1).max(64),
30220
30842
  /**
30221
30843
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30222
30844
  *
30223
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30224
- * which one is actually binding before reasoning from that. At the shipped
30225
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30226
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30227
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30228
- * change that admits fewer frames buys retention WINDOW at constant RAM
30229
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30845
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30846
+ * is what decides how much is held, and the ceiling is the number above which
30847
+ * something is wrong. Before that it was the effective cap at 1024 MB with
30848
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30849
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30850
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30230
30851
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30231
30852
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30232
30853
  * to replace).
@@ -30252,22 +30873,45 @@ object({
30252
30873
  * there is the signal that some caller names frames outside the inference set
30253
30874
  * and that this must go back to `all`.
30254
30875
  */
30255
- admission: NativeLeaseAdmissionSchema
30876
+ admission: NativeLeaseAdmissionSchema,
30877
+ /**
30878
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30879
+ * compressed native crops the worker cuts at the moment a frame's detection
30880
+ * result arrives, and keeps long after the frame itself is freed.
30881
+ *
30882
+ * This is the knob that replaced the old retention window, and it buys about
30883
+ * three orders of magnitude more of it: a tile is one subject at native
30884
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30885
+ * the frame it was cut from. A frame on which nothing was detected costs
30886
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30887
+ * was interrogated per SUBJECT.
30888
+ *
30889
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30890
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30891
+ * reproduce that.
30892
+ */
30893
+ tileBudgetMb: number().int().min(0).max(1024)
30256
30894
  });
30257
30895
  /**
30258
- * The values in force when the operator has set nothing — byte-for-byte the
30259
- * constants the decode worker shipped with as env-var defaults, so making these
30260
- * settings changed no behaviour on the day it landed.
30896
+ * The values in force when the operator has set nothing.
30897
+ *
30898
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30899
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30900
+ * in the same change that redefines it would make a regression and a retune
30901
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30902
+ * live traffic.
30261
30903
  */
30262
30904
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30263
- ttlMs: 1200,
30905
+ holdFrames: 8,
30264
30906
  budgetMb: 1024,
30265
30907
  activityMs: 15e3,
30908
+ tileBudgetMb: 64,
30266
30909
  admission: "inferred"
30267
30910
  };
30268
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30911
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30269
30912
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30270
30913
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30914
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30271
30915
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30272
30916
  //#endregion
30273
30917
  //#region ../../node_modules/xtend/immutable.js