@camstack/addon-pipeline 1.2.327 → 1.2.329

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 (44) hide show
  1. package/THIRD_PARTY_MODELS.md +35 -27
  2. package/dist/audio-analyzer/index.js +2 -2
  3. package/dist/audio-analyzer/index.mjs +2 -2
  4. package/dist/{default-detection-model-CBIYdAJ5.js → default-detection-model-ChH7Y219.js} +130 -61
  5. package/dist/{default-detection-model-hql6BX9-.mjs → default-detection-model-j0nBpRoB.mjs} +130 -61
  6. package/dist/detection-pipeline/index.js +458 -16
  7. package/dist/detection-pipeline/index.mjs +458 -16
  8. package/dist/{dist-B9LnBPz9.mjs → dist-0HoA3wAi.mjs} +503 -370
  9. package/dist/{dist-BBZwYfSN.js → dist-BlIWhjnu.js} +550 -369
  10. package/dist/motion-wasm/index.js +1 -1
  11. package/dist/motion-wasm/index.mjs +1 -1
  12. package/dist/{node-mJQBUiEc.js → node-BPpVMnZy.js} +1 -1
  13. package/dist/{node-Ci0E-0VP.mjs → node-HOMWRPzW.mjs} +1 -1
  14. package/dist/pipeline-runner/index.js +215 -78
  15. package/dist/pipeline-runner/index.mjs +215 -78
  16. package/dist/{process-memory-DgEfKdtC.js → process-memory-BW06vOIQ.js} +1 -1
  17. package/dist/{process-memory-B63Jlpev.mjs → process-memory-DuF8pa2w.mjs} +1 -1
  18. package/dist/recorder/index.js +2 -2
  19. package/dist/recorder/index.mjs +2 -2
  20. package/dist/{segment-demux-js-DzwHW4Ey.mjs → segment-demux-js-BU2MXpln.mjs} +1 -1
  21. package/dist/{segment-demux-js-C2ufKMu0.js → segment-demux-js-Dl52Zz8w.js} +1 -1
  22. package/dist/session-decode/decode-worker-main.js +13 -21
  23. package/dist/session-decode/decode-worker-main.mjs +13 -21
  24. package/dist/stream-broker/_stub.js +1 -1
  25. package/dist/stream-broker/{_virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-B4fPzS-8.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_stream_broker_widgets-vNfS65In.mjs} +3 -3
  26. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DfeHvW4k.mjs +26 -0
  27. package/dist/stream-broker/demux-worker-child.js +1 -1
  28. package/dist/stream-broker/demux-worker-child.mjs +1 -1
  29. package/dist/stream-broker/{hostInit-Cg4IdtE5.mjs → hostInit-Ciacp783.mjs} +3 -3
  30. package/dist/stream-broker/index.js +4 -3
  31. package/dist/stream-broker/index.mjs +4 -3
  32. package/dist/stream-broker/remoteEntry.js +1 -1
  33. package/package.json +1 -1
  34. package/python/edgetpu_dequant.py +38 -1
  35. package/python/inference_pool.py +69 -138
  36. package/python/postprocessors/test_bird_edgetpu.py +124 -0
  37. package/python/postprocessors/test_yolox_plate_edgetpu.py +126 -0
  38. package/python/postprocessors/test_yunet_edgetpu.py +149 -0
  39. package/python/postprocessors/testdata/bird_classifier_int8_outputs.json +1 -0
  40. package/python/postprocessors/testdata/yolox_plate_int8_outputs.json +1 -0
  41. package/python/postprocessors/testdata/yunet_int8_outputs.json +1 -0
  42. package/python/postprocessors/yolo.py +44 -0
  43. package/python/test_inference_pool_static_batch.py +2 -4
  44. package/dist/stream-broker/_virtual_mf___mfe_internal__addon_stream_broker_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-BDGzcgLP.mjs +0 -26
@@ -3,11 +3,11 @@ 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-BBZwYfSN.js");
7
- const require_node = require("../node-mJQBUiEc.js");
8
- const require_default_detection_model = require("../default-detection-model-CBIYdAJ5.js");
6
+ const require_dist = require("../dist-BlIWhjnu.js");
7
+ const require_node = require("../node-BPpVMnZy.js");
8
+ const require_default_detection_model = require("../default-detection-model-ChH7Y219.js");
9
9
  const require_lazy_sharp = require("../lazy-sharp-BuwKlQLR.js");
10
- const require_process_memory = require("../process-memory-DgEfKdtC.js");
10
+ const require_process_memory = require("../process-memory-BW06vOIQ.js");
11
11
  let node_os = require("node:os");
