@camstack/addon-decoder-nodeav 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.
Files changed (3) hide show
  1. package/dist/index.js +686 -42
  2. package/dist/index.mjs +686 -42
  3. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -7205,8 +7205,31 @@ var AdoptionJobSchema = object({
7205
7205
  error: string().nullable()
7206
7206
  });
7207
7207
  /**
7208
- * Per-camera FUNCTION SWITCHES — the one coherent on/off surface over the
7209
- * pipeline functions an operator thinks in terms of.
7208
+ * Per-camera FUNCTION SWITCHES.
7209
+ *
7210
+ * ## The aggregate group is being withdrawn — the BADGE is not (D113)
7211
+ *
7212
+ * This file shipped as "the one coherent on/off surface over the pipeline
7213
+ * functions an operator thinks in terms of". The operator's verdict on
7214
+ * 2026-08-12 was that the coherent surface bought complexity and no clarity:
7215
+ * every function already had a settings page of its own, and a second place to
7216
+ * turn it off is a second place to look. Each switch is going back to its own
7217
+ * component's original options — detection to the detection-pipeline wrapper
7218
+ * binding, audio analysis to its own, recording to `RecordingConfig.enabled`
7219
+ * (which was always first-class; the switch was a veneer over
7220
+ * `recording.setDeviceConfig`), notifications to a notification-center
7221
+ * per-device setting, the two camera planes to their own components.
7222
+ *
7223
+ * What survives is {@link composeSwitchedOff}: `CameraStatus.switchedOff`, the
7224
+ * thing that lets a status surface say DISABLED instead of BROKEN, recomposed
7225
+ * straight from the authorities with no group in the middle. That rule was
7226
+ * never about a control panel.
7227
+ *
7228
+ * Everything else here — {@link CAMERA_SWITCH_CATALOG}, {@link CameraSwitch},
7229
+ * {@link deriveCameraSwitches}, the `pipelineOrchestrator.getCameraSwitches` /
7230
+ * `setCameraSwitch` pair — is a COMPATIBILITY surface for as long as deployed
7231
+ * viewers (v1.0.305) and the admin UI still call it. It is deleted when they
7232
+ * stop; nothing new may be built on it.
7210
7233
  *
7211
7234
  * ## This file adds no state
7212
7235
  *
@@ -7557,7 +7580,15 @@ var RecordingConfigSchema = object({
7557
7580
  * Each completed/failed run also lands one durable ops-log row on its owning
7558
7581
  * addon surface.
7559
7582
  */
