@camstack/addon-pipeline 1.2.70 → 1.2.71

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 (29) hide show
  1. package/dist/audio-analyzer/index.js +1 -1
  2. package/dist/audio-analyzer/index.mjs +1 -1
  3. package/dist/detection-pipeline/index.js +2 -2
  4. package/dist/detection-pipeline/index.mjs +2 -2
  5. package/dist/{dist-cR-pvD_z.js → dist-CtOVWTCi.js} +78 -33
  6. package/dist/{dist-BPaa4_z6.mjs → dist-D1Xk5Tji.mjs} +78 -33
  7. package/dist/{event-loop-stall-monitor-STRdnQWm.js → event-loop-stall-monitor-BJs7Yws7.js} +1 -1
  8. package/dist/{event-loop-stall-monitor-B79REtL2.mjs → event-loop-stall-monitor-Cmbt664E.mjs} +1 -1
  9. package/dist/motion-wasm/index.js +1 -1
  10. package/dist/motion-wasm/index.mjs +1 -1
  11. package/dist/pipeline-runner/index.js +95 -28
  12. package/dist/pipeline-runner/index.mjs +95 -28
  13. package/dist/recorder/index.js +365 -73
  14. package/dist/recorder/index.mjs +365 -73
  15. package/dist/session-decode/decode-worker-child.js +483 -52
  16. package/dist/session-decode/decode-worker-child.mjs +483 -52
  17. package/dist/stream-broker/_stub.js +660 -556
  18. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-B-HGBNad.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-BWf4H4Nl.mjs} +3 -3
  19. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-Cu_kQpIy.mjs +26 -0
  20. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CExO0piw.mjs +26 -0
  21. package/dist/stream-broker/{hostInit-B12DHOv7.mjs → hostInit-DD5Z1U6p.mjs} +3 -3
  22. package/dist/stream-broker/index.js +1 -1
  23. package/dist/stream-broker/index.mjs +1 -1
  24. package/dist/stream-broker/remoteEntry.js +1 -1
  25. package/dist/{worker-protocol-C7V1qIIA.js → worker-protocol-DEV7g32b.js} +26 -19
  26. package/dist/{worker-protocol-CBO8nwQj.mjs → worker-protocol-Dm6LQ9Ls.mjs} +26 -19
  27. package/package.json +1 -1
  28. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-D1CqbPrT.mjs +0 -26
  29. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-NjvjJWz-.mjs +0 -26
@@ -3,7 +3,7 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../chunk-emK7D4bc.js");
6
- const require_dist = require("../dist-cR-pvD_z.js");
6
+ const require_dist = require("../dist-CtOVWTCi.js");
7
7
  const require_node_topology_platform = require("../node-topology-platform-CFZ7F4xW.js");
8
8
  const require_addon_utils = require("../addon-utils-CQs-AjTJ.js");
9
9
  let node_fs = require("node:fs");
@@ -1,5 +1,5 @@
1
1
  import { n as __require } from "../chunk-DnnnRqeS.mjs";
2
- import { B as mapAudioLabelToMacro, E as audioAnalyzerCapability, T as audioAnalysisCapability, ft as hydrateSchema, m as HF_BASE_URL, n as AUDIO_BACKEND_CHOICES, o as DEFAULT_AUDIO_ANALYZER_CONFIG, st as BaseAddon, tt as errMsg } from "../dist-BPaa4_z6.mjs";
2
+ import { B as mapAudioLabelToMacro, E as audioAnalyzerCapability, T as audioAnalysisCapability, ft as hydrateSchema, m as HF_BASE_URL, n as AUDIO_BACKEND_CHOICES, o as DEFAULT_AUDIO_ANALYZER_CONFIG, st as BaseAddon, tt as errMsg } from "../dist-D1Xk5Tji.mjs";
3
3
  import { t as pickNodePlatformArch } from "../node-topology-platform-BkR_k6WT.mjs";
4
4
  import { i as downloadFile } from "../addon-utils-CZ2xo67g.mjs";
5
5
  import * as fs from "node:fs";
@@ -3,8 +3,8 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../chunk-emK7D4bc.js");
6
- const require_dist = require("../dist-cR-pvD_z.js");
7
- const require_event_loop_stall_monitor = require("../event-loop-stall-monitor-STRdnQWm.js");
6
+ const require_dist = require("../dist-CtOVWTCi.js");
7
+ const require_event_loop_stall_monitor = require("../event-loop-stall-monitor-BJs7Yws7.js");
8
8
  const require_lazy_sharp = require("../lazy-sharp-CcYuXtsa.js");
9
9
  const require_node_topology_platform = require("../node-topology-platform-CFZ7F4xW.js");
10
10
  const require_addon_utils = require("../addon-utils-CQs-AjTJ.js");
@@ -1,6 +1,6 @@
1
1
  import { n as __require } from "../chunk-DnnnRqeS.mjs";