12
12
  node_os = require_chunk.__toESM(node_os);
13
13
  let node_fs = require("node:fs");
@@ -2816,6 +2816,8 @@ var PipelineModelManager = class {
2816
2816
  stepId,
2817
2817
  modelId,
2818
2818
  poolIndex: index,
2819
+ path: config.path,
2820
+ ...settings !== void 0 ? { settings } : {},
2819
2821
  lruTick: ++this.lruClock,
2820
2822
  decode
2821
2823
  };
@@ -2823,6 +2825,56 @@ var PipelineModelManager = class {
2823
2825
  return entry;
2824
2826
  }
2825
2827
  /**
2828
+ * Reload every resident slot whose model FILE is no longer the one
2829
+ * `buildConfig` names — a Coral pool that switched co-compiled set (D724).
2830
+ * The new slot is loaded BEFORE the old one is unloaded and the entry is
2831
+ * replaced in between, so a lookup always finds a loaded index. Returns the
2832
+ * `(step, model)` pairs reloaded. A failed reload keeps the old slot (it
2833
+ * still serves, from the file it was loaded from) and is logged.
2834
+ */
2835
+ async reloadChangedPaths() {
2836
+ const reloaded = [];
2837
+ for (const [stepId, perStep] of this.loaded) for (const entry of perStep.values()) {
2838
+ const config = this.source.buildConfig(stepId, entry.modelId, entry.settings);
2839
+ if (config.path === entry.path) continue;
2840
+ const index = this.pool.allocateIndex();
2841
+ try {
2842
+ await this.pool.loadModel(index, config);
2843
+ } catch (err) {
2844
+ this.pool.releaseIndex(index);
2845
+ this.log.error("Step variant reload from another model file failed — the old file keeps serving", { meta: {
2846
+ step: stepId,
2847
+ modelId: entry.modelId,
2848
+ deviceKey: this.deviceKey,
2849
+ from: entry.path,
2850
+ to: config.path,
2851
+ error: err instanceof Error ? err.message : String(err)
2852
+ } });
2853
+ continue;
2854
+ }
2855
+ perStep.set(entry.modelId, {
2856
+ ...entry,
2857
+ poolIndex: index,
2858
+ path: config.path,
2859
+ decode: poolDecodeSettingsOf(config)
2860
+ });
2861
+ await this.pool.unloadModel(entry.poolIndex);
2862
+ this.log.info("Step variant reloaded from another model file", { meta: {
2863
+ step: stepId,
2864
+ modelId: entry.modelId,
2865
+ deviceKey: this.deviceKey,
2866
+ from: entry.path,
2867
+ to: config.path,
2868
+ poolIndex: index
2869
+ } });
2870
+ reloaded.push({
2871
+ stepId,
2872
+ modelId: entry.modelId
2873
+ });
2874
+ }
2875
+ return reloaded;
2876
+ }
2877
+ /**
2826
2878
  * Push a retuned decode setting into ONE already-loaded slot.
2827
2879
  *
2828
2880
  * Scope is the point: `reconfigure` names a single pool index, so a slider
@@ -2981,6 +3033,251 @@ function deviceKeyOf(engine) {
2981
3033
  return engine.device ? `${engine.backend}:${engine.device}` : engine.backend;
2982
3034
  }
2983
3035
  //#endregion
3036
+ //#region src/detection-pipeline/engine/coral-cocompiled-set.ts
3037
+ var ROOT_DETECTOR_STEP_ID = "object-detection";
3038
+ /** The models a dispatch places on the pool that runs it: every enabled video step. */
3039
+ function placedModelsOf(steps) {
3040
+ return flattenEnabledVideoSteps(steps).map((s) => ({
3041
+ stepId: s.addonId,
3042
+ modelId: s.modelId
3043
+ }));
3044
+ }
3045
+ var sameModel = (a, b) => a.stepId === b.stepId && a.modelId === b.modelId;
3046
+ /**
3047
+ * The set for `placed`, or why there is none.
3048
+ *
3049
+ * 1. A set that reserves the cache for the root detector is eligible only when
3050
+ * the root is placed here, and a rootless set only when it is not: a root
3051
+ * set on a pool without the root wastes the cache the root would have had,
3052
+ * and a rootless set beside a root makes the root swap.
3053
+ * 2. A set must stand for at least two placed models — one model alone is
3054
+ * better off with the whole cache (its separately compiled file).
3055
+ * 3. Most placed models covered wins; then the set with fewest members nobody
3056
+ * placed (they hold cache for nothing); then declaration order.
3057
+ */
3058
+ function selectCoCompiledSet(placed, sets) {
3059
+ if (placed.length === 0) return {
3060
+ kind: "separate",
3061
+ reason: "nothing-placed"
3062
+ };
3063
+ if (placed.length === 1) return {
3064
+ kind: "separate",
3065
+ reason: "single-model"
3066
+ };
3067
+ const hostsRoot = placed.some((p) => p.stepId === ROOT_DETECTOR_STEP_ID);
3068
+ let best = null;
3069
+ for (const set of sets) {
3070
+ if (set.hostsRoot !== hostsRoot) continue;
3071
+ const covered = placed.filter((p) => set.members.some((m) => sameModel(m, p)));
3072
+ if (covered.length < 2) continue;
3073
+ const idle = set.members.length - covered.length;
3074
+ if (best === null || covered.length > best.covered.length || covered.length === best.covered.length && idle < best.idle) best = {
3075
+ set,
3076
+ covered,
3077
+ idle
3078
+ };
3079
+ }
3080
+ if (best === null) return {
3081
+ kind: "separate",
3082
+ reason: "no-set-covers-two"
3083
+ };
3084
+ const { set, covered } = best;
3085
+ return {
3086
+ kind: "set",
3087
+ set,
3088
+ covered,
3089
+ uncovered: placed.filter((p) => !covered.some((c) => sameModel(c, p)))
3090
+ };
3091
+ }
3092
+ /** The member a selection loads `(stepId, modelId)` from, or `null` (its own `formats.tflite`). */
3093
+ function setMemberFor(selection, stepId, modelId) {
3094
+ if (selection.kind !== "set") return null;
3095
+ return selection.set.members.find((m) => m.stepId === stepId && m.modelId === modelId) ?? null;
3096
+ }
3097
+ /**
3098
+ * `entry` with its `tflite` build pointed at the set's file. Everything else —
3099
+ * labels, postprocessor, input contract, licence — is the entry's own: a
3100
+ * member is the same model, compiled together with others.
3101
+ */
3102
+ function withSetBuild(entry, member) {
3103
+ return {
3104
+ ...entry,
3105
+ formats: {
3106
+ ...entry.formats,
3107
+ tflite: {
3108
+ url: member.url,
3109
+ sizeMB: member.sizeMB,
3110
+ runtimes: ["python"]
3111
+ }
3112
+ }
3113
+ };
3114
+ }
3115
+ /** Identity of a selection for change detection: the set AND what it leaves out. */
3116
+ var selectionKey = (s) => s.kind === "set" ? `${s.set.id}|${s.uncovered.map((u) => `${u.stepId}/${u.modelId}`).toSorted().join(",")}` : `separate:${s.reason}`;
3117
+ /**
3118
+ * The placement of ONE Coral pool and the set it loads. Lives exactly as long
3119
+ * as the pool (the factory owns it).
3120
+ */
3121
+ var CoralSetPlanner = class {
3122
+ sets;
3123
+ placed = [];
3124
+ current = {
3125
+ kind: "separate",
3126
+ reason: "nothing-placed"
3127
+ };
3128
+ constructor(sets) {
3129
+ this.sets = sets;
3130
+ }
3131
+ /** Add the models a dispatch places on this pool; say whether the set changed. */
3132
+ note(models) {
3133
+ let grew = false;
3134
+ for (const m of models) {
3135
+ if (this.placed.some((p) => sameModel(p, m))) continue;
3136
+ this.placed.push({
3137
+ stepId: m.stepId,
3138
+ modelId: m.modelId
3139
+ });
3140
+ grew = true;
3141
+ }
3142
+ if (!grew) return { kind: "unchanged" };
3143
+ const next = selectCoCompiledSet(this.placed, this.sets);
3144
+ if (selectionKey(next) === selectionKey(this.current)) {
3145
+ this.current = next;
3146
+ return { kind: "unchanged" };
3147
+ }
3148
+ const from = this.current;
3149
+ this.current = next;
3150
+ return {
3151
+ kind: "changed",
3152
+ from,
3153
+ to: next,
3154
+ placed: [...this.placed]
3155
+ };
3156
+ }
3157
+ selection() {
3158
+ return this.current;
3159
+ }
3160
+ /** `entry` as this pool must load it: from the set when the set stands for it. */
3161
+ entryFor(stepId, entry) {
3162
+ const member = setMemberFor(this.current, stepId, entry.id);
3163
+ return member === null ? entry : withSetBuild(entry, member);
3164
+ }
3165
+ };
3166
+ //#endregion
3167
+ //#region src/detection-pipeline/registry/edgetpu-cocompiled-sets.ts
3168
+ /**
3169
+ * Co-compiled Edge TPU sets — pool-level artifacts, not models (D724).
3170
+ *
3171
+ * A Coral holds ~6.9 MiB of parameter cache. Two separately compiled models
3172
+ * carry two different cache tokens, so every alternation between them on one
3173
+ * Coral flushes the cache and re-streams the incoming model's parameters over
3174
+ * USB (D710). `edgetpu_compiler` given several models at once allocates the
3175
+ * cache between them, in command-line order, under ONE token: loaded from the
3176
+ * same set, they never evict each other — whatever does not fit is streamed on
3177
+ * every invoke of THAT model instead.
3178
+ *
3179
+ * Each member is the SAME model as its catalog entry's `formats.tflite` (same
3180
+ * `modelId`, same int8 graph, same labels and licence record), compiled
3181
+ * together with the other members (D710: a Coral build is a format of the
3182
+ * survivor; the set is where it is placed, not a new model). A Coral pool picks
3183
+ * at most one set from the models placed on it (`coral-cocompiled-set.ts`) and
3184
+ * falls back to the separately compiled `formats.tflite` for everything else.
3185
+ *
3186
+ * Built by `scripts/build-edgetpu-sets.py` (compile order = `members` order =
3187
+ * cache priority) and hosted under `edgetpuSets/<id>/`. Only sets whose
3188
+ * measured cost is acceptable are listed here: a set that would make the root
3189
+ * detector stream parameters on every frame (root + YuNet at 640: the root
3190
+ * keeps 3.34 of its 6.39 MiB, YuNet's activations take the rest) is
3191
+ * deliberately absent.
3192
+ */
3193
+ var HF_REPO = "camstack/camstack-models";
3194
+ var setFile = (setId, file) => require_dist.hfModelUrl(HF_REPO, `edgetpuSets/${setId}/${setId}__${file}`);
3195
+ var SSD = "ssd-mobilenet-v2-coco-edgetpu";
3196
+ var YUNET = "yunet-2023mar";
3197
+ var YOLOX = "yolox-tiny-plate";
3198
+ var BIRD = "bird-classifier";
3199
+ var EDGETPU_COCOMPILED_SETS = [
3200
+ {
3201
+ id: "root-plate-bird",
3202
+ hostsRoot: true,
3203
+ members: [
3204
+ {
3205
+ stepId: "object-detection",
3206
+ modelId: SSD,
3207
+ url: setFile("root-plate-bird", "ssd_mobilenet_v2_coco_quant_postprocess_edgetpu.tflite"),
3208
+ sizeMB: 6.9,
3209
+ onChipMiB: 6.39,
3210
+ streamedMiB: 0
3211
+ },
3212
+ {
3213
+ stepId: "plate-detection",
3214
+ modelId: YOLOX,
3215
+ url: setFile("root-plate-bird", "camstack-yolox-tiny-plate_int8_edgetpu.tflite"),
3216
+ sizeMB: 6.9,
3217
+ onChipMiB: .08,
3218
+ streamedMiB: 5.41
3219
+ },
3220
+ {
3221
+ stepId: "bird-classifier",
3222
+ modelId: BIRD,
3223
+ url: setFile("root-plate-bird", "mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite"),
3224
+ sizeMB: 4.9,
3225
+ onChipMiB: 0,
3226
+ streamedMiB: 4.54
3227
+ }
3228
+ ]
3229
+ },
3230
+ {
3231
+ id: "face-plate-bird",
3232
+ hostsRoot: false,
3233
+ members: [
3234
+ {
3235
+ stepId: "face-detection",
3236
+ modelId: YUNET,
3237
+ url: setFile("face-plate-bird", "camstack-yunet-2023mar_int8_edgetpu.tflite"),
3238
+ sizeMB: .7,
3239
+ onChipMiB: .11,
3240
+ streamedMiB: 0
3241
+ },
3242
+ {
3243
+ stepId: "plate-detection",
3244
+ modelId: YOLOX,
3245
+ url: setFile("face-plate-bird", "camstack-yolox-tiny-plate_int8_edgetpu.tflite"),
3246
+ sizeMB: 6.9,
3247
+ onChipMiB: 3.23,
3248
+ streamedMiB: 2.27
3249
+ },
3250
+ {
3251
+ stepId: "bird-classifier",
3252
+ modelId: BIRD,
3253
+ url: setFile("face-plate-bird", "mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite"),
3254
+ sizeMB: 4.9,
3255
+ onChipMiB: 0,
3256
+ streamedMiB: 4.54
3257
+ }
3258
+ ]
3259
+ },
3260
+ {
3261
+ id: "plate-bird",
3262
+ hostsRoot: false,
3263
+ members: [{
3264
+ stepId: "plate-detection",
3265
+ modelId: YOLOX,
3266
+ url: setFile("plate-bird", "camstack-yolox-tiny-plate_int8_edgetpu.tflite"),
3267
+ sizeMB: 6.9,
3268
+ onChipMiB: 5.55,
3269
+ streamedMiB: 0
3270
+ }, {
3271
+ stepId: "bird-classifier",
3272
+ modelId: BIRD,
3273
+ url: setFile("plate-bird", "mobilenet_v2_1.0_224_inat_bird_quant_edgetpu.tflite"),
3274
+ sizeMB: 4.1,
3275
+ onChipMiB: .92,
3276
+ streamedMiB: 2.8
3277
+ }]
3278
+ }
3279
+ ];
3280
+ //#endregion
2984
3281
  //#region src/detection-pipeline/engine/engine-factory.ts
