@camstack/addon-post-analysis 1.2.625 → 1.2.627

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 (14) hide show
  1. package/dist/{clip-model-registry-BmPWAiiw.mjs → clip-model-registry-CCMO8jrp.mjs} +6820 -1413
  2. package/dist/{clip-model-registry-Bz5VWLtO.js → clip-model-registry-RSxtlgdN.js} +6825 -1412
  3. package/dist/embedding-encoder/index.js +1 -1
  4. package/dist/embedding-encoder/index.mjs +1 -1
  5. package/dist/pipeline-analytics/_stub.js +2 -2
  6. package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-u9k_8R7t.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-CB62NeGh.mjs} +3 -3
  7. package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-DY-_tUCM.mjs +26 -0
  8. package/dist/pipeline-analytics/{_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Dh58k_r9.mjs → _virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-_Ip2ZGVX.mjs} +1 -1
  9. package/dist/pipeline-analytics/{hostInit-Bx3x53tR.mjs → hostInit-BUdkjx1s.mjs} +3 -3
  10. package/dist/pipeline-analytics/index.js +132 -41
  11. package/dist/pipeline-analytics/index.mjs +132 -41
  12. package/dist/pipeline-analytics/remoteEntry.js +1 -1
  13. package/package.json +1 -1
  14. package/dist/pipeline-analytics/_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_types__loadShare__.js-yap5surJ.mjs +0 -26
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_clip_model_registry = require("../clip-model-registry-Bz5VWLtO.js");
5
+ const require_clip_model_registry = require("../clip-model-registry-RSxtlgdN.js");
6
6
  let node_fs = require("node:fs");
7
7
  node_fs = require_clip_model_registry.__toESM(node_fs, 1);
8
8
  let node_path = require("node:path");
@@ -16404,6 +16404,18 @@ function gapDistance(a, b) {
16404
16404
  if (last === void 0 || first === void 0 || first.timestamp < last.timestamp) return 0;
16405
16405
  return Math.sqrt((first.x - last.x) ** 2 + (first.y - last.y) ** 2);
16406
16406
  }
16407
+ /**
16408
+ * WHERE a fused track was detected (D683 L2 fusion): it OPENED where its
16409
+ * earliest-born piece opened and CLOSED where its latest-seen piece was last
16410
+ * sighted — the same span `firstSeen` / `lastSeen` take, decided by the times
16411
+ * rather than by which piece survived (an absorbed piece can overlap and end
16412
+ * first). The placements of the pieces in between are not kept: the row
16413
+ * answers "where did this subject start and end", and a hop in the middle is
16414
+ * the `inference device selection` log's to tell. A piece with no placement
16415
+ * never erases the other's.
16416
+ */
16417
+ var earlierOpened = (a, b) => b.firstSeen < a.firstSeen ? b.openedPlacement ?? a.openedPlacement : a.openedPlacement ?? b.openedPlacement;
16418
+ var laterClosed = (a, b) => b.lastSeen >= a.lastSeen ? b.closedPlacement ?? a.closedPlacement : a.closedPlacement ?? b.closedPlacement;
16407
16419
  var TRACK_MERGE_RULES = {
16408
16420
  trackId: survivor$1("trackId"),
16409
16421
  deviceId: survivor$1("deviceId"),
@@ -16444,6 +16456,8 @@ var TRACK_MERGE_RULES = {
16444
16456
  hasRider: either$1("hasRider"),
16445
16457
  closedReason: survivor$1("closedReason"),
16446
16458
  provenance: survivor$1("provenance"),
16459
+ openedPlacement: earlierOpened,
16460
+ closedPlacement: laterClosed,
16447
16461
  movedProbe: mergedMovedProbe,
16448
16462
  keptAtPromotion: (a, b) => a.keptAtPromotion === true || b.keptAtPromotion === true ? true : void 0
16449
16463
  };
@@ -16485,6 +16499,8 @@ var TRACK_MERGE_KEYS = [
16485
16499
  "hasRider",
16486
16500
  "closedReason",
16487
16501
  "provenance",
16502
+ "openedPlacement",
16503
+ "closedPlacement",
16488
16504
  "movedProbe",
16489
16505
  "keptAtPromotion"
16490
16506
  ];
@@ -16821,7 +16837,15 @@ var TRACKS_COLUMNS = [
16821
16837
  {
16822
16838
  name: "observations",
16823
16839
  type: "INTEGER"
16824
- })
16840
+ }),
16841
+ {
16842
+ name: "openedPlacement",
16843
+ type: "JSON"
16844
+ },
16845
+ {
16846
+ name: "closedPlacement",
16847
+ type: "JSON"
16848
+ }
16825
16849
  ];
