@camstack/addon-provider-rademacher 0.2.28 → 0.2.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +1968 -1820
  2. package/dist/addon.mjs +1968 -1820
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -16767,7 +16767,23 @@ var NcHistoryEntrySchema = object({
16767
16767
  updatedAt: number(),
16768
16768
  /** Failure detail — present on a `dead` row. */
16769
16769
  error: string().optional(),
16770
- subject: NcHistorySubjectSchema
16770
+ subject: NcHistorySubjectSchema,
16771
+ /**
16772
+ * Ids of the artefacts (still, then gif, then clip) this row's successful
16773
+ * delivery indexed in the artefact library — a REFERENCE, never the bytes
16774
+ * (an artefact is often megabytes; this row is durable JSON rewritten on
16775
+ * every delivery attempt). Absent on a row still pending/dead, a row
16776
+ * delivered before this field shipped, or a wiring with no artefact index.
16777
+ *
16778
+ * Resolve one to a fetchable URL with `resolveArtifactUrl` — an id
16779
+ * outlives any one URL's TTL, so a caller mints a fresh link on demand
16780
+ * rather than trusting one frozen at delivery time. `resolveArtifactUrl`
16781
+ * also answers `null` for an id whose artefact has since expired past the
16782
+ * retained shelf's own age bound — the degrade a caller (the Home
16783
+ * Assistant export) must render as "no image right now", never as a
16784
+ * broken link.
16785
+ */
16786
+ artifactIds: array(string().min(1)).optional()
16771
16787
  });
16772
16788
  /**
16773
16789
  * Query filter for `getHistory` (spec §4.2). Every field is a narrowing
@@ -16994,7 +17010,7 @@ method(object({}), object({ rules: array(NcRuleSchema) }), { auth: "admin" }), m
16994
17010
  }), method(object({}), object({
16995
17011
  catalog: array(NcConditionDescriptorSchema),
16996
17012
  taxonomy: NcTaxonomySchema.optional()
16997
- })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
17013
+ })), method(object({ filter: NcHistoryFilterSchema.default({ limit: 100 }) }), object({ entries: array(NcHistoryEntrySchema) }), { auth: "admin" }), method(object({ artifactId: string().min(1) }), object({ url: string().nullable() }), { auth: "admin" }), method(object({}), object({ snoozes: array(NcSnoozeSchema) }), { caller: "required" }), method(object({ snooze: NcSnoozeInputSchema }), object({ snooze: NcSnoozeSchema }), {
16998
17014
  kind: "mutation",
16999
17015
  caller: "required"
17000
17016
  }), method(object({ snoozeId: string() }), object({ success: literal(true) }), {
@@ -17334,1760 +17350,1996 @@ var OauthIntegrationDescriptorSchema = object({
17334
17350
  });
17335
17351
  method(_void(), OauthIntegrationDescriptorSchema, { auth: "admin" });
17336
17352
  /**
17337
- * pipeline-analytics device-scoped wrapper cap. Refines raw
17338
- * per-frame detections emitted by the pipeline runner into tracked
17339
- * objects, per-kind event collections (motion / object / audio), and
17340
- * persisted media. Owns the post-detection domain end-to-end:
17341
- *
17342
- * runner emits PipelineInferenceResult
17343
- * ↓ (event bus)
17344
- * pipeline-analytics subscriber
17345
- * ↓ SORT tracker + zone engine + state analyzer + event emitter
17346
- * → three DB collections (one per kind), one FS media tree, one
17347
- * unified event emitter (FrameTracked + TrackStarted/Ended +
17348
- * DetectionEvent on bus)
17349
- *
17350
- * Pure subscriber model. No `processFrame` cap method — the runner
17351
- * already publishes the raw frame on the bus. The cap surface is
17352
- * only QUERIES + per-device settings, bound on/off via
17353
- * `device-manager.setWrapperActive`. `defaultActive: true` because
17354
- * every camera with a detection pipeline wants its raw detections
17355
- * refined; operators opt out per-device via BindingsTab when needed.
17356
- *
17357
- * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
17358
- * (per-device surface) and `track-trail` caps — see P11 cleanup.
17353
+ * Reference to the frame's retained NATIVE surface + the parent crop's placement
17354
+ * within the frame, so the executor can re-cut a leaf child ROI at native
17355
+ * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
17359
17356
  */
17360
- var TrackStateSchema = _enum([
17361
- "new",
17362
- "entered",
17363
- "left",
17364
- "moving",
17365
- "idle"
17366
- ]);
17367
- var EventKindSchema = _enum([
17368
- "motion",
17369
- "object",
17370
- "audio"
17371
- ]);
17357
+ var NativeCropRefSchema = object({
17358
+ /** Handle keying the retained native surface (node-pinned to its owner). */
17359
+ handle: FrameHandleSchema,
17360
+ /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
17361
+ cropFrameSpace: object({
17362
+ x: number(),
17363
+ y: number(),
17364
+ w: number(),
17365
+ h: number()
17366
+ })
17367
+ });
17368
+ object({
17369
+ crop: object({
17370
+ left: number(),
17371
+ top: number(),
17372
+ width: number().positive(),
17373
+ height: number().positive()
17374
+ }).optional(),
17375
+ content: object({
17376
+ width: number().int().positive(),
17377
+ height: number().int().positive()
17378
+ }),
17379
+ fit: _enum(["stretch", "contain"]),
17380
+ format: _enum([
17381
+ "rgb",
17382
+ "gray",
17383
+ "jpeg"
17384
+ ])
17385
+ });
17372
17386
  /**
17373
- * Spatial filter for `listTracks` the rect + polygon variants of the shared
17374
- * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
17375
- * of the camera frame (top-left origin), matching the drawing-plane editor.
17387
+ * Process-local frame identity. It is serializable so it can ride an in-process
17388
+ * capability call, but `registryId` deliberately prevents resolution in any
17389
+ * other process or execution group.
17376
17390
  */
