@camstack/addon-provider-unifi 0.2.42 → 0.2.45

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 +452 -23
  2. package/dist/addon.mjs +452 -23
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8039,18 +8039,61 @@ var RelocateFootageInputSchema = object({
8039
8039
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8040
8040
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8041
8041
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8042
+ /**
8043
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8044
+ * mover (the engine already walks both collections with a timestamp cursor and
8045
+ * already has a stamp-without-copy path).
8046
+ *
8047
+ * - `move` — the default and the historical behaviour: event-media and
8048
+ * retrain blobs move to `toLocationId` and their rows are
8049
+ * stamped. The enrolled gallery is skipped (D197).
8050
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8051
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8052
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8053
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8054
+ * instant a repoint moves that pointer the row reads from the
8055
+ * new disk while its bytes are on the old one.
8056
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8057
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8058
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8059
+ * never run beside a live second location: it is stop-the-world
8060
+ * by construction, which is acceptable only because the gallery
8061
+ * is a few KB per enrolled sample.
8062
+ */
8063
+ var MediaRelocateModeSchema = _enum([
8064
+ "move",
8065
+ "seal",
8066
+ "gallery"
8067
+ ]);
8042
8068
  var RelocateMediaInputSchema = object({
8043
8069
  toLocationId: string(),
8044
- throttleMbps: number().min(1).max(1e3).optional()
8070
+ throttleMbps: number().min(1).max(1e3).optional(),
8071
+ /** Omitted = `move`, the pre-existing behaviour. */
8072
+ mode: MediaRelocateModeSchema.optional()
8073
+ });
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()
8045
8081
  });
8046
8082
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8047
- /** The independently selectable logical storage classes. `recordings`
8048
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8049
- * segments; `eventMedia` is post-analysis blobs. */
8083
+ /** The independently selectable logical storage classes — every class
8084
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8085
+ * Zod enum error where they should meet an explanation.
8086
+ *
8087
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8088
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8089
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8090
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8050
8091
  var StorageMigrationClassSchema = _enum([
8051
8092
  "recordings",
8052
8093
  "recordingsLow",
8053
- "eventMedia"
8094
+ "eventMedia",
8095
+ "backups",
8096
+ "galleryMedia"
8054
8097
  ]);
8055
8098
  /** A destination is always an existing, fully-qualified location id. The
8056
8099
  * migration API intentionally never changes a source location's `basePath`:
@@ -8058,20 +8101,56 @@ var StorageMigrationClassSchema = _enum([
8058
8101
  var StorageMigrationDestinationsSchema = object({
8059
8102
  recordings: string().min(1).optional(),
8060
8103
  recordingsLow: string().min(1).optional(),
8061
- eventMedia: string().min(1).optional()
8104
+ eventMedia: string().min(1).optional(),
8105
+ backups: string().min(1).optional(),
8106
+ galleryMedia: string().min(1).optional()
8062
8107
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8108
+ /**
8109
+ * How a migration sequences the cutover against the byte move.
8110
+ *
8111
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8112
+ * resume. Recording is stopped for the whole move. Right
8113
+ * for a small or a cold class, and the only legal mode for
8114
+ * a `cardinality: 'single'` class.
8115
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8116
+ * refresh, resume, then move the past with everything
8117
+ * running. The pause is three bounded instants (a detach +
8118
+ * attach round, a write-gate drain, a lease) instead of one
8119
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8120
+ * stopped recording under `blocking`; the same move is
8121
+ * seconds of stopped recording under `nonBlocking`.
8122
+ *
8123
+ * The mode is on the JOB, not only on the input, because `status` is where an
8124
+ * operator finds out which one is running.
8125
+ */
8126
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8063
8127
  /** Shared input for planning and starting an orchestrated storage migration. */
8064
8128
  var StorageMigrationInputSchema = object({
8065
8129
  destinations: StorageMigrationDestinationsSchema,
8066
- throttleMbps: number().min(1).max(1e3).optional()
8130
+ throttleMbps: number().min(1).max(1e3).optional(),
8131
+ /** Omitted = `blocking`, which stays the default. */
8132
+ mode: StorageMigrationModeSchema.optional()
8067
8133
  });
