@camstack/addon-provider-unifi 0.2.43 → 0.2.46

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 +387 -19
  2. package/dist/addon.mjs +387 -19
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8003,6 +8003,21 @@ var RelocateJobSchema = object({
8003
8003
  bytesMoved: number().int(),
8004
8004
  /** Total files discovered up front; null while (or when) unknown. */
8005
8005
  filesTotal: number().int().nullable(),
8006
+ /**
8007
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8008
+ * made that nobody asked for, so it is reported where the operator reads the
8009
+ * job rather than only in a log line.
8010
+ *
8011
+ * A footage segment records its byte count in its own NAME, and the durable
8012
+ * hour row derives its aggregates from those names. A file that does not
8013
+ * match its name therefore makes the ledger's sums — and with them quota and
8014
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8015
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8016
+ *
8017
+ * Absent on lanes where the question has no meaning: a media blob's size is
8018
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8019
+ */
8020
+ rowsReconciled: number().int().nonnegative().optional(),
8006
8021
  startedAt: number(),
8007
8022
  finishedAt: number().nullable(),
8008
8023
  error: string().nullable()
@@ -8071,14 +8086,42 @@ var RelocateMediaInputSchema = object({
8071
8086
  /** Omitted = `move`, the pre-existing behaviour. */
8072
8087
  mode: MediaRelocateModeSchema.optional()
8073
8088
  });
8074
- /** How many rows still carry NO `locationId` — the population a repoint would
8075
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8076
- * value that permits a non-blocking `eventMedia` cutover. */
8077
- var UnstampedEventMediaCountSchema = object({
8078
- media: number().int().nonnegative(),
8079
- retrainFrames: number().int().nonnegative(),
8080
- total: number().int().nonnegative()
8089
+ /**
8090
+ * The unstamped population of ONE collection — split, because the gate and the
8091
+ * operator ask two different questions and only one of them has to be cheap.
8092
+ *
8093
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8094
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8095
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8096
+ * that matters — after a seal, when the population is empty.
8097
+ *
8098
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8099
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8100
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8101
+ * and useful answer: "there are some, and this read could not say how many"
8102
+ * still refuses the cutover, which is the whole job.
8103
+ */
8104
+ var UnstampedRowsSchema = object({
8105
+ present: boolean(),
8106
+ rows: number().int().nonnegative().nullable()
8081
8107
  });
8108
+ /**
8109
+ * How many rows still carry NO `locationId` — the population a repoint would
8110
+ * silently re-aim at a disk that does not hold their bytes.
8111
+ *
8112
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8113
+ * over. The gate opens on a measured absence and on nothing else; an unread
8114
+ * collection and an empty one are different facts, and this repo has already
8115
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8116
+ */
8117
+ var UnstampedEventMediaCountSchema = object({
8118
+ media: UnstampedRowsSchema,
8119
+ retrainFrames: UnstampedRowsSchema,
8120
+ /** True when EITHER collection holds one. The refusal reads this. */
8121
+ anyPresent: boolean(),
8122
+ /** Sum across both, or `null` when either lane could not be counted. */
8123
+ total: number().int().nonnegative().nullable()
8124
+ }).nullable();
8082
8125
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8083
8126
  /** The independently selectable logical storage classes — every class
8084
8127
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8164,13 +8207,53 @@ var StorageMigrationParticipantSchema = _enum([
8164
8207
  "recorder",
8165
8208
  "analytics"
8166
8209
  ]);
8210
+ /**
8211
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8212
+ *
8213
+ * The long half of a non-blocking migration is `draining`, and it is measured
8214
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8215
+ * existed the only place those numbers appeared was a Loki line, so an operator
8216
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8217
+ * afternoon.
8218
+ *
8219
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8220
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8221
+ * mover — which is the exact failure this is meant to end. The coordinator's
8222
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8223
+ * read `state`; folding the counters costs no extra read and makes the durable
8224
+ * record say afterwards how far a move actually got.
8225
+ *
8226
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8227
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8228
+ * cannot say M, and a 0 there would render as "100 % done".
8229
+ */
8230
+ var StorageMigrationMoveProgressSchema = object({
8231
+ filesMoved: number().int().nonnegative(),
8232
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8233
+ filesTotal: number().int().nonnegative().nullable(),
8234
+ bytesMoved: number().int().nonnegative(),
8235
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8236
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8237
+ * rows would be the same failure as one that silently skipped them. */
8238
+ rowsReconciled: number().int().nonnegative().optional(),
8239
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8240
+ * crash gets a new mover, and a rate computed from the migration's start
8241
+ * would silently average in the time nothing was running. */
8242
+ startedAt: number(),
8243
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8244
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8245
+ * subtract its own. */
8246
+ observedAt: number()
8247
+ });
8167
8248
  var StorageMigrationMoveSchema = object({
8168
8249
  storageClass: StorageMigrationClassSchema,
8169
8250
  fromLocationId: string(),
8170
8251
  toLocationId: string(),
8171
8252
  moverJobId: string().nullable(),
8172
8253
  state: RelocateJobStateSchema.nullable(),
8173
- error: string().nullable()
8254
+ error: string().nullable(),
8255
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8256
+ progress: StorageMigrationMoveProgressSchema.nullable()
8174
8257
  });
8175
8258
  var StorageMigrationJobSchema = object({
8176
8259
  jobId: string(),
@@ -8216,6 +8299,98 @@ var StorageMigrationPlanSchema = object({
8216
8299
  findings: array(StorageMigrationFindingSchema)
8217
8300
  });
8218
8301
  /**
8302
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8303
+ *
8304
+ * The coordinator's job record is the state of record for a migration, and its
8305
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8306
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8307
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8308
+ * way because no supported UI path existed. A mover armed like that has no job
8309
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8310
+ *
8311
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8312
+ * orchestrated it.
8313
+ */
8314
+ var StorageMigrationMoverSchema = object({
8315
+ lane: _enum(["footage", "media"]),
8316
+ job: RelocateJobSchema,
8317
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8318
+ * directly against the owning addon. */
8319
+ migrationJobId: string().nullable(),
8320
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8321
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8322
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8323
+ * rate made of two different clocks. */
8324
+ observedAt: number()
8325
+ });
8326
+ /**
8327
+ * What a SOURCE still holds for one storage class — the number that makes a
8328
+ * "drain remaining" action honest rather than hopeful.
8329
+ *
8330
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8331
+ * engine's own selection count for media), never from the resident index: a
8332
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8333
+ * never been told about (D295).
8334
+ *
8335
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8336
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8337
+ * because refusing on an unanswerable read would hide exactly the case an
8338
+ * operator needs to act on.
8339
+ */
8340
+ var StorageMigrationResidueSchema = object({
8341
+ storageClass: StorageMigrationClassSchema,
8342
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8343
+ * move from wherever they are rather than from one named source. */
8344
+ fromLocationId: string(),
8345
+ /** Where a drain would move it — the class's CURRENT default. */
8346
+ toLocationId: string(),
8347
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8348
+ items: number().int().nonnegative().nullable(),
8349
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8350
+ bytes: number().int().nonnegative().nullable()
8351
+ });
8352
+ /**
8353
+ * Run the DRAIN half and nothing else.
8354
+ *
8355
+ * A migration that reached `done` has already repointed, so `start` correctly
8356
+ * refuses its destination ("already the default") — there is nothing left to
8357
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8358
+ * or finish against a work list that was a tenth of the archive (D295), and
8359
+ * before this there was no supported way to run only that half: the only way
8360
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8361
+ *
8362
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8363
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8364
+ * re-repoint a class that is already migrated.
8365
+ */
8366
+ var StorageMigrationDrainInputSchema = object({
8367
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8368
+ * a class whose source is already empty is refused rather than started. */
8369
+ classes: array(StorageMigrationClassSchema).min(1),
8370
+ throttleMbps: number().min(1).max(1e3).optional()
8371
+ });
8372
+ /** What a footage source still holds, asked of the durable hour ledger. */
8373
+ var RelocateResidueInputSchema = object({
8374
+ fromLocationId: string().min(1),
8375
+ /** Narrow to one logical class; omit for every profile on the location. */
8376
+ footageClass: RelocateFootageClassSchema.optional()
8377
+ });
8378
+ /** `null` = the archive could not answer (no ledger on this node, or the
8379
+ * aggregate failed). Never conflated with an empty source. */
8380
+ var RelocateResidueSchema = object({
8381
+ segments: number().int().nonnegative(),
8382
+ bytes: number().int().nonnegative()
8383
+ }).nullable();
8384
+ /** How many rows a media pass would still act on against a given target — the
8385
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8386
+ * never disagree. `null` = the count could not be taken. */
8387
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8388
+ var RelocatableMediaCountInputSchema = object({
8389
+ toLocationId: string().min(1),
8390
+ /** Omitted = `move`. */
8391
+ mode: MediaRelocateModeSchema.optional()
8392
+ });
8393
+ /**
8219
8394
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
8220
8395
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
8221
8396
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -8319,6 +8494,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8319
8494
  * two addons declaring the same `id` must agree on `cardinality` (validated
8320
8495
  * at kernel aggregation time, not here).
8321
8496
  */
8497
+ /**
8498
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8499
+ * actually reaches the bytes. It is the constraint that decides which
8500
+ * `storage-provider`s may back a location of that kind.
8501
+ *
8502
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8503
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8504
+ * post-analysis media roots). Only a provider that serves a genuine local
8505
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8506
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8507
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8508
+ * against a same-named local directory that is something else entirely.
8509
+ *
8510
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8511
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8512
+ * service never sees a path, so any provider can back it. `backups` is the
8513
+ * one kind that qualifies today.
8514
+ *
8515
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8516
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8517
+ * refused the configuration; the first write simply went somewhere wrong, and
8518
+ * a recording write that goes wrong surfaces as a silent black window rather
8519
+ * than an error (the read path does not `stat`). This turns that accident into
8520
+ * a declared, enforced, testable refusal.
8521
+ */
8522
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8322
8523
  var StorageLocationDeclarationSchema = object({
8323
8524
  /**
8324
8525
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8338,6 +8539,19 @@ var StorageLocationDeclarationSchema = object({
8338
8539
  */
8339
8540
  cardinality: _enum(["single", "multi"]),
8340
8541
  /**
8542
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8543
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8544
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8545
+ *
8546
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8547
+ * can only over-restrict (refuse a remote provider for a kind that might
8548
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8549
+ * permissive direction and is therefore never inferred — a repo guard
8550
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8551
+ * reached by omission.
8552
+ */
8553
+ access: StorageAccessSchema.optional(),
8554
+ /**
8341
8555
  * When set, the default instance for this location inherits its resolved
8342
8556
  * root from the named location's default instance. Useful for derivative
8343
8557
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18205,8 +18419,10 @@ var TrackSchema = object({
18205
18419
  lastSeen: number(),
18206
18420
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18207
18421
  positions: array(TrackPositionSchema).readonly(),
18208
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18209
- * saveThumbnails policy). */
18422
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18423
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18424
+ * the retired `saveThumbnails` used to gate this and the rolling
18425
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18210
18426
  snapshots: array(TrackSnapshotSchema).readonly(),
18211
18427
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18212
18428
  zonesVisited: array(string()).readonly(),
@@ -19066,7 +19282,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19066
19282
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19067
19283
  kind: "mutation",
19068
19284
  auth: "admin"
19069
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(object({}), array(RelocateJobSchema).readonly(), {
19285
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19286
+ kind: "query",
19287
+ auth: "admin"
19288
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19070
19289
  kind: "query",
19071
19290
  auth: "admin"
19072
19291
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
@@ -21025,6 +21244,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21025
21244
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21026
21245
  kind: "mutation",
21027
21246
  auth: "admin"
21247
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21248
+ kind: "mutation",
21249
+ auth: "admin"
21028
21250
  });
21029
21251
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21030
21252
  providerId: string().min(1),
@@ -21423,12 +21645,38 @@ response: record(string(), unknown()) }), object({
21423
21645
  *
21424
21646
  * ## Why this is a capability and not a helper
21425
21647
  *
21426
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21427
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21428
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21429
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21430
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21431
- * load 5,000 rows before ranking anything.
21648
+ * This capability was introduced with the claim that SIX stores in
21649
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21650
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21651
+ * claim was never true, and leaving it here made five stores look like pending
21652
+ * work when three of them have no vector at all. Counted column by column on
21653
+ * 2026-08-30, exactly THREE ever held one:
21654
+ *
21655
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21656
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21657
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21658
+ * face, migrated 2026-08-30 into its OWN index (see below).
21659
+ *
21660
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21661
+ * and `identities` store a name; the event store stores no derivative vector.
21662
+ * They are not migration candidates and never were.
21663
+ *
21664
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21665
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21666
+ * rows before ranking anything.
21667
+ *
21668
+ * ## One index per COMPARISON, never per encoder
21669
+ *
21670
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21671
+ * model, and they still get two indexes. An index is a set of things that are
21672
+ * ranked against each other and that live and die together, and these two are
21673
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21674
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21675
+ * forever and is the gallery every recognition ranks against. One index would
21676
+ * mean every gallery load and every reconcile carried a filter whose failure
21677
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21678
+ * person's only sample. The dimension they share is not a reason to share an
21679
+ * index; the question they answer is, and it differs.
21432
21680
  *
21433
21681
  * The fix is not a faster loop, it is a different backend — and the backend
21434
21682
  * should be replaceable without touching six callers. So: a singleton
@@ -21533,7 +21781,20 @@ var VectorQueryResultSchema = object({
21533
21781
  */
21534
21782
  scanned: number(),
21535
21783
  /** True when the backend could not consider every row that passed the filter. */
21536
- truncated: boolean()
21784
+ truncated: boolean(),
21785
+ /**
21786
+ * The `topK` the backend actually ran with.
21787
+ *
21788
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21789
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21790
+ * own log rather than in its answer. That is how an audit asking for 20,000
21791
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21792
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21793
+ * MUCH, in the return value, where the caller cannot fail to see it.
21794
+ *
21795
+ * Equals the requested `topK` whenever nothing was lowered.
21796
+ */
21797
+ effectiveTopK: number().int().positive()
21537
21798
  });
21538
21799
  var VectorDeleteInputSchema = object({
21539
21800
  index: string(),
@@ -21562,6 +21823,68 @@ var VectorGetResultSchema = object({ items: array(object({
21562
21823
  id: string(),
21563
21824
  metadata: VectorMetadataSchema
21564
21825
  })) });
21826
+ /**
21827
+ * Ids to read back WITH their vectors.
21828
+ *
21829
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21830
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21831
+ * caller depends on that promise. This one promises the opposite.
21832
+ *
21833
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21834
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21835
+ * a per-face cross-process KNN would be a network round trip inside the
21836
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21837
+ * it requires the index to hand the floats back. Without this method the only
21838
+ * way to keep a readable vector is a JSON column, which is the thing this
21839
+ * capability exists to delete.
21840
+ *
21841
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21842
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21843
+ */
21844
+ var VectorFetchInputSchema = object({
21845
+ index: string(),
21846
+ ids: array(string())
21847
+ });
21848
+ var VectorFetchResultSchema = object({ items: array(object({
21849
+ id: string(),
21850
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21851
+ vector: string(),
21852
+ metadata: VectorMetadataSchema
21853
+ })) });
21854
+ /**
21855
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21856
+ *
21857
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21858
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21859
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21860
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21861
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21862
+ * looked" for as long as anyone cared to read it.
21863
+ *
21864
+ * This is the primitive that question actually needs: a bounded page, ordered
21865
+ * by the backend's own row order, costing no distance computation at all.
21866
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21867
+ * the full-table read this capability was built to stop.
21868
+ */
21869
+ var VectorScanInputSchema = object({
21870
+ index: string(),
21871
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21872
+ cursor: number().int().nonnegative().default(0),
21873
+ limit: number().int().positive()
21874
+ });
21875
+ var VectorScanResultSchema = object({
21876
+ items: array(object({
21877
+ id: string(),
21878
+ metadata: VectorMetadataSchema
21879
+ })),
21880
+ /**
21881
+ * Where the next page starts, or `null` when the walk reached the end.
21882
+ *
21883
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21884
+ * from a short page: a backend is free to return fewer rows than asked.
21885
+ */
21886
+ nextCursor: number().int().nonnegative().nullable()
21887
+ });
21565
21888
  var VectorStatsInputSchema = object({ index: string() });
21566
21889
  var VectorStatsResultSchema = object({
21567
21890
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21580,7 +21903,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21580
21903
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21581
21904
  kind: "mutation",
21582
21905
  auth: "admin"
21583
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21906
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21584
21907
  kind: "mutation",
21585
21908
  auth: "admin"
21586
21909
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28216,6 +28539,9 @@ method(object({
28216
28539
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28217
28540
  kind: "query",
28218
28541
  auth: "admin"
28542
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28543
+ kind: "query",
28544
+ auth: "admin"
28219
28545
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28220
28546
  kind: "mutation",
28221
28547
  auth: "admin"
@@ -34850,6 +35176,12 @@ Object.freeze({
34850
35176
  addonId: null,
34851
35177
  access: "create"
34852
35178
  },
35179
+ "pipelineAnalytics.countRelocatableMedia": {
35180
+ capName: "pipeline-analytics",
35181
+ capScope: "device",
35182
+ addonId: null,
35183
+ access: "view"
35184
+ },
34853
35185
  "pipelineAnalytics.countUnstampedEventMedia": {
34854
35186
  capName: "pipeline-analytics",
34855
35187
  capScope: "device",
@@ -36014,6 +36346,12 @@ Object.freeze({
36014
36346
  addonId: null,
36015
36347
  access: "view"
36016
36348
  },
36349
+ "recording.getRelocateResidue": {
36350
+ capName: "recording",
36351
+ capScope: "system",
36352
+ addonId: null,
36353
+ access: "view"
36354
+ },
36017
36355
  "recording.getStorageMigrationMoveStatus": {
36018
36356
  capName: "recording",
36019
36357
  capScope: "system",
@@ -36560,12 +36898,30 @@ Object.freeze({
36560
36898
  addonId: null,
36561
36899
  access: "create"
36562
36900
  },
36901
+ "storageMigration.drain": {
36902
+ capName: "storage-migration",
36903
+ capScope: "system",
36904
+ addonId: null,
36905
+ access: "create"
36906
+ },
36907
+ "storageMigration.movers": {
36908
+ capName: "storage-migration",
36909
+ capScope: "system",
36910
+ addonId: null,
36911
+ access: "view"
36912
+ },
36563
36913
  "storageMigration.plan": {
36564
36914
  capName: "storage-migration",
36565
36915
  capScope: "system",
36566
36916
  addonId: null,
36567
36917
  access: "view"
36568
36918
  },
36919
+ "storageMigration.residue": {
36920
+ capName: "storage-migration",
36921
+ capScope: "system",
36922
+ addonId: null,
36923
+ access: "view"
36924
+ },
36569
36925
  "storageMigration.start": {
36570
36926
  capName: "storage-migration",
36571
36927
  capScope: "system",
@@ -37400,6 +37756,12 @@ Object.freeze({
37400
37756
  addonId: null,
37401
37757
  access: "delete"
37402
37758
  },
37759
+ "vectorStore.fetchByIds": {
37760
+ capName: "vector-store",
37761
+ capScope: "system",
37762
+ addonId: null,
37763
+ access: "view"
37764
+ },
37403
37765
  "vectorStore.getByIds": {
37404
37766
  capName: "vector-store",
37405
37767
  capScope: "system",
@@ -37412,6 +37774,12 @@ Object.freeze({
37412
37774
  addonId: null,
37413
37775
  access: "view"
37414
37776
  },
37777
+ "vectorStore.scan": {
37778
+ capName: "vector-store",
37779
+ capScope: "system",
37780
+ addonId: null,
37781
+ access: "view"
37782
+ },
37415
37783
  "vectorStore.stats": {
37416
37784
  capName: "vector-store",
37417
37785
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8002,6 +8002,21 @@ var RelocateJobSchema = object({
8002
8002
  bytesMoved: number().int(),
8003
8003
  /** Total files discovered up front; null while (or when) unknown. */
8004
8004
  filesTotal: number().int().nullable(),
8005
+ /**
8006
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8007
+ * made that nobody asked for, so it is reported where the operator reads the
8008
+ * job rather than only in a log line.
8009
+ *
8010
+ * A footage segment records its byte count in its own NAME, and the durable
8011
+ * hour row derives its aggregates from those names. A file that does not
8012
+ * match its name therefore makes the ledger's sums — and with them quota and
8013
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8014
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8015
+ *
8016
+ * Absent on lanes where the question has no meaning: a media blob's size is
8017
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8018
+ */
8019
+ rowsReconciled: number().int().nonnegative().optional(),
8005
8020
  startedAt: number(),
8006
8021
  finishedAt: number().nullable(),
8007
8022
  error: string().nullable()
@@ -8070,14 +8085,42 @@ var RelocateMediaInputSchema = object({
8070
8085
  /** Omitted = `move`, the pre-existing behaviour. */
8071
8086
  mode: MediaRelocateModeSchema.optional()
8072
8087
  });
8073
- /** How many rows still carry NO `locationId` — the population a repoint would
8074
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8075
- * value that permits a non-blocking `eventMedia` cutover. */
8076
- var UnstampedEventMediaCountSchema = object({
8077
- media: number().int().nonnegative(),
8078
- retrainFrames: number().int().nonnegative(),
8079
- total: number().int().nonnegative()
8088
+ /**
8089
+ * The unstamped population of ONE collection — split, because the gate and the
8090
+ * operator ask two different questions and only one of them has to be cheap.
8091
+ *
8092
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8093
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8094
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8095
+ * that matters — after a seal, when the population is empty.
8096
+ *
8097
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8098
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8099
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8100
+ * and useful answer: "there are some, and this read could not say how many"
8101
+ * still refuses the cutover, which is the whole job.
8102
+ */
8103
+ var UnstampedRowsSchema = object({
8104
+ present: boolean(),
8105
+ rows: number().int().nonnegative().nullable()
8080
8106
  });
8107
+ /**
8108
+ * How many rows still carry NO `locationId` — the population a repoint would
8109
+ * silently re-aim at a disk that does not hold their bytes.
8110
+ *
8111
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8112
+ * over. The gate opens on a measured absence and on nothing else; an unread
8113
+ * collection and an empty one are different facts, and this repo has already
8114
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8115
+ */
8116
+ var UnstampedEventMediaCountSchema = object({
8117
+ media: UnstampedRowsSchema,
8118
+ retrainFrames: UnstampedRowsSchema,
8119
+ /** True when EITHER collection holds one. The refusal reads this. */
8120
+ anyPresent: boolean(),
8121
+ /** Sum across both, or `null` when either lane could not be counted. */
8122
+ total: number().int().nonnegative().nullable()
8123
+ }).nullable();
8081
8124
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8082
8125
  /** The independently selectable logical storage classes — every class
8083
8126
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8163,13 +8206,53 @@ var StorageMigrationParticipantSchema = _enum([
8163
8206
  "recorder",
8164
8207
  "analytics"
8165
8208
  ]);
8209
+ /**
8210
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8211
+ *
8212
+ * The long half of a non-blocking migration is `draining`, and it is measured
8213
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8214
+ * existed the only place those numbers appeared was a Loki line, so an operator
8215
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8216
+ * afternoon.
8217
+ *
8218
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8219
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8220
+ * mover — which is the exact failure this is meant to end. The coordinator's
8221
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8222
+ * read `state`; folding the counters costs no extra read and makes the durable
8223
+ * record say afterwards how far a move actually got.
8224
+ *
8225
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8226
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8227
+ * cannot say M, and a 0 there would render as "100 % done".
8228
+ */
8229
+ var StorageMigrationMoveProgressSchema = object({
8230
+ filesMoved: number().int().nonnegative(),
8231
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8232
+ filesTotal: number().int().nonnegative().nullable(),
8233
+ bytesMoved: number().int().nonnegative(),
8234
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8235
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8236
+ * rows would be the same failure as one that silently skipped them. */
8237
+ rowsReconciled: number().int().nonnegative().optional(),
8238
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8239
+ * crash gets a new mover, and a rate computed from the migration's start
8240
+ * would silently average in the time nothing was running. */
8241
+ startedAt: number(),
8242
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8243
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8244
+ * subtract its own. */
8245
+ observedAt: number()
8246
+ });
8166
8247
  var StorageMigrationMoveSchema = object({
8167
8248
  storageClass: StorageMigrationClassSchema,
8168
8249
  fromLocationId: string(),
8169
8250
  toLocationId: string(),
8170
8251
  moverJobId: string().nullable(),
8171
8252
  state: RelocateJobStateSchema.nullable(),
8172
- error: string().nullable()
8253
+ error: string().nullable(),
8254
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8255
+ progress: StorageMigrationMoveProgressSchema.nullable()
8173
8256
  });
8174
8257
  var StorageMigrationJobSchema = object({
8175
8258
  jobId: string(),
@@ -8215,6 +8298,98 @@ var StorageMigrationPlanSchema = object({
8215
8298
  findings: array(StorageMigrationFindingSchema)
8216
8299
  });
8217
8300
  /**
8301
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8302
+ *
8303
+ * The coordinator's job record is the state of record for a migration, and its
8304
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8305
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8306
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8307
+ * way because no supported UI path existed. A mover armed like that has no job
8308
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8309
+ *
8310
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8311
+ * orchestrated it.
8312
+ */
8313
+ var StorageMigrationMoverSchema = object({
8314
+ lane: _enum(["footage", "media"]),
8315
+ job: RelocateJobSchema,
8316
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8317
+ * directly against the owning addon. */
8318
+ migrationJobId: string().nullable(),
8319
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8320
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8321
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8322
+ * rate made of two different clocks. */
8323
+ observedAt: number()
8324
+ });
8325
+ /**
8326
+ * What a SOURCE still holds for one storage class — the number that makes a
8327
+ * "drain remaining" action honest rather than hopeful.
8328
+ *
8329
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8330
+ * engine's own selection count for media), never from the resident index: a
8331
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8332
+ * never been told about (D295).
8333
+ *
8334
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8335
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8336
+ * because refusing on an unanswerable read would hide exactly the case an
8337
+ * operator needs to act on.
8338
+ */
8339
+ var StorageMigrationResidueSchema = object({
8340
+ storageClass: StorageMigrationClassSchema,
8341
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8342
+ * move from wherever they are rather than from one named source. */
8343
+ fromLocationId: string(),
8344
+ /** Where a drain would move it — the class's CURRENT default. */
8345
+ toLocationId: string(),
8346
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8347
+ items: number().int().nonnegative().nullable(),
8348
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8349
+ bytes: number().int().nonnegative().nullable()
8350
+ });
8351
+ /**
8352
+ * Run the DRAIN half and nothing else.
8353
+ *
8354
+ * A migration that reached `done` has already repointed, so `start` correctly
8355
+ * refuses its destination ("already the default") — there is nothing left to
8356
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8357
+ * or finish against a work list that was a tenth of the archive (D295), and
8358
+ * before this there was no supported way to run only that half: the only way
8359
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8360
+ *
8361
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8362
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8363
+ * re-repoint a class that is already migrated.
8364
+ */
8365
+ var StorageMigrationDrainInputSchema = object({
8366
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8367
+ * a class whose source is already empty is refused rather than started. */
8368
+ classes: array(StorageMigrationClassSchema).min(1),
8369
+ throttleMbps: number().min(1).max(1e3).optional()
8370
+ });
8371
+ /** What a footage source still holds, asked of the durable hour ledger. */
8372
+ var RelocateResidueInputSchema = object({
8373
+ fromLocationId: string().min(1),
8374
+ /** Narrow to one logical class; omit for every profile on the location. */
8375
+ footageClass: RelocateFootageClassSchema.optional()
8376
+ });
8377
+ /** `null` = the archive could not answer (no ledger on this node, or the
8378
+ * aggregate failed). Never conflated with an empty source. */
8379
+ var RelocateResidueSchema = object({
8380
+ segments: number().int().nonnegative(),
8381
+ bytes: number().int().nonnegative()
8382
+ }).nullable();
8383
+ /** How many rows a media pass would still act on against a given target — the
8384
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8385
+ * never disagree. `null` = the count could not be taken. */
8386
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8387
+ var RelocatableMediaCountInputSchema = object({
8388
+ toLocationId: string().min(1),
8389
+ /** Omitted = `move`. */
8390
+ mode: MediaRelocateModeSchema.optional()
8391
+ });
8392
+ /**
8218
8393
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
8219
8394
  * storage a location serves. Defined here (not in `capabilities/storage.cap.ts`)
8220
8395
  * so the persisted record schema and the consumer-facing cap can both consume it
@@ -8318,6 +8493,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8318
8493
  * two addons declaring the same `id` must agree on `cardinality` (validated
8319
8494
  * at kernel aggregation time, not here).
8320
8495
  */
8496
+ /**
8497
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8498
+ * actually reaches the bytes. It is the constraint that decides which
8499
+ * `storage-provider`s may back a location of that kind.
8500
+ *
8501
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8502
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8503
+ * post-analysis media roots). Only a provider that serves a genuine local
8504
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8505
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8506
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8507
+ * against a same-named local directory that is something else entirely.
8508
+ *
8509
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8510
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8511
+ * service never sees a path, so any provider can back it. `backups` is the
8512
+ * one kind that qualifies today.
8513
+ *
8514
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8515
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8516
+ * refused the configuration; the first write simply went somewhere wrong, and
8517
+ * a recording write that goes wrong surfaces as a silent black window rather
8518
+ * than an error (the read path does not `stat`). This turns that accident into
8519
+ * a declared, enforced, testable refusal.
8520
+ */
8521
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8321
8522
  var StorageLocationDeclarationSchema = object({
8322
8523
  /**
8323
8524
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8337,6 +8538,19 @@ var StorageLocationDeclarationSchema = object({
8337
8538
  */
8338
8539
  cardinality: _enum(["single", "multi"]),
8339
8540
  /**
8541
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8542
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8543
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8544
+ *
8545
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8546
+ * can only over-restrict (refuse a remote provider for a kind that might
8547
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8548
+ * permissive direction and is therefore never inferred — a repo guard
8549
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8550
+ * reached by omission.
8551
+ */
8552
+ access: StorageAccessSchema.optional(),
8553
+ /**
8340
8554
  * When set, the default instance for this location inherits its resolved
8341
8555
  * root from the named location's default instance. Useful for derivative
8342
8556
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18204,8 +18418,10 @@ var TrackSchema = object({
18204
18418
  lastSeen: number(),
18205
18419
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18206
18420
  positions: array(TrackPositionSchema).readonly(),
18207
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18208
- * saveThumbnails policy). */
18421
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18422
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18423
+ * the retired `saveThumbnails` used to gate this and the rolling
18424
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18209
18425
  snapshots: array(TrackSnapshotSchema).readonly(),
18210
18426
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18211
18427
  zonesVisited: array(string()).readonly(),
@@ -19065,7 +19281,10 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19065
19281
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19066
19282
  kind: "mutation",
19067
19283
  auth: "admin"
19068
- }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(object({}), array(RelocateJobSchema).readonly(), {
19284
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19285
+ kind: "query",
19286
+ auth: "admin"
19287
+ }), method(object({}), array(RelocateJobSchema).readonly(), {
19069
19288
  kind: "query",
19070
19289
  auth: "admin"
19071
19290
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
@@ -21024,6 +21243,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21024
21243
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21025
21244
  kind: "mutation",
21026
21245
  auth: "admin"
21246
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21247
+ kind: "mutation",
21248
+ auth: "admin"
21027
21249
  });
21028
21250
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21029
21251
  providerId: string().min(1),
@@ -21422,12 +21644,38 @@ response: record(string(), unknown()) }), object({
21422
21644
  *
21423
21645
  * ## Why this is a capability and not a helper
21424
21646
  *
21425
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21426
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21427
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21428
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21429
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21430
- * load 5,000 rows before ranking anything.
21647
+ * This capability was introduced with the claim that SIX stores in
21648
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21649
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21650
+ * claim was never true, and leaving it here made five stores look like pending
21651
+ * work when three of them have no vector at all. Counted column by column on
21652
+ * 2026-08-30, exactly THREE ever held one:
21653
+ *
21654
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21655
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21656
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21657
+ * face, migrated 2026-08-30 into its OWN index (see below).
21658
+ *
21659
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21660
+ * and `identities` store a name; the event store stores no derivative vector.
21661
+ * They are not migration candidates and never were.
21662
+ *
21663
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21664
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21665
+ * rows before ranking anything.
21666
+ *
21667
+ * ## One index per COMPARISON, never per encoder
21668
+ *
21669
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21670
+ * model, and they still get two indexes. An index is a set of things that are
21671
+ * ranked against each other and that live and die together, and these two are
21672
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21673
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21674
+ * forever and is the gallery every recognition ranks against. One index would
21675
+ * mean every gallery load and every reconcile carried a filter whose failure
21676
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21677
+ * person's only sample. The dimension they share is not a reason to share an
21678
+ * index; the question they answer is, and it differs.
21431
21679
  *
21432
21680
  * The fix is not a faster loop, it is a different backend — and the backend
21433
21681
  * should be replaceable without touching six callers. So: a singleton
@@ -21532,7 +21780,20 @@ var VectorQueryResultSchema = object({
21532
21780
  */
21533
21781
  scanned: number(),
21534
21782
  /** True when the backend could not consider every row that passed the filter. */
21535
- truncated: boolean()
21783
+ truncated: boolean(),
21784
+ /**
21785
+ * The `topK` the backend actually ran with.
21786
+ *
21787
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21788
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21789
+ * own log rather than in its answer. That is how an audit asking for 20,000
21790
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21791
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21792
+ * MUCH, in the return value, where the caller cannot fail to see it.
21793
+ *
21794
+ * Equals the requested `topK` whenever nothing was lowered.
21795
+ */
21796
+ effectiveTopK: number().int().positive()
21536
21797
  });
21537
21798
  var VectorDeleteInputSchema = object({
21538
21799
  index: string(),
@@ -21561,6 +21822,68 @@ var VectorGetResultSchema = object({ items: array(object({
21561
21822
  id: string(),
21562
21823
  metadata: VectorMetadataSchema
21563
21824
  })) });
21825
+ /**
21826
+ * Ids to read back WITH their vectors.
21827
+ *
21828
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21829
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21830
+ * caller depends on that promise. This one promises the opposite.
21831
+ *
21832
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21833
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21834
+ * a per-face cross-process KNN would be a network round trip inside the
21835
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21836
+ * it requires the index to hand the floats back. Without this method the only
21837
+ * way to keep a readable vector is a JSON column, which is the thing this
21838
+ * capability exists to delete.
21839
+ *
21840
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21841
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21842
+ */
21843
+ var VectorFetchInputSchema = object({
21844
+ index: string(),
21845
+ ids: array(string())
21846
+ });
21847
+ var VectorFetchResultSchema = object({ items: array(object({
21848
+ id: string(),
21849
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21850
+ vector: string(),
21851
+ metadata: VectorMetadataSchema
21852
+ })) });
21853
+ /**
21854
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21855
+ *
21856
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21857
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21858
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21859
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21860
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21861
+ * looked" for as long as anyone cared to read it.
21862
+ *
21863
+ * This is the primitive that question actually needs: a bounded page, ordered
21864
+ * by the backend's own row order, costing no distance computation at all.
21865
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21866
+ * the full-table read this capability was built to stop.
21867
+ */
21868
+ var VectorScanInputSchema = object({
21869
+ index: string(),
21870
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21871
+ cursor: number().int().nonnegative().default(0),
21872
+ limit: number().int().positive()
21873
+ });
21874
+ var VectorScanResultSchema = object({
21875
+ items: array(object({
21876
+ id: string(),
21877
+ metadata: VectorMetadataSchema
21878
+ })),
21879
+ /**
21880
+ * Where the next page starts, or `null` when the walk reached the end.
21881
+ *
21882
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21883
+ * from a short page: a backend is free to return fewer rows than asked.
21884
+ */
21885
+ nextCursor: number().int().nonnegative().nullable()
21886
+ });
21564
21887
  var VectorStatsInputSchema = object({ index: string() });
21565
21888
  var VectorStatsResultSchema = object({
21566
21889
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21579,7 +21902,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21579
21902
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21580
21903
  kind: "mutation",
21581
21904
  auth: "admin"
21582
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21905
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21583
21906
  kind: "mutation",
21584
21907
  auth: "admin"
21585
21908
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28215,6 +28538,9 @@ method(object({
28215
28538
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28216
28539
  kind: "query",
28217
28540
  auth: "admin"
28541
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28542
+ kind: "query",
28543
+ auth: "admin"
28218
28544
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28219
28545
  kind: "mutation",
28220
28546
  auth: "admin"
@@ -34849,6 +35175,12 @@ Object.freeze({
34849
35175
  addonId: null,
34850
35176
  access: "create"
34851
35177
  },
35178
+ "pipelineAnalytics.countRelocatableMedia": {
35179
+ capName: "pipeline-analytics",
35180
+ capScope: "device",
35181
+ addonId: null,
35182
+ access: "view"
35183
+ },
34852
35184
  "pipelineAnalytics.countUnstampedEventMedia": {
34853
35185
  capName: "pipeline-analytics",
34854
35186
  capScope: "device",
@@ -36013,6 +36345,12 @@ Object.freeze({
36013
36345
  addonId: null,
36014
36346
  access: "view"
36015
36347
  },
36348
+ "recording.getRelocateResidue": {
36349
+ capName: "recording",
36350
+ capScope: "system",
36351
+ addonId: null,
36352
+ access: "view"
36353
+ },
36016
36354
  "recording.getStorageMigrationMoveStatus": {
36017
36355
  capName: "recording",
36018
36356
  capScope: "system",
@@ -36559,12 +36897,30 @@ Object.freeze({
36559
36897
  addonId: null,
36560
36898
  access: "create"
36561
36899
  },
36900
+ "storageMigration.drain": {
36901
+ capName: "storage-migration",
36902
+ capScope: "system",
36903
+ addonId: null,
36904
+ access: "create"
36905
+ },
36906
+ "storageMigration.movers": {
36907
+ capName: "storage-migration",
36908
+ capScope: "system",
36909
+ addonId: null,
36910
+ access: "view"
36911
+ },
36562
36912
  "storageMigration.plan": {
36563
36913
  capName: "storage-migration",
36564
36914
  capScope: "system",
36565
36915
  addonId: null,
36566
36916
  access: "view"
36567
36917
  },
36918
+ "storageMigration.residue": {
36919
+ capName: "storage-migration",
36920
+ capScope: "system",
36921
+ addonId: null,
36922
+ access: "view"
36923
+ },
36568
36924
  "storageMigration.start": {
36569
36925
  capName: "storage-migration",
36570
36926
  capScope: "system",
@@ -37399,6 +37755,12 @@ Object.freeze({
37399
37755
  addonId: null,
37400
37756
  access: "delete"
37401
37757
  },
37758
+ "vectorStore.fetchByIds": {
37759
+ capName: "vector-store",
37760
+ capScope: "system",
37761
+ addonId: null,
37762
+ access: "view"
37763
+ },
37402
37764
  "vectorStore.getByIds": {
37403
37765
  capName: "vector-store",
37404
37766
  capScope: "system",
@@ -37411,6 +37773,12 @@ Object.freeze({
37411
37773
  addonId: null,
37412
37774
  access: "view"
37413
37775
  },
37776
+ "vectorStore.scan": {
37777
+ capName: "vector-store",
37778
+ capScope: "system",
37779
+ addonId: null,
37780
+ access: "view"
37781
+ },
37414
37782
  "vectorStore.stats": {
37415
37783
  capName: "vector-store",
37416
37784
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-unifi",
3
- "version": "0.2.43",
3
+ "version": "0.2.46",
4
4
  "description": "UniFi Network controller device-provider addon for CamStack — local-controller infra switches/APs (as containers) + network-client presence. NO cameras/Protect.",
5
5
  "keywords": [
6
6
  "camstack",