@camstack/addon-post-analysis 1.2.211 → 1.2.212

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.
@@ -7823,6 +7823,226 @@ var CameraSwitchGroupSchema = object({
7823
7823
  */
7824
7824
  var DETECTION_PIPELINE_CAP_NAME = "detection-pipeline";
7825
7825
  /**
7826
+ * Birth-decision ledger — one durable row per track-birth VERDICT (D409).
7827
+ *
7828
+ * ── Why this exists ────────────────────────────────────────────────────────
7829
+ * On 2026-09-08 the operator marked eleven tracks for review and five of them
7830
+ * said "traccia partita in ritardo" — the track appears to begin long after the
7831
+ * subject entered the scene. Two causes were proposed and NEITHER was measured:
7832
+ *
7833
+ * - the confirmation gate's deferral (`maxDeferralMs`, 2 s). This is now
7834
+ * DISPROVEN as a cause of a late TIMELINE: a track's `firstSeen` and its
7835
+ * first position are the CANDIDATE's first frame, not the confirmation's.
7836
+ * Verified on `d035f251` (device 3829): first position == `firstSeen`, with
7837
+ * confirmation 2 163 ms later.
7838
+ * - the detector simply not firing until the subject is well into the scene.
7839
+ * Unmeasured, and the reason this table exists.
7840
+ *
7841
+ * A second, real defect is also unquantified. The deferred-birth re-offer in
7842
+ * `index.ts` takes the track from `result.tracked` with NO `matchedThisFrame`
7843
+ * check, so a birth can be CONFIRMED on a frame the subject was never observed
7844
+ * in. D379's carried birth evidence means some of those confirmations rest on a
7845
+ * real observation of the birth instant anyway — and how often is exactly what
7846
+ * nobody knows. {@link BirthDecisionRecord.decidedOnCoastedFrame} and
7847
+ * {@link BirthDecisionRecord.decidedByBirthEvidence} are the two columns that
7848
+ * answer it together.
7849
+ *
7850
+ * ── Why a TABLE and not a log line ─────────────────────────────────────────
7851
+ * `logs.query` is an in-memory ring. Measured on the live hub on 2026-09-08 it
7852
+ * held 40 000 entries covering 38 minutes — the whole ring is under an hour of
7853
+ * fleet traffic. Every question this data is for ("how often, on camera 617,
7854
+ * over the week the operator complained about") outlives that ring by two
7855
+ * orders of magnitude, and a previous investigation in this repo was blocked
7856
+ * for precisely this reason. The gate ALREADY writes a log line per decision
7857
+ * (`confirmation gate: birth confirmed/suppressed/undecided`); adding a
7858
+ * fourteenth field to it would answer nothing a day later.
7859
+ *
7860
+ * This is a MEASUREMENT table. It changes no behaviour, gates nothing, and
7861
+ * nothing reads it on the frame path.
7862
+ */
7863
+ /**
7864
+ * How many birth decisions the cluster keeps, across every camera.
7865
+ *
7866
+ * Sized off a MEASURED rate, not a guess. Fleet-wide on the live hub,
7867
+ * 2026-09-08 20:16 local, over the 38 minutes the log ring covered: 17 `track
7868
+ * started` + 14 `birth suppressed — track record retracted` = 31 decided
7869
+ * births, i.e. ~49/hour, ~1 200/day. Call a busy daytime hour five times that
7870
+ * and the fleet writes ~6 000 rows/day.
7871
+ *
7872
+ * 30 000 rows is therefore ~25 days at the measured rate and ~5 days at five
7873
+ * times it — comfortably past "a few days of traffic", which is the bar the
7874
+ * operator's week-long complaint sets. At ~200 bytes a row the ceiling is
7875
+ * ~6 MB, against a `tracks` table measured at 4.6 MB for a single 501-row page.
7876
+ *
7877
+ * A COUNT and not an age, for the same reason as the debug-note archive: the
7878
+ * denominator of a miss rate is only meaningful over whatever window the table
7879
+ * actually holds, and a quiet fleet should keep more of it, not less. Trimmed
7880
+ * oldest-first on append.
7881
+ */
7882
+ var MAX_BIRTH_DECISION_RECORDS = 3e4;
7883
+ /**
7884
+ * How stale a motion onset may be and still be offered as the birth-latency
7885
+ * proxy. Beyond this the row records `null`, never a large number.
7886
+ *
7887
+ * 60 s is one order of magnitude above the latency being measured (the
7888
+ * complaint is "seconds late") and one below the duration of a busy scene's
7889
+ * continuous motion burst, where the onset is minutes old and says nothing
7890
+ * about THIS subject. See {@link BirthDecisionRecord.birthLatencyMs} for the
7891
+ * full error bars.
7892
+ */
7893
+ var MAX_BIRTH_LATENCY_PROXY_MS = 6e4;
7894
+ /**
7895
+ * What the gate decided about a birth, from the CALLER's point of view.
7896
+ *
7897
+ * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
7898
+ * at all — it is a deferral, and the row is written when the deferral ENDS.
7899
+ * The third member is the one the gate's own type cannot express, because
7900
+ * exhaustion is a property of how long the caller waited.
7901
+ */
7902
+ var BirthDecisionVerdictSchema = _enum([
7903
+ "confirmed",
7904
+ "suppressed",
7905
+ "exhausted-fallback"
7906
+ ]);
7907
+ /** One birth decision, as it is kept. */
7908
+ var BirthDecisionRecordSchema = object({
7909
+ id: string(),
7910
+ /** Epoch ms the VERDICT was taken (not the birth instant — see `firstSeen`). */
7911
+ at: number().int(),
7912
+ /** The camera. Required: every question here is asked per-camera. */
7913
+ deviceId: number().int(),
7914
+ /**
7915
+ * The track the decision was about. PROVENANCE, not ownership — a suppressed
7916
+ * birth has no track at all, and a confirmed one is expected to age out long
7917
+ * before this row does. Named `sourceTrackId` so the retention model's
7918
+ * ownership derivation (`collection-classification.ts`, which keys on a
7919
+ * column literally called `trackId`) cannot reach it.
7920
+ */
7921
+ sourceTrackId: string(),
7922
+ /** The candidate's claimed class. The miss rate is asked per class too. */
7923
+ className: string(),
7924
+ verdict: BirthDecisionVerdictSchema,
7925
+ /**
7926
+ * The gate's own `ConfirmationReason` (`confirmed`, `suppressed`,
7927
+ * `native-pass`, `no-crop`, `timeout`, `carried-inconclusive`, …), or `null`
7928
+ * when the gate is DISABLED and every birth is waved through. `null` is not
7929
+ * "unknown": it says the gate took no measurement because it was off, which
7930
+ * is a different population and must never be averaged in with the rest.
7931
+ */
7932
+ reason: string().nullable(),
7933
+ /** Deferral attempts this birth used. 0 = decided on its first look. */
7934
+ attempts: number().int(),
7935
+ /** Ms from the FIRST undecided attempt to this verdict. 0 = never deferred. */
7936
+ deferredForMs: number().int(),
7937
+ /**
7938
+ * THE COLUMN THE RE-OFFER DEFECT IS COUNTED IN.
7939
+ *
7940
+ * `true` when the frame the verdict was taken on carried no matched
7941
+ * detection for this track — the tracker was coasting a frozen box and the
7942
+ * subject was not observed. The deferred-birth re-offer pulls the candidate
7943
+ * straight out of `result.tracked` without checking, so this is reachable
7944
+ * today; the question is the RATE, per camera, and whether refusing those
7945
+ * frames would have cost real tracks (cross-read against `verdict` and
7946
+ * `decidedByBirthEvidence`).
7947
+ */
7948
+ decidedOnCoastedFrame: boolean(),
7949
+ /** Were D379 birth-instant pixels in hand when this candidate was submitted? */
7950
+ birthEvidenceAvailable: boolean(),
7951
+ /**
7952
+ * Did those pixels DECIDE it (`cropSource === 'carried'`)? Available and
7953
+ * deciding are different: the carried crop is confirm-only, so a candidate
7954
+ * can hold evidence, be found inconclusive on it, and be decided by a native
7955
+ * crop of a later instant. A coasted decision backed by carried evidence is
7956
+ * a real observation of the birth instant; one without it is not.
7957
+ */
7958
+ decidedByBirthEvidence: boolean(),
7959
+ /** Best class-compatible crop score, or `null` when nothing compatible was
7960
+ * found — deliberately not 0, which would be a measurement that never was. */
7961
+ bestScore: number().nullable(),
7962
+ /** The bar this candidate actually faced (the phantom-cell hook may raise it). */
7963
+ appliedMinConfidence: number().nullable(),
7964
+ /**
7965
+ * The track's own `firstSeen` — the candidate's first frame, which is where
7966
+ * the timeline starts. `null` for a suppressed birth, which has no track.
7967
+ */
7968
+ firstSeen: number().int().nullable(),
7969
+ /**
7970
+ * The device's most recent motion RISING EDGE at the moment of the decision,
7971
+ * or `null` when there is none, it is older than
7972
+ * {@link MAX_BIRTH_LATENCY_PROXY_MS}, or this runner never saw one.
7973
+ */
7974
+ motionOnsetAt: number().int().nullable(),
7975
+ /**
7976
+ * `firstSeen − motionOnsetAt` — THE OPERATOR'S COMPLAINT, IN MILLISECONDS,
7977
+ * AND THE WEAKEST NUMBER IN THIS ROW. Read the error bars before quoting it.
7978
+ *
7979
+ * **Why motion onset and not something else.** Two other proxies were
7980
+ * considered and rejected:
7981
+ * - *the recording/pipeline session start*: for a camera on
7982
+ * `detectionMode: 'always'` the session opens at process start, hours
7983
+ * before any subject. It measures nothing.
7984
+ * - *the first detection on the device in this burst*: CIRCULAR. A track's
7985
+ * `firstSeen` IS the first detection of that object, so for the track that
7986
+ * OPENS a burst — the only one the operator is complaining about — the two
7987
+ * are the same instant and the latency is 0 by construction.
7988
+ * Motion onset is the only in-process signal produced by a DIFFERENT
7989
+ * mechanism from the object detector, so it is the only one that can precede
7990
+ * it. It is also already maintained per-device at frame rate on this very
7991
+ * node (`handleMotionAnalysis` / `handleOnboardMotion`), which is what makes
7992
+ * it free — and, decisively, the frame path and the motion path are gated to
7993
+ * the SAME designated post-processing node, so the mirror is never empty for
7994
+ * a camera whose births land here.
7995
+ *
7996
+ * **Error bars, all of them.**
7997
+ * 1. *Motion has no class.* A burst opened by rain, a headlight sweeping a
7998
+ * wall or a branch, and only later joined by the person, OVERSTATES the
7999
+ * latency without bound. Mitigated, never removed, by
8000
+ * {@link BirthDecisionRecord.birthIndexInBurst}: only index 0 is a
8001
+ * candidate for "this burst is this subject", and even then it is a
8002
+ * candidate, not a fact.
8003
+ * 2. *The sign is not guaranteed.* The analyzer needs a pixel-count and
8004
+ * intensity threshold. A subject entering slowly at the far edge of the
8005
+ * frame can clear the detector's confidence floor BEFORE it clears the
8006
+ * motion floor, making this negative. Negatives are stored as-is and
8007
+ * never clamped — clamping would fabricate the distribution's left tail,
8008
+ * which is the half that says the proxy is unreliable.
8009
+ * 3. *Onboard motion carries firmware latency of unknown, per-model offset*
8010
+ * (hundreds of ms), plus camera-vs-hub clock skew on top. Numbers are
8011
+ * therefore comparable WITHIN a camera and not across cameras of
8012
+ * different motion sources. The motion source is deliberately not copied
8013
+ * here — it belongs to the addon that owns the device (D224) and this is
8014
+ * a write on the frame path — so group by `deviceId`, which is how the
8015
+ * question is always asked anyway.
8016
+ * 4. *Continuous motion.* On a busy scene the burst never closes and the
8017
+ * onset is minutes old. Bounded by {@link MAX_BIRTH_LATENCY_PROXY_MS};
8018
+ * past it this is `null`.
8019
+ * 5. *No motion signal at all* — analyzer off, onboard-only camera not
8020
+ * reporting, or nothing since boot: `null`. Which is the truth about a
8021
+ * camera nobody has a reference instant for.
8022
+ *
8023
+ * So this is a per-camera DISTRIBUTION over index-0 births, and it is honest
8024
+ * as such. It is not a per-track fact and must never be shown as one.
8025
+ */
8026
+ birthLatencyMs: number().int().nullable(),
8027
+ /**
8028
+ * How many births this device has already decided since that motion onset.
8029
+ * 0 = the first, i.e. the only index at which the burst plausibly belongs to
8030
+ * this subject. `null` when there is no usable onset.
8031
+ */
8032
+ birthIndexInBurst: number().int().nullable()
8033
+ });
8034
+ /** Query input for `listBirthDecisions` — newest first, one camera or all. */
8035
+ var BirthDecisionQueryInputSchema = object({
8036
+ /** Restrict to a single camera; omit for every row. */
8037
+ deviceId: number().int().optional(),
8038
+ /** Only decisions at or after this epoch ms. */
8039
+ since: number().int().optional(),
8040
+ /** Restrict to one verdict — the miss rate is read one population at a time. */
8041
+ verdict: BirthDecisionVerdictSchema.optional(),
8042
+ /** Max rows returned, newest-first. */
8043
+ limit: number().int().min(1).max(5e3).optional()
8044
+ });
8045
+ /**
7826
8046
  * Debug-note archive — the durable corpus of what operators asked to be
7827
8047
  * checked, and the ONE thing about a debug note that outlives its track.
7828
8048
  *
@@ -21462,6 +21682,26 @@ var pipelineAnalyticsCapability = {
21462
21682
  */
21463
21683
  listArchivedDebugNotes: method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }),
