@camstack/addon-provider-rademacher 0.2.12 → 0.2.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +686 -42
  2. package/dist/addon.mjs +686 -42
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8204,8 +8204,31 @@ var AdoptionJobSchema = object({
8204
8204
  error: string().nullable()
8205
8205
  });
8206
8206
  /**
8207
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
8208
- * pipeline functions an operator thinks in terms of.
8207
+ * Per-camera FUNCTION SWITCHES.
8208
+ *
8209
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
8210
+ *
8211
+ * This file shipped as "the one coherent on/off surface over the pipeline
8212
+ * functions an operator thinks in terms of". The operator's verdict on
8213
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
8214
+ * every function already had a settings page of its own, and a second place to
8215
+ * turn it off is a second place to look. Each switch is going back to its own
8216
+ * component's original options — detection to the detection-pipeline wrapper
8217
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
8218
+ * (which was always first-class; the switch was a veneer over
8219
+ * `recording.setDeviceConfig`), notifications to a notification-center
8220
+ * per-device setting, the two camera planes to their own components.
8221
+ *
8222
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
8223
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
8224
+ * straight from the authorities with no group in the middle. That rule was
8225
+ * never about a control panel.
8226
+ *
8227
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
8228
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
8229
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
8230
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
8231
+ * stop; nothing new may be built on it.
8209
8232
  *
8210
8233
  * ## This file adds no state
8211
8234
  *
@@ -8556,7 +8579,15 @@ var RecordingConfigSchema = object({
8556
8579
  * Each completed/failed run also lands one durable ops-log row on its owning
8557
8580
  * addon surface.
8558
8581
  */