16826
16850
  /**
16827
16851
  * The columns `rowToTrack` reads, per projection — the SELECT list the store
@@ -16968,7 +16992,9 @@ function cloneTrack(t) {
16968
16992
  ...t.provenance !== void 0 ? {
16969
16993
  frameWidth: t.provenance.frameWidth,
16970
16994
  frameHeight: t.provenance.frameHeight
16971
- } : {}
16995
+ } : {},
16996
+ ...t.openedPlacement !== void 0 ? { openedPlacement: { ...t.openedPlacement } } : {},
16997
+ ...t.closedPlacement !== void 0 ? { closedPlacement: { ...t.closedPlacement } } : {}
16972
16998
  };
16973
16999
  }
16974
17000
  /** Ids per set-based `benchPinned` statement — well under SQLite's bound
@@ -17116,7 +17142,11 @@ var TrackStore = class {
17116
17142
  active: true,
17117
17143
  lastSnapshotAt: 0,
17118
17144
  movedProbe: stepMovedProbe(EMPTY_MOVED_PROBE, params.position.bbox),
17119
- ...params.provenance !== void 0 ? { provenance: params.provenance } : {}
17145
+ ...params.provenance !== void 0 ? { provenance: params.provenance } : {},
17146
+ ...params.placement !== void 0 ? {
17147
+ openedPlacement: params.placement,
17148
+ closedPlacement: params.placement
17149
+ } : {}
17120
17150
  };
17121
17151
  }
17122
17152
  const existing = this.active.get(params.trackId);
@@ -17130,6 +17160,7 @@ var TrackStore = class {
17130
17160
  const last = existing.positions[existing.positions.length - 1];
17131
17161
  const dist = last ? Math.sqrt((params.position.x - last.x) ** 2 + (params.position.y - last.y) ** 2) : 0;
17132
17162
  existing.lastSeen = params.timestamp;
17163
+ if (params.placement !== void 0) existing.closedPlacement = params.placement;
17133
17164
  existing.totalDistance += dist;
17134
17165
  existing.state = params.state;
17135
17166
  existing.movedProbe = stepMovedProbe(existing.movedProbe, params.position.bbox);
@@ -17155,7 +17186,11 @@ var TrackStore = class {
17155
17186
  active: true,
17156
17187
  lastSnapshotAt: 0,
17157
17188
  movedProbe: stepMovedProbe(EMPTY_MOVED_PROBE, params.position.bbox),
17158
- ...params.provenance !== void 0 ? { provenance: params.provenance } : {}
17189
+ ...params.provenance !== void 0 ? { provenance: params.provenance } : {},
17190
+ ...params.placement !== void 0 ? {
17191
+ openedPlacement: params.placement,
17192
+ closedPlacement: params.placement
17193
+ } : {}
17159
17194
  };
17160
17195
  this.active.set(params.trackId, fresh);
17161
17196
  return fresh;
@@ -18906,7 +18941,9 @@ var TrackStore = class {
18906
18941
  frameWidth: dims.w,
18907
18942
  frameHeight: dims.h
18908
18943
  } : {},
18909
- ...t.modelId !== void 0 ? { modelId: t.modelId } : {}
18944
+ ...t.modelId !== void 0 ? { modelId: t.modelId } : {},
18945
+ ...t.openedPlacement !== void 0 ? { openedPlacement: t.openedPlacement } : {},
18946
+ ...t.closedPlacement !== void 0 ? { closedPlacement: t.closedPlacement } : {}
18910
18947
  }
18911
18948
  });
18912
18949
  }
@@ -18971,6 +19008,8 @@ var TrackStore = class {
18971
19008
  * string read, absent stays absent. */
18972
19009
  const previewMissReason = data["previewMissReason"];
18973
19010
  const modelId = data["modelId"];