21464
21684
  /**
21685
+ * Birth decisions — one row per resolved confirmation-gate verdict (D409).
21686
+ *
21687
+ * The READ half of a measurement, and only that: it gates nothing and no
21688
+ * runtime path consults it. It exists because the two questions the
21689
+ * operator's "traccia partita in ritardo" marks raised are both multi-day
21690
+ * and `logs.query` holds under an hour of fleet traffic —
21691
+ * • how often is a birth DECIDED on a frame the subject was not observed
21692
+ * in (`decidedOnCoastedFrame`), and did D379's carried pixels make it a
21693
+ * real observation anyway (`decidedByBirthEvidence`);
21694
+ * • how long after the camera's motion onset does a track's `firstSeen`
21695
+ * land (`birthLatencyMs` — read its error bars in
21696
+ * `BirthDecisionRecordSchema` before quoting it).
21697
+ *
21698
+ * Newest-first, capped by `limit` (default
21699
+ * {@link BIRTH_DECISION_DEFAULT_LIMIT}), optionally scoped to one camera,
21700
+ * one verdict, or a `since`. The table is bounded by row count, not age —
21701
+ * see {@link MAX_BIRTH_DECISION_RECORDS}.
21702
+ */
21703
+ listBirthDecisions: method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }),
21704
+ /**
21465
21705
  * Durable event-store footprint for the management UI: event rows
21466
21706
  * (motion + object + audio) counted per camera + total, plus the
21467
21707
  * event-owned media bytes on disk per camera + total. Stat/count-based,
@@ -39139,6 +39379,12 @@ Object.freeze({
39139
39379
  addonId: null,
39140
39380
  access: "view"
39141
39381
  },
39382
+ "pipelineAnalytics.listBirthDecisions": {
39383
+ capName: "pipeline-analytics",
39384
+ capScope: "device",
39385
+ addonId: null,
39386
+ access: "view"
39387
+ },
39142
39388
  "pipelineAnalytics.listEventKinds": {
39143
39389
  capName: "pipeline-analytics",
39144
39390
  capScope: "device",
@@ -42931,6 +43177,11 @@ Object.freeze({
42931
43177
  form: "single",
42932
43178
  optional: true
42933
43179
  }],
43180
+ "pipelineAnalytics.listBirthDecisions": [{
43181
+ name: "deviceId",
43182
+ form: "single",
43183
+ optional: true
43184
+ }],
42934
43185
  "pipelineAnalytics.listEventKinds": [{
42935
43186
  name: "deviceId",
42936
43187
  form: "single",
@@ -44857,4 +45108,4 @@ function vectorDimFromBase64(encoded) {
44857
45108
  return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
44858
45109
  }
44859
45110
  //#endregion
44860
- export { assertTimelapseCadences as $, string as $t, NcScheduleSchema as A, subKindsOf as At, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS as B, hydrateSchema as Bt, NC_SNOOZE_MAX_MINUTES as C, plateGalleryCapability as Ct, NcRulePatchSchema as D, resolvePoolMemoryPolicy as Dt, NcRuleInputSchema as E, resolveLocationMode as Et, NcTaxonomySchema as F, errMsg as Ft, TIMELAPSE_DENSE_FLOOR_SEC as G, array as Gt, SCENE_DEFAULT_UNCOVERED_POLICY as H, nodePin as Ht, OpsLogEntrySchema as I, BaseAddon as It, TimelapseRuleSchema as J, literal as Jt, TimelapseRuleInputSchema as K, boolean as Kt, PoolMemoryWatchdog as L, CamProfileSchema as Lt, NcSnoozeSchema as M, vectorDimFromBase64 as Mt, NcSnoozeSuppressedSchema as N, videoclipsCapability as Nt, NcRuleSchema as O, sceneMonitorCapability as Ot, NcSystemEventKindSchema as P, zoneAnalyticsCapability as Pt, alarmPanelCapability as Q, record as Qt, RECORDING_EXPORT_MAX_READ_BYTES as R, DeviceType as Rt, NC_DEFAULT_SNOOZE_MINUTES as S, pipelineAnalyticsCapability as St, NcConditionDescriptorSchema as T, readTimelapseGeneratedAt as Tt, SCENE_DIVERGED as U, sleep as Ut, SCENE_DEFAULT_ANCHOR_THRESHOLD as V, isDeviceScopedCap as Vt, SceneMonitorSchema as W, _enum as Wt, VISIT_MERGE_GAP_MS as X, object as Xt, TrackSourceSchema as Y, number as Yt, addonWidgetsSourceCapability as Z, partialRecord as Zt, MACRO_LABELS as _, kebabToCamel as _t, COCO_TO_MACRO as a, defineCustomActions as at, NC_ALARM_SYSTEM_EVENT_KINDS as b, parseProcStatus as bt, DEFAULT_TIMELAPSE_PREVIEW_TEXT as c, encodeVectorBase64 as ct, DeclaredDevices as d, faceGalleryCapability as dt, unknown as en, audioMetricsCapability as et, EVENT_KIND_BY_CAP as f, failureContributionCapability as ft, LabelAttributionSchema as g, isSourceCap as gt, FailureCounters as h, isScheduleActive as ht, CLUSTER_MODEL_SCOPED_STEPS as i, customAction as it, NcSnoozeInputSchema as j, systemEventFilterApplies as jt, NcRuleTargetSchema as k, storageOccupancyCapability as kt, DETECTION_MACRO_CLASSES as l, evaluateSensorEdge as lt, FULL_IMAGE_BBOX as m, isDetectionMacroClass as mt, ArchivedDebugNoteSchema as n, buildEventKindDescriptor as nt, DEFAULT_EVENT_COLOR as o, deriveRecordingMode as ot, EVENT_PAD_MS as p, hfModelUrl as pt, TimelapseRulePatchSchema as q, discriminatedUnion as qt, BaseDevice as r, cosineSimilarity as rt, DEFAULT_FIRST_SIGHTING_FRESHNESS_MS as s, embeddingEncoderCapability as st, AUDIO_MACRO_LABELS as t, EventCategory as tn, audioModeOf as tt, DETECTION_PIPELINE_CAP_NAME as u, evictionPolicyOfLocation as ut, MAX_ARCHIVED_DEBUG_NOTES as v, mayWriteToLocation as vt, NC_TAXONOMY as w, readDeviceStateFrom as wt, NC_CONDITION_CATALOG as x, pickClusterStepModels as xt, MediaFileKindEnum as y, notificationRulesCapability as yt, RetrainStatusSchema as z, createEvent as zt };
45111
+ export { VISIT_MERGE_GAP_MS as $, object as $t, NcRulePatchSchema as A, resolvePoolMemoryPolicy as At, PoolMemoryWatchdog as B, CamProfileSchema as Bt, NC_ALARM_SYSTEM_EVENT_KINDS as C, parseProcStatus as Ct, NC_TAXONOMY as D, readDeviceStateFrom as Dt, NC_SNOOZE_MAX_MINUTES as E, plateGalleryCapability as Et, NcSnoozeSchema as F, vectorDimFromBase64 as Ft, SCENE_DEFAULT_UNCOVERED_POLICY as G, nodePin as Gt, RetrainStatusSchema as H, createEvent as Ht, NcSnoozeSuppressedSchema as I, videoclipsCapability as It, TIMELAPSE_DENSE_FLOOR_SEC as J, array as Jt, SCENE_DIVERGED as K, sleep as Kt, NcSystemEventKindSchema as L, zoneAnalyticsCapability as Lt, NcRuleTargetSchema as M, storageOccupancyCapability as Mt, NcScheduleSchema as N, subKindsOf as Nt, NcConditionDescriptorSchema as O, readTimelapseGeneratedAt as Ot, NcSnoozeInputSchema as P, systemEventFilterApplies as Pt, TrackSourceSchema as Q, number as Qt, NcTaxonomySchema as R, errMsg as Rt, MediaFileKindEnum as S, notificationRulesCapability as St, NC_DEFAULT_SNOOZE_MINUTES as T, pipelineAnalyticsCapability as Tt, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS as U, hydrateSchema as Ut, RECORDING_EXPORT_MAX_READ_BYTES as V, DeviceType as Vt, SCENE_DEFAULT_ANCHOR_THRESHOLD as W, isDeviceScopedCap as Wt, TimelapseRulePatchSchema as X, discriminatedUnion as Xt, TimelapseRuleInputSchema as Y, boolean as Yt, TimelapseRuleSchema as Z, literal as Zt, LabelAttributionSchema as _, isDetectionMacroClass as _t, CLUSTER_MODEL_SCOPED_STEPS as a, buildEventKindDescriptor as at, MAX_BIRTH_DECISION_RECORDS as b, kebabToCamel as bt, DEFAULT_FIRST_SIGHTING_FRESHNESS_MS as c, defineCustomActions as ct, DETECTION_PIPELINE_CAP_NAME as d, encodeVectorBase64 as dt, partialRecord as en, addonWidgetsSourceCapability as et, DeclaredDevices as f, evaluateSensorEdge as ft, FailureCounters as g, hfModelUrl as gt, FULL_IMAGE_BBOX as h, failureContributionCapability as ht, BirthDecisionRecordSchema as i, EventCategory as in, audioModeOf as it, NcRuleSchema as j, sceneMonitorCapability as jt, NcRuleInputSchema as k, resolveLocationMode as kt, DEFAULT_TIMELAPSE_PREVIEW_TEXT as l, deriveRecordingMode as lt, EVENT_PAD_MS as m, faceGalleryCapability as mt, ArchivedDebugNoteSchema as n, string as nn, assertTimelapseCadences as nt, COCO_TO_MACRO as o, cosineSimilarity as ot, EVENT_KIND_BY_CAP as p, evictionPolicyOfLocation as pt, SceneMonitorSchema as q, _enum as qt, BaseDevice as r, unknown as rn, audioMetricsCapability as rt, DEFAULT_EVENT_COLOR as s, customAction as st, AUDIO_MACRO_LABELS as t, record as tn, alarmPanelCapability as tt, DETECTION_MACRO_CLASSES as u, embeddingEncoderCapability as ut, MACRO_LABELS as v, isScheduleActive as vt, NC_CONDITION_CATALOG as w, pickClusterStepModels as wt, MAX_BIRTH_LATENCY_PROXY_MS as x, mayWriteToLocation as xt, MAX_ARCHIVED_DEBUG_NOTES as y, isSourceCap as yt, OpsLogEntrySchema as z, BaseAddon as zt };
@@ -7854,6 +7854,226 @@ var CameraSwitchGroupSchema = object({
7854
7854
  */
