@camstack/addon-tailscale 1.2.42 → 1.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.
@@ -24,7 +24,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  enumerable: true
25
25
  }) : target, mod));
26
26
  //#endregion
27
- const require_dist = require("../dist-XsZAD0zE.js");
27
+ const require_dist = require("../dist-ki6Kt6cL.js");
28
28
  let node_child_process = require("node:child_process");
29
29
  let node_util = require("node:util");
30
30
  let node_fs = require("node:fs");
@@ -1,4 +1,4 @@
1
- import { a as EventCategory, i as BaseAddon, n as networkAccessCapability, r as BOOT_RECOVERY_BACKOFF_MS, t as meshNetworkCapability } from "../dist-D1h1qkz3.mjs";
1
+ import { a as EventCategory, i as BaseAddon, n as networkAccessCapability, r as BOOT_RECOVERY_BACKOFF_MS, t as meshNetworkCapability } from "../dist-RluxJbgF.mjs";
2
2
  import { execFile, spawn } from "node:child_process";
3
3
  import { promisify } from "node:util";
4
4
  import * as fs from "node:fs";
@@ -8056,18 +8056,61 @@ var RelocateFootageInputSchema = object({
8056
8056
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8057
8057
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8058
8058
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8059
+ /**
8060
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8061
+ * mover (the engine already walks both collections with a timestamp cursor and
8062
+ * already has a stamp-without-copy path).
8063
+ *
8064
+ * - `move` — the default and the historical behaviour: event-media and
8065
+ * retrain blobs move to `toLocationId` and their rows are
8066
+ * stamped. The enrolled gallery is skipped (D197).
8067
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8068
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8069
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8070
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8071
+ * instant a repoint moves that pointer the row reads from the
8072
+ * new disk while its bytes are on the old one.
8073
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8074
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8075
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8076
+ * never run beside a live second location: it is stop-the-world
8077
+ * by construction, which is acceptable only because the gallery
8078
+ * is a few KB per enrolled sample.
8079
+ */
8080
+ var MediaRelocateModeSchema = _enum([
8081
+ "move",
8082
+ "seal",
8083
+ "gallery"
8084
+ ]);
8059
8085
  var RelocateMediaInputSchema = object({
8060
8086
  toLocationId: string(),
8061
- throttleMbps: number().min(1).max(1e3).optional()
8087
+ throttleMbps: number().min(1).max(1e3).optional(),
8088
+ /** Omitted = `move`, the pre-existing behaviour. */
8089
+ mode: MediaRelocateModeSchema.optional()
8090
+ });
8091
+ /** How many rows still carry NO `locationId` — the population a repoint would
8092
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8093
+ * value that permits a non-blocking `eventMedia` cutover. */
8094
+ var UnstampedEventMediaCountSchema = object({
8095
+ media: number().int().nonnegative(),
8096
+ retrainFrames: number().int().nonnegative(),
8097
+ total: number().int().nonnegative()
8062
8098
  });
8063
8099
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8064
- /** The independently selectable logical storage classes. `recordings`
8065
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8066
- * segments; `eventMedia` is post-analysis blobs. */
8100
+ /** The independently selectable logical storage classes — every class
8101
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8102
+ * Zod enum error where they should meet an explanation.
8103
+ *
8104
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8105
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8106
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8107
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8067
8108
  var StorageMigrationClassSchema = _enum([
8068
8109
  "recordings",
8069
8110
  "recordingsLow",
8070
- "eventMedia"
8111
+ "eventMedia",
8112
+ "backups",
8113
+ "galleryMedia"
8071
8114
  ]);
8072
8115
  /** A destination is always an existing, fully-qualified location id. The
8073
8116
  * migration API intentionally never changes a source location's `basePath`:
@@ -8075,20 +8118,56 @@ var StorageMigrationClassSchema = _enum([
8075
8118
  var StorageMigrationDestinationsSchema = object({
8076
8119
  recordings: string().min(1).optional(),
8077
8120
  recordingsLow: string().min(1).optional(),
8078
- eventMedia: string().min(1).optional()
8121
+ eventMedia: string().min(1).optional(),
8122
+ backups: string().min(1).optional(),
8123
+ galleryMedia: string().min(1).optional()
8079
8124
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8125
+ /**
8126
+ * How a migration sequences the cutover against the byte move.
8127
+ *
8128
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8129
+ * resume. Recording is stopped for the whole move. Right
8130
+ * for a small or a cold class, and the only legal mode for
8131
+ * a `cardinality: 'single'` class.
8132
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8133
+ * refresh, resume, then move the past with everything
8134
+ * running. The pause is three bounded instants (a detach +
8135
+ * attach round, a write-gate drain, a lease) instead of one
8136
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8137
+ * stopped recording under `blocking`; the same move is
8138
+ * seconds of stopped recording under `nonBlocking`.
8139
+ *
8140
+ * The mode is on the JOB, not only on the input, because `status` is where an
8141
+ * operator finds out which one is running.
8142
+ */
8143
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8080
8144
  /** Shared input for planning and starting an orchestrated storage migration. */
8081
8145
  var StorageMigrationInputSchema = object({
8082
8146
  destinations: StorageMigrationDestinationsSchema,
8083
- throttleMbps: number().min(1).max(1e3).optional()
8147
+ throttleMbps: number().min(1).max(1e3).optional(),
8148
+ /** Omitted = `blocking`, which stays the default. */
8149
+ mode: StorageMigrationModeSchema.optional()
8084
8150
  });
8085
- /** The durable coordinator state machine. The only phase that changes default
8086
- * locations is `repointing`, after every selected mover has completed and been
8087
- * verified. */
8151
+ /**
8152
+ * The durable coordinator state machine.
8153
+ *
8154
+ * `blocking`:
8155
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8156
+ *
8157
+ * `nonBlocking`:
8158
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8159
+ *
8160
+ * Same phases, different order plus two new ones — not a second mover.
8161
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8162
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8163
+ * `repointing` is still the only phase that changes a default location.
8164
+ */
8088
8165
  var StorageMigrationPhaseSchema = _enum([
8089
8166
  "planning",
8167
+ "sealing",
8090
8168
  "pausing",
8091
8169
  "moving",
8170
+ "draining",
8092
8171
  "verifying",
8093
8172
  "repointing",
8094
8173
  "refreshing",
@@ -8102,17 +8181,56 @@ var StorageMigrationParticipantSchema = _enum([
8102
8181
  "recorder",
8103
8182
  "analytics"
8104
8183
  ]);
8184
+ /**
8185
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8186
+ *
8187
+ * The long half of a non-blocking migration is `draining`, and it is measured
8188
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8189
+ * existed the only place those numbers appeared was a Loki line, so an operator
8190
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8191
+ * afternoon.
8192
+ *
8193
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8194
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8195
+ * mover — which is the exact failure this is meant to end. The coordinator's
8196
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8197
+ * read `state`; folding the counters costs no extra read and makes the durable
8198
+ * record say afterwards how far a move actually got.
8199
+ *
8200
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8201
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8202
+ * cannot say M, and a 0 there would render as "100 % done".
8203
+ */
8204
+ var StorageMigrationMoveProgressSchema = object({
8205
+ filesMoved: number().int().nonnegative(),
8206
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8207
+ filesTotal: number().int().nonnegative().nullable(),
8208
+ bytesMoved: number().int().nonnegative(),
8209
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8210
+ * crash gets a new mover, and a rate computed from the migration's start
8211
+ * would silently average in the time nothing was running. */
8212
+ startedAt: number(),
8213
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8214
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8215
+ * subtract its own. */
8216
+ observedAt: number()
8217
+ });
8105
8218
  var StorageMigrationMoveSchema = object({
8106
8219
  storageClass: StorageMigrationClassSchema,
8107
8220
  fromLocationId: string(),
8108
8221
  toLocationId: string(),
8109
8222
  moverJobId: string().nullable(),
8110
8223
  state: RelocateJobStateSchema.nullable(),
8111
- error: string().nullable()
8224
+ error: string().nullable(),
8225
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8226
+ progress: StorageMigrationMoveProgressSchema.nullable()
8112
8227
  });
8113
8228
  var StorageMigrationJobSchema = object({
8114
8229
  jobId: string(),
8115
8230
  phase: StorageMigrationPhaseSchema,
8231
+ /** Which order this job is running. `status` is the only place an operator
8232
+ * can tell a seconds-long cutover from a thirty-hour one. */
8233
+ mode: StorageMigrationModeSchema,
8116
8234
  destinations: StorageMigrationDestinationsSchema,
8117
8235
  throttleMbps: number(),
8118
8236
  moves: array(StorageMigrationMoveSchema),
@@ -8125,13 +8243,122 @@ var StorageMigrationJobSchema = object({
8125
8243
  finishedAt: number().nullable(),
8126
8244
  error: string().nullable()
8127
8245
  });
8246
+ var StorageMigrationFindingSchema = object({
8247
+ code: _enum([
8248
+ "sharesDeviceWithSource",
8249
+ "deviceIdentityUnknown",
8250
+ "unstampedEventMediaRows",
8251
+ "blockingOnly",
8252
+ "noMover"
8253
+ ]),
8254
+ storageClass: StorageMigrationClassSchema,
8255
+ /** Human-readable, already carrying the ids and counts. */
8256
+ message: string()
8257
+ });
8128
8258
  var StorageMigrationPlanSchema = object({
8129
8259
  destinations: StorageMigrationDestinationsSchema,
8260
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8261
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8262
+ * it. */
8263
+ mode: StorageMigrationModeSchema,
8130
8264
  moves: array(object({
8131
8265
  storageClass: StorageMigrationClassSchema,
8132
8266
  fromLocationId: string(),
8133
8267
  toLocationId: string()
8134
- }))
8268
+ })),
8269
+ findings: array(StorageMigrationFindingSchema)
8270
+ });
8271
+ /**
8272
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8273
+ *
8274
+ * The coordinator's job record is the state of record for a migration, and its
8275
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8276
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8277
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8278
+ * way because no supported UI path existed. A mover armed like that has no job
8279
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8280
+ *
8281
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8282
+ * orchestrated it.
8283
+ */
8284
+ var StorageMigrationMoverSchema = object({
8285
+ lane: _enum(["footage", "media"]),
8286
+ job: RelocateJobSchema,
8287
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8288
+ * directly against the owning addon. */
8289
+ migrationJobId: string().nullable(),
8290
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8291
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8292
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8293
+ * rate made of two different clocks. */
8294
+ observedAt: number()
8295
+ });
8296
+ /**
8297
+ * What a SOURCE still holds for one storage class — the number that makes a
8298
+ * "drain remaining" action honest rather than hopeful.
8299
+ *
8300
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8301
+ * engine's own selection count for media), never from the resident index: a
8302
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8303
+ * never been told about (D295).
8304
+ *
8305
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8306
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8307
+ * because refusing on an unanswerable read would hide exactly the case an
8308
+ * operator needs to act on.
8309
+ */
8310
+ var StorageMigrationResidueSchema = object({
8311
+ storageClass: StorageMigrationClassSchema,
8312
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8313
+ * move from wherever they are rather than from one named source. */
8314
+ fromLocationId: string(),
8315
+ /** Where a drain would move it — the class's CURRENT default. */
8316
+ toLocationId: string(),
8317
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8318
+ items: number().int().nonnegative().nullable(),
8319
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8320
+ bytes: number().int().nonnegative().nullable()
8321
+ });
8322
+ /**
8323
+ * Run the DRAIN half and nothing else.
8324
+ *
8325
+ * A migration that reached `done` has already repointed, so `start` correctly
8326
+ * refuses its destination ("already the default") — there is nothing left to
8327
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8328
+ * or finish against a work list that was a tenth of the archive (D295), and
8329
+ * before this there was no supported way to run only that half: the only way
8330
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8331
+ *
8332
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8333
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8334
+ * re-repoint a class that is already migrated.
8335
+ */
8336
+ var StorageMigrationDrainInputSchema = object({
8337
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8338
+ * a class whose source is already empty is refused rather than started. */
8339
+ classes: array(StorageMigrationClassSchema).min(1),
8340
+ throttleMbps: number().min(1).max(1e3).optional()
8341
+ });
8342
+ /** What a footage source still holds, asked of the durable hour ledger. */
8343
+ var RelocateResidueInputSchema = object({
8344
+ fromLocationId: string().min(1),
8345
+ /** Narrow to one logical class; omit for every profile on the location. */
8346
+ footageClass: RelocateFootageClassSchema.optional()
8347
+ });
8348
+ /** `null` = the archive could not answer (no ledger on this node, or the
8349
+ * aggregate failed). Never conflated with an empty source. */
8350
+ var RelocateResidueSchema = object({
8351
+ segments: number().int().nonnegative(),
8352
+ bytes: number().int().nonnegative()
8353
+ }).nullable();
8354
+ /** How many rows a media pass would still act on against a given target — the
8355
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8356
+ * never disagree. `null` = the count could not be taken. */
8357
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8358
+ var RelocatableMediaCountInputSchema = object({
8359
+ toLocationId: string().min(1),
8360
+ /** Omitted = `move`. */
8361
+ mode: MediaRelocateModeSchema.optional()
8135
8362
  });
8136
8363
  /**
8137
8364
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8237,6 +8464,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8237
8464
  * two addons declaring the same `id` must agree on `cardinality` (validated
8238
8465
  * at kernel aggregation time, not here).
8239
8466
  */
8467
+ /**
8468
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8469
+ * actually reaches the bytes. It is the constraint that decides which
8470
+ * `storage-provider`s may back a location of that kind.
8471
+ *
8472
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8473
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8474
+ * post-analysis media roots). Only a provider that serves a genuine local
8475
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8476
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8477
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8478
+ * against a same-named local directory that is something else entirely.
8479
+ *
8480
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8481
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8482
+ * service never sees a path, so any provider can back it. `backups` is the
8483
+ * one kind that qualifies today.
8484
+ *
8485
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8486
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8487
+ * refused the configuration; the first write simply went somewhere wrong, and
8488
+ * a recording write that goes wrong surfaces as a silent black window rather
8489
+ * than an error (the read path does not `stat`). This turns that accident into
8490
+ * a declared, enforced, testable refusal.
8491
+ */
8492
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8240
8493
  var StorageLocationDeclarationSchema = object({
8241
8494
  /**
8242
8495
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8256,6 +8509,19 @@ var StorageLocationDeclarationSchema = object({
8256
8509
  */
8257
8510
  cardinality: _enum(["single", "multi"]),
8258
8511
  /**
8512
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8513
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8514
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8515
+ *
8516
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8517
+ * can only over-restrict (refuse a remote provider for a kind that might
8518
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8519
+ * permissive direction and is therefore never inferred — a repo guard
8520
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8521
+ * reached by omission.
8522
+ */
8523
+ access: StorageAccessSchema.optional(),
8524
+ /**
8259
8525
  * When set, the default instance for this location inherits its resolved
8260
8526
  * root from the named location's default instance. Useful for derivative
8261
8527
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -17798,8 +18064,10 @@ var TrackSchema = object({
17798
18064
  lastSeen: number(),
17799
18065
  /** Frame-rate position history (subject to maxPositionHistory cap). */
17800
18066
  positions: array(TrackPositionSchema).readonly(),
17801
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17802
- * saveThumbnails policy). */
18067
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18068
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18069
+ * the retired `saveThumbnails` used to gate this and the rolling
18070
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
17803
18071
  snapshots: array(TrackSnapshotSchema).readonly(),
17804
18072
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
17805
18073
  zonesVisited: array(string()).readonly(),
@@ -18659,6 +18927,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18659
18927
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18660
18928
  kind: "mutation",
18661
18929
  auth: "admin"
18930
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
18931
+ kind: "query",
18932
+ auth: "admin"
18662
18933
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18663
18934
  kind: "query",
18664
18935
  auth: "admin"
@@ -20566,7 +20837,10 @@ method(object({
20566
20837
  }), StorageLocationSchema, {
20567
20838
  kind: "mutation",
20568
20839
  auth: "admin"
20569
- }), method(object({ id: string() }), _void(), {
20840
+ }), method(object({
20841
+ id: string(),
20842
+ force: boolean().optional()
20843
+ }), _void(), {
20570
20844
  kind: "mutation",
20571
20845
  auth: "admin"
20572
20846
  }), method(object({ id: string() }), object({
@@ -20615,6 +20889,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20615
20889
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20616
20890
  kind: "mutation",
20617
20891
  auth: "admin"
20892
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
20893
+ kind: "mutation",
20894
+ auth: "admin"
20618
20895
  });
20619
20896
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20620
20897
  providerId: string().min(1),
@@ -21013,12 +21290,38 @@ response: record(string(), unknown()) }), object({
21013
21290
  *
21014
21291
  * ## Why this is a capability and not a helper
21015
21292
  *
21016
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21017
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21018
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21019
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21020
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21021
- * load 5,000 rows before ranking anything.
21293
+ * This capability was introduced with the claim that SIX stores in
21294
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21295
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21296
+ * claim was never true, and leaving it here made five stores look like pending
21297
+ * work when three of them have no vector at all. Counted column by column on
21298
+ * 2026-08-30, exactly THREE ever held one:
21299
+ *
21300
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21301
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21302
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21303
+ * face, migrated 2026-08-30 into its OWN index (see below).
21304
+ *
21305
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21306
+ * and `identities` store a name; the event store stores no derivative vector.
21307
+ * They are not migration candidates and never were.
21308
+ *
21309
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21310
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21311
+ * rows before ranking anything.
21312
+ *
21313
+ * ## One index per COMPARISON, never per encoder
21314
+ *
21315
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21316
+ * model, and they still get two indexes. An index is a set of things that are
21317
+ * ranked against each other and that live and die together, and these two are
21318
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21319
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21320
+ * forever and is the gallery every recognition ranks against. One index would
21321
+ * mean every gallery load and every reconcile carried a filter whose failure
21322
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21323
+ * person's only sample. The dimension they share is not a reason to share an
21324
+ * index; the question they answer is, and it differs.
21022
21325
  *
21023
21326
  * The fix is not a faster loop, it is a different backend — and the backend
21024
21327
  * should be replaceable without touching six callers. So: a singleton
@@ -21123,7 +21426,20 @@ var VectorQueryResultSchema = object({
21123
21426
  */
21124
21427
  scanned: number(),
21125
21428
  /** True when the backend could not consider every row that passed the filter. */
21126
- truncated: boolean()
21429
+ truncated: boolean(),
21430
+ /**
21431
+ * The `topK` the backend actually ran with.
21432
+ *
21433
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21434
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21435
+ * own log rather than in its answer. That is how an audit asking for 20,000
21436
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21437
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21438
+ * MUCH, in the return value, where the caller cannot fail to see it.
21439
+ *
21440
+ * Equals the requested `topK` whenever nothing was lowered.
21441
+ */
21442
+ effectiveTopK: number().int().positive()
21127
21443
  });
21128
21444
  var VectorDeleteInputSchema = object({
21129
21445
  index: string(),
@@ -21152,6 +21468,68 @@ var VectorGetResultSchema = object({ items: array(object({
21152
21468
  id: string(),
21153
21469
  metadata: VectorMetadataSchema
21154
21470
  })) });
21471
+ /**
21472
+ * Ids to read back WITH their vectors.
21473
+ *
21474
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21475
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21476
+ * caller depends on that promise. This one promises the opposite.
21477
+ *
21478
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21479
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21480
+ * a per-face cross-process KNN would be a network round trip inside the
21481
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21482
+ * it requires the index to hand the floats back. Without this method the only
21483
+ * way to keep a readable vector is a JSON column, which is the thing this
21484
+ * capability exists to delete.
21485
+ *
21486
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21487
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21488
+ */
21489
+ var VectorFetchInputSchema = object({
21490
+ index: string(),
21491
+ ids: array(string())
21492
+ });
21493
+ var VectorFetchResultSchema = object({ items: array(object({
21494
+ id: string(),
21495
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21496
+ vector: string(),
21497
+ metadata: VectorMetadataSchema
21498
+ })) });
21499
+ /**
21500
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21501
+ *
21502
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21503
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21504
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21505
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21506
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21507
+ * looked" for as long as anyone cared to read it.
21508
+ *
21509
+ * This is the primitive that question actually needs: a bounded page, ordered
21510
+ * by the backend's own row order, costing no distance computation at all.
21511
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21512
+ * the full-table read this capability was built to stop.
21513
+ */
21514
+ var VectorScanInputSchema = object({
21515
+ index: string(),
21516
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21517
+ cursor: number().int().nonnegative().default(0),
21518
+ limit: number().int().positive()
21519
+ });
21520
+ var VectorScanResultSchema = object({
21521
+ items: array(object({
21522
+ id: string(),
21523
+ metadata: VectorMetadataSchema
21524
+ })),
21525
+ /**
21526
+ * Where the next page starts, or `null` when the walk reached the end.
21527
+ *
21528
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21529
+ * from a short page: a backend is free to return fewer rows than asked.
21530
+ */
21531
+ nextCursor: number().int().nonnegative().nullable()
21532
+ });
21155
21533
  var VectorStatsInputSchema = object({ index: string() });
21156
21534
  var VectorStatsResultSchema = object({
21157
21535
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21170,7 +21548,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21170
21548
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21171
21549
  kind: "mutation",
21172
21550
  auth: "admin"
21173
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21551
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21174
21552
  kind: "mutation",
21175
21553
  auth: "admin"
21176
21554
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -26135,6 +26513,9 @@ method(object({
26135
26513
  }), method(object({}), array(RelocateJobSchema).readonly(), {
26136
26514
  kind: "query",
26137
26515
  auth: "admin"
26516
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
26517
+ kind: "query",
26518
+ auth: "admin"
26138
26519
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26139
26520
  kind: "mutation",
26140
26521
  auth: "admin"
@@ -31100,6 +31481,18 @@ Object.freeze({
31100
31481
  addonId: null,
31101
31482
  access: "create"
31102
31483
  },
31484
+ "pipelineAnalytics.countRelocatableMedia": {
31485
+ capName: "pipeline-analytics",
31486
+ capScope: "device",
31487
+ addonId: null,
31488
+ access: "view"
31489
+ },
31490
+ "pipelineAnalytics.countUnstampedEventMedia": {
31491
+ capName: "pipeline-analytics",
31492
+ capScope: "device",
31493
+ addonId: null,
31494
+ access: "view"
31495
+ },
31103
31496
  "pipelineAnalytics.deleteDeviceEvents": {
31104
31497
  capName: "pipeline-analytics",
31105
31498
  capScope: "device",
@@ -32258,6 +32651,12 @@ Object.freeze({
32258
32651
  addonId: null,
32259
32652
  access: "view"
32260
32653
  },
32654
+ "recording.getRelocateResidue": {
32655
+ capName: "recording",
32656
+ capScope: "system",
32657
+ addonId: null,
32658
+ access: "view"
32659
+ },
32261
32660
  "recording.getStorageMigrationMoveStatus": {
32262
32661
  capName: "recording",
32263
32662
  capScope: "system",
@@ -32804,12 +33203,30 @@ Object.freeze({
32804
33203
  addonId: null,
32805
33204
  access: "create"
32806
33205
  },
33206
+ "storageMigration.drain": {
33207
+ capName: "storage-migration",
33208
+ capScope: "system",
33209
+ addonId: null,
33210
+ access: "create"
33211
+ },
33212
+ "storageMigration.movers": {
33213
+ capName: "storage-migration",
33214
+ capScope: "system",
33215
+ addonId: null,
33216
+ access: "view"
33217
+ },
32807
33218
  "storageMigration.plan": {
32808
33219
  capName: "storage-migration",
32809
33220
  capScope: "system",
32810
33221
  addonId: null,
32811
33222
  access: "view"
32812
33223
  },
33224
+ "storageMigration.residue": {
33225
+ capName: "storage-migration",
33226
+ capScope: "system",
33227
+ addonId: null,
33228
+ access: "view"
33229
+ },
32813
33230
  "storageMigration.start": {
32814
33231
  capName: "storage-migration",
32815
33232
  capScope: "system",
@@ -33644,6 +34061,12 @@ Object.freeze({
33644
34061
  addonId: null,
33645
34062
  access: "delete"
33646
34063
  },
34064
+ "vectorStore.fetchByIds": {
34065
+ capName: "vector-store",
34066
+ capScope: "system",
34067
+ addonId: null,
34068
+ access: "view"
34069
+ },
33647
34070
  "vectorStore.getByIds": {
33648
34071
  capName: "vector-store",
33649
34072
  capScope: "system",
@@ -33656,6 +34079,12 @@ Object.freeze({
33656
34079
  addonId: null,
33657
34080
  access: "view"
33658
34081
  },
34082
+ "vectorStore.scan": {
34083
+ capName: "vector-store",
34084
+ capScope: "system",
34085
+ addonId: null,
34086
+ access: "view"
34087
+ },
33659
34088
  "vectorStore.stats": {
33660
34089
  capName: "vector-store",
33661
34090
  capScope: "system",
@@ -8056,18 +8056,61 @@ var RelocateFootageInputSchema = object({
8056
8056
  * `RecordingConfig.enabled` or camera wrapper bindings. */
8057
8057
  var StorageMigrationLeaseInputSchema = object({ leaseId: string().min(1) });
8058
8058
  var StorageMigrationFootageMoveInputSchema = RelocateFootageInputSchema.extend({ leaseId: string().min(1) });
8059
+ /**
8060
+ * What a `relocateMedia` pass DOES. One engine, three passes — never a second
8061
+ * mover (the engine already walks both collections with a timestamp cursor and
8062
+ * already has a stamp-without-copy path).
8063
+ *
8064
+ * - `move` — the default and the historical behaviour: event-media and
8065
+ * retrain blobs move to `toLocationId` and their rows are
8066
+ * stamped. The enrolled gallery is skipped (D197).
8067
+ * - `seal` — ROWS ONLY, no bytes. Every row whose `locationId` is NULL is
8068
+ * stamped with `toLocationId`. `toLocationId` here is the id the
8069
+ * bytes ALREADY sit on — today's `eventMedia` default — because
8070
+ * a NULL row means "wherever `eventMedia` points *now*", and the
8071
+ * instant a repoint moves that pointer the row reads from the
8072
+ * new disk while its bytes are on the old one.
8073
+ * - `gallery` — the inverse selection of `move`: ONLY the retention-exempt
8074
+ * (enrolled-gallery) rows, which `move` deliberately skips.
8075
+ * `galleryMedia` is `cardinality: 'single'`, so this pass can
8076
+ * never run beside a live second location: it is stop-the-world
8077
+ * by construction, which is acceptable only because the gallery
8078
+ * is a few KB per enrolled sample.
8079
+ */
8080
+ var MediaRelocateModeSchema = _enum([
8081
+ "move",
8082
+ "seal",
8083
+ "gallery"
8084
+ ]);
8059
8085
  var RelocateMediaInputSchema = object({
8060
8086
  toLocationId: string(),
8061
- throttleMbps: number().min(1).max(1e3).optional()
8087
+ throttleMbps: number().min(1).max(1e3).optional(),
8088
+ /** Omitted = `move`, the pre-existing behaviour. */
8089
+ mode: MediaRelocateModeSchema.optional()
8090
+ });
8091
+ /** How many rows still carry NO `locationId` — the population a repoint would
8092
+ * silently re-aim at a disk that does not hold their bytes. Zero is the only
8093
+ * value that permits a non-blocking `eventMedia` cutover. */
8094
+ var UnstampedEventMediaCountSchema = object({
8095
+ media: number().int().nonnegative(),
8096
+ retrainFrames: number().int().nonnegative(),
8097
+ total: number().int().nonnegative()
8062
8098
  });
8063
8099
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8064
- /** The independently selectable logical storage classes. `recordings`
8065
- * encompasses the high and mid segment profiles; `recordingsLow` is low
8066
- * segments; `eventMedia` is post-analysis blobs. */
8100
+ /** The independently selectable logical storage classes — every class
8101
+ * `storage.listLocationDeclarations` reports, so an operator never meets a
8102
+ * Zod enum error where they should meet an explanation.
8103
+ *
8104
+ * `recordings` encompasses the high and mid segment profiles; `recordingsLow`
8105
+ * is low segments; `eventMedia` is post-analysis blobs; `galleryMedia` is the
8106
+ * enrolled gallery; `backups` is the system backup archive. The last two have
8107
+ * their own rules — see {@link StorageMigrationFindingCodeSchema}. */
8067
8108
  var StorageMigrationClassSchema = _enum([
8068
8109
  "recordings",
8069
8110
  "recordingsLow",
8070
- "eventMedia"
8111
+ "eventMedia",
8112
+ "backups",
8113
+ "galleryMedia"
8071
8114
  ]);
8072
8115
  /** A destination is always an existing, fully-qualified location id. The
8073
8116
  * migration API intentionally never changes a source location's `basePath`:
@@ -8075,20 +8118,56 @@ var StorageMigrationClassSchema = _enum([
8075
8118
  var StorageMigrationDestinationsSchema = object({
8076
8119
  recordings: string().min(1).optional(),
8077
8120
  recordingsLow: string().min(1).optional(),
8078
- eventMedia: string().min(1).optional()
8121
+ eventMedia: string().min(1).optional(),
8122
+ backups: string().min(1).optional(),
8123
+ galleryMedia: string().min(1).optional()
8079
8124
  }).refine((value) => Object.keys(value).length > 0, { message: "select at least one storage class" });
8125
+ /**
8126
+ * How a migration sequences the cutover against the byte move.
8127
+ *
8128
+ * - `blocking` — the historical order: pause, move every byte, repoint,
8129
+ * resume. Recording is stopped for the whole move. Right
8130
+ * for a small or a cold class, and the only legal mode for
8131
+ * a `cardinality: 'single'` class.
8132
+ * - `nonBlocking` — repoint FIRST, drain behind: seal, pause, repoint,
8133
+ * refresh, resume, then move the past with everything
8134
+ * running. The pause is three bounded instants (a detach +
8135
+ * attach round, a write-gate drain, a lease) instead of one
8136
+ * bounded by bytes. 1.09 TB at 7–14 MB/s is thirty hours of
8137
+ * stopped recording under `blocking`; the same move is
8138
+ * seconds of stopped recording under `nonBlocking`.
8139
+ *
8140
+ * The mode is on the JOB, not only on the input, because `status` is where an
8141
+ * operator finds out which one is running.
8142
+ */
8143
+ var StorageMigrationModeSchema = _enum(["blocking", "nonBlocking"]);
8080
8144
  /** Shared input for planning and starting an orchestrated storage migration. */
8081
8145
  var StorageMigrationInputSchema = object({
8082
8146
  destinations: StorageMigrationDestinationsSchema,
8083
- throttleMbps: number().min(1).max(1e3).optional()
8147
+ throttleMbps: number().min(1).max(1e3).optional(),
8148
+ /** Omitted = `blocking`, which stays the default. */
8149
+ mode: StorageMigrationModeSchema.optional()
8084
8150
  });
8085
- /** The durable coordinator state machine. The only phase that changes default
8086
- * locations is `repointing`, after every selected mover has completed and been
8087
- * verified. */
8151
+ /**
8152
+ * The durable coordinator state machine.
8153
+ *
8154
+ * `blocking`:
8155
+ * planning → pausing → moving → verifying → repointing → refreshing → resuming → done
8156
+ *
8157
+ * `nonBlocking`:
8158
+ * planning → sealing → pausing → repointing → refreshing → resuming → draining → verifying → done
8159
+ *
8160
+ * Same phases, different order plus two new ones — not a second mover.
8161
+ * `sealing` closes the `eventMedia` NULL-row hole BEFORE anything is paused;
8162
+ * `draining` runs the same movers UNLEASED, after every writer is back up.
8163
+ * `repointing` is still the only phase that changes a default location.
8164
+ */
8088
8165
  var StorageMigrationPhaseSchema = _enum([
8089
8166
  "planning",
8167
+ "sealing",
8090
8168
  "pausing",
8091
8169
  "moving",
8170
+ "draining",
8092
8171
  "verifying",
8093
8172
  "repointing",
8094
8173
  "refreshing",
@@ -8102,17 +8181,56 @@ var StorageMigrationParticipantSchema = _enum([
8102
8181
  "recorder",
8103
8182
  "analytics"
8104
8183
  ]);
8184
+ /**
8185
+ * The mover's own numbers, folded onto the coordinator's durable move record.
8186
+ *
8187
+ * The long half of a non-blocking migration is `draining`, and it is measured
8188
+ * in hours: 136 885 files at ~4 MB/s is about five of them. Before this shape
8189
+ * existed the only place those numbers appeared was a Loki line, so an operator
8190
+ * watching the Admin UI saw `phase: draining` and nothing else for a whole
8191
+ * afternoon.
8192
+ *
8193
+ * It is POLLED, never pushed. Events are telemetry and may be dropped
8194
+ * (D8/D11), and a dropped progress event is indistinguishable from a stalled
8195
+ * mover — which is the exact failure this is meant to end. The coordinator's
8196
+ * `waitForMoves` already fetches the whole {@link RelocateJob} on every tick to
8197
+ * read `state`; folding the counters costs no extra read and makes the durable
8198
+ * record say afterwards how far a move actually got.
8199
+ *
8200
+ * `filesTotal` is `null` for "no honest denominator" and is never zero-filled:
8201
+ * a windowed footage job (`sinceMs`) and a node with no ledger both genuinely
8202
+ * cannot say M, and a 0 there would render as "100 % done".
8203
+ */
8204
+ var StorageMigrationMoveProgressSchema = object({
8205
+ filesMoved: number().int().nonnegative(),
8206
+ /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8207
+ filesTotal: number().int().nonnegative().nullable(),
8208
+ bytesMoved: number().int().nonnegative(),
8209
+ /** The MOVER's start, not the migration's: a drain restarted after an addon
8210
+ * crash gets a new mover, and a rate computed from the migration's start
8211
+ * would silently average in the time nothing was running. */
8212
+ startedAt: number(),
8213
+ /** When the coordinator last read these numbers. Paired with `startedAt` it
8214
+ * is the only honest rate: both clocks are the hub's, so a UI never has to
8215
+ * subtract its own. */
8216
+ observedAt: number()
8217
+ });
8105
8218
  var StorageMigrationMoveSchema = object({
8106
8219
  storageClass: StorageMigrationClassSchema,
8107
8220
  fromLocationId: string(),
8108
8221
  toLocationId: string(),
8109
8222
  moverJobId: string().nullable(),
8110
8223
  state: RelocateJobStateSchema.nullable(),
8111
- error: string().nullable()
8224
+ error: string().nullable(),
8225
+ /** Last observed mover counters; `null` until the mover has been polled once. */
8226
+ progress: StorageMigrationMoveProgressSchema.nullable()
8112
8227
  });
8113
8228
  var StorageMigrationJobSchema = object({
8114
8229
  jobId: string(),
8115
8230
  phase: StorageMigrationPhaseSchema,
8231
+ /** Which order this job is running. `status` is the only place an operator
8232
+ * can tell a seconds-long cutover from a thirty-hour one. */
8233
+ mode: StorageMigrationModeSchema,
8116
8234
  destinations: StorageMigrationDestinationsSchema,
8117
8235
  throttleMbps: number(),
8118
8236
  moves: array(StorageMigrationMoveSchema),
@@ -8125,13 +8243,122 @@ var StorageMigrationJobSchema = object({
8125
8243
  finishedAt: number().nullable(),
8126
8244
  error: string().nullable()
8127
8245
  });
8246
+ var StorageMigrationFindingSchema = object({
8247
+ code: _enum([
8248
+ "sharesDeviceWithSource",
8249
+ "deviceIdentityUnknown",
8250
+ "unstampedEventMediaRows",
8251
+ "blockingOnly",
8252
+ "noMover"
8253
+ ]),
8254
+ storageClass: StorageMigrationClassSchema,
8255
+ /** Human-readable, already carrying the ids and counts. */
8256
+ message: string()
8257
+ });
8128
8258
  var StorageMigrationPlanSchema = object({
8129
8259
  destinations: StorageMigrationDestinationsSchema,
8260
+ /** The mode this plan was built for. A plan is only valid for its mode: the
8261
+ * `eventMedia` seal gate and the single-cardinality refusal both depend on
8262
+ * it. */
8263
+ mode: StorageMigrationModeSchema,
8130
8264
  moves: array(object({
8131
8265
  storageClass: StorageMigrationClassSchema,
8132
8266
  fromLocationId: string(),
8133
8267
  toLocationId: string()
8134
- }))
8268
+ })),
8269
+ findings: array(StorageMigrationFindingSchema)
8270
+ });
8271
+ /**
8272
+ * A mover as it exists RIGHT NOW, whether or not a migration job owns it.
8273
+ *
8274
+ * The coordinator's job record is the state of record for a migration, and its
8275
+ * moves carry {@link StorageMigrationMoveProgress}. But the movers are usable
8276
+ * standalone — `recording.relocateFootage` and `pipelineAnalytics.relocateMedia`
8277
+ * are both operator-callable, and on 2026-08-29 a five-hour drain was armed that
8278
+ * way because no supported UI path existed. A mover armed like that has no job
8279
+ * to fold progress into, so it has to be readable on its own or it is invisible.
8280
+ *
8281
+ * `migrationJobId` is what tells the two apart: `null` means nothing here
8282
+ * orchestrated it.
8283
+ */
8284
+ var StorageMigrationMoverSchema = object({
8285
+ lane: _enum(["footage", "media"]),
8286
+ job: RelocateJobSchema,
8287
+ /** The coordinator job that armed this mover, or `null` for a mover armed
8288
+ * directly against the owning addon. */
8289
+ migrationJobId: string().nullable(),
8290
+ /** When the hub read these counters. Stamped here so a rate is `bytesMoved`
8291
+ * over (`observedAt` − `job.startedAt`) with BOTH ends on the hub's clock —
8292
+ * a browser subtracting its own `Date.now()` from a server `startedAt` is a
8293
+ * rate made of two different clocks. */
8294
+ observedAt: number()
8295
+ });
8296
+ /**
8297
+ * What a SOURCE still holds for one storage class — the number that makes a
8298
+ * "drain remaining" action honest rather than hopeful.
8299
+ *
8300
+ * It comes from the archive (`SegmentHourLedger.census` for footage, the media
8301
+ * engine's own selection count for media), never from the resident index: a
8302
+ * drain sized off `RecordingIndex` is what reported `done` over 80.3 GB it had
8303
+ * never been told about (D295).
8304
+ *
8305
+ * `items`/`bytes` are `null` for "the archive could not be asked", which is
8306
+ * deliberately NOT zero: a drain is still offered for an unknown residue,
8307
+ * because refusing on an unanswerable read would hide exactly the case an
8308
+ * operator needs to act on.
8309
+ */
8310
+ var StorageMigrationResidueSchema = object({
8311
+ storageClass: StorageMigrationClassSchema,
8312
+ /** The location still holding the data. `'*'` for the media lane, whose rows
8313
+ * move from wherever they are rather than from one named source. */
8314
+ fromLocationId: string(),
8315
+ /** Where a drain would move it — the class's CURRENT default. */
8316
+ toLocationId: string(),
8317
+ /** Segments (footage lane) or rows (media lane) still on the source. */
8318
+ items: number().int().nonnegative().nullable(),
8319
+ /** Bytes on the source; `null` when the lane counts rows rather than bytes. */
8320
+ bytes: number().int().nonnegative().nullable()
8321
+ });
8322
+ /**
8323
+ * Run the DRAIN half and nothing else.
8324
+ *
8325
+ * A migration that reached `done` has already repointed, so `start` correctly
8326
+ * refuses its destination ("already the default") — there is nothing left to
8327
+ * repoint. But the drain can fail, be cancelled, be interrupted by a restart,
8328
+ * or finish against a work list that was a tenth of the archive (D295), and
8329
+ * before this there was no supported way to run only that half: the only way
8330
+ * through was calling `recording.relocateFootage` by hand over admin tRPC.
8331
+ *
8332
+ * `drain` NEVER calls `setDefaultLocations`. That is what keeps `start`'s
8333
+ * refusal meaningful: the two verbs are disjoint, so nothing here can silently
8334
+ * re-repoint a class that is already migrated.
8335
+ */
8336
+ var StorageMigrationDrainInputSchema = object({
8337
+ /** The classes to drain. Each must appear in `storageMigration.residue`, so
8338
+ * a class whose source is already empty is refused rather than started. */
8339
+ classes: array(StorageMigrationClassSchema).min(1),
8340
+ throttleMbps: number().min(1).max(1e3).optional()
8341
+ });
8342
+ /** What a footage source still holds, asked of the durable hour ledger. */
8343
+ var RelocateResidueInputSchema = object({
8344
+ fromLocationId: string().min(1),
8345
+ /** Narrow to one logical class; omit for every profile on the location. */
8346
+ footageClass: RelocateFootageClassSchema.optional()
8347
+ });
8348
+ /** `null` = the archive could not answer (no ledger on this node, or the
8349
+ * aggregate failed). Never conflated with an empty source. */
8350
+ var RelocateResidueSchema = object({
8351
+ segments: number().int().nonnegative(),
8352
+ bytes: number().int().nonnegative()
8353
+ }).nullable();
8354
+ /** How many rows a media pass would still act on against a given target — the
8355
+ * media lane's denominator AND its residue, from ONE derivation so the two can
8356
+ * never disagree. `null` = the count could not be taken. */
8357
+ var RelocatableMediaCountSchema = object({ rows: number().int().nonnegative() }).nullable();
8358
+ var RelocatableMediaCountInputSchema = object({
8359
+ toLocationId: string().min(1),
8360
+ /** Omitted = `move`. */
8361
+ mode: MediaRelocateModeSchema.optional()
8135
8362
  });
8136
8363
  /**
8137
8364
  * `StorageLocationType` — an addon-declared id that identifies the *kind* of
@@ -8237,6 +8464,32 @@ var StorageLocationRefSchema = union([StorageLocationTypeSchema, string().regex(
8237
8464
  * two addons declaring the same `id` must agree on `cardinality` (validated
8238
8465
  * at kernel aggregation time, not here).
8239
8466
  */
8467
+ /**
8468
+ * `StorageAccess` — how the service that DECLARED a storage-location kind
8469
+ * actually reaches the bytes. It is the constraint that decides which
8470
+ * `storage-provider`s may back a location of that kind.
8471
+ *
8472
+ * - `'local-path'` — the service asks `storage.resolve` for a path string and
8473
+ * then does its own `node:fs` I/O on it (the recorder's segment writer, the
8474
+ * post-analysis media roots). Only a provider that serves a genuine local
8475
+ * filesystem (`getProviderInfo().nodeLocal === true`) can satisfy that: a
8476
+ * remote provider's `resolve` returns a path on the REMOTE host, and
8477
+ * `fs.readdir` of it on this node either fails or — far worse — succeeds
8478
+ * against a same-named local directory that is something else entirely.
8479
+ *
8480
+ * - `'cap-mediated'` — every byte travels through the `storage` cap
8481
+ * (`read`/`write`, or `beginUpload`/`writeChunk`/`finalizeUpload`). The
8482
+ * service never sees a path, so any provider can back it. `backups` is the
8483
+ * one kind that qualifies today.
8484
+ *
8485
+ * Before this existed, `recordings` was unreachable by SFTP/S3/WebDAV only as
8486
+ * an EMERGENT property of how the recorder happened to be written. Nothing
8487
+ * refused the configuration; the first write simply went somewhere wrong, and
8488
+ * a recording write that goes wrong surfaces as a silent black window rather
8489
+ * than an error (the read path does not `stat`). This turns that accident into
8490
+ * a declared, enforced, testable refusal.
8491
+ */
8492
+ var StorageAccessSchema = _enum(["local-path", "cap-mediated"]);
8240
8493
  var StorageLocationDeclarationSchema = object({
8241
8494
  /**
8242
8495
  * Global location identifier, e.g. `recordings` or `recordingsLow`.
@@ -8256,6 +8509,19 @@ var StorageLocationDeclarationSchema = object({
8256
8509
  */
8257
8510
  cardinality: _enum(["single", "multi"]),
8258
8511
  /**
8512
+ * HOW the declaring service reaches the bytes — and therefore WHICH
8513
+ * providers may back a location of this kind. See {@link StorageAccessSchema}
8514
+ * and {@link STORAGE_ACCESS_FALLBACK}.
8515
+ *
8516
+ * Absent means `'local-path'`. That default is FAIL-CLOSED on purpose: it
8517
+ * can only over-restrict (refuse a remote provider for a kind that might
8518
+ * have coped) and never under-restrict. Declaring `'cap-mediated'` is the
8519
+ * permissive direction and is therefore never inferred — a repo guard
8520
+ * (`scripts/check-storage-access-declarations.ts`) refuses to let it be
8521
+ * reached by omission.
8522
+ */
8523
+ access: StorageAccessSchema.optional(),
8524
+ /**
8259
8525
  * When set, the default instance for this location inherits its resolved
8260
8526
  * root from the named location's default instance. Useful for derivative
8261
8527
  * slots (e.g. `recordingsLow` → `recordings`) so operators only need to
@@ -17798,8 +18064,10 @@ var TrackSchema = object({
17798
18064
  lastSeen: number(),
17799
18065
  /** Frame-rate position history (subject to maxPositionHistory cap). */
17800
18066
  positions: array(TrackPositionSchema).readonly(),
17801
- /** Periodic snapshots at snapshotIntervalMs cadence (subject to
17802
- * saveThumbnails policy). */
18067
+ /** Periodic snapshots at snapshotIntervalMs cadence — DEBUG media, produced
18068
+ * only while `MediaSettings.debugMediaEnabled` is on for the camera (D299;
18069
+ * the retired `saveThumbnails` used to gate this and the rolling
18070
+ * `lastFrame` together). Empty is the healthy default, not a capture gap. */
17803
18071
  snapshots: array(TrackSnapshotSchema).readonly(),
17804
18072
  /** Deduplicated zones the track has entered at least once. Zone IDS. */
17805
18073
  zonesVisited: array(string()).readonly(),
@@ -18659,6 +18927,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18659
18927
  }), method(RelocateMediaInputSchema, object({ jobId: string() }), {
18660
18928
  kind: "mutation",
18661
18929
  auth: "admin"
18930
+ }), method(object({}), UnstampedEventMediaCountSchema, { auth: "admin" }), method(RelocatableMediaCountInputSchema, RelocatableMediaCountSchema, {
18931
+ kind: "query",
18932
+ auth: "admin"
18662
18933
  }), method(object({}), array(RelocateJobSchema).readonly(), {
18663
18934
  kind: "query",
18664
18935
  auth: "admin"
@@ -20566,7 +20837,10 @@ method(object({
20566
20837
  }), StorageLocationSchema, {
20567
20838
  kind: "mutation",
20568
20839
  auth: "admin"
20569
- }), method(object({ id: string() }), _void(), {
20840
+ }), method(object({
20841
+ id: string(),
20842
+ force: boolean().optional()
20843
+ }), _void(), {
20570
20844
  kind: "mutation",
20571
20845
  auth: "admin"
20572
20846
  }), method(object({ id: string() }), object({
@@ -20615,6 +20889,9 @@ method(StorageMigrationInputSchema, StorageMigrationPlanSchema, { auth: "admin"
20615
20889
  }), method(object({ jobId: string().optional() }), StorageMigrationJobSchema.nullable(), { auth: "admin" }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
20616
20890
  kind: "mutation",
20617
20891
  auth: "admin"
20892
+ }), method(object({}), array(StorageMigrationMoverSchema).readonly(), { auth: "admin" }), method(object({}), array(StorageMigrationResidueSchema).readonly(), { auth: "admin" }), method(StorageMigrationDrainInputSchema, object({ jobId: string() }), {
20893
+ kind: "mutation",
20894
+ auth: "admin"
20618
20895
  });
20619
20896
  var ProviderInfoSchema = discriminatedUnion("shouldSaveDiskSpace", [object({
20620
20897
  providerId: string().min(1),
@@ -21013,12 +21290,38 @@ response: record(string(), unknown()) }), object({
21013
21290
  *
21014
21291
  * ## Why this is a capability and not a helper
21015
21292
  *
21016
- * Six stores in `addon-post-analysis` already hold vectors — object CLIP, face,
21017
- * plate, vehicle, identity, and the event store's derivatives — and every one of
21018
- * them keeps its vectors in a `JSON` settings-store column and ranks them by
21019
- * brute-force cosine in JS. Measured on the live hub that costs ~11.7 KB per row
21020
- * (512 floats as TEXT, `JSON.parse`d on every search) and made semantic search
21021
- * load 5,000 rows before ranking anything.
21293
+ * This capability was introduced with the claim that SIX stores in
21294
+ * `addon-post-analysis` held vectors in a `JSON` settings-store column — object
21295
+ * CLIP, face, plate, vehicle, identity, and the event store's derivatives. That
21296
+ * claim was never true, and leaving it here made five stores look like pending
21297
+ * work when three of them have no vector at all. Counted column by column on
21298
+ * 2026-08-30, exactly THREE ever held one:
21299
+ *
21300
+ * - `object-clip` — 512-dim CLIP image embedding, migrated 2026-08-06.
21301
+ * - `faces.embedding` — 512-dim ArcFace face embedding, migrated 2026-08-30.
21302
+ * - `identity-samples.embedding` — the same ArcFace vector for an ENROLLED
21303
+ * face, migrated 2026-08-30 into its OWN index (see below).
21304
+ *
21305
+ * `plates` and `vehicle-samples` store a plate STRING and a score; `vehicles`
21306
+ * and `identities` store a name; the event store stores no derivative vector.
21307
+ * They are not migration candidates and never were.
21308
+ *
21309
+ * Measured on the live hub the JSON encoding cost ~11.7 KB per row (512 floats
21310
+ * as TEXT, `JSON.parse`d on every search) and made semantic search load 5,000
21311
+ * rows before ranking anything.
21312
+ *
21313
+ * ## One index per COMPARISON, never per encoder
21314
+ *
21315
+ * `faces` and `identity-samples` hold the same 512 ArcFace dims from the same
21316
+ * model, and they still get two indexes. An index is a set of things that are
21317
+ * ranked against each other and that live and die together, and these two are
21318
+ * neither: a `faces` row is TRACK-OWNED and cascades away with its track under
21319
+ * a per-camera capacity cap, an `identity-samples` row is retention-EXEMPT
21320
+ * forever and is the gallery every recognition ranks against. One index would
21321
+ * mean every gallery load and every reconcile carried a filter whose failure
21322
+ * mode is either ranking a candidate against itself or reclaiming an enrolled
21323
+ * person's only sample. The dimension they share is not a reason to share an
21324
+ * index; the question they answer is, and it differs.
21022
21325
  *
21023
21326
  * The fix is not a faster loop, it is a different backend — and the backend
21024
21327
  * should be replaceable without touching six callers. So: a singleton
@@ -21123,7 +21426,20 @@ var VectorQueryResultSchema = object({
21123
21426
  */
21124
21427
  scanned: number(),
21125
21428
  /** True when the backend could not consider every row that passed the filter. */
21126
- truncated: boolean()
21429
+ truncated: boolean(),
21430
+ /**
21431
+ * The `topK` the backend actually ran with.
21432
+ *
21433
+ * Every backend has a ceiling — sqlite-vec's is 4,096 — and a caller asking
21434
+ * past it used to learn nothing but a boolean, from a WARN in the provider's
21435
+ * own log rather than in its answer. That is how an audit asking for 20,000
21436
+ * consumed 4,096 and reported `examined: 4096` as if it had walked the index,
21437
+ * for weeks. `truncated` says THAT the answer was short; this says BY HOW
21438
+ * MUCH, in the return value, where the caller cannot fail to see it.
21439
+ *
21440
+ * Equals the requested `topK` whenever nothing was lowered.
21441
+ */
21442
+ effectiveTopK: number().int().positive()
21127
21443
  });
21128
21444
  var VectorDeleteInputSchema = object({
21129
21445
  index: string(),
@@ -21152,6 +21468,68 @@ var VectorGetResultSchema = object({ items: array(object({
21152
21468
  id: string(),
21153
21469
  metadata: VectorMetadataSchema
21154
21470
  })) });
21471
+ /**
21472
+ * Ids to read back WITH their vectors.
21473
+ *
21474
+ * The sibling of {@link VectorGetResultSchema}, and deliberately a separate
21475
+ * method rather than a flag on it: `getByIds` promises no vectors and its one
21476
+ * caller depends on that promise. This one promises the opposite.
21477
+ *
21478
+ * It exists because a store cannot put its vectors here otherwise. An ArcFace
21479
+ * gallery is ranked IN PROCESS, per detection, against every enrolled sample —
21480
+ * a per-face cross-process KNN would be a network round trip inside the
21481
+ * recognition loop. So the gallery is loaded once and held in RAM, and loading
21482
+ * it requires the index to hand the floats back. Without this method the only
21483
+ * way to keep a readable vector is a JSON column, which is the thing this
21484
+ * capability exists to delete.
21485
+ *
21486
+ * BOUNDED BY THE CALLER: ids are named, never "everything". Enumerating an
21487
+ * index is {@link VectorScanInputSchema}'s job, and it returns no vectors.
21488
+ */
21489
+ var VectorFetchInputSchema = object({
21490
+ index: string(),
21491
+ ids: array(string())
21492
+ });
21493
+ var VectorFetchResultSchema = object({ items: array(object({
21494
+ id: string(),
21495
+ /** base64 Float32LE — the same wire form `upsert` accepts. */
21496
+ vector: string(),
21497
+ metadata: VectorMetadataSchema
21498
+ })) });
21499
+ /**
21500
+ * ENUMERATE an index: one page of rows in a stable order, no ranking.
21501
+ *
21502
+ * A reconcile does not want the nearest rows, it wants ALL of them, and asking
21503
+ * a KNN for "all" is the wrong question twice over. It hits the backend's `k`
21504
+ * ceiling — 4,096 on sqlite-vec against a 22,128-row index — and it needs a
21505
+ * probe vector it does not have, so the audit passed a ZERO vector whose cosine
21506
+ * distance to every row is degenerate. `examined: 4096` then read as "we
21507
+ * looked" for as long as anyone cared to read it.
21508
+ *
21509
+ * This is the primitive that question actually needs: a bounded page, ordered
21510
+ * by the backend's own row order, costing no distance computation at all.
21511
+ * Vectors are NOT returned — an enumeration that shipped 2 KB per row would be
21512
+ * the full-table read this capability was built to stop.
21513
+ */
21514
+ var VectorScanInputSchema = object({
21515
+ index: string(),
21516
+ /** Opaque resume point. `0` starts at the top; pass back `nextCursor`. */
21517
+ cursor: number().int().nonnegative().default(0),
21518
+ limit: number().int().positive()
21519
+ });
21520
+ var VectorScanResultSchema = object({
21521
+ items: array(object({
21522
+ id: string(),
21523
+ metadata: VectorMetadataSchema
21524
+ })),
21525
+ /**
21526
+ * Where the next page starts, or `null` when the walk reached the end.
21527
+ *
21528
+ * `null` is the ONLY end-of-index signal. A caller must not infer the end
21529
+ * from a short page: a backend is free to return fewer rows than asked.
21530
+ */
21531
+ nextCursor: number().int().nonnegative().nullable()
21532
+ });
21155
21533
  var VectorStatsInputSchema = object({ index: string() });
21156
21534
  var VectorStatsResultSchema = object({
21157
21535
  /** Provider id, so an operator can tell brute force from an ANN index. */
@@ -21170,7 +21548,7 @@ method(VectorDeclareIndexInputSchema, _void(), {
21170
21548
  }), method(VectorUpsertInputSchema, VectorUpsertResultSchema, {
21171
21549
  kind: "mutation",
21172
21550
  auth: "admin"
21173
- }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21551
+ }), method(VectorQueryInputSchema, VectorQueryResultSchema, { auth: "admin" }), method(VectorGetInputSchema, VectorGetResultSchema, { auth: "admin" }), method(VectorFetchInputSchema, VectorFetchResultSchema, { auth: "admin" }), method(VectorScanInputSchema, VectorScanResultSchema, { auth: "admin" }), method(VectorDeleteInputSchema, VectorDeleteResultSchema, {
21174
21552
  kind: "mutation",
21175
21553
  auth: "admin"
21176
21554
  }), method(VectorDeleteByFilterInputSchema, VectorDeleteResultSchema, {
@@ -26135,6 +26513,9 @@ method(object({
26135
26513
  }), method(object({}), array(RelocateJobSchema).readonly(), {
26136
26514
  kind: "query",
26137
26515
  auth: "admin"
26516
+ }), method(RelocateResidueInputSchema, RelocateResidueSchema, {
26517
+ kind: "query",
26518
+ auth: "admin"
26138
26519
  }), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
26139
26520
  kind: "mutation",
26140
26521
  auth: "admin"
@@ -31100,6 +31481,18 @@ Object.freeze({
31100
31481
  addonId: null,
31101
31482
  access: "create"
31102
31483
  },
31484
+ "pipelineAnalytics.countRelocatableMedia": {
31485
+ capName: "pipeline-analytics",
31486
+ capScope: "device",
31487
+ addonId: null,
31488
+ access: "view"
31489
+ },
31490
+ "pipelineAnalytics.countUnstampedEventMedia": {
31491
+ capName: "pipeline-analytics",
31492
+ capScope: "device",
31493
+ addonId: null,
31494
+ access: "view"
31495
+ },
31103
31496
  "pipelineAnalytics.deleteDeviceEvents": {
31104
31497
  capName: "pipeline-analytics",
31105
31498
  capScope: "device",
@@ -32258,6 +32651,12 @@ Object.freeze({
32258
32651
  addonId: null,
32259
32652
  access: "view"
32260
32653
  },
32654
+ "recording.getRelocateResidue": {
32655
+ capName: "recording",
32656
+ capScope: "system",
32657
+ addonId: null,
32658
+ access: "view"
32659
+ },
32261
32660
  "recording.getStorageMigrationMoveStatus": {
32262
32661
  capName: "recording",
32263
32662
  capScope: "system",
@@ -32804,12 +33203,30 @@ Object.freeze({
32804
33203
  addonId: null,
32805
33204
  access: "create"
32806
33205
  },
33206
+ "storageMigration.drain": {
33207
+ capName: "storage-migration",
33208
+ capScope: "system",
33209
+ addonId: null,
33210
+ access: "create"
33211
+ },
33212
+ "storageMigration.movers": {
33213
+ capName: "storage-migration",
33214
+ capScope: "system",
33215
+ addonId: null,
33216
+ access: "view"
33217
+ },
32807
33218
  "storageMigration.plan": {
32808
33219
  capName: "storage-migration",
32809
33220
  capScope: "system",
32810
33221
  addonId: null,
32811
33222
  access: "view"
32812
33223
  },
33224
+ "storageMigration.residue": {
33225
+ capName: "storage-migration",
33226
+ capScope: "system",
33227
+ addonId: null,
33228
+ access: "view"
33229
+ },
32813
33230
  "storageMigration.start": {
32814
33231
  capName: "storage-migration",
32815
33232
  capScope: "system",
@@ -33644,6 +34061,12 @@ Object.freeze({
33644
34061
  addonId: null,
33645
34062
  access: "delete"
33646
34063
  },
34064
+ "vectorStore.fetchByIds": {
34065
+ capName: "vector-store",
34066
+ capScope: "system",
34067
+ addonId: null,
34068
+ access: "view"
34069
+ },
33647
34070
  "vectorStore.getByIds": {
33648
34071
  capName: "vector-store",
33649
34072
  capScope: "system",
@@ -33656,6 +34079,12 @@ Object.freeze({
33656
34079
  addonId: null,
33657
34080
  access: "view"
33658
34081
  },
34082
+ "vectorStore.scan": {
34083
+ capName: "vector-store",
34084
+ capScope: "system",
34085
+ addonId: null,
34086
+ access: "view"
34087
+ },
33659
34088
  "vectorStore.stats": {
33660
34089
  capName: "vector-store",
33661
34090
  capScope: "system",
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_dist = require("../dist-XsZAD0zE.js");
5
+ const require_dist = require("../dist-ki6Kt6cL.js");
6
6
  let node_crypto = require("node:crypto");
7
7
  let node_child_process = require("node:child_process");
8
8
  //#region src/ingress/tailscale-cli.ts
@@ -1,4 +1,4 @@
1
- import { a as EventCategory, i as BaseAddon, n as networkAccessCapability } from "../dist-D1h1qkz3.mjs";
1
+ import { a as EventCategory, i as BaseAddon, n as networkAccessCapability } from "../dist-RluxJbgF.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import { execFile } from "node:child_process";
4
4
  import { promisify } from "node:util";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-tailscale",
3
- "version": "1.2.42",
3
+ "version": "1.2.45",
4
4
  "description": "Tailscale bundle for CamStack — joins the host to a tailnet (client) and exposes the hub via Serve/Funnel (ingress). Multi-entry npm package shipping 2 addons under a single bundle.",
5
5
  "keywords": [
6
6
  "camstack",