19011
+ const openedPlacement = require_clip_model_registry.TrackPlacementSchema.safeParse(data["openedPlacement"]);
19012
+ const closedPlacement = require_clip_model_registry.TrackPlacementSchema.safeParse(data["closedPlacement"]);
18974
19013
  const frameWidth = data["frameWidth"];
18975
19014
  const frameHeight = data["frameHeight"];
18976
19015
  const envMinX = data["envMinX"];
@@ -19023,7 +19062,9 @@ var TrackStore = class {
19023
19062
  ...typeof frameWidth === "number" && typeof frameHeight === "number" ? {
19024
19063
  frameWidth,
19025
19064
  frameHeight
19026
- } : {}
19065
+ } : {},
19066
+ ...openedPlacement.success ? { openedPlacement: openedPlacement.data } : {},
19067
+ ...closedPlacement.success ? { closedPlacement: closedPlacement.data } : {}
19027
19068
  });
19028
19069
  }
19029
19070
  };
@@ -74889,6 +74930,16 @@ function trackProvenanceOf(frame) {
74889
74930
  };
74890
74931
  }
74891
74932
  //#endregion
74933
+ //#region src/pipeline-analytics/pipeline/track-placement.ts
74934
+ function trackPlacementOf(frame, nodeId) {
74935
+ if (nodeId.length === 0) return void 0;
74936
+ return {
74937
+ nodeId,
74938
+ ...frame.rootDeviceKey !== void 0 && frame.rootDeviceKey.length > 0 ? { deviceKey: frame.rootDeviceKey } : {},
74939
+ ...frame.rootModelId !== void 0 && frame.rootModelId.length > 0 ? { modelId: frame.rootModelId } : {}
74940
+ };
74941
+ }
74942
+ //#endregion
74892
74943
  //#region src/pipeline-analytics/pipeline/best-detection-tracker.ts
