@camstack/addon-matter-broker 0.2.41 → 0.2.44

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
@@ -8053,18 +8053,61 @@ var RelocateFootageInputSchema = object({
8053
8053
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8054
8054
  var StorageMigrationLeaseInputSchema = object({ leaseId: string$2().min(1) });
8055
8055
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string$2().min(1) });
8056
+ /**
8057
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8058
+ * mover (the engine already walks both collections with a timestamp cursor and
8059
+ * already has a stamp-without-copy path).
8060
+ *
8061
+ * - `move` — the default and the historical behaviour: event-media and
8062
+ * retrain blobs move to `toLocationId` and their rows are
8063
+ * stamped. The enrolled gallery is skipped (D197).
8064
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8065
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8066
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8067
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8068
+ * instant a repoint moves that pointer the row reads from the
8069
+ * new disk while its bytes are on the old one.
8070
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8071
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8072
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8073
+ * never run beside a live second location: it is stop-the-world
8074
+ * by construction, which is acceptable only because the gallery
8075
+ * is a few KB per enrolled sample.
8076
+ */
8077
+ var MediaRelocateModeSchema = _enum([
8078
+ "move",
8079
+ "seal",
8080
+ "gallery"
8081
+ ]);
8056
8082
  var RelocateMediaInputSchema = object({
8057
8083
  toLocationId: string$2(),
8058
- throttleMbps: number().min(1).max(1e3).optional()
8084
+ throttleMbps: number().min(1).max(1e3).optional(),
8085
+ /** Omitted = `move`, the pre-existing behaviour. */
8086
+ mode: MediaRelocateModeSchema.optional()
8087
+ });
8088
+ /** How many rows still carry NO `locationId` — the population a repoint would
8089
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8090
+ * value that permits a non-blocking `eventMedia` cutover. */
8091
+ var UnstampedEventMediaCountSchema = object({
8092
+ media: number().int().nonnegative(),
8093
+ retrainFrames: number().int().nonnegative(),
8094
+ total: number().int().nonnegative()
8059
8095
  });
8060
8096
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string$2().min(1) });
8061
- /** The independently selectable logical storage classes. `recordings`
8062
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8063
- * segments; `eventMedia` is post-analysis blobs. */
8097
+ /** The independently selectable logical storage classes — every class
8098
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8099
+ * Zod enum error where they should meet an explanation.
8100
+ *
8101
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8102
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8103
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8104
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8064
8105
  var StorageMigrationClassSchema = _enum([
8065
8106
  "recordings",
8066
8107
  "recordingsLow",
8067
- "eventMedia"
8108
+ "eventMedia",
8109
+ "backups",
8110
+ "galleryMedia"
8068
8111
  ]);
8069
8112
  /** A destination is always an existing, fully-qualified location id. The
8070
8113
  * migration API intentionally never changes a source location's `basePath`:
@@ -8072,20 +8115,56 @@ var StorageMigrationClassSchema = _enum([
8072
8115
  var StorageMigrationDestinationsSchema = object({
8073
8116
  recordings: string$2().min(1).optional(),
8074
8117
  recordingsLow: string$2().min(1).optional(),
8075
- eventMedia: string$2().min(1).optional()
8118
+ eventMedia: string$2().min(1).optional(),
8119
+ backups: string$2().min(1).optional(),
8120
+ galleryMedia: string$2().min(1).optional()
8076
8121
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8122
+ /**
8123
+ * How a migration sequences the cutover against the byte move.
8124
+ *
8125
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8126
+ * resume. Recording is stopped for the whole move. Right
8127
+ * for a small or a cold class, and the only legal mode for
8128
+ * a `cardinality: 'single'` class.
8129
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8130
+ * refresh, resume, then move the past with everything
8131
+ * running. The pause is three bounded instants (a detach +
8132
+ * attach round, a write-gate drain, a lease) instead of one
8133
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8134
+ * stopped recording under `blocking`; the same move is
8135
+ * seconds of stopped recording under `nonBlocking`.
8136
+ *
8137
+ * The mode is on the JOB, not only on the input, because `status` is where an
8138
+ * operator finds out which one is running.
8139
+ */
8140
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8077
8141
  /** Shared input for planning and starting an orchestrated storage migration. */
8078
8142
  var StorageMigrationInputSchema = object({
8079
8143
  destinations: StorageMigrationDestinationsSchema,
8080
- throttleMbps: number().min(1).max(1e3).optional()
8144
+ throttleMbps: number().min(1).max(1e3).optional(),
8145
+ /** Omitted = `blocking`, which stays the default. */
8146
+ mode: StorageMigrationModeSchema.optional()
8081
8147
  });
