@camstack/addon-provider-hikvision 1.2.50 → 1.2.53

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
@@ -8034,18 +8034,61 @@ var RelocateFootageInputSchema = object({
8034
8034
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8035
8035
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8036
8036
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8037
+ /**
8038
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8039
+ * mover (the engine already walks both collections with a timestamp cursor and
8040
+ * already has a stamp-without-copy path).
8041
+ *
8042
+ * - `move` — the default and the historical behaviour: event-media and
8043
+ * retrain blobs move to `toLocationId` and their rows are
8044
+ * stamped. The enrolled gallery is skipped (D197).
8045
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8046
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8047
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8048
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8049
+ * instant a repoint moves that pointer the row reads from the
8050
+ * new disk while its bytes are on the old one.
8051
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8052
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8053
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8054
+ * never run beside a live second location: it is stop-the-world
8055
+ * by construction, which is acceptable only because the gallery
8056
+ * is a few KB per enrolled sample.
8057
+ */
8058
+ var MediaRelocateModeSchema = _enum([
8059
+ "move",
8060
+ "seal",
8061
+ "gallery"
8062
+ ]);
8037
8063
  var RelocateMediaInputSchema = object({
8038
8064
  toLocationId: string(),
8039
- throttleMbps: number().min(1).max(1e3).optional()
8065
+ throttleMbps: number().min(1).max(1e3).optional(),
8066
+ /** Omitted = `move`, the pre-existing behaviour. */
8067
+ mode: MediaRelocateModeSchema.optional()
8068
+ });
8069
+ /** How many rows still carry NO `locationId` — the population a repoint would
8070
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8071
+ * value that permits a non-blocking `eventMedia` cutover. */
8072
+ var UnstampedEventMediaCountSchema = object({
8073
+ media: number().int().nonnegative(),
8074
+ retrainFrames: number().int().nonnegative(),
8075
+ total: number().int().nonnegative()
8040
8076
  });
8041
8077
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8042
- /** The independently selectable logical storage classes. `recordings`
8043
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8044
- * segments; `eventMedia` is post-analysis blobs. */
8078
+ /** The independently selectable logical storage classes — every class
8079
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8080
+ * Zod enum error where they should meet an explanation.
8081
+ *
8082
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8083
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8084
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8085
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8045
8086
  var StorageMigrationClassSchema = _enum([
8046
8087
  "recordings",
8047
8088
  "recordingsLow",
8048
- "eventMedia"
8089
+ "eventMedia",
8090
+ "backups",
8091
+ "galleryMedia"
8049
8092
  ]);
8050
8093
  /** A destination is always an existing, fully-qualified location id. The
8051
8094
  * migration API intentionally never changes a source location's `basePath`:
@@ -8053,20 +8096,56 @@ var StorageMigrationClassSchema = _enum([
8053
8096
  var StorageMigrationDestinationsSchema = object({
8054
8097
  recordings: string().min(1).optional(),
8055
8098
  recordingsLow: string().min(1).optional(),
8056
- eventMedia: string().min(1).optional()
8099
+ eventMedia: string().min(1).optional(),
8100
+ backups: string().min(1).optional(),
8101
+ galleryMedia: string().min(1).optional()
8057
8102
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8103
+ /**
8104
+ * How a migration sequences the cutover against the byte move.
8105
+ *
8106
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8107
+ * resume. Recording is stopped for the whole move. Right
8108
+ * for a small or a cold class, and the only legal mode for
8109
+ * a `cardinality: 'single'` class.
8110
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8111
+ * refresh, resume, then move the past with everything
8112
+ * running. The pause is three bounded instants (a detach +
8113
+ * attach round, a write-gate drain, a lease) instead of one
8114
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8115
+ * stopped recording under `blocking`; the same move is
8116
+ * seconds of stopped recording under `nonBlocking`.
8117
+ *
8118
+ * The mode is on the JOB, not only on the input, because `status` is where an
8119
+ * operator finds out which one is running.
8120
+ */
8121
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8058
8122
  /** Shared input for planning and starting an orchestrated storage migration. */
8059
8123
  var StorageMigrationInputSchema = object({
8060
8124
  destinations: StorageMigrationDestinationsSchema,
8061
- throttleMbps: number().min(1).max(1e3).optional()
8125
+ throttleMbps: number().min(1).max(1e3).optional(),
8126
+ /** Omitted = `blocking`, which stays the default. */
8127
+ mode: StorageMigrationModeSchema.optional()
8062
8128
  });
8063
- /** The durable coordinator state machine. The only phase that changes default
8064
- * locations is `repointing`, after every selected mover has completed and been
8065
- * verified. */
8129
+ /**
8130
+ * The durable coordinator state machine.
8131
+ *
8132
+ * `blocking`:
8133
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8134
+ *
8135
+ * `nonBlocking`:
8136
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8137
+ *
8138
+ * Same phases, different order plus two new ones — not a second mover.
8139
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8140
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8141
+ * `repointing` is still the only phase that changes a default location.
8142
+ */
8066
8143
  var StorageMigrationPhaseSchema = _enum([
8067
8144
  "planning",
8145
+ "sealing",
8068
8146
  "pausing",
8069
8147
  "moving",
8148
+ "draining",
8070
8149
  "verifying",
8071
8150
  "repointing",
8072
8151
  "refreshing",
@@ -8080,17 +8159,56 @@ var StorageMigrationParticipantSchema = _enum([
8080
8159
  "recorder",
8081
8160
  "analytics"
8082
8161
  ]);
8162
+ /**
8163
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8164
+ *
8165
+ * The long half of a non-blocking migration is `draining`, and it is measured
8166
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8167
+ * existed the only place those numbers appeared was a Loki line, so an operator
8168
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8169
+ * afternoon.
8170
+ *
8171
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8172
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8173
+ * mover — which is the exact failure this is meant to end. The coordinator's
8174
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8175
+ * read `state`; folding the counters costs no extra read and makes the durable
8176
+ * record say afterwards how far a move actually got.
8177
+ *
8178
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8179
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8180
+ * cannot say M, and a 0 there would render as "100 % done".
8181
+ */
8182
+ var StorageMigrationMoveProgressSchema = object({
8183
+ filesMoved: number().int().nonnegative(),
8184
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8185
+ filesTotal: number().int().nonnegative().nullable(),
8186
+ bytesMoved: number().int().nonnegative(),
8187
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8188
+ * crash gets a new mover, and a rate computed from the migration's start
8189
+ * would silently average in the time nothing was running. */
8190
+ startedAt: number(),
8191
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8192
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8193
+ * subtract its own. */
8194
+ observedAt: number()
8195
+ });
8083
8196
  var StorageMigrationMoveSchema = object({
8084
8197
  storageClass: StorageMigrationClassSchema,
8085
8198
  fromLocationId: string(),
8086
8199
  toLocationId: string(),
8087
8200
  moverJobId: string().nullable(),
8088
8201
  state: RelocateJobStateSchema.nullable(),
8089
- error: string().nullable()
8202
+ error: string().nullable(),
8203
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8204
+ progress: StorageMigrationMoveProgressSchema.nullable()
8090
8205
  });
8091
8206
  var StorageMigrationJobSchema = object({
8092
8207
  jobId: string(),
8093
8208
  phase: StorageMigrationPhaseSchema,
8209
+ /** Which order this job is running. `status` is the only place an operator
8210
+ * can tell a seconds-long cutover from a thirty-hour one. */
8211
+ mode: StorageMigrationModeSchema,
8094
8212
  destinations: StorageMigrationDestinationsSchema,
8095
8213
  throttleMbps: number(),
8096
8214
  moves: array(StorageMigrationMoveSchema),
@@ -8103,13 +8221,122 @@ var StorageMigrationJobSchema = object({
8103
8221
  finishedAt: number().nullable(),
8104
8222
  error: string().nullable()
8105
8223
  });
8224
+ var StorageMigrationFindingSchema = object({
8225
+ code: _enum([
8226
+ "sharesDeviceWithSource",
8227
+ "deviceIdentityUnknown",
8228
+ "unstampedEventMediaRows",
8229
+ "blockingOnly",
8230
+ "noMover"
8231
+ ]),
8232
+ storageClass: StorageMigrationClassSchema,
8233
+ /** Human-readable, already carrying the ids and counts. */
8234
+ message: string()
8235
+ });
8106
8236
  var StorageMigrationPlanSchema = object({
8107
8237
  destinations: StorageMigrationDestinationsSchema,
8238
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8239
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8240
+ * it. */
8241
+ mode: StorageMigrationModeSchema,
8108
8242
  moves: array(object({
8109
8243
  storageClass: StorageMigrationClassSchema,
8110
8244
  fromLocationId: string(),
8111
8245
  toLocationId: string()
8112
- }))
8246
+ })),
8247
+ findings: array(StorageMigrationFindingSchema)
8248
+ });
8249
+ /**
8250
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8251
+ *
8252
+ * The coordinator's job record is the state of record for a migration, and its
8253
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8254
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8255
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8256
+ * way because no supported UI path existed. A mover armed like that has no job
8257
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8258
+ *
8259
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8260
+ * orchestrated it.
8261
+ */
8262
+ var StorageMigrationMoverSchema = object({
8263
+ lane: _enum(["footage", "media"]),
8264
+ job: RelocateJobSchema,
8265
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8266
+ * directly against the owning addon. */
8267
+ migrationJobId: string().nullable(),
8268
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8269
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8270
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8271
+ * rate made of two different clocks. */
8272
+ observedAt: number()
8273
+ });
8274
+ /**
8275
+ * What a SOURCE still holds for one storage class — the number that makes a
8276
+ * "drain remaining" action honest rather than hopeful.
8277
+ *
8278
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8279
+ * engine's own selection count for media), never from the resident index: a
8280
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8281
+ * never been told about (D295).
8282
+ *
8283
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8284
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8285
+ * because refusing on an unanswerable read would hide exactly the case an
8286
+ * operator needs to act on.
8287
+ */
8288
+ var StorageMigrationResidueSchema = object({
8289
+ storageClass: StorageMigrationClassSchema,
8290
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8291
+ * move from wherever they are rather than from one named source. */
8292
+ fromLocationId: string(),
8293
+ /** Where a drain would move it — the class's CURRENT default. */
8294
+ toLocationId: string(),
8295
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8296
+ items: number().int().nonnegative().nullable(),
8297
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8298
+ bytes: number().int().nonnegative().nullable()
8299
+ });
8300
+ /**
8301
+ * Run the DRAIN half and nothing else.
8302
+ *
8303
+ * A migration that reached `done` has already repointed, so `start` correctly
8304
+ * refuses its destination ("already the default") — there is nothing left to
8305
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8306
+ * or finish against a work list that was a tenth of the archive (D295), and
8307
+ * before this there was no supported way to run only that half: the only way
8308
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8309
+ *
8310
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8311
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8312
+ * re-repoint a class that is already migrated.
8313
+ */
8314
+ var StorageMigrationDrainInputSchema = object({
8315
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8316
+ * a class whose source is already empty is refused rather than started. */
8317
+ classes: array(StorageMigrationClassSchema).min(1),
8318
+ throttleMbps: number().min(1).max(1e3).optional()
8319
+ });
8320
+ /** What a footage source still holds, asked of the durable hour ledger. */
8321
+ var RelocateResidueInputSchema = object({
8322
+ fromLocationId: string().min(1),
8323
+ /** Narrow to one logical class; omit for every profile on the location. */
8324
+ footageClass: RelocateFootageClassSchema.optional()
8325
+ });
8326
+ /** `null` = the archive could not answer (no ledger on this node, or the
8327
+ * aggregate failed). Never conflated with an empty source. */
8328
+ var RelocateResidueSchema = object({
8329
+ segments: number().int().nonnegative(),
8330
+ bytes: number().int().nonnegative()
8331
+ }).nullable();
8332
+ /** How many rows a media pass would still act on against a given target — the
8333
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8334
+ * never disagree. `null` = the count could not be taken. */
8335
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8336
+ var RelocatableMediaCountInputSchema = object({
8337
+ toLocationId: string().min(1),
8338
+ /** Omitted = `move`. */
8339
+ mode: MediaRelocateModeSchema.optional()
8113
8340
  });
8114
8341
  /**
8115
8342
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8215,6 +8442,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8215
8442
  * two addons declaring the same `id` must agree on `cardinality` (validated
8216
8443
  * at kernel aggregation time, not here).
8217
8444
  */
8445
+ /**
8446
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8447
+ * actually reaches the bytes. It is the constraint that decides which
8448
+ * `storage-provider`s may back a location of that kind.
8449
+ *
8450
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8451
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8452
+ * post-analysis media roots). Only a provider that serves a genuine local
8453
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8454
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8455
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8456
+ * against a same-named local directory that is something else entirely.
8457
+ *
8458
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8459
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8460
+ * service never sees a path, so any provider can back it. `backups` is the
8461
+ * one kind that qualifies today.
8462
+ *
8463
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8464
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8465
+ * refused the configuration; the first write simply went somewhere wrong, and
8466
+ * a recording write that goes wrong surfaces as a silent black window rather
8467
+ * than an error (the read path does not `stat`). This turns that accident into
8468
+ * a declared, enforced, testable refusal.
8469
+ */
8470
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8218
8471
  var StorageLocationDeclarationSchema = object({
8219
8472
  /**
8220
8473
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8234,6 +8487,19 @@ var StorageLocationDeclarationSchema = object({
8234
8487
  */
8235
8488
  cardinality: _enum(["single", "multi"]),
8236
8489
  /**
8490
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8491
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8492
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8493
+ *
8494
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8495
+ * can only over-restrict (refuse a remote provider for a kind that might
8496
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8497
+ * permissive direction and is therefore never inferred — a repo guard
8498
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8499
+ * reached by omission.
8500
+ */
8501
+ access: StorageAccessSchema.optional(),
8502
+ /**
8237
8503
  * When set, the default instance for this location inherits its resolved
8238
8504
  * root from the named location's default instance. Useful for derivative
8239
8505
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18413,8 +18679,10 @@ var TrackSchema = object({
18413
18679
  lastSeen: number(),
18414
18680
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18415
18681
  positions: array(TrackPositionSchema).readonly(),
18416
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18417
- * saveThumbnails policy). */
18682
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18683
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18684
+ * the retired `saveThumbnails` used to gate this and the rolling
18685
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18418
18686
  snapshots: array(TrackSnapshotSchema).readonly(),
18419
18687
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18420
18688
  zonesVisited: array(string()).readonly(),
@@ -19274,6 +19542,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19274
19542
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19275
19543
  kind: "mutation",
19276
19544
  auth: "admin"
19545
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19546
+ kind: "query",
19547
+ auth: "admin"
19277
19548
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19278
19549
  kind: "query",
19279
19550
  auth: "admin"
@@ -21285,7 +21556,10 @@ method(object({
21285
21556
  }), StorageLocationSchema, {
21286
21557
  kind: "mutation",
21287
21558
  auth: "admin"
21288
- }), method(object({ id: string() }), _void(), {
21559
+ }), method(object({
21560
+ id: string(),
21561
+ force: boolean().optional()
21562
+ }), _void(), {
21289
21563
  kind: "mutation",
21290
21564
  auth: "admin"
21291
21565
  }), method(object({ id: string() }), object({
@@ -21334,6 +21608,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21334
21608
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21335
21609
  kind: "mutation",
21336
21610
  auth: "admin"
21611
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21612
+ kind: "mutation",
21613
+ auth: "admin"
21337
21614
  });
21338
21615
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21339
21616
  providerId: string().min(1),
@@ -21732,12 +22009,38 @@ response: record(string(), unknown()) }), object({
21732
22009
  *
21733
22010
  * ## Why this is a capability and not a helper
21734
22011
  *
21735
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21736
- * plate, vehicle, identity, and the event store's derivativesand every one of
21737
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21738
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21739
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21740
- * load 5,000 rows before ranking anything.
22012
+ * This capability was introduced with the claim that SIX stores in
22013
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
22014
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22015
+ * claim was never true, and leaving it here made five stores look like pending
22016
+ * work when three of them have no vector at all. Counted column by column on
22017
+ * 2026-08-30, exactly THREE ever held one:
22018
+ *
22019
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22020
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22021
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22022
+ * face, migrated 2026-08-30 into its OWN index (see below).
22023
+ *
22024
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22025
+ * and `identities` store a name; the event store stores no derivative vector.
22026
+ * They are not migration candidates and never were.
22027
+ *
22028
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22029
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22030
+ * rows before ranking anything.
22031
+ *
22032
+ * ## One index per COMPARISON, never per encoder
22033
+ *
22034
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22035
+ * model, and they still get two indexes. An index is a set of things that are
22036
+ * ranked against each other and that live and die together, and these two are
22037
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22038
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22039
+ * forever and is the gallery every recognition ranks against. One index would
22040
+ * mean every gallery load and every reconcile carried a filter whose failure
22041
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22042
+ * person's only sample. The dimension they share is not a reason to share an
22043
+ * index; the question they answer is, and it differs.
21741
22044
  *
21742
22045
  * The fix is not a faster loop, it is a different backend — and the backend
21743
22046
  * should be replaceable without touching six callers. So: a singleton
@@ -21842,7 +22145,20 @@ var VectorQueryResultSchema = object({
21842
22145
  */
21843
22146
  scanned: number(),
21844
22147
  /** True when the backend could not consider every row that passed the filter. */
21845
- truncated: boolean()
22148
+ truncated: boolean(),
22149
+ /**
22150
+ * The `topK` the backend actually ran with.
22151
+ *
22152
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22153
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22154
+ * own log rather than in its answer. That is how an audit asking for 20,000
22155
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22156
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22157
+ * MUCH, in the return value, where the caller cannot fail to see it.
22158
+ *
22159
+ * Equals the requested `topK` whenever nothing was lowered.
22160
+ */
22161
+ effectiveTopK: number().int().positive()
21846
22162
  });
21847
22163
  var VectorDeleteInputSchema = object({
21848
22164
  index: string(),
@@ -21871,6 +22187,68 @@ var VectorGetResultSchema = object({ items: array(object({
21871
22187
  id: string(),
21872
22188
  metadata: VectorMetadataSchema
21873
22189
  })) });
22190
+ /**
22191
+ * Ids to read back WITH their vectors.
22192
+ *
22193
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22194
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22195
+ * caller depends on that promise. This one promises the opposite.
22196
+ *
22197
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22198
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22199
+ * a per-face cross-process KNN would be a network round trip inside the
22200
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22201
+ * it requires the index to hand the floats back. Without this method the only
22202
+ * way to keep a readable vector is a JSON column, which is the thing this
22203
+ * capability exists to delete.
22204
+ *
22205
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22206
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22207
+ */
22208
+ var VectorFetchInputSchema = object({
22209
+ index: string(),
22210
+ ids: array(string())
22211
+ });
22212
+ var VectorFetchResultSchema = object({ items: array(object({
22213
+ id: string(),
22214
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22215
+ vector: string(),
22216
+ metadata: VectorMetadataSchema
22217
+ })) });
22218
+ /**
22219
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22220
+ *
22221
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22222
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22223
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22224
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22225
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22226
+ * looked" for as long as anyone cared to read it.
22227
+ *
22228
+ * This is the primitive that question actually needs: a bounded page, ordered
22229
+ * by the backend's own row order, costing no distance computation at all.
22230
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22231
+ * the full-table read this capability was built to stop.
22232
+ */
22233
+ var VectorScanInputSchema = object({
22234
+ index: string(),
22235
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22236
+ cursor: number().int().nonnegative().default(0),
22237
+ limit: number().int().positive()
22238
+ });
22239
+ var VectorScanResultSchema = object({
22240
+ items: array(object({
22241
+ id: string(),
22242
+ metadata: VectorMetadataSchema
22243
+ })),
22244
+ /**
22245
+ * Where the next page starts, or `null` when the walk reached the end.
22246
+ *
22247
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22248
+ * from a short page: a backend is free to return fewer rows than asked.
22249
+ */
22250
+ nextCursor: number().int().nonnegative().nullable()
22251
+ });
21874
22252
  var VectorStatsInputSchema = object({ index: string() });
21875
22253
  var VectorStatsResultSchema = object({
21876
22254
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21889,7 +22267,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21889
22267
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21890
22268
  kind: "mutation",
21891
22269
  auth: "admin"
21892
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22270
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21893
22271
  kind: "mutation",
21894
22272
  auth: "admin"
21895
22273
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28641,6 +29019,9 @@ method(object({
28641
29019
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28642
29020
  kind: "query",
28643
29021
  auth: "admin"
29022
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
29023
+ kind: "query",
29024
+ auth: "admin"
28644
29025
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28645
29026
  kind: "mutation",
28646
29027
  auth: "admin"
@@ -35706,6 +36087,18 @@ Object.freeze({
35706
36087
  addonId: null,
35707
36088
  access: "create"
35708
36089
  },
36090
+ "pipelineAnalytics.countRelocatableMedia": {
36091
+ capName: "pipeline-analytics",
36092
+ capScope: "device",
36093
+ addonId: null,
36094
+ access: "view"
36095
+ },
36096
+ "pipelineAnalytics.countUnstampedEventMedia": {
36097
+ capName: "pipeline-analytics",
36098
+ capScope: "device",
36099
+ addonId: null,
36100
+ access: "view"
36101
+ },
35709
36102
  "pipelineAnalytics.deleteDeviceEvents": {
35710
36103
  capName: "pipeline-analytics",
35711
36104
  capScope: "device",
@@ -36864,6 +37257,12 @@ Object.freeze({
36864
37257
  addonId: null,
36865
37258
  access: "view"
36866
37259
  },
37260
+ "recording.getRelocateResidue": {
37261
+ capName: "recording",
37262
+ capScope: "system",
37263
+ addonId: null,
37264
+ access: "view"
37265
+ },
36867
37266
  "recording.getStorageMigrationMoveStatus": {
36868
37267
  capName: "recording",
36869
37268
  capScope: "system",
@@ -37410,12 +37809,30 @@ Object.freeze({
37410
37809
  addonId: null,
37411
37810
  access: "create"
37412
37811
  },
37812
+ "storageMigration.drain": {
37813
+ capName: "storage-migration",
37814
+ capScope: "system",
37815
+ addonId: null,
37816
+ access: "create"
37817
+ },
37818
+ "storageMigration.movers": {
37819
+ capName: "storage-migration",
37820
+ capScope: "system",
37821
+ addonId: null,
37822
+ access: "view"
37823
+ },
37413
37824
  "storageMigration.plan": {
37414
37825
  capName: "storage-migration",
37415
37826
  capScope: "system",
37416
37827
  addonId: null,
37417
37828
  access: "view"
37418
37829
  },
37830
+ "storageMigration.residue": {
37831
+ capName: "storage-migration",
37832
+ capScope: "system",
37833
+ addonId: null,
37834
+ access: "view"
37835
+ },
37419
37836
  "storageMigration.start": {
37420
37837
  capName: "storage-migration",
37421
37838
  capScope: "system",
@@ -38250,6 +38667,12 @@ Object.freeze({
38250
38667
  addonId: null,
38251
38668
  access: "delete"
38252
38669
  },
38670
+ "vectorStore.fetchByIds": {
38671
+ capName: "vector-store",
38672
+ capScope: "system",
38673
+ addonId: null,
38674
+ access: "view"
38675
+ },
38253
38676
  "vectorStore.getByIds": {
38254
38677
  capName: "vector-store",
38255
38678
  capScope: "system",
@@ -38262,6 +38685,12 @@ Object.freeze({
38262
38685
  addonId: null,
38263
38686
  access: "view"
38264
38687
  },
38688
+ "vectorStore.scan": {
38689
+ capName: "vector-store",
38690
+ capScope: "system",
38691
+ addonId: null,
38692
+ access: "view"
38693
+ },
38265
38694
  "vectorStore.stats": {
38266
38695
  capName: "vector-store",
38267
38696
  capScope: "system",
package/dist/addon.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
@@ -18414,8 +18680,10 @@ var TrackSchema = object({
18414
18680
  lastSeen: number(),
18415
18681
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18416
18682
  positions: array(TrackPositionSchema).readonly(),
18417
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18418
- * saveThumbnails policy). */
18683
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18684
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18685
+ * the retired `saveThumbnails` used to gate this and the rolling
18686
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18419
18687
  snapshots: array(TrackSnapshotSchema).readonly(),
18420
18688
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18421
18689
  zonesVisited: array(string()).readonly(),
@@ -19275,6 +19543,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19275
19543
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19276
19544
  kind: "mutation",
19277
19545
  auth: "admin"
19546
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19547
+ kind: "query",
19548
+ auth: "admin"
19278
19549
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19279
19550
  kind: "query",
19280
19551
  auth: "admin"
@@ -21286,7 +21557,10 @@ method(object({
21286
21557
  }), StorageLocationSchema, {
21287
21558
  kind: "mutation",
21288
21559
  auth: "admin"
21289
- }), method(object({ id: string() }), _void(), {
21560
+ }), method(object({
21561
+ id: string(),
21562
+ force: boolean().optional()
21563
+ }), _void(), {
21290
21564
  kind: "mutation",
21291
21565
  auth: "admin"
21292
21566
  }), method(object({ id: string() }), object({
@@ -21335,6 +21609,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21335
21609
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21336
21610
  kind: "mutation",
21337
21611
  auth: "admin"
21612
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21613
+ kind: "mutation",
21614
+ auth: "admin"
21338
21615
  });
21339
21616
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21340
21617
  providerId: string().min(1),
@@ -21733,12 +22010,38 @@ response: record(string(), unknown()) }), object({
21733
22010
  *
21734
22011
  * ## Why this is a capability and not a helper
21735
22012
  *
21736
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21737
- * plate, vehicle, identity, and the event store's derivativesand every one of
21738
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21739
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21740
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21741
- * load 5,000 rows before ranking anything.
22013
+ * This capability was introduced with the claim that SIX stores in
22014
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
22015
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22016
+ * claim was never true, and leaving it here made five stores look like pending
22017
+ * work when three of them have no vector at all. Counted column by column on
22018
+ * 2026-08-30, exactly THREE ever held one:
22019
+ *
22020
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22021
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22022
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22023
+ * face, migrated 2026-08-30 into its OWN index (see below).
22024
+ *
22025
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22026
+ * and `identities` store a name; the event store stores no derivative vector.
22027
+ * They are not migration candidates and never were.
22028
+ *
22029
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22030
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22031
+ * rows before ranking anything.
22032
+ *
22033
+ * ## One index per COMPARISON, never per encoder
22034
+ *
22035
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22036
+ * model, and they still get two indexes. An index is a set of things that are
22037
+ * ranked against each other and that live and die together, and these two are
22038
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22039
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22040
+ * forever and is the gallery every recognition ranks against. One index would
22041
+ * mean every gallery load and every reconcile carried a filter whose failure
22042
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22043
+ * person's only sample. The dimension they share is not a reason to share an
22044
+ * index; the question they answer is, and it differs.
21742
22045
  *
21743
22046
  * The fix is not a faster loop, it is a different backend — and the backend
21744
22047
  * should be replaceable without touching six callers. So: a singleton
@@ -21843,7 +22146,20 @@ var VectorQueryResultSchema = object({
21843
22146
  */
21844
22147
  scanned: number(),
21845
22148
  /** True when the backend could not consider every row that passed the filter. */
21846
- truncated: boolean()
22149
+ truncated: boolean(),
22150
+ /**
22151
+ * The `topK` the backend actually ran with.
22152
+ *
22153
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22154
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22155
+ * own log rather than in its answer. That is how an audit asking for 20,000
22156
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22157
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22158
+ * MUCH, in the return value, where the caller cannot fail to see it.
22159
+ *
22160
+ * Equals the requested `topK` whenever nothing was lowered.
22161
+ */
22162
+ effectiveTopK: number().int().positive()
21847
22163
  });
21848
22164
  var VectorDeleteInputSchema = object({
21849
22165
  index: string(),
@@ -21872,6 +22188,68 @@ var VectorGetResultSchema = object({ items: array(object({
21872
22188
  id: string(),
21873
22189
  metadata: VectorMetadataSchema
21874
22190
  })) });
22191
+ /**
22192
+ * Ids to read back WITH their vectors.
22193
+ *
22194
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22195
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22196
+ * caller depends on that promise. This one promises the opposite.
22197
+ *
22198
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22199
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22200
+ * a per-face cross-process KNN would be a network round trip inside the
22201
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22202
+ * it requires the index to hand the floats back. Without this method the only
22203
+ * way to keep a readable vector is a JSON column, which is the thing this
22204
+ * capability exists to delete.
22205
+ *
22206
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22207
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22208
+ */
22209
+ var VectorFetchInputSchema = object({
22210
+ index: string(),
22211
+ ids: array(string())
22212
+ });
22213
+ var VectorFetchResultSchema = object({ items: array(object({
22214
+ id: string(),
22215
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22216
+ vector: string(),
22217
+ metadata: VectorMetadataSchema
22218
+ })) });
22219
+ /**
22220
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22221
+ *
22222
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22223
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22224
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22225
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22226
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22227
+ * looked" for as long as anyone cared to read it.
22228
+ *
22229
+ * This is the primitive that question actually needs: a bounded page, ordered
22230
+ * by the backend's own row order, costing no distance computation at all.
22231
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22232
+ * the full-table read this capability was built to stop.
22233
+ */
22234
+ var VectorScanInputSchema = object({
22235
+ index: string(),
22236
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22237
+ cursor: number().int().nonnegative().default(0),
22238
+ limit: number().int().positive()
22239
+ });
22240
+ var VectorScanResultSchema = object({
22241
+ items: array(object({
22242
+ id: string(),
22243
+ metadata: VectorMetadataSchema
22244
+ })),
22245
+ /**
22246
+ * Where the next page starts, or `null` when the walk reached the end.
22247
+ *
22248
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22249
+ * from a short page: a backend is free to return fewer rows than asked.
22250
+ */
22251
+ nextCursor: number().int().nonnegative().nullable()
22252
+ });
21875
22253
  var VectorStatsInputSchema = object({ index: string() });
21876
22254
  var VectorStatsResultSchema = object({
21877
22255
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21890,7 +22268,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21890
22268
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21891
22269
  kind: "mutation",
21892
22270
  auth: "admin"
21893
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22271
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21894
22272
  kind: "mutation",
21895
22273
  auth: "admin"
21896
22274
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28642,6 +29020,9 @@ method(object({
28642
29020
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28643
29021
  kind: "query",
28644
29022
  auth: "admin"
29023
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
29024
+ kind: "query",
29025
+ auth: "admin"
28645
29026
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28646
29027
  kind: "mutation",
28647
29028
  auth: "admin"
@@ -35707,6 +36088,18 @@ Object.freeze({
35707
36088
  addonId: null,
35708
36089
  access: "create"
35709
36090
  },
36091
+ "pipelineAnalytics.countRelocatableMedia": {
36092
+ capName: "pipeline-analytics",
36093
+ capScope: "device",
36094
+ addonId: null,
36095
+ access: "view"
36096
+ },
36097
+ "pipelineAnalytics.countUnstampedEventMedia": {
36098
+ capName: "pipeline-analytics",
36099
+ capScope: "device",
36100
+ addonId: null,
36101
+ access: "view"
36102
+ },
35710
36103
  "pipelineAnalytics.deleteDeviceEvents": {
35711
36104
  capName: "pipeline-analytics",
35712
36105
  capScope: "device",
@@ -36865,6 +37258,12 @@ Object.freeze({
36865
37258
  addonId: null,
36866
37259
  access: "view"
36867
37260
  },
37261
+ "recording.getRelocateResidue": {
37262
+ capName: "recording",
37263
+ capScope: "system",
37264
+ addonId: null,
37265
+ access: "view"
37266
+ },
36868
37267
  "recording.getStorageMigrationMoveStatus": {
36869
37268
  capName: "recording",
36870
37269
  capScope: "system",
@@ -37411,12 +37810,30 @@ Object.freeze({
37411
37810
  addonId: null,
37412
37811
  access: "create"
37413
37812
  },
37813
+ "storageMigration.drain": {
37814
+ capName: "storage-migration",
37815
+ capScope: "system",
37816
+ addonId: null,
37817
+ access: "create"
37818
+ },
37819
+ "storageMigration.movers": {
37820
+ capName: "storage-migration",
37821
+ capScope: "system",
37822
+ addonId: null,
37823
+ access: "view"
37824
+ },
37414
37825
  "storageMigration.plan": {
37415
37826
  capName: "storage-migration",
37416
37827
  capScope: "system",
37417
37828
  addonId: null,
37418
37829
  access: "view"
37419
37830
  },
37831
+ "storageMigration.residue": {
37832
+ capName: "storage-migration",
37833
+ capScope: "system",
37834
+ addonId: null,
37835
+ access: "view"
37836
+ },
37420
37837
  "storageMigration.start": {
37421
37838
  capName: "storage-migration",
37422
37839
  capScope: "system",
@@ -38251,6 +38668,12 @@ Object.freeze({
38251
38668
  addonId: null,
38252
38669
  access: "delete"
38253
38670
  },
38671
+ "vectorStore.fetchByIds": {
38672
+ capName: "vector-store",
38673
+ capScope: "system",
38674
+ addonId: null,
38675
+ access: "view"
38676
+ },
38254
38677
  "vectorStore.getByIds": {
38255
38678
  capName: "vector-store",
38256
38679
  capScope: "system",
@@ -38263,6 +38686,12 @@ Object.freeze({
38263
38686
  addonId: null,
38264
38687
  access: "view"
38265
38688
  },
38689
+ "vectorStore.scan": {
38690
+ capName: "vector-store",
38691
+ capScope: "system",
38692
+ addonId: null,
38693
+ access: "view"
38694
+ },
38266
38695
  "vectorStore.stats": {
38267
38696
  capName: "vector-store",
38268
38697
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-hikvision",
3
- "version": "1.2.50",
3
+ "version": "1.2.53",
4
4
  "description": "Hikvision camera device provider addon for CamStack — ISAPI over HTTP(S) with digest auth (snapshot, alarm stream, RTSP discovery)",
5
5
  "keywords": [
6
6
  "camstack",