@camstack/addon-provider-gree 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
@@ -8042,18 +8042,61 @@ var RelocateFootageInputSchema = object({
8042
8042
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8043
8043
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8044
8044
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8045
+ /**
8046
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8047
+ * mover (the engine already walks both collections with a timestamp cursor and
8048
+ * already has a stamp-without-copy path).
8049
+ *
8050
+ * - `move` — the default and the historical behaviour: event-media and
8051
+ * retrain blobs move to `toLocationId` and their rows are
8052
+ * stamped. The enrolled gallery is skipped (D197).
8053
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8054
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8055
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8056
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8057
+ * instant a repoint moves that pointer the row reads from the
8058
+ * new disk while its bytes are on the old one.
8059
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8060
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8061
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8062
+ * never run beside a live second location: it is stop-the-world
8063
+ * by construction, which is acceptable only because the gallery
8064
+ * is a few KB per enrolled sample.
8065
+ */
8066
+ var MediaRelocateModeSchema = _enum([
8067
+ "move",
8068
+ "seal",
8069
+ "gallery"
8070
+ ]);
8045
8071
  var RelocateMediaInputSchema = object({
8046
8072
  toLocationId: string(),
8047
- throttleMbps: number().min(1).max(1e3).optional()
8073
+ throttleMbps: number().min(1).max(1e3).optional(),
8074
+ /** Omitted = `move`, the pre-existing behaviour. */
8075
+ mode: MediaRelocateModeSchema.optional()
8076
+ });
8077
+ /** How many rows still carry NO `locationId` — the population a repoint would
8078
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8079
+ * value that permits a non-blocking `eventMedia` cutover. */
8080
+ var UnstampedEventMediaCountSchema = object({
8081
+ media: number().int().nonnegative(),
8082
+ retrainFrames: number().int().nonnegative(),
8083
+ total: number().int().nonnegative()
8048
8084
  });
8049
8085
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8050
- /** The independently selectable logical storage classes. `recordings`
8051
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8052
- * segments; `eventMedia` is post-analysis blobs. */
8086
+ /** The independently selectable logical storage classes — every class
8087
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8088
+ * Zod enum error where they should meet an explanation.
8089
+ *
8090
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8091
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8092
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8093
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8053
8094
  var StorageMigrationClassSchema = _enum([
8054
8095
  "recordings",
8055
8096
  "recordingsLow",
8056
- "eventMedia"
8097
+ "eventMedia",
8098
+ "backups",
8099
+ "galleryMedia"
8057
8100
  ]);
8058
8101
  /** A destination is always an existing, fully-qualified location id. The
8059
8102
  * migration API intentionally never changes a source location's `basePath`:
@@ -8061,20 +8104,56 @@ var StorageMigrationClassSchema = _enum([
8061
8104
  var StorageMigrationDestinationsSchema = object({
8062
8105
  recordings: string().min(1).optional(),
8063
8106
  recordingsLow: string().min(1).optional(),
8064
- eventMedia: string().min(1).optional()
8107
+ eventMedia: string().min(1).optional(),
8108
+ backups: string().min(1).optional(),
8109
+ galleryMedia: string().min(1).optional()
8065
8110
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8111
+ /**
8112
+ * How a migration sequences the cutover against the byte move.
8113
+ *
8114
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8115
+ * resume. Recording is stopped for the whole move. Right
8116
+ * for a small or a cold class, and the only legal mode for
8117
+ * a `cardinality: 'single'` class.
8118
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8119
+ * refresh, resume, then move the past with everything
8120
+ * running. The pause is three bounded instants (a detach +
8121
+ * attach round, a write-gate drain, a lease) instead of one
8122
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8123
+ * stopped recording under `blocking`; the same move is
8124
+ * seconds of stopped recording under `nonBlocking`.
8125
+ *
8126
+ * The mode is on the JOB, not only on the input, because `status` is where an
8127
+ * operator finds out which one is running.
8128
+ */
8129
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8066
8130
  /** Shared input for planning and starting an orchestrated storage migration. */
8067
8131
  var StorageMigrationInputSchema = object({
8068
8132
  destinations: StorageMigrationDestinationsSchema,
8069
- throttleMbps: number().min(1).max(1e3).optional()
8133
+ throttleMbps: number().min(1).max(1e3).optional(),
8134
+ /** Omitted = `blocking`, which stays the default. */
8135
+ mode: StorageMigrationModeSchema.optional()
8070
8136
  });
8071
- /** The durable coordinator state machine. The only phase that changes default
8072
- * locations is `repointing`, after every selected mover has completed and been
8073
- * verified. */
8137
+ /**
8138
+ * The durable coordinator state machine.
8139
+ *
8140
+ * `blocking`:
8141
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8142
+ *
8143
+ * `nonBlocking`:
8144
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8145
+ *
8146
+ * Same phases, different order plus two new ones — not a second mover.
8147
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8148
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8149
+ * `repointing` is still the only phase that changes a default location.
8150
+ */
8074
8151
  var StorageMigrationPhaseSchema = _enum([
8075
8152
  "planning",
8153
+ "sealing",
8076
8154
  "pausing",
8077
8155
  "moving",
8156
+ "draining",
8078
8157
  "verifying",
8079
8158
  "repointing",
8080
8159
  "refreshing",
@@ -8088,17 +8167,56 @@ var StorageMigrationParticipantSchema = _enum([
8088
8167
  "recorder",
8089
8168
  "analytics"
8090
8169
  ]);
8170
+ /**
8171
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8172
+ *
8173
+ * The long half of a non-blocking migration is `draining`, and it is measured
8174
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8175
+ * existed the only place those numbers appeared was a Loki line, so an operator
8176
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8177
+ * afternoon.
8178
+ *
8179
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8180
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8181
+ * mover — which is the exact failure this is meant to end. The coordinator's
8182
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8183
+ * read `state`; folding the counters costs no extra read and makes the durable
8184
+ * record say afterwards how far a move actually got.
8185
+ *
8186
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8187
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8188
+ * cannot say M, and a 0 there would render as "100 % done".
8189
+ */
8190
+ var StorageMigrationMoveProgressSchema = object({
8191
+ filesMoved: number().int().nonnegative(),
8192
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8193
+ filesTotal: number().int().nonnegative().nullable(),
8194
+ bytesMoved: number().int().nonnegative(),
8195
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8196
+ * crash gets a new mover, and a rate computed from the migration's start
8197
+ * would silently average in the time nothing was running. */
8198
+ startedAt: number(),
8199
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8200
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8201
+ * subtract its own. */
8202
+ observedAt: number()
8203
+ });
8091
8204
  var StorageMigrationMoveSchema = object({
8092
8205
  storageClass: StorageMigrationClassSchema,
8093
8206
  fromLocationId: string(),
8094
8207
  toLocationId: string(),
8095
8208
  moverJobId: string().nullable(),
8096
8209
  state: RelocateJobStateSchema.nullable(),
8097
- error: string().nullable()
8210
+ error: string().nullable(),
8211
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8212
+ progress: StorageMigrationMoveProgressSchema.nullable()
8098
8213
  });
8099
8214
  var StorageMigrationJobSchema = object({
8100
8215
  jobId: string(),
8101
8216
  phase: StorageMigrationPhaseSchema,
8217
+ /** Which order this job is running. `status` is the only place an operator
8218
+ * can tell a seconds-long cutover from a thirty-hour one. */
8219
+ mode: StorageMigrationModeSchema,
8102
8220
  destinations: StorageMigrationDestinationsSchema,
8103
8221
  throttleMbps: number(),
8104
8222
  moves: array(StorageMigrationMoveSchema),
@@ -8111,13 +8229,122 @@ var StorageMigrationJobSchema = object({
8111
8229
  finishedAt: number().nullable(),
8112
8230
  error: string().nullable()
8113
8231
  });
8232
+ var StorageMigrationFindingSchema = object({
8233
+ code: _enum([
8234
+ "sharesDeviceWithSource",
8235
+ "deviceIdentityUnknown",
8236
+ "unstampedEventMediaRows",
8237
+ "blockingOnly",
8238
+ "noMover"
8239
+ ]),
8240
+ storageClass: StorageMigrationClassSchema,
8241
+ /** Human-readable, already carrying the ids and counts. */
8242
+ message: string()
8243
+ });
8114
8244
  var StorageMigrationPlanSchema = object({
8115
8245
  destinations: StorageMigrationDestinationsSchema,
8246
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8247
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8248
+ * it. */
8249
+ mode: StorageMigrationModeSchema,
8116
8250
  moves: array(object({
8117
8251
  storageClass: StorageMigrationClassSchema,
8118
8252
  fromLocationId: string(),
8119
8253
  toLocationId: string()
8120
- }))
8254
+ })),
8255
+ findings: array(StorageMigrationFindingSchema)
8256
+ });
8257
+ /**
8258
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8259
+ *
8260
+ * The coordinator's job record is the state of record for a migration, and its
8261
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8262
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8263
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8264
+ * way because no supported UI path existed. A mover armed like that has no job
8265
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8266
+ *
8267
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8268
+ * orchestrated it.
8269
+ */
8270
+ var StorageMigrationMoverSchema = object({
8271
+ lane: _enum(["footage", "media"]),
8272
+ job: RelocateJobSchema,
8273
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8274
+ * directly against the owning addon. */
8275
+ migrationJobId: string().nullable(),
8276
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8277
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8278
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8279
+ * rate made of two different clocks. */
8280
+ observedAt: number()
8281
+ });
8282
+ /**
8283
+ * What a SOURCE still holds for one storage class — the number that makes a
8284
+ * "drain remaining" action honest rather than hopeful.
8285
+ *
8286
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8287
+ * engine's own selection count for media), never from the resident index: a
8288
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8289
+ * never been told about (D295).
8290
+ *
8291
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8292
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8293
+ * because refusing on an unanswerable read would hide exactly the case an
8294
+ * operator needs to act on.
8295
+ */
8296
+ var StorageMigrationResidueSchema = object({
8297
+ storageClass: StorageMigrationClassSchema,
8298
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8299
+ * move from wherever they are rather than from one named source. */
8300
+ fromLocationId: string(),
8301
+ /** Where a drain would move it — the class's CURRENT default. */
8302
+ toLocationId: string(),
8303
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8304
+ items: number().int().nonnegative().nullable(),
8305
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8306
+ bytes: number().int().nonnegative().nullable()
8307
+ });
8308
+ /**
8309
+ * Run the DRAIN half and nothing else.
8310
+ *
8311
+ * A migration that reached `done` has already repointed, so `start` correctly
8312
+ * refuses its destination ("already the default") — there is nothing left to
8313
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8314
+ * or finish against a work list that was a tenth of the archive (D295), and
8315
+ * before this there was no supported way to run only that half: the only way
8316
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8317
+ *
8318
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8319
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8320
+ * re-repoint a class that is already migrated.
8321
+ */
8322
+ var StorageMigrationDrainInputSchema = object({
8323
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8324
+ * a class whose source is already empty is refused rather than started. */
8325
+ classes: array(StorageMigrationClassSchema).min(1),
8326
+ throttleMbps: number().min(1).max(1e3).optional()
8327
+ });
8328
+ /** What a footage source still holds, asked of the durable hour ledger. */
8329
+ var RelocateResidueInputSchema = object({
8330
+ fromLocationId: string().min(1),
8331
+ /** Narrow to one logical class; omit for every profile on the location. */
8332
+ footageClass: RelocateFootageClassSchema.optional()
8333
+ });
8334
+ /** `null` = the archive could not answer (no ledger on this node, or the
8335
+ * aggregate failed). Never conflated with an empty source. */
8336
+ var RelocateResidueSchema = object({
8337
+ segments: number().int().nonnegative(),
8338
+ bytes: number().int().nonnegative()
8339
+ }).nullable();
8340
+ /** How many rows a media pass would still act on against a given target — the
8341
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8342
+ * never disagree. `null` = the count could not be taken. */
8343
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8344
+ var RelocatableMediaCountInputSchema = object({
8345
+ toLocationId: string().min(1),
8346
+ /** Omitted = `move`. */
8347
+ mode: MediaRelocateModeSchema.optional()
8121
8348
  });
8122
8349
  /**
8123
8350
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8223,6 +8450,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8223
8450
  * two addons declaring the same `id` must agree on `cardinality` (validated
8224
8451
  * at kernel aggregation time, not here).
8225
8452
  */
8453
+ /**
8454
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8455
+ * actually reaches the bytes. It is the constraint that decides which
8456
+ * `storage-provider`s may back a location of that kind.
8457
+ *
8458
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8459
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8460
+ * post-analysis media roots). Only a provider that serves a genuine local
8461
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8462
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8463
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8464
+ * against a same-named local directory that is something else entirely.
8465
+ *
8466
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8467
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8468
+ * service never sees a path, so any provider can back it. `backups` is the
8469
+ * one kind that qualifies today.
8470
+ *
8471
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8472
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8473
+ * refused the configuration; the first write simply went somewhere wrong, and
8474
+ * a recording write that goes wrong surfaces as a silent black window rather
8475
+ * than an error (the read path does not `stat`). This turns that accident into
8476
+ * a declared, enforced, testable refusal.
8477
+ */
8478
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8226
8479
  var StorageLocationDeclarationSchema = object({
8227
8480
  /**
8228
8481
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8242,6 +8495,19 @@ var StorageLocationDeclarationSchema = object({
8242
8495
  */
8243
8496
  cardinality: _enum(["single", "multi"]),
8244
8497
  /**
8498
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8499
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8500
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8501
+ *
8502
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8503
+ * can only over-restrict (refuse a remote provider for a kind that might
8504
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8505
+ * permissive direction and is therefore never inferred — a repo guard
8506
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8507
+ * reached by omission.
8508
+ */
8509
+ access: StorageAccessSchema.optional(),
8510
+ /**
8245
8511
  * When set, the default instance for this location inherits its resolved
8246
8512
  * root from the named location's default instance. Useful for derivative
8247
8513
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18109,8 +18375,10 @@ var TrackSchema = object({
18109
18375
  lastSeen: number(),
18110
18376
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18111
18377
  positions: array(TrackPositionSchema).readonly(),
18112
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18113
- * saveThumbnails policy). */
18378
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18379
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18380
+ * the retired `saveThumbnails` used to gate this and the rolling
18381
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18114
18382
  snapshots: array(TrackSnapshotSchema).readonly(),
18115
18383
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18116
18384
  zonesVisited: array(string()).readonly(),
@@ -18970,6 +19238,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18970
19238
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18971
19239
  kind: "mutation",
18972
19240
  auth: "admin"
19241
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19242
+ kind: "query",
19243
+ auth: "admin"
18973
19244
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18974
19245
  kind: "query",
18975
19246
  auth: "admin"
@@ -20877,7 +21148,10 @@ method(object({
20877
21148
  }), StorageLocationSchema, {
20878
21149
  kind: "mutation",
20879
21150
  auth: "admin"
20880
- }), method(object({ id: string() }), _void(), {
21151
+ }), method(object({
21152
+ id: string(),
21153
+ force: boolean().optional()
21154
+ }), _void(), {
20881
21155
  kind: "mutation",
20882
21156
  auth: "admin"
20883
21157
  }), method(object({ id: string() }), object({
@@ -20926,6 +21200,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20926
21200
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20927
21201
  kind: "mutation",
20928
21202
  auth: "admin"
21203
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21204
+ kind: "mutation",
21205
+ auth: "admin"
20929
21206
  });
20930
21207
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20931
21208
  providerId: string().min(1),
@@ -21324,12 +21601,38 @@ response: record(string(), unknown()) }), object({
21324
21601
  *
21325
21602
  * ## Why this is a capability and not a helper
21326
21603
  *
21327
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21328
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21329
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21330
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21331
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21332
- * load 5,000 rows before ranking anything.
21604
+ * This capability was introduced with the claim that SIX stores in
21605
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21606
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21607
+ * claim was never true, and leaving it here made five stores look like pending
21608
+ * work when three of them have no vector at all. Counted column by column on
21609
+ * 2026-08-30, exactly THREE ever held one:
21610
+ *
21611
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21612
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21613
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21614
+ * face, migrated 2026-08-30 into its OWN index (see below).
21615
+ *
21616
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21617
+ * and `identities` store a name; the event store stores no derivative vector.
21618
+ * They are not migration candidates and never were.
21619
+ *
21620
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21621
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21622
+ * rows before ranking anything.
21623
+ *
21624
+ * ## One index per COMPARISON, never per encoder
21625
+ *
21626
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21627
+ * model, and they still get two indexes. An index is a set of things that are
21628
+ * ranked against each other and that live and die together, and these two are
21629
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21630
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21631
+ * forever and is the gallery every recognition ranks against. One index would
21632
+ * mean every gallery load and every reconcile carried a filter whose failure
21633
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21634
+ * person's only sample. The dimension they share is not a reason to share an
21635
+ * index; the question they answer is, and it differs.
21333
21636
  *
21334
21637
  * The fix is not a faster loop, it is a different backend — and the backend
21335
21638
  * should be replaceable without touching six callers. So: a singleton
@@ -21434,7 +21737,20 @@ var VectorQueryResultSchema = object({
21434
21737
  */
21435
21738
  scanned: number(),
21436
21739
  /** True when the backend could not consider every row that passed the filter. */
21437
- truncated: boolean()
21740
+ truncated: boolean(),
21741
+ /**
21742
+ * The `topK` the backend actually ran with.
21743
+ *
21744
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21745
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21746
+ * own log rather than in its answer. That is how an audit asking for 20,000
21747
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21748
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21749
+ * MUCH, in the return value, where the caller cannot fail to see it.
21750
+ *
21751
+ * Equals the requested `topK` whenever nothing was lowered.
21752
+ */
21753
+ effectiveTopK: number().int().positive()
21438
21754
  });
21439
21755
  var VectorDeleteInputSchema = object({
21440
21756
  index: string(),
@@ -21463,6 +21779,68 @@ var VectorGetResultSchema = object({ items: array(object({
21463
21779
  id: string(),
21464
21780
  metadata: VectorMetadataSchema
21465
21781
  })) });
21782
+ /**
21783
+ * Ids to read back WITH their vectors.
21784
+ *
21785
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21786
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21787
+ * caller depends on that promise. This one promises the opposite.
21788
+ *
21789
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21790
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21791
+ * a per-face cross-process KNN would be a network round trip inside the
21792
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21793
+ * it requires the index to hand the floats back. Without this method the only
21794
+ * way to keep a readable vector is a JSON column, which is the thing this
21795
+ * capability exists to delete.
21796
+ *
21797
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21798
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21799
+ */
21800
+ var VectorFetchInputSchema = object({
21801
+ index: string(),
21802
+ ids: array(string())
21803
+ });
21804
+ var VectorFetchResultSchema = object({ items: array(object({
21805
+ id: string(),
21806
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21807
+ vector: string(),
21808
+ metadata: VectorMetadataSchema
21809
+ })) });
21810
+ /**
21811
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21812
+ *
21813
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21814
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21815
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21816
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21817
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21818
+ * looked" for as long as anyone cared to read it.
21819
+ *
21820
+ * This is the primitive that question actually needs: a bounded page, ordered
21821
+ * by the backend's own row order, costing no distance computation at all.
21822
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21823
+ * the full-table read this capability was built to stop.
21824
+ */
21825
+ var VectorScanInputSchema = object({
21826
+ index: string(),
21827
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21828
+ cursor: number().int().nonnegative().default(0),
21829
+ limit: number().int().positive()
21830
+ });
21831
+ var VectorScanResultSchema = object({
21832
+ items: array(object({
21833
+ id: string(),
21834
+ metadata: VectorMetadataSchema
21835
+ })),
21836
+ /**
21837
+ * Where the next page starts, or `null` when the walk reached the end.
21838
+ *
21839
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21840
+ * from a short page: a backend is free to return fewer rows than asked.
21841
+ */
21842
+ nextCursor: number().int().nonnegative().nullable()
21843
+ });
21466
21844
  var VectorStatsInputSchema = object({ index: string() });
21467
21845
  var VectorStatsResultSchema = object({
21468
21846
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21481,7 +21859,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21481
21859
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21482
21860
  kind: "mutation",
21483
21861
  auth: "admin"
21484
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21862
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21485
21863
  kind: "mutation",
21486
21864
  auth: "admin"
21487
21865
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28100,6 +28478,9 @@ method(object({
28100
28478
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28101
28479
  kind: "query",
28102
28480
  auth: "admin"
28481
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28482
+ kind: "query",
28483
+ auth: "admin"
28103
28484
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28104
28485
  kind: "mutation",
28105
28486
  auth: "admin"
@@ -34734,6 +35115,18 @@ Object.freeze({
34734
35115
  addonId: null,
34735
35116
  access: "create"
34736
35117
  },
35118
+ "pipelineAnalytics.countRelocatableMedia": {
35119
+ capName: "pipeline-analytics",
35120
+ capScope: "device",
35121
+ addonId: null,
35122
+ access: "view"
35123
+ },
35124
+ "pipelineAnalytics.countUnstampedEventMedia": {
35125
+ capName: "pipeline-analytics",
35126
+ capScope: "device",
35127
+ addonId: null,
35128
+ access: "view"
35129
+ },
34737
35130
  "pipelineAnalytics.deleteDeviceEvents": {
34738
35131
  capName: "pipeline-analytics",
34739
35132
  capScope: "device",
@@ -35892,6 +36285,12 @@ Object.freeze({
35892
36285
  addonId: null,
35893
36286
  access: "view"
35894
36287
  },
36288
+ "recording.getRelocateResidue": {
36289
+ capName: "recording",
36290
+ capScope: "system",
36291
+ addonId: null,
36292
+ access: "view"
36293
+ },
35895
36294
  "recording.getStorageMigrationMoveStatus": {
35896
36295
  capName: "recording",
35897
36296
  capScope: "system",
@@ -36438,12 +36837,30 @@ Object.freeze({
36438
36837
  addonId: null,
36439
36838
  access: "create"
36440
36839
  },
36840
+ "storageMigration.drain": {
36841
+ capName: "storage-migration",
36842
+ capScope: "system",
36843
+ addonId: null,
36844
+ access: "create"
36845
+ },
36846
+ "storageMigration.movers": {
36847
+ capName: "storage-migration",
36848
+ capScope: "system",
36849
+ addonId: null,
36850
+ access: "view"
36851
+ },
36441
36852
  "storageMigration.plan": {
36442
36853
  capName: "storage-migration",
36443
36854
  capScope: "system",
36444
36855
  addonId: null,
36445
36856
  access: "view"
36446
36857
  },
36858
+ "storageMigration.residue": {
36859
+ capName: "storage-migration",
36860
+ capScope: "system",
36861
+ addonId: null,
36862
+ access: "view"
36863
+ },
36447
36864
  "storageMigration.start": {
36448
36865
  capName: "storage-migration",
36449
36866
  capScope: "system",
@@ -37278,6 +37695,12 @@ Object.freeze({
37278
37695
  addonId: null,
37279
37696
  access: "delete"
37280
37697
  },
37698
+ "vectorStore.fetchByIds": {
37699
+ capName: "vector-store",
37700
+ capScope: "system",
37701
+ addonId: null,
37702
+ access: "view"
37703
+ },
37281
37704
  "vectorStore.getByIds": {
37282
37705
  capName: "vector-store",
37283
37706
  capScope: "system",
@@ -37290,6 +37713,12 @@ Object.freeze({
37290
37713
  addonId: null,
37291
37714
  access: "view"
37292
37715
  },
37716
+ "vectorStore.scan": {
37717
+ capName: "vector-store",
37718
+ capScope: "system",
37719
+ addonId: null,
37720
+ access: "view"
37721
+ },
37293
37722
  "vectorStore.stats": {
37294
37723
  capName: "vector-store",
37295
37724
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8041,18 +8041,61 @@ var RelocateFootageInputSchema = object({
8041
8041
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8042
8042
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8043
8043
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8044
+ /**
8045
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8046
+ * mover (the engine already walks both collections with a timestamp cursor and
8047
+ * already has a stamp-without-copy path).
8048
+ *
8049
+ * - `move` — the default and the historical behaviour: event-media and
8050
+ * retrain blobs move to `toLocationId` and their rows are
8051
+ * stamped. The enrolled gallery is skipped (D197).
8052
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8053
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8054
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8055
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8056
+ * instant a repoint moves that pointer the row reads from the
8057
+ * new disk while its bytes are on the old one.
8058
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8059
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8060
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8061
+ * never run beside a live second location: it is stop-the-world
8062
+ * by construction, which is acceptable only because the gallery
8063
+ * is a few KB per enrolled sample.
8064
+ */
8065
+ var MediaRelocateModeSchema = _enum([
8066
+ "move",
8067
+ "seal",
8068
+ "gallery"
8069
+ ]);
8044
8070
  var RelocateMediaInputSchema = object({
8045
8071
  toLocationId: string(),
8046
- throttleMbps: number().min(1).max(1e3).optional()
8072
+ throttleMbps: number().min(1).max(1e3).optional(),
8073
+ /** Omitted = `move`, the pre-existing behaviour. */
8074
+ mode: MediaRelocateModeSchema.optional()
8075
+ });
8076
+ /** How many rows still carry NO `locationId` — the population a repoint would
8077
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8078
+ * value that permits a non-blocking `eventMedia` cutover. */
8079
+ var UnstampedEventMediaCountSchema = object({
8080
+ media: number().int().nonnegative(),
8081
+ retrainFrames: number().int().nonnegative(),
8082
+ total: number().int().nonnegative()
8047
8083
  });
8048
8084
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8049
- /** The independently selectable logical storage classes. `recordings`
8050
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8051
- * segments; `eventMedia` is post-analysis blobs. */
8085
+ /** The independently selectable logical storage classes — every class
8086
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8087
+ * Zod enum error where they should meet an explanation.
8088
+ *
8089
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8090
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8091
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8092
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8052
8093
  var StorageMigrationClassSchema = _enum([
8053
8094
  "recordings",
8054
8095
  "recordingsLow",
8055
- "eventMedia"
8096
+ "eventMedia",
8097
+ "backups",
8098
+ "galleryMedia"
8056
8099
  ]);
8057
8100
  /** A destination is always an existing, fully-qualified location id. The
8058
8101
  * migration API intentionally never changes a source location's `basePath`:
@@ -8060,20 +8103,56 @@ var StorageMigrationClassSchema = _enum([
8060
8103
  var StorageMigrationDestinationsSchema = object({
8061
8104
  recordings: string().min(1).optional(),
8062
8105
  recordingsLow: string().min(1).optional(),
8063
- eventMedia: string().min(1).optional()
8106
+ eventMedia: string().min(1).optional(),
8107
+ backups: string().min(1).optional(),
8108
+ galleryMedia: string().min(1).optional()
8064
8109
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8110
+ /**
8111
+ * How a migration sequences the cutover against the byte move.
8112
+ *
8113
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8114
+ * resume. Recording is stopped for the whole move. Right
8115
+ * for a small or a cold class, and the only legal mode for
8116
+ * a `cardinality: 'single'` class.
8117
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8118
+ * refresh, resume, then move the past with everything
8119
+ * running. The pause is three bounded instants (a detach +
8120
+ * attach round, a write-gate drain, a lease) instead of one
8121
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8122
+ * stopped recording under `blocking`; the same move is
8123
+ * seconds of stopped recording under `nonBlocking`.
8124
+ *
8125
+ * The mode is on the JOB, not only on the input, because `status` is where an
8126
+ * operator finds out which one is running.
8127
+ */
8128
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8065
8129
  /** Shared input for planning and starting an orchestrated storage migration. */
8066
8130
  var StorageMigrationInputSchema = object({
8067
8131
  destinations: StorageMigrationDestinationsSchema,
8068
- throttleMbps: number().min(1).max(1e3).optional()
8132
+ throttleMbps: number().min(1).max(1e3).optional(),
8133
+ /** Omitted = `blocking`, which stays the default. */
8134
+ mode: StorageMigrationModeSchema.optional()
8069
8135
  });
8070
- /** The durable coordinator state machine. The only phase that changes default
8071
- * locations is `repointing`, after every selected mover has completed and been
8072
- * verified. */
8136
+ /**
8137
+ * The durable coordinator state machine.
8138
+ *
8139
+ * `blocking`:
8140
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8141
+ *
8142
+ * `nonBlocking`:
8143
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8144
+ *
8145
+ * Same phases, different order plus two new ones — not a second mover.
8146
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8147
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8148
+ * `repointing` is still the only phase that changes a default location.
8149
+ */
8073
8150
  var StorageMigrationPhaseSchema = _enum([
8074
8151
  "planning",
8152
+ "sealing",
8075
8153
  "pausing",
8076
8154
  "moving",
8155
+ "draining",
8077
8156
  "verifying",
8078
8157
  "repointing",
8079
8158
  "refreshing",
@@ -8087,17 +8166,56 @@ var StorageMigrationParticipantSchema = _enum([
8087
8166
  "recorder",
8088
8167
  "analytics"
8089
8168
  ]);
8169
+ /**
8170
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8171
+ *
8172
+ * The long half of a non-blocking migration is `draining`, and it is measured
8173
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8174
+ * existed the only place those numbers appeared was a Loki line, so an operator
8175
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8176
+ * afternoon.
8177
+ *
8178
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8179
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8180
+ * mover — which is the exact failure this is meant to end. The coordinator's
8181
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8182
+ * read `state`; folding the counters costs no extra read and makes the durable
8183
+ * record say afterwards how far a move actually got.
8184
+ *
8185
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8186
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8187
+ * cannot say M, and a 0 there would render as "100 % done".
8188
+ */
8189
+ var StorageMigrationMoveProgressSchema = object({
8190
+ filesMoved: number().int().nonnegative(),
8191
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8192
+ filesTotal: number().int().nonnegative().nullable(),
8193
+ bytesMoved: number().int().nonnegative(),
8194
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8195
+ * crash gets a new mover, and a rate computed from the migration's start
8196
+ * would silently average in the time nothing was running. */
8197
+ startedAt: number(),
8198
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8199
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8200
+ * subtract its own. */
8201
+ observedAt: number()
8202
+ });
8090
8203
  var StorageMigrationMoveSchema = object({
8091
8204
  storageClass: StorageMigrationClassSchema,
8092
8205
  fromLocationId: string(),
8093
8206
  toLocationId: string(),
8094
8207
  moverJobId: string().nullable(),
8095
8208
  state: RelocateJobStateSchema.nullable(),
8096
- error: string().nullable()
8209
+ error: string().nullable(),
8210
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8211
+ progress: StorageMigrationMoveProgressSchema.nullable()
8097
8212
  });
8098
8213
  var StorageMigrationJobSchema = object({
8099
8214
  jobId: string(),
8100
8215
  phase: StorageMigrationPhaseSchema,
8216
+ /** Which order this job is running. `status` is the only place an operator
8217
+ * can tell a seconds-long cutover from a thirty-hour one. */
8218
+ mode: StorageMigrationModeSchema,
8101
8219
  destinations: StorageMigrationDestinationsSchema,
8102
8220
  throttleMbps: number(),
8103
8221
  moves: array(StorageMigrationMoveSchema),
@@ -8110,13 +8228,122 @@ var StorageMigrationJobSchema = object({
8110
8228
  finishedAt: number().nullable(),
8111
8229
  error: string().nullable()
8112
8230
  });
8231
+ var StorageMigrationFindingSchema = object({
8232
+ code: _enum([
8233
+ "sharesDeviceWithSource",
8234
+ "deviceIdentityUnknown",
8235
+ "unstampedEventMediaRows",
8236
+ "blockingOnly",
8237
+ "noMover"
8238
+ ]),
8239
+ storageClass: StorageMigrationClassSchema,
8240
+ /** Human-readable, already carrying the ids and counts. */
8241
+ message: string()
8242
+ });
8113
8243
  var StorageMigrationPlanSchema = object({
8114
8244
  destinations: StorageMigrationDestinationsSchema,
8245
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8246
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8247
+ * it. */
8248
+ mode: StorageMigrationModeSchema,
8115
8249
  moves: array(object({
8116
8250
  storageClass: StorageMigrationClassSchema,
8117
8251
  fromLocationId: string(),
8118
8252
  toLocationId: string()
8119
- }))
8253
+ })),
8254
+ findings: array(StorageMigrationFindingSchema)
8255
+ });
8256
+ /**
8257
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8258
+ *
8259
+ * The coordinator's job record is the state of record for a migration, and its
8260
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8261
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8262
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8263
+ * way because no supported UI path existed. A mover armed like that has no job
8264
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8265
+ *
8266
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8267
+ * orchestrated it.
8268
+ */
8269
+ var StorageMigrationMoverSchema = object({
8270
+ lane: _enum(["footage", "media"]),
8271
+ job: RelocateJobSchema,
8272
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8273
+ * directly against the owning addon. */
8274
+ migrationJobId: string().nullable(),
8275
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8276
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8277
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8278
+ * rate made of two different clocks. */
8279
+ observedAt: number()
8280
+ });
8281
+ /**
8282
+ * What a SOURCE still holds for one storage class — the number that makes a
8283
+ * "drain remaining" action honest rather than hopeful.
8284
+ *
8285
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8286
+ * engine's own selection count for media), never from the resident index: a
8287
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8288
+ * never been told about (D295).
8289
+ *
8290
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8291
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8292
+ * because refusing on an unanswerable read would hide exactly the case an
8293
+ * operator needs to act on.
8294
+ */
8295
+ var StorageMigrationResidueSchema = object({
8296
+ storageClass: StorageMigrationClassSchema,
8297
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8298
+ * move from wherever they are rather than from one named source. */
8299
+ fromLocationId: string(),
8300
+ /** Where a drain would move it — the class's CURRENT default. */
8301
+ toLocationId: string(),
8302
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8303
+ items: number().int().nonnegative().nullable(),
8304
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8305
+ bytes: number().int().nonnegative().nullable()
8306
+ });
8307
+ /**
8308
+ * Run the DRAIN half and nothing else.
8309
+ *
8310
+ * A migration that reached `done` has already repointed, so `start` correctly
8311
+ * refuses its destination ("already the default") — there is nothing left to
8312
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8313
+ * or finish against a work list that was a tenth of the archive (D295), and
8314
+ * before this there was no supported way to run only that half: the only way
8315
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8316
+ *
8317
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8318
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8319
+ * re-repoint a class that is already migrated.
8320
+ */
8321
+ var StorageMigrationDrainInputSchema = object({
8322
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8323
+ * a class whose source is already empty is refused rather than started. */
8324
+ classes: array(StorageMigrationClassSchema).min(1),
8325
+ throttleMbps: number().min(1).max(1e3).optional()
8326
+ });
8327
+ /** What a footage source still holds, asked of the durable hour ledger. */
8328
+ var RelocateResidueInputSchema = object({
8329
+ fromLocationId: string().min(1),
8330
+ /** Narrow to one logical class; omit for every profile on the location. */
8331
+ footageClass: RelocateFootageClassSchema.optional()
8332
+ });
8333
+ /** `null` = the archive could not answer (no ledger on this node, or the
8334
+ * aggregate failed). Never conflated with an empty source. */
8335
+ var RelocateResidueSchema = object({
8336
+ segments: number().int().nonnegative(),
8337
+ bytes: number().int().nonnegative()
8338
+ }).nullable();
8339
+ /** How many rows a media pass would still act on against a given target — the
8340
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8341
+ * never disagree. `null` = the count could not be taken. */
8342
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8343
+ var RelocatableMediaCountInputSchema = object({
8344
+ toLocationId: string().min(1),
8345
+ /** Omitted = `move`. */
8346
+ mode: MediaRelocateModeSchema.optional()
8120
8347
  });
8121
8348
  /**
8122
8349
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8222,6 +8449,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8222
8449
  * two addons declaring the same `id` must agree on `cardinality` (validated
8223
8450
  * at kernel aggregation time, not here).
8224
8451
  */
8452
+ /**
8453
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8454
+ * actually reaches the bytes. It is the constraint that decides which
8455
+ * `storage-provider`s may back a location of that kind.
8456
+ *
8457
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8458
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8459
+ * post-analysis media roots). Only a provider that serves a genuine local
8460
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8461
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8462
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8463
+ * against a same-named local directory that is something else entirely.
8464
+ *
8465
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8466
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8467
+ * service never sees a path, so any provider can back it. `backups` is the
8468
+ * one kind that qualifies today.
8469
+ *
8470
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8471
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8472
+ * refused the configuration; the first write simply went somewhere wrong, and
8473
+ * a recording write that goes wrong surfaces as a silent black window rather
8474
+ * than an error (the read path does not `stat`). This turns that accident into
8475
+ * a declared, enforced, testable refusal.
8476
+ */
8477
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8225
8478
  var StorageLocationDeclarationSchema = object({
8226
8479
  /**
8227
8480
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8241,6 +8494,19 @@ var StorageLocationDeclarationSchema = object({
8241
8494
  */
8242
8495
  cardinality: _enum(["single", "multi"]),
8243
8496
  /**
8497
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8498
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8499
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8500
+ *
8501
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8502
+ * can only over-restrict (refuse a remote provider for a kind that might
8503
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8504
+ * permissive direction and is therefore never inferred — a repo guard
8505
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8506
+ * reached by omission.
8507
+ */
8508
+ access: StorageAccessSchema.optional(),
8509
+ /**
8244
8510
  * When set, the default instance for this location inherits its resolved
8245
8511
  * root from the named location's default instance. Useful for derivative
8246
8512
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18108,8 +18374,10 @@ var TrackSchema = object({
18108
18374
  lastSeen: number(),
18109
18375
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18110
18376
  positions: array(TrackPositionSchema).readonly(),
18111
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18112
- * saveThumbnails policy). */
18377
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18378
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18379
+ * the retired `saveThumbnails` used to gate this and the rolling
18380
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18113
18381
  snapshots: array(TrackSnapshotSchema).readonly(),
18114
18382
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18115
18383
  zonesVisited: array(string()).readonly(),
@@ -18969,6 +19237,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18969
19237
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18970
19238
  kind: "mutation",
18971
19239
  auth: "admin"
19240
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19241
+ kind: "query",
19242
+ auth: "admin"
18972
19243
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18973
19244
  kind: "query",
18974
19245
  auth: "admin"
@@ -20876,7 +21147,10 @@ method(object({
20876
21147
  }), StorageLocationSchema, {
20877
21148
  kind: "mutation",
20878
21149
  auth: "admin"
20879
- }), method(object({ id: string() }), _void(), {
21150
+ }), method(object({
21151
+ id: string(),
21152
+ force: boolean().optional()
21153
+ }), _void(), {
20880
21154
  kind: "mutation",
20881
21155
  auth: "admin"
20882
21156
  }), method(object({ id: string() }), object({
@@ -20925,6 +21199,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20925
21199
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20926
21200
  kind: "mutation",
20927
21201
  auth: "admin"
21202
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21203
+ kind: "mutation",
21204
+ auth: "admin"
20928
21205
  });
20929
21206
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20930
21207
  providerId: string().min(1),
@@ -21323,12 +21600,38 @@ response: record(string(), unknown()) }), object({
21323
21600
  *
21324
21601
  * ## Why this is a capability and not a helper
21325
21602
  *
21326
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21327
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21328
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21329
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21330
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21331
- * load 5,000 rows before ranking anything.
21603
+ * This capability was introduced with the claim that SIX stores in
21604
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21605
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21606
+ * claim was never true, and leaving it here made five stores look like pending
21607
+ * work when three of them have no vector at all. Counted column by column on
21608
+ * 2026-08-30, exactly THREE ever held one:
21609
+ *
21610
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21611
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21612
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21613
+ * face, migrated 2026-08-30 into its OWN index (see below).
21614
+ *
21615
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21616
+ * and `identities` store a name; the event store stores no derivative vector.
21617
+ * They are not migration candidates and never were.
21618
+ *
21619
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21620
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21621
+ * rows before ranking anything.
21622
+ *
21623
+ * ## One index per COMPARISON, never per encoder
21624
+ *
21625
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21626
+ * model, and they still get two indexes. An index is a set of things that are
21627
+ * ranked against each other and that live and die together, and these two are
21628
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21629
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21630
+ * forever and is the gallery every recognition ranks against. One index would
21631
+ * mean every gallery load and every reconcile carried a filter whose failure
21632
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21633
+ * person's only sample. The dimension they share is not a reason to share an
21634
+ * index; the question they answer is, and it differs.
21332
21635
  *
21333
21636
  * The fix is not a faster loop, it is a different backend — and the backend
21334
21637
  * should be replaceable without touching six callers. So: a singleton
@@ -21433,7 +21736,20 @@ var VectorQueryResultSchema = object({
21433
21736
  */
21434
21737
  scanned: number(),
21435
21738
  /** True when the backend could not consider every row that passed the filter. */
21436
- truncated: boolean()
21739
+ truncated: boolean(),
21740
+ /**
21741
+ * The `topK` the backend actually ran with.
21742
+ *
21743
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21744
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21745
+ * own log rather than in its answer. That is how an audit asking for 20,000
21746
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21747
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21748
+ * MUCH, in the return value, where the caller cannot fail to see it.
21749
+ *
21750
+ * Equals the requested `topK` whenever nothing was lowered.
21751
+ */
21752
+ effectiveTopK: number().int().positive()
21437
21753
  });
21438
21754
  var VectorDeleteInputSchema = object({
21439
21755
  index: string(),
@@ -21462,6 +21778,68 @@ var VectorGetResultSchema = object({ items: array(object({
21462
21778
  id: string(),
21463
21779
  metadata: VectorMetadataSchema
21464
21780
  })) });
21781
+ /**
21782
+ * Ids to read back WITH their vectors.
21783
+ *
21784
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21785
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21786
+ * caller depends on that promise. This one promises the opposite.
21787
+ *
21788
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21789
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21790
+ * a per-face cross-process KNN would be a network round trip inside the
21791
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21792
+ * it requires the index to hand the floats back. Without this method the only
21793
+ * way to keep a readable vector is a JSON column, which is the thing this
21794
+ * capability exists to delete.
21795
+ *
21796
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21797
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21798
+ */
21799
+ var VectorFetchInputSchema = object({
21800
+ index: string(),
21801
+ ids: array(string())
21802
+ });
21803
+ var VectorFetchResultSchema = object({ items: array(object({
21804
+ id: string(),
21805
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21806
+ vector: string(),
21807
+ metadata: VectorMetadataSchema
21808
+ })) });
21809
+ /**
21810
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21811
+ *
21812
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21813
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21814
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21815
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21816
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21817
+ * looked" for as long as anyone cared to read it.
21818
+ *
21819
+ * This is the primitive that question actually needs: a bounded page, ordered
21820
+ * by the backend's own row order, costing no distance computation at all.
21821
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21822
+ * the full-table read this capability was built to stop.
21823
+ */
21824
+ var VectorScanInputSchema = object({
21825
+ index: string(),
21826
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21827
+ cursor: number().int().nonnegative().default(0),
21828
+ limit: number().int().positive()
21829
+ });
21830
+ var VectorScanResultSchema = object({
21831
+ items: array(object({
21832
+ id: string(),
21833
+ metadata: VectorMetadataSchema
21834
+ })),
21835
+ /**
21836
+ * Where the next page starts, or `null` when the walk reached the end.
21837
+ *
21838
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21839
+ * from a short page: a backend is free to return fewer rows than asked.
21840
+ */
21841
+ nextCursor: number().int().nonnegative().nullable()
21842
+ });
21465
21843
  var VectorStatsInputSchema = object({ index: string() });
21466
21844
  var VectorStatsResultSchema = object({
21467
21845
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21480,7 +21858,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21480
21858
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21481
21859
  kind: "mutation",
21482
21860
  auth: "admin"
21483
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21861
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21484
21862
  kind: "mutation",
21485
21863
  auth: "admin"
21486
21864
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28099,6 +28477,9 @@ method(object({
28099
28477
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28100
28478
  kind: "query",
28101
28479
  auth: "admin"
28480
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
28481
+ kind: "query",
28482
+ auth: "admin"
28102
28483
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28103
28484
  kind: "mutation",
28104
28485
  auth: "admin"
@@ -34733,6 +35114,18 @@ Object.freeze({
34733
35114
  addonId: null,
34734
35115
  access: "create"
34735
35116
  },
35117
+ "pipelineAnalytics.countRelocatableMedia": {
35118
+ capName: "pipeline-analytics",
35119
+ capScope: "device",
35120
+ addonId: null,
35121
+ access: "view"
35122
+ },
35123
+ "pipelineAnalytics.countUnstampedEventMedia": {
35124
+ capName: "pipeline-analytics",
35125
+ capScope: "device",
35126
+ addonId: null,
35127
+ access: "view"
35128
+ },
34736
35129
  "pipelineAnalytics.deleteDeviceEvents": {
34737
35130
  capName: "pipeline-analytics",
34738
35131
  capScope: "device",
@@ -35891,6 +36284,12 @@ Object.freeze({
35891
36284
  addonId: null,
35892
36285
  access: "view"
35893
36286
  },
36287
+ "recording.getRelocateResidue": {
36288
+ capName: "recording",
36289
+ capScope: "system",
36290
+ addonId: null,
36291
+ access: "view"
36292
+ },
35894
36293
  "recording.getStorageMigrationMoveStatus": {
35895
36294
  capName: "recording",
35896
36295
  capScope: "system",
@@ -36437,12 +36836,30 @@ Object.freeze({
36437
36836
  addonId: null,
36438
36837
  access: "create"
36439
36838
  },
36839
+ "storageMigration.drain": {
36840
+ capName: "storage-migration",
36841
+ capScope: "system",
36842
+ addonId: null,
36843
+ access: "create"
36844
+ },
36845
+ "storageMigration.movers": {
36846
+ capName: "storage-migration",
36847
+ capScope: "system",
36848
+ addonId: null,
36849
+ access: "view"
36850
+ },
36440
36851
  "storageMigration.plan": {
36441
36852
  capName: "storage-migration",
36442
36853
  capScope: "system",
36443
36854
  addonId: null,
36444
36855
  access: "view"
36445
36856
  },
36857
+ "storageMigration.residue": {
36858
+ capName: "storage-migration",
36859
+ capScope: "system",
36860
+ addonId: null,
36861
+ access: "view"
36862
+ },
36446
36863
  "storageMigration.start": {
36447
36864
  capName: "storage-migration",
36448
36865
  capScope: "system",
@@ -37277,6 +37694,12 @@ Object.freeze({
37277
37694
  addonId: null,
37278
37695
  access: "delete"
37279
37696
  },
37697
+ "vectorStore.fetchByIds": {
37698
+ capName: "vector-store",
37699
+ capScope: "system",
37700
+ addonId: null,
37701
+ access: "view"
37702
+ },
37280
37703
  "vectorStore.getByIds": {
37281
37704
  capName: "vector-store",
37282
37705
  capScope: "system",
@@ -37289,6 +37712,12 @@ Object.freeze({
37289
37712
  addonId: null,
37290
37713
  access: "view"
37291
37714
  },
37715
+ "vectorStore.scan": {
37716
+ capName: "vector-store",
37717
+ capScope: "system",
37718
+ addonId: null,
37719
+ access: "view"
37720
+ },
37292
37721
  "vectorStore.stats": {
37293
37722
  capName: "vector-store",
37294
37723
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-gree",
3
- "version": "0.2.41",
3
+ "version": "0.2.44",
4
4
  "description": "Gree air-conditioner device-provider addon for CamStack — wraps the @apocaliss92/nodegree local-UDP client (LAN discovery + AES control), exposing climate-control and fan-control",
5
5
  "keywords": [
6
6
  "camstack",