@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.
@@ -7213,8 +7213,31 @@ var AdoptionJobSchema = object({
7213
7213
  error: string().nullable()
7214
7214
  });
7215
7215
  /**
7216
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7217
- * pipeline functions an operator thinks in terms of.
7216
+ * Per-camera FUNCTION SWITCHES.
7217
+ *
7218
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7219
+ *
7220
+ * This file shipped as "the one coherent on/off surface over the pipeline
7221
+ * functions an operator thinks in terms of". The operator's verdict on
7222
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7223
+ * every function already had a settings page of its own, and a second place to
7224
+ * turn it off is a second place to look. Each switch is going back to its own
7225
+ * component's original options — detection to the detection-pipeline wrapper
7226
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7227
+ * (which was always first-class; the switch was a veneer over
7228
+ * `recording.setDeviceConfig`), notifications to a notification-center
7229
+ * per-device setting, the two camera planes to their own components.
7230
+ *
7231
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7232
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7233
+ * straight from the authorities with no group in the middle. That rule was
7234
+ * never about a control panel.
7235
+ *
7236
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7237
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7238
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7239
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7240
+ * stop; nothing new may be built on it.
7218
7241
  *
7219
7242
  * ## This file adds no state
7220
7243
  *
@@ -7565,7 +7588,15 @@ var RecordingConfigSchema = object({
7565
7588
  * Each completed/failed run also lands one durable ops-log row on its owning
7566
7589
  * addon surface.
7567
7590
  */
