@camstack/addon-provider-tuya 0.2.42 → 0.2.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/addon.js +452 -23
  2. package/dist/addon.mjs +452 -23
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8859,18 +8859,61 @@ var RelocateFootageInputSchema = object({
8859
8859
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8860
8860
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8861
8861
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8862
+ /**
8863
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8864
+ * mover (the engine already walks both collections with a timestamp cursor and
8865
+ * already has a stamp-without-copy path).
8866
+ *
8867
+ * - `move` — the default and the historical behaviour: event-media and
8868
+ * retrain blobs move to `toLocationId` and their rows are
8869
+ * stamped. The enrolled gallery is skipped (D197).
8870
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8871
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8872
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8873
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8874
+ * instant a repoint moves that pointer the row reads from the
8875
+ * new disk while its bytes are on the old one.
8876
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8877
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8878
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8879
+ * never run beside a live second location: it is stop-the-world
8880
+ * by construction, which is acceptable only because the gallery
8881
+ * is a few KB per enrolled sample.
8882
+ */
8883
+ var MediaRelocateModeSchema = _enum([
8884
+ "move",
8885
+ "seal",
8886
+ "gallery"
8887
+ ]);
8862
8888
  var RelocateMediaInputSchema = object({
8863
8889
  toLocationId: string(),
8864
- throttleMbps: number().min(1).max(1e3).optional()
8890
+ throttleMbps: number().min(1).max(1e3).optional(),
8891
+ /** Omitted = `move`, the pre-existing behaviour. */
8892
+ mode: MediaRelocateModeSchema.optional()
8893
+ });
8894
+ /** How many rows still carry NO `locationId` — the population a repoint would
8895
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8896
+ * value that permits a non-blocking `eventMedia` cutover. */
8897
+ var UnstampedEventMediaCountSchema = object({
8898
+ media: number().int().nonnegative(),
8899
+ retrainFrames: number().int().nonnegative(),
8900
+ total: number().int().nonnegative()
8865
8901
  });
8866
8902
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8867
- /** The independently selectable logical storage classes. `recordings`
8868
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8869
- * segments; `eventMedia` is post-analysis blobs. */
8903
+ /** The independently selectable logical storage classes — every class
8904
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8905
+ * Zod enum error where they should meet an explanation.
8906
+ *
8907
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8908
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8909
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8910
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8870
8911
  var StorageMigrationClassSchema = _enum([
8871
8912
  "recordings",
8872
8913
  "recordingsLow",
8873
- "eventMedia"
8914
+ "eventMedia",
8915
+ "backups",
8916
+ "galleryMedia"
8874
8917
  ]);
8875
8918
  /** A destination is always an existing, fully-qualified location id. The
8876
8919
  * migration API intentionally never changes a source location's `basePath`:
@@ -8878,20 +8921,56 @@ var StorageMigrationClassSchema = _enum([
8878
8921
  var StorageMigrationDestinationsSchema = object({
8879
8922
  recordings: string().min(1).optional(),
8880
8923
  recordingsLow: string().min(1).optional(),
8881
- eventMedia: string().min(1).optional()
8924
+ eventMedia: string().min(1).optional(),
8925
+ backups: string().min(1).optional(),
8926
+ galleryMedia: string().min(1).optional()
8882
8927
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8928
+ /**
8929
+ * How a migration sequences the cutover against the byte move.
8930
+ *
8931
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8932
+ * resume. Recording is stopped for the whole move. Right
8933
+ * for a small or a cold class, and the only legal mode for
8934
+ * a `cardinality: 'single'` class.
8935
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8936
+ * refresh, resume, then move the past with everything
8937
+ * running. The pause is three bounded instants (a detach +
8938
+ * attach round, a write-gate drain, a lease) instead of one
8939
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8940
+ * stopped recording under `blocking`; the same move is
8941
+ * seconds of stopped recording under `nonBlocking`.
8942
+ *
8943
+ * The mode is on the JOB, not only on the input, because `status` is where an
8944
+ * operator finds out which one is running.
8945
+ */
8946
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8883
8947
  /** Shared input for planning and starting an orchestrated storage migration. */
8884
8948
  var StorageMigrationInputSchema = object({
8885
8949
  destinations: StorageMigrationDestinationsSchema,
8886
- throttleMbps: number().min(1).max(1e3).optional()
8950
+ throttleMbps: number().min(1).max(1e3).optional(),
8951
+ /** Omitted = `blocking`, which stays the default. */
8952
+ mode: StorageMigrationModeSchema.optional()
8887
8953
  });
8888
- /** The durable coordinator state machine. The only phase that changes default
8889
- * locations is `repointing`, after every selected mover has completed and been
8890
- * verified. */
8954
+ /**
8955
+ * The durable coordinator state machine.
8956
+ *
8957
+ * `blocking`:
8958
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8959
+ *
8960
+ * `nonBlocking`:
8961
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8962
+ *
8963
+ * Same phases, different order plus two new ones — not a second mover.
8964
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8965
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8966
+ * `repointing` is still the only phase that changes a default location.
8967
+ */
8891
8968
  var StorageMigrationPhaseSchema = _enum([
8892
8969
  "planning",
8970
+ "sealing",
8893
8971
  "pausing",
8894
8972
  "moving",
8973
+ "draining",
8895
8974
  "verifying",
8896
8975
  "repointing",
8897
8976
  "refreshing",
@@ -8905,17 +8984,56 @@ var StorageMigrationParticipantSchema = _enum([
8905
8984
  "recorder",
8906
8985
  "analytics"
8907
8986
  ]);
8987
+ /**
8988
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8989
+ *
8990
+ * The long half of a non-blocking migration is `draining`, and it is measured
8991
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8992
+ * existed the only place those numbers appeared was a Loki line, so an operator
8993
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8994
+ * afternoon.
8995
+ *
8996
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8997
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8998
+ * mover — which is the exact failure this is meant to end. The coordinator's
8999
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
9000
+ * read `state`; folding the counters costs no extra read and makes the durable
9001
+ * record say afterwards how far a move actually got.
9002
+ *
9003
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
9004
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
9005
+ * cannot say M, and a 0 there would render as "100 % done".
9006
+ */
9007
+ var StorageMigrationMoveProgressSchema = object({
9008
+ filesMoved: number().int().nonnegative(),
9009
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
9010
+ filesTotal: number().int().nonnegative().nullable(),
9011
+ bytesMoved: number().int().nonnegative(),
9012
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
9013
+ * crash gets a new mover, and a rate computed from the migration's start
9014
+ * would silently average in the time nothing was running. */
9015
+ startedAt: number(),
9016
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
9017
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
9018
+ * subtract its own. */
9019
+ observedAt: number()
9020
+ });
8908
9021
  var StorageMigrationMoveSchema = object({
8909
9022
  storageClass: StorageMigrationClassSchema,
8910
9023
  fromLocationId: string(),
8911
9024
  toLocationId: string(),
8912
9025
  moverJobId: string().nullable(),
8913
9026
  state: RelocateJobStateSchema.nullable(),
8914
- error: string().nullable()
9027
+ error: string().nullable(),
9028
+ /** Last observed mover counters; `null` until the mover has been polled once. */
9029
+ progress: StorageMigrationMoveProgressSchema.nullable()
8915
9030
  });
8916
9031
  var StorageMigrationJobSchema = object({
8917
9032
  jobId: string(),
8918
9033
  phase: StorageMigrationPhaseSchema,
9034
+ /** Which order this job is running. `status` is the only place an operator
9035
+ * can tell a seconds-long cutover from a thirty-hour one. */
9036
+ mode: StorageMigrationModeSchema,
8919
9037
  destinations: StorageMigrationDestinationsSchema,
8920
9038
  throttleMbps: number(),
8921
9039
  moves: array(StorageMigrationMoveSchema),
@@ -8928,13 +9046,122 @@ var StorageMigrationJobSchema = object({
8928
9046
  finishedAt: number().nullable(),
8929
9047
  error: string().nullable()
8930
9048
  });
9049
+ var StorageMigrationFindingSchema = object({
9050
+ code: _enum([
9051
+ "sharesDeviceWithSource",
9052
+ "deviceIdentityUnknown",
9053
+ "unstampedEventMediaRows",
9054
+ "blockingOnly",
9055
+ "noMover"
9056
+ ]),
9057
+ storageClass: StorageMigrationClassSchema,
9058
+ /** Human-readable, already carrying the ids and counts. */
9059
+ message: string()
9060
+ });
8931
9061
  var StorageMigrationPlanSchema = object({
8932
9062
  destinations: StorageMigrationDestinationsSchema,
9063
+ /** The mode this plan was built for. A plan is only valid for its mode: the
9064
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
9065
+ * it. */
9066
+ mode: StorageMigrationModeSchema,
8933
9067
  moves: array(object({
8934
9068
  storageClass: StorageMigrationClassSchema,
8935
9069
  fromLocationId: string(),
8936
9070
  toLocationId: string()
8937
- }))
9071
+ })),
9072
+ findings: array(StorageMigrationFindingSchema)
9073
+ });
9074
+ /**
9075
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
9076
+ *
9077
+ * The coordinator's job record is the state of record for a migration, and its
9078
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
9079
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
9080
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
9081
+ * way because no supported UI path existed. A mover armed like that has no job
9082
+ * to fold progress into, so it has to be readable on its own or it is invisible.
9083
+ *
9084
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
9085
+ * orchestrated it.
9086
+ */
9087
+ var StorageMigrationMoverSchema = object({
9088
+ lane: _enum(["footage", "media"]),
9089
+ job: RelocateJobSchema,
9090
+ /** The coordinator job that armed this mover, or `null` for a mover armed
9091
+ * directly against the owning addon. */
9092
+ migrationJobId: string().nullable(),
9093
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
9094
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
9095
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
9096
+ * rate made of two different clocks. */
9097
+ observedAt: number()
9098
+ });
9099
+ /**
9100
+ * What a SOURCE still holds for one storage class — the number that makes a
9101
+ * "drain remaining" action honest rather than hopeful.
9102
+ *
9103
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
9104
+ * engine's own selection count for media), never from the resident index: a
9105
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
9106
+ * never been told about (D295).
9107
+ *
9108
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
9109
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
9110
+ * because refusing on an unanswerable read would hide exactly the case an
9111
+ * operator needs to act on.
9112
+ */
9113
+ var StorageMigrationResidueSchema = object({
9114
+ storageClass: StorageMigrationClassSchema,
9115
+ /** The location still holding the data. `'*'` for the media lane, whose rows
9116
+ * move from wherever they are rather than from one named source. */
9117
+ fromLocationId: string(),
9118
+ /** Where a drain would move it — the class's CURRENT default. */
9119
+ toLocationId: string(),
9120
+ /** Segments (footage lane) or rows (media lane) still on the source. */
9121
+ items: number().int().nonnegative().nullable(),
9122
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
9123
+ bytes: number().int().nonnegative().nullable()
9124
+ });
9125
+ /**
9126
+ * Run the DRAIN half and nothing else.
9127
+ *
9128
+ * A migration that reached `done` has already repointed, so `start` correctly
9129
+ * refuses its destination ("already the default") — there is nothing left to
9130
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
9131
+ * or finish against a work list that was a tenth of the archive (D295), and
9132
+ * before this there was no supported way to run only that half: the only way
9133
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
9134
+ *
9135
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
9136
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
9137
+ * re-repoint a class that is already migrated.
9138
+ */
9139
+ var StorageMigrationDrainInputSchema = object({
9140
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
9141
+ * a class whose source is already empty is refused rather than started. */
9142
+ classes: array(StorageMigrationClassSchema).min(1),
9143
+ throttleMbps: number().min(1).max(1e3).optional()
9144
+ });
9145
+ /** What a footage source still holds, asked of the durable hour ledger. */
9146
+ var RelocateResidueInputSchema = object({
9147
+ fromLocationId: string().min(1),
9148
+ /** Narrow to one logical class; omit for every profile on the location. */
9149
+ footageClass: RelocateFootageClassSchema.optional()
9150
+ });
9151
+ /** `null` = the archive could not answer (no ledger on this node, or the
9152
+ * aggregate failed). Never conflated with an empty source. */
9153
+ var RelocateResidueSchema = object({
9154
+ segments: number().int().nonnegative(),
9155
+ bytes: number().int().nonnegative()
9156
+ }).nullable();
9157
+ /** How many rows a media pass would still act on against a given target — the
9158
+ * media lane's denominator AND its residue, from ONE derivation so the two can
9159
+ * never disagree. `null` = the count could not be taken. */
9160
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
9161
+ var RelocatableMediaCountInputSchema = object({
9162
+ toLocationId: string().min(1),
9163
+ /** Omitted = `move`. */
9164
+ mode: MediaRelocateModeSchema.optional()
8938
9165
  });
8939
9166
  /**
8940
9167
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -9040,6 +9267,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
9040
9267
  * two addons declaring the same `id` must agree on `cardinality` (validated
9041
9268
  * at kernel aggregation time, not here).
9042
9269
  */
9270
+ /**
9271
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
9272
+ * actually reaches the bytes. It is the constraint that decides which
9273
+ * `storage-provider`s may back a location of that kind.
9274
+ *
9275
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
9276
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
9277
+ * post-analysis media roots). Only a provider that serves a genuine local
9278
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
9279
+ * remote provider's `resolve` returns a path on the REMOTE host, and
9280
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
9281
+ * against a same-named local directory that is something else entirely.
9282
+ *
9283
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
9284
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
9285
+ * service never sees a path, so any provider can back it. `backups` is the
9286
+ * one kind that qualifies today.
9287
+ *
9288
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
9289
+ * an EMERGENT property of how the recorder happened to be written. Nothing
9290
+ * refused the configuration; the first write simply went somewhere wrong, and
9291
+ * a recording write that goes wrong surfaces as a silent black window rather
9292
+ * than an error (the read path does not `stat`). This turns that accident into
9293
+ * a declared, enforced, testable refusal.
9294
+ */
9295
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
9043
9296
  var StorageLocationDeclarationSchema = object({
9044
9297
  /**
9045
9298
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -9059,6 +9312,19 @@ var StorageLocationDeclarationSchema = object({
9059
9312
  */
9060
9313
  cardinality: _enum(["single", "multi"]),
9061
9314
  /**
9315
+ * HOW the declaring service reaches the bytes — and therefore WHICH
9316
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
9317
+ * and {@link STORAGE_ACCESS_FALLBACK}.
9318
+ *
9319
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
9320
+ * can only over-restrict (refuse a remote provider for a kind that might
9321
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
9322
+ * permissive direction and is therefore never inferred — a repo guard
9323
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
9324
+ * reached by omission.
9325
+ */
9326
+ access: StorageAccessSchema.optional(),
9327
+ /**
9062
9328
  * When set, the default instance for this location inherits its resolved
9063
9329
  * root from the named location's default instance. Useful for derivative
9064
9330
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18943,8 +19209,10 @@ var TrackSchema = object({
18943
19209
  lastSeen: number(),
18944
19210
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18945
19211
  positions: array(TrackPositionSchema).readonly(),
18946
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18947
- * saveThumbnails policy). */
19212
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
19213
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
19214
+ * the retired `saveThumbnails` used to gate this and the rolling
19215
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18948
19216
  snapshots: array(TrackSnapshotSchema).readonly(),
18949
19217
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18950
19218
  zonesVisited: array(string()).readonly(),
@@ -19804,6 +20072,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19804
20072
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19805
20073
  kind: "mutation",
19806
20074
  auth: "admin"
20075
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
20076
+ kind: "query",
20077
+ auth: "admin"
19807
20078
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19808
20079
  kind: "query",
19809
20080
  auth: "admin"
@@ -21711,7 +21982,10 @@ method(object({
21711
21982
  }), StorageLocationSchema, {
21712
21983
  kind: "mutation",
21713
21984
  auth: "admin"
21714
- }), method(object({ id: string() }), _void(), {
21985
+ }), method(object({
21986
+ id: string(),
21987
+ force: boolean().optional()
21988
+ }), _void(), {
21715
21989
  kind: "mutation",
21716
21990
  auth: "admin"
21717
21991
  }), method(object({ id: string() }), object({
@@ -21760,6 +22034,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21760
22034
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21761
22035
  kind: "mutation",
21762
22036
  auth: "admin"
22037
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
22038
+ kind: "mutation",
22039
+ auth: "admin"
21763
22040
  });
21764
22041
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21765
22042
  providerId: string().min(1),
@@ -22158,12 +22435,38 @@ response: record(string(), unknown()) }), object({
22158
22435
  *
22159
22436
  * ## Why this is a capability and not a helper
22160
22437
  *
22161
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
22162
- * plate, vehicle, identity, and the event store's derivatives — and every one of
22163
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
22164
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
22165
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
22166
- * load 5,000 rows before ranking anything.
22438
+ * This capability was introduced with the claim that SIX stores in
22439
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
22440
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22441
+ * claim was never true, and leaving it here made five stores look like pending
22442
+ * work when three of them have no vector at all. Counted column by column on
22443
+ * 2026-08-30, exactly THREE ever held one:
22444
+ *
22445
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22446
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22447
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22448
+ * face, migrated 2026-08-30 into its OWN index (see below).
22449
+ *
22450
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22451
+ * and `identities` store a name; the event store stores no derivative vector.
22452
+ * They are not migration candidates and never were.
22453
+ *
22454
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22455
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22456
+ * rows before ranking anything.
22457
+ *
22458
+ * ## One index per COMPARISON, never per encoder
22459
+ *
22460
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22461
+ * model, and they still get two indexes. An index is a set of things that are
22462
+ * ranked against each other and that live and die together, and these two are
22463
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22464
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22465
+ * forever and is the gallery every recognition ranks against. One index would
22466
+ * mean every gallery load and every reconcile carried a filter whose failure
22467
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22468
+ * person's only sample. The dimension they share is not a reason to share an
22469
+ * index; the question they answer is, and it differs.
22167
22470
  *
22168
22471
  * The fix is not a faster loop, it is a different backend — and the backend
22169
22472
  * should be replaceable without touching six callers. So: a singleton
@@ -22268,7 +22571,20 @@ var VectorQueryResultSchema = object({
22268
22571
  */
22269
22572
  scanned: number(),
22270
22573
  /** True when the backend could not consider every row that passed the filter. */
22271
- truncated: boolean()
22574
+ truncated: boolean(),
22575
+ /**
22576
+ * The `topK` the backend actually ran with.
22577
+ *
22578
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22579
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22580
+ * own log rather than in its answer. That is how an audit asking for 20,000
22581
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22582
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22583
+ * MUCH, in the return value, where the caller cannot fail to see it.
22584
+ *
22585
+ * Equals the requested `topK` whenever nothing was lowered.
22586
+ */
22587
+ effectiveTopK: number().int().positive()
22272
22588
  });
22273
22589
  var VectorDeleteInputSchema = object({
22274
22590
  index: string(),
@@ -22297,6 +22613,68 @@ var VectorGetResultSchema = object({ items: array(object({
22297
22613
  id: string(),
22298
22614
  metadata: VectorMetadataSchema
22299
22615
  })) });
22616
+ /**
22617
+ * Ids to read back WITH their vectors.
22618
+ *
22619
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22620
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22621
+ * caller depends on that promise. This one promises the opposite.
22622
+ *
22623
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22624
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22625
+ * a per-face cross-process KNN would be a network round trip inside the
22626
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22627
+ * it requires the index to hand the floats back. Without this method the only
22628
+ * way to keep a readable vector is a JSON column, which is the thing this
22629
+ * capability exists to delete.
22630
+ *
22631
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22632
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22633
+ */
22634
+ var VectorFetchInputSchema = object({
22635
+ index: string(),
22636
+ ids: array(string())
22637
+ });
22638
+ var VectorFetchResultSchema = object({ items: array(object({
22639
+ id: string(),
22640
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22641
+ vector: string(),
22642
+ metadata: VectorMetadataSchema
22643
+ })) });
22644
+ /**
22645
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22646
+ *
22647
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22648
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22649
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22650
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22651
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22652
+ * looked" for as long as anyone cared to read it.
22653
+ *
22654
+ * This is the primitive that question actually needs: a bounded page, ordered
22655
+ * by the backend's own row order, costing no distance computation at all.
22656
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22657
+ * the full-table read this capability was built to stop.
22658
+ */
22659
+ var VectorScanInputSchema = object({
22660
+ index: string(),
22661
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22662
+ cursor: number().int().nonnegative().default(0),
22663
+ limit: number().int().positive()
22664
+ });
22665
+ var VectorScanResultSchema = object({
22666
+ items: array(object({
22667
+ id: string(),
22668
+ metadata: VectorMetadataSchema
22669
+ })),
22670
+ /**
22671
+ * Where the next page starts, or `null` when the walk reached the end.
22672
+ *
22673
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22674
+ * from a short page: a backend is free to return fewer rows than asked.
22675
+ */
22676
+ nextCursor: number().int().nonnegative().nullable()
22677
+ });
22300
22678
  var VectorStatsInputSchema = object({ index: string() });
22301
22679
  var VectorStatsResultSchema = object({
22302
22680
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -22315,7 +22693,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
22315
22693
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
22316
22694
  kind: "mutation",
22317
22695
  auth: "admin"
22318
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22696
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22319
22697
  kind: "mutation",
22320
22698
  auth: "admin"
22321
22699
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28942,6 +29320,9 @@ method(object({
28942
29320
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28943
29321
  kind: "query",
28944
29322
  auth: "admin"
29323
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
29324
+ kind: "query",
29325
+ auth: "admin"
28945
29326
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28946
29327
  kind: "mutation",
28947
29328
  auth: "admin"
@@ -35576,6 +35957,18 @@ Object.freeze({
35576
35957
  addonId: null,
35577
35958
  access: "create"
35578
35959
  },
35960
+ "pipelineAnalytics.countRelocatableMedia": {
35961
+ capName: "pipeline-analytics",
35962
+ capScope: "device",
35963
+ addonId: null,
35964
+ access: "view"
35965
+ },
35966
+ "pipelineAnalytics.countUnstampedEventMedia": {
35967
+ capName: "pipeline-analytics",
35968
+ capScope: "device",
35969
+ addonId: null,
35970
+ access: "view"
35971
+ },
35579
35972
  "pipelineAnalytics.deleteDeviceEvents": {
35580
35973
  capName: "pipeline-analytics",
35581
35974
  capScope: "device",
@@ -36734,6 +37127,12 @@ Object.freeze({
36734
37127
  addonId: null,
36735
37128
  access: "view"
36736
37129
  },
37130
+ "recording.getRelocateResidue": {
37131
+ capName: "recording",
37132
+ capScope: "system",
37133
+ addonId: null,
37134
+ access: "view"
37135
+ },
36737
37136
  "recording.getStorageMigrationMoveStatus": {
36738
37137
  capName: "recording",
36739
37138
  capScope: "system",
@@ -37280,12 +37679,30 @@ Object.freeze({
37280
37679
  addonId: null,
37281
37680
  access: "create"
37282
37681
  },
37682
+ "storageMigration.drain": {
37683
+ capName: "storage-migration",
37684
+ capScope: "system",
37685
+ addonId: null,
37686
+ access: "create"
37687
+ },
37688
+ "storageMigration.movers": {
37689
+ capName: "storage-migration",
37690
+ capScope: "system",
37691
+ addonId: null,
37692
+ access: "view"
37693
+ },
37283
37694
  "storageMigration.plan": {
37284
37695
  capName: "storage-migration",
37285
37696
  capScope: "system",
37286
37697
  addonId: null,
37287
37698
  access: "view"
37288
37699
  },
37700
+ "storageMigration.residue": {
37701
+ capName: "storage-migration",
37702
+ capScope: "system",
37703
+ addonId: null,
37704
+ access: "view"
37705
+ },
37289
37706
  "storageMigration.start": {
37290
37707
  capName: "storage-migration",
37291
37708
  capScope: "system",
@@ -38120,6 +38537,12 @@ Object.freeze({
38120
38537
  addonId: null,
38121
38538
  access: "delete"
38122
38539
  },
38540
+ "vectorStore.fetchByIds": {
38541
+ capName: "vector-store",
38542
+ capScope: "system",
38543
+ addonId: null,
38544
+ access: "view"
38545
+ },
38123
38546
  "vectorStore.getByIds": {
38124
38547
  capName: "vector-store",
38125
38548
  capScope: "system",
@@ -38132,6 +38555,12 @@ Object.freeze({
38132
38555
  addonId: null,
38133
38556
  access: "view"
38134
38557
  },
38558
+ "vectorStore.scan": {
38559
+ capName: "vector-store",
38560
+ capScope: "system",
38561
+ addonId: null,
38562
+ access: "view"
38563
+ },
38135
38564
  "vectorStore.stats": {
38136
38565
  capName: "vector-store",
38137
38566
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -8858,18 +8858,61 @@ var RelocateFootageInputSchema = object({
8858
8858
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8859
8859
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8860
8860
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8861
+ /**
8862
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8863
+ * mover (the engine already walks both collections with a timestamp cursor and
8864
+ * already has a stamp-without-copy path).
8865
+ *
8866
+ * - `move` — the default and the historical behaviour: event-media and
8867
+ * retrain blobs move to `toLocationId` and their rows are
8868
+ * stamped. The enrolled gallery is skipped (D197).
8869
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8870
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8871
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8872
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8873
+ * instant a repoint moves that pointer the row reads from the
8874
+ * new disk while its bytes are on the old one.
8875
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8876
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8877
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8878
+ * never run beside a live second location: it is stop-the-world
8879
+ * by construction, which is acceptable only because the gallery
8880
+ * is a few KB per enrolled sample.
8881
+ */
8882
+ var MediaRelocateModeSchema = _enum([
8883
+ "move",
8884
+ "seal",
8885
+ "gallery"
8886
+ ]);
8861
8887
  var RelocateMediaInputSchema = object({
8862
8888
  toLocationId: string(),
8863
- throttleMbps: number().min(1).max(1e3).optional()
8889
+ throttleMbps: number().min(1).max(1e3).optional(),
8890
+ /** Omitted = `move`, the pre-existing behaviour. */
8891
+ mode: MediaRelocateModeSchema.optional()
8892
+ });
8893
+ /** How many rows still carry NO `locationId` — the population a repoint would
8894
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8895
+ * value that permits a non-blocking `eventMedia` cutover. */
8896
+ var UnstampedEventMediaCountSchema = object({
8897
+ media: number().int().nonnegative(),
8898
+ retrainFrames: number().int().nonnegative(),
8899
+ total: number().int().nonnegative()
8864
8900
  });
8865
8901
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8866
- /** The independently selectable logical storage classes. `recordings`
8867
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8868
- * segments; `eventMedia` is post-analysis blobs. */
8902
+ /** The independently selectable logical storage classes — every class
8903
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8904
+ * Zod enum error where they should meet an explanation.
8905
+ *
8906
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8907
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8908
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8909
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8869
8910
  var StorageMigrationClassSchema = _enum([
8870
8911
  "recordings",
8871
8912
  "recordingsLow",
8872
- "eventMedia"
8913
+ "eventMedia",
8914
+ "backups",
8915
+ "galleryMedia"
8873
8916
  ]);
8874
8917
  /** A destination is always an existing, fully-qualified location id. The
8875
8918
  * migration API intentionally never changes a source location's `basePath`:
@@ -8877,20 +8920,56 @@ var StorageMigrationClassSchema = _enum([
8877
8920
  var StorageMigrationDestinationsSchema = object({
8878
8921
  recordings: string().min(1).optional(),
8879
8922
  recordingsLow: string().min(1).optional(),
8880
- eventMedia: string().min(1).optional()
8923
+ eventMedia: string().min(1).optional(),
8924
+ backups: string().min(1).optional(),
8925
+ galleryMedia: string().min(1).optional()
8881
8926
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8927
+ /**
8928
+ * How a migration sequences the cutover against the byte move.
8929
+ *
8930
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8931
+ * resume. Recording is stopped for the whole move. Right
8932
+ * for a small or a cold class, and the only legal mode for
8933
+ * a `cardinality: 'single'` class.
8934
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8935
+ * refresh, resume, then move the past with everything
8936
+ * running. The pause is three bounded instants (a detach +
8937
+ * attach round, a write-gate drain, a lease) instead of one
8938
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8939
+ * stopped recording under `blocking`; the same move is
8940
+ * seconds of stopped recording under `nonBlocking`.
8941
+ *
8942
+ * The mode is on the JOB, not only on the input, because `status` is where an
8943
+ * operator finds out which one is running.
8944
+ */
8945
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8882
8946
  /** Shared input for planning and starting an orchestrated storage migration. */
8883
8947
  var StorageMigrationInputSchema = object({
8884
8948
  destinations: StorageMigrationDestinationsSchema,
8885
- throttleMbps: number().min(1).max(1e3).optional()
8949
+ throttleMbps: number().min(1).max(1e3).optional(),
8950
+ /** Omitted = `blocking`, which stays the default. */
8951
+ mode: StorageMigrationModeSchema.optional()
8886
8952
  });
8887
- /** The durable coordinator state machine. The only phase that changes default
8888
- * locations is `repointing`, after every selected mover has completed and been
8889
- * verified. */
8953
+ /**
8954
+ * The durable coordinator state machine.
8955
+ *
8956
+ * `blocking`:
8957
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8958
+ *
8959
+ * `nonBlocking`:
8960
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8961
+ *
8962
+ * Same phases, different order plus two new ones — not a second mover.
8963
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8964
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8965
+ * `repointing` is still the only phase that changes a default location.
8966
+ */
8890
8967
  var StorageMigrationPhaseSchema = _enum([
8891
8968
  "planning",
8969
+ "sealing",
8892
8970
  "pausing",
8893
8971
  "moving",
8972
+ "draining",
8894
8973
  "verifying",
8895
8974
  "repointing",
8896
8975
  "refreshing",
@@ -8904,17 +8983,56 @@ var StorageMigrationParticipantSchema = _enum([
8904
8983
  "recorder",
8905
8984
  "analytics"
8906
8985
  ]);
8986
+ /**
8987
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8988
+ *
8989
+ * The long half of a non-blocking migration is `draining`, and it is measured
8990
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8991
+ * existed the only place those numbers appeared was a Loki line, so an operator
8992
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8993
+ * afternoon.
8994
+ *
8995
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8996
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8997
+ * mover — which is the exact failure this is meant to end. The coordinator's
8998
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8999
+ * read `state`; folding the counters costs no extra read and makes the durable
9000
+ * record say afterwards how far a move actually got.
9001
+ *
9002
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
9003
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
9004
+ * cannot say M, and a 0 there would render as "100 % done".
9005
+ */
9006
+ var StorageMigrationMoveProgressSchema = object({
9007
+ filesMoved: number().int().nonnegative(),
9008
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
9009
+ filesTotal: number().int().nonnegative().nullable(),
9010
+ bytesMoved: number().int().nonnegative(),
9011
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
9012
+ * crash gets a new mover, and a rate computed from the migration's start
9013
+ * would silently average in the time nothing was running. */
9014
+ startedAt: number(),
9015
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
9016
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
9017
+ * subtract its own. */
9018
+ observedAt: number()
9019
+ });
8907
9020
  var StorageMigrationMoveSchema = object({
8908
9021
  storageClass: StorageMigrationClassSchema,
8909
9022
  fromLocationId: string(),
8910
9023
  toLocationId: string(),
8911
9024
  moverJobId: string().nullable(),
8912
9025
  state: RelocateJobStateSchema.nullable(),
8913
- error: string().nullable()
9026
+ error: string().nullable(),
9027
+ /** Last observed mover counters; `null` until the mover has been polled once. */
9028
+ progress: StorageMigrationMoveProgressSchema.nullable()
8914
9029
  });
8915
9030
  var StorageMigrationJobSchema = object({
8916
9031
  jobId: string(),
8917
9032
  phase: StorageMigrationPhaseSchema,
9033
+ /** Which order this job is running. `status` is the only place an operator
9034
+ * can tell a seconds-long cutover from a thirty-hour one. */
9035
+ mode: StorageMigrationModeSchema,
8918
9036
  destinations: StorageMigrationDestinationsSchema,
8919
9037
  throttleMbps: number(),
8920
9038
  moves: array(StorageMigrationMoveSchema),
@@ -8927,13 +9045,122 @@ var StorageMigrationJobSchema = object({
8927
9045
  finishedAt: number().nullable(),
8928
9046
  error: string().nullable()
8929
9047
  });
9048
+ var StorageMigrationFindingSchema = object({
9049
+ code: _enum([
9050
+ "sharesDeviceWithSource",
9051
+ "deviceIdentityUnknown",
9052
+ "unstampedEventMediaRows",
9053
+ "blockingOnly",
9054
+ "noMover"
9055
+ ]),
9056
+ storageClass: StorageMigrationClassSchema,
9057
+ /** Human-readable, already carrying the ids and counts. */
9058
+ message: string()
9059
+ });
8930
9060
  var StorageMigrationPlanSchema = object({
8931
9061
  destinations: StorageMigrationDestinationsSchema,
9062
+ /** The mode this plan was built for. A plan is only valid for its mode: the
9063
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
9064
+ * it. */
9065
+ mode: StorageMigrationModeSchema,
8932
9066
  moves: array(object({
8933
9067
  storageClass: StorageMigrationClassSchema,
8934
9068
  fromLocationId: string(),
8935
9069
  toLocationId: string()
8936
- }))
9070
+ })),
9071
+ findings: array(StorageMigrationFindingSchema)
9072
+ });
9073
+ /**
9074
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
9075
+ *
9076
+ * The coordinator's job record is the state of record for a migration, and its
9077
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
9078
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
9079
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
9080
+ * way because no supported UI path existed. A mover armed like that has no job
9081
+ * to fold progress into, so it has to be readable on its own or it is invisible.
9082
+ *
9083
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
9084
+ * orchestrated it.
9085
+ */
9086
+ var StorageMigrationMoverSchema = object({
9087
+ lane: _enum(["footage", "media"]),
9088
+ job: RelocateJobSchema,
9089
+ /** The coordinator job that armed this mover, or `null` for a mover armed
9090
+ * directly against the owning addon. */
9091
+ migrationJobId: string().nullable(),
9092
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
9093
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
9094
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
9095
+ * rate made of two different clocks. */
9096
+ observedAt: number()
9097
+ });
9098
+ /**
9099
+ * What a SOURCE still holds for one storage class — the number that makes a
9100
+ * "drain remaining" action honest rather than hopeful.
9101
+ *
9102
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
9103
+ * engine's own selection count for media), never from the resident index: a
9104
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
9105
+ * never been told about (D295).
9106
+ *
9107
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
9108
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
9109
+ * because refusing on an unanswerable read would hide exactly the case an
9110
+ * operator needs to act on.
9111
+ */
9112
+ var StorageMigrationResidueSchema = object({
9113
+ storageClass: StorageMigrationClassSchema,
9114
+ /** The location still holding the data. `'*'` for the media lane, whose rows
9115
+ * move from wherever they are rather than from one named source. */
9116
+ fromLocationId: string(),
9117
+ /** Where a drain would move it — the class's CURRENT default. */
9118
+ toLocationId: string(),
9119
+ /** Segments (footage lane) or rows (media lane) still on the source. */
9120
+ items: number().int().nonnegative().nullable(),
9121
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
9122
+ bytes: number().int().nonnegative().nullable()
9123
+ });
9124
+ /**
9125
+ * Run the DRAIN half and nothing else.
9126
+ *
9127
+ * A migration that reached `done` has already repointed, so `start` correctly
9128
+ * refuses its destination ("already the default") — there is nothing left to
9129
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
9130
+ * or finish against a work list that was a tenth of the archive (D295), and
9131
+ * before this there was no supported way to run only that half: the only way
9132
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
9133
+ *
9134
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
9135
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
9136
+ * re-repoint a class that is already migrated.
9137
+ */
9138
+ var StorageMigrationDrainInputSchema = object({
9139
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
9140
+ * a class whose source is already empty is refused rather than started. */
9141
+ classes: array(StorageMigrationClassSchema).min(1),
9142
+ throttleMbps: number().min(1).max(1e3).optional()
9143
+ });
9144
+ /** What a footage source still holds, asked of the durable hour ledger. */
9145
+ var RelocateResidueInputSchema = object({
9146
+ fromLocationId: string().min(1),
9147
+ /** Narrow to one logical class; omit for every profile on the location. */
9148
+ footageClass: RelocateFootageClassSchema.optional()
9149
+ });
9150
+ /** `null` = the archive could not answer (no ledger on this node, or the
9151
+ * aggregate failed). Never conflated with an empty source. */
9152
+ var RelocateResidueSchema = object({
9153
+ segments: number().int().nonnegative(),
9154
+ bytes: number().int().nonnegative()
9155
+ }).nullable();
9156
+ /** How many rows a media pass would still act on against a given target — the
9157
+ * media lane's denominator AND its residue, from ONE derivation so the two can
9158
+ * never disagree. `null` = the count could not be taken. */
9159
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
9160
+ var RelocatableMediaCountInputSchema = object({
9161
+ toLocationId: string().min(1),
9162
+ /** Omitted = `move`. */
9163
+ mode: MediaRelocateModeSchema.optional()
8937
9164
  });
8938
9165
  /**
8939
9166
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -9039,6 +9266,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
9039
9266
  * two addons declaring the same `id` must agree on `cardinality` (validated
9040
9267
  * at kernel aggregation time, not here).
9041
9268
  */
9269
+ /**
9270
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
9271
+ * actually reaches the bytes. It is the constraint that decides which
9272
+ * `storage-provider`s may back a location of that kind.
9273
+ *
9274
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
9275
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
9276
+ * post-analysis media roots). Only a provider that serves a genuine local
9277
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
9278
+ * remote provider's `resolve` returns a path on the REMOTE host, and
9279
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
9280
+ * against a same-named local directory that is something else entirely.
9281
+ *
9282
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
9283
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
9284
+ * service never sees a path, so any provider can back it. `backups` is the
9285
+ * one kind that qualifies today.
9286
+ *
9287
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
9288
+ * an EMERGENT property of how the recorder happened to be written. Nothing
9289
+ * refused the configuration; the first write simply went somewhere wrong, and
9290
+ * a recording write that goes wrong surfaces as a silent black window rather
9291
+ * than an error (the read path does not `stat`). This turns that accident into
9292
+ * a declared, enforced, testable refusal.
9293
+ */
9294
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
9042
9295
  var StorageLocationDeclarationSchema = object({
9043
9296
  /**
9044
9297
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -9058,6 +9311,19 @@ var StorageLocationDeclarationSchema = object({
9058
9311
  */
9059
9312
  cardinality: _enum(["single", "multi"]),
9060
9313
  /**
9314
+ * HOW the declaring service reaches the bytes — and therefore WHICH
9315
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
9316
+ * and {@link STORAGE_ACCESS_FALLBACK}.
9317
+ *
9318
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
9319
+ * can only over-restrict (refuse a remote provider for a kind that might
9320
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
9321
+ * permissive direction and is therefore never inferred — a repo guard
9322
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
9323
+ * reached by omission.
9324
+ */
9325
+ access: StorageAccessSchema.optional(),
9326
+ /**
9061
9327
  * When set, the default instance for this location inherits its resolved
9062
9328
  * root from the named location's default instance. Useful for derivative
9063
9329
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18942,8 +19208,10 @@ var TrackSchema = object({
18942
19208
  lastSeen: number(),
18943
19209
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18944
19210
  positions: array(TrackPositionSchema).readonly(),
18945
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18946
- * saveThumbnails policy). */
19211
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
19212
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
19213
+ * the retired `saveThumbnails` used to gate this and the rolling
19214
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18947
19215
  snapshots: array(TrackSnapshotSchema).readonly(),
18948
19216
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18949
19217
  zonesVisited: array(string()).readonly(),
@@ -19803,6 +20071,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19803
20071
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19804
20072
  kind: "mutation",
19805
20073
  auth: "admin"
20074
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
20075
+ kind: "query",
20076
+ auth: "admin"
19806
20077
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19807
20078
  kind: "query",
19808
20079
  auth: "admin"
@@ -21710,7 +21981,10 @@ method(object({
21710
21981
  }), StorageLocationSchema, {
21711
21982
  kind: "mutation",
21712
21983
  auth: "admin"
21713
- }), method(object({ id: string() }), _void(), {
21984
+ }), method(object({
21985
+ id: string(),
21986
+ force: boolean().optional()
21987
+ }), _void(), {
21714
21988
  kind: "mutation",
21715
21989
  auth: "admin"
21716
21990
  }), method(object({ id: string() }), object({
@@ -21759,6 +22033,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21759
22033
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21760
22034
  kind: "mutation",
21761
22035
  auth: "admin"
22036
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
22037
+ kind: "mutation",
22038
+ auth: "admin"
21762
22039
  });
21763
22040
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21764
22041
  providerId: string().min(1),
@@ -22157,12 +22434,38 @@ response: record(string(), unknown()) }), object({
22157
22434
  *
22158
22435
  * ## Why this is a capability and not a helper
22159
22436
  *
22160
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
22161
- * plate, vehicle, identity, and the event store's derivatives — and every one of
22162
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
22163
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
22164
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
22165
- * load 5,000 rows before ranking anything.
22437
+ * This capability was introduced with the claim that SIX stores in
22438
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
22439
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22440
+ * claim was never true, and leaving it here made five stores look like pending
22441
+ * work when three of them have no vector at all. Counted column by column on
22442
+ * 2026-08-30, exactly THREE ever held one:
22443
+ *
22444
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22445
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22446
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22447
+ * face, migrated 2026-08-30 into its OWN index (see below).
22448
+ *
22449
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22450
+ * and `identities` store a name; the event store stores no derivative vector.
22451
+ * They are not migration candidates and never were.
22452
+ *
22453
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22454
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22455
+ * rows before ranking anything.
22456
+ *
22457
+ * ## One index per COMPARISON, never per encoder
22458
+ *
22459
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22460
+ * model, and they still get two indexes. An index is a set of things that are
22461
+ * ranked against each other and that live and die together, and these two are
22462
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22463
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22464
+ * forever and is the gallery every recognition ranks against. One index would
22465
+ * mean every gallery load and every reconcile carried a filter whose failure
22466
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22467
+ * person's only sample. The dimension they share is not a reason to share an
22468
+ * index; the question they answer is, and it differs.
22166
22469
  *
22167
22470
  * The fix is not a faster loop, it is a different backend — and the backend
22168
22471
  * should be replaceable without touching six callers. So: a singleton
@@ -22267,7 +22570,20 @@ var VectorQueryResultSchema = object({
22267
22570
  */
22268
22571
  scanned: number(),
22269
22572
  /** True when the backend could not consider every row that passed the filter. */
22270
- truncated: boolean()
22573
+ truncated: boolean(),
22574
+ /**
22575
+ * The `topK` the backend actually ran with.
22576
+ *
22577
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22578
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22579
+ * own log rather than in its answer. That is how an audit asking for 20,000
22580
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22581
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22582
+ * MUCH, in the return value, where the caller cannot fail to see it.
22583
+ *
22584
+ * Equals the requested `topK` whenever nothing was lowered.
22585
+ */
22586
+ effectiveTopK: number().int().positive()
22271
22587
  });
22272
22588
  var VectorDeleteInputSchema = object({
22273
22589
  index: string(),
@@ -22296,6 +22612,68 @@ var VectorGetResultSchema = object({ items: array(object({
22296
22612
  id: string(),
22297
22613
  metadata: VectorMetadataSchema
22298
22614
  })) });
22615
+ /**
22616
+ * Ids to read back WITH their vectors.
22617
+ *
22618
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22619
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22620
+ * caller depends on that promise. This one promises the opposite.
22621
+ *
22622
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22623
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22624
+ * a per-face cross-process KNN would be a network round trip inside the
22625
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22626
+ * it requires the index to hand the floats back. Without this method the only
22627
+ * way to keep a readable vector is a JSON column, which is the thing this
22628
+ * capability exists to delete.
22629
+ *
22630
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22631
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22632
+ */
22633
+ var VectorFetchInputSchema = object({
22634
+ index: string(),
22635
+ ids: array(string())
22636
+ });
22637
+ var VectorFetchResultSchema = object({ items: array(object({
22638
+ id: string(),
22639
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22640
+ vector: string(),
22641
+ metadata: VectorMetadataSchema
22642
+ })) });
22643
+ /**
22644
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22645
+ *
22646
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22647
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22648
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22649
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22650
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22651
+ * looked" for as long as anyone cared to read it.
22652
+ *
22653
+ * This is the primitive that question actually needs: a bounded page, ordered
22654
+ * by the backend's own row order, costing no distance computation at all.
22655
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22656
+ * the full-table read this capability was built to stop.
22657
+ */
22658
+ var VectorScanInputSchema = object({
22659
+ index: string(),
22660
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22661
+ cursor: number().int().nonnegative().default(0),
22662
+ limit: number().int().positive()
22663
+ });
22664
+ var VectorScanResultSchema = object({
22665
+ items: array(object({
22666
+ id: string(),
22667
+ metadata: VectorMetadataSchema
22668
+ })),
22669
+ /**
22670
+ * Where the next page starts, or `null` when the walk reached the end.
22671
+ *
22672
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22673
+ * from a short page: a backend is free to return fewer rows than asked.
22674
+ */
22675
+ nextCursor: number().int().nonnegative().nullable()
22676
+ });
22299
22677
  var VectorStatsInputSchema = object({ index: string() });
22300
22678
  var VectorStatsResultSchema = object({
22301
22679
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -22314,7 +22692,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
22314
22692
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
22315
22693
  kind: "mutation",
22316
22694
  auth: "admin"
22317
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22695
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22318
22696
  kind: "mutation",
22319
22697
  auth: "admin"
22320
22698
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -28941,6 +29319,9 @@ method(object({
28941
29319
  }), method(object({}), array(RelocateJobSchema).readonly(), {
28942
29320
  kind: "query",
28943
29321
  auth: "admin"
29322
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
29323
+ kind: "query",
29324
+ auth: "admin"
28944
29325
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
28945
29326
  kind: "mutation",
28946
29327
  auth: "admin"
@@ -35575,6 +35956,18 @@ Object.freeze({
35575
35956
  addonId: null,
35576
35957
  access: "create"
35577
35958
  },
35959
+ "pipelineAnalytics.countRelocatableMedia": {
35960
+ capName: "pipeline-analytics",
35961
+ capScope: "device",
35962
+ addonId: null,
35963
+ access: "view"
35964
+ },
35965
+ "pipelineAnalytics.countUnstampedEventMedia": {
35966
+ capName: "pipeline-analytics",
35967
+ capScope: "device",
35968
+ addonId: null,
35969
+ access: "view"
35970
+ },
35578
35971
  "pipelineAnalytics.deleteDeviceEvents": {
35579
35972
  capName: "pipeline-analytics",
35580
35973
  capScope: "device",
@@ -36733,6 +37126,12 @@ Object.freeze({
36733
37126
  addonId: null,
36734
37127
  access: "view"
36735
37128
  },
37129
+ "recording.getRelocateResidue": {
37130
+ capName: "recording",
37131
+ capScope: "system",
37132
+ addonId: null,
37133
+ access: "view"
37134
+ },
36736
37135
  "recording.getStorageMigrationMoveStatus": {
36737
37136
  capName: "recording",
36738
37137
  capScope: "system",
@@ -37279,12 +37678,30 @@ Object.freeze({
37279
37678
  addonId: null,
37280
37679
  access: "create"
37281
37680
  },
37681
+ "storageMigration.drain": {
37682
+ capName: "storage-migration",
37683
+ capScope: "system",
37684
+ addonId: null,
37685
+ access: "create"
37686
+ },
37687
+ "storageMigration.movers": {
37688
+ capName: "storage-migration",
37689
+ capScope: "system",
37690
+ addonId: null,
37691
+ access: "view"
37692
+ },
37282
37693
  "storageMigration.plan": {
37283
37694
  capName: "storage-migration",
37284
37695
  capScope: "system",
37285
37696
  addonId: null,
37286
37697
  access: "view"
37287
37698
  },
37699
+ "storageMigration.residue": {
37700
+ capName: "storage-migration",
37701
+ capScope: "system",
37702
+ addonId: null,
37703
+ access: "view"
37704
+ },
37288
37705
  "storageMigration.start": {
37289
37706
  capName: "storage-migration",
37290
37707
  capScope: "system",
@@ -38119,6 +38536,12 @@ Object.freeze({
38119
38536
  addonId: null,
38120
38537
  access: "delete"
38121
38538
  },
38539
+ "vectorStore.fetchByIds": {
38540
+ capName: "vector-store",
38541
+ capScope: "system",
38542
+ addonId: null,
38543
+ access: "view"
38544
+ },
38122
38545
  "vectorStore.getByIds": {
38123
38546
  capName: "vector-store",
38124
38547
  capScope: "system",
@@ -38131,6 +38554,12 @@ Object.freeze({
38131
38554
  addonId: null,
38132
38555
  access: "view"
38133
38556
  },
38557
+ "vectorStore.scan": {
38558
+ capName: "vector-store",
38559
+ capScope: "system",
38560
+ addonId: null,
38561
+ access: "view"
38562
+ },
38134
38563
  "vectorStore.stats": {
38135
38564
  capName: "vector-store",
38136
38565
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-tuya",
3
- "version": "0.2.42",
3
+ "version": "0.2.45",
4
4
  "description": "Tuya / Smart Life device-provider addon for CamStack — account-onboarded (Tuya IoT cloud fetch of device localKeys) + LOCAL DP control via the @apocaliss92/nodetuya encrypted-LAN client, exposing switch / water-heater-family kettle entities",
5
5
  "keywords": [
6
6
  "camstack",