@camstack/addon-export-hap 1.2.53 → 1.2.56

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.
@@ -8705,18 +8705,61 @@ var RelocateFootageInputSchema = object({
8705
8705
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8706
8706
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8707
8707
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8708
+ /**
8709
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8710
+ * mover (the engine already walks both collections with a timestamp cursor and
8711
+ * already has a stamp-without-copy path).
8712
+ *
8713
+ * - `move` — the default and the historical behaviour: event-media and
8714
+ * retrain blobs move to `toLocationId` and their rows are
8715
+ * stamped. The enrolled gallery is skipped (D197).
8716
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8717
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8718
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8719
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8720
+ * instant a repoint moves that pointer the row reads from the
8721
+ * new disk while its bytes are on the old one.
8722
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8723
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8724
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8725
+ * never run beside a live second location: it is stop-the-world
8726
+ * by construction, which is acceptable only because the gallery
8727
+ * is a few KB per enrolled sample.
8728
+ */
8729
+ var MediaRelocateModeSchema = _enum([
8730
+ "move",
8731
+ "seal",
8732
+ "gallery"
8733
+ ]);
8708
8734
  var RelocateMediaInputSchema = object({
8709
8735
  toLocationId: string(),
8710
- throttleMbps: number().min(1).max(1e3).optional()
8736
+ throttleMbps: number().min(1).max(1e3).optional(),
8737
+ /** Omitted = `move`, the pre-existing behaviour. */
8738
+ mode: MediaRelocateModeSchema.optional()
8739
+ });
8740
+ /** How many rows still carry NO `locationId` — the population a repoint would
8741
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8742
+ * value that permits a non-blocking `eventMedia` cutover. */
8743
+ var UnstampedEventMediaCountSchema = object({
8744
+ media: number().int().nonnegative(),
8745
+ retrainFrames: number().int().nonnegative(),
8746
+ total: number().int().nonnegative()
8711
8747
  });
8712
8748
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8713
- /** The independently selectable logical storage classes. `recordings`
8714
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8715
- * segments; `eventMedia` is post-analysis blobs. */
8749
+ /** The independently selectable logical storage classes — every class
8750
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8751
+ * Zod enum error where they should meet an explanation.
8752
+ *
8753
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8754
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8755
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8756
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8716
8757
  var StorageMigrationClassSchema = _enum([
8717
8758
  "recordings",
8718
8759
  "recordingsLow",
8719
- "eventMedia"
8760
+ "eventMedia",
8761
+ "backups",
8762
+ "galleryMedia"
8720
8763
  ]);
8721
8764
  /** A destination is always an existing, fully-qualified location id. The
8722
8765
  * migration API intentionally never changes a source location's `basePath`:
@@ -8724,20 +8767,56 @@ var StorageMigrationClassSchema = _enum([
8724
8767
  var StorageMigrationDestinationsSchema = object({
8725
8768
  recordings: string().min(1).optional(),
8726
8769
  recordingsLow: string().min(1).optional(),
8727
- eventMedia: string().min(1).optional()
8770
+ eventMedia: string().min(1).optional(),
8771
+ backups: string().min(1).optional(),
8772
+ galleryMedia: string().min(1).optional()
8728
8773
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8774
+ /**
8775
+ * How a migration sequences the cutover against the byte move.
8776
+ *
8777
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8778
+ * resume. Recording is stopped for the whole move. Right
8779
+ * for a small or a cold class, and the only legal mode for
8780
+ * a `cardinality: 'single'` class.
8781
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8782
+ * refresh, resume, then move the past with everything
8783
+ * running. The pause is three bounded instants (a detach +
8784
+ * attach round, a write-gate drain, a lease) instead of one
8785
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8786
+ * stopped recording under `blocking`; the same move is
8787
+ * seconds of stopped recording under `nonBlocking`.
8788
+ *
8789
+ * The mode is on the JOB, not only on the input, because `status` is where an
8790
+ * operator finds out which one is running.
8791
+ */
8792
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8729
8793
  /** Shared input for planning and starting an orchestrated storage migration. */
8730
8794
  var StorageMigrationInputSchema = object({
8731
8795
  destinations: StorageMigrationDestinationsSchema,
8732
- throttleMbps: number().min(1).max(1e3).optional()
8796
+ throttleMbps: number().min(1).max(1e3).optional(),
8797
+ /** Omitted = `blocking`, which stays the default. */
8798
+ mode: StorageMigrationModeSchema.optional()
8733
8799
  });
8734
- /** The durable coordinator state machine. The only phase that changes default
8735
- * locations is `repointing`, after every selected mover has completed and been
8736
- * verified. */
8800
+ /**
8801
+ * The durable coordinator state machine.
8802
+ *
8803
+ * `blocking`:
8804
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8805
+ *
8806
+ * `nonBlocking`:
8807
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8808
+ *
8809
+ * Same phases, different order plus two new ones — not a second mover.
8810
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8811
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8812
+ * `repointing` is still the only phase that changes a default location.
8813
+ */
8737
8814
  var StorageMigrationPhaseSchema = _enum([
8738
8815
  "planning",
8816
+ "sealing",
8739
8817
  "pausing",
8740
8818
  "moving",
8819
+ "draining",
8741
8820
  "verifying",
8742
8821
  "repointing",
8743
8822
  "refreshing",
@@ -8751,17 +8830,56 @@ var StorageMigrationParticipantSchema = _enum([
8751
8830
  "recorder",
8752
8831
  "analytics"
8753
8832
  ]);
8833
+ /**
8834
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8835
+ *
8836
+ * The long half of a non-blocking migration is `draining`, and it is measured
8837
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8838
+ * existed the only place those numbers appeared was a Loki line, so an operator
8839
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8840
+ * afternoon.
8841
+ *
8842
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8843
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8844
+ * mover — which is the exact failure this is meant to end. The coordinator's
8845
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8846
+ * read `state`; folding the counters costs no extra read and makes the durable
8847
+ * record say afterwards how far a move actually got.
8848
+ *
8849
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8850
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8851
+ * cannot say M, and a 0 there would render as "100 % done".
8852
+ */
8853
+ var StorageMigrationMoveProgressSchema = object({
8854
+ filesMoved: number().int().nonnegative(),
8855
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8856
+ filesTotal: number().int().nonnegative().nullable(),
8857
+ bytesMoved: number().int().nonnegative(),
8858
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8859
+ * crash gets a new mover, and a rate computed from the migration's start
8860
+ * would silently average in the time nothing was running. */
8861
+ startedAt: number(),
8862
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8863
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8864
+ * subtract its own. */
8865
+ observedAt: number()
8866
+ });
8754
8867
  var StorageMigrationMoveSchema = object({
8755
8868
  storageClass: StorageMigrationClassSchema,
8756
8869
  fromLocationId: string(),
8757
8870
  toLocationId: string(),
8758
8871
  moverJobId: string().nullable(),
8759
8872
  state: RelocateJobStateSchema.nullable(),
8760
- error: string().nullable()
8873
+ error: string().nullable(),
8874
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8875
+ progress: StorageMigrationMoveProgressSchema.nullable()
8761
8876
  });
8762
8877
  var StorageMigrationJobSchema = object({
8763
8878
  jobId: string(),
8764
8879
  phase: StorageMigrationPhaseSchema,
8880
+ /** Which order this job is running. `status` is the only place an operator
8881
+ * can tell a seconds-long cutover from a thirty-hour one. */
8882
+ mode: StorageMigrationModeSchema,
8765
8883
  destinations: StorageMigrationDestinationsSchema,
8766
8884
  throttleMbps: number(),
8767
8885
  moves: array(StorageMigrationMoveSchema),
@@ -8774,13 +8892,122 @@ var StorageMigrationJobSchema = object({
8774
8892
  finishedAt: number().nullable(),
8775
8893
  error: string().nullable()
8776
8894
  });
8895
+ var StorageMigrationFindingSchema = object({
8896
+ code: _enum([
8897
+ "sharesDeviceWithSource",
8898
+ "deviceIdentityUnknown",
8899
+ "unstampedEventMediaRows",
8900
+ "blockingOnly",
8901
+ "noMover"
8902
+ ]),
8903
+ storageClass: StorageMigrationClassSchema,
8904
+ /** Human-readable, already carrying the ids and counts. */
8905
+ message: string()
8906
+ });
8777
8907
  var StorageMigrationPlanSchema = object({
8778
8908
  destinations: StorageMigrationDestinationsSchema,
8909
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8910
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8911
+ * it. */
8912
+ mode: StorageMigrationModeSchema,
8779
8913
  moves: array(object({
8780
8914
  storageClass: StorageMigrationClassSchema,
8781
8915
  fromLocationId: string(),
8782
8916
  toLocationId: string()
8783
- }))
8917
+ })),
8918
+ findings: array(StorageMigrationFindingSchema)
8919
+ });
8920
+ /**
8921
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8922
+ *
8923
+ * The coordinator's job record is the state of record for a migration, and its
8924
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8925
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8926
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8927
+ * way because no supported UI path existed. A mover armed like that has no job
8928
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8929
+ *
8930
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8931
+ * orchestrated it.
8932
+ */
8933
+ var StorageMigrationMoverSchema = object({
8934
+ lane: _enum(["footage", "media"]),
8935
+ job: RelocateJobSchema,
8936
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8937
+ * directly against the owning addon. */
8938
+ migrationJobId: string().nullable(),
8939
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8940
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8941
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8942
+ * rate made of two different clocks. */
8943
+ observedAt: number()
8944
+ });
8945
+ /**
8946
+ * What a SOURCE still holds for one storage class — the number that makes a
8947
+ * "drain remaining" action honest rather than hopeful.
8948
+ *
8949
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8950
+ * engine's own selection count for media), never from the resident index: a
8951
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8952
+ * never been told about (D295).
8953
+ *
8954
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8955
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8956
+ * because refusing on an unanswerable read would hide exactly the case an
8957
+ * operator needs to act on.
8958
+ */
8959
+ var StorageMigrationResidueSchema = object({
8960
+ storageClass: StorageMigrationClassSchema,
8961
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8962
+ * move from wherever they are rather than from one named source. */
8963
+ fromLocationId: string(),
8964
+ /** Where a drain would move it — the class's CURRENT default. */
8965
+ toLocationId: string(),
8966
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8967
+ items: number().int().nonnegative().nullable(),
8968
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8969
+ bytes: number().int().nonnegative().nullable()
8970
+ });
8971
+ /**
8972
+ * Run the DRAIN half and nothing else.
8973
+ *
8974
+ * A migration that reached `done` has already repointed, so `start` correctly
8975
+ * refuses its destination ("already the default") — there is nothing left to
8976
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8977
+ * or finish against a work list that was a tenth of the archive (D295), and
8978
+ * before this there was no supported way to run only that half: the only way
8979
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8980
+ *
8981
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8982
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8983
+ * re-repoint a class that is already migrated.
8984
+ */
8985
+ var StorageMigrationDrainInputSchema = object({
8986
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8987
+ * a class whose source is already empty is refused rather than started. */
8988
+ classes: array(StorageMigrationClassSchema).min(1),
8989
+ throttleMbps: number().min(1).max(1e3).optional()
8990
+ });
8991
+ /** What a footage source still holds, asked of the durable hour ledger. */
8992
+ var RelocateResidueInputSchema = object({
8993
+ fromLocationId: string().min(1),
8994
+ /** Narrow to one logical class; omit for every profile on the location. */
8995
+ footageClass: RelocateFootageClassSchema.optional()
8996
+ });
8997
+ /** `null` = the archive could not answer (no ledger on this node, or the
8998
+ * aggregate failed). Never conflated with an empty source. */
8999
+ var RelocateResidueSchema = object({
9000
+ segments: number().int().nonnegative(),
9001
+ bytes: number().int().nonnegative()
9002
+ }).nullable();
9003
+ /** How many rows a media pass would still act on against a given target — the
9004
+ * media lane's denominator AND its residue, from ONE derivation so the two can
9005
+ * never disagree. `null` = the count could not be taken. */
9006
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
9007
+ var RelocatableMediaCountInputSchema = object({
9008
+ toLocationId: string().min(1),
9009
+ /** Omitted = `move`. */
9010
+ mode: MediaRelocateModeSchema.optional()
8784
9011
  });
8785
9012
  /**
8786
9013
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8886,6 +9113,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8886
9113
  * two addons declaring the same `id` must agree on `cardinality` (validated
8887
9114
  * at kernel aggregation time, not here).
8888
9115
  */
9116
+ /**
9117
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
9118
+ * actually reaches the bytes. It is the constraint that decides which
9119
+ * `storage-provider`s may back a location of that kind.
9120
+ *
9121
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
9122
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
9123
+ * post-analysis media roots). Only a provider that serves a genuine local
9124
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
9125
+ * remote provider's `resolve` returns a path on the REMOTE host, and
9126
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
9127
+ * against a same-named local directory that is something else entirely.
9128
+ *
9129
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
9130
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
9131
+ * service never sees a path, so any provider can back it. `backups` is the
9132
+ * one kind that qualifies today.
9133
+ *
9134
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
9135
+ * an EMERGENT property of how the recorder happened to be written. Nothing
9136
+ * refused the configuration; the first write simply went somewhere wrong, and
9137
+ * a recording write that goes wrong surfaces as a silent black window rather
9138
+ * than an error (the read path does not `stat`). This turns that accident into
9139
+ * a declared, enforced, testable refusal.
9140
+ */
9141
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8889
9142
  var StorageLocationDeclarationSchema = object({
8890
9143
  /**
8891
9144
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8905,6 +9158,19 @@ var StorageLocationDeclarationSchema = object({
8905
9158
  */
8906
9159
  cardinality: _enum(["single", "multi"]),
8907
9160
  /**
9161
+ * HOW the declaring service reaches the bytes — and therefore WHICH
9162
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
9163
+ * and {@link STORAGE_ACCESS_FALLBACK}.
9164
+ *
9165
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
9166
+ * can only over-restrict (refuse a remote provider for a kind that might
9167
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
9168
+ * permissive direction and is therefore never inferred — a repo guard
9169
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
9170
+ * reached by omission.
9171
+ */
9172
+ access: StorageAccessSchema.optional(),
9173
+ /**
8908
9174
  * When set, the default instance for this location inherits its resolved
8909
9175
  * root from the named location's default instance. Useful for derivative
8910
9176
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18565,8 +18831,10 @@ var TrackSchema = object({
18565
18831
  lastSeen: number(),
18566
18832
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18567
18833
  positions: array(TrackPositionSchema).readonly(),
18568
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18569
- * saveThumbnails policy). */
18834
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18835
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18836
+ * the retired `saveThumbnails` used to gate this and the rolling
18837
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18570
18838
  snapshots: array(TrackSnapshotSchema).readonly(),
18571
18839
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18572
18840
  zonesVisited: array(string()).readonly(),
@@ -19426,6 +19694,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19426
19694
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19427
19695
  kind: "mutation",
19428
19696
  auth: "admin"
19697
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19698
+ kind: "query",
19699
+ auth: "admin"
19429
19700
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19430
19701
  kind: "query",
19431
19702
  auth: "admin"
@@ -21333,7 +21604,10 @@ method(object({
21333
21604
  }), StorageLocationSchema, {
21334
21605
  kind: "mutation",
21335
21606
  auth: "admin"
21336
- }), method(object({ id: string() }), _void(), {
21607
+ }), method(object({
21608
+ id: string(),
21609
+ force: boolean().optional()
21610
+ }), _void(), {
21337
21611
  kind: "mutation",
21338
21612
  auth: "admin"
21339
21613
  }), method(object({ id: string() }), object({
@@ -21382,6 +21656,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21382
21656
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21383
21657
  kind: "mutation",
21384
21658
  auth: "admin"
21659
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21660
+ kind: "mutation",
21661
+ auth: "admin"
21385
21662
  });
21386
21663
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21387
21664
  providerId: string().min(1),
@@ -21780,12 +22057,38 @@ response: record(string(), unknown()) }), object({
21780
22057
  *
21781
22058
  * ## Why this is a capability and not a helper
21782
22059
  *
21783
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21784
- * plate, vehicle, identity, and the event store's derivativesand every one of
21785
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21786
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21787
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21788
- * load 5,000 rows before ranking anything.
22060
+ * This capability was introduced with the claim that SIX stores in
22061
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
22062
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22063
+ * claim was never true, and leaving it here made five stores look like pending
22064
+ * work when three of them have no vector at all. Counted column by column on
22065
+ * 2026-08-30, exactly THREE ever held one:
22066
+ *
22067
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22068
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22069
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22070
+ * face, migrated 2026-08-30 into its OWN index (see below).
22071
+ *
22072
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22073
+ * and `identities` store a name; the event store stores no derivative vector.
22074
+ * They are not migration candidates and never were.
22075
+ *
22076
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22077
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22078
+ * rows before ranking anything.
22079
+ *
22080
+ * ## One index per COMPARISON, never per encoder
22081
+ *
22082
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22083
+ * model, and they still get two indexes. An index is a set of things that are
22084
+ * ranked against each other and that live and die together, and these two are
22085
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22086
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22087
+ * forever and is the gallery every recognition ranks against. One index would
22088
+ * mean every gallery load and every reconcile carried a filter whose failure
22089
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22090
+ * person's only sample. The dimension they share is not a reason to share an
22091
+ * index; the question they answer is, and it differs.
21789
22092
  *
21790
22093
  * The fix is not a faster loop, it is a different backend — and the backend
21791
22094
  * should be replaceable without touching six callers. So: a singleton
@@ -21890,7 +22193,20 @@ var VectorQueryResultSchema = object({
21890
22193
  */
21891
22194
  scanned: number(),
21892
22195
  /** True when the backend could not consider every row that passed the filter. */
21893
- truncated: boolean()
22196
+ truncated: boolean(),
22197
+ /**
22198
+ * The `topK` the backend actually ran with.
22199
+ *
22200
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22201
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22202
+ * own log rather than in its answer. That is how an audit asking for 20,000
22203
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22204
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22205
+ * MUCH, in the return value, where the caller cannot fail to see it.
22206
+ *
22207
+ * Equals the requested `topK` whenever nothing was lowered.
22208
+ */
22209
+ effectiveTopK: number().int().positive()
21894
22210
  });
21895
22211
  var VectorDeleteInputSchema = object({
21896
22212
  index: string(),
@@ -21919,6 +22235,68 @@ var VectorGetResultSchema = object({ items: array(object({
21919
22235
  id: string(),
21920
22236
  metadata: VectorMetadataSchema
21921
22237
  })) });
22238
+ /**
22239
+ * Ids to read back WITH their vectors.
22240
+ *
22241
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22242
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22243
+ * caller depends on that promise. This one promises the opposite.
22244
+ *
22245
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22246
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22247
+ * a per-face cross-process KNN would be a network round trip inside the
22248
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22249
+ * it requires the index to hand the floats back. Without this method the only
22250
+ * way to keep a readable vector is a JSON column, which is the thing this
22251
+ * capability exists to delete.
22252
+ *
22253
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22254
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22255
+ */
22256
+ var VectorFetchInputSchema = object({
22257
+ index: string(),
22258
+ ids: array(string())
22259
+ });
22260
+ var VectorFetchResultSchema = object({ items: array(object({
22261
+ id: string(),
22262
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22263
+ vector: string(),
22264
+ metadata: VectorMetadataSchema
22265
+ })) });
22266
+ /**
22267
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22268
+ *
22269
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22270
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22271
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22272
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22273
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22274
+ * looked" for as long as anyone cared to read it.
22275
+ *
22276
+ * This is the primitive that question actually needs: a bounded page, ordered
22277
+ * by the backend's own row order, costing no distance computation at all.
22278
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22279
+ * the full-table read this capability was built to stop.
22280
+ */
22281
+ var VectorScanInputSchema = object({
22282
+ index: string(),
22283
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22284
+ cursor: number().int().nonnegative().default(0),
22285
+ limit: number().int().positive()
22286
+ });
22287
+ var VectorScanResultSchema = object({
22288
+ items: array(object({
22289
+ id: string(),
22290
+ metadata: VectorMetadataSchema
22291
+ })),
22292
+ /**
22293
+ * Where the next page starts, or `null` when the walk reached the end.
22294
+ *
22295
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22296
+ * from a short page: a backend is free to return fewer rows than asked.
22297
+ */
22298
+ nextCursor: number().int().nonnegative().nullable()
22299
+ });
21922
22300
  var VectorStatsInputSchema = object({ index: string() });
21923
22301
  var VectorStatsResultSchema = object({
21924
22302
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21937,7 +22315,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21937
22315
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21938
22316
  kind: "mutation",
21939
22317
  auth: "admin"
21940
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22318
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21941
22319
  kind: "mutation",
21942
22320
  auth: "admin"
21943
22321
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -26889,6 +27267,9 @@ method(object({
26889
27267
  }), method(object({}), array(RelocateJobSchema).readonly(), {
26890
27268
  kind: "query",
26891
27269
  auth: "admin"
27270
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
27271
+ kind: "query",
27272
+ auth: "admin"
26892
27273
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26893
27274
  kind: "mutation",
26894
27275
  auth: "admin"
@@ -31879,6 +32260,18 @@ Object.freeze({
31879
32260
  addonId: null,
31880
32261
  access: "create"
31881
32262
  },
32263
+ "pipelineAnalytics.countRelocatableMedia": {
32264
+ capName: "pipeline-analytics",
32265
+ capScope: "device",
32266
+ addonId: null,
32267
+ access: "view"
32268
+ },
32269
+ "pipelineAnalytics.countUnstampedEventMedia": {
32270
+ capName: "pipeline-analytics",
32271
+ capScope: "device",
32272
+ addonId: null,
32273
+ access: "view"
32274
+ },
31882
32275
  "pipelineAnalytics.deleteDeviceEvents": {
31883
32276
  capName: "pipeline-analytics",
31884
32277
  capScope: "device",
@@ -33037,6 +33430,12 @@ Object.freeze({
33037
33430
  addonId: null,
33038
33431
  access: "view"
33039
33432
  },
33433
+ "recording.getRelocateResidue": {
33434
+ capName: "recording",
33435
+ capScope: "system",
33436
+ addonId: null,
33437
+ access: "view"
33438
+ },
33040
33439
  "recording.getStorageMigrationMoveStatus": {
33041
33440
  capName: "recording",
33042
33441
  capScope: "system",
@@ -33583,12 +33982,30 @@ Object.freeze({
33583
33982
  addonId: null,
33584
33983
  access: "create"
33585
33984
  },
33985
+ "storageMigration.drain": {
33986
+ capName: "storage-migration",
33987
+ capScope: "system",
33988
+ addonId: null,
33989
+ access: "create"
33990
+ },
33991
+ "storageMigration.movers": {
33992
+ capName: "storage-migration",
33993
+ capScope: "system",
33994
+ addonId: null,
33995
+ access: "view"
33996
+ },
33586
33997
  "storageMigration.plan": {
33587
33998
  capName: "storage-migration",
33588
33999
  capScope: "system",
33589
34000
  addonId: null,
33590
34001
  access: "view"
33591
34002
  },
34003
+ "storageMigration.residue": {
34004
+ capName: "storage-migration",
34005
+ capScope: "system",
34006
+ addonId: null,
34007
+ access: "view"
34008
+ },
33592
34009
  "storageMigration.start": {
33593
34010
  capName: "storage-migration",
33594
34011
  capScope: "system",
@@ -34423,6 +34840,12 @@ Object.freeze({
34423
34840
  addonId: null,
34424
34841
  access: "delete"
34425
34842
  },
34843
+ "vectorStore.fetchByIds": {
34844
+ capName: "vector-store",
34845
+ capScope: "system",
34846
+ addonId: null,
34847
+ access: "view"
34848
+ },
34426
34849
  "vectorStore.getByIds": {
34427
34850
  capName: "vector-store",
34428
34851
  capScope: "system",
@@ -34435,6 +34858,12 @@ Object.freeze({
34435
34858
  addonId: null,
34436
34859
  access: "view"
34437
34860
  },
34861
+ "vectorStore.scan": {
34862
+ capName: "vector-store",
34863
+ capScope: "system",
34864
+ addonId: null,
34865
+ access: "view"
34866
+ },
34438
34867
  "vectorStore.stats": {
34439
34868
  capName: "vector-store",
34440
34869
  capScope: "system",
@@ -8693,18 +8693,61 @@ var RelocateFootageInputSchema = object({
8693
8693
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8694
8694
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8695
8695
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8696
+ /**
8697
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8698
+ * mover (the engine already walks both collections with a timestamp cursor and
8699
+ * already has a stamp-without-copy path).
8700
+ *
8701
+ * - `move` — the default and the historical behaviour: event-media and
8702
+ * retrain blobs move to `toLocationId` and their rows are
8703
+ * stamped. The enrolled gallery is skipped (D197).
8704
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8705
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8706
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8707
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8708
+ * instant a repoint moves that pointer the row reads from the
8709
+ * new disk while its bytes are on the old one.
8710
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8711
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8712
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8713
+ * never run beside a live second location: it is stop-the-world
8714
+ * by construction, which is acceptable only because the gallery
8715
+ * is a few KB per enrolled sample.
8716
+ */
8717
+ var MediaRelocateModeSchema = _enum([
8718
+ "move",
8719
+ "seal",
8720
+ "gallery"
8721
+ ]);
8696
8722
  var RelocateMediaInputSchema = object({
8697
8723
  toLocationId: string(),
8698
- throttleMbps: number().min(1).max(1e3).optional()
8724
+ throttleMbps: number().min(1).max(1e3).optional(),
8725
+ /** Omitted = `move`, the pre-existing behaviour. */
8726
+ mode: MediaRelocateModeSchema.optional()
8727
+ });
8728
+ /** How many rows still carry NO `locationId` — the population a repoint would
8729
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8730
+ * value that permits a non-blocking `eventMedia` cutover. */
8731
+ var UnstampedEventMediaCountSchema = object({
8732
+ media: number().int().nonnegative(),
8733
+ retrainFrames: number().int().nonnegative(),
8734
+ total: number().int().nonnegative()
8699
8735
  });
8700
8736
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8701
- /** The independently selectable logical storage classes. `recordings`
8702
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8703
- * segments; `eventMedia` is post-analysis blobs. */
8737
+ /** The independently selectable logical storage classes — every class
8738
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8739
+ * Zod enum error where they should meet an explanation.
8740
+ *
8741
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8742
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8743
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8744
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8704
8745
  var StorageMigrationClassSchema = _enum([
8705
8746
  "recordings",
8706
8747
  "recordingsLow",
8707
- "eventMedia"
8748
+ "eventMedia",
8749
+ "backups",
8750
+ "galleryMedia"
8708
8751
  ]);
8709
8752
  /** A destination is always an existing, fully-qualified location id. The
8710
8753
  * migration API intentionally never changes a source location's `basePath`:
@@ -8712,20 +8755,56 @@ var StorageMigrationClassSchema = _enum([
8712
8755
  var StorageMigrationDestinationsSchema = object({
8713
8756
  recordings: string().min(1).optional(),
8714
8757
  recordingsLow: string().min(1).optional(),
8715
- eventMedia: string().min(1).optional()
8758
+ eventMedia: string().min(1).optional(),
8759
+ backups: string().min(1).optional(),
8760
+ galleryMedia: string().min(1).optional()
8716
8761
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8762
+ /**
8763
+ * How a migration sequences the cutover against the byte move.
8764
+ *
8765
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8766
+ * resume. Recording is stopped for the whole move. Right
8767
+ * for a small or a cold class, and the only legal mode for
8768
+ * a `cardinality: 'single'` class.
8769
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8770
+ * refresh, resume, then move the past with everything
8771
+ * running. The pause is three bounded instants (a detach +
8772
+ * attach round, a write-gate drain, a lease) instead of one
8773
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8774
+ * stopped recording under `blocking`; the same move is
8775
+ * seconds of stopped recording under `nonBlocking`.
8776
+ *
8777
+ * The mode is on the JOB, not only on the input, because `status` is where an
8778
+ * operator finds out which one is running.
8779
+ */
8780
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8717
8781
  /** Shared input for planning and starting an orchestrated storage migration. */
8718
8782
  var StorageMigrationInputSchema = object({
8719
8783
  destinations: StorageMigrationDestinationsSchema,
8720
- throttleMbps: number().min(1).max(1e3).optional()
8784
+ throttleMbps: number().min(1).max(1e3).optional(),
8785
+ /** Omitted = `blocking`, which stays the default. */
8786
+ mode: StorageMigrationModeSchema.optional()
8721
8787
  });
8722
- /** The durable coordinator state machine. The only phase that changes default
8723
- * locations is `repointing`, after every selected mover has completed and been
8724
- * verified. */
8788
+ /**
8789
+ * The durable coordinator state machine.
8790
+ *
8791
+ * `blocking`:
8792
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8793
+ *
8794
+ * `nonBlocking`:
8795
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8796
+ *
8797
+ * Same phases, different order plus two new ones — not a second mover.
8798
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8799
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8800
+ * `repointing` is still the only phase that changes a default location.
8801
+ */
8725
8802
  var StorageMigrationPhaseSchema = _enum([
8726
8803
  "planning",
8804
+ "sealing",
8727
8805
  "pausing",
8728
8806
  "moving",
8807
+ "draining",
8729
8808
  "verifying",
8730
8809
  "repointing",
8731
8810
  "refreshing",
@@ -8739,17 +8818,56 @@ var StorageMigrationParticipantSchema = _enum([
8739
8818
  "recorder",
8740
8819
  "analytics"
8741
8820
  ]);
8821
+ /**
8822
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8823
+ *
8824
+ * The long half of a non-blocking migration is `draining`, and it is measured
8825
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8826
+ * existed the only place those numbers appeared was a Loki line, so an operator
8827
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8828
+ * afternoon.
8829
+ *
8830
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8831
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8832
+ * mover — which is the exact failure this is meant to end. The coordinator's
8833
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8834
+ * read `state`; folding the counters costs no extra read and makes the durable
8835
+ * record say afterwards how far a move actually got.
8836
+ *
8837
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8838
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8839
+ * cannot say M, and a 0 there would render as "100 % done".
8840
+ */
8841
+ var StorageMigrationMoveProgressSchema = object({
8842
+ filesMoved: number().int().nonnegative(),
8843
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8844
+ filesTotal: number().int().nonnegative().nullable(),
8845
+ bytesMoved: number().int().nonnegative(),
8846
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8847
+ * crash gets a new mover, and a rate computed from the migration's start
8848
+ * would silently average in the time nothing was running. */
8849
+ startedAt: number(),
8850
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8851
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8852
+ * subtract its own. */
8853
+ observedAt: number()
8854
+ });
8742
8855
  var StorageMigrationMoveSchema = object({
8743
8856
  storageClass: StorageMigrationClassSchema,
8744
8857
  fromLocationId: string(),
8745
8858
  toLocationId: string(),
8746
8859
  moverJobId: string().nullable(),
8747
8860
  state: RelocateJobStateSchema.nullable(),
8748
- error: string().nullable()
8861
+ error: string().nullable(),
8862
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8863
+ progress: StorageMigrationMoveProgressSchema.nullable()
8749
8864
  });
8750
8865
  var StorageMigrationJobSchema = object({
8751
8866
  jobId: string(),
8752
8867
  phase: StorageMigrationPhaseSchema,
8868
+ /** Which order this job is running. `status` is the only place an operator
8869
+ * can tell a seconds-long cutover from a thirty-hour one. */
8870
+ mode: StorageMigrationModeSchema,
8753
8871
  destinations: StorageMigrationDestinationsSchema,
8754
8872
  throttleMbps: number(),
8755
8873
  moves: array(StorageMigrationMoveSchema),
@@ -8762,13 +8880,122 @@ var StorageMigrationJobSchema = object({
8762
8880
  finishedAt: number().nullable(),
8763
8881
  error: string().nullable()
8764
8882
  });
8883
+ var StorageMigrationFindingSchema = object({
8884
+ code: _enum([
8885
+ "sharesDeviceWithSource",
8886
+ "deviceIdentityUnknown",
8887
+ "unstampedEventMediaRows",
8888
+ "blockingOnly",
8889
+ "noMover"
8890
+ ]),
8891
+ storageClass: StorageMigrationClassSchema,
8892
+ /** Human-readable, already carrying the ids and counts. */
8893
+ message: string()
8894
+ });
8765
8895
  var StorageMigrationPlanSchema = object({
8766
8896
  destinations: StorageMigrationDestinationsSchema,
8897
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8898
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8899
+ * it. */
8900
+ mode: StorageMigrationModeSchema,
8767
8901
  moves: array(object({
8768
8902
  storageClass: StorageMigrationClassSchema,
8769
8903
  fromLocationId: string(),
8770
8904
  toLocationId: string()
8771
- }))
8905
+ })),
8906
+ findings: array(StorageMigrationFindingSchema)
8907
+ });
8908
+ /**
8909
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8910
+ *
8911
+ * The coordinator's job record is the state of record for a migration, and its
8912
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8913
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8914
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8915
+ * way because no supported UI path existed. A mover armed like that has no job
8916
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8917
+ *
8918
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8919
+ * orchestrated it.
8920
+ */
8921
+ var StorageMigrationMoverSchema = object({
8922
+ lane: _enum(["footage", "media"]),
8923
+ job: RelocateJobSchema,
8924
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8925
+ * directly against the owning addon. */
8926
+ migrationJobId: string().nullable(),
8927
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8928
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8929
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8930
+ * rate made of two different clocks. */
8931
+ observedAt: number()
8932
+ });
8933
+ /**
8934
+ * What a SOURCE still holds for one storage class — the number that makes a
8935
+ * "drain remaining" action honest rather than hopeful.
8936
+ *
8937
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8938
+ * engine's own selection count for media), never from the resident index: a
8939
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8940
+ * never been told about (D295).
8941
+ *
8942
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8943
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8944
+ * because refusing on an unanswerable read would hide exactly the case an
8945
+ * operator needs to act on.
8946
+ */
8947
+ var StorageMigrationResidueSchema = object({
8948
+ storageClass: StorageMigrationClassSchema,
8949
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8950
+ * move from wherever they are rather than from one named source. */
8951
+ fromLocationId: string(),
8952
+ /** Where a drain would move it — the class's CURRENT default. */
8953
+ toLocationId: string(),
8954
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8955
+ items: number().int().nonnegative().nullable(),
8956
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8957
+ bytes: number().int().nonnegative().nullable()
8958
+ });
8959
+ /**
8960
+ * Run the DRAIN half and nothing else.
8961
+ *
8962
+ * A migration that reached `done` has already repointed, so `start` correctly
8963
+ * refuses its destination ("already the default") — there is nothing left to
8964
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8965
+ * or finish against a work list that was a tenth of the archive (D295), and
8966
+ * before this there was no supported way to run only that half: the only way
8967
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8968
+ *
8969
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8970
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8971
+ * re-repoint a class that is already migrated.
8972
+ */
8973
+ var StorageMigrationDrainInputSchema = object({
8974
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8975
+ * a class whose source is already empty is refused rather than started. */
8976
+ classes: array(StorageMigrationClassSchema).min(1),
8977
+ throttleMbps: number().min(1).max(1e3).optional()
8978
+ });
8979
+ /** What a footage source still holds, asked of the durable hour ledger. */
8980
+ var RelocateResidueInputSchema = object({
8981
+ fromLocationId: string().min(1),
8982
+ /** Narrow to one logical class; omit for every profile on the location. */
8983
+ footageClass: RelocateFootageClassSchema.optional()
8984
+ });
8985
+ /** `null` = the archive could not answer (no ledger on this node, or the
8986
+ * aggregate failed). Never conflated with an empty source. */
8987
+ var RelocateResidueSchema = object({
8988
+ segments: number().int().nonnegative(),
8989
+ bytes: number().int().nonnegative()
8990
+ }).nullable();
8991
+ /** How many rows a media pass would still act on against a given target — the
8992
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8993
+ * never disagree. `null` = the count could not be taken. */
8994
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8995
+ var RelocatableMediaCountInputSchema = object({
8996
+ toLocationId: string().min(1),
8997
+ /** Omitted = `move`. */
8998
+ mode: MediaRelocateModeSchema.optional()
8772
8999
  });
8773
9000
  /**
8774
9001
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8874,6 +9101,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8874
9101
  * two addons declaring the same `id` must agree on `cardinality` (validated
8875
9102
  * at kernel aggregation time, not here).
8876
9103
  */
9104
+ /**
9105
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
9106
+ * actually reaches the bytes. It is the constraint that decides which
9107
+ * `storage-provider`s may back a location of that kind.
9108
+ *
9109
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
9110
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
9111
+ * post-analysis media roots). Only a provider that serves a genuine local
9112
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
9113
+ * remote provider's `resolve` returns a path on the REMOTE host, and
9114
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
9115
+ * against a same-named local directory that is something else entirely.
9116
+ *
9117
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
9118
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
9119
+ * service never sees a path, so any provider can back it. `backups` is the
9120
+ * one kind that qualifies today.
9121
+ *
9122
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
9123
+ * an EMERGENT property of how the recorder happened to be written. Nothing
9124
+ * refused the configuration; the first write simply went somewhere wrong, and
9125
+ * a recording write that goes wrong surfaces as a silent black window rather
9126
+ * than an error (the read path does not `stat`). This turns that accident into
9127
+ * a declared, enforced, testable refusal.
9128
+ */
9129
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8877
9130
  var StorageLocationDeclarationSchema = object({
8878
9131
  /**
8879
9132
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8893,6 +9146,19 @@ var StorageLocationDeclarationSchema = object({
8893
9146
  */
8894
9147
  cardinality: _enum(["single", "multi"]),
8895
9148
  /**
9149
+ * HOW the declaring service reaches the bytes — and therefore WHICH
9150
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
9151
+ * and {@link STORAGE_ACCESS_FALLBACK}.
9152
+ *
9153
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
9154
+ * can only over-restrict (refuse a remote provider for a kind that might
9155
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
9156
+ * permissive direction and is therefore never inferred — a repo guard
9157
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
9158
+ * reached by omission.
9159
+ */
9160
+ access: StorageAccessSchema.optional(),
9161
+ /**
8896
9162
  * When set, the default instance for this location inherits its resolved
8897
9163
  * root from the named location's default instance. Useful for derivative
8898
9164
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -18553,8 +18819,10 @@ var TrackSchema = object({
18553
18819
  lastSeen: number(),
18554
18820
  /** Frame-rate position history (subject to maxPositionHistory cap). */
18555
18821
  positions: array(TrackPositionSchema).readonly(),
18556
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
18557
- * saveThumbnails policy). */
18822
+ /** Periodic snapshots at snapshotIntervalMs cadence DEBUG media, produced
18823
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18824
+ * the retired `saveThumbnails` used to gate this and the rolling
18825
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
18558
18826
  snapshots: array(TrackSnapshotSchema).readonly(),
18559
18827
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
18560
18828
  zonesVisited: array(string()).readonly(),
@@ -19414,6 +19682,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19414
19682
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
19415
19683
  kind: "mutation",
19416
19684
  auth: "admin"
19685
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
19686
+ kind: "query",
19687
+ auth: "admin"
19417
19688
  }), method(object({}), array(RelocateJobSchema).readonly(), {
19418
19689
  kind: "query",
19419
19690
  auth: "admin"
@@ -21321,7 +21592,10 @@ method(object({
21321
21592
  }), StorageLocationSchema, {
21322
21593
  kind: "mutation",
21323
21594
  auth: "admin"
21324
- }), method(object({ id: string() }), _void(), {
21595
+ }), method(object({
21596
+ id: string(),
21597
+ force: boolean().optional()
21598
+ }), _void(), {
21325
21599
  kind: "mutation",
21326
21600
  auth: "admin"
21327
21601
  }), method(object({ id: string() }), object({
@@ -21370,6 +21644,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
21370
21644
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
21371
21645
  kind: "mutation",
21372
21646
  auth: "admin"
21647
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
21648
+ kind: "mutation",
21649
+ auth: "admin"
21373
21650
  });
21374
21651
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
21375
21652
  providerId: string().min(1),
@@ -21768,12 +22045,38 @@ response: record(string(), unknown()) }), object({
21768
22045
  *
21769
22046
  * ## Why this is a capability and not a helper
21770
22047
  *
21771
- * Six stores in `addon-post-analysis` already hold vectors object CLIP, face,
21772
- * plate, vehicle, identity, and the event store's derivativesand every one of
21773
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21774
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21775
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21776
- * load 5,000 rows before ranking anything.
22048
+ * This capability was introduced with the claim that SIX stores in
22049
+ * `addon-post-analysis` held vectors in a `JSON` settings-store columnobject
22050
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
22051
+ * claim was never true, and leaving it here made five stores look like pending
22052
+ * work when three of them have no vector at all. Counted column by column on
22053
+ * 2026-08-30, exactly THREE ever held one:
22054
+ *
22055
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
22056
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
22057
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
22058
+ * face, migrated 2026-08-30 into its OWN index (see below).
22059
+ *
22060
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
22061
+ * and `identities` store a name; the event store stores no derivative vector.
22062
+ * They are not migration candidates and never were.
22063
+ *
22064
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
22065
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
22066
+ * rows before ranking anything.
22067
+ *
22068
+ * ## One index per COMPARISON, never per encoder
22069
+ *
22070
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
22071
+ * model, and they still get two indexes. An index is a set of things that are
22072
+ * ranked against each other and that live and die together, and these two are
22073
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
22074
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
22075
+ * forever and is the gallery every recognition ranks against. One index would
22076
+ * mean every gallery load and every reconcile carried a filter whose failure
22077
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
22078
+ * person's only sample. The dimension they share is not a reason to share an
22079
+ * index; the question they answer is, and it differs.
21777
22080
  *
21778
22081
  * The fix is not a faster loop, it is a different backend — and the backend
21779
22082
  * should be replaceable without touching six callers. So: a singleton
@@ -21878,7 +22181,20 @@ var VectorQueryResultSchema = object({
21878
22181
  */
21879
22182
  scanned: number(),
21880
22183
  /** True when the backend could not consider every row that passed the filter. */
21881
- truncated: boolean()
22184
+ truncated: boolean(),
22185
+ /**
22186
+ * The `topK` the backend actually ran with.
22187
+ *
22188
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
22189
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
22190
+ * own log rather than in its answer. That is how an audit asking for 20,000
22191
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
22192
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
22193
+ * MUCH, in the return value, where the caller cannot fail to see it.
22194
+ *
22195
+ * Equals the requested `topK` whenever nothing was lowered.
22196
+ */
22197
+ effectiveTopK: number().int().positive()
21882
22198
  });
21883
22199
  var VectorDeleteInputSchema = object({
21884
22200
  index: string(),
@@ -21907,6 +22223,68 @@ var VectorGetResultSchema = object({ items: array(object({
21907
22223
  id: string(),
21908
22224
  metadata: VectorMetadataSchema
21909
22225
  })) });
22226
+ /**
22227
+ * Ids to read back WITH their vectors.
22228
+ *
22229
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
22230
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
22231
+ * caller depends on that promise. This one promises the opposite.
22232
+ *
22233
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
22234
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
22235
+ * a per-face cross-process KNN would be a network round trip inside the
22236
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
22237
+ * it requires the index to hand the floats back. Without this method the only
22238
+ * way to keep a readable vector is a JSON column, which is the thing this
22239
+ * capability exists to delete.
22240
+ *
22241
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
22242
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
22243
+ */
22244
+ var VectorFetchInputSchema = object({
22245
+ index: string(),
22246
+ ids: array(string())
22247
+ });
22248
+ var VectorFetchResultSchema = object({ items: array(object({
22249
+ id: string(),
22250
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
22251
+ vector: string(),
22252
+ metadata: VectorMetadataSchema
22253
+ })) });
22254
+ /**
22255
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
22256
+ *
22257
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
22258
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
22259
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
22260
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
22261
+ * distance to every row is degenerate. `examined: 4096` then read as "we
22262
+ * looked" for as long as anyone cared to read it.
22263
+ *
22264
+ * This is the primitive that question actually needs: a bounded page, ordered
22265
+ * by the backend's own row order, costing no distance computation at all.
22266
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
22267
+ * the full-table read this capability was built to stop.
22268
+ */
22269
+ var VectorScanInputSchema = object({
22270
+ index: string(),
22271
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
22272
+ cursor: number().int().nonnegative().default(0),
22273
+ limit: number().int().positive()
22274
+ });
22275
+ var VectorScanResultSchema = object({
22276
+ items: array(object({
22277
+ id: string(),
22278
+ metadata: VectorMetadataSchema
22279
+ })),
22280
+ /**
22281
+ * Where the next page starts, or `null` when the walk reached the end.
22282
+ *
22283
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
22284
+ * from a short page: a backend is free to return fewer rows than asked.
22285
+ */
22286
+ nextCursor: number().int().nonnegative().nullable()
22287
+ });
21910
22288
  var VectorStatsInputSchema = object({ index: string() });
21911
22289
  var VectorStatsResultSchema = object({
21912
22290
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21925,7 +22303,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21925
22303
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21926
22304
  kind: "mutation",
21927
22305
  auth: "admin"
21928
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
22306
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21929
22307
  kind: "mutation",
21930
22308
  auth: "admin"
21931
22309
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -26877,6 +27255,9 @@ method(object({
26877
27255
  }), method(object({}), array(RelocateJobSchema).readonly(), {
26878
27256
  kind: "query",
26879
27257
  auth: "admin"
27258
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
27259
+ kind: "query",
27260
+ auth: "admin"
26880
27261
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26881
27262
  kind: "mutation",
26882
27263
  auth: "admin"
@@ -31867,6 +32248,18 @@ Object.freeze({
31867
32248
  addonId: null,
31868
32249
  access: "create"
31869
32250
  },
32251
+ "pipelineAnalytics.countRelocatableMedia": {
32252
+ capName: "pipeline-analytics",
32253
+ capScope: "device",
32254
+ addonId: null,
32255
+ access: "view"
32256
+ },
32257
+ "pipelineAnalytics.countUnstampedEventMedia": {
32258
+ capName: "pipeline-analytics",
32259
+ capScope: "device",
32260
+ addonId: null,
32261
+ access: "view"
32262
+ },
31870
32263
  "pipelineAnalytics.deleteDeviceEvents": {
31871
32264
  capName: "pipeline-analytics",
31872
32265
  capScope: "device",
@@ -33025,6 +33418,12 @@ Object.freeze({
33025
33418
  addonId: null,
33026
33419
  access: "view"
33027
33420
  },
33421
+ "recording.getRelocateResidue": {
33422
+ capName: "recording",
33423
+ capScope: "system",
33424
+ addonId: null,
33425
+ access: "view"
33426
+ },
33028
33427
  "recording.getStorageMigrationMoveStatus": {
33029
33428
  capName: "recording",
33030
33429
  capScope: "system",
@@ -33571,12 +33970,30 @@ Object.freeze({
33571
33970
  addonId: null,
33572
33971
  access: "create"
33573
33972
  },
33973
+ "storageMigration.drain": {
33974
+ capName: "storage-migration",
33975
+ capScope: "system",
33976
+ addonId: null,
33977
+ access: "create"
33978
+ },
33979
+ "storageMigration.movers": {
33980
+ capName: "storage-migration",
33981
+ capScope: "system",
33982
+ addonId: null,
33983
+ access: "view"
33984
+ },
33574
33985
  "storageMigration.plan": {
33575
33986
  capName: "storage-migration",
33576
33987
  capScope: "system",
33577
33988
  addonId: null,
33578
33989
  access: "view"
33579
33990
  },
33991
+ "storageMigration.residue": {
33992
+ capName: "storage-migration",
33993
+ capScope: "system",
33994
+ addonId: null,
33995
+ access: "view"
33996
+ },
33580
33997
  "storageMigration.start": {
33581
33998
  capName: "storage-migration",
33582
33999
  capScope: "system",
@@ -34411,6 +34828,12 @@ Object.freeze({
34411
34828
  addonId: null,
34412
34829
  access: "delete"
34413
34830
  },
34831
+ "vectorStore.fetchByIds": {
34832
+ capName: "vector-store",
34833
+ capScope: "system",
34834
+ addonId: null,
34835
+ access: "view"
34836
+ },
34414
34837
  "vectorStore.getByIds": {
34415
34838
  capName: "vector-store",
34416
34839
  capScope: "system",
@@ -34423,6 +34846,12 @@ Object.freeze({
34423
34846
  addonId: null,
34424
34847
  access: "view"
34425
34848
  },
34849
+ "vectorStore.scan": {
34850
+ capName: "vector-store",
34851
+ capScope: "system",
34852
+ addonId: null,
34853
+ access: "view"
34854
+ },
34426
34855
  "vectorStore.stats": {
34427
34856
  capName: "vector-store",
34428
34857
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-export-hap",
3
- "version": "1.2.53",
3
+ "version": "1.2.56",
4
4
  "description": "HomeKit (HAP) exporter for CamStack devices. Publishes each exposed device as its own HomeKit accessory: cameras and doorbells with SRTP streaming, HomeKit Secure Video, motion, two-way audio, PTZ and battery; switches, lights, locks and sensors through a capability→service table.",
5
5
  "keywords": [
6
6
  "camstack",