2985
3282
  var BACKEND_TO_POOL_RUNTIME = {
2986
3283
  coreml: "coreml",
@@ -3074,11 +3371,45 @@ var EngineFactory = class {
3074
3371
  * trying to be.
3075
3372
  */
3076
3373
  resolvedProvisioning;
3374
+ /**
3375
+ * A Coral pool's placement and the co-compiled set it loads (D724); `null`
3376
+ * on every other runtime. Lives exactly as long as this factory — a new
3377
+ * pool starts from nothing placed.
3378
+ */
3379
+ coralSets;
3077
3380
  constructor(opts) {
3078
3381
  this.opts = opts;
3079
3382
  this.log = opts.logger;
3080
3383
  this.deviceKey = deviceKeyOf(opts.engine);
3081
3384
  this.resolvedProvisioning = resolvePoolProvisioning(opts.engine, opts.provisioning);
3385
+ this.coralSets = BACKEND_TO_POOL_RUNTIME[opts.engine.backend] === "edgetpu" ? new CoralSetPlanner(opts.coCompiledSets ?? EDGETPU_COCOMPILED_SETS) : null;
3386
+ }
3387
+ /**
3388
+ * Record the models a dispatch places on this pool. On a Coral pool the
3389
+ * answer says whether the co-compiled set it loads from changed; on any
3390
+ * other pool nothing is placed and nothing changes.
3391
+ */
3392
+ notePlacement(models) {
3393
+ return this.coralSets?.note(models) ?? { kind: "unchanged" };
3394
+ }
3395
+ /** The co-compiled set this pool loads from, or why none (`null`: not a Coral pool). */
3396
+ coralSetSelection() {
3397
+ return this.coralSets?.selection() ?? null;
3398
+ }
3399
+ /**
3400
+ * The catalog entry as THIS pool must download and load it: on a Coral pool
3401
+ * whose set stands for the model, the `tflite` build is the set's file.
3402
+ * Every other entry is returned unchanged.
3403
+ */
3404
+ entryForPool(stepId, entry) {
3405
+ return this.coralSets?.entryFor(stepId, entry) ?? entry;
3406
+ }
3407
+ /**
3408
+ * Reload every resident model whose file this pool no longer names — after
3409
+ * the Coral set changed. The caller has already downloaded the new files.
3410
+ */
3411
+ async reloadChangedModelFiles() {
3412
+ return this.poolManager?.reloadChangedPaths() ?? [];
3082
3413
  }
3083
3414
  /**
3084
3415
  * The provisioning this factory's pool runs with — resolved from the pool's
@@ -3340,6 +3671,7 @@ var EngineFactory = class {
3340
3671
  stepSettings,
3341
3672
  device: this.opts.engine.device,
3342
3673
  resolveCustomModel: this.opts.resolveCustomModel,
3674
+ entryForPool: (sid, entry) => this.entryForPool(sid, entry),
3343
3675
  onClassMapDrop: ({ stepId: sid, modelId: mid, unmappedLabels }) => {
3344
3676
  const key = `${sid}::${mid}`;
3345
3677
  if (this.classMapDropLogged.has(key)) return;
@@ -3365,8 +3697,9 @@ var EngineFactory = class {
3365
3697
  function buildPoolModelConfigForStep(inputs) {
3366
3698
  const { stepId, modelId, poolRuntime, modelsDir } = inputs;
3367
3699
  const def = require_default_detection_model.getStepDefinition(stepId);
3368
- const modelEntry = def.models.find((m) => m.id === modelId) ?? inputs.resolveCustomModel?.(stepId, modelId);
3369
- if (!modelEntry) throw new Error(`Model "${modelId}" not found in step "${stepId}" catalog (static or custom registry)`);
3700
+ const resolvedEntry = def.models.find((m) => m.id === modelId) ?? inputs.resolveCustomModel?.(stepId, modelId);
3701
+ if (!resolvedEntry) throw new Error(`Model "${modelId}" not found in step "${stepId}" catalog (static or custom registry)`);
3702
+ const modelEntry = inputs.entryForPool?.(stepId, resolvedEntry) ?? resolvedEntry;
3370
3703
  const format = RUNTIME_TO_FORMAT[poolRuntime];
3371
3704
  if (!format) throw new Error(`No format mapping for pool runtime "${poolRuntime}"`);
3372
3705
  const dropWarning = collectClassMapDropWarning(def, modelEntry);
@@ -5444,7 +5777,7 @@ var PLATE_OCR_CROP_POLICIES = {
5444
5777
  minLongSidePx: 85
5445
5778
  },
5446
5779
  "plate-slots": {
5447
- marginFraction: .15,
5780
+ marginFraction: .05,
5448
5781
  rectify: false,
5449
5782
  minLongSidePx: 70
5450
5783
  }
@@ -6134,6 +6467,41 @@ function toMutableRootDetection(det, rootStep, idGen, rootStepLatencyMs) {
6134
6467
  };
6135
6468
  }
6136
6469
  //#endregion
6470
+ //#region src/detection-pipeline/pipeline/linked-label.ts
6471
+ /**
6472
+ * The detector's linked label (D715): when the model that RAN declares it
6473
+ * fills a step, a detection whose raw class names that step's effect carries
6474
+ * the effect as a `ScoredLabel` attributed to `detector-link:<stepId>` — in
6475
+ * the step's own vocabulary and tier, so tier 1 means one thing whichever
6476
+ * writer produced it.
6477
+ *
6478
+ * Written at score 0 here, always: the executor cannot see the camera's whole
6479
+ * step tree (a detail step placed on another pool is pruned from the dispatch),
6480
+ * so it cannot know who the writer is. The runner, which holds the attach
6481
+ * config, raises the score to the detection's own when the detector is
6482
+ * authoritative (`pipeline-runner/label-link.ts`). Score 0 is the fallback any
6483
+ * scored answer of the step outranks.
6484
+ */
6485
+ /** The linked labels one mapped root detection carries. Pure. */
6486
+ function linkedLabelsFor(fills, rawClass, macroClass, modelId) {
6487
+ if (fills === void 0 || fills.length === 0) return [];
6488
+ const out = [];
6489
+ for (const fill of fills) {
6490
+ if (require_dist.FILLABLE_STEP_MACRO[fill.stepId] !== macroClass) continue;
6491
+ const effect = fill.labelToEffect[rawClass];
6492
+ if (effect === void 0 || effect === macroClass) continue;
6493
+ const tier = require_default_detection_model.getStepDefinition(fill.stepId).labelTier;
6494
+ out.push({
6495
+ label: effect,
6496
+ score: 0,
6497
+ ...tier !== void 0 ? { tier } : {},
6498
+ stepId: require_dist.linkedLabelStepId(fill.stepId),
6499
+ modelId
6500
+ });
6501
+ }
6502
+ return out;
6503
+ }
6504
+ //#endregion
6137
6505
  //#region src/detection-pipeline/pipeline/executor.ts
6138
6506
  /**
6139
6507
  * Default minimum short-side (px, source-frame resolution) of a face bbox for
@@ -6403,6 +6771,7 @@ var PipelineExecutor = class {
6403
6771
  continue;
6404
6772
  }
6405
6773
  }
6774
+ for (const linked of linkedLabelsFor(rootStep.fillsClassifierEffects, det.class, mutable.macroClass, rootStep.modelId)) mutable.ownLabels.push(linked);
6406
6775
  const filterVerdict = this.macroFilterVerdict(mutable.macroClass, mutable.score, rootStep.settings);
6407
6776
  if (filterVerdict !== "pass") {
6408
6777
  (discarded ??= []).push({
@@ -6971,7 +7340,8 @@ function buildNode(step, getEngine, resolveModel, onMissingVariant, resolved) {
6971
7340
  enabled: step.enabled,
6972
7341
  children,
6973
7342
  ...Object.keys(mergedSettings).length > 0 ? { settings: mergedSettings } : {},
6974
- ...effectiveClassMap !== void 0 ? { effectiveClassMap } : {}
7343
+ ...effectiveClassMap !== void 0 ? { effectiveClassMap } : {},
7344
+ ...modelEntry?.fillsClassifierEffects !== void 0 ? { fillsClassifierEffects: modelEntry.fillsClassifierEffects } : {}
6975
7345
  };
6976
7346
  }
6977
7347
  /**
@@ -7757,7 +8127,9 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
7757
8127
  * The rebuild is not cheap — `ensureModelsForSteps` loads EVERY enabled step
7758
8128
  * into the fresh factory, which on the hub is seven models
7759
8129
  * (yolov9m-320-int8, scrfd-2.5g, arcface-r100, yolov8n-plate,
7760
- * vgg_english_g2, mobileclip-s1-vision, yolov8n-package). The hub log shows
8130
+ * vgg_english_g2, mobileclip-s1-vision, yolov8n-package — the set of that
8131
+ * date; all but the root detector have since been replaced, D703/D719).
8132
+ * The hub log shows
7761
8133
  * the cycle plainly: `COMPILE ×7` → shed within 7-15s → `EVICT` ~2.5 min
7762
8134
  * later → repeat. So the first seconds of a motion event — precisely when
7763
8135
  * detection matters — were spent recompiling models that had just been
@@ -9393,6 +9765,7 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
9393
9765
  */
9394
9766
  async loadDispatchModels(steps, factory, format, context, policy) {
9395
9767
  const failures = [];
9768
+ if (factory !== null) await this.noteCoralPlacement(steps, factory, format, context);
9396
9769
  const walk = async (nodes, root) => {
9397
9770
  for (const step of nodes) {
9398
9771
  if (!step.enabled || step.slot === "audio-classifier") continue;
@@ -9417,6 +9790,69 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
9417
9790
  await walk(steps, true);
9418
9791
  return failures;
9419
9792
  }
9793
+ /**
9794
+ * Tell a Coral pool which models this dispatch places on it, and act on a
9795
+ * change of the co-compiled set it loads from (D724): download the set's
9796
+ * files for the models already resident and reload them — queued behind the
9797
+ * pool's other loads, so nothing loads from the old file meanwhile. Logged
9798
+ * once per change, tagged with the camera whose dispatch moved it.
9799
+ */
9800
+ async noteCoralPlacement(steps, factory, format, context) {
9801
+ const change = factory.notePlacement(placedModelsOf(steps));
9802
+ if (change.kind === "unchanged") return;
9803
+ const deviceKey = context.deviceKey ?? deviceKeyOf(this.currentEngine);
9804
+ const tags = context.deviceId !== void 0 ? { tags: { deviceId: context.deviceId } } : {};
9805
+ const placed = change.placed.map((p) => `${p.stepId}/${p.modelId}`);
9806
+ if (change.to.kind === "set") this.log.info("Coral pool loads a co-compiled set — the models placed on it share the parameter cache", {
9807
+ ...tags,
9808
+ meta: {
9809
+ deviceKey,
9810
+ set: change.to.set.id,
9811
+ placed,
9812
+ fromSet: change.to.covered.map((p) => `${p.stepId}/${p.modelId}`),
9813
+ separatelyCompiled: change.to.uncovered.map((p) => `${p.stepId}/${p.modelId}`),
9814
+ previous: change.from.kind === "set" ? change.from.set.id : null
9815
+ }
9816
+ });
9817
+ else if (change.to.reason === "no-set-covers-two") this.log.warn("Coral pool has no co-compiled set for the models placed on it — each is compiled alone, so they evict each other from the parameter cache on every alternation", {
9818
+ ...tags,
9819
+ meta: {
9820
+ deviceKey,
9821
+ placed,
9822
+ previous: change.from.kind === "set" ? change.from.set.id : null,
9823
+ hint: "keep the extra step off this Coral with its jumpDeviceKey, or place a combination a published set covers"
9824
+ }
9825
+ });
9826
+ const pool = factory;
9827
+ const previous = this.modelLoadTail.get(pool) ?? Promise.resolve();
9828
+ const tail = (async () => {
9829
+ await previous;
9830
+ for (const loaded of factory.listLoaded()) {
9831
+ const resolved = await this.resolveModelEntry(loaded.stepId, loaded.modelId);
9832
+ if (resolved === void 0) continue;
9833
+ const entry = factory.entryForPool(loaded.stepId, resolved);
9834
+ if (!(0, _camstack_system_addon_utils.isModelDownloaded)(this.modelsDir, entry, format)) await this.downloadWithRetry(entry, format, 3);
9835
+ }
9836
+ const reloaded = await factory.reloadChangedModelFiles();
9837
+ if (reloaded.length > 0) this.log.info("Coral pool reloaded its resident models from the new set", {
9838
+ ...tags,
9839
+ meta: {
9840
+ deviceKey,
9841
+ reloaded: reloaded.map((r) => `${r.stepId}/${r.modelId}`)
9842
+ }
9843
+ });
9844
+ })().catch((err) => {
9845
+ this.log.error("Coral pool could not move its resident models to the new set — they keep serving from the old files", {
9846
+ ...tags,
9847
+ meta: {
9848
+ deviceKey,
9849
+ error: require_dist.errMsg(err)
9850
+ }
9851
+ });
9852
+ });
9853
+ this.modelLoadTail.set(pool, tail);
9854
+ await tail;
9855
+ }
9420
9856
  /** Ensure all models needed by steps are downloaded and loaded in the engine pool.
9421
9857
  * `factory`/`format` default to the node's engine; a per-device dispatch passes
9422
9858
  * that device's factory + format (Phase 2 multi-device). `context` names the
@@ -9514,7 +9950,7 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
9514
9950
  const refusal = this.loadRefusal(pool, deviceKey, models);
9515
9951
  if (refusal !== null) throw refusal;
9516
9952
  try {
9517
- await this.downloadNeededModels(needed, format);
9953
+ await this.downloadNeededModels(needed, format, factory);
9518
9954
  this.log.info("Loading additional models for benchmark", { meta: {
9519
9955
  count: needed.length,
9520
9956
  models,
@@ -9578,16 +10014,21 @@ var DetectionPipelineProvider = class DetectionPipelineProvider {
9578
10014
  });
9579
10015
  }
9580
10016
  /** Download any model of `needed` missing in `format` (the device's). */
9581
- async downloadNeededModels(needed, format) {
10017
+ async downloadNeededModels(needed, format, factory = null) {
9582
10018
  for (const step of needed) try {
9583
- await this.ensureStepModelArtifact(step, format);
10019
+ await this.ensureStepModelArtifact(step, format, factory);
9584
10020
  } catch (err) {
9585
10021
  throw new StepModelArtifactError(step.addonId, step.modelId, err);
9586
10022
  }
9587
10023
  }
9588
- /** Make one step's model artifact present on disk for `format`, or say why it cannot be. */
9589
- async ensureStepModelArtifact(step, format) {
9590
- const modelEntry = await this.resolveModelEntry(step.addonId, step.modelId);
10024
+ /**
10025
+ * Make one step's model artifact present on disk for `format`, or say why it
10026
+ * cannot be. The entry is the one `factory`'s pool will LOAD — on a Coral
10027
+ * pool, a co-compiled set's file when the set stands for the model (D724).
10028
+ */
10029
+ async ensureStepModelArtifact(step, format, factory = null) {
10030
+ const resolved = await this.resolveModelEntry(step.addonId, step.modelId);
10031
+ const modelEntry = resolved && factory !== null ? factory.entryForPool(step.addonId, resolved) : resolved;
9591
10032
  if (modelEntry && !(0, _camstack_system_addon_utils.isModelDownloaded)(this.modelsDir, modelEntry, format)) {
9592
10033
  if (modelEntry.formats[format] === void 0) throw new Error(`Model "${modelEntry.id}" has no ${format} format build (available: ${Object.keys(modelEntry.formats).join(", ") || "none"}) — not retrying a permanent format mismatch`);
9593
10034
  if (modelEntry.formats[format]?.url.startsWith("camstack-local://") === true) throw new Error(`Custom model "${modelEntry.id}" (${format}) is not present in this node's models directory — distribute it to this node from Model Studio before selecting it here`);
@@ -10608,7 +11049,8 @@ function buildSchemaSlots(formats, modelsDir, customByStep) {
10608
11049
  ...m.group ? { group: m.group } : {},
10609
11050
  ...m.legacy !== void 0 ? { legacy: m.legacy } : {},
10610
11051
  provider: m.provider ?? "camstack",
10611
- defaultConfidence: require_default_detection_model.resolveModelDefaultConfidence(step, m)
11052
+ defaultConfidence: require_default_detection_model.resolveModelDefaultConfidence(step, m),
11053
+ ...m.fillsClassifierEffects !== void 0 ? { fillsClassifierEffects: m.fillsClassifierEffects } : {}
10612
11054
  })),
10613
11055
  defaultModelId: step.defaultModelId,
10614
11056
  ...step.defaultModelIdByFormat ? { defaultModelIdByFormat: { ...step.defaultModelIdByFormat } } : {},