@camstack/addon-provider-amcrest 0.2.43 → 0.2.46

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +452 -23
  2. package/dist/addon.mjs +452 -23
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8032,18 +8032,61 @@ var RelocateFootageInputSchema = object({
8032
8032
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8033
8033
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8034
8034
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8035
+ /**
8036
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8037
+ * mover (the engine already walks both collections with a timestamp cursor and
8038
+ * already has a stamp-without-copy path).
8039
+ *
8040
+ * - `move` — the default and the historical behaviour: event-media and
8041
+ * retrain blobs move to `toLocationId` and their rows are
8042
+ * stamped. The enrolled gallery is skipped (D197).
8043
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8044
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8045
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8046
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8047
+ * instant a repoint moves that pointer the row reads from the
8048
+ * new disk while its bytes are on the old one.
8049
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8050
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8051
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8052
+ * never run beside a live second location: it is stop-the-world
8053
+ * by construction, which is acceptable only because the gallery
8054
+ * is a few KB per enrolled sample.
8055
+ */
8056
+ var MediaRelocateModeSchema = _enum([
8057
+ "move",
8058
+ "seal",
8059
+ "gallery"
8060
+ ]);
8035
8061
  var RelocateMediaInputSchema = object({
8036
8062
  toLocationId: string(),
8037
- throttleMbps: number().min(1).max(1e3).optional()
8063
+ throttleMbps: number().min(1).max(1e3).optional(),
8064
+ /** Omitted = `move`, the pre-existing behaviour. */
8065
+ mode: MediaRelocateModeSchema.optional()
8066
+ });
8067
+ /** How many rows still carry NO `locationId` — the population a repoint would
8068
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8069
+ * value that permits a non-blocking `eventMedia` cutover. */
8070
+ var UnstampedEventMediaCountSchema = object({
8071
+ media: number().int().nonnegative(),
8072
+ retrainFrames: number().int().nonnegative(),
8073
+ total: number().int().nonnegative()
8038
8074
  });
8039
8075
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8040
- /** The independently selectable logical storage classes. `recordings`
8041
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8042
- * segments; `eventMedia` is post-analysis blobs. */
8076
+ /** The independently selectable logical storage classes — every class
8077
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8078
+ * Zod enum error where they should meet an explanation.
8079
+ *
8080
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8081
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8082
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8083
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8043
8084
  var StorageMigrationClassSchema = _enum([
8044
8085
  "recordings",
8045
8086
  "recordingsLow",
8046
- "eventMedia"
8087
+ "eventMedia",
8088
+ "backups",
8089
+ "galleryMedia"
8047
8090
  ]);
8048
8091
  /** A destination is always an existing, fully-qualified location id. The
8049
8092
  * migration API intentionally never changes a source location's `basePath`:
@@ -8051,20 +8094,56 @@ var StorageMigrationClassSchema = _enum([
8051
8094
  var StorageMigrationDestinationsSchema = object({
8052
8095
  recordings: string().min(1).optional(),
8053
8096
  recordingsLow: string().min(1).optional(),
8054
- eventMedia: string().min(1).optional()
8097
+ eventMedia: string().min(1).optional(),
8098
+ backups: string().min(1).optional(),
8099
+ galleryMedia: string().min(1).optional()
8055
8100
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8101
+ /**
8102
+ * How a migration sequences the cutover against the byte move.
8103
+ *
8104
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8105
+ * resume. Recording is stopped for the whole move. Right
8106
+ * for a small or a cold class, and the only legal mode for
8107
+ * a `cardinality: 'single'` class.
8108
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8109
+ * refresh, resume, then move the past with everything
8110
+ * running. The pause is three bounded instants (a detach +
8111
+ * attach round, a write-gate drain, a lease) instead of one
8112
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8113
+ * stopped recording under `blocking`; the same move is
8114
+ * seconds of stopped recording under `nonBlocking`.
8115
+ *
8116
+ * The mode is on the JOB, not only on the input, because `status` is where an
8117
+ * operator finds out which one is running.
8118
+ */
8119
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8056
8120
  /** Shared input for planning and starting an orchestrated storage migration. */
8057
8121
  var StorageMigrationInputSchema = object({
8058
8122
  destinations: StorageMigrationDestinationsSchema,
8059
- throttleMbps: number().min(1).max(1e3).optional()
8123
+ throttleMbps: number().min(1).max(1e3).optional(),
8124
+ /** Omitted = `blocking`, which stays the default. */
8125
+ mode: StorageMigrationModeSchema.optional()
8060
8126
  });
8061
- /** The durable coordinator state machine. The only phase that changes default
8062
- * locations is `repointing`, after every selected mover has completed and been
8063
- * verified. */
8127
+ /**
8128
+ * The durable coordinator state machine.
8129
+ *
8130
+ * `blocking`:
8131
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8132
+ *
8133
+ * `nonBlocking`:
8134
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8135
+ *
8136
+ * Same phases, different order plus two new ones — not a second mover.
8137
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8138
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8139
+ * `repointing` is still the only phase that changes a default location.
8140
+ */
8064
8141
  var StorageMigrationPhaseSchema = _enum([
8065
8142
  "planning",
8143
+ "sealing",
8066
8144
  "pausing",
8067
8145
  "moving",
8146
+ "draining",
8068
8147
  "verifying",
8069
8148
  "repointing",
8070
8149
  "refreshing",
@@ -8078,17 +8157,56 @@ var StorageMigrationParticipantSchema = _enum([
8078
8157
  "recorder",
8079
8158
  "analytics"
8080
8159
  ]);
8160
+ /**
8161
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8162
+ *
8163
+ * The long half of a non-blocking migration is `draining`, and it is measured
8164
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8165
+ * existed the only place those numbers appeared was a Loki line, so an operator
8166
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8167
+ * afternoon.
8168
+ *
8169
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8170
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8171
+ * mover — which is the exact failure this is meant to end. The coordinator's
8172
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8173
+ * read `state`; folding the counters costs no extra read and makes the durable
8174
+ * record say afterwards how far a move actually got.
8175
+ *
8176
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8177
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8178
+ * cannot say M, and a 0 there would render as "100 % done".
8179
+ */
8180
+ var StorageMigrationMoveProgressSchema = object({
8181
+ filesMoved: number().int().nonnegative(),
8182
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8183
+ filesTotal: number().int().nonnegative().nullable(),
8184
+ bytesMoved: number().int().nonnegative(),
8185
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8186
+ * crash gets a new mover, and a rate computed from the migration's start
8187
+ * would silently average in the time nothing was running. */
8188
+ startedAt: number(),
8189
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8190
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8191
+ * subtract its own. */
8192
+ observedAt: number()
8193
+ });
8081
8194
  var StorageMigrationMoveSchema = object({
8082
8195
  storageClass: StorageMigrationClassSchema,
8083
8196
  fromLocationId: string(),
8084
8197
  toLocationId: string(),
8085
8198
  moverJobId: string().nullable(),
8086
8199
  state: RelocateJobStateSchema.nullable(),
8087
- error: string().nullable()
8200
+ error: string().nullable(),
8201
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8202
+ progress: StorageMigrationMoveProgressSchema.nullable()
8088
8203
  });
8089
8204
  var StorageMigrationJobSchema = object({
8090
8205
  jobId: string(),
8091
8206
  phase: StorageMigrationPhaseSchema,
8207
+ /** Which order this job is running. `status` is the only place an operator
8208
+ * can tell a seconds-long cutover from a thirty-hour one. */
8209
+ mode: StorageMigrationModeSchema,
8092
8210
  destinations: StorageMigrationDestinationsSchema,
8093
8211
  throttleMbps: number(),
8094
8212
  moves: array(StorageMigrationMoveSchema),
@@ -8101,13 +8219,122 @@ var StorageMigrationJobSchema = object({
8101
8219
  finishedAt: number().nullable(),
8102
8220
  error: string().nullable()
8103
8221
  });
8222
+ var StorageMigrationFindingSchema = object({
8223
+ code: _enum([
8224
+ "sharesDeviceWithSource",
8225
+ "deviceIdentityUnknown",
8226
+ "unstampedEventMediaRows",
8227
+ "blockingOnly",
8228
+ "noMover"
8229
+ ]),
8230
+ storageClass: StorageMigrationClassSchema,
8231
+ /** Human-readable, already carrying the ids and counts. */
8232
+ message: string()
8233
+ });
8104
8234
  var StorageMigrationPlanSchema = object({
8105
8235
  destinations: StorageMigrationDestinationsSchema,
8236
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8237
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8238
+ * it. */
8239
+ mode: StorageMigrationModeSchema,
8106
8240
  moves: array(object({
8107
8241
  storageClass: StorageMigrationClassSchema,
8108
8242
  fromLocationId: string(),
8109
8243
  toLocationId: string()
8110
- }))
8244
+ })),
8245
+ findings: array(StorageMigrationFindingSchema)
8246
+ });
8247
+ /**
8248
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8249
+ *
8250
+ * The coordinator's job record is the state of record for a migration, and its
8251
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8252
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8253
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8254
+ * way because no supported UI path existed. A mover armed like that has no job
8255
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8256
+ *
8257
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8258
+ * orchestrated it.
8259
+ */
8260
+ var StorageMigrationMoverSchema = object({
8261
+ lane: _enum(["footage", "media"]),
8262
+ job: RelocateJobSchema,
8263
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8264
+ * directly against the owning addon. */
8265
+ migrationJobId: string().nullable(),
8266
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8267
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8268
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8269
+ * rate made of two different clocks. */
8270
+ observedAt: number()
8271
+ });
8272
+ /**
8273
+ * What a SOURCE still holds for one storage class — the number that makes a
8274
+ * "drain remaining" action honest rather than hopeful.
8275
+ *
8276
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8277
+ * engine's own selection count for media), never from the resident index: a
8278
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8279
+ * never been told about (D295).
8280
+ *
8281
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8282
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8283
+ * because refusing on an unanswerable read would hide exactly the case an
8284
+ * operator needs to act on.
8285
+ */
8286
+ var StorageMigrationResidueSchema = object({
8287
+ storageClass: StorageMigrationClassSchema,
8288
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8289
+ * move from wherever they are rather than from one named source. */
8290
+ fromLocationId: string(),
8291
+ /** Where a drain would move it — the class's CURRENT default. */
8292
+ toLocationId: string(),
8293
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8294
+ items: number().int().nonnegative().nullable(),
8295
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8296
+ bytes: number().int().nonnegative().nullable()
8297
+ });
8298
+ /**
8299
+ * Run the DRAIN half and nothing else.
8300
+ *
8301
+ * A migration that reached `done` has already repointed, so `start` correctly
8302
+ * refuses its destination ("already the default") — there is nothing left to
8303
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8304
+ * or finish against a work list that was a tenth of the archive (D295), and
8305
+ * before this there was no supported way to run only that half: the only way
8306
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8307
+ *
8308
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8309
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8310
+ * re-repoint a class that is already migrated.
8311
+ */
8312
+ var StorageMigrationDrainInputSchema = object({
8313
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8314
+ * a class whose source is already empty is refused rather than started. */
8315
+ classes: array(StorageMigrationClassSchema).min(1),
8316
+ throttleMbps: number().min(1).max(1e3).optional()
8317
+ });
8318
+ /** What a footage source still holds, asked of the durable hour ledger. */
8319
+ var RelocateResidueInputSchema = object({
8320
+ fromLocationId: string().min(1),
8321
+ /** Narrow to one logical class; omit for every profile on the location. */
8322
+ footageClass: RelocateFootageClassSchema.optional()
8323
+ });
8324
+ /** `null` = the archive could not answer (no ledger on this node, or the
8325
+ * aggregate failed). Never conflated with an empty source. */
8326
+ var RelocateResidueSchema = object({
8327
+ segments: number().int().nonnegative(),
8328
+ bytes: number().int().nonnegative()
8329
+ }).nullable();
8330
+ /** How many rows a media pass would still act on against a given target — the
8331
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8332
+ * never disagree. `null` = the count could not be taken. */
8333
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8334
+ var RelocatableMediaCountInputSchema = object({
8335
+ toLocationId: string().min(1),
8336
+ /** Omitted = `move`. */
8337
+ mode: MediaRelocateModeSchema.optional()
8111
8338
  });
8112
8339
  /**
8113
8340
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8213,6 +8440,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8213
8440
  * two addons declaring the same `id` must agree on `cardinality` (validated
8214
8441
  * at kernel aggregation time, not here).
8215
8442
  */
8443
+ /**
8444
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8445
+ * actually reaches the bytes. It is the constraint that decides which
8446
+ * `storage-provider`s may back a location of that kind.
8447
+ *
8448
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8449
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8450
+ * post-analysis media roots). Only a provider that serves a genuine local
8451
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8452
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8453
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8454
+ * against a same-named local directory that is something else entirely.
8455
+ *
8456
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8457
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8458
+ * service never sees a path, so any provider can back it. `backups` is the
8459
+ * one kind that qualifies today.
8460
+ *
8461
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8462
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8463
+ * refused the configuration; the first write simply went somewhere wrong, and
8464
+ * a recording write that goes wrong surfaces as a silent black window rather
8465
+ * than an error (the read path does not `stat`). This turns that accident into
8466
+ * a declared, enforced, testable refusal.
8467
+ */
8468
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8216
8469
  var StorageLocationDeclarationSchema = object({
8217
8470
  /**
8218
8471
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8232,6 +8485,19 @@ var StorageLocationDeclarationSchema = object({
8232
8485
  */
8233
8486
  cardinality: _enum(["single", "multi"]),
8234
8487
  /**
8488
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8489
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8490
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8491
+ *
8492
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8493
+ * can only over-restrict (refuse a remote provider for a kind that might
8494
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8495
+ * permissive direction and is therefore never inferred — a repo guard
8496
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8497
+ * reached by omission.
8498
+ */
8499
+ access: StorageAccessSchema.optional(),
8500
+ /**
8235
8501
  * When set, the default instance for this location inherits its resolved
8236
8502
  * root from the named location's default instance. Useful for derivative
8237
8503
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18099,8 +18365,10 @@ var TrackSchema = object({
18099
18365
  lastSeen: number(),
18100
18366
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18101
18367
  positions: array(TrackPositionSchema).readonly(),
18102
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18103
- * saveThumbnails policy). */
18368
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18369
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18370
+ * the retired `saveThumbnails` used to gate this and the rolling
18371
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18104
18372
  snapshots: array(TrackSnapshotSchema).readonly(),
18105
18373
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18106
18374
  zonesVisited: array(string()).readonly(),
@@ -18960,6 +19228,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18960
19228
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18961
19229
  kind: "mutation",
18962
19230
  auth: "admin"
19231
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19232
+ kind: "query",
19233
+ auth: "admin"
18963
19234
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18964
19235
  kind: "query",
18965
19236
  auth: "admin"
@@ -20971,7 +21242,10 @@ method(object({
20971
21242
  }), StorageLocationSchema, {
20972
21243
  kind: "mutation",
20973
21244
  auth: "admin"
20974
- }), method(object({ id: string() }), _void(), {
21245
+ }), method(object({
21246
+ id: string(),
21247
+ force: boolean().optional()
21248
+ }), _void(), {
20975
21249
  kind: "mutation",
20976
21250
  auth: "admin"
20977
21251
  }), method(object({ id: string() }), object({
@@ -21020,6 +21294,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21020
21294
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21021
21295
  kind: "mutation",
21022
21296
  auth: "admin"
21297
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21298
+ kind: "mutation",
21299
+ auth: "admin"
21023
21300
  });
21024
21301
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21025
21302
  providerId: string().min(1),
@@ -21418,12 +21695,38 @@ response: record(string(), unknown()) }), object({
21418
21695
  *
21419
21696
  * ## Why this is a capability and not a helper
21420
21697
  *
21421
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21422
- * plate, vehicle, identity, and the event store's derivativesand every one of
21423
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21424
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21425
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21426
- * load 5,000 rows before ranking anything.
21698
+ * This capability was introduced with the claim that SIX stores in
21699
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
21700
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21701
+ * claim was never true, and leaving it here made five stores look like pending
21702
+ * work when three of them have no vector at all. Counted column by column on
21703
+ * 2026-08-30, exactly THREE ever held one:
21704
+ *
21705
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21706
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21707
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21708
+ * face, migrated 2026-08-30 into its OWN index (see below).
21709
+ *
21710
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21711
+ * and `identities` store a name; the event store stores no derivative vector.
21712
+ * They are not migration candidates and never were.
21713
+ *
21714
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21715
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21716
+ * rows before ranking anything.
21717
+ *
21718
+ * ## One index per COMPARISON, never per encoder
21719
+ *
21720
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21721
+ * model, and they still get two indexes. An index is a set of things that are
21722
+ * ranked against each other and that live and die together, and these two are
21723
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21724
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21725
+ * forever and is the gallery every recognition ranks against. One index would
21726
+ * mean every gallery load and every reconcile carried a filter whose failure
21727
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21728
+ * person's only sample. The dimension they share is not a reason to share an
21729
+ * index; the question they answer is, and it differs.
21427
21730
  *
21428
21731
  * The fix is not a faster loop, it is a different backend — and the backend
21429
21732
  * should be replaceable without touching six callers. So: a singleton
@@ -21528,7 +21831,20 @@ var VectorQueryResultSchema = object({
21528
21831
  */
21529
21832
  scanned: number(),
21530
21833
  /** True when the backend could not consider every row that passed the filter. */
21531
- truncated: boolean()
21834
+ truncated: boolean(),
21835
+ /**
21836
+ * The `topK` the backend actually ran with.
21837
+ *
21838
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21839
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21840
+ * own log rather than in its answer. That is how an audit asking for 20,000
21841
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21842
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21843
+ * MUCH, in the return value, where the caller cannot fail to see it.
21844
+ *
21845
+ * Equals the requested `topK` whenever nothing was lowered.
21846
+ */
21847
+ effectiveTopK: number().int().positive()
21532
21848
  });
21533
21849
  var VectorDeleteInputSchema = object({
21534
21850
  index: string(),
@@ -21557,6 +21873,68 @@ var VectorGetResultSchema = object({ items: array(object({
21557
21873
  id: string(),
21558
21874
  metadata: VectorMetadataSchema
21559
21875
  })) });
21876
+ /**
21877
+ * Ids to read back WITH their vectors.
21878
+ *
21879
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21880
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21881
+ * caller depends on that promise. This one promises the opposite.
21882
+ *
21883
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21884
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21885
+ * a per-face cross-process KNN would be a network round trip inside the
21886
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21887
+ * it requires the index to hand the floats back. Without this method the only
21888
+ * way to keep a readable vector is a JSON column, which is the thing this
21889
+ * capability exists to delete.
21890
+ *
21891
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21892
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21893
+ */
21894
+ var VectorFetchInputSchema = object({
21895
+ index: string(),
21896
+ ids: array(string())
21897
+ });
21898
+ var VectorFetchResultSchema = object({ items: array(object({
21899
+ id: string(),
21900
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21901
+ vector: string(),
21902
+ metadata: VectorMetadataSchema
21903
+ })) });
21904
+ /**
21905
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21906
+ *
21907
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21908
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21909
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21910
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21911
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21912
+ * looked" for as long as anyone cared to read it.
21913
+ *
21914
+ * This is the primitive that question actually needs: a bounded page, ordered
21915
+ * by the backend's own row order, costing no distance computation at all.
21916
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21917
+ * the full-table read this capability was built to stop.
21918
+ */
21919
+ var VectorScanInputSchema = object({
21920
+ index: string(),
21921
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21922
+ cursor: number().int().nonnegative().default(0),
21923
+ limit: number().int().positive()
21924
+ });
21925
+ var VectorScanResultSchema = object({
21926
+ items: array(object({
21927
+ id: string(),
21928
+ metadata: VectorMetadataSchema
21929
+ })),
21930
+ /**
21931
+ * Where the next page starts, or `null` when the walk reached the end.
21932
+ *
21933
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21934
+ * from a short page: a backend is free to return fewer rows than asked.
21935
+ */
21936
+ nextCursor: number().int().nonnegative().nullable()
21937
+ });
21560
21938
  var VectorStatsInputSchema = object({ index: string() });
21561
21939
  var VectorStatsResultSchema = object({
21562
21940
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21575,7 +21953,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21575
21953
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21576
21954
  kind: "mutation",
21577
21955
  auth: "admin"
21578
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21956
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21579
21957
  kind: "mutation",
21580
21958
  auth: "admin"
21581
21959
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28282,6 +28660,9 @@ method(object({
28282
28660
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28283
28661
  kind: "query",
28284
28662
  auth: "admin"
28663
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28664
+ kind: "query",
28665
+ auth: "admin"
28285
28666
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28286
28667
  kind: "mutation",
28287
28668
  auth: "admin"
@@ -35320,6 +35701,18 @@ Object.freeze({
35320
35701
  addonId: null,
35321
35702
  access: "create"
35322
35703
  },
35704
+ "pipelineAnalytics.countRelocatableMedia": {
35705
+ capName: "pipeline-analytics",
35706
+ capScope: "device",
35707
+ addonId: null,
35708
+ access: "view"
35709
+ },
35710
+ "pipelineAnalytics.countUnstampedEventMedia": {
35711
+ capName: "pipeline-analytics",
35712
+ capScope: "device",
35713
+ addonId: null,
35714
+ access: "view"
35715
+ },
35323
35716
  "pipelineAnalytics.deleteDeviceEvents": {
35324
35717
  capName: "pipeline-analytics",
35325
35718
  capScope: "device",
@@ -36478,6 +36871,12 @@ Object.freeze({
36478
36871
  addonId: null,
36479
36872
  access: "view"
36480
36873
  },
36874
+ "recording.getRelocateResidue": {
36875
+ capName: "recording",
36876
+ capScope: "system",
36877
+ addonId: null,
36878
+ access: "view"
36879
+ },
36481
36880
  "recording.getStorageMigrationMoveStatus": {
36482
36881
  capName: "recording",
36483
36882
  capScope: "system",
@@ -37024,12 +37423,30 @@ Object.freeze({
37024
37423
  addonId: null,
37025
37424
  access: "create"
37026
37425
  },
37426
+ "storageMigration.drain": {
37427
+ capName: "storage-migration",
37428
+ capScope: "system",
37429
+ addonId: null,
37430
+ access: "create"
37431
+ },
37432
+ "storageMigration.movers": {
37433
+ capName: "storage-migration",
37434
+ capScope: "system",
37435
+ addonId: null,
37436
+ access: "view"
37437
+ },
37027
37438
  "storageMigration.plan": {
37028
37439
  capName: "storage-migration",
37029
37440
  capScope: "system",
37030
37441
  addonId: null,
37031
37442
  access: "view"
37032
37443
  },
37444
+ "storageMigration.residue": {
37445
+ capName: "storage-migration",
37446
+ capScope: "system",
37447
+ addonId: null,
37448
+ access: "view"
37449
+ },
37033
37450
  "storageMigration.start": {
37034
37451
  capName: "storage-migration",
37035
37452
  capScope: "system",
@@ -37864,6 +38281,12 @@ Object.freeze({
37864
38281
  addonId: null,
37865
38282
  access: "delete"
37866
38283
  },
38284
+ "vectorStore.fetchByIds": {
38285
+ capName: "vector-store",
38286
+ capScope: "system",
38287
+ addonId: null,
38288
+ access: "view"
38289
+ },
37867
38290
  "vectorStore.getByIds": {
37868
38291
  capName: "vector-store",
37869
38292
  capScope: "system",
@@ -37876,6 +38299,12 @@ Object.freeze({
37876
38299
  addonId: null,
37877
38300
  access: "view"
37878
38301
  },
38302
+ "vectorStore.scan": {
38303
+ capName: "vector-store",
38304
+ capScope: "system",
38305
+ addonId: null,
38306
+ access: "view"
38307
+ },
37879
38308
  "vectorStore.stats": {
37880
38309
  capName: "vector-store",
37881
38310
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8033,18 +8033,61 @@ var RelocateFootageInputSchema = object({
8033
8033
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8034
8034
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8035
8035
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8036
+ /**
8037
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8038
+ * mover (the engine already walks both collections with a timestamp cursor and
8039
+ * already has a stamp-without-copy path).
8040
+ *
8041
+ * - `move` — the default and the historical behaviour: event-media and
8042
+ * retrain blobs move to `toLocationId` and their rows are
8043
+ * stamped. The enrolled gallery is skipped (D197).
8044
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8045
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8046
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8047
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8048
+ * instant a repoint moves that pointer the row reads from the
8049
+ * new disk while its bytes are on the old one.
8050
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8051
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8052
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8053
+ * never run beside a live second location: it is stop-the-world
8054
+ * by construction, which is acceptable only because the gallery
8055
+ * is a few KB per enrolled sample.
8056
+ */
8057
+ var MediaRelocateModeSchema = _enum([
8058
+ "move",
8059
+ "seal",
8060
+ "gallery"
8061
+ ]);
8036
8062
  var RelocateMediaInputSchema = object({
8037
8063
  toLocationId: string(),
8038
- throttleMbps: number().min(1).max(1e3).optional()
8064
+ throttleMbps: number().min(1).max(1e3).optional(),
8065
+ /** Omitted = `move`, the pre-existing behaviour. */
8066
+ mode: MediaRelocateModeSchema.optional()
8067
+ });
8068
+ /** How many rows still carry NO `locationId` — the population a repoint would
8069
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8070
+ * value that permits a non-blocking `eventMedia` cutover. */
8071
+ var UnstampedEventMediaCountSchema = object({
8072
+ media: number().int().nonnegative(),
8073
+ retrainFrames: number().int().nonnegative(),
8074
+ total: number().int().nonnegative()
8039
8075
  });
8040
8076
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8041
- /** The independently selectable logical storage classes. `recordings`
8042
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8043
- * segments; `eventMedia` is post-analysis blobs. */
8077
+ /** The independently selectable logical storage classes — every class
8078
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8079
+ * Zod enum error where they should meet an explanation.
8080
+ *
8081
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8082
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8083
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8084
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8044
8085
  var StorageMigrationClassSchema = _enum([
8045
8086
  "recordings",
8046
8087
  "recordingsLow",
8047
- "eventMedia"
8088
+ "eventMedia",
8089
+ "backups",
8090
+ "galleryMedia"
8048
8091
  ]);
8049
8092
  /** A destination is always an existing, fully-qualified location id. The
8050
8093
  * migration API intentionally never changes a source location's `basePath`:
@@ -8052,20 +8095,56 @@ var StorageMigrationClassSchema = _enum([
8052
8095
  var StorageMigrationDestinationsSchema = object({
8053
8096
  recordings: string().min(1).optional(),
8054
8097
  recordingsLow: string().min(1).optional(),
8055
- eventMedia: string().min(1).optional()
8098
+ eventMedia: string().min(1).optional(),
8099
+ backups: string().min(1).optional(),
8100
+ galleryMedia: string().min(1).optional()
8056
8101
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8102
+ /**
8103
+ * How a migration sequences the cutover against the byte move.
8104
+ *
8105
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8106
+ * resume. Recording is stopped for the whole move. Right
8107
+ * for a small or a cold class, and the only legal mode for
8108
+ * a `cardinality: 'single'` class.
8109
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8110
+ * refresh, resume, then move the past with everything
8111
+ * running. The pause is three bounded instants (a detach +
8112
+ * attach round, a write-gate drain, a lease) instead of one
8113
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8114
+ * stopped recording under `blocking`; the same move is
8115
+ * seconds of stopped recording under `nonBlocking`.
8116
+ *
8117
+ * The mode is on the JOB, not only on the input, because `status` is where an
8118
+ * operator finds out which one is running.
8119
+ */
8120
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8057
8121
  /** Shared input for planning and starting an orchestrated storage migration. */
8058
8122
  var StorageMigrationInputSchema = object({
8059
8123
  destinations: StorageMigrationDestinationsSchema,
8060
- throttleMbps: number().min(1).max(1e3).optional()
8124
+ throttleMbps: number().min(1).max(1e3).optional(),
8125
+ /** Omitted = `blocking`, which stays the default. */
8126
+ mode: StorageMigrationModeSchema.optional()
8061
8127
  });
8062
- /** The durable coordinator state machine. The only phase that changes default
8063
- * locations is `repointing`, after every selected mover has completed and been
8064
- * verified. */
8128
+ /**
8129
+ * The durable coordinator state machine.
8130
+ *
8131
+ * `blocking`:
8132
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8133
+ *
8134
+ * `nonBlocking`:
8135
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8136
+ *
8137
+ * Same phases, different order plus two new ones — not a second mover.
8138
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8139
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8140
+ * `repointing` is still the only phase that changes a default location.
8141
+ */
8065
8142
  var StorageMigrationPhaseSchema = _enum([
8066
8143
  "planning",
8144
+ "sealing",
8067
8145
  "pausing",
8068
8146
  "moving",
8147
+ "draining",
8069
8148
  "verifying",
8070
8149
  "repointing",
8071
8150
  "refreshing",
@@ -8079,17 +8158,56 @@ var StorageMigrationParticipantSchema = _enum([
8079
8158
  "recorder",
8080
8159
  "analytics"
8081
8160
  ]);
8161
+ /**
8162
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8163
+ *
8164
+ * The long half of a non-blocking migration is `draining`, and it is measured
8165
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8166
+ * existed the only place those numbers appeared was a Loki line, so an operator
8167
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8168
+ * afternoon.
8169
+ *
8170
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8171
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8172
+ * mover — which is the exact failure this is meant to end. The coordinator's
8173
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8174
+ * read `state`; folding the counters costs no extra read and makes the durable
8175
+ * record say afterwards how far a move actually got.
8176
+ *
8177
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8178
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8179
+ * cannot say M, and a 0 there would render as "100 % done".
8180
+ */
8181
+ var StorageMigrationMoveProgressSchema = object({
8182
+ filesMoved: number().int().nonnegative(),
8183
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8184
+ filesTotal: number().int().nonnegative().nullable(),
8185
+ bytesMoved: number().int().nonnegative(),
8186
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8187
+ * crash gets a new mover, and a rate computed from the migration's start
8188
+ * would silently average in the time nothing was running. */
8189
+ startedAt: number(),
8190
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8191
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8192
+ * subtract its own. */
8193
+ observedAt: number()
8194
+ });
8082
8195
  var StorageMigrationMoveSchema = object({
8083
8196
  storageClass: StorageMigrationClassSchema,
8084
8197
  fromLocationId: string(),
8085
8198
  toLocationId: string(),
8086
8199
  moverJobId: string().nullable(),
8087
8200
  state: RelocateJobStateSchema.nullable(),
8088
- error: string().nullable()
8201
+ error: string().nullable(),
8202
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8203
+ progress: StorageMigrationMoveProgressSchema.nullable()
8089
8204
  });
8090
8205
  var StorageMigrationJobSchema = object({
8091
8206
  jobId: string(),
8092
8207
  phase: StorageMigrationPhaseSchema,
8208
+ /** Which order this job is running. `status` is the only place an operator
8209
+ * can tell a seconds-long cutover from a thirty-hour one. */
8210
+ mode: StorageMigrationModeSchema,
8093
8211
  destinations: StorageMigrationDestinationsSchema,
8094
8212
  throttleMbps: number(),
8095
8213
  moves: array(StorageMigrationMoveSchema),
@@ -8102,13 +8220,122 @@ var StorageMigrationJobSchema = object({
8102
8220
  finishedAt: number().nullable(),
8103
8221
  error: string().nullable()
8104
8222
  });
8223
+ var StorageMigrationFindingSchema = object({
8224
+ code: _enum([
8225
+ "sharesDeviceWithSource",
8226
+ "deviceIdentityUnknown",
8227
+ "unstampedEventMediaRows",
8228
+ "blockingOnly",
8229
+ "noMover"
8230
+ ]),
8231
+ storageClass: StorageMigrationClassSchema,
8232
+ /** Human-readable, already carrying the ids and counts. */
8233
+ message: string()
8234
+ });
8105
8235
  var StorageMigrationPlanSchema = object({
8106
8236
  destinations: StorageMigrationDestinationsSchema,
8237
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8238
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8239
+ * it. */
8240
+ mode: StorageMigrationModeSchema,
8107
8241
  moves: array(object({
8108
8242
  storageClass: StorageMigrationClassSchema,
8109
8243
  fromLocationId: string(),
8110
8244
  toLocationId: string()
8111
- }))
8245
+ })),
8246
+ findings: array(StorageMigrationFindingSchema)
8247
+ });
8248
+ /**
8249
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8250
+ *
8251
+ * The coordinator's job record is the state of record for a migration, and its
8252
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8253
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8254
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8255
+ * way because no supported UI path existed. A mover armed like that has no job
8256
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8257
+ *
8258
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8259
+ * orchestrated it.
8260
+ */
8261
+ var StorageMigrationMoverSchema = object({
8262
+ lane: _enum(["footage", "media"]),
8263
+ job: RelocateJobSchema,
8264
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8265
+ * directly against the owning addon. */
8266
+ migrationJobId: string().nullable(),
8267
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8268
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8269
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8270
+ * rate made of two different clocks. */
8271
+ observedAt: number()
8272
+ });
8273
+ /**
8274
+ * What a SOURCE still holds for one storage class — the number that makes a
8275
+ * "drain remaining" action honest rather than hopeful.
8276
+ *
8277
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8278
+ * engine's own selection count for media), never from the resident index: a
8279
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8280
+ * never been told about (D295).
8281
+ *
8282
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8283
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8284
+ * because refusing on an unanswerable read would hide exactly the case an
8285
+ * operator needs to act on.
8286
+ */
8287
+ var StorageMigrationResidueSchema = object({
8288
+ storageClass: StorageMigrationClassSchema,
8289
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8290
+ * move from wherever they are rather than from one named source. */
8291
+ fromLocationId: string(),
8292
+ /** Where a drain would move it — the class's CURRENT default. */
8293
+ toLocationId: string(),
8294
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8295
+ items: number().int().nonnegative().nullable(),
8296
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8297
+ bytes: number().int().nonnegative().nullable()
8298
+ });
8299
+ /**
8300
+ * Run the DRAIN half and nothing else.
8301
+ *
8302
+ * A migration that reached `done` has already repointed, so `start` correctly
8303
+ * refuses its destination ("already the default") — there is nothing left to
8304
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8305
+ * or finish against a work list that was a tenth of the archive (D295), and
8306
+ * before this there was no supported way to run only that half: the only way
8307
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8308
+ *
8309
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8310
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8311
+ * re-repoint a class that is already migrated.
8312
+ */
8313
+ var StorageMigrationDrainInputSchema = object({
8314
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8315
+ * a class whose source is already empty is refused rather than started. */
8316
+ classes: array(StorageMigrationClassSchema).min(1),
8317
+ throttleMbps: number().min(1).max(1e3).optional()
8318
+ });
8319
+ /** What a footage source still holds, asked of the durable hour ledger. */
8320
+ var RelocateResidueInputSchema = object({
8321
+ fromLocationId: string().min(1),
8322
+ /** Narrow to one logical class; omit for every profile on the location. */
8323
+ footageClass: RelocateFootageClassSchema.optional()
8324
+ });
8325
+ /** `null` = the archive could not answer (no ledger on this node, or the
8326
+ * aggregate failed). Never conflated with an empty source. */
8327
+ var RelocateResidueSchema = object({
8328
+ segments: number().int().nonnegative(),
8329
+ bytes: number().int().nonnegative()
8330
+ }).nullable();
8331
+ /** How many rows a media pass would still act on against a given target — the
8332
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8333
+ * never disagree. `null` = the count could not be taken. */
8334
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8335
+ var RelocatableMediaCountInputSchema = object({
8336
+ toLocationId: string().min(1),
8337
+ /** Omitted = `move`. */
8338
+ mode: MediaRelocateModeSchema.optional()
8112
8339
  });
8113
8340
  /**
8114
8341
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8214,6 +8441,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8214
8441
  * two addons declaring the same `id` must agree on `cardinality` (validated
8215
8442
  * at kernel aggregation time, not here).
8216
8443
  */
8444
+ /**
8445
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8446
+ * actually reaches the bytes. It is the constraint that decides which
8447
+ * `storage-provider`s may back a location of that kind.
8448
+ *
8449
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8450
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8451
+ * post-analysis media roots). Only a provider that serves a genuine local
8452
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8453
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8454
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8455
+ * against a same-named local directory that is something else entirely.
8456
+ *
8457
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8458
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8459
+ * service never sees a path, so any provider can back it. `backups` is the
8460
+ * one kind that qualifies today.
8461
+ *
8462
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8463
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8464
+ * refused the configuration; the first write simply went somewhere wrong, and
8465
+ * a recording write that goes wrong surfaces as a silent black window rather
8466
+ * than an error (the read path does not `stat`). This turns that accident into
8467
+ * a declared, enforced, testable refusal.
8468
+ */
8469
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8217
8470
  var StorageLocationDeclarationSchema = object({
8218
8471
  /**
8219
8472
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8233,6 +8486,19 @@ var StorageLocationDeclarationSchema = object({
8233
8486
  */
8234
8487
  cardinality: _enum(["single", "multi"]),
8235
8488
  /**
8489
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8490
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8491
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8492
+ *
8493
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8494
+ * can only over-restrict (refuse a remote provider for a kind that might
8495
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8496
+ * permissive direction and is therefore never inferred — a repo guard
8497
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8498
+ * reached by omission.
8499
+ */
8500
+ access: StorageAccessSchema.optional(),
8501
+ /**
8236
8502
  * When set, the default instance for this location inherits its resolved
8237
8503
  * root from the named location's default instance. Useful for derivative
8238
8504
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18100,8 +18366,10 @@ var TrackSchema = object({
18100
18366
  lastSeen: number(),
18101
18367
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18102
18368
  positions: array(TrackPositionSchema).readonly(),
18103
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18104
- * saveThumbnails policy). */
18369
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18370
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18371
+ * the retired `saveThumbnails` used to gate this and the rolling
18372
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18105
18373
  snapshots: array(TrackSnapshotSchema).readonly(),
18106
18374
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18107
18375
  zonesVisited: array(string()).readonly(),
@@ -18961,6 +19229,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18961
19229
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18962
19230
  kind: "mutation",
18963
19231
  auth: "admin"
19232
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19233
+ kind: "query",
19234
+ auth: "admin"
18964
19235
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18965
19236
  kind: "query",
18966
19237
  auth: "admin"
@@ -20972,7 +21243,10 @@ method(object({
20972
21243
  }), StorageLocationSchema, {
20973
21244
  kind: "mutation",
20974
21245
  auth: "admin"
20975
- }), method(object({ id: string() }), _void(), {
21246
+ }), method(object({
21247
+ id: string(),
21248
+ force: boolean().optional()
21249
+ }), _void(), {
20976
21250
  kind: "mutation",
20977
21251
  auth: "admin"
20978
21252
  }), method(object({ id: string() }), object({
@@ -21021,6 +21295,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21021
21295
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21022
21296
  kind: "mutation",
21023
21297
  auth: "admin"
21298
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21299
+ kind: "mutation",
21300
+ auth: "admin"
21024
21301
  });
21025
21302
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21026
21303
  providerId: string().min(1),
@@ -21419,12 +21696,38 @@ response: record(string(), unknown()) }), object({
21419
21696
  *
21420
21697
  * ## Why this is a capability and not a helper
21421
21698
  *
21422
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21423
- * plate, vehicle, identity, and the event store's derivativesand every one of
21424
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21425
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21426
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21427
- * load 5,000 rows before ranking anything.
21699
+ * This capability was introduced with the claim that SIX stores in
21700
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
21701
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21702
+ * claim was never true, and leaving it here made five stores look like pending
21703
+ * work when three of them have no vector at all. Counted column by column on
21704
+ * 2026-08-30, exactly THREE ever held one:
21705
+ *
21706
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21707
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21708
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21709
+ * face, migrated 2026-08-30 into its OWN index (see below).
21710
+ *
21711
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21712
+ * and `identities` store a name; the event store stores no derivative vector.
21713
+ * They are not migration candidates and never were.
21714
+ *
21715
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21716
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21717
+ * rows before ranking anything.
21718
+ *
21719
+ * ## One index per COMPARISON, never per encoder
21720
+ *
21721
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21722
+ * model, and they still get two indexes. An index is a set of things that are
21723
+ * ranked against each other and that live and die together, and these two are
21724
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21725
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21726
+ * forever and is the gallery every recognition ranks against. One index would
21727
+ * mean every gallery load and every reconcile carried a filter whose failure
21728
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21729
+ * person's only sample. The dimension they share is not a reason to share an
21730
+ * index; the question they answer is, and it differs.
21428
21731
  *
21429
21732
  * The fix is not a faster loop, it is a different backend — and the backend
21430
21733
  * should be replaceable without touching six callers. So: a singleton
@@ -21529,7 +21832,20 @@ var VectorQueryResultSchema = object({
21529
21832
  */
21530
21833
  scanned: number(),
21531
21834
  /** True when the backend could not consider every row that passed the filter. */
21532
- truncated: boolean()
21835
+ truncated: boolean(),
21836
+ /**
21837
+ * The `topK` the backend actually ran with.
21838
+ *
21839
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21840
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21841
+ * own log rather than in its answer. That is how an audit asking for 20,000
21842
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21843
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21844
+ * MUCH, in the return value, where the caller cannot fail to see it.
21845
+ *
21846
+ * Equals the requested `topK` whenever nothing was lowered.
21847
+ */
21848
+ effectiveTopK: number().int().positive()
21533
21849
  });
21534
21850
  var VectorDeleteInputSchema = object({
21535
21851
  index: string(),
@@ -21558,6 +21874,68 @@ var VectorGetResultSchema = object({ items: array(object({
21558
21874
  id: string(),
21559
21875
  metadata: VectorMetadataSchema
21560
21876
  })) });
21877
+ /**
21878
+ * Ids to read back WITH their vectors.
21879
+ *
21880
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21881
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21882
+ * caller depends on that promise. This one promises the opposite.
21883
+ *
21884
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21885
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21886
+ * a per-face cross-process KNN would be a network round trip inside the
21887
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21888
+ * it requires the index to hand the floats back. Without this method the only
21889
+ * way to keep a readable vector is a JSON column, which is the thing this
21890
+ * capability exists to delete.
21891
+ *
21892
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21893
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21894
+ */
21895
+ var VectorFetchInputSchema = object({
21896
+ index: string(),
21897
+ ids: array(string())
21898
+ });
21899
+ var VectorFetchResultSchema = object({ items: array(object({
21900
+ id: string(),
21901
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21902
+ vector: string(),
21903
+ metadata: VectorMetadataSchema
21904
+ })) });
21905
+ /**
21906
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21907
+ *
21908
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21909
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21910
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21911
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21912
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21913
+ * looked" for as long as anyone cared to read it.
21914
+ *
21915
+ * This is the primitive that question actually needs: a bounded page, ordered
21916
+ * by the backend's own row order, costing no distance computation at all.
21917
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21918
+ * the full-table read this capability was built to stop.
21919
+ */
21920
+ var VectorScanInputSchema = object({
21921
+ index: string(),
21922
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21923
+ cursor: number().int().nonnegative().default(0),
21924
+ limit: number().int().positive()
21925
+ });
21926
+ var VectorScanResultSchema = object({
21927
+ items: array(object({
21928
+ id: string(),
21929
+ metadata: VectorMetadataSchema
21930
+ })),
21931
+ /**
21932
+ * Where the next page starts, or `null` when the walk reached the end.
21933
+ *
21934
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21935
+ * from a short page: a backend is free to return fewer rows than asked.
21936
+ */
21937
+ nextCursor: number().int().nonnegative().nullable()
21938
+ });
21561
21939
  var VectorStatsInputSchema = object({ index: string() });
21562
21940
  var VectorStatsResultSchema = object({
21563
21941
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21576,7 +21954,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21576
21954
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21577
21955
  kind: "mutation",
21578
21956
  auth: "admin"
21579
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21957
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21580
21958
  kind: "mutation",
21581
21959
  auth: "admin"
21582
21960
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28283,6 +28661,9 @@ method(object({
28283
28661
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28284
28662
  kind: "query",
28285
28663
  auth: "admin"
28664
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28665
+ kind: "query",
28666
+ auth: "admin"
28286
28667
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28287
28668
  kind: "mutation",
28288
28669
  auth: "admin"
@@ -35321,6 +35702,18 @@ Object.freeze({
35321
35702
  addonId: null,
35322
35703
  access: "create"
35323
35704
  },
35705
+ "pipelineAnalytics.countRelocatableMedia": {
35706
+ capName: "pipeline-analytics",
35707
+ capScope: "device",
35708
+ addonId: null,
35709
+ access: "view"
35710
+ },
35711
+ "pipelineAnalytics.countUnstampedEventMedia": {
35712
+ capName: "pipeline-analytics",
35713
+ capScope: "device",
35714
+ addonId: null,
35715
+ access: "view"
35716
+ },
35324
35717
  "pipelineAnalytics.deleteDeviceEvents": {
35325
35718
  capName: "pipeline-analytics",
35326
35719
  capScope: "device",
@@ -36479,6 +36872,12 @@ Object.freeze({
36479
36872
  addonId: null,
36480
36873
  access: "view"
36481
36874
  },
36875
+ "recording.getRelocateResidue": {
36876
+ capName: "recording",
36877
+ capScope: "system",
36878
+ addonId: null,
36879
+ access: "view"
36880
+ },
36482
36881
  "recording.getStorageMigrationMoveStatus": {
36483
36882
  capName: "recording",
36484
36883
  capScope: "system",
@@ -37025,12 +37424,30 @@ Object.freeze({
37025
37424
  addonId: null,
37026
37425
  access: "create"
37027
37426
  },
37427
+ "storageMigration.drain": {
37428
+ capName: "storage-migration",
37429
+ capScope: "system",
37430
+ addonId: null,
37431
+ access: "create"
37432
+ },
37433
+ "storageMigration.movers": {
37434
+ capName: "storage-migration",
37435
+ capScope: "system",
37436
+ addonId: null,
37437
+ access: "view"
37438
+ },
37028
37439
  "storageMigration.plan": {
37029
37440
  capName: "storage-migration",
37030
37441
  capScope: "system",
37031
37442
  addonId: null,
37032
37443
  access: "view"
37033
37444
  },
37445
+ "storageMigration.residue": {
37446
+ capName: "storage-migration",
37447
+ capScope: "system",
37448
+ addonId: null,
37449
+ access: "view"
37450
+ },
37034
37451
  "storageMigration.start": {
37035
37452
  capName: "storage-migration",
37036
37453
  capScope: "system",
@@ -37865,6 +38282,12 @@ Object.freeze({
37865
38282
  addonId: null,
37866
38283
  access: "delete"
37867
38284
  },
38285
+ "vectorStore.fetchByIds": {
38286
+ capName: "vector-store",
38287
+ capScope: "system",
38288
+ addonId: null,
38289
+ access: "view"
38290
+ },
37868
38291
  "vectorStore.getByIds": {
37869
38292
  capName: "vector-store",
37870
38293
  capScope: "system",
@@ -37877,6 +38300,12 @@ Object.freeze({
37877
38300
  addonId: null,
37878
38301
  access: "view"
37879
38302
  },
38303
+ "vectorStore.scan": {
38304
+ capName: "vector-store",
38305
+ capScope: "system",
38306
+ addonId: null,
38307
+ access: "view"
38308
+ },
37880
38309
  "vectorStore.stats": {
37881
38310
  capName: "vector-store",
37882
38311
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-amcrest",
3
- "version": "0.2.43",
3
+ "version": "0.2.46",
4
4
  "description": "Amcrest/Dahua camera device provider addon for CamStack — Dahua CGI over HTTP(S) with digest auth (snapshot, RTSP catalog, PTZ, image/day-night config)",
5
5
  "keywords": [
6
6
  "camstack",