2
- import { $ as supportedRuntimes$1, A as defaultDeviceFor$1, At as string, C as YAMNET_TO_MACRO, G as pipelineExecutorCapability, L as enumerateInferenceDevices, Mt as EventCategory, Ot as object, P as detectionPipelineCapability, R as evaluateZoneRules, St as array, X as runtimeDevices$1, _t as parseJsonUnknown, bt as sleep, dt as createEvent, ft as hydrateSchema, gt as nodePin, jt as union, st as BaseAddon, t as APPLE_SA_TO_MACRO, tt as errMsg, u as DEVICE_BACKEND_TO_FORMAT } from "../dist-BPaa4_z6.mjs";
3
- import { a as getDefaultModelForFormat, c as getStepDefinition, i as ALL_STEPS, l as resolveModelForFormat, n as startEventLoopStallMonitor, o as getDefaultModelForFormatFromDef, r as ALL_PIPELINE_STEPS, s as getStep } from "../event-loop-stall-monitor-B79REtL2.mjs";
2
+ import { $ as supportedRuntimes$1, A as defaultDeviceFor$1, At as string, C as YAMNET_TO_MACRO, G as pipelineExecutorCapability, L as enumerateInferenceDevices, Mt as EventCategory, Ot as object, P as detectionPipelineCapability, R as evaluateZoneRules, St as array, X as runtimeDevices$1, _t as parseJsonUnknown, bt as sleep, dt as createEvent, ft as hydrateSchema, gt as nodePin, jt as union, st as BaseAddon, t as APPLE_SA_TO_MACRO, tt as errMsg, u as DEVICE_BACKEND_TO_FORMAT } from "../dist-D1Xk5Tji.mjs";
3
+ import { a as getDefaultModelForFormat, c as getStepDefinition, i as ALL_STEPS, l as resolveModelForFormat, n as startEventLoopStallMonitor, o as getDefaultModelForFormatFromDef, r as ALL_PIPELINE_STEPS, s as getStep } from "../event-loop-stall-monitor-Cmbt664E.mjs";
4
4
  import { t as getSharp } from "../lazy-sharp-B-mb8uWx.mjs";
5
5
  import { t as pickNodePlatformArch } from "../node-topology-platform-BkR_k6WT.mjs";
6
6
  import { a as ensureModel, o as isModelDownloaded, r as deleteModelFromDisk } from "../addon-utils-CZ2xo67g.mjs";
