@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.
@@ -1,4 +1,4 @@
1
- import { $ as assertTimelapseCadences, $t as string, A as NcScheduleSchema, At as subKindsOf, Bt as hydrateSchema, Ct as plateGalleryCapability, D as NcRulePatchSchema, E as NcRuleInputSchema, Et as resolveLocationMode, F as NcTaxonomySchema, Ft as errMsg$1, G as TIMELAPSE_DENSE_FLOOR_SEC, Gt as array, H as SCENE_DEFAULT_UNCOVERED_POLICY, Ht as nodePin, I as OpsLogEntrySchema, It as BaseAddon, J as TimelapseRuleSchema, Jt as literal, K as TimelapseRuleInputSchema, Kt as boolean, Lt as CamProfileSchema, M as NcSnoozeSchema, Mt as vectorDimFromBase64, N as NcSnoozeSuppressedSchema, Nt as videoclipsCapability, O as NcRuleSchema, Ot as sceneMonitorCapability, P as NcSystemEventKindSchema, Pt as zoneAnalyticsCapability, Q as alarmPanelCapability, Qt as record, R as RECORDING_EXPORT_MAX_READ_BYTES, Rt as DeviceType, S as NC_DEFAULT_SNOOZE_MINUTES, St as pipelineAnalyticsCapability, T as NcConditionDescriptorSchema, Tt as readTimelapseGeneratedAt, U as SCENE_DIVERGED, Ut as sleep$1, V as SCENE_DEFAULT_ANCHOR_THRESHOLD, Vt as isDeviceScopedCap, W as SceneMonitorSchema, Wt as _enum, X as VISIT_MERGE_GAP_MS, Xt as object, Y as TrackSourceSchema, Yt as number, Z as addonWidgetsSourceCapability, Zt as partialRecord, _ as MACRO_LABELS, _t as kebabToCamel, a as COCO_TO_MACRO, at as defineCustomActions, b as NC_ALARM_SYSTEM_EVENT_KINDS, ct as encodeVectorBase64, d as DeclaredDevices, dt as faceGalleryCapability, en as unknown, et as audioMetricsCapability, f as EVENT_KIND_BY_CAP, ft as failureContributionCapability, g as LabelAttributionSchema, gt as isSourceCap, h as FailureCounters, ht as isScheduleActive, i as CLUSTER_MODEL_SCOPED_STEPS, it as customAction, j as NcSnoozeInputSchema, jt as systemEventFilterApplies, k as NcRuleTargetSchema, kt as storageOccupancyCapability, l as DETECTION_MACRO_CLASSES, lt as evaluateSensorEdge, m as FULL_IMAGE_BBOX, mt as isDetectionMacroClass, n as ArchivedDebugNoteSchema, nt as buildEventKindDescriptor, o as DEFAULT_EVENT_COLOR, ot as deriveRecordingMode, p as EVENT_PAD_MS, q as TimelapseRulePatchSchema, qt as discriminatedUnion, r as BaseDevice, rt as cosineSimilarity$1, t as AUDIO_MACRO_LABELS, tn as EventCategory, tt as audioModeOf, ut as evictionPolicyOfLocation, v as MAX_ARCHIVED_DEBUG_NOTES, vt as mayWriteToLocation, w as NC_TAXONOMY, wt as readDeviceStateFrom, x as NC_CONDITION_CATALOG, xt as pickClusterStepModels, y as MediaFileKindEnum, yt as notificationRulesCapability, z as RetrainStatusSchema, zt as createEvent } from "../dist-D2rFaMex.mjs";
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-GQbzNwJB.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";
@@ -53358,6 +53358,95 @@ var BirthEvidenceStore = class {
53358
53358
  }
53359
53359
  };
53360
53360
  //#endregion
53361
+ //#region src/pipeline-analytics/pipeline/birth-decision-record.ts
53362
+ /**
53363
+ * birth-decision-record — turn one resolved birth verdict into the row that is
53364
+ * kept (D409).
53365
+ *
53366
+ * PURE, and separated from the store for the usual reason: the two rules worth
53367
+ * getting right — what counts as the fail-open, and when the latency proxy is
53368
+ * allowed to report a number — are decisions, not I/O, and a decision that only
53369
+ * exists inside a SQLite call cannot be tested or argued with.
53370
+ *
53371
+ * MEASUREMENT ONLY. Nothing here gates a birth, changes a verdict, or feeds
53372
+ * back into the frame path. The caller writes the row after the verdict is
53373
+ * already taken.
53374
+ */
53375
+ /**
53376
+ * The verdict as the ledger reports it.
53377
+ *
53378
+ * `exhausted-fallback` is a CONFIRMATION and is counted apart from one, because
53379
+ * a birth nobody ever looked at and a birth measured and passed are the same
53380
+ * row in every existing aggregate — which is what made "the gate stopped
53381
+ * failing open" and "the gate now suppresses everything it cannot measure"
53382
+ * indistinguishable. Exhaustion attached to a SUPPRESSION is meaningless
53383
+ * (exhaustion only ever waves a birth through) and is discarded rather than
53384
+ * inventing a fourth member.
53385
+ */
53386
+ function verdictFor(input) {
53387
+ if (!input.confirmed) return "suppressed";
53388
+ return input.exhaustedFallback ? "exhausted-fallback" : "confirmed";
53389
+ }
53390
+ /**
53391
+ * The latency proxy, and the three ways it declines to produce a number.
53392
+ *
53393
+ * It reports `null` — never a fabricated or clamped value — when there is no
53394
+ * track (a suppressed birth), no motion reference on this runner, or a
53395
+ * reference older than {@link MAX_BIRTH_LATENCY_PROXY_MS}. That last case is
53396
+ * the one that matters: on a busy scene the burst never closes and the onset is
53397
+ * minutes old, and a minutes-long "birth latency" would be read as the
53398
+ * detector's fault when it is the proxy's. When the reference is refused, the
53399
+ * onset and the burst index go with it — reporting an index against a reference
53400
+ * this row does not carry would be an invitation to join them back up.
53401
+ *
53402
+ * A NEGATIVE result is returned as measured. The analyzer's pixel-count floor
53403
+ * can be crossed after the detector's confidence floor for a subject entering
53404
+ * slowly at the frame edge, and clamping that away would delete precisely the
53405
+ * evidence that the proxy is unreliable. See `BirthDecisionRecordSchema` for
53406
+ * the full error bars.
53407
+ */
53408
+ function latencyFor(input, firstSeen) {
53409
+ const onset = input.motionOnsetAtMs;
53410
+ if (firstSeen === null || onset === null) return {
53411
+ motionOnsetAt: null,
53412
+ birthLatencyMs: null,
53413
+ birthIndexInBurst: null
53414
+ };
53415
+ if (firstSeen - onset > 6e4) return {
53416
+ motionOnsetAt: null,
53417
+ birthLatencyMs: null,
53418
+ birthIndexInBurst: null
53419
+ };
53420
+ return {
53421
+ motionOnsetAt: onset,
53422
+ birthLatencyMs: firstSeen - onset,
53423
+ birthIndexInBurst: input.birthIndexInBurst
53424
+ };
53425
+ }
53426
+ /** Build the durable row for one resolved birth decision. */
53427
+ function buildBirthDecisionRecord(input) {
53428
+ const verdict = verdictFor(input);
53429
+ const firstSeen = verdict === "suppressed" ? null : input.firstSeen;
53430
+ const latency = latencyFor(input, firstSeen);
53431
+ return {
53432
+ at: input.decidedAtMs,
53433
+ deviceId: input.deviceId,
53434
+ sourceTrackId: input.trackId,
53435
+ className: input.className,
53436
+ verdict,
53437
+ reason: input.reason ?? null,
53438
+ attempts: input.attempts,
53439
+ deferredForMs: input.deferredForMs,
53440
+ decidedOnCoastedFrame: input.matchedThisFrame === false,
53441
+ birthEvidenceAvailable: input.birthEvidenceAvailable,
53442
+ decidedByBirthEvidence: input.decidedByBirthEvidence,
53443
+ bestScore: input.bestScore ?? null,
53444
+ appliedMinConfidence: input.appliedMinConfidence ?? null,
53445
+ firstSeen,
53446
+ ...latency
53447
+ };
53448
+ }
53449
+ //#endregion
53361
53450
  //#region src/pipeline-analytics/pipeline/deferred-births.ts