74893
74944
  /**
74894
74945
  * `BestDetectionTracker` — the SINGLE canonical policy for "the best detection
@@ -83789,21 +83840,30 @@ async function measure(candidate, crop, config, deps, cropSource) {
83789
83840
  if (detections === null) return undecided(candidate, "redetect-error");
83790
83841
  let best;
83791
83842
  let bestIncompatible;
83792
- for (const d of detections) if (isConfirmationCompatible(candidate.className, d.macroClass)) {
83793
- if (!best || d.score > best.score) best = d;
83794
- } else if (!bestIncompatible || d.score > bestIncompatible.score) bestIncompatible = d;
83843
+ let bestRefused;
83844
+ for (const d of detections) {
83845
+ const compatible = isConfirmationCompatible(candidate.className, d.macroClass);
83846
+ if (d.refusedByDetectorFloor === true) {
83847
+ if (compatible && (!bestRefused || d.score > bestRefused.score)) bestRefused = d;
83848
+ continue;
83849
+ }
83850
+ if (compatible) {
83851
+ if (!best || d.score > best.score) best = d;
83852
+ } else if (!bestIncompatible || d.score > bestIncompatible.score) bestIncompatible = d;
83853
+ }
83795
83854
  const bar = barFor(candidate, config, deps);
83796
83855
  const confirmed = best !== void 0 && best.score >= bar;
83797
83856
  if (!confirmed && cropSource !== "native") return undecided(candidate, cropSource === "fallback" ? "fallback-inconclusive" : "carried-inconclusive");
83798
83857
  const secondary = bestIncompatible ? promoteSecondary(candidate, bestIncompatible, bar, deps) : null;
83858
+ const scored = best ?? bestRefused;
83799
83859
  return {
83800
83860
  trackId: candidate.trackId,
83801
83861
  verdict: confirmed ? "confirmed" : "suppressed",
83802
- reason: confirmed ? "confirmed" : "suppressed",
83862
+ reason: confirmed ? "confirmed" : suppressionReason(best, bestRefused, bestIncompatible),
83803
83863
  className: candidate.className,
83804
83864
  appliedMinConfidence: bar,
83805
83865
  cropSource,
83806
- ...best ? { bestScore: best.score } : {},
83866
+ ...scored ? { bestScore: scored.score } : {},
83807
83867
  ...bestIncompatible ? {
83808
83868
  bestIncompatibleClass: bestIncompatible.macroClass,
83809
83869
  bestIncompatibleScore: bestIncompatible.score
@@ -83811,6 +83871,13 @@ async function measure(candidate, crop, config, deps, cropSource) {
83811
83871
  ...secondary ? { secondary } : {}
83812
83872
  };
83813
83873
  }
83874
+ /** Why a measured native crop said no — first matching rule wins (D922). */
83875
+ function suppressionReason(best, bestRefused, bestIncompatible) {
83876
+ if (best !== void 0) return "scored-below-threshold";
83877
+ if (bestRefused !== void 0) return "below-detector-floor";
83878
+ if (bestIncompatible !== void 0) return "incompatible-class";
83879
+ return "no-detection";
83880
+ }
83814
83881
  /**
83815
83882
  * The incompatible best becomes a secondary subject when it clears the SAME
83816
83883
  * bar the candidate faced and can be placed in the frame. The crop-normalised
@@ -93000,11 +93067,37 @@ function buildBirthDecisionRecord(input) {
93000
93067
  decidedByBirthEvidence: input.decidedByBirthEvidence,
93001
93068
  bestScore: input.bestScore ?? null,
93002
93069
  appliedMinConfidence: input.appliedMinConfidence ?? null,
93070
+ cropSource: input.cropSource ?? null,
93003
93071
  firstSeen,
93004
93072
  ...latency
93005
93073
  };
93006
93074
  }
93007
93075
  //#endregion
93076
+ //#region src/pipeline-analytics/confirmation-redetect-result.ts
93077
+ /** Map a re-detect result to the gate's input; `null` when it carried no detections array. */
93078
+ function toConfirmationDetections(result) {
93079
+ const detections = result?.detections;
93080
+ if (!result || !detections) return null;
93081
+ const cropWidth = result.width ?? 0;
93082
+ const cropHeight = result.height ?? 0;
93083
+ const kept = detections.map((d) => ({
93084
+ macroClass: d.macroClass,
93085
+ score: d.score,
93086
+ ...d.bbox !== void 0 && cropWidth > 0 && cropHeight > 0 ? { bbox: {
93087
+ x: d.bbox.x / cropWidth,
93088
+ y: d.bbox.y / cropHeight,
93089
+ w: d.bbox.width / cropWidth,
93090
+ h: d.bbox.height / cropHeight
93091
+ } } : {}
93092
+ }));
93093
+ const refused = (result.discarded ?? []).filter((d) => d.reason === "below-threshold").map((d) => ({
93094
+ macroClass: d.macroClass,
93095
+ score: d.score,
93096
+ refusedByDetectorFloor: true
93097
+ }));
93098
+ return [...kept, ...refused];
93099
+ }
93100
+ //#endregion
93008
93101
  //#region src/pipeline-analytics/pipeline/birth-evidence-store.ts
93009
93102
  /**
93010
93103
  * The pixels a birth arrived with, held for as long as its deferral can last —
@@ -118465,7 +118558,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
118465
118558
  }
118466
118559
  });
118467
118560
  }
118468
- await this.processFrame(deviceId, frame, data.source ?? "pipeline", data.frameHandle, data.detailSteps, data.occasion ?? "session");
118561
+ await this.processFrame(deviceId, frame, data.source ?? "pipeline", data.frameHandle, data.detailSteps, data.occasion ?? "session", data.nodeId);
118469
118562
  }
118470
118563
  /**
118471
118564
  * Run one detection frame through the analysis layers for a given
@@ -118739,7 +118832,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
118739
118832
  }
118740
118833
  });
118741
118834
  }
118742
- async processFrame(deviceId, frame, source, rawFrameHandle, detailSteps, occasion = "session") {
118835
+ async processFrame(deviceId, frame, source, rawFrameHandle, detailSteps, occasion = "session", producerNodeId = "") {
118743
118836
  if (this.shuttingDown) return;
118744
118837
  if (detailSteps !== void 0) this.detailStepsByDevice.set(deviceId, detailSteps);
118745
118838
  if (!await this.bindingCache.isActive(deviceId)) {
@@ -118926,6 +119019,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
118926
119019
  const currentTrackIds = /* @__PURE__ */ new Set();
118927
119020
  const positionsCountById = /* @__PURE__ */ new Map();
