@camstack/addon-static-turn 1.2.12 → 1.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.
@@ -7188,8 +7188,31 @@ var AdoptionJobSchema = object({
7188
7188
  error: string().nullable()
7189
7189
  });
7190
7190
  /**
7191
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7192
- * pipeline functions an operator thinks in terms of.
7191
+ * Per-camera FUNCTION SWITCHES.
7192
+ *
7193
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7194
+ *
7195
+ * This file shipped as "the one coherent on/off surface over the pipeline
7196
+ * functions an operator thinks in terms of". The operator's verdict on
7197
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7198
+ * every function already had a settings page of its own, and a second place to
7199
+ * turn it off is a second place to look. Each switch is going back to its own
7200
+ * component's original options — detection to the detection-pipeline wrapper
7201
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7202
+ * (which was always first-class; the switch was a veneer over
7203
+ * `recording.setDeviceConfig`), notifications to a notification-center
7204
+ * per-device setting, the two camera planes to their own components.
7205
+ *
7206
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7207
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7208
+ * straight from the authorities with no group in the middle. That rule was
7209
+ * never about a control panel.
7210
+ *
7211
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7212
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7213
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7214
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7215
+ * stop; nothing new may be built on it.
7193
7216
  *
7194
7217
  * ## This file adds no state
7195
7218
  *
@@ -7540,7 +7563,15 @@ var RecordingConfigSchema = object({
7540
7563
  * Each completed/failed run also lands one durable ops-log row on its owning
7541
7564
  * addon surface.
7542
7565
  */
