@camstack/addon-terminal 0.1.47 → 0.1.50

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
@@ -8138,18 +8138,61 @@ var RelocateFootageInputSchema = object({
8138
8138
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8139
8139
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8140
8140
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8141
+ /**
8142
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8143
+ * mover (the engine already walks both collections with a timestamp cursor and
8144
+ * already has a stamp-without-copy path).
8145
+ *
8146
+ * - `move` — the default and the historical behaviour: event-media and
8147
+ * retrain blobs move to `toLocationId` and their rows are
8148
+ * stamped. The enrolled gallery is skipped (D197).
8149
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8150
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8151
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8152
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8153
+ * instant a repoint moves that pointer the row reads from the
8154
+ * new disk while its bytes are on the old one.
8155
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8156
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8157
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8158
+ * never run beside a live second location: it is stop-the-world
8159
+ * by construction, which is acceptable only because the gallery
8160
+ * is a few KB per enrolled sample.
8161
+ */
8162
+ var MediaRelocateModeSchema = _enum([
8163
+ "move",
8164
+ "seal",
8165
+ "gallery"
8166
+ ]);
8141
8167
  var RelocateMediaInputSchema = object({
8142
8168
  toLocationId: string(),
8143
- throttleMbps: number().min(1).max(1e3).optional()
8169
+ throttleMbps: number().min(1).max(1e3).optional(),
8170
+ /** Omitted = `move`, the pre-existing behaviour. */
8171
+ mode: MediaRelocateModeSchema.optional()
8172
+ });
8173
+ /** How many rows still carry NO `locationId` — the population a repoint would
8174
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8175
+ * value that permits a non-blocking `eventMedia` cutover. */
8176
+ var UnstampedEventMediaCountSchema = object({
8177
+ media: number().int().nonnegative(),
8178
+ retrainFrames: number().int().nonnegative(),
8179
+ total: number().int().nonnegative()
8144
8180
  });
8145
8181
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8146
- /** The independently selectable logical storage classes. `recordings`
8147
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8148
- * segments; `eventMedia` is post-analysis blobs. */
8182
+ /** The independently selectable logical storage classes — every class
8183
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8184
+ * Zod enum error where they should meet an explanation.
8185
+ *
8186
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8187
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8188
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8189
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8149
8190
  var StorageMigrationClassSchema = _enum([
8150
8191
  "recordings",
8151
8192
  "recordingsLow",
8152
- "eventMedia"
8193
+ "eventMedia",
8194
+ "backups",
8195
+ "galleryMedia"
8153
8196
  ]);
8154
8197
  /** A destination is always an existing, fully-qualified location id. The
8155
8198
  * migration API intentionally never changes a source location's `basePath`:
@@ -8157,20 +8200,56 @@ var StorageMigrationClassSchema = _enum([
8157
8200
  var StorageMigrationDestinationsSchema = object({
8158
8201
  recordings: string().min(1).optional(),
8159
8202
  recordingsLow: string().min(1).optional(),
8160
- eventMedia: string().min(1).optional()
8203
+ eventMedia: string().min(1).optional(),
8204
+ backups: string().min(1).optional(),
8205
+ galleryMedia: string().min(1).optional()
8161
8206
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8207
+ /**
8208
+ * How a migration sequences the cutover against the byte move.
8209
+ *
8210
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8211
+ * resume. Recording is stopped for the whole move. Right
8212
+ * for a small or a cold class, and the only legal mode for
8213
+ * a `cardinality: 'single'` class.
8214
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8215
+ * refresh, resume, then move the past with everything
8216
+ * running. The pause is three bounded instants (a detach +
8217
+ * attach round, a write-gate drain, a lease) instead of one
8218
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8219
+ * stopped recording under `blocking`; the same move is
8220
+ * seconds of stopped recording under `nonBlocking`.
8221
+ *
8222
+ * The mode is on the JOB, not only on the input, because `status` is where an
8223
+ * operator finds out which one is running.
8224
+ */
8225
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8162
8226
  /** Shared input for planning and starting an orchestrated storage migration. */
8163
8227
  var StorageMigrationInputSchema = object({
8164
8228
  destinations: StorageMigrationDestinationsSchema,
8165
- throttleMbps: number().min(1).max(1e3).optional()
8229
+ throttleMbps: number().min(1).max(1e3).optional(),
8230
+ /** Omitted = `blocking`, which stays the default. */
8231
+ mode: StorageMigrationModeSchema.optional()
8166
8232
  });
8167
- /** The durable coordinator state machine. The only phase that changes default
8168
- * locations is `repointing`, after every selected mover has completed and been
8169
- * verified. */
8233
+ /**
8234
+ * The durable coordinator state machine.
8235
+ *
8236
+ * `blocking`:
8237
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8238
+ *
8239
+ * `nonBlocking`:
8240
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8241
+ *
8242
+ * Same phases, different order plus two new ones — not a second mover.
8243
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8244
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8245
+ * `repointing` is still the only phase that changes a default location.
8246
+ */
8170
8247
  var StorageMigrationPhaseSchema = _enum([
8171
8248
  "planning",
8249
+ "sealing",
8172
8250
  "pausing",
8173
8251
  "moving",
8252
+ "draining",
8174
8253
  "verifying",
8175
8254
  "repointing",
8176
8255
  "refreshing",
@@ -8184,17 +8263,56 @@ var StorageMigrationParticipantSchema = _enum([
8184
8263
  "recorder",
8185
8264
  "analytics"
8186
8265
  ]);
8266
+ /**
8267
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8268
+ *
8269
+ * The long half of a non-blocking migration is `draining`, and it is measured
8270
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8271
+ * existed the only place those numbers appeared was a Loki line, so an operator
8272
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8273
+ * afternoon.
8274
+ *
8275
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8276
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8277
+ * mover — which is the exact failure this is meant to end. The coordinator's
8278
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8279
+ * read `state`; folding the counters costs no extra read and makes the durable
8280
+ * record say afterwards how far a move actually got.
8281
+ *
8282
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8283
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8284
+ * cannot say M, and a 0 there would render as "100 % done".
8285
+ */
8286
+ var StorageMigrationMoveProgressSchema = object({
8287
+ filesMoved: number().int().nonnegative(),
8288
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8289
+ filesTotal: number().int().nonnegative().nullable(),
8290
+ bytesMoved: number().int().nonnegative(),
8291
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8292
+ * crash gets a new mover, and a rate computed from the migration's start
8293
+ * would silently average in the time nothing was running. */
8294
+ startedAt: number(),
8295
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8296
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8297
+ * subtract its own. */
8298
+ observedAt: number()
8299
+ });
8187
8300
  var StorageMigrationMoveSchema = object({
8188
8301
  storageClass: StorageMigrationClassSchema,
8189
8302
  fromLocationId: string(),
8190
8303
  toLocationId: string(),
8191
8304
  moverJobId: string().nullable(),
8192
8305
  state: RelocateJobStateSchema.nullable(),
8193
- error: string().nullable()
8306
+ error: string().nullable(),
8307
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8308
+ progress: StorageMigrationMoveProgressSchema.nullable()
8194
8309
  });
8195
8310
  var StorageMigrationJobSchema = object({
8196
8311
  jobId: string(),
8197
8312
  phase: StorageMigrationPhaseSchema,
8313
+ /** Which order this job is running. `status` is the only place an operator
8314
+ * can tell a seconds-long cutover from a thirty-hour one. */
8315
+ mode: StorageMigrationModeSchema,
8198
8316
  destinations: StorageMigrationDestinationsSchema,
8199
8317
  throttleMbps: number(),
8200
8318
  moves: array(StorageMigrationMoveSchema),
@@ -8207,13 +8325,122 @@ var StorageMigrationJobSchema = object({
8207
8325
  finishedAt: number().nullable(),
8208
8326
  error: string().nullable()
8209
8327
  });
8328
+ var StorageMigrationFindingSchema = object({
8329
+ code: _enum([
8330
+ "sharesDeviceWithSource",
8331
+ "deviceIdentityUnknown",
8332
+ "unstampedEventMediaRows",
8333
+ "blockingOnly",
8334
+ "noMover"
8335
+ ]),
8336
+ storageClass: StorageMigrationClassSchema,
8337
+ /** Human-readable, already carrying the ids and counts. */
8338
+ message: string()
8339
+ });
8210
8340
  var StorageMigrationPlanSchema = object({
8211
8341
  destinations: StorageMigrationDestinationsSchema,
8342
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8343
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8344
+ * it. */
8345
+ mode: StorageMigrationModeSchema,
8212
8346
  moves: array(object({
8213
8347
  storageClass: StorageMigrationClassSchema,
8214
8348
  fromLocationId: string(),
8215
8349
  toLocationId: string()
8216
- }))
8350
+ })),
8351
+ findings: array(StorageMigrationFindingSchema)
8352
+ });
8353
+ /**
8354
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8355
+ *
8356
+ * The coordinator's job record is the state of record for a migration, and its
8357
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8358
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8359
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8360
+ * way because no supported UI path existed. A mover armed like that has no job
8361
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8362
+ *
8363
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8364
+ * orchestrated it.
8365
+ */
8366
+ var StorageMigrationMoverSchema = object({
8367
+ lane: _enum(["footage", "media"]),
8368
+ job: RelocateJobSchema,
8369
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8370
+ * directly against the owning addon. */
8371
+ migrationJobId: string().nullable(),
8372
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8373
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8374
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8375
+ * rate made of two different clocks. */
8376
+ observedAt: number()
8377
+ });
8378
+ /**
8379
+ * What a SOURCE still holds for one storage class — the number that makes a
8380
+ * "drain remaining" action honest rather than hopeful.
8381
+ *
8382
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8383
+ * engine's own selection count for media), never from the resident index: a
8384
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8385
+ * never been told about (D295).
8386
+ *
8387
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8388
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8389
+ * because refusing on an unanswerable read would hide exactly the case an
8390
+ * operator needs to act on.
8391
+ */
8392
+ var StorageMigrationResidueSchema = object({
8393
+ storageClass: StorageMigrationClassSchema,
8394
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8395
+ * move from wherever they are rather than from one named source. */
8396
+ fromLocationId: string(),
8397
+ /** Where a drain would move it — the class's CURRENT default. */
8398
+ toLocationId: string(),
8399
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8400
+ items: number().int().nonnegative().nullable(),
8401
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8402
+ bytes: number().int().nonnegative().nullable()
8403
+ });
8404
+ /**
8405
+ * Run the DRAIN half and nothing else.
8406
+ *
8407
+ * A migration that reached `done` has already repointed, so `start` correctly
8408
+ * refuses its destination ("already the default") — there is nothing left to
8409
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8410
+ * or finish against a work list that was a tenth of the archive (D295), and
8411
+ * before this there was no supported way to run only that half: the only way
8412
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8413
+ *
8414
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8415
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8416
+ * re-repoint a class that is already migrated.
8417
+ */
8418
+ var StorageMigrationDrainInputSchema = object({
8419
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8420
+ * a class whose source is already empty is refused rather than started. */
8421
+ classes: array(StorageMigrationClassSchema).min(1),
8422
+ throttleMbps: number().min(1).max(1e3).optional()
8423
+ });
8424
+ /** What a footage source still holds, asked of the durable hour ledger. */
8425
+ var RelocateResidueInputSchema = object({
8426
+ fromLocationId: string().min(1),
8427
+ /** Narrow to one logical class; omit for every profile on the location. */
8428
+ footageClass: RelocateFootageClassSchema.optional()
8429
+ });
8430
+ /** `null` = the archive could not answer (no ledger on this node, or the
8431
+ * aggregate failed). Never conflated with an empty source. */
8432
+ var RelocateResidueSchema = object({
8433
+ segments: number().int().nonnegative(),
8434
+ bytes: number().int().nonnegative()
8435
+ }).nullable();
8436
+ /** How many rows a media pass would still act on against a given target — the
8437
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8438
+ * never disagree. `null` = the count could not be taken. */
8439
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8440
+ var RelocatableMediaCountInputSchema = object({
8441
+ toLocationId: string().min(1),
8442
+ /** Omitted = `move`. */
8443
+ mode: MediaRelocateModeSchema.optional()
8217
8444
  });
8218
8445
  /**
8219
8446
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8319,6 +8546,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8319
8546
  * two addons declaring the same `id` must agree on `cardinality` (validated
8320
8547
  * at kernel aggregation time, not here).
8321
8548
  */
8549
+ /**
8550
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8551
+ * actually reaches the bytes. It is the constraint that decides which
8552
+ * `storage-provider`s may back a location of that kind.
8553
+ *
8554
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8555
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8556
+ * post-analysis media roots). Only a provider that serves a genuine local
8557
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8558
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8559
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8560
+ * against a same-named local directory that is something else entirely.
8561
+ *
8562
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8563
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8564
+ * service never sees a path, so any provider can back it. `backups` is the
8565
+ * one kind that qualifies today.
8566
+ *
8567
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8568
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8569
+ * refused the configuration; the first write simply went somewhere wrong, and
8570
+ * a recording write that goes wrong surfaces as a silent black window rather
8571
+ * than an error (the read path does not `stat`). This turns that accident into
8572
+ * a declared, enforced, testable refusal.
8573
+ */
8574
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8322
8575
  var StorageLocationDeclarationSchema = object({
8323
8576
  /**
8324
8577
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8338,6 +8591,19 @@ var StorageLocationDeclarationSchema = object({
8338
8591
  */
8339
8592
  cardinality: _enum(["single", "multi"]),
8340
8593
  /**
8594
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8595
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8596
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8597
+ *
8598
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8599
+ * can only over-restrict (refuse a remote provider for a kind that might
8600
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8601
+ * permissive direction and is therefore never inferred — a repo guard
8602
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8603
+ * reached by omission.
8604
+ */
8605
+ access: StorageAccessSchema.optional(),
8606
+ /**
8341
8607
  * When set, the default instance for this location inherits its resolved
8342
8608
  * root from the named location's default instance. Useful for derivative
8343
8609
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18150,8 +18416,10 @@ var TrackSchema = object({
18150
18416
  lastSeen: number(),
18151
18417
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18152
18418
  positions: array(TrackPositionSchema).readonly(),
18153
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18154
- * saveThumbnails policy). */
18419
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18420
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18421
+ * the retired `saveThumbnails` used to gate this and the rolling
18422
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18155
18423
  snapshots: array(TrackSnapshotSchema).readonly(),
18156
18424
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18157
18425
  zonesVisited: array(string()).readonly(),
@@ -19011,6 +19279,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19011
19279
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19012
19280
  kind: "mutation",
19013
19281
  auth: "admin"
19282
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19283
+ kind: "query",
19284
+ auth: "admin"
19014
19285
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19015
19286
  kind: "query",
19016
19287
  auth: "admin"
@@ -21022,7 +21293,10 @@ method(object({
21022
21293
  }), StorageLocationSchema, {
21023
21294
  kind: "mutation",
21024
21295
  auth: "admin"
21025
- }), method(object({ id: string() }), _void(), {
21296
+ }), method(object({
21297
+ id: string(),
21298
+ force: boolean().optional()
21299
+ }), _void(), {
21026
21300
  kind: "mutation",
21027
21301
  auth: "admin"
21028
21302
  }), method(object({ id: string() }), object({
@@ -21071,6 +21345,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21071
21345
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21072
21346
  kind: "mutation",
21073
21347
  auth: "admin"
21348
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21349
+ kind: "mutation",
21350
+ auth: "admin"
21074
21351
  });
21075
21352
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21076
21353
  providerId: string().min(1),
@@ -21513,12 +21790,38 @@ response: record(string(), unknown()) }), object({
21513
21790
  *
21514
21791
  * ## Why this is a capability and not a helper
21515
21792
  *
21516
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21517
- * plate, vehicle, identity, and the event store's derivativesand every one of
21518
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21519
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21520
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21521
- * load 5,000 rows before ranking anything.
21793
+ * This capability was introduced with the claim that SIX stores in
21794
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
21795
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21796
+ * claim was never true, and leaving it here made five stores look like pending
21797
+ * work when three of them have no vector at all. Counted column by column on
21798
+ * 2026-08-30, exactly THREE ever held one:
21799
+ *
21800
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21801
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21802
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21803
+ * face, migrated 2026-08-30 into its OWN index (see below).
21804
+ *
21805
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21806
+ * and `identities` store a name; the event store stores no derivative vector.
21807
+ * They are not migration candidates and never were.
21808
+ *
21809
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21810
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21811
+ * rows before ranking anything.
21812
+ *
21813
+ * ## One index per COMPARISON, never per encoder
21814
+ *
21815
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21816
+ * model, and they still get two indexes. An index is a set of things that are
21817
+ * ranked against each other and that live and die together, and these two are
21818
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21819
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21820
+ * forever and is the gallery every recognition ranks against. One index would
21821
+ * mean every gallery load and every reconcile carried a filter whose failure
21822
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21823
+ * person's only sample. The dimension they share is not a reason to share an
21824
+ * index; the question they answer is, and it differs.
21522
21825
  *
21523
21826
  * The fix is not a faster loop, it is a different backend — and the backend
21524
21827
  * should be replaceable without touching six callers. So: a singleton
@@ -21623,7 +21926,20 @@ var VectorQueryResultSchema = object({
21623
21926
  */
21624
21927
  scanned: number(),
21625
21928
  /** True when the backend could not consider every row that passed the filter. */
21626
- truncated: boolean()
21929
+ truncated: boolean(),
21930
+ /**
21931
+ * The `topK` the backend actually ran with.
21932
+ *
21933
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21934
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21935
+ * own log rather than in its answer. That is how an audit asking for 20,000
21936
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21937
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21938
+ * MUCH, in the return value, where the caller cannot fail to see it.
21939
+ *
21940
+ * Equals the requested `topK` whenever nothing was lowered.
21941
+ */
21942
+ effectiveTopK: number().int().positive()
21627
21943
  });
21628
21944
  var VectorDeleteInputSchema = object({
21629
21945
  index: string(),
@@ -21652,6 +21968,68 @@ var VectorGetResultSchema = object({ items: array(object({
21652
21968
  id: string(),
21653
21969
  metadata: VectorMetadataSchema
21654
21970
  })) });
21971
+ /**
21972
+ * Ids to read back WITH their vectors.
21973
+ *
21974
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21975
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21976
+ * caller depends on that promise. This one promises the opposite.
21977
+ *
21978
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21979
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21980
+ * a per-face cross-process KNN would be a network round trip inside the
21981
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21982
+ * it requires the index to hand the floats back. Without this method the only
21983
+ * way to keep a readable vector is a JSON column, which is the thing this
21984
+ * capability exists to delete.
21985
+ *
21986
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21987
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21988
+ */
21989
+ var VectorFetchInputSchema = object({
21990
+ index: string(),
21991
+ ids: array(string())
21992
+ });
21993
+ var VectorFetchResultSchema = object({ items: array(object({
21994
+ id: string(),
21995
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21996
+ vector: string(),
21997
+ metadata: VectorMetadataSchema
21998
+ })) });
21999
+ /**
22000
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22001
+ *
22002
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22003
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22004
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22005
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22006
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22007
+ * looked" for as long as anyone cared to read it.
22008
+ *
22009
+ * This is the primitive that question actually needs: a bounded page, ordered
22010
+ * by the backend's own row order, costing no distance computation at all.
22011
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22012
+ * the full-table read this capability was built to stop.
22013
+ */
22014
+ var VectorScanInputSchema = object({
22015
+ index: string(),
22016
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22017
+ cursor: number().int().nonnegative().default(0),
22018
+ limit: number().int().positive()
22019
+ });
22020
+ var VectorScanResultSchema = object({
22021
+ items: array(object({
22022
+ id: string(),
22023
+ metadata: VectorMetadataSchema
22024
+ })),
22025
+ /**
22026
+ * Where the next page starts, or `null` when the walk reached the end.
22027
+ *
22028
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22029
+ * from a short page: a backend is free to return fewer rows than asked.
22030
+ */
22031
+ nextCursor: number().int().nonnegative().nullable()
22032
+ });
21655
22033
  var VectorStatsInputSchema = object({ index: string() });
21656
22034
  var VectorStatsResultSchema = object({
21657
22035
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21670,7 +22048,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21670
22048
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21671
22049
  kind: "mutation",
21672
22050
  auth: "admin"
21673
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22051
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21674
22052
  kind: "mutation",
21675
22053
  auth: "admin"
21676
22054
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28289,6 +28667,9 @@ method(object({
28289
28667
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28290
28668
  kind: "query",
28291
28669
  auth: "admin"
28670
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28671
+ kind: "query",
28672
+ auth: "admin"
28292
28673
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28293
28674
  kind: "mutation",
28294
28675
  auth: "admin"
@@ -34921,6 +35302,18 @@ Object.freeze({
34921
35302
  addonId: null,
34922
35303
  access: "create"
34923
35304
  },
35305
+ "pipelineAnalytics.countRelocatableMedia": {
35306
+ capName: "pipeline-analytics",
35307
+ capScope: "device",
35308
+ addonId: null,
35309
+ access: "view"
35310
+ },
35311
+ "pipelineAnalytics.countUnstampedEventMedia": {
35312
+ capName: "pipeline-analytics",
35313
+ capScope: "device",
35314
+ addonId: null,
35315
+ access: "view"
35316
+ },
34924
35317
  "pipelineAnalytics.deleteDeviceEvents": {
34925
35318
  capName: "pipeline-analytics",
34926
35319
  capScope: "device",
@@ -36079,6 +36472,12 @@ Object.freeze({
36079
36472
  addonId: null,
36080
36473
  access: "view"
36081
36474
  },
36475
+ "recording.getRelocateResidue": {
36476
+ capName: "recording",
36477
+ capScope: "system",
36478
+ addonId: null,
36479
+ access: "view"
36480
+ },
36082
36481
  "recording.getStorageMigrationMoveStatus": {
36083
36482
  capName: "recording",
36084
36483
  capScope: "system",
@@ -36625,12 +37024,30 @@ Object.freeze({
36625
37024
  addonId: null,
36626
37025
  access: "create"
36627
37026
  },
37027
+ "storageMigration.drain": {
37028
+ capName: "storage-migration",
37029
+ capScope: "system",
37030
+ addonId: null,
37031
+ access: "create"
37032
+ },
37033
+ "storageMigration.movers": {
37034
+ capName: "storage-migration",
37035
+ capScope: "system",
37036
+ addonId: null,
37037
+ access: "view"
37038
+ },
36628
37039
  "storageMigration.plan": {
36629
37040
  capName: "storage-migration",
36630
37041
  capScope: "system",
36631
37042
  addonId: null,
36632
37043
  access: "view"
36633
37044
  },
37045
+ "storageMigration.residue": {
37046
+ capName: "storage-migration",
37047
+ capScope: "system",
37048
+ addonId: null,
37049
+ access: "view"
37050
+ },
36634
37051
  "storageMigration.start": {
36635
37052
  capName: "storage-migration",
36636
37053
  capScope: "system",
@@ -37465,6 +37882,12 @@ Object.freeze({
37465
37882
  addonId: null,
37466
37883
  access: "delete"
37467
37884
  },
37885
+ "vectorStore.fetchByIds": {
37886
+ capName: "vector-store",
37887
+ capScope: "system",
37888
+ addonId: null,
37889
+ access: "view"
37890
+ },
37468
37891
  "vectorStore.getByIds": {
37469
37892
  capName: "vector-store",
37470
37893
  capScope: "system",
@@ -37477,6 +37900,12 @@ Object.freeze({
37477
37900
  addonId: null,
37478
37901
  access: "view"
37479
37902
  },
37903
+ "vectorStore.scan": {
37904
+ capName: "vector-store",
37905
+ capScope: "system",
37906
+ addonId: null,
37907
+ access: "view"
37908
+ },
37480
37909
  "vectorStore.stats": {
37481
37910
  capName: "vector-store",
37482
37911
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8115,18 +8115,61 @@ var RelocateFootageInputSchema = object({
8115
8115
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8116
8116
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8117
8117
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8118
+ /**
8119
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8120
+ * mover (the engine already walks both collections with a timestamp cursor and
8121
+ * already has a stamp-without-copy path).
8122
+ *
8123
+ * - `move` — the default and the historical behaviour: event-media and
8124
+ * retrain blobs move to `toLocationId` and their rows are
8125
+ * stamped. The enrolled gallery is skipped (D197).
8126
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8127
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8128
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8129
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8130
+ * instant a repoint moves that pointer the row reads from the
8131
+ * new disk while its bytes are on the old one.
8132
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8133
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8134
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8135
+ * never run beside a live second location: it is stop-the-world
8136
+ * by construction, which is acceptable only because the gallery
8137
+ * is a few KB per enrolled sample.
8138
+ */
8139
+ var MediaRelocateModeSchema = _enum([
8140
+ "move",
8141
+ "seal",
8142
+ "gallery"
8143
+ ]);
8118
8144
  var RelocateMediaInputSchema = object({
8119
8145
  toLocationId: string(),
8120
- throttleMbps: number().min(1).max(1e3).optional()
8146
+ throttleMbps: number().min(1).max(1e3).optional(),
8147
+ /** Omitted = `move`, the pre-existing behaviour. */
8148
+ mode: MediaRelocateModeSchema.optional()
8149
+ });
8150
+ /** How many rows still carry NO `locationId` — the population a repoint would
8151
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8152
+ * value that permits a non-blocking `eventMedia` cutover. */
8153
+ var UnstampedEventMediaCountSchema = object({
8154
+ media: number().int().nonnegative(),
8155
+ retrainFrames: number().int().nonnegative(),
8156
+ total: number().int().nonnegative()
8121
8157
  });
8122
8158
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8123
- /** The independently selectable logical storage classes. `recordings`
8124
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8125
- * segments; `eventMedia` is post-analysis blobs. */
8159
+ /** The independently selectable logical storage classes — every class
8160
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8161
+ * Zod enum error where they should meet an explanation.
8162
+ *
8163
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8164
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8165
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8166
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8126
8167
  var StorageMigrationClassSchema = _enum([
8127
8168
  "recordings",
8128
8169
  "recordingsLow",
8129
- "eventMedia"
8170
+ "eventMedia",
8171
+ "backups",
8172
+ "galleryMedia"
8130
8173
  ]);
8131
8174
  /** A destination is always an existing, fully-qualified location id. The
8132
8175
  * migration API intentionally never changes a source location's `basePath`:
@@ -8134,20 +8177,56 @@ var StorageMigrationClassSchema = _enum([
8134
8177
  var StorageMigrationDestinationsSchema = object({
8135
8178
  recordings: string().min(1).optional(),
8136
8179
  recordingsLow: string().min(1).optional(),
8137
- eventMedia: string().min(1).optional()
8180
+ eventMedia: string().min(1).optional(),
8181
+ backups: string().min(1).optional(),
8182
+ galleryMedia: string().min(1).optional()
8138
8183
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8184
+ /**
8185
+ * How a migration sequences the cutover against the byte move.
8186
+ *
8187
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8188
+ * resume. Recording is stopped for the whole move. Right
8189
+ * for a small or a cold class, and the only legal mode for
8190
+ * a `cardinality: 'single'` class.
8191
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8192
+ * refresh, resume, then move the past with everything
8193
+ * running. The pause is three bounded instants (a detach +
8194
+ * attach round, a write-gate drain, a lease) instead of one
8195
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8196
+ * stopped recording under `blocking`; the same move is
8197
+ * seconds of stopped recording under `nonBlocking`.
8198
+ *
8199
+ * The mode is on the JOB, not only on the input, because `status` is where an
8200
+ * operator finds out which one is running.
8201
+ */
8202
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8139
8203
  /** Shared input for planning and starting an orchestrated storage migration. */
8140
8204
  var StorageMigrationInputSchema = object({
8141
8205
  destinations: StorageMigrationDestinationsSchema,
8142
- throttleMbps: number().min(1).max(1e3).optional()
8206
+ throttleMbps: number().min(1).max(1e3).optional(),
8207
+ /** Omitted = `blocking`, which stays the default. */
8208
+ mode: StorageMigrationModeSchema.optional()
8143
8209
  });
8144
- /** The durable coordinator state machine. The only phase that changes default
8145
- * locations is `repointing`, after every selected mover has completed and been
8146
- * verified. */
8210
+ /**
8211
+ * The durable coordinator state machine.
8212
+ *
8213
+ * `blocking`:
8214
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8215
+ *
8216
+ * `nonBlocking`:
8217
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8218
+ *
8219
+ * Same phases, different order plus two new ones — not a second mover.
8220
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8221
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8222
+ * `repointing` is still the only phase that changes a default location.
8223
+ */
8147
8224
  var StorageMigrationPhaseSchema = _enum([
8148
8225
  "planning",
8226
+ "sealing",
8149
8227
  "pausing",
8150
8228
  "moving",
8229
+ "draining",
8151
8230
  "verifying",
8152
8231
  "repointing",
8153
8232
  "refreshing",
@@ -8161,17 +8240,56 @@ var StorageMigrationParticipantSchema = _enum([
8161
8240
  "recorder",
8162
8241
  "analytics"
8163
8242
  ]);
8243
+ /**
8244
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8245
+ *
8246
+ * The long half of a non-blocking migration is `draining`, and it is measured
8247
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8248
+ * existed the only place those numbers appeared was a Loki line, so an operator
8249
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8250
+ * afternoon.
8251
+ *
8252
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8253
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8254
+ * mover — which is the exact failure this is meant to end. The coordinator's
8255
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8256
+ * read `state`; folding the counters costs no extra read and makes the durable
8257
+ * record say afterwards how far a move actually got.
8258
+ *
8259
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8260
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8261
+ * cannot say M, and a 0 there would render as "100 % done".
8262
+ */
8263
+ var StorageMigrationMoveProgressSchema = object({
8264
+ filesMoved: number().int().nonnegative(),
8265
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8266
+ filesTotal: number().int().nonnegative().nullable(),
8267
+ bytesMoved: number().int().nonnegative(),
8268
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8269
+ * crash gets a new mover, and a rate computed from the migration's start
8270
+ * would silently average in the time nothing was running. */
8271
+ startedAt: number(),
8272
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8273
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8274
+ * subtract its own. */
8275
+ observedAt: number()
8276
+ });
8164
8277
  var StorageMigrationMoveSchema = object({
8165
8278
  storageClass: StorageMigrationClassSchema,
8166
8279
  fromLocationId: string(),
8167
8280
  toLocationId: string(),
8168
8281
  moverJobId: string().nullable(),
8169
8282
  state: RelocateJobStateSchema.nullable(),
8170
- error: string().nullable()
8283
+ error: string().nullable(),
8284
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8285
+ progress: StorageMigrationMoveProgressSchema.nullable()
8171
8286
  });
8172
8287
  var StorageMigrationJobSchema = object({
8173
8288
  jobId: string(),
8174
8289
  phase: StorageMigrationPhaseSchema,
8290
+ /** Which order this job is running. `status` is the only place an operator
8291
+ * can tell a seconds-long cutover from a thirty-hour one. */
8292
+ mode: StorageMigrationModeSchema,
8175
8293
  destinations: StorageMigrationDestinationsSchema,
8176
8294
  throttleMbps: number(),
8177
8295
  moves: array(StorageMigrationMoveSchema),
@@ -8184,13 +8302,122 @@ var StorageMigrationJobSchema = object({
8184
8302
  finishedAt: number().nullable(),
8185
8303
  error: string().nullable()
8186
8304
  });
8305
+ var StorageMigrationFindingSchema = object({
8306
+ code: _enum([
8307
+ "sharesDeviceWithSource",
8308
+ "deviceIdentityUnknown",
8309
+ "unstampedEventMediaRows",
8310
+ "blockingOnly",
8311
+ "noMover"
8312
+ ]),
8313
+ storageClass: StorageMigrationClassSchema,
8314
+ /** Human-readable, already carrying the ids and counts. */
8315
+ message: string()
8316
+ });
8187
8317
  var StorageMigrationPlanSchema = object({
8188
8318
  destinations: StorageMigrationDestinationsSchema,
8319
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8320
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8321
+ * it. */
8322
+ mode: StorageMigrationModeSchema,
8189
8323
  moves: array(object({
8190
8324
  storageClass: StorageMigrationClassSchema,
8191
8325
  fromLocationId: string(),
8192
8326
  toLocationId: string()
8193
- }))
8327
+ })),
8328
+ findings: array(StorageMigrationFindingSchema)
8329
+ });
8330
+ /**
8331
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8332
+ *
8333
+ * The coordinator's job record is the state of record for a migration, and its
8334
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8335
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8336
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8337
+ * way because no supported UI path existed. A mover armed like that has no job
8338
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8339
+ *
8340
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8341
+ * orchestrated it.
8342
+ */
8343
+ var StorageMigrationMoverSchema = object({
8344
+ lane: _enum(["footage", "media"]),
8345
+ job: RelocateJobSchema,
8346
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8347
+ * directly against the owning addon. */
8348
+ migrationJobId: string().nullable(),
8349
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8350
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8351
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8352
+ * rate made of two different clocks. */
8353
+ observedAt: number()
8354
+ });
8355
+ /**
8356
+ * What a SOURCE still holds for one storage class — the number that makes a
8357
+ * "drain remaining" action honest rather than hopeful.
8358
+ *
8359
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8360
+ * engine's own selection count for media), never from the resident index: a
8361
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8362
+ * never been told about (D295).
8363
+ *
8364
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8365
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8366
+ * because refusing on an unanswerable read would hide exactly the case an
8367
+ * operator needs to act on.
8368
+ */
8369
+ var StorageMigrationResidueSchema = object({
8370
+ storageClass: StorageMigrationClassSchema,
8371
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8372
+ * move from wherever they are rather than from one named source. */
8373
+ fromLocationId: string(),
8374
+ /** Where a drain would move it — the class's CURRENT default. */
8375
+ toLocationId: string(),
8376
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8377
+ items: number().int().nonnegative().nullable(),
8378
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8379
+ bytes: number().int().nonnegative().nullable()
8380
+ });
8381
+ /**
8382
+ * Run the DRAIN half and nothing else.
8383
+ *
8384
+ * A migration that reached `done` has already repointed, so `start` correctly
8385
+ * refuses its destination ("already the default") — there is nothing left to
8386
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8387
+ * or finish against a work list that was a tenth of the archive (D295), and
8388
+ * before this there was no supported way to run only that half: the only way
8389
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8390
+ *
8391
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8392
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8393
+ * re-repoint a class that is already migrated.
8394
+ */
8395
+ var StorageMigrationDrainInputSchema = object({
8396
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8397
+ * a class whose source is already empty is refused rather than started. */
8398
+ classes: array(StorageMigrationClassSchema).min(1),
8399
+ throttleMbps: number().min(1).max(1e3).optional()
8400
+ });
8401
+ /** What a footage source still holds, asked of the durable hour ledger. */
8402
+ var RelocateResidueInputSchema = object({
8403
+ fromLocationId: string().min(1),
8404
+ /** Narrow to one logical class; omit for every profile on the location. */
8405
+ footageClass: RelocateFootageClassSchema.optional()
8406
+ });
8407
+ /** `null` = the archive could not answer (no ledger on this node, or the
8408
+ * aggregate failed). Never conflated with an empty source. */
8409
+ var RelocateResidueSchema = object({
8410
+ segments: number().int().nonnegative(),
8411
+ bytes: number().int().nonnegative()
8412
+ }).nullable();
8413
+ /** How many rows a media pass would still act on against a given target — the
8414
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8415
+ * never disagree. `null` = the count could not be taken. */
8416
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8417
+ var RelocatableMediaCountInputSchema = object({
8418
+ toLocationId: string().min(1),
8419
+ /** Omitted = `move`. */
8420
+ mode: MediaRelocateModeSchema.optional()
8194
8421
  });
8195
8422
  /**
8196
8423
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8296,6 +8523,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8296
8523
  * two addons declaring the same `id` must agree on `cardinality` (validated
8297
8524
  * at kernel aggregation time, not here).
8298
8525
  */
8526
+ /**
8527
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8528
+ * actually reaches the bytes. It is the constraint that decides which
8529
+ * `storage-provider`s may back a location of that kind.
8530
+ *
8531
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8532
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8533
+ * post-analysis media roots). Only a provider that serves a genuine local
8534
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8535
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8536
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8537
+ * against a same-named local directory that is something else entirely.
8538
+ *
8539
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8540
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8541
+ * service never sees a path, so any provider can back it. `backups` is the
8542
+ * one kind that qualifies today.
8543
+ *
8544
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8545
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8546
+ * refused the configuration; the first write simply went somewhere wrong, and
8547
+ * a recording write that goes wrong surfaces as a silent black window rather
8548
+ * than an error (the read path does not `stat`). This turns that accident into
8549
+ * a declared, enforced, testable refusal.
8550
+ */
8551
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8299
8552
  var StorageLocationDeclarationSchema = object({
8300
8553
  /**
8301
8554
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8315,6 +8568,19 @@ var StorageLocationDeclarationSchema = object({
8315
8568
  */
8316
8569
  cardinality: _enum(["single", "multi"]),
8317
8570
  /**
8571
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8572
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8573
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8574
+ *
8575
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8576
+ * can only over-restrict (refuse a remote provider for a kind that might
8577
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8578
+ * permissive direction and is therefore never inferred — a repo guard
8579
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8580
+ * reached by omission.
8581
+ */
8582
+ access: StorageAccessSchema.optional(),
8583
+ /**
8318
8584
  * When set, the default instance for this location inherits its resolved
8319
8585
  * root from the named location's default instance. Useful for derivative
8320
8586
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18127,8 +18393,10 @@ var TrackSchema = object({
18127
18393
  lastSeen: number(),
18128
18394
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18129
18395
  positions: array(TrackPositionSchema).readonly(),
18130
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18131
- * saveThumbnails policy). */
18396
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18397
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18398
+ * the retired `saveThumbnails` used to gate this and the rolling
18399
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18132
18400
  snapshots: array(TrackSnapshotSchema).readonly(),
18133
18401
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18134
18402
  zonesVisited: array(string()).readonly(),
@@ -18988,6 +19256,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18988
19256
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18989
19257
  kind: "mutation",
18990
19258
  auth: "admin"
19259
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19260
+ kind: "query",
19261
+ auth: "admin"
18991
19262
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18992
19263
  kind: "query",
18993
19264
  auth: "admin"
@@ -20999,7 +21270,10 @@ method(object({
20999
21270
  }), StorageLocationSchema, {
21000
21271
  kind: "mutation",
21001
21272
  auth: "admin"
21002
- }), method(object({ id: string() }), _void(), {
21273
+ }), method(object({
21274
+ id: string(),
21275
+ force: boolean().optional()
21276
+ }), _void(), {
21003
21277
  kind: "mutation",
21004
21278
  auth: "admin"
21005
21279
  }), method(object({ id: string() }), object({
@@ -21048,6 +21322,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21048
21322
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21049
21323
  kind: "mutation",
21050
21324
  auth: "admin"
21325
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21326
+ kind: "mutation",
21327
+ auth: "admin"
21051
21328
  });
21052
21329
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21053
21330
  providerId: string().min(1),
@@ -21490,12 +21767,38 @@ response: record(string(), unknown()) }), object({
21490
21767
  *
21491
21768
  * ## Why this is a capability and not a helper
21492
21769
  *
21493
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21494
- * plate, vehicle, identity, and the event store's derivativesand every one of
21495
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21496
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21497
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21498
- * load 5,000 rows before ranking anything.
21770
+ * This capability was introduced with the claim that SIX stores in
21771
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
21772
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21773
+ * claim was never true, and leaving it here made five stores look like pending
21774
+ * work when three of them have no vector at all. Counted column by column on
21775
+ * 2026-08-30, exactly THREE ever held one:
21776
+ *
21777
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21778
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21779
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21780
+ * face, migrated 2026-08-30 into its OWN index (see below).
21781
+ *
21782
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21783
+ * and `identities` store a name; the event store stores no derivative vector.
21784
+ * They are not migration candidates and never were.
21785
+ *
21786
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21787
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21788
+ * rows before ranking anything.
21789
+ *
21790
+ * ## One index per COMPARISON, never per encoder
21791
+ *
21792
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21793
+ * model, and they still get two indexes. An index is a set of things that are
21794
+ * ranked against each other and that live and die together, and these two are
21795
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21796
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21797
+ * forever and is the gallery every recognition ranks against. One index would
21798
+ * mean every gallery load and every reconcile carried a filter whose failure
21799
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21800
+ * person's only sample. The dimension they share is not a reason to share an
21801
+ * index; the question they answer is, and it differs.
21499
21802
  *
21500
21803
  * The fix is not a faster loop, it is a different backend — and the backend
21501
21804
  * should be replaceable without touching six callers. So: a singleton
@@ -21600,7 +21903,20 @@ var VectorQueryResultSchema = object({
21600
21903
  */
21601
21904
  scanned: number(),
21602
21905
  /** True when the backend could not consider every row that passed the filter. */
21603
- truncated: boolean()
21906
+ truncated: boolean(),
21907
+ /**
21908
+ * The `topK` the backend actually ran with.
21909
+ *
21910
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21911
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21912
+ * own log rather than in its answer. That is how an audit asking for 20,000
21913
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21914
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21915
+ * MUCH, in the return value, where the caller cannot fail to see it.
21916
+ *
21917
+ * Equals the requested `topK` whenever nothing was lowered.
21918
+ */
21919
+ effectiveTopK: number().int().positive()
21604
21920
  });
21605
21921
  var VectorDeleteInputSchema = object({
21606
21922
  index: string(),
@@ -21629,6 +21945,68 @@ var VectorGetResultSchema = object({ items: array(object({
21629
21945
  id: string(),
21630
21946
  metadata: VectorMetadataSchema
21631
21947
  })) });
21948
+ /**
21949
+ * Ids to read back WITH their vectors.
21950
+ *
21951
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21952
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21953
+ * caller depends on that promise. This one promises the opposite.
21954
+ *
21955
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21956
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21957
+ * a per-face cross-process KNN would be a network round trip inside the
21958
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21959
+ * it requires the index to hand the floats back. Without this method the only
21960
+ * way to keep a readable vector is a JSON column, which is the thing this
21961
+ * capability exists to delete.
21962
+ *
21963
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21964
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21965
+ */
21966
+ var VectorFetchInputSchema = object({
21967
+ index: string(),
21968
+ ids: array(string())
21969
+ });
21970
+ var VectorFetchResultSchema = object({ items: array(object({
21971
+ id: string(),
21972
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21973
+ vector: string(),
21974
+ metadata: VectorMetadataSchema
21975
+ })) });
21976
+ /**
21977
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21978
+ *
21979
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21980
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21981
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21982
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21983
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21984
+ * looked" for as long as anyone cared to read it.
21985
+ *
21986
+ * This is the primitive that question actually needs: a bounded page, ordered
21987
+ * by the backend's own row order, costing no distance computation at all.
21988
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21989
+ * the full-table read this capability was built to stop.
21990
+ */
21991
+ var VectorScanInputSchema = object({
21992
+ index: string(),
21993
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21994
+ cursor: number().int().nonnegative().default(0),
21995
+ limit: number().int().positive()
21996
+ });
21997
+ var VectorScanResultSchema = object({
21998
+ items: array(object({
21999
+ id: string(),
22000
+ metadata: VectorMetadataSchema
22001
+ })),
22002
+ /**
22003
+ * Where the next page starts, or `null` when the walk reached the end.
22004
+ *
22005
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22006
+ * from a short page: a backend is free to return fewer rows than asked.
22007
+ */
22008
+ nextCursor: number().int().nonnegative().nullable()
22009
+ });
21632
22010
  var VectorStatsInputSchema = object({ index: string() });
21633
22011
  var VectorStatsResultSchema = object({
21634
22012
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21647,7 +22025,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21647
22025
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21648
22026
  kind: "mutation",
21649
22027
  auth: "admin"
21650
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22028
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21651
22029
  kind: "mutation",
21652
22030
  auth: "admin"
21653
22031
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28266,6 +28644,9 @@ method(object({
28266
28644
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28267
28645
  kind: "query",
28268
28646
  auth: "admin"
28647
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28648
+ kind: "query",
28649
+ auth: "admin"
28269
28650
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28270
28651
  kind: "mutation",
28271
28652
  auth: "admin"
@@ -34898,6 +35279,18 @@ Object.freeze({
34898
35279
  addonId: null,
34899
35280
  access: "create"
34900
35281
  },
35282
+ "pipelineAnalytics.countRelocatableMedia": {
35283
+ capName: "pipeline-analytics",
35284
+ capScope: "device",
35285
+ addonId: null,
35286
+ access: "view"
35287
+ },
35288
+ "pipelineAnalytics.countUnstampedEventMedia": {
35289
+ capName: "pipeline-analytics",
35290
+ capScope: "device",
35291
+ addonId: null,
35292
+ access: "view"
35293
+ },
34901
35294
  "pipelineAnalytics.deleteDeviceEvents": {
34902
35295
  capName: "pipeline-analytics",
34903
35296
  capScope: "device",
@@ -36056,6 +36449,12 @@ Object.freeze({
36056
36449
  addonId: null,
36057
36450
  access: "view"
36058
36451
  },
36452
+ "recording.getRelocateResidue": {
36453
+ capName: "recording",
36454
+ capScope: "system",
36455
+ addonId: null,
36456
+ access: "view"
36457
+ },
36059
36458
  "recording.getStorageMigrationMoveStatus": {
36060
36459
  capName: "recording",
36061
36460
  capScope: "system",
@@ -36602,12 +37001,30 @@ Object.freeze({
36602
37001
  addonId: null,
36603
37002
  access: "create"
36604
37003
  },
37004
+ "storageMigration.drain": {
37005
+ capName: "storage-migration",
37006
+ capScope: "system",
37007
+ addonId: null,
37008
+ access: "create"
37009
+ },
37010
+ "storageMigration.movers": {
37011
+ capName: "storage-migration",
37012
+ capScope: "system",
37013
+ addonId: null,
37014
+ access: "view"
37015
+ },
36605
37016
  "storageMigration.plan": {
36606
37017
  capName: "storage-migration",
36607
37018
  capScope: "system",
36608
37019
  addonId: null,
36609
37020
  access: "view"
36610
37021
  },
37022
+ "storageMigration.residue": {
37023
+ capName: "storage-migration",
37024
+ capScope: "system",
37025
+ addonId: null,
37026
+ access: "view"
37027
+ },
36611
37028
  "storageMigration.start": {
36612
37029
  capName: "storage-migration",
36613
37030
  capScope: "system",
@@ -37442,6 +37859,12 @@ Object.freeze({
37442
37859
  addonId: null,
37443
37860
  access: "delete"
37444
37861
  },
37862
+ "vectorStore.fetchByIds": {
37863
+ capName: "vector-store",
37864
+ capScope: "system",
37865
+ addonId: null,
37866
+ access: "view"
37867
+ },
37445
37868
  "vectorStore.getByIds": {
37446
37869
  capName: "vector-store",
37447
37870
  capScope: "system",
@@ -37454,6 +37877,12 @@ Object.freeze({
37454
37877
  addonId: null,
37455
37878
  access: "view"
37456
37879
  },
37880
+ "vectorStore.scan": {
37881
+ capName: "vector-store",
37882
+ capScope: "system",
37883
+ addonId: null,
37884
+ access: "view"
37885
+ },
37457
37886
  "vectorStore.stats": {
37458
37887
  capName: "vector-store",
37459
37888
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-terminal",
3
- "version": "0.1.47",
3
+ "version": "0.1.50",
4
4
  "description": "Interactive terminal sessions (pty + xterm) as a CamStack addon",
5
5
  "keywords": [
6
6
  "camstack",