7855
7855
  var DETECTION_PIPELINE_CAP_NAME = "detection-pipeline";
7856
7856
  /**
7857
+ * Birth-decision ledger — one durable row per track-birth VERDICT (D409).
7858
+ *
7859
+ * ── Why this exists ────────────────────────────────────────────────────────
7860
+ * On 2026-09-08 the operator marked eleven tracks for review and five of them
7861
+ * said "traccia partita in ritardo" — the track appears to begin long after the
7862
+ * subject entered the scene. Two causes were proposed and NEITHER was measured:
7863
+ *
7864
+ * - the confirmation gate's deferral (`maxDeferralMs`, 2 s). This is now
7865
+ * DISPROVEN as a cause of a late TIMELINE: a track's `firstSeen` and its
7866
+ * first position are the CANDIDATE's first frame, not the confirmation's.
7867
+ * Verified on `d035f251` (device 3829): first position == `firstSeen`, with
7868
+ * confirmation 2 163 ms later.
7869
+ * - the detector simply not firing until the subject is well into the scene.
7870
+ * Unmeasured, and the reason this table exists.
7871
+ *
7872
+ * A second, real defect is also unquantified. The deferred-birth re-offer in
7873
+ * `index.ts` takes the track from `result.tracked` with NO `matchedThisFrame`
7874
+ * check, so a birth can be CONFIRMED on a frame the subject was never observed
7875
+ * in. D379's carried birth evidence means some of those confirmations rest on a
7876
+ * real observation of the birth instant anyway — and how often is exactly what
7877
+ * nobody knows. {@link BirthDecisionRecord.decidedOnCoastedFrame} and
7878
+ * {@link BirthDecisionRecord.decidedByBirthEvidence} are the two columns that
7879
+ * answer it together.
7880
+ *
7881
+ * ── Why a TABLE and not a log line ─────────────────────────────────────────
7882
+ * `logs.query` is an in-memory ring. Measured on the live hub on 2026-09-08 it
7883
+ * held 40 000 entries covering 38 minutes — the whole ring is under an hour of
7884
+ * fleet traffic. Every question this data is for ("how often, on camera 617,
7885
+ * over the week the operator complained about") outlives that ring by two
7886
+ * orders of magnitude, and a previous investigation in this repo was blocked
7887
+ * for precisely this reason. The gate ALREADY writes a log line per decision
7888
+ * (`confirmation gate: birth confirmed/suppressed/undecided`); adding a
7889
+ * fourteenth field to it would answer nothing a day later.
7890
+ *
7891
+ * This is a MEASUREMENT table. It changes no behaviour, gates nothing, and
7892
+ * nothing reads it on the frame path.
7893
+ */
7894
+ /**
7895
+ * How many birth decisions the cluster keeps, across every camera.
7896
+ *
7897
+ * Sized off a MEASURED rate, not a guess. Fleet-wide on the live hub,
7898
+ * 2026-09-08 20:16 local, over the 38 minutes the log ring covered: 17 `track
7899
+ * started` + 14 `birth suppressed — track record retracted` = 31 decided
7900
+ * births, i.e. ~49/hour, ~1 200/day. Call a busy daytime hour five times that
7901
+ * and the fleet writes ~6 000 rows/day.
7902
+ *
7903
+ * 30 000 rows is therefore ~25 days at the measured rate and ~5 days at five
7904
+ * times it — comfortably past "a few days of traffic", which is the bar the
7905
+ * operator's week-long complaint sets. At ~200 bytes a row the ceiling is
7906
+ * ~6 MB, against a `tracks` table measured at 4.6 MB for a single 501-row page.
7907
+ *
7908
+ * A COUNT and not an age, for the same reason as the debug-note archive: the
7909
+ * denominator of a miss rate is only meaningful over whatever window the table
7910
+ * actually holds, and a quiet fleet should keep more of it, not less. Trimmed
7911
+ * oldest-first on append.
7912
+ */
7913
+ var MAX_BIRTH_DECISION_RECORDS = 3e4;
7914
+ /**
7915
+ * How stale a motion onset may be and still be offered as the birth-latency
7916
+ * proxy. Beyond this the row records `null`, never a large number.
7917
+ *
7918
+ * 60 s is one order of magnitude above the latency being measured (the
7919
+ * complaint is "seconds late") and one below the duration of a busy scene's
7920
+ * continuous motion burst, where the onset is minutes old and says nothing
7921
+ * about THIS subject. See {@link BirthDecisionRecord.birthLatencyMs} for the
7922
+ * full error bars.
7923
+ */
7924
+ var MAX_BIRTH_LATENCY_PROXY_MS = 6e4;
7925
+ /**
7926
+ * What the gate decided about a birth, from the CALLER's point of view.
7927
+ *
7928
+ * Deliberately not `ConfirmationVerdict`: `undecided` is not a birth decision
7929
+ * at all — it is a deferral, and the row is written when the deferral ENDS.
7930
+ * The third member is the one the gate's own type cannot express, because
7931
+ * exhaustion is a property of how long the caller waited.
7932
+ */
7933
+ var BirthDecisionVerdictSchema = _enum([
7934
+ "confirmed",
7935
+ "suppressed",
7936
+ "exhausted-fallback"
7937
+ ]);
7938
+ /** One birth decision, as it is kept. */
7939
+ var BirthDecisionRecordSchema = object({
7940
+ id: string(),
7941
+ /** Epoch ms the VERDICT was taken (not the birth instant — see `firstSeen`). */
7942
+ at: number().int(),
7943
+ /** The camera. Required: every question here is asked per-camera. */
7944
+ deviceId: number().int(),
7945
+ /**
7946
+ * The track the decision was about. PROVENANCE, not ownership — a suppressed
7947
+ * birth has no track at all, and a confirmed one is expected to age out long
7948
+ * before this row does. Named `sourceTrackId` so the retention model's
7949
+ * ownership derivation (`collection-classification.ts`, which keys on a
7950
+ * column literally called `trackId`) cannot reach it.
7951
+ */
7952
+ sourceTrackId: string(),
7953
+ /** The candidate's claimed class. The miss rate is asked per class too. */
7954
+ className: string(),
7955
+ verdict: BirthDecisionVerdictSchema,
7956
+ /**
7957
+ * The gate's own `ConfirmationReason` (`confirmed`, `suppressed`,
7958
+ * `native-pass`, `no-crop`, `timeout`, `carried-inconclusive`, …), or `null`
7959
+ * when the gate is DISABLED and every birth is waved through. `null` is not
7960
+ * "unknown": it says the gate took no measurement because it was off, which
7961
+ * is a different population and must never be averaged in with the rest.
7962
+ */
7963
+ reason: string().nullable(),
7964
+ /** Deferral attempts this birth used. 0 = decided on its first look. */
7965
+ attempts: number().int(),
7966
+ /** Ms from the FIRST undecided attempt to this verdict. 0 = never deferred. */
7967
+ deferredForMs: number().int(),
7968
+ /**
7969
+ * THE COLUMN THE RE-OFFER DEFECT IS COUNTED IN.
7970
+ *
7971
+ * `true` when the frame the verdict was taken on carried no matched
7972
+ * detection for this track — the tracker was coasting a frozen box and the
7973
+ * subject was not observed. The deferred-birth re-offer pulls the candidate
7974
+ * straight out of `result.tracked` without checking, so this is reachable
7975
+ * today; the question is the RATE, per camera, and whether refusing those
7976
+ * frames would have cost real tracks (cross-read against `verdict` and
7977
+ * `decidedByBirthEvidence`).
7978
+ */
7979
+ decidedOnCoastedFrame: boolean(),
7980
+ /** Were D379 birth-instant pixels in hand when this candidate was submitted? */
7981
+ birthEvidenceAvailable: boolean(),
7982
+ /**
7983
+ * Did those pixels DECIDE it (`cropSource === 'carried'`)? Available and
7984
+ * deciding are different: the carried crop is confirm-only, so a candidate
7985
+ * can hold evidence, be found inconclusive on it, and be decided by a native
7986
+ * crop of a later instant. A coasted decision backed by carried evidence is
7987
+ * a real observation of the birth instant; one without it is not.
7988
+ */
7989
+ decidedByBirthEvidence: boolean(),
7990
+ /** Best class-compatible crop score, or `null` when nothing compatible was
7991
+ * found — deliberately not 0, which would be a measurement that never was. */
7992
+ bestScore: number().nullable(),
7993
+ /** The bar this candidate actually faced (the phantom-cell hook may raise it). */
7994
+ appliedMinConfidence: number().nullable(),
7995
+ /**
7996
+ * The track's own `firstSeen` — the candidate's first frame, which is where
7997
+ * the timeline starts. `null` for a suppressed birth, which has no track.
7998
+ */
7999
+ firstSeen: number().int().nullable(),
8000
+ /**
8001
+ * The device's most recent motion RISING EDGE at the moment of the decision,
8002
+ * or `null` when there is none, it is older than
8003
+ * {@link MAX_BIRTH_LATENCY_PROXY_MS}, or this runner never saw one.
8004
+ */
8005
+ motionOnsetAt: number().int().nullable(),
8006
+ /**
8007
+ * `firstSeen − motionOnsetAt` — THE OPERATOR'S COMPLAINT, IN MILLISECONDS,
8008
+ * AND THE WEAKEST NUMBER IN THIS ROW. Read the error bars before quoting it.
8009
+ *
8010
+ * **Why motion onset and not something else.** Two other proxies were
8011
+ * considered and rejected:
8012
+ * - *the recording/pipeline session start*: for a camera on
8013
+ * `detectionMode: 'always'` the session opens at process start, hours
8014
+ * before any subject. It measures nothing.
8015
+ * - *the first detection on the device in this burst*: CIRCULAR. A track's
8016
+ * `firstSeen` IS the first detection of that object, so for the track that
8017
+ * OPENS a burst — the only one the operator is complaining about — the two
8018
+ * are the same instant and the latency is 0 by construction.
8019
+ * Motion onset is the only in-process signal produced by a DIFFERENT
8020
+ * mechanism from the object detector, so it is the only one that can precede
8021
+ * it. It is also already maintained per-device at frame rate on this very
8022
+ * node (`handleMotionAnalysis` / `handleOnboardMotion`), which is what makes
8023
+ * it free — and, decisively, the frame path and the motion path are gated to
8024
+ * the SAME designated post-processing node, so the mirror is never empty for
8025
+ * a camera whose births land here.
8026
+ *
8027
+ * **Error bars, all of them.**
8028
+ * 1. *Motion has no class.* A burst opened by rain, a headlight sweeping a
8029
+ * wall or a branch, and only later joined by the person, OVERSTATES the
8030
+ * latency without bound. Mitigated, never removed, by
8031
+ * {@link BirthDecisionRecord.birthIndexInBurst}: only index 0 is a
8032
+ * candidate for "this burst is this subject", and even then it is a
8033
+ * candidate, not a fact.
8034
+ * 2. *The sign is not guaranteed.* The analyzer needs a pixel-count and
8035
+ * intensity threshold. A subject entering slowly at the far edge of the
8036
+ * frame can clear the detector's confidence floor BEFORE it clears the
8037
+ * motion floor, making this negative. Negatives are stored as-is and
8038
+ * never clamped — clamping would fabricate the distribution's left tail,
8039
+ * which is the half that says the proxy is unreliable.
8040
+ * 3. *Onboard motion carries firmware latency of unknown, per-model offset*
8041
+ * (hundreds of ms), plus camera-vs-hub clock skew on top. Numbers are
8042
+ * therefore comparable WITHIN a camera and not across cameras of
8043
+ * different motion sources. The motion source is deliberately not copied
8044
+ * here — it belongs to the addon that owns the device (D224) and this is
8045
+ * a write on the frame path — so group by `deviceId`, which is how the
8046
+ * question is always asked anyway.
8047
+ * 4. *Continuous motion.* On a busy scene the burst never closes and the
8048
+ * onset is minutes old. Bounded by {@link MAX_BIRTH_LATENCY_PROXY_MS};
8049
+ * past it this is `null`.
8050
+ * 5. *No motion signal at all* — analyzer off, onboard-only camera not
8051
+ * reporting, or nothing since boot: `null`. Which is the truth about a
8052
+ * camera nobody has a reference instant for.
8053
+ *
8054
+ * So this is a per-camera DISTRIBUTION over index-0 births, and it is honest
8055
+ * as such. It is not a per-track fact and must never be shown as one.
8056
+ */
8057
+ birthLatencyMs: number().int().nullable(),
8058
+ /**
8059
+ * How many births this device has already decided since that motion onset.
8060
+ * 0 = the first, i.e. the only index at which the burst plausibly belongs to
8061
+ * this subject. `null` when there is no usable onset.
8062
+ */
8063
+ birthIndexInBurst: number().int().nullable()
8064
+ });
8065
+ /** Query input for `listBirthDecisions` — newest first, one camera or all. */
8066
+ var BirthDecisionQueryInputSchema = object({
8067
+ /** Restrict to a single camera; omit for every row. */
8068
+ deviceId: number().int().optional(),
8069
+ /** Only decisions at or after this epoch ms. */
8070
+ since: number().int().optional(),
8071
+ /** Restrict to one verdict — the miss rate is read one population at a time. */
8072
+ verdict: BirthDecisionVerdictSchema.optional(),
8073
+ /** Max rows returned, newest-first. */
8074
+ limit: number().int().min(1).max(5e3).optional()
8075
+ });
8076
+ /**
7857
8077
  * Debug-note archive — the durable corpus of what operators asked to be
7858
8078
  * checked, and the ONE thing about a debug note that outlives its track.
7859
8079
  *
@@ -21493,6 +21713,26 @@ var pipelineAnalyticsCapability = {
21493
21713
  */
