@camstack/addon-remote-storage 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.
@@ -7190,8 +7190,31 @@ var AdoptionJobSchema = object({
7190
7190
  error: string().nullable()
7191
7191
  });
7192
7192
  /**
7193
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7194
- * pipeline functions an operator thinks in terms of.
7193
+ * Per-camera FUNCTION SWITCHES.
7194
+ *
7195
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7196
+ *
7197
+ * This file shipped as "the one coherent on/off surface over the pipeline
7198
+ * functions an operator thinks in terms of". The operator's verdict on
7199
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7200
+ * every function already had a settings page of its own, and a second place to
7201
+ * turn it off is a second place to look. Each switch is going back to its own
7202
+ * component's original options — detection to the detection-pipeline wrapper
7203
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7204
+ * (which was always first-class; the switch was a veneer over
7205
+ * `recording.setDeviceConfig`), notifications to a notification-center
7206
+ * per-device setting, the two camera planes to their own components.
7207
+ *
7208
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7209
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7210
+ * straight from the authorities with no group in the middle. That rule was
7211
+ * never about a control panel.
7212
+ *
7213
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7214
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7215
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7216
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7217
+ * stop; nothing new may be built on it.
7195
7218
  *
7196
7219
  * ## This file adds no state
7197
7220
  *
@@ -7542,7 +7565,15 @@ var RecordingConfigSchema = object({
7542
7565
  * Each completed/failed run also lands one durable ops-log row on its owning
7543
7566
  * addon surface.
7544
7567
  */