7591
+ /**
7592
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7593
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7594
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7595
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7596
+ * runs at all.
7597
+ */
7568
7598
  var RelocateJobStateSchema = _enum([
7599
+ "queued",
7569
7600
  "running",
7570
7601
  "done",
7571
7602
  "failed",
@@ -7600,6 +7631,15 @@ var RelocateFootageInputSchema = object({
7600
7631
  /** Limits relocation to the logical profile class. Omit only for the
7601
7632
  * pre-orchestration compatibility path. */
7602
7633
  footageClass: RelocateFootageClassSchema.optional(),
7634
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7635
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7636
+ * unit is a (camera, profile) pile, not a disk. */
7637
+ deviceId: number().int().optional(),
7638
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7639
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7640
+ * placement plan assigns those two independently, so a rebalance that could
7641
+ * only say "recordings" would move footage the plan never asked to move. */
7642
+ profiles: array(string()).optional(),
7603
7643
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7604
7644
  * never allowed to starve live writers. */
7605
7645
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7735,6 +7775,21 @@ var StorageLocationSchema = object({
7735
7775
  nodeId: string().optional(),
7736
7776
  isDefault: boolean().default(false),
7737
7777
  isSystem: boolean().default(false),
7778
+ /**
7779
+ * Operator opt-in: whether consumers that BALANCE across several locations
7780
+ * of a type may write here. Recordings reads it today; event media and
7781
+ * backups are the next consumers, which is why the flag lives on the
7782
+ * location rather than in any one addon's store — nothing has to be
7783
+ * extended to add the next consumer.
7784
+ *
7785
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7786
+ * flag existed reads back with no flag and keeps working exactly as before;
7787
+ * that is the whole compat story, and it is why no migration ships with it.
7788
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7789
+ * disk must not silently start writing to it); the default of a type is
7790
+ * always stamped `true`.
7791
+ */
7792
+ enabled: boolean().optional(),
7738
7793
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7739
7794
  * for node-local locations it can reach) — never persisted, absent when the
7740
7795
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12037,7 +12092,8 @@ method(object({
12037
12092
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12038
12093
  /**
12039
12094
  * filesystem-browse — per-node capability for browsing the node's local
12040
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12095
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12096
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12041
12097
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12042
12098
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12043
12099
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13850,6 +13906,13 @@ var MaskGridDimsSchema = object({
13850
13906
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13851
13907
  * this one field keeps the schema additive — a rule still declares exactly
13852
13908
  * one trigger.
13909
+ *
13910
+ * AUDIO rules add no member here, for the reason occupancy added none: the
13911
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
13912
+ * mirror.ts` fails the build on a member the app cannot render) and every
13913
+ * member costs a release train. A sustained-sound rule is therefore an
13914
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
13915
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13853
13916
  */
13854
13917
  var NcDeliverySchema = _enum([
13855
13918
  "immediate",
@@ -13864,15 +13927,32 @@ var NcDeliverySchema = _enum([
13864
13927
  * depend on a provider's raw event name or payload shape.
13865
13928
  */
13866
13929
  var NcSystemEventKindSchema = _enum([
13867
- "camera-online",
13868
- "camera-offline",
13930
+ "device-online",
13931
+ "device-offline",
13932
+ "device-disabled",
13933
+ "device-enabled",
13869
13934
  "stream-online",
13870
13935
  "stream-offline",
13871
13936
  "node-online",
13872
13937
  "node-offline",
13873
13938
  "addon-update-available",
13874
- "server-update-available"
13939
+ "server-update-available",
13940
+ "alarm-triggered",
13941
+ "alarm-armed",
13942
+ "alarm-disarmed",
13943
+ "camera-online",
13944
+ "camera-offline",
13945
+ "camera-disabled",
13946
+ "camera-enabled"
13947
+ ]);
13948
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
13949
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
13950
+ "camera-online",
13951
+ "camera-offline",
13952
+ "camera-disabled",
13953
+ "camera-enabled"
13875
13954
  ]);
13955
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13876
13956
  /**
13877
13957
  * One coherent system-event condition. `kinds` is the required opt-in safety
13878
13958
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -13881,6 +13961,18 @@ var NcSystemEventKindSchema = _enum([
13881
13961
  var NcSystemEventConditionSchema = object({
13882
13962
  kinds: array(NcSystemEventKindSchema).min(1),
13883
13963
  deviceIds: array(number().int()).min(1).optional(),
13964
+ /**
13965
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
13966
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
13967
+ * is what a liveness rule means when nobody said otherwise.
13968
+ *
13969
+ * This is where "only my cameras" is expressed, and it lives on the rule for
13970
+ * one reason: the intake cannot know which devices this household cares
13971
+ * about, and a producer-side filter is one no operator can change. Fails
13972
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
13973
+ * does not carry) matches no `deviceTypes` list.
13974
+ */
13975
+ deviceTypes: array(string().min(1)).min(1).optional(),
13884
13976
  nodeIds: array(string().min(1)).min(1).optional(),
13885
13977
  packageNames: array(string().min(1)).min(1).optional()
13886
13978
  });
@@ -13931,6 +14023,47 @@ var NcOccupancyConditionSchema = object({
13931
14023
  sustainSeconds: number().int().min(0).max(3600).default(15)
13932
14024
  });
13933
14025
  /**
14026
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14027
+ *
14028
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14029
+ * reference notifier uses, so an operator moving between them re-uses what
14030
+ * they already know): a rule matches when, over a sampling window of
14031
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14032
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14033
+ *
14034
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14035
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14036
+ * - `labels` — the classifier put at least one of these labels on it.
14037
+ *
14038
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14039
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14040
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14041
+ * is given** — a window in which every sample is trivially a hit would fire on
14042
+ * silence, so the engine refuses such a condition rather than notifying on
14043
+ * nothing (the schema cannot express "at least one of" without becoming a
14044
+ * ZodEffects the cap path would have to special-case).
14045
+ *
14046
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14047
+ * must be FULL before it can match — a window that has been open for two
14048
+ * seconds of its ten is 100% of nothing, and firing on it would make
14049
+ * `samplingSeconds` decorative.
14050
+ *
14051
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14052
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14053
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14054
+ * an operator who typed `dog` mean the same thing.
14055
+ */
14056
+ var NcAudioConditionSchema = object({
14057
+ /** Audio macro labels; absent = any sound (level-only rule). */
14058
+ labels: array(string().min(1)).min(1).optional(),
14059
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14060
+ dbThreshold: number().min(-96).max(0).optional(),
14061
+ /** Percentage of the window's samples that must be hits (1–100). */
14062
+ hitPercent: number().int().min(1).max(100).default(60),
14063
+ /** Length of the sampling window in seconds. */
14064
+ samplingSeconds: number().int().min(1).max(300).default(10)
14065
+ });
14066
+ /**
13934
14067
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
13935
14068
  *
13936
14069
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14203,7 +14336,33 @@ var NcConditionsSchema = object({
14203
14336
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14204
14337
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14205
14338
  */
14206
- occupancy: NcOccupancyConditionSchema.optional()
14339
+ occupancy: NcOccupancyConditionSchema.optional(),
14340
+ /**
14341
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14342
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14343
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14344
+ * a window that is not full yet, neither filter given). See
14345
+ * {@link NcAudioCondition}.
14346
+ *
14347
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14348
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14349
+ * a detection, a track or a device event (the same fail-closed pairing
14350
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14351
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14352
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14353
+ * classified sample) stays exactly as it was for rules that already use it.
14354
+ *
14355
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14356
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14357
+ * (`camstack/src/data/notification-center.ts`, guarded by
14358
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14359
+ * condition fields it does not know when a rule is saved from the phone.
14360
+ * Publishing an editor for a condition the app cannot round-trip is how an
14361
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14362
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14363
+ * does an audio rule become authorable.
14364
+ */
14365
+ audio: NcAudioConditionSchema.optional()
14207
14366
  });
14208
14367
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14209
14368
  var NcRuleTargetSchema = object({
@@ -14317,6 +14476,73 @@ var NcThrottleSchema = object({
14317
14476
  */
14318
14477
  granularity: NcThrottleGranularitySchema.optional()
14319
14478
  });
14479
+ /**
14480
+ * How long the confirm gate may hold ONE notification, and how big the picture
14481
+ * it judges may be.
14482
+ *
14483
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14484
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14485
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14486
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14487
+ * tokens for pixels the model pools away.
14488
+ */
14489
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14490
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14491
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14492
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14493
+ var NcConfirmExpectSchema = object({
14494
+ op: _enum([
14495
+ ">=",
14496
+ ">",
14497
+ "<=",
14498
+ "<",
14499
+ "=="
14500
+ ]),
14501
+ count: number().int().min(0).max(1e3)
14502
+ });
14503
+ /**
14504
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14505
+ * to ship and says whether it agrees with the rule.
14506
+ *
14507
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14508
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14509
+ * on the operator's phone is not a verdict about this notification.
14510
+ *
14511
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14512
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14513
+ * the default and every fail-open is COUNTED, because a gate that always fails
14514
+ * open looks in the log exactly like a gate that works.
14515
+ *
14516
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14517
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14518
+ * production failures in one day), so the gate reads absent as the constant
14519
+ * above rather than trusting a parse it may never have seen.
14520
+ */
14521
+ var NcConfirmSchema = object({
14522
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14523
+ * same thing, and both mean "deliver exactly as before". */
14524
+ enabled: boolean().default(false),
14525
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14526
+ profileId: string().optional(),
14527
+ /**
14528
+ * The operator's question, in his own words. Absent = a question derived
14529
+ * from the rule (its class and its expectation).
14530
+ *
14531
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14532
+ * banners, signage and plates as instructions if you let them reach the
14533
+ * prompt — proven live — so the authoritative contract stays in the system
14534
+ * turn and only rule-authored words land here.
14535
+ */
14536
+ prompt: string().max(1e3).optional(),
14537
+ /** Fire only when the model's count satisfies this. Absent = the model's
14538
+ * own boolean verdict decides. */
14539
+ expect: NcConfirmExpectSchema.optional(),
14540
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14541
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14542
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14543
+ /** Longest edge the judged image is downscaled to before it is sent. */
14544
+ maxImagePx: number().int().min(64).max(2048).default(448)
14545
+ });
14320
14546
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14321
14547
  var NcRuleInputSchema = object({
14322
14548
  name: string().min(1).max(200),
@@ -14377,7 +14603,13 @@ var NcRuleInputSchema = object({
14377
14603
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14378
14604
  * shape as every other actuation.
14379
14605
  */
14380
- actions: NcRuleActionsSchema.optional()
14606
+ actions: NcRuleActionsSchema.optional(),
14607
+ /**
14608
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14609
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14610
+ * did, and absent is the only way to say that without a migration.
14611
+ */
14612
+ confirm: NcConfirmSchema.optional()
14381
14613
  });
14382
14614
  /**
14383
14615
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14388,7 +14620,37 @@ var NcRuleInputSchema = object({
14388
14620
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14389
14621
  * `updateRule` patch.
14390
14622
  */
14391
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14623
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14624
+ disabledTargetIds: array(string()).optional(),
14625
+ /**
14626
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14627
+ *
14628
+ * It makes the key optional to SUPPLY; the parse still materialises the
14629
+ * default when the key is absent. And `NcRuleStore.update` merges with
14630
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14631
+ * one — which made every partial edit destructive:
14632
+ *
14633
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14634
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14635
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14636
+ *
14637
+ * A rule scoped to one camera and one zone silently became a rule that
14638
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14639
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14640
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14641
+ * within a minute of a two-field patch.
14642
+ *
14643
+ * So every defaulted field is re-declared here WITHOUT its default. The
14644
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14645
+ * conditions remains a real instruction ("clear them") — and only the
14646
+ * absent key is now genuinely absent.
14647
+ */
14648
+ enabled: boolean().optional(),
14649
+ conditions: NcConditionsSchema.optional(),
14650
+ media: NcMediaPolicySchema.optional(),
14651
+ throttle: NcThrottleSchema.optional(),
14652
+ priority: number().int().min(1).max(5).optional()
14653
+ });
14392
14654
  /** A persisted rule. */
14393
14655
  var NcRuleSchema = NcRuleInputSchema.extend({
14394
14656
  id: string(),
@@ -14689,6 +14951,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14689
14951
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14690
14952
  * copy would lie the first time a rule is disabled.
14691
14953
  */
14954
+ /**
14955
+ * Why a device a mode NAMES is nonetheless not armed by it.
14956
+ *
14957
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
14958
+ * per-camera notification switch the Notification Center already owns,
14959
+ * `detection-off` is the device's own detection binding being inactive, and
14960
+ * `offline` is the device manager's liveness. A fourth reason would mean a
14961
+ * fourth authority, and inventing one here is how a panel starts disagreeing
14962
+ * with the switches the operator actually used.
14963
+ */
14964
+ var NcAlarmSkipReasonSchema = _enum([
14965
+ "muted",
14966
+ "detection-off",
14967
+ "offline"
14968
+ ]);
14969
+ var NcAlarmSkippedDeviceSchema = object({
14970
+ deviceId: number().int(),
14971
+ reason: NcAlarmSkipReasonSchema
14972
+ });
14692
14973
  var NcAlarmModeCoverageSchema = object({
14693
14974
  mode: AlarmArmModeSchema,
14694
14975
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14696,7 +14977,18 @@ var NcAlarmModeCoverageSchema = object({
14696
14977
  /** At least one covering rule has no device scope, so the mode covers all. */
14697
14978
  allDevices: boolean(),
14698
14979
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14699
- deviceIds: array(number().int())
14980
+ deviceIds: array(number().int()),
14981
+ /**
14982
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
14983
+ * excludes it.
14984
+ *
14985
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
14986
+ * twelve makes it false in exactly the way nobody notices until an incident.
14987
+ * Defaulted to `[]` so a coverage answer computed before this field existed
14988
+ * still parses as "nothing known to be skipped" rather than failing the whole
14989
+ * alarm tab.
14990
+ */
14991
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14700
14992
  });
14701
14993
  var NcAlarmConfigSchema = object({
14702
14994
  /**
@@ -17495,9 +17787,16 @@ var CameraStatusSchema = object({
17495
17787
  audio: CameraAudioStatusSchema.nullable(),
17496
17788
  recording: CameraRecordingStatusSchema.nullable(),
17497
17789
  /**
17498
- * Per-camera function switches an OPERATOR has turned off
17790
+ * Per-camera functions an OPERATOR has turned off
17499
17791
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17500
17792
  *
17793
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17794
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17795
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17796
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17797
+ * The badge outlives the control panel: the panel was a convenience, this is
17798
+ * the difference between a camera being off and a camera being dead.
17799
+ *
17501
17800
  * This is the difference between DISABLED and BROKEN. A camera whose
17502
17801
  * `detection` block reports zero fps and whose `switchedOff` contains
17503
17802
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23051,7 +23350,19 @@ var RecordingManifestSchema = object({
23051
23350
  * profiles/subtrees/locations on this node). */
23052
23351
  var RecordingDeviceUsageSchema = object({
23053
23352
  deviceId: number(),
23054
- usedBytes: number()
23353
+ usedBytes: number(),
23354
+ /**
23355
+ * Start of this camera's OLDEST indexed segment, across every profile and
23356
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23357
+ * only honest answer to "is retention actually holding?" per camera.
23358
+ *
23359
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23360
+ * predates this field omits it entirely, and a hub whose types carry the
23361
+ * field must keep validating that older provider's payload: the framework
23362
+ * (types) and the addon ship on different trains, and the addon is usually
23363
+ * the later of the two.
23364
+ */
23365
+ oldestMs: number().nullable().optional()
23055
23366
  });
23056
23367
  /** Recording storage usage + capacity for one storage location. */
23057
23368
  var RecordingLocationUsageSchema = object({
@@ -23079,6 +23390,57 @@ var RecordingStorageUsageSchema = object({
23079
23390
  locations: array(RecordingLocationUsageSchema)
23080
23391
  });
23081
23392
  /**
23393
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23394
+ *
23395
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23396
+ * is the operator asking for the EXISTING archive to be brought into line with
23397
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23398
+ * location, run FIFO behind the single-flight mover.
23399
+ *
23400
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23401
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23402
+ * (empty on the plan).
23403
+ */
23404
+ var RecordingRebalanceMoveSchema = object({
23405
+ deviceId: number(),
23406
+ profile: string(),
23407
+ fromLocationId: string(),
23408
+ toLocationId: string(),
23409
+ bytes: number(),
23410
+ files: number().int()
23411
+ });
23412
+ /** Why a pile that is out of place is staying there. Every refusal is
23413
+ * reported: a rebalance that silently drops a camera reads exactly like one
23414
+ * that had nothing to do. */
23415
+ var RecordingRebalanceSkipReasonSchema = _enum([
23416
+ "unassigned",
23417
+ "target-not-writable",
23418
+ "below-threshold",
23419
+ "no-headroom"
23420
+ ]);
23421
+ var RecordingRebalanceSkipSchema = object({
23422
+ deviceId: number(),
23423
+ profile: string(),
23424
+ fromLocationId: string(),
23425
+ /** The location the plan wants; null when the camera has no assignment. */
23426
+ toLocationId: string().nullable(),
23427
+ bytes: number(),
23428
+ reason: RecordingRebalanceSkipReasonSchema
23429
+ });
23430
+ var RecordingRebalancePlanSchema = object({
23431
+ moves: array(RecordingRebalanceMoveSchema),
23432
+ skipped: array(RecordingRebalanceSkipSchema),
23433
+ bytesToMove: number(),
23434
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23435
+ jobIds: array(string())
23436
+ });
23437
+ var RecordingRebalanceInputSchema = object({
23438
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23439
+ throttleMbps: number().min(1).max(1e3).optional(),
23440
+ /** Ignore piles smaller than this (default 1 GB). */
23441
+ minMoveGb: number().min(0).optional()
23442
+ });
23443
+ /**
23082
23444
  * Result of locating footage at a wall-clock instant for one device/profile.
23083
23445
  * `segment` carries the covering segment's window; `gap` reports the forward
23084
23446
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23241,9 +23603,24 @@ method(object({
23241
23603
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23242
23604
  kind: "mutation",
23243
23605
  auth: "admin"
23606
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23607
+ kind: "mutation",
23608
+ auth: "admin"
23609
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23610
+ kind: "query",
23611
+ auth: "admin"
23612
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23613
+ kind: "mutation",
23614
+ auth: "admin"
23615
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23616
+ kind: "query",
23617
+ auth: "admin"
23618
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23619
+ kind: "mutation",
23620
+ auth: "admin"
23244
23621
  });
23245
23622
  /**
23246
- * `recordingExport` cap — render a footage time range into a single downloadable
23623
+ * `recording-export` cap — render a footage time range into a single downloadable
23247
23624
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23248
23625
  * bounded lifetime with a durable history, auto-expiry, and optional
23249
23626
  * delete-after-download.
@@ -23258,10 +23635,53 @@ method(object({
23258
23635
  */
23259
23636
  /** Playback-speed multiplier for the render (1 = realtime). */
23260
23637
  var ExportSpeedSchema = number().min(.25).max(32);
23638
+ /**
23639
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23640
+ *
23641
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23642
+ * derives these bounds from things that happened at a TIME (a track's
23643
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23644
+ * every segment present for the range, with each recording GAP removed. The
23645
+ * two agree only on a window that recorded without one interruption, and only
23646
+ * the render side knows the segments, so the translation lives there
23647
+ * (`export-dense-map.ts`, addon-pipeline).
23648
+ *
23649
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23650
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23651
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23652
+ * the video was a uniform timelapse, and the log line reported the five ranges
23653
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23654
+ *
23655
+ * Relative and not absolute epoch, because an absolute epoch would make every
23656
+ * call site responsible for the same subtraction.
23657
+ */
23658
+ var ExportDenseRangeSchema = object({
23659
+ fromSec: number().nonnegative(),
23660
+ toSec: number().nonnegative()
23661
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23662
+ /**
23663
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23664
+ * listed ranges and at the base `everyMs` everywhere else.
23665
+ *
23666
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23667
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23668
+ */
23669
+ var ExportDenseSchema = object({
23670
+ everyMs: number().int().positive(),
23671
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23672
+ });
23261
23673
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23262
23674
  var ExportTimelapseSchema = object({
23263
23675
  everyMs: number().int().positive(),
23264
- outputFps: number().int().min(1).max(60).optional()
23676
+ outputFps: number().int().min(1).max(60).optional(),
23677
+ /** Optional second, FASTER rate over the intervals that matter. */
23678
+ dense: ExportDenseSchema.optional()
23679
+ }).superRefine((v, ctx) => {
23680
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23681
+ code: ZodIssueCode.custom,
23682
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23683
+ path: ["dense", "everyMs"]
23684
+ });
23265
23685
  });
23266
23686
  /**
23267
23687
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23319,6 +23739,19 @@ var ExportDownloadSchema = object({
23319
23739
  url: string(),
23320
23740
  endpoints: array(string())
23321
23741
  });
23742
+ /**
23743
+ * A finished export's bytes, inline.
23744
+ *
23745
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23746
+ * against, so nobody has to infer it from the base64 length.
23747
+ */
23748
+ var ExportBytesSchema = object({
23749
+ base64: string(),
23750
+ contentType: string(),
23751
+ /** Suggested filename, extension included. */
23752
+ name: string(),
23753
+ bytes: number().int().nonnegative()
23754
+ });
23322
23755
  method(object({
23323
23756
  deviceId: number(),
23324
23757
  profile: string(),
@@ -23343,6 +23776,9 @@ method(object({
23343
23776
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23344
23777
  kind: "query",
23345
23778
  auth: "protected"
23779
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23780
+ kind: "query",
23781
+ auth: "protected"
23346
23782
  });
23347
23783
  /**
23348
23784
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28536,6 +28972,12 @@ Object.freeze({
28536
28972
  addonId: null,
28537
28973
  access: "create"
28538
28974
  },
28975
+ "recording.cancelRelocateJob": {
28976
+ capName: "recording",
28977
+ capScope: "system",
28978
+ addonId: null,
28979
+ access: "create"
28980
+ },
28539
28981
  "recording.cancelStorageMigrationMove": {
28540
28982
  capName: "recording",
28541
28983
  capScope: "system",
@@ -28590,6 +29032,12 @@ Object.freeze({
28590
29032
  addonId: null,
28591
29033
  access: "view"
28592
29034
  },
29035
+ "recording.listRelocateJobs": {
29036
+ capName: "recording",
29037
+ capScope: "system",
29038
+ addonId: null,
29039
+ access: "view"
29040
+ },
28593
29041
  "recording.locateSegment": {
28594
29042
  capName: "recording",
28595
29043
  capScope: "system",
@@ -28602,6 +29050,12 @@ Object.freeze({
28602
29050
  addonId: null,
28603
29051
  access: "create"
28604
29052
  },
29053
+ "recording.planStorageRebalance": {
29054
+ capName: "recording",
29055
+ capScope: "system",
29056
+ addonId: null,
29057
+ access: "view"
29058
+ },
28605
29059
  "recording.pruneFootage": {
28606
29060
  capName: "recording",
28607
29061
  capScope: "system",
@@ -28626,6 +29080,12 @@ Object.freeze({
28626
29080
  addonId: null,
28627
29081
  access: "create"
28628
29082
  },
29083
+ "recording.relocateFootage": {
29084
+ capName: "recording",
29085
+ capScope: "system",
29086
+ addonId: null,
29087
+ access: "create"
29088
+ },
28629
29089
  "recording.renderClip": {
28630
29090
  capName: "recording",
28631
29091
  capScope: "system",
@@ -28662,38 +29122,50 @@ Object.freeze({
28662
29122
  addonId: null,
28663
29123
  access: "create"
28664
29124
  },
29125
+ "recording.startStorageRebalance": {
29126
+ capName: "recording",
29127
+ capScope: "system",
29128
+ addonId: null,
29129
+ access: "create"
29130
+ },
28665
29131
  "recordingExport.cancelExport": {
28666
- capName: "recordingExport",
29132
+ capName: "recording-export",
28667
29133
  capScope: "system",
28668
29134
  addonId: null,
28669
29135
  access: "create"
28670
29136
  },
28671
29137
  "recordingExport.createExport": {
28672
- capName: "recordingExport",
29138
+ capName: "recording-export",
28673
29139
  capScope: "system",
28674
29140
  addonId: null,
28675
29141
  access: "create"
28676
29142
  },
28677
29143
  "recordingExport.deleteExport": {
28678
- capName: "recordingExport",
29144
+ capName: "recording-export",
28679
29145
  capScope: "system",
28680
29146
  addonId: null,
28681
29147
  access: "delete"
28682
29148
  },
28683
29149
  "recordingExport.getDownloadUrl": {
28684
- capName: "recordingExport",
29150
+ capName: "recording-export",
28685
29151
  capScope: "system",
28686
29152
  addonId: null,
28687
29153
  access: "view"
28688
29154
  },
28689
29155
  "recordingExport.getExport": {
28690
- capName: "recordingExport",
29156
+ capName: "recording-export",
28691
29157
  capScope: "system",
28692
29158
  addonId: null,
28693
29159
  access: "view"
28694
29160
  },
28695
29161
  "recordingExport.listExports": {
28696
- capName: "recordingExport",
29162
+ capName: "recording-export",
29163
+ capScope: "system",
29164
+ addonId: null,
29165
+ access: "view"
29166
+ },
29167
+ "recordingExport.readExportBytes": {
29168
+ capName: "recording-export",
28697
29169
  capScope: "system",
28698
29170
  addonId: null,
28699
29171
  access: "view"
@@ -30070,6 +30542,104 @@ var FramerateField = number().int().min(1).max(60);
30070
30542
  var TargetsField = array(NcRuleTargetSchema).min(1);
30071
30543
  var PriorityField = number().int().min(1).max(5);
30072
30544
  /**
30545
+ * Explicit override of the DENSE sampling cadence, seconds.
30546
+ *
30547
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30548
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30549
+ * made that same base 3 s and rendered a person pass as two frames.)
30550
+ *
30551
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30552
+ * `denseCadenceSec` and played at `framerate` occupies
30553
+ *
30554
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30555
+ *
30556
+ * 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.
30557
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30558
+ * and therefore the length of a quiet night, does not move.
30559
+ *
30560
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30561
+ * the recording has them returns the same frames, requested twice. Must be
30562
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30563
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30564
+ * rather than letting the export cap reject the render hours after the window.
30565
+ */
30566
+ var DenseCadenceSecField = number().min(.1).max(3600);
30567
+ /**
30568
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30569
+ *
30570
+ * The operator-facing form of the arithmetic above: instead of solving for a
30571
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30572
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30573
+ * that range every ~583 ms.
30574
+ *
30575
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30576
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30577
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30578
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30579
+ * schema change and are the tracked follow-up.
30580
+ *
30581
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30582
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30583
+ * by real footage, never met by duplicating frames into motion that never
30584
+ * happened.
30585
+ */
30586
+ var MinDwellSecField = number().min(0).max(60);
30587
+ /**
30588
+ * Caption burned into the notification's preview frame.
30589
+ *
30590
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30591
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30592
+ * templating dialect for one field would be a second thing to explain.
30593
+ *
30594
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30595
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30596
+ * the reason this is not `.min(1)`.
30597
+ */
30598
+ var PreviewTextField = string().max(200);
30599
+ /**
30600
+ * Whether the notification's preview is a STILL or a short animation.
30601
+ *
30602
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30603
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30604
+ * night reads better as three seconds of motion than as one frame of it. Both
30605
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30606
+ * simply applies it to a dozen frames sampled across the render and assembles
30607
+ * them.
30608
+ *
30609
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30610
+ * seeks and a palette pass, and no rule that never asked for one should start
30611
+ * paying that on the deploy that shipped it.
30612
+ *
30613
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30614
+ */
30615
+ var PreviewModeField = _enum(["image", "gif"]);
30616
+ /**
30617
+ * Which detection classes the notification reports counts for.
30618
+ *
30619
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30620
+ * plan — no second query — aggregated per class. Absent or empty means "every
30621
+ * class the window actually contained", which is what an operator who never
30622
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30623
+ * counts cars all night).
30624
+ *
30625
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30626
+ * …). An unknown name simply never matches and reports nothing — it is not an
30627
+ * error, because a rule may legitimately name a class this camera's model does
30628
+ * not emit.
30629
+ *
30630
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30631
+ * - `{{detections}}` — total over the reported classes
30632
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30633
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30634
+ * one per class, `count_` + the class name
30635
+ *
30636
+ * With NO custom body template the summary is appended to the derived body, and
30637
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30638
+ * reads. With a custom template the operator owns every word — nothing is
30639
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30640
+ */
30641
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30642
+ /**
30073
30643
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30074
30644
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30075
30645
  * here (see the ownership note above).
@@ -30089,9 +30659,30 @@ var TimelapseRuleInputSchema = object({
30089
30659
  cadenceSec: CadenceSecField.default(15),
30090
30660
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30091
30661
  framerate: FramerateField.default(10),
30662
+ /**
30663
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30664
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30665
+ * field gets.
30666
+ */
30667
+ denseCadenceSec: DenseCadenceSecField.optional(),
30668
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30669
+ minDwellSec: MinDwellSecField.optional(),
30092
30670
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30093
30671
  targets: TargetsField,
30094
30672
  template: TimelapseTemplateSchema.optional(),
30673
+ /**
30674
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30675
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30676
+ *
30677
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30678
+ * the notification's title/body, and clearing it (`template: null`) must not
30679
+ * silently clear the caption too.
30680
+ */
30681
+ previewText: PreviewTextField.optional(),
30682
+ /** Still or animation — see {@link PreviewModeField}. */
30683
+ previewMode: PreviewModeField.default("image"),
30684
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30685
+ reportClasses: ReportClassesField.optional(),
30095
30686
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30096
30687
  priority: PriorityField.default(3)
30097
30688
  });
@@ -30102,8 +30693,13 @@ object({
30102
30693
  schedule: NcScheduleSchema.optional(),
30103
30694
  cadenceSec: CadenceSecField.optional(),
30104
30695
  framerate: FramerateField.optional(),
30696
+ denseCadenceSec: DenseCadenceSecField.optional(),
30697
+ minDwellSec: MinDwellSecField.optional(),
30105
30698
  targets: TargetsField.optional(),
30106
30699
  template: TimelapseTemplateSchema.nullable().optional(),
30700
+ previewText: PreviewTextField.optional(),
30701
+ previewMode: PreviewModeField.optional(),
30702
+ reportClasses: ReportClassesField.optional(),
30107
30703
  priority: PriorityField.optional()
30108
30704
  });
30109
30705
  TimelapseRuleInputSchema.extend({
@@ -30115,10 +30711,28 @@ TimelapseRuleInputSchema.extend({
30115
30711
  */
30116
30712
  ownerUserId: string().optional(),
30117
30713
  /**
30118
- * Epoch-ms of the last successful generation the 1-hour re-generation
30119
- * guard's durable state (predecessor parity). Absent = never generated.
30714
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30715
+ * rule. What a UI shows, and the compatibility floor for
30716
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30120
30717
  */
30121
30718
  lastGeneratedAt: number().optional(),
30719
+ /**
30720
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30721
+ * re-generation guard's real durable state.
30722
+ *
30723
+ * One rule covers several cameras and each renders its own video, so a rule
30724
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30725
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30726
+ * already done — and B's night is gone for good, because the window will not
30727
+ * come back.
30728
+ *
30729
+ * ADDITIVE, so the migration is free: a row written before this field simply
30730
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30731
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30732
+ * "never generated" would re-render and re-notify every camera of every rule
30733
+ * once, on the deploy that shipped the map.
30734
+ */
30735
+ generatedByDevice: record(string(), number()).optional(),
30122
30736
  /** userId of the caller who created the rule (server-stamped). */
30123
30737
  createdBy: string(),
30124
30738
  createdAt: number(),
@@ -30169,25 +30783,32 @@ object({
30169
30783
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30170
30784
  object({
30171
30785
  /**
30172
- * How long a retained native frame is served before it counts as a miss.
30786
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30787
+ * detection result.
30788
+ *
30789
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30790
+ * a time window was never related to the event the pixels were waiting for.
30791
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30792
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30793
+ * releases the frame. The bound exists only so a runner that stops answering
30794
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30173
30795
  *
30174
- * Must cover the FULL late-crop horizon: detection inference + the
30175
- * cross-process inference-result hop to hub post-analysis + tracking + the
30176
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30177
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30178
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30796
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30797
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30798
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30799
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
30800
+ * `holdOverflow` on the metrics line is what says you need it.
30179
30801
  */
30180
- ttlMs: number().int().min(250).max(1e4),
30802
+ holdFrames: number().int().min(1).max(64),
30181
30803
  /**
30182
30804
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30183
30805
  *
30184
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30185
- * which one is actually binding before reasoning from that. At the shipped
30186
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30187
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30188
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30189
- * change that admits fewer frames buys retention WINDOW at constant RAM
30190
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30806
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30807
+ * is what decides how much is held, and the ceiling is the number above which
30808
+ * something is wrong. Before that it was the effective cap at 1024 MB with
30809
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30810
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30811
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30191
30812
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30192
30813
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30193
30814
  * to replace).
@@ -30213,22 +30834,45 @@ object({
30213
30834
  * there is the signal that some caller names frames outside the inference set
30214
30835
  * and that this must go back to `all`.
30215
30836
  */
30216
- admission: NativeLeaseAdmissionSchema
30837
+ admission: NativeLeaseAdmissionSchema,
30838
+ /**
30839
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30840
+ * compressed native crops the worker cuts at the moment a frame's detection
30841
+ * result arrives, and keeps long after the frame itself is freed.
30842
+ *
30843
+ * This is the knob that replaced the old retention window, and it buys about
30844
+ * three orders of magnitude more of it: a tile is one subject at native
30845
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30846
+ * the frame it was cut from. A frame on which nothing was detected costs
30847
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30848
+ * was interrogated per SUBJECT.
30849
+ *
30850
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30851
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30852
+ * reproduce that.
30853
+ */
30854
+ tileBudgetMb: number().int().min(0).max(1024)
30217
30855
  });
30218
30856
  /**
30219
- * The values in force when the operator has set nothing — byte-for-byte the
30220
- * constants the decode worker shipped with as env-var defaults, so making these
30221
- * settings changed no behaviour on the day it landed.
30857
+ * The values in force when the operator has set nothing.
30858
+ *
30859
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30860
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30861
+ * in the same change that redefines it would make a regression and a retune
30862
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30863
+ * live traffic.
30222
30864
  */
30223
30865
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30224
- ttlMs: 1200,
30866
+ holdFrames: 8,
30225
30867
  budgetMb: 1024,
30226
30868
  activityMs: 15e3,
30869
+ tileBudgetMb: 64,
30227
30870
  admission: "inferred"
30228
30871
  };
30229
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30872
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30230
30873
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30231
30874
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30875
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30232
30876
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30233
30877
  //#endregion
30234
30878
  //#region src/shared.ts