21494
21714
  listArchivedDebugNotes: method(ArchivedDebugNoteQueryInputSchema, array(ArchivedDebugNoteSchema).readonly(), { kind: "query" }),
21495
21715
  /**
21716
+ * Birth decisions — one row per resolved confirmation-gate verdict (D409).
21717
+ *
21718
+ * The READ half of a measurement, and only that: it gates nothing and no
21719
+ * runtime path consults it. It exists because the two questions the
21720
+ * operator's "traccia partita in ritardo" marks raised are both multi-day
21721
+ * and `logs.query` holds under an hour of fleet traffic —
21722
+ * • how often is a birth DECIDED on a frame the subject was not observed
21723
+ * in (`decidedOnCoastedFrame`), and did D379's carried pixels make it a
21724
+ * real observation anyway (`decidedByBirthEvidence`);
21725
+ * • how long after the camera's motion onset does a track's `firstSeen`
21726
+ * land (`birthLatencyMs` — read its error bars in
21727
+ * `BirthDecisionRecordSchema` before quoting it).
21728
+ *
21729
+ * Newest-first, capped by `limit` (default
21730
+ * {@link BIRTH_DECISION_DEFAULT_LIMIT}), optionally scoped to one camera,
21731
+ * one verdict, or a `since`. The table is bounded by row count, not age —
21732
+ * see {@link MAX_BIRTH_DECISION_RECORDS}.
21733
+ */
21734
+ listBirthDecisions: method(BirthDecisionQueryInputSchema, array(BirthDecisionRecordSchema).readonly(), { kind: "query" }),
21735
+ /**
21496
21736
  * Durable event-store footprint for the management UI: event rows
21497
21737
  * (motion + object + audio) counted per camera + total, plus the
21498
21738
  * event-owned media bytes on disk per camera + total. Stat/count-based,
@@ -39170,6 +39410,12 @@ Object.freeze({
39170
39410
  addonId: null,
39171
39411
  access: "view"
39172
39412
  },
39413
+ "pipelineAnalytics.listBirthDecisions": {
39414
+ capName: "pipeline-analytics",
39415
+ capScope: "device",
39416
+ addonId: null,
39417
+ access: "view"
39418
+ },
39173
39419
  "pipelineAnalytics.listEventKinds": {
39174
39420
  capName: "pipeline-analytics",
39175
39421
  capScope: "device",
@@ -42962,6 +43208,11 @@ Object.freeze({
42962
43208
  form: "single",
42963
43209
  optional: true
42964
43210
  }],
43211
+ "pipelineAnalytics.listBirthDecisions": [{
43212
+ name: "deviceId",
43213
+ form: "single",
43214
+ optional: true
43215
+ }],
42965
43216
  "pipelineAnalytics.listEventKinds": [{
42966
43217
  name: "deviceId",
42967
43218
  form: "single",
@@ -44912,6 +45163,12 @@ Object.defineProperty(exports, "BaseDevice", {
44912
45163
  return BaseDevice;
44913
45164
  }
44914
45165
  });
45166
+ Object.defineProperty(exports, "BirthDecisionRecordSchema", {
45167
+ enumerable: true,
45168
+ get: function() {
45169
+ return BirthDecisionRecordSchema;
45170
+ }
45171
+ });
44915
45172
  Object.defineProperty(exports, "CLUSTER_MODEL_SCOPED_STEPS", {
44916
45173
  enumerable: true,
44917
45174
  get: function() {
@@ -45020,6 +45277,18 @@ Object.defineProperty(exports, "MAX_ARCHIVED_DEBUG_NOTES", {
45020
45277
  return MAX_ARCHIVED_DEBUG_NOTES;
45021
45278
  }
45022
45279
  });
45280
+ Object.defineProperty(exports, "MAX_BIRTH_DECISION_RECORDS", {
45281
+ enumerable: true,
45282
+ get: function() {
45283
+ return MAX_BIRTH_DECISION_RECORDS;
45284
+ }
45285
+ });
45286
+ Object.defineProperty(exports, "MAX_BIRTH_LATENCY_PROXY_MS", {
45287
+ enumerable: true,
45288
+ get: function() {
45289
+ return MAX_BIRTH_LATENCY_PROXY_MS;
45290
+ }
45291
+ });
45023
45292
  Object.defineProperty(exports, "MediaFileKindEnum", {
45024
45293
  enumerable: true,
45025
45294
  get: function() {
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_dist = require("../dist-FHSaZkf_.js");
5
+ const require_dist = require("../dist-IE6UOohI.js");
6
6
  let node_fs = require("node:fs");
7
7
  node_fs = require_dist.__toESM(node_fs);
8
8
  let node_path = require("node:path");
@@ -1,4 +1,4 @@
1
- import { Dt as resolvePoolMemoryPolicy, It as BaseAddon, L as PoolMemoryWatchdog, bt as parseProcStatus, pt as hfModelUrl, st as embeddingEncoderCapability } from "../dist-D2rFaMex.mjs";
1
+ import { At as resolvePoolMemoryPolicy, B as PoolMemoryWatchdog, Ct as parseProcStatus, gt as hfModelUrl, ut as embeddingEncoderCapability, zt as BaseAddon } from "../dist-GQbzNwJB.mjs";
2
2
  import { createRequire } from "node:module";
3
3
  import * as fs from "node:fs";
4
4
  import * as path$1 from "node:path";
@@ -1,6 +1,6 @@
1
1
  import { a as e, i as t, n, o as r, r as i, t as a } from "./_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare__react__loadShare__.js-C0AuF9av.mjs";
2
2
  import { t as o } from "./_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_tanstack_mf_1_react_mf_2_query__loadShare__.js-B3Wx5J80.mjs";
3
- import { a as s, i as c, n as l, o as u, r as d, s as f, t as p } from "./_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-B2Kde85q.mjs";
3
+ import { a as s, i as c, n as l, o as u, r as d, s as f, t as p } from "./_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare___mf_0_camstack_mf_1_ui_mf_2_library__loadShare__.js-CcE47LPf.mjs";
4
4
  import { n as m, r as h, t as g } from "./_virtual_mf___mfe_internal__addon_pipeline_analytics_widgets__loadShare__react_mf_1_jsx_mf_2_runtime__loadShare__.js-Bm-iyjmq.mjs";
5
5
  //#region ../../node_modules/lucide-react/dist/esm/shared/src/utils.js
6
6
  var _ = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), v = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), y = (e) => {
@@ -3,7 +3,7 @@ import "./dist-CYZr2fwk.mjs";
3
3
  var e = {
4
4
  "@camstack/sdk": {
5
5
  name: "@camstack/sdk",
6
- version: "1.2.90",
6
+ version: "1.2.91",
7
7
  scope: ["default"],
8
8
  loaded: !1,
9
9
  from: "addon_pipeline_analytics_widgets",
@@ -18,7 +18,7 @@ var e = {
18
18
  },
19
19
  "@camstack/types": {
20
20
  name: "@camstack/types",
21
- version: "1.2.170",
21
+ version: "1.2.171",
22
22
  scope: ["default"],
23
23
  loaded: !1,
24
24
  from: "addon_pipeline_analytics_widgets",
@@ -33,7 +33,7 @@ var e = {
33
33
  },
34
34
  "@camstack/ui-library": {
35
35
  name: "@camstack/ui-library",
36
- version: "1.2.138",
36
+ version: "1.2.139",
37
37
  scope: ["default"],
38
38
  loaded: !1,
39
39
  from: "addon_pipeline_analytics_widgets",