7568
+ /**
7569
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7570
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7571
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7572
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7573
+ * runs at all.
7574
+ */
7545
7575
  var RelocateJobStateSchema = _enum([
7576
+ "queued",
7546
7577
  "running",
7547
7578
  "done",
7548
7579
  "failed",
@@ -7577,6 +7608,15 @@ var RelocateFootageInputSchema = object({
7577
7608
  /** Limits relocation to the logical profile class. Omit only for the
7578
7609
  * pre-orchestration compatibility path. */
7579
7610
  footageClass: RelocateFootageClassSchema.optional(),
7611
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7612
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7613
+ * unit is a (camera, profile) pile, not a disk. */
7614
+ deviceId: number().int().optional(),
7615
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7616
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7617
+ * placement plan assigns those two independently, so a rebalance that could
7618
+ * only say "recordings" would move footage the plan never asked to move. */
7619
+ profiles: array(string()).optional(),
7580
7620
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7581
7621
  * never allowed to starve live writers. */
7582
7622
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7712,6 +7752,21 @@ var StorageLocationSchema = object({
7712
7752
  nodeId: string().optional(),
7713
7753
  isDefault: boolean().default(false),
7714
7754
  isSystem: boolean().default(false),
7755
+ /**
7756
+ * Operator opt-in: whether consumers that BALANCE across several locations
7757
+ * of a type may write here. Recordings reads it today; event media and
7758
+ * backups are the next consumers, which is why the flag lives on the
7759
+ * location rather than in any one addon's store — nothing has to be
7760
+ * extended to add the next consumer.
7761
+ *
7762
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7763
+ * flag existed reads back with no flag and keeps working exactly as before;
7764
+ * that is the whole compat story, and it is why no migration ships with it.
7765
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7766
+ * disk must not silently start writing to it); the default of a type is
7767
+ * always stamped `true`.
7768
+ */
7769
+ enabled: boolean().optional(),
7715
7770
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7716
7771
  * for node-local locations it can reach) — never persisted, absent when the
7717
7772
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12014,7 +12069,8 @@ method(object({
12014
12069
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12015
12070
  /**
12016
12071
  * filesystem-browse — per-node capability for browsing the node's local
12017
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12072
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12073
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12018
12074
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12019
12075
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12020
12076
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13827,6 +13883,13 @@ var MaskGridDimsSchema = object({
13827
13883
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13828
13884
  * this one field keeps the schema additive — a rule still declares exactly
13829
13885
  * one trigger.
13886
+ *
13887
+ * AUDIO rules add no member here, for the reason occupancy added none: the
13888
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
13889
+ * mirror.ts` fails the build on a member the app cannot render) and every
13890
+ * member costs a release train. A sustained-sound rule is therefore an
13891
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
13892
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13830
13893
  */
13831
13894
  var NcDeliverySchema = _enum([
13832
13895
  "immediate",
@@ -13841,15 +13904,32 @@ var NcDeliverySchema = _enum([
13841
13904
  * depend on a provider's raw event name or payload shape.
13842
13905
  */
13843
13906
  var NcSystemEventKindSchema = _enum([
13844
- "camera-online",
13845
- "camera-offline",
13907
+ "device-online",
13908
+ "device-offline",
13909
+ "device-disabled",
13910
+ "device-enabled",
13846
13911
  "stream-online",
13847
13912
  "stream-offline",
13848
13913
  "node-online",
13849
13914
  "node-offline",
13850
13915
  "addon-update-available",
13851
- "server-update-available"
13916
+ "server-update-available",
13917
+ "alarm-triggered",
13918
+ "alarm-armed",
13919
+ "alarm-disarmed",
13920
+ "camera-online",
13921
+ "camera-offline",
13922
+ "camera-disabled",
13923
+ "camera-enabled"
13924
+ ]);
13925
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
13926
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
13927
+ "camera-online",
13928
+ "camera-offline",
13929
+ "camera-disabled",
13930
+ "camera-enabled"
13852
13931
  ]);
13932
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13853
13933
  /**
13854
13934
  * One coherent system-event condition. `kinds` is the required opt-in safety
13855
13935
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -13858,6 +13938,18 @@ var NcSystemEventKindSchema = _enum([
13858
13938
  var NcSystemEventConditionSchema = object({
13859
13939
  kinds: array(NcSystemEventKindSchema).min(1),
13860
13940
  deviceIds: array(number().int()).min(1).optional(),
13941
+ /**
13942
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
13943
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
13944
+ * is what a liveness rule means when nobody said otherwise.
13945
+ *
13946
+ * This is where "only my cameras" is expressed, and it lives on the rule for
13947
+ * one reason: the intake cannot know which devices this household cares
13948
+ * about, and a producer-side filter is one no operator can change. Fails
13949
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
13950
+ * does not carry) matches no `deviceTypes` list.
13951
+ */
13952
+ deviceTypes: array(string().min(1)).min(1).optional(),
13861
13953
  nodeIds: array(string().min(1)).min(1).optional(),
13862
13954
  packageNames: array(string().min(1)).min(1).optional()
13863
13955
  });
@@ -13908,6 +14000,47 @@ var NcOccupancyConditionSchema = object({
13908
14000
  sustainSeconds: number().int().min(0).max(3600).default(15)
13909
14001
  });
13910
14002
  /**
14003
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14004
+ *
14005
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14006
+ * reference notifier uses, so an operator moving between them re-uses what
14007
+ * they already know): a rule matches when, over a sampling window of
14008
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14009
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14010
+ *
14011
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14012
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14013
+ * - `labels` — the classifier put at least one of these labels on it.
14014
+ *
14015
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14016
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14017
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14018
+ * is given** — a window in which every sample is trivially a hit would fire on
14019
+ * silence, so the engine refuses such a condition rather than notifying on
14020
+ * nothing (the schema cannot express "at least one of" without becoming a
14021
+ * ZodEffects the cap path would have to special-case).
14022
+ *
14023
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14024
+ * must be FULL before it can match — a window that has been open for two
14025
+ * seconds of its ten is 100% of nothing, and firing on it would make
14026
+ * `samplingSeconds` decorative.
14027
+ *
14028
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14029
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14030
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14031
+ * an operator who typed `dog` mean the same thing.
14032
+ */
14033
+ var NcAudioConditionSchema = object({
14034
+ /** Audio macro labels; absent = any sound (level-only rule). */
14035
+ labels: array(string().min(1)).min(1).optional(),
14036
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14037
+ dbThreshold: number().min(-96).max(0).optional(),
14038
+ /** Percentage of the window's samples that must be hits (1–100). */
14039
+ hitPercent: number().int().min(1).max(100).default(60),
14040
+ /** Length of the sampling window in seconds. */
14041
+ samplingSeconds: number().int().min(1).max(300).default(10)
14042
+ });
14043
+ /**
13911
14044
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
13912
14045
  *
13913
14046
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14180,7 +14313,33 @@ var NcConditionsSchema = object({
14180
14313
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14181
14314
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14182
14315
  */
14183
- occupancy: NcOccupancyConditionSchema.optional()
14316
+ occupancy: NcOccupancyConditionSchema.optional(),
14317
+ /**
14318
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14319
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14320
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14321
+ * a window that is not full yet, neither filter given). See
14322
+ * {@link NcAudioCondition}.
14323
+ *
14324
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14325
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14326
+ * a detection, a track or a device event (the same fail-closed pairing
14327
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14328
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14329
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14330
+ * classified sample) stays exactly as it was for rules that already use it.
14331
+ *
14332
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14333
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14334
+ * (`camstack/src/data/notification-center.ts`, guarded by
14335
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14336
+ * condition fields it does not know when a rule is saved from the phone.
14337
+ * Publishing an editor for a condition the app cannot round-trip is how an
14338
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14339
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14340
+ * does an audio rule become authorable.
14341
+ */
14342
+ audio: NcAudioConditionSchema.optional()
14184
14343
  });
14185
14344
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14186
14345
  var NcRuleTargetSchema = object({
@@ -14294,6 +14453,73 @@ var NcThrottleSchema = object({
14294
14453
  */
14295
14454
  granularity: NcThrottleGranularitySchema.optional()
14296
14455
  });
14456
+ /**
14457
+ * How long the confirm gate may hold ONE notification, and how big the picture
14458
+ * it judges may be.
14459
+ *
14460
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14461
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14462
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14463
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14464
+ * tokens for pixels the model pools away.
14465
+ */
14466
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14467
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14468
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14469
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14470
+ var NcConfirmExpectSchema = object({
14471
+ op: _enum([
14472
+ ">=",
14473
+ ">",
14474
+ "<=",
14475
+ "<",
14476
+ "=="
14477
+ ]),
14478
+ count: number().int().min(0).max(1e3)
14479
+ });
14480
+ /**
14481
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14482
+ * to ship and says whether it agrees with the rule.
14483
+ *
14484
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14485
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14486
+ * on the operator's phone is not a verdict about this notification.
14487
+ *
14488
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14489
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14490
+ * the default and every fail-open is COUNTED, because a gate that always fails
14491
+ * open looks in the log exactly like a gate that works.
14492
+ *
14493
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14494
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14495
+ * production failures in one day), so the gate reads absent as the constant
14496
+ * above rather than trusting a parse it may never have seen.
14497
+ */
14498
+ var NcConfirmSchema = object({
14499
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14500
+ * same thing, and both mean "deliver exactly as before". */
14501
+ enabled: boolean().default(false),
14502
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14503
+ profileId: string().optional(),
14504
+ /**
14505
+ * The operator's question, in his own words. Absent = a question derived
14506
+ * from the rule (its class and its expectation).
14507
+ *
14508
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14509
+ * banners, signage and plates as instructions if you let them reach the
14510
+ * prompt — proven live — so the authoritative contract stays in the system
14511
+ * turn and only rule-authored words land here.
14512
+ */
14513
+ prompt: string().max(1e3).optional(),
14514
+ /** Fire only when the model's count satisfies this. Absent = the model's
14515
+ * own boolean verdict decides. */
14516
+ expect: NcConfirmExpectSchema.optional(),
14517
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14518
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14519
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14520
+ /** Longest edge the judged image is downscaled to before it is sent. */
14521
+ maxImagePx: number().int().min(64).max(2048).default(448)
14522
+ });
14297
14523
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14298
14524
  var NcRuleInputSchema = object({
14299
14525
  name: string().min(1).max(200),
@@ -14354,7 +14580,13 @@ var NcRuleInputSchema = object({
14354
14580
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14355
14581
  * shape as every other actuation.
14356
14582
  */
14357
- actions: NcRuleActionsSchema.optional()
14583
+ actions: NcRuleActionsSchema.optional(),
14584
+ /**
14585
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14586
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14587
+ * did, and absent is the only way to say that without a migration.
14588
+ */
14589
+ confirm: NcConfirmSchema.optional()
14358
14590
  });
14359
14591
  /**
14360
14592
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14365,7 +14597,37 @@ var NcRuleInputSchema = object({
14365
14597
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14366
14598
  * `updateRule` patch.
14367
14599
  */
14368
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14600
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14601
+ disabledTargetIds: array(string()).optional(),
14602
+ /**
14603
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14604
+ *
14605
+ * It makes the key optional to SUPPLY; the parse still materialises the
14606
+ * default when the key is absent. And `NcRuleStore.update` merges with
14607
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14608
+ * one — which made every partial edit destructive:
14609
+ *
14610
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14611
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14612
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14613
+ *
14614
+ * A rule scoped to one camera and one zone silently became a rule that
14615
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14616
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14617
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14618
+ * within a minute of a two-field patch.
14619
+ *
14620
+ * So every defaulted field is re-declared here WITHOUT its default. The
14621
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14622
+ * conditions remains a real instruction ("clear them") — and only the
14623
+ * absent key is now genuinely absent.
14624
+ */
14625
+ enabled: boolean().optional(),
14626
+ conditions: NcConditionsSchema.optional(),
14627
+ media: NcMediaPolicySchema.optional(),
14628
+ throttle: NcThrottleSchema.optional(),
14629
+ priority: number().int().min(1).max(5).optional()
14630
+ });
14369
14631
  /** A persisted rule. */
14370
14632
  var NcRuleSchema = NcRuleInputSchema.extend({
14371
14633
  id: string(),
@@ -14666,6 +14928,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14666
14928
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14667
14929
  * copy would lie the first time a rule is disabled.
14668
14930
  */
14931
+ /**
14932
+ * Why a device a mode NAMES is nonetheless not armed by it.
14933
+ *
14934
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
14935
+ * per-camera notification switch the Notification Center already owns,
14936
+ * `detection-off` is the device's own detection binding being inactive, and
14937
+ * `offline` is the device manager's liveness. A fourth reason would mean a
14938
+ * fourth authority, and inventing one here is how a panel starts disagreeing
14939
+ * with the switches the operator actually used.
14940
+ */
14941
+ var NcAlarmSkipReasonSchema = _enum([
14942
+ "muted",
14943
+ "detection-off",
14944
+ "offline"
14945
+ ]);
14946
+ var NcAlarmSkippedDeviceSchema = object({
14947
+ deviceId: number().int(),
14948
+ reason: NcAlarmSkipReasonSchema
14949
+ });
14669
14950
  var NcAlarmModeCoverageSchema = object({
14670
14951
  mode: AlarmArmModeSchema,
14671
14952
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14673,7 +14954,18 @@ var NcAlarmModeCoverageSchema = object({
14673
14954
  /** At least one covering rule has no device scope, so the mode covers all. */
14674
14955
  allDevices: boolean(),
14675
14956
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14676
- deviceIds: array(number().int())
14957
+ deviceIds: array(number().int()),
14958
+ /**
14959
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
14960
+ * excludes it.
14961
+ *
14962
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
14963
+ * twelve makes it false in exactly the way nobody notices until an incident.
14964
+ * Defaulted to `[]` so a coverage answer computed before this field existed
14965
+ * still parses as "nothing known to be skipped" rather than failing the whole
14966
+ * alarm tab.
14967
+ */
14968
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14677
14969
  });
14678
14970
  var NcAlarmConfigSchema = object({
14679
14971
  /**
@@ -17472,9 +17764,16 @@ var CameraStatusSchema = object({
17472
17764
  audio: CameraAudioStatusSchema.nullable(),
17473
17765
  recording: CameraRecordingStatusSchema.nullable(),
17474
17766
  /**
17475
- * Per-camera function switches an OPERATOR has turned off
17767
+ * Per-camera functions an OPERATOR has turned off
17476
17768
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17477
17769
  *
17770
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17771
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17772
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17773
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17774
+ * The badge outlives the control panel: the panel was a convenience, this is
17775
+ * the difference between a camera being off and a camera being dead.
17776
+ *
17478
17777
  * This is the difference between DISABLED and BROKEN. A camera whose
17479
17778
  * `detection` block reports zero fps and whose `switchedOff` contains
17480
17779
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23028,7 +23327,19 @@ var RecordingManifestSchema = object({
23028
23327
  * profiles/subtrees/locations on this node). */
23029
23328
  var RecordingDeviceUsageSchema = object({
23030
23329
  deviceId: number(),
23031
- usedBytes: number()
23330
+ usedBytes: number(),
23331
+ /**
23332
+ * Start of this camera's OLDEST indexed segment, across every profile and
23333
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23334
+ * only honest answer to "is retention actually holding?" per camera.
23335
+ *
23336
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23337
+ * predates this field omits it entirely, and a hub whose types carry the
23338
+ * field must keep validating that older provider's payload: the framework
23339
+ * (types) and the addon ship on different trains, and the addon is usually
23340
+ * the later of the two.
23341
+ */
23342
+ oldestMs: number().nullable().optional()
23032
23343
  });
23033
23344
  /** Recording storage usage + capacity for one storage location. */
23034
23345
  var RecordingLocationUsageSchema = object({
@@ -23056,6 +23367,57 @@ var RecordingStorageUsageSchema = object({
23056
23367
  locations: array(RecordingLocationUsageSchema)
23057
23368
  });
23058
23369
  /**
23370
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23371
+ *
23372
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23373
+ * is the operator asking for the EXISTING archive to be brought into line with
23374
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23375
+ * location, run FIFO behind the single-flight mover.
23376
+ *
23377
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23378
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23379
+ * (empty on the plan).
23380
+ */
23381
+ var RecordingRebalanceMoveSchema = object({
23382
+ deviceId: number(),
23383
+ profile: string(),
23384
+ fromLocationId: string(),
23385
+ toLocationId: string(),
23386
+ bytes: number(),
23387
+ files: number().int()
23388
+ });
23389
+ /** Why a pile that is out of place is staying there. Every refusal is
23390
+ * reported: a rebalance that silently drops a camera reads exactly like one
23391
+ * that had nothing to do. */
23392
+ var RecordingRebalanceSkipReasonSchema = _enum([
23393
+ "unassigned",
23394
+ "target-not-writable",
23395
+ "below-threshold",
23396
+ "no-headroom"
23397
+ ]);
23398
+ var RecordingRebalanceSkipSchema = object({
23399
+ deviceId: number(),
23400
+ profile: string(),
23401
+ fromLocationId: string(),
23402
+ /** The location the plan wants; null when the camera has no assignment. */
23403
+ toLocationId: string().nullable(),
23404
+ bytes: number(),
23405
+ reason: RecordingRebalanceSkipReasonSchema
23406
+ });
23407
+ var RecordingRebalancePlanSchema = object({
23408
+ moves: array(RecordingRebalanceMoveSchema),
23409
+ skipped: array(RecordingRebalanceSkipSchema),
23410
+ bytesToMove: number(),
23411
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23412
+ jobIds: array(string())
23413
+ });
23414
+ var RecordingRebalanceInputSchema = object({
23415
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23416
+ throttleMbps: number().min(1).max(1e3).optional(),
23417
+ /** Ignore piles smaller than this (default 1 GB). */
23418
+ minMoveGb: number().min(0).optional()
23419
+ });
23420
+ /**
23059
23421
  * Result of locating footage at a wall-clock instant for one device/profile.
23060
23422
  * `segment` carries the covering segment's window; `gap` reports the forward
23061
23423
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23218,9 +23580,24 @@ method(object({
23218
23580
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23219
23581
  kind: "mutation",
23220
23582
  auth: "admin"
23583
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23584
+ kind: "mutation",
23585
+ auth: "admin"
23586
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23587
+ kind: "query",
23588
+ auth: "admin"
23589
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23590
+ kind: "mutation",
23591
+ auth: "admin"
23592
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23593
+ kind: "query",
23594
+ auth: "admin"
23595
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23596
+ kind: "mutation",
23597
+ auth: "admin"
23221
23598
  });
23222
23599
  /**
23223
- * `recordingExport` cap — render a footage time range into a single downloadable
23600
+ * `recording-export` cap — render a footage time range into a single downloadable
23224
23601
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23225
23602
  * bounded lifetime with a durable history, auto-expiry, and optional
23226
23603
  * delete-after-download.
@@ -23235,10 +23612,53 @@ method(object({
23235
23612
  */
23236
23613
  /** Playback-speed multiplier for the render (1 = realtime). */
23237
23614
  var ExportSpeedSchema = number().min(.25).max(32);
23615
+ /**
23616
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23617
+ *
23618
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23619
+ * derives these bounds from things that happened at a TIME (a track's
23620
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23621
+ * every segment present for the range, with each recording GAP removed. The
23622
+ * two agree only on a window that recorded without one interruption, and only
23623
+ * the render side knows the segments, so the translation lives there
23624
+ * (`export-dense-map.ts`, addon-pipeline).
23625
+ *
23626
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23627
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23628
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23629
+ * the video was a uniform timelapse, and the log line reported the five ranges
23630
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23631
+ *
23632
+ * Relative and not absolute epoch, because an absolute epoch would make every
23633
+ * call site responsible for the same subtraction.
23634
+ */
23635
+ var ExportDenseRangeSchema = object({
23636
+ fromSec: number().nonnegative(),
23637
+ toSec: number().nonnegative()
23638
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23639
+ /**
23640
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23641
+ * listed ranges and at the base `everyMs` everywhere else.
23642
+ *
23643
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23644
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23645
+ */
23646
+ var ExportDenseSchema = object({
23647
+ everyMs: number().int().positive(),
23648
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23649
+ });
23238
23650
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23239
23651
  var ExportTimelapseSchema = object({
23240
23652
  everyMs: number().int().positive(),
23241
- outputFps: number().int().min(1).max(60).optional()
23653
+ outputFps: number().int().min(1).max(60).optional(),
23654
+ /** Optional second, FASTER rate over the intervals that matter. */
23655
+ dense: ExportDenseSchema.optional()
23656
+ }).superRefine((v, ctx) => {
23657
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23658
+ code: ZodIssueCode.custom,
23659
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23660
+ path: ["dense", "everyMs"]
23661
+ });
23242
23662
  });
23243
23663
  /**
23244
23664
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23296,6 +23716,19 @@ var ExportDownloadSchema = object({
23296
23716
  url: string(),
23297
23717
  endpoints: array(string())
23298
23718
  });
23719
+ /**
23720
+ * A finished export's bytes, inline.
23721
+ *
23722
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23723
+ * against, so nobody has to infer it from the base64 length.
23724
+ */
23725
+ var ExportBytesSchema = object({
23726
+ base64: string(),
23727
+ contentType: string(),
23728
+ /** Suggested filename, extension included. */
23729
+ name: string(),
23730
+ bytes: number().int().nonnegative()
23731
+ });
23299
23732
  method(object({
23300
23733
  deviceId: number(),
23301
23734
  profile: string(),
@@ -23320,6 +23753,9 @@ method(object({
23320
23753
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23321
23754
  kind: "query",
23322
23755
  auth: "protected"
23756
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23757
+ kind: "query",
23758
+ auth: "protected"
23323
23759
  });
23324
23760
  /**
23325
23761
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28513,6 +28949,12 @@ Object.freeze({
28513
28949
  addonId: null,
28514
28950
  access: "create"
28515
28951
  },
28952
+ "recording.cancelRelocateJob": {
28953
+ capName: "recording",
28954
+ capScope: "system",
28955
+ addonId: null,
28956
+ access: "create"
28957
+ },
28516
28958
  "recording.cancelStorageMigrationMove": {
28517
28959
  capName: "recording",
28518
28960
  capScope: "system",
@@ -28567,6 +29009,12 @@ Object.freeze({
28567
29009
  addonId: null,
28568
29010
  access: "view"
28569
29011
  },
29012
+ "recording.listRelocateJobs": {
29013
+ capName: "recording",
29014
+ capScope: "system",
29015
+ addonId: null,
29016
+ access: "view"
29017
+ },
28570
29018
  "recording.locateSegment": {
28571
29019
  capName: "recording",
28572
29020
  capScope: "system",
@@ -28579,6 +29027,12 @@ Object.freeze({
28579
29027
  addonId: null,
28580
29028
  access: "create"
28581
29029
  },
29030
+ "recording.planStorageRebalance": {
29031
+ capName: "recording",
29032
+ capScope: "system",
29033
+ addonId: null,
29034
+ access: "view"
29035
+ },
28582
29036
  "recording.pruneFootage": {
28583
29037
  capName: "recording",
28584
29038
  capScope: "system",
@@ -28603,6 +29057,12 @@ Object.freeze({
28603
29057
  addonId: null,
28604
29058
  access: "create"
28605
29059
  },
29060
+ "recording.relocateFootage": {
29061
+ capName: "recording",
29062
+ capScope: "system",
29063
+ addonId: null,
29064
+ access: "create"
29065
+ },
28606
29066
  "recording.renderClip": {
28607
29067
  capName: "recording",
28608
29068
  capScope: "system",
@@ -28639,38 +29099,50 @@ Object.freeze({
28639
29099
  addonId: null,
28640
29100
  access: "create"
28641
29101
  },
29102
+ "recording.startStorageRebalance": {
29103
+ capName: "recording",
29104
+ capScope: "system",
29105
+ addonId: null,
29106
+ access: "create"
29107
+ },
28642
29108
  "recordingExport.cancelExport": {
28643
- capName: "recordingExport",
29109
+ capName: "recording-export",
28644
29110
  capScope: "system",
28645
29111
  addonId: null,
28646
29112
  access: "create"
28647
29113
  },
28648
29114
  "recordingExport.createExport": {
28649
- capName: "recordingExport",
29115
+ capName: "recording-export",
28650
29116
  capScope: "system",
28651
29117
  addonId: null,
28652
29118
  access: "create"
28653
29119
  },
28654
29120
  "recordingExport.deleteExport": {
28655
- capName: "recordingExport",
29121
+ capName: "recording-export",
28656
29122
  capScope: "system",
28657
29123
  addonId: null,
28658
29124
  access: "delete"
28659
29125
  },
28660
29126
  "recordingExport.getDownloadUrl": {
28661
- capName: "recordingExport",
29127
+ capName: "recording-export",
28662
29128
  capScope: "system",
28663
29129
  addonId: null,
28664
29130
  access: "view"
28665
29131
  },
28666
29132
  "recordingExport.getExport": {
28667
- capName: "recordingExport",
29133
+ capName: "recording-export",
28668
29134
  capScope: "system",
28669
29135
  addonId: null,
28670
29136
  access: "view"
28671
29137
  },
28672
29138
  "recordingExport.listExports": {
28673
- capName: "recordingExport",
29139
+ capName: "recording-export",
29140
+ capScope: "system",
29141
+ addonId: null,
29142
+ access: "view"
29143
+ },
29144
+ "recordingExport.readExportBytes": {
29145
+ capName: "recording-export",
28674
29146
  capScope: "system",
28675
29147
  addonId: null,
28676
29148
  access: "view"
@@ -30047,6 +30519,104 @@ var FramerateField = number().int().min(1).max(60);
30047
30519
  var TargetsField = array(NcRuleTargetSchema).min(1);
30048
30520
  var PriorityField = number().int().min(1).max(5);
30049
30521
  /**
30522
+ * Explicit override of the DENSE sampling cadence, seconds.
30523
+ *
30524
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30525
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30526
+ * made that same base 3 s and rendered a person pass as two frames.)
30527
+ *
30528
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30529
+ * `denseCadenceSec` and played at `framerate` occupies
30530
+ *
30531
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30532
+ *
30533
+ * 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.
30534
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30535
+ * and therefore the length of a quiet night, does not move.
30536
+ *
30537
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30538
+ * the recording has them returns the same frames, requested twice. Must be
30539
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30540
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30541
+ * rather than letting the export cap reject the render hours after the window.
30542
+ */
30543
+ var DenseCadenceSecField = number().min(.1).max(3600);
30544
+ /**
30545
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30546
+ *
30547
+ * The operator-facing form of the arithmetic above: instead of solving for a
30548
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30549
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30550
+ * that range every ~583 ms.
30551
+ *
30552
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30553
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30554
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30555
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30556
+ * schema change and are the tracked follow-up.
30557
+ *
30558
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30559
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30560
+ * by real footage, never met by duplicating frames into motion that never
30561
+ * happened.
30562
+ */
30563
+ var MinDwellSecField = number().min(0).max(60);
30564
+ /**
30565
+ * Caption burned into the notification's preview frame.
30566
+ *
30567
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30568
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30569
+ * templating dialect for one field would be a second thing to explain.
30570
+ *
30571
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30572
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30573
+ * the reason this is not `.min(1)`.
30574
+ */
30575
+ var PreviewTextField = string().max(200);
30576
+ /**
30577
+ * Whether the notification's preview is a STILL or a short animation.
30578
+ *
30579
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30580
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30581
+ * night reads better as three seconds of motion than as one frame of it. Both
30582
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30583
+ * simply applies it to a dozen frames sampled across the render and assembles
30584
+ * them.
30585
+ *
30586
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30587
+ * seeks and a palette pass, and no rule that never asked for one should start
30588
+ * paying that on the deploy that shipped it.
30589
+ *
30590
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30591
+ */
30592
+ var PreviewModeField = _enum(["image", "gif"]);
30593
+ /**
30594
+ * Which detection classes the notification reports counts for.
30595
+ *
30596
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30597
+ * plan — no second query — aggregated per class. Absent or empty means "every
30598
+ * class the window actually contained", which is what an operator who never
30599
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30600
+ * counts cars all night).
30601
+ *
30602
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30603
+ * …). An unknown name simply never matches and reports nothing — it is not an
30604
+ * error, because a rule may legitimately name a class this camera's model does
30605
+ * not emit.
30606
+ *
30607
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30608
+ * - `{{detections}}` — total over the reported classes
30609
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30610
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30611
+ * one per class, `count_` + the class name
30612
+ *
30613
+ * With NO custom body template the summary is appended to the derived body, and
30614
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30615
+ * reads. With a custom template the operator owns every word — nothing is
30616
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30617
+ */
30618
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30619
+ /**
30050
30620
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30051
30621
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30052
30622
  * here (see the ownership note above).
@@ -30066,9 +30636,30 @@ var TimelapseRuleInputSchema = object({
30066
30636
  cadenceSec: CadenceSecField.default(15),
30067
30637
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30068
30638
  framerate: FramerateField.default(10),
30639
+ /**
30640
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30641
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30642
+ * field gets.
30643
+ */
30644
+ denseCadenceSec: DenseCadenceSecField.optional(),
30645
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30646
+ minDwellSec: MinDwellSecField.optional(),
30069
30647
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30070
30648
  targets: TargetsField,
30071
30649
  template: TimelapseTemplateSchema.optional(),
30650
+ /**
30651
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30652
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30653
+ *
30654
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30655
+ * the notification's title/body, and clearing it (`template: null`) must not
30656
+ * silently clear the caption too.
30657
+ */
30658
+ previewText: PreviewTextField.optional(),
30659
+ /** Still or animation — see {@link PreviewModeField}. */
30660
+ previewMode: PreviewModeField.default("image"),
30661
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30662
+ reportClasses: ReportClassesField.optional(),
30072
30663
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30073
30664
  priority: PriorityField.default(3)
30074
30665
  });
@@ -30079,8 +30670,13 @@ object({
30079
30670
  schedule: NcScheduleSchema.optional(),
30080
30671
  cadenceSec: CadenceSecField.optional(),
30081
30672
  framerate: FramerateField.optional(),
30673
+ denseCadenceSec: DenseCadenceSecField.optional(),
30674
+ minDwellSec: MinDwellSecField.optional(),
30082
30675
  targets: TargetsField.optional(),
30083
30676
  template: TimelapseTemplateSchema.nullable().optional(),
30677
+ previewText: PreviewTextField.optional(),
30678
+ previewMode: PreviewModeField.optional(),
30679
+ reportClasses: ReportClassesField.optional(),
30084
30680
  priority: PriorityField.optional()
30085
30681
  });
30086
30682
  TimelapseRuleInputSchema.extend({
@@ -30092,10 +30688,28 @@ TimelapseRuleInputSchema.extend({
30092
30688
  */
30093
30689
  ownerUserId: string().optional(),
30094
30690
  /**
30095
- * Epoch-ms of the last successful generation the 1-hour re-generation
30096
- * guard's durable state (predecessor parity). Absent = never generated.
30691
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30692
+ * rule. What a UI shows, and the compatibility floor for
30693
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30097
30694
  */
30098
30695
  lastGeneratedAt: number().optional(),
30696
+ /**
30697
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30698
+ * re-generation guard's real durable state.
30699
+ *
30700
+ * One rule covers several cameras and each renders its own video, so a rule
30701
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30702
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30703
+ * already done — and B's night is gone for good, because the window will not
30704
+ * come back.
30705
+ *
30706
+ * ADDITIVE, so the migration is free: a row written before this field simply
30707
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30708
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30709
+ * "never generated" would re-render and re-notify every camera of every rule
30710
+ * once, on the deploy that shipped the map.
30711
+ */
30712
+ generatedByDevice: record(string(), number()).optional(),
30099
30713
  /** userId of the caller who created the rule (server-stamped). */
30100
30714
  createdBy: string(),
30101
30715
  createdAt: number(),
@@ -30146,25 +30760,32 @@ object({
30146
30760
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30147
30761
  object({
30148
30762
  /**
30149
- * How long a retained native frame is served before it counts as a miss.
30763
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30764
+ * detection result.
30765
+ *
30766
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30767
+ * a time window was never related to the event the pixels were waiting for.
30768
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30769
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30770
+ * releases the frame. The bound exists only so a runner that stops answering
30771
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30150
30772
  *
30151
- * Must cover the FULL late-crop horizon: detection inference + the
30152
- * cross-process inference-result hop to hub post-analysis + tracking + the
30153
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30154
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30155
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30773
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30774
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30775
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30776
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
30777
+ * `holdOverflow` on the metrics line is what says you need it.
30156
30778
  */
30157
- ttlMs: number().int().min(250).max(1e4),
30779
+ holdFrames: number().int().min(1).max(64),
30158
30780
  /**
30159
30781
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30160
30782
  *
30161
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30162
- * which one is actually binding before reasoning from that. At the shipped
30163
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30164
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30165
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30166
- * change that admits fewer frames buys retention WINDOW at constant RAM
30167
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30783
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30784
+ * is what decides how much is held, and the ceiling is the number above which
30785
+ * something is wrong. Before that it was the effective cap at 1024 MB with
30786
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30787
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30788
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30168
30789
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30169
30790
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30170
30791
  * to replace).
@@ -30190,22 +30811,45 @@ object({
30190
30811
  * there is the signal that some caller names frames outside the inference set
30191
30812
  * and that this must go back to `all`.
30192
30813
  */
30193
- admission: NativeLeaseAdmissionSchema
30814
+ admission: NativeLeaseAdmissionSchema,
30815
+ /**
30816
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30817
+ * compressed native crops the worker cuts at the moment a frame's detection
30818
+ * result arrives, and keeps long after the frame itself is freed.
30819
+ *
30820
+ * This is the knob that replaced the old retention window, and it buys about
30821
+ * three orders of magnitude more of it: a tile is one subject at native
30822
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30823
+ * the frame it was cut from. A frame on which nothing was detected costs
30824
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30825
+ * was interrogated per SUBJECT.
30826
+ *
30827
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30828
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30829
+ * reproduce that.
30830
+ */
30831
+ tileBudgetMb: number().int().min(0).max(1024)
30194
30832
  });
30195
30833
  /**
30196
- * The values in force when the operator has set nothing — byte-for-byte the
30197
- * constants the decode worker shipped with as env-var defaults, so making these
30198
- * settings changed no behaviour on the day it landed.
30834
+ * The values in force when the operator has set nothing.
30835
+ *
30836
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30837
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30838
+ * in the same change that redefines it would make a regression and a retune
30839
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30840
+ * live traffic.
30199
30841
  */
30200
30842
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30201
- ttlMs: 1200,
30843
+ holdFrames: 8,
30202
30844
  budgetMb: 1024,
30203
30845
  activityMs: 15e3,
30846
+ tileBudgetMb: 64,
30204
30847
  admission: "inferred"
30205
30848
  };
30206
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30849
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30207
30850
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30208
30851
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30852
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30209
30853
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30210
30854
  //#endregion
30211
30855
  //#region src/shared.ts