8068
- /** The durable coordinator state machine. The only phase that changes default
8069
- * locations is `repointing`, after every selected mover has completed and been
8070
- * verified. */
8134
+ /**
8135
+ * The durable coordinator state machine.
8136
+ *
8137
+ * `blocking`:
8138
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8139
+ *
8140
+ * `nonBlocking`:
8141
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8142
+ *
8143
+ * Same phases, different order plus two new ones — not a second mover.
8144
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8145
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8146
+ * `repointing` is still the only phase that changes a default location.
8147
+ */
8071
8148
  var StorageMigrationPhaseSchema = _enum([
8072
8149
  "planning",
8150
+ "sealing",
8073
8151
  "pausing",
8074
8152
  "moving",
8153
+ "draining",
8075
8154
  "verifying",
8076
8155
  "repointing",
8077
8156
  "refreshing",
@@ -8085,17 +8164,56 @@ var StorageMigrationParticipantSchema = _enum([
8085
8164
  "recorder",
8086
8165
  "analytics"
8087
8166
  ]);
8167
+ /**
8168
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8169
+ *
8170
+ * The long half of a non-blocking migration is `draining`, and it is measured
8171
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8172
+ * existed the only place those numbers appeared was a Loki line, so an operator
8173
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8174
+ * afternoon.
8175
+ *
8176
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8177
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8178
+ * mover — which is the exact failure this is meant to end. The coordinator's
8179
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8180
+ * read `state`; folding the counters costs no extra read and makes the durable
8181
+ * record say afterwards how far a move actually got.
8182
+ *
8183
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8184
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8185
+ * cannot say M, and a 0 there would render as "100 % done".
8186
+ */
8187
+ var StorageMigrationMoveProgressSchema = object({
8188
+ filesMoved: number().int().nonnegative(),
8189
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8190
+ filesTotal: number().int().nonnegative().nullable(),
8191
+ bytesMoved: number().int().nonnegative(),
8192
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8193
+ * crash gets a new mover, and a rate computed from the migration's start
8194
+ * would silently average in the time nothing was running. */
8195
+ startedAt: number(),
8196
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8197
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8198
+ * subtract its own. */
8199
+ observedAt: number()
8200
+ });
8088
8201
  var StorageMigrationMoveSchema = object({
8089
8202
  storageClass: StorageMigrationClassSchema,
8090
8203
  fromLocationId: string(),
8091
8204
  toLocationId: string(),
8092
8205
  moverJobId: string().nullable(),
8093
8206
  state: RelocateJobStateSchema.nullable(),
8094
- error: string().nullable()
8207
+ error: string().nullable(),
8208
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8209
+ progress: StorageMigrationMoveProgressSchema.nullable()
8095
8210
  });
8096
8211
  var StorageMigrationJobSchema = object({
8097
8212
  jobId: string(),
8098
8213
  phase: StorageMigrationPhaseSchema,
8214
+ /** Which order this job is running. `status` is the only place an operator
8215
+ * can tell a seconds-long cutover from a thirty-hour one. */
8216
+ mode: StorageMigrationModeSchema,
8099
8217
  destinations: StorageMigrationDestinationsSchema,
8100
8218
  throttleMbps: number(),
8101
8219
  moves: array(StorageMigrationMoveSchema),
@@ -8108,13 +8226,122 @@ var StorageMigrationJobSchema = object({
8108
8226
  finishedAt: number().nullable(),
8109
8227
  error: string().nullable()
8110
8228
  });
8229
+ var StorageMigrationFindingSchema = object({
8230
+ code: _enum([
8231
+ "sharesDeviceWithSource",
8232
+ "deviceIdentityUnknown",
8233
+ "unstampedEventMediaRows",
8234
+ "blockingOnly",
8235
+ "noMover"
8236
+ ]),
8237
+ storageClass: StorageMigrationClassSchema,
8238
+ /** Human-readable, already carrying the ids and counts. */
8239
+ message: string()
8240
+ });
8111
8241
  var StorageMigrationPlanSchema = object({
8112
8242
  destinations: StorageMigrationDestinationsSchema,
8243
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8244
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8245
+ * it. */
8246
+ mode: StorageMigrationModeSchema,
8113
8247
  moves: array(object({
8114
8248
  storageClass: StorageMigrationClassSchema,
8115
8249
  fromLocationId: string(),
8116
8250
  toLocationId: string()
8117
- }))
8251
+ })),
8252
+ findings: array(StorageMigrationFindingSchema)
8253
+ });
8254
+ /**
8255
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8256
+ *
8257
+ * The coordinator's job record is the state of record for a migration, and its
8258
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8259
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8260
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8261
+ * way because no supported UI path existed. A mover armed like that has no job
8262
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8263
+ *
8264
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8265
+ * orchestrated it.
8266
+ */
8267
+ var StorageMigrationMoverSchema = object({
8268
+ lane: _enum(["footage", "media"]),
8269
+ job: RelocateJobSchema,
8270
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8271
+ * directly against the owning addon. */
8272
+ migrationJobId: string().nullable(),
8273
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8274
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8275
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8276
+ * rate made of two different clocks. */
8277
+ observedAt: number()
8278
+ });
8279
+ /**
8280
+ * What a SOURCE still holds for one storage class — the number that makes a
8281
+ * "drain remaining" action honest rather than hopeful.
8282
+ *
8283
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8284
+ * engine's own selection count for media), never from the resident index: a
8285
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8286
+ * never been told about (D295).
8287
+ *
8288
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8289
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8290
+ * because refusing on an unanswerable read would hide exactly the case an
8291
+ * operator needs to act on.
8292
+ */
8293
+ var StorageMigrationResidueSchema = object({
8294
+ storageClass: StorageMigrationClassSchema,
8295
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8296
+ * move from wherever they are rather than from one named source. */
8297
+ fromLocationId: string(),
8298
+ /** Where a drain would move it — the class's CURRENT default. */
8299
+ toLocationId: string(),
8300
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8301
+ items: number().int().nonnegative().nullable(),
8302
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8303
+ bytes: number().int().nonnegative().nullable()
8304
+ });
8305
+ /**
8306
+ * Run the DRAIN half and nothing else.
8307
+ *
8308
+ * A migration that reached `done` has already repointed, so `start` correctly
8309
+ * refuses its destination ("already the default") — there is nothing left to
8310
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8311
+ * or finish against a work list that was a tenth of the archive (D295), and
8312
+ * before this there was no supported way to run only that half: the only way
8313
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8314
+ *
8315
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8316
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8317
+ * re-repoint a class that is already migrated.
8318
+ */
8319
+ var StorageMigrationDrainInputSchema = object({
8320
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8321
+ * a class whose source is already empty is refused rather than started. */
8322
+ classes: array(StorageMigrationClassSchema).min(1),
8323
+ throttleMbps: number().min(1).max(1e3).optional()
8324
+ });
8325
+ /** What a footage source still holds, asked of the durable hour ledger. */
8326
+ var RelocateResidueInputSchema = object({
8327
+ fromLocationId: string().min(1),
8328
+ /** Narrow to one logical class; omit for every profile on the location. */
8329
+ footageClass: RelocateFootageClassSchema.optional()
8330
+ });
8331
+ /** `null` = the archive could not answer (no ledger on this node, or the
8332
+ * aggregate failed). Never conflated with an empty source. */
8333
+ var RelocateResidueSchema = object({
8334
+ segments: number().int().nonnegative(),
8335
+ bytes: number().int().nonnegative()
8336
+ }).nullable();
8337
+ /** How many rows a media pass would still act on against a given target — the
8338
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8339
+ * never disagree. `null` = the count could not be taken. */
8340
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8341
+ var RelocatableMediaCountInputSchema = object({
8342
+ toLocationId: string().min(1),
8343
+ /** Omitted = `move`. */
8344
+ mode: MediaRelocateModeSchema.optional()
8118
8345
  });
8119
8346
  /**
8120
8347
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8220,6 +8447,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8220
8447
  * two addons declaring the same `id` must agree on `cardinality` (validated
8221
8448
  * at kernel aggregation time, not here).
8222
8449
  */
8450
+ /**
8451
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8452
+ * actually reaches the bytes. It is the constraint that decides which
8453
+ * `storage-provider`s may back a location of that kind.
8454
+ *
8455
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8456
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8457
+ * post-analysis media roots). Only a provider that serves a genuine local
8458
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8459
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8460
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8461
+ * against a same-named local directory that is something else entirely.
8462
+ *
8463
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8464
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8465
+ * service never sees a path, so any provider can back it. `backups` is the
8466
+ * one kind that qualifies today.
8467
+ *
8468
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8469
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8470
+ * refused the configuration; the first write simply went somewhere wrong, and
8471
+ * a recording write that goes wrong surfaces as a silent black window rather
8472
+ * than an error (the read path does not `stat`). This turns that accident into
8473
+ * a declared, enforced, testable refusal.
8474
+ */
8475
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8223
8476
  var StorageLocationDeclarationSchema = object({
8224
8477
  /**
8225
8478
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8239,6 +8492,19 @@ var StorageLocationDeclarationSchema = object({
8239
8492
  */
8240
8493
  cardinality: _enum(["single", "multi"]),
8241
8494
  /**
8495
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8496
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8497
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8498
+ *
8499
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8500
+ * can only over-restrict (refuse a remote provider for a kind that might
8501
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8502
+ * permissive direction and is therefore never inferred — a repo guard
8503
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8504
+ * reached by omission.
8505
+ */
8506
+ access: StorageAccessSchema.optional(),
8507
+ /**
8242
8508
  * When set, the default instance for this location inherits its resolved
8243
8509
  * root from the named location's default instance. Useful for derivative
8244
8510
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18106,8 +18372,10 @@ var TrackSchema = object({
18106
18372
  lastSeen: number(),
18107
18373
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18108
18374
  positions: array(TrackPositionSchema).readonly(),
18109
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18110
- * saveThumbnails policy). */
18375
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18376
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18377
+ * the retired `saveThumbnails` used to gate this and the rolling
18378
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18111
18379
  snapshots: array(TrackSnapshotSchema).readonly(),
18112
18380
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18113
18381
  zonesVisited: array(string()).readonly(),
@@ -18967,6 +19235,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18967
19235
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18968
19236
  kind: "mutation",
18969
19237
  auth: "admin"
19238
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19239
+ kind: "query",
19240
+ auth: "admin"
18970
19241
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18971
19242
  kind: "query",
18972
19243
  auth: "admin"
@@ -20874,7 +21145,10 @@ method(object({
20874
21145
  }), StorageLocationSchema, {
20875
21146
  kind: "mutation",
20876
21147
  auth: "admin"
20877
- }), method(object({ id: string() }), _void(), {
21148
+ }), method(object({
21149
+ id: string(),
21150
+ force: boolean().optional()
21151
+ }), _void(), {
20878
21152
  kind: "mutation",
20879
21153
  auth: "admin"
20880
21154
  }), method(object({ id: string() }), object({
@@ -20923,6 +21197,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20923
21197
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20924
21198
  kind: "mutation",
20925
21199
  auth: "admin"
21200
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21201
+ kind: "mutation",
21202
+ auth: "admin"
20926
21203
  });
20927
21204
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20928
21205
  providerId: string().min(1),
@@ -21321,12 +21598,38 @@ response: record(string(), unknown()) }), object({
21321
21598
  *
21322
21599
  * ## Why this is a capability and not a helper
21323
21600
  *
21324
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21325
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21326
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21327
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21328
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21329
- * load 5,000 rows before ranking anything.
21601
+ * This capability was introduced with the claim that SIX stores in
21602
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21603
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21604
+ * claim was never true, and leaving it here made five stores look like pending
21605
+ * work when three of them have no vector at all. Counted column by column on
21606
+ * 2026-08-30, exactly THREE ever held one:
21607
+ *
21608
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21609
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21610
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21611
+ * face, migrated 2026-08-30 into its OWN index (see below).
21612
+ *
21613
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21614
+ * and `identities` store a name; the event store stores no derivative vector.
21615
+ * They are not migration candidates and never were.
21616
+ *
21617
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21618
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21619
+ * rows before ranking anything.
21620
+ *
21621
+ * ## One index per COMPARISON, never per encoder
21622
+ *
21623
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21624
+ * model, and they still get two indexes. An index is a set of things that are
21625
+ * ranked against each other and that live and die together, and these two are
21626
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21627
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21628
+ * forever and is the gallery every recognition ranks against. One index would
21629
+ * mean every gallery load and every reconcile carried a filter whose failure
21630
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21631
+ * person's only sample. The dimension they share is not a reason to share an
21632
+ * index; the question they answer is, and it differs.
21330
21633
  *
21331
21634
  * The fix is not a faster loop, it is a different backend — and the backend
21332
21635
  * should be replaceable without touching six callers. So: a singleton
@@ -21431,7 +21734,20 @@ var VectorQueryResultSchema = object({
21431
21734
  */
21432
21735
  scanned: number(),
21433
21736
  /** True when the backend could not consider every row that passed the filter. */
21434
- truncated: boolean()
21737
+ truncated: boolean(),
21738
+ /**
21739
+ * The `topK` the backend actually ran with.
21740
+ *
21741
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21742
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21743
+ * own log rather than in its answer. That is how an audit asking for 20,000
21744
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21745
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21746
+ * MUCH, in the return value, where the caller cannot fail to see it.
21747
+ *
21748
+ * Equals the requested `topK` whenever nothing was lowered.
21749
+ */
21750
+ effectiveTopK: number().int().positive()
21435
21751
  });
21436
21752
  var VectorDeleteInputSchema = object({
21437
21753
  index: string(),
@@ -21460,6 +21776,68 @@ var VectorGetResultSchema = object({ items: array(object({
21460
21776
  id: string(),
21461
21777
  metadata: VectorMetadataSchema
21462
21778
  })) });
21779
+ /**
21780
+ * Ids to read back WITH their vectors.
21781
+ *
21782
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21783
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21784
+ * caller depends on that promise. This one promises the opposite.
21785
+ *
21786
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21787
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21788
+ * a per-face cross-process KNN would be a network round trip inside the
21789
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21790
+ * it requires the index to hand the floats back. Without this method the only
21791
+ * way to keep a readable vector is a JSON column, which is the thing this
21792
+ * capability exists to delete.
21793
+ *
21794
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21795
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21796
+ */
21797
+ var VectorFetchInputSchema = object({
21798
+ index: string(),
21799
+ ids: array(string())
21800
+ });
21801
+ var VectorFetchResultSchema = object({ items: array(object({
21802
+ id: string(),
21803
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21804
+ vector: string(),
21805
+ metadata: VectorMetadataSchema
21806
+ })) });
21807
+ /**
21808
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21809
+ *
21810
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21811
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21812
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21813
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21814
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21815
+ * looked" for as long as anyone cared to read it.
21816
+ *
21817
+ * This is the primitive that question actually needs: a bounded page, ordered
21818
+ * by the backend's own row order, costing no distance computation at all.
21819
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21820
+ * the full-table read this capability was built to stop.
21821
+ */
21822
+ var VectorScanInputSchema = object({
21823
+ index: string(),
21824
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21825
+ cursor: number().int().nonnegative().default(0),
21826
+ limit: number().int().positive()
21827
+ });
21828
+ var VectorScanResultSchema = object({
21829
+ items: array(object({
21830
+ id: string(),
21831
+ metadata: VectorMetadataSchema
21832
+ })),
21833
+ /**
21834
+ * Where the next page starts, or `null` when the walk reached the end.
21835
+ *
21836
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21837
+ * from a short page: a backend is free to return fewer rows than asked.
21838
+ */
21839
+ nextCursor: number().int().nonnegative().nullable()
21840
+ });
21463
21841
  var VectorStatsInputSchema = object({ index: string() });
21464
21842
  var VectorStatsResultSchema = object({
21465
21843
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21478,7 +21856,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21478
21856
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21479
21857
  kind: "mutation",
21480
21858
  auth: "admin"
21481
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21859
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21482
21860
  kind: "mutation",
21483
21861
  auth: "admin"
21484
21862
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28114,6 +28492,9 @@ method(object({
28114
28492
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28115
28493
  kind: "query",
28116
28494
  auth: "admin"
28495
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28496
+ kind: "query",
28497
+ auth: "admin"
28117
28498
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28118
28499
  kind: "mutation",
28119
28500
  auth: "admin"
@@ -34748,6 +35129,18 @@ Object.freeze({
34748
35129
  addonId: null,
34749
35130
  access: "create"
34750
35131
  },
35132
+ "pipelineAnalytics.countRelocatableMedia": {
35133
+ capName: "pipeline-analytics",
35134
+ capScope: "device",
35135
+ addonId: null,
35136
+ access: "view"
35137
+ },
35138
+ "pipelineAnalytics.countUnstampedEventMedia": {
35139
+ capName: "pipeline-analytics",
35140
+ capScope: "device",
35141
+ addonId: null,
35142
+ access: "view"
35143
+ },
34751
35144
  "pipelineAnalytics.deleteDeviceEvents": {
34752
35145
  capName: "pipeline-analytics",
34753
35146
  capScope: "device",
@@ -35906,6 +36299,12 @@ Object.freeze({
35906
36299
  addonId: null,
35907
36300
  access: "view"
35908
36301
  },
36302
+ "recording.getRelocateResidue": {
36303
+ capName: "recording",
36304
+ capScope: "system",
36305
+ addonId: null,
36306
+ access: "view"
36307
+ },
35909
36308
  "recording.getStorageMigrationMoveStatus": {
35910
36309
  capName: "recording",
35911
36310
  capScope: "system",
@@ -36452,12 +36851,30 @@ Object.freeze({
36452
36851
  addonId: null,
36453
36852
  access: "create"
36454
36853
  },
36854
+ "storageMigration.drain": {
36855
+ capName: "storage-migration",
36856
+ capScope: "system",
36857
+ addonId: null,
36858
+ access: "create"
36859
+ },
36860
+ "storageMigration.movers": {
36861
+ capName: "storage-migration",
36862
+ capScope: "system",
36863
+ addonId: null,
36864
+ access: "view"
36865
+ },
36455
36866
  "storageMigration.plan": {
36456
36867
  capName: "storage-migration",
36457
36868
  capScope: "system",
36458
36869
  addonId: null,
36459
36870
  access: "view"
36460
36871
  },
36872
+ "storageMigration.residue": {
36873
+ capName: "storage-migration",
36874
+ capScope: "system",
36875
+ addonId: null,
36876
+ access: "view"
36877
+ },
36461
36878
  "storageMigration.start": {
36462
36879
  capName: "storage-migration",
36463
36880
  capScope: "system",
@@ -37292,6 +37709,12 @@ Object.freeze({
37292
37709
  addonId: null,
37293
37710
  access: "delete"
37294
37711
  },
37712
+ "vectorStore.fetchByIds": {
37713
+ capName: "vector-store",
37714
+ capScope: "system",
37715
+ addonId: null,
37716
+ access: "view"
37717
+ },
37295
37718
  "vectorStore.getByIds": {
37296
37719
  capName: "vector-store",
37297
37720
  capScope: "system",
@@ -37304,6 +37727,12 @@ Object.freeze({
37304
37727
  addonId: null,
37305
37728
  access: "view"
37306
37729
  },
37730
+ "vectorStore.scan": {
37731
+ capName: "vector-store",
37732
+ capScope: "system",
37733
+ addonId: null,
37734
+ access: "view"
37735
+ },
37307
37736
  "vectorStore.stats": {
37308
37737
  capName: "vector-store",
37309
37738
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8038,18 +8038,61 @@ var RelocateFootageInputSchema = object({
8038
8038
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8039
8039
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8040
8040
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8041
+ /**
8042
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8043
+ * mover (the engine already walks both collections with a timestamp cursor and
8044
+ * already has a stamp-without-copy path).
8045
+ *
8046
+ * - `move` — the default and the historical behaviour: event-media and
8047
+ * retrain blobs move to `toLocationId` and their rows are
8048
+ * stamped. The enrolled gallery is skipped (D197).
8049
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8050
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8051
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8052
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8053
+ * instant a repoint moves that pointer the row reads from the
8054
+ * new disk while its bytes are on the old one.
8055
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8056
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8057
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8058
+ * never run beside a live second location: it is stop-the-world
8059
+ * by construction, which is acceptable only because the gallery
8060
+ * is a few KB per enrolled sample.
8061
+ */
8062
+ var MediaRelocateModeSchema = _enum([
8063
+ "move",
8064
+ "seal",
8065
+ "gallery"
8066
+ ]);
8041
8067
  var RelocateMediaInputSchema = object({
8042
8068
  toLocationId: string(),
8043
- throttleMbps: number().min(1).max(1e3).optional()
8069
+ throttleMbps: number().min(1).max(1e3).optional(),
8070
+ /** Omitted = `move`, the pre-existing behaviour. */
8071
+ mode: MediaRelocateModeSchema.optional()
8072
+ });
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()
8044
8080
  });
8045
8081
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8046
- /** The independently selectable logical storage classes. `recordings`
8047
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8048
- * segments; `eventMedia` is post-analysis blobs. */
8082
+ /** The independently selectable logical storage classes — every class
8083
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8084
+ * Zod enum error where they should meet an explanation.
8085
+ *
8086
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8087
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8088
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8089
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8049
8090
  var StorageMigrationClassSchema = _enum([
8050
8091
  "recordings",
8051
8092
  "recordingsLow",
8052
- "eventMedia"
8093
+ "eventMedia",
8094
+ "backups",
8095
+ "galleryMedia"
8053
8096
  ]);
8054
8097
  /** A destination is always an existing, fully-qualified location id. The
8055
8098
  * migration API intentionally never changes a source location's `basePath`:
@@ -8057,20 +8100,56 @@ var StorageMigrationClassSchema = _enum([
8057
8100
  var StorageMigrationDestinationsSchema = object({
8058
8101
  recordings: string().min(1).optional(),
8059
8102
  recordingsLow: string().min(1).optional(),
8060
- eventMedia: string().min(1).optional()
8103
+ eventMedia: string().min(1).optional(),
8104
+ backups: string().min(1).optional(),
8105
+ galleryMedia: string().min(1).optional()
8061
8106
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8107
+ /**
8108
+ * How a migration sequences the cutover against the byte move.
8109
+ *
8110
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8111
+ * resume. Recording is stopped for the whole move. Right
8112
+ * for a small or a cold class, and the only legal mode for
8113
+ * a `cardinality: 'single'` class.
8114
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8115
+ * refresh, resume, then move the past with everything
8116
+ * running. The pause is three bounded instants (a detach +
8117
+ * attach round, a write-gate drain, a lease) instead of one
8118
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8119
+ * stopped recording under `blocking`; the same move is
8120
+ * seconds of stopped recording under `nonBlocking`.
8121
+ *
8122
+ * The mode is on the JOB, not only on the input, because `status` is where an
8123
+ * operator finds out which one is running.
8124
+ */
8125
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8062
8126
  /** Shared input for planning and starting an orchestrated storage migration. */
8063
8127
  var StorageMigrationInputSchema = object({
8064
8128
  destinations: StorageMigrationDestinationsSchema,
8065
- throttleMbps: number().min(1).max(1e3).optional()
8129
+ throttleMbps: number().min(1).max(1e3).optional(),
8130
+ /** Omitted = `blocking`, which stays the default. */
8131
+ mode: StorageMigrationModeSchema.optional()
8066
8132
  });
8067
- /** The durable coordinator state machine. The only phase that changes default
8068
- * locations is `repointing`, after every selected mover has completed and been
8069
- * verified. */
8133
+ /**
8134
+ * The durable coordinator state machine.
8135
+ *
8136
+ * `blocking`:
8137
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8138
+ *
8139
+ * `nonBlocking`:
8140
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8141
+ *
8142
+ * Same phases, different order plus two new ones — not a second mover.
8143
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8144
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8145
+ * `repointing` is still the only phase that changes a default location.
8146
+ */
8070
8147
  var StorageMigrationPhaseSchema = _enum([
8071
8148
  "planning",
8149
+ "sealing",
8072
8150
  "pausing",
8073
8151
  "moving",
8152
+ "draining",
8074
8153
  "verifying",
8075
8154
  "repointing",
8076
8155
  "refreshing",
@@ -8084,17 +8163,56 @@ var StorageMigrationParticipantSchema = _enum([
8084
8163
  "recorder",
8085
8164
  "analytics"
8086
8165
  ]);
8166
+ /**
8167
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8168
+ *
8169
+ * The long half of a non-blocking migration is `draining`, and it is measured
8170
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8171
+ * existed the only place those numbers appeared was a Loki line, so an operator
8172
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8173
+ * afternoon.
8174
+ *
8175
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8176
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8177
+ * mover — which is the exact failure this is meant to end. The coordinator's
8178
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8179
+ * read `state`; folding the counters costs no extra read and makes the durable
8180
+ * record say afterwards how far a move actually got.
8181
+ *
8182
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8183
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8184
+ * cannot say M, and a 0 there would render as "100 % done".
8185
+ */
8186
+ var StorageMigrationMoveProgressSchema = object({
8187
+ filesMoved: number().int().nonnegative(),
8188
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8189
+ filesTotal: number().int().nonnegative().nullable(),
8190
+ bytesMoved: number().int().nonnegative(),
8191
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8192
+ * crash gets a new mover, and a rate computed from the migration's start
8193
+ * would silently average in the time nothing was running. */
8194
+ startedAt: number(),
8195
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8196
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8197
+ * subtract its own. */
8198
+ observedAt: number()
8199
+ });
8087
8200
  var StorageMigrationMoveSchema = object({
8088
8201
  storageClass: StorageMigrationClassSchema,
8089
8202
  fromLocationId: string(),
8090
8203
  toLocationId: string(),
8091
8204
  moverJobId: string().nullable(),
8092
8205
  state: RelocateJobStateSchema.nullable(),
8093
- error: string().nullable()
8206
+ error: string().nullable(),
8207
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8208
+ progress: StorageMigrationMoveProgressSchema.nullable()
8094
8209
  });
8095
8210
  var StorageMigrationJobSchema = object({
8096
8211
  jobId: string(),
8097
8212
  phase: StorageMigrationPhaseSchema,
8213
+ /** Which order this job is running. `status` is the only place an operator
8214
+ * can tell a seconds-long cutover from a thirty-hour one. */
8215
+ mode: StorageMigrationModeSchema,
8098
8216
  destinations: StorageMigrationDestinationsSchema,
8099
8217
  throttleMbps: number(),
8100
8218
  moves: array(StorageMigrationMoveSchema),
@@ -8107,13 +8225,122 @@ var StorageMigrationJobSchema = object({
8107
8225
  finishedAt: number().nullable(),
8108
8226
  error: string().nullable()
8109
8227
  });
8228
+ var StorageMigrationFindingSchema = object({
8229
+ code: _enum([
8230
+ "sharesDeviceWithSource",
8231
+ "deviceIdentityUnknown",
8232
+ "unstampedEventMediaRows",
8233
+ "blockingOnly",
8234
+ "noMover"
8235
+ ]),
8236
+ storageClass: StorageMigrationClassSchema,
8237
+ /** Human-readable, already carrying the ids and counts. */
8238
+ message: string()
8239
+ });
8110
8240
  var StorageMigrationPlanSchema = object({
8111
8241
  destinations: StorageMigrationDestinationsSchema,
8242
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8243
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8244
+ * it. */
8245
+ mode: StorageMigrationModeSchema,
8112
8246
  moves: array(object({
8113
8247
  storageClass: StorageMigrationClassSchema,
8114
8248
  fromLocationId: string(),
8115
8249
  toLocationId: string()
8116
- }))
8250
+ })),
8251
+ findings: array(StorageMigrationFindingSchema)
8252
+ });
8253
+ /**
8254
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8255
+ *
8256
+ * The coordinator's job record is the state of record for a migration, and its
8257
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8258
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8259
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8260
+ * way because no supported UI path existed. A mover armed like that has no job
8261
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8262
+ *
8263
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8264
+ * orchestrated it.
8265
+ */
8266
+ var StorageMigrationMoverSchema = object({
8267
+ lane: _enum(["footage", "media"]),
8268
+ job: RelocateJobSchema,
8269
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8270
+ * directly against the owning addon. */
8271
+ migrationJobId: string().nullable(),
8272
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8273
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8274
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8275
+ * rate made of two different clocks. */
8276
+ observedAt: number()
8277
+ });
8278
+ /**
8279
+ * What a SOURCE still holds for one storage class — the number that makes a
8280
+ * "drain remaining" action honest rather than hopeful.
8281
+ *
8282
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8283
+ * engine's own selection count for media), never from the resident index: a
8284
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8285
+ * never been told about (D295).
8286
+ *
8287
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8288
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8289
+ * because refusing on an unanswerable read would hide exactly the case an
8290
+ * operator needs to act on.
8291
+ */
8292
+ var StorageMigrationResidueSchema = object({
8293
+ storageClass: StorageMigrationClassSchema,
8294
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8295
+ * move from wherever they are rather than from one named source. */
8296
+ fromLocationId: string(),
8297
+ /** Where a drain would move it — the class's CURRENT default. */
8298
+ toLocationId: string(),
8299
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8300
+ items: number().int().nonnegative().nullable(),
8301
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8302
+ bytes: number().int().nonnegative().nullable()
8303
+ });
8304
+ /**
8305
+ * Run the DRAIN half and nothing else.
8306
+ *
8307
+ * A migration that reached `done` has already repointed, so `start` correctly
8308
+ * refuses its destination ("already the default") — there is nothing left to
8309
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8310
+ * or finish against a work list that was a tenth of the archive (D295), and
8311
+ * before this there was no supported way to run only that half: the only way
8312
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8313
+ *
8314
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8315
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8316
+ * re-repoint a class that is already migrated.
8317
+ */
8318
+ var StorageMigrationDrainInputSchema = object({
8319
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8320
+ * a class whose source is already empty is refused rather than started. */
8321
+ classes: array(StorageMigrationClassSchema).min(1),
8322
+ throttleMbps: number().min(1).max(1e3).optional()
8323
+ });
8324
+ /** What a footage source still holds, asked of the durable hour ledger. */
8325
+ var RelocateResidueInputSchema = object({
8326
+ fromLocationId: string().min(1),
8327
+ /** Narrow to one logical class; omit for every profile on the location. */
8328
+ footageClass: RelocateFootageClassSchema.optional()
8329
+ });
8330
+ /** `null` = the archive could not answer (no ledger on this node, or the
8331
+ * aggregate failed). Never conflated with an empty source. */
8332
+ var RelocateResidueSchema = object({
8333
+ segments: number().int().nonnegative(),
8334
+ bytes: number().int().nonnegative()
8335
+ }).nullable();
8336
+ /** How many rows a media pass would still act on against a given target — the
8337
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8338
+ * never disagree. `null` = the count could not be taken. */
8339
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8340
+ var RelocatableMediaCountInputSchema = object({
8341
+ toLocationId: string().min(1),
8342
+ /** Omitted = `move`. */
8343
+ mode: MediaRelocateModeSchema.optional()
8117
8344
  });
8118
8345
  /**
8119
8346
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8219,6 +8446,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8219
8446
  * two addons declaring the same `id` must agree on `cardinality` (validated
8220
8447
  * at kernel aggregation time, not here).
8221
8448
  */
8449
+ /**
8450
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8451
+ * actually reaches the bytes. It is the constraint that decides which
8452
+ * `storage-provider`s may back a location of that kind.
8453
+ *
8454
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8455
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8456
+ * post-analysis media roots). Only a provider that serves a genuine local
8457
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8458
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8459
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8460
+ * against a same-named local directory that is something else entirely.
8461
+ *
8462
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8463
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8464
+ * service never sees a path, so any provider can back it. `backups` is the
8465
+ * one kind that qualifies today.
8466
+ *
8467
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8468
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8469
+ * refused the configuration; the first write simply went somewhere wrong, and
8470
+ * a recording write that goes wrong surfaces as a silent black window rather
8471
+ * than an error (the read path does not `stat`). This turns that accident into
8472
+ * a declared, enforced, testable refusal.
8473
+ */
8474
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8222
8475
  var StorageLocationDeclarationSchema = object({
8223
8476
  /**
8224
8477
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8238,6 +8491,19 @@ var StorageLocationDeclarationSchema = object({
8238
8491
  */
8239
8492
  cardinality: _enum(["single", "multi"]),
8240
8493
  /**
8494
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8495
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8496
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8497
+ *
8498
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8499
+ * can only over-restrict (refuse a remote provider for a kind that might
8500
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8501
+ * permissive direction and is therefore never inferred — a repo guard
8502
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8503
+ * reached by omission.
8504
+ */
8505
+ access: StorageAccessSchema.optional(),
8506
+ /**
8241
8507
  * When set, the default instance for this location inherits its resolved
8242
8508
  * root from the named location's default instance. Useful for derivative
8243
8509
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18105,8 +18371,10 @@ var TrackSchema = object({
18105
18371
  lastSeen: number(),
18106
18372
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18107
18373
  positions: array(TrackPositionSchema).readonly(),
18108
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18109
- * saveThumbnails policy). */
18374
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18375
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18376
+ * the retired `saveThumbnails` used to gate this and the rolling
18377
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18110
18378
  snapshots: array(TrackSnapshotSchema).readonly(),
18111
18379
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18112
18380
  zonesVisited: array(string()).readonly(),
@@ -18966,6 +19234,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18966
19234
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18967
19235
  kind: "mutation",
18968
19236
  auth: "admin"
19237
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19238
+ kind: "query",
19239
+ auth: "admin"
18969
19240
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18970
19241
  kind: "query",
18971
19242
  auth: "admin"
@@ -20873,7 +21144,10 @@ method(object({
20873
21144
  }), StorageLocationSchema, {
20874
21145
  kind: "mutation",
20875
21146
  auth: "admin"
20876
- }), method(object({ id: string() }), _void(), {
21147
+ }), method(object({
21148
+ id: string(),
21149
+ force: boolean().optional()
21150
+ }), _void(), {
20877
21151
  kind: "mutation",
20878
21152
  auth: "admin"
20879
21153
  }), method(object({ id: string() }), object({
@@ -20922,6 +21196,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20922
21196
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20923
21197
  kind: "mutation",
20924
21198
  auth: "admin"
21199
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21200
+ kind: "mutation",
21201
+ auth: "admin"
20925
21202
  });
20926
21203
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20927
21204
  providerId: string().min(1),
@@ -21320,12 +21597,38 @@ response: record(string(), unknown()) }), object({
21320
21597
  *
21321
21598
  * ## Why this is a capability and not a helper
21322
21599
  *
21323
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21324
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21325
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21326
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21327
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21328
- * load 5,000 rows before ranking anything.
21600
+ * This capability was introduced with the claim that SIX stores in
21601
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21602
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21603
+ * claim was never true, and leaving it here made five stores look like pending
21604
+ * work when three of them have no vector at all. Counted column by column on
21605
+ * 2026-08-30, exactly THREE ever held one:
21606
+ *
21607
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21608
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21609
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21610
+ * face, migrated 2026-08-30 into its OWN index (see below).
21611
+ *
21612
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21613
+ * and `identities` store a name; the event store stores no derivative vector.
21614
+ * They are not migration candidates and never were.
21615
+ *
21616
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21617
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21618
+ * rows before ranking anything.
21619
+ *
21620
+ * ## One index per COMPARISON, never per encoder
21621
+ *
21622
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21623
+ * model, and they still get two indexes. An index is a set of things that are
21624
+ * ranked against each other and that live and die together, and these two are
21625
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21626
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21627
+ * forever and is the gallery every recognition ranks against. One index would
21628
+ * mean every gallery load and every reconcile carried a filter whose failure
21629
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21630
+ * person's only sample. The dimension they share is not a reason to share an
21631
+ * index; the question they answer is, and it differs.
21329
21632
  *
21330
21633
  * The fix is not a faster loop, it is a different backend — and the backend
21331
21634
  * should be replaceable without touching six callers. So: a singleton
@@ -21430,7 +21733,20 @@ var VectorQueryResultSchema = object({
21430
21733
  */
21431
21734
  scanned: number(),
21432
21735
  /** True when the backend could not consider every row that passed the filter. */
21433
- truncated: boolean()
21736
+ truncated: boolean(),
21737
+ /**
21738
+ * The `topK` the backend actually ran with.
21739
+ *
21740
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21741
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21742
+ * own log rather than in its answer. That is how an audit asking for 20,000
21743
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21744
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21745
+ * MUCH, in the return value, where the caller cannot fail to see it.
21746
+ *
21747
+ * Equals the requested `topK` whenever nothing was lowered.
21748
+ */
21749
+ effectiveTopK: number().int().positive()
21434
21750
  });
21435
21751
  var VectorDeleteInputSchema = object({
21436
21752
  index: string(),
@@ -21459,6 +21775,68 @@ var VectorGetResultSchema = object({ items: array(object({
21459
21775
  id: string(),
21460
21776
  metadata: VectorMetadataSchema
21461
21777
  })) });
21778
+ /**
21779
+ * Ids to read back WITH their vectors.
21780
+ *
21781
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21782
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21783
+ * caller depends on that promise. This one promises the opposite.
21784
+ *
21785
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21786
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21787
+ * a per-face cross-process KNN would be a network round trip inside the
21788
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21789
+ * it requires the index to hand the floats back. Without this method the only
21790
+ * way to keep a readable vector is a JSON column, which is the thing this
21791
+ * capability exists to delete.
21792
+ *
21793
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21794
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21795
+ */
21796
+ var VectorFetchInputSchema = object({
21797
+ index: string(),
21798
+ ids: array(string())
21799
+ });
21800
+ var VectorFetchResultSchema = object({ items: array(object({
21801
+ id: string(),
21802
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21803
+ vector: string(),
21804
+ metadata: VectorMetadataSchema
21805
+ })) });
21806
+ /**
21807
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21808
+ *
21809
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21810
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21811
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21812
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21813
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21814
+ * looked" for as long as anyone cared to read it.
21815
+ *
21816
+ * This is the primitive that question actually needs: a bounded page, ordered
21817
+ * by the backend's own row order, costing no distance computation at all.
21818
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21819
+ * the full-table read this capability was built to stop.
21820
+ */
21821
+ var VectorScanInputSchema = object({
21822
+ index: string(),
21823
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21824
+ cursor: number().int().nonnegative().default(0),
21825
+ limit: number().int().positive()
21826
+ });
21827
+ var VectorScanResultSchema = object({
21828
+ items: array(object({
21829
+ id: string(),
21830
+ metadata: VectorMetadataSchema
21831
+ })),
21832
+ /**
21833
+ * Where the next page starts, or `null` when the walk reached the end.
21834
+ *
21835
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21836
+ * from a short page: a backend is free to return fewer rows than asked.
21837
+ */
21838
+ nextCursor: number().int().nonnegative().nullable()
21839
+ });
21462
21840
  var VectorStatsInputSchema = object({ index: string() });
21463
21841
  var VectorStatsResultSchema = object({
21464
21842
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21477,7 +21855,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21477
21855
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21478
21856
  kind: "mutation",
21479
21857
  auth: "admin"
21480
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21858
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21481
21859
  kind: "mutation",
21482
21860
  auth: "admin"
21483
21861
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28113,6 +28491,9 @@ method(object({
28113
28491
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28114
28492
  kind: "query",
28115
28493
  auth: "admin"
28494
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28495
+ kind: "query",
28496
+ auth: "admin"
28116
28497
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28117
28498
  kind: "mutation",
28118
28499
  auth: "admin"
@@ -34747,6 +35128,18 @@ Object.freeze({
34747
35128
  addonId: null,
34748
35129
  access: "create"
34749
35130
  },
35131
+ "pipelineAnalytics.countRelocatableMedia": {
35132
+ capName: "pipeline-analytics",
35133
+ capScope: "device",
35134
+ addonId: null,
35135
+ access: "view"
35136
+ },
35137
+ "pipelineAnalytics.countUnstampedEventMedia": {
35138
+ capName: "pipeline-analytics",
35139
+ capScope: "device",
35140
+ addonId: null,
35141
+ access: "view"
35142
+ },
34750
35143
  "pipelineAnalytics.deleteDeviceEvents": {
34751
35144
  capName: "pipeline-analytics",
34752
35145
  capScope: "device",
@@ -35905,6 +36298,12 @@ Object.freeze({
35905
36298
  addonId: null,
35906
36299
  access: "view"
35907
36300
  },
36301
+ "recording.getRelocateResidue": {
36302
+ capName: "recording",
36303
+ capScope: "system",
36304
+ addonId: null,
36305
+ access: "view"
36306
+ },
35908
36307
  "recording.getStorageMigrationMoveStatus": {
35909
36308
  capName: "recording",
35910
36309
  capScope: "system",
@@ -36451,12 +36850,30 @@ Object.freeze({
36451
36850
  addonId: null,
36452
36851
  access: "create"
36453
36852
  },
36853
+ "storageMigration.drain": {
36854
+ capName: "storage-migration",
36855
+ capScope: "system",
36856
+ addonId: null,
36857
+ access: "create"
36858
+ },
36859
+ "storageMigration.movers": {
36860
+ capName: "storage-migration",
36861
+ capScope: "system",
36862
+ addonId: null,
36863
+ access: "view"
36864
+ },
36454
36865
  "storageMigration.plan": {
36455
36866
  capName: "storage-migration",
36456
36867
  capScope: "system",
36457
36868
  addonId: null,
36458
36869
  access: "view"
36459
36870
  },
36871
+ "storageMigration.residue": {
36872
+ capName: "storage-migration",
36873
+ capScope: "system",
36874
+ addonId: null,
36875
+ access: "view"
36876
+ },
36460
36877
  "storageMigration.start": {
36461
36878
  capName: "storage-migration",
36462
36879
  capScope: "system",
@@ -37291,6 +37708,12 @@ Object.freeze({
37291
37708
  addonId: null,
37292
37709
  access: "delete"
37293
37710
  },
37711
+ "vectorStore.fetchByIds": {
37712
+ capName: "vector-store",
37713
+ capScope: "system",
37714
+ addonId: null,
37715
+ access: "view"
37716
+ },
37294
37717
  "vectorStore.getByIds": {
37295
37718
  capName: "vector-store",
37296
37719
  capScope: "system",
@@ -37303,6 +37726,12 @@ Object.freeze({
37303
37726
  addonId: null,
37304
37727
  access: "view"
37305
37728
  },
37729
+ "vectorStore.scan": {
37730
+ capName: "vector-store",
37731
+ capScope: "system",
37732
+ addonId: null,
37733
+ access: "view"
37734
+ },
37306
37735
  "vectorStore.stats": {
37307
37736
  capName: "vector-store",
37308
37737
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-unifi",
3
- "version": "0.2.42",
3
+ "version": "0.2.45",
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",