7583
+ /**
7584
+ * `queued` exists because the recorder mover is SINGLE-FLIGHT and an operator
7585
+ * rebalance enqueues one job per (camera, profile). Refusing the second job —
7586
+ * what the engine did before — turned a fifteen-camera rebalance into fifteen
7587
+ * manual retries. Queued jobs run FIFO; a queued job that is cancelled never
7588
+ * runs at all.
7589
+ */
7560
7590
  var RelocateJobStateSchema = _enum([
7591
+ "queued",
7561
7592
  "running",
7562
7593
  "done",
7563
7594
  "failed",
@@ -7592,6 +7623,15 @@ var RelocateFootageInputSchema = object({
7592
7623
  /** Limits relocation to the logical profile class. Omit only for the
7593
7624
  * pre-orchestration compatibility path. */
7594
7625
  footageClass: RelocateFootageClassSchema.optional(),
7626
+ /** Scope the move to ONE camera. Absent = every camera on the source, which
7627
+ * is what a whole-disk drain means. The rebalance path always sets it: its
7628
+ * unit is a (camera, profile) pile, not a disk. */
7629
+ deviceId: number().int().optional(),
7630
+ /** Scope the move to specific segment profiles (`high` / `mid` / `low`).
7631
+ * Finer than `footageClass`, which cannot separate high from mid — and the
7632
+ * placement plan assigns those two independently, so a rebalance that could
7633
+ * only say "recordings" would move footage the plan never asked to move. */
7634
+ profiles: array(string()).optional(),
7595
7635
  /** Copy throttle in MB/s (default 40) — the drain is a background chore,
7596
7636
  * never allowed to starve live writers. */
7597
7637
  throttleMbps: number().min(1).max(1e3).optional()
@@ -7727,6 +7767,21 @@ var StorageLocationSchema = object({
7727
7767
  nodeId: string().optional(),
7728
7768
  isDefault: boolean().default(false),
7729
7769
  isSystem: boolean().default(false),
7770
+ /**
7771
+ * Operator opt-in: whether consumers that BALANCE across several locations
7772
+ * of a type may write here. Recordings reads it today; event media and
7773
+ * backups are the next consumers, which is why the flag lives on the
7774
+ * location rather than in any one addon's store — nothing has to be
7775
+ * extended to add the next consumer.
7776
+ *
7777
+ * OPTIONAL, and ABSENT MEANS ACTIVE. Every location persisted before the
7778
+ * flag existed reads back with no flag and keeps working exactly as before;
7779
+ * that is the whole compat story, and it is why no migration ships with it.
7780
+ * A newly CREATED sibling is stamped `false` by the orchestrator (creating a
7781
+ * disk must not silently start writing to it); the default of a type is
7782
+ * always stamped `true`.
7783
+ */
7784
+ enabled: boolean().optional(),
7730
7785
  /** COMPUTED at read time by the orchestrator (statfs of the backing volume
7731
7786
  * for node-local locations it can reach) — never persisted, absent when the
7732
7787
  * volume is remote/unreachable. The single capacity truth every UI reads. */
@@ -12159,7 +12214,8 @@ method(object({
12159
12214
  }), EmbeddingResultSchema), method(object({ text: string() }), EmbeddingResultSchema), method(_void(), EmbeddingInfoSchema);
12160
12215
  /**
12161
12216
  * filesystem-browse — per-node capability for browsing the node's local
12162
- * filesystem, sandboxed to operator-configured allowed roots. Used by the
12217
+ * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12218
+ * are sandboxed to operator-configured allowed roots (D115). Used by the
12163
12219
  * admin "Add filesystem location" flow to pick a node + path. `mode:'per-node'`
12164
12220
  * (one provider per node); the hub calls it with `{nodeId}` so the codegen
12165
12221
  * routes to that exact node (default `nodeIdMode:'routing'`).
@@ -13972,6 +14028,13 @@ var MaskGridDimsSchema = object({
13972
14028
  * `package-event` are pure trigger kinds (no urgency dimension). Extending
13973
14029
  * this one field keeps the schema additive — a rule still declares exactly
13974
14030
  * one trigger.
14031
+ *
14032
+ * AUDIO rules add no member here, for the reason occupancy added none: the
14033
+ * enum is mirrored by hand in the viewer (`scripts/check-viewer-condition-
14034
+ * mirror.ts` fails the build on a member the app cannot render) and every
14035
+ * member costs a release train. A sustained-sound rule is therefore an
14036
+ * `immediate` rule carrying {@link NcConditions.audio} — the condition is the
14037
+ * trigger discriminator, exactly as `occupancy` is on `device-event`.
13975
14038
  */
13976
14039
  var NcDeliverySchema = _enum([
13977
14040
  "immediate",
@@ -13986,15 +14049,32 @@ var NcDeliverySchema = _enum([
13986
14049
  * depend on a provider's raw event name or payload shape.
13987
14050
  */
13988
14051
  var NcSystemEventKindSchema = _enum([
13989
- "camera-online",
13990
- "camera-offline",
14052
+ "device-online",
14053
+ "device-offline",
14054
+ "device-disabled",
14055
+ "device-enabled",
13991
14056
  "stream-online",
13992
14057
  "stream-offline",
13993
14058
  "node-online",
13994
14059
  "node-offline",
13995
14060
  "addon-update-available",
13996
- "server-update-available"
14061
+ "server-update-available",
14062
+ "alarm-triggered",
14063
+ "alarm-armed",
14064
+ "alarm-disarmed",
14065
+ "camera-online",
14066
+ "camera-offline",
14067
+ "camera-disabled",
14068
+ "camera-enabled"
14069
+ ]);
14070
+ /** The legacy tail of {@link NcSystemEventKindSchema} — see its docblock. */
14071
+ var NC_LEGACY_SYSTEM_EVENT_KINDS = new Set([
14072
+ "camera-online",
14073
+ "camera-offline",
14074
+ "camera-disabled",
14075
+ "camera-enabled"
13997
14076
  ]);
14077
+ NcSystemEventKindSchema.options.filter((kind) => !NC_LEGACY_SYSTEM_EVENT_KINDS.has(kind));
13998
14078
  /**
13999
14079
  * One coherent system-event condition. `kinds` is the required opt-in safety
14000
14080
  * gate; the remaining lists are optional narrowing filters relevant to the
@@ -14003,6 +14083,18 @@ var NcSystemEventKindSchema = _enum([
14003
14083
  var NcSystemEventConditionSchema = object({
14004
14084
  kinds: array(NcSystemEventKindSchema).min(1),
14005
14085
  deviceIds: array(number().int()).min(1).optional(),
14086
+ /**
14087
+ * Narrow a `device-*` kind to these device TYPES (`DeviceType` values —
14088
+ * `camera`, `switch`, `sensor`, `container`, …). Absent = every type, which
14089
+ * is what a liveness rule means when nobody said otherwise.
14090
+ *
14091
+ * This is where "only my cameras" is expressed, and it lives on the rule for
14092
+ * one reason: the intake cannot know which devices this household cares
14093
+ * about, and a producer-side filter is one no operator can change. Fails
14094
+ * CLOSED — a subject whose device type is unknown (an id the device mirror
14095
+ * does not carry) matches no `deviceTypes` list.
14096
+ */
14097
+ deviceTypes: array(string().min(1)).min(1).optional(),
14006
14098
  nodeIds: array(string().min(1)).min(1).optional(),
14007
14099
  packageNames: array(string().min(1)).min(1).optional()
14008
14100
  });
@@ -14053,6 +14145,47 @@ var NcOccupancyConditionSchema = object({
14053
14145
  sustainSeconds: number().int().min(0).max(3600).default(15)
14054
14146
  });
14055
14147
  /**
14148
+ * Audio condition (IMMEDIATE trigger) — a rule on SOUND, not on a picture.
14149
+ *
14150
+ * Operator-approved vocabulary (2026-08-12, option A — the same one the
14151
+ * reference notifier uses, so an operator moving between them re-uses what
14152
+ * they already know): a rule matches when, over a sampling window of
14153
+ * `samplingSeconds`, at least `hitPercent`% of the audio samples in that
14154
+ * window are HITS. A sample is a hit when it satisfies BOTH present filters:
14155
+ *
14156
+ * - `dbThreshold` — its level is at or above this many dBFS (see
14157
+ * {@link NC_AUDIO_DBFS_FLOOR}: negative-going, `0` = full scale);
14158
+ * - `labels` — the classifier put at least one of these labels on it.
14159
+ *
14160
+ * Both are OPTIONAL and independent, which is the point of the shape: a
14161
+ * loudness rule ("something loud at 3am") needs no model to be right, and a
14162
+ * label rule ("a dog barked") needs no threshold. **Fail-closed when NEITHER
14163
+ * is given** — a window in which every sample is trivially a hit would fire on
14164
+ * silence, so the engine refuses such a condition rather than notifying on
14165
+ * nothing (the schema cannot express "at least one of" without becoming a
14166
+ * ZodEffects the cap path would have to special-case).
14167
+ *
14168
+ * `hitPercent` is over the samples the window actually HOLDS, and the window
14169
+ * must be FULL before it can match — a window that has been open for two
14170
+ * seconds of its ten is 100% of nothing, and firing on it would make
14171
+ * `samplingSeconds` decorative.
14172
+ *
14173
+ * Labels are the audio macro classes (`AUDIO_MACRO_LABELS` / the NC taxonomy's
14174
+ * `audio-*` ids). Both spellings are accepted — the matcher normalizes the
14175
+ * `audio-` prefix away on both sides, so a picker that offers taxonomy ids and
14176
+ * an operator who typed `dog` mean the same thing.
14177
+ */
14178
+ var NcAudioConditionSchema = object({
14179
+ /** Audio macro labels; absent = any sound (level-only rule). */
14180
+ labels: array(string().min(1)).min(1).optional(),
14181
+ /** Level floor in dBFS (negative-going, `0` = full scale); absent = any level. */
14182
+ dbThreshold: number().min(-96).max(0).optional(),
14183
+ /** Percentage of the window's samples that must be hits (1–100). */
14184
+ hitPercent: number().int().min(1).max(100).default(60),
14185
+ /** Length of the sampling window in seconds. */
14186
+ samplingSeconds: number().int().min(1).max(300).default(10)
14187
+ });
14188
+ /**
14056
14189
  * Which zone-crossing DIRECTION a rule accepts (`ObjectEvent.zoneCrossing`).
14057
14190
  *
14058
14191
  * The values are not symmetric, and deliberately so — the absent value has to
@@ -14325,7 +14458,33 @@ var NcConditionsSchema = object({
14325
14458
  * threshold and holds for `sustainSeconds`. Fail-closed on missing
14326
14459
  * substrate (no snapshot / missing zone). See {@link NcOccupancyCondition}.
14327
14460
  */
14328
- occupancy: NcOccupancyConditionSchema.optional()
14461
+ occupancy: NcOccupancyConditionSchema.optional(),
14462
+ /**
14463
+ * IMMEDIATE only. Sustained-sound matcher — `hitPercent` of the samples in a
14464
+ * `samplingSeconds` window clear the optional `dbThreshold` and carry one of
14465
+ * the optional `labels`. Fail-closed on missing substrate (no audio samples,
14466
+ * a window that is not full yet, neither filter given). See
14467
+ * {@link NcAudioCondition}.
14468
+ *
14469
+ * Presence of this key is what makes a rule an AUDIO rule: the engine fires
14470
+ * it ONLY on a confirmed audio window, and a rule carrying it never fires on
14471
+ * a detection, a track or a device event (the same fail-closed pairing
14472
+ * `occupancy` has with the `device-event` trigger). That is how audio labels
14473
+ * leave `classes`: an audio rule names its sounds HERE, and the legacy path
14474
+ * (an `immediate` rule naming an `audio-*` class, one notification per
14475
+ * classified sample) stays exactly as it was for rules that already use it.
14476
+ *
14477
+ * NOT in {@link NC_CONDITION_CATALOG} yet, and that is the sequencing rule
14478
+ * rather than an oversight: the viewer mirrors the descriptor enums BY HAND
14479
+ * (`camstack/src/data/notification-center.ts`, guarded by
14480
+ * `scripts/check-viewer-condition-mirror.ts`) and its rule editor STRIPS the
14481
+ * condition fields it does not know when a rule is saved from the phone.
14482
+ * Publishing an editor for a condition the app cannot round-trip is how an
14483
+ * operator loses a rule's conditions by opening it — so the descriptor, the
14484
+ * admin widget and the viewer mirror land together (P2 + P3), and only then
14485
+ * does an audio rule become authorable.
14486
+ */
14487
+ audio: NcAudioConditionSchema.optional()
14329
14488
  });
14330
14489
  /** One delivery target: a `notification-output` Target ref + passthrough params. */
14331
14490
  var NcRuleTargetSchema = object({
@@ -14439,6 +14598,73 @@ var NcThrottleSchema = object({
14439
14598
  */
14440
14599
  granularity: NcThrottleGranularitySchema.optional()
14441
14600
  });
14601
+ /**
14602
+ * How long the confirm gate may hold ONE notification, and how big the picture
14603
+ * it judges may be.
14604
+ *
14605
+ * The clamp is the product decision, not a coincidence of the model: p50 was
14606
+ * 4.9 s warm and 15.3 s cold against qwen3-vl-8b, and a notification that
14607
+ * arrives after the visitor has gone is not a notification. 448 px was enough
14608
+ * to score 16/16 on the operator's parking scenario — bigger costs latency and
14609
+ * tokens for pixels the model pools away.
14610
+ */
14611
+ var NC_CONFIRM_MIN_TIMEOUT_MS = 1e3;
14612
+ var NC_CONFIRM_MAX_TIMEOUT_MS = 2e4;
14613
+ var NC_CONFIRM_DEFAULT_TIMEOUT_MS = 8e3;
14614
+ /** Comparison the model's COUNT must satisfy for the notification to fire. */
14615
+ var NcConfirmExpectSchema = object({
14616
+ op: _enum([
14617
+ ">=",
14618
+ ">",
14619
+ "<=",
14620
+ "<",
14621
+ "=="
14622
+ ]),
14623
+ count: number().int().min(0).max(1e3)
14624
+ });
14625
+ /**
14626
+ * AI CONFIRM — a vision model looks at the picture this notification is about
14627
+ * to ship and says whether it agrees with the rule.
14628
+ *
14629
+ * It runs AFTER the attachments resolve, deliberately: the crop JUDGED is the
14630
+ * crop SHIPPED (D52). A verdict about a different pixel rectangle than the one
14631
+ * on the operator's phone is not a verdict about this notification.
14632
+ *
14633
+ * FAIL-OPEN is the only safe default. A gate that cannot reach its model, or
14634
+ * whose model is cold, must not silence a camera — so `onTimeout: 'fire'` is
14635
+ * the default and every fail-open is COUNTED, because a gate that always fails
14636
+ * open looks in the log exactly like a gate that works.
14637
+ *
14638
+ * Every field is `.optional()` rather than relied on as a Zod default at the
14639
+ * runtime seam: a Zod default does NOT run on the addon→addon cap path (three
14640
+ * production failures in one day), so the gate reads absent as the constant
14641
+ * above rather than trusting a parse it may never have seen.
14642
+ */
14643
+ var NcConfirmSchema = object({
14644
+ /** Off unless asked for. An absent `confirm` and `enabled:false` are the
14645
+ * same thing, and both mean "deliver exactly as before". */
14646
+ enabled: boolean().default(false),
14647
+ /** Explicit vision profile; absent = the `purpose:'vision'` cluster default. */
14648
+ profileId: string().optional(),
14649
+ /**
14650
+ * The operator's question, in his own words. Absent = a question derived
14651
+ * from the rule (its class and its expectation).
14652
+ *
14653
+ * NEVER composed with text READ OUT OF THE FRAME. The model reads OSD
14654
+ * banners, signage and plates as instructions if you let them reach the
14655
+ * prompt — proven live — so the authoritative contract stays in the system
14656
+ * turn and only rule-authored words land here.
14657
+ */
14658
+ prompt: string().max(1e3).optional(),
14659
+ /** Fire only when the model's count satisfies this. Absent = the model's
14660
+ * own boolean verdict decides. */
14661
+ expect: NcConfirmExpectSchema.optional(),
14662
+ timeoutMs: number().int().min(NC_CONFIRM_MIN_TIMEOUT_MS).max(NC_CONFIRM_MAX_TIMEOUT_MS).default(NC_CONFIRM_DEFAULT_TIMEOUT_MS),
14663
+ /** What a timeout / unreachable model MEANS. `fire` (default) = fail-open. */
14664
+ onTimeout: _enum(["fire", "suppress"]).default("fire"),
14665
+ /** Longest edge the judged image is downscaled to before it is sent. */
14666
+ maxImagePx: number().int().min(64).max(2048).default(448)
14667
+ });
14442
14668
  /** Client-supplied rule fields (server stamps id/createdBy/createdAt/updatedAt). */
14443
14669
  var NcRuleInputSchema = object({
14444
14670
  name: string().min(1).max(200),
@@ -14499,7 +14725,13 @@ var NcRuleInputSchema = object({
14499
14725
  * `{ cap: 'alarm-panel', method: 'arm', args: { mode: 'away' } }`, the same
14500
14726
  * shape as every other actuation.
14501
14727
  */
14502
- actions: NcRuleActionsSchema.optional()
14728
+ actions: NcRuleActionsSchema.optional(),
14729
+ /**
14730
+ * AI CONFIRM — see {@link NcConfirmSchema}. `.optional()`, never defaulted:
14731
+ * a rule that predates the gate must keep delivering byte-for-byte as it
14732
+ * did, and absent is the only way to say that without a migration.
14733
+ */
14734
+ confirm: NcConfirmSchema.optional()
14503
14735
  });
14504
14736
  /**
14505
14737
  * Partial patch for `updateRule` — any subset of the input fields, plus the
@@ -14510,7 +14742,37 @@ var NcRuleInputSchema = object({
14510
14742
  * still flow through `nc.setRuleTargetEnabled` (owner-checked), never a raw
14511
14743
  * `updateRule` patch.
14512
14744
  */
14513
- var NcRulePatchSchema = NcRuleInputSchema.partial().extend({ disabledTargetIds: array(string()).optional() });
14745
+ var NcRulePatchSchema = NcRuleInputSchema.partial().extend({
14746
+ disabledTargetIds: array(string()).optional(),
14747
+ /**
14748
+ * `.partial()` DOES NOT REMOVE A FIELD'S `.default()`.
14749
+ *
14750
+ * It makes the key optional to SUPPLY; the parse still materialises the
14751
+ * default when the key is absent. And `NcRuleStore.update` merges with
14752
+ * `{ ...existing, ...patch }`, so a materialised key OVERWRITES the stored
14753
+ * one — which made every partial edit destructive:
14754
+ *
14755
+ * nc.updateRule({ throttle }) → conditions reset to `{}`
14756
+ * nc.setRuleTargetEnabled(...) → conditions reset to `{}`
14757
+ * setEnabled(ruleId, false) → conditions reset to `{}`
14758
+ *
14759
+ * A rule scoped to one camera and one zone silently became a rule that
14760
+ * matches EVERY event on EVERY camera, and lost its `media` policy
14761
+ * (zoneCrop / gif / clip / frame) and its `priority` at the same time. Seen
14762
+ * live on 2026-08-12: a rule scoped to device 617 fired on 590 and 615
14763
+ * within a minute of a two-field patch.
14764
+ *
14765
+ * So every defaulted field is re-declared here WITHOUT its default. The
14766
+ * inner defaults still apply when the caller DOES send the key — `{}` for
14767
+ * conditions remains a real instruction ("clear them") — and only the
14768
+ * absent key is now genuinely absent.
14769
+ */
14770
+ enabled: boolean().optional(),
14771
+ conditions: NcConditionsSchema.optional(),
14772
+ media: NcMediaPolicySchema.optional(),
14773
+ throttle: NcThrottleSchema.optional(),
14774
+ priority: number().int().min(1).max(5).optional()
14775
+ });
14514
14776
  /** A persisted rule. */
14515
14777
  var NcRuleSchema = NcRuleInputSchema.extend({
14516
14778
  id: string(),
@@ -14811,6 +15073,25 @@ var NcAlarmSettingsPatchSchema = NcAlarmSettingsSchema.partial();
14811
15073
  * Never authored, never stored — see `alarm-mode-coverage.ts` for why a stored
14812
15074
  * copy would lie the first time a rule is disabled.
14813
15075
  */
15076
+ /**
15077
+ * Why a device a mode NAMES is nonetheless not armed by it.
15078
+ *
15079
+ * Each value is an existing authority, never a new flag (D62): `muted` is the
15080
+ * per-camera notification switch the Notification Center already owns,
15081
+ * `detection-off` is the device's own detection binding being inactive, and
15082
+ * `offline` is the device manager's liveness. A fourth reason would mean a
15083
+ * fourth authority, and inventing one here is how a panel starts disagreeing
15084
+ * with the switches the operator actually used.
15085
+ */
15086
+ var NcAlarmSkipReasonSchema = _enum([
15087
+ "muted",
15088
+ "detection-off",
15089
+ "offline"
15090
+ ]);
15091
+ var NcAlarmSkippedDeviceSchema = object({
15092
+ deviceId: number().int(),
15093
+ reason: NcAlarmSkipReasonSchema
15094
+ });
14814
15095
  var NcAlarmModeCoverageSchema = object({
14815
15096
  mode: AlarmArmModeSchema,
14816
15097
  /** Enabled rules gated on `armed_<mode>`. Zero means the mode does nothing. */
@@ -14818,7 +15099,18 @@ var NcAlarmModeCoverageSchema = object({
14818
15099
  /** At least one covering rule has no device scope, so the mode covers all. */
14819
15100
  allDevices: boolean(),
14820
15101
  /** Ids named by the covering rules. A SUBSET when `allDevices` is true. */
14821
- deviceIds: array(number().int())
15102
+ deviceIds: array(number().int()),
15103
+ /**
15104
+ * Devices this mode NAMES but cannot actually arm, each with the switch that
15105
+ * excludes it.
15106
+ *
15107
+ * "Away armed — 12 cameras" is a promise, and a muted camera among those
15108
+ * twelve makes it false in exactly the way nobody notices until an incident.
15109
+ * Defaulted to `[]` so a coverage answer computed before this field existed
15110
+ * still parses as "nothing known to be skipped" rather than failing the whole
15111
+ * alarm tab.
15112
+ */
15113
+ skippedDevices: array(NcAlarmSkippedDeviceSchema).default([])
14822
15114
  });
14823
15115
  var NcAlarmConfigSchema = object({
14824
15116
  /**
@@ -17617,9 +17909,16 @@ var CameraStatusSchema = object({
17617
17909
  audio: CameraAudioStatusSchema.nullable(),
17618
17910
  recording: CameraRecordingStatusSchema.nullable(),
17619
17911
  /**
17620
- * Per-camera function switches an OPERATOR has turned off
17912
+ * Per-camera functions an OPERATOR has turned off
17621
17913
  * ([D61](../../../../docs/decisions/adr-0067.md)).
17622
17914
  *
17915
+ * Composed from the AUTHORITIES themselves — the wrapper bindings,
17916
+ * `RecordingConfig.enabled`, the notification mute, the broker's audio
17917
+ * policy, the camera's own microphone — via `composeSwitchedOff`, not from
17918
+ * the deprecated `getCameraSwitches` group ([D113](../../../../docs/decisions/adr-0113.md)).
17919
+ * The badge outlives the control panel: the panel was a convenience, this is
17920
+ * the difference between a camera being off and a camera being dead.
17921
+ *
17623
17922
  * This is the difference between DISABLED and BROKEN. A camera whose
17624
17923
  * `detection` block reports zero fps and whose `switchedOff` contains
17625
17924
  * `'object-detection'` was switched off by a person; the same camera with an
@@ -23128,7 +23427,19 @@ var RecordingManifestSchema = object({
23128
23427
  * profiles/subtrees/locations on this node). */
23129
23428
  var RecordingDeviceUsageSchema = object({
23130
23429
  deviceId: number(),
23131
- usedBytes: number()
23430
+ usedBytes: number(),
23431
+ /**
23432
+ * Start of this camera's OLDEST indexed segment, across every profile and
23433
+ * location — the "Oldest footage" column in Recordings → Storage, and the
23434
+ * only honest answer to "is retention actually holding?" per camera.
23435
+ *
23436
+ * `null` = the camera has no footage. OPTIONAL because a recorder that
23437
+ * predates this field omits it entirely, and a hub whose types carry the
23438
+ * field must keep validating that older provider's payload: the framework
23439
+ * (types) and the addon ship on different trains, and the addon is usually
23440
+ * the later of the two.
23441
+ */
23442
+ oldestMs: number().nullable().optional()
23132
23443
  });
23133
23444
  /** Recording storage usage + capacity for one storage location. */
23134
23445
  var RecordingLocationUsageSchema = object({
@@ -23156,6 +23467,57 @@ var RecordingStorageUsageSchema = object({
23156
23467
  locations: array(RecordingLocationUsageSchema)
23157
23468
  });
23158
23469
  /**
23470
+ * The OPERATOR-ARMED half of multi-location recordings (D116).
23471
+ *
23472
+ * The placement plan decides where NEW writes go and moves nothing. A rebalance
23473
+ * is the operator asking for the EXISTING archive to be brought into line with
23474
+ * that plan: one relocate job per (camera, profile) pile that sits on the wrong
23475
+ * location, run FIFO behind the single-flight mover.
23476
+ *
23477
+ * `plan…` and `start…` return the SAME shape deliberately — what the operator
23478
+ * confirms is exactly what gets enqueued, and `jobIds` is the only difference
23479
+ * (empty on the plan).
23480
+ */
23481
+ var RecordingRebalanceMoveSchema = object({
23482
+ deviceId: number(),
23483
+ profile: string(),
23484
+ fromLocationId: string(),
23485
+ toLocationId: string(),
23486
+ bytes: number(),
23487
+ files: number().int()
23488
+ });
23489
+ /** Why a pile that is out of place is staying there. Every refusal is
23490
+ * reported: a rebalance that silently drops a camera reads exactly like one
23491
+ * that had nothing to do. */
23492
+ var RecordingRebalanceSkipReasonSchema = _enum([
23493
+ "unassigned",
23494
+ "target-not-writable",
23495
+ "below-threshold",
23496
+ "no-headroom"
23497
+ ]);
23498
+ var RecordingRebalanceSkipSchema = object({
23499
+ deviceId: number(),
23500
+ profile: string(),
23501
+ fromLocationId: string(),
23502
+ /** The location the plan wants; null when the camera has no assignment. */
23503
+ toLocationId: string().nullable(),
23504
+ bytes: number(),
23505
+ reason: RecordingRebalanceSkipReasonSchema
23506
+ });
23507
+ var RecordingRebalancePlanSchema = object({
23508
+ moves: array(RecordingRebalanceMoveSchema),
23509
+ skipped: array(RecordingRebalanceSkipSchema),
23510
+ bytesToMove: number(),
23511
+ /** Relocate job ids enqueued. Always empty for the plan (dry-run) call. */
23512
+ jobIds: array(string())
23513
+ });
23514
+ var RecordingRebalanceInputSchema = object({
23515
+ /** Copy throttle in MB/s (default 40) — a rebalance is a background chore. */
23516
+ throttleMbps: number().min(1).max(1e3).optional(),
23517
+ /** Ignore piles smaller than this (default 1 GB). */
23518
+ minMoveGb: number().min(0).optional()
23519
+ });
23520
+ /**
23159
23521
  * Result of locating footage at a wall-clock instant for one device/profile.
23160
23522
  * `segment` carries the covering segment's window; `gap` reports the forward
23161
23523
  * nearest covered edge (`null` past the end of footage / when none exists)
@@ -23318,9 +23680,24 @@ method(object({
23318
23680
  }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23319
23681
  kind: "mutation",
23320
23682
  auth: "admin"
23683
+ }), method(RelocateFootageInputSchema, object({ jobId: string() }), {
23684
+ kind: "mutation",
23685
+ auth: "admin"
23686
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
23687
+ kind: "query",
23688
+ auth: "admin"
23689
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
23690
+ kind: "mutation",
23691
+ auth: "admin"
23692
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23693
+ kind: "query",
23694
+ auth: "admin"
23695
+ }), method(RecordingRebalanceInputSchema, RecordingRebalancePlanSchema, {
23696
+ kind: "mutation",
23697
+ auth: "admin"
23321
23698
  });
23322
23699
  /**
23323
- * `recordingExport` cap — render a footage time range into a single downloadable
23700
+ * `recording-export` cap — render a footage time range into a single downloadable
23324
23701
  * MP4 (regular / accelerated / decelerated / timelapse, ± audio), kept for a
23325
23702
  * bounded lifetime with a durable history, auto-expiry, and optional
23326
23703
  * delete-after-download.
@@ -23335,10 +23712,53 @@ method(object({
23335
23712
  */
23336
23713
  /** Playback-speed multiplier for the render (1 = realtime). */
23337
23714
  var ExportSpeedSchema = number().min(.25).max(32);
23715
+ /**
23716
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
23717
+ *
23718
+ * **Wall clock, not ffmpeg's `t`** — and the recorder translates. A caller
23719
+ * derives these bounds from things that happened at a TIME (a track's
23720
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
23721
+ * every segment present for the range, with each recording GAP removed. The
23722
+ * two agree only on a window that recorded without one interruption, and only
23723
+ * the render side knows the segments, so the translation lives there
23724
+ * (`export-dense-map.ts`, addon-pipeline).
23725
+ *
23726
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
23727
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
23728
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
23729
+ * the video was a uniform timelapse, and the log line reported the five ranges
23730
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
23731
+ *
23732
+ * Relative and not absolute epoch, because an absolute epoch would make every
23733
+ * call site responsible for the same subtraction.
23734
+ */
23735
+ var ExportDenseRangeSchema = object({
23736
+ fromSec: number().nonnegative(),
23737
+ toSec: number().nonnegative()
23738
+ }).refine((r) => r.toSec > r.fromSec, { message: "dense range must have toSec > fromSec" });
23739
+ /**
23740
+ * Dense-interval overlay for a timelapse: sample at `dense.everyMs` INSIDE the
23741
+ * listed ranges and at the base `everyMs` everywhere else.
23742
+ *
23743
+ * `everyMs` must be strictly smaller than the base cadence — a dense rate that
23744
+ * is not denser renders a uniform timelapse the operator believes is two-rate.
23745
+ */
23746
+ var ExportDenseSchema = object({
23747
+ everyMs: number().int().positive(),
23748
+ ranges: array(ExportDenseRangeSchema).min(1).max(200)
23749
+ });
23338
23750
  /** Timelapse cadence — sample one source frame per `everyMs`, output at `outputFps`. */
23339
23751
  var ExportTimelapseSchema = object({
23340
23752
  everyMs: number().int().positive(),
23341
- outputFps: number().int().min(1).max(60).optional()
23753
+ outputFps: number().int().min(1).max(60).optional(),
23754
+ /** Optional second, FASTER rate over the intervals that matter. */
23755
+ dense: ExportDenseSchema.optional()
23756
+ }).superRefine((v, ctx) => {
23757
+ if (v.dense !== void 0 && v.dense.everyMs >= v.everyMs) ctx.addIssue({
23758
+ code: ZodIssueCode.custom,
23759
+ message: "dense.everyMs must be strictly smaller than the base everyMs",
23760
+ path: ["dense", "everyMs"]
23761
+ });
23342
23762
  });
23343
23763
  /**
23344
23764
  * Render options. `speed` and `timelapse` are mutually exclusive. `includeAudio`
@@ -23396,6 +23816,19 @@ var ExportDownloadSchema = object({
23396
23816
  url: string(),
23397
23817
  endpoints: array(string())
23398
23818
  });
23819
+ /**
23820
+ * A finished export's bytes, inline.
23821
+ *
23822
+ * `bytes` is the DECODED length — the number the caller bounds and logs
23823
+ * against, so nobody has to infer it from the base64 length.
23824
+ */
23825
+ var ExportBytesSchema = object({
23826
+ base64: string(),
23827
+ contentType: string(),
23828
+ /** Suggested filename, extension included. */
23829
+ name: string(),
23830
+ bytes: number().int().nonnegative()
23831
+ });
23399
23832
  method(object({
23400
23833
  deviceId: number(),
23401
23834
  profile: string(),
@@ -23420,6 +23853,9 @@ method(object({
23420
23853
  }), method(object({ exportId: string() }), ExportDownloadSchema, {
23421
23854
  kind: "query",
23422
23855
  auth: "protected"
23856
+ }), method(object({ exportId: string() }), ExportBytesSchema, {
23857
+ kind: "query",
23858
+ auth: "protected"
23423
23859
  });
23424
23860
  /**
23425
23861
  * scene-monitor — device-scoped reference-region state cap. An operator marks
@@ -28613,6 +29049,12 @@ Object.freeze({
28613
29049
  addonId: null,
28614
29050
  access: "create"
28615
29051
  },
29052
+ "recording.cancelRelocateJob": {
29053
+ capName: "recording",
29054
+ capScope: "system",
29055
+ addonId: null,
29056
+ access: "create"
29057
+ },
28616
29058
  "recording.cancelStorageMigrationMove": {
28617
29059
  capName: "recording",
28618
29060
  capScope: "system",
@@ -28667,6 +29109,12 @@ Object.freeze({
28667
29109
  addonId: null,
28668
29110
  access: "view"
28669
29111
  },
29112
+ "recording.listRelocateJobs": {
29113
+ capName: "recording",
29114
+ capScope: "system",
29115
+ addonId: null,
29116
+ access: "view"
29117
+ },
28670
29118
  "recording.locateSegment": {
28671
29119
  capName: "recording",
28672
29120
  capScope: "system",
@@ -28679,6 +29127,12 @@ Object.freeze({
28679
29127
  addonId: null,
28680
29128
  access: "create"
28681
29129
  },
29130
+ "recording.planStorageRebalance": {
29131
+ capName: "recording",
29132
+ capScope: "system",
29133
+ addonId: null,
29134
+ access: "view"
29135
+ },
28682
29136
  "recording.pruneFootage": {
28683
29137
  capName: "recording",
28684
29138
  capScope: "system",
@@ -28703,6 +29157,12 @@ Object.freeze({
28703
29157
  addonId: null,
28704
29158
  access: "create"
28705
29159
  },
29160
+ "recording.relocateFootage": {
29161
+ capName: "recording",
29162
+ capScope: "system",
29163
+ addonId: null,
29164
+ access: "create"
29165
+ },
28706
29166
  "recording.renderClip": {
28707
29167
  capName: "recording",
28708
29168
  capScope: "system",
@@ -28739,38 +29199,50 @@ Object.freeze({
28739
29199
  addonId: null,
28740
29200
  access: "create"
28741
29201
  },
29202
+ "recording.startStorageRebalance": {
29203
+ capName: "recording",
29204
+ capScope: "system",
29205
+ addonId: null,
29206
+ access: "create"
29207
+ },
28742
29208
  "recordingExport.cancelExport": {
28743
- capName: "recordingExport",
29209
+ capName: "recording-export",
28744
29210
  capScope: "system",
28745
29211
  addonId: null,
28746
29212
  access: "create"
28747
29213
  },
28748
29214
  "recordingExport.createExport": {
28749
- capName: "recordingExport",
29215
+ capName: "recording-export",
28750
29216
  capScope: "system",
28751
29217
  addonId: null,
28752
29218
  access: "create"
28753
29219
  },
28754
29220
  "recordingExport.deleteExport": {
28755
- capName: "recordingExport",
29221
+ capName: "recording-export",
28756
29222
  capScope: "system",
28757
29223
  addonId: null,
28758
29224
  access: "delete"
28759
29225
  },
28760
29226
  "recordingExport.getDownloadUrl": {
28761
- capName: "recordingExport",
29227
+ capName: "recording-export",
28762
29228
  capScope: "system",
28763
29229
  addonId: null,
28764
29230
  access: "view"
28765
29231
  },
28766
29232
  "recordingExport.getExport": {
28767
- capName: "recordingExport",
29233
+ capName: "recording-export",
28768
29234
  capScope: "system",
28769
29235
  addonId: null,
28770
29236
  access: "view"
28771
29237
  },
28772
29238
  "recordingExport.listExports": {
28773
- capName: "recordingExport",
29239
+ capName: "recording-export",
29240
+ capScope: "system",
29241
+ addonId: null,
29242
+ access: "view"
29243
+ },
29244
+ "recordingExport.readExportBytes": {
29245
+ capName: "recording-export",
28774
29246
  capScope: "system",
28775
29247
  addonId: null,
28776
29248
  access: "view"
@@ -30147,6 +30619,104 @@ var FramerateField = number().int().min(1).max(60);
30147
30619
  var TargetsField = array(NcRuleTargetSchema).min(1);
30148
30620
  var PriorityField = number().int().min(1).max(5);
30149
30621
  /**
30622
+ * Explicit override of the DENSE sampling cadence, seconds.
30623
+ *
30624
+ * Absent ⇒ derived as `max(1s, cadenceSec / 30)` — a 30 s base samples every
30625
+ * 1 s inside a detection range. (It was `base / 10` until 2026-08-12, which
30626
+ * made that same base 3 s and rendered a person pass as two frames.)
30627
+ *
30628
+ * THE ARITHMETIC. A detection range of `rangeSec` seconds sampled every
30629
+ * `denseCadenceSec` and played at `framerate` occupies
30630
+ *
30631
+ * outputSeconds = (rangeSec / denseCadenceSec) / framerate
30632
+ *
30633
+ * 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.
30634
+ * Halving this field doubles the frames INSIDE ranges only — the base cadence,
30635
+ * and therefore the length of a quiet night, does not move.
30636
+ *
30637
+ * Floored at {@link TIMELAPSE_DENSE_FLOOR_SEC}: asking for frames faster than
30638
+ * the recording has them returns the same frames, requested twice. Must be
30639
+ * STRICTLY smaller than `cadenceSec` — a dense rate that is not denser renders
30640
+ * a uniform video the operator believes is two-rate — and upsert refuses it
30641
+ * rather than letting the export cap reject the render hours after the window.
30642
+ */
30643
+ var DenseCadenceSecField = number().min(.1).max(3600);
30644
+ /**
30645
+ * Minimum seconds of OUTPUT video each detection range must occupy.
30646
+ *
30647
+ * The operator-facing form of the arithmetic above: instead of solving for a
30648
+ * cadence, state the dwell and let the renderer solve. `minDwellSec: 1` on a
30649
+ * 30 s base at 12 fps turns a 7 s pass into a full second of video by sampling
30650
+ * that range every ~583 ms.
30651
+ *
30652
+ * ONE CADENCE SERVES EVERY RANGE. `ExportDenseSchema.everyMs` is global — the
30653
+ * ranges are terms of a single ffmpeg `select` expression that cannot vary rate
30654
+ * per term — so the MOST DEMANDING (shortest) range sets the rate and longer
30655
+ * ranges are sampled denser than they need. Per-range cadences require a cap
30656
+ * schema change and are the tracked follow-up.
30657
+ *
30658
+ * A range too short to reach the dwell even at {@link TIMELAPSE_DENSE_FLOOR_SEC}
30659
+ * is rendered with every frame that EXISTS and no more: the guarantee is capped
30660
+ * by real footage, never met by duplicating frames into motion that never
30661
+ * happened.
30662
+ */
30663
+ var MinDwellSecField = number().min(0).max(60);
30664
+ /**
30665
+ * Caption burned into the notification's preview frame.
30666
+ *
30667
+ * Same `{{var}}` vocabulary as {@link TimelapseTemplateSchema} (`camera`,
30668
+ * `rule`, `from`, `to`) and rendered by the SAME renderer — a second
30669
+ * templating dialect for one field would be a second thing to explain.
30670
+ *
30671
+ * Absent ⇒ {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}. An EMPTY STRING is the
30672
+ * operator saying "the frame, no caption" — a distinct, reachable answer, and
30673
+ * the reason this is not `.min(1)`.
30674
+ */
30675
+ var PreviewTextField = string().max(200);
30676
+ /**
30677
+ * Whether the notification's preview is a STILL or a short animation.
30678
+ *
30679
+ * The operator's ask, verbatim: *"inviato come gif o video (come per le altre
30680
+ * rule)"* — his Scrypted advanced-notifier has a `gifRule`, and a ten-hour
30681
+ * night reads better as three seconds of motion than as one frame of it. Both
30682
+ * modes get the SAME treatment (blurred frame, large centred title); `'gif'`
30683
+ * simply applies it to a dozen frames sampled across the render and assembles
30684
+ * them.
30685
+ *
30686
+ * `'image'` is the default and stays the default: a GIF costs a dozen ffmpeg
30687
+ * seeks and a palette pass, and no rule that never asked for one should start
30688
+ * paying that on the deploy that shipped it.
30689
+ *
30690
+ * A GIF that cannot be assembled DEGRADES to the still — never to nothing.
30691
+ */
30692
+ var PreviewModeField = _enum(["image", "gif"]);
30693
+ /**
30694
+ * Which detection classes the notification reports counts for.
30695
+ *
30696
+ * The counts come from the tracks the render ALREADY fetched for its dense-range
30697
+ * plan — no second query — aggregated per class. Absent or empty means "every
30698
+ * class the window actually contained", which is what an operator who never
30699
+ * opened the field wants; a list narrows it (`['person']` on a driveway that
30700
+ * counts cars all night).
30701
+ *
30702
+ * Class names are the tracker's own (`person`, `vehicle`, `animal`, `package`,
30703
+ * …). An unknown name simply never matches and reports nothing — it is not an
30704
+ * error, because a rule may legitimately name a class this camera's model does
30705
+ * not emit.
30706
+ *
30707
+ * The counts are exposed to {@link TimelapseTemplateSchema} as:
30708
+ * - `{{detections}}` — total over the reported classes
30709
+ * - `{{detectionSummary}}` — `2 persone, 1 veicolo`
30710
+ * - `{{count_person}}` / `{{count_vehicle}}` / `{{count_animal}}` / … —
30711
+ * one per class, `count_` + the class name
30712
+ *
30713
+ * With NO custom body template the summary is appended to the derived body, and
30714
+ * only when the total is non-zero: a nightly `0 rilevamenti` is a line nobody
30715
+ * reads. With a custom template the operator owns every word — nothing is
30716
+ * appended, so `{{detectionSummary}}` is how he asks for it.
30717
+ */
30718
+ var ReportClassesField = array(string().min(1).max(40)).max(20);
30719
+ /**
30150
30720
  * Client-supplied timelapse-rule fields. The server stamps id / createdBy /
30151
30721
  * createdAt / updatedAt / ownerUserId / lastGeneratedAt — none of them appear
30152
30722
  * here (see the ownership note above).
@@ -30166,9 +30736,30 @@ var TimelapseRuleInputSchema = object({
30166
30736
  cadenceSec: CadenceSecField.default(15),
30167
30737
  /** Output frames per second of the assembled mp4 (predecessor parity). */
30168
30738
  framerate: FramerateField.default(10),
30739
+ /**
30740
+ * Explicit dense cadence — see {@link DenseCadenceSecField}. Absent ⇒ derived
30741
+ * as `max(1s, cadenceSec / 30)`, which is what every rule written before this
30742
+ * field gets.
30743
+ */
30744
+ denseCadenceSec: DenseCadenceSecField.optional(),
30745
+ /** Output-seconds guarantee per detection range — see {@link MinDwellSecField}. */
30746
+ minDwellSec: MinDwellSecField.optional(),
30169
30747
  /** `notification-output` targets the finished video/thumbnail is sent to. */
30170
30748
  targets: TargetsField,
30171
30749
  template: TimelapseTemplateSchema.optional(),
30750
+ /**
30751
+ * Caption on the notification's PREVIEW FRAME — see {@link PreviewTextField}
30752
+ * and {@link DEFAULT_TIMELAPSE_PREVIEW_TEXT}.
30753
+ *
30754
+ * Deliberately NOT part of {@link TimelapseTemplateSchema}: that object is
30755
+ * the notification's title/body, and clearing it (`template: null`) must not
30756
+ * silently clear the caption too.
30757
+ */
30758
+ previewText: PreviewTextField.optional(),
30759
+ /** Still or animation — see {@link PreviewModeField}. */
30760
+ previewMode: PreviewModeField.default("image"),
30761
+ /** Classes the notification counts — see {@link ReportClassesField}. */
30762
+ reportClasses: ReportClassesField.optional(),
30172
30763
  /** Canonical notification priority ordinal (1..5); per-target overridable. */
30173
30764
  priority: PriorityField.default(3)
30174
30765
  });
@@ -30179,8 +30770,13 @@ object({
30179
30770
  schedule: NcScheduleSchema.optional(),
30180
30771
  cadenceSec: CadenceSecField.optional(),
30181
30772
  framerate: FramerateField.optional(),
30773
+ denseCadenceSec: DenseCadenceSecField.optional(),
30774
+ minDwellSec: MinDwellSecField.optional(),
30182
30775
  targets: TargetsField.optional(),
30183
30776
  template: TimelapseTemplateSchema.nullable().optional(),
30777
+ previewText: PreviewTextField.optional(),
30778
+ previewMode: PreviewModeField.optional(),
30779
+ reportClasses: ReportClassesField.optional(),
30184
30780
  priority: PriorityField.optional()
30185
30781
  });
30186
30782
  TimelapseRuleInputSchema.extend({
@@ -30192,10 +30788,28 @@ TimelapseRuleInputSchema.extend({
30192
30788
  */
30193
30789
  ownerUserId: string().optional(),
30194
30790
  /**
30195
- * Epoch-ms of the last successful generation the 1-hour re-generation
30196
- * guard's durable state (predecessor parity). Absent = never generated.
30791
+ * Epoch-ms of the NEWEST successful generation across every camera of this
30792
+ * rule. What a UI shows, and the compatibility floor for
30793
+ * {@link readTimelapseGeneratedAt}. Absent = never generated.
30197
30794
  */
30198
30795
  lastGeneratedAt: number().optional(),
30796
+ /**
30797
+ * PER-CAMERA generation state, keyed by `String(deviceId)` — the
30798
+ * re-generation guard's real durable state.
30799
+ *
30800
+ * One rule covers several cameras and each renders its own video, so a rule
30801
+ * -wide stamp is wrong in the direction that DESTROYS work: camera A
30802
+ * succeeding at 06:05 tells camera B, whose render failed, that it is
30803
+ * already done — and B's night is gone for good, because the window will not
30804
+ * come back.
30805
+ *
30806
+ * ADDITIVE, so the migration is free: a row written before this field simply
30807
+ * has no map, and {@link readTimelapseGeneratedAt} falls back to
30808
+ * {@link TimelapseRuleSchema.shape.lastGeneratedAt}. Reading an old row as
30809
+ * "never generated" would re-render and re-notify every camera of every rule
30810
+ * once, on the deploy that shipped the map.
30811
+ */
30812
+ generatedByDevice: record(string(), number()).optional(),
30199
30813
  /** userId of the caller who created the rule (server-stamped). */
30200
30814
  createdBy: string(),
30201
30815
  createdAt: number(),
@@ -30246,25 +30860,32 @@ object({
30246
30860
  var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
30247
30861
  object({
30248
30862
  /**
30249
- * How long a retained native frame is served before it counts as a miss.
30863
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
30864
+ * detection result.
30865
+ *
30866
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
30867
+ * a time window was never related to the event the pixels were waiting for.
30868
+ * A held frame now lives from delivery until the runner has its `FrameResult`
30869
+ * — at which moment the runner cuts the subject tiles it actually wanted and
30870
+ * releases the frame. The bound exists only so a runner that stops answering
30871
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
30250
30872
  *
30251
- * Must cover the FULL late-crop horizon: detection inference + the
30252
- * cross-process inference-result hop to hub post-analysis + tracking + the
30253
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
30254
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
30255
- * RAM per busy camera grows linearly with no measured hit-rate gain.
30873
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
30874
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
30875
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
30876
+ * Raising it does not buy hit rate it buys tolerance for a slow runner, and
30877
+ * `holdOverflow` on the metrics line is what says you need it.
30256
30878
  */
30257
- ttlMs: number().int().min(250).max(1e4),
30879
+ holdFrames: number().int().min(1).max(64),
30258
30880
  /**
30259
30881
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
30260
30882
  *
30261
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
30262
- * which one is actually binding before reasoning from that. At the shipped
30263
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
30264
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
30265
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
30266
- * change that admits fewer frames buys retention WINDOW at constant RAM
30267
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
30883
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
30884
+ * is what decides how much is held, and the ceiling is the number above which
30885
+ * something is wrong. Before that it was the effective cap at 1024 MB with
30886
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
30887
+ * with the TTL expiring nothing, which is exactly the confusion the hold
30888
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
30268
30889
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
30269
30890
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
30270
30891
  * to replace).
@@ -30290,22 +30911,45 @@ object({
30290
30911
  * there is the signal that some caller names frames outside the inference set
30291
30912
  * and that this must go back to `all`.
30292
30913
  */
30293
- admission: NativeLeaseAdmissionSchema
30914
+ admission: NativeLeaseAdmissionSchema,
30915
+ /**
30916
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
30917
+ * compressed native crops the worker cuts at the moment a frame's detection
30918
+ * result arrives, and keeps long after the frame itself is freed.
30919
+ *
30920
+ * This is the knob that replaced the old retention window, and it buys about
30921
+ * three orders of magnitude more of it: a tile is one subject at native
30922
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
30923
+ * the frame it was cut from. A frame on which nothing was detected costs
30924
+ * nothing at all, which is the real change — the old lease paid per FRAME and
30925
+ * was interrogated per SUBJECT.
30926
+ *
30927
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
30928
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
30929
+ * reproduce that.
30930
+ */
30931
+ tileBudgetMb: number().int().min(0).max(1024)
30294
30932
  });
30295
30933
  /**
30296
- * The values in force when the operator has set nothing — byte-for-byte the
30297
- * constants the decode worker shipped with as env-var defaults, so making these
30298
- * settings changed no behaviour on the day it landed.
30934
+ * The values in force when the operator has set nothing.
30935
+ *
30936
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
30937
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
30938
+ * in the same change that redefines it would make a regression and a retune
30939
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
30940
+ * live traffic.
30299
30941
  */
30300
30942
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
30301
- ttlMs: 1200,
30943
+ holdFrames: 8,
30302
30944
  budgetMb: 1024,
30303
30945
  activityMs: 15e3,
30946
+ tileBudgetMb: 64,
30304
30947
  admission: "inferred"
30305
30948
  };
30306
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
30949
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
30307
30950
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
30308
30951
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
30952
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
30309
30953
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
30310
30954
  /**
30311
30955
  * Fixed-capacity ring buffer. When full, push() overwrites the oldest entry.