53362
53451
  var DeferredBirthRegistry = class {
53363
53452
  byDevice = /* @__PURE__ */ new Map();
@@ -53432,6 +53521,44 @@ var DeferredBirthRegistry = class {
53432
53521
  }
53433
53522
  };
53434
53523
  //#endregion
53524
+ //#region src/pipeline-analytics/pipeline/motion-onset-registry.ts
53525
+ var MotionOnsetRegistry = class {
53526
+ byDevice = /* @__PURE__ */ new Map();
53527
+ /**
53528
+ * Motion went off→on at `atMs`. Opens a new burst, discarding the previous
53529
+ * one's birth count — a new burst is a new subject population.
53530
+ */
53531
+ noteRisingEdge(deviceId, atMs) {
53532
+ this.byDevice.set(deviceId, {
53533
+ onsetAtMs: atMs,
53534
+ births: 0
53535
+ });
53536
+ }
53537
+ /** The open burst's onset, or `null` for a device with no reference. */
53538
+ onsetFor(deviceId) {
53539
+ return this.byDevice.get(deviceId)?.onsetAtMs ?? null;
53540
+ }
53541
+ /**
53542
+ * Count one birth decision against this device's burst and return its 0-based
53543
+ * index — `null` when there is no burst to count it against.
53544
+ *
53545
+ * Index 0 is the only index at which the burst plausibly belongs to the same
53546
+ * subject as the birth; the ledger records the index rather than filtering
53547
+ * here, so the reader can see how often it is not 0.
53548
+ */
53549
+ noteBirth(deviceId) {
53550
+ const burst = this.byDevice.get(deviceId);
53551
+ if (burst === void 0) return null;
53552
+ const index = burst.births;
53553
+ burst.births += 1;
53554
+ return index;
53555
+ }
53556
+ /** Drop a device's reference (device removed / pipeline reset). */
53557
+ forgetDevice(deviceId) {
53558
+ this.byDevice.delete(deviceId);
53559
+ }
53560
+ };
53561
+ //#endregion
53435
53562
  //#region src/pipeline-analytics/pipeline/detail-semantic-gate.ts
53436
53563
  /** The detail `className` whose result IS the recognition. */
53437
53564
  var PLATE_CLASS = "plate";
@@ -59960,6 +60087,332 @@ var IdentityStore = class {
59960
60087
  }
59961
60088
  };
59962
60089
  //#endregion
