@camstack/addon-post-analysis 1.2.148 → 1.2.151

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.
@@ -8273,6 +8273,21 @@ var RelocateJobSchema = object({
8273
8273
  bytesMoved: number().int(),
8274
8274
  /** Total files discovered up front; null while (or when) unknown. */
8275
8275
  filesTotal: number().int().nullable(),
8276
+ /**
8277
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8278
+ * made that nobody asked for, so it is reported where the operator reads the
8279
+ * job rather than only in a log line.
8280
+ *
8281
+ * A footage segment records its byte count in its own NAME, and the durable
8282
+ * hour row derives its aggregates from those names. A file that does not
8283
+ * match its name therefore makes the ledger's sums — and with them quota and
8284
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8285
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8286
+ *
8287
+ * Absent on lanes where the question has no meaning: a media blob's size is
8288
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8289
+ */
8290
+ rowsReconciled: number().int().nonnegative().optional(),
8276
8291
  startedAt: number(),
8277
8292
  finishedAt: number().nullable(),
8278
8293
  error: string().nullable()
@@ -8341,14 +8356,42 @@ var RelocateMediaInputSchema = object({
8341
8356
  /** Omitted = `move`, the pre-existing behaviour. */
8342
8357
  mode: MediaRelocateModeSchema.optional()
8343
8358
  });
8344
- /** How many rows still carry NO `locationId` — the population a repoint would
8345
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8346
- * value that permits a non-blocking `eventMedia` cutover. */
8347
- var UnstampedEventMediaCountSchema = object({
8348
- media: number().int().nonnegative(),
8349
- retrainFrames: number().int().nonnegative(),
8350
- total: number().int().nonnegative()
8359
+ /**
8360
+ * The unstamped population of ONE collection — split, because the gate and the
8361
+ * operator ask two different questions and only one of them has to be cheap.
8362
+ *
8363
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8364
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8365
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8366
+ * that matters — after a seal, when the population is empty.
8367
+ *
8368
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8369
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8370
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8371
+ * and useful answer: "there are some, and this read could not say how many"
8372
+ * still refuses the cutover, which is the whole job.
8373
+ */
8374
+ var UnstampedRowsSchema = object({
8375
+ present: boolean(),
8376
+ rows: number().int().nonnegative().nullable()
8351
8377
  });
8378
+ /**
8379
+ * How many rows still carry NO `locationId` — the population a repoint would
8380
+ * silently re-aim at a disk that does not hold their bytes.
8381
+ *
8382
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8383
+ * over. The gate opens on a measured absence and on nothing else; an unread
8384
+ * collection and an empty one are different facts, and this repo has already
8385
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8386
+ */
8387
+ var UnstampedEventMediaCountSchema = object({
8388
+ media: UnstampedRowsSchema,
8389
+ retrainFrames: UnstampedRowsSchema,
8390
+ /** True when EITHER collection holds one. The refusal reads this. */
8391
+ anyPresent: boolean(),
8392
+ /** Sum across both, or `null` when either lane could not be counted. */
8393
+ total: number().int().nonnegative().nullable()
8394
+ }).nullable();
8352
8395
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8353
8396
  /** The independently selectable logical storage classes — every class
8354
8397
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8434,13 +8477,53 @@ var StorageMigrationParticipantSchema = _enum([
8434
8477
  "recorder",
8435
8478
  "analytics"
8436
8479
  ]);
8480
+ /**
8481
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8482
+ *
8483
+ * The long half of a non-blocking migration is `draining`, and it is measured
8484
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8485
+ * existed the only place those numbers appeared was a Loki line, so an operator
8486
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8487
+ * afternoon.
8488
+ *
8489
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8490
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8491
+ * mover — which is the exact failure this is meant to end. The coordinator's
8492
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8493
+ * read `state`; folding the counters costs no extra read and makes the durable
8494
+ * record say afterwards how far a move actually got.
8495
+ *
8496
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8497
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8498
+ * cannot say M, and a 0 there would render as "100 % done".
8499
+ */
8500
+ var StorageMigrationMoveProgressSchema = object({
8501
+ filesMoved: number().int().nonnegative(),
8502
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8503
+ filesTotal: number().int().nonnegative().nullable(),
8504
+ bytesMoved: number().int().nonnegative(),
8505
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8506
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8507
+ * rows would be the same failure as one that silently skipped them. */
8508
+ rowsReconciled: number().int().nonnegative().optional(),
8509
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8510
+ * crash gets a new mover, and a rate computed from the migration's start
8511
+ * would silently average in the time nothing was running. */
8512
+ startedAt: number(),
8513
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8514
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8515
+ * subtract its own. */
8516
+ observedAt: number()
8517
+ });
8437
8518
  var StorageMigrationMoveSchema = object({
8438
8519
  storageClass: StorageMigrationClassSchema,
8439
8520
  fromLocationId: string(),
8440
8521
  toLocationId: string(),
8441
8522
  moverJobId: string().nullable(),
8442
8523
  state: RelocateJobStateSchema.nullable(),
8443
- error: string().nullable()
8524
+ error: string().nullable(),
8525
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8526
+ progress: StorageMigrationMoveProgressSchema.nullable()
8444
8527
  });
8445
8528
  var StorageMigrationJobSchema = object({
8446
8529
  jobId: string(),
@@ -8486,6 +8569,98 @@ var StorageMigrationPlanSchema = object({
8486
8569
  findings: array(StorageMigrationFindingSchema)
8487
8570
  });
8488
8571
  /**
8572
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8573
+ *
8574
+ * The coordinator's job record is the state of record for a migration, and its
8575
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8576
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8577
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8578
+ * way because no supported UI path existed. A mover armed like that has no job
8579
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8580
+ *
8581
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8582
+ * orchestrated it.
8583
+ */
8584
+ var StorageMigrationMoverSchema = object({
8585
+ lane: _enum(["footage", "media"]),
8586
+ job: RelocateJobSchema,
8587
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8588
+ * directly against the owning addon. */
8589
+ migrationJobId: string().nullable(),
8590
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8591
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8592
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8593
+ * rate made of two different clocks. */
8594
+ observedAt: number()
8595
+ });
8596
+ /**
8597
+ * What a SOURCE still holds for one storage class — the number that makes a
8598
+ * "drain remaining" action honest rather than hopeful.
8599
+ *
8600
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8601
+ * engine's own selection count for media), never from the resident index: a
8602
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8603
+ * never been told about (D295).
8604
+ *
8605
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8606
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8607
+ * because refusing on an unanswerable read would hide exactly the case an
8608
+ * operator needs to act on.
8609
+ */
8610
+ var StorageMigrationResidueSchema = object({
8611
+ storageClass: StorageMigrationClassSchema,
8612
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8613
+ * move from wherever they are rather than from one named source. */
8614
+ fromLocationId: string(),
8615
+ /** Where a drain would move it — the class's CURRENT default. */
8616
+ toLocationId: string(),
8617
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8618
+ items: number().int().nonnegative().nullable(),
8619
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8620
+ bytes: number().int().nonnegative().nullable()
8621
+ });
8622
+ /**
8623
+ * Run the DRAIN half and nothing else.
8624
+ *
8625
+ * A migration that reached `done` has already repointed, so `start` correctly
8626
+ * refuses its destination ("already the default") — there is nothing left to
8627
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8628
+ * or finish against a work list that was a tenth of the archive (D295), and
8629
+ * before this there was no supported way to run only that half: the only way
8630
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8631
+ *
8632
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8633
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8634
+ * re-repoint a class that is already migrated.
8635
+ */
8636
+ var StorageMigrationDrainInputSchema = object({
8637
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8638
+ * a class whose source is already empty is refused rather than started. */
8639
+ classes: array(StorageMigrationClassSchema).min(1),
8640
+ throttleMbps: number().min(1).max(1e3).optional()
8641
+ });
8642
+ /** What a footage source still holds, asked of the durable hour ledger. */
8643
+ var RelocateResidueInputSchema = object({
8644
+ fromLocationId: string().min(1),
8645
+ /** Narrow to one logical class; omit for every profile on the location. */
8646
+ footageClass: RelocateFootageClassSchema.optional()
8647
+ });
8648
+ /** `null` = the archive could not answer (no ledger on this node, or the
8649
+ * aggregate failed). Never conflated with an empty source. */
8650
+ var RelocateResidueSchema = object({
8651
+ segments: number().int().nonnegative(),
8652
+ bytes: number().int().nonnegative()
8653
+ }).nullable();
8654
+ /** How many rows a media pass would still act on against a given target — the
8655
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8656
+ * never disagree. `null` = the count could not be taken. */
8657
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8658
+ var RelocatableMediaCountInputSchema = object({
8659
+ toLocationId: string().min(1),
8660
+ /** Omitted = `move`. */
8661
+ mode: MediaRelocateModeSchema.optional()
8662
+ });
8663
+ /**
8489
8664
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
8490
8665
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
8491
8666
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -8589,6 +8764,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8589
8764
  * two addons declaring the same `id` must agree on `cardinality` (validated
8590
8765
  * at kernel aggregation time, not here).
8591
8766
  */
8767
+ /**
8768
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8769
+ * actually reaches the bytes. It is the constraint that decides which
8770
+ * `storage-provider`s may back a location of that kind.
8771
+ *
8772
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8773
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8774
+ * post-analysis media roots). Only a provider that serves a genuine local
8775
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8776
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8777
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8778
+ * against a same-named local directory that is something else entirely.
8779
+ *
8780
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8781
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8782
+ * service never sees a path, so any provider can back it. `backups` is the
8783
+ * one kind that qualifies today.
8784
+ *
8785
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8786
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8787
+ * refused the configuration; the first write simply went somewhere wrong, and
8788
+ * a recording write that goes wrong surfaces as a silent black window rather
8789
+ * than an error (the read path does not `stat`). This turns that accident into
8790
+ * a declared, enforced, testable refusal.
8791
+ */
8792
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8592
8793
  var StorageLocationDeclarationSchema = object({
8593
8794
  /**
8594
8795
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8608,6 +8809,19 @@ var StorageLocationDeclarationSchema = object({
8608
8809
  */
8609
8810
  cardinality: _enum(["single", "multi"]),
8610
8811
  /**
8812
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8813
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8814
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8815
+ *
8816
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8817
+ * can only over-restrict (refuse a remote provider for a kind that might
8818
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8819
+ * permissive direction and is therefore never inferred — a repo guard
8820
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8821
+ * reached by omission.
8822
+ */
8823
+ access: StorageAccessSchema.optional(),
8824
+ /**
8611
8825
  * When set, the default instance for this location inherits its resolved
8612
8826
  * root from the named location's default instance. Useful for derivative
8613
8827
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -19235,8 +19449,10 @@ var TrackSchema = object({
19235
19449
  lastSeen: number(),
19236
19450
  /** Frame-rate position history (subject to maxPositionHistory cap). */
19237
19451
  positions: array(TrackPositionSchema).readonly(),
19238
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
19239
- * saveThumbnails policy). */
19452
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
19453
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
19454
+ * the retired `saveThumbnails` used to gate this and the rolling
19455
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
19240
19456
  snapshots: array(TrackSnapshotSchema).readonly(),
19241
19457
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
19242
19458
  zonesVisited: array(string()).readonly(),
@@ -20317,8 +20533,34 @@ var pipelineAnalyticsCapability = {
20317
20533
  * happens to stamp it. This count is what the migration planner's
20318
20534
  * non-blocking gate reads; `relocateMedia({ mode: 'seal' })` is what drives
20319
20535
  * it to zero.
20536
+ *
20537
+ * TWO indexed statements per collection, not a walk. It used to page the
20538
+ * whole collection at 200 rows per RPC ordered by an unindexed column, so
20539
+ * on the live hub — 1 254 576 rows — it hit the 60 s RPC deadline every
20540
+ * time it was called, and the migration it gates could never start. The
20541
+ * cheap question (`present`: is there at least one) is asked first and
20542
+ * separately from the expensive one (`rows`), because only the first has
20543
+ * to be answerable for the gate to do its job.
20544
+ *
20545
+ * **`null` is "not measurable", never zero** — at either level. An
20546
+ * unreadable collection must not read as a sealed one.
20320
20547
  */
20321
20548
  countUnstampedEventMedia: method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }),
20549
+ /**
20550
+ * How many rows a pass would STILL act on against `toLocationId`.
20551
+ *
20552
+ * One derivation, two consumers: it is the media lane's denominator (the
20553
+ * **M** the footage lane gets from the ledger census — D295) and it is the
20554
+ * residue behind "drain remaining". Deriving them separately is how "N of M"
20555
+ * ends up comparing two different populations.
20556
+ *
20557
+ * `null` means the count could not be taken; it is never zero-filled,
20558
+ * because a zero here reads as "nothing left to move".
20559
+ */
20560
+ countRelocatableMedia: method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
20561
+ kind: "query",
20562
+ auth: "admin"
20563
+ }),
20322
20564
  /** Every relocate job this addon knows about, newest first (in RAM: the
20323
20565
  * move is resumable, so a lost list costs nothing but the display). */
20324
20566
  listRelocateMediaJobs: method(object({}), array(RelocateJobSchema).readonly(), {
@@ -22534,6 +22776,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
22534
22776
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
22535
22777
  kind: "mutation",
22536
22778
  auth: "admin"
22779
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
22780
+ kind: "mutation",
22781
+ auth: "admin"
22537
22782
  });
22538
22783
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
22539
22784
  providerId: string().min(1),
@@ -22932,12 +23177,38 @@ response: record(string(), unknown()) }), object({
22932
23177
  *
22933
23178
  * ## Why this is a capability and not a helper
22934
23179
  *
22935
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
22936
- * plate, vehicle, identity, and the event store's derivatives — and every one of
22937
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
22938
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
22939
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
22940
- * load 5,000 rows before ranking anything.
23180
+ * This capability was introduced with the claim that SIX stores in
23181
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
23182
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
23183
+ * claim was never true, and leaving it here made five stores look like pending
23184
+ * work when three of them have no vector at all. Counted column by column on
23185
+ * 2026-08-30, exactly THREE ever held one:
23186
+ *
23187
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
23188
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
23189
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
23190
+ * face, migrated 2026-08-30 into its OWN index (see below).
23191
+ *
23192
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
23193
+ * and `identities` store a name; the event store stores no derivative vector.
23194
+ * They are not migration candidates and never were.
23195
+ *
23196
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
23197
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
23198
+ * rows before ranking anything.
23199
+ *
23200
+ * ## One index per COMPARISON, never per encoder
23201
+ *
23202
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
23203
+ * model, and they still get two indexes. An index is a set of things that are
23204
+ * ranked against each other and that live and die together, and these two are
23205
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
23206
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
23207
+ * forever and is the gallery every recognition ranks against. One index would
23208
+ * mean every gallery load and every reconcile carried a filter whose failure
23209
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
23210
+ * person's only sample. The dimension they share is not a reason to share an
23211
+ * index; the question they answer is, and it differs.
22941
23212
  *
22942
23213
  * The fix is not a faster loop, it is a different backend — and the backend
22943
23214
  * should be replaceable without touching six callers. So: a singleton
@@ -23042,7 +23313,20 @@ var VectorQueryResultSchema = object({
23042
23313
  */
23043
23314
  scanned: number(),
23044
23315
  /** True when the backend could not consider every row that passed the filter. */
23045
- truncated: boolean()
23316
+ truncated: boolean(),
23317
+ /**
23318
+ * The `topK` the backend actually ran with.
23319
+ *
23320
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
23321
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
23322
+ * own log rather than in its answer. That is how an audit asking for 20,000
23323
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
23324
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
23325
+ * MUCH, in the return value, where the caller cannot fail to see it.
23326
+ *
23327
+ * Equals the requested `topK` whenever nothing was lowered.
23328
+ */
23329
+ effectiveTopK: number().int().positive()
23046
23330
  });
23047
23331
  var VectorDeleteInputSchema = object({
23048
23332
  index: string(),
@@ -23071,6 +23355,68 @@ var VectorGetResultSchema = object({ items: array(object({
23071
23355
  id: string(),
23072
23356
  metadata: VectorMetadataSchema
23073
23357
  })) });
23358
+ /**
23359
+ * Ids to read back WITH their vectors.
23360
+ *
23361
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
23362
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
23363
+ * caller depends on that promise. This one promises the opposite.
23364
+ *
23365
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
23366
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
23367
+ * a per-face cross-process KNN would be a network round trip inside the
23368
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
23369
+ * it requires the index to hand the floats back. Without this method the only
23370
+ * way to keep a readable vector is a JSON column, which is the thing this
23371
+ * capability exists to delete.
23372
+ *
23373
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
23374
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
23375
+ */
23376
+ var VectorFetchInputSchema = object({
23377
+ index: string(),
23378
+ ids: array(string())
23379
+ });
23380
+ var VectorFetchResultSchema = object({ items: array(object({
23381
+ id: string(),
23382
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
23383
+ vector: string(),
23384
+ metadata: VectorMetadataSchema
23385
+ })) });
23386
+ /**
23387
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
23388
+ *
23389
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
23390
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
23391
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
23392
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
23393
+ * distance to every row is degenerate. `examined: 4096` then read as "we
23394
+ * looked" for as long as anyone cared to read it.
23395
+ *
23396
+ * This is the primitive that question actually needs: a bounded page, ordered
23397
+ * by the backend's own row order, costing no distance computation at all.
23398
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
23399
+ * the full-table read this capability was built to stop.
23400
+ */
23401
+ var VectorScanInputSchema = object({
23402
+ index: string(),
23403
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
23404
+ cursor: number().int().nonnegative().default(0),
23405
+ limit: number().int().positive()
23406
+ });
23407
+ var VectorScanResultSchema = object({
23408
+ items: array(object({
23409
+ id: string(),
23410
+ metadata: VectorMetadataSchema
23411
+ })),
23412
+ /**
23413
+ * Where the next page starts, or `null` when the walk reached the end.
23414
+ *
23415
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
23416
+ * from a short page: a backend is free to return fewer rows than asked.
23417
+ */
23418
+ nextCursor: number().int().nonnegative().nullable()
23419
+ });
23074
23420
  var VectorStatsInputSchema = object({ index: string() });
23075
23421
  var VectorStatsResultSchema = object({
23076
23422
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -23089,7 +23435,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
23089
23435
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
23090
23436
  kind: "mutation",
23091
23437
  auth: "admin"
23092
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
23438
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
23093
23439
  kind: "mutation",
23094
23440
  auth: "admin"
23095
23441
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -29782,6 +30128,9 @@ method(object({
29782
30128
  }), method(object({}), array(RelocateJobSchema).readonly(), {
29783
30129
  kind: "query",
29784
30130
  auth: "admin"
30131
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
30132
+ kind: "query",
30133
+ auth: "admin"
29785
30134
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
29786
30135
  kind: "mutation",
29787
30136
  auth: "admin"
@@ -32272,6 +32621,146 @@ function readDeviceStateFrom(runtimeState) {
32272
32621
  }
32273
32622
  }
32274
32623
  /**
32624
+ * LA tabella "quale booleano di questo tipo di device conta come ALTO", e il
32625
+ * valutatore puro del suo FRONTE.
32626
+ *
32627
+ * Viveva dentro il builtin virtual-doorbell
32628
+ * (`@camstack/system` — `builtins/doorbell/trigger-engine.ts`) e i suoi
32629
+ * predicati erano privati al modulo. Il recorder ne ha bisogno per il trigger
32630
+ * `RecordingTriggers.sensorDeviceIds`: copiarla avrebbe creato la SECONDA
32631
+ * tabella, che diverge alla prima cap aggiunta e il cui sintomo — "il sensore
32632
+ * fa suonare il campanello ma non registra" — è esattamente D62. Quindi si
32633
+ * SPOSTA qui e il doorbell la ri-esporta.
32634
+ *
32635
+ * ⚠ NON è `DEVICE_STATE_READERS` (`catalogs/device-state-vocabulary.ts`), e le
32636
+ * due non vanno unificate: quella risponde a "qual è la PAROLA di stato per una
32637
+ * regola" (e include `presence`, `cover`, `alarm-panel`), questa a "qual è il
32638
+ * booleano il cui FRONTE conta". Vocabolari deliberatamente diversi.
32639
+ */
32640
+ /**
32641
+ * Known binary / switch source caps → the boolean slice field whose
32642
+ * false→true rise counts as ACTIVE. Every entry is "fire on active".
32643
+ * Sensors whose "active" reading is not a plain boolean (presence's string
32644
+ * state, connectivity's connected flag) are deliberately excluded — a
32645
+ * reconnect is not a doorbell press, and it is not a recording either.
32646
+ */
32647
+ var SOURCE_CAP_ACTIVE_FIELD = {
32648
+ contact: "entryOpen",
32649
+ binary: "on",
32650
+ switch: "on",
32651
+ motion: "detected",
32652
+ flood: "flooded",
32653
+ gas: "detected",
32654
+ smoke: "detected",
32655
+ "carbon-monoxide": "detected",
32656
+ vibration: "detected",
32657
+ tamper: "tampered"
32658
+ };
32659
+ /**
32660
+ * The same caps → the slice field carrying the ms-epoch timestamp of the
32661
+ * last transition. Every source cap MUST appear here (guarded by a spec):
32662
+ * without a transition timestamp the evaluator cannot tell a genuine rise
32663
+ * from a boot-time hydration when the FIRST slice it ever sees is already
32664
+ * active, and errs towards silence — swallowing the rise.
32665
+ *
32666
+ * These timestamps are UPSTREAM ones, not ingest ones: the Home Assistant
32667
+ * provider derives them from `state.last_changed`, so they survive our own
32668
+ * restarts and correctly read as "hours ago" for a state that has been
32669
+ * active for hours. `motion` names its rise timestamp `lastDetectedAt`.
32670
+ */
32671
+ var SOURCE_CAP_CHANGED_AT_FIELD = {
32672
+ contact: "lastChangedAt",
32673
+ binary: "lastChangedAt",
32674
+ switch: "lastChangedAt",
32675
+ motion: "lastDetectedAt",
32676
+ flood: "lastChangedAt",
32677
+ gas: "lastChangedAt",
32678
+ smoke: "lastChangedAt",
32679
+ "carbon-monoxide": "lastChangedAt",
32680
+ vibration: "lastChangedAt",
32681
+ tamper: "lastChangedAt"
32682
+ };
32683
+ /** True when a cap is a recognised binary/switch source. */
32684
+ function isSourceCap(capName) {
32685
+ return Object.prototype.hasOwnProperty.call(SOURCE_CAP_ACTIVE_FIELD, capName);
32686
+ }
32687
+ /** Extract the "active" boolean a source cap's slice carries, or null when
32688
+ * the cap is unknown or the field is missing / non-boolean. */
32689
+ function sliceActiveValue(capName, slice) {
32690
+ const field = SOURCE_CAP_ACTIVE_FIELD[capName];
32691
+ if (field === void 0) return null;
32692
+ const raw = slice[field];
32693
+ return typeof raw === "boolean" ? raw : null;
32694
+ }
32695
+ /** Ms-epoch transition timestamp a source cap's slice carries, or null when
32696
+ * it is absent, non-numeric or the zero "never observed" sentinel. */
32697
+ function sliceChangedAt(capName, slice) {
32698
+ const field = SOURCE_CAP_CHANGED_AT_FIELD[capName];
32699
+ if (field === void 0) return null;
32700
+ const raw = slice[field];
32701
+ if (typeof raw !== "number" || !Number.isFinite(raw) || raw <= 0) return null;
32702
+ return raw;
32703
+ }
32704
+ /**
32705
+ * How recent a source's own transition timestamp must be for a FIRST
32706
+ * sighting that is already active to count as a genuine rise rather than a
32707
+ * hydration of long-standing state.
32708
+ */
32709
+ var DEFAULT_FIRST_SIGHTING_FRESHNESS_MS = 3e4;
32710
+ /**
32711
+ * IL fronte. Puro: nessun orologio proprio, nessuna memoria — il chiamante
32712
+ * porta `prior`, `nowMs` e il proprio `startedAtMs`.
32713
+ *
32714
+ * Il caso della PRIMA slice già attiva è trattato esplicitamente e vale come
32715
+ * fronte solo se il timestamp UPSTREAM della transizione è posteriore a
32716
+ * `startedAtMs` **e** entro `firstSightingFreshnessMs`. Entrambe le metà
32717
+ * servono: la sola freschezza scatterebbe su un'idratazione al boot di uno
32718
+ * stato flippato pochi secondi prima del riavvio, e il solo "dopo che abbiamo
32719
+ * iniziato" scatterebbe, su un processo di lunga vita, per una sorgente
32720
+ * adottata oggi il cui stato è cambiato ieri. Il caso ambiguo ERRA VERSO IL
32721
+ * SILENZIO e lo dichiara (`baseline-seeded-stale-active`).
32722
+ */
32723
+ function evaluateSensorEdge(input) {
32724
+ const value = sliceActiveValue(input.capName, input.slice);
32725
+ if (value === null) return {
32726
+ edge: "none",
32727
+ value: null,
32728
+ reason: isSourceCap(input.capName) ? "non-boolean-value" : "unknown-cap"
32729
+ };
32730
+ if (input.prior === void 0) {
32731
+ if (!value) return {
32732
+ edge: "none",
32733
+ value,
32734
+ reason: "baseline-seeded-inactive"
32735
+ };
32736
+ const changedAt = sliceChangedAt(input.capName, input.slice);
32737
+ const floor = Math.max(input.startedAtMs, input.nowMs - input.firstSightingFreshnessMs);
32738
+ if (changedAt === null || changedAt < floor) return {
32739
+ edge: "none",
32740
+ value,
32741
+ reason: "baseline-seeded-stale-active"
32742
+ };
32743
+ return {
32744
+ edge: "rising",
32745
+ value: true
32746
+ };
32747
+ }
32748
+ if (input.prior === value) return {
32749
+ edge: "none",
32750
+ value,
32751
+ reason: "no-change"
32752
+ };
32753
+ if (!value) return {
32754
+ edge: "none",
32755
+ value,
32756
+ reason: "falling-edge"
32757
+ };
32758
+ return {
32759
+ edge: "rising",
32760
+ value: true
32761
+ };
32762
+ }
32763
+ /**
32275
32764
  * Accessory device helpers — shared across drivers.
32276
32765
  *
32277
32766
  * Many vendor-specific drivers register accessory child devices on
@@ -36493,6 +36982,12 @@ Object.freeze({
36493
36982
  addonId: null,
36494
36983
  access: "create"
36495
36984
  },
36985
+ "pipelineAnalytics.countRelocatableMedia": {
36986
+ capName: "pipeline-analytics",
36987
+ capScope: "device",
36988
+ addonId: null,
36989
+ access: "view"
36990
+ },
36496
36991
  "pipelineAnalytics.countUnstampedEventMedia": {
36497
36992
  capName: "pipeline-analytics",
36498
36993
  capScope: "device",
@@ -37657,6 +38152,12 @@ Object.freeze({
37657
38152
  addonId: null,
37658
38153
  access: "view"
37659
38154
  },
38155
+ "recording.getRelocateResidue": {
38156
+ capName: "recording",
38157
+ capScope: "system",
38158
+ addonId: null,
38159
+ access: "view"
38160
+ },
37660
38161
  "recording.getStorageMigrationMoveStatus": {
37661
38162
  capName: "recording",
37662
38163
  capScope: "system",
@@ -38203,12 +38704,30 @@ Object.freeze({
38203
38704
  addonId: null,
38204
38705
  access: "create"
38205
38706
  },
38707
+ "storageMigration.drain": {
38708
+ capName: "storage-migration",
38709
+ capScope: "system",
38710
+ addonId: null,
38711
+ access: "create"
38712
+ },
38713
+ "storageMigration.movers": {
38714
+ capName: "storage-migration",
38715
+ capScope: "system",
38716
+ addonId: null,
38717
+ access: "view"
38718
+ },
38206
38719
  "storageMigration.plan": {
38207
38720
  capName: "storage-migration",
38208
38721
  capScope: "system",
38209
38722
  addonId: null,
38210
38723
  access: "view"
38211
38724
  },
38725
+ "storageMigration.residue": {
38726
+ capName: "storage-migration",
38727
+ capScope: "system",
38728
+ addonId: null,
38729
+ access: "view"
38730
+ },
38212
38731
  "storageMigration.start": {
38213
38732
  capName: "storage-migration",
38214
38733
  capScope: "system",
@@ -39043,6 +39562,12 @@ Object.freeze({
39043
39562
  addonId: null,
39044
39563
  access: "delete"
39045
39564
  },
39565
+ "vectorStore.fetchByIds": {
39566
+ capName: "vector-store",
39567
+ capScope: "system",
39568
+ addonId: null,
39569
+ access: "view"
39570
+ },
39046
39571
  "vectorStore.getByIds": {
39047
39572
  capName: "vector-store",
39048
39573
  capScope: "system",
@@ -39055,6 +39580,12 @@ Object.freeze({
39055
39580
  addonId: null,
39056
39581
  access: "view"
39057
39582
  },
39583
+ "vectorStore.scan": {
39584
+ capName: "vector-store",
39585
+ capScope: "system",
39586
+ addonId: null,
39587
+ access: "view"
39588
+ },
39058
39589
  "vectorStore.stats": {
39059
39590
  capName: "vector-store",
39060
39591
  capScope: "system",
@@ -42132,6 +42663,12 @@ Object.defineProperty(exports, "DEFAULT_EVENT_COLOR", {
42132
42663
  return DEFAULT_EVENT_COLOR;
42133
42664
  }
42134
42665
  });
42666
+ Object.defineProperty(exports, "DEFAULT_FIRST_SIGHTING_FRESHNESS_MS", {
42667
+ enumerable: true,
42668
+ get: function() {
42669
+ return DEFAULT_FIRST_SIGHTING_FRESHNESS_MS;
42670
+ }
42671
+ });
42135
42672
  Object.defineProperty(exports, "DEFAULT_TIMELAPSE_PREVIEW_TEXT", {
42136
42673
  enumerable: true,
42137
42674
  get: function() {
@@ -42510,6 +43047,12 @@ Object.defineProperty(exports, "errMsg", {
42510
43047
  return errMsg;
42511
43048
  }
42512
43049
  });
43050
+ Object.defineProperty(exports, "evaluateSensorEdge", {
43051
+ enumerable: true,
43052
+ get: function() {
43053
+ return evaluateSensorEdge;
43054
+ }
43055
+ });
42513
43056
  Object.defineProperty(exports, "faceGalleryCapability", {
42514
43057
  enumerable: true,
42515
43058
  get: function() {
@@ -42552,6 +43095,12 @@ Object.defineProperty(exports, "isScheduleActive", {
42552
43095
  return isScheduleActive;
42553
43096
  }
42554
43097
  });
43098
+ Object.defineProperty(exports, "isSourceCap", {
43099
+ enumerable: true,
43100
+ get: function() {
43101
+ return isSourceCap;
43102
+ }
43103
+ });
42555
43104
  Object.defineProperty(exports, "kebabToCamel", {
42556
43105
  enumerable: true,
42557
43106
  get: function() {