17377
- var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
17378
- /** Closed icon vocabulary so clients render a known glyph per kind. */
17379
- var EventKindIconSchema = _enum([
17380
- "motion",
17381
- "audio",
17382
- "person",
17383
- "vehicle",
17384
- "animal",
17385
- "door",
17386
- "pir",
17387
- "smoke",
17388
- "water",
17389
- "button",
17390
- "package",
17391
- "generic"
17391
+ var FrameRefSchema = object({
17392
+ registryId: string().min(1),
17393
+ id: string().min(1),
17394
+ width: number().int().positive(),
17395
+ height: number().int().positive(),
17396
+ format: _enum(["rgb", "gray"]),
17397
+ timestamp: number(),
17398
+ capturedAt: number().optional()
17399
+ });
17400
+ var ModelFormatSchema$1 = _enum([
17401
+ "onnx",
17402
+ "coreml",
17403
+ "openvino",
17404
+ "tflite",
17405
+ "pt",
17406
+ "gguf"
17392
17407
  ]);
17393
- var EventKindCategorySchema = _enum([
17394
- "motion",
17395
- "audio",
17396
- "detection",
17397
- "sensor",
17398
- "control",
17399
- "custom",
17400
- "package"
17408
+ var PipelineSlotSchema = _enum([
17409
+ "detector",
17410
+ "cropper",
17411
+ "classifier",
17412
+ "refiner",
17413
+ "audio-classifier"
17401
17414
  ]);
17402
- /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
17403
- var EventKindLevelSchema = _enum(["macro", "sub"]);
17404
- var EventKindDescriptorSchema = object({
17405
- /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
17406
- kind: string(),
17407
- /** i18n key resolved on the UI side; `label` is the English fallback. */
17408
- labelKey: string(),
17409
- /** English fallback label (kept for clients that don't translate). */
17410
- label: string(),
17411
- /** Hex color for timeline/legend rendering. */
17412
- color: string(),
17413
- /** Dictionary id → lucide component on the UI side. */
17414
- iconId: string(),
17415
- /** Legacy closed-vocab glyph — fallback for `iconId`. */
17416
- icon: EventKindIconSchema,
17417
- category: EventKindCategorySchema,
17418
- /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
17419
- parentKind: string().nullable(),
17420
- /** Derived from `parentKind`, explicit for the client tree. */
17421
- level: EventKindLevelSchema,
17422
- /** Which cap + device contributes this kind. For built-ins the camera
17423
- * itself; for sensor kinds the LINKED source device. */
17424
- source: object({
17425
- capName: string(),
17426
- deviceId: number()
17427
- })
17415
+ var PipelineEngineChoiceSchema = object({
17416
+ runtime: _enum(["node", "python"]),
17417
+ backend: string(),
17418
+ format: ModelFormatSchema$1,
17419
+ device: string().optional()
17428
17420
  });
17429
- /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
17430
- var EventKindsForDeviceSchema = object({
17431
- deviceId: number(),
17432
- kinds: array(EventKindDescriptorSchema).readonly()
17421
+ var AvailableEngineSchema = object({
17422
+ engine: PipelineEngineChoiceSchema,
17423
+ devices: array(object({
17424
+ id: string(),
17425
+ label: string(),
17426
+ description: string().optional()
17427
+ })).readonly(),
17428
+ defaultDevice: string()
17433
17429
  });
17434
- var SensorEventSchema = object({
17430
+ var PipelineDefaultStepSchema = lazy(() => object({
17431
+ addonId: string(),
17432
+ addonName: string(),
17433
+ slot: PipelineSlotSchema,
17434
+ inputClasses: array(string()).readonly(),
17435
+ outputClasses: array(string()).readonly(),
17436
+ enabled: boolean(),
17437
+ modelId: string(),
17438
+ children: array(PipelineDefaultStepSchema).readonly(),
17439
+ group: string().optional(),
17440
+ settings: record(string(), unknown()).optional()
17441
+ }));
17442
+ var PipelineTemplateStepSchema = lazy(() => object({
17443
+ addonId: string(),
17444
+ enabled: boolean(),
17445
+ modelId: string(),
17446
+ children: array(PipelineTemplateStepSchema).readonly(),
17447
+ settings: record(string(), unknown()).optional()
17448
+ }));
17449
+ var PipelineTemplateSchema$1 = object({
17435
17450
  id: string(),
17436
- /** The CAMERA the event is attributed to (a sensor linked to N cameras
17437
- * yields N rows, one per camera). */
17438
- deviceId: number(),
17439
- /** The linked sensor device whose state changed. */
17440
- sourceDeviceId: number(),
17441
- /** Event kind id — matches an `EventKindDescriptor.kind`. */
17442
- kind: string(),
17443
- /** Snapshot of the sensor cap's runtime-state slice at the change. */
17444
- value: record(string(), unknown()).nullable(),
17445
- timestamp: number()
17451
+ name: string(),
17452
+ createdAt: string(),
17453
+ updatedAt: string(),
17454
+ engine: PipelineEngineChoiceSchema,
17455
+ steps: array(PipelineTemplateStepSchema).readonly()
17446
17456
  });
17447
- var TrackPositionSchema = object({
17448
- x: number(),
17449
- y: number(),
17450
- timestamp: number(),
17451
- bbox: BoundingBoxSchema
17457
+ var PipelineModelOptionSchema = object({
17458
+ id: string(),
17459
+ name: string(),
17460
+ formats: record(string(), object({
17461
+ downloaded: boolean(),
17462
+ sizeMB: number()
17463
+ })),
17464
+ group: ModelVariantGroupSchema.optional(),
17465
+ legacy: boolean().optional(),
17466
+ provider: ModelProviderIdSchema.optional()
17452
17467
  });
17453
- var TrackSnapshotSchema = object({
17454
- timestamp: number(),
17455
- position: TrackPositionSchema,
17456
- /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
17457
- mediaKey: string()
17468
+ var ConfigFieldBridge = custom();
17469
+ var PipelineAddonSchemaSchema = object({
17470
+ id: string(),
17471
+ name: string(),
17472
+ slot: PipelineSlotSchema,
17473
+ inputClasses: array(string()).readonly(),
17474
+ outputClasses: array(string()).readonly(),
17475
+ childSlots: array(PipelineSlotSchema).readonly(),
17476
+ models: array(PipelineModelOptionSchema).readonly(),
17477
+ defaultModelId: string(),
17478
+ defaultModelIdByFormat: record(string(), string()).optional(),
17479
+ enabledByDefault: boolean().optional(),
17480
+ backfillIntoExistingOverrides: boolean().optional(),
17481
+ defaultConfidence: number(),
17482
+ group: string().optional(),
17483
+ configSchema: array(ConfigFieldBridge).readonly().optional()
17458
17484
  });
17459
- /**
17460
- * Normalized 0..1 trajectory envelope (min/max over every position bbox,
17461
- * divided by the track's detection-frame dims), computed at persist time.
17462
- * Absent when the frame dims were unknown when the track was persisted
17463
- * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
17464
- */
17465
- var TrackEnvelopeSchema = object({
17466
- minX: number(),
17467
- minY: number(),
17468
- maxX: number(),
17469
- maxY: number()
17485
+ var PipelineSlotSchemaSchema = object({
17486
+ id: PipelineSlotSchema,
17487
+ label: string(),
17488
+ priority: number(),
17489
+ parentSlot: PipelineSlotSchema.nullable(),
17490
+ addons: array(PipelineAddonSchemaSchema).readonly()
17470
17491
  });
17471
- /**
17472
- * Row projection for track list queries. `full` (default) returns the
17473
- * complete Track including the frame-rate `positions[]` history and the
17474
- * `snapshots[]` references — megabytes across a page of tracks. `slim`
17475
- * keeps every scalar the list surfaces actually render (ids, class(es),
17476
- * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
17477
- * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
17478
- * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
17479
- * `getTrack`. Mirrors the event-store `projection` convention
17480
- * (`getObjectEvents` et al.).
17481
- */
17482
- var TrackProjectionSchema = _enum(["full", "slim"]);
17483
- /**
17484
- * One audio-classification label heard on the track's camera while the
17485
- * track was alive, aggregated per label. An "episode" is one persisted
17486
- * audio event (the confident-classification path: score ≥ the device's
17487
- * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
17488
- * one 32 ms inference chunk, so counts stay human-scaled.
17489
- */
17490
- var TrackAudioLabelSchema = object({
17491
- label: string(),
17492
- /** Highest classification score observed across the label's episodes. */
17493
- peakScore: number(),
17494
- /** Number of coalesced audio-event episodes carrying this label. */
17495
- count: number(),
17496
- firstAt: number(),
17497
- lastAt: number()
17492
+ var PipelineSchemaSchema = object({
17493
+ availableEngines: array(AvailableEngineSchema).readonly(),
17494
+ selectedEngine: PipelineEngineChoiceSchema,
17495
+ slots: array(PipelineSlotSchemaSchema).readonly()
17498
17496
  });
17499
- /**
17500
- * How a track was produced. `pipeline` (default / absent) = the spatial
17501
- * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
17502
- * no positions, a single snapshot, and no bbox trajectory at all:
17503
- *
17504
- * - `sensor` — a linked sensor/control device state change.
17505
- * - `audio` — an audio event on the camera itself that was anomalous for
17506
- * THAT camera, loud, and heard while nothing visual was happening (D62).
17507
- *
17508
- * The spatial subsystems (tracker association, occupancy count, re-id /
17509
- * embedding, resurrection) MUST skip every synthetic source. Test for that
17510
- * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
17511
- * check silently readmits every source added after it was written.
17512
- */
17513
- var TrackSourceSchema = _enum([
17514
- "pipeline",
17515
- "sensor",
17516
- "audio"
17517
- ]);
17518
- /**
17519
- * Where a track sits in the RETRAIN lifecycle (D81).
17520
- *
17521
- * - `none` never marked, or un-marked. Evictable.
17522
- * - `staging`the operator wants this track as training material and has not
17523
- * finished with it. **This is the only state retention holds**: the track and
17524
- * everything it owns (object events, crops, keyframes, CLIP vector) survive
17525
- * the device's age window.
17526
- * - `trained` — the retrain page has taken what it needed. The frames it chose
17527
- * were COPIED into the retrain dataset at selection time, so the dataset no
17528
- * longer depends on the track's media and the track becomes EVICTABLE again.
17529
- * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
17530
- * a deliberate action of the retrain page, not a side effect of a checkbox.
17531
- *
17532
- * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
17533
- * the store's filter language has only positive equality and `whereIn` — no
17534
- * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
17535
- * would make the entire pre-column history immortal in one deploy.
17536
- */
17537
- var RetrainStatusSchema = _enum([
17538
- "none",
17539
- "staging",
17540
- "trained"
17541
- ]);
17542
- /**
17543
- * Per-track OPERATOR flags — set by hand from the admin UI or the viewer, never
17544
- * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
17545
- * so the two surfaces cannot drift.
17546
- *
17547
- * **Absent ≠ false.** A track that has never been touched omits the field; an
17548
- * explicitly un-flagged track carries `false`. Legacy rows written before the
17549
- * columns existed read as absent, and a consumer that needs a boolean should say
17550
- * `flag === true`, not `flag !== false`.
17551
- *
17552
- * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
17553
- * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
17554
- * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
17555
- * `trained` track reports `false` while refusing both writes. The boolean is
17556
- * kept because three surfaces drive a toggle off it; anything that needs to tell
17557
- * "never marked" from "already trained" must read `retrainStatus`.
17558
- *
17559
- * `debug` does NOT pin; it is attention, not durability.
17560
- *
17561
- * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
17562
- * A favourited track is skipped by retention the same way `staging` is, but
17563
- * it does not enter `none|staging|trained` and has no staging budget.
17564
- */
17565
- var TrackFlagFields = {
17566
- /** Operator marked this track as training material — i.e. `retrainStatus` is
17567
- * `'staging'`. */
17568
- markForTrain: boolean().optional(),
17569
- /** Operator marked this track for diagnostic attention. */
17570
- debug: boolean().optional(),
17571
- /** Operator favourited this track. Pins it against pruning. */
17572
- favourited: boolean().optional()
17573
- };
17574
- /**
17575
- * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
17576
- * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
17577
- * write patch, and the status is not something the toggle sets — it is what the
17578
- * toggle's boolean is derived from. Absent on an in-RAM track never touched;
17579
- * always present on a persisted row (the column default materialises `'none'`).
17580
- */
17581
- var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
17582
- /**
17583
- * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
17584
- * one flag can never clear the other — the toggles are independent and are
17585
- * driven from three surfaces that do not know about each other.
17586
- */
17587
- var TrackFlagsPatchSchema = object(TrackFlagFields);
17588
- /**
17589
- * The resolved flag state after a write. Both fields are REQUIRED here (absent
17590
- * collapses to `false`) so a caller can drive a toggle's checked state off the
17591
- * mutation result without a re-fetch.
17592
- */
17593
- var TrackFlagsSchema = object({
17594
- trackId: string(),
17595
- markForTrain: boolean(),
17596
- debug: boolean(),
17597
- favourited: boolean(),
17598
- /** The lifecycle state the boolean was derived from. Required here (unlike on
17599
- * a track row) because this shape is only ever produced by the write body,
17600
- * which always knows it — and a surface that has just written needs to render
17601
- * `trained` without a re-fetch. */
17602
- retrainStatus: RetrainStatusSchema
17497
+ var EngineProvisioningSchema = object({
17498
+ runtimeId: _enum([
17499
+ "onnx",
17500
+ "openvino",
17501
+ "coreml",
17502
+ "edgetpu"
17503
+ ]).nullable(),
17504
+ device: string().nullable(),
17505
+ state: _enum([
17506
+ "idle",
17507
+ "installing",
17508
+ "verifying",
17509
+ "ready",
17510
+ "failed"
17511
+ ]),
17512
+ progress: number().optional(),
17513
+ error: string().optional(),
17514
+ nextRetryAt: number().optional(),
17515
+ /**
17516
+ * Gate A (config-correctness gate at engine change): human-readable
17517
+ * config issues surfaced EAGERLY when the node's engine changes — model
17518
+ * substitutions ("chose X, running Y") and zero-build steps ("no model
17519
+ * has a <format> build"). Additive/optional: informational only, never
17520
+ * enforced here `assertEngineReady` (readiness) still gates inference.
17521
+ * Absent/empty when the node-default tree resolves cleanly.
17522
+ */
17523
+ configIssues: array(string()).optional()
17603
17524
  });
17604
- union([literal(1), literal(2)]);
17605
- /**
17606
- * WHO decided a label, and when. Carried per tier so a value can be traced to
17607
- * the step and model that produced it — which is what makes the write rule
17608
- * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
17609
- * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
17610
- *
17611
- * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
17612
- * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
17613
- * `migration:4g` for a value the 4g migration moved from the single-slot era —
17614
- * that value has no provenance, and the write rule lets ANY properly-attributed
17615
- * write of the same tier replace it regardless of score.
17616
- */
17617
- var LabelAttributionSchema = object({
17618
- stepId: string(),
17525
+ var PipelineStepInputSchema = lazy(() => object({
17526
+ addonId: string(),
17619
17527
  modelId: string().optional(),
17620
- decidedAt: number(),
17528
+ enabled: boolean().default(true),
17529
+ children: array(PipelineStepInputSchema).optional(),
17530
+ settings: record(string(), unknown()).optional(),
17531
+ jumpDeviceKey: string().optional()
17532
+ }));
17533
+ var ModelSubstitutionSchema = object({
17534
+ addonId: string(),
17535
+ chosen: string(),
17536
+ running: string(),
17537
+ format: string()
17538
+ });
17539
+ var PipelineValidationIssueSchema = object({
17540
+ addonId: string(),
17541
+ kind: _enum(["unknown-addon", "no-format-build"]),
17542
+ detail: string()
17543
+ });
17544
+ var PipelineValidationResultSchema = object({
17545
+ ok: boolean(),
17546
+ issues: array(PipelineValidationIssueSchema).readonly(),
17547
+ substitutions: array(ModelSubstitutionSchema).readonly(),
17548
+ /** The node's `currentEngine.format` this validation ran against. */
17549
+ format: string()
17550
+ });
17551
+ var ReferenceImageEntrySchema = object({
17552
+ filename: string(),
17553
+ stepIds: array(string()).readonly().optional()
17554
+ });
17555
+ var ReferenceImageBodySchema = object({
17556
+ base64: string(),
17557
+ filename: string()
17558
+ });
17559
+ var ReferenceAudioEntrySchema = object({
17560
+ filename: string(),
17561
+ sizeKb: number()
17562
+ });
17563
+ var ReferenceAudioBodySchema = object({ base64: string() });
17564
+ var AudioBackendSchema = object({
17565
+ id: string(),
17566
+ name: string(),
17567
+ description: string(),
17568
+ available: boolean(),
17621
17569
  /**
17622
- * The GALLERY id behind a recognised tier-2 label — a face-gallery
17623
- * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
17624
- *
17625
- * The text alone is a DISPLAY NAME, and a display name is renameable: a
17626
- * notification rule authored on "Gianluca" stopped matching the moment the
17627
- * operator fixed the spelling in the gallery, and nothing said so. The id is
17628
- * the thing that does not move, so it is what a rule matches on
17629
- * (`NcConditions.identities`) and the text is what a human is shown.
17630
- *
17631
- * Absent when the label names no gallery row — a plate the OCR read but no
17632
- * vehicle claims, a sub-class, a species, any tier-1 value.
17570
+ * Raw classifier labels this backend can emit (e.g. YAMNet's
17571
+ * 521-class set or Apple SoundAnalysis's 303-class set). Used by
17572
+ * the benchmark UI to populate the `enabledMicroClasses` filter
17573
+ * specific to the selected backend without a separate fetch.
17633
17574
  */
17634
- identityId: string().optional()
17575
+ rawLabels: array(string()).readonly().optional()
17576
+ });
17577
+ var AudioCapabilitiesSchema = object({
17578
+ activeBackend: string(),
17579
+ availableBackends: array(AudioBackendSchema).readonly(),
17580
+ sampleRate: number(),
17581
+ chunkDurationMs: number()
17582
+ });
17583
+ var DownloadModelResultSchema = object({
17584
+ filePath: string(),
17585
+ sizeMB: number(),
17586
+ durationMs: number()
17635
17587
  });
17636
17588
  /**
17637
- * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
17638
- * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
17639
- * track and its events always answer the same question the same way.
17640
- *
17641
- * Two scalar columns, not an array: every consumer wants "the coarse one" or
17642
- * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
17643
- * is tier 2, and each carries its own score + attribution.
17644
- *
17645
- * **Reading it.** What a human should be shown is `subLabel ?? label` — the
17646
- * finest thing known. Before 4g the single `label` column held the finest
17647
- * value, so a consumer that has not been updated reads the tier-1 slot and
17648
- * shows nothing on a species-only row; that is why the migration puts every
17649
- * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
17650
- * and why the read surfaces were changed in the same train.
17651
- *
17652
- * **Writing it.** The slots are independent, which is the whole point: a
17653
- * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
17654
- * migratorius`), so fineness cannot regress by construction. Within a tier the
17655
- * higher score wins. One rule, one implementation — see
17656
- * `pipeline/label-tier.ts` in addon-post-analysis.
17657
- */
17658
- var TieredLabelFields = {
17659
- /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
17660
- label: string().optional(),
17661
- /** Confidence of the tier-1 value, as reported by the deciding step. */
17662
- labelScore: number().optional(),
17663
- /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
17664
- labelMeta: LabelAttributionSchema.optional(),
17665
- /** Tier 2 — the instance. See {@link LabelTierSchema}. */
17666
- subLabel: string().optional(),
17667
- /** Confidence of the tier-2 value, as reported by the deciding step. */
17668
- subLabelScore: number().optional(),
17669
- /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
17670
- subLabelMeta: LabelAttributionSchema.optional()
17671
- };
17672
- /** Per-camera slice of a training-export estimate. */
17673
- var TrainingExportDeviceTotalsSchema = object({
17674
- deviceId: number(),
17675
- tracks: number().int(),
17676
- files: number().int(),
17677
- bytes: number().int()
17678
- });
17679
- /**
17680
- * What a training export WOULD contain. Computed from media index rows only —
17681
- * no blob is read to produce this.
17589
+ * Wrapper carrying a single test run's result. Replaces the legacy
17590
+ * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
17591
+ * canonical `AudioResult` from the Phase 6 output rework: one
17592
+ * `AudioDetection` per class above `minScore`, top-N candidates in
17593
+ * `debug.alternateLabels['audio-classifier']`, per-source timings in
17594
+ * `debug.stepTimings`. The outer `success`/`error` fields stay so the
17595
+ * benchmark UI can still report a clean failure when the classifier
17596
+ * cap isn't available.
17682
17597
  */
17683
- var TrainingExportSummarySchema = object({
17684
- generatedAt: number(),
17685
- trackCount: number().int(),
17686
- fileCount: number().int(),
17687
- byteCount: number().int(),
17688
- /** More marked tracks exist than a single pass carries. */
17689
- truncated: boolean(),
17690
- devices: array(TrainingExportDeviceTotalsSchema).readonly()
17598
+ var AudioTestResultSchema = object({
17599
+ success: boolean(),
17600
+ error: string().optional(),
17601
+ frame: custom().optional()
17691
17602
  });
17692
- var TrackSchema = object({
17693
- trackId: string(),
17694
- deviceId: number(),
17695
- className: string(),
17696
- ...TieredLabelFields,
17697
- producingDeviceName: string().optional(),
17698
- /** Track provenance. Absent `pipeline` (legacy rows). */
17699
- source: TrackSourceSchema.optional(),
17700
- firstSeen: number(),
17701
- lastSeen: number(),
17702
- /** Frame-rate position history (subject to maxPositionHistory cap). */
17703
- positions: array(TrackPositionSchema).readonly(),
17704
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17705
- * saveThumbnails policy). */
17706
- snapshots: array(TrackSnapshotSchema).readonly(),
17707
- /** Deduplicated zones the track has entered at least once. Zone IDS. */
17708
- zonesVisited: array(string()).readonly(),
17603
+ var PipelineConfigBridge = custom();
17604
+ var ConfigUISchemaBridge = custom();
17605
+ var ConfigUISchemaNullableBridge = custom();
17606
+ var InferenceCapabilitiesBridge = custom();
17607
+ var ModelAvailabilityListBridge = custom();
17608
+ var PipelineRunResultBridge = custom();
17609
+ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
17610
+ modelId: string(),
17611
+ settings: record(string(), unknown()).readonly()
17612
+ }))), method(object({ steps: record(string(), object({
17613
+ modelId: string(),
17614
+ settings: record(string(), unknown()).readonly()
17615
+ })) }), object({ success: literal(true) }), {
17616
+ kind: "mutation",
17617
+ auth: "admin"
17618
+ }), method(object({ nodeId: string() }), object({
17619
+ success: literal(true),
17620
+ clearedDevices: number()
17621
+ }), {
17622
+ kind: "mutation",
17623
+ auth: "admin"
17624
+ }), method(object({ nodeId: string() }), object({ unhealthy: array(object({
17625
+ /** `<backend>:<device>`, e.g. `openvino:gpu`. */
17626
+ deviceKey: string(),
17709
17627
  /**
17710
- * Human NAMES for {@link zonesVisited}, resolved at READ time against the
17711
- * `zones` capability.
17712
- *
17713
- * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
17714
- * and no card can render — so every free-text search surface was structurally
17715
- * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
17716
- * just returned nothing. Resolving here rather than in each client keeps ONE
17717
- * derivation and costs the clients no extra call (the `zones` cap is
17718
- * per-device, so a client-side resolve would be a per-camera fan-out on a
17719
- * surface built to avoid exactly that).
17720
- *
17721
- * Resolved, never invented: a zone deleted since the track was written has no
17722
- * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
17723
- * two are not positionally aligned. Absent when the track visited no zone, or
17724
- * when the zone catalogue could not be read.
17628
+ * `failed` the per-device restart budget is exhausted; no pool
17629
+ * will be spawned until an operator re-arms it or the runner
17630
+ * respawns. `backoff` — under budget, waiting out the backoff (or
17631
+ * a cached pool observed dead and not yet condemned).
17725
17632
  */
17726
- zoneNames: array(string()).readonly().optional(),
17727
- /** Deduplicated set of detector classes observed for this track over its
17728
- * life (a track may be reclassified, e.g. person→vehicle). Absent on
17729
- * legacy rows written before class accumulation shipped. */
17730
- classes: array(string()).readonly().optional(),
17731
- /** Cumulative normalized distance travelled (0..1 units = full frame width). */
17732
- totalDistance: number(),
17733
- state: TrackStateSchema,
17734
- active: boolean(),
17735
- /** Deterministic key-event importance score in [0,1] (server-computed at
17736
- * track expiry, recomputed on late label). Absent on legacy rows written
17737
- * before scoring shipped — consumers degrade to absence / compute-on-read. */
17738
- importance: number().optional(),
17739
- /** Id of the track's highest-confidence ObjectEvent (its representative
17740
- * "best" frame). Absent when the track produced no object events. */
17741
- bestEventId: string().optional(),
17742
- /** Tag of the importance sub-signal that dominated the score
17743
- * (identity|dwell|proximity|class|confidence|travel|zone). */
17744
- importanceReason: string().optional(),
17745
- /** Audio-classification labels heard on the camera during the track's
17746
- * life (score ≥ device `classificationMinScore`), aggregated per label.
17747
- * Absent on legacy rows / tracks with no confident audio. */
17748
- audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
17749
- /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
17750
- * Populated from the persisted envelope columns on historical reads;
17751
- * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
17752
- envelope: TrackEnvelopeSchema.optional(),
17633
+ state: _enum(["failed", "backoff"]),
17634
+ /** Epoch ms of the death that produced this state. */
17635
+ since: number(),
17636
+ /** Pool deaths inside the current window. */
17637
+ deaths: number(),
17638
+ /** The last death's message. */
17639
+ lastError: string()
17640
+ })).readonly() })), method(object({
17641
+ nodeId: string(),
17642
+ deviceKey: string()
17643
+ }), object({ rearmed: boolean() }), {
17644
+ kind: "mutation",
17645
+ auth: "admin"
17646
+ }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
17647
+ name: string(),
17648
+ steps: array(PipelineTemplateStepSchema).readonly(),
17649
+ engine: PipelineEngineChoiceSchema
17650
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
17651
+ id: string(),
17652
+ name: string().optional(),
17653
+ steps: array(PipelineTemplateStepSchema).readonly().optional()
17654
+ }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
17655
+ addonId: string(),
17656
+ modelId: string(),
17657
+ format: ModelFormatSchema$1
17658
+ }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
17659
+ addonId: string(),
17660
+ modelId: string(),
17661
+ format: ModelFormatSchema$1
17662
+ }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
17663
+ engine: PipelineEngineChoiceSchema.optional(),
17664
+ steps: array(PipelineStepInputSchema).min(1),
17665
+ frame: FrameInputSchema.optional(),
17753
17666
  /**
17754
- * A face DETECTOR found a face on this track — nothing more. It says the
17755
- * detail plane produced a `face` detail; it does NOT say the face was
17756
- * embedded, matched, above `minFacePx`, or that the recognizer was even
17757
- * enabled. Set once and never cleared.
17758
- *
17759
- * **This exists so "face present but not recognised" is expressible.** A
17760
- * recognised identity lands in `subLabel` (attributed to the face chain via
17761
- * `subLabelMeta.stepId`), so before this field a track with an unmatched face
17762
- * and a track with no face at all were byte-identical on the wire and no
17763
- * surface could tell them apart. The read is `hasFace === true && subLabel
17764
- * === undefined`.
17765
- *
17766
- * **Absent ≠ false.** Every row written before the column existed omits it,
17767
- * and so does every server that predates the field — a consumer must test
17768
- * `=== true` and render nothing otherwise, never infer "no face".
17667
+ * Process-local lazy frame. Valid only when caller and provider resolve
17668
+ * in the same execution-group process; split/cross-node callers use
17669
+ * `frame`/`image` inline compatibility instead.
17769
17670
  */
17770
- hasFace: boolean().optional(),
17671
+ frameRef: FrameRefSchema.optional(),
17771
17672
  /**
17772
- * This track has a face row IN THE GALLERY: a crop **and** an embedding a
17773
- * face an operator could ASSIGN to an identity.
17774
- *
17775
- * The STRICT twin of {@link hasFace}, and the pair only earns its keep
17776
- * because the two disagree. `hasFace` is stamped at the TOP of the face
17777
- * branch, before every gate, and means no more than "a face detector produced
17778
- * a face detail". This one is stamped at the single moment the gallery row
17779
- * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
17780
- * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
17781
- * candidate gate, the imageless-track drop (no crop was ever captured) and
17782
- * the crop-store drop. Everything between the detector and that insert can
17783
- * legitimately refuse the face, so a flag written any earlier promises the
17784
- * operator something to assign and delivers nothing.
17785
- *
17786
- * **Independent of recognition.** A face collected but never auto-matched is
17787
- * still assignable — it is in fact the face an operator most wants to reach —
17788
- * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
17789
- * `subLabel`; this says only that the raw material exists.
17790
- *
17791
- * **Set once, never cleared.** A track that produced a gallery row produced
17792
- * one; deleting the row later is the gallery's business, not this flag's.
17793
- *
17794
- * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
17795
- * before the column omits it, and so does every server that predates the
17796
- * field. A consumer must test `=== true` and render nothing otherwise —
17797
- * never infer "no assignable face".
17673
+ * CB5 shm passthrough a `FrameHandle` naming the same ring slot
17674
+ * the decoded pixels live in. One more member of the one-of
17675
+ * frame/frameHandle/image/imageBase64/referenceImage group.
17798
17676
  */
17799
- hasEmbeddedFace: boolean().optional(),
17677
+ frameHandle: FrameHandleSchema.optional(),
17678
+ imageBase64: string().optional(),
17800
17679
  /**
17801
- * This subject CONTAINS a folded rider a person the rider-pairing step
17802
- * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
17803
- * so the passage is tracked once and as a VEHICLE.
17804
- *
17805
- * It exists because the fold's record was dishonest. D34 and the code both
17806
- * said "the person is not lost — it is reported so both entities stay on the
17807
- * record"; in fact the pair went into a per-processor RAM field behind an
17808
- * accessor nobody called, and every durable surface said `vehicle`, full
17809
- * stop. This is the composition note that makes the row true.
17810
- *
17811
- * A COMPOSITION, never a class and never a label. "This vehicle contains a
17812
- * person" is not an answer to "what is this" — both label tiers would refuse
17813
- * a macro token anyway (D89), and correctly. Nothing here changes what the
17814
- * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
17815
- * and a `person` rule still does not fire for someone cycling past.
17816
- *
17817
- * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
17818
- * the column, and every hub that predates the field, omits it. Test
17819
- * `=== true` and render nothing otherwise — never infer "no rider".
17680
+ * Binary JPEG bytespreferred over `imageBase64` on internal
17681
+ * hops (hub forked worker via Moleculer MsgPack) because it
17682
+ * skips the 33% base64 overhead + the per-call base64 decode on
17683
+ * the detection-pipeline worker. Callers can pass either; exactly
17684
+ * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
17820
17685
  */
17821
- hasRider: boolean().optional(),
17822
- ...TrackFlagFields,
17823
- ...TrackRetrainFields
17824
- });
17825
- var BaseEventFields = {
17826
- id: string(),
17827
- deviceId: number(),
17828
- timestamp: number()
17829
- };
17830
- var MotionEventSchema = object({
17831
- ...BaseEventFields,
17832
- kind: literal("motion"),
17833
- regionCount: number(),
17834
- /** Heavy JSON array omitted in slim projection. */
17835
- regions: array(object({
17836
- bbox: BoundingBoxSchema,
17837
- pixelCount: number(),
17838
- intensity: number()
17839
- })).readonly().optional(),
17840
- /** Omitted in slim projection. */
17841
- frameWidth: number().optional(),
17842
- /** Omitted in slim projection. */
17843
- frameHeight: number().optional(),
17844
- /** Populated by B5 (recording playback URL for this event). */
17845
- mediaUrl: string().optional()
17846
- });
17686
+ image: _instanceof(Uint8Array).optional(),
17687
+ referenceImage: string().optional(),
17688
+ deviceId: number().optional(),
17689
+ sessionId: string().optional(),
17690
+ /**
17691
+ * Execution plane. 'full' (default) runs the whole tree — benchmark,
17692
+ * reference-image, and detail-subtree calls. 'frame' is the live
17693
+ * per-frame dispatch: ONLY root-plane steps run; crop children
17694
+ * (inputClasses ≠ null) are skipped and served per-track via
17695
+ * pipelineRunner.runDetailSubtree (two-plane design).
17696
+ */
17697
+ plane: _enum(["full", "frame"]).optional(),
17698
+ /**
17699
+ * Inference-device selector (Phase 2 multi-device). Format
17700
+ * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
17701
+ * Omitted ⇒ the runner's default device (current single-engine
17702
+ * behaviour). Selects WHICH device pool of the node runs the call.
17703
+ */
17704
+ deviceKey: string().optional(),
17705
+ /**
17706
+ * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
17707
+ * when the parent crop was resolved from the frame's retained NATIVE
17708
+ * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
17709
+ * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
17710
+ * resolution from that surface — the SAME quality path faces already
17711
+ * had — instead of the downscaled parent tile. `handle` keys the native
17712
+ * surface (node-pinned to its owner); `cropFrameSpace` is the parent
17713
+ * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
17714
+ * the executor's crop-normalized child ROI back into frame-normalized
17715
+ * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
17716
+ * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
17717
+ * (today's behaviour on the fallback path).
17718
+ */
17719
+ nativeCropRef: NativeCropRefSchema.optional()
17720
+ }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
17721
+ engine: PipelineEngineChoiceSchema.optional(),
17722
+ steps: array(PipelineStepInputSchema).min(1),
17723
+ frames: array(FrameInputSchema).min(1).max(255),
17724
+ deviceId: number().optional(),
17725
+ sessionId: string().optional(),
17726
+ /**
17727
+ * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
17728
+ * the batch to the Python pool's bench preprocess cache
17729
+ * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
17730
+ * preprocessed ONCE and every later inference is a pure-inference cache
17731
+ * hit — the sustained-throughput run measures inference, not
17732
+ * decode+preprocess+infer. Omitted/0 for live frames (all different →
17733
+ * full preprocess every call, correct). Fresh per sustained run;
17734
+ * released via `uncacheFrame`.
17735
+ */
17736
+ frameId: number().int().nonnegative().optional(),
17737
+ /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
17738
+ deviceKey: string().optional()
17739
+ }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
17740
+ data: _instanceof(Uint8Array),
17741
+ width: number().int().positive(),
17742
+ height: number().int().positive(),
17743
+ format: _enum([
17744
+ "rgb",
17745
+ "bgr",
17746
+ "gray"
17747
+ ])
17748
+ }), object({
17749
+ frameId: number(),
17750
+ width: number(),
17751
+ height: number()
17752
+ }), { kind: "mutation" }), method(object({
17753
+ stepId: string(),
17754
+ frameId: number().int()
17755
+ }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
17756
+ batchMode: string(),
17757
+ windowMs: number(),
17758
+ maxBatchSize: number(),
17759
+ concurrency: number()
17760
+ })), method(_void(), array(object({
17761
+ engineKey: string(),
17762
+ engine: PipelineEngineChoiceSchema,
17763
+ modelsLoaded: array(string()).readonly(),
17764
+ inUseByCameras: array(number()).readonly(),
17765
+ /**
17766
+ * Origin of this resident factory.
17767
+ * - `runtime` — main camera-serving engine (no idle TTL).
17768
+ * - `warm-override` — benchmark/test override held in the warm
17769
+ * cache; auto-disposed after the idle TTL.
17770
+ * - `device-pool` — a concurrent per-device pool (Phase 2
17771
+ * multi-device, keyed by `deviceKey`) resolved
17772
+ * via `resolveDeviceFactory`. Runs alongside the
17773
+ * `runtime` engine on a DIFFERENT accelerator
17774
+ * (NPU / iGPU / Coral) — this is how the
17775
+ * Engines tab shows all pools running at once.
17776
+ */
17777
+ kind: _enum([
17778
+ "runtime",
17779
+ "warm-override",
17780
+ "device-pool"
17781
+ ]),
17782
+ /** Native pid of the underlying Python pool (null when no pool). */
17783
+ poolPid: number().nullable(),
17784
+ /** ms since this factory was last used (null when not warm-tracked). */
17785
+ idleMs: number().nullable(),
17786
+ /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
17787
+ idleTtlMs: number().nullable()
17788
+ })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
17789
+ kind: "mutation",
17790
+ auth: "admin"
17791
+ }), method(object({
17792
+ engine: PipelineEngineChoiceSchema,
17793
+ force: boolean().optional()
17794
+ }), object({
17795
+ success: boolean(),
17796
+ reason: string().optional()
17797
+ }), {
17798
+ kind: "mutation",
17799
+ auth: "admin"
17800
+ }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
17801
+ addonId: string(),
17802
+ modelId: string(),
17803
+ filename: string().optional(),
17804
+ settings: record(string(), unknown()).optional()
17805
+ }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
17847
17806
  /**
17848
- * Which detection SOURCE produced an object event. `pipeline` = the ML
17849
- * detection pipeline (decoded-frame inference); `onboard` = the camera's
17850
- * native on-device AI. Both flow through the SAME analysis layers (zoning,
17851
- * tracking, per-kind persistence) but stay distinguishable so consumers
17852
- * (advanced-notifier, occupancy, …) can select which source(s) to act on.
17853
- * Absent on legacy rows treat as `pipeline`.
17807
+ * Per-stage gating mode applied to the zones a rule references.
17808
+ *
17809
+ * - `include`: the rule contributes to a **whitelist** for its stage.
17810
+ * When at least one `include` rule fires for a stage, only entities
17811
+ * inside one of those zones pass that stage.
17812
+ * - `exclude`: the rule contributes to a **blacklist** for its stage.
17813
+ * Entities inside one of those zones are dropped at that stage.
17814
+ *
17815
+ * `monitor`-style observation (count without filtering) is not a rule
17816
+ * mode — zones without any matching rule are observed naturally by
17817
+ * `zone-analytics` (live snapshot + history), so an "I just want to
17818
+ * count, not filter" use case needs no rule at all.
17854
17819
  */
17855
- var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
17820
+ var ZoneRuleModeEnum = _enum(["include", "exclude"]);
17856
17821
  /**
17857
- * The confirmed zone crossing that produced an object event. Present ONLY on
17858
- * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
17859
- * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
17860
- * appearance event carry none, so a rule asking for a direction fails closed
17861
- * on them.
17822
+ * Per-consumer rule that references existing zones (geometry) and
17823
+ * defines how a specific pipeline stage should treat them. Each
17824
+ * consumer addon owns its own `ZoneRule[]` array in its per-device
17825
+ * settings:
17862
17826
  *
17863
- * Exactly ONE crossing per event: the emitter turns each confirmed crossing
17864
- * into its own event, so a frame in which a track enters A while leaving B
17865
- * produces two events with two directions — never one ambiguous row.
17827
+ * - `addon-motion-wasm` `motionZoneRules: ZoneRule[]` (motion stage)
17828
+ * - `addon-detection-pipeline` `detectionZoneRules: ZoneRule[]` (detection stage)
17829
+ * - future: notification rules, audio gating, etc.
17866
17830
  *
17867
- * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
17868
- * membership the box has NOW, and by definition it no longer contains the zone
17869
- * that was just left. Without the id here, a zone-scoped rule could never match
17870
- * the exit it asked for.
17831
+ * One rule applies to N zones (`zoneIds[]`) so the operator can
17832
+ * express "ignore motion in ALL of {garden, street}" with a single
17833
+ * rule. `classFilter` narrows the rule to specific object classes
17834
+ * "drop person detections in the street, but keep cars" is one
17835
+ * `exclude` rule with `classFilter: ['person']`.
17836
+ *
17837
+ * `enabled` is a soft toggle — the operator can keep the rule
17838
+ * configured but inert without deleting it.
17871
17839
  */
17872
- var ZoneCrossingSchema = object({
17873
- direction: _enum(["enter", "exit"]),
17874
- /** Admin zone id crossed. */
17875
- zoneId: string(),
17876
- /** Zone display name at crossing time (falls back to the id). */
17877
- zoneName: string().optional()
17878
- });
17879
- var ObjectEventSchema = object({
17880
- ...BaseEventFields,
17881
- kind: literal("object"),
17882
- /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
17883
- source: DetectionSourceSchema.optional(),
17840
+ var ZoneRuleSchema = object({
17841
+ /** Stable rule id — survives edits, used by the UI for diffing. */
17842
+ id: string(),
17843
+ /** Optional human-readable label rendered in the rule editor. */
17844
+ name: string().optional(),
17845
+ /** Zones this rule targets. The rule's `mode` applies to ALL
17846
+ * listed zones (OR-set: a detection in any one of them counts).
17847
+ * At least one zone id required — a rule with no targets is a
17848
+ * configuration mistake and the form validator rejects it. */
17849
+ zoneIds: array(string()).min(1).readonly(),
17850
+ mode: ZoneRuleModeEnum,
17884
17851
  /**
17885
- * Inference-frame id shared by every object event emitted from the SAME frame
17886
- * the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
17887
- * 2 people + 1 dog) under one full frame, and link a track's frames over time
17888
- * (group by `trackId`, pick a representative `frameId` as the parent frame).
17889
- * Optional for backward-compat with pre-existing rows / the slim projection
17890
- * includes it (it is light). Absent on rows written before this field.
17852
+ * Class names this rule applies to. Empty / undefined rule
17853
+ * applies to every class. Class strings match the `macroClass`
17854
+ * field on detections (e.g. `person`, `car`, `dog`).
17891
17855
  */
17892
- frameId: string().optional(),
17893
- /** Omitted in slim projection. */
17894
- trackId: string().optional(),
17895
- className: string(),
17896
- ...TieredLabelFields,
17897
- /** Omitted in slim projection. */
17898
- confidence: number().optional(),
17899
- /** Heavy JSON — omitted in slim projection. */
17900
- bbox: BoundingBoxSchema.optional(),
17901
- /** Heavy JSON — omitted in slim projection. */
17902
- zones: array(string()).readonly().optional(),
17903
- /** Omitted in slim projection. */
17904
- state: TrackStateSchema.optional(),
17856
+ classFilter: array(string()).readonly().optional(),
17905
17857
  /**
17906
- * The zone crossing this event IS, when it is one. Absent on every other
17907
- * event kind (movement state, appearance, package) see
17908
- * {@link ZoneCrossingSchema}. Omitted in slim projection.
17858
+ * Minimum bbox/mask overlap (0–1) with any of the rule's zones
17859
+ * required to consider an entity "in the zone". Defaults to the
17860
+ * consumer's stage default when omitted. Kept for back-compat with
17861
+ * existing per-rule overrides; new operators pick the value via
17862
+ * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
17863
+ * set, the lower-level engine reads it as a 0–1 fraction.
17909
17864
  */
17910
- zoneCrossing: ZoneCrossingSchema.optional(),
17911
- /** Detection-frame dimensions in pixels — let consumers normalize the
17912
- * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
17913
- frameWidth: number().optional(),
17914
- frameHeight: number().optional(),
17915
- /** MediaStore key for the crop attached to this event (if any). */
17916
- mediaKey: string().optional(),
17917
- /** Design B: MediaStore key of the track's native-resolution key frame (the
17918
- * best-detection full frame). Resolve via the event-media data-plane
17919
- * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
17920
- * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
17921
- * sources — consumers fall back to `mediaKey` (the tight crop). */
17922
- keyFrameMediaKey: string().optional(),
17923
- /** Populated by B5 (recording playback URL for this event). */
17924
- mediaUrl: string().optional(),
17925
- /** The parent track's key-event importance [0,1], propagated to every object
17926
- * event of the track (so an event row can be sorted by importance without a
17927
- * track join). Absent on legacy rows / before the track was scored. */
17928
- importance: number().optional()
17929
- });
17930
- var AudioEventSchema = object({
17931
- ...BaseEventFields,
17932
- kind: literal("audio"),
17933
- rms: number(),
17934
- dbfs: number(),
17935
- classification: object({
17936
- className: string(),
17937
- originalClass: string().optional(),
17938
- score: number()
17939
- }).optional(),
17940
- /** Populated by B5 (recording playback URL for this event). */
17941
- mediaUrl: string().optional()
17865
+ overlapThreshold: number().min(0).max(1).optional(),
17866
+ /**
17867
+ * Operator-friendly version of `overlapThreshold` the percentage
17868
+ * of the detection's bbox that must lie inside the zone for the
17869
+ * rule to match. Documented default is 85%; the engine substitutes
17870
+ * that when the field is omitted (kept optional so existing rules
17871
+ * stored without it stay valid).
17872
+ *
17873
+ * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
17874
+ * rule, the engine prefers `bboxInclusionPct` because it's the
17875
+ * field exposed in the UI. Internally both feed the same gate.
17876
+ */
17877
+ bboxInclusionPct: number().min(0).max(100).optional(),
17878
+ /**
17879
+ * When `true` and a detection has a segmentation mask, use the
17880
+ * mask for overlap instead of the bbox. Detection-stage only;
17881
+ * motion rules ignore this field.
17882
+ */
17883
+ preferMask: boolean().optional(),
17884
+ /**
17885
+ * Soft-toggle: `false` disables the rule without deleting it.
17886
+ * Defaults to `true` so operators creating a rule via the UI
17887
+ * see it active immediately.
17888
+ */
17889
+ enabled: boolean().default(true)
17942
17890
  });
17943
- var MediaFileKindEnum = _enum([
17944
- "crop",
17945
- "thumbnail",
17946
- "snapshot",
17947
- "firstFrame",
17948
- "lastFrame",
17949
- "fullFrame",
17950
- "fullFrameBoxed",
17951
- "faceCrop",
17952
- "plateCrop",
17953
- "keyFrame",
17954
- "keyFrameSmall",
17955
- "thumbnailSmall"
17956
- ]);
17957
- var MediaFileSchema = object({
17958
- key: string(),
17959
- kind: MediaFileKindEnum,
17960
- base64: string(),
17961
- sizeBytes: number(),
17962
- timestamp: number()
17891
+ array(ZoneRuleSchema).readonly();
17892
+ /**
17893
+ * Zone — pure geometry + identity. NO filtering behaviour.
17894
+ *
17895
+ * Zones describe **where** in the frame the operator wants to flag
17896
+ * something; consumer-owned {@link ZoneRule} arrays describe **how**
17897
+ * each pipeline stage uses them. Splitting the two means a single
17898
+ * polygon "Driveway" can simultaneously back a motion-exclude rule,
17899
+ * a detection-include rule on `['car']`, and an occupancy aggregate
17900
+ * — without three duplicated polygons.
17901
+ *
17902
+ * Owned by the orchestrator addon (provider) and mirrored into the
17903
+ * `zones` device-state slice on every mutation. Consumers
17904
+ * (motion-wasm, pipeline-executor, analytics, admin UI) read either
17905
+ * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
17906
+ * mirror with `onChanged`).
17907
+ *
17908
+ * Coordinates are normalised fractions of the frame (0–1) so zones
17909
+ * survive resolution changes and stream profile switches.
17910
+ *
17911
+ * `kind` discriminates between full polygons (closed regions used
17912
+ * for intrusion / occupancy filters) and tripwires (open 2-point
17913
+ * line segments used for cross events). Onboard / firmware-reported
17914
+ * zones (Reolink, ONVIF) are out of scope for now — see the deferred
17915
+ * task list.
17916
+ */
17917
+ var ZoneKindEnum = _enum(["polygon", "tripwire"]);
17918
+ /** Polygon vertex in fraction-of-frame coordinates (0–1). */
17919
+ var PolygonPointSchema = object({
17920
+ x: number(),
17921
+ y: number()
17922
+ });
17923
+ /** A camera detection zone — pure geometry/identity. */
17924
+ var ZoneSchema = object({
17925
+ id: string(),
17926
+ name: string(),
17927
+ kind: ZoneKindEnum.default("polygon"),
17928
+ /** Polygon vertices, fraction of frame (0–1). */
17929
+ polygon: array(PolygonPointSchema).readonly(),
17930
+ /** Visual color for UI rendering. */
17931
+ color: string().default("#3b82f6")
17963
17932
  });
17964
17933
  /**
17965
- * One media row WITHOUT its bytes.
17934
+ * Zones capability per-camera CRUD over polygon detection zones.
17966
17935
  *
17967
- * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
17968
- * 140 s track), and a client that renders tiles from the media data plane needs
17969
- * to know only WHAT EXISTS the bytes then arrive per tile, lazily, over HTTP
17970
- * with an immutable cache, instead of all at once inside a tRPC response that
17971
- * blocks the whole view.
17936
+ * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
17937
+ * to per-device settings and mirrors into the `zones` device-state
17938
+ * slice on every mutation, so downstream consumers can subscribe via
17939
+ * `dev.state.zones.onChanged`.
17972
17940
  *
17973
- * `sizeBytes` is carried because it is what lets a client decide between the
17974
- * stored blob and a `?variant=thumb` rendering without fetching either.
17941
+ * The cap surface only handles geometry + identity; filtering
17942
+ * behaviour (per-class, include/exclude, threshold) lives in the
17943
+ * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
17944
+ * `capabilities/schemas/zone-rule.js`.
17975
17945
  */
17976
- var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17946
+ var zonesCapability = {
17947
+ name: "zones",
17948
+ scope: "device",
17949
+ mode: "singleton",
17950
+ deviceTypes: [DeviceType.Camera],
17951
+ methods: {
17952
+ listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
17953
+ addZone: method(object({
17954
+ deviceId: number(),
17955
+ zone: ZoneSchema
17956
+ }), _void(), {
17957
+ kind: "mutation",
17958
+ auth: "admin"
17959
+ }),
17960
+ removeZone: method(object({
17961
+ deviceId: number(),
17962
+ zoneId: string()
17963
+ }), _void(), {
17964
+ kind: "mutation",
17965
+ auth: "admin"
17966
+ }),
17967
+ updateZone: method(object({
17968
+ deviceId: number(),
17969
+ zone: ZoneSchema
17970
+ }), _void(), {
17971
+ kind: "mutation",
17972
+ auth: "admin"
17973
+ })
17974
+ },
17975
+ /**
17976
+ * Runtime-state slice — the live zone catalogue mirrored by the
17977
+ * orchestrator on every CRUD mutation. Consumers read via
17978
+ * `device.state.zones.value` / `.watch(...)` without round-tripping
17979
+ * the cap, and the codegen DeviceProxy auto-wires the reactive
17980
+ * handle. Slice shape is `{ zones: Zone[] }` so future extensions
17981
+ * (e.g. zone groupings) can sit alongside the polygon list.
17982
+ */
17983
+ runtimeState: object({ zones: array(ZoneSchema).readonly() }),
17984
+ /**
17985
+ * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
17986
+ *
17987
+ * See `RuntimeStateDurability`. Enforced by
17988
+ * `scripts/check-runtime-state-durability.ts`.
17989
+ */
17990
+ durability: "restored"
17991
+ };
17977
17992
  /**
17978
- * The MACRO tier of an annotation — a CLOSED set.
17993
+ * pipeline-analytics device-scoped wrapper cap. Refines raw
17994
+ * per-frame detections emitted by the pipeline runner into tracked
17995
+ * objects, per-kind event collections (motion / object / audio), and
17996
+ * persisted media. Owns the post-detection domain end-to-end:
17979
17997
  *
17980
- * This is what the exported detector predicts, so a typo here is a new class
17981
- * with one example in it. `label` and `subLabel` are open strings by contrast:
17982
- * the whole point of the page is teaching the model things it does not know
17983
- * yet, and constraining that vocabulary would make it useless.
17998
+ * runner emits PipelineInferenceResult
17999
+ * (event bus)
18000
+ * pipeline-analytics subscriber
18001
+ * SORT tracker + zone engine + state analyzer + event emitter
18002
+ * → three DB collections (one per kind), one FS media tree, one
18003
+ * unified event emitter (FrameTracked + TrackStarted/Ended +
18004
+ * DetectionEvent on bus)
17984
18005
  *
17985
- * A macro class is NEVER a label. The provider refuses a write whose `label` or
17986
- * `subLabel` is one of these values, in any casing, because once `person`
17987
- * exists in both tiers "every person box" stops being answerable without
17988
- * knowing every string anyone ever typed — and the damage is retroactive.
18006
+ * Pure subscriber model. No `processFrame` cap method the runner
18007
+ * already publishes the raw frame on the bus. The cap surface is
18008
+ * only QUERIES + per-device settings, bound on/off via
18009
+ * `device-manager.setWrapperActive`. `defaultActive: true` because
18010
+ * every camera with a detection pipeline wants its raw detections
18011
+ * refined; operators opt out per-device via BindingsTab when needed.
18012
+ *
18013
+ * Replaces the legacy `analysis-pipeline`, `analysis-data-persistence`
18014
+ * (per-device surface) and `track-trail` caps — see P11 cleanup.
17989
18015
  */
17990
- var RetrainMacroClassSchema = _enum([
18016
+ var TrackStateSchema = _enum([
18017
+ "new",
18018
+ "entered",
18019
+ "left",
18020
+ "moving",
18021
+ "idle"
18022
+ ]);
18023
+ var EventKindSchema = _enum([
18024
+ "motion",
18025
+ "object",
18026
+ "audio"
18027
+ ]);
18028
+ /**
18029
+ * Spatial filter for `listTracks` — the rect + polygon variants of the shared
18030
+ * MaskShape vocabulary (see `mask-shape.ts`). Coordinates are NORMALIZED 0..1
18031
+ * of the camera frame (top-left origin), matching the drawing-plane editor.
18032
+ */
18033
+ var TrackZoneFilterSchema = discriminatedUnion("kind", [MaskRectShapeSchema, MaskPolygonShapeSchema]);
18034
+ /** Closed icon vocabulary so clients render a known glyph per kind. */
18035
+ var EventKindIconSchema = _enum([
18036
+ "motion",
18037
+ "audio",
17991
18038
  "person",
17992
18039
  "vehicle",
17993
18040
  "animal",
18041
+ "door",
18042
+ "pir",
18043
+ "smoke",
18044
+ "water",
18045
+ "button",
17994
18046
  "package",
17995
- "face",
17996
- "plate"
18047
+ "generic"
17997
18048
  ]);
17998
- /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
17999
- var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18000
- /** Did a human draw this box, or did the assist propose it? */
18001
- var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18002
- /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18003
- var RetrainBboxSchema = object({
18004
- x: number(),
18005
- y: number(),
18006
- w: number(),
18007
- h: number()
18008
- });
18009
- /**
18010
- * One annotated subject.
18011
- *
18012
- * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18013
- * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18014
- * derived from it at export and never stored storing them is how one feature
18015
- * space ends up holding two crops of the same subject (D52).
18016
- */
18017
- var RetrainAnnotationSchema = object({
18018
- id: string(),
18019
- trackId: string(),
18020
- deviceId: number(),
18021
- /** The COPY in retrain storage — never the source track's media key. */
18022
- mediaKey: string(),
18023
- bbox: RetrainBboxSchema,
18024
- macroClass: RetrainMacroClassSchema,
18025
- label: string().optional(),
18026
- subLabel: string().optional(),
18027
- kind: RetrainAnnotationKindSchema,
18028
- source: RetrainAnnotationSourceSchema,
18029
- /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18030
- assistModelId: string().optional(),
18031
- assistScore: number().optional(),
18032
- exportedInBatch: string().optional(),
18033
- createdAt: number()
18034
- });
18035
- /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18036
- var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18037
- id: true,
18038
- trackId: true,
18039
- deviceId: true,
18040
- mediaKey: true,
18041
- createdAt: true,
18042
- exportedInBatch: true
18049
+ var EventKindCategorySchema = _enum([
18050
+ "motion",
18051
+ "audio",
18052
+ "detection",
18053
+ "sensor",
18054
+ "control",
18055
+ "custom",
18056
+ "package"
18057
+ ]);
18058
+ /** Taxonomy level — macro (timeline lane) vs sub (events-page leaf). */
18059
+ var EventKindLevelSchema = _enum(["macro", "sub"]);
18060
+ var EventKindDescriptorSchema = object({
18061
+ /** Stable kind id (e.g. 'motion', 'vehicle', 'car', 'lock'). */
18062
+ kind: string(),
18063
+ /** i18n key resolved on the UI side; `label` is the English fallback. */
18064
+ labelKey: string(),
18065
+ /** English fallback label (kept for clients that don't translate). */
18066
+ label: string(),
18067
+ /** Hex color for timeline/legend rendering. */
18068
+ color: string(),
18069
+ /** Dictionary id → lucide component on the UI side. */
18070
+ iconId: string(),
18071
+ /** Legacy closed-vocab glyph — fallback for `iconId`. */
18072
+ icon: EventKindIconSchema,
18073
+ category: EventKindCategorySchema,
18074
+ /** Macro parent for this kind ('car' → 'vehicle'); null for a macro. */
18075
+ parentKind: string().nullable(),
18076
+ /** Derived from `parentKind`, explicit for the client tree. */
18077
+ level: EventKindLevelSchema,
18078
+ /** Which cap + device contributes this kind. For built-ins the camera
18079
+ * itself; for sensor kinds the LINKED source device. */
18080
+ source: object({
18081
+ capName: string(),
18082
+ deviceId: number()
18083
+ })
18043
18084
  });
18044
- /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18045
- var RetrainTrackSchema = object({
18046
- trackId: string(),
18085
+ /** One camera's event vocabulary, as returned by `listEventKindsBatch`. */
18086
+ var EventKindsForDeviceSchema = object({
18047
18087
  deviceId: number(),
18048
- className: string(),
18049
- label: string().optional(),
18050
- firstSeen: number(),
18051
- lastSeen: number(),
18052
- /** How many frames the dataset already holds from this track. */
18053
- frameCount: number().int(),
18054
- /** How many subjects have been annotated on those frames. `0` with
18055
- * `frameCount: 0` is exactly "staging, still to work". */
18056
- annotationCount: number().int()
18057
- });
18058
- /** A frame the picker may offer — an index row, no blob was read to produce it. */
18059
- var RetrainFrameCandidateSchema = object({
18060
- mediaKey: string(),
18061
- kind: MediaFileKindEnum,
18062
- timestamp: number(),
18063
- sizeBytes: number().int(),
18064
- /** A copy of this original already exists — selecting it is free and cannot
18065
- * fail, whatever became of the original. */
18066
- copied: boolean()
18088
+ kinds: array(EventKindDescriptorSchema).readonly()
18067
18089
  });
18068
- /** A frame the dataset OWNS: bytes copied at selection time. */
18069
- var RetrainFrameSchema = object({
18070
- frameId: string(),
18090
+ var SensorEventSchema = object({
18091
+ id: string(),
18092
+ /** The CAMERA the event is attributed to (a sensor linked to N cameras
18093
+ * yields N rows, one per camera). */
18071
18094
  deviceId: number(),
18072
- trackId: string(),
18073
- /** Provenance only. It may already point at nothing — that is expected. */
18074
- sourceMediaKey: string(),
18075
- sourceKind: MediaFileKindEnum,
18076
- sizeBytes: number().int(),
18077
- width: number().int(),
18078
- height: number().int(),
18079
- copiedAt: number()
18095
+ /** The linked sensor device whose state changed. */
18096
+ sourceDeviceId: number(),
18097
+ /** Event kind id — matches an `EventKindDescriptor.kind`. */
18098
+ kind: string(),
18099
+ /** Snapshot of the sensor cap's runtime-state slice at the change. */
18100
+ value: record(string(), unknown()).nullable(),
18101
+ timestamp: number()
18080
18102
  });
18081
- /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18082
- var RetrainCopyRefusalSchema = _enum([
18083
- "source-missing",
18084
- "unreadable-image",
18085
- "write-failed"
18086
- ]);
18087
- var RetrainFrameSelectionSchema = object({
18088
- copied: array(RetrainFrameSchema).readonly(),
18089
- refused: array(object({
18090
- sourceMediaKey: string(),
18091
- reason: RetrainCopyRefusalSchema
18092
- })).readonly()
18103
+ var TrackPositionSchema = object({
18104
+ x: number(),
18105
+ y: number(),
18106
+ timestamp: number(),
18107
+ bbox: BoundingBoxSchema
18093
18108
  });
18094
- var RetrainFrameListSchema = object({
18095
- candidates: array(RetrainFrameCandidateSchema).readonly(),
18096
- copies: array(RetrainFrameSchema).readonly(),
18097
- /** What the page pre-selects the native key frame when one survives. */
18098
- autoPickMediaKey: string().optional()
18109
+ var TrackSnapshotSchema = object({
18110
+ timestamp: number(),
18111
+ position: TrackPositionSchema,
18112
+ /** MediaStore key; resolve via `getTrackMedia({ trackId })`. */
18113
+ mediaKey: string()
18099
18114
  });
18100
- /** What the operator asked the assist to look for. */
18101
- var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18102
- kind: literal("package"),
18103
- zone: RetrainBboxSchema.optional()
18104
- }), object({
18105
- kind: literal("objects"),
18106
- modelId: string(),
18107
- minScore: number().optional()
18108
- })]);
18109
18115
  /**
18110
- * The assist's answer a discriminated union, because "the model saw nothing"
18111
- * and "this node cannot run that model" lead to different next moves and a
18112
- * nullable result cannot tell them apart.
18116
+ * Normalized 0..1 trajectory envelope (min/max over every position bbox,
18117
+ * divided by the track's detection-frame dims), computed at persist time.
18118
+ * Absent when the frame dims were unknown when the track was persisted
18119
+ * (legacy rows / dims-less sources) and on active (in-RAM) tracks.
18113
18120
  */
18114
- var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18115
- kind: literal("proposed"),
18116
- modelId: string(),
18117
- stepId: string(),
18118
- minScore: number(),
18119
- /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18120
- proposals: array(RetrainAnnotationDraftSchema).readonly(),
18121
- /** Returned by the runner but removed by the threshold. */
18122
- belowThreshold: number().int()
18123
- }), object({
18124
- kind: literal("refused"),
18125
- /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18126
- reason: string(),
18127
- detail: string().optional()
18128
- })]);
18129
- /** The outcome of a lifecycle move owned by the retrain page. */
18130
- var RetrainTransitionResultSchema = object({
18131
- trackId: string(),
18132
- /** Where the track ended up, whatever happened. */
18133
- retrainStatus: RetrainStatusSchema,
18134
- /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18135
- changed: boolean(),
18136
- reason: _enum([
18137
- "unknown-track",
18138
- "no-frames-copied",
18139
- "not-staging",
18140
- "not-trained",
18141
- "unchanged"
18142
- ]).optional()
18143
- });
18144
- var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18145
- var MAX_EVENT_QUERY_LIMIT = 5e3;
18146
- var DeviceEventQueryInput = object({
18147
- deviceId: number(),
18148
- since: number().optional(),
18149
- until: number().optional(),
18150
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18151
- /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18152
- * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18153
- * exact behaviour. Callers may omit this field — the store defaults to
18154
- * `full` when not provided. */
18155
- projection: _enum(["full", "slim"]).optional()
18156
- });
18157
- var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18158
- var RecentTracksQueryInput = object({
18159
- /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18160
- deviceIds: array(number()),
18161
- /** Window lower bound on `lastSeen` (inclusive). */
18162
- since: number().optional(),
18163
- /** Window upper bound on `lastSeen` (inclusive). */
18164
- until: number().optional(),
18165
- /** Page size. Default 200, max 1000. */
18166
- limit: number().int().min(1).max(1e3).default(200),
18167
- /** Opaque continuation cursor from a previous page's `nextCursor`.
18168
- * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18169
- cursor: string().optional(),
18170
- /** See {@link TrackProjectionSchema}. Default `full`. */
18171
- projection: TrackProjectionSchema.optional(),
18172
- /** Include stationary-promoted rows (parked objects). Default false: the
18173
- * feed lists passages; parking records live on the stationary registry. */
18174
- includeStationary: boolean().optional()
18175
- });
18176
- var RecentTracksPageSchema = object({
18177
- /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18178
- tracks: array(TrackSchema).readonly(),
18179
- /** Cursor for the next page, or null when this page is the last. */
18180
- nextCursor: string().nullable()
18181
- });
18182
- var LIST_GROUPS_DEFAULT_LIMIT = 40;
18183
- var LIST_GROUPS_MAX_LIMIT = 100;
18184
- var AnalyticsGroupRecordSchema = object({
18185
- id: string(),
18186
- deviceId: number().int(),
18187
- openedAt: number().int(),
18188
- closedAt: number().int(),
18189
- timestamp: number().int(),
18190
- memberCount: number().int(),
18191
- memberTrackIds: array(string()).readonly(),
18192
- className: string(),
18193
- classes: array(string()).readonly(),
18194
- /** Relative event-media path, or null when the group has no picture yet. */
18195
- mediaUrl: string().nullable(),
18196
- singleton: boolean()
18121
+ var TrackEnvelopeSchema = object({
18122
+ minX: number(),
18123
+ minY: number(),
18124
+ maxX: number(),
18125
+ maxY: number()
18197
18126
  });
18198
- var AnalyticsGroupMemberSchema = object({
18199
- trackId: string(),
18200
- deviceId: number().int(),
18201
- className: string(),
18202
- firstSeen: number().int(),
18203
- lastSeen: number().int(),
18204
- mediaUrl: string().nullable()
18205
- });
18206
- var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18207
- var ListGroupsQueryInput = object({
18208
- /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18209
- deviceIds: array(number()),
18210
- /** Window lower bound on `closedAt` (inclusive). */
18211
- since: number().optional(),
18212
- /** Window upper bound on `openedAt` (inclusive). */
18213
- until: number().optional(),
18214
- limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18215
- /** Opaque continuation cursor from a previous page's `nextCursor`. */
18216
- cursor: string().optional()
18217
- });
18218
- var ListGroupsPageSchema = object({
18219
- groups: array(AnalyticsGroupRecordSchema).readonly(),
18220
- nextCursor: string().nullable()
18221
- });
18222
- var KeyEventQueryInput = object({
18223
- deviceId: number(),
18224
- /** Window lower bound (track firstSeen ≥ since). */
18225
- since: number(),
18226
- /** Window upper bound (track firstSeen ≤ until). */
18227
- until: number(),
18228
- limit: number().int().min(1).max(200).default(50),
18229
- /** Drop tracks scoring below this importance. */
18230
- minImportance: number().min(0).max(1).optional(),
18231
- /** Restrict to a single class (e.g. 'person'). */
18232
- classFilter: string().optional()
18233
- });
18234
- var KeyEventSchema = object({
18235
- /** The representative event id (the track's best ObjectEvent, else its trackId). */
18236
- id: string(),
18237
- trackId: string(),
18238
- /** Track start time (firstSeen). */
18239
- timestamp: number(),
18240
- className: string(),
18241
- ...TieredLabelFields,
18242
- importance: number(),
18243
- /** Highest-confidence ObjectEvent id for the track (empty when none). */
18244
- bestEventId: string(),
18245
- /** Track lifetime in ms (lastSeen - firstSeen). */
18246
- windowMs: number().optional(),
18247
- ...TrackFlagFields,
18248
- ...TrackRetrainFields
18249
- });
18250
- object({
18251
- trackId: string(),
18252
- className: string(),
18253
- confidence: number(),
18254
- bbox: BoundingBoxSchema,
18255
- zones: array(string()).readonly(),
18256
- state: TrackStateSchema
18257
- });
18258
- var OverlayDetectionSchema = looseObject({
18259
- id: string(),
18260
- kind: _enum(["first-level", "detail"]),
18261
- macroClass: string(),
18262
- score: number(),
18263
- bbox: object({
18264
- x: number(),
18265
- y: number(),
18266
- width: number(),
18267
- height: number()
18268
- }),
18269
- labels: array(looseObject({
18270
- label: string(),
18271
- score: number()
18272
- })).readonly(),
18273
- parentId: string().optional()
18274
- });
18275
- var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18276
- var SearchObjectEventsInput = object({
18277
- text: string(),
18278
- deviceId: number().optional(),
18279
- since: number().optional(),
18280
- until: number().optional(),
18281
- classFilter: string().optional(),
18282
- limit: number().default(50),
18283
- minScore: number().min(0).max(1).default(.2)
18284
- });
18285
- var TrackCascadeCountsSchema = object({
18286
- /** Persisted track roots deleted (authoritative). */
18287
- tracks: number().int(),
18288
- /** Object events removed with their tracks (best-effort; see note above). */
18289
- events: number().int(),
18290
- /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18291
- media: number().int(),
18292
- /** Unassigned (non-enrolled) face reads removed (best-effort). */
18293
- faces: number().int(),
18294
- /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18295
- plates: number().int(),
18296
- /** Per-track CLIP search vectors removed (best-effort). */
18297
- embeddings: number().int(),
18298
- /** Group membership + group rows removed with their last member (best-effort). */
18299
- groups: number().int()
18300
- });
18301
- /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18302
- var DiskReconcileCountsSchema = object({
18303
- mediaDropped: number().int(),
18304
- tracks: number().int(),
18305
- events: number().int()
18306
- });
18307
- /** Event-store footprint for one camera. */
18308
- var EventStoreDeviceFootprintSchema = object({
18309
- deviceId: number(),
18310
- /** Persisted event rows (motion + object + audio) for the camera. */
18311
- rows: number().int(),
18312
- /** Event-owned media bytes on disk for the camera. */
18313
- bytes: number().int()
18314
- });
18315
- /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18316
- var EventStoreFootprintSchema = object({
18317
- totalRows: number().int(),
18318
- totalBytes: number().int(),
18319
- devices: array(EventStoreDeviceFootprintSchema).readonly()
18320
- });
18321
- /** Per-kind counts returned by the event-prune / device-delete mutations. */
18322
- var EventPruneCountsSchema = object({
18323
- motion: number().int(),
18324
- object: number().int(),
18325
- audio: number().int()
18127
+ /**
18128
+ * Row projection for track list queries. `full` (default) returns the
18129
+ * complete Track including the frame-rate `positions[]` history and the
18130
+ * `snapshots[]` references — megabytes across a page of tracks. `slim`
18131
+ * keeps every scalar the list surfaces actually render (ids, class(es),
18132
+ * label / audioLabels / importance enrichment, firstSeen/lastSeen, state,
18133
+ * zonesVisited, bestEventId, envelope, hasFace, hasEmbeddedFace, hasRider) and returns `positions` /
18134
+ * `snapshots` as EMPTY arrays — detail views re-fetch the full row via
18135
+ * `getTrack`. Mirrors the event-store `projection` convention
18136
+ * (`getObjectEvents` et al.).
18137
+ */
18138
+ var TrackProjectionSchema = _enum(["full", "slim"]);
18139
+ /**
18140
+ * One audio-classification label heard on the track's camera while the
18141
+ * track was alive, aggregated per label. An "episode" is one persisted
18142
+ * audio event (the confident-classification path: score ≥ the device's
18143
+ * `classificationMinScore`, class-change-or-heartbeat coalesced) — NOT
18144
+ * one 32 ms inference chunk, so counts stay human-scaled.
18145
+ */
18146
+ var TrackAudioLabelSchema = object({
18147
+ label: string(),
18148
+ /** Highest classification score observed across the label's episodes. */
18149
+ peakScore: number(),
18150
+ /** Number of coalesced audio-event episodes carrying this label. */
18151
+ count: number(),
18152
+ firstAt: number(),
18153
+ lastAt: number()
18326
18154
  });
18327
18155
  /**
18328
- * Re-embed stored tracks from their key frames.
18156
+ * How a track was produced. `pipeline` (default / absent) = the spatial
18157
+ * detection+tracking pipeline. Every OTHER value is a SYNTHETIC projection —
18158
+ * no positions, a single snapshot, and no bbox trajectory at all:
18329
18159
  *
18330
- * The reason this is an operator-callable method and not a migration script:
18331
- * every knob that decides what a vector MEANS encoder model, crop margin,
18332
- * squaring is only changeable if the existing vectors can be regenerated.
18333
- * Mixing feature spaces in one index makes cosine scores incomparable, and the
18334
- * symptom is a quality regression with no visible cause.
18160
+ * - `sensor` a linked sensor/control device state change.
18161
+ * - `audio` an audio event on the camera itself that was anomalous for
18162
+ * THAT camera, loud, and heard while nothing visual was happening (D62).
18163
+ *
18164
+ * The spatial subsystems (tracker association, occupancy count, re-id /
18165
+ * embedding, resurrection) MUST skip every synthetic source. Test for that
18166
+ * with `isSpatialTrack`, which allow-lists `pipeline` — a `!== 'sensor'`
18167
+ * check silently readmits every source added after it was written.
18335
18168
  */
18336
- var RebuildObjectEmbeddingsInput = object({
18337
- /** Restrict to one camera. Omit for the whole fleet. */
18338
- deviceId: number().optional(),
18339
- since: number().optional(),
18340
- until: number().optional(),
18341
- /** Stop after this many tracks; the result reports whether more remain. */
18342
- maxTracks: number().int().positive().optional(),
18343
- /**
18344
- * Run every embedding on THIS node instead of round-robining the fleet.
18345
- *
18346
- * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
18347
- * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
18348
- * calling it that would pin the rebuild REQUEST itself to that node — the
18349
- * rebuild orchestration lives on the hub, and only the per-track step runs
18350
- * remotely. This field is data; the per-track pin is applied inside.
18351
- *
18352
- * Absent ⇒ round-robin over every online node whose runner can serve the
18353
- * pinned model.
18354
- */
18355
- executeOnNodeId: string().optional(),
18356
- /**
18357
- * Milliseconds to wait between tracks; omit for the built-in default, `0` to
18358
- * run flat out.
18359
- *
18360
- * A rebuild is bulk maintenance on hub-main's single thread. Measured
18361
- * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
18362
- * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
18363
- * force is logged at start and finish so a deliberately slow pass reads
18364
- * differently from a stalled one.
18365
- */
18366
- pacingMs: number().int().nonnegative().optional()
18367
- });
18169
+ var TrackSourceSchema = _enum([
18170
+ "pipeline",
18171
+ "sensor",
18172
+ "audio"
18173
+ ]);
18368
18174
  /**
18369
- * Result of emptying the CLIP index.
18175
+ * Where a track sits in the RETRAIN lifecycle (D81).
18370
18176
  *
18371
- * The clean slate before a policy change: a new crop margin or encoder model
18372
- * leaves two feature spaces in one index whose cosine scores are not
18373
- * comparable, so wiping and rebuilding is the only way to be sure every vector
18374
- * means the same thing.
18177
+ * - `none` never marked, or un-marked. Evictable.
18178
+ * - `staging` the operator wants this track as training material and has not
18179
+ * finished with it. **This is the only state retention holds**: the track and
18180
+ * everything it owns (object events, crops, keyframes, CLIP vector) survive
18181
+ * the device's age window.
18182
+ * - `trained` — the retrain page has taken what it needed. The frames it chose
18183
+ * were COPIED into the retrain dataset at selection time, so the dataset no
18184
+ * longer depends on the track's media and the track becomes EVICTABLE again.
18185
+ * Terminal for the plain `markForTrain` toggle: returning it to `staging` is
18186
+ * a deliberate action of the retrain page, not a side effect of a checkbox.
18187
+ *
18188
+ * There is no `null`. The state is stored `TEXT NOT NULL DEFAULT 'none'` because
18189
+ * the store's filter language has only positive equality and `whereIn` — no
18190
+ * negation, no IS NULL — so a NULL would be unselectable by ANY predicate and
18191
+ * would make the entire pre-column history immortal in one deploy.
18375
18192
  */
18376
- var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
18193
+ var RetrainStatusSchema = _enum([
18194
+ "none",
18195
+ "staging",
18196
+ "trained"
18197
+ ]);
18377
18198
  /**
18378
- * Acknowledgement that a rebuild STARTED.
18199
+ * Per-track OPERATOR flags set by hand from the admin UI or the viewer, never
18200
+ * by the pipeline. Spread into `TrackSchema` and `KeyEventSchema` from one place
18201
+ * so the two surfaces cannot drift.
18379
18202
  *
18380
- * The pass costs ~1s per track 45 minutes for a 2,600-track fleet so it
18381
- * runs detached and this returns immediately. Waiting for it made the client
18382
- * time out while the work carried on server-side, which is the worst of both:
18383
- * no result and no way to know it was still going. Poll
18384
- * `getObjectEmbeddingRebuildStatus` for progress.
18203
+ * **Absent false.** A track that has never been touched omits the field; an
18204
+ * explicitly un-flagged track carries `false`. Legacy rows written before the
18205
+ * columns existed read as absent, and a consumer that needs a boolean should say
18206
+ * `flag === true`, not `flag !== false`.
18207
+ *
18208
+ * `markForTrain` is the WIRE FACE of {@link RetrainStatusSchema}, not a column:
18209
+ * it is exactly `retrainStatus === 'staging'`, in both directions. Writing
18210
+ * `true` moves `none → staging`, writing `false` moves `staging → none`, and a
18211
+ * `trained` track reports `false` while refusing both writes. The boolean is
18212
+ * kept because three surfaces drive a toggle off it; anything that needs to tell
18213
+ * "never marked" from "already trained" must read `retrainStatus`.
18214
+ *
18215
+ * `debug` does NOT pin; it is attention, not durability.
18216
+ *
18217
+ * `favourited` IS a BOOLEAN pin (durability bit), not a retrain lifecycle.
18218
+ * A favourited track is skipped by retention the same way `staging` is, but
18219
+ * it does not enter `none|staging|trained` and has no staging budget.
18385
18220
  */
18386
- var RebuildObjectEmbeddingsResultSchema = object({
18387
- started: boolean(),
18388
- /** True when a pass was already running; the new request is ignored. */
18389
- alreadyRunning: boolean()
18390
- });
18391
- var RebuildStatusSchema = object({
18392
- running: boolean(),
18393
- scanned: number(),
18394
- rebuilt: number(),
18395
- /** Tracks whose key frame is gone — nothing to re-embed from. */
18396
- missingKeyFrame: number(),
18397
- /** Tracks with no usable detection box. */
18398
- missingBbox: number(),
18399
- /**
18400
- * Tracks an executing node REFUSED rather than broke on an unreadable key
18401
- * frame, a step that threw. Separate from `failed` because the remedy is
18402
- * different, and because a whole camera silently contributing zero vectors
18403
- * is the shape of failure a rebuild must never hide.
18404
- */
18405
- notRunnable: number(),
18406
- /**
18407
- * The pass stopped because NO node could serve the pinned model.
18408
- *
18409
- * Distinct from `notRunnable` on purpose: that one says "this track was
18410
- * refused", this one says "the cluster cannot do this work at all" — every
18411
- * candidate node either lacks the `clip-embedding` step, lacks a build of the
18412
- * pinned model for its engine format, or dropped out. The remedy is a model /
18413
- * engine change, not a per-camera one. Non-zero here always comes with
18414
- * `complete: false`.
18415
- */
18416
- noCapableNode: number(),
18417
- failed: number(),
18418
- /** Set once a pass ends: true only when EVERYTHING was covered. */
18419
- complete: boolean().nullable(),
18420
- startedAtMs: number().nullable(),
18421
- finishedAtMs: number().nullable(),
18422
- /** Present when the pass ended by throwing. */
18423
- error: string().nullable()
18221
+ var TrackFlagFields = {
18222
+ /** Operator marked this track as training material — i.e. `retrainStatus` is
18223
+ * `'staging'`. */
18224
+ markForTrain: boolean().optional(),
18225
+ /** Operator marked this track for diagnostic attention. */
18226
+ debug: boolean().optional(),
18227
+ /** Operator favourited this track. Pins it against pruning. */
18228
+ favourited: boolean().optional()
18229
+ };
18230
+ /**
18231
+ * The lifecycle field itself, on the READ surfaces only (`Track`, `KeyEvent`).
18232
+ * Deliberately NOT part of {@link TrackFlagFields}: that group also builds the
18233
+ * write patch, and the status is not something the toggle sets — it is what the
18234
+ * toggle's boolean is derived from. Absent on an in-RAM track never touched;
18235
+ * always present on a persisted row (the column default materialises `'none'`).
18236
+ */
18237
+ var TrackRetrainFields = { retrainStatus: RetrainStatusSchema.optional() };
18238
+ /**
18239
+ * The write half: a PARTIAL patch. An omitted key is left untouched, so setting
18240
+ * one flag can never clear the other — the toggles are independent and are
18241
+ * driven from three surfaces that do not know about each other.
18242
+ */
18243
+ var TrackFlagsPatchSchema = object(TrackFlagFields);
18244
+ /**
18245
+ * The resolved flag state after a write. Both fields are REQUIRED here (absent
18246
+ * collapses to `false`) so a caller can drive a toggle's checked state off the
18247
+ * mutation result without a re-fetch.
18248
+ */
18249
+ var TrackFlagsSchema = object({
18250
+ trackId: string(),
18251
+ markForTrain: boolean(),
18252
+ debug: boolean(),
18253
+ favourited: boolean(),
18254
+ /** The lifecycle state the boolean was derived from. Required here (unlike on
18255
+ * a track row) because this shape is only ever produced by the write body,
18256
+ * which always knows it — and a surface that has just written needs to render
18257
+ * `trained` without a re-fetch. */
18258
+ retrainStatus: RetrainStatusSchema
18424
18259
  });
18425
- DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
18426
- deviceId: number(),
18427
- trackId: string()
18428
- }), TrackSchema.nullable()), method(object({
18429
- deviceId: number(),
18430
- since: number().optional(),
18431
- until: number().optional(),
18432
- limit: number().optional(),
18433
- /** Spatial filter only tracks whose trajectory intersects the zone
18434
- * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
18435
- * envelope columns, then precisely tested per position. Tracks with
18436
- * an unknown envelope (no frame dims at persist time) always match. */
18437
- zone: TrackZoneFilterSchema.optional(),
18438
- /** See {@link TrackProjectionSchema}. Default `full` (backward
18439
- * compatible — omitting the field keeps today's exact behaviour). */
18440
- projection: TrackProjectionSchema.optional(),
18441
- /** Include stationary-promoted rows (parked objects handed to the
18442
- * stationary registry). Default false: the timeline lists passages,
18443
- * not parking records (operator decision, 2026-08-15). */
18444
- includeStationary: boolean().optional()
18445
- }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
18446
- deviceId: number(),
18447
- groupId: string().min(1)
18448
- }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
18449
- kind: "mutation",
18450
- auth: "admin"
18451
- }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
18452
- deviceId: number(),
18453
- since: number().optional(),
18454
- until: number().optional(),
18455
- kinds: array(string()).optional(),
18456
- limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
18457
- }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
18458
- deviceId: number(),
18459
- since: number(),
18460
- until: number(),
18461
- bucketMs: number().int().positive()
18462
- }), array(object({
18463
- bucketStart: number(),
18464
- motion: number().int(),
18465
- object: number().int(),
18466
- audio: number().int()
18467
- })).readonly()), method(object({
18468
- deviceId: number(),
18469
- cutoffMs: number()
18470
- }), object({
18471
- motion: number().int(),
18472
- object: number().int(),
18473
- audio: number().int()
18474
- }), {
18475
- kind: "mutation",
18476
- auth: "admin"
18477
- }), method(object({
18478
- deviceId: number(),
18479
- cutoffMs: number()
18480
- }), TrackCascadeCountsSchema, {
18481
- kind: "mutation",
18482
- auth: "admin"
18483
- }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
18484
- kind: "mutation",
18485
- auth: "admin"
18486
- }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
18487
- kind: "mutation",
18488
- auth: "admin"
18489
- }), method(object({
18490
- deviceId: number(),
18491
- trackIds: array(string()).min(1)
18492
- }), object({
18493
- deleted: number().int(),
18494
- failed: array(string()).readonly()
18495
- }), {
18496
- kind: "mutation",
18497
- auth: "admin"
18498
- }), method(object({
18499
- /** Log/audit scope only — the trackId is globally unique on its own. */
18260
+ union([literal(1), literal(2)]);
18261
+ /**
18262
+ * WHO decided a label, and when. Carried per tier so a value can be traced to
18263
+ * the step and model that produced it — which is what makes the write rule
18264
+ * arguable after the fact ("why is 592's label `dog` and not `Canis lupus`?")
18265
+ * and what lets a migrated, UNATTRIBUTED value be told apart from a real one.
18266
+ *
18267
+ * `stepId` is the pipeline step id (`animal-classifier`, `bird-classifier`,
18268
+ * `plate-ocr`, `face-embedding`, `object-detection`), or the sentinel
18269
+ * `migration:4g` for a value the 4g migration moved from the single-slot era —
18270
+ * that value has no provenance, and the write rule lets ANY properly-attributed
18271
+ * write of the same tier replace it regardless of score.
18272
+ */
18273
+ var LabelAttributionSchema = object({
18274
+ stepId: string(),
18275
+ modelId: string().optional(),
18276
+ decidedAt: number(),
18277
+ /**
18278
+ * The GALLERY id behind a recognised tier-2 label — a face-gallery
18279
+ * `Identity.id` or a plate-gallery `Vehicle.id` (both `randomUUID`).
18280
+ *
18281
+ * The text alone is a DISPLAY NAME, and a display name is renameable: a
18282
+ * notification rule authored on "Gianluca" stopped matching the moment the
18283
+ * operator fixed the spelling in the gallery, and nothing said so. The id is
18284
+ * the thing that does not move, so it is what a rule matches on
18285
+ * (`NcConditions.identities`) and the text is what a human is shown.
18286
+ *
18287
+ * Absent when the label names no gallery row — a plate the OCR read but no
18288
+ * vehicle claims, a sub-class, a species, any tier-1 value.
18289
+ */
18290
+ identityId: string().optional()
18291
+ });
18292
+ /**
18293
+ * The TIERED label model (roadmap 4g), spread into `TrackSchema` and
18294
+ * `ObjectEventSchema` from ONE place so the two surfaces cannot drift — a
18295
+ * track and its events always answer the same question the same way.
18296
+ *
18297
+ * Two scalar columns, not an array: every consumer wants "the coarse one" or
18298
+ * "the fine one", and an array made both a scan. `label` is tier 1, `subLabel`
18299
+ * is tier 2, and each carries its own score + attribution.
18300
+ *
18301
+ * **Reading it.** What a human should be shown is `subLabel ?? label` — the
18302
+ * finest thing known. Before 4g the single `label` column held the finest
18303
+ * value, so a consumer that has not been updated reads the tier-1 slot and
18304
+ * shows nothing on a species-only row; that is why the migration puts every
18305
+ * pre-4g value in tier 2 (it cannot regress a display that reads the fallback)
18306
+ * and why the read surfaces were changed in the same train.
18307
+ *
18308
+ * **Writing it.** The slots are independent, which is the whole point: a
18309
+ * tier-1 write (`bird`) can never overwrite a tier-2 value (`Turdus
18310
+ * migratorius`), so fineness cannot regress by construction. Within a tier the
18311
+ * higher score wins. One rule, one implementation — see
18312
+ * `pipeline/label-tier.ts` in addon-post-analysis.
18313
+ */
18314
+ var TieredLabelFields = {
18315
+ /** Tier 1 — the sub-class. See {@link LabelTierSchema}. */
18316
+ label: string().optional(),
18317
+ /** Confidence of the tier-1 value, as reported by the deciding step. */
18318
+ labelScore: number().optional(),
18319
+ /** Provenance of the tier-1 value. See {@link LabelAttributionSchema}. */
18320
+ labelMeta: LabelAttributionSchema.optional(),
18321
+ /** Tier 2 the instance. See {@link LabelTierSchema}. */
18322
+ subLabel: string().optional(),
18323
+ /** Confidence of the tier-2 value, as reported by the deciding step. */
18324
+ subLabelScore: number().optional(),
18325
+ /** Provenance of the tier-2 value. See {@link LabelAttributionSchema}. */
18326
+ subLabelMeta: LabelAttributionSchema.optional()
18327
+ };
18328
+ /** Per-camera slice of a training-export estimate. */
18329
+ var TrainingExportDeviceTotalsSchema = object({
18500
18330
  deviceId: number(),
18331
+ tracks: number().int(),
18332
+ files: number().int(),
18333
+ bytes: number().int()
18334
+ });
18335
+ /**
18336
+ * What a training export WOULD contain. Computed from media index rows only —
18337
+ * no blob is read to produce this.
18338
+ */
18339
+ var TrainingExportSummarySchema = object({
18340
+ generatedAt: number(),
18341
+ trackCount: number().int(),
18342
+ fileCount: number().int(),
18343
+ byteCount: number().int(),
18344
+ /** More marked tracks exist than a single pass carries. */
18345
+ truncated: boolean(),
18346
+ devices: array(TrainingExportDeviceTotalsSchema).readonly()
18347
+ });
18348
+ var TrackSchema = object({
18501
18349
  trackId: string(),
18502
- flags: TrackFlagsPatchSchema
18503
- }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
18504
- kind: "query",
18505
- auth: "admin"
18506
- }), method(object({
18507
- olderThanMs: number(),
18508
- reason: OpsLogReasonSchema.optional()
18509
- }), EventPruneCountsSchema, {
18510
- kind: "mutation",
18511
- auth: "admin"
18512
- }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
18513
- kind: "mutation",
18514
- auth: "admin"
18515
- }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
18516
- kind: "mutation",
18517
- auth: "admin"
18518
- }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
18519
- kind: "mutation",
18520
- auth: "admin"
18521
- }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
18522
- kind: "mutation",
18523
- auth: "admin"
18524
- }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
18525
- kind: "mutation",
18526
- auth: "admin"
18527
- }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18528
- kind: "mutation",
18529
- auth: "admin"
18530
- }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18531
- kind: "mutation",
18532
- auth: "admin"
18533
- }), method(object({}), array(RelocateJobSchema).readonly(), {
18534
- kind: "query",
18535
- auth: "admin"
18536
- }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18537
- kind: "mutation",
18538
- auth: "admin"
18539
- }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
18540
- kind: "query",
18541
- auth: "admin"
18542
- }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
18543
- kind: "query",
18544
- auth: "admin"
18545
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18546
- kind: "query",
18547
- auth: "admin"
18548
- }), method(object({
18549
- /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
18550
- * `deviceId`, deliberately: `deviceId` would make this device-bound and
18551
- * route it at one camera's owner, and "every camera" would stop being
18552
- * expressible at all. */
18553
- deviceIds: array(number()).optional(),
18554
- limit: number().int().min(1).max(500).optional()
18555
- }), array(RetrainTrackSchema).readonly(), {
18556
- kind: "query",
18557
- auth: "admin"
18558
- }), method(object({ trackId: string() }), RetrainFrameListSchema, {
18559
- kind: "query",
18560
- auth: "admin"
18561
- }), method(object({
18562
18350
  deviceId: number(),
18563
- trackId: string(),
18564
- mediaKeys: array(string()).min(1)
18565
- }), RetrainFrameSelectionSchema, {
18566
- kind: "mutation",
18567
- auth: "admin"
18568
- }), method(object({
18351
+ className: string(),
18352
+ ...TieredLabelFields,
18353
+ producingDeviceName: string().optional(),
18354
+ /** Track provenance. Absent ⇒ `pipeline` (legacy rows). */
18355
+ source: TrackSourceSchema.optional(),
18356
+ firstSeen: number(),
18357
+ lastSeen: number(),
18358
+ /** Frame-rate position history (subject to maxPositionHistory cap). */
18359
+ positions: array(TrackPositionSchema).readonly(),
18360
+ /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18361
+ * saveThumbnails policy). */
18362
+ snapshots: array(TrackSnapshotSchema).readonly(),
18363
+ /** Deduplicated zones the track has entered at least once. Zone IDS. */
18364
+ zonesVisited: array(string()).readonly(),
18365
+ /**
18366
+ * Human NAMES for {@link zonesVisited}, resolved at READ time against the
18367
+ * `zones` capability.
18368
+ *
18369
+ * `zonesVisited` persists ids (`cfeec78c-8d69-…`), which no operator can type
18370
+ * and no card can render — so every free-text search surface was structurally
18371
+ * unable to answer "show me the tracks in Uscio", and did not fail loudly, it
18372
+ * just returned nothing. Resolving here rather than in each client keeps ONE
18373
+ * derivation and costs the clients no extra call (the `zones` cap is
18374
+ * per-device, so a client-side resolve would be a per-camera fan-out on a
18375
+ * surface built to avoid exactly that).
18376
+ *
18377
+ * Resolved, never invented: a zone deleted since the track was written has no
18378
+ * name and is DROPPED, so this array can be shorter than `zonesVisited` — the
18379
+ * two are not positionally aligned. Absent when the track visited no zone, or
18380
+ * when the zone catalogue could not be read.
18381
+ */
18382
+ zoneNames: array(string()).readonly().optional(),
18383
+ /** Deduplicated set of detector classes observed for this track over its
18384
+ * life (a track may be reclassified, e.g. person→vehicle). Absent on
18385
+ * legacy rows written before class accumulation shipped. */
18386
+ classes: array(string()).readonly().optional(),
18387
+ /** Cumulative normalized distance travelled (0..1 units = full frame width). */
18388
+ totalDistance: number(),
18389
+ state: TrackStateSchema,
18390
+ active: boolean(),
18391
+ /** Deterministic key-event importance score in [0,1] (server-computed at
18392
+ * track expiry, recomputed on late label). Absent on legacy rows written
18393
+ * before scoring shipped — consumers degrade to absence / compute-on-read. */
18394
+ importance: number().optional(),
18395
+ /** Id of the track's highest-confidence ObjectEvent (its representative
18396
+ * "best" frame). Absent when the track produced no object events. */
18397
+ bestEventId: string().optional(),
18398
+ /** Tag of the importance sub-signal that dominated the score
18399
+ * (identity|dwell|proximity|class|confidence|travel|zone). */
18400
+ importanceReason: string().optional(),
18401
+ /** Audio-classification labels heard on the camera during the track's
18402
+ * life (score ≥ device `classificationMinScore`), aggregated per label.
18403
+ * Absent on legacy rows / tracks with no confident audio. */
18404
+ audioLabels: array(TrackAudioLabelSchema).readonly().optional(),
18405
+ /** Normalized 0..1 trajectory envelope (see {@link TrackEnvelopeSchema}).
18406
+ * Populated from the persisted envelope columns on historical reads;
18407
+ * absent on legacy rows, dims-less tracks and active (in-RAM) tracks. */
18408
+ envelope: TrackEnvelopeSchema.optional(),
18409
+ /**
18410
+ * A face DETECTOR found a face on this track — nothing more. It says the
18411
+ * detail plane produced a `face` detail; it does NOT say the face was
18412
+ * embedded, matched, above `minFacePx`, or that the recognizer was even
18413
+ * enabled. Set once and never cleared.
18414
+ *
18415
+ * **This exists so "face present but not recognised" is expressible.** A
18416
+ * recognised identity lands in `subLabel` (attributed to the face chain via
18417
+ * `subLabelMeta.stepId`), so before this field a track with an unmatched face
18418
+ * and a track with no face at all were byte-identical on the wire and no
18419
+ * surface could tell them apart. The read is `hasFace === true && subLabel
18420
+ * === undefined`.
18421
+ *
18422
+ * **Absent ≠ false.** Every row written before the column existed omits it,
18423
+ * and so does every server that predates the field — a consumer must test
18424
+ * `=== true` and render nothing otherwise, never infer "no face".
18425
+ */
18426
+ hasFace: boolean().optional(),
18427
+ /**
18428
+ * This track has a face row IN THE GALLERY: a crop **and** an embedding — a
18429
+ * face an operator could ASSIGN to an identity.
18430
+ *
18431
+ * The STRICT twin of {@link hasFace}, and the pair only earns its keep
18432
+ * because the two disagree. `hasFace` is stamped at the TOP of the face
18433
+ * branch, before every gate, and means no more than "a face detector produced
18434
+ * a face detail". This one is stamped at the single moment the gallery row
18435
+ * LANDS — after `FaceRecognizer.onTrackEnd` successfully persists it, i.e.
18436
+ * past the embedding-magnitude verdict, the `minFacePx` detection gate, the
18437
+ * candidate gate, the imageless-track drop (no crop was ever captured) and
18438
+ * the crop-store drop. Everything between the detector and that insert can
18439
+ * legitimately refuse the face, so a flag written any earlier promises the
18440
+ * operator something to assign and delivers nothing.
18441
+ *
18442
+ * **Independent of recognition.** A face collected but never auto-matched is
18443
+ * still assignable — it is in fact the face an operator most wants to reach —
18444
+ * so this is NOT gated on `recognizedIdentityId`. Recognition lands in
18445
+ * `subLabel`; this says only that the raw material exists.
18446
+ *
18447
+ * **Set once, never cleared.** A track that produced a gallery row produced
18448
+ * one; deleting the row later is the gallery's business, not this flag's.
18449
+ *
18450
+ * **Absent ≠ false**, the same rule as {@link hasFace}: every row written
18451
+ * before the column omits it, and so does every server that predates the
18452
+ * field. A consumer must test `=== true` and render nothing otherwise —
18453
+ * never infer "no assignable face".
18454
+ */
18455
+ hasEmbeddedFace: boolean().optional(),
18456
+ /**
18457
+ * This subject CONTAINS a folded rider — a person the rider-pairing step
18458
+ * ([D34](../decisions/adr-0034.md)) removed from the frame BEFORE the tracker,
18459
+ * so the passage is tracked once and as a VEHICLE.
18460
+ *
18461
+ * It exists because the fold's record was dishonest. D34 and the code both
18462
+ * said "the person is not lost — it is reported so both entities stay on the
18463
+ * record"; in fact the pair went into a per-processor RAM field behind an
18464
+ * accessor nobody called, and every durable surface said `vehicle`, full
18465
+ * stop. This is the composition note that makes the row true.
18466
+ *
18467
+ * A COMPOSITION, never a class and never a label. "This vehicle contains a
18468
+ * person" is not an answer to "what is this" — both label tiers would refuse
18469
+ * a macro token anyway (D89), and correctly. Nothing here changes what the
18470
+ * subject IS: a cyclist stays one vehicle track, occupancy still counts one,
18471
+ * and a `person` rule still does not fire for someone cycling past.
18472
+ *
18473
+ * **Absent ≠ false**, exactly like {@link hasFace}: every row written before
18474
+ * the column, and every hub that predates the field, omits it. Test
18475
+ * `=== true` and render nothing otherwise — never infer "no rider".
18476
+ */
18477
+ hasRider: boolean().optional(),
18478
+ ...TrackFlagFields,
18479
+ ...TrackRetrainFields
18480
+ });
18481
+ var BaseEventFields = {
18482
+ id: string(),
18569
18483
  deviceId: number(),
18570
- trackId: string(),
18571
- frameId: string()
18572
- }), object({
18573
- removed: boolean(),
18574
- removedAnnotations: number().int()
18575
- }), {
18576
- kind: "mutation",
18577
- auth: "admin"
18578
- }), method(object({ frameId: string() }), object({
18484
+ timestamp: number()
18485
+ };
18486
+ var MotionEventSchema = object({
18487
+ ...BaseEventFields,
18488
+ kind: literal("motion"),
18489
+ regionCount: number(),
18490
+ /** Heavy JSON array — omitted in slim projection. */
18491
+ regions: array(object({
18492
+ bbox: BoundingBoxSchema,
18493
+ pixelCount: number(),
18494
+ intensity: number()
18495
+ })).readonly().optional(),
18496
+ /** Omitted in slim projection. */
18497
+ frameWidth: number().optional(),
18498
+ /** Omitted in slim projection. */
18499
+ frameHeight: number().optional(),
18500
+ /** Populated by B5 (recording playback URL for this event). */
18501
+ mediaUrl: string().optional()
18502
+ });
18503
+ /**
18504
+ * Which detection SOURCE produced an object event. `pipeline` = the ML
18505
+ * detection pipeline (decoded-frame inference); `onboard` = the camera's
18506
+ * native on-device AI. Both flow through the SAME analysis layers (zoning,
18507
+ * tracking, per-kind persistence) but stay distinguishable so consumers
18508
+ * (advanced-notifier, occupancy, …) can select which source(s) to act on.
18509
+ * Absent on legacy rows ⇒ treat as `pipeline`.
18510
+ */
18511
+ var DetectionSourceSchema = _enum(["pipeline", "onboard"]);
18512
+ /**
18513
+ * The confirmed zone crossing that produced an object event. Present ONLY on
18514
+ * an event emitted BY a crossing (`zone.enter` / `zone.exit`); a movement-state
18515
+ * event (`object.entering` / `leaving` / `stationary` / `loitering`) and an
18516
+ * appearance event carry none, so a rule asking for a direction fails closed
18517
+ * on them.
18518
+ *
18519
+ * Exactly ONE crossing per event: the emitter turns each confirmed crossing
18520
+ * into its own event, so a frame in which a track enters A while leaving B
18521
+ * produces two events with two directions — never one ambiguous row.
18522
+ *
18523
+ * `zoneId` is load-bearing for an EXIT: the event's `zones` list is the
18524
+ * membership the box has NOW, and by definition it no longer contains the zone
18525
+ * that was just left. Without the id here, a zone-scoped rule could never match
18526
+ * the exit it asked for.
18527
+ */
18528
+ var ZoneCrossingSchema = object({
18529
+ direction: _enum(["enter", "exit"]),
18530
+ /** Admin zone id crossed. */
18531
+ zoneId: string(),
18532
+ /** Zone display name at crossing time (falls back to the id). */
18533
+ zoneName: string().optional()
18534
+ });
18535
+ var ObjectEventSchema = object({
18536
+ ...BaseEventFields,
18537
+ kind: literal("object"),
18538
+ /** Detection source. Optional for backward-compat; absent ⇒ `pipeline`. */
18539
+ source: DetectionSourceSchema.optional(),
18540
+ /**
18541
+ * Inference-frame id shared by every object event emitted from the SAME frame
18542
+ * — the "scene/parent" key. Lets a consumer group co-occurring detections (e.g.
18543
+ * 2 people + 1 dog) under one full frame, and link a track's frames over time
18544
+ * (group by `trackId`, pick a representative `frameId` as the parent frame).
18545
+ * Optional for backward-compat with pre-existing rows / the slim projection
18546
+ * includes it (it is light). Absent on rows written before this field.
18547
+ */
18548
+ frameId: string().optional(),
18549
+ /** Omitted in slim projection. */
18550
+ trackId: string().optional(),
18551
+ className: string(),
18552
+ ...TieredLabelFields,
18553
+ /** Omitted in slim projection. */
18554
+ confidence: number().optional(),
18555
+ /** Heavy JSON — omitted in slim projection. */
18556
+ bbox: BoundingBoxSchema.optional(),
18557
+ /** Heavy JSON — omitted in slim projection. */
18558
+ zones: array(string()).readonly().optional(),
18559
+ /** Omitted in slim projection. */
18560
+ state: TrackStateSchema.optional(),
18561
+ /**
18562
+ * The zone crossing this event IS, when it is one. Absent on every other
18563
+ * event kind (movement state, appearance, package) — see
18564
+ * {@link ZoneCrossingSchema}. Omitted in slim projection.
18565
+ */
18566
+ zoneCrossing: ZoneCrossingSchema.optional(),
18567
+ /** Detection-frame dimensions in pixels — let consumers normalize the
18568
+ * pixel-space `bbox` onto a displayed image. Omitted in slim projection. */
18569
+ frameWidth: number().optional(),
18570
+ frameHeight: number().optional(),
18571
+ /** MediaStore key for the crop attached to this event (if any). */
18572
+ mediaKey: string().optional(),
18573
+ /** Design B: MediaStore key of the track's native-resolution key frame (the
18574
+ * best-detection full frame). Resolve via the event-media data-plane
18575
+ * (`/addon/<addonId>/event-media/<keyFrameMediaKey>`) for a detail view that
18576
+ * draws `bbox` over the native frame. Absent on legacy rows / non-decoded
18577
+ * sources — consumers fall back to `mediaKey` (the tight crop). */
18578
+ keyFrameMediaKey: string().optional(),
18579
+ /** Populated by B5 (recording playback URL for this event). */
18580
+ mediaUrl: string().optional(),
18581
+ /** The parent track's key-event importance [0,1], propagated to every object
18582
+ * event of the track (so an event row can be sorted by importance without a
18583
+ * track join). Absent on legacy rows / before the track was scored. */
18584
+ importance: number().optional()
18585
+ });
18586
+ var AudioEventSchema = object({
18587
+ ...BaseEventFields,
18588
+ kind: literal("audio"),
18589
+ rms: number(),
18590
+ dbfs: number(),
18591
+ classification: object({
18592
+ className: string(),
18593
+ originalClass: string().optional(),
18594
+ score: number()
18595
+ }).optional(),
18596
+ /** Populated by B5 (recording playback URL for this event). */
18597
+ mediaUrl: string().optional()
18598
+ });
18599
+ var MediaFileKindEnum = _enum([
18600
+ "crop",
18601
+ "thumbnail",
18602
+ "snapshot",
18603
+ "firstFrame",
18604
+ "lastFrame",
18605
+ "fullFrame",
18606
+ "fullFrameBoxed",
18607
+ "faceCrop",
18608
+ "plateCrop",
18609
+ "keyFrame",
18610
+ "keyFrameSmall",
18611
+ "thumbnailSmall"
18612
+ ]);
18613
+ var MediaFileSchema = object({
18614
+ key: string(),
18615
+ kind: MediaFileKindEnum,
18579
18616
  base64: string(),
18580
- width: number().int(),
18581
- height: number().int()
18582
- }), {
18583
- kind: "query",
18584
- auth: "admin"
18585
- }), method(object({
18586
- deviceId: number(),
18587
- trackId: string(),
18588
- frameId: string(),
18589
- subject: RetrainAssistSubjectSchema,
18590
- /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
18591
- nodeId: string().optional()
18592
- }), RetrainAssistResultSchema, {
18593
- kind: "mutation",
18594
- auth: "admin"
18595
- }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
18596
- kind: "query",
18597
- auth: "admin"
18598
- }), method(object({
18599
- deviceId: number(),
18600
- trackId: string(),
18601
- frameId: string(),
18602
- annotations: array(RetrainAnnotationDraftSchema)
18603
- }), array(RetrainAnnotationSchema).readonly(), {
18604
- kind: "mutation",
18605
- auth: "admin"
18606
- }), method(object({
18607
- deviceId: number(),
18608
- trackId: string()
18609
- }), RetrainTransitionResultSchema, {
18610
- kind: "mutation",
18611
- auth: "admin"
18612
- }), method(object({
18613
- deviceId: number(),
18614
- trackId: string()
18615
- }), RetrainTransitionResultSchema, {
18616
- kind: "mutation",
18617
- auth: "admin"
18618
- }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
18619
- kind: "query",
18620
- auth: "admin"
18621
- }), method(object({
18622
- eventId: string(),
18623
- kind: MediaFileKindEnum.optional(),
18624
- deviceId: number()
18625
- }), array(MediaFileSchema).readonly()), method(object({
18626
- trackId: string(),
18627
- kinds: array(MediaFileKindEnum).optional(),
18628
- deviceId: number()
18629
- }), array(MediaFileSchema).readonly()), method(object({
18617
+ sizeBytes: number(),
18618
+ timestamp: number()
18619
+ });
18620
+ /**
18621
+ * One media row WITHOUT its bytes.
18622
+ *
18623
+ * A track's media is 5-8 MB of base64 (measured: 7.67 MB across 23 files for a
18624
+ * 140 s track), and a client that renders tiles from the media data plane needs
18625
+ * to know only WHAT EXISTS — the bytes then arrive per tile, lazily, over HTTP
18626
+ * with an immutable cache, instead of all at once inside a tRPC response that
18627
+ * blocks the whole view.
18628
+ *
18629
+ * `sizeBytes` is carried because it is what lets a client decide between the
18630
+ * stored blob and a `?variant=thumb` rendering without fetching either.
18631
+ */
18632
+ var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18633
+ /**
18634
+ * The MACRO tier of an annotation — a CLOSED set.
18635
+ *
18636
+ * This is what the exported detector predicts, so a typo here is a new class
18637
+ * with one example in it. `label` and `subLabel` are open strings by contrast:
18638
+ * the whole point of the page is teaching the model things it does not know
18639
+ * yet, and constraining that vocabulary would make it useless.
18640
+ *
18641
+ * A macro class is NEVER a label. The provider refuses a write whose `label` or
18642
+ * `subLabel` is one of these values, in any casing, because once `person`
18643
+ * exists in both tiers "every person box" stops being answerable without
18644
+ * knowing every string anyone ever typed — and the damage is retroactive.
18645
+ */
18646
+ var RetrainMacroClassSchema = _enum([
18647
+ "person",
18648
+ "vehicle",
18649
+ "animal",
18650
+ "package",
18651
+ "face",
18652
+ "plate"
18653
+ ]);
18654
+ /** A subject to learn, or a phantom to unlearn (taught by OMISSION). */
18655
+ var RetrainAnnotationKindSchema = _enum(["subject", "model_error"]);
18656
+ /** Did a human draw this box, or did the assist propose it? */
18657
+ var RetrainAnnotationSourceSchema = _enum(["operator", "assist"]);
18658
+ /** Normalised `[0,1]` rectangle against the FULL frame — the canonical form. */
18659
+ var RetrainBboxSchema = object({
18660
+ x: number(),
18661
+ y: number(),
18662
+ w: number(),
18663
+ h: number()
18664
+ });
18665
+ /**
18666
+ * One annotated subject.
18667
+ *
18668
+ * `bbox` is normalised against the full frame, ALWAYS. The per-model shapes
18669
+ * (letterboxed root / zone-cropped package / subject-cropped classifier) are
18670
+ * derived from it at export and never stored — storing them is how one feature
18671
+ * space ends up holding two crops of the same subject (D52).
18672
+ */
18673
+ var RetrainAnnotationSchema = object({
18674
+ id: string(),
18630
18675
  trackId: string(),
18631
- deviceId: number()
18632
- }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18633
- kind: "mutation",
18634
- auth: "admin"
18635
- }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
18636
- kind: "mutation",
18637
- auth: "admin"
18638
- }), method(object({}), RebuildStatusSchema), object({
18639
- deviceId: number(),
18640
- timestamp: number(),
18641
- frameWidth: number(),
18642
- frameHeight: number(),
18643
- detections: array(OverlayDetectionSchema).readonly()
18644
- }), object({
18645
18676
  deviceId: number(),
18677
+ /** The COPY in retrain storage — never the source track's media key. */
18678
+ mediaKey: string(),
18679
+ bbox: RetrainBboxSchema,
18680
+ macroClass: RetrainMacroClassSchema,
18681
+ label: string().optional(),
18682
+ subLabel: string().optional(),
18683
+ kind: RetrainAnnotationKindSchema,
18684
+ source: RetrainAnnotationSourceSchema,
18685
+ /** Which model proposed this box — or, on a `model_error`, drew the phantom. */
18686
+ assistModelId: string().optional(),
18687
+ assistScore: number().optional(),
18688
+ exportedInBatch: string().optional(),
18689
+ createdAt: number()
18690
+ });
18691
+ /** The write form — the server owns `id`, `createdAt` and the frame binding. */
18692
+ var RetrainAnnotationDraftSchema = RetrainAnnotationSchema.omit({
18693
+ id: true,
18694
+ trackId: true,
18695
+ deviceId: true,
18696
+ mediaKey: true,
18697
+ createdAt: true,
18698
+ exportedInBatch: true
18699
+ });
18700
+ /** A track sitting in `staging`, with everything the worklist needs to rank it. */
18701
+ var RetrainTrackSchema = object({
18646
18702
  trackId: string(),
18647
- className: string()
18648
- }), object({
18649
18703
  deviceId: number(),
18650
- trackId: string(),
18651
18704
  className: string(),
18652
- durationMs: number()
18653
- }), object({
18705
+ label: string().optional(),
18706
+ firstSeen: number(),
18707
+ lastSeen: number(),
18708
+ /** How many frames the dataset already holds from this track. */
18709
+ frameCount: number().int(),
18710
+ /** How many subjects have been annotated on those frames. `0` with
18711
+ * `frameCount: 0` is exactly "staging, still to work". */
18712
+ annotationCount: number().int()
18713
+ });
18714
+ /** A frame the picker may offer — an index row, no blob was read to produce it. */
18715
+ var RetrainFrameCandidateSchema = object({
18716
+ mediaKey: string(),
18717
+ kind: MediaFileKindEnum,
18718
+ timestamp: number(),
18719
+ sizeBytes: number().int(),
18720
+ /** A copy of this original already exists — selecting it is free and cannot
18721
+ * fail, whatever became of the original. */
18722
+ copied: boolean()
18723
+ });
18724
+ /** A frame the dataset OWNS: bytes copied at selection time. */
18725
+ var RetrainFrameSchema = object({
18726
+ frameId: string(),
18654
18727
  deviceId: number(),
18655
- kind: EventKindSchema,
18656
- eventId: string(),
18657
- timestamp: number()
18728
+ trackId: string(),
18729
+ /** Provenance only. It may already point at nothing — that is expected. */
18730
+ sourceMediaKey: string(),
18731
+ sourceKind: MediaFileKindEnum,
18732
+ sizeBytes: number().int(),
18733
+ width: number().int(),
18734
+ height: number().int(),
18735
+ copiedAt: number()
18658
18736
  });
18659
- /**
18660
- * Reference to the frame's retained NATIVE surface + the parent crop's placement
18661
- * within the frame, so the executor can re-cut a leaf child ROI at native
18662
- * resolution on the detail plane. See the `runPipeline` `nativeCropRef` field.
18663
- */
18664
- var NativeCropRefSchema = object({
18665
- /** Handle keying the retained native surface (node-pinned to its owner). */
18666
- handle: FrameHandleSchema,
18667
- /** The parent crop's padded/clamped rectangle in FRAME-space pixels. */
18668
- cropFrameSpace: object({
18669
- x: number(),
18670
- y: number(),
18671
- w: number(),
18672
- h: number()
18673
- })
18737
+ /** Why a copy-on-select could not be honoured — named, never a silent skip. */
18738
+ var RetrainCopyRefusalSchema = _enum([
18739
+ "source-missing",
18740
+ "unreadable-image",
18741
+ "write-failed"
18742
+ ]);
18743
+ var RetrainFrameSelectionSchema = object({
18744
+ copied: array(RetrainFrameSchema).readonly(),
18745
+ refused: array(object({
18746
+ sourceMediaKey: string(),
18747
+ reason: RetrainCopyRefusalSchema
18748
+ })).readonly()
18674
18749
  });
18675
- object({
18676
- crop: object({
18677
- left: number(),
18678
- top: number(),
18679
- width: number().positive(),
18680
- height: number().positive()
18681
- }).optional(),
18682
- content: object({
18683
- width: number().int().positive(),
18684
- height: number().int().positive()
18685
- }),
18686
- fit: _enum(["stretch", "contain"]),
18687
- format: _enum([
18688
- "rgb",
18689
- "gray",
18690
- "jpeg"
18691
- ])
18750
+ var RetrainFrameListSchema = object({
18751
+ candidates: array(RetrainFrameCandidateSchema).readonly(),
18752
+ copies: array(RetrainFrameSchema).readonly(),
18753
+ /** What the page pre-selects — the native key frame when one survives. */
18754
+ autoPickMediaKey: string().optional()
18692
18755
  });
18756
+ /** What the operator asked the assist to look for. */
18757
+ var RetrainAssistSubjectSchema = discriminatedUnion("kind", [object({
18758
+ kind: literal("package"),
18759
+ zone: RetrainBboxSchema.optional()
18760
+ }), object({
18761
+ kind: literal("objects"),
18762
+ modelId: string(),
18763
+ minScore: number().optional()
18764
+ })]);
18693
18765
  /**
18694
- * Process-local frame identity. It is serializable so it can ride an in-process
18695
- * capability call, but `registryId` deliberately prevents resolution in any
18696
- * other process or execution group.
18766
+ * The assist's answer a discriminated union, because "the model saw nothing"
18767
+ * and "this node cannot run that model" lead to different next moves and a
18768
+ * nullable result cannot tell them apart.
18697
18769
  */
18698
- var FrameRefSchema = object({
18699
- registryId: string().min(1),
18700
- id: string().min(1),
18701
- width: number().int().positive(),
18702
- height: number().int().positive(),
18703
- format: _enum(["rgb", "gray"]),
18704
- timestamp: number(),
18705
- capturedAt: number().optional()
18770
+ var RetrainAssistResultSchema = discriminatedUnion("kind", [object({
18771
+ kind: literal("proposed"),
18772
+ modelId: string(),
18773
+ stepId: string(),
18774
+ minScore: number(),
18775
+ /** Drafts, ready to edit. `source: 'assist'` until the operator touches one. */
18776
+ proposals: array(RetrainAnnotationDraftSchema).readonly(),
18777
+ /** Returned by the runner but removed by the threshold. */
18778
+ belowThreshold: number().int()
18779
+ }), object({
18780
+ kind: literal("refused"),
18781
+ /** `no-zone` is ours; the rest are the runner's own refusal vocabulary. */
18782
+ reason: string(),
18783
+ detail: string().optional()
18784
+ })]);
18785
+ /** The outcome of a lifecycle move owned by the retrain page. */
18786
+ var RetrainTransitionResultSchema = object({
18787
+ trackId: string(),
18788
+ /** Where the track ended up, whatever happened. */
18789
+ retrainStatus: RetrainStatusSchema,
18790
+ /** `false` ⇒ the move was refused or was a no-op; `reason` says which. */
18791
+ changed: boolean(),
18792
+ reason: _enum([
18793
+ "unknown-track",
18794
+ "no-frames-copied",
18795
+ "not-staging",
18796
+ "not-trained",
18797
+ "unchanged"
18798
+ ]).optional()
18706
18799
  });
18707
- var ModelFormatSchema$1 = _enum([
18708
- "onnx",
18709
- "coreml",
18710
- "openvino",
18711
- "tflite",
18712
- "pt",
18713
- "gguf"
18714
- ]);
18715
- var PipelineSlotSchema = _enum([
18716
- "detector",
18717
- "cropper",
18718
- "classifier",
18719
- "refiner",
18720
- "audio-classifier"
18721
- ]);
18722
- var PipelineEngineChoiceSchema = object({
18723
- runtime: _enum(["node", "python"]),
18724
- backend: string(),
18725
- format: ModelFormatSchema$1,
18726
- device: string().optional()
18800
+ var DEFAULT_EVENT_QUERY_LIMIT = 1e3;
18801
+ var MAX_EVENT_QUERY_LIMIT = 5e3;
18802
+ var DeviceEventQueryInput = object({
18803
+ deviceId: number(),
18804
+ since: number().optional(),
18805
+ until: number().optional(),
18806
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT),
18807
+ /** `slim` drops heavy JSON fields (regions/bbox/zones) and carries an
18808
+ * optional `mediaUrl` (populated by B5). `full` (default) keeps today's
18809
+ * exact behaviour. Callers may omit this field — the store defaults to
18810
+ * `full` when not provided. */
18811
+ projection: _enum(["full", "slim"]).optional()
18727
18812
  });
18728
- var AvailableEngineSchema = object({
18729
- engine: PipelineEngineChoiceSchema,
18730
- devices: array(object({
18731
- id: string(),
18732
- label: string(),
18733
- description: string().optional()
18734
- })).readonly(),
18735
- defaultDevice: string()
18813
+ var ObjectEventQueryInput = DeviceEventQueryInput.extend({ classFilter: string().optional() });
18814
+ var RecentTracksQueryInput = object({
18815
+ /** Devices to merge. An empty array yields `{ tracks: [], nextCursor: null }`. */
18816
+ deviceIds: array(number()),
18817
+ /** Window lower bound on `lastSeen` (inclusive). */
18818
+ since: number().optional(),
18819
+ /** Window upper bound on `lastSeen` (inclusive). */
18820
+ until: number().optional(),
18821
+ /** Page size. Default 200, max 1000. */
18822
+ limit: number().int().min(1).max(1e3).default(200),
18823
+ /** Opaque continuation cursor from a previous page's `nextCursor`.
18824
+ * Encodes the (lastSeen, trackId) sort position — treat as opaque. */
18825
+ cursor: string().optional(),
18826
+ /** See {@link TrackProjectionSchema}. Default `full`. */
18827
+ projection: TrackProjectionSchema.optional(),
18828
+ /** Include stationary-promoted rows (parked objects). Default false: the
18829
+ * feed lists passages; parking records live on the stationary registry. */
18830
+ includeStationary: boolean().optional()
18831
+ });
18832
+ var RecentTracksPageSchema = object({
18833
+ /** Merged page, ordered by (`lastSeen` DESC, `trackId` DESC). */
18834
+ tracks: array(TrackSchema).readonly(),
18835
+ /** Cursor for the next page, or null when this page is the last. */
18836
+ nextCursor: string().nullable()
18736
18837
  });
18737
- var PipelineDefaultStepSchema = lazy(() => object({
18738
- addonId: string(),
18739
- addonName: string(),
18740
- slot: PipelineSlotSchema,
18741
- inputClasses: array(string()).readonly(),
18742
- outputClasses: array(string()).readonly(),
18743
- enabled: boolean(),
18744
- modelId: string(),
18745
- children: array(PipelineDefaultStepSchema).readonly(),
18746
- group: string().optional(),
18747
- settings: record(string(), unknown()).optional()
18748
- }));
18749
- var PipelineTemplateStepSchema = lazy(() => object({
18750
- addonId: string(),
18751
- enabled: boolean(),
18752
- modelId: string(),
18753
- children: array(PipelineTemplateStepSchema).readonly(),
18754
- settings: record(string(), unknown()).optional()
18755
- }));
18756
- var PipelineTemplateSchema$1 = object({
18838
+ var LIST_GROUPS_DEFAULT_LIMIT = 40;
18839
+ var LIST_GROUPS_MAX_LIMIT = 100;
18840
+ var AnalyticsGroupRecordSchema = object({
18757
18841
  id: string(),
18758
- name: string(),
18759
- createdAt: string(),
18760
- updatedAt: string(),
18761
- engine: PipelineEngineChoiceSchema,
18762
- steps: array(PipelineTemplateStepSchema).readonly()
18842
+ deviceId: number().int(),
18843
+ openedAt: number().int(),
18844
+ closedAt: number().int(),
18845
+ timestamp: number().int(),
18846
+ memberCount: number().int(),
18847
+ memberTrackIds: array(string()).readonly(),
18848
+ className: string(),
18849
+ classes: array(string()).readonly(),
18850
+ /** Relative event-media path, or null when the group has no picture yet. */
18851
+ mediaUrl: string().nullable(),
18852
+ singleton: boolean()
18763
18853
  });
18764
- var PipelineModelOptionSchema = object({
18765
- id: string(),
18766
- name: string(),
18767
- formats: record(string(), object({
18768
- downloaded: boolean(),
18769
- sizeMB: number()
18770
- })),
18771
- group: ModelVariantGroupSchema.optional(),
18772
- legacy: boolean().optional(),
18773
- provider: ModelProviderIdSchema.optional()
18854
+ var AnalyticsGroupMemberSchema = object({
18855
+ trackId: string(),
18856
+ deviceId: number().int(),
18857
+ className: string(),
18858
+ firstSeen: number().int(),
18859
+ lastSeen: number().int(),
18860
+ mediaUrl: string().nullable()
18774
18861
  });
18775
- var ConfigFieldBridge = custom();
18776
- var PipelineAddonSchemaSchema = object({
18777
- id: string(),
18778
- name: string(),
18779
- slot: PipelineSlotSchema,
18780
- inputClasses: array(string()).readonly(),
18781
- outputClasses: array(string()).readonly(),
18782
- childSlots: array(PipelineSlotSchema).readonly(),
18783
- models: array(PipelineModelOptionSchema).readonly(),
18784
- defaultModelId: string(),
18785
- defaultModelIdByFormat: record(string(), string()).optional(),
18786
- enabledByDefault: boolean().optional(),
18787
- backfillIntoExistingOverrides: boolean().optional(),
18788
- defaultConfidence: number(),
18789
- group: string().optional(),
18790
- configSchema: array(ConfigFieldBridge).readonly().optional()
18862
+ var AnalyticsGroupDetailSchema = AnalyticsGroupRecordSchema.extend({ members: array(AnalyticsGroupMemberSchema).readonly() });
18863
+ var ListGroupsQueryInput = object({
18864
+ /** Devices to merge. An empty array yields `{ groups: [], nextCursor: null }`. */
18865
+ deviceIds: array(number()),
18866
+ /** Window lower bound on `closedAt` (inclusive). */
18867
+ since: number().optional(),
18868
+ /** Window upper bound on `openedAt` (inclusive). */
18869
+ until: number().optional(),
18870
+ limit: number().int().min(1).max(LIST_GROUPS_MAX_LIMIT).default(LIST_GROUPS_DEFAULT_LIMIT),
18871
+ /** Opaque continuation cursor from a previous page's `nextCursor`. */
18872
+ cursor: string().optional()
18791
18873
  });
18792
- var PipelineSlotSchemaSchema = object({
18793
- id: PipelineSlotSchema,
18794
- label: string(),
18795
- priority: number(),
18796
- parentSlot: PipelineSlotSchema.nullable(),
18797
- addons: array(PipelineAddonSchemaSchema).readonly()
18874
+ var ListGroupsPageSchema = object({
18875
+ groups: array(AnalyticsGroupRecordSchema).readonly(),
18876
+ nextCursor: string().nullable()
18798
18877
  });
18799
- var PipelineSchemaSchema = object({
18800
- availableEngines: array(AvailableEngineSchema).readonly(),
18801
- selectedEngine: PipelineEngineChoiceSchema,
18802
- slots: array(PipelineSlotSchemaSchema).readonly()
18878
+ var KeyEventQueryInput = object({
18879
+ deviceId: number(),
18880
+ /** Window lower bound (track firstSeen ≥ since). */
18881
+ since: number(),
18882
+ /** Window upper bound (track firstSeen ≤ until). */
18883
+ until: number(),
18884
+ limit: number().int().min(1).max(200).default(50),
18885
+ /** Drop tracks scoring below this importance. */
18886
+ minImportance: number().min(0).max(1).optional(),
18887
+ /** Restrict to a single class (e.g. 'person'). */
18888
+ classFilter: string().optional()
18803
18889
  });
18804
- var EngineProvisioningSchema = object({
18805
- runtimeId: _enum([
18806
- "onnx",
18807
- "openvino",
18808
- "coreml",
18809
- "edgetpu"
18810
- ]).nullable(),
18811
- device: string().nullable(),
18812
- state: _enum([
18813
- "idle",
18814
- "installing",
18815
- "verifying",
18816
- "ready",
18817
- "failed"
18818
- ]),
18819
- progress: number().optional(),
18820
- error: string().optional(),
18821
- nextRetryAt: number().optional(),
18822
- /**
18823
- * Gate A (config-correctness gate at engine change): human-readable
18824
- * config issues surfaced EAGERLY when the node's engine changes — model
18825
- * substitutions ("chose X, running Y") and zero-build steps ("no model
18826
- * has a <format> build"). Additive/optional: informational only, never
18827
- * enforced here — `assertEngineReady` (readiness) still gates inference.
18828
- * Absent/empty when the node-default tree resolves cleanly.
18829
- */
18830
- configIssues: array(string()).optional()
18890
+ var KeyEventSchema = object({
18891
+ /** The representative event id (the track's best ObjectEvent, else its trackId). */
18892
+ id: string(),
18893
+ trackId: string(),
18894
+ /** Track start time (firstSeen). */
18895
+ timestamp: number(),
18896
+ className: string(),
18897
+ ...TieredLabelFields,
18898
+ importance: number(),
18899
+ /** Highest-confidence ObjectEvent id for the track (empty when none). */
18900
+ bestEventId: string(),
18901
+ /** Track lifetime in ms (lastSeen - firstSeen). */
18902
+ windowMs: number().optional(),
18903
+ ...TrackFlagFields,
18904
+ ...TrackRetrainFields
18831
18905
  });
18832
- var PipelineStepInputSchema = lazy(() => object({
18833
- addonId: string(),
18834
- modelId: string().optional(),
18835
- enabled: boolean().default(true),
18836
- children: array(PipelineStepInputSchema).optional(),
18837
- settings: record(string(), unknown()).optional(),
18838
- jumpDeviceKey: string().optional()
18839
- }));
18840
- var ModelSubstitutionSchema = object({
18841
- addonId: string(),
18842
- chosen: string(),
18843
- running: string(),
18844
- format: string()
18906
+ object({
18907
+ trackId: string(),
18908
+ className: string(),
18909
+ confidence: number(),
18910
+ bbox: BoundingBoxSchema,
18911
+ zones: array(string()).readonly(),
18912
+ state: TrackStateSchema
18845
18913
  });
18846
- var PipelineValidationIssueSchema = object({
18847
- addonId: string(),
18848
- kind: _enum(["unknown-addon", "no-format-build"]),
18849
- detail: string()
18914
+ var OverlayDetectionSchema = looseObject({
18915
+ id: string(),
18916
+ kind: _enum(["first-level", "detail"]),
18917
+ macroClass: string(),
18918
+ score: number(),
18919
+ bbox: object({
18920
+ x: number(),
18921
+ y: number(),
18922
+ width: number(),
18923
+ height: number()
18924
+ }),
18925
+ labels: array(looseObject({
18926
+ label: string(),
18927
+ score: number()
18928
+ })).readonly(),
18929
+ parentId: string().optional()
18850
18930
  });
18851
- var PipelineValidationResultSchema = object({
18852
- ok: boolean(),
18853
- issues: array(PipelineValidationIssueSchema).readonly(),
18854
- substitutions: array(ModelSubstitutionSchema).readonly(),
18855
- /** The node's `currentEngine.format` this validation ran against. */
18856
- format: string()
18931
+ var ScoredObjectEventSchema = ObjectEventSchema.extend({ score: number() });
18932
+ var SearchObjectEventsInput = object({
18933
+ text: string(),
18934
+ deviceId: number().optional(),
18935
+ since: number().optional(),
18936
+ until: number().optional(),
18937
+ classFilter: string().optional(),
18938
+ limit: number().default(50),
18939
+ minScore: number().min(0).max(1).default(.2)
18857
18940
  });
18858
- var ReferenceImageEntrySchema = object({
18859
- filename: string(),
18860
- stepIds: array(string()).readonly().optional()
18941
+ var TrackCascadeCountsSchema = object({
18942
+ /** Persisted track roots deleted (authoritative). */
18943
+ tracks: number().int(),
18944
+ /** Object events removed with their tracks (best-effort; see note above). */
18945
+ events: number().int(),
18946
+ /** Track/face/plate-owned media removed (best-effort). Never identity media. */
18947
+ media: number().int(),
18948
+ /** Unassigned (non-enrolled) face reads removed (best-effort). */
18949
+ faces: number().int(),
18950
+ /** Unassigned plate reads removed (best-effort; plate leg deferred to plate-intelligence). */
18951
+ plates: number().int(),
18952
+ /** Per-track CLIP search vectors removed (best-effort). */
18953
+ embeddings: number().int(),
18954
+ /** Group membership + group rows removed with their last member (best-effort). */
18955
+ groups: number().int()
18861
18956
  });
18862
- var ReferenceImageBodySchema = object({
18863
- base64: string(),
18864
- filename: string()
18957
+ /** Disk-wins reconcile: media rows whose blobs are gone, then empty tracks. */
18958
+ var DiskReconcileCountsSchema = object({
18959
+ mediaDropped: number().int(),
18960
+ tracks: number().int(),
18961
+ events: number().int()
18865
18962
  });
18866
- var ReferenceAudioEntrySchema = object({
18867
- filename: string(),
18868
- sizeKb: number()
18963
+ /** Event-store footprint for one camera. */
18964
+ var EventStoreDeviceFootprintSchema = object({
18965
+ deviceId: number(),
18966
+ /** Persisted event rows (motion + object + audio) for the camera. */
18967
+ rows: number().int(),
18968
+ /** Event-owned media bytes on disk for the camera. */
18969
+ bytes: number().int()
18970
+ });
18971
+ /** Aggregate event-store footprint: global totals + per-camera breakdown. */
18972
+ var EventStoreFootprintSchema = object({
18973
+ totalRows: number().int(),
18974
+ totalBytes: number().int(),
18975
+ devices: array(EventStoreDeviceFootprintSchema).readonly()
18976
+ });
18977
+ /** Per-kind counts returned by the event-prune / device-delete mutations. */
18978
+ var EventPruneCountsSchema = object({
18979
+ motion: number().int(),
18980
+ object: number().int(),
18981
+ audio: number().int()
18869
18982
  });
18870
- var ReferenceAudioBodySchema = object({ base64: string() });
18871
- var AudioBackendSchema = object({
18872
- id: string(),
18873
- name: string(),
18874
- description: string(),
18875
- available: boolean(),
18983
+ /**
18984
+ * Re-embed stored tracks from their key frames.
18985
+ *
18986
+ * The reason this is an operator-callable method and not a migration script:
18987
+ * every knob that decides what a vector MEANS — encoder model, crop margin,
18988
+ * squaring — is only changeable if the existing vectors can be regenerated.
18989
+ * Mixing feature spaces in one index makes cosine scores incomparable, and the
18990
+ * symptom is a quality regression with no visible cause.
18991
+ */
18992
+ var RebuildObjectEmbeddingsInput = object({
18993
+ /** Restrict to one camera. Omit for the whole fleet. */
18994
+ deviceId: number().optional(),
18995
+ since: number().optional(),
18996
+ until: number().optional(),
18997
+ /** Stop after this many tracks; the result reports whether more remain. */
18998
+ maxTracks: number().int().positive().optional(),
18876
18999
  /**
18877
- * Raw classifier labels this backend can emit (e.g. YAMNet's
18878
- * 521-class set or Apple SoundAnalysis's 303-class set). Used by
18879
- * the benchmark UI to populate the `enabledMicroClasses` filter
18880
- * specific to the selected backend without a separate fetch.
19000
+ * Run every embedding on THIS node instead of round-robining the fleet.
19001
+ *
19002
+ * Named `executeOnNodeId` and not `nodeId` on purpose: an inline `nodeId`
19003
+ * field in cap args is read by `parent-unowned-call.ts` as a ROUTING PIN, so
19004
+ * calling it that would pin the rebuild REQUEST itself to that node — the
19005
+ * rebuild orchestration lives on the hub, and only the per-track step runs
19006
+ * remotely. This field is data; the per-track pin is applied inside.
19007
+ *
19008
+ * Absent ⇒ round-robin over every online node whose runner can serve the
19009
+ * pinned model.
18881
19010
  */
18882
- rawLabels: array(string()).readonly().optional()
18883
- });
18884
- var AudioCapabilitiesSchema = object({
18885
- activeBackend: string(),
18886
- availableBackends: array(AudioBackendSchema).readonly(),
18887
- sampleRate: number(),
18888
- chunkDurationMs: number()
18889
- });
18890
- var DownloadModelResultSchema = object({
18891
- filePath: string(),
18892
- sizeMB: number(),
18893
- durationMs: number()
19011
+ executeOnNodeId: string().optional(),
19012
+ /**
19013
+ * Milliseconds to wait between tracks; omit for the built-in default, `0` to
19014
+ * run flat out.
19015
+ *
19016
+ * A rebuild is bulk maintenance on hub-main's single thread. Measured
19017
+ * 2026-08-06, an unpaced pass held that thread busy 82.2 s out of 120 and
19018
+ * pushed `nodes.topology` from 0.25 s to 26 s for 43 minutes. The value in
19019
+ * force is logged at start and finish so a deliberately slow pass reads
19020
+ * differently from a stalled one.
19021
+ */
19022
+ pacingMs: number().int().nonnegative().optional()
18894
19023
  });
18895
19024
  /**
18896
- * Wrapper carrying a single test run's result. Replaces the legacy
18897
- * ad-hoc `{labels: [{className, originalClass, score}]}` shape with the
18898
- * canonical `AudioResult` from the Phase 6 output rework: one
18899
- * `AudioDetection` per class above `minScore`, top-N candidates in
18900
- * `debug.alternateLabels['audio-classifier']`, per-source timings in
18901
- * `debug.stepTimings`. The outer `success`/`error` fields stay so the
18902
- * benchmark UI can still report a clean failure when the classifier
18903
- * cap isn't available.
19025
+ * Result of emptying the CLIP index.
19026
+ *
19027
+ * The clean slate before a policy change: a new crop margin or encoder model
19028
+ * leaves two feature spaces in one index whose cosine scores are not
19029
+ * comparable, so wiping and rebuilding is the only way to be sure every vector
19030
+ * means the same thing.
18904
19031
  */
18905
- var AudioTestResultSchema = object({
18906
- success: boolean(),
18907
- error: string().optional(),
18908
- frame: custom().optional()
19032
+ var WipeObjectEmbeddingsResultSchema = object({ deleted: number() });
19033
+ /**
19034
+ * Acknowledgement that a rebuild STARTED.
19035
+ *
19036
+ * The pass costs ~1s per track — 45 minutes for a 2,600-track fleet — so it
19037
+ * runs detached and this returns immediately. Waiting for it made the client
19038
+ * time out while the work carried on server-side, which is the worst of both:
19039
+ * no result and no way to know it was still going. Poll
19040
+ * `getObjectEmbeddingRebuildStatus` for progress.
19041
+ */
19042
+ var RebuildObjectEmbeddingsResultSchema = object({
19043
+ started: boolean(),
19044
+ /** True when a pass was already running; the new request is ignored. */
19045
+ alreadyRunning: boolean()
18909
19046
  });
18910
- var PipelineConfigBridge = custom();
18911
- var ConfigUISchemaBridge = custom();
18912
- var ConfigUISchemaNullableBridge = custom();
18913
- var InferenceCapabilitiesBridge = custom();
18914
- var ModelAvailabilityListBridge = custom();
18915
- var PipelineRunResultBridge = custom();
18916
- method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngineChoiceSchema), method(PipelineEngineChoiceSchema, array(PipelineDefaultStepSchema)), method(object({ nodeId: string() }), EngineProvisioningSchema), method(_void(), record(string(), object({
18917
- modelId: string(),
18918
- settings: record(string(), unknown()).readonly()
18919
- }))), method(object({ steps: record(string(), object({
18920
- modelId: string(),
18921
- settings: record(string(), unknown()).readonly()
18922
- })) }), object({ success: literal(true) }), {
19047
+ var RebuildStatusSchema = object({
19048
+ running: boolean(),
19049
+ scanned: number(),
19050
+ rebuilt: number(),
19051
+ /** Tracks whose key frame is gone — nothing to re-embed from. */
19052
+ missingKeyFrame: number(),
19053
+ /** Tracks with no usable detection box. */
19054
+ missingBbox: number(),
19055
+ /**
19056
+ * Tracks an executing node REFUSED rather than broke on — an unreadable key
19057
+ * frame, a step that threw. Separate from `failed` because the remedy is
19058
+ * different, and because a whole camera silently contributing zero vectors
19059
+ * is the shape of failure a rebuild must never hide.
19060
+ */
19061
+ notRunnable: number(),
19062
+ /**
19063
+ * The pass stopped because NO node could serve the pinned model.
19064
+ *
19065
+ * Distinct from `notRunnable` on purpose: that one says "this track was
19066
+ * refused", this one says "the cluster cannot do this work at all" — every
19067
+ * candidate node either lacks the `clip-embedding` step, lacks a build of the
19068
+ * pinned model for its engine format, or dropped out. The remedy is a model /
19069
+ * engine change, not a per-camera one. Non-zero here always comes with
19070
+ * `complete: false`.
19071
+ */
19072
+ noCapableNode: number(),
19073
+ failed: number(),
19074
+ /** Set once a pass ends: true only when EVERYTHING was covered. */
19075
+ complete: boolean().nullable(),
19076
+ startedAtMs: number().nullable(),
19077
+ finishedAtMs: number().nullable(),
19078
+ /** Present when the pass ended by throwing. */
19079
+ error: string().nullable()
19080
+ });
19081
+ var ReplayFrameInputSchema = object({
19082
+ timestamp: number(),
19083
+ frame: PipelineRunResultBridge
19084
+ });
19085
+ var RunReplayFrameProcessorResultSchema = object({ tracks: array(object({
19086
+ className: string(),
19087
+ firstSeenMs: number(),
19088
+ lastSeenMs: number(),
19089
+ /** Bbox of the track's FIRST matched detection, pixel-space in the clip's
19090
+ * frame — a representative box for the diff's `(className, window, IoU)`
19091
+ * pairing (`replay-diff.ts`). A replay does not need the full per-frame
19092
+ * trajectory production's `Track.positions` keeps. */
19093
+ bbox: BoundingBoxSchema,
19094
+ /** How many of the input frames this track matched a real detection on
19095
+ * (never a coasted/extrapolated frame) — the replay's own signal for "how
19096
+ * solid is this track", cheaper than re-deriving it from a trajectory. */
19097
+ framesMatched: number().int()
19098
+ })).readonly() });
19099
+ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).readonly()), method(object({
19100
+ deviceId: number(),
19101
+ trackId: string()
19102
+ }), TrackSchema.nullable()), method(object({
19103
+ deviceId: number(),
19104
+ since: number().optional(),
19105
+ until: number().optional(),
19106
+ limit: number().optional(),
19107
+ /** Spatial filter — only tracks whose trajectory intersects the zone
19108
+ * (normalized 0..1 rect or polygon). SQL-prefiltered on the persisted
19109
+ * envelope columns, then precisely tested per position. Tracks with
19110
+ * an unknown envelope (no frame dims at persist time) always match. */
19111
+ zone: TrackZoneFilterSchema.optional(),
19112
+ /** See {@link TrackProjectionSchema}. Default `full` (backward
19113
+ * compatible — omitting the field keeps today's exact behaviour). */
19114
+ projection: TrackProjectionSchema.optional(),
19115
+ /** Include stationary-promoted rows (parked objects handed to the
19116
+ * stationary registry). Default false: the timeline lists passages,
19117
+ * not parking records (operator decision, 2026-08-15). */
19118
+ includeStationary: boolean().optional()
19119
+ }), array(TrackSchema).readonly()), method(RecentTracksQueryInput, RecentTracksPageSchema), method(ListGroupsQueryInput, ListGroupsPageSchema), method(object({
19120
+ deviceId: number(),
19121
+ groupId: string().min(1)
19122
+ }), AnalyticsGroupDetailSchema.nullable()), method(object({ deviceId: number() }), _void(), {
19123
+ kind: "mutation",
19124
+ auth: "admin"
19125
+ }), method(DeviceEventQueryInput, array(MotionEventSchema).readonly()), method(ObjectEventQueryInput, array(ObjectEventSchema).readonly()), method(DeviceEventQueryInput, array(AudioEventSchema).readonly()), method(object({ deviceId: number() }), array(EventKindDescriptorSchema).readonly()), method(object({ deviceIds: array(number()).min(1).max(200) }), array(EventKindsForDeviceSchema).readonly()), method(object({
19126
+ deviceId: number(),
19127
+ since: number().optional(),
19128
+ until: number().optional(),
19129
+ kinds: array(string()).optional(),
19130
+ limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
19131
+ }), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
19132
+ deviceId: number(),
19133
+ since: number(),
19134
+ until: number(),
19135
+ bucketMs: number().int().positive()
19136
+ }), array(object({
19137
+ bucketStart: number(),
19138
+ motion: number().int(),
19139
+ object: number().int(),
19140
+ audio: number().int()
19141
+ })).readonly()), method(object({
19142
+ deviceId: number(),
19143
+ cutoffMs: number()
19144
+ }), object({
19145
+ motion: number().int(),
19146
+ object: number().int(),
19147
+ audio: number().int()
19148
+ }), {
19149
+ kind: "mutation",
19150
+ auth: "admin"
19151
+ }), method(object({
19152
+ deviceId: number(),
19153
+ cutoffMs: number()
19154
+ }), TrackCascadeCountsSchema, {
19155
+ kind: "mutation",
19156
+ auth: "admin"
19157
+ }), method(object({ deviceId: number() }), TrackCascadeCountsSchema, {
19158
+ kind: "mutation",
19159
+ auth: "admin"
19160
+ }), method(object({ deviceId: number() }), DiskReconcileCountsSchema, {
19161
+ kind: "mutation",
19162
+ auth: "admin"
19163
+ }), method(object({
19164
+ deviceId: number(),
19165
+ trackIds: array(string()).min(1)
19166
+ }), object({
19167
+ deleted: number().int(),
19168
+ failed: array(string()).readonly()
19169
+ }), {
19170
+ kind: "mutation",
19171
+ auth: "admin"
19172
+ }), method(object({
19173
+ /** Log/audit scope only — the trackId is globally unique on its own. */
19174
+ deviceId: number(),
19175
+ trackId: string(),
19176
+ flags: TrackFlagsPatchSchema
19177
+ }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19178
+ kind: "query",
19179
+ auth: "admin"
19180
+ }), method(object({
19181
+ olderThanMs: number(),
19182
+ reason: OpsLogReasonSchema.optional()
19183
+ }), EventPruneCountsSchema, {
19184
+ kind: "mutation",
19185
+ auth: "admin"
19186
+ }), method(object({ deviceId: number() }), EventPruneCountsSchema, {
19187
+ kind: "mutation",
19188
+ auth: "admin"
19189
+ }), method(StorageMigrationLeaseInputSchema, object({ paused: literal(true) }), {
19190
+ kind: "mutation",
19191
+ auth: "admin"
19192
+ }), method(StorageMigrationLeaseInputSchema, object({ resumed: literal(true) }), {
19193
+ kind: "mutation",
19194
+ auth: "admin"
19195
+ }), method(StorageMigrationLeaseInputSchema, object({ refreshed: literal(true) }), {
19196
+ kind: "mutation",
19197
+ auth: "admin"
19198
+ }), method(StorageMigrationMediaMoveInputSchema, object({ jobId: string() }), {
19199
+ kind: "mutation",
19200
+ auth: "admin"
19201
+ }), method(object({ jobId: string() }), RelocateJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
19202
+ kind: "mutation",
19203
+ auth: "admin"
19204
+ }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19205
+ kind: "mutation",
19206
+ auth: "admin"
19207
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19208
+ kind: "query",
19209
+ auth: "admin"
19210
+ }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
18923
19211
  kind: "mutation",
18924
19212
  auth: "admin"
18925
- }), method(object({ nodeId: string() }), object({
18926
- success: literal(true),
18927
- clearedDevices: number()
18928
- }), {
19213
+ }), method(OpsLogQueryInputSchema, array(OpsLogEntrySchema).readonly(), {
19214
+ kind: "query",
19215
+ auth: "admin"
19216
+ }), method(object({ deviceIds: array(number()).optional() }), TrainingExportSummarySchema, {
19217
+ kind: "query",
19218
+ auth: "admin"
19219
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19220
+ kind: "query",
19221
+ auth: "admin"
19222
+ }), method(object({
19223
+ /** Empty ⇒ every camera that has staging tracks. A LIST, not a single
19224
+ * `deviceId`, deliberately: `deviceId` would make this device-bound and
19225
+ * route it at one camera's owner, and "every camera" would stop being
19226
+ * expressible at all. */
19227
+ deviceIds: array(number()).optional(),
19228
+ limit: number().int().min(1).max(500).optional()
19229
+ }), array(RetrainTrackSchema).readonly(), {
19230
+ kind: "query",
19231
+ auth: "admin"
19232
+ }), method(object({ trackId: string() }), RetrainFrameListSchema, {
19233
+ kind: "query",
19234
+ auth: "admin"
19235
+ }), method(object({
19236
+ deviceId: number(),
19237
+ trackId: string(),
19238
+ mediaKeys: array(string()).min(1)
19239
+ }), RetrainFrameSelectionSchema, {
18929
19240
  kind: "mutation",
18930
19241
  auth: "admin"
18931
- }), method(_void(), PipelineSchemaSchema), method(_void(), array(PipelineDefaultStepSchema).readonly().nullable()), method(_void(), PipelineConfigBridge), method(_void(), ConfigUISchemaBridge), method(object({ steps: array(PipelineStepInputSchema) }), PipelineValidationResultSchema), method(_void(), array(PipelineTemplateSchema$1).readonly()), method(object({
18932
- name: string(),
18933
- steps: array(PipelineTemplateStepSchema).readonly(),
18934
- engine: PipelineEngineChoiceSchema
18935
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({
18936
- id: string(),
18937
- name: string().optional(),
18938
- steps: array(PipelineTemplateStepSchema).readonly().optional()
18939
- }), PipelineTemplateSchema$1, { kind: "mutation" }), method(object({ id: string() }), _void(), { kind: "mutation" }), method(_void(), InferenceCapabilitiesBridge), method(object({ addonId: string() }), ModelAvailabilityListBridge), method(object({
18940
- addonId: string(),
18941
- modelId: string(),
18942
- format: ModelFormatSchema$1
18943
- }), DownloadModelResultSchema, { kind: "mutation" }), method(object({
18944
- addonId: string(),
18945
- modelId: string(),
18946
- format: ModelFormatSchema$1
18947
- }), object({ success: literal(true) }), { kind: "mutation" }), method(object({
18948
- engine: PipelineEngineChoiceSchema.optional(),
18949
- steps: array(PipelineStepInputSchema).min(1),
18950
- frame: FrameInputSchema.optional(),
18951
- /**
18952
- * Process-local lazy frame. Valid only when caller and provider resolve
18953
- * in the same execution-group process; split/cross-node callers use
18954
- * `frame`/`image` inline compatibility instead.
18955
- */
18956
- frameRef: FrameRefSchema.optional(),
18957
- /**
18958
- * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
18959
- * the decoded pixels live in. One more member of the one-of
18960
- * frame/frameHandle/image/imageBase64/referenceImage group.
18961
- */
18962
- frameHandle: FrameHandleSchema.optional(),
18963
- imageBase64: string().optional(),
18964
- /**
18965
- * Binary JPEG bytes — preferred over `imageBase64` on internal
18966
- * hops (hub → forked worker via Moleculer MsgPack) because it
18967
- * skips the 33% base64 overhead + the per-call base64 decode on
18968
- * the detection-pipeline worker. Callers can pass either; exactly
18969
- * one of `frame`/`image`/`imageBase64`/`referenceImage` is required.
18970
- */
18971
- image: _instanceof(Uint8Array).optional(),
18972
- referenceImage: string().optional(),
18973
- deviceId: number().optional(),
18974
- sessionId: string().optional(),
18975
- /**
18976
- * Execution plane. 'full' (default) runs the whole tree — benchmark,
18977
- * reference-image, and detail-subtree calls. 'frame' is the live
18978
- * per-frame dispatch: ONLY root-plane steps run; crop children
18979
- * (inputClasses ≠ null) are skipped and served per-track via
18980
- * pipelineRunner.runDetailSubtree (two-plane design).
18981
- */
18982
- plane: _enum(["full", "frame"]).optional(),
18983
- /**
18984
- * Inference-device selector (Phase 2 multi-device). Format
18985
- * `<backend>:<device>` (e.g. `openvino:gpu`, `edgetpu:usb`, `cpu`).
18986
- * Omitted ⇒ the runner's default device (current single-engine
18987
- * behaviour). Selects WHICH device pool of the node runs the call.
18988
- */
18989
- deviceKey: string().optional(),
18990
- /**
18991
- * Two-plane NATIVE child-crop reference. Set by `runDetailSubtree` ONLY
18992
- * when the parent crop was resolved from the frame's retained NATIVE
18993
- * surface (a frameHandle HIT). Lets the executor re-cut a LEAF crop
18994
- * child's ROI (plate-ocr, face-embedding, leaf classifiers) at native
18995
- * resolution from that surface — the SAME quality path faces already
18996
- * had — instead of the downscaled parent tile. `handle` keys the native
18997
- * surface (node-pinned to its owner); `cropFrameSpace` is the parent
18998
- * crop's padded/clamped rectangle in FRAME-space pixels, used to compose
18999
- * the executor's crop-normalized child ROI back into frame-normalized
19000
- * coordinates. Auxiliary to the image source (`image`/`frame`/…), NOT one
19001
- * of the mutually-exclusive image inputs. Absent ⇒ tile-crop children
19002
- * (today's behaviour on the fallback path).
19003
- */
19004
- nativeCropRef: NativeCropRefSchema.optional()
19005
- }), PipelineRunResultBridge, { kind: "mutation" }), method(object({
19006
- engine: PipelineEngineChoiceSchema.optional(),
19007
- steps: array(PipelineStepInputSchema).min(1),
19008
- frames: array(FrameInputSchema).min(1).max(255),
19009
- deviceId: number().optional(),
19010
- sessionId: string().optional(),
19011
- /**
19012
- * Pure-inference benchmark hint. A NONZERO uint32 pins every frame in
19013
- * the batch to the Python pool's bench preprocess cache
19014
- * (`_bench_frame_id`) so a REPEATED benchmark frame is decoded +
19015
- * preprocessed ONCE and every later inference is a pure-inference cache
19016
- * hit — the sustained-throughput run measures inference, not
19017
- * decode+preprocess+infer. Omitted/0 for live frames (all different →
19018
- * full preprocess every call, correct). Fresh per sustained run;
19019
- * released via `uncacheFrame`.
19020
- */
19021
- frameId: number().int().nonnegative().optional(),
19022
- /** Inference-device selector (Phase 2 multi-device); see runPipeline. */
19023
- deviceKey: string().optional()
19024
- }), object({ results: array(PipelineRunResultBridge).readonly() }), { kind: "mutation" }), method(object({
19025
- data: _instanceof(Uint8Array),
19026
- width: number().int().positive(),
19027
- height: number().int().positive(),
19028
- format: _enum([
19029
- "rgb",
19030
- "bgr",
19031
- "gray"
19032
- ])
19242
+ }), method(object({
19243
+ deviceId: number(),
19244
+ trackId: string(),
19245
+ frameId: string()
19033
19246
  }), object({
19034
- frameId: number(),
19035
- width: number(),
19036
- height: number()
19037
- }), { kind: "mutation" }), method(object({
19038
- stepId: string(),
19039
- frameId: number().int()
19040
- }), record(string(), unknown()), { kind: "mutation" }), method(object({ frameId: number().int() }), _void(), { kind: "mutation" }), method(_void(), object({
19041
- batchMode: string(),
19042
- windowMs: number(),
19043
- maxBatchSize: number(),
19044
- concurrency: number()
19045
- })), method(_void(), array(object({
19046
- engineKey: string(),
19047
- engine: PipelineEngineChoiceSchema,
19048
- modelsLoaded: array(string()).readonly(),
19049
- inUseByCameras: array(number()).readonly(),
19050
- /**
19051
- * Origin of this resident factory.
19052
- * - `runtime` — main camera-serving engine (no idle TTL).
19053
- * - `warm-override` — benchmark/test override held in the warm
19054
- * cache; auto-disposed after the idle TTL.
19055
- * - `device-pool` — a concurrent per-device pool (Phase 2
19056
- * multi-device, keyed by `deviceKey`) resolved
19057
- * via `resolveDeviceFactory`. Runs alongside the
19058
- * `runtime` engine on a DIFFERENT accelerator
19059
- * (NPU / iGPU / Coral) — this is how the
19060
- * Engines tab shows all pools running at once.
19061
- */
19062
- kind: _enum([
19063
- "runtime",
19064
- "warm-override",
19065
- "device-pool"
19066
- ]),
19067
- /** Native pid of the underlying Python pool (null when no pool). */
19068
- poolPid: number().nullable(),
19069
- /** ms since this factory was last used (null when not warm-tracked). */
19070
- idleMs: number().nullable(),
19071
- /** Idle TTL after which `warm-override` factories self-evict (null when not applicable). */
19072
- idleTtlMs: number().nullable()
19073
- })).readonly()), method(object({ engine: PipelineEngineChoiceSchema }), object({ success: literal(true) }), {
19247
+ removed: boolean(),
19248
+ removedAnnotations: number().int()
19249
+ }), {
19074
19250
  kind: "mutation",
19075
19251
  auth: "admin"
19252
+ }), method(object({ frameId: string() }), object({
19253
+ base64: string(),
19254
+ width: number().int(),
19255
+ height: number().int()
19256
+ }), {
19257
+ kind: "query",
19258
+ auth: "admin"
19076
19259
  }), method(object({
19077
- engine: PipelineEngineChoiceSchema,
19078
- force: boolean().optional()
19260
+ deviceId: number(),
19261
+ trackId: string(),
19262
+ frameId: string(),
19263
+ subject: RetrainAssistSubjectSchema,
19264
+ /** Which node runs it. Absent ⇒ wherever an unowned call lands. */
19265
+ nodeId: string().optional()
19266
+ }), RetrainAssistResultSchema, {
19267
+ kind: "mutation",
19268
+ auth: "admin"
19269
+ }), method(object({
19270
+ deviceId: number(),
19271
+ source: DetectionSourceSchema,
19272
+ zones: array(ZoneSchema).readonly().optional(),
19273
+ detectionRules: array(ZoneRuleSchema).readonly().optional(),
19274
+ zoneMembershipMinOverlap: number().min(0).max(1).optional(),
19275
+ frames: array(ReplayFrameInputSchema).min(1)
19276
+ }), RunReplayFrameProcessorResultSchema, {
19277
+ kind: "mutation",
19278
+ auth: "admin"
19279
+ }), method(object({ trackId: string() }), array(RetrainAnnotationSchema).readonly(), {
19280
+ kind: "query",
19281
+ auth: "admin"
19282
+ }), method(object({
19283
+ deviceId: number(),
19284
+ trackId: string(),
19285
+ frameId: string(),
19286
+ annotations: array(RetrainAnnotationDraftSchema)
19287
+ }), array(RetrainAnnotationSchema).readonly(), {
19288
+ kind: "mutation",
19289
+ auth: "admin"
19290
+ }), method(object({
19291
+ deviceId: number(),
19292
+ trackId: string()
19293
+ }), RetrainTransitionResultSchema, {
19294
+ kind: "mutation",
19295
+ auth: "admin"
19296
+ }), method(object({
19297
+ deviceId: number(),
19298
+ trackId: string()
19299
+ }), RetrainTransitionResultSchema, {
19300
+ kind: "mutation",
19301
+ auth: "admin"
19302
+ }), method(object({ deviceIds: array(number()).optional() }), object({ url: string() }), {
19303
+ kind: "query",
19304
+ auth: "admin"
19305
+ }), method(object({
19306
+ eventId: string(),
19307
+ kind: MediaFileKindEnum.optional(),
19308
+ deviceId: number()
19309
+ }), array(MediaFileSchema).readonly()), method(object({
19310
+ trackId: string(),
19311
+ kinds: array(MediaFileKindEnum).optional(),
19312
+ deviceId: number()
19313
+ }), array(MediaFileSchema).readonly()), method(object({
19314
+ trackId: string(),
19315
+ deviceId: number()
19316
+ }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19317
+ kind: "mutation",
19318
+ auth: "admin"
19319
+ }), method(RebuildObjectEmbeddingsInput, RebuildObjectEmbeddingsResultSchema, {
19320
+ kind: "mutation",
19321
+ auth: "admin"
19322
+ }), method(object({}), RebuildStatusSchema), object({
19323
+ deviceId: number(),
19324
+ timestamp: number(),
19325
+ frameWidth: number(),
19326
+ frameHeight: number(),
19327
+ detections: array(OverlayDetectionSchema).readonly()
19328
+ }), object({
19329
+ deviceId: number(),
19330
+ trackId: string(),
19331
+ className: string()
19079
19332
  }), object({
19080
- success: boolean(),
19081
- reason: string().optional()
19082
- }), {
19083
- kind: "mutation",
19084
- auth: "admin"
19085
- }), method(_void(), array(ReferenceImageEntrySchema).readonly()), method(object({ filename: string() }), ReferenceImageBodySchema.nullable()), method(_void(), array(ReferenceAudioEntrySchema).readonly()), method(object({ filename: string() }), ReferenceAudioBodySchema.nullable()), method(_void(), AudioCapabilitiesSchema), method(object({
19086
- addonId: string(),
19087
- modelId: string(),
19088
- filename: string().optional(),
19089
- settings: record(string(), unknown()).optional()
19090
- }), AudioTestResultSchema, { kind: "mutation" }), method(_void(), ConfigUISchemaNullableBridge);
19333
+ deviceId: number(),
19334
+ trackId: string(),
19335
+ className: string(),
19336
+ durationMs: number()
19337
+ }), object({
19338
+ deviceId: number(),
19339
+ kind: EventKindSchema,
19340
+ eventId: string(),
19341
+ timestamp: number()
19342
+ });
19091
19343
  object({
19092
19344
  activeCameras: number(),
19093
19345
  throttledCameras: number(),
@@ -19113,106 +19365,6 @@ var CameraMetricsSchema = object({
19113
19365
  });
19114
19366
  var CameraMetricsWithDeviceIdSchema = CameraMetricsSchema.extend({ deviceId: number() });
19115
19367
  /**
19116
- * Zone — pure geometry + identity. NO filtering behaviour.
19117
- *
19118
- * Zones describe **where** in the frame the operator wants to flag
19119
- * something; consumer-owned {@link ZoneRule} arrays describe **how**
19120
- * each pipeline stage uses them. Splitting the two means a single
19121
- * polygon "Driveway" can simultaneously back a motion-exclude rule,
19122
- * a detection-include rule on `['car']`, and an occupancy aggregate
19123
- * — without three duplicated polygons.
19124
- *
19125
- * Owned by the orchestrator addon (provider) and mirrored into the
19126
- * `zones` device-state slice on every mutation. Consumers
19127
- * (motion-wasm, pipeline-executor, analytics, admin UI) read either
19128
- * via `api.zones.listZones` (one-shot) or via `dev.state.zones` (live
19129
- * mirror with `onChanged`).
19130
- *
19131
- * Coordinates are normalised fractions of the frame (0–1) so zones
19132
- * survive resolution changes and stream profile switches.
19133
- *
19134
- * `kind` discriminates between full polygons (closed regions used
19135
- * for intrusion / occupancy filters) and tripwires (open 2-point
19136
- * line segments used for cross events). Onboard / firmware-reported
19137
- * zones (Reolink, ONVIF) are out of scope for now — see the deferred
19138
- * task list.
19139
- */
19140
- var ZoneKindEnum = _enum(["polygon", "tripwire"]);
19141
- /** Polygon vertex in fraction-of-frame coordinates (0–1). */
19142
- var PolygonPointSchema = object({
19143
- x: number(),
19144
- y: number()
19145
- });
19146
- /** A camera detection zone — pure geometry/identity. */
19147
- var ZoneSchema = object({
19148
- id: string(),
19149
- name: string(),
19150
- kind: ZoneKindEnum.default("polygon"),
19151
- /** Polygon vertices, fraction of frame (0–1). */
19152
- polygon: array(PolygonPointSchema).readonly(),
19153
- /** Visual color for UI rendering. */
19154
- color: string().default("#3b82f6")
19155
- });
19156
- /**
19157
- * Zones capability — per-camera CRUD over polygon detection zones.
19158
- *
19159
- * Provider lives in `addon-pipeline-orchestrator` (hub-only). Persists
19160
- * to per-device settings and mirrors into the `zones` device-state
19161
- * slice on every mutation, so downstream consumers can subscribe via
19162
- * `dev.state.zones.onChanged`.
19163
- *
19164
- * The cap surface only handles geometry + identity; filtering
19165
- * behaviour (per-class, include/exclude, threshold) lives in the
19166
- * consumer addons' rule arrays — see `ZoneRuleSchema` exported from
19167
- * `capabilities/schemas/zone-rule.js`.
19168
- */
19169
- var zonesCapability = {
19170
- name: "zones",
19171
- scope: "device",
19172
- mode: "singleton",
19173
- deviceTypes: [DeviceType.Camera],
19174
- methods: {
19175
- listZones: method(object({ deviceId: number() }), array(ZoneSchema).readonly()),
19176
- addZone: method(object({
19177
- deviceId: number(),
19178
- zone: ZoneSchema
19179
- }), _void(), {
19180
- kind: "mutation",
19181
- auth: "admin"
19182
- }),
19183
- removeZone: method(object({
19184
- deviceId: number(),
19185
- zoneId: string()
19186
- }), _void(), {
19187
- kind: "mutation",
19188
- auth: "admin"
19189
- }),
19190
- updateZone: method(object({
19191
- deviceId: number(),
19192
- zone: ZoneSchema
19193
- }), _void(), {
19194
- kind: "mutation",
19195
- auth: "admin"
19196
- })
19197
- },
19198
- /**
19199
- * Runtime-state slice — the live zone catalogue mirrored by the
19200
- * orchestrator on every CRUD mutation. Consumers read via
19201
- * `device.state.zones.value` / `.watch(...)` without round-tripping
19202
- * the cap, and the codegen DeviceProxy auto-wires the reactive
19203
- * handle. Slice shape is `{ zones: Zone[] }` so future extensions
19204
- * (e.g. zone groupings) can sit alongside the polygon list.
19205
- */
19206
- runtimeState: object({ zones: array(ZoneSchema).readonly() }),
19207
- /**
19208
- * Runtime-state durability: **restored** — written only on operator mutation, so a camera that never had one has nothing to re-derive from. This is the slice `zone-mirror-hydration.ts` exists to paper over.
19209
- *
19210
- * See `RuntimeStateDurability`. Enforced by
19211
- * `scripts/check-runtime-state-durability.ts`.
19212
- */
19213
- durability: "restored"
19214
- };
19215
- /**
19216
19368
  * A bounding box in NORMALIZED [0,1] frame coordinates for `getNativeCrop`. The
19217
19369
  * decode worker resolves it against the RETAINED native frame's real pixel dims,
19218
19370
  * so the caller supplies only the detection-res bbox divided by the detection
@@ -27878,6 +28030,39 @@ var ReadGopBytesResultSchema = object({
27878
28030
  /** Media ms the returned fragment covers. */
27879
28031
  gopDurMs: number()
27880
28032
  });
28033
+ /**
28034
+ * A time WINDOW of one finalized segment, cut by byte range — the multi-GOP
28035
+ * twin of {@link ReadGopBytesResultSchema}'s single instant. Built for the
28036
+ * replay clip's `recording` source (`docs/design/plans/2026-08-26-replay-clip-su-pipeline.md`):
28037
+ * a replay needs several seconds of native pixels, not one frame.
28038
+ *
28039
+ * `ok.data` is standalone-demuxable, same as a GOP read. `ok.reachesRequestedEnd`
28040
+ * is `false` when the returned bytes were cut short by the read's own safety
28041
+ * byte cap before covering `[fromMs, toMs)` — a truncation, reported, not a
28042
+ * silently shorter answer. `spans-multiple-segments` is a REFUSAL, not a
28043
+ * degradation: a window whose end falls past the covering segment would need
28044
+ * bytes stitched from a second segment file (its own `ftyp`+`moov`), which is
28045
+ * not one standalone-demuxable stream — the caller's answer is to request a
28046
+ * shorter window or one aligned to a single segment, not to receive spliced
28047
+ * bytes nothing has proven decodable.
28048
+ */
28049
+ var ReadWindowBytesResultSchema = discriminatedUnion("kind", [object({
28050
+ kind: literal("ok"),
28051
+ data: _instanceof(Uint8Array),
28052
+ /** Absolute epoch ms of the returned bytes' first sample — at or before
28053
+ * the requested `fromMs` (anchored on the nearest keyframe). */
28054
+ gopStartMs: number(),
28055
+ /** Media ms the returned bytes cover, from `gopStartMs`. */
28056
+ gopDurMs: number(),
28057
+ /** `false` ⇒ the safety byte cap cut the read short before it reached
28058
+ * the requested `toMs`; the caller got fewer frames than asked for. */
28059
+ reachesRequestedEnd: boolean()
28060
+ }), object({
28061
+ kind: literal("spans-multiple-segments"),
28062
+ /** Where the covering segment's own footage runs out — informational,
28063
+ * not a retry hint (retrying the same window would refuse again). */
28064
+ segmentEndMs: number()
28065
+ })]);
27881
28066
  method(object({
27882
28067
  deviceId: number(),
27883
28068
  fromMs: number(),
@@ -27928,6 +28113,15 @@ method(object({
27928
28113
  }), ReadGopBytesResultSchema, {
27929
28114
  kind: "query",
27930
28115
  auth: "admin"
28116
+ }), method(object({
28117
+ deviceId: number(),
28118
+ profile: string(),
28119
+ startMs: number(),
28120
+ fromMs: number(),
28121
+ toMs: number()
28122
+ }), ReadWindowBytesResultSchema, {
28123
+ kind: "query",
28124
+ auth: "admin"
27931
28125
  }), method(object({
27932
28126
  deviceId: number(),
27933
28127
  config: RecordingConfigSchema
@@ -28523,92 +28717,6 @@ var sceneMonitorCapability = {
28523
28717
  durability: "session"
28524
28718
  };
28525
28719
  /**
28526
- * Per-stage gating mode applied to the zones a rule references.
28527
- *
28528
- * - `include`: the rule contributes to a **whitelist** for its stage.
28529
- * When at least one `include` rule fires for a stage, only entities
28530
- * inside one of those zones pass that stage.
28531
- * - `exclude`: the rule contributes to a **blacklist** for its stage.
28532
- * Entities inside one of those zones are dropped at that stage.
28533
- *
28534
- * `monitor`-style observation (count without filtering) is not a rule
28535
- * mode — zones without any matching rule are observed naturally by
28536
- * `zone-analytics` (live snapshot + history), so an "I just want to
28537
- * count, not filter" use case needs no rule at all.
28538
- */
28539
- var ZoneRuleModeEnum = _enum(["include", "exclude"]);
28540
- /**
28541
- * Per-consumer rule that references existing zones (geometry) and
28542
- * defines how a specific pipeline stage should treat them. Each
28543
- * consumer addon owns its own `ZoneRule[]` array in its per-device
28544
- * settings:
28545
- *
28546
- * - `addon-motion-wasm` → `motionZoneRules: ZoneRule[]` (motion stage)
28547
- * - `addon-detection-pipeline` → `detectionZoneRules: ZoneRule[]` (detection stage)
28548
- * - future: notification rules, audio gating, etc.
28549
- *
28550
- * One rule applies to N zones (`zoneIds[]`) so the operator can
28551
- * express "ignore motion in ALL of {garden, street}" with a single
28552
- * rule. `classFilter` narrows the rule to specific object classes —
28553
- * "drop person detections in the street, but keep cars" is one
28554
- * `exclude` rule with `classFilter: ['person']`.
28555
- *
28556
- * `enabled` is a soft toggle — the operator can keep the rule
28557
- * configured but inert without deleting it.
28558
- */
28559
- var ZoneRuleSchema = object({
28560
- /** Stable rule id — survives edits, used by the UI for diffing. */
28561
- id: string(),
28562
- /** Optional human-readable label rendered in the rule editor. */
28563
- name: string().optional(),
28564
- /** Zones this rule targets. The rule's `mode` applies to ALL
28565
- * listed zones (OR-set: a detection in any one of them counts).
28566
- * At least one zone id required — a rule with no targets is a
28567
- * configuration mistake and the form validator rejects it. */
28568
- zoneIds: array(string()).min(1).readonly(),
28569
- mode: ZoneRuleModeEnum,
28570
- /**
28571
- * Class names this rule applies to. Empty / undefined ⇒ rule
28572
- * applies to every class. Class strings match the `macroClass`
28573
- * field on detections (e.g. `person`, `car`, `dog`).
28574
- */
28575
- classFilter: array(string()).readonly().optional(),
28576
- /**
28577
- * Minimum bbox/mask overlap (0–1) with any of the rule's zones
28578
- * required to consider an entity "in the zone". Defaults to the
28579
- * consumer's stage default when omitted. Kept for back-compat with
28580
- * existing per-rule overrides; new operators pick the value via
28581
- * `bboxInclusionPct` (operator-friendly 0–100). Whichever field is
28582
- * set, the lower-level engine reads it as a 0–1 fraction.
28583
- */
28584
- overlapThreshold: number().min(0).max(1).optional(),
28585
- /**
28586
- * Operator-friendly version of `overlapThreshold` — the percentage
28587
- * of the detection's bbox that must lie inside the zone for the
28588
- * rule to match. Documented default is 85%; the engine substitutes
28589
- * that when the field is omitted (kept optional so existing rules
28590
- * stored without it stay valid).
28591
- *
28592
- * When BOTH `overlapThreshold` and `bboxInclusionPct` are set on a
28593
- * rule, the engine prefers `bboxInclusionPct` because it's the
28594
- * field exposed in the UI. Internally both feed the same gate.
28595
- */
28596
- bboxInclusionPct: number().min(0).max(100).optional(),
28597
- /**
28598
- * When `true` and a detection has a segmentation mask, use the
28599
- * mask for overlap instead of the bbox. Detection-stage only;
28600
- * motion rules ignore this field.
28601
- */
28602
- preferMask: boolean().optional(),
28603
- /**
28604
- * Soft-toggle: `false` disables the rule without deleting it.
28605
- * Defaults to `true` so operators creating a rule via the UI
28606
- * see it active immediately.
28607
- */
28608
- enabled: boolean().default(true)
28609
- });
28610
- array(ZoneRuleSchema).readonly();
28611
- /**
28612
28720
  * Script-runner cap. Models HA `script.*` entities on
28613
28721
  * `DeviceType.Script`. A Script is a pre-recorded action sequence
28614
28722
  * that can be invoked imperatively — optionally with a variables
@@ -34101,6 +34209,12 @@ Object.freeze({
34101
34209
  addonId: null,
34102
34210
  access: "view"
34103
34211
  },
34212
+ "notificationRules.resolveArtifactUrl": {
34213
+ capName: "notification-rules",
34214
+ capScope: "system",
34215
+ addonId: null,
34216
+ access: "view"
34217
+ },
34104
34218
  "notificationRules.setAlarmConfig": {
34105
34219
  capName: "notification-rules",
34106
34220
  capScope: "system",
@@ -34545,6 +34659,12 @@ Object.freeze({
34545
34659
  addonId: null,
34546
34660
  access: "create"
34547
34661
  },
34662
+ "pipelineAnalytics.runReplayFrameProcessor": {
34663
+ capName: "pipeline-analytics",
34664
+ capScope: "device",
34665
+ addonId: null,
34666
+ access: "create"
34667
+ },
34548
34668
  "pipelineAnalytics.saveRetrainAnnotations": {
34549
34669
  capName: "pipeline-analytics",
34550
34670
  capScope: "device",
@@ -34677,6 +34797,12 @@ Object.freeze({
34677
34797
  addonId: null,
34678
34798
  access: "view"
34679
34799
  },
34800
+ "pipelineExecutor.getInferenceDeviceHealth": {
34801
+ capName: "pipeline-executor",
34802
+ capScope: "system",
34803
+ addonId: null,
34804
+ access: "view"
34805
+ },
34680
34806
  "pipelineExecutor.getOrchestratorConfigSchema": {
34681
34807
  capName: "pipeline-executor",
34682
34808
  capScope: "system",
@@ -34749,6 +34875,12 @@ Object.freeze({
34749
34875
  addonId: null,
34750
34876
  access: "view"
34751
34877
  },
34878
+ "pipelineExecutor.rearmInferenceDevice": {
34879
+ capName: "pipeline-executor",
34880
+ capScope: "system",
34881
+ addonId: null,
34882
+ access: "create"
34883
+ },
34752
34884
  "pipelineExecutor.runAudioTest": {
34753
34885
  capName: "pipeline-executor",
34754
34886
  capScope: "system",
@@ -35487,6 +35619,12 @@ Object.freeze({
35487
35619
  addonId: null,
35488
35620
  access: "view"
35489
35621
  },
35622
+ "recording.readWindowBytes": {
35623
+ capName: "recording",
35624
+ capScope: "system",
35625
+ addonId: null,
35626
+ access: "view"
35627
+ },
35490
35628
  "recording.refreshStorageLocationsForMigration": {
35491
35629
  capName: "recording",
35492
35630
  capScope: "system",
@@ -37997,6 +38135,11 @@ Object.freeze({
37997
38135
  form: "single",
37998
38136
  optional: false
37999
38137
  }],
38138
+ "pipelineAnalytics.runReplayFrameProcessor": [{
38139
+ name: "deviceId",
38140
+ form: "single",
38141
+ optional: false
38142
+ }],
38000
38143
  "pipelineAnalytics.saveRetrainAnnotations": [{
38001
38144
  name: "deviceId",
38002
38145
  form: "single",
@@ -38312,6 +38455,11 @@ Object.freeze({
38312
38455
  form: "single",
38313
38456
  optional: false
38314
38457
  }],
38458
+ "recording.readWindowBytes": [{
38459
+ name: "deviceId",
38460
+ form: "single",
38461
+ optional: false
38462
+ }],
38315
38463
  "recording.relocateFootage": [{
38316
38464
  name: "deviceId",
38317
38465
  form: "single",