60090
+ //#region src/pipeline-analytics/store/birth-decision-ledger-store.ts
60091
+ /**
60092
+ * BirthDecisionLedgerStore — the durable record of every track-birth verdict
60093
+ * (D409).
60094
+ *
60095
+ * A declared SQL-backed collection, like the events ops-log and the debug-note
60096
+ * archive next door, and for the same reason: pipeline-analytics already owns
60097
+ * SQLite collections, and an undeclared collection crash-loops the runner. MUST
60098
+ * be declared in `onInitialize` before the first write.
60099
+ *
60100
+ * Collection name: pipeline-analytics:birth-decision-ledger
60101
+ *
60102
+ * ── Why a table rather than a log line ─────────────────────────────────────
60103
+ * The gate ALREADY logs every decision. `logs.query` is an in-memory ring that
60104
+ * measured 40 000 entries covering 38 MINUTES of fleet traffic on 2026-09-08 —
60105
+ * so a fourteenth field on that line answers nothing the next morning, and the
60106
+ * questions this data exists for ("what fraction of births on 617 were decided
60107
+ * on a coasted frame, over the week the operator complained about") are all
60108
+ * multi-day. A previous investigation in this repo was blocked for exactly
60109
+ * this.
60110
+ *
60111
+ * ── Why it is safe on the write path ──────────────────────────────────────
60112
+ * ONE INSERT PER BIRTH DECISION. Not per frame, not periodic, and never an
60113
+ * update of an existing row. Measured fleet-wide on the live hub, 2026-09-08:
60114
+ * 31 decided births in 38 minutes = ~49/hour = 0.014 writes/s. The write
60115
+ * amplification the runtime-state guard exists to prevent
60116
+ * (`scripts/check-runtime-state-durability.ts`: 12-19 writes/s rewriting
60117
+ * ~2.6-5 GB/day to maintain 161 KB) is three orders of magnitude above this and
60118
+ * is a different shape entirely — that one is a periodic REWRITE of a slice
60119
+ * whose values do not change. Nothing here advances a clock under an unchanged
60120
+ * value, because every row is new.
60121
+ *
60122
+ * ── Two properties, stated once ───────────────────────────────────────────
60123
+ * - **It is not track-owned.** A SUPPRESSED birth never had a track; a
60124
+ * confirmed one is expected to age out long before this row. The column is
60125
+ * `sourceTrackId` and not `trackId` so the ownership derivation in
60126
+ * `collection-classification.ts` cannot see it and cascade it away.
60127
+ * - **It is bounded by COUNT, not by age.** A miss rate needs a denominator
60128
+ * over whatever window the table holds; a quiet fleet should keep more of
60129
+ * that window, not less. See {@link MAX_BIRTH_DECISION_RECORDS}.
60130
+ *
60131
+ * MEASUREMENT ONLY. Nothing reads this on the frame path; nothing gates on it.
60132
+ */
60133
+ /**
60134
+ * @durable class=ledger owner=pipeline-analytics
60135
+ * write="one row per track-birth VERDICT — appended by the birth loop in
60136
+ * `processFrame` the instant the confirmation gate's verdict resolves
60137
+ * (confirmed / suppressed / exhausted fail-open). Per BIRTH, never per
60138
+ * frame: measured at ~49 rows/hour fleet-wide on 2026-09-08. Append-only,
60139
+ * never updated. BEST-EFFORT — it logs and swallows, because a failed
60140
+ * measurement must not fail the birth it measures."
60141
+ * retention="NOT track retention and NOT an age clock — a miss rate needs
60142
+ * whatever window the table holds, and an age sweep would shorten it on a
60143
+ * quiet fleet exactly when more history is affordable. Bounded by ROW
60144
+ * COUNT (MAX_BIRTH_DECISION_RECORDS, 30000, fleet-wide), oldest `at`
60145
+ * first, trimmed on append. ~6 MB at the ceiling."
60146
+ */
60147
+ var BIRTH_DECISION_LEDGER_COLLECTION = "pipeline-analytics:birth-decision-ledger";
60148
+ var BIRTH_DECISION_LEDGER_COLUMNS = [
60149
+ {
60150
+ name: "id",
60151
+ type: "TEXT",
60152
+ primaryKey: true,
60153
+ notNull: true
60154
+ },
60155
+ {
60156
+ name: "at",
60157
+ type: "INTEGER",
60158
+ notNull: true
60159
+ },
60160
+ {
60161
+ name: "deviceId",
60162
+ type: "INTEGER",
60163
+ notNull: true
60164
+ },
60165
+ {
60166
+ name: "sourceTrackId",
60167
+ type: "TEXT",
60168
+ notNull: true
60169
+ },
60170
+ {
60171
+ name: "className",
60172
+ type: "TEXT",
60173
+ notNull: true
60174
+ },
60175
+ {
60176
+ name: "verdict",
60177
+ type: "TEXT",
60178
+ notNull: true
60179
+ },
60180
+ {
60181
+ name: "reason",
60182
+ type: "TEXT"
60183
+ },
60184
+ {
60185
+ name: "attempts",
60186
+ type: "INTEGER",
60187
+ notNull: true
60188
+ },
60189
+ {
60190
+ name: "deferredForMs",
60191
+ type: "INTEGER",
60192
+ notNull: true
60193
+ },
60194
+ {
60195
+ name: "decidedOnCoastedFrame",
60196
+ type: "BOOLEAN",
60197
+ notNull: true
60198
+ },
60199
+ {
60200
+ name: "birthEvidenceAvailable",
60201
+ type: "BOOLEAN",
60202
+ notNull: true
60203
+ },
60204
+ {
60205
+ name: "decidedByBirthEvidence",
60206
+ type: "BOOLEAN",
60207
+ notNull: true
60208
+ },
60209
+ {
60210
+ name: "bestScore",
60211
+ type: "REAL"
60212
+ },
60213
+ {
60214
+ name: "appliedMinConfidence",
60215
+ type: "REAL"
60216
+ },
60217
+ {
60218
+ name: "firstSeen",
60219
+ type: "INTEGER"
60220
+ },
60221
+ {
60222
+ name: "motionOnsetAt",
60223
+ type: "INTEGER"
60224
+ },
60225
+ {
60226
+ name: "birthLatencyMs",
60227
+ type: "INTEGER"
60228
+ },
60229
+ {
60230
+ name: "birthIndexInBurst",
60231
+ type: "INTEGER"
60232
+ }
60233
+ ];
60234
+ var BIRTH_DECISION_LEDGER_INDEXES = [{
60235
+ name: "idx_birthdecision_at",
60236
+ columns: ["at"]
60237
+ }, {
60238
+ name: "idx_birthdecision_device_at",
60239
+ columns: ["deviceId", "at"]
60240
+ }];
60241
+ var BirthDecisionLedgerStore = class {
60242
+ store;
60243
+ logger;
60244
+ newId;
60245
+ maxRows;
60246
+ trimEvery;
60247
+ /** Rows appended since the last trim — see {@link trim}. */
60248
+ sinceTrim = 0;
60249
+ constructor(deps) {
60250
+ this.store = deps.store;
60251
+ this.logger = deps.logger;
60252
+ this.newId = deps.newId ?? (() => globalThis.crypto.randomUUID());
60253
+ this.maxRows = deps.maxRows ?? 3e4;
60254
+ this.trimEvery = deps.trimEvery ?? DEFAULT_TRIM_EVERY;
60255
+ }
60256
+ /** The ceiling a store built without an override enforces. */
60257
+ static defaultMaxRows() {
60258
+ return MAX_BIRTH_DECISION_RECORDS;
60259
+ }
60260
+ static async declare(store) {
60261
+ await store.declareCollection.mutate({
60262
+ collection: BIRTH_DECISION_LEDGER_COLLECTION,
60263
+ columns: [...BIRTH_DECISION_LEDGER_COLUMNS],
60264
+ indexes: [...BIRTH_DECISION_LEDGER_INDEXES]
60265
+ });
60266
+ }
60267
+ /**
60268
+ * Append one birth decision. NEVER THROWS.
60269
+ *
60270
+ * Best-effort, unlike the debug-note archive and deliberately so: that table
60271
+ * holds the only copy of something a PERSON typed, and this one holds a
60272
+ * measurement the system takes ~49 times an hour. A birth must not fail — nor
60273
+ * be delayed by a retry — because bookkeeping could not be written. The
60274
+ * failure is logged with `tags: { deviceId }` so a camera whose rows are
60275
+ * silently missing is attributable rather than an unexplained hole in the
60276
+ * denominator.
60277
+ */
60278
+ async append(draft) {
60279
+ try {
60280
+ const row = BirthDecisionRecordSchema.parse({
60281
+ id: this.newId(),
60282
+ ...draft
60283
+ });
60284
+ await this.store.insert.mutate({
60285
+ collection: BIRTH_DECISION_LEDGER_COLLECTION,
60286
+ record: {
60287
+ id: row.id,
60288
+ data: {
60289
+ at: row.at,
60290
+ deviceId: row.deviceId,
60291
+ sourceTrackId: row.sourceTrackId,
60292
+ className: row.className,
60293
+ verdict: row.verdict,
60294
+ reason: row.reason,
60295
+ attempts: row.attempts,
60296
+ deferredForMs: row.deferredForMs,
60297
+ decidedOnCoastedFrame: row.decidedOnCoastedFrame,
60298
+ birthEvidenceAvailable: row.birthEvidenceAvailable,
60299
+ decidedByBirthEvidence: row.decidedByBirthEvidence,
60300
+ bestScore: row.bestScore,
60301
+ appliedMinConfidence: row.appliedMinConfidence,
60302
+ firstSeen: row.firstSeen,
60303
+ motionOnsetAt: row.motionOnsetAt,
60304
+ birthLatencyMs: row.birthLatencyMs,
60305
+ birthIndexInBurst: row.birthIndexInBurst
60306
+ }
60307
+ }
60308
+ });
60309
+ this.sinceTrim += 1;
60310
+ await this.trim();
60311
+ } catch (err) {
60312
+ this.logger.warn("birth-decision ledger append failed — this decision is not counted", {
60313
+ tags: { deviceId: draft.deviceId },
60314
+ meta: {
60315
+ trackId: draft.sourceTrackId,
60316
+ verdict: draft.verdict,
60317
+ error: err instanceof Error ? err.message : String(err)
60318
+ }
60319
+ });
60320
+ }
60321
+ }
60322
+ /**
60323
+ * Hold the table at its ceiling, oldest first.
60324
+ *
60325
+ * NOT an age-keyed sweep and must never become one: the boundary is computed
60326
+ * from the POSITION of the excess rows, never from a clock. Rows sharing the
60327
+ * boundary timestamp go together, which at this write rate is a rounding
60328
+ * error against a 30 000-row ceiling.
60329
+ *
60330
+ * AMORTISED. The debug-note archive counts on every append because it writes
60331
+ * a few rows a week; this one writes ~49 an hour, and a `count` round trip per
60332
+ * birth would triple the ledger's own store traffic to answer a question whose
60333
+ * answer only changes on the row that crosses the ceiling. Checking once per
60334
+ * {@link DEFAULT_TRIM_EVERY} appends bounds the overshoot at that many rows —
60335
+ * 0.3% of the ceiling — for two hours' delay in enforcing it.
60336
+ */
60337
+ async trim() {
60338
+ if (this.sinceTrim < this.trimEvery) return;
60339
+ this.sinceTrim = 0;
60340
+ try {
60341
+ const held = await this.store.count.query({ collection: BIRTH_DECISION_LEDGER_COLLECTION });
60342
+ const excess = held - this.maxRows;
60343
+ if (excess <= 0) return;
60344
+ const boundary = (await this.store.query.query({
60345
+ collection: BIRTH_DECISION_LEDGER_COLLECTION,
60346
+ filter: {
60347
+ orderBy: {
60348
+ field: "at",
60349
+ direction: "asc"
60350
+ },
60351
+ limit: excess
60352
+ },
60353
+ columns: ["at"]
60354
+ })).reduce((acc, r) => {
60355
+ const at = r.data["at"];
60356
+ return typeof at === "number" && at > acc ? at : acc;
60357
+ }, 0);
60358
+ if (boundary === 0) return;
60359
+ const { deleted } = await this.store.deleteWhere.mutate({
60360
+ collection: BIRTH_DECISION_LEDGER_COLLECTION,
60361
+ filter: { whereBetween: { at: [0, boundary] } }
60362
+ });
60363
+ this.logger.info("birth-decision ledger trimmed to its ceiling", { meta: {
60364
+ held,
60365
+ ceiling: this.maxRows,
60366
+ deleted
60367
+ } });
60368
+ } catch (err) {
60369
+ this.logger.warn("birth-decision ledger trim failed — the ledger will keep growing", { meta: {
60370
+ ceiling: this.maxRows,
60371
+ error: err instanceof Error ? err.message : String(err)
60372
+ } });
60373
+ }
60374
+ }
60375
+ /** Birth decisions, newest first, optionally scoped by camera / verdict / age. */
60376
+ async list(query) {
60377
+ const where = {};
60378
+ if (query.deviceId !== void 0) where["deviceId"] = query.deviceId;
60379
+ if (query.verdict !== void 0) where["verdict"] = query.verdict;
60380
+ const filter = {
60381
+ orderBy: {
60382
+ field: "at",
60383
+ direction: "desc"
60384
+ },
60385
+ limit: query.limit ?? 500
60386
+ };
60387
+ if (Object.keys(where).length > 0) filter["where"] = where;
60388
+ if (query.since !== void 0) filter["whereBetween"] = { at: [query.since, Number.MAX_SAFE_INTEGER] };
60389
+ const rows = await this.store.query.query({
60390
+ collection: BIRTH_DECISION_LEDGER_COLLECTION,
60391
+ filter
60392
+ });
60393
+ const out = [];
60394
+ for (const r of rows) {
60395
+ const parsed = BirthDecisionRecordSchema.safeParse({
60396
+ id: r.id,
60397
+ ...r.data
60398
+ });
60399
+ if (parsed.success) out.push(parsed.data);
60400
+ else this.logger.debug("birth-decision ledger: skipped a malformed row", { meta: { id: r.id } });
60401
+ }
60402
+ return out;
60403
+ }
60404
+ };
60405
+ /**
60406
+ * How many appends between ceiling checks, by default. See
60407
+ * {@link BirthDecisionLedgerStore.trim}.
60408
+ *
60409
+ * 100 rows is two hours of measured fleet traffic and 0.3% of the ceiling —
60410
+ * small enough that the table's real size never meaningfully exceeds its stated
60411
+ * bound, large enough that the ledger costs one `count` per two hours instead of
60412
+ * one per birth.
60413
+ */
60414
+ var DEFAULT_TRIM_EVERY = 100;
60415
+ //#endregion
59963
60416
  //#region src/pipeline-analytics/store/debug-note-archive-store.ts
