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