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