59964
60417
  /**
59965
60418
  * DebugNoteArchiveStore — the durable corpus of what operators asked to be
@@ -61585,6 +62038,13 @@ var ANALYTICS_COLLECTIONS = [
61585
62038
  why: "the archived operator notes (D405) — the ONE table here whose whole purpose is to outlive the track it names. `debug` never pinned a track against retention and D405 does not change that, so the track a note was written on IS expected to be evicted; deleting the note with it is the failure the archive was built to fix (25–27 notes from one sweep unreadable the same afternoon). Its column is called `sourceTrackId` and not `trackId` precisely so the ownership derivation cannot reach it, and its bound is a fleet-wide ROW COUNT trimmed on append — never an age sweep, which would delete the corpus for the one property that makes it valuable."
61586
62039
  }
61587
62040
  },
62041
+ {
62042
+ collection: BIRTH_DECISION_LEDGER_COLLECTION,
62043
+ classification: {
62044
+ kind: "never-orphaned",
62045
+ why: "the birth-decision ledger (D409) — a measurement of what the confirmation gate decided, not analytics data about a track. Most of its rows describe births that were SUPPRESSED and therefore never had a track at all, and the confirmed ones are expected to outlive theirs: a miss rate needs its denominator for as long as the table holds, and cascading rows away with their tracks would silently shorten the window while leaving the numerator behind. Its column is called `sourceTrackId` and not `trackId` precisely so the ownership derivation cannot reach it, and its bound is a fleet-wide ROW COUNT trimmed on append — never an age sweep."
62046
+ }
62047
+ },
61588
62048
  {
61589
62049
  collection: STATIONARY_COLLECTION,
61590
62050
  classification: {
@@ -69361,6 +69821,11 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
69361
69821
  * operator asked for never depends on this addon's own bookkeeping.
69362
69822
  */
