@camstack/addon-post-analysis 1.2.214 → 1.2.216
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.
- package/dist/{dist-DA1sJKXM.js → dist-B_6UZCut.js} +204 -17
- package/dist/{dist-CT2SouNJ.mjs → dist-DWZqNymj.mjs} +204 -17
- package/dist/embedding-encoder/index.js +1 -1
- package/dist/embedding-encoder/index.mjs +1 -1
- package/dist/pipeline-analytics/_stub.js +1 -1
- package/dist/pipeline-analytics/{_virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-TUlCd-Zk.mjs → _virtual_mf-localSharedImportMap___mfe_internal__addon_pipeline_analytics_widgets-BmDXGilB.mjs} +3 -3
- package/dist/pipeline-analytics/{_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CcE47LPf.mjs → _virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-Dgmog5ky.mjs} +1 -1
- package/dist/pipeline-analytics/{hostInit-CN3MIGfb.mjs → hostInit-DMDZJw2T.mjs} +3 -3
- package/dist/pipeline-analytics/index.js +640 -201
- package/dist/pipeline-analytics/index.mjs +632 -193
- package/dist/pipeline-analytics/remoteEntry.js +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as VISIT_MERGE_GAP_MS, $t as object, A as NcRulePatchSchema, Bt as CamProfileSchema, C as NC_ALARM_SYSTEM_EVENT_KINDS, D as NC_TAXONOMY, Dt as readDeviceStateFrom, Et as plateGalleryCapability, F as NcSnoozeSchema, Ft as vectorDimFromBase64, G as SCENE_DEFAULT_UNCOVERED_POLICY, Gt as nodePin, H as RetrainStatusSchema, Ht as createEvent, I as NcSnoozeSuppressedSchema, It as videoclipsCapability, J as TIMELAPSE_DENSE_FLOOR_SEC, Jt as array, K as SCENE_DIVERGED, Kt as sleep$1, L as NcSystemEventKindSchema, Lt as zoneAnalyticsCapability, M as NcRuleTargetSchema, Mt as storageOccupancyCapability, N as NcScheduleSchema, Nt as subKindsOf, O as NcConditionDescriptorSchema, Ot as readTimelapseGeneratedAt, P as NcSnoozeInputSchema, Pt as systemEventFilterApplies, Q as TrackSourceSchema, Qt as number, R as NcTaxonomySchema, Rt as errMsg$1, S as MediaFileKindEnum, St as notificationRulesCapability, T as NC_DEFAULT_SNOOZE_MINUTES, Tt as pipelineAnalyticsCapability, Ut as hydrateSchema, V as RECORDING_EXPORT_MAX_READ_BYTES, Vt as DeviceType, W as SCENE_DEFAULT_ANCHOR_THRESHOLD, Wt as isDeviceScopedCap, X as TimelapseRulePatchSchema, Xt as discriminatedUnion, Y as TimelapseRuleInputSchema, Yt as boolean, Z as TimelapseRuleSchema, Zt as literal, _ as LabelAttributionSchema, _t as isDetectionMacroClass, a as CLUSTER_MODEL_SCOPED_STEPS, at as buildEventKindDescriptor, b as MAX_BIRTH_DECISION_RECORDS, bt as kebabToCamel, ct as defineCustomActions, dt as encodeVectorBase64, en as partialRecord, et as addonWidgetsSourceCapability, f as DeclaredDevices, ft as evaluateSensorEdge, g as FailureCounters, h as FULL_IMAGE_BBOX, ht as failureContributionCapability, i as BirthDecisionRecordSchema, in as EventCategory, it as audioModeOf, j as NcRuleSchema, jt as sceneMonitorCapability, k as NcRuleInputSchema, kt as resolveLocationMode, lt as deriveRecordingMode, m as EVENT_PAD_MS, mt as faceGalleryCapability, n as ArchivedDebugNoteSchema, nn as string, nt as assertTimelapseCadences, o as COCO_TO_MACRO, ot as cosineSimilarity$1, p as EVENT_KIND_BY_CAP, pt as evictionPolicyOfLocation, q as SceneMonitorSchema, qt as _enum, r as BaseDevice, rn as unknown, rt as audioMetricsCapability, s as DEFAULT_EVENT_COLOR, st as customAction, t as AUDIO_MACRO_LABELS, tn as record, tt as alarmPanelCapability, u as DETECTION_MACRO_CLASSES, v as MACRO_LABELS, vt as isScheduleActive, w as NC_CONDITION_CATALOG, wt as pickClusterStepModels, xt as mayWriteToLocation, y as MAX_ARCHIVED_DEBUG_NOTES, yt as isSourceCap, z as OpsLogEntrySchema, zt as BaseAddon } from "../dist-
|
|
1
|
+
import { $ as VISIT_MERGE_GAP_MS, $t as object, A as NcRulePatchSchema, Bt as CamProfileSchema, C as NC_ALARM_SYSTEM_EVENT_KINDS, D as NC_TAXONOMY, Dt as readDeviceStateFrom, Et as plateGalleryCapability, F as NcSnoozeSchema, Ft as vectorDimFromBase64, G as SCENE_DEFAULT_UNCOVERED_POLICY, Gt as nodePin, H as RetrainStatusSchema, Ht as createEvent, I as NcSnoozeSuppressedSchema, It as videoclipsCapability, J as TIMELAPSE_DENSE_FLOOR_SEC, Jt as array, K as SCENE_DIVERGED, Kt as sleep$1, L as NcSystemEventKindSchema, Lt as zoneAnalyticsCapability, M as NcRuleTargetSchema, Mt as storageOccupancyCapability, N as NcScheduleSchema, Nt as subKindsOf, O as NcConditionDescriptorSchema, Ot as readTimelapseGeneratedAt, P as NcSnoozeInputSchema, Pt as systemEventFilterApplies, Q as TrackSourceSchema, Qt as number, R as NcTaxonomySchema, Rt as errMsg$1, S as MediaFileKindEnum, St as notificationRulesCapability, T as NC_DEFAULT_SNOOZE_MINUTES, Tt as pipelineAnalyticsCapability, Ut as hydrateSchema, V as RECORDING_EXPORT_MAX_READ_BYTES, Vt as DeviceType, W as SCENE_DEFAULT_ANCHOR_THRESHOLD, Wt as isDeviceScopedCap, X as TimelapseRulePatchSchema, Xt as discriminatedUnion, Y as TimelapseRuleInputSchema, Yt as boolean, Z as TimelapseRuleSchema, Zt as literal, _ as LabelAttributionSchema, _t as isDetectionMacroClass, a as CLUSTER_MODEL_SCOPED_STEPS, at as buildEventKindDescriptor, b as MAX_BIRTH_DECISION_RECORDS, bt as kebabToCamel, ct as defineCustomActions, dt as encodeVectorBase64, en as partialRecord, et as addonWidgetsSourceCapability, f as DeclaredDevices, ft as evaluateSensorEdge, g as FailureCounters, h as FULL_IMAGE_BBOX, ht as failureContributionCapability, i as BirthDecisionRecordSchema, in as EventCategory, it as audioModeOf, j as NcRuleSchema, jt as sceneMonitorCapability, k as NcRuleInputSchema, kt as resolveLocationMode, lt as deriveRecordingMode, m as EVENT_PAD_MS, mt as faceGalleryCapability, n as ArchivedDebugNoteSchema, nn as string, nt as assertTimelapseCadences, o as COCO_TO_MACRO, ot as cosineSimilarity$1, p as EVENT_KIND_BY_CAP, pt as evictionPolicyOfLocation, q as SceneMonitorSchema, qt as _enum, r as BaseDevice, rn as unknown, rt as audioMetricsCapability, s as DEFAULT_EVENT_COLOR, st as customAction, t as AUDIO_MACRO_LABELS, tn as record, tt as alarmPanelCapability, u as DETECTION_MACRO_CLASSES, v as MACRO_LABELS, vt as isScheduleActive, w as NC_CONDITION_CATALOG, wt as pickClusterStepModels, xt as mayWriteToLocation, y as MAX_ARCHIVED_DEBUG_NOTES, yt as isSourceCap, z as OpsLogEntrySchema, zt as BaseAddon } from "../dist-DWZqNymj.mjs";
|
|
2
2
|
import { t as __exportAll } from "../embedding-encoder/index.mjs";
|
|
3
3
|
import * as fs from "node:fs";
|
|
4
4
|
import { promises } from "node:fs";
|
|
@@ -14914,7 +14914,7 @@ function buildOccupancyStatus(input) {
|
|
|
14914
14914
|
* `this.byId.clear()` happened to sit AFTER the `await` that threw. Nothing
|
|
14915
14915
|
* said so, and hoisting one line would have silently turned every transient
|
|
14916
14916
|
* store error into a hub that stops notifying — the reversal behind the D130
|
|
14917
|
-
* flood and the
|
|
14917
|
+
* flood and the occupancy cold-seed loss. The ledger's contract
|
|
14918
14918
|
* rule 2 (a failed load NEVER clears the mirror, deliberately no knob) makes
|
|
14919
14919
|
* that reversal unexpressible here. `rule-store-load-failure-direction.spec.ts`
|
|
14920
14920
|
* holds the direction and records what was removed to make it red.
|
|
@@ -18131,7 +18131,7 @@ function clockOf$2(atMs) {
|
|
|
18131
18131
|
*
|
|
18132
18132
|
* ## The `.partial()` trap this file exists to avoid
|
|
18133
18133
|
*
|
|
18134
|
-
*
|
|
18134
|
+
* Found in production 2026-08-12: `NcRulePatchSchema` was
|
|
18135
18135
|
* `NcRuleInputSchema.partial()`, and Zod 4 `.partial()` KEEPS the inner
|
|
18136
18136
|
* `.default()`. Parsing `{ name: 'x' }` therefore materialised every defaulted
|
|
18137
18137
|
* key, and `{ ...existing, ...patch }` wrote them over the rule — a camera- and
|
|
@@ -34881,6 +34881,8 @@ var SortTracker = class SortTracker {
|
|
|
34881
34881
|
refusalSampler = new SpawnRefusalSampler();
|
|
34882
34882
|
/** Sink for dropped-detection diagnostics — see {@link setSpawnRefusalObserver}. */
|
|
34883
34883
|
spawnRefusalObserver = null;
|
|
34884
|
+
/** Unsampled copy for the frame path — see `setSpawnRefusalSink`. */
|
|
34885
|
+
refusalSink = null;
|
|
34884
34886
|
/** Per-reason counters behind the sampled spawn-beside-coasting diagnostics. */
|
|
34885
34887
|
spawnBesideSampler = new SpawnBesideCoastingSampler();
|
|
34886
34888
|
/** Sink for fragmentation diagnostics — see {@link setSpawnBesideCoastingObserver}. */
|
|
@@ -34993,11 +34995,7 @@ var SortTracker = class SortTracker {
|
|
|
34993
34995
|
}
|
|
34994
34996
|
/** Emit one dropped-detection record, subject to the refusal sampler. */
|
|
34995
34997
|
reportRefusal(reason, det, extra = {}) {
|
|
34996
|
-
const
|
|
34997
|
-
if (!observer) return;
|
|
34998
|
-
const refusalCount = this.refusalSampler.next(reason);
|
|
34999
|
-
if (refusalCount === void 0) return;
|
|
35000
|
-
observer({
|
|
34998
|
+
const base = {
|
|
35001
34999
|
reason,
|
|
35002
35000
|
detClass: det.class,
|
|
35003
35001
|
detScore: det.score,
|
|
@@ -35009,13 +35007,31 @@ var SortTracker = class SortTracker {
|
|
|
35009
35007
|
againstTrackId: extra.against.id,
|
|
35010
35008
|
againstTrackClass: extra.against.class
|
|
35011
35009
|
} : {},
|
|
35012
|
-
refusalCount,
|
|
35013
|
-
sampledEvery: 10,
|
|
35014
35010
|
...extra.droppedTrackId !== void 0 ? { droppedTrackId: extra.droppedTrackId } : {},
|
|
35015
35011
|
...extra.trackLifeMs !== void 0 ? { trackLifeMs: extra.trackLifeMs } : {}
|
|
35012
|
+
};
|
|
35013
|
+
this.refusalSink?.(base);
|
|
35014
|
+
const observer = this.spawnRefusalObserver;
|
|
35015
|
+
if (!observer) return;
|
|
35016
|
+
const refusalCount = this.refusalSampler.next(reason);
|
|
35017
|
+
if (refusalCount === void 0) return;
|
|
35018
|
+
observer({
|
|
35019
|
+
...base,
|
|
35020
|
+
refusalCount,
|
|
35021
|
+
sampledEvery: 10
|
|
35016
35022
|
});
|
|
35017
35023
|
}
|
|
35018
35024
|
/**
|
|
35025
|
+
* Wire the UNSAMPLED refusal sink — the frame path's copy.
|
|
35026
|
+
*
|
|
35027
|
+
* Separate from {@link setSpawnRefusalObserver} because the two want
|
|
35028
|
+
* different things from the same record: the observer wants a readable log
|
|
35029
|
+
* and accepts a sample; this decides whether an EVENT exists.
|
|
35030
|
+
*/
|
|
35031
|
+
setSpawnRefusalSink(sink) {
|
|
35032
|
+
this.refusalSink = sink;
|
|
35033
|
+
}
|
|
35034
|
+
/**
|
|
35019
35035
|
* Report a TRACK that ends having emitted nothing — the last silent branch
|
|
35020
35036
|
* on the detection→position path (D391).
|
|
35021
35037
|
*
|
|
@@ -36109,6 +36125,20 @@ var FrameProcessor = class {
|
|
|
36109
36125
|
/** Sink + sampler for the drops this stage owns (the detection-stage zone
|
|
36110
36126
|
* filter). Shares the tracker's vocabulary — see {@link SpawnRefusalReason}. */
|
|
36111
36127
|
spawnRefusalObserver = null;
|
|
36128
|
+
/** Where a collected refusal is forwarded for LOGGING, when anyone asked. */
|
|
36129
|
+
spawnRefusalForward = null;
|
|
36130
|
+
/**
|
|
36131
|
+
* The spawn refusals of the frame being processed.
|
|
36132
|
+
*
|
|
36133
|
+
* Filled by the same sink that feeds the diagnostic log, and drained at the
|
|
36134
|
+
* end of `process`. It exists because a refused detection inside a watched
|
|
36135
|
+
* zone still has to become an EVENT: an immediate zone rule asks "is there an
|
|
36136
|
+
* animal in the flowerbed now?", which does not need "is it the same animal
|
|
36137
|
+
* as before?" answered first. See `zone-detection-emits-without-a-track`.
|
|
36138
|
+
*/
|
|
36139
|
+
refusalsThisFrame = [];
|
|
36140
|
+
/** Running count of events this path has produced — the volume measure. */
|
|
36141
|
+
zoneRefusalEventCount = 0;
|
|
36112
36142
|
zoneRefusalSampler = new SpawnRefusalSampler();
|
|
36113
36143
|
/** Optional stationary-object gate (parked-object suppression). Null until
|
|
36114
36144
|
* the addon wires it via {@link setStationaryGate}. */
|
|
@@ -36123,6 +36153,9 @@ var FrameProcessor = class {
|
|
|
36123
36153
|
this.deviceId = deviceId;
|
|
36124
36154
|
this.source = source;
|
|
36125
36155
|
this.tracker = new SortTracker(trackerConfig);
|
|
36156
|
+
this.tracker.setSpawnRefusalSink((record) => {
|
|
36157
|
+
this.refusalsThisFrame.push(record);
|
|
36158
|
+
});
|
|
36126
36159
|
this.stateAnalyzer = new StateAnalyzer(stateConfig);
|
|
36127
36160
|
this.eventEmitter = new DetectionEventEmitter(emitterConfig);
|
|
36128
36161
|
this.zones = [];
|
|
@@ -36229,6 +36262,55 @@ var FrameProcessor = class {
|
|
|
36229
36262
|
* ate it. Sampled like every other refusal: an excluded box is excluded on
|
|
36230
36263
|
* every frame of a passage.
|
|
36231
36264
|
*/
|
|
36265
|
+
/**
|
|
36266
|
+
* Turn this frame's refused spawns into events, but only those inside a zone.
|
|
36267
|
+
*
|
|
36268
|
+
* Drains {@link refusalsThisFrame}. Each surviving record becomes an
|
|
36269
|
+
* `object.detected` event with NO track — carrying the zones it fell in, the
|
|
36270
|
+
* percentage of the box inside each, and the refusal reason so a consumer can
|
|
36271
|
+
* tell it apart from a track whose media went missing.
|
|
36272
|
+
*
|
|
36273
|
+
* `zone-filtered` refusals are excluded on purpose: that reason means the
|
|
36274
|
+
* operator's own detection rules already said the box does not count on this
|
|
36275
|
+
* camera, and re-admitting it here would overrule a decision they made.
|
|
36276
|
+
*/
|
|
36277
|
+
eventsForRefusedDetectionsInZones(timestamp, frame, frameWidth, frameHeight) {
|
|
36278
|
+
const refusals = this.refusalsThisFrame;
|
|
36279
|
+
this.refusalsThisFrame = [];
|
|
36280
|
+
if (refusals.length === 0 || this.zones.length === 0) return [];
|
|
36281
|
+
const out = [];
|
|
36282
|
+
for (const r of refusals) {
|
|
36283
|
+
if (r.reason === "zone-filtered") continue;
|
|
36284
|
+
const { memberships } = this.zoneEngine.splitDetectionZones(r.bbox, this.zones, frameWidth, frameHeight, void 0, void 0, void 0, this.zoneMembershipMinOverlap);
|
|
36285
|
+
if (memberships.length === 0) continue;
|
|
36286
|
+
this.zoneRefusalEventCount += 1;
|
|
36287
|
+
out.push({
|
|
36288
|
+
id: randomUUID(),
|
|
36289
|
+
kind: "object",
|
|
36290
|
+
deviceId: this.deviceId,
|
|
36291
|
+
timestamp,
|
|
36292
|
+
frameId: frame.frameId,
|
|
36293
|
+
className: r.detClass,
|
|
36294
|
+
confidence: r.detScore,
|
|
36295
|
+
bbox: r.bbox,
|
|
36296
|
+
frameWidth,
|
|
36297
|
+
frameHeight,
|
|
36298
|
+
zones: memberships.map((m) => m.zoneId),
|
|
36299
|
+
zoneOverlaps: memberships.map((m) => ({
|
|
36300
|
+
zoneId: m.zoneId,
|
|
36301
|
+
...m.zoneName === void 0 ? {} : { zoneName: m.zoneName },
|
|
36302
|
+
overlapPct: Math.round(m.overlap * 1e3) / 10
|
|
36303
|
+
})),
|
|
36304
|
+
spawnRefused: r.reason
|
|
36305
|
+
});
|
|
36306
|
+
}
|
|
36307
|
+
return out;
|
|
36308
|
+
}
|
|
36309
|
+
/** How many zone-refusal events this processor has emitted — the measure that
|
|
36310
|
+
* says whether this path is a trickle or a storm. Read by the addon. */
|
|
36311
|
+
zoneRefusalEventsEmitted() {
|
|
36312
|
+
return this.zoneRefusalEventCount;
|
|
36313
|
+
}
|
|
36232
36314
|
reportZoneFiltered(excluded) {
|
|
36233
36315
|
const observer = this.spawnRefusalObserver;
|
|
36234
36316
|
if (!observer || excluded.length === 0) return;
|
|
@@ -36630,9 +36712,11 @@ var FrameProcessor = class {
|
|
|
36630
36712
|
frameHeight
|
|
36631
36713
|
};
|
|
36632
36714
|
};
|
|
36715
|
+
const zoneRefusalEvents = this.eventsForRefusedDetectionsInZones(timestamp, frame, frameWidth, frameHeight);
|
|
36633
36716
|
const withTrackId = rawEvents.filter((e) => e.detection.trackId);
|
|
36634
36717
|
const objectEvents = withTrackId.filter((e) => e.type !== "object.detected").map((e) => toObjectEvent(e));
|
|
36635
36718
|
const appearanceEvents = withTrackId.filter((e) => e.type === "object.detected").map((e) => toObjectEvent(e, "entered"));
|
|
36719
|
+
objectEvents.push(...zoneRefusalEvents);
|
|
36636
36720
|
return {
|
|
36637
36721
|
deviceId: this.deviceId,
|
|
36638
36722
|
timestamp,
|
|
@@ -47246,6 +47330,7 @@ var TrackDetailDispatcher = class {
|
|
|
47246
47330
|
if (!dev) return;
|
|
47247
47331
|
dev.scheduler.onTrackEnded(trackId);
|
|
47248
47332
|
dev.tracks.delete(trackId);
|
|
47333
|
+
dev.parcelEnriched.delete(trackId);
|
|
47249
47334
|
dev.candidateBest.delete(trackId);
|
|
47250
47335
|
if (dev.tracks.size === 0) this.clearTimer(dev);
|
|
47251
47336
|
}
|
|
@@ -47255,6 +47340,7 @@ var TrackDetailDispatcher = class {
|
|
|
47255
47340
|
this.clearTimer(dev);
|
|
47256
47341
|
dev.queue.length = 0;
|
|
47257
47342
|
dev.tracks.clear();
|
|
47343
|
+
dev.parcelEnriched.clear();
|
|
47258
47344
|
dev.candidateBest.clear();
|
|
47259
47345
|
}
|
|
47260
47346
|
this.devices.clear();
|
|
@@ -47265,6 +47351,7 @@ var TrackDetailDispatcher = class {
|
|
|
47265
47351
|
dev = {
|
|
47266
47352
|
scheduler: new DetailScheduler(),
|
|
47267
47353
|
tracks: /* @__PURE__ */ new Map(),
|
|
47354
|
+
parcelEnriched: /* @__PURE__ */ new Map(),
|
|
47268
47355
|
candidateBest: new BestDetectionTracker(CANDIDATE_IMPROVE_POLICY),
|
|
47269
47356
|
queue: [],
|
|
47270
47357
|
coastedFramesIgnored: 0,
|
|
@@ -47381,19 +47468,21 @@ var TrackDetailDispatcher = class {
|
|
|
47381
47468
|
*
|
|
47382
47469
|
* 1. `frameHandle` — cheapest when it hits: no payload moves and the runner's
|
|
47383
47470
|
* leaf children re-cut their ROI at native resolution. Tried first, always.
|
|
47384
|
-
* 2. `frameJpeg` — the
|
|
47385
|
-
*
|
|
47386
|
-
*
|
|
47387
|
-
*
|
|
47388
|
-
*
|
|
47389
|
-
* the
|
|
47471
|
+
* 2. `frameJpeg` — the track's PARKED key frame (D422): the full native frame
|
|
47472
|
+
* the owning node copied at the best instant, retrieved by track and handed
|
|
47473
|
+
* to the runner UNCUT, so the rectangle still comes from the single
|
|
47474
|
+
* derivation (D52). This rung exists because rung 1 is structurally
|
|
47475
|
+
* unreachable for most dispatches — a tick + inference routinely lands
|
|
47476
|
+
* outside the lease — and it cannot miss on age. It runs ONCE per parcel
|
|
47477
|
+
* per step; a dispatch that finds the same parcel already enriched skips
|
|
47478
|
+
* it, so a coasting track does not re-embed the same image every second.
|
|
47390
47479
|
* 3. `cropJpeg` — the pre-cut tile. Last, because the caller decided its
|
|
47391
47480
|
* rectangle and because in practice the same native miss that emptied rung 1
|
|
47392
47481
|
* empties this one too.
|
|
47393
47482
|
*
|
|
47394
|
-
* On D9/D18: the payload that crosses in rung 2 is a COMPRESSED JPEG
|
|
47395
|
-
* demand, per TRACK per dispatch (≤2 in flight per device, ~1 Hz) and only
|
|
47396
|
-
* rung 1 missed — never a frame-rate stream, and never raw pixels.
|
|
47483
|
+
* On D9/D18: the payload that crosses in rung 2 is a COMPRESSED JPEG retrieved
|
|
47484
|
+
* on demand, per TRACK per dispatch (≤2 in flight per device, ~1 Hz) and only
|
|
47485
|
+
* after rung 1 missed — never a frame-rate stream, and never raw pixels.
|
|
47397
47486
|
*
|
|
47398
47487
|
* ONE outcome stops the ladder cold: the runner's typed `not-attached`
|
|
47399
47488
|
* refusal (`detail-refusal.ts`). It names the camera's SESSION state, not
|
|
@@ -47431,34 +47520,39 @@ var TrackDetailDispatcher = class {
|
|
|
47431
47520
|
}
|
|
47432
47521
|
});
|
|
47433
47522
|
}
|
|
47434
|
-
if (this.deps.
|
|
47435
|
-
const
|
|
47436
|
-
if (
|
|
47523
|
+
if (this.deps.captureParkedFrame !== void 0) try {
|
|
47524
|
+
const parked = await this.deps.captureParkedFrame(deviceId, req.trackId);
|
|
47525
|
+
if (parked !== null) if (dev.parcelEnriched.get(req.trackId)?.get(req.stepId) === parked.timestamp) this.deps.logger.debug("detail parcel already enriched for this step — skipping", {
|
|
47437
47526
|
tags: { deviceId },
|
|
47438
47527
|
meta: {
|
|
47439
47528
|
trackId: req.trackId,
|
|
47440
47529
|
stepId: req.stepId,
|
|
47441
|
-
|
|
47442
|
-
frameHeight: full.height,
|
|
47443
|
-
bboxFrameWidth: frame.frameWidth,
|
|
47444
|
-
bboxFrameHeight: frame.frameHeight
|
|
47530
|
+
parkedTimestamp: parked.timestamp
|
|
47445
47531
|
}
|
|
47446
47532
|
});
|
|
47447
47533
|
else {
|
|
47448
47534
|
const derived = await this.deps.runDetailSubtree({
|
|
47449
47535
|
deviceId,
|
|
47450
|
-
frameJpeg:
|
|
47451
|
-
parent
|
|
47536
|
+
frameJpeg: parked.base64,
|
|
47537
|
+
parent: {
|
|
47538
|
+
bbox: { ...parked.bbox },
|
|
47539
|
+
className: frame.className
|
|
47540
|
+
},
|
|
47452
47541
|
steps
|
|
47453
|
-
},
|
|
47454
|
-
if (derived !== null)
|
|
47542
|
+
}, parked.nodeId);
|
|
47543
|
+
if (derived !== null) {
|
|
47544
|
+
const perStep = dev.parcelEnriched.get(req.trackId) ?? /* @__PURE__ */ new Map();
|
|
47545
|
+
perStep.set(req.stepId, parked.timestamp);
|
|
47546
|
+
dev.parcelEnriched.set(req.trackId, perStep);
|
|
47547
|
+
return derived.details;
|
|
47548
|
+
}
|
|
47455
47549
|
}
|
|
47456
47550
|
} catch (err) {
|
|
47457
47551
|
if (isDetailNotAttachedRefusal(err)) {
|
|
47458
47552
|
this.warnNotAttachedThrottled(deviceId, dev, req);
|
|
47459
47553
|
return null;
|
|
47460
47554
|
}
|
|
47461
|
-
this.deps.logger.debug("detail
|
|
47555
|
+
this.deps.logger.debug("detail parked-frame rung failed", {
|
|
47462
47556
|
tags: { deviceId },
|
|
47463
47557
|
meta: {
|
|
47464
47558
|
trackId: req.trackId,
|
|
@@ -47525,7 +47619,7 @@ var TrackDetailDispatcher = class {
|
|
|
47525
47619
|
trackId: req.trackId,
|
|
47526
47620
|
stepId: req.stepId,
|
|
47527
47621
|
reason: req.reason,
|
|
47528
|
-
|
|
47622
|
+
triedParkedFrame: this.deps.captureParkedFrame !== void 0,
|
|
47529
47623
|
triedCropJpeg: this.deps.captureCropBase64 !== void 0
|
|
47530
47624
|
}
|
|
47531
47625
|
});
|
|
@@ -53890,6 +53984,17 @@ async function encodeKeyFrameVariants(native) {
|
|
|
53890
53984
|
})
|
|
53891
53985
|
};
|
|
53892
53986
|
}
|
|
53987
|
+
/**
|
|
53988
|
+
* The web companion from the PARKED key frame's own JPEG (D422): the parcel is
|
|
53989
|
+
* stored verbatim as `keyFrame`, and `keyFrameSmall` is this — the same bytes
|
|
53990
|
+
* downscaled to {@link KEYFRAME_SMALL_MAX_WIDTH}. One decode, one encode,
|
|
53991
|
+
* never a second fetch; `withoutEnlargement` never upscales a sub-960 frame.
|
|
53992
|
+
* The by-handle twin ({@link encodeKeyFrameVariants}) remains for the
|
|
53993
|
+
* summary group shot, which still fetches a native surface by handle.
|
|
53994
|
+
*/
|
|
53995
|
+
async function deriveKeyFrameSmall(keyFrameJpeg) {
|
|
53996
|
+
return sharp(keyFrameJpeg).resize(960, null, { withoutEnlargement: true }).jpeg({ quality: 88 }).toBuffer();
|
|
53997
|
+
}
|
|
53893
53998
|
//#endregion
|
|
53894
53999
|
//#region src/pipeline-analytics/pipeline/key-frame-metrics.ts
|
|
53895
54000
|
var DEFAULT_FLUSH_INTERVAL_MS = 6e4;
|
|
@@ -53915,11 +54020,8 @@ var KeyFrameCaptureLog = class {
|
|
|
53915
54020
|
w.landed += 1;
|
|
53916
54021
|
if (sample.retry) w.retryLanded += 1;
|
|
53917
54022
|
break;
|
|
53918
|
-
case "
|
|
53919
|
-
w.
|
|
53920
|
-
break;
|
|
53921
|
-
case "ram-tier":
|
|
53922
|
-
w.ramTier += 1;
|
|
54023
|
+
case "parcel-missing":
|
|
54024
|
+
w.parcelMissing += 1;
|
|
53923
54025
|
break;
|
|
53924
54026
|
case "error":
|
|
53925
54027
|
w.error += 1;
|
|
@@ -53948,8 +54050,7 @@ var KeyFrameCaptureLog = class {
|
|
|
53948
54050
|
landed: 0,
|
|
53949
54051
|
retryAttempts: 0,
|
|
53950
54052
|
retryLanded: 0,
|
|
53951
|
-
|
|
53952
|
-
ramTier: 0,
|
|
54053
|
+
parcelMissing: 0,
|
|
53953
54054
|
error: 0,
|
|
53954
54055
|
skippedNodeOffline: 0
|
|
53955
54056
|
};
|
|
@@ -53964,8 +54065,7 @@ var KeyFrameCaptureLog = class {
|
|
|
53964
54065
|
landed: w.landed,
|
|
53965
54066
|
retryAttempts: w.retryAttempts,
|
|
53966
54067
|
retryLanded: w.retryLanded,
|
|
53967
|
-
|
|
53968
|
-
ramTier: w.ramTier,
|
|
54068
|
+
parcelMissing: w.parcelMissing,
|
|
53969
54069
|
error: w.error,
|
|
53970
54070
|
skippedNodeOffline: w.skippedNodeOffline
|
|
53971
54071
|
};
|
|
@@ -53974,63 +54074,44 @@ var KeyFrameCaptureLog = class {
|
|
|
53974
54074
|
//#endregion
|
|
53975
54075
|
//#region src/pipeline-analytics/pipeline/key-frame-persist.ts
|
|
53976
54076
|
/**
|
|
53977
|
-
*
|
|
54077
|
+
* Read, derive and store one track's key frame + its web companion.
|
|
53978
54078
|
*
|
|
53979
|
-
*
|
|
53980
|
-
*
|
|
53981
|
-
* outcome carries — a `keyFrameSmall` failure afterwards must not re-arm a
|
|
54079
|
+
* PARCEL-OR-NOTHING: no parcel writes nothing and the caller's bounded retry
|
|
54080
|
+
* parks a later frame. The `keyFrame` write lands FIRST and its key is what
|
|
54081
|
+
* the outcome carries — a `keyFrameSmall` failure afterwards must not re-arm a
|
|
53982
54082
|
* retry that would re-shoot a key frame the rebuild can already read.
|
|
53983
54083
|
*/
|
|
53984
54084
|
async function persistTrackKeyFrame(deps, input) {
|
|
53985
|
-
const { deviceId, trackId,
|
|
54085
|
+
const { deviceId, trackId, retry } = input;
|
|
53986
54086
|
const drop = {
|
|
53987
54087
|
tags: { deviceId },
|
|
53988
54088
|
meta: {
|
|
53989
54089
|
trackId,
|
|
53990
|
-
nodeId: frameHandle.nodeId,
|
|
53991
54090
|
retry
|
|
53992
54091
|
}
|
|
53993
54092
|
};
|
|
53994
54093
|
try {
|
|
53995
|
-
const
|
|
53996
|
-
|
|
53997
|
-
|
|
53998
|
-
|
|
53999
|
-
...drop,
|
|
54000
|
-
meta: {
|
|
54001
|
-
...drop.meta,
|
|
54002
|
-
shmId: frameHandle.shmId
|
|
54003
|
-
}
|
|
54004
|
-
});
|
|
54005
|
-
return { kind: "native-miss" };
|
|
54006
|
-
}
|
|
54007
|
-
if (!keyFrameAcceptsTier(result.tier)) {
|
|
54008
|
-
deps.logger.warn("keyFrame native miss — RAM tier rejected, will retry while budget remains", {
|
|
54009
|
-
...drop,
|
|
54010
|
-
meta: {
|
|
54011
|
-
...drop.meta,
|
|
54012
|
-
shmId: frameHandle.shmId,
|
|
54013
|
-
tier: result.tier
|
|
54014
|
-
}
|
|
54015
|
-
});
|
|
54016
|
-
return { kind: "ram-tier" };
|
|
54094
|
+
const parcel = await deps.fetchParkedKeyFrame(deviceId, trackId);
|
|
54095
|
+
if (parcel === null || parcel.jpeg.byteLength === 0) {
|
|
54096
|
+
deps.logger.error("key-frame parcel missing — nothing to write, retry parks a later frame", { ...drop });
|
|
54097
|
+
return { kind: "parcel-missing" };
|
|
54017
54098
|
}
|
|
54018
|
-
const { keyFrame, keyFrameSmall } = await deps.encodeVariants(native);
|
|
54019
54099
|
const keyFrameKey = await deps.media.putReplacing({
|
|
54020
54100
|
deviceId,
|
|
54021
54101
|
ownerKind: "track",
|
|
54022
54102
|
ownerId: trackId,
|
|
54023
54103
|
kind: "keyFrame",
|
|
54024
|
-
timestamp:
|
|
54025
|
-
data:
|
|
54104
|
+
timestamp: parcel.timestamp,
|
|
54105
|
+
data: parcel.jpeg
|
|
54026
54106
|
});
|
|
54027
54107
|
try {
|
|
54108
|
+
const keyFrameSmall = await deps.deriveSmall(parcel.jpeg);
|
|
54028
54109
|
await deps.media.putReplacing({
|
|
54029
54110
|
deviceId,
|
|
54030
54111
|
ownerKind: "track",
|
|
54031
54112
|
ownerId: trackId,
|
|
54032
54113
|
kind: "keyFrameSmall",
|
|
54033
|
-
timestamp:
|
|
54114
|
+
timestamp: parcel.timestamp,
|
|
54034
54115
|
data: keyFrameSmall
|
|
54035
54116
|
});
|
|
54036
54117
|
} catch (err) {
|
|
@@ -54038,17 +54119,29 @@ async function persistTrackKeyFrame(deps, input) {
|
|
|
54038
54119
|
...drop,
|
|
54039
54120
|
meta: {
|
|
54040
54121
|
...drop.meta,
|
|
54122
|
+
nodeId: parcel.nodeId,
|
|
54041
54123
|
error: errMsg$1(err)
|
|
54042
54124
|
}
|
|
54043
54125
|
});
|
|
54044
54126
|
}
|
|
54127
|
+
deps.logger.debug("key frame written from the parked parcel", {
|
|
54128
|
+
...drop,
|
|
54129
|
+
meta: {
|
|
54130
|
+
...drop.meta,
|
|
54131
|
+
nodeId: parcel.nodeId,
|
|
54132
|
+
width: parcel.width,
|
|
54133
|
+
height: parcel.height,
|
|
54134
|
+
bytes: parcel.jpeg.byteLength,
|
|
54135
|
+
parkedTimestamp: parcel.timestamp
|
|
54136
|
+
}
|
|
54137
|
+
});
|
|
54045
54138
|
return {
|
|
54046
54139
|
kind: "landed",
|
|
54047
54140
|
keyFrameKey
|
|
54048
54141
|
};
|
|
54049
54142
|
} catch (err) {
|
|
54050
54143
|
const error = errMsg$1(err);
|
|
54051
|
-
deps.logger.warn("key-frame
|
|
54144
|
+
deps.logger.warn("key-frame write failed", {
|
|
54052
54145
|
...drop,
|
|
54053
54146
|
meta: {
|
|
54054
54147
|
...drop.meta,
|
|
@@ -54235,6 +54328,61 @@ function createKeyFrameCrop(deps) {
|
|
|
54235
54328
|
};
|
|
54236
54329
|
}
|
|
54237
54330
|
//#endregion
|
|
54331
|
+
//#region src/pipeline-analytics/pipeline/track-park.ts
|
|
54332
|
+
/** The whole frame — what a `keyFrame` park cuts. */
|
|
54333
|
+
var FULL_FRAME = {
|
|
54334
|
+
x: 0,
|
|
54335
|
+
y: 0,
|
|
54336
|
+
w: 1,
|
|
54337
|
+
h: 1
|
|
54338
|
+
};
|
|
54339
|
+
/** The two parcels a best-frame decision orders, in a fixed order. */
|
|
54340
|
+
function buildParkOrders(decision) {
|
|
54341
|
+
const subject = {
|
|
54342
|
+
bbox: { ...decision.bbox },
|
|
54343
|
+
frameWidth: decision.frameWidth,
|
|
54344
|
+
frameHeight: decision.frameHeight
|
|
54345
|
+
};
|
|
54346
|
+
const layout = deliveredWideCentralSquareLayout(decision.bbox, {
|
|
54347
|
+
W: decision.frameWidth,
|
|
54348
|
+
H: decision.frameHeight
|
|
54349
|
+
});
|
|
54350
|
+
const base = {
|
|
54351
|
+
deviceId: decision.deviceId,
|
|
54352
|
+
trackId: decision.trackId,
|
|
54353
|
+
handle: decision.frameHandle,
|
|
54354
|
+
timestamp: decision.timestamp,
|
|
54355
|
+
subject
|
|
54356
|
+
};
|
|
54357
|
+
return [{
|
|
54358
|
+
...base,
|
|
54359
|
+
kind: "keyFrame",
|
|
54360
|
+
bbox: FULL_FRAME,
|
|
54361
|
+
maxWidth: KEYFRAME_NATIVE_MAX_WIDTH
|
|
54362
|
+
}, {
|
|
54363
|
+
...base,
|
|
54364
|
+
kind: "thumbnail",
|
|
54365
|
+
bbox: layout.fetch,
|
|
54366
|
+
layout
|
|
54367
|
+
}];
|
|
54368
|
+
}
|
|
54369
|
+
/**
|
|
54370
|
+
* The subject's box in the PARCEL's pixel space. The box was measured on the
|
|
54371
|
+
* ≤640 detection raster; the parcel is native-resolution. Both show the same
|
|
54372
|
+
* scene at the same aspect, so a uniform per-axis scale places the box on the
|
|
54373
|
+
* parcel — the runner then derives the crop rectangle from it (D52).
|
|
54374
|
+
*/
|
|
54375
|
+
function scaleSubjectIntoParcel(subject, parcelWidth, parcelHeight) {
|
|
54376
|
+
const sx = parcelWidth / subject.frameWidth;
|
|
54377
|
+
const sy = parcelHeight / subject.frameHeight;
|
|
54378
|
+
return {
|
|
54379
|
+
x: subject.bbox.x * sx,
|
|
54380
|
+
y: subject.bbox.y * sy,
|
|
54381
|
+
w: subject.bbox.w * sx,
|
|
54382
|
+
h: subject.bbox.h * sy
|
|
54383
|
+
};
|
|
54384
|
+
}
|
|
54385
|
+
//#endregion
|
|
54238
54386
|
//#region src/pipeline-analytics/pipeline/native-detection.ts
|
|
54239
54387
|
/**
|
|
54240
54388
|
* Nominal frame size used to denormalize native `[0,1]` boxes when a
|
|
@@ -58765,7 +58913,28 @@ async function reconcileGallerySamples(deps, options) {
|
|
|
58765
58913
|
}
|
|
58766
58914
|
//#endregion
|
|
58767
58915
|
//#region src/pipeline-analytics/summary/summary-store.ts
|
|
58916
|
+
/**
|
|
58917
|
+
* @durable class=ledger owner=pipeline-analytics
|
|
58918
|
+
* write="one row per SUMMARY — a window of co-present tracks on one camera
|
|
58919
|
+
* group. Opened by `openOrAbsorb` when the first member arrives, updated
|
|
58920
|
+
* in place while the window absorbs more, and finalised by `seal` when the
|
|
58921
|
+
* window closes. Per WINDOW, never per frame or per track: the sealed
|
|
58922
|
+
* summary is what a notification rule reads."
|
|
58923
|
+
* retention="age-keyed on `sealedAt`, swept with the rest of the analytics
|
|
58924
|
+
* retention. An unsealed row belongs to a window still open and is never
|
|
58925
|
+
* swept by age — it is closed or cascaded away with its members."
|
|
58926
|
+
*/
|
|
58768
58927
|
var SUMMARIES_COLLECTION = "pipeline-analytics:summaries";
|
|
58928
|
+
/**
|
|
58929
|
+
* @durable class=ledger owner=pipeline-analytics
|
|
58930
|
+
* write="one row per (summary, track) membership, written as a window
|
|
58931
|
+
* absorbs a track. The join that lets a sealed summary name its subjects
|
|
58932
|
+
* without re-reading the track store."
|
|
58933
|
+
* retention="cascaded — a member dies with its summary (`delete-track-cascade`
|
|
58934
|
+
* counts them as leaves) or with the track it names. It carries no clock of
|
|
58935
|
+
* its own: an age sweep here could outlive or predecease the summary the
|
|
58936
|
+
* row only means anything inside of."
|
|
58937
|
+
*/
|
|
58769
58938
|
var SUMMARY_MEMBERS_COLLECTION = "pipeline-analytics:summary-members";
|
|
58770
58939
|
var SUMMARIES_COLUMNS = [
|
|
58771
58940
|
{
|
|
@@ -63593,35 +63762,6 @@ function createNativeFrameTransport(deps) {
|
|
|
63593
63762
|
const getRemoteFrame = async (handle) => requestNativeCrop(handle, FULL_FRAME_BBOX, handle.width, replyToFullFrame);
|
|
63594
63763
|
const fetchNativeFullFrameTiered = async (handle, maxWidth) => requestNativeCrop(handle, FULL_FRAME_BBOX, maxWidth, replyToTieredFullFrame);
|
|
63595
63764
|
const getNativeFullFrameRgb = async (handle, maxWidth) => (await fetchNativeFullFrameTiered(handle, maxWidth))?.frame ?? null;
|
|
63596
|
-
const getFullFrameJpegBase64 = async (handle, maxWidth) => {
|
|
63597
|
-
if (!pipelineRunnerApi?.getNativeCrop) return null;
|
|
63598
|
-
try {
|
|
63599
|
-
const full = await pipelineRunnerApi.getNativeCrop.query({
|
|
63600
|
-
handle,
|
|
63601
|
-
bbox: {
|
|
63602
|
-
x: 0,
|
|
63603
|
-
y: 0,
|
|
63604
|
-
w: 1,
|
|
63605
|
-
h: 1
|
|
63606
|
-
},
|
|
63607
|
-
maxWidth,
|
|
63608
|
-
encodeJpeg: true
|
|
63609
|
-
}, nodePin(handle.nodeId));
|
|
63610
|
-
if (!full?.jpeg || full.width <= 0 || full.height <= 0) return null;
|
|
63611
|
-
return {
|
|
63612
|
-
base64: full.jpeg,
|
|
63613
|
-
width: full.width,
|
|
63614
|
-
height: full.height,
|
|
63615
|
-
tier: full.tier === "ram-fullframe" ? "ram-fullframe" : "native"
|
|
63616
|
-
};
|
|
63617
|
-
} catch (err) {
|
|
63618
|
-
logger.debug("full-frame jpeg fetch failed", { meta: {
|
|
63619
|
-
nodeId: handle.nodeId,
|
|
63620
|
-
error: errMsg$1(err)
|
|
63621
|
-
} });
|
|
63622
|
-
return null;
|
|
63623
|
-
}
|
|
63624
|
-
};
|
|
63625
63765
|
const cropMetricLogger = logger.child("NativeCrop");
|
|
63626
63766
|
let nativeHits = 0;
|
|
63627
63767
|
let nativeFallbacks = 0;
|
|
@@ -63701,7 +63841,6 @@ function createNativeFrameTransport(deps) {
|
|
|
63701
63841
|
getRemoteFrame,
|
|
63702
63842
|
getNativeFullFrameRgb,
|
|
63703
63843
|
getNativeKeyFrameRgb: fetchNativeFullFrameTiered,
|
|
63704
|
-
getFullFrameJpegBase64,
|
|
63705
63844
|
getNativeCropJpeg,
|
|
63706
63845
|
captureCrop: createCaptureCrop({
|
|
63707
63846
|
tryNativeCrop,
|
|
@@ -63812,6 +63951,233 @@ function parseTopologySnapshotNodes(data) {
|
|
|
63812
63951
|
return parsed;
|
|
63813
63952
|
}
|
|
63814
63953
|
//#endregion
|
|
63954
|
+
//#region src/pipeline-analytics/runtime/parked-frame-client.ts
|
|
63955
|
+
/**
|
|
63956
|
+
* Bound on the mirror. A track's record leaves at release; this is the
|
|
63957
|
+
* backstop for a lost close. At the busiest measured hub (~12 sessions,
|
|
63958
|
+
* a few tracks each) 4 096 is an hour of tracks, past which the OLDEST record
|
|
63959
|
+
* is forgotten — its parcel still ages out on the node on its own.
|
|
63960
|
+
*/
|
|
63961
|
+
var MAX_MIRRORED_TRACKS = 4096;
|
|
63962
|
+
/** One "runner has no park method" line per camera per minute. */
|
|
63963
|
+
var SKEW_WARN_THROTTLE_MS = 6e4;
|
|
63964
|
+
function inFlightKey(trackId, kind) {
|
|
63965
|
+
return `${trackId} ${kind}`;
|
|
63966
|
+
}
|
|
63967
|
+
/** Strip the hub-side context off an order: only the wire fields travel. */
|
|
63968
|
+
function toWireInput(order) {
|
|
63969
|
+
return {
|
|
63970
|
+
deviceId: order.deviceId,
|
|
63971
|
+
trackId: order.trackId,
|
|
63972
|
+
kind: order.kind,
|
|
63973
|
+
handle: order.handle,
|
|
63974
|
+
bbox: order.bbox,
|
|
63975
|
+
...order.maxWidth !== void 0 ? { maxWidth: order.maxWidth } : {},
|
|
63976
|
+
timestamp: order.timestamp
|
|
63977
|
+
};
|
|
63978
|
+
}
|
|
63979
|
+
function createParkedFrameClient(deps) {
|
|
63980
|
+
const { api, logger } = deps;
|
|
63981
|
+
const now = deps.now ?? Date.now;
|
|
63982
|
+
/** trackId → kind → what the hub kept beside the parcel. */
|
|
63983
|
+
const mirror = /* @__PURE__ */ new Map();
|
|
63984
|
+
const inFlight = /* @__PURE__ */ new Map();
|
|
63985
|
+
const skewWarnedAt = /* @__PURE__ */ new Map();
|
|
63986
|
+
const remember = (order, answer) => {
|
|
63987
|
+
let kinds = mirror.get(order.trackId);
|
|
63988
|
+
if (kinds === void 0) {
|
|
63989
|
+
kinds = /* @__PURE__ */ new Map();
|
|
63990
|
+
mirror.set(order.trackId, kinds);
|
|
63991
|
+
while (mirror.size > MAX_MIRRORED_TRACKS) {
|
|
63992
|
+
const oldest = mirror.keys().next().value;
|
|
63993
|
+
if (oldest === void 0) break;
|
|
63994
|
+
mirror.delete(oldest);
|
|
63995
|
+
}
|
|
63996
|
+
}
|
|
63997
|
+
kinds.set(order.kind, {
|
|
63998
|
+
nodeId: answer.nodeId,
|
|
63999
|
+
deviceId: order.deviceId,
|
|
64000
|
+
kind: order.kind,
|
|
64001
|
+
timestamp: order.timestamp,
|
|
64002
|
+
width: answer.width,
|
|
64003
|
+
height: answer.height,
|
|
64004
|
+
subject: order.subject,
|
|
64005
|
+
...order.layout !== void 0 ? { layout: order.layout } : {}
|
|
64006
|
+
});
|
|
64007
|
+
};
|
|
64008
|
+
const warnSkew = (order) => {
|
|
64009
|
+
const at = skewWarnedAt.get(order.deviceId) ?? 0;
|
|
64010
|
+
if (now() - at < SKEW_WARN_THROTTLE_MS) return;
|
|
64011
|
+
skewWarnedAt.set(order.deviceId, now());
|
|
64012
|
+
logger.warn("track frame park impossible — the runner api has no park method (version skew)", {
|
|
64013
|
+
tags: { deviceId: order.deviceId },
|
|
64014
|
+
meta: {
|
|
64015
|
+
trackId: order.trackId,
|
|
64016
|
+
kind: order.kind,
|
|
64017
|
+
nodeId: order.handle.nodeId
|
|
64018
|
+
}
|
|
64019
|
+
});
|
|
64020
|
+
};
|
|
64021
|
+
const sendPark = async (order) => {
|
|
64022
|
+
if (api === void 0) {
|
|
64023
|
+
warnSkew(order);
|
|
64024
|
+
return false;
|
|
64025
|
+
}
|
|
64026
|
+
if (deps.isNodeOffline?.(order.handle.nodeId) === true) {
|
|
64027
|
+
logger.debug("track frame park skipped — the owning node is offline in the registry", {
|
|
64028
|
+
tags: { deviceId: order.deviceId },
|
|
64029
|
+
meta: {
|
|
64030
|
+
trackId: order.trackId,
|
|
64031
|
+
kind: order.kind,
|
|
64032
|
+
nodeId: order.handle.nodeId
|
|
64033
|
+
}
|
|
64034
|
+
});
|
|
64035
|
+
return false;
|
|
64036
|
+
}
|
|
64037
|
+
const meta = {
|
|
64038
|
+
trackId: order.trackId,
|
|
64039
|
+
kind: order.kind,
|
|
64040
|
+
nodeId: order.handle.nodeId,
|
|
64041
|
+
handle: `${order.handle.shmId}#${order.handle.slot}#${order.handle.seq}`
|
|
64042
|
+
};
|
|
64043
|
+
try {
|
|
64044
|
+
const answer = await api.parkTrackFrame.mutate(toWireInput(order), nodePin(order.handle.nodeId));
|
|
64045
|
+
if (answer.parked) {
|
|
64046
|
+
remember(order, answer);
|
|
64047
|
+
logger.debug("track frame parked", {
|
|
64048
|
+
tags: { deviceId: order.deviceId },
|
|
64049
|
+
meta: {
|
|
64050
|
+
...meta,
|
|
64051
|
+
bytes: answer.bytes,
|
|
64052
|
+
replaced: answer.replaced
|
|
64053
|
+
}
|
|
64054
|
+
});
|
|
64055
|
+
return true;
|
|
64056
|
+
}
|
|
64057
|
+
logger.warn("track frame park refused by the owning node", {
|
|
64058
|
+
tags: { deviceId: order.deviceId },
|
|
64059
|
+
meta: {
|
|
64060
|
+
...meta,
|
|
64061
|
+
reason: answer.reason,
|
|
64062
|
+
handleAgeMs: answer.handleAgeMs,
|
|
64063
|
+
...answer.detail !== void 0 ? { detail: answer.detail } : {}
|
|
64064
|
+
}
|
|
64065
|
+
});
|
|
64066
|
+
return false;
|
|
64067
|
+
} catch (err) {
|
|
64068
|
+
logger.warn("track frame park failed — the order did not reach the node", {
|
|
64069
|
+
tags: { deviceId: order.deviceId },
|
|
64070
|
+
meta: {
|
|
64071
|
+
...meta,
|
|
64072
|
+
error: errMsg$1(err)
|
|
64073
|
+
}
|
|
64074
|
+
});
|
|
64075
|
+
return false;
|
|
64076
|
+
}
|
|
64077
|
+
};
|
|
64078
|
+
const park = (order) => {
|
|
64079
|
+
const key = inFlightKey(order.trackId, order.kind);
|
|
64080
|
+
const pending = inFlight.get(key);
|
|
64081
|
+
if (pending !== void 0) return pending;
|
|
64082
|
+
const run = sendPark(order).finally(() => {
|
|
64083
|
+
if (inFlight.get(key) === run) inFlight.delete(key);
|
|
64084
|
+
});
|
|
64085
|
+
inFlight.set(key, run);
|
|
64086
|
+
return run;
|
|
64087
|
+
};
|
|
64088
|
+
const awaitPark = async (trackId, kind) => {
|
|
64089
|
+
const pending = inFlight.get(inFlightKey(trackId, kind));
|
|
64090
|
+
if (pending !== void 0) await pending;
|
|
64091
|
+
};
|
|
64092
|
+
const info = (trackId, kind) => mirror.get(trackId)?.get(kind);
|
|
64093
|
+
const fetch = async (trackId, kind) => {
|
|
64094
|
+
const known = info(trackId, kind);
|
|
64095
|
+
if (known === void 0 || api === void 0) return null;
|
|
64096
|
+
if (deps.isNodeOffline?.(known.nodeId) === true) {
|
|
64097
|
+
logger.warn("parked frame retrieval skipped — the holding node is offline in the registry", {
|
|
64098
|
+
tags: { deviceId: known.deviceId },
|
|
64099
|
+
meta: {
|
|
64100
|
+
trackId,
|
|
64101
|
+
kind,
|
|
64102
|
+
nodeId: known.nodeId
|
|
64103
|
+
}
|
|
64104
|
+
});
|
|
64105
|
+
return null;
|
|
64106
|
+
}
|
|
64107
|
+
try {
|
|
64108
|
+
const parcel = await api.getParkedTrackFrame.query({
|
|
64109
|
+
deviceId: known.deviceId,
|
|
64110
|
+
trackId,
|
|
64111
|
+
kind
|
|
64112
|
+
}, nodePin(known.nodeId));
|
|
64113
|
+
if (parcel === null) {
|
|
64114
|
+
logger.warn("parked frame gone at retrieval — the node no longer holds it", {
|
|
64115
|
+
tags: { deviceId: known.deviceId },
|
|
64116
|
+
meta: {
|
|
64117
|
+
trackId,
|
|
64118
|
+
kind,
|
|
64119
|
+
nodeId: known.nodeId,
|
|
64120
|
+
parkedTimestamp: known.timestamp
|
|
64121
|
+
}
|
|
64122
|
+
});
|
|
64123
|
+
return null;
|
|
64124
|
+
}
|
|
64125
|
+
return {
|
|
64126
|
+
jpeg: Buffer.from(parcel.jpeg, "base64"),
|
|
64127
|
+
width: parcel.width,
|
|
64128
|
+
height: parcel.height,
|
|
64129
|
+
timestamp: parcel.timestamp,
|
|
64130
|
+
info: known
|
|
64131
|
+
};
|
|
64132
|
+
} catch (err) {
|
|
64133
|
+
logger.warn("parked frame retrieval failed", {
|
|
64134
|
+
tags: { deviceId: known.deviceId },
|
|
64135
|
+
meta: {
|
|
64136
|
+
trackId,
|
|
64137
|
+
kind,
|
|
64138
|
+
nodeId: known.nodeId,
|
|
64139
|
+
error: errMsg$1(err)
|
|
64140
|
+
}
|
|
64141
|
+
});
|
|
64142
|
+
return null;
|
|
64143
|
+
}
|
|
64144
|
+
};
|
|
64145
|
+
const release = (trackId) => {
|
|
64146
|
+
const kinds = mirror.get(trackId);
|
|
64147
|
+
if (kinds === void 0) return;
|
|
64148
|
+
mirror.delete(trackId);
|
|
64149
|
+
if (api === void 0) return;
|
|
64150
|
+
const targets = /* @__PURE__ */ new Map();
|
|
64151
|
+
for (const record of kinds.values()) targets.set(record.nodeId, record.deviceId);
|
|
64152
|
+
for (const [nodeId, deviceId] of targets) api.releaseParkedTrackFrames.mutate({
|
|
64153
|
+
deviceId,
|
|
64154
|
+
trackId
|
|
64155
|
+
}, nodePin(nodeId)).catch((err) => {
|
|
64156
|
+
logger.debug("parked frame release did not reach the node", {
|
|
64157
|
+
tags: { deviceId },
|
|
64158
|
+
meta: {
|
|
64159
|
+
trackId,
|
|
64160
|
+
nodeId,
|
|
64161
|
+
error: errMsg$1(err)
|
|
64162
|
+
}
|
|
64163
|
+
});
|
|
64164
|
+
});
|
|
64165
|
+
};
|
|
64166
|
+
const dispose = () => {
|
|
64167
|
+
mirror.clear();
|
|
64168
|
+
inFlight.clear();
|
|
64169
|
+
skewWarnedAt.clear();
|
|
64170
|
+
};
|
|
64171
|
+
return {
|
|
64172
|
+
park,
|
|
64173
|
+
awaitPark,
|
|
64174
|
+
info,
|
|
64175
|
+
fetch,
|
|
64176
|
+
release,
|
|
64177
|
+
dispose
|
|
64178
|
+
};
|
|
64179
|
+
}
|
|
64180
|
+
//#endregion
|
|
63815
64181
|
//#region src/pipeline-analytics/runtime/widget-manifest.ts
|
|
63816
64182
|
/** The remote-module coordinates shared by every analytics widget. */
|
|
63817
64183
|
var REMOTE_NAME = "addon_pipeline_analytics_widgets";
|
|
@@ -64913,7 +65279,8 @@ function isUniformRgbFrame(data, width, height) {
|
|
|
64913
65279
|
* frame downscaled to {@link SNAPSHOT_MAX_WIDTH} (960) with ONLY the track's own
|
|
64914
65280
|
* box burned in, falling back to the ≤640 detection frame (honest lower res,
|
|
64915
65281
|
* never an upscale) on a native miss. The best `thumbnail` stays a clean,
|
|
64916
|
-
* uncapped native subject crop
|
|
65282
|
+
* uncapped native subject crop — read from the track's PARKED slab, by track
|
|
65283
|
+
* (D422), never by handle.
|
|
64917
65284
|
*
|
|
64918
65285
|
* The detection frame is resolved ONCE per call (blank-frame guard); native full
|
|
64919
65286
|
* frames + subject crops are fetched per target by handle. Frames recycle in
|
|
@@ -65181,10 +65548,10 @@ var EventMediaDispatcher = class {
|
|
|
65181
65548
|
if (sn.rollingLastFrame && boxed) lastFrameWritten = await this.replaceKind(deviceId, sn.trackId, "lastFrame", sn.timestamp, boxed);
|
|
65182
65549
|
let thumbnailWritten = false;
|
|
65183
65550
|
if (sn.bestThumbnail) {
|
|
65184
|
-
const variants = await this.cropSubjectVariants(deviceId, sn.trackId
|
|
65551
|
+
const variants = await this.cropSubjectVariants(deviceId, sn.trackId);
|
|
65185
65552
|
if (variants) {
|
|
65186
|
-
thumbnailWritten = await this.replaceKind(deviceId, sn.trackId, "thumbnail",
|
|
65187
|
-
await this.replaceKind(deviceId, sn.trackId, "thumbnailSmall",
|
|
65553
|
+
thumbnailWritten = await this.replaceKind(deviceId, sn.trackId, "thumbnail", variants.timestamp, variants.thumbnail, "native");
|
|
65554
|
+
await this.replaceKind(deviceId, sn.trackId, "thumbnailSmall", variants.timestamp, variants.thumbnailSmall, "native");
|
|
65188
65555
|
}
|
|
65189
65556
|
}
|
|
65190
65557
|
return {
|
|
@@ -65262,81 +65629,49 @@ var EventMediaDispatcher = class {
|
|
|
65262
65629
|
}
|
|
65263
65630
|
/**
|
|
65264
65631
|
* The best-shot subject crop as its TWO persisted variants (best-crop
|
|
65265
|
-
* fast-load, 2026-07-21; 16:9 central-square reframe, 2026-07-22)
|
|
65266
|
-
*
|
|
65267
|
-
*
|
|
65268
|
-
*
|
|
65269
|
-
*
|
|
65270
|
-
* the
|
|
65271
|
-
*
|
|
65272
|
-
*
|
|
65273
|
-
*
|
|
65274
|
-
*
|
|
65275
|
-
*
|
|
65276
|
-
*
|
|
65277
|
-
*
|
|
65278
|
-
*
|
|
65279
|
-
*
|
|
65280
|
-
*
|
|
65281
|
-
*
|
|
65282
|
-
|
|
65283
|
-
|
|
65284
|
-
* upscale of a ≤640 tile (a blurred lie).
|
|
65285
|
-
*/
|
|
65286
|
-
async cropSubjectVariants(deviceId, trackId, frameHandle, fw, fh, bbox) {
|
|
65287
|
-
if (!this.deps.getNativeCropJpeg) {
|
|
65288
|
-
this.deps.logger.warn("native subject crop miss — will retry, no upscale", {
|
|
65289
|
-
tags: { deviceId },
|
|
65290
|
-
meta: {
|
|
65291
|
-
shmId: frameHandle.shmId,
|
|
65292
|
-
reason: "no-native-cap"
|
|
65293
|
-
}
|
|
65294
|
-
});
|
|
65295
|
-
this.deps.onSubjectCropMiss?.(deviceId, trackId, "no-native-cap");
|
|
65296
|
-
return null;
|
|
65297
|
-
}
|
|
65632
|
+
* fast-load, 2026-07-21; 16:9 central-square reframe, 2026-07-22), from the
|
|
65633
|
+
* track's PARKED slab (D422). ONE read, by `(deviceId, trackId)`: the
|
|
65634
|
+
* in-frame slab of the 16:9 central-square WINDOW
|
|
65635
|
+
* ({@link wideCentralSquareLayout}) the runner cut at uncapped native
|
|
65636
|
+
* resolution the instant the track's best was decided. It is composed into
|
|
65637
|
+
* the full 16:9 window (lateral letterbox only for the part outside the
|
|
65638
|
+
* frame) → the `thumbnail`. The `thumbnailSmall` is DERIVED by downscaling
|
|
65639
|
+
* that SAME window to the 480 long-side cap — never a second read, never
|
|
65640
|
+
* upscaled ({@link deriveThumbnailSmall} never upscales a smaller window).
|
|
65641
|
+
*
|
|
65642
|
+
* Both variants share the SAME framing + central-square containment
|
|
65643
|
+
* guarantee: wide consumers use the 16:9 image as-is; square consumers
|
|
65644
|
+
* center-crop the middle square (subject always inside it).
|
|
65645
|
+
*
|
|
65646
|
+
* PARCEL-OR-NOTHING: no parcel (or a throw) returns `null` after a loud
|
|
65647
|
+
* `logger.warn`; the caller SKIPS the write and the per-frame retry parks a
|
|
65648
|
+
* later frame. Never a by-handle crop, never a local upscale of a ≤640 tile.
|
|
65649
|
+
*/
|
|
65650
|
+
async cropSubjectVariants(deviceId, trackId) {
|
|
65298
65651
|
try {
|
|
65299
|
-
const
|
|
65300
|
-
|
|
65301
|
-
|
|
65302
|
-
});
|
|
65303
|
-
if (centralSquareContainmentFraction(bbox, {
|
|
65304
|
-
W: fw,
|
|
65305
|
-
H: fh
|
|
65306
|
-
}) < .5) this.deps.logger.info("best-shot delivered via contained square layout (edge subject)", {
|
|
65307
|
-
tags: { deviceId },
|
|
65308
|
-
meta: {
|
|
65309
|
-
bbox,
|
|
65310
|
-
frameW: fw,
|
|
65311
|
-
frameH: fh
|
|
65312
|
-
}
|
|
65313
|
-
});
|
|
65314
|
-
const askedAt = Date.now();
|
|
65315
|
-
const slab = await this.deps.getNativeCropJpeg(frameHandle, layout.fetch, void 0, deviceId);
|
|
65316
|
-
if (!slab) {
|
|
65317
|
-
this.deps.logger.warn("native subject crop miss — will retry, no upscale", {
|
|
65652
|
+
const parked = await this.deps.getParkedSubjectSlab(deviceId, trackId);
|
|
65653
|
+
if (!parked) {
|
|
65654
|
+
this.deps.logger.warn("best-shot parcel missing — no thumbnail this frame, will retry", {
|
|
65318
65655
|
tags: { deviceId },
|
|
65319
65656
|
meta: {
|
|
65320
|
-
|
|
65321
|
-
|
|
65322
|
-
handleNodeId: frameHandle.nodeId,
|
|
65323
|
-
roundTripMs: Date.now() - askedAt,
|
|
65324
|
-
reason: "native-miss"
|
|
65657
|
+
trackId,
|
|
65658
|
+
reason: "parcel-missing"
|
|
65325
65659
|
}
|
|
65326
65660
|
});
|
|
65327
|
-
this.deps.onSubjectCropMiss?.(deviceId, trackId, "
|
|
65661
|
+
this.deps.onSubjectCropMiss?.(deviceId, trackId, "parcel-missing");
|
|
65328
65662
|
return null;
|
|
65329
65663
|
}
|
|
65330
|
-
const thumbnail = await composeWideCentralSquareThumbnail(slab, layout);
|
|
65664
|
+
const thumbnail = await composeWideCentralSquareThumbnail(parked.slab, parked.layout);
|
|
65331
65665
|
return {
|
|
65332
65666
|
thumbnail,
|
|
65333
|
-
thumbnailSmall: await deriveThumbnailSmall(thumbnail)
|
|
65667
|
+
thumbnailSmall: await deriveThumbnailSmall(thumbnail),
|
|
65668
|
+
timestamp: parked.timestamp
|
|
65334
65669
|
};
|
|
65335
65670
|
} catch (err) {
|
|
65336
|
-
this.deps.logger.warn("
|
|
65671
|
+
this.deps.logger.warn("best-shot parcel read failed — no thumbnail this frame, will retry", {
|
|
65337
65672
|
tags: { deviceId },
|
|
65338
65673
|
meta: {
|
|
65339
|
-
|
|
65674
|
+
trackId,
|
|
65340
65675
|
reason: "threw",
|
|
65341
65676
|
error: err instanceof Error ? err.message : String(err)
|
|
65342
65677
|
}
|
|
@@ -70627,7 +70962,17 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
70627
70962
|
* the FULL cleanup litany on every teardown path (and cancels the track's
|
|
70628
70963
|
* queued captures via the onClose hook) and `closeDevice` finally clears
|
|
70629
70964
|
* per-track state on device removal (the two documented leaks). */
|
|
70630
|
-
residents = new TrackResidentState({ onClose: (trackId) =>
|
|
70965
|
+
residents = new TrackResidentState({ onClose: (trackId) => {
|
|
70966
|
+
this.captureScheduler.cancelForTrack(trackId);
|
|
70967
|
+
this.parkedFrames?.release(trackId);
|
|
70968
|
+
} });
|
|
70969
|
+
/**
|
|
70970
|
+
* The hub's side of a PARK (D422): orders the owning node to keep a track's
|
|
70971
|
+
* best frame the instant `BestDetectionTracker` accepts it, and answers the
|
|
70972
|
+
* keyFrame writer, the best-shot thumbnail and the detail plane's full-frame
|
|
70973
|
+
* rung by `(deviceId, trackId, kind)` — never by handle. Null until init.
|
|
70974
|
+
*/
|
|
70975
|
+
parkedFrames = null;
|
|
70631
70976
|
/** Defence in depth for the 2026-08-21 `b50e09f7` incident: a row the track
|
|
70632
70977
|
* store has already CLOSED never earns another media target, whatever the
|
|
70633
70978
|
* tracker keeps handing back. Reads the store's in-RAM close record only —
|
|
@@ -71022,17 +71367,23 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
71022
71367
|
noteCropOutcome: (deviceId, reason) => this.failureReport.noteEnrichmentCrop(deviceId, reason)
|
|
71023
71368
|
});
|
|
71024
71369
|
this.getNativeKeyFrameRgb = transport.getNativeKeyFrameRgb;
|
|
71370
|
+
this.parkedFrames = createParkedFrameClient({
|
|
71371
|
+
api: api.pipelineRunner,
|
|
71372
|
+
logger: logger.child("ParkedFrames"),
|
|
71373
|
+
isNodeOffline: (nodeId) => this.nodeLiveness.isKnownOffline(nodeId, Date.now())
|
|
71374
|
+
});
|
|
71025
71375
|
this.captureCrop = transport.captureCrop;
|
|
71026
71376
|
this.eventMediaDispatcher = new EventMediaDispatcher({
|
|
71027
71377
|
getRemoteFrame: transport.getRemoteFrame,
|
|
71028
71378
|
getNativeCropJpeg: transport.getNativeCropJpeg,
|
|
71029
71379
|
getNativeFullFrameRgb: transport.getNativeFullFrameRgb,
|
|
71380
|
+
getParkedSubjectSlab: (deviceId, trackId) => this.fetchParkedSubjectSlab(deviceId, trackId),
|
|
71030
71381
|
mediaStore: stores.mediaStore,
|
|
71031
71382
|
logger: logger.child("EventMediaDispatcher"),
|
|
71032
71383
|
onSubjectCropMiss: (deviceId, trackId, reason) => this.residents.notePreviewCaptureMiss(deviceId, trackId, `thumbnail:${reason}`)
|
|
71033
71384
|
});
|
|
71034
71385
|
this.buildRecognizers(api, logger, stores, transport);
|
|
71035
|
-
this.buildDetailDispatcher(api, logger
|
|
71386
|
+
this.buildDetailDispatcher(api, logger);
|
|
71036
71387
|
const capProviders = this.buildAnalyticsProviders(api, logger);
|
|
71037
71388
|
await step("buildNotificationCenter", () => this.buildNotificationCenter(api, logger, stores));
|
|
71038
71389
|
await step("serveEventMediaDataPlane", () => this.serveEventMediaDataPlane());
|
|
@@ -71862,7 +72213,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
71862
72213
|
* demand via `pipelineRunner.runDetailSubtree`. The dispatcher owns the
|
|
71863
72214
|
* per-device schedulers, concurrency cap, and 1 s tick; result routing +
|
|
71864
72215
|
* the pinned call + crop fallback are injected here. */
|
|
71865
|
-
buildDetailDispatcher(api, logger
|
|
72216
|
+
buildDetailDispatcher(api, logger) {
|
|
71866
72217
|
const runnerApi = api.pipelineRunner;
|
|
71867
72218
|
this.detailDispatcher = new TrackDetailDispatcher({
|
|
71868
72219
|
logger: logger.child("DetailDispatcher"),
|
|
@@ -71872,13 +72223,16 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
71872
72223
|
return runnerApi.runDetailSubtree.mutate(input);
|
|
71873
72224
|
},
|
|
71874
72225
|
routeResults: (deviceId, trackId, details, frame) => this.routeDetailResults(deviceId, trackId, details, frame),
|
|
71875
|
-
|
|
71876
|
-
|
|
71877
|
-
|
|
71878
|
-
return
|
|
71879
|
-
base64:
|
|
71880
|
-
width:
|
|
71881
|
-
height:
|
|
72226
|
+
captureParkedFrame: async (_deviceId, trackId) => {
|
|
72227
|
+
const parcel = await this.fetchParkedParcel(trackId, "keyFrame");
|
|
72228
|
+
if (parcel === null) return null;
|
|
72229
|
+
return {
|
|
72230
|
+
base64: parcel.jpeg.toString("base64"),
|
|
72231
|
+
width: parcel.width,
|
|
72232
|
+
height: parcel.height,
|
|
72233
|
+
bbox: scaleSubjectIntoParcel(parcel.info.subject, parcel.width, parcel.height),
|
|
72234
|
+
nodeId: parcel.info.nodeId,
|
|
72235
|
+
timestamp: parcel.timestamp
|
|
71882
72236
|
};
|
|
71883
72237
|
},
|
|
71884
72238
|
captureCropBase64: async (frame) => {
|
|
@@ -73520,6 +73874,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
73520
73874
|
this.audioMarkers?.flush(Date.now());
|
|
73521
73875
|
this.detailDispatcher?.dispose();
|
|
73522
73876
|
this.detailDispatcher = null;
|
|
73877
|
+
this.parkedFrames?.dispose();
|
|
73523
73878
|
this.overlayState.clear();
|
|
73524
73879
|
this.overlaySynthesisWarnAt.clear();
|
|
73525
73880
|
this.processors.clear();
|
|
@@ -74178,7 +74533,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
74178
74533
|
let plateCrops = 0;
|
|
74179
74534
|
for (const crops of childCropsByEvent.values()) for (const c of crops) if (c.kind === "faceCrop") faceCrops += 1;
|
|
74180
74535
|
else plateCrops += 1;
|
|
74181
|
-
const snapshotTargets = this.buildSnapshotTargets(deviceId, result.tracked, result.timestamp, mediaSettings, result.frameWidth, result.frameHeight);
|
|
74536
|
+
const snapshotTargets = this.buildSnapshotTargets(deviceId, result.tracked, result.timestamp, mediaSettings, result.frameWidth, result.frameHeight, frameHandle);
|
|
74182
74537
|
this.offerGroupShot(deviceId, result, frameHandle);
|
|
74183
74538
|
for (const retry of this.collectFirstFrameRetries(deviceId, result.tracked, result.timestamp, firstFrameTargets)) firstFrameTargets.push(retry);
|
|
74184
74539
|
const targetedThisFrame = new Set([...firstFrameTargets.map((t) => t.trackId), ...snapshotTargets.map((s) => s.trackId)]);
|
|
@@ -74297,7 +74652,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
74297
74652
|
}).catch(() => {});
|
|
74298
74653
|
}
|
|
74299
74654
|
const keyFrameCaptures = selectKeyFrameCaptures(snapshotTargets);
|
|
74300
|
-
if (keyFrameCaptures.length > 0) this.persistKeyFrames(deviceId, result.timestamp, keyFrameCaptures
|
|
74655
|
+
if (keyFrameCaptures.length > 0) this.persistKeyFrames(deviceId, result.timestamp, keyFrameCaptures);
|
|
74301
74656
|
}
|
|
74302
74657
|
if (this.faceRecognizer && faceGloballyEnabled && faceSettings) this.faceRecognizer.processFrame({
|
|
74303
74658
|
deviceId,
|
|
@@ -75227,10 +75582,46 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
75227
75582
|
});
|
|
75228
75583
|
}).catch(() => {});
|
|
75229
75584
|
}
|
|
75230
|
-
|
|
75231
|
-
|
|
75585
|
+
/**
|
|
75586
|
+
* Order the parcels a best-frame decision wants (D422). Skipped entirely at
|
|
75587
|
+
* a node the registry already called offline (D58) — logged on the
|
|
75588
|
+
* transition by `noteCapturesGated`, counted in the key-frame window.
|
|
75589
|
+
* `onlyIfMissing` is the retry rule: a later frame may fill a kind that has
|
|
75590
|
+
* no parcel, never replace one the ranking preferred.
|
|
75591
|
+
*/
|
|
75592
|
+
issueParkOrders(decision, kinds, onlyIfMissing) {
|
|
75593
|
+
const client = this.parkedFrames;
|
|
75594
|
+
if (client === null) return;
|
|
75595
|
+
if (this.nodeLiveness.isKnownOffline(decision.frameHandle.nodeId, Date.now())) {
|
|
75596
|
+
this.noteCapturesGated(decision.deviceId, decision.frameHandle.nodeId);
|
|
75597
|
+
return;
|
|
75598
|
+
}
|
|
75599
|
+
for (const order of buildParkOrders(decision)) {
|
|
75600
|
+
if (!kinds.includes(order.kind)) continue;
|
|
75601
|
+
if (onlyIfMissing && client.info(order.trackId, order.kind) !== void 0) continue;
|
|
75602
|
+
client.park(order);
|
|
75603
|
+
}
|
|
75604
|
+
}
|
|
75605
|
+
/** A parcel by track, after any park in flight for it has landed. */
|
|
75606
|
+
async fetchParkedParcel(trackId, kind) {
|
|
75607
|
+
const client = this.parkedFrames;
|
|
75608
|
+
if (client === null) return null;
|
|
75609
|
+
await client.awaitPark(trackId, kind);
|
|
75610
|
+
return client.fetch(trackId, kind);
|
|
75611
|
+
}
|
|
75612
|
+
/** The best-shot slab for the dispatcher: the parcel plus the layout the hub kept. */
|
|
75613
|
+
async fetchParkedSubjectSlab(_deviceId, trackId) {
|
|
75614
|
+
const parcel = await this.fetchParkedParcel(trackId, "thumbnail");
|
|
75615
|
+
if (parcel === null || parcel.info.layout === void 0) return null;
|
|
75616
|
+
return {
|
|
75617
|
+
slab: parcel.jpeg,
|
|
75618
|
+
layout: parcel.info.layout,
|
|
75619
|
+
timestamp: parcel.timestamp
|
|
75620
|
+
};
|
|
75621
|
+
}
|
|
75622
|
+
async persistKeyFrames(deviceId, timestamp, captures) {
|
|
75232
75623
|
const mediaStore = this.mediaStore;
|
|
75233
|
-
if (
|
|
75624
|
+
if (this.parkedFrames === null || !mediaStore) return;
|
|
75234
75625
|
await Promise.all(captures.map((capture) => this.captureScheduler.request({
|
|
75235
75626
|
deviceId,
|
|
75236
75627
|
trackId: capture.trackId,
|
|
@@ -75240,16 +75631,23 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
75240
75631
|
exec: async () => {
|
|
75241
75632
|
this.residents.noteKeyFrameAttempt(deviceId, capture.trackId, timestamp, capture.retry);
|
|
75242
75633
|
const outcome = await persistTrackKeyFrame({
|
|
75243
|
-
|
|
75244
|
-
|
|
75634
|
+
fetchParkedKeyFrame: async (parcelDeviceId, trackId) => {
|
|
75635
|
+
const parcel = await this.fetchParkedParcel(trackId, "keyFrame");
|
|
75636
|
+
if (parcel === null || parcel.info.deviceId !== parcelDeviceId) return null;
|
|
75637
|
+
return {
|
|
75638
|
+
jpeg: parcel.jpeg,
|
|
75639
|
+
width: parcel.width,
|
|
75640
|
+
height: parcel.height,
|
|
75641
|
+
timestamp: parcel.timestamp,
|
|
75642
|
+
nodeId: parcel.info.nodeId
|
|
75643
|
+
};
|
|
75644
|
+
},
|
|
75645
|
+
deriveSmall: deriveKeyFrameSmall,
|
|
75245
75646
|
media: mediaStore,
|
|
75246
75647
|
logger: this.ctx.logger
|
|
75247
75648
|
}, {
|
|
75248
75649
|
deviceId,
|
|
75249
75650
|
trackId: capture.trackId,
|
|
75250
|
-
timestamp,
|
|
75251
|
-
frameHandle,
|
|
75252
|
-
maxWidth: KEYFRAME_NATIVE_MAX_WIDTH,
|
|
75253
75651
|
retry: capture.retry
|
|
75254
75652
|
});
|
|
75255
75653
|
if (outcome.kind === "landed") {
|
|
@@ -75329,10 +75727,19 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
75329
75727
|
isKeyFrameLanded: (trackId) => this.residents.keyFrameCapture(trackId).landed,
|
|
75330
75728
|
captureBodyThumbnail: (req) => this.captureHierarchyBodyThumbnail(req),
|
|
75331
75729
|
captureKeyFrame: async (req) => {
|
|
75730
|
+
this.issueParkOrders({
|
|
75731
|
+
deviceId: req.deviceId,
|
|
75732
|
+
trackId: req.trackId,
|
|
75733
|
+
timestamp: req.timestamp,
|
|
75734
|
+
frameHandle: req.frameHandle,
|
|
75735
|
+
bbox: { ...req.bodyBbox },
|
|
75736
|
+
frameWidth: req.frameWidth,
|
|
75737
|
+
frameHeight: req.frameHeight
|
|
75738
|
+
}, ["keyFrame"], true);
|
|
75332
75739
|
await this.persistKeyFrames(req.deviceId, req.timestamp, [{
|
|
75333
75740
|
trackId: req.trackId,
|
|
75334
75741
|
retry: false
|
|
75335
|
-
}]
|
|
75742
|
+
}]);
|
|
75336
75743
|
}
|
|
75337
75744
|
}, input);
|
|
75338
75745
|
}
|
|
@@ -75386,10 +75793,19 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
75386
75793
|
* (coalescing, per-device budget and land-only bookkeeping identical). */
|
|
75387
75794
|
captureSemanticBestShot(request) {
|
|
75388
75795
|
const { deviceId, trackId, timestamp, bbox, frameHandle } = request;
|
|
75796
|
+
this.issueParkOrders({
|
|
75797
|
+
deviceId,
|
|
75798
|
+
trackId,
|
|
75799
|
+
timestamp,
|
|
75800
|
+
frameHandle,
|
|
75801
|
+
bbox: { ...bbox },
|
|
75802
|
+
frameWidth: request.frameWidth,
|
|
75803
|
+
frameHeight: request.frameHeight
|
|
75804
|
+
}, ["keyFrame", "thumbnail"], false);
|
|
75389
75805
|
this.persistKeyFrames(deviceId, timestamp, [{
|
|
75390
75806
|
trackId,
|
|
75391
75807
|
retry: false
|
|
75392
|
-
}]
|
|
75808
|
+
}]);
|
|
75393
75809
|
const dispatcher = this.eventMediaDispatcher;
|
|
75394
75810
|
if (!dispatcher) return;
|
|
75395
75811
|
if (this.captureScheduler.isKeyActive(captureCoalesceKey(deviceId, "thumbnail", trackId))) {
|
|
@@ -75540,7 +75956,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
75540
75956
|
}
|
|
75541
75957
|
return retries;
|
|
75542
75958
|
}
|
|
75543
|
-
buildSnapshotTargets(deviceId, tracked, timestamp, media, frameWidth, frameHeight) {
|
|
75959
|
+
buildSnapshotTargets(deviceId, tracked, timestamp, media, frameWidth, frameHeight, frameHandle) {
|
|
75544
75960
|
const targets = [];
|
|
75545
75961
|
for (const t of tracked) {
|
|
75546
75962
|
if (t.matchedThisFrame === false) continue;
|
|
@@ -75626,6 +76042,29 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
75626
76042
|
state: this.residents.keyFrameCapture(t.trackId),
|
|
75627
76043
|
now: timestamp
|
|
75628
76044
|
}).kind;
|
|
76045
|
+
if (frameHandle !== void 0 && plausibleBox) {
|
|
76046
|
+
const decision = {
|
|
76047
|
+
deviceId,
|
|
76048
|
+
trackId: t.trackId,
|
|
76049
|
+
timestamp,
|
|
76050
|
+
frameHandle,
|
|
76051
|
+
bbox: {
|
|
76052
|
+
x: t.bbox.x,
|
|
76053
|
+
y: t.bbox.y,
|
|
76054
|
+
w: t.bbox.w,
|
|
76055
|
+
h: t.bbox.h
|
|
76056
|
+
},
|
|
76057
|
+
frameWidth,
|
|
76058
|
+
frameHeight
|
|
76059
|
+
};
|
|
76060
|
+
if (isNewBest) this.issueParkOrders(decision, ["keyFrame", "thumbnail"], false);
|
|
76061
|
+
else {
|
|
76062
|
+
const retryKinds = [];
|
|
76063
|
+
if (keyFrame === "retry") retryKinds.push("keyFrame");
|
|
76064
|
+
if (bestThumbnail) retryKinds.push("thumbnail");
|
|
76065
|
+
if (retryKinds.length > 0) this.issueParkOrders(decision, retryKinds, true);
|
|
76066
|
+
}
|
|
76067
|
+
}
|
|
75629
76068
|
const suppressedBy = (() => {
|
|
75630
76069
|
if (skipParkedThumb) return "parked-thumbnail";
|
|
75631
76070
|
if (!isNewBest || bestThumbnail) return void 0;
|