8082
- /** The durable coordinator state machine. The only phase that changes default
8083
- * locations is `repointing`, after every selected mover has completed and been
8084
- * verified. */
8148
+ /**
8149
+ * The durable coordinator state machine.
8150
+ *
8151
+ * `blocking`:
8152
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8153
+ *
8154
+ * `nonBlocking`:
8155
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8156
+ *
8157
+ * Same phases, different order plus two new ones — not a second mover.
8158
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8159
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8160
+ * `repointing` is still the only phase that changes a default location.
8161
+ */
8085
8162
  var StorageMigrationPhaseSchema = _enum([
8086
8163
  "planning",
8164
+ "sealing",
8087
8165
  "pausing",
8088
8166
  "moving",
8167
+ "draining",
8089
8168
  "verifying",
8090
8169
  "repointing",
8091
8170
  "refreshing",
@@ -8099,17 +8178,56 @@ var StorageMigrationParticipantSchema = _enum([
8099
8178
  "recorder",
8100
8179
  "analytics"
8101
8180
  ]);
8181
+ /**
8182
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8183
+ *
8184
+ * The long half of a non-blocking migration is `draining`, and it is measured
8185
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8186
+ * existed the only place those numbers appeared was a Loki line, so an operator
8187
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8188
+ * afternoon.
8189
+ *
8190
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8191
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8192
+ * mover — which is the exact failure this is meant to end. The coordinator's
8193
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8194
+ * read `state`; folding the counters costs no extra read and makes the durable
8195
+ * record say afterwards how far a move actually got.
8196
+ *
8197
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8198
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8199
+ * cannot say M, and a 0 there would render as "100 % done".
8200
+ */
8201
+ var StorageMigrationMoveProgressSchema = object({
8202
+ filesMoved: number().int().nonnegative(),
8203
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8204
+ filesTotal: number().int().nonnegative().nullable(),
8205
+ bytesMoved: number().int().nonnegative(),
8206
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8207
+ * crash gets a new mover, and a rate computed from the migration's start
8208
+ * would silently average in the time nothing was running. */
8209
+ startedAt: number(),
8210
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8211
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8212
+ * subtract its own. */
8213
+ observedAt: number()
8214
+ });
8102
8215
  var StorageMigrationMoveSchema = object({
8103
8216
  storageClass: StorageMigrationClassSchema,
8104
8217
  fromLocationId: string$2(),
8105
8218
  toLocationId: string$2(),
8106
8219
  moverJobId: string$2().nullable(),
8107
8220
  state: RelocateJobStateSchema.nullable(),
8108
- error: string$2().nullable()
8221
+ error: string$2().nullable(),
8222
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8223
+ progress: StorageMigrationMoveProgressSchema.nullable()
8109
8224
  });
8110
8225
  var StorageMigrationJobSchema = object({
8111
8226
  jobId: string$2(),
8112
8227
  phase: StorageMigrationPhaseSchema,
8228
+ /** Which order this job is running. `status` is the only place an operator
8229
+ * can tell a seconds-long cutover from a thirty-hour one. */
8230
+ mode: StorageMigrationModeSchema,
8113
8231
  destinations: StorageMigrationDestinationsSchema,
8114
8232
  throttleMbps: number(),
8115
8233
  moves: array(StorageMigrationMoveSchema),
@@ -8122,13 +8240,122 @@ var StorageMigrationJobSchema = object({
8122
8240
  finishedAt: number().nullable(),
8123
8241
  error: string$2().nullable()
8124
8242
  });
8243
+ var StorageMigrationFindingSchema = object({
8244
+ code: _enum([
8245
+ "sharesDeviceWithSource",
8246
+ "deviceIdentityUnknown",
8247
+ "unstampedEventMediaRows",
8248
+ "blockingOnly",
8249
+ "noMover"
8250
+ ]),
8251
+ storageClass: StorageMigrationClassSchema,
8252
+ /** Human-readable, already carrying the ids and counts. */
8253
+ message: string$2()
8254
+ });
8125
8255
  var StorageMigrationPlanSchema = object({
8126
8256
  destinations: StorageMigrationDestinationsSchema,
8257
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8258
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8259
+ * it. */
8260
+ mode: StorageMigrationModeSchema,
8127
8261
  moves: array(object({
8128
8262
  storageClass: StorageMigrationClassSchema,
8129
8263
  fromLocationId: string$2(),
8130
8264
  toLocationId: string$2()
8131
- }))
8265
+ })),
8266
+ findings: array(StorageMigrationFindingSchema)
8267
+ });
8268
+ /**
8269
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8270
+ *
8271
+ * The coordinator's job record is the state of record for a migration, and its
8272
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8273
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8274
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8275
+ * way because no supported UI path existed. A mover armed like that has no job
8276
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8277
+ *
8278
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8279
+ * orchestrated it.
8280
+ */
8281
+ var StorageMigrationMoverSchema = object({
8282
+ lane: _enum(["footage", "media"]),
8283
+ job: RelocateJobSchema,
8284
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8285
+ * directly against the owning addon. */
8286
+ migrationJobId: string$2().nullable(),
8287
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8288
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8289
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8290
+ * rate made of two different clocks. */
8291
+ observedAt: number()
8292
+ });
8293
+ /**
8294
+ * What a SOURCE still holds for one storage class — the number that makes a
8295
+ * "drain remaining" action honest rather than hopeful.
8296
+ *
8297
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8298
+ * engine's own selection count for media), never from the resident index: a
8299
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8300
+ * never been told about (D295).
8301
+ *
8302
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8303
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8304
+ * because refusing on an unanswerable read would hide exactly the case an
8305
+ * operator needs to act on.
8306
+ */
8307
+ var StorageMigrationResidueSchema = object({
8308
+ storageClass: StorageMigrationClassSchema,
8309
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8310
+ * move from wherever they are rather than from one named source. */
8311
+ fromLocationId: string$2(),
8312
+ /** Where a drain would move it — the class's CURRENT default. */
8313
+ toLocationId: string$2(),
8314
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8315
+ items: number().int().nonnegative().nullable(),
8316
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8317
+ bytes: number().int().nonnegative().nullable()
8318
+ });
8319
+ /**
8320
+ * Run the DRAIN half and nothing else.
8321
+ *
8322
+ * A migration that reached `done` has already repointed, so `start` correctly
8323
+ * refuses its destination ("already the default") — there is nothing left to
8324
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8325
+ * or finish against a work list that was a tenth of the archive (D295), and
8326
+ * before this there was no supported way to run only that half: the only way
8327
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8328
+ *
8329
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8330
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8331
+ * re-repoint a class that is already migrated.
8332
+ */
8333
+ var StorageMigrationDrainInputSchema = object({
8334
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8335
+ * a class whose source is already empty is refused rather than started. */
8336
+ classes: array(StorageMigrationClassSchema).min(1),
8337
+ throttleMbps: number().min(1).max(1e3).optional()
8338
+ });
8339
+ /** What a footage source still holds, asked of the durable hour ledger. */
8340
+ var RelocateResidueInputSchema = object({
8341
+ fromLocationId: string$2().min(1),
8342
+ /** Narrow to one logical class; omit for every profile on the location. */
8343
+ footageClass: RelocateFootageClassSchema.optional()
8344
+ });
8345
+ /** `null` = the archive could not answer (no ledger on this node, or the
8346
+ * aggregate failed). Never conflated with an empty source. */
8347
+ var RelocateResidueSchema = object({
8348
+ segments: number().int().nonnegative(),
8349
+ bytes: number().int().nonnegative()
8350
+ }).nullable();
8351
+ /** How many rows a media pass would still act on against a given target — the
8352
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8353
+ * never disagree. `null` = the count could not be taken. */
8354
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8355
+ var RelocatableMediaCountInputSchema = object({
8356
+ toLocationId: string$2().min(1),
8357
+ /** Omitted = `move`. */
8358
+ mode: MediaRelocateModeSchema.optional()
8132
8359
  });
8133
8360
  /**
8134
8361
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8234,6 +8461,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string$2().rege
8234
8461
  * two addons declaring the same `id` must agree on `cardinality` (validated
8235
8462
  * at kernel aggregation time, not here).
8236
8463
  */
8464
+ /**
8465
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8466
+ * actually reaches the bytes. It is the constraint that decides which
8467
+ * `storage-provider`s may back a location of that kind.
8468
+ *
8469
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8470
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8471
+ * post-analysis media roots). Only a provider that serves a genuine local
8472
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8473
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8474
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8475
+ * against a same-named local directory that is something else entirely.
8476
+ *
8477
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8478
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8479
+ * service never sees a path, so any provider can back it. `backups` is the
8480
+ * one kind that qualifies today.
8481
+ *
8482
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8483
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8484
+ * refused the configuration; the first write simply went somewhere wrong, and
8485
+ * a recording write that goes wrong surfaces as a silent black window rather
8486
+ * than an error (the read path does not `stat`). This turns that accident into
8487
+ * a declared, enforced, testable refusal.
8488
+ */
8489
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8237
8490
  var StorageLocationDeclarationSchema = object({
8238
8491
  /**
8239
8492
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8253,6 +8506,19 @@ var StorageLocationDeclarationSchema = object({
8253
8506
  */
8254
8507
  cardinality: _enum(["single", "multi"]),
8255
8508
  /**
8509
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8510
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8511
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8512
+ *
8513
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8514
+ * can only over-restrict (refuse a remote provider for a kind that might
8515
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8516
+ * permissive direction and is therefore never inferred — a repo guard
8517
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8518
+ * reached by omission.
8519
+ */
8520
+ access: StorageAccessSchema.optional(),
8521
+ /**
8256
8522
  * When set, the default instance for this location inherits its resolved
8257
8523
  * root from the named location's default instance. Useful for derivative
8258
8524
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18186,8 +18452,10 @@ var TrackSchema = object({
18186
18452
  lastSeen: number(),
18187
18453
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18188
18454
  positions: array(TrackPositionSchema).readonly(),
18189
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18190
- * saveThumbnails policy). */
18455
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18456
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18457
+ * the retired `saveThumbnails` used to gate this and the rolling
18458
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18191
18459
  snapshots: array(TrackSnapshotSchema).readonly(),
18192
18460
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18193
18461
  zonesVisited: array(string$2()).readonly(),
@@ -19047,6 +19315,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19047
19315
  }), method(RelocateMediaInputSchema, object({ jobId: string$2() }), {
19048
19316
  kind: "mutation",
19049
19317
  auth: "admin"
19318
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19319
+ kind: "query",
19320
+ auth: "admin"
19050
19321
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19051
19322
  kind: "query",
19052
19323
  auth: "admin"
@@ -20954,7 +21225,10 @@ method(object({
20954
21225
  }), StorageLocationSchema, {
20955
21226
  kind: "mutation",
20956
21227
  auth: "admin"
20957
- }), method(object({ id: string$2() }), _void(), {
21228
+ }), method(object({
21229
+ id: string$2(),
21230
+ force: boolean().optional()
21231
+ }), _void(), {
20958
21232
  kind: "mutation",
20959
21233
  auth: "admin"
20960
21234
  }), method(object({ id: string$2() }), object({
@@ -21003,6 +21277,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21003
21277
  }), method(object({ jobId: string$2().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
21004
21278
  kind: "mutation",
21005
21279
  auth: "admin"
21280
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string$2() }), {
21281
+ kind: "mutation",
21282
+ auth: "admin"
21006
21283
  });
21007
21284
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21008
21285
  providerId: string$2().min(1),
@@ -21401,12 +21678,38 @@ response: record(string$2(), unknown()) }), object({
21401
21678
  *
21402
21679
  * ## Why this is a capability and not a helper
21403
21680
  *
21404
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21405
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21406
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21407
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21408
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21409
- * load 5,000 rows before ranking anything.
21681
+ * This capability was introduced with the claim that SIX stores in
21682
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21683
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21684
+ * claim was never true, and leaving it here made five stores look like pending
21685
+ * work when three of them have no vector at all. Counted column by column on
21686
+ * 2026-08-30, exactly THREE ever held one:
21687
+ *
21688
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21689
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21690
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21691
+ * face, migrated 2026-08-30 into its OWN index (see below).
21692
+ *
21693
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21694
+ * and `identities` store a name; the event store stores no derivative vector.
21695
+ * They are not migration candidates and never were.
21696
+ *
21697
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21698
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21699
+ * rows before ranking anything.
21700
+ *
21701
+ * ## One index per COMPARISON, never per encoder
21702
+ *
21703
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21704
+ * model, and they still get two indexes. An index is a set of things that are
21705
+ * ranked against each other and that live and die together, and these two are
21706
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21707
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21708
+ * forever and is the gallery every recognition ranks against. One index would
21709
+ * mean every gallery load and every reconcile carried a filter whose failure
21710
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21711
+ * person's only sample. The dimension they share is not a reason to share an
21712
+ * index; the question they answer is, and it differs.
21410
21713
  *
21411
21714
  * The fix is not a faster loop, it is a different backend — and the backend
21412
21715
  * should be replaceable without touching six callers. So: a singleton
@@ -21511,7 +21814,20 @@ var VectorQueryResultSchema = object({
21511
21814
  */
21512
21815
  scanned: number(),
21513
21816
  /** True when the backend could not consider every row that passed the filter. */
21514
- truncated: boolean()
21817
+ truncated: boolean(),
21818
+ /**
21819
+ * The `topK` the backend actually ran with.
21820
+ *
21821
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21822
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21823
+ * own log rather than in its answer. That is how an audit asking for 20,000
21824
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21825
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21826
+ * MUCH, in the return value, where the caller cannot fail to see it.
21827
+ *
21828
+ * Equals the requested `topK` whenever nothing was lowered.
21829
+ */
21830
+ effectiveTopK: number().int().positive()
21515
21831
  });
21516
21832
  var VectorDeleteInputSchema = object({
21517
21833
  index: string$2(),
@@ -21540,6 +21856,68 @@ var VectorGetResultSchema = object({ items: array(object({
21540
21856
  id: string$2(),
21541
21857
  metadata: VectorMetadataSchema
21542
21858
  })) });
21859
+ /**
21860
+ * Ids to read back WITH their vectors.
21861
+ *
21862
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21863
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21864
+ * caller depends on that promise. This one promises the opposite.
21865
+ *
21866
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21867
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21868
+ * a per-face cross-process KNN would be a network round trip inside the
21869
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21870
+ * it requires the index to hand the floats back. Without this method the only
21871
+ * way to keep a readable vector is a JSON column, which is the thing this
21872
+ * capability exists to delete.
21873
+ *
21874
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21875
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21876
+ */
21877
+ var VectorFetchInputSchema = object({
21878
+ index: string$2(),
21879
+ ids: array(string$2())
21880
+ });
21881
+ var VectorFetchResultSchema = object({ items: array(object({
21882
+ id: string$2(),
21883
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21884
+ vector: string$2(),
21885
+ metadata: VectorMetadataSchema
21886
+ })) });
21887
+ /**
21888
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21889
+ *
21890
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21891
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21892
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21893
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21894
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21895
+ * looked" for as long as anyone cared to read it.
21896
+ *
21897
+ * This is the primitive that question actually needs: a bounded page, ordered
21898
+ * by the backend's own row order, costing no distance computation at all.
21899
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21900
+ * the full-table read this capability was built to stop.
21901
+ */
21902
+ var VectorScanInputSchema = object({
21903
+ index: string$2(),
21904
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21905
+ cursor: number().int().nonnegative().default(0),
21906
+ limit: number().int().positive()
21907
+ });
21908
+ var VectorScanResultSchema = object({
21909
+ items: array(object({
21910
+ id: string$2(),
21911
+ metadata: VectorMetadataSchema
21912
+ })),
21913
+ /**
21914
+ * Where the next page starts, or `null` when the walk reached the end.
21915
+ *
21916
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21917
+ * from a short page: a backend is free to return fewer rows than asked.
21918
+ */
21919
+ nextCursor: number().int().nonnegative().nullable()
21920
+ });
21543
21921
  var VectorStatsInputSchema = object({ index: string$2() });
21544
21922
  var VectorStatsResultSchema = object({
21545
21923
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21558,7 +21936,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21558
21936
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21559
21937
  kind: "mutation",
21560
21938
  auth: "admin"
21561
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21939
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21562
21940
  kind: "mutation",
21563
21941
  auth: "admin"
21564
21942
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28194,6 +28572,9 @@ method(object({
28194
28572
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28195
28573
  kind: "query",
28196
28574
  auth: "admin"
28575
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28576
+ kind: "query",
28577
+ auth: "admin"
28197
28578
  }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
28198
28579
  kind: "mutation",
28199
28580
  auth: "admin"
@@ -34828,6 +35209,18 @@ Object.freeze({
34828
35209
  addonId: null,
34829
35210
  access: "create"
34830
35211
  },
35212
+ "pipelineAnalytics.countRelocatableMedia": {
35213
+ capName: "pipeline-analytics",
35214
+ capScope: "device",
35215
+ addonId: null,
35216
+ access: "view"
35217
+ },
35218
+ "pipelineAnalytics.countUnstampedEventMedia": {
35219
+ capName: "pipeline-analytics",
35220
+ capScope: "device",
35221
+ addonId: null,
35222
+ access: "view"
35223
+ },
34831
35224
  "pipelineAnalytics.deleteDeviceEvents": {
34832
35225
  capName: "pipeline-analytics",
34833
35226
  capScope: "device",
@@ -35986,6 +36379,12 @@ Object.freeze({
35986
36379
  addonId: null,
35987
36380
  access: "view"
35988
36381
  },
36382
+ "recording.getRelocateResidue": {
36383
+ capName: "recording",
36384
+ capScope: "system",
36385
+ addonId: null,
36386
+ access: "view"
36387
+ },
35989
36388
  "recording.getStorageMigrationMoveStatus": {
35990
36389
  capName: "recording",
35991
36390
  capScope: "system",
@@ -36532,12 +36931,30 @@ Object.freeze({
36532
36931
  addonId: null,
36533
36932
  access: "create"
36534
36933
  },
36934
+ "storageMigration.drain": {
36935
+ capName: "storage-migration",
36936
+ capScope: "system",
36937
+ addonId: null,
36938
+ access: "create"
36939
+ },
36940
+ "storageMigration.movers": {
36941
+ capName: "storage-migration",
36942
+ capScope: "system",
36943
+ addonId: null,
36944
+ access: "view"
36945
+ },
36535
36946
  "storageMigration.plan": {
36536
36947
  capName: "storage-migration",
36537
36948
  capScope: "system",
36538
36949
  addonId: null,
36539
36950
  access: "view"
36540
36951
  },
36952
+ "storageMigration.residue": {
36953
+ capName: "storage-migration",
36954
+ capScope: "system",
36955
+ addonId: null,
36956
+ access: "view"
36957
+ },
36541
36958
  "storageMigration.start": {
36542
36959
  capName: "storage-migration",
36543
36960
  capScope: "system",
@@ -37372,6 +37789,12 @@ Object.freeze({
37372
37789
  addonId: null,
37373
37790
  access: "delete"
37374
37791
  },
37792
+ "vectorStore.fetchByIds": {
37793
+ capName: "vector-store",
37794
+ capScope: "system",
37795
+ addonId: null,
37796
+ access: "view"
37797
+ },
37375
37798
  "vectorStore.getByIds": {
37376
37799
  capName: "vector-store",
37377
37800
  capScope: "system",
@@ -37384,6 +37807,12 @@ Object.freeze({
37384
37807
  addonId: null,
37385
37808
  access: "view"
37386
37809
  },
37810
+ "vectorStore.scan": {
37811
+ capName: "vector-store",
37812
+ capScope: "system",
37813
+ addonId: null,
37814
+ access: "view"
37815
+ },
37387
37816
  "vectorStore.stats": {
37388
37817
  capName: "vector-store",
37389
37818
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8051,18 +8051,61 @@ var RelocateFootageInputSchema = object({
8051
8051
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8052
8052
  var StorageMigrationLeaseInputSchema = object({ leaseId: string$2().min(1) });
8053
8053
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string$2().min(1) });
8054
+ /**
8055
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8056
+ * mover (the engine already walks both collections with a timestamp cursor and
8057
+ * already has a stamp-without-copy path).
8058
+ *
8059
+ * - `move` — the default and the historical behaviour: event-media and
8060
+ * retrain blobs move to `toLocationId` and their rows are
8061
+ * stamped. The enrolled gallery is skipped (D197).
8062
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8063
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8064
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8065
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8066
+ * instant a repoint moves that pointer the row reads from the
8067
+ * new disk while its bytes are on the old one.
8068
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8069
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8070
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8071
+ * never run beside a live second location: it is stop-the-world
8072
+ * by construction, which is acceptable only because the gallery
8073
+ * is a few KB per enrolled sample.
8074
+ */
8075
+ var MediaRelocateModeSchema = _enum([
8076
+ "move",
8077
+ "seal",
8078
+ "gallery"
8079
+ ]);
8054
8080
  var RelocateMediaInputSchema = object({
8055
8081
  toLocationId: string$2(),
8056
- throttleMbps: number().min(1).max(1e3).optional()
8082
+ throttleMbps: number().min(1).max(1e3).optional(),
8083
+ /** Omitted = `move`, the pre-existing behaviour. */
8084
+ mode: MediaRelocateModeSchema.optional()
8085
+ });
8086
+ /** How many rows still carry NO `locationId` — the population a repoint would
8087
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8088
+ * value that permits a non-blocking `eventMedia` cutover. */
8089
+ var UnstampedEventMediaCountSchema = object({
8090
+ media: number().int().nonnegative(),
8091
+ retrainFrames: number().int().nonnegative(),
8092
+ total: number().int().nonnegative()
8057
8093
  });
8058
8094
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string$2().min(1) });
8059
- /** The independently selectable logical storage classes. `recordings`
8060
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8061
- * segments; `eventMedia` is post-analysis blobs. */
8095
+ /** The independently selectable logical storage classes — every class
8096
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8097
+ * Zod enum error where they should meet an explanation.
8098
+ *
8099
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8100
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8101
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8102
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8062
8103
  var StorageMigrationClassSchema = _enum([
8063
8104
  "recordings",
8064
8105
  "recordingsLow",
8065
- "eventMedia"
8106
+ "eventMedia",
8107
+ "backups",
8108
+ "galleryMedia"
8066
8109
  ]);
8067
8110
  /** A destination is always an existing, fully-qualified location id. The
8068
8111
  * migration API intentionally never changes a source location's `basePath`:
@@ -8070,20 +8113,56 @@ var StorageMigrationClassSchema = _enum([
8070
8113
  var StorageMigrationDestinationsSchema = object({
8071
8114
  recordings: string$2().min(1).optional(),
8072
8115
  recordingsLow: string$2().min(1).optional(),
8073
- eventMedia: string$2().min(1).optional()
8116
+ eventMedia: string$2().min(1).optional(),
8117
+ backups: string$2().min(1).optional(),
8118
+ galleryMedia: string$2().min(1).optional()
8074
8119
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8120
+ /**
8121
+ * How a migration sequences the cutover against the byte move.
8122
+ *
8123
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8124
+ * resume. Recording is stopped for the whole move. Right
8125
+ * for a small or a cold class, and the only legal mode for
8126
+ * a `cardinality: 'single'` class.
8127
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8128
+ * refresh, resume, then move the past with everything
8129
+ * running. The pause is three bounded instants (a detach +
8130
+ * attach round, a write-gate drain, a lease) instead of one
8131
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8132
+ * stopped recording under `blocking`; the same move is
8133
+ * seconds of stopped recording under `nonBlocking`.
8134
+ *
8135
+ * The mode is on the JOB, not only on the input, because `status` is where an
8136
+ * operator finds out which one is running.
8137
+ */
8138
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8075
8139
  /** Shared input for planning and starting an orchestrated storage migration. */
8076
8140
  var StorageMigrationInputSchema = object({
8077
8141
  destinations: StorageMigrationDestinationsSchema,
8078
- throttleMbps: number().min(1).max(1e3).optional()
8142
+ throttleMbps: number().min(1).max(1e3).optional(),
8143
+ /** Omitted = `blocking`, which stays the default. */
8144
+ mode: StorageMigrationModeSchema.optional()
8079
8145
  });
8080
- /** The durable coordinator state machine. The only phase that changes default
8081
- * locations is `repointing`, after every selected mover has completed and been
8082
- * verified. */
8146
+ /**
8147
+ * The durable coordinator state machine.
8148
+ *
8149
+ * `blocking`:
8150
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8151
+ *
8152
+ * `nonBlocking`:
8153
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8154
+ *
8155
+ * Same phases, different order plus two new ones — not a second mover.
8156
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8157
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8158
+ * `repointing` is still the only phase that changes a default location.
8159
+ */
8083
8160
  var StorageMigrationPhaseSchema = _enum([
8084
8161
  "planning",
8162
+ "sealing",
8085
8163
  "pausing",
8086
8164
  "moving",
8165
+ "draining",
8087
8166
  "verifying",
8088
8167
  "repointing",
8089
8168
  "refreshing",
@@ -8097,17 +8176,56 @@ var StorageMigrationParticipantSchema = _enum([
8097
8176
  "recorder",
8098
8177
  "analytics"
8099
8178
  ]);
8179
+ /**
8180
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8181
+ *
8182
+ * The long half of a non-blocking migration is `draining`, and it is measured
8183
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8184
+ * existed the only place those numbers appeared was a Loki line, so an operator
8185
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8186
+ * afternoon.
8187
+ *
8188
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8189
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8190
+ * mover — which is the exact failure this is meant to end. The coordinator's
8191
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8192
+ * read `state`; folding the counters costs no extra read and makes the durable
8193
+ * record say afterwards how far a move actually got.
8194
+ *
8195
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8196
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8197
+ * cannot say M, and a 0 there would render as "100 % done".
8198
+ */
8199
+ var StorageMigrationMoveProgressSchema = object({
8200
+ filesMoved: number().int().nonnegative(),
8201
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8202
+ filesTotal: number().int().nonnegative().nullable(),
8203
+ bytesMoved: number().int().nonnegative(),
8204
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8205
+ * crash gets a new mover, and a rate computed from the migration's start
8206
+ * would silently average in the time nothing was running. */
8207
+ startedAt: number(),
8208
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8209
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8210
+ * subtract its own. */
8211
+ observedAt: number()
8212
+ });
8100
8213
  var StorageMigrationMoveSchema = object({
8101
8214
  storageClass: StorageMigrationClassSchema,
8102
8215
  fromLocationId: string$2(),
8103
8216
  toLocationId: string$2(),
8104
8217
  moverJobId: string$2().nullable(),
8105
8218
  state: RelocateJobStateSchema.nullable(),
8106
- error: string$2().nullable()
8219
+ error: string$2().nullable(),
8220
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8221
+ progress: StorageMigrationMoveProgressSchema.nullable()
8107
8222
  });
8108
8223
  var StorageMigrationJobSchema = object({
8109
8224
  jobId: string$2(),
8110
8225
  phase: StorageMigrationPhaseSchema,
8226
+ /** Which order this job is running. `status` is the only place an operator
8227
+ * can tell a seconds-long cutover from a thirty-hour one. */
8228
+ mode: StorageMigrationModeSchema,
8111
8229
  destinations: StorageMigrationDestinationsSchema,
8112
8230
  throttleMbps: number(),
8113
8231
  moves: array(StorageMigrationMoveSchema),
@@ -8120,13 +8238,122 @@ var StorageMigrationJobSchema = object({
8120
8238
  finishedAt: number().nullable(),
8121
8239
  error: string$2().nullable()
8122
8240
  });
8241
+ var StorageMigrationFindingSchema = object({
8242
+ code: _enum([
8243
+ "sharesDeviceWithSource",
8244
+ "deviceIdentityUnknown",
8245
+ "unstampedEventMediaRows",
8246
+ "blockingOnly",
8247
+ "noMover"
8248
+ ]),
8249
+ storageClass: StorageMigrationClassSchema,
8250
+ /** Human-readable, already carrying the ids and counts. */
8251
+ message: string$2()
8252
+ });
8123
8253
  var StorageMigrationPlanSchema = object({
8124
8254
  destinations: StorageMigrationDestinationsSchema,
8255
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8256
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8257
+ * it. */
8258
+ mode: StorageMigrationModeSchema,
8125
8259
  moves: array(object({
8126
8260
  storageClass: StorageMigrationClassSchema,
8127
8261
  fromLocationId: string$2(),
8128
8262
  toLocationId: string$2()
8129
- }))
8263
+ })),
8264
+ findings: array(StorageMigrationFindingSchema)
8265
+ });
8266
+ /**
8267
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8268
+ *
8269
+ * The coordinator's job record is the state of record for a migration, and its
8270
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8271
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8272
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8273
+ * way because no supported UI path existed. A mover armed like that has no job
8274
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8275
+ *
8276
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8277
+ * orchestrated it.
8278
+ */
8279
+ var StorageMigrationMoverSchema = object({
8280
+ lane: _enum(["footage", "media"]),
8281
+ job: RelocateJobSchema,
8282
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8283
+ * directly against the owning addon. */
8284
+ migrationJobId: string$2().nullable(),
8285
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8286
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8287
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8288
+ * rate made of two different clocks. */
8289
+ observedAt: number()
8290
+ });
8291
+ /**
8292
+ * What a SOURCE still holds for one storage class — the number that makes a
8293
+ * "drain remaining" action honest rather than hopeful.
8294
+ *
8295
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8296
+ * engine's own selection count for media), never from the resident index: a
8297
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8298
+ * never been told about (D295).
8299
+ *
8300
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8301
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8302
+ * because refusing on an unanswerable read would hide exactly the case an
8303
+ * operator needs to act on.
8304
+ */
8305
+ var StorageMigrationResidueSchema = object({
8306
+ storageClass: StorageMigrationClassSchema,
8307
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8308
+ * move from wherever they are rather than from one named source. */
8309
+ fromLocationId: string$2(),
8310
+ /** Where a drain would move it — the class's CURRENT default. */
8311
+ toLocationId: string$2(),
8312
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8313
+ items: number().int().nonnegative().nullable(),
8314
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8315
+ bytes: number().int().nonnegative().nullable()
8316
+ });
8317
+ /**
8318
+ * Run the DRAIN half and nothing else.
8319
+ *
8320
+ * A migration that reached `done` has already repointed, so `start` correctly
8321
+ * refuses its destination ("already the default") — there is nothing left to
8322
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8323
+ * or finish against a work list that was a tenth of the archive (D295), and
8324
+ * before this there was no supported way to run only that half: the only way
8325
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8326
+ *
8327
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8328
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8329
+ * re-repoint a class that is already migrated.
8330
+ */
8331
+ var StorageMigrationDrainInputSchema = object({
8332
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8333
+ * a class whose source is already empty is refused rather than started. */
8334
+ classes: array(StorageMigrationClassSchema).min(1),
8335
+ throttleMbps: number().min(1).max(1e3).optional()
8336
+ });
8337
+ /** What a footage source still holds, asked of the durable hour ledger. */
8338
+ var RelocateResidueInputSchema = object({
8339
+ fromLocationId: string$2().min(1),
8340
+ /** Narrow to one logical class; omit for every profile on the location. */
8341
+ footageClass: RelocateFootageClassSchema.optional()
8342
+ });
8343
+ /** `null` = the archive could not answer (no ledger on this node, or the
8344
+ * aggregate failed). Never conflated with an empty source. */
8345
+ var RelocateResidueSchema = object({
8346
+ segments: number().int().nonnegative(),
8347
+ bytes: number().int().nonnegative()
8348
+ }).nullable();
8349
+ /** How many rows a media pass would still act on against a given target — the
8350
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8351
+ * never disagree. `null` = the count could not be taken. */
8352
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8353
+ var RelocatableMediaCountInputSchema = object({
8354
+ toLocationId: string$2().min(1),
8355
+ /** Omitted = `move`. */
8356
+ mode: MediaRelocateModeSchema.optional()
8130
8357
  });
8131
8358
  /**
8132
8359
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8232,6 +8459,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string$2().rege
8232
8459
  * two addons declaring the same `id` must agree on `cardinality` (validated
8233
8460
  * at kernel aggregation time, not here).
8234
8461
  */
8462
+ /**
8463
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8464
+ * actually reaches the bytes. It is the constraint that decides which
8465
+ * `storage-provider`s may back a location of that kind.
8466
+ *
8467
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8468
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8469
+ * post-analysis media roots). Only a provider that serves a genuine local
8470
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8471
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8472
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8473
+ * against a same-named local directory that is something else entirely.
8474
+ *
8475
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8476
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8477
+ * service never sees a path, so any provider can back it. `backups` is the
8478
+ * one kind that qualifies today.
8479
+ *
8480
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8481
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8482
+ * refused the configuration; the first write simply went somewhere wrong, and
8483
+ * a recording write that goes wrong surfaces as a silent black window rather
8484
+ * than an error (the read path does not `stat`). This turns that accident into
8485
+ * a declared, enforced, testable refusal.
8486
+ */
8487
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8235
8488
  var StorageLocationDeclarationSchema = object({
8236
8489
  /**
8237
8490
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8251,6 +8504,19 @@ var StorageLocationDeclarationSchema = object({
8251
8504
  */
8252
8505
  cardinality: _enum(["single", "multi"]),
8253
8506
  /**
8507
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8508
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8509
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8510
+ *
8511
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8512
+ * can only over-restrict (refuse a remote provider for a kind that might
8513
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8514
+ * permissive direction and is therefore never inferred — a repo guard
8515
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8516
+ * reached by omission.
8517
+ */
8518
+ access: StorageAccessSchema.optional(),
8519
+ /**
8254
8520
  * When set, the default instance for this location inherits its resolved
8255
8521
  * root from the named location's default instance. Useful for derivative
8256
8522
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18184,8 +18450,10 @@ var TrackSchema = object({
18184
18450
  lastSeen: number(),
18185
18451
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18186
18452
  positions: array(TrackPositionSchema).readonly(),
18187
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18188
- * saveThumbnails policy). */
18453
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18454
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18455
+ * the retired `saveThumbnails` used to gate this and the rolling
18456
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18189
18457
  snapshots: array(TrackSnapshotSchema).readonly(),
18190
18458
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18191
18459
  zonesVisited: array(string$2()).readonly(),
@@ -19045,6 +19313,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19045
19313
  }), method(RelocateMediaInputSchema, object({ jobId: string$2() }), {
19046
19314
  kind: "mutation",
19047
19315
  auth: "admin"
19316
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19317
+ kind: "query",
19318
+ auth: "admin"
19048
19319
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19049
19320
  kind: "query",
19050
19321
  auth: "admin"
@@ -20952,7 +21223,10 @@ method(object({
20952
21223
  }), StorageLocationSchema, {
20953
21224
  kind: "mutation",
20954
21225
  auth: "admin"
20955
- }), method(object({ id: string$2() }), _void(), {
21226
+ }), method(object({
21227
+ id: string$2(),
21228
+ force: boolean().optional()
21229
+ }), _void(), {
20956
21230
  kind: "mutation",
20957
21231
  auth: "admin"
20958
21232
  }), method(object({ id: string$2() }), object({
@@ -21001,6 +21275,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21001
21275
  }), method(object({ jobId: string$2().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
21002
21276
  kind: "mutation",
21003
21277
  auth: "admin"
21278
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string$2() }), {
21279
+ kind: "mutation",
21280
+ auth: "admin"
21004
21281
  });
21005
21282
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21006
21283
  providerId: string$2().min(1),
@@ -21399,12 +21676,38 @@ response: record(string$2(), unknown()) }), object({
21399
21676
  *
21400
21677
  * ## Why this is a capability and not a helper
21401
21678
  *
21402
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21403
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21404
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21405
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21406
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21407
- * load 5,000 rows before ranking anything.
21679
+ * This capability was introduced with the claim that SIX stores in
21680
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21681
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21682
+ * claim was never true, and leaving it here made five stores look like pending
21683
+ * work when three of them have no vector at all. Counted column by column on
21684
+ * 2026-08-30, exactly THREE ever held one:
21685
+ *
21686
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21687
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21688
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21689
+ * face, migrated 2026-08-30 into its OWN index (see below).
21690
+ *
21691
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21692
+ * and `identities` store a name; the event store stores no derivative vector.
21693
+ * They are not migration candidates and never were.
21694
+ *
21695
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21696
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21697
+ * rows before ranking anything.
21698
+ *
21699
+ * ## One index per COMPARISON, never per encoder
21700
+ *
21701
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21702
+ * model, and they still get two indexes. An index is a set of things that are
21703
+ * ranked against each other and that live and die together, and these two are
21704
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21705
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21706
+ * forever and is the gallery every recognition ranks against. One index would
21707
+ * mean every gallery load and every reconcile carried a filter whose failure
21708
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21709
+ * person's only sample. The dimension they share is not a reason to share an
21710
+ * index; the question they answer is, and it differs.
21408
21711
  *
21409
21712
  * The fix is not a faster loop, it is a different backend — and the backend
21410
21713
  * should be replaceable without touching six callers. So: a singleton
@@ -21509,7 +21812,20 @@ var VectorQueryResultSchema = object({
21509
21812
  */
21510
21813
  scanned: number(),
21511
21814
  /** True when the backend could not consider every row that passed the filter. */
21512
- truncated: boolean()
21815
+ truncated: boolean(),
21816
+ /**
21817
+ * The `topK` the backend actually ran with.
21818
+ *
21819
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21820
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21821
+ * own log rather than in its answer. That is how an audit asking for 20,000
21822
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21823
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21824
+ * MUCH, in the return value, where the caller cannot fail to see it.
21825
+ *
21826
+ * Equals the requested `topK` whenever nothing was lowered.
21827
+ */
21828
+ effectiveTopK: number().int().positive()
21513
21829
  });
21514
21830
  var VectorDeleteInputSchema = object({
21515
21831
  index: string$2(),
@@ -21538,6 +21854,68 @@ var VectorGetResultSchema = object({ items: array(object({
21538
21854
  id: string$2(),
21539
21855
  metadata: VectorMetadataSchema
21540
21856
  })) });
21857
+ /**
21858
+ * Ids to read back WITH their vectors.
21859
+ *
21860
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21861
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21862
+ * caller depends on that promise. This one promises the opposite.
21863
+ *
21864
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21865
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21866
+ * a per-face cross-process KNN would be a network round trip inside the
21867
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21868
+ * it requires the index to hand the floats back. Without this method the only
21869
+ * way to keep a readable vector is a JSON column, which is the thing this
21870
+ * capability exists to delete.
21871
+ *
21872
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21873
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21874
+ */
21875
+ var VectorFetchInputSchema = object({
21876
+ index: string$2(),
21877
+ ids: array(string$2())
21878
+ });
21879
+ var VectorFetchResultSchema = object({ items: array(object({
21880
+ id: string$2(),
21881
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21882
+ vector: string$2(),
21883
+ metadata: VectorMetadataSchema
21884
+ })) });
21885
+ /**
21886
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21887
+ *
21888
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21889
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21890
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21891
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21892
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21893
+ * looked" for as long as anyone cared to read it.
21894
+ *
21895
+ * This is the primitive that question actually needs: a bounded page, ordered
21896
+ * by the backend's own row order, costing no distance computation at all.
21897
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21898
+ * the full-table read this capability was built to stop.
21899
+ */
21900
+ var VectorScanInputSchema = object({
21901
+ index: string$2(),
21902
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21903
+ cursor: number().int().nonnegative().default(0),
21904
+ limit: number().int().positive()
21905
+ });
21906
+ var VectorScanResultSchema = object({
21907
+ items: array(object({
21908
+ id: string$2(),
21909
+ metadata: VectorMetadataSchema
21910
+ })),
21911
+ /**
21912
+ * Where the next page starts, or `null` when the walk reached the end.
21913
+ *
21914
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21915
+ * from a short page: a backend is free to return fewer rows than asked.
21916
+ */
21917
+ nextCursor: number().int().nonnegative().nullable()
21918
+ });
21541
21919
  var VectorStatsInputSchema = object({ index: string$2() });
21542
21920
  var VectorStatsResultSchema = object({
21543
21921
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21556,7 +21934,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21556
21934
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21557
21935
  kind: "mutation",
21558
21936
  auth: "admin"
21559
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21937
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21560
21938
  kind: "mutation",
21561
21939
  auth: "admin"
21562
21940
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28192,6 +28570,9 @@ method(object({
28192
28570
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28193
28571
  kind: "query",
28194
28572
  auth: "admin"
28573
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28574
+ kind: "query",
28575
+ auth: "admin"
28195
28576
  }), method(object({ jobId: string$2() }), object({ cancelled: boolean() }), {
28196
28577
  kind: "mutation",
28197
28578
  auth: "admin"
@@ -34826,6 +35207,18 @@ Object.freeze({
34826
35207
  addonId: null,
34827
35208
  access: "create"
34828
35209
  },
35210
+ "pipelineAnalytics.countRelocatableMedia": {
35211
+ capName: "pipeline-analytics",
35212
+ capScope: "device",
35213
+ addonId: null,
35214
+ access: "view"
35215
+ },
35216
+ "pipelineAnalytics.countUnstampedEventMedia": {
35217
+ capName: "pipeline-analytics",
35218
+ capScope: "device",
35219
+ addonId: null,
35220
+ access: "view"
35221
+ },
34829
35222
  "pipelineAnalytics.deleteDeviceEvents": {
34830
35223
  capName: "pipeline-analytics",
34831
35224
  capScope: "device",
@@ -35984,6 +36377,12 @@ Object.freeze({
35984
36377
  addonId: null,
35985
36378
  access: "view"
35986
36379
  },
36380
+ "recording.getRelocateResidue": {
36381
+ capName: "recording",
36382
+ capScope: "system",
36383
+ addonId: null,
36384
+ access: "view"
36385
+ },
35987
36386
  "recording.getStorageMigrationMoveStatus": {
35988
36387
  capName: "recording",
35989
36388
  capScope: "system",
@@ -36530,12 +36929,30 @@ Object.freeze({
36530
36929
  addonId: null,
36531
36930
  access: "create"
36532
36931
  },
36932
+ "storageMigration.drain": {
36933
+ capName: "storage-migration",
36934
+ capScope: "system",
36935
+ addonId: null,
36936
+ access: "create"
36937
+ },
36938
+ "storageMigration.movers": {
36939
+ capName: "storage-migration",
36940
+ capScope: "system",
36941
+ addonId: null,
36942
+ access: "view"
36943
+ },
36533
36944
  "storageMigration.plan": {
36534
36945
  capName: "storage-migration",
36535
36946
  capScope: "system",
36536
36947
  addonId: null,
36537
36948
  access: "view"
36538
36949
  },
36950
+ "storageMigration.residue": {
36951
+ capName: "storage-migration",
36952
+ capScope: "system",
36953
+ addonId: null,
36954
+ access: "view"
36955
+ },
36539
36956
  "storageMigration.start": {
36540
36957
  capName: "storage-migration",
36541
36958
  capScope: "system",
@@ -37370,6 +37787,12 @@ Object.freeze({
37370
37787
  addonId: null,
37371
37788
  access: "delete"
37372
37789
  },
37790
+ "vectorStore.fetchByIds": {
37791
+ capName: "vector-store",
37792
+ capScope: "system",
37793
+ addonId: null,
37794
+ access: "view"
37795
+ },
37373
37796
  "vectorStore.getByIds": {
37374
37797
  capName: "vector-store",
37375
37798
  capScope: "system",
@@ -37382,6 +37805,12 @@ Object.freeze({
37382
37805
  addonId: null,
37383
37806
  access: "view"
37384
37807
  },
37808
+ "vectorStore.scan": {
37809
+ capName: "vector-store",
37810
+ capScope: "system",
37811
+ addonId: null,
37812
+ access: "view"
37813
+ },
37385
37814
  "vectorStore.stats": {
37386
37815
  capName: "vector-store",
37387
37816
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-matter-broker",
3
- "version": "0.2.41",
3
+ "version": "0.2.44",
4
4
  "description": "Matter broker addon for CamStack — owns a Matter fabric (commissioning + the long-lived controller) via the matter.js controller and brokers commissioned Matter nodes into CamStack",
5
5
  "keywords": [
6
6
  "camstack",