@camstack/addon-decoder-nodeav 1.2.42 → 1.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/index.js +452 -23
  2. package/dist/index.mjs +452 -23
  3. package/package.json +1 -1
package/dist/index.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
@@ -17894,8 +18160,10 @@ var TrackSchema = object({
17894
18160
  lastSeen: number(),
17895
18161
  /** Frame-rate position history (subject to maxPositionHistory cap). */
17896
18162
  positions: array(TrackPositionSchema).readonly(),
17897
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17898
- * saveThumbnails policy). */
18163
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18164
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18165
+ * the retired `saveThumbnails` used to gate this and the rolling
18166
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
17899
18167
  snapshots: array(TrackSnapshotSchema).readonly(),
17900
18168
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
17901
18169
  zonesVisited: array(string()).readonly(),
@@ -18755,6 +19023,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18755
19023
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18756
19024
  kind: "mutation",
18757
19025
  auth: "admin"
19026
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19027
+ kind: "query",
19028
+ auth: "admin"
18758
19029
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18759
19030
  kind: "query",
18760
19031
  auth: "admin"
@@ -20662,7 +20933,10 @@ method(object({
20662
20933
  }), StorageLocationSchema, {
20663
20934
  kind: "mutation",
20664
20935
  auth: "admin"
20665
- }), method(object({ id: string() }), _void(), {
20936
+ }), method(object({
20937
+ id: string(),
20938
+ force: boolean().optional()
20939
+ }), _void(), {
20666
20940
  kind: "mutation",
20667
20941
  auth: "admin"
20668
20942
  }), method(object({ id: string() }), object({
@@ -20711,6 +20985,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20711
20985
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20712
20986
  kind: "mutation",
20713
20987
  auth: "admin"
20988
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
20989
+ kind: "mutation",
20990
+ auth: "admin"
20714
20991
  });
20715
20992
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20716
20993
  providerId: string().min(1),
@@ -21109,12 +21386,38 @@ response: record(string(), unknown()) }), object({
21109
21386
  *
21110
21387
  * ## Why this is a capability and not a helper
21111
21388
  *
21112
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21113
- * plate, vehicle, identity, and the event store's derivativesand every one of
21114
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21115
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21116
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21117
- * load 5,000 rows before ranking anything.
21389
+ * This capability was introduced with the claim that SIX stores in
21390
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
21391
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21392
+ * claim was never true, and leaving it here made five stores look like pending
21393
+ * work when three of them have no vector at all. Counted column by column on
21394
+ * 2026-08-30, exactly THREE ever held one:
21395
+ *
21396
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21397
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21398
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21399
+ * face, migrated 2026-08-30 into its OWN index (see below).
21400
+ *
21401
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21402
+ * and `identities` store a name; the event store stores no derivative vector.
21403
+ * They are not migration candidates and never were.
21404
+ *
21405
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21406
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21407
+ * rows before ranking anything.
21408
+ *
21409
+ * ## One index per COMPARISON, never per encoder
21410
+ *
21411
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21412
+ * model, and they still get two indexes. An index is a set of things that are
21413
+ * ranked against each other and that live and die together, and these two are
21414
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21415
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21416
+ * forever and is the gallery every recognition ranks against. One index would
21417
+ * mean every gallery load and every reconcile carried a filter whose failure
21418
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21419
+ * person's only sample. The dimension they share is not a reason to share an
21420
+ * index; the question they answer is, and it differs.
21118
21421
  *
21119
21422
  * The fix is not a faster loop, it is a different backend — and the backend
21120
21423
  * should be replaceable without touching six callers. So: a singleton
@@ -21219,7 +21522,20 @@ var VectorQueryResultSchema = object({
21219
21522
  */
21220
21523
  scanned: number(),
21221
21524
  /** True when the backend could not consider every row that passed the filter. */
21222
- truncated: boolean()
21525
+ truncated: boolean(),
21526
+ /**
21527
+ * The `topK` the backend actually ran with.
21528
+ *
21529
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21530
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21531
+ * own log rather than in its answer. That is how an audit asking for 20,000
21532
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21533
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21534
+ * MUCH, in the return value, where the caller cannot fail to see it.
21535
+ *
21536
+ * Equals the requested `topK` whenever nothing was lowered.
21537
+ */
21538
+ effectiveTopK: number().int().positive()
21223
21539
  });
21224
21540
  var VectorDeleteInputSchema = object({
21225
21541
  index: string(),
@@ -21248,6 +21564,68 @@ var VectorGetResultSchema = object({ items: array(object({
21248
21564
  id: string(),
21249
21565
  metadata: VectorMetadataSchema
21250
21566
  })) });
21567
+ /**
21568
+ * Ids to read back WITH their vectors.
21569
+ *
21570
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21571
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21572
+ * caller depends on that promise. This one promises the opposite.
21573
+ *
21574
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21575
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21576
+ * a per-face cross-process KNN would be a network round trip inside the
21577
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21578
+ * it requires the index to hand the floats back. Without this method the only
21579
+ * way to keep a readable vector is a JSON column, which is the thing this
21580
+ * capability exists to delete.
21581
+ *
21582
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21583
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21584
+ */
21585
+ var VectorFetchInputSchema = object({
21586
+ index: string(),
21587
+ ids: array(string())
21588
+ });
21589
+ var VectorFetchResultSchema = object({ items: array(object({
21590
+ id: string(),
21591
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21592
+ vector: string(),
21593
+ metadata: VectorMetadataSchema
21594
+ })) });
21595
+ /**
21596
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21597
+ *
21598
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21599
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21600
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21601
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21602
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21603
+ * looked" for as long as anyone cared to read it.
21604
+ *
21605
+ * This is the primitive that question actually needs: a bounded page, ordered
21606
+ * by the backend's own row order, costing no distance computation at all.
21607
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21608
+ * the full-table read this capability was built to stop.
21609
+ */
21610
+ var VectorScanInputSchema = object({
21611
+ index: string(),
21612
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21613
+ cursor: number().int().nonnegative().default(0),
21614
+ limit: number().int().positive()
21615
+ });
21616
+ var VectorScanResultSchema = object({
21617
+ items: array(object({
21618
+ id: string(),
21619
+ metadata: VectorMetadataSchema
21620
+ })),
21621
+ /**
21622
+ * Where the next page starts, or `null` when the walk reached the end.
21623
+ *
21624
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21625
+ * from a short page: a backend is free to return fewer rows than asked.
21626
+ */
21627
+ nextCursor: number().int().nonnegative().nullable()
21628
+ });
21251
21629
  var VectorStatsInputSchema = object({ index: string() });
21252
21630
  var VectorStatsResultSchema = object({
21253
21631
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21266,7 +21644,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21266
21644
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21267
21645
  kind: "mutation",
21268
21646
  auth: "admin"
21269
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21647
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21270
21648
  kind: "mutation",
21271
21649
  auth: "admin"
21272
21650
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -26170,6 +26548,9 @@ method(object({
26170
26548
  }), method(object({}), array(RelocateJobSchema).readonly(), {
26171
26549
  kind: "query",
26172
26550
  auth: "admin"
26551
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
26552
+ kind: "query",
26553
+ auth: "admin"
26173
26554
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26174
26555
  kind: "mutation",
26175
26556
  auth: "admin"
@@ -31135,6 +31516,18 @@ Object.freeze({
31135
31516
  addonId: null,
31136
31517
  access: "create"
31137
31518
  },
31519
+ "pipelineAnalytics.countRelocatableMedia": {
31520
+ capName: "pipeline-analytics",
31521
+ capScope: "device",
31522
+ addonId: null,
31523
+ access: "view"
31524
+ },
31525
+ "pipelineAnalytics.countUnstampedEventMedia": {
31526
+ capName: "pipeline-analytics",
31527
+ capScope: "device",
31528
+ addonId: null,
31529
+ access: "view"
31530
+ },
31138
31531
  "pipelineAnalytics.deleteDeviceEvents": {
31139
31532
  capName: "pipeline-analytics",
31140
31533
  capScope: "device",
@@ -32293,6 +32686,12 @@ Object.freeze({
32293
32686
  addonId: null,
32294
32687
  access: "view"
32295
32688
  },
32689
+ "recording.getRelocateResidue": {
32690
+ capName: "recording",
32691
+ capScope: "system",
32692
+ addonId: null,
32693
+ access: "view"
32694
+ },
32296
32695
  "recording.getStorageMigrationMoveStatus": {
32297
32696
  capName: "recording",
32298
32697
  capScope: "system",
@@ -32839,12 +33238,30 @@ Object.freeze({
32839
33238
  addonId: null,
32840
33239
  access: "create"
32841
33240
  },
33241
+ "storageMigration.drain": {
33242
+ capName: "storage-migration",
33243
+ capScope: "system",
33244
+ addonId: null,
33245
+ access: "create"
33246
+ },
33247
+ "storageMigration.movers": {
33248
+ capName: "storage-migration",
33249
+ capScope: "system",
33250
+ addonId: null,
33251
+ access: "view"
33252
+ },
32842
33253
  "storageMigration.plan": {
32843
33254
  capName: "storage-migration",
32844
33255
  capScope: "system",
32845
33256
  addonId: null,
32846
33257
  access: "view"
32847
33258
  },
33259
+ "storageMigration.residue": {
33260
+ capName: "storage-migration",
33261
+ capScope: "system",
33262
+ addonId: null,
33263
+ access: "view"
33264
+ },
32848
33265
  "storageMigration.start": {
32849
33266
  capName: "storage-migration",
32850
33267
  capScope: "system",
@@ -33679,6 +34096,12 @@ Object.freeze({
33679
34096
  addonId: null,
33680
34097
  access: "delete"
33681
34098
  },
34099
+ "vectorStore.fetchByIds": {
34100
+ capName: "vector-store",
34101
+ capScope: "system",
34102
+ addonId: null,
34103
+ access: "view"
34104
+ },
33682
34105
  "vectorStore.getByIds": {
33683
34106
  capName: "vector-store",
33684
34107
  capScope: "system",
@@ -33691,6 +34114,12 @@ Object.freeze({
33691
34114
  addonId: null,
33692
34115
  access: "view"
33693
34116
  },
34117
+ "vectorStore.scan": {
34118
+ capName: "vector-store",
34119
+ capScope: "system",
34120
+ addonId: null,
34121
+ access: "view"
34122
+ },
33694
34123
  "vectorStore.stats": {
33695
34124
  capName: "vector-store",
33696
34125
  capScope: "system",
package/dist/index.mjs CHANGED
@@ -8035,18 +8035,61 @@ var RelocateFootageInputSchema = object({
8035
8035
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8036
8036
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8037
8037
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8038
+ /**
8039
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8040
+ * mover (the engine already walks both collections with a timestamp cursor and
8041
+ * already has a stamp-without-copy path).
8042
+ *
8043
+ * - `move` — the default and the historical behaviour: event-media and
8044
+ * retrain blobs move to `toLocationId` and their rows are
8045
+ * stamped. The enrolled gallery is skipped (D197).
8046
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8047
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8048
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8049
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8050
+ * instant a repoint moves that pointer the row reads from the
8051
+ * new disk while its bytes are on the old one.
8052
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8053
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8054
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8055
+ * never run beside a live second location: it is stop-the-world
8056
+ * by construction, which is acceptable only because the gallery
8057
+ * is a few KB per enrolled sample.
8058
+ */
8059
+ var MediaRelocateModeSchema = _enum([
8060
+ "move",
8061
+ "seal",
8062
+ "gallery"
8063
+ ]);
8038
8064
  var RelocateMediaInputSchema = object({
8039
8065
  toLocationId: string(),
8040
- throttleMbps: number().min(1).max(1e3).optional()
8066
+ throttleMbps: number().min(1).max(1e3).optional(),
8067
+ /** Omitted = `move`, the pre-existing behaviour. */
8068
+ mode: MediaRelocateModeSchema.optional()
8069
+ });
8070
+ /** How many rows still carry NO `locationId` — the population a repoint would
8071
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8072
+ * value that permits a non-blocking `eventMedia` cutover. */
8073
+ var UnstampedEventMediaCountSchema = object({
8074
+ media: number().int().nonnegative(),
8075
+ retrainFrames: number().int().nonnegative(),
8076
+ total: number().int().nonnegative()
8041
8077
  });
8042
8078
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8043
- /** The independently selectable logical storage classes. `recordings`
8044
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8045
- * segments; `eventMedia` is post-analysis blobs. */
8079
+ /** The independently selectable logical storage classes — every class
8080
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8081
+ * Zod enum error where they should meet an explanation.
8082
+ *
8083
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8084
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8085
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8086
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8046
8087
  var StorageMigrationClassSchema = _enum([
8047
8088
  "recordings",
8048
8089
  "recordingsLow",
8049
- "eventMedia"
8090
+ "eventMedia",
8091
+ "backups",
8092
+ "galleryMedia"
8050
8093
  ]);
8051
8094
  /** A destination is always an existing, fully-qualified location id. The
8052
8095
  * migration API intentionally never changes a source location's `basePath`:
@@ -8054,20 +8097,56 @@ var StorageMigrationClassSchema = _enum([
8054
8097
  var StorageMigrationDestinationsSchema = object({
8055
8098
  recordings: string().min(1).optional(),
8056
8099
  recordingsLow: string().min(1).optional(),
8057
- eventMedia: string().min(1).optional()
8100
+ eventMedia: string().min(1).optional(),
8101
+ backups: string().min(1).optional(),
8102
+ galleryMedia: string().min(1).optional()
8058
8103
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8104
+ /**
8105
+ * How a migration sequences the cutover against the byte move.
8106
+ *
8107
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8108
+ * resume. Recording is stopped for the whole move. Right
8109
+ * for a small or a cold class, and the only legal mode for
8110
+ * a `cardinality: 'single'` class.
8111
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8112
+ * refresh, resume, then move the past with everything
8113
+ * running. The pause is three bounded instants (a detach +
8114
+ * attach round, a write-gate drain, a lease) instead of one
8115
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8116
+ * stopped recording under `blocking`; the same move is
8117
+ * seconds of stopped recording under `nonBlocking`.
8118
+ *
8119
+ * The mode is on the JOB, not only on the input, because `status` is where an
8120
+ * operator finds out which one is running.
8121
+ */
8122
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8059
8123
  /** Shared input for planning and starting an orchestrated storage migration. */
8060
8124
  var StorageMigrationInputSchema = object({
8061
8125
  destinations: StorageMigrationDestinationsSchema,
8062
- throttleMbps: number().min(1).max(1e3).optional()
8126
+ throttleMbps: number().min(1).max(1e3).optional(),
8127
+ /** Omitted = `blocking`, which stays the default. */
8128
+ mode: StorageMigrationModeSchema.optional()
8063
8129
  });
8064
- /** The durable coordinator state machine. The only phase that changes default
8065
- * locations is `repointing`, after every selected mover has completed and been
8066
- * verified. */
8130
+ /**
8131
+ * The durable coordinator state machine.
8132
+ *
8133
+ * `blocking`:
8134
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8135
+ *
8136
+ * `nonBlocking`:
8137
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8138
+ *
8139
+ * Same phases, different order plus two new ones — not a second mover.
8140
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8141
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8142
+ * `repointing` is still the only phase that changes a default location.
8143
+ */
8067
8144
  var StorageMigrationPhaseSchema = _enum([
8068
8145
  "planning",
8146
+ "sealing",
8069
8147
  "pausing",
8070
8148
  "moving",
8149
+ "draining",
8071
8150
  "verifying",
8072
8151
  "repointing",
8073
8152
  "refreshing",
@@ -8081,17 +8160,56 @@ var StorageMigrationParticipantSchema = _enum([
8081
8160
  "recorder",
8082
8161
  "analytics"
8083
8162
  ]);
8163
+ /**
8164
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8165
+ *
8166
+ * The long half of a non-blocking migration is `draining`, and it is measured
8167
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8168
+ * existed the only place those numbers appeared was a Loki line, so an operator
8169
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8170
+ * afternoon.
8171
+ *
8172
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8173
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8174
+ * mover — which is the exact failure this is meant to end. The coordinator's
8175
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8176
+ * read `state`; folding the counters costs no extra read and makes the durable
8177
+ * record say afterwards how far a move actually got.
8178
+ *
8179
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8180
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8181
+ * cannot say M, and a 0 there would render as "100 % done".
8182
+ */
8183
+ var StorageMigrationMoveProgressSchema = object({
8184
+ filesMoved: number().int().nonnegative(),
8185
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8186
+ filesTotal: number().int().nonnegative().nullable(),
8187
+ bytesMoved: number().int().nonnegative(),
8188
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8189
+ * crash gets a new mover, and a rate computed from the migration's start
8190
+ * would silently average in the time nothing was running. */
8191
+ startedAt: number(),
8192
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8193
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8194
+ * subtract its own. */
8195
+ observedAt: number()
8196
+ });
8084
8197
  var StorageMigrationMoveSchema = object({
8085
8198
  storageClass: StorageMigrationClassSchema,
8086
8199
  fromLocationId: string(),
8087
8200
  toLocationId: string(),
8088
8201
  moverJobId: string().nullable(),
8089
8202
  state: RelocateJobStateSchema.nullable(),
8090
- error: string().nullable()
8203
+ error: string().nullable(),
8204
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8205
+ progress: StorageMigrationMoveProgressSchema.nullable()
8091
8206
  });
8092
8207
  var StorageMigrationJobSchema = object({
8093
8208
  jobId: string(),
8094
8209
  phase: StorageMigrationPhaseSchema,
8210
+ /** Which order this job is running. `status` is the only place an operator
8211
+ * can tell a seconds-long cutover from a thirty-hour one. */
8212
+ mode: StorageMigrationModeSchema,
8095
8213
  destinations: StorageMigrationDestinationsSchema,
8096
8214
  throttleMbps: number(),
8097
8215
  moves: array(StorageMigrationMoveSchema),
@@ -8104,13 +8222,122 @@ var StorageMigrationJobSchema = object({
8104
8222
  finishedAt: number().nullable(),
8105
8223
  error: string().nullable()
8106
8224
  });
8225
+ var StorageMigrationFindingSchema = object({
8226
+ code: _enum([
8227
+ "sharesDeviceWithSource",
8228
+ "deviceIdentityUnknown",
8229
+ "unstampedEventMediaRows",
8230
+ "blockingOnly",
8231
+ "noMover"
8232
+ ]),
8233
+ storageClass: StorageMigrationClassSchema,
8234
+ /** Human-readable, already carrying the ids and counts. */
8235
+ message: string()
8236
+ });
8107
8237
  var StorageMigrationPlanSchema = object({
8108
8238
  destinations: StorageMigrationDestinationsSchema,
8239
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8240
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8241
+ * it. */
8242
+ mode: StorageMigrationModeSchema,
8109
8243
  moves: array(object({
8110
8244
  storageClass: StorageMigrationClassSchema,
8111
8245
  fromLocationId: string(),
8112
8246
  toLocationId: string()
8113
- }))
8247
+ })),
8248
+ findings: array(StorageMigrationFindingSchema)
8249
+ });
8250
+ /**
8251
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8252
+ *
8253
+ * The coordinator's job record is the state of record for a migration, and its
8254
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8255
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8256
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8257
+ * way because no supported UI path existed. A mover armed like that has no job
8258
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8259
+ *
8260
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8261
+ * orchestrated it.
8262
+ */
8263
+ var StorageMigrationMoverSchema = object({
8264
+ lane: _enum(["footage", "media"]),
8265
+ job: RelocateJobSchema,
8266
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8267
+ * directly against the owning addon. */
8268
+ migrationJobId: string().nullable(),
8269
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8270
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8271
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8272
+ * rate made of two different clocks. */
8273
+ observedAt: number()
8274
+ });
8275
+ /**
8276
+ * What a SOURCE still holds for one storage class — the number that makes a
8277
+ * "drain remaining" action honest rather than hopeful.
8278
+ *
8279
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8280
+ * engine's own selection count for media), never from the resident index: a
8281
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8282
+ * never been told about (D295).
8283
+ *
8284
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8285
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8286
+ * because refusing on an unanswerable read would hide exactly the case an
8287
+ * operator needs to act on.
8288
+ */
8289
+ var StorageMigrationResidueSchema = object({
8290
+ storageClass: StorageMigrationClassSchema,
8291
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8292
+ * move from wherever they are rather than from one named source. */
8293
+ fromLocationId: string(),
8294
+ /** Where a drain would move it — the class's CURRENT default. */
8295
+ toLocationId: string(),
8296
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8297
+ items: number().int().nonnegative().nullable(),
8298
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8299
+ bytes: number().int().nonnegative().nullable()
8300
+ });
8301
+ /**
8302
+ * Run the DRAIN half and nothing else.
8303
+ *
8304
+ * A migration that reached `done` has already repointed, so `start` correctly
8305
+ * refuses its destination ("already the default") — there is nothing left to
8306
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8307
+ * or finish against a work list that was a tenth of the archive (D295), and
8308
+ * before this there was no supported way to run only that half: the only way
8309
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8310
+ *
8311
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8312
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8313
+ * re-repoint a class that is already migrated.
8314
+ */
8315
+ var StorageMigrationDrainInputSchema = object({
8316
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8317
+ * a class whose source is already empty is refused rather than started. */
8318
+ classes: array(StorageMigrationClassSchema).min(1),
8319
+ throttleMbps: number().min(1).max(1e3).optional()
8320
+ });
8321
+ /** What a footage source still holds, asked of the durable hour ledger. */
8322
+ var RelocateResidueInputSchema = object({
8323
+ fromLocationId: string().min(1),
8324
+ /** Narrow to one logical class; omit for every profile on the location. */
8325
+ footageClass: RelocateFootageClassSchema.optional()
8326
+ });
8327
+ /** `null` = the archive could not answer (no ledger on this node, or the
8328
+ * aggregate failed). Never conflated with an empty source. */
8329
+ var RelocateResidueSchema = object({
8330
+ segments: number().int().nonnegative(),
8331
+ bytes: number().int().nonnegative()
8332
+ }).nullable();
8333
+ /** How many rows a media pass would still act on against a given target — the
8334
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8335
+ * never disagree. `null` = the count could not be taken. */
8336
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8337
+ var RelocatableMediaCountInputSchema = object({
8338
+ toLocationId: string().min(1),
8339
+ /** Omitted = `move`. */
8340
+ mode: MediaRelocateModeSchema.optional()
8114
8341
  });
8115
8342
  /**
8116
8343
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8216,6 +8443,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8216
8443
  * two addons declaring the same `id` must agree on `cardinality` (validated
8217
8444
  * at kernel aggregation time, not here).
8218
8445
  */
8446
+ /**
8447
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8448
+ * actually reaches the bytes. It is the constraint that decides which
8449
+ * `storage-provider`s may back a location of that kind.
8450
+ *
8451
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8452
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8453
+ * post-analysis media roots). Only a provider that serves a genuine local
8454
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8455
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8456
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8457
+ * against a same-named local directory that is something else entirely.
8458
+ *
8459
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8460
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8461
+ * service never sees a path, so any provider can back it. `backups` is the
8462
+ * one kind that qualifies today.
8463
+ *
8464
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8465
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8466
+ * refused the configuration; the first write simply went somewhere wrong, and
8467
+ * a recording write that goes wrong surfaces as a silent black window rather
8468
+ * than an error (the read path does not `stat`). This turns that accident into
8469
+ * a declared, enforced, testable refusal.
8470
+ */
8471
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8219
8472
  var StorageLocationDeclarationSchema = object({
8220
8473
  /**
8221
8474
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8235,6 +8488,19 @@ var StorageLocationDeclarationSchema = object({
8235
8488
  */
8236
8489
  cardinality: _enum(["single", "multi"]),
8237
8490
  /**
8491
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8492
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8493
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8494
+ *
8495
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8496
+ * can only over-restrict (refuse a remote provider for a kind that might
8497
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8498
+ * permissive direction and is therefore never inferred — a repo guard
8499
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8500
+ * reached by omission.
8501
+ */
8502
+ access: StorageAccessSchema.optional(),
8503
+ /**
8238
8504
  * When set, the default instance for this location inherits its resolved
8239
8505
  * root from the named location's default instance. Useful for derivative
8240
8506
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -17890,8 +18156,10 @@ var TrackSchema = object({
17890
18156
  lastSeen: number(),
17891
18157
  /** Frame-rate position history (subject to maxPositionHistory cap). */
17892
18158
  positions: array(TrackPositionSchema).readonly(),
17893
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17894
- * saveThumbnails policy). */
18159
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18160
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18161
+ * the retired `saveThumbnails` used to gate this and the rolling
18162
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
17895
18163
  snapshots: array(TrackSnapshotSchema).readonly(),
17896
18164
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
17897
18165
  zonesVisited: array(string()).readonly(),
@@ -18751,6 +19019,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18751
19019
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18752
19020
  kind: "mutation",
18753
19021
  auth: "admin"
19022
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19023
+ kind: "query",
19024
+ auth: "admin"
18754
19025
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18755
19026
  kind: "query",
18756
19027
  auth: "admin"
@@ -20658,7 +20929,10 @@ method(object({
20658
20929
  }), StorageLocationSchema, {
20659
20930
  kind: "mutation",
20660
20931
  auth: "admin"
20661
- }), method(object({ id: string() }), _void(), {
20932
+ }), method(object({
20933
+ id: string(),
20934
+ force: boolean().optional()
20935
+ }), _void(), {
20662
20936
  kind: "mutation",
20663
20937
  auth: "admin"
20664
20938
  }), method(object({ id: string() }), object({
@@ -20707,6 +20981,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20707
20981
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20708
20982
  kind: "mutation",
20709
20983
  auth: "admin"
20984
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
20985
+ kind: "mutation",
20986
+ auth: "admin"
20710
20987
  });
20711
20988
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20712
20989
  providerId: string().min(1),
@@ -21105,12 +21382,38 @@ response: record(string(), unknown()) }), object({
21105
21382
  *
21106
21383
  * ## Why this is a capability and not a helper
21107
21384
  *
21108
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21109
- * plate, vehicle, identity, and the event store's derivativesand every one of
21110
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21111
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21112
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21113
- * load 5,000 rows before ranking anything.
21385
+ * This capability was introduced with the claim that SIX stores in
21386
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
21387
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21388
+ * claim was never true, and leaving it here made five stores look like pending
21389
+ * work when three of them have no vector at all. Counted column by column on
21390
+ * 2026-08-30, exactly THREE ever held one:
21391
+ *
21392
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21393
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21394
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21395
+ * face, migrated 2026-08-30 into its OWN index (see below).
21396
+ *
21397
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21398
+ * and `identities` store a name; the event store stores no derivative vector.
21399
+ * They are not migration candidates and never were.
21400
+ *
21401
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21402
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21403
+ * rows before ranking anything.
21404
+ *
21405
+ * ## One index per COMPARISON, never per encoder
21406
+ *
21407
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21408
+ * model, and they still get two indexes. An index is a set of things that are
21409
+ * ranked against each other and that live and die together, and these two are
21410
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21411
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21412
+ * forever and is the gallery every recognition ranks against. One index would
21413
+ * mean every gallery load and every reconcile carried a filter whose failure
21414
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21415
+ * person's only sample. The dimension they share is not a reason to share an
21416
+ * index; the question they answer is, and it differs.
21114
21417
  *
21115
21418
  * The fix is not a faster loop, it is a different backend — and the backend
21116
21419
  * should be replaceable without touching six callers. So: a singleton
@@ -21215,7 +21518,20 @@ var VectorQueryResultSchema = object({
21215
21518
  */
21216
21519
  scanned: number(),
21217
21520
  /** True when the backend could not consider every row that passed the filter. */
21218
- truncated: boolean()
21521
+ truncated: boolean(),
21522
+ /**
21523
+ * The `topK` the backend actually ran with.
21524
+ *
21525
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21526
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21527
+ * own log rather than in its answer. That is how an audit asking for 20,000
21528
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21529
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21530
+ * MUCH, in the return value, where the caller cannot fail to see it.
21531
+ *
21532
+ * Equals the requested `topK` whenever nothing was lowered.
21533
+ */
21534
+ effectiveTopK: number().int().positive()
21219
21535
  });
21220
21536
  var VectorDeleteInputSchema = object({
21221
21537
  index: string(),
@@ -21244,6 +21560,68 @@ var VectorGetResultSchema = object({ items: array(object({
21244
21560
  id: string(),
21245
21561
  metadata: VectorMetadataSchema
21246
21562
  })) });
21563
+ /**
21564
+ * Ids to read back WITH their vectors.
21565
+ *
21566
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21567
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21568
+ * caller depends on that promise. This one promises the opposite.
21569
+ *
21570
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21571
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21572
+ * a per-face cross-process KNN would be a network round trip inside the
21573
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21574
+ * it requires the index to hand the floats back. Without this method the only
21575
+ * way to keep a readable vector is a JSON column, which is the thing this
21576
+ * capability exists to delete.
21577
+ *
21578
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21579
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21580
+ */
21581
+ var VectorFetchInputSchema = object({
21582
+ index: string(),
21583
+ ids: array(string())
21584
+ });
21585
+ var VectorFetchResultSchema = object({ items: array(object({
21586
+ id: string(),
21587
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21588
+ vector: string(),
21589
+ metadata: VectorMetadataSchema
21590
+ })) });
21591
+ /**
21592
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21593
+ *
21594
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21595
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21596
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21597
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21598
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21599
+ * looked" for as long as anyone cared to read it.
21600
+ *
21601
+ * This is the primitive that question actually needs: a bounded page, ordered
21602
+ * by the backend's own row order, costing no distance computation at all.
21603
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21604
+ * the full-table read this capability was built to stop.
21605
+ */
21606
+ var VectorScanInputSchema = object({
21607
+ index: string(),
21608
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21609
+ cursor: number().int().nonnegative().default(0),
21610
+ limit: number().int().positive()
21611
+ });
21612
+ var VectorScanResultSchema = object({
21613
+ items: array(object({
21614
+ id: string(),
21615
+ metadata: VectorMetadataSchema
21616
+ })),
21617
+ /**
21618
+ * Where the next page starts, or `null` when the walk reached the end.
21619
+ *
21620
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21621
+ * from a short page: a backend is free to return fewer rows than asked.
21622
+ */
21623
+ nextCursor: number().int().nonnegative().nullable()
21624
+ });
21247
21625
  var VectorStatsInputSchema = object({ index: string() });
21248
21626
  var VectorStatsResultSchema = object({
21249
21627
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21262,7 +21640,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21262
21640
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21263
21641
  kind: "mutation",
21264
21642
  auth: "admin"
21265
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21643
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21266
21644
  kind: "mutation",
21267
21645
  auth: "admin"
21268
21646
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -26166,6 +26544,9 @@ method(object({
26166
26544
  }), method(object({}), array(RelocateJobSchema).readonly(), {
26167
26545
  kind: "query",
26168
26546
  auth: "admin"
26547
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
26548
+ kind: "query",
26549
+ auth: "admin"
26169
26550
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26170
26551
  kind: "mutation",
26171
26552
  auth: "admin"
@@ -31131,6 +31512,18 @@ Object.freeze({
31131
31512
  addonId: null,
31132
31513
  access: "create"
31133
31514
  },
31515
+ "pipelineAnalytics.countRelocatableMedia": {
31516
+ capName: "pipeline-analytics",
31517
+ capScope: "device",
31518
+ addonId: null,
31519
+ access: "view"
31520
+ },
31521
+ "pipelineAnalytics.countUnstampedEventMedia": {
31522
+ capName: "pipeline-analytics",
31523
+ capScope: "device",
31524
+ addonId: null,
31525
+ access: "view"
31526
+ },
31134
31527
  "pipelineAnalytics.deleteDeviceEvents": {
31135
31528
  capName: "pipeline-analytics",
31136
31529
  capScope: "device",
@@ -32289,6 +32682,12 @@ Object.freeze({
32289
32682
  addonId: null,
32290
32683
  access: "view"
32291
32684
  },
32685
+ "recording.getRelocateResidue": {
32686
+ capName: "recording",
32687
+ capScope: "system",
32688
+ addonId: null,
32689
+ access: "view"
32690
+ },
32292
32691
  "recording.getStorageMigrationMoveStatus": {
32293
32692
  capName: "recording",
32294
32693
  capScope: "system",
@@ -32835,12 +33234,30 @@ Object.freeze({
32835
33234
  addonId: null,
32836
33235
  access: "create"
32837
33236
  },
33237
+ "storageMigration.drain": {
33238
+ capName: "storage-migration",
33239
+ capScope: "system",
33240
+ addonId: null,
33241
+ access: "create"
33242
+ },
33243
+ "storageMigration.movers": {
33244
+ capName: "storage-migration",
33245
+ capScope: "system",
33246
+ addonId: null,
33247
+ access: "view"
33248
+ },
32838
33249
  "storageMigration.plan": {
32839
33250
  capName: "storage-migration",
32840
33251
  capScope: "system",
32841
33252
  addonId: null,
32842
33253
  access: "view"
32843
33254
  },
33255
+ "storageMigration.residue": {
33256
+ capName: "storage-migration",
33257
+ capScope: "system",
33258
+ addonId: null,
33259
+ access: "view"
33260
+ },
32844
33261
  "storageMigration.start": {
32845
33262
  capName: "storage-migration",
32846
33263
  capScope: "system",
@@ -33675,6 +34092,12 @@ Object.freeze({
33675
34092
  addonId: null,
33676
34093
  access: "delete"
33677
34094
  },
34095
+ "vectorStore.fetchByIds": {
34096
+ capName: "vector-store",
34097
+ capScope: "system",
34098
+ addonId: null,
34099
+ access: "view"
34100
+ },
33678
34101
  "vectorStore.getByIds": {
33679
34102
  capName: "vector-store",
33680
34103
  capScope: "system",
@@ -33687,6 +34110,12 @@ Object.freeze({
33687
34110
  addonId: null,
33688
34111
  access: "view"
33689
34112
  },
34113
+ "vectorStore.scan": {
34114
+ capName: "vector-store",
34115
+ capScope: "system",
34116
+ addonId: null,
34117
+ access: "view"
34118
+ },
33690
34119
  "vectorStore.stats": {
33691
34120
  capName: "vector-store",
33692
34121
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-decoder-nodeav",
3
- "version": "1.2.42",
3
+ "version": "1.2.45",
4
4
  "description": "Standalone in-process node-av decoder addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",