@camstack/addon-post-analysis 1.2.361 → 1.2.362
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.
|
@@ -64653,6 +64653,11 @@ var LATE_ABSORBED_WORK_SAMPLE_MS = 6e4;
|
|
|
64653
64653
|
/** Absorbed ids remembered after their survivor closed, so late work for
|
|
64654
64654
|
* them is refused rather than resurrected (oldest forgotten first). */
|
|
64655
64655
|
var MAX_RETIRED_ABSORBED_IDS = 4096;
|
|
64656
|
+
/** Closed track ids remembered (oldest forgotten first) so an async completion
|
|
64657
|
+
* settling AFTER `close` is refused instead of re-creating a resident nothing
|
|
64658
|
+
* would ever close. Track ids are unique per birth; 16384 covers hours of
|
|
64659
|
+
* settling at the busiest observed birth rate. */
|
|
64660
|
+
var MAX_CLOSED_TRACK_IDS = 16384;
|
|
64656
64661
|
var TrackResidentState = class {
|
|
64657
64662
|
hooks;
|
|
64658
64663
|
residents = /* @__PURE__ */ new Map();
|
|
@@ -64694,6 +64699,8 @@ var TrackResidentState = class {
|
|
|
64694
64699
|
bestShotHolder = /* @__PURE__ */ new Map();
|
|
64695
64700
|
/** Absorbed id → survivor id, for survivors that already closed (bounded). */
|
|
64696
64701
|
retired = /* @__PURE__ */ new Map();
|
|
64702
|
+
/** Ids closed by `close` (bounded FIFO). Only `open` — a birth — clears one. */
|
|
64703
|
+
closedIds = /* @__PURE__ */ new Set();
|
|
64697
64704
|
/** Per device: start of the current late-work sample window, and how many
|
|
64698
64705
|
* refusals it has swallowed since the last sampled call. */
|
|
64699
64706
|
lateWorkSample = /* @__PURE__ */ new Map();
|
|
@@ -64707,7 +64714,13 @@ var TrackResidentState = class {
|
|
|
64707
64714
|
/** Idempotently create the track's resident record (deviceId travels with
|
|
64708
64715
|
* it so device teardown can enumerate its tracks). */
|
|
64709
64716
|
open(deviceId, trackId) {
|
|
64710
|
-
this.
|
|
64717
|
+
this.closedIds.delete(trackId);
|
|
64718
|
+
this.ensure(deviceId, trackId, "general", "open");
|
|
64719
|
+
}
|
|
64720
|
+
/** True while the track owns a live resident (its survivor's, when absorbed).
|
|
64721
|
+
* Async completions check this before doing work for a track. */
|
|
64722
|
+
isLive(trackId) {
|
|
64723
|
+
return this.residents.has(this.canonical(trackId));
|
|
64711
64724
|
}
|
|
64712
64725
|
/**
|
|
64713
64726
|
* Get-or-create the resident record (every mutator routes through this so
|
|
@@ -64718,15 +64731,19 @@ var TrackResidentState = class {
|
|
|
64718
64731
|
* An absorbed id whose survivor already closed is refused. `undefined` =
|
|
64719
64732
|
* refused (sampled through `onLateAbsorbedWork`); nothing is created.
|
|
64720
64733
|
*/
|
|
64721
|
-
ensure(deviceId, trackId, kind = "general") {
|
|
64734
|
+
ensure(deviceId, trackId, kind = "general", write = "ensure") {
|
|
64722
64735
|
const retiredInto = this.retired.get(trackId);
|
|
64723
64736
|
if (retiredInto !== void 0) {
|
|
64724
|
-
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed");
|
|
64737
|
+
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed", write);
|
|
64738
|
+
return;
|
|
64739
|
+
}
|
|
64740
|
+
if (this.closedIds.has(trackId)) {
|
|
64741
|
+
this.refuseLateWork(deviceId, trackId, trackId, "track-closed", write);
|
|
64725
64742
|
return;
|
|
64726
64743
|
}
|
|
64727
64744
|
const survivorId = this.aliases.get(trackId);
|
|
64728
64745
|
if (survivorId !== void 0 && kind === "bestShot" && (this.bestShotHolder.get(survivorId) ?? survivorId) !== trackId) {
|
|
64729
|
-
this.refuseLateWork(deviceId, trackId, survivorId, "losing-shot");
|
|
64746
|
+
this.refuseLateWork(deviceId, trackId, survivorId, "losing-shot", write);
|
|
64730
64747
|
return;
|
|
64731
64748
|
}
|
|
64732
64749
|
const id = survivorId ?? trackId;
|
|
@@ -64741,10 +64758,10 @@ var TrackResidentState = class {
|
|
|
64741
64758
|
liveId(deviceId, trackId) {
|
|
64742
64759
|
const retiredInto = this.retired.get(trackId);
|
|
64743
64760
|
if (retiredInto === void 0) return this.canonical(trackId);
|
|
64744
|
-
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed");
|
|
64761
|
+
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed", "liveId");
|
|
64745
64762
|
}
|
|
64746
64763
|
/** Count a refused late write; hand the host one sampled line per window. */
|
|
64747
|
-
refuseLateWork(deviceId, trackId, survivorId, reason) {
|
|
64764
|
+
refuseLateWork(deviceId, trackId, survivorId, reason, write) {
|
|
64748
64765
|
const now = Date.now();
|
|
64749
64766
|
const sample = this.lateWorkSample.get(deviceId);
|
|
64750
64767
|
if (sample !== void 0 && now - sample.at < LATE_ABSORBED_WORK_SAMPLE_MS) {
|
|
@@ -64761,7 +64778,8 @@ var TrackResidentState = class {
|
|
|
64761
64778
|
trackId,
|
|
64762
64779
|
survivorId,
|
|
64763
64780
|
reason,
|
|
64764
|
-
refused
|
|
64781
|
+
refused,
|
|
64782
|
+
write
|
|
64765
64783
|
});
|
|
64766
64784
|
}
|
|
64767
64785
|
/**
|
|
@@ -64781,6 +64799,12 @@ var TrackResidentState = class {
|
|
|
64781
64799
|
mediaId: resident.keyFrameMediaId
|
|
64782
64800
|
});
|
|
64783
64801
|
this.hooks.onClose?.(trackId);
|
|
64802
|
+
this.closedIds.add(trackId);
|
|
64803
|
+
while (this.closedIds.size > MAX_CLOSED_TRACK_IDS) {
|
|
64804
|
+
const oldest = this.closedIds.values().next().value;
|
|
64805
|
+
if (oldest === void 0) break;
|
|
64806
|
+
this.closedIds.delete(oldest);
|
|
64807
|
+
}
|
|
64784
64808
|
const absorbed = this.absorbedBy.get(trackId);
|
|
64785
64809
|
this.bestShotHolder.delete(trackId);
|
|
64786
64810
|
if (absorbed !== void 0) {
|
|
@@ -64848,6 +64872,7 @@ var TrackResidentState = class {
|
|
|
64848
64872
|
this.aliases.clear();
|
|
64849
64873
|
this.bestShotHolder.clear();
|
|
64850
64874
|
this.retired.clear();
|
|
64875
|
+
this.closedIds.clear();
|
|
64851
64876
|
this.lateWorkSample.clear();
|
|
64852
64877
|
}
|
|
64853
64878
|
size() {
|
|
@@ -64930,7 +64955,7 @@ var TrackResidentState = class {
|
|
|
64930
64955
|
...observed,
|
|
64931
64956
|
trackId: id
|
|
64932
64957
|
};
|
|
64933
|
-
this.
|
|
64958
|
+
if (this.ensure(deviceId, id, "general", "observeObjectEmbeddingBest") === void 0) return false;
|
|
64934
64959
|
const modelId = obs.embeddingModelId ?? "";
|
|
64935
64960
|
let selector = this.objectEmbeddingBestSelectors.get(modelId);
|
|
64936
64961
|
if (selector === void 0) {
|
|
@@ -64947,7 +64972,7 @@ var TrackResidentState = class {
|
|
|
64947
64972
|
return this.residents.get(this.canonical(trackId))?.keyFrameMediaId ?? this.deferredKeyFrameKeys.get(trackId)?.mediaId;
|
|
64948
64973
|
}
|
|
64949
64974
|
setKeyFrameMediaId(deviceId, trackId, mediaId) {
|
|
64950
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
64975
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "setKeyFrameMediaId");
|
|
64951
64976
|
if (resident !== void 0) resident.keyFrameMediaId = mediaId;
|
|
64952
64977
|
}
|
|
64953
64978
|
/** Settle the keyFrame-id drop (called once the face recognizer's
|
|
@@ -64963,7 +64988,7 @@ var TrackResidentState = class {
|
|
|
64963
64988
|
return this.residents.get(this.canonical(trackId))?.lastFrameAt;
|
|
64964
64989
|
}
|
|
64965
64990
|
setLastFrameAt(deviceId, trackId, atMs) {
|
|
64966
|
-
const resident = this.ensure(deviceId, trackId);
|
|
64991
|
+
const resident = this.ensure(deviceId, trackId, "general", "setLastFrameAt");
|
|
64967
64992
|
if (resident !== void 0) resident.lastFrameAt = atMs;
|
|
64968
64993
|
}
|
|
64969
64994
|
anyFirstFramePending() {
|
|
@@ -64983,7 +65008,7 @@ var TrackResidentState = class {
|
|
|
64983
65008
|
}
|
|
64984
65009
|
/** A `firstFrame` write landed for this track (see {@link TrackResident.firstFrameLanded}). */
|
|
64985
65010
|
markFirstFrameLanded(deviceId, trackId) {
|
|
64986
|
-
const resident = this.ensure(deviceId, trackId);
|
|
65011
|
+
const resident = this.ensure(deviceId, trackId, "general", "markFirstFrameLanded");
|
|
64987
65012
|
if (resident !== void 0) resident.firstFrameLanded = true;
|
|
64988
65013
|
}
|
|
64989
65014
|
isFirstFrameLanded(trackId) {
|
|
@@ -64993,7 +65018,7 @@ var TrackResidentState = class {
|
|
|
64993
65018
|
return this.residents.get(this.canonical(trackId))?.thumbnailLanded ?? false;
|
|
64994
65019
|
}
|
|
64995
65020
|
markThumbnailLanded(deviceId, trackId) {
|
|
64996
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
65021
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "markThumbnailLanded");
|
|
64997
65022
|
if (resident !== void 0) resident.thumbnailLanded = true;
|
|
64998
65023
|
}
|
|
64999
65024
|
/**
|
|
@@ -65040,14 +65065,14 @@ var TrackResidentState = class {
|
|
|
65040
65065
|
* spend one of the track's three retries.
|
|
65041
65066
|
*/
|
|
65042
65067
|
noteKeyFrameAttempt(deviceId, trackId, atMs, retry) {
|
|
65043
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
65068
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "noteKeyFrameAttempt");
|
|
65044
65069
|
if (resident === void 0) return;
|
|
65045
65070
|
resident.keyFrameLastAttemptAt = atMs;
|
|
65046
65071
|
if (retry) resident.keyFrameRetries += 1;
|
|
65047
65072
|
}
|
|
65048
65073
|
/** A `keyFrame` write landed — sticky, and the end of the retry path. */
|
|
65049
65074
|
markKeyFrameLanded(deviceId, trackId) {
|
|
65050
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
65075
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "markKeyFrameLanded");
|
|
65051
65076
|
if (resident !== void 0) resident.keyFrameLanded = true;
|
|
65052
65077
|
}
|
|
65053
65078
|
lifecycleUpdateMem(trackId) {
|
|
@@ -65100,7 +65125,7 @@ var TrackResidentState = class {
|
|
|
65100
65125
|
/** Retain the FIRST detection-raster crop per track (zero-media fallback);
|
|
65101
65126
|
* a later frame never overwrites an existing one. */
|
|
65102
65127
|
retainRasterFallback(deviceId, trackId, fallback) {
|
|
65103
|
-
const resident = this.ensure(deviceId, trackId);
|
|
65128
|
+
const resident = this.ensure(deviceId, trackId, "general", "retainRasterFallback");
|
|
65104
65129
|
if (resident !== void 0 && resident.rasterFallback === void 0) resident.rasterFallback = fallback;
|
|
65105
65130
|
}
|
|
65106
65131
|
};
|
|
@@ -110773,6 +110798,8 @@ var NO_PUBLICATION = {
|
|
|
110773
110798
|
url: null,
|
|
110774
110799
|
artifactId: null
|
|
110775
110800
|
};
|
|
110801
|
+
/** How often the resident-vs-live-track heartbeat line is written. */
|
|
110802
|
+
var RESIDENT_HEARTBEAT_INTERVAL_MS = 5 * 6e4;
|
|
110776
110803
|
/**
|
|
110777
110804
|
* A tRPC-shaped router or procedure reached by DYNAMIC name off `ctx.api`.
|
|
110778
110805
|
*
|
|
@@ -111853,12 +111880,13 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
|
|
|
111853
111880
|
this.parkedFrames?.adopt(survivorId, absorbedId, bestShotFrom);
|
|
111854
111881
|
},
|
|
111855
111882
|
onLateAbsorbedWork: (work) => {
|
|
111856
|
-
this.ctx.logger.info("track resident: late work
|
|
111883
|
+
this.ctx.logger.info("track resident: late work after close refused", {
|
|
111857
111884
|
tags: { deviceId: work.deviceId },
|
|
111858
111885
|
meta: {
|
|
111859
111886
|
trackId: work.trackId,
|
|
111860
111887
|
survivorId: work.survivorId,
|
|
111861
111888
|
reason: work.reason,
|
|
111889
|
+
kind: work.write,
|
|
111862
111890
|
refused: work.refused
|
|
111863
111891
|
}
|
|
111864
111892
|
});
|
|
@@ -115322,11 +115350,31 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
|
|
|
115322
115350
|
this.releaseProxy(deviceId);
|
|
115323
115351
|
this.notificationCenter?.onDeviceDeleted(deviceId);
|
|
115324
115352
|
}
|
|
115353
|
+
/** Wall-clock of the last resident heartbeat line. */
|
|
115354
|
+
residentHeartbeatAt = 0;
|
|
115355
|
+
/**
|
|
115356
|
+
* Resident records vs live tracks, once per interval: a resident count that
|
|
115357
|
+
* climbs past the live-track count is the signature of a record nothing
|
|
115358
|
+
* closes (the late-completion ghost fixed 2026-10-14).
|
|
115359
|
+
*/
|
|
115360
|
+
logResidentHeartbeat(now) {
|
|
115361
|
+
if (now - this.residentHeartbeatAt < RESIDENT_HEARTBEAT_INTERVAL_MS) return;
|
|
115362
|
+
this.residentHeartbeatAt = now;
|
|
115363
|
+
let liveTracks = 0;
|
|
115364
|
+
for (const ids of this.lastActiveTrackIds.values()) liveTracks += ids.size;
|
|
115365
|
+
const mem = process.memoryUsage();
|
|
115366
|
+
this.ctx.logger.info("analytics resident heartbeat", { meta: {
|
|
115367
|
+
residents: this.residents.size(),
|
|
115368
|
+
liveTracks,
|
|
115369
|
+
externalNonBufferMb: Math.max(0, Math.round((mem.external - mem.arrayBuffers) / 1048576))
|
|
115370
|
+
} });
|
|
115371
|
+
}
|
|
115325
115372
|
/** Periodic sweeps — TTL promotion + retention/stationary aging. */
|
|
115326
115373
|
startSweepTimers() {
|
|
115327
115374
|
this.ttlSweepTimer = setInterval(() => {
|
|
115328
115375
|
this.sweepExpiredTracks();
|
|
115329
115376
|
this.runPackageStillnessSweep(Date.now());
|
|
115377
|
+
this.logResidentHeartbeat(Date.now());
|
|
115330
115378
|
}, TTL_SWEEP_INTERVAL_MS);
|
|
115331
115379
|
this.faceReembedAutoTimer = setInterval(() => {
|
|
115332
115380
|
this.maybeAutoReembedFaces().then(() => this.faceAlignmentJobs?.maybeAutoRunPhotoPass());
|
|
@@ -116986,17 +117034,21 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends require_clip_m
|
|
|
116986
117034
|
}),
|
|
116987
117035
|
holdKeys: heldCaptureKeys,
|
|
116988
117036
|
staleAfterMs: ENRICHMENT_CAPTURE_STALE_MS,
|
|
116989
|
-
exec: () => pinnedFramePromise.then((pinnedFrame) =>
|
|
116990
|
-
|
|
116991
|
-
|
|
116992
|
-
|
|
116993
|
-
|
|
116994
|
-
|
|
116995
|
-
|
|
116996
|
-
|
|
116997
|
-
|
|
116998
|
-
|
|
116999
|
-
|
|
117037
|
+
exec: () => pinnedFramePromise.then((pinnedFrame) => {
|
|
117038
|
+
const liveWanted = /* @__PURE__ */ new Set();
|
|
117039
|
+
for (const id of rasterFallbackWantedTrackIds) if (this.residents.isLive(id)) liveWanted.add(id);
|
|
117040
|
+
return dispatcher.captureForFrame({
|
|
117041
|
+
deviceId,
|
|
117042
|
+
frameHandle,
|
|
117043
|
+
events: eventTargets,
|
|
117044
|
+
trackFrames: firstFrameTargets,
|
|
117045
|
+
snapshots: snapshotTargets,
|
|
117046
|
+
cropPadding: mediaSettings.cropPadding,
|
|
117047
|
+
rasterFallbackWantedTrackIds: liveWanted,
|
|
117048
|
+
rasterFallbackCandidates: rasterFallbackCandidates.filter((c) => this.residents.isLive(c.trackId)),
|
|
117049
|
+
...pinnedFrame !== null ? { pinnedFrame } : {}
|
|
117050
|
+
});
|
|
117051
|
+
}).then((res) => {
|
|
117000
117052
|
for (const rf of res.rasterFallbacks) this.residents.retainRasterFallback(deviceId, rf.trackId, {
|
|
117001
117053
|
jpeg: rf.jpeg,
|
|
117002
117054
|
timestamp: rf.timestamp
|
|
@@ -64609,6 +64609,11 @@ var LATE_ABSORBED_WORK_SAMPLE_MS = 6e4;
|
|
|
64609
64609
|
/** Absorbed ids remembered after their survivor closed, so late work for
|
|
64610
64610
|
* them is refused rather than resurrected (oldest forgotten first). */
|
|
64611
64611
|
var MAX_RETIRED_ABSORBED_IDS = 4096;
|
|
64612
|
+
/** Closed track ids remembered (oldest forgotten first) so an async completion
|
|
64613
|
+
* settling AFTER `close` is refused instead of re-creating a resident nothing
|
|
64614
|
+
* would ever close. Track ids are unique per birth; 16384 covers hours of
|
|
64615
|
+
* settling at the busiest observed birth rate. */
|
|
64616
|
+
var MAX_CLOSED_TRACK_IDS = 16384;
|
|
64612
64617
|
var TrackResidentState = class {
|
|
64613
64618
|
hooks;
|
|
64614
64619
|
residents = /* @__PURE__ */ new Map();
|
|
@@ -64650,6 +64655,8 @@ var TrackResidentState = class {
|
|
|
64650
64655
|
bestShotHolder = /* @__PURE__ */ new Map();
|
|
64651
64656
|
/** Absorbed id → survivor id, for survivors that already closed (bounded). */
|
|
64652
64657
|
retired = /* @__PURE__ */ new Map();
|
|
64658
|
+
/** Ids closed by `close` (bounded FIFO). Only `open` — a birth — clears one. */
|
|
64659
|
+
closedIds = /* @__PURE__ */ new Set();
|
|
64653
64660
|
/** Per device: start of the current late-work sample window, and how many
|
|
64654
64661
|
* refusals it has swallowed since the last sampled call. */
|
|
64655
64662
|
lateWorkSample = /* @__PURE__ */ new Map();
|
|
@@ -64663,7 +64670,13 @@ var TrackResidentState = class {
|
|
|
64663
64670
|
/** Idempotently create the track's resident record (deviceId travels with
|
|
64664
64671
|
* it so device teardown can enumerate its tracks). */
|
|
64665
64672
|
open(deviceId, trackId) {
|
|
64666
|
-
this.
|
|
64673
|
+
this.closedIds.delete(trackId);
|
|
64674
|
+
this.ensure(deviceId, trackId, "general", "open");
|
|
64675
|
+
}
|
|
64676
|
+
/** True while the track owns a live resident (its survivor's, when absorbed).
|
|
64677
|
+
* Async completions check this before doing work for a track. */
|
|
64678
|
+
isLive(trackId) {
|
|
64679
|
+
return this.residents.has(this.canonical(trackId));
|
|
64667
64680
|
}
|
|
64668
64681
|
/**
|
|
64669
64682
|
* Get-or-create the resident record (every mutator routes through this so
|
|
@@ -64674,15 +64687,19 @@ var TrackResidentState = class {
|
|
|
64674
64687
|
* An absorbed id whose survivor already closed is refused. `undefined` =
|
|
64675
64688
|
* refused (sampled through `onLateAbsorbedWork`); nothing is created.
|
|
64676
64689
|
*/
|
|
64677
|
-
ensure(deviceId, trackId, kind = "general") {
|
|
64690
|
+
ensure(deviceId, trackId, kind = "general", write = "ensure") {
|
|
64678
64691
|
const retiredInto = this.retired.get(trackId);
|
|
64679
64692
|
if (retiredInto !== void 0) {
|
|
64680
|
-
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed");
|
|
64693
|
+
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed", write);
|
|
64694
|
+
return;
|
|
64695
|
+
}
|
|
64696
|
+
if (this.closedIds.has(trackId)) {
|
|
64697
|
+
this.refuseLateWork(deviceId, trackId, trackId, "track-closed", write);
|
|
64681
64698
|
return;
|
|
64682
64699
|
}
|
|
64683
64700
|
const survivorId = this.aliases.get(trackId);
|
|
64684
64701
|
if (survivorId !== void 0 && kind === "bestShot" && (this.bestShotHolder.get(survivorId) ?? survivorId) !== trackId) {
|
|
64685
|
-
this.refuseLateWork(deviceId, trackId, survivorId, "losing-shot");
|
|
64702
|
+
this.refuseLateWork(deviceId, trackId, survivorId, "losing-shot", write);
|
|
64686
64703
|
return;
|
|
64687
64704
|
}
|
|
64688
64705
|
const id = survivorId ?? trackId;
|
|
@@ -64697,10 +64714,10 @@ var TrackResidentState = class {
|
|
|
64697
64714
|
liveId(deviceId, trackId) {
|
|
64698
64715
|
const retiredInto = this.retired.get(trackId);
|
|
64699
64716
|
if (retiredInto === void 0) return this.canonical(trackId);
|
|
64700
|
-
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed");
|
|
64717
|
+
this.refuseLateWork(deviceId, trackId, retiredInto, "survivor-closed", "liveId");
|
|
64701
64718
|
}
|
|
64702
64719
|
/** Count a refused late write; hand the host one sampled line per window. */
|
|
64703
|
-
refuseLateWork(deviceId, trackId, survivorId, reason) {
|
|
64720
|
+
refuseLateWork(deviceId, trackId, survivorId, reason, write) {
|
|
64704
64721
|
const now = Date.now();
|
|
64705
64722
|
const sample = this.lateWorkSample.get(deviceId);
|
|
64706
64723
|
if (sample !== void 0 && now - sample.at < LATE_ABSORBED_WORK_SAMPLE_MS) {
|
|
@@ -64717,7 +64734,8 @@ var TrackResidentState = class {
|
|
|
64717
64734
|
trackId,
|
|
64718
64735
|
survivorId,
|
|
64719
64736
|
reason,
|
|
64720
|
-
refused
|
|
64737
|
+
refused,
|
|
64738
|
+
write
|
|
64721
64739
|
});
|
|
64722
64740
|
}
|
|
64723
64741
|
/**
|
|
@@ -64737,6 +64755,12 @@ var TrackResidentState = class {
|
|
|
64737
64755
|
mediaId: resident.keyFrameMediaId
|
|
64738
64756
|
});
|
|
64739
64757
|
this.hooks.onClose?.(trackId);
|
|
64758
|
+
this.closedIds.add(trackId);
|
|
64759
|
+
while (this.closedIds.size > MAX_CLOSED_TRACK_IDS) {
|
|
64760
|
+
const oldest = this.closedIds.values().next().value;
|
|
64761
|
+
if (oldest === void 0) break;
|
|
64762
|
+
this.closedIds.delete(oldest);
|
|
64763
|
+
}
|
|
64740
64764
|
const absorbed = this.absorbedBy.get(trackId);
|
|
64741
64765
|
this.bestShotHolder.delete(trackId);
|
|
64742
64766
|
if (absorbed !== void 0) {
|
|
@@ -64804,6 +64828,7 @@ var TrackResidentState = class {
|
|
|
64804
64828
|
this.aliases.clear();
|
|
64805
64829
|
this.bestShotHolder.clear();
|
|
64806
64830
|
this.retired.clear();
|
|
64831
|
+
this.closedIds.clear();
|
|
64807
64832
|
this.lateWorkSample.clear();
|
|
64808
64833
|
}
|
|
64809
64834
|
size() {
|
|
@@ -64886,7 +64911,7 @@ var TrackResidentState = class {
|
|
|
64886
64911
|
...observed,
|
|
64887
64912
|
trackId: id
|
|
64888
64913
|
};
|
|
64889
|
-
this.
|
|
64914
|
+
if (this.ensure(deviceId, id, "general", "observeObjectEmbeddingBest") === void 0) return false;
|
|
64890
64915
|
const modelId = obs.embeddingModelId ?? "";
|
|
64891
64916
|
let selector = this.objectEmbeddingBestSelectors.get(modelId);
|
|
64892
64917
|
if (selector === void 0) {
|
|
@@ -64903,7 +64928,7 @@ var TrackResidentState = class {
|
|
|
64903
64928
|
return this.residents.get(this.canonical(trackId))?.keyFrameMediaId ?? this.deferredKeyFrameKeys.get(trackId)?.mediaId;
|
|
64904
64929
|
}
|
|
64905
64930
|
setKeyFrameMediaId(deviceId, trackId, mediaId) {
|
|
64906
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
64931
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "setKeyFrameMediaId");
|
|
64907
64932
|
if (resident !== void 0) resident.keyFrameMediaId = mediaId;
|
|
64908
64933
|
}
|
|
64909
64934
|
/** Settle the keyFrame-id drop (called once the face recognizer's
|
|
@@ -64919,7 +64944,7 @@ var TrackResidentState = class {
|
|
|
64919
64944
|
return this.residents.get(this.canonical(trackId))?.lastFrameAt;
|
|
64920
64945
|
}
|
|
64921
64946
|
setLastFrameAt(deviceId, trackId, atMs) {
|
|
64922
|
-
const resident = this.ensure(deviceId, trackId);
|
|
64947
|
+
const resident = this.ensure(deviceId, trackId, "general", "setLastFrameAt");
|
|
64923
64948
|
if (resident !== void 0) resident.lastFrameAt = atMs;
|
|
64924
64949
|
}
|
|
64925
64950
|
anyFirstFramePending() {
|
|
@@ -64939,7 +64964,7 @@ var TrackResidentState = class {
|
|
|
64939
64964
|
}
|
|
64940
64965
|
/** A `firstFrame` write landed for this track (see {@link TrackResident.firstFrameLanded}). */
|
|
64941
64966
|
markFirstFrameLanded(deviceId, trackId) {
|
|
64942
|
-
const resident = this.ensure(deviceId, trackId);
|
|
64967
|
+
const resident = this.ensure(deviceId, trackId, "general", "markFirstFrameLanded");
|
|
64943
64968
|
if (resident !== void 0) resident.firstFrameLanded = true;
|
|
64944
64969
|
}
|
|
64945
64970
|
isFirstFrameLanded(trackId) {
|
|
@@ -64949,7 +64974,7 @@ var TrackResidentState = class {
|
|
|
64949
64974
|
return this.residents.get(this.canonical(trackId))?.thumbnailLanded ?? false;
|
|
64950
64975
|
}
|
|
64951
64976
|
markThumbnailLanded(deviceId, trackId) {
|
|
64952
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
64977
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "markThumbnailLanded");
|
|
64953
64978
|
if (resident !== void 0) resident.thumbnailLanded = true;
|
|
64954
64979
|
}
|
|
64955
64980
|
/**
|
|
@@ -64996,14 +65021,14 @@ var TrackResidentState = class {
|
|
|
64996
65021
|
* spend one of the track's three retries.
|
|
64997
65022
|
*/
|
|
64998
65023
|
noteKeyFrameAttempt(deviceId, trackId, atMs, retry) {
|
|
64999
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
65024
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "noteKeyFrameAttempt");
|
|
65000
65025
|
if (resident === void 0) return;
|
|
65001
65026
|
resident.keyFrameLastAttemptAt = atMs;
|
|
65002
65027
|
if (retry) resident.keyFrameRetries += 1;
|
|
65003
65028
|
}
|
|
65004
65029
|
/** A `keyFrame` write landed — sticky, and the end of the retry path. */
|
|
65005
65030
|
markKeyFrameLanded(deviceId, trackId) {
|
|
65006
|
-
const resident = this.ensure(deviceId, trackId, "bestShot");
|
|
65031
|
+
const resident = this.ensure(deviceId, trackId, "bestShot", "markKeyFrameLanded");
|
|
65007
65032
|
if (resident !== void 0) resident.keyFrameLanded = true;
|
|
65008
65033
|
}
|
|
65009
65034
|
lifecycleUpdateMem(trackId) {
|
|
@@ -65056,7 +65081,7 @@ var TrackResidentState = class {
|
|
|
65056
65081
|
/** Retain the FIRST detection-raster crop per track (zero-media fallback);
|
|
65057
65082
|
* a later frame never overwrites an existing one. */
|
|
65058
65083
|
retainRasterFallback(deviceId, trackId, fallback) {
|
|
65059
|
-
const resident = this.ensure(deviceId, trackId);
|
|
65084
|
+
const resident = this.ensure(deviceId, trackId, "general", "retainRasterFallback");
|
|
65060
65085
|
if (resident !== void 0 && resident.rasterFallback === void 0) resident.rasterFallback = fallback;
|
|
65061
65086
|
}
|
|
65062
65087
|
};
|
|
@@ -110678,6 +110703,8 @@ var NO_PUBLICATION = {
|
|
|
110678
110703
|
url: null,
|
|
110679
110704
|
artifactId: null
|
|
110680
110705
|
};
|
|
110706
|
+
/** How often the resident-vs-live-track heartbeat line is written. */
|
|
110707
|
+
var RESIDENT_HEARTBEAT_INTERVAL_MS = 5 * 6e4;
|
|
110681
110708
|
/**
|
|
110682
110709
|
* A tRPC-shaped router or procedure reached by DYNAMIC name off `ctx.api`.
|
|
110683
110710
|
*
|
|
@@ -111758,12 +111785,13 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
111758
111785
|
this.parkedFrames?.adopt(survivorId, absorbedId, bestShotFrom);
|
|
111759
111786
|
},
|
|
111760
111787
|
onLateAbsorbedWork: (work) => {
|
|
111761
|
-
this.ctx.logger.info("track resident: late work
|
|
111788
|
+
this.ctx.logger.info("track resident: late work after close refused", {
|
|
111762
111789
|
tags: { deviceId: work.deviceId },
|
|
111763
111790
|
meta: {
|
|
111764
111791
|
trackId: work.trackId,
|
|
111765
111792
|
survivorId: work.survivorId,
|
|
111766
111793
|
reason: work.reason,
|
|
111794
|
+
kind: work.write,
|
|
111767
111795
|
refused: work.refused
|
|
111768
111796
|
}
|
|
111769
111797
|
});
|
|
@@ -115227,11 +115255,31 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
115227
115255
|
this.releaseProxy(deviceId);
|
|
115228
115256
|
this.notificationCenter?.onDeviceDeleted(deviceId);
|
|
115229
115257
|
}
|
|
115258
|
+
/** Wall-clock of the last resident heartbeat line. */
|
|
115259
|
+
residentHeartbeatAt = 0;
|
|
115260
|
+
/**
|
|
115261
|
+
* Resident records vs live tracks, once per interval: a resident count that
|
|
115262
|
+
* climbs past the live-track count is the signature of a record nothing
|
|
115263
|
+
* closes (the late-completion ghost fixed 2026-10-14).
|
|
115264
|
+
*/
|
|
115265
|
+
logResidentHeartbeat(now) {
|
|
115266
|
+
if (now - this.residentHeartbeatAt < RESIDENT_HEARTBEAT_INTERVAL_MS) return;
|
|
115267
|
+
this.residentHeartbeatAt = now;
|
|
115268
|
+
let liveTracks = 0;
|
|
115269
|
+
for (const ids of this.lastActiveTrackIds.values()) liveTracks += ids.size;
|
|
115270
|
+
const mem = process.memoryUsage();
|
|
115271
|
+
this.ctx.logger.info("analytics resident heartbeat", { meta: {
|
|
115272
|
+
residents: this.residents.size(),
|
|
115273
|
+
liveTracks,
|
|
115274
|
+
externalNonBufferMb: Math.max(0, Math.round((mem.external - mem.arrayBuffers) / 1048576))
|
|
115275
|
+
} });
|
|
115276
|
+
}
|
|
115230
115277
|
/** Periodic sweeps — TTL promotion + retention/stationary aging. */
|
|
115231
115278
|
startSweepTimers() {
|
|
115232
115279
|
this.ttlSweepTimer = setInterval(() => {
|
|
115233
115280
|
this.sweepExpiredTracks();
|
|
115234
115281
|
this.runPackageStillnessSweep(Date.now());
|
|
115282
|
+
this.logResidentHeartbeat(Date.now());
|
|
115235
115283
|
}, TTL_SWEEP_INTERVAL_MS);
|
|
115236
115284
|
this.faceReembedAutoTimer = setInterval(() => {
|
|
115237
115285
|
this.maybeAutoReembedFaces().then(() => this.faceAlignmentJobs?.maybeAutoRunPhotoPass());
|
|
@@ -116891,17 +116939,21 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
|
|
|
116891
116939
|
}),
|
|
116892
116940
|
holdKeys: heldCaptureKeys,
|
|
116893
116941
|
staleAfterMs: ENRICHMENT_CAPTURE_STALE_MS,
|
|
116894
|
-
exec: () => pinnedFramePromise.then((pinnedFrame) =>
|
|
116895
|
-
|
|
116896
|
-
|
|
116897
|
-
|
|
116898
|
-
|
|
116899
|
-
|
|
116900
|
-
|
|
116901
|
-
|
|
116902
|
-
|
|
116903
|
-
|
|
116904
|
-
|
|
116942
|
+
exec: () => pinnedFramePromise.then((pinnedFrame) => {
|
|
116943
|
+
const liveWanted = /* @__PURE__ */ new Set();
|
|
116944
|
+
for (const id of rasterFallbackWantedTrackIds) if (this.residents.isLive(id)) liveWanted.add(id);
|
|
116945
|
+
return dispatcher.captureForFrame({
|
|
116946
|
+
deviceId,
|
|
116947
|
+
frameHandle,
|
|
116948
|
+
events: eventTargets,
|
|
116949
|
+
trackFrames: firstFrameTargets,
|
|
116950
|
+
snapshots: snapshotTargets,
|
|
116951
|
+
cropPadding: mediaSettings.cropPadding,
|
|
116952
|
+
rasterFallbackWantedTrackIds: liveWanted,
|
|
116953
|
+
rasterFallbackCandidates: rasterFallbackCandidates.filter((c) => this.residents.isLive(c.trackId)),
|
|
116954
|
+
...pinnedFrame !== null ? { pinnedFrame } : {}
|
|
116955
|
+
});
|
|
116956
|
+
}).then((res) => {
|
|
116905
116957
|
for (const rf of res.rasterFallbacks) this.residents.retainRasterFallback(deviceId, rf.trackId, {
|
|
116906
116958
|
jpeg: rf.jpeg,
|
|
116907
116959
|
timestamp: rf.timestamp
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/addon-post-analysis",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.362",
|
|
4
4
|
"description": "Post-Analysis bundle — enrichment, embedding-encoder, pipeline-analytics. Multi-entry npm package shipping addons that consume pipeline output.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"camstack",
|