7566
+ /**
7567
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7568
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7569
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7570
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7571
+ * runs at all.
7572
+ */
7543
7573
  var RelocateJobStateSchema = _enum([
7574
+ "queued",
7544
7575
  "running",
7545
7576
  "done",
7546
7577
  "failed",
@@ -7575,6 +7606,15 @@ var RelocateFootageInputSchema = object({
7575
7606
  /** Limits relocation to the logical profile class. Omit only for the
7576
7607
  * pre-orchestration compatibility path. */
7577
7608
  footageClass: RelocateFootageClassSchema.optional(),
7609
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7610
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7611
+ * unit is a (camera, profile) pile, not a disk. */
7612
+ deviceId: number().int().optional(),
7613
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7614
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7615
+ * placement plan assigns those two independently, so a rebalance that could
7616
+ * only say "recordings" would move footage the plan never asked to move. */
7617
+ profiles: array(string()).optional(),
7578
7618
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7579
7619
  * never allowed to starve live writers. */
7580
7620
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7710,6 +7750,21 @@ var StorageLocationSchema = object({
7710
7750
  nodeId: string().optional(),
7711
7751
  isDefault: boolean().default(false),
7712
7752
  isSystem: boolean().default(false),
7753
+ /**
7754
+ * Operator opt-in: whether consumers that BALANCE across several locations
7755
+ * of a type may write here. Recordings reads it today; event media and
7756
+ * backups are the next consumers, which is why the flag lives on the
7757
+ * location rather than in any one addon's store — nothing has to be
7758
+ * extended to add the next consumer.
7759
+ *
7760
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7761
+ * flag existed reads back with no flag and keeps working exactly as before;
7762
+ * that is the whole compat story, and it is why no migration ships with it.
7763
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7764
+ * disk must not silently start writing to it); the default of a type is
7765
+ * always stamped `true`.
7766
+ */
7767
+ enabled: boolean().optional(),
7713
7768
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7714
7769
  * for node-local locations it can reach) — never persisted, absent when the
7715
7770
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12012,7 +12067,8 @@ method(object({
12012
12067
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12013
12068
  /**
12014
12069
  * filesystem-browse — per-node capability for browsing the node's local
12015
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12070
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12071
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12016
12072
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12017
12073
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12018
12074
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13825,6 +13881,13 @@ var MaskGridDimsSchema = object({
13825
13881
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13826
13882
  * this one field keeps the schema additive — a rule still declares exactly
13827
13883
  * one trigger.
13884
+ *
13885
+ * AUDIO rules add no member here, for the reason occupancy added none: the
13886
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
13887
+ * mirror.ts` fails the build on a member the app cannot render) and every
13888
+ * member costs a release train. A sustained-sound rule is therefore an
13889
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
13890
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13828
13891
  */
13829
13892
  var NcDeliverySchema = _enum([
13830
13893
  "immediate",
@@ -13839,15 +13902,32 @@ var NcDeliverySchema = _enum([
13839
13902
  * depend on a provider's raw event name or payload shape.
13840
13903
  */
13841
13904
  var NcSystemEventKindSchema = _enum([
13842
- "camera-online",
13843
- "camera-offline",
13905
+ "device-online",
13906
+ "device-offline",
13907
+ "device-disabled",
13908
+ "device-enabled",
13844
13909
  "stream-online",
13845
13910
  "stream-offline",
13846
13911
  "node-online",
13847
13912
  "node-offline",
13848
13913
  "addon-update-available",
13849
- "server-update-available"
13914
+ "server-update-available",
13915
+ "alarm-triggered",
13916
+ "alarm-armed",
13917
+ "alarm-disarmed",
13918
+ "camera-online",
13919
+ "camera-offline",
13920
+ "camera-disabled",
13921
+ "camera-enabled"
13922
+ ]);
13923
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
13924
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
13925
+ "camera-online",
13926
+ "camera-offline",
13927
+ "camera-disabled",
13928
+ "camera-enabled"
13850
13929
  ]);
13930
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13851
13931
  /**
13852
13932
  * One coherent system-event condition. `kinds` is the required opt-in safety
13853
13933
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -13856,6 +13936,18 @@ var NcSystemEventKindSchema = _enum([
13856
13936
  var NcSystemEventConditionSchema = object({
13857
13937
  kinds: array(NcSystemEventKindSchema).min(1),
13858
13938
  deviceIds: array(number().int()).min(1).optional(),
13939
+ /**
13940
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
13941
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
13942
+ * is what a liveness rule means when nobody said otherwise.
13943
+ *
13944
+ * This is where "only my cameras" is expressed, and it lives on the rule for
13945
+ * one reason: the intake cannot know which devices this household cares
13946
+ * about, and a producer-side filter is one no operator can change. Fails
13947
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
13948
+ * does not carry) matches no `deviceTypes` list.
13949
+ */
13950
+ deviceTypes: array(string().min(1)).min(1).optional(),
13859
13951
  nodeIds: array(string().min(1)).min(1).optional(),
13860
13952
  packageNames: array(string().min(1)).min(1).optional()
13861
13953
  });
@@ -13906,6 +13998,47 @@ var NcOccupancyConditionSchema = object({
13906
13998
  sustainSeconds: number().int().min(0).max(3600).default(15)
13907
13999
  });
13908
14000
  /**
14001
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14002
+ *
14003
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14004
+ * reference notifier uses, so an operator moving between them re-uses what
14005
+ * they already know): a rule matches when, over a sampling window of
14006
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14007
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14008
+ *
14009
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14010
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14011
+ * - `labels` — the classifier put at least one of these labels on it.
14012
+ *
14013
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14014
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14015
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14016
+ * is given** — a window in which every sample is trivially a hit would fire on
14017
+ * silence, so the engine refuses such a condition rather than notifying on
14018
+ * nothing (the schema cannot express "at least one of" without becoming a
14019
+ * ZodEffects the cap path would have to special-case).
14020
+ *
14021
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14022
+ * must be FULL before it can match — a window that has been open for two
14023
+ * seconds of its ten is 100% of nothing, and firing on it would make
14024
+ * `samplingSeconds` decorative.
14025
+ *
14026
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14027
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14028
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14029
+ * an operator who typed `dog` mean the same thing.
14030
+ */
14031
+ var NcAudioConditionSchema = object({
14032
+ /** Audio macro labels; absent = any sound (level-only rule). */
14033
+ labels: array(string().min(1)).min(1).optional(),
14034
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14035
+ dbThreshold: number().min(-96).max(0).optional(),
14036
+ /** Percentage of the window's samples that must be hits (1–100). */
14037
+ hitPercent: number().int().min(1).max(100).default(60),
14038
+ /** Length of the sampling window in seconds. */
14039
+ samplingSeconds: number().int().min(1).max(300).default(10)
14040
+ });
14041
+ /**
13909
14042
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
13910
14043
  *
13911
14044
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14178,7 +14311,33 @@ var NcConditionsSchema = object({
14178
14311
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14179
14312
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14180
14313
  */
14181
- occupancy: NcOccupancyConditionSchema.optional()
14314
+ occupancy: NcOccupancyConditionSchema.optional(),
14315
+ /**
14316
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14317
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14318
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14319
+ * a window that is not full yet, neither filter given). See
14320
+ * {@link NcAudioCondition}.
14321
+ *
14322
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14323
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14324
+ * a detection, a track or a device event (the same fail-closed pairing
14325
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14326
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14327
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14328
+ * classified sample) stays exactly as it was for rules that already use it.
14329
+ *
14330
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14331
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14332
+ * (`camstack/src/data/notification-center.ts`, guarded by
14333
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14334
+ * condition fields it does not know when a rule is saved from the phone.
14335
+ * Publishing an editor for a condition the app cannot round-trip is how an
14336
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14337
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14338
+ * does an audio rule become authorable.
14339
+ */
14340
+ audio: NcAudioConditionSchema.optional()
14182
14341
  });
14183
14342
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14184
14343
  var NcRuleTargetSchema = object({
@@ -14292,6 +14451,73 @@ var NcThrottleSchema = object({
14292
14451
  */
14293
14452
  granularity: NcThrottleGranularitySchema.optional()
14294
14453
  });
14454
+ /**
14455
+ * How long the confirm gate may hold ONE notification, and how big the picture
14456
+ * it judges may be.
14457
+ *
14458
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14459
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14460
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14461
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14462
+ * tokens for pixels the model pools away.
14463
+ */
14464
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14465
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14466
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14467
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14468
+ var NcConfirmExpectSchema = object({
14469
+ op: _enum([
14470
+ ">=",
14471
+ ">",
14472
+ "<=",
14473
+ "<",
14474
+ "=="
14475
+ ]),
14476
+ count: number().int().min(0).max(1e3)
14477
+ });
14478
+ /**
14479
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14480
+ * to ship and says whether it agrees with the rule.
14481
+ *
14482
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14483
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14484
+ * on the operator's phone is not a verdict about this notification.
14485
+ *
14486
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14487
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14488
+ * the default and every fail-open is COUNTED, because a gate that always fails
14489
+ * open looks in the log exactly like a gate that works.
14490
+ *
14491
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14492
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14493
+ * production failures in one day), so the gate reads absent as the constant
14494
+ * above rather than trusting a parse it may never have seen.
14495
+ */
14496
+ var NcConfirmSchema = object({
14497
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14498
+ * same thing, and both mean "deliver exactly as before". */
14499
+ enabled: boolean().default(false),
14500
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14501
+ profileId: string().optional(),
14502
+ /**
14503
+ * The operator's question, in his own words. Absent = a question derived
14504
+ * from the rule (its class and its expectation).
14505
+ *
14506
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14507
+ * banners, signage and plates as instructions if you let them reach the
14508
+ * prompt — proven live — so the authoritative contract stays in the system
14509
+ * turn and only rule-authored words land here.
14510
+ */
14511
+ prompt: string().max(1e3).optional(),
14512
+ /** Fire only when the model's count satisfies this. Absent = the model's
14513
+ * own boolean verdict decides. */
14514
+ expect: NcConfirmExpectSchema.optional(),
14515
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14516
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14517
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14518
+ /** Longest edge the judged image is downscaled to before it is sent. */
14519
+ maxImagePx: number().int().min(64).max(2048).default(448)
14520
+ });
14295
14521
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14296
14522
  var NcRuleInputSchema = object({
14297
14523
  name: string().min(1).max(200),
@@ -14352,7 +14578,13 @@ var NcRuleInputSchema = object({
14352
14578
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14353
14579
  * shape as every other actuation.
14354
14580
  */
14355
- actions: NcRuleActionsSchema.optional()
14581
+ actions: NcRuleActionsSchema.optional(),
14582
+ /**
14583
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14584
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14585
+ * did, and absent is the only way to say that without a migration.
14586
+ */
14587
+ confirm: NcConfirmSchema.optional()
14356
14588
  });
14357
14589
  /**
14358
14590
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14363,7 +14595,37 @@ var NcRuleInputSchema = object({
14363
14595
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14364
14596
  * `updateRule` patch.
14365
14597
  */
14366
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14598
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14599
+ disabledTargetIds: array(string()).optional(),
14600
+ /**
14601
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14602
+ *
14603
+ * It makes the key optional to SUPPLY; the parse still materialises the
14604
+ * default when the key is absent. And `NcRuleStore.update` merges with
14605
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14606
+ * one — which made every partial edit destructive:
14607
+ *
14608
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14609
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14610
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14611
+ *
14612
+ * A rule scoped to one camera and one zone silently became a rule that
14613
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14614
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14615
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14616
+ * within a minute of a two-field patch.
14617
+ *
14618
+ * So every defaulted field is re-declared here WITHOUT its default. The
14619
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14620
+ * conditions remains a real instruction ("clear them") — and only the
14621
+ * absent key is now genuinely absent.
14622
+ */
14623
+ enabled: boolean().optional(),
14624
+ conditions: NcConditionsSchema.optional(),
14625
+ media: NcMediaPolicySchema.optional(),
14626
+ throttle: NcThrottleSchema.optional(),
14627
+ priority: number().int().min(1).max(5).optional()
14628
+ });
14367
14629
  /** A persisted rule. */
14368
14630
  var NcRuleSchema = NcRuleInputSchema.extend({
14369
14631
  id: string(),
@@ -14664,6 +14926,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14664
14926
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14665
14927
  * copy would lie the first time a rule is disabled.
14666
14928
  */
14929
+ /**
14930
+ * Why a device a mode NAMES is nonetheless not armed by it.
14931
+ *
14932
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
14933
+ * per-camera notification switch the Notification Center already owns,
14934
+ * `detection-off` is the device's own detection binding being inactive, and
14935
+ * `offline` is the device manager's liveness. A fourth reason would mean a
14936
+ * fourth authority, and inventing one here is how a panel starts disagreeing
14937
+ * with the switches the operator actually used.
14938
+ */
14939
+ var NcAlarmSkipReasonSchema = _enum([
14940
+ "muted",
14941
+ "detection-off",
14942
+ "offline"
14943
+ ]);
14944
+ var NcAlarmSkippedDeviceSchema = object({
14945
+ deviceId: number().int(),
14946
+ reason: NcAlarmSkipReasonSchema
14947
+ });
14667
14948
  var NcAlarmModeCoverageSchema = object({
14668
14949
  mode: AlarmArmModeSchema,
14669
14950
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14671,7 +14952,18 @@ var NcAlarmModeCoverageSchema = object({
14671
14952
  /** At least one covering rule has no device scope, so the mode covers all. */
14672
14953
  allDevices: boolean(),
14673
14954
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14674
- deviceIds: array(number().int())
14955
+ deviceIds: array(number().int()),
14956
+ /**
14957
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
14958
+ * excludes it.
14959
+ *
14960
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
14961
+ * twelve makes it false in exactly the way nobody notices until an incident.
14962
+ * Defaulted to `[]` so a coverage answer computed before this field existed
14963
+ * still parses as "nothing known to be skipped" rather than failing the whole
14964
+ * alarm tab.
14965
+ */
14966
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14675
14967
  });
14676
14968
  var NcAlarmConfigSchema = object({
14677
14969
  /**
@@ -17470,9 +17762,16 @@ var CameraStatusSchema = object({
17470
17762
  audio: CameraAudioStatusSchema.nullable(),
17471
17763
  recording: CameraRecordingStatusSchema.nullable(),
17472
17764
  /**
17473
- * Per-camera function switches an OPERATOR has turned off
17765
+ * Per-camera functions an OPERATOR has turned off
17474
17766
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17475
17767
  *
17768
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17769
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17770
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17771
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17772
+ * The badge outlives the control panel: the panel was a convenience, this is
17773
+ * the difference between a camera being off and a camera being dead.
17774
+ *
17476
17775
  * This is the difference between DISABLED and BROKEN. A camera whose
17477
17776
  * `detection` block reports zero fps and whose `switchedOff` contains
17478
17777
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23004,7 +23303,19 @@ var RecordingManifestSchema = object({
23004
23303
  * profiles/subtrees/locations on this node). */
23005
23304
  var RecordingDeviceUsageSchema = object({
23006
23305
  deviceId: number(),
23007
- usedBytes: number()
23306
+ usedBytes: number(),
23307
+ /**
23308
+ * Start of this camera's OLDEST indexed segment, across every profile and
23309
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23310
+ * only honest answer to "is retention actually holding?" per camera.
23311
+ *
23312
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23313
+ * predates this field omits it entirely, and a hub whose types carry the
23314
+ * field must keep validating that older provider's payload: the framework
23315
+ * (types) and the addon ship on different trains, and the addon is usually
23316
+ * the later of the two.
23317
+ */
23318
+ oldestMs: number().nullable().optional()
23008
23319
  });
23009
23320
  /** Recording storage usage + capacity for one storage location. */
23010
23321
  var RecordingLocationUsageSchema = object({
@@ -23032,6 +23343,57 @@ var RecordingStorageUsageSchema = object({
23032
23343
  locations: array(RecordingLocationUsageSchema)
23033
23344
  });
23034
23345
  /**
23346
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23347
+ *
23348
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23349
+ * is the operator asking for the EXISTING archive to be brought into line with
23350
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23351
+ * location, run FIFO behind the single-flight mover.
23352
+ *
23353
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23354
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23355
+ * (empty on the plan).
23356
+ */
23357
+ var RecordingRebalanceMoveSchema = object({
23358
+ deviceId: number(),
23359
+ profile: string(),
23360
+ fromLocationId: string(),
23361
+ toLocationId: string(),
23362
+ bytes: number(),
23363
+ files: number().int()
23364
+ });
23365
+ /** Why a pile that is out of place is staying there. Every refusal is
23366
+ * reported: a rebalance that silently drops a camera reads exactly like one
23367
+ * that had nothing to do. */
23368
+ var RecordingRebalanceSkipReasonSchema = _enum([
23369
+ "unassigned",
23370
+ "target-not-writable",
23371
+ "below-threshold",
23372
+ "no-headroom"
23373
+ ]);
23374
+ var RecordingRebalanceSkipSchema = object({
23375
+ deviceId: number(),
23376
+ profile: string(),
23377
+ fromLocationId: string(),
23378
+ /** The location the plan wants; null when the camera has no assignment. */
23379
+ toLocationId: string().nullable(),
23380
+ bytes: number(),
23381
+ reason: RecordingRebalanceSkipReasonSchema
23382
+ });
23383
+ var RecordingRebalancePlanSchema = object({
23384
+ moves: array(RecordingRebalanceMoveSchema),
23385
+ skipped: array(RecordingRebalanceSkipSchema),
23386
+ bytesToMove: number(),
23387
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23388
+ jobIds: array(string())
23389
+ });
23390
+ var RecordingRebalanceInputSchema = object({
23391
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23392
+ throttleMbps: number().min(1).max(1e3).optional(),
23393
+ /** Ignore piles smaller than this (default 1 GB). */
23394
+ minMoveGb: number().min(0).optional()
23395
+ });
23396
+ /**
23035
23397
  * Result of locating footage at a wall-clock instant for one device/profile.
23036
23398
  * `segment` carries the covering segment's window; `gap` reports the forward
23037
23399
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23194,9 +23556,24 @@ method(object({
23194
23556
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23195
23557
  kind: "mutation",
23196
23558
  auth: "admin"
23559
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23560
+ kind: "mutation",
23561
+ auth: "admin"
23562
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23563
+ kind: "query",
23564
+ auth: "admin"
23565
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23566
+ kind: "mutation",
23567
+ auth: "admin"
23568
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23569
+ kind: "query",
23570
+ auth: "admin"
23571
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23572
+ kind: "mutation",
23573
+ auth: "admin"
23197
23574
  });
23198
23575
  /**
23199
- * `recordingExport` cap — render a footage time range into a single downloadable
23576
+ * `recording-export` cap — render a footage time range into a single downloadable
23200
23577
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23201
23578
  * bounded lifetime with a durable history, auto-expiry, and optional
23202
23579
  * delete-after-download.
@@ -23211,10 +23588,53 @@ method(object({
23211
23588
  */
23212
23589
  /** Playback-speed multiplier for the render (1 = realtime). */
23213
23590
  var ExportSpeedSchema = number().min(.25).max(32);
23591
+ /**
23592
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23593
+ *
23594
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23595
+ * derives these bounds from things that happened at a TIME (a track's
23596
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23597
+ * every segment present for the range, with each recording GAP removed. The
23598
+ * two agree only on a window that recorded without one interruption, and only
23599
+ * the render side knows the segments, so the translation lives there
23600
+ * (`export-dense-map.ts`, addon-pipeline).
23601
+ *
23602
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23603
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23604
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23605
+ * the video was a uniform timelapse, and the log line reported the five ranges
23606
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23607
+ *
23608
+ * Relative and not absolute epoch, because an absolute epoch would make every
23609
+ * call site responsible for the same subtraction.
23610
+ */
23611
+ var ExportDenseRangeSchema = object({
23612
+ fromSec: number().nonnegative(),
23613
+ toSec: number().nonnegative()
23614
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23615
+ /**
23616
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23617
+ * listed ranges and at the base `everyMs` everywhere else.
23618
+ *
23619
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23620
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23621
+ */
23622
+ var ExportDenseSchema = object({
23623
+ everyMs: number().int().positive(),
23624
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23625
+ });
23214
23626
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23215
23627
  var ExportTimelapseSchema = object({
23216
23628
  everyMs: number().int().positive(),
23217
- outputFps: number().int().min(1).max(60).optional()
23629
+ outputFps: number().int().min(1).max(60).optional(),
23630
+ /** Optional second, FASTER rate over the intervals that matter. */
23631
+ dense: ExportDenseSchema.optional()
23632
+ }).superRefine((v, ctx) => {
23633
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23634
+ code: ZodIssueCode.custom,
23635
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23636
+ path: ["dense", "everyMs"]
23637
+ });
23218
23638
  });
23219
23639
  /**
23220
23640
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23272,6 +23692,19 @@ var ExportDownloadSchema = object({
23272
23692
  url: string(),
23273
23693
  endpoints: array(string())
23274
23694
  });
23695
+ /**
23696
+ * A finished export's bytes, inline.
23697
+ *
23698
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23699
+ * against, so nobody has to infer it from the base64 length.
23700
+ */
23701
+ var ExportBytesSchema = object({
23702
+ base64: string(),
23703
+ contentType: string(),
23704
+ /** Suggested filename, extension included. */
23705
+ name: string(),
23706
+ bytes: number().int().nonnegative()
23707
+ });
23275
23708
  method(object({
23276
23709
  deviceId: number(),
23277
23710
  profile: string(),
@@ -23296,6 +23729,9 @@ method(object({
23296
23729
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23297
23730
  kind: "query",
23298
23731
  auth: "protected"
23732
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23733
+ kind: "query",
23734
+ auth: "protected"
23299
23735
  });
23300
23736
  /**
23301
23737
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28489,6 +28925,12 @@ Object.freeze({
28489
28925
  addonId: null,
28490
28926
  access: "create"
28491
28927
  },
28928
+ "recording.cancelRelocateJob": {
28929
+ capName: "recording",
28930
+ capScope: "system",
28931
+ addonId: null,
28932
+ access: "create"
28933
+ },
28492
28934
  "recording.cancelStorageMigrationMove": {
28493
28935
  capName: "recording",
28494
28936
  capScope: "system",
@@ -28543,6 +28985,12 @@ Object.freeze({
28543
28985
  addonId: null,
28544
28986
  access: "view"
28545
28987
  },
28988
+ "recording.listRelocateJobs": {
28989
+ capName: "recording",
28990
+ capScope: "system",
28991
+ addonId: null,
28992
+ access: "view"
28993
+ },
28546
28994
  "recording.locateSegment": {
28547
28995
  capName: "recording",
28548
28996
  capScope: "system",
@@ -28555,6 +29003,12 @@ Object.freeze({
28555
29003
  addonId: null,
28556
29004
  access: "create"
28557
29005
  },
29006
+ "recording.planStorageRebalance": {
29007
+ capName: "recording",
29008
+ capScope: "system",
29009
+ addonId: null,
29010
+ access: "view"
29011
+ },
28558
29012
  "recording.pruneFootage": {
28559
29013
  capName: "recording",
28560
29014
  capScope: "system",
@@ -28579,6 +29033,12 @@ Object.freeze({
28579
29033
  addonId: null,
28580
29034
  access: "create"
28581
29035
  },
29036
+ "recording.relocateFootage": {
29037
+ capName: "recording",
29038
+ capScope: "system",
29039
+ addonId: null,
29040
+ access: "create"
29041
+ },
28582
29042
  "recording.renderClip": {
28583
29043
  capName: "recording",
28584
29044
  capScope: "system",
@@ -28615,38 +29075,50 @@ Object.freeze({
28615
29075
  addonId: null,
28616
29076
  access: "create"
28617
29077
  },
29078
+ "recording.startStorageRebalance": {
29079
+ capName: "recording",
29080
+ capScope: "system",
29081
+ addonId: null,
29082
+ access: "create"
29083
+ },
28618
29084
  "recordingExport.cancelExport": {
28619
- capName: "recordingExport",
29085
+ capName: "recording-export",
28620
29086
  capScope: "system",
28621
29087
  addonId: null,
28622
29088
  access: "create"
28623
29089
  },
28624
29090
  "recordingExport.createExport": {
28625
- capName: "recordingExport",
29091
+ capName: "recording-export",
28626
29092
  capScope: "system",
28627
29093
  addonId: null,
28628
29094
  access: "create"
28629
29095
  },
28630
29096
  "recordingExport.deleteExport": {
28631
- capName: "recordingExport",
29097
+ capName: "recording-export",
28632
29098
  capScope: "system",
28633
29099
  addonId: null,
28634
29100
  access: "delete"
28635
29101
  },
28636
29102
  "recordingExport.getDownloadUrl": {
28637
- capName: "recordingExport",
29103
+ capName: "recording-export",
28638
29104
  capScope: "system",
28639
29105
  addonId: null,
28640
29106
  access: "view"
28641
29107
  },
28642
29108
  "recordingExport.getExport": {
28643
- capName: "recordingExport",
29109
+ capName: "recording-export",
28644
29110
  capScope: "system",
28645
29111
  addonId: null,
28646
29112
  access: "view"
28647
29113
  },
28648
29114
  "recordingExport.listExports": {
28649
- capName: "recordingExport",
29115
+ capName: "recording-export",
29116
+ capScope: "system",
29117
+ addonId: null,
29118
+ access: "view"
29119
+ },
29120
+ "recordingExport.readExportBytes": {
29121
+ capName: "recording-export",
28650
29122
  capScope: "system",
28651
29123
  addonId: null,
28652
29124
  access: "view"
@@ -30023,6 +30495,104 @@ var FramerateField = number().int().min(1).max(60);
30023
30495
  var TargetsField = array(NcRuleTargetSchema).min(1);
30024
30496
  var PriorityField = number().int().min(1).max(5);
30025
30497
  /**
30498
+ * Explicit override of the DENSE sampling cadence, seconds.
30499
+ *
30500
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30501
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30502
+ * made that same base 3 s and rendered a person pass as two frames.)
30503
+ *
30504
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30505
+ * `denseCadenceSec` and played at `framerate` occupies
30506
+ *
30507
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30508
+ *
30509
+ * 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.
30510
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30511
+ * and therefore the length of a quiet night, does not move.
30512
+ *
30513
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30514
+ * the recording has them returns the same frames, requested twice. Must be
30515
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30516
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30517
+ * rather than letting the export cap reject the render hours after the window.
30518
+ */
30519
+ var DenseCadenceSecField = number().min(.1).max(3600);
30520
+ /**
30521
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30522
+ *
30523
+ * The operator-facing form of the arithmetic above: instead of solving for a
30524
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30525
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30526
+ * that range every ~583 ms.
30527
+ *
30528
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30529
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30530
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30531
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30532
+ * schema change and are the tracked follow-up.
30533
+ *
30534
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30535
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30536
+ * by real footage, never met by duplicating frames into motion that never
30537
+ * happened.
30538
+ */
30539
+ var MinDwellSecField = number().min(0).max(60);
30540
+ /**
30541
+ * Caption burned into the notification's preview frame.
30542
+ *
30543
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30544
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30545
+ * templating dialect for one field would be a second thing to explain.
30546
+ *
30547
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30548
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30549
+ * the reason this is not `.min(1)`.
30550
+ */
30551
+ var PreviewTextField = string().max(200);
30552
+ /**
30553
+ * Whether the notification's preview is a STILL or a short animation.
30554
+ *
30555
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30556
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30557
+ * night reads better as three seconds of motion than as one frame of it. Both
30558
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30559
+ * simply applies it to a dozen frames sampled across the render and assembles
30560
+ * them.
30561
+ *
30562
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30563
+ * seeks and a palette pass, and no rule that never asked for one should start
30564
+ * paying that on the deploy that shipped it.
30565
+ *
30566
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30567
+ */
30568
+ var PreviewModeField = _enum(["image", "gif"]);
30569
+ /**
30570
+ * Which detection classes the notification reports counts for.
30571
+ *
30572
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30573
+ * plan — no second query — aggregated per class. Absent or empty means "every
30574
+ * class the window actually contained", which is what an operator who never
30575
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30576
+ * counts cars all night).
30577
+ *
30578
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30579
+ * …). An unknown name simply never matches and reports nothing — it is not an
30580
+ * error, because a rule may legitimately name a class this camera's model does
30581
+ * not emit.
30582
+ *
30583
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30584
+ * - `{{detections}}` — total over the reported classes
30585
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30586
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30587
+ * one per class, `count_` + the class name
30588
+ *
30589
+ * With NO custom body template the summary is appended to the derived body, and
30590
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30591
+ * reads. With a custom template the operator owns every word — nothing is
30592
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30593
+ */
30594
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30595
+ /**
30026
30596
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30027
30597
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30028
30598
  * here (see the ownership note above).
@@ -30042,9 +30612,30 @@ var TimelapseRuleInputSchema = object({
30042
30612
  cadenceSec: CadenceSecField.default(15),
30043
30613
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30044
30614
  framerate: FramerateField.default(10),
30615
+ /**
30616
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30617
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30618
+ * field gets.
30619
+ */
30620
+ denseCadenceSec: DenseCadenceSecField.optional(),
30621
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30622
+ minDwellSec: MinDwellSecField.optional(),
30045
30623
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30046
30624
  targets: TargetsField,
30047
30625
  template: TimelapseTemplateSchema.optional(),
30626
+ /**
30627
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30628
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30629
+ *
30630
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30631
+ * the notification's title/body, and clearing it (`template: null`) must not
30632
+ * silently clear the caption too.
30633
+ */
30634
+ previewText: PreviewTextField.optional(),
30635
+ /** Still or animation — see {@link PreviewModeField}. */
30636
+ previewMode: PreviewModeField.default("image"),
30637
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30638
+ reportClasses: ReportClassesField.optional(),
30048
30639
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30049
30640
  priority: PriorityField.default(3)
30050
30641
  });
@@ -30055,8 +30646,13 @@ object({
30055
30646
  schedule: NcScheduleSchema.optional(),
30056
30647
  cadenceSec: CadenceSecField.optional(),
30057
30648
  framerate: FramerateField.optional(),
30649
+ denseCadenceSec: DenseCadenceSecField.optional(),
30650
+ minDwellSec: MinDwellSecField.optional(),
30058
30651
  targets: TargetsField.optional(),
30059
30652
  template: TimelapseTemplateSchema.nullable().optional(),
30653
+ previewText: PreviewTextField.optional(),
30654
+ previewMode: PreviewModeField.optional(),
30655
+ reportClasses: ReportClassesField.optional(),
30060
30656
  priority: PriorityField.optional()
30061
30657
  });
30062
30658
  TimelapseRuleInputSchema.extend({
@@ -30068,10 +30664,28 @@ TimelapseRuleInputSchema.extend({
30068
30664
  */
30069
30665
  ownerUserId: string().optional(),
30070
30666
  /**
30071
- * Epoch-ms of the last successful generation the 1-hour re-generation
30072
- * guard's durable state (predecessor parity). Absent = never generated.
30667
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30668
+ * rule. What a UI shows, and the compatibility floor for
30669
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30073
30670
  */
30074
30671
  lastGeneratedAt: number().optional(),
30672
+ /**
30673
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30674
+ * re-generation guard's real durable state.
30675
+ *
30676
+ * One rule covers several cameras and each renders its own video, so a rule
30677
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30678
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30679
+ * already done — and B's night is gone for good, because the window will not
30680
+ * come back.
30681
+ *
30682
+ * ADDITIVE, so the migration is free: a row written before this field simply
30683
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30684
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30685
+ * "never generated" would re-render and re-notify every camera of every rule
30686
+ * once, on the deploy that shipped the map.
30687
+ */
30688
+ generatedByDevice: record(string(), number()).optional(),
30075
30689
  /** userId of the caller who created the rule (server-stamped). */
30076
30690
  createdBy: string(),
30077
30691
  createdAt: number(),
@@ -30122,25 +30736,32 @@ object({
30122
30736
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30123
30737
  object({
30124
30738
  /**
30125
- * How long a retained native frame is served before it counts as a miss.
30739
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30740
+ * detection result.
30741
+ *
30742
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30743
+ * a time window was never related to the event the pixels were waiting for.
30744
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30745
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30746
+ * releases the frame. The bound exists only so a runner that stops answering
30747
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30126
30748
  *
30127
- * Must cover the FULL late-crop horizon: detection inference + the
30128
- * cross-process inference-result hop to hub post-analysis + tracking + the
30129
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30130
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30131
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30749
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30750
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30751
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30752
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
30753
+ * `holdOverflow` on the metrics line is what says you need it.
30132
30754
  */
30133
- ttlMs: number().int().min(250).max(1e4),
30755
+ holdFrames: number().int().min(1).max(64),
30134
30756
  /**
30135
30757
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30136
30758
  *
30137
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30138
- * which one is actually binding before reasoning from that. At the shipped
30139
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30140
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30141
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30142
- * change that admits fewer frames buys retention WINDOW at constant RAM
30143
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30759
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30760
+ * is what decides how much is held, and the ceiling is the number above which
30761
+ * something is wrong. Before that it was the effective cap at 1024 MB with
30762
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30763
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30764
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30144
30765
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30145
30766
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30146
30767
  * to replace).
@@ -30166,22 +30787,45 @@ object({
30166
30787
  * there is the signal that some caller names frames outside the inference set
30167
30788
  * and that this must go back to `all`.
30168
30789
  */
30169
- admission: NativeLeaseAdmissionSchema
30790
+ admission: NativeLeaseAdmissionSchema,
30791
+ /**
30792
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30793
+ * compressed native crops the worker cuts at the moment a frame's detection
30794
+ * result arrives, and keeps long after the frame itself is freed.
30795
+ *
30796
+ * This is the knob that replaced the old retention window, and it buys about
30797
+ * three orders of magnitude more of it: a tile is one subject at native
30798
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30799
+ * the frame it was cut from. A frame on which nothing was detected costs
30800
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30801
+ * was interrogated per SUBJECT.
30802
+ *
30803
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30804
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30805
+ * reproduce that.
30806
+ */
30807
+ tileBudgetMb: number().int().min(0).max(1024)
30170
30808
  });
30171
30809
  /**
30172
- * The values in force when the operator has set nothing — byte-for-byte the
30173
- * constants the decode worker shipped with as env-var defaults, so making these
30174
- * settings changed no behaviour on the day it landed.
30810
+ * The values in force when the operator has set nothing.
30811
+ *
30812
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30813
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30814
+ * in the same change that redefines it would make a regression and a retune
30815
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30816
+ * live traffic.
30175
30817
  */
30176
30818
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30177
- ttlMs: 1200,
30819
+ holdFrames: 8,
30178
30820
  budgetMb: 1024,
30179
30821
  activityMs: 15e3,
30822
+ tileBudgetMb: 64,
30180
30823
  admission: "inferred"
30181
30824
  };
30182
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30825
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30183
30826
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30184
30827
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30828
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30185
30829
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30186
30830
  //#endregion
30187
30831
  //#region src/static-turn.addon.ts