@@ -25860,13 +25860,24 @@ var recordingCapability = {
25860
25860
  /** Playback-speed multiplier for the render (1 = realtime). */
25861
25861
  var ExportSpeedSchema = number().min(.25).max(32);
25862
25862
  /**
25863
- * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
25863
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25864
25864
  *
25865
- * Relative and not absolute epoch on purpose: the renderer's frame-select
25866
- * expression sees ffmpeg's `t`, which starts at 0 for the export's source
25867
- * playlist. Handing it absolute epochs would make every call site responsible
25868
- * for the same subtraction, and the one that forgot would emit a filter that
25869
- * selects nothing silently, as a uniform timelapse.
25865
+ * **Wall clock, not ffmpeg's `t`** and the recorder translates. A caller
25866
+ * derives these bounds from things that happened at a TIME (a track's
25867
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25868
+ * every segment present for the range, with each recording GAP removed. The
25869
+ * two agree only on a window that recorded without one interruption, and only
25870
+ * the render side knows the segments, so the translation lives there
25871
+ * (`export-dense-map.ts`, addon-pipeline).
25872
+ *
25873
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25874
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25875
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25876
+ * the video was a uniform timelapse, and the log line reported the five ranges
25877
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25878
+ *
25879
+ * Relative and not absolute epoch, because an absolute epoch would make every
25880
+ * call site responsible for the same subtraction.
25870
25881
  */
25871
25882
  var ExportDenseRangeSchema = object({
25872
25883
  fromSec: number().nonnegative(),
@@ -33152,10 +33163,11 @@ function slideInsideFrame(rect, frameWidth, frameHeight) {
33152
33163
  h
33153
33164
  };
33154
33165
  }
33155
- var NATIVE_LEASE_TTL_KEY = "nativeLeaseTtlMs";
33166
+ var NATIVE_LEASE_HOLD_KEY = "nativeLeaseHoldFrames";
33156
33167
  var NATIVE_LEASE_BUDGET_KEY = "nativeLeaseBudgetMb";
33157
33168
  var NATIVE_LEASE_ACTIVITY_KEY = "nativeLeaseActivityMs";
33158
33169
  var NATIVE_LEASE_ADMISSION_KEY = "nativeLeaseAdmission";
33170
+ var NATIVE_LEASE_TILE_BUDGET_KEY = "nativeTileBudgetMb";
33159
33171
  /**
33160
33172
  * WHICH delivered frames the decode worker retains a native copy of.
33161
33173
  *
@@ -33182,25 +33194,32 @@ var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33182
33194
  */
33183
33195
  var NativeLeaseSettingsSchema = object({
33184
33196
  /**
33185
- * How long a retained native frame is served before it counts as a miss.
33197
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33198
+ * detection result.
33186
33199
  *
33187
- * Must cover the FULL late-crop horizon: detection inference + the
33188
- * cross-process inference-result hop to hub post-analysis + tracking + the
33189
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33190
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33191
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33200
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33201
+ * a time window was never related to the event the pixels were waiting for.
33202
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33203
+ * at which moment the runner cuts the subject tiles it actually wanted and
33204
+ * releases the frame. The bound exists only so a runner that stops answering
33205
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33206
+ *
33207
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33208
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33209
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33210
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
33211
+ * `holdOverflow` on the metrics line is what says you need it.
33192
33212
  */
33193
- ttlMs: number().int().min(250).max(1e4),
33213
+ holdFrames: number().int().min(1).max(64),
33194
33214
  /**
33195
33215
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33196
33216
  *
33197
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33198
- * which one is actually binding before reasoning from that. At the shipped
33199
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33200
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33201
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33202
- * change that admits fewer frames buys retention WINDOW at constant RAM
33203
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33217
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33218
+ * is what decides how much is held, and the ceiling is the number above which
33219
+ * something is wrong. Before that it was the effective cap at 1024 MB with
33220
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33221
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33222
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33204
33223
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33205
33224
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33206
33225
  * to replace).
@@ -33226,22 +33245,45 @@ var NativeLeaseSettingsSchema = object({
33226
33245
  * there is the signal that some caller names frames outside the inference set
33227
33246
  * and that this must go back to `all`.
33228
33247
  */
33229
- admission: NativeLeaseAdmissionSchema
33248
+ admission: NativeLeaseAdmissionSchema,
33249
+ /**
33250
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
33251
+ * compressed native crops the worker cuts at the moment a frame's detection
33252
+ * result arrives, and keeps long after the frame itself is freed.
33253
+ *
33254
+ * This is the knob that replaced the old retention window, and it buys about
33255
+ * three orders of magnitude more of it: a tile is one subject at native
33256
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
33257
+ * the frame it was cut from. A frame on which nothing was detected costs
33258
+ * nothing at all, which is the real change — the old lease paid per FRAME and
33259
+ * was interrogated per SUBJECT.
33260
+ *
33261
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
33262
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
33263
+ * reproduce that.
33264
+ */
33265
+ tileBudgetMb: number().int().min(0).max(1024)
33230
33266
  });
33231
33267
  /**
33232
- * The values in force when the operator has set nothing — byte-for-byte the
33233
- * constants the decode worker shipped with as env-var defaults, so making these
33234
- * settings changed no behaviour on the day it landed.
33268
+ * The values in force when the operator has set nothing.
33269
+ *
33270
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
33271
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
33272
+ * in the same change that redefines it would make a regression and a retune
33273
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
33274
+ * live traffic.
33235
33275
  */
33236
33276
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33237
- ttlMs: 1200,
33277
+ holdFrames: 8,
33238
33278
  budgetMb: 1024,
33239
33279
  activityMs: 15e3,
33280
+ tileBudgetMb: 64,
33240
33281
  admission: "inferred"
33241
33282
  };
33242
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
33283
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33243
33284
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33244
33285
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33286
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33245
33287
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33246
33288
  /**
33247
33289
  * Parse one knob, reporting `null` for absent, junk, out-of-bounds — AND for a
@@ -33251,7 +33293,7 @@ DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33251
33293
  * precedence being true and being a lie. `addon-settings.getGlobalSettings`
33252
33294
  * returns a HYDRATED payload, and `hydrateField` fills an unstored field with
33253
33295
  * the schema's own `default` (verified live on the hub: a cluster that has never
33254
- * opened the form still reports `nativeLeaseTtlMs = 1200`). A reader that took
33296
+ * opened the form still reports `nativeLeaseHoldFrames = 8`). A reader that took
33255
33297
  * that at face value would report all three knobs as "set" on every cluster on
33256
33298
  * the day this shipped, permanently retiring the `CAMSTACK_SESSION_NATIVE_LEASE_*`
33257
33299
  * emergency override that the precedence promises. There is no raw-store read on
@@ -33285,25 +33327,28 @@ function readAdmissionKnob(raw) {
33285
33327
  * {@link readKnob} for why the default counts as unset.
33286
33328
  */
33287
33329
  function readNativeLeaseOverride(config) {
33288
- const ttlMs = readKnob("ttlMs", config[NATIVE_LEASE_TTL_KEY]);
33330
+ const holdFrames = readKnob("holdFrames", config[NATIVE_LEASE_HOLD_KEY]);
33289
33331
  const budgetMb = readKnob("budgetMb", config[NATIVE_LEASE_BUDGET_KEY]);
33290
33332
  const activityMs = readKnob("activityMs", config[NATIVE_LEASE_ACTIVITY_KEY]);
33291
33333
  const admission = readAdmissionKnob(config[NATIVE_LEASE_ADMISSION_KEY]);
33334
+ const tileBudgetMb = readKnob("tileBudgetMb", config[NATIVE_LEASE_TILE_BUDGET_KEY]);
33292
33335
  return {
33293
- ...ttlMs === null ? {} : { ttlMs },
33336
+ ...holdFrames === null ? {} : { holdFrames },
33294
33337
  ...budgetMb === null ? {} : { budgetMb },
33295
33338
  ...activityMs === null ? {} : { activityMs },
33296
- ...admission === null ? {} : { admission }
33339
+ ...admission === null ? {} : { admission },
33340
+ ...tileBudgetMb === null ? {} : { tileBudgetMb }
33297
33341
  };
33298
33342
  }
33299
33343
  function isHydratedField(entry) {
33300
33344
  return typeof entry === "object" && entry !== null && "key" in entry;
33301
33345
  }
33302
33346
  var LEASE_KEYS = [
33303
- NATIVE_LEASE_TTL_KEY,
33347
+ NATIVE_LEASE_HOLD_KEY,
33304
33348
  NATIVE_LEASE_BUDGET_KEY,
33305
33349
  NATIVE_LEASE_ACTIVITY_KEY,
33306
- NATIVE_LEASE_ADMISSION_KEY
33350
+ NATIVE_LEASE_ADMISSION_KEY,
33351
+ NATIVE_LEASE_TILE_BUDGET_KEY
33307
33352
  ];
33308
33353
  /**
33309
33354
  * Extract the operator's lease overrides from an
@@ -25860,13 +25860,24 @@ var recordingCapability = {
25860
25860
  /** Playback-speed multiplier for the render (1 = realtime). */
25861
25861
  var ExportSpeedSchema = number().min(.25).max(32);
25862
25862
  /**
25863
- * One dense interval, in SECONDS FROM THE EXPORT'S OWN `fromMs`.
25863
+ * One dense interval, in WALL-CLOCK SECONDS FROM THE EXPORT'S OWN `fromMs`.
25864
25864
  *
25865
- * Relative and not absolute epoch on purpose: the renderer's frame-select
25866
- * expression sees ffmpeg's `t`, which starts at 0 for the export's source
25867
- * playlist. Handing it absolute epochs would make every call site responsible
25868
- * for the same subtraction, and the one that forgot would emit a filter that
25869
- * selects nothing silently, as a uniform timelapse.
25865
+ * **Wall clock, not ffmpeg's `t`** and the recorder translates. A caller
25866
+ * derives these bounds from things that happened at a TIME (a track's
25867
+ * `firstSeen`), while `t` runs over the source playlist: the concatenation of
25868
+ * every segment present for the range, with each recording GAP removed. The
25869
+ * two agree only on a window that recorded without one interruption, and only
25870
+ * the render side knows the segments, so the translation lives there
25871
+ * (`export-dense-map.ts`, addon-pipeline).
25872
+ *
25873
+ * It was not always so. These seconds were fed to `between(t,…)` verbatim, and
25874
+ * on a 10 h window holding 29,393 s of footage every range landed late by the
25875
+ * gap accumulated before it — up to 6,607 s, well past EOF. Nothing matched,
25876
+ * the video was a uniform timelapse, and the log line reported the five ranges
25877
+ * that had been ASKED for (2026-08-13, export `57d14363`, camera 615).
25878
+ *
25879
+ * Relative and not absolute epoch, because an absolute epoch would make every
25880
+ * call site responsible for the same subtraction.
25870
25881
  */
25871
25882
  var ExportDenseRangeSchema = object({
25872
25883
  fromSec: number().nonnegative(),
@@ -33152,10 +33163,11 @@ function slideInsideFrame(rect, frameWidth, frameHeight) {
33152
33163
  h
33153
33164
  };
33154
33165
  }
33155
- var NATIVE_LEASE_TTL_KEY = "nativeLeaseTtlMs";
33166
+ var NATIVE_LEASE_HOLD_KEY = "nativeLeaseHoldFrames";
33156
33167
  var NATIVE_LEASE_BUDGET_KEY = "nativeLeaseBudgetMb";
33157
33168
  var NATIVE_LEASE_ACTIVITY_KEY = "nativeLeaseActivityMs";
33158
33169
  var NATIVE_LEASE_ADMISSION_KEY = "nativeLeaseAdmission";
33170
+ var NATIVE_LEASE_TILE_BUDGET_KEY = "nativeTileBudgetMb";
33159
33171
  /**
33160
33172
  * WHICH delivered frames the decode worker retains a native copy of.
33161
33173
  *
@@ -33182,25 +33194,32 @@ var NativeLeaseAdmissionSchema = _enum(["all", "inferred"]);
33182
33194
  */
33183
33195
  var NativeLeaseSettingsSchema = object({
33184
33196
  /**
33185
- * How long a retained native frame is served before it counts as a miss.
33197
+ * How many delivered frames the worker HOLDS at once, waiting for each one's
33198
+ * detection result.
33186
33199
  *
33187
- * Must cover the FULL late-crop horizon: detection inference + the
33188
- * cross-process inference-result hop to hub post-analysis + tracking + the
33189
- * tRPC crop round-trip back. Below ~500 ms the busiest cameras' subject crops
33190
- * outrun it and fall back to the ≤640 detection frame; above ~3 s the resident
33191
- * RAM per busy camera grows linearly with no measured hit-rate gain.
33200
+ * This replaced a TTL on 2026-08-13, and the replacement is the whole point:
33201
+ * a time window was never related to the event the pixels were waiting for.
33202
+ * A held frame now lives from delivery until the runner has its `FrameResult`
33203
+ * at which moment the runner cuts the subject tiles it actually wanted and
33204
+ * releases the frame. The bound exists only so a runner that stops answering
33205
+ * cannot pin RAM: above it the OLDEST held frame is dropped and counted.
33206
+ *
33207
+ * Sizing: the steady state is `inferenceLatency × deliveredFps`, measured at
33208
+ * 40-160 ms × ≤25 fps = 1-4 frames. The default leaves headroom for a hiccup
33209
+ * without ever approaching the old resident set (43 frames × 24.9 MB at 4K).
33210
+ * Raising it does not buy hit rate — it buys tolerance for a slow runner, and
33211
+ * `holdOverflow` on the metrics line is what says you need it.
33192
33212
  */
33193
- ttlMs: number().int().min(250).max(1e4),
33213
+ holdFrames: number().int().min(1).max(64),
33194
33214
  /**
33195
33215
  * Hard per-decode-worker RAM ceiling for retained native frames, in MB.
33196
33216
  *
33197
- * Intended as a SAFETY ceiling with the TTL as the effective cap — but check
33198
- * which one is actually binding before reasoning from that. At the shipped
33199
- * 1024 MB and a 2 800 ms TTL, a 4K camera hits the CEILING first (~43 frames
33200
- * at ~24 MB each) and the TTL never gets to expire anything; `leaseMb` /
33201
- * `leaseFrames` on the metrics line say which. When the ceiling binds, a
33202
- * change that admits fewer frames buys retention WINDOW at constant RAM
33203
- * rather than giving RAM back — lower this knob if RAM is what you wanted.
33217
+ * Since 2026-08-13 this is a SAFETY ceiling and nothing else: `holdFrames`
33218
+ * is what decides how much is held, and the ceiling is the number above which
33219
+ * something is wrong. Before that it was the effective cap at 1024 MB with
33220
+ * a 2 800 ms TTL a 4K camera sat pinned at `leaseMb:1020, leaseFrames:43`
33221
+ * with the TTL expiring nothing, which is exactly the confusion the hold
33222
+ * removes. `leaseMb` / `leaseFrames` still say what is resident.
33204
33223
  * `0` DISABLES the lease entirely and falls the worker back to the tiny
33205
33224
  * leak-prone GPU surface ring (~85% crop miss; that is what the lease exists
33206
33225
  * to replace).
@@ -33226,22 +33245,45 @@ var NativeLeaseSettingsSchema = object({
33226
33245
  * there is the signal that some caller names frames outside the inference set
33227
33246
  * and that this must go back to `all`.
33228
33247
  */
33229
- admission: NativeLeaseAdmissionSchema
33248
+ admission: NativeLeaseAdmissionSchema,
33249
+ /**
33250
+ * RAM ceiling per decode worker, in MB, for the SUBJECT TILES — the
33251
+ * compressed native crops the worker cuts at the moment a frame's detection
33252
+ * result arrives, and keeps long after the frame itself is freed.
33253
+ *
33254
+ * This is the knob that replaced the old retention window, and it buys about
33255
+ * three orders of magnitude more of it: a tile is one subject at native
33256
+ * resolution, JPEG-encoded (~60-120 KB on a 4K person), against ~24.9 MB for
33257
+ * the frame it was cut from. A frame on which nothing was detected costs
33258
+ * nothing at all, which is the real change — the old lease paid per FRAME and
33259
+ * was interrogated per SUBJECT.
33260
+ *
33261
+ * `0` DISABLES tiles, leaving only the hold window and the ≤640 RAM
33262
+ * fallback — i.e. the pre-2026-08-13 miss profile. Set it there only to
33263
+ * reproduce that.
33264
+ */
33265
+ tileBudgetMb: number().int().min(0).max(1024)
33230
33266
  });
33231
33267
  /**
33232
- * The values in force when the operator has set nothing — byte-for-byte the
33233
- * constants the decode worker shipped with as env-var defaults, so making these
33234
- * settings changed no behaviour on the day it landed.
33268
+ * The values in force when the operator has set nothing.
33269
+ *
33270
+ * `budgetMb` stays at 1024 on the day the hold landed, deliberately: it stopped
33271
+ * being the retention window and became the OOM ceiling, and lowering a ceiling
33272
+ * in the same change that redefines it would make a regression and a retune
33273
+ * indistinguishable. Cut it once `tileHits` / `holdOverflow` have been read on
33274
+ * live traffic.
33235
33275
  */
33236
33276
  var DEFAULT_NATIVE_LEASE_SETTINGS = {
33237
- ttlMs: 1200,
33277
+ holdFrames: 8,
33238
33278
  budgetMb: 1024,
33239
33279
  activityMs: 15e3,
33280
+ tileBudgetMb: 64,
33240
33281
  admission: "inferred"
33241
33282
  };
33242
- DEFAULT_NATIVE_LEASE_SETTINGS.ttlMs;
33283
+ DEFAULT_NATIVE_LEASE_SETTINGS.holdFrames;
33243
33284
  DEFAULT_NATIVE_LEASE_SETTINGS.budgetMb;
33244
33285
  DEFAULT_NATIVE_LEASE_SETTINGS.activityMs;
33286
+ DEFAULT_NATIVE_LEASE_SETTINGS.tileBudgetMb;
33245
33287
  DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33246
33288
  /**
33247
33289
  * Parse one knob, reporting `null` for absent, junk, out-of-bounds — AND for a
@@ -33251,7 +33293,7 @@ DEFAULT_NATIVE_LEASE_SETTINGS.admission;
33251
33293
  * precedence being true and being a lie. `addon-settings.getGlobalSettings`
33252
33294
  * returns a HYDRATED payload, and `hydrateField` fills an unstored field with
33253
33295
  * the schema's own `default` (verified live on the hub: a cluster that has never
33254
- * opened the form still reports `nativeLeaseTtlMs = 1200`). A reader that took
33296
+ * opened the form still reports `nativeLeaseHoldFrames = 8`). A reader that took
33255
33297
  * that at face value would report all three knobs as "set" on every cluster on
33256
33298
  * the day this shipped, permanently retiring the `CAMSTACK_SESSION_NATIVE_LEASE_*`
33257
33299
  * emergency override that the precedence promises. There is no raw-store read on
@@ -33285,25 +33327,28 @@ function readAdmissionKnob(raw) {
33285
33327
  * {@link readKnob} for why the default counts as unset.
33286
33328
  */
33287
33329
  function readNativeLeaseOverride(config) {
33288
- const ttlMs = readKnob("ttlMs", config[NATIVE_LEASE_TTL_KEY]);
33330
+ const holdFrames = readKnob("holdFrames", config[NATIVE_LEASE_HOLD_KEY]);
33289
33331
  const budgetMb = readKnob("budgetMb", config[NATIVE_LEASE_BUDGET_KEY]);
33290
33332
  const activityMs = readKnob("activityMs", config[NATIVE_LEASE_ACTIVITY_KEY]);
33291
33333
  const admission = readAdmissionKnob(config[NATIVE_LEASE_ADMISSION_KEY]);
33334
+ const tileBudgetMb = readKnob("tileBudgetMb", config[NATIVE_LEASE_TILE_BUDGET_KEY]);
33292
33335
  return {
33293
- ...ttlMs === null ? {} : { ttlMs },
33336
+ ...holdFrames === null ? {} : { holdFrames },
33294
33337
  ...budgetMb === null ? {} : { budgetMb },
33295
33338
  ...activityMs === null ? {} : { activityMs },
33296
- ...admission === null ? {} : { admission }
33339
+ ...admission === null ? {} : { admission },
33340
+ ...tileBudgetMb === null ? {} : { tileBudgetMb }
33297
33341
  };
33298
33342
  }
33299
33343
  function isHydratedField(entry) {
33300
33344
  return typeof entry === "object" && entry !== null && "key" in entry;
33301
33345
  }
33302
33346
  var LEASE_KEYS = [
33303
- NATIVE_LEASE_TTL_KEY,
33347
+ NATIVE_LEASE_HOLD_KEY,
33304
33348
  NATIVE_LEASE_BUDGET_KEY,
33305
33349
  NATIVE_LEASE_ACTIVITY_KEY,
33306
- NATIVE_LEASE_ADMISSION_KEY
33350
+ NATIVE_LEASE_ADMISSION_KEY,
33351
+ NATIVE_LEASE_TILE_BUDGET_KEY
33307
33352
  ];
33308
33353
  /**
33309
33354
  * Extract the operator's lease overrides from an
@@ -1,4 +1,4 @@
1
- const require_dist = require("./dist-cR-pvD_z.js");
1
+ const require_dist = require("./dist-CtOVWTCi.js");
2
2
  let node_perf_hooks = require("node:perf_hooks");
3
3
  //#region src/detection-pipeline/registry/model-catalogs.ts
4
4
  var HF_REPO = "camstack/camstack-models";
@@ -1,4 +1,4 @@
1
- import { a as COCO_TO_MACRO, i as COCO_80_LABELS, r as AUDIO_MACRO_LABELS, z as hfModelUrl } from "./dist-BPaa4_z6.mjs";
1
+ import { a as COCO_TO_MACRO, i as COCO_80_LABELS, r as AUDIO_MACRO_LABELS, z as hfModelUrl } from "./dist-D1Xk5Tji.mjs";
2
2
  import { PerformanceObserver } from "node:perf_hooks";
3
3
  //#region src/detection-pipeline/registry/model-catalogs.ts
4
4
  var HF_REPO = "camstack/camstack-models";
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_dist = require("../dist-cR-pvD_z.js");
5
+ const require_dist = require("../dist-CtOVWTCi.js");
6
6
  const require_lazy_sharp = require("../lazy-sharp-CcYuXtsa.js");
7
7
  let node_fs = require("node:fs");
8
8
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { H as motionDetectionCapability, R as evaluateZoneRules, ft as hydrateSchema, st as BaseAddon, ut as DeviceType } from "../dist-BPaa4_z6.mjs";
1
+ import { H as motionDetectionCapability, R as evaluateZoneRules, ft as hydrateSchema, st as BaseAddon, ut as DeviceType } from "../dist-D1Xk5Tji.mjs";
2
2
  import { t as getSharp } from "../lazy-sharp-B-mb8uWx.mjs";
3
3
  import { readFileSync } from "node:fs";
4
4
  import { join } from "node:path";
@@ -3,9 +3,9 @@ Object.defineProperties(exports, {
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
5
  const require_chunk = require("../chunk-emK7D4bc.js");
6
- const require_dist = require("../dist-cR-pvD_z.js");
7
- const require_event_loop_stall_monitor = require("../event-loop-stall-monitor-STRdnQWm.js");
8
- const require_worker_protocol = require("../worker-protocol-C7V1qIIA.js");
6
+ const require_dist = require("../dist-CtOVWTCi.js");
7
+ const require_event_loop_stall_monitor = require("../event-loop-stall-monitor-BJs7Yws7.js");
8
+ const require_worker_protocol = require("../worker-protocol-DEV7g32b.js");
9
9
  const require_hub_hostname = require("../hub-hostname-DAJXlOgV.js");
10
10
  const require_lazy_sharp = require("../lazy-sharp-CcYuXtsa.js");
11
11
  const require_remote_restream = require("../remote-restream-BYbAsgUf.js");
@@ -17,28 +17,6 @@ let node_perf_hooks = require("node:perf_hooks");
17
17
  let node_os = require("node:os");
18
18
  node_os = require_chunk.__toESM(node_os);
19
19
  //#region src/session-decode/fork-decode-worker.ts
20
- /**
21
- * Real `fork` implementation for the session-decode coordinator — Epic C P1,
22
- * Task 4.
23
- *
24
- * Spawns the decode-worker child (`decode-worker-child.ts`, Task 2) as a
25
- * dedicated `child_process.fork` and adapts the returned `ChildProcess` to the
26
- * coordinator's minimal {@link ForkedChildLike} contract WITHOUT any cast —
27
- * an explicit forwarding wrapper, so a wider Node `ChildProcess` signature
28
- * never has to structurally satisfy the narrower interface.
29
- *
30
- * `serialization: 'advanced'` is MANDATORY: Node's default 'json' IPC
31
- * base64-serialises the `buffer` reply's `Uint8Array`, breaking the "raw
32
- * bytes, not base64" contract the coordinator + `worker-protocol.ts`'s
33
- * `value.bytes instanceof Uint8Array` guard both depend on. Advanced (V8
34
- * structured-clone) preserves the typed array on the wire.
35
- *
36
- * The child entry is resolved relative to THIS module's built location. Both
37
- * this module and `pipeline-runner/index.ts` bundle into the SAME entry
38
- * (`dist/pipeline-runner/index.js`, `manualChunks: () => null`), so
39
- * `import.meta.url` here is that file's URL and the sibling child lands at
40
- * `dist/session-decode/decode-worker-child.js` (its own vite build entry).
41
- */
42
20
  /** Absolute path to the built decode-worker child entry (a vite build entry). */
43
21
  var CHILD_ENTRY_PATH = (0, node_url.fileURLToPath)(new URL("../session-decode/decode-worker-child.js", require("url").pathToFileURL(__filename).href));
44
22
  /**
@@ -696,8 +674,24 @@ var SessionDecodeSession = class {
696
674
  });
697
675
  }
698
676
  /**
699
- * Prompt-release the worker's RAM native-frame lease for `frameId`. Fire and
700
- * forget (no reply): a lease also self-expires on its TTL, so a dropped
677
+ * The runner has this frame's detections: cut one native subject tile per box
678
+ * and END the hold on `frameId`. Fire and forget (no reply) so the encode can
679
+ * never delay the runner; a dropped message costs only the tiles.
680
+ *
681
+ * An EMPTY box list is still sent — it is how a frame that detected nothing
682
+ * releases its hold, and that is the common case.
683
+ */
684
+ cutTiles(frameId, bboxes) {
685
+ if (this.exited) return;
686
+ this.trySend({
687
+ kind: "cutTiles",
688
+ frameId,
689
+ bboxes
690
+ });
691
+ }
692
+ /**
693
+ * Prompt-release the worker's RAM native-frame hold for `frameId`. Fire and
694
+ * forget (no reply): the hold is also bounded by a frame count, so a dropped
701
695
  * release only defers reclaim. No-op once the worker has exited.
702
696
  */
703
697
  releaseLease(frameId) {
@@ -977,6 +971,7 @@ function buildFrameImage(session, reply) {
977
971
  return session.requestBuffer(reply.frameId, opts);
978
972
  },
979
973
  nativeCrop: (bbox, maxWidth) => session.requestNativeCrop(reply.frameId, bbox, maxWidth),
974
+ cutTiles: (bboxes) => session.cutTiles(reply.frameId, bboxes),
980
975
  releaseNativeLease: () => session.releaseLease(reply.frameId),
981
976
  markInferred: () => session.markInferred(reply.frameId),
982
977
  close: () => {
@@ -1117,6 +1112,7 @@ function startSessionDecodePump(deps) {
1117
1112
  const image = frame.image;
1118
1113
  const cropFn = image.nativeCrop;
1119
1114
  const nativeCrop = cropFn ? Object.assign((bbox, maxWidth) => cropFn(bbox, maxWidth), {
1115
+ cutTiles: (bboxes) => image.cutTiles?.(bboxes),
1120
1116
  release: () => image.releaseNativeLease?.(),
1121
1117
  markInferred: () => image.markInferred?.()
1122
1118
  }) : void 0;
@@ -2525,7 +2521,7 @@ var NATIVE_LEASE_OWNER_ADDON_ID = "pipeline-orchestrator";
2525
2521
  * old value.
2526
2522
  */
2527
2523
  function sameOverride(a, b) {
2528
- return a.ttlMs === b.ttlMs && a.budgetMb === b.budgetMb && a.activityMs === b.activityMs && a.admission === b.admission;
2524
+ return a.holdFrames === b.holdFrames && a.budgetMb === b.budgetMb && a.activityMs === b.activityMs && a.admission === b.admission && a.tileBudgetMb === b.tileBudgetMb;
2529
2525
  }
2530
2526
  /**
2531
2527
  * TTL-cached read of the cluster native-lease knobs.
@@ -3802,6 +3798,42 @@ async function runStatelessStep(deps, input) {
3802
3798
  details
3803
3799
  };
3804
3800
  }
3801
+ /**
3802
+ * Normalised boxes for the subjects worth a tile, highest confidence first,
3803
+ * capped.
3804
+ *
3805
+ * Returns an empty array for a frame with no usable detections — and the caller
3806
+ * still sends it: an empty `cutTiles` is how a frame that detected nothing ends
3807
+ * its hold, which is the majority of frames and the whole reason this design
3808
+ * costs less than the one it replaces.
3809
+ *
3810
+ * A degenerate or non-finite box is DROPPED rather than clamped: a zero-area
3811
+ * container serves nothing, and a NaN one would poison the worker's geometry.
3812
+ */
3813
+ function planTileCuts(detections, frame, maxSubjects = 4) {
3814
+ if (frame.width <= 0 || frame.height <= 0) return [];
3815
+ const ordered = [...detections.filter((d) => isUsable(d.bbox))].sort((a, b) => b.score - a.score);
3816
+ const out = [];
3817
+ for (const detection of ordered.slice(0, Math.max(0, maxSubjects))) {
3818
+ const { x, y, width, height } = detection.bbox;
3819
+ out.push({
3820
+ x: x / frame.width,
3821
+ y: y / frame.height,
3822
+ w: width / frame.width,
3823
+ h: height / frame.height
3824
+ });
3825
+ }
3826
+ return out;
3827
+ }
3828
+ function isUsable(bbox) {
3829
+ if (![
3830
+ bbox.x,
3831
+ bbox.y,
3832
+ bbox.width,
3833
+ bbox.height
3834
+ ].every((v) => Number.isFinite(v))) return false;
3835
+ return bbox.width > 0 && bbox.height > 0;
3836
+ }
3805
3837
  //#endregion
3806
3838
  //#region src/pipeline-runner/index.ts
3807
3839
  var DEFAULT_CONFIG = {
@@ -4290,6 +4322,7 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
4290
4322
  this.handleDetectionStreamChange(deviceId, action);
4291
4323
  });
4292
4324
  this.runner.onResult(async (deviceId, frame, result, _streamType, handle) => {
4325
+ this.cutSubjectTiles(deviceId, result, handle);
4293
4326
  this.emitInferenceResult(deviceId, frame, result, handle);
4294
4327
  const detectionCount = result.detections?.length ?? 0;
4295
4328
  this.runner?.noteDetectionResult(deviceId, detectionCount);
@@ -5111,6 +5144,40 @@ var PipelineRunnerAddon = class PipelineRunnerAddon extends require_dist.BaseAdd
5111
5144
  }, resolved.tier, input.encodeJpeg);
5112
5145
  }
5113
5146
  /**
5147
+ * Turn a finished frame into subject TILES and end its hold — the runner half
5148
+ * of R2 (`docs/design/2026-08-13-native-lease-two-tier-redesign.md`).
5149
+ *
5150
+ * Called from the result callback, which is the last instant at which the
5151
+ * frame's native pixels exist and its detections are known at the same time.
5152
+ * Every path through here ends the hold, including the one where there is
5153
+ * nothing to cut: a frame that detected nothing is the majority of frames and
5154
+ * releasing it promptly is most of the RAM this redesign gives back.
5155
+ *
5156
+ * Deliberately synchronous and unawaited. The worker replies to nothing, so
5157
+ * there is nothing to wait for, and a detection result must never be delayed
5158
+ * by an encode.
5159
+ */
5160
+ cutSubjectTiles(deviceId, result, handle) {
5161
+ if (!handle) return;
5162
+ const found = this.nativeCropRegistry.get(handle);
5163
+ if (!found) return;
5164
+ const boxes = planTileCuts(result.detections ?? [], {
5165
+ width: result.width,
5166
+ height: result.height
5167
+ });
5168
+ try {
5169
+ found.request.cutTiles(boxes);
5170
+ } catch (err) {
5171
+ this.ctx.logger.debug("subject tile cut could not be dispatched", {
5172
+ tags: { deviceId },
5173
+ meta: {
5174
+ subjects: boxes.length,
5175
+ error: err instanceof Error ? err.message : String(err)
5176
+ }
5177
+ });
5178
+ }
5179
+ }
5180
+ /**
5114
5181
  * The native-lease half of {@link getNativeCrop}, extracted so the DETAIL path
5115
5182
  * can keep the miss REASON the cap's `null` return has no room for. Both
5116
5183
  * callers share this one decision — a second copy of the tier arithmetic is