118928
119021
  const provenance = trackProvenanceOf(frame);
119022
+ const placement = trackPlacementOf(frame, producerNodeId);
118929
119023
  for (const t of result.tracked) {
118930
119024
  currentTrackIds.add(t.trackId);
118931
119025
  if (this.suppressedBirths.isRejected(key, t.trackId)) continue;
@@ -118950,7 +119044,8 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
118950
119044
  },
118951
119045
  zones: t.zones,
118952
119046
  state: t.state,
118953
- ...provenance !== void 0 ? { provenance } : {}
119047
+ ...provenance !== void 0 ? { provenance } : {},
119048
+ ...placement !== void 0 ? { placement } : {}
118954
119049
  });
118955
119050
  positionsCountById.set(t.trackId, upserted.positions.length);
118956
119051
  }
@@ -119144,16 +119239,25 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
119144
119239
  processor.markSuppressed(id);
119145
119240
  this.trackStore?.dropActive(id);
119146
119241
  this.clearLiveTrackState(deviceId, id);
119147
- log.info("birth suppressed — track record retracted", { meta: {
119148
- trackId: id,
119149
- className: t.className,
119150
- source,
119151
- ...wasDeferred ? {
119152
- wasDeferred,
119153
- deferredForMs,
119154
- deferredAttempts
119155
- } : {}
119156
- } });
119242
+ const suppression = run.decisions.get(id);
119243
+ log.info("birth suppressed — track record retracted", {
119244
+ tags: { deviceId },
119245
+ meta: {
119246
+ trackId: id,
119247
+ className: t.className,
119248
+ source,
119249
+ reason: suppression?.reason ?? null,
119250
+ bestScore: suppression?.bestScore ?? null,
119251
+ appliedMinConfidence: suppression?.appliedMinConfidence ?? null,
119252
+ cropSource: suppression?.cropSource ?? null,
119253
+ attempts: deferredAttempts,
119254
+ ...wasDeferred ? {
119255
+ wasDeferred,
119256
+ deferredForMs,
119257
+ deferredAttempts
119258
+ } : {}
119259
+ }
119260
+ });
119157
119261
  continue;
119158
119262
  }
119159
119263
  if (wasDeferred && exhaustedIds.has(id)) log.warn("birth allowed unmeasured — deferral exhausted, no crop available", { meta: {
@@ -119900,26 +120004,12 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
119900
120004
  const executor = this.pipelineExecutorApi();
119901
120005
  if (!executor?.runPipeline) return null;
119902
120006
  try {
119903
- const result = await executor.runPipeline.mutate({
120007
+ return toConfirmationDetections(await executor.runPipeline.mutate({
119904
120008
  steps: [step],
119905
120009
  image: new Uint8Array(cropJpeg),
119906
120010
  deviceId,
119907
120011
  plane: "frame"
119908
- }, require_clip_model_registry.nodePin(nodeId));
119909
- const detections = result?.detections;
119910
- if (!detections) return null;
119911
- const cropWidth = result.width ?? 0;
119912
- const cropHeight = result.height ?? 0;
119913
- return detections.map((d) => ({
119914
- macroClass: d.macroClass,
119915
- score: d.score,
119916
- ...d.bbox !== void 0 && cropWidth > 0 && cropHeight > 0 ? { bbox: {
119917
- x: d.bbox.x / cropWidth,
119918
- y: d.bbox.y / cropHeight,
119919
- w: d.bbox.width / cropWidth,
119920
- h: d.bbox.height / cropHeight
119921
- } } : {}
119922
- }));
120012
+ }, require_clip_model_registry.nodePin(nodeId)));
119923
120013
  } catch (err) {
119924
120014
  this.ctx.logger.debug("confirmation gate: re-detection failed — fail-open", {
119925
120015
  tags: { deviceId },
@@ -119980,6 +120070,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
119980
120070
  reason: decision?.reason ?? null,
119981
120071
  bestScore: decision?.bestScore ?? null,
119982
120072
  appliedMinConfidence: decision?.appliedMinConfidence ?? null,
120073
+ cropSource: decision?.cropSource ?? null,
119983
120074
  decidedAtMs: input.decidedAtMs,
119984
120075
  firstSeen: input.firstSeen,
119985
120076
  motionOnsetAtMs,