69363
69823
  debugNoteArchive = null;
69824
+ /** The durable birth-decision ledger (D409) — measurement, never a gate. */
69825
+ birthDecisionLedger = null;
69826
+ /** Has the "no ledger on this runner" warning already been said? Once per
69827
+ * process: the condition is a property of the runner, not of the birth. */
69828
+ birthLedgerAbsenceLogged = false;
69364
69829
  /** Event-media relocation engine (entity-routing Phase 4). */
69365
69830
  mediaRelocate = null;
69366
69831
  mediaLocationStorage = null;
@@ -69799,6 +70264,14 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
69799
70264
  /** Births the gate could not MEASURE, awaiting another look on a later frame. */
69800
70265
  deferredBirths = new DeferredBirthRegistry();
69801
70266
  /**
70267
+ * The last motion RISING EDGE per device — the reference instant the
70268
+ * birth-latency proxy is measured from (D409). Measurement only; nothing
70269
+ * gates on it. Fed by the two motion handlers, which are subscribed on the
70270
+ * SAME designated post-processing node as the frame path, so a camera whose
70271
+ * births land here always has its motion mirror here too.
70272
+ */
70273
+ motionOnsets = new MotionOnsetRegistry();
70274
+ /**
69802
70275
  * The pixels each deferred birth arrived with — a RESERVE per camera, evicted
69803
70276
  * by age inside that camera's own quota (D379).
69804
70277
  *
@@ -70353,6 +70826,10 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
70353
70826
  store: api.settingsStore,
70354
70827
  logger: logger.child("debug-note-archive")
70355
70828
  });
70829
+ this.birthDecisionLedger = new BirthDecisionLedgerStore({
70830
+ store: api.settingsStore,
70831
+ logger: logger.child("birth-decision-ledger")
70832
+ });
70356
70833
  {
70357
70834
  const designated = await step("postProcessingNodeState", () => this.postProcessingNodeState.get());
70358
70835
  this.isPostProcessingNode = ownNodeId === designated;
@@ -70673,6 +71150,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
70673
71150
  RetrainAnnotationStore.declare(api.settingsStore),
70674
71151
  OpsLogStore.declare(api.settingsStore),
70675
71152
  DebugNoteArchiveStore.declare(api.settingsStore),
71153
+ BirthDecisionLedgerStore.declare(api.settingsStore),
70676
71154
  AnalyticsLts.declare(api.settingsStore),
70677
71155
  SceneStore.declare(api.settingsStore),
70678
71156
  NotificationCenter.declare(api.settingsStore),
@@ -72337,6 +72815,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
72337
72815
  this.overlaySynthesisWarnAt.delete(deviceId);
72338
72816
  this.forgetDeviceProcessors(deviceId);
72339
72817
  this.levelStateByDevice.delete(deviceId);
72818
+ this.motionOnsets.forgetDevice(deviceId);
72340
72819
  this.audioConfirmByDevice.delete(deviceId);
72341
72820
  this.lastTrackActivityMs.delete(deviceId);
72342
72821
  this.motionEventSnapshots?.forgetDevice(deviceId);
@@ -73123,8 +73602,10 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
73123
73602
  if (t.birthEvidence === void 0) continue;
73124
73603
  this.birthEvidence.remember(key, id, Buffer.from(t.birthEvidence.jpegBase64, "base64"), exhaustionNowMs);
73125
73604
  }
73126
- const outcome = await this.confirmTrackBirths(bornCandidates.map(({ id, t }) => {
73605
+ const withBirthEvidence = /* @__PURE__ */ new Set();
73606
+ const run = await this.confirmTrackBirths(bornCandidates.map(({ id, t }) => {
73127
73607
  const evidenceCrop = this.birthEvidence.get(key, id, exhaustionNowMs);
73608
+ if (evidenceCrop !== null) withBirthEvidence.add(id);
73128
73609
  return {
73129
73610
  trackId: id,
73130
73611
  className: t.className,
@@ -73139,6 +73620,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
73139
73620
  frameWidth: result.frameWidth,
73140
73621
  frameHeight: result.frameHeight
73141
73622
  }, exhaustedIds);
73623
+ const outcome = run.outcome;
73142
73624
  const gateNowMs = Date.now();
73143
73625
  for (const { id, t } of bornCandidates) {
73144
73626
  if (outcome.undecided.has(id)) {
@@ -73167,6 +73649,20 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
73167
73649
  } });
73168
73650
  continue;
73169
73651
  }