8582
+ /**
8583
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
8584
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
8585
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
8586
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
8587
+ * runs at all.
8588
+ */
8559
8589
  var RelocateJobStateSchema = _enum([
8590
+ "queued",
8560
8591
  "running",
8561
8592
  "done",
8562
8593
  "failed",
@@ -8591,6 +8622,15 @@ var RelocateFootageInputSchema = object({
8591
8622
  /** Limits relocation to the logical profile class. Omit only for the
8592
8623
  * pre-orchestration compatibility path. */
8593
8624
  footageClass: RelocateFootageClassSchema.optional(),
8625
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
8626
+ * is what a whole-disk drain means. The rebalance path always sets it: its
8627
+ * unit is a (camera, profile) pile, not a disk. */
8628
+ deviceId: number().int().optional(),
8629
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
8630
+ * Finer than `footageClass`, which cannot separate high from mid — and the
8631
+ * placement plan assigns those two independently, so a rebalance that could
8632
+ * only say "recordings" would move footage the plan never asked to move. */
8633
+ profiles: array(string()).optional(),
8594
8634
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
8595
8635
  * never allowed to starve live writers. */
8596
8636
  throttleMbps: number().min(1).max(1e3).optional()
@@ -8726,6 +8766,21 @@ var StorageLocationSchema = object({
8726
8766
  nodeId: string().optional(),
8727
8767
  isDefault: boolean().default(false),
8728
8768
  isSystem: boolean().default(false),
8769
+ /**
8770
+ * Operator opt-in: whether consumers that BALANCE across several locations
8771
+ * of a type may write here. Recordings reads it today; event media and
8772
+ * backups are the next consumers, which is why the flag lives on the
8773
+ * location rather than in any one addon's store — nothing has to be
8774
+ * extended to add the next consumer.
8775
+ *
8776
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
8777
+ * flag existed reads back with no flag and keeps working exactly as before;
8778
+ * that is the whole compat story, and it is why no migration ships with it.
8779
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
8780
+ * disk must not silently start writing to it); the default of a type is
8781
+ * always stamped `true`.
8782
+ */
8783
+ enabled: boolean().optional(),
8729
8784
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
8730
8785
  * for node-local locations it can reach) — never persisted, absent when the
8731
8786
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -13278,7 +13333,8 @@ method(object({
13278
13333
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
13279
13334
  /**
13280
13335
  * filesystem-browse — per-node capability for browsing the node's local
13281
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
13336
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13337
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
13282
13338
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
13283
13339
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
13284
13340
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -15119,6 +15175,13 @@ var MaskGridDimsSchema = object({
15119
15175
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
15120
15176
  * this one field keeps the schema additive — a rule still declares exactly
15121
15177
  * one trigger.
15178
+ *
15179
+ * AUDIO rules add no member here, for the reason occupancy added none: the
15180
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
15181
+ * mirror.ts` fails the build on a member the app cannot render) and every
15182
+ * member costs a release train. A sustained-sound rule is therefore an
15183
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
15184
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
15122
15185
  */
15123
15186
  var NcDeliverySchema = _enum([
15124
15187
  "immediate",
@@ -15133,15 +15196,32 @@ var NcDeliverySchema = _enum([
15133
15196
  * depend on a provider's raw event name or payload shape.
15134
15197
  */
15135
15198
  var NcSystemEventKindSchema = _enum([
15136
- "camera-online",
15137
- "camera-offline",
15199
+ "device-online",
15200
+ "device-offline",
15201
+ "device-disabled",
15202
+ "device-enabled",
15138
15203
  "stream-online",
15139
15204
  "stream-offline",
15140
15205
  "node-online",
15141
15206
  "node-offline",
15142
15207
  "addon-update-available",
15143
- "server-update-available"
15208
+ "server-update-available",
15209
+ "alarm-triggered",
15210
+ "alarm-armed",
15211
+ "alarm-disarmed",
15212
+ "camera-online",
15213
+ "camera-offline",
15214
+ "camera-disabled",
15215
+ "camera-enabled"
15216
+ ]);
15217
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
15218
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
15219
+ "camera-online",
15220
+ "camera-offline",
15221
+ "camera-disabled",
15222
+ "camera-enabled"
15144
15223
  ]);
15224
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
15145
15225
  /**
15146
15226
  * One coherent system-event condition. `kinds` is the required opt-in safety
15147
15227
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -15150,6 +15230,18 @@ var NcSystemEventKindSchema = _enum([
15150
15230
  var NcSystemEventConditionSchema = object({
15151
15231
  kinds: array(NcSystemEventKindSchema).min(1),
15152
15232
  deviceIds: array(number().int()).min(1).optional(),
15233
+ /**
15234
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
15235
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
15236
+ * is what a liveness rule means when nobody said otherwise.
15237
+ *
15238
+ * This is where "only my cameras" is expressed, and it lives on the rule for
15239
+ * one reason: the intake cannot know which devices this household cares
15240
+ * about, and a producer-side filter is one no operator can change. Fails
15241
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
15242
+ * does not carry) matches no `deviceTypes` list.
15243
+ */
15244
+ deviceTypes: array(string().min(1)).min(1).optional(),
15153
15245
  nodeIds: array(string().min(1)).min(1).optional(),
15154
15246
  packageNames: array(string().min(1)).min(1).optional()
15155
15247
  });
@@ -15200,6 +15292,47 @@ var NcOccupancyConditionSchema = object({
15200
15292
  sustainSeconds: number().int().min(0).max(3600).default(15)
15201
15293
  });
15202
15294
  /**
15295
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
15296
+ *
15297
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
15298
+ * reference notifier uses, so an operator moving between them re-uses what
15299
+ * they already know): a rule matches when, over a sampling window of
15300
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
15301
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
15302
+ *
15303
+ * - `dbThreshold` — its level is at or above this many dBFS (see
15304
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
15305
+ * - `labels` — the classifier put at least one of these labels on it.
15306
+ *
15307
+ * Both are OPTIONAL and independent, which is the point of the shape: a
15308
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
15309
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
15310
+ * is given** — a window in which every sample is trivially a hit would fire on
15311
+ * silence, so the engine refuses such a condition rather than notifying on
15312
+ * nothing (the schema cannot express "at least one of" without becoming a
15313
+ * ZodEffects the cap path would have to special-case).
15314
+ *
15315
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
15316
+ * must be FULL before it can match — a window that has been open for two
15317
+ * seconds of its ten is 100% of nothing, and firing on it would make
15318
+ * `samplingSeconds` decorative.
15319
+ *
15320
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
15321
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
15322
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
15323
+ * an operator who typed `dog` mean the same thing.
15324
+ */
15325
+ var NcAudioConditionSchema = object({
15326
+ /** Audio macro labels; absent = any sound (level-only rule). */
15327
+ labels: array(string().min(1)).min(1).optional(),
15328
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
15329
+ dbThreshold: number().min(-96).max(0).optional(),
15330
+ /** Percentage of the window's samples that must be hits (1–100). */
15331
+ hitPercent: number().int().min(1).max(100).default(60),
15332
+ /** Length of the sampling window in seconds. */
15333
+ samplingSeconds: number().int().min(1).max(300).default(10)
15334
+ });
15335
+ /**
15203
15336
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
15204
15337
  *
15205
15338
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -15472,7 +15605,33 @@ var NcConditionsSchema = object({
15472
15605
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
15473
15606
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
15474
15607
  */
15475
- occupancy: NcOccupancyConditionSchema.optional()
15608
+ occupancy: NcOccupancyConditionSchema.optional(),
15609
+ /**
15610
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
15611
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
15612
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
15613
+ * a window that is not full yet, neither filter given). See
15614
+ * {@link NcAudioCondition}.
15615
+ *
15616
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
15617
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
15618
+ * a detection, a track or a device event (the same fail-closed pairing
15619
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
15620
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
15621
+ * (an `immediate` rule naming an `audio-*` class, one notification per
15622
+ * classified sample) stays exactly as it was for rules that already use it.
15623
+ *
15624
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
15625
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
15626
+ * (`camstack/src/data/notification-center.ts`, guarded by
15627
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
15628
+ * condition fields it does not know when a rule is saved from the phone.
15629
+ * Publishing an editor for a condition the app cannot round-trip is how an
15630
+ * operator loses a rule's conditions by opening it — so the descriptor, the
15631
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
15632
+ * does an audio rule become authorable.
15633
+ */
15634
+ audio: NcAudioConditionSchema.optional()
15476
15635
  });
15477
15636
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
15478
15637
  var NcRuleTargetSchema = object({
@@ -15586,6 +15745,73 @@ var NcThrottleSchema = object({
15586
15745
  */
15587
15746
  granularity: NcThrottleGranularitySchema.optional()
15588
15747
  });
15748
+ /**
15749
+ * How long the confirm gate may hold ONE notification, and how big the picture
15750
+ * it judges may be.
15751
+ *
15752
+ * The clamp is the product decision, not a coincidence of the model: p50 was
15753
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
15754
+ * arrives after the visitor has gone is not a notification. 448 px was enough
15755
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
15756
+ * tokens for pixels the model pools away.
15757
+ */
15758
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
15759
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
15760
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
15761
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
15762
+ var NcConfirmExpectSchema = object({
15763
+ op: _enum([
15764
+ ">=",
15765
+ ">",
15766
+ "<=",
15767
+ "<",
15768
+ "=="
15769
+ ]),
15770
+ count: number().int().min(0).max(1e3)
15771
+ });
15772
+ /**
15773
+ * AI CONFIRM — a vision model looks at the picture this notification is about
15774
+ * to ship and says whether it agrees with the rule.
15775
+ *
15776
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
15777
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
15778
+ * on the operator's phone is not a verdict about this notification.
15779
+ *
15780
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
15781
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
15782
+ * the default and every fail-open is COUNTED, because a gate that always fails
15783
+ * open looks in the log exactly like a gate that works.
15784
+ *
15785
+ * Every field is `.optional()` rather than relied on as a Zod default at the
15786
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
15787
+ * production failures in one day), so the gate reads absent as the constant
15788
+ * above rather than trusting a parse it may never have seen.
15789
+ */
15790
+ var NcConfirmSchema = object({
15791
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
15792
+ * same thing, and both mean "deliver exactly as before". */
15793
+ enabled: boolean().default(false),
15794
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
15795
+ profileId: string().optional(),
15796
+ /**
15797
+ * The operator's question, in his own words. Absent = a question derived
15798
+ * from the rule (its class and its expectation).
15799
+ *
15800
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
15801
+ * banners, signage and plates as instructions if you let them reach the
15802
+ * prompt — proven live — so the authoritative contract stays in the system
15803
+ * turn and only rule-authored words land here.
15804
+ */
15805
+ prompt: string().max(1e3).optional(),
15806
+ /** Fire only when the model's count satisfies this. Absent = the model's
15807
+ * own boolean verdict decides. */
15808
+ expect: NcConfirmExpectSchema.optional(),
15809
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
15810
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
15811
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
15812
+ /** Longest edge the judged image is downscaled to before it is sent. */
15813
+ maxImagePx: number().int().min(64).max(2048).default(448)
15814
+ });
15589
15815
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
15590
15816
  var NcRuleInputSchema = object({
15591
15817
  name: string().min(1).max(200),
@@ -15646,7 +15872,13 @@ var NcRuleInputSchema = object({
15646
15872
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
15647
15873
  * shape as every other actuation.
15648
15874
  */
15649
- actions: NcRuleActionsSchema.optional()
15875
+ actions: NcRuleActionsSchema.optional(),
15876
+ /**
15877
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
15878
+ * a rule that predates the gate must keep delivering byte-for-byte as it
15879
+ * did, and absent is the only way to say that without a migration.
15880
+ */
15881
+ confirm: NcConfirmSchema.optional()
15650
15882
  });
15651
15883
  /**
15652
15884
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -15657,7 +15889,37 @@ var NcRuleInputSchema = object({
15657
15889
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
15658
15890
  * `updateRule` patch.
15659
15891
  */
15660
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
15892
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
15893
+ disabledTargetIds: array(string()).optional(),
15894
+ /**
15895
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
15896
+ *
15897
+ * It makes the key optional to SUPPLY; the parse still materialises the
15898
+ * default when the key is absent. And `NcRuleStore.update` merges with
15899
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
15900
+ * one — which made every partial edit destructive:
15901
+ *
15902
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
15903
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
15904
+ * setEnabled(ruleId, false) → conditions reset to `{}`
15905
+ *
15906
+ * A rule scoped to one camera and one zone silently became a rule that
15907
+ * matches EVERY event on EVERY camera, and lost its `media` policy
15908
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
15909
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
15910
+ * within a minute of a two-field patch.
15911
+ *
15912
+ * So every defaulted field is re-declared here WITHOUT its default. The
15913
+ * inner defaults still apply when the caller DOES send the key — `{}` for
15914
+ * conditions remains a real instruction ("clear them") — and only the
15915
+ * absent key is now genuinely absent.
15916
+ */
15917
+ enabled: boolean().optional(),
15918
+ conditions: NcConditionsSchema.optional(),
15919
+ media: NcMediaPolicySchema.optional(),
15920
+ throttle: NcThrottleSchema.optional(),
15921
+ priority: number().int().min(1).max(5).optional()
15922
+ });
15661
15923
  /** A persisted rule. */
15662
15924
  var NcRuleSchema = NcRuleInputSchema.extend({
15663
15925
  id: string(),
@@ -15958,6 +16220,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
15958
16220
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
15959
16221
  * copy would lie the first time a rule is disabled.
15960
16222
  */
16223
+ /**
16224
+ * Why a device a mode NAMES is nonetheless not armed by it.
16225
+ *
16226
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
16227
+ * per-camera notification switch the Notification Center already owns,
16228
+ * `detection-off` is the device's own detection binding being inactive, and
16229
+ * `offline` is the device manager's liveness. A fourth reason would mean a
16230
+ * fourth authority, and inventing one here is how a panel starts disagreeing
16231
+ * with the switches the operator actually used.
16232
+ */
16233
+ var NcAlarmSkipReasonSchema = _enum([
16234
+ "muted",
16235
+ "detection-off",
16236
+ "offline"
16237
+ ]);
16238
+ var NcAlarmSkippedDeviceSchema = object({
16239
+ deviceId: number().int(),
16240
+ reason: NcAlarmSkipReasonSchema
16241
+ });
15961
16242
  var NcAlarmModeCoverageSchema = object({
15962
16243
  mode: AlarmArmModeSchema,
15963
16244
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -15965,7 +16246,18 @@ var NcAlarmModeCoverageSchema = object({
15965
16246
  /** At least one covering rule has no device scope, so the mode covers all. */
15966
16247
  allDevices: boolean(),
15967
16248
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
15968
- deviceIds: array(number().int())
16249
+ deviceIds: array(number().int()),
16250
+ /**
16251
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
16252
+ * excludes it.
16253
+ *
16254
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
16255
+ * twelve makes it false in exactly the way nobody notices until an incident.
16256
+ * Defaulted to `[]` so a coverage answer computed before this field existed
16257
+ * still parses as "nothing known to be skipped" rather than failing the whole
16258
+ * alarm tab.
16259
+ */
16260
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
15969
16261
  });
15970
16262
  var NcAlarmConfigSchema = object({
15971
16263
  /**
@@ -18797,9 +19089,16 @@ var CameraStatusSchema = object({
18797
19089
  audio: CameraAudioStatusSchema.nullable(),
18798
19090
  recording: CameraRecordingStatusSchema.nullable(),
18799
19091
  /**
18800
- * Per-camera function switches an OPERATOR has turned off
19092
+ * Per-camera functions an OPERATOR has turned off
18801
19093
  * ([D61](../../../../docs/decisions/adr-0067.md)).
18802
19094
  *
19095
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
19096
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
19097
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
19098
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
19099
+ * The badge outlives the control panel: the panel was a convenience, this is
19100
+ * the difference between a camera being off and a camera being dead.
19101
+ *
18803
19102
  * This is the difference between DISABLED and BROKEN. A camera whose
18804
19103
  * `detection` block reports zero fps and whose `switchedOff` contains
18805
19104
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -25541,7 +25840,19 @@ var RecordingManifestSchema = object({
25541
25840
  * profiles/subtrees/locations on this node). */
25542
25841
  var RecordingDeviceUsageSchema = object({
25543
25842
  deviceId: number(),
25544
- usedBytes: number()
25843
+ usedBytes: number(),
25844
+ /**
25845
+ * Start of this camera's OLDEST indexed segment, across every profile and
25846
+ * location — the "Oldest footage" column in Recordings → Storage, and the
25847
+ * only honest answer to "is retention actually holding?" per camera.
25848
+ *
25849
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
25850
+ * predates this field omits it entirely, and a hub whose types carry the
25851
+ * field must keep validating that older provider's payload: the framework
25852
+ * (types) and the addon ship on different trains, and the addon is usually
25853
+ * the later of the two.
25854
+ */
25855
+ oldestMs: number().nullable().optional()
25545
25856
  });
25546
25857
  /** Recording storage usage + capacity for one storage location. */
25547
25858
  var RecordingLocationUsageSchema = object({
@@ -25569,6 +25880,57 @@ var RecordingStorageUsageSchema = object({
25569
25880
  locations: array(RecordingLocationUsageSchema)
25570
25881
  });
25571
25882
  /**
25883
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
25884
+ *
25885
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
25886
+ * is the operator asking for the EXISTING archive to be brought into line with
25887
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
25888
+ * location, run FIFO behind the single-flight mover.
25889
+ *
25890
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
25891
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
25892
+ * (empty on the plan).
25893
+ */
25894
+ var RecordingRebalanceMoveSchema = object({
25895
+ deviceId: number(),
25896
+ profile: string(),
25897
+ fromLocationId: string(),
25898
+ toLocationId: string(),
25899
+ bytes: number(),
25900
+ files: number().int()
25901
+ });
25902
+ /** Why a pile that is out of place is staying there. Every refusal is
25903
+ * reported: a rebalance that silently drops a camera reads exactly like one
25904
+ * that had nothing to do. */
25905
+ var RecordingRebalanceSkipReasonSchema = _enum([
25906
+ "unassigned",
25907
+ "target-not-writable",
25908
+ "below-threshold",
25909
+ "no-headroom"
25910
+ ]);
25911
+ var RecordingRebalanceSkipSchema = object({
25912
+ deviceId: number(),
25913
+ profile: string(),
25914
+ fromLocationId: string(),
25915
+ /** The location the plan wants; null when the camera has no assignment. */
25916
+ toLocationId: string().nullable(),
25917
+ bytes: number(),
25918
+ reason: RecordingRebalanceSkipReasonSchema
25919
+ });
25920
+ var RecordingRebalancePlanSchema = object({
25921
+ moves: array(RecordingRebalanceMoveSchema),
25922
+ skipped: array(RecordingRebalanceSkipSchema),
25923
+ bytesToMove: number(),
25924
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
25925
+ jobIds: array(string())
25926
+ });
25927
+ var RecordingRebalanceInputSchema = object({
25928
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
25929
+ throttleMbps: number().min(1).max(1e3).optional(),
25930
+ /** Ignore piles smaller than this (default 1 GB). */
25931
+ minMoveGb: number().min(0).optional()
25932
+ });
25933
+ /**
25572
25934
  * Result of locating footage at a wall-clock instant for one device/profile.
25573
25935
  * `segment` carries the covering segment's window; `gap` reports the forward
25574
25936
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -25731,9 +26093,24 @@ method(object({
25731
26093
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
25732
26094
  kind: "mutation",
25733
26095
  auth: "admin"
26096
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
26097
+ kind: "mutation",
26098
+ auth: "admin"
26099
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
26100
+ kind: "query",
26101
+ auth: "admin"
26102
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26103
+ kind: "mutation",
26104
+ auth: "admin"
26105
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26106
+ kind: "query",
26107
+ auth: "admin"
26108
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
26109
+ kind: "mutation",
26110
+ auth: "admin"
25734
26111
  });
25735
26112
  /**
25736
- * `recordingExport` cap — render a footage time range into a single downloadable
26113
+ * `recording-export` cap — render a footage time range into a single downloadable
25737
26114
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
25738
26115
  * bounded lifetime with a durable history, auto-expiry, and optional
25739
26116
  * delete-after-download.
@@ -25748,10 +26125,53 @@ method(object({
25748
26125
  */
25749
26126
  /** Playback-speed multiplier for the render (1 = realtime). */
25750
26127
  var ExportSpeedSchema = number().min(.25).max(32);
26128
+ /**
26129
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
26130
+ *
26131
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
26132
+ * derives these bounds from things that happened at a TIME (a track's
26133
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
26134
+ * every segment present for the range, with each recording GAP removed. The
26135
+ * two agree only on a window that recorded without one interruption, and only
26136
+ * the render side knows the segments, so the translation lives there
26137
+ * (`export-dense-map.ts`, addon-pipeline).
26138
+ *
26139
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
26140
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
26141
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
26142
+ * the video was a uniform timelapse, and the log line reported the five ranges
26143
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
26144
+ *
26145
+ * Relative and not absolute epoch, because an absolute epoch would make every
26146
+ * call site responsible for the same subtraction.
26147
+ */
26148
+ var ExportDenseRangeSchema = object({
26149
+ fromSec: number().nonnegative(),
26150
+ toSec: number().nonnegative()
26151
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
26152
+ /**
26153
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
26154
+ * listed ranges and at the base `everyMs` everywhere else.
26155
+ *
26156
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
26157
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
26158
+ */
26159
+ var ExportDenseSchema = object({
26160
+ everyMs: number().int().positive(),
26161
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
26162
+ });
25751
26163
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
25752
26164
  var ExportTimelapseSchema = object({
25753
26165
  everyMs: number().int().positive(),
25754
- outputFps: number().int().min(1).max(60).optional()
26166
+ outputFps: number().int().min(1).max(60).optional(),
26167
+ /** Optional second, FASTER rate over the intervals that matter. */
26168
+ dense: ExportDenseSchema.optional()
26169
+ }).superRefine((v, ctx) => {
26170
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
26171
+ code: ZodIssueCode.custom,
26172
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
26173
+ path: ["dense", "everyMs"]
26174
+ });
25755
26175
  });
25756
26176
  /**
25757
26177
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -25809,6 +26229,19 @@ var ExportDownloadSchema = object({
25809
26229
  url: string(),
25810
26230
  endpoints: array(string())
25811
26231
  });
26232
+ /**
26233
+ * A finished export's bytes, inline.
26234
+ *
26235
+ * `bytes` is the DECODED length — the number the caller bounds and logs
26236
+ * against, so nobody has to infer it from the base64 length.
26237
+ */
26238
+ var ExportBytesSchema = object({
26239
+ base64: string(),
26240
+ contentType: string(),
26241
+ /** Suggested filename, extension included. */
26242
+ name: string(),
26243
+ bytes: number().int().nonnegative()
26244
+ });
25812
26245
  method(object({
25813
26246
  deviceId: number(),
25814
26247
  profile: string(),
@@ -25833,6 +26266,9 @@ method(object({
25833
26266
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
25834
26267
  kind: "query",
25835
26268
  auth: "protected"
26269
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
26270
+ kind: "query",
26271
+ auth: "protected"
25836
26272
  });
25837
26273
  /**
25838
26274
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -32510,6 +32946,12 @@ Object.freeze({
32510
32946
  addonId: null,
32511
32947
  access: "create"
32512
32948
  },
32949
+ "recording.cancelRelocateJob": {
32950
+ capName: "recording",
32951
+ capScope: "system",
32952
+ addonId: null,
32953
+ access: "create"
32954
+ },
32513
32955
  "recording.cancelStorageMigrationMove": {
32514
32956
  capName: "recording",
32515
32957
  capScope: "system",
@@ -32564,6 +33006,12 @@ Object.freeze({
32564
33006
  addonId: null,
32565
33007
  access: "view"
32566
33008
  },
33009
+ "recording.listRelocateJobs": {
33010
+ capName: "recording",
33011
+ capScope: "system",
33012
+ addonId: null,
33013
+ access: "view"
33014
+ },
32567
33015
  "recording.locateSegment": {
32568
33016
  capName: "recording",
32569
33017
  capScope: "system",
@@ -32576,6 +33024,12 @@ Object.freeze({
32576
33024
  addonId: null,
32577
33025
  access: "create"
32578
33026
  },
33027
+ "recording.planStorageRebalance": {
33028
+ capName: "recording",
33029
+ capScope: "system",
33030
+ addonId: null,
33031
+ access: "view"
33032
+ },
32579
33033
  "recording.pruneFootage": {
32580
33034
  capName: "recording",
32581
33035
  capScope: "system",
@@ -32600,6 +33054,12 @@ Object.freeze({
32600
33054
  addonId: null,
32601
33055
  access: "create"
32602
33056
  },
33057
+ "recording.relocateFootage": {
33058
+ capName: "recording",
33059
+ capScope: "system",
33060
+ addonId: null,
33061
+ access: "create"
33062
+ },
32603
33063
  "recording.renderClip": {
32604
33064
  capName: "recording",
32605
33065
  capScope: "system",
@@ -32636,38 +33096,50 @@ Object.freeze({
32636
33096
  addonId: null,
32637
33097
  access: "create"
32638
33098
  },
33099
+ "recording.startStorageRebalance": {
33100
+ capName: "recording",
33101
+ capScope: "system",
33102
+ addonId: null,
33103
+ access: "create"
33104
+ },
32639
33105
  "recordingExport.cancelExport": {
32640
- capName: "recordingExport",
33106
+ capName: "recording-export",
32641
33107
  capScope: "system",
32642
33108
  addonId: null,
32643
33109
  access: "create"
32644
33110
  },
32645
33111
  "recordingExport.createExport": {
32646
- capName: "recordingExport",
33112
+ capName: "recording-export",
32647
33113
  capScope: "system",
32648
33114
  addonId: null,
32649
33115
  access: "create"
32650
33116
  },
32651
33117
  "recordingExport.deleteExport": {
32652
- capName: "recordingExport",
33118
+ capName: "recording-export",
32653
33119
  capScope: "system",
32654
33120
  addonId: null,
32655
33121
  access: "delete"
32656
33122
  },
32657
33123
  "recordingExport.getDownloadUrl": {
32658
- capName: "recordingExport",
33124
+ capName: "recording-export",
32659
33125
  capScope: "system",
32660
33126
  addonId: null,
32661
33127
  access: "view"
32662
33128
  },
32663
33129
  "recordingExport.getExport": {
32664
- capName: "recordingExport",
33130
+ capName: "recording-export",
32665
33131
  capScope: "system",
32666
33132
  addonId: null,
32667
33133
  access: "view"
32668
33134
  },
32669
33135
  "recordingExport.listExports": {
32670
- capName: "recordingExport",
33136
+ capName: "recording-export",
33137
+ capScope: "system",
33138
+ addonId: null,
33139
+ access: "view"
33140
+ },
33141
+ "recordingExport.readExportBytes": {
33142
+ capName: "recording-export",
32671
33143
  capScope: "system",
32672
33144
  addonId: null,
32673
33145
  access: "view"
@@ -34044,6 +34516,104 @@ var FramerateField = number().int().min(1).max(60);
34044
34516
  var TargetsField = array(NcRuleTargetSchema).min(1);
34045
34517
  var PriorityField = number().int().min(1).max(5);
34046
34518
  /**
34519
+ * Explicit override of the DENSE sampling cadence, seconds.
34520
+ *
34521
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
34522
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
34523
+ * made that same base 3 s and rendered a person pass as two frames.)
34524
+ *
34525
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
34526
+ * `denseCadenceSec` and played at `framerate` occupies
34527
+ *
34528
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
34529
+ *
34530
+ * 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.
34531
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
34532
+ * and therefore the length of a quiet night, does not move.
34533
+ *
34534
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
34535
+ * the recording has them returns the same frames, requested twice. Must be
34536
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
34537
+ * a uniform video the operator believes is two-rate — and upsert refuses it
34538
+ * rather than letting the export cap reject the render hours after the window.
34539
+ */
34540
+ var DenseCadenceSecField = number().min(.1).max(3600);
34541
+ /**
34542
+ * Minimum seconds of OUTPUT video each detection range must occupy.
34543
+ *
34544
+ * The operator-facing form of the arithmetic above: instead of solving for a
34545
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
34546
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
34547
+ * that range every ~583 ms.
34548
+ *
34549
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
34550
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
34551
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
34552
+ * ranges are sampled denser than they need. Per-range cadences require a cap
34553
+ * schema change and are the tracked follow-up.
34554
+ *
34555
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
34556
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
34557
+ * by real footage, never met by duplicating frames into motion that never
34558
+ * happened.
34559
+ */
34560
+ var MinDwellSecField = number().min(0).max(60);
34561
+ /**
34562
+ * Caption burned into the notification's preview frame.
34563
+ *
34564
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
34565
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
34566
+ * templating dialect for one field would be a second thing to explain.
34567
+ *
34568
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
34569
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
34570
+ * the reason this is not `.min(1)`.
34571
+ */
34572
+ var PreviewTextField = string().max(200);
34573
+ /**
34574
+ * Whether the notification's preview is a STILL or a short animation.
34575
+ *
34576
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
34577
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
34578
+ * night reads better as three seconds of motion than as one frame of it. Both
34579
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
34580
+ * simply applies it to a dozen frames sampled across the render and assembles
34581
+ * them.
34582
+ *
34583
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
34584
+ * seeks and a palette pass, and no rule that never asked for one should start
34585
+ * paying that on the deploy that shipped it.
34586
+ *
34587
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
34588
+ */
34589
+ var PreviewModeField = _enum(["image", "gif"]);
34590
+ /**
34591
+ * Which detection classes the notification reports counts for.
34592
+ *
34593
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
34594
+ * plan — no second query — aggregated per class. Absent or empty means "every
34595
+ * class the window actually contained", which is what an operator who never
34596
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
34597
+ * counts cars all night).
34598
+ *
34599
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
34600
+ * …). An unknown name simply never matches and reports nothing — it is not an
34601
+ * error, because a rule may legitimately name a class this camera's model does
34602
+ * not emit.
34603
+ *
34604
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
34605
+ * - `{{detections}}` — total over the reported classes
34606
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
34607
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
34608
+ * one per class, `count_` + the class name
34609
+ *
34610
+ * With NO custom body template the summary is appended to the derived body, and
34611
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
34612
+ * reads. With a custom template the operator owns every word — nothing is
34613
+ * appended, so `{{detectionSummary}}` is how he asks for it.
34614
+ */
34615
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
34616
+ /**
34047
34617
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
34048
34618
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
34049
34619
  * here (see the ownership note above).
@@ -34063,9 +34633,30 @@ var TimelapseRuleInputSchema = object({
34063
34633
  cadenceSec: CadenceSecField.default(15),
34064
34634
  /** Output frames per second of the assembled mp4 (predecessor parity). */
34065
34635
  framerate: FramerateField.default(10),
34636
+ /**
34637
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
34638
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
34639
+ * field gets.
34640
+ */
34641
+ denseCadenceSec: DenseCadenceSecField.optional(),
34642
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
34643
+ minDwellSec: MinDwellSecField.optional(),
34066
34644
  /** `notification-output` targets the finished video/thumbnail is sent to. */
34067
34645
  targets: TargetsField,
34068
34646
  template: TimelapseTemplateSchema.optional(),
34647
+ /**
34648
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
34649
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
34650
+ *
34651
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
34652
+ * the notification's title/body, and clearing it (`template: null`) must not
34653
+ * silently clear the caption too.
34654
+ */
34655
+ previewText: PreviewTextField.optional(),
34656
+ /** Still or animation — see {@link PreviewModeField}. */
34657
+ previewMode: PreviewModeField.default("image"),
34658
+ /** Classes the notification counts — see {@link ReportClassesField}. */
34659
+ reportClasses: ReportClassesField.optional(),
34069
34660
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
34070
34661
  priority: PriorityField.default(3)
34071
34662
  });
@@ -34076,8 +34667,13 @@ object({
34076
34667
  schedule: NcScheduleSchema.optional(),
34077
34668
  cadenceSec: CadenceSecField.optional(),
34078
34669
  framerate: FramerateField.optional(),
34670
+ denseCadenceSec: DenseCadenceSecField.optional(),
34671
+ minDwellSec: MinDwellSecField.optional(),
34079
34672
  targets: TargetsField.optional(),
34080
34673
  template: TimelapseTemplateSchema.nullable().optional(),
34674
+ previewText: PreviewTextField.optional(),
34675
+ previewMode: PreviewModeField.optional(),
34676
+ reportClasses: ReportClassesField.optional(),
34081
34677
  priority: PriorityField.optional()
34082
34678
  });
34083
34679
  TimelapseRuleInputSchema.extend({
@@ -34089,10 +34685,28 @@ TimelapseRuleInputSchema.extend({
34089
34685
  */
34090
34686
  ownerUserId: string().optional(),
34091
34687
  /**
34092
- * Epoch-ms of the last successful generation the 1-hour re-generation
34093
- * guard's durable state (predecessor parity). Absent = never generated.
34688
+ * Epoch-ms of the NEWEST successful generation across every camera of this
34689
+ * rule. What a UI shows, and the compatibility floor for
34690
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
34094
34691
  */
34095
34692
  lastGeneratedAt: number().optional(),
34693
+ /**
34694
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
34695
+ * re-generation guard's real durable state.
34696
+ *
34697
+ * One rule covers several cameras and each renders its own video, so a rule
34698
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
34699
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
34700
+ * already done — and B's night is gone for good, because the window will not
34701
+ * come back.
34702
+ *
34703
+ * ADDITIVE, so the migration is free: a row written before this field simply
34704
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
34705
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
34706
+ * "never generated" would re-render and re-notify every camera of every rule
34707
+ * once, on the deploy that shipped the map.
34708
+ */
34709
+ generatedByDevice: record(string(), number()).optional(),
34096
34710
  /** userId of the caller who created the rule (server-stamped). */
34097
34711
  createdBy: string(),
34098
34712
  createdAt: number(),
@@ -34143,25 +34757,32 @@ object({
34143
34757
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
34144
34758
  object({
34145
34759
  /**
34146
- * How long a retained native frame is served before it counts as a miss.
34760
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
34761
+ * detection result.
34762
+ *
34763
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
34764
+ * a time window was never related to the event the pixels were waiting for.
34765
+ * A held frame now lives from delivery until the runner has its `FrameResult`
34766
+ * — at which moment the runner cuts the subject tiles it actually wanted and
34767
+ * releases the frame. The bound exists only so a runner that stops answering
34768
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
34147
34769
  *
34148
- * Must cover the FULL late-crop horizon: detection inference + the
34149
- * cross-process inference-result hop to hub post-analysis + tracking + the
34150
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
34151
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
34152
- * RAM per busy camera grows linearly with no measured hit-rate gain.
34770
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
34771
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
34772
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
34773
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
34774
+ * `holdOverflow` on the metrics line is what says you need it.
34153
34775
  */
34154
- ttlMs: number().int().min(250).max(1e4),
34776
+ holdFrames: number().int().min(1).max(64),
34155
34777
  /**
34156
34778
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
34157
34779
  *
34158
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
34159
- * which one is actually binding before reasoning from that. At the shipped
34160
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
34161
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
34162
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
34163
- * change that admits fewer frames buys retention WINDOW at constant RAM
34164
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
34780
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
34781
+ * is what decides how much is held, and the ceiling is the number above which
34782
+ * something is wrong. Before that it was the effective cap at 1024 MB with
34783
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
34784
+ * with the TTL expiring nothing, which is exactly the confusion the hold
34785
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
34165
34786
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
34166
34787
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
34167
34788
  * to replace).
@@ -34187,22 +34808,45 @@ object({
34187
34808
  * there is the signal that some caller names frames outside the inference set
34188
34809
  * and that this must go back to `all`.
34189
34810
  */
34190
- admission: NativeLeaseAdmissionSchema
34811
+ admission: NativeLeaseAdmissionSchema,
34812
+ /**
34813
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
34814
+ * compressed native crops the worker cuts at the moment a frame's detection
34815
+ * result arrives, and keeps long after the frame itself is freed.
34816
+ *
34817
+ * This is the knob that replaced the old retention window, and it buys about
34818
+ * three orders of magnitude more of it: a tile is one subject at native
34819
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
34820
+ * the frame it was cut from. A frame on which nothing was detected costs
34821
+ * nothing at all, which is the real change — the old lease paid per FRAME and
34822
+ * was interrogated per SUBJECT.
34823
+ *
34824
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
34825
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
34826
+ * reproduce that.
34827
+ */
34828
+ tileBudgetMb: number().int().min(0).max(1024)
34191
34829
  });
34192
34830
  /**
34193
- * The values in force when the operator has set nothing — byte-for-byte the
34194
- * constants the decode worker shipped with as env-var defaults, so making these
34195
- * settings changed no behaviour on the day it landed.
34831
+ * The values in force when the operator has set nothing.
34832
+ *
34833
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
34834
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
34835
+ * in the same change that redefines it would make a regression and a retune
34836
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
34837
+ * live traffic.
34196
34838
  */
34197
34839
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
34198
- ttlMs: 1200,
34840
+ holdFrames: 8,
34199
34841
  budgetMb: 1024,
34200
34842
  activityMs: 15e3,
34843
+ tileBudgetMb: 64,
34201
34844
  admission: "inferred"
34202
34845
  };
34203
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
34846
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
34204
34847
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
34205
34848
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
34849
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
34206
34850
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
34207
34851
  //#endregion
34208
34852
  //#region src/config.ts