73652
+ this.recordBirthDecision({
73653
+ deviceId,
73654
+ trackId: id,
73655
+ className: t.className,
73656
+ confirmed: outcome.confirmed.has(id),
73657
+ exhaustedFallback: wasDeferred && exhaustedIds.has(id),
73658
+ attempts: deferredAttempts,
73659
+ deferredForMs,
73660
+ matchedThisFrame: t.matchedThisFrame,
73661
+ birthEvidenceAvailable: withBirthEvidence.has(id),
73662
+ decision: run.decisions.get(id),
73663
+ decidedAtMs: gateNowMs,
73664
+ firstSeen: this.trackStore?.peekActive(id)?.firstSeen ?? null
73665
+ });
73170
73666
  if (!outcome.confirmed.has(id)) {
73171
73667
  this.suppressedBirths.reject(key, id);
73172
73668
  this.trackStore?.dropActive(id);
@@ -73865,10 +74361,64 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
73865
74361
  * candidate) and each failure path fails OPEN, so the synchronous frame path
73866
74362
  * is never blocked or reordered by a slow/failed re-detection.
73867
74363
  */
74364
+ /**
74365
+ * Record ONE resolved birth verdict in the durable ledger (D409).
74366
+ *
74367
+ * Synchronous up to the append, which is fired and forgotten: the frame path
74368
+ * awaits `confirmTrackBirths` already, and a measurement must never add a
74369
+ * store round trip to the latency of a birth. `BirthDecisionLedgerStore.append`
74370
+ * never throws, so the un-awaited promise cannot reject.
74371
+ *
74372
+ * Cost, per BIRTH and not per frame: one `Map.get`, one `Set.has`, a counter
74373
+ * bump and one INSERT. Measured fleet-wide on the live hub 2026-09-08 at ~49
74374
+ * births/hour, i.e. 0.014 writes/s — three orders of magnitude below the
74375
+ * 12-19/s the runtime-state guard was written for, and a different shape
74376
+ * (append-only, never a periodic rewrite of an unchanged slice).
74377
+ *
74378
+ * A runner with no ledger (construction failed) records nothing and says so
74379
+ * exactly once per process, rather than per birth: a measurement that cannot
74380
+ * be taken must be visible, but it must not become the noisiest line in Loki.
74381
+ */
74382
+ recordBirthDecision(input) {
74383
+ const ledger = this.birthDecisionLedger;
74384
+ if (ledger === null) {
74385
+ if (!this.birthLedgerAbsenceLogged) {
74386
+ this.birthLedgerAbsenceLogged = true;
74387
+ this.ctx.logger.warn("birth decisions are NOT being measured — no ledger on this runner", { tags: { deviceId: input.deviceId } });
74388
+ }
74389
+ return;
74390
+ }
74391
+ const motionOnsetAtMs = this.motionOnsets.onsetFor(input.deviceId);
74392
+ const birthIndexInBurst = this.motionOnsets.noteBirth(input.deviceId);
74393
+ const decision = input.decision;
74394
+ ledger.append(buildBirthDecisionRecord({
74395
+ deviceId: input.deviceId,
74396
+ trackId: input.trackId,
74397
+ className: input.className,
74398
+ confirmed: input.confirmed,
74399
+ exhaustedFallback: input.exhaustedFallback,
74400
+ attempts: input.attempts,
74401
+ deferredForMs: input.deferredForMs,
74402
+ ...input.matchedThisFrame !== void 0 ? { matchedThisFrame: input.matchedThisFrame } : {},
74403
+ birthEvidenceAvailable: input.birthEvidenceAvailable,
74404
+ decidedByBirthEvidence: decision?.cropSource === "carried",
74405
+ reason: decision?.reason ?? null,
74406
+ bestScore: decision?.bestScore ?? null,
74407
+ appliedMinConfidence: decision?.appliedMinConfidence ?? null,
74408
+ decidedAtMs: input.decidedAtMs,
74409
+ firstSeen: input.firstSeen,
74410
+ motionOnsetAtMs,
74411
+ birthIndexInBurst
74412
+ }));
74413
+ }
73868
74414
  async confirmTrackBirths(candidates, params, exhaustedIds = /* @__PURE__ */ new Set()) {
74415
+ const decisions = /* @__PURE__ */ new Map();
73869
74416
  const allConfirmed = () => ({
73870
- confirmed: new Set(candidates.map((c) => c.trackId)),
73871
- undecided: /* @__PURE__ */ new Set()
74417
+ outcome: {
74418
+ confirmed: new Set(candidates.map((c) => c.trackId)),
74419
+ undecided: /* @__PURE__ */ new Set()
74420
+ },
74421
+ decisions
73872
74422
  });
73873
74423
  if (candidates.length === 0) return allConfirmed();
73874
74424
  const config = await this.resolveDeviceConfirmationGateSettings(params.deviceId);
@@ -73891,101 +74441,105 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
73891
74441
  const nodeId = frameHandle.nodeId;
73892
74442
  const candidateNativeRecovery = /* @__PURE__ */ new Map();
73893
74443
  for (const c of candidates) if (c.nativeRecovery !== void 0) candidateNativeRecovery.set(c.trackId, c.nativeRecovery);
73894
- return confirmBirths(candidates, config, {
73895
- fetchCrop: (candidate) => this.captureScheduler.request({
73896
- deviceId,
73897
- trackId: candidate.trackId,
73898
- kind: "confirm",
73899
- staleAfterMs: config.timeoutMs,
73900
- exec: () => captureCrop(frameHandle, {
74444
+ return {
74445
+ outcome: await confirmBirths(candidates, config, {
74446
+ fetchCrop: (candidate) => this.captureScheduler.request({
74447
+ deviceId,
74448
+ trackId: candidate.trackId,
74449
+ kind: "confirm",
74450
+ staleAfterMs: config.timeoutMs,
74451
+ exec: () => captureCrop(frameHandle, {
74452
+ x: candidate.bbox.x,
74453
+ y: candidate.bbox.y,
74454
+ w: candidate.bbox.w,
74455
+ h: candidate.bbox.h
74456
+ }, frameWidth, frameHeight, CONFIRMATION_CROP_PADDING, 320, deviceId)
74457
+ }),
74458
+ fetchFallbackCrop: (candidate) => {
74459
+ const displayCrop = this.captureDisplayCropFn;
74460
+ if (!displayCrop) return Promise.resolve(null);
74461
+ return displayCrop(frameHandle, {
74462
+ x: candidate.bbox.x,
74463
+ y: candidate.bbox.y,
74464
+ w: candidate.bbox.w,
74465
+ h: candidate.bbox.h
74466
+ }, frameWidth, frameHeight, CONFIRMATION_CROP_PADDING, candidate.trackId, 320);
74467
+ },
74468
+ redetect: (cropJpeg) => this.redetectCropForConfirmation(nodeId, deviceId, cropJpeg),
74469
+ cropRectFor: (candidate) => captureCropFrameRect({
73901
74470
  x: candidate.bbox.x,
73902
74471
  y: candidate.bbox.y,
73903
74472
  w: candidate.bbox.w,
73904
74473
  h: candidate.bbox.h
73905
- }, frameWidth, frameHeight, CONFIRMATION_CROP_PADDING, 320, deviceId)
73906
- }),
73907
- fetchFallbackCrop: (candidate) => {
73908
- const displayCrop = this.captureDisplayCropFn;
73909
- if (!displayCrop) return Promise.resolve(null);
73910
- return displayCrop(frameHandle, {
74474
+ }, frameWidth, frameHeight, CONFIRMATION_CROP_PADDING),
74475
+ minConfidenceFor: (candidate) => this.phantomCells?.spawnBar({
74476
+ deviceId,
74477
+ className: candidate.className,
73911
74478
  x: candidate.bbox.x,
73912
74479
  y: candidate.bbox.y,
73913
- w: candidate.bbox.w,
73914
- h: candidate.bbox.h
73915
- }, frameWidth, frameHeight, CONFIRMATION_CROP_PADDING, candidate.trackId, 320);
73916
- },
73917
- redetect: (cropJpeg) => this.redetectCropForConfirmation(nodeId, deviceId, cropJpeg),
73918
- cropRectFor: (candidate) => captureCropFrameRect({
73919
- x: candidate.bbox.x,
73920
- y: candidate.bbox.y,
73921
- w: candidate.bbox.w,
73922
- h: candidate.bbox.h
73923
- }, frameWidth, frameHeight, CONFIRMATION_CROP_PADDING),
73924
- minConfidenceFor: (candidate) => this.phantomCells?.spawnBar({
73925
- deviceId,
73926
- className: candidate.className,
73927
- x: candidate.bbox.x,
73928
- y: candidate.bbox.y,
73929
- base: config.minConfidence,
73930
- now: Date.now()
73931
- }).bar ?? config.minConfidence,
73932
- onDecision: (decision) => {
73933
- const meta = {
73934
- trackId: decision.trackId,
73935
- reason: decision.reason,
73936
- className: decision.className,
73937
- ...decision.bestScore !== void 0 ? { bestScore: decision.bestScore } : {},
73938
- ...decision.bestIncompatibleClass !== void 0 ? {
73939
- bestIncompatibleClass: decision.bestIncompatibleClass,
73940
- bestIncompatibleScore: decision.bestIncompatibleScore
73941
- } : {},
73942
- minConfidence: config.minConfidence,
73943
- ...decision.cropSource !== void 0 ? { cropSource: decision.cropSource } : {},
73944
- ...decision.reason === "native-pass" ? {
73945
- nativeRecoveryCropSidePx: candidateNativeRecovery.get(decision.trackId)?.cropSidePx,
73946
- nativeRecoveryViewPx: candidateNativeRecovery.get(decision.trackId)?.viewPx
73947
- } : {},
73948
- ...decision.appliedMinConfidence !== void 0 && decision.appliedMinConfidence > config.minConfidence ? {
73949
- appliedMinConfidence: decision.appliedMinConfidence,
73950
- barRaisedByPhantomCell: true
73951
- } : {}
73952
- };
73953
- switch (decision.verdict) {
73954
- case "suppressed":
73955
- this.ctx.logger.info("confirmation gate: birth suppressed (false positive)", {
73956
- tags: { deviceId },
73957
- meta
73958
- });
73959
- break;
73960
- case "undecided":
73961
- this.ctx.logger.info("confirmation gate: birth undecided", {
73962
- tags: { deviceId },
73963
- meta
73964
- });
73965
- break;
73966
- case "confirmed":
73967
- this.ctx.logger.info("confirmation gate: birth confirmed", {
74480
+ base: config.minConfidence,
74481
+ now: Date.now()
74482
+ }).bar ?? config.minConfidence,
74483
+ onDecision: (decision) => {
74484
+ decisions.set(decision.trackId, decision);
74485
+ const meta = {
74486
+ trackId: decision.trackId,
74487
+ reason: decision.reason,
74488
+ className: decision.className,
74489
+ ...decision.bestScore !== void 0 ? { bestScore: decision.bestScore } : {},
74490
+ ...decision.bestIncompatibleClass !== void 0 ? {
74491
+ bestIncompatibleClass: decision.bestIncompatibleClass,
74492
+ bestIncompatibleScore: decision.bestIncompatibleScore
74493
+ } : {},
74494
+ minConfidence: config.minConfidence,
74495
+ ...decision.cropSource !== void 0 ? { cropSource: decision.cropSource } : {},
74496
+ ...decision.reason === "native-pass" ? {
74497
+ nativeRecoveryCropSidePx: candidateNativeRecovery.get(decision.trackId)?.cropSidePx,
74498
+ nativeRecoveryViewPx: candidateNativeRecovery.get(decision.trackId)?.viewPx
74499
+ } : {},
74500
+ ...decision.appliedMinConfidence !== void 0 && decision.appliedMinConfidence > config.minConfidence ? {
74501
+ appliedMinConfidence: decision.appliedMinConfidence,
74502
+ barRaisedByPhantomCell: true
74503
+ } : {}
74504
+ };
74505
+ switch (decision.verdict) {
74506
+ case "suppressed":
74507
+ this.ctx.logger.info("confirmation gate: birth suppressed (false positive)", {
74508
+ tags: { deviceId },
74509
+ meta
74510
+ });
74511
+ break;
74512
+ case "undecided":
74513
+ this.ctx.logger.info("confirmation gate: birth undecided", {
74514
+ tags: { deviceId },
74515
+ meta
74516
+ });
74517
+ break;
74518
+ case "confirmed":
74519
+ this.ctx.logger.info("confirmation gate: birth confirmed", {
74520
+ tags: { deviceId },
74521
+ meta
74522
+ });
74523
+ break;
74524
+ }
74525
+ if (decision.secondary !== void 0) {
74526
+ this.secondarySubjects.add(this.procKey(deviceId, source), decision.secondary, decision.trackId, Date.now());
74527
+ this.ctx.logger.info("confirmation gate: secondary subject promoted from the crop", {
73968
74528
  tags: { deviceId },
73969
- meta
74529
+ meta: {
74530
+ trackId: decision.trackId,
74531
+ className: decision.className,
74532
+ secondaryClass: decision.secondary.className,
74533
+ secondaryScore: decision.secondary.score,
74534
+ secondaryBbox: decision.secondary.bbox,
74535
+ verdict: decision.verdict
74536
+ }
73970
74537
  });
73971
- break;
73972
- }
73973
- if (decision.secondary !== void 0) {
73974
- this.secondarySubjects.add(this.procKey(deviceId, source), decision.secondary, decision.trackId, Date.now());
73975
- this.ctx.logger.info("confirmation gate: secondary subject promoted from the crop", {
73976
- tags: { deviceId },
73977
- meta: {
73978
- trackId: decision.trackId,
73979
- className: decision.className,
73980
- secondaryClass: decision.secondary.className,
73981
- secondaryScore: decision.secondary.score,
73982
- secondaryBbox: decision.secondary.bbox,
73983
- verdict: decision.verdict
73984
- }
73985
- });
74538
+ }
73986
74539
  }
73987
- }
73988
- }, exhaustedIds);
74540
+ }, exhaustedIds),
74541
+ decisions
74542
+ };
73989
74543
  }
73990
74544
  async resolveGlobalFaceEnabled() {
73991
74545
  return this.faceGlobalEnabledCache.get(() => this.faceGlobalEnabledState.get());
@@ -75317,6 +75871,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
75317
75871
  detected,
75318
75872
  atMs: timestamp
75319
75873
  });
75874
+ if (transitionedOn) this.motionOnsets.noteRisingEdge(deviceId, timestamp);
75320
75875
  this.sceneEngine?.noteMotion(deviceId, timestamp);
75321
75876
  await this.eventStore.insertMotion(ev);
75322
75877
  this.ctx.eventBus.emit({
@@ -75392,6 +75947,7 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
75392
75947
  detected,
75393
75948
  atMs: timestamp
75394
75949
  });
75950
+ if (transitionedOn) this.motionOnsets.noteRisingEdge(deviceId, timestamp);
75395
75951
  this.sceneEngine?.noteMotion(deviceId, timestamp);
75396
75952
  await this.eventStore.insertMotion(ev);
75397
75953
  this.ctx.eventBus.emit({
@@ -78351,6 +78907,18 @@ var PipelineAnalyticsAddon = class PipelineAnalyticsAddon extends BaseAddon {
78351
78907
  return await this.debugNoteArchive?.list(input) ?? [];
78352
78908
  }
78353
78909
  /**
78910
+ * The birth-decision ledger, newest first (D409).
78911
+ *
78912
+ * A READ of a measurement table and nothing else — no join back to the
78913
+ * tracks, deliberately: a SUPPRESSED birth never had a track row and a
78914
+ * confirmed one is expected to have aged out, so a join would return exactly
78915
+ * the rows the ledger exists to preserve. A runner with no ledger answers
78916
+ * EMPTY, which is true: nothing has been measured here.
78917
+ */
78918
+ async listBirthDecisions(input) {
78919
+ return await this.birthDecisionLedger?.list(input) ?? [];
78920
+ }
78921
+ /**
78354
78922
  * Track-centric time-based retention (design §5.1). Drains every persisted
78355
78923
  * track for the device whose `lastSeen < cutoffMs`, page by page, through the
78356
78924
  * widened cascade — enrolled faces/plates + identity media are exempt (design