@camstack/addon-remote-storage 1.2.44 → 1.2.46

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.
package/dist/s3.addon.js CHANGED
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_shared = require("./shared-CzYVi403.js");
5
+ const require_shared = require("./shared-DAxSJcnX.js");
6
6
  let node_stream = require("node:stream");
7
7
  let _aws_sdk_client_s3 = require("@aws-sdk/client-s3");
8
8
  let _aws_sdk_lib_storage = require("@aws-sdk/lib-storage");
package/dist/s3.addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { c as BaseAddon, i as rearmIdleAbort, n as getOptionalBasePath, o as scheduleIdleAbort, s as storageProviderCapability, t as createSessionId } from "./shared-DsnRUNmJ.mjs";
1
+ import { c as BaseAddon, i as rearmIdleAbort, n as getOptionalBasePath, o as scheduleIdleAbort, s as storageProviderCapability, t as createSessionId } from "./shared-hUiD7Ohg.mjs";
2
2
  import { PassThrough } from "node:stream";
3
3
  import { DeleteObjectCommand, GetObjectCommand, HeadBucketCommand, HeadObjectCommand, ListObjectsV2Command, PutObjectCommand, S3Client } from "@aws-sdk/client-s3";
4
4
  import { Upload } from "@aws-sdk/lib-storage";
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_shared = require("./shared-CzYVi403.js");
5
+ const require_shared = require("./shared-DAxSJcnX.js");
6
6
  let ssh2 = require("ssh2");
7
7
  let node_path = require("node:path");
8
8
  node_path = require_shared.__toESM(node_path);
@@ -1,4 +1,4 @@
1
- import { a as safeJoinRemotePath, c as BaseAddon, i as rearmIdleAbort, o as scheduleIdleAbort, r as getRequiredBasePath, s as storageProviderCapability, t as createSessionId } from "./shared-DsnRUNmJ.mjs";
1
+ import { a as safeJoinRemotePath, c as BaseAddon, i as rearmIdleAbort, o as scheduleIdleAbort, r as getRequiredBasePath, s as storageProviderCapability, t as createSessionId } from "./shared-hUiD7Ohg.mjs";
2
2
  import { Client } from "ssh2";
3
3
  import * as path from "node:path";
4
4
  //#region src/providers/sftp/sftp-config-schema.ts
@@ -8011,6 +8011,21 @@ var RelocateJobSchema = object({
8011
8011
  bytesMoved: number().int(),
8012
8012
  /** Total files discovered up front; null while (or when) unknown. */
8013
8013
  filesTotal: number().int().nullable(),
8014
+ /**
8015
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8016
+ * made that nobody asked for, so it is reported where the operator reads the
8017
+ * job rather than only in a log line.
8018
+ *
8019
+ * A footage segment records its byte count in its own NAME, and the durable
8020
+ * hour row derives its aggregates from those names. A file that does not
8021
+ * match its name therefore makes the ledger's sums — and with them quota and
8022
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8023
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8024
+ *
8025
+ * Absent on lanes where the question has no meaning: a media blob's size is
8026
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8027
+ */
8028
+ rowsReconciled: number().int().nonnegative().optional(),
8014
8029
  startedAt: number(),
8015
8030
  finishedAt: number().nullable(),
8016
8031
  error: string().nullable()
@@ -8079,14 +8094,42 @@ var RelocateMediaInputSchema = object({
8079
8094
  /** Omitted = `move`, the pre-existing behaviour. */
8080
8095
  mode: MediaRelocateModeSchema.optional()
8081
8096
  });
8082
- /** How many rows still carry NO `locationId` — the population a repoint would
8083
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8084
- * value that permits a non-blocking `eventMedia` cutover. */
8085
- var UnstampedEventMediaCountSchema = object({
8086
- media: number().int().nonnegative(),
8087
- retrainFrames: number().int().nonnegative(),
8088
- total: number().int().nonnegative()
8097
+ /**
8098
+ * The unstamped population of ONE collection split, because the gate and the
8099
+ * operator ask two different questions and only one of them has to be cheap.
8100
+ *
8101
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8102
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8103
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8104
+ * that matters — after a seal, when the population is empty.
8105
+ *
8106
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8107
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8108
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8109
+ * and useful answer: "there are some, and this read could not say how many"
8110
+ * still refuses the cutover, which is the whole job.
8111
+ */
8112
+ var UnstampedRowsSchema = object({
8113
+ present: boolean(),
8114
+ rows: number().int().nonnegative().nullable()
8089
8115
  });
8116
+ /**
8117
+ * How many rows still carry NO `locationId` — the population a repoint would
8118
+ * silently re-aim at a disk that does not hold their bytes.
8119
+ *
8120
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8121
+ * over. The gate opens on a measured absence and on nothing else; an unread
8122
+ * collection and an empty one are different facts, and this repo has already
8123
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8124
+ */
8125
+ var UnstampedEventMediaCountSchema = object({
8126
+ media: UnstampedRowsSchema,
8127
+ retrainFrames: UnstampedRowsSchema,
8128
+ /** True when EITHER collection holds one. The refusal reads this. */
8129
+ anyPresent: boolean(),
8130
+ /** Sum across both, or `null` when either lane could not be counted. */
8131
+ total: number().int().nonnegative().nullable()
8132
+ }).nullable();
8090
8133
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8091
8134
  /** The independently selectable logical storage classes — every class
8092
8135
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8197,6 +8240,10 @@ var StorageMigrationMoveProgressSchema = object({
8197
8240
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8198
8241
  filesTotal: number().int().nonnegative().nullable(),
8199
8242
  bytesMoved: number().int().nonnegative(),
8243
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8244
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8245
+ * rows would be the same failure as one that silently skipped them. */
8246
+ rowsReconciled: number().int().nonnegative().optional(),
8200
8247
  /** The MOVER's start, not the migration's: a drain restarted after an addon
8201
8248
  * crash gets a new mover, and a rate computed from the migration's start
8202
8249
  * would silently average in the time nothing was running. */
@@ -12881,6 +12928,114 @@ method(object({
12881
12928
  height: number()
12882
12929
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12883
12930
  /**
12931
+ * `failure-contribution` — the capability an addon reports its OWN losses
12932
+ * through, per camera, with the denominator attached. It stores nothing.
12933
+ *
12934
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
12935
+ *
12936
+ * `load-contribution` answers *what did this camera COST*. This answers *what
12937
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
12938
+ * copied: the contributor reports what it already knows, hub-main adds only
12939
+ * `addonId`, nothing needs global knowledge, and there is no central list for
12940
+ * somebody to forget to edit.
12941
+ *
12942
+ * They are not merged, because their invariants are opposites:
12943
+ *
12944
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
12945
+ * claim a camera cost nothing, which is a measurement nobody made;
12946
+ * - a `failure-contribution` zero is the **most valuable value on the
12947
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
12948
+ * and it is exactly what an absent entry cannot say.
12949
+ *
12950
+ * Putting a loss counter on a cost entry would also break the reconciliation
12951
+ * that gives `load-contribution` its point: contributions are subtracted from
12952
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
12953
+ * has no process.
12954
+ *
12955
+ * ## Why not a log line, since the counters already exist
12956
+ *
12957
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
12958
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
12959
+ * ends in a log line, and a log line is the thing the operator asked to stop
12960
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
12961
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
12962
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
12963
+ * media blackout were both diagnosed. The counters stay; this is where they can
12964
+ * be READ.
12965
+ *
12966
+ * ## The rate is served with its denominator or not at all
12967
+ *
12968
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
12969
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
12970
+ * than yesterday" and was **flat across twelve hours** once divided by the
12971
+ * successes on the same path. A surface that publishes only the numerator
12972
+ * reproduces that mistake on every read.
12973
+ *
12974
+ * ## Shape
12975
+ *
12976
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
12977
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
12978
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
12979
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
12980
+ * a forked runner's entries reach hub-main over transport that already exists.
12981
+ * No new UDS message, no second registry (D3). The operator reads the assembled
12982
+ * result through `system.getFailureContributions`.
12983
+ */
12984
+ var FailureReasonCountSchema = object({
12985
+ /**
12986
+ * Why the attempt did not land, in the contributor's own vocabulary —
12987
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
12988
+ * strings that already appear in this repo's logs and, where one exists, the
12989
+ * same string the per-track `previewMissReason` records (D276): a second
12990
+ * vocabulary for the same loss would make the row and the counter
12991
+ * un-joinable.
12992
+ */
12993
+ reason: string(),
12994
+ count: number().int().nonnegative()
12995
+ });
12996
+ var FailureContributionSchema = object({
12997
+ /**
12998
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
12999
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13000
+ * `unit` free: the families are owned by different addons and a shared enum
13001
+ * is a central list that rots invisibly.
13002
+ */
13003
+ family: string(),
13004
+ /**
13005
+ * The NUMERIC device id — the same value every log line carries as
13006
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13007
+ * cannot name the camera must not emit the entry, because a fleet total
13008
+ * cannot answer the only question anybody asks of this surface.
13009
+ */
13010
+ deviceId: number().int().positive(),
13011
+ /**
13012
+ * A second dimension inside the family: the model / step id for an inference
13013
+ * timeout, so "which camera AND which model" is one read. Absent when the
13014
+ * family has a single variant.
13015
+ */
13016
+ variant: string().optional(),
13017
+ /**
13018
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13019
+ * differencing two reads must drop the interval when it changes, because the
13020
+ * counter restarted from zero in a respawned runner. Same discipline as
13021
+ * `LoadContribution.startedAtMs`.
13022
+ */
13023
+ sinceMs: number(),
13024
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13025
+ atMs: number(),
13026
+ /**
13027
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13028
+ * window. A failure count published without it is the mistake this schema
13029
+ * exists to make impossible.
13030
+ */
13031
+ attempts: number().int().nonnegative(),
13032
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13033
+ succeeded: number().int().nonnegative(),
13034
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13035
+ reasons: array(FailureReasonCountSchema).readonly()
13036
+ });
13037
+ method(_void(), array(FailureContributionSchema).readonly());
13038
+ /**
12884
13039
  * filesystem-browse — per-node capability for browsing the node's local
12885
13040
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12886
13041
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -13402,6 +13557,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13402
13557
  kind: "mutation",
13403
13558
  auth: "admin"
13404
13559
  });
13560
+ var LoadContributionSchema = object({
13561
+ role: _enum([
13562
+ "decode",
13563
+ "transcode",
13564
+ "recording",
13565
+ "streaming",
13566
+ "detection"
13567
+ ]),
13568
+ /**
13569
+ * The NUMERIC device id — the same value every log line carries as
13570
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13571
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
13572
+ * contributor that cannot name its camera must not emit the entry at all,
13573
+ * because an unnamed per-camera entry is indistinguishable from a shared one
13574
+ * and would quietly turn one camera's cost into everybody's.
13575
+ */
13576
+ deviceId: number().int().positive().nullable(),
13577
+ attribution: _enum([
13578
+ "measured",
13579
+ "accounted",
13580
+ "unattributable"
13581
+ ]),
13582
+ /**
13583
+ * What ONE entry is, in the contributor's own words — `615/high`,
13584
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13585
+ * family and inventing a common one would lose the only information that
13586
+ * makes two entries for the same camera distinguishable.
13587
+ */
13588
+ unit: string(),
13589
+ /**
13590
+ * The OS process this cost lives in, when there is one. Present so a
13591
+ * consumer can (a) tell two generations of the same unit apart across a
13592
+ * restart, and (b) subtract claimed processes from the node's process
13593
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13594
+ * process of its own.
13595
+ */
13596
+ pid: number().int().positive().optional(),
13597
+ /**
13598
+ * When this generation started. The pid's incarnation marker: a consumer
13599
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13600
+ * window when this changes, because the counter restarted from zero in a new
13601
+ * process.
13602
+ */
13603
+ startedAtMs: number().optional(),
13604
+ /**
13605
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13606
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
13607
+ * contribution is asked for.
13608
+ *
13609
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
13610
+ * needs a sampler, and a new per-node sampler is the defect half of
13611
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13612
+ * by whoever already keeps a history; a rate cannot be un-averaged.
13613
+ *
13614
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13615
+ * an entry with no process.
13616
+ */
13617
+ cpuSeconds: number().optional(),
13618
+ /** Resident bytes of this unit's process, same source and same rules. */
13619
+ rssBytes: number().optional()
13620
+ });
13621
+ method(_void(), array(LoadContributionSchema).readonly());
13405
13622
  /**
13406
13623
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
13407
13624
  * through. It stores nothing.
@@ -13478,176 +13695,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13478
13695
  tags: record(string(), string()).optional()
13479
13696
  }), array(LogEntrySchema).readonly());
13480
13697
  /**
13481
- * `failure-contribution` — the capability an addon reports its OWN losses
13482
- * through, per camera, with the denominator attached. It stores nothing.
13483
- *
13484
- * ## The twin of `load-contribution`, and why it is a twin and not a field
13485
- *
13486
- * `load-contribution` answers *what did this camera COST*. This answers *what
13487
- * did this camera LOSE*. The reporting discipline is identical and deliberately
13488
- * copied: the contributor reports what it already knows, hub-main adds only
13489
- * `addonId`, nothing needs global knowledge, and there is no central list for
13490
- * somebody to forget to edit.
13491
- *
13492
- * They are not merged, because their invariants are opposites:
13493
- *
13494
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
13495
- * claim a camera cost nothing, which is a measurement nobody made;
13496
- * - a `failure-contribution` zero is the **most valuable value on the
13497
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13498
- * and it is exactly what an absent entry cannot say.
13499
- *
13500
- * Putting a loss counter on a cost entry would also break the reconciliation
13501
- * that gives `load-contribution` its point: contributions are subtracted from
13502
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13503
- * has no process.
13504
- *
13505
- * ## Why not a log line, since the counters already exist
13506
- *
13507
- * Several of these paths already counted themselves — `CaptureScheduler`'s
13508
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13509
- * ends in a log line, and a log line is the thing the operator asked to stop
13510
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13511
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13512
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13513
- * media blackout were both diagnosed. The counters stay; this is where they can
13514
- * be READ.
13515
- *
13516
- * ## The rate is served with its denominator or not at all
13517
- *
13518
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
13519
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13520
- * than yesterday" and was **flat across twelve hours** once divided by the
13521
- * successes on the same path. A surface that publishes only the numerator
13522
- * reproduces that mistake on every read.
13523
- *
13524
- * ## Shape
13525
- *
13526
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13527
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13528
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13529
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13530
- * a forked runner's entries reach hub-main over transport that already exists.
13531
- * No new UDS message, no second registry (D3). The operator reads the assembled
13532
- * result through `system.getFailureContributions`.
13533
- */
13534
- var FailureReasonCountSchema = object({
13535
- /**
13536
- * Why the attempt did not land, in the contributor's own vocabulary —
13537
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13538
- * strings that already appear in this repo's logs and, where one exists, the
13539
- * same string the per-track `previewMissReason` records (D276): a second
13540
- * vocabulary for the same loss would make the row and the counter
13541
- * un-joinable.
13542
- */
13543
- reason: string(),
13544
- count: number().int().nonnegative()
13545
- });
13546
- var FailureContributionSchema = object({
13547
- /**
13548
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13549
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13550
- * `unit` free: the families are owned by different addons and a shared enum
13551
- * is a central list that rots invisibly.
13552
- */
13553
- family: string(),
13554
- /**
13555
- * The NUMERIC device id — the same value every log line carries as
13556
- * `tags.deviceId`. Never nullable and never absent: a contributor that
13557
- * cannot name the camera must not emit the entry, because a fleet total
13558
- * cannot answer the only question anybody asks of this surface.
13559
- */
13560
- deviceId: number().int().positive(),
13561
- /**
13562
- * A second dimension inside the family: the model / step id for an inference
13563
- * timeout, so "which camera AND which model" is one read. Absent when the
13564
- * family has a single variant.
13565
- */
13566
- variant: string().optional(),
13567
- /**
13568
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13569
- * differencing two reads must drop the interval when it changes, because the
13570
- * counter restarted from zero in a respawned runner. Same discipline as
13571
- * `LoadContribution.startedAtMs`.
13572
- */
13573
- sinceMs: number(),
13574
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13575
- atMs: number(),
13576
- /**
13577
- * THE DENOMINATOR — every attempt on this path for this camera in the
13578
- * window. A failure count published without it is the mistake this schema
13579
- * exists to make impossible.
13580
- */
13581
- attempts: number().int().nonnegative(),
13582
- /** Attempts that landed. `attempts - succeeded` is the loss. */
13583
- succeeded: number().int().nonnegative(),
13584
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
13585
- reasons: array(FailureReasonCountSchema).readonly()
13586
- });
13587
- method(_void(), array(FailureContributionSchema).readonly());
13588
- var LoadContributionSchema = object({
13589
- role: _enum([
13590
- "decode",
13591
- "transcode",
13592
- "recording",
13593
- "streaming",
13594
- "detection"
13595
- ]),
13596
- /**
13597
- * The NUMERIC device id — the same value every log line carries as
13598
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13599
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
13600
- * contributor that cannot name its camera must not emit the entry at all,
13601
- * because an unnamed per-camera entry is indistinguishable from a shared one
13602
- * and would quietly turn one camera's cost into everybody's.
13603
- */
13604
- deviceId: number().int().positive().nullable(),
13605
- attribution: _enum([
13606
- "measured",
13607
- "accounted",
13608
- "unattributable"
13609
- ]),
13610
- /**
13611
- * What ONE entry is, in the contributor's own words — `615/high`,
13612
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13613
- * family and inventing a common one would lose the only information that
13614
- * makes two entries for the same camera distinguishable.
13615
- */
13616
- unit: string(),
13617
- /**
13618
- * The OS process this cost lives in, when there is one. Present so a
13619
- * consumer can (a) tell two generations of the same unit apart across a
13620
- * restart, and (b) subtract claimed processes from the node's process
13621
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13622
- * process of its own.
13623
- */
13624
- pid: number().int().positive().optional(),
13625
- /**
13626
- * When this generation started. The pid's incarnation marker: a consumer
13627
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13628
- * window when this changes, because the counter restarted from zero in a new
13629
- * process.
13630
- */
13631
- startedAtMs: number().optional(),
13632
- /**
13633
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13634
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
13635
- * contribution is asked for.
13636
- *
13637
- * Cumulative and not a rate on purpose: a rate needs a window, a window
13638
- * needs a sampler, and a new per-node sampler is the defect half of
13639
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13640
- * by whoever already keeps a history; a rate cannot be un-averaged.
13641
- *
13642
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13643
- * an entry with no process.
13644
- */
13645
- cpuSeconds: number().optional(),
13646
- /** Resident bytes of this unit's process, same source and same rules. */
13647
- rssBytes: number().optional()
13648
- });
13649
- method(_void(), array(LoadContributionSchema).readonly());
13650
- /**
13651
13698
  * `login-method` — collection cap through which auth addons contribute
13652
13699
  * their pre-auth login surfaces to the login page. This is the SINGLE,
13653
13700
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -18307,12 +18354,53 @@ var MediaFileKindEnum = _enum([
18307
18354
  "keyFrameSmall",
18308
18355
  "thumbnailSmall"
18309
18356
  ]);
18357
+ /**
18358
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
18359
+ * ARE — never the bytes themselves.
18360
+ *
18361
+ * ## Why `url` and not `base64`
18362
+ *
18363
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
18364
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
18365
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
18366
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
18367
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
18368
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
18369
+ *
18370
+ * `url` points at the `event-media` data plane
18371
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
18372
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
18373
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
18374
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
18375
+ * no less protected than they were inside a `view`-level cap response — see
18376
+ * `data-plane-access.ts` for the rule and the one gap it does not close
18377
+ * (per-device scoping).
18378
+ *
18379
+ * The URL is built from the row's **stored** key, which is not always its
18380
+ * published `kind`: a track's face/plate crop is stored as `crop` under
18381
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
18382
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
18383
+ *
18384
+ * ## `base64` is TRANSITIONAL and is going away
18385
+ *
18386
+ * It is still populated for one reason: the deployed viewer's track-detail
18387
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
18388
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
18389
+ * triangle — not as absence. Removing the field before that viewer ships is an
18390
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
18391
+ * delete this line and the `withBytes` pass-through in
18392
+ * `analytics-query-facade.ts`; nothing else reads it.
18393
+ */
18310
18394
  var MediaFileSchema = object({
18311
18395
  key: string(),
18312
18396
  kind: MediaFileKindEnum,
18313
- base64: string(),
18314
18397
  sizeBytes: number(),
18315
18398
  timestamp: number()
18399
+ }).extend({
18400
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
18401
+ url: string(),
18402
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
18403
+ base64: string()
18316
18404
  });
18317
18405
  /**
18318
18406
  * One media row WITHOUT its bytes.
@@ -18324,7 +18412,9 @@ var MediaFileSchema = object({
18324
18412
  * blocks the whole view.
18325
18413
  *
18326
18414
  * `sizeBytes` is carried because it is what lets a client decide between the
18327
- * stored blob and a `?variant=thumb` rendering without fetching either.
18415
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
18416
+ * `url` because a client that had to build the plane path itself is a second
18417
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
18328
18418
  */
18329
18419
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18330
18420
  /**
@@ -19013,6 +19103,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19013
19103
  }), array(MediaFileSchema).readonly()), method(object({
19014
19104
  trackId: string(),
19015
19105
  deviceId: number()
19106
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19107
+ eventId: string(),
19108
+ deviceId: number()
19016
19109
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19017
19110
  kind: "mutation",
19018
19111
  auth: "admin"
@@ -23333,10 +23426,24 @@ var FaceClusterSchema = object({
23333
23426
  size: number().int(),
23334
23427
  cohesion: number()
23335
23428
  });
23429
+ /**
23430
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
23431
+ * are — never the bytes.
23432
+ *
23433
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
23434
+ * track/event contract) is still populated because a deployed viewer requires
23435
+ * the field to parse a row at all; this method has no such reader. Its ONE
23436
+ * caller is the admin UI's detail modal, which was building
23437
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
23438
+ * dialog already rendering its key FRAME from the `event-media` plane.
23439
+ *
23440
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
23441
+ * media key directly, so this needed no new plane and no new access decision.
23442
+ */
23336
23443
  var MediaFileLiteSchema$1 = object({
23337
23444
  key: string(),
23338
23445
  kind: string(),
23339
- base64: string(),
23446
+ url: string(),
23340
23447
  sizeBytes: number(),
23341
23448
  timestamp: number()
23342
23449
  });
@@ -25588,10 +25695,24 @@ var PlateInfoSchema = object({
25588
25695
  */
25589
25696
  cropUrl: string().optional()
25590
25697
  });
25698
+ /**
25699
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
25700
+ * are — never the bytes.
25701
+ *
25702
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
25703
+ * track/event contract) is still populated because a deployed viewer requires
25704
+ * the field to parse a row at all; this method has no such reader. Its ONE
25705
+ * caller is the admin UI's detail modal, which was building
25706
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
25707
+ * dialog already rendering its key FRAME from the `event-media` plane.
25708
+ *
25709
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
25710
+ * media key directly, so this needed no new plane and no new access decision.
25711
+ */
25591
25712
  var MediaFileLiteSchema = object({
25592
25713
  key: string(),
25593
25714
  kind: string(),
25594
- base64: string(),
25715
+ url: string(),
25595
25716
  sizeBytes: number(),
25596
25717
  timestamp: number()
25597
25718
  });
@@ -31604,6 +31725,12 @@ Object.freeze({
31604
31725
  addonId: null,
31605
31726
  access: "view"
31606
31727
  },
31728
+ "pipelineAnalytics.listEventMedia": {
31729
+ capName: "pipeline-analytics",
31730
+ capScope: "device",
31731
+ addonId: null,
31732
+ access: "view"
31733
+ },
31607
31734
  "pipelineAnalytics.listGroups": {
31608
31735
  capName: "pipeline-analytics",
31609
31736
  capScope: "device",
@@ -35227,6 +35354,11 @@ Object.freeze({
35227
35354
  form: "array",
35228
35355
  optional: false
35229
35356
  }],
35357
+ "pipelineAnalytics.listEventMedia": [{
35358
+ name: "deviceId",
35359
+ form: "single",
35360
+ optional: false
35361
+ }],
35230
35362
  "pipelineAnalytics.listGroups": [{
35231
35363
  name: "deviceIds",
35232
35364
  form: "array",
@@ -7988,6 +7988,21 @@ var RelocateJobSchema = object({
7988
7988
  bytesMoved: number().int(),
7989
7989
  /** Total files discovered up front; null while (or when) unknown. */
7990
7990
  filesTotal: number().int().nullable(),
7991
+ /**
7992
+ * Rows this run CORRECTED while moving them — a durable mutation the move
7993
+ * made that nobody asked for, so it is reported where the operator reads the
7994
+ * job rather than only in a log line.
7995
+ *
7996
+ * A footage segment records its byte count in its own NAME, and the durable
7997
+ * hour row derives its aggregates from those names. A file that does not
7998
+ * match its name therefore makes the ledger's sums — and with them quota and
7999
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8000
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8001
+ *
8002
+ * Absent on lanes where the question has no meaning: a media blob's size is
8003
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8004
+ */
8005
+ rowsReconciled: number().int().nonnegative().optional(),
7991
8006
  startedAt: number(),
7992
8007
  finishedAt: number().nullable(),
7993
8008
  error: string().nullable()
@@ -8056,14 +8071,42 @@ var RelocateMediaInputSchema = object({
8056
8071
  /** Omitted = `move`, the pre-existing behaviour. */
8057
8072
  mode: MediaRelocateModeSchema.optional()
8058
8073
  });
8059
- /** How many rows still carry NO `locationId` — the population a repoint would
8060
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8061
- * value that permits a non-blocking `eventMedia` cutover. */
8062
- var UnstampedEventMediaCountSchema = object({
8063
- media: number().int().nonnegative(),
8064
- retrainFrames: number().int().nonnegative(),
8065
- total: number().int().nonnegative()
8074
+ /**
8075
+ * The unstamped population of ONE collection split, because the gate and the
8076
+ * operator ask two different questions and only one of them has to be cheap.
8077
+ *
8078
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8079
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8080
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8081
+ * that matters — after a seal, when the population is empty.
8082
+ *
8083
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8084
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8085
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8086
+ * and useful answer: "there are some, and this read could not say how many"
8087
+ * still refuses the cutover, which is the whole job.
8088
+ */
8089
+ var UnstampedRowsSchema = object({
8090
+ present: boolean(),
8091
+ rows: number().int().nonnegative().nullable()
8066
8092
  });
8093
+ /**
8094
+ * How many rows still carry NO `locationId` — the population a repoint would
8095
+ * silently re-aim at a disk that does not hold their bytes.
8096
+ *
8097
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8098
+ * over. The gate opens on a measured absence and on nothing else; an unread
8099
+ * collection and an empty one are different facts, and this repo has already
8100
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8101
+ */
8102
+ var UnstampedEventMediaCountSchema = object({
8103
+ media: UnstampedRowsSchema,
8104
+ retrainFrames: UnstampedRowsSchema,
8105
+ /** True when EITHER collection holds one. The refusal reads this. */
8106
+ anyPresent: boolean(),
8107
+ /** Sum across both, or `null` when either lane could not be counted. */
8108
+ total: number().int().nonnegative().nullable()
8109
+ }).nullable();
8067
8110
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string().min(1) });
8068
8111
  /** The independently selectable logical storage classes — every class
8069
8112
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8174,6 +8217,10 @@ var StorageMigrationMoveProgressSchema = object({
8174
8217
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8175
8218
  filesTotal: number().int().nonnegative().nullable(),
8176
8219
  bytesMoved: number().int().nonnegative(),
8220
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8221
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8222
+ * rows would be the same failure as one that silently skipped them. */
8223
+ rowsReconciled: number().int().nonnegative().optional(),
8177
8224
  /** The MOVER's start, not the migration's: a drain restarted after an addon
8178
8225
  * crash gets a new mover, and a rate computed from the migration's start
8179
8226
  * would silently average in the time nothing was running. */
@@ -12858,6 +12905,114 @@ method(object({
12858
12905
  height: number()
12859
12906
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
12860
12907
  /**
12908
+ * `failure-contribution` — the capability an addon reports its OWN losses
12909
+ * through, per camera, with the denominator attached. It stores nothing.
12910
+ *
12911
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
12912
+ *
12913
+ * `load-contribution` answers *what did this camera COST*. This answers *what
12914
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
12915
+ * copied: the contributor reports what it already knows, hub-main adds only
12916
+ * `addonId`, nothing needs global knowledge, and there is no central list for
12917
+ * somebody to forget to edit.
12918
+ *
12919
+ * They are not merged, because their invariants are opposites:
12920
+ *
12921
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
12922
+ * claim a camera cost nothing, which is a measurement nobody made;
12923
+ * - a `failure-contribution` zero is the **most valuable value on the
12924
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
12925
+ * and it is exactly what an absent entry cannot say.
12926
+ *
12927
+ * Putting a loss counter on a cost entry would also break the reconciliation
12928
+ * that gives `load-contribution` its point: contributions are subtracted from
12929
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
12930
+ * has no process.
12931
+ *
12932
+ * ## Why not a log line, since the counters already exist
12933
+ *
12934
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
12935
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
12936
+ * ends in a log line, and a log line is the thing the operator asked to stop
12937
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
12938
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
12939
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
12940
+ * media blackout were both diagnosed. The counters stay; this is where they can
12941
+ * be READ.
12942
+ *
12943
+ * ## The rate is served with its denominator or not at all
12944
+ *
12945
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
12946
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
12947
+ * than yesterday" and was **flat across twelve hours** once divided by the
12948
+ * successes on the same path. A surface that publishes only the numerator
12949
+ * reproduces that mistake on every read.
12950
+ *
12951
+ * ## Shape
12952
+ *
12953
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
12954
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
12955
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
12956
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
12957
+ * a forked runner's entries reach hub-main over transport that already exists.
12958
+ * No new UDS message, no second registry (D3). The operator reads the assembled
12959
+ * result through `system.getFailureContributions`.
12960
+ */
12961
+ var FailureReasonCountSchema = object({
12962
+ /**
12963
+ * Why the attempt did not land, in the contributor's own vocabulary —
12964
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
12965
+ * strings that already appear in this repo's logs and, where one exists, the
12966
+ * same string the per-track `previewMissReason` records (D276): a second
12967
+ * vocabulary for the same loss would make the row and the counter
12968
+ * un-joinable.
12969
+ */
12970
+ reason: string(),
12971
+ count: number().int().nonnegative()
12972
+ });
12973
+ var FailureContributionSchema = object({
12974
+ /**
12975
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
12976
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
12977
+ * `unit` free: the families are owned by different addons and a shared enum
12978
+ * is a central list that rots invisibly.
12979
+ */
12980
+ family: string(),
12981
+ /**
12982
+ * The NUMERIC device id — the same value every log line carries as
12983
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
12984
+ * cannot name the camera must not emit the entry, because a fleet total
12985
+ * cannot answer the only question anybody asks of this surface.
12986
+ */
12987
+ deviceId: number().int().positive(),
12988
+ /**
12989
+ * A second dimension inside the family: the model / step id for an inference
12990
+ * timeout, so "which camera AND which model" is one read. Absent when the
12991
+ * family has a single variant.
12992
+ */
12993
+ variant: string().optional(),
12994
+ /**
12995
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
12996
+ * differencing two reads must drop the interval when it changes, because the
12997
+ * counter restarted from zero in a respawned runner. Same discipline as
12998
+ * `LoadContribution.startedAtMs`.
12999
+ */
13000
+ sinceMs: number(),
13001
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13002
+ atMs: number(),
13003
+ /**
13004
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13005
+ * window. A failure count published without it is the mistake this schema
13006
+ * exists to make impossible.
13007
+ */
13008
+ attempts: number().int().nonnegative(),
13009
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13010
+ succeeded: number().int().nonnegative(),
13011
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13012
+ reasons: array(FailureReasonCountSchema).readonly()
13013
+ });
13014
+ method(_void(), array(FailureContributionSchema).readonly());
13015
+ /**
12861
13016
  * filesystem-browse — per-node capability for browsing the node's local
12862
13017
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
12863
13018
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -13379,6 +13534,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13379
13534
  kind: "mutation",
13380
13535
  auth: "admin"
13381
13536
  });
13537
+ var LoadContributionSchema = object({
13538
+ role: _enum([
13539
+ "decode",
13540
+ "transcode",
13541
+ "recording",
13542
+ "streaming",
13543
+ "detection"
13544
+ ]),
13545
+ /**
13546
+ * The NUMERIC device id — the same value every log line carries as
13547
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13548
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
13549
+ * contributor that cannot name its camera must not emit the entry at all,
13550
+ * because an unnamed per-camera entry is indistinguishable from a shared one
13551
+ * and would quietly turn one camera's cost into everybody's.
13552
+ */
13553
+ deviceId: number().int().positive().nullable(),
13554
+ attribution: _enum([
13555
+ "measured",
13556
+ "accounted",
13557
+ "unattributable"
13558
+ ]),
13559
+ /**
13560
+ * What ONE entry is, in the contributor's own words — `615/high`,
13561
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13562
+ * family and inventing a common one would lose the only information that
13563
+ * makes two entries for the same camera distinguishable.
13564
+ */
13565
+ unit: string(),
13566
+ /**
13567
+ * The OS process this cost lives in, when there is one. Present so a
13568
+ * consumer can (a) tell two generations of the same unit apart across a
13569
+ * restart, and (b) subtract claimed processes from the node's process
13570
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13571
+ * process of its own.
13572
+ */
13573
+ pid: number().int().positive().optional(),
13574
+ /**
13575
+ * When this generation started. The pid's incarnation marker: a consumer
13576
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13577
+ * window when this changes, because the counter restarted from zero in a new
13578
+ * process.
13579
+ */
13580
+ startedAtMs: number().optional(),
13581
+ /**
13582
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13583
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
13584
+ * contribution is asked for.
13585
+ *
13586
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
13587
+ * needs a sampler, and a new per-node sampler is the defect half of
13588
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13589
+ * by whoever already keeps a history; a rate cannot be un-averaged.
13590
+ *
13591
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13592
+ * an entry with no process.
13593
+ */
13594
+ cpuSeconds: number().optional(),
13595
+ /** Resident bytes of this unit's process, same source and same rules. */
13596
+ rssBytes: number().optional()
13597
+ });
13598
+ method(_void(), array(LoadContributionSchema).readonly());
13382
13599
  /**
13383
13600
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
13384
13601
  * through. It stores nothing.
@@ -13455,176 +13672,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13455
13672
  tags: record(string(), string()).optional()
13456
13673
  }), array(LogEntrySchema).readonly());
13457
13674
  /**
13458
- * `failure-contribution` — the capability an addon reports its OWN losses
13459
- * through, per camera, with the denominator attached. It stores nothing.
13460
- *
13461
- * ## The twin of `load-contribution`, and why it is a twin and not a field
13462
- *
13463
- * `load-contribution` answers *what did this camera COST*. This answers *what
13464
- * did this camera LOSE*. The reporting discipline is identical and deliberately
13465
- * copied: the contributor reports what it already knows, hub-main adds only
13466
- * `addonId`, nothing needs global knowledge, and there is no central list for
13467
- * somebody to forget to edit.
13468
- *
13469
- * They are not merged, because their invariants are opposites:
13470
- *
13471
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
13472
- * claim a camera cost nothing, which is a measurement nobody made;
13473
- * - a `failure-contribution` zero is the **most valuable value on the
13474
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13475
- * and it is exactly what an absent entry cannot say.
13476
- *
13477
- * Putting a loss counter on a cost entry would also break the reconciliation
13478
- * that gives `load-contribution` its point: contributions are subtracted from
13479
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13480
- * has no process.
13481
- *
13482
- * ## Why not a log line, since the counters already exist
13483
- *
13484
- * Several of these paths already counted themselves — `CaptureScheduler`'s
13485
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13486
- * ends in a log line, and a log line is the thing the operator asked to stop
13487
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13488
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13489
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13490
- * media blackout were both diagnosed. The counters stay; this is where they can
13491
- * be READ.
13492
- *
13493
- * ## The rate is served with its denominator or not at all
13494
- *
13495
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
13496
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13497
- * than yesterday" and was **flat across twelve hours** once divided by the
13498
- * successes on the same path. A surface that publishes only the numerator
13499
- * reproduces that mistake on every read.
13500
- *
13501
- * ## Shape
13502
- *
13503
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13504
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13505
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13506
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13507
- * a forked runner's entries reach hub-main over transport that already exists.
13508
- * No new UDS message, no second registry (D3). The operator reads the assembled
13509
- * result through `system.getFailureContributions`.
13510
- */
13511
- var FailureReasonCountSchema = object({
13512
- /**
13513
- * Why the attempt did not land, in the contributor's own vocabulary —
13514
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13515
- * strings that already appear in this repo's logs and, where one exists, the
13516
- * same string the per-track `previewMissReason` records (D276): a second
13517
- * vocabulary for the same loss would make the row and the counter
13518
- * un-joinable.
13519
- */
13520
- reason: string(),
13521
- count: number().int().nonnegative()
13522
- });
13523
- var FailureContributionSchema = object({
13524
- /**
13525
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13526
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13527
- * `unit` free: the families are owned by different addons and a shared enum
13528
- * is a central list that rots invisibly.
13529
- */
13530
- family: string(),
13531
- /**
13532
- * The NUMERIC device id — the same value every log line carries as
13533
- * `tags.deviceId`. Never nullable and never absent: a contributor that
13534
- * cannot name the camera must not emit the entry, because a fleet total
13535
- * cannot answer the only question anybody asks of this surface.
13536
- */
13537
- deviceId: number().int().positive(),
13538
- /**
13539
- * A second dimension inside the family: the model / step id for an inference
13540
- * timeout, so "which camera AND which model" is one read. Absent when the
13541
- * family has a single variant.
13542
- */
13543
- variant: string().optional(),
13544
- /**
13545
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13546
- * differencing two reads must drop the interval when it changes, because the
13547
- * counter restarted from zero in a respawned runner. Same discipline as
13548
- * `LoadContribution.startedAtMs`.
13549
- */
13550
- sinceMs: number(),
13551
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13552
- atMs: number(),
13553
- /**
13554
- * THE DENOMINATOR — every attempt on this path for this camera in the
13555
- * window. A failure count published without it is the mistake this schema
13556
- * exists to make impossible.
13557
- */
13558
- attempts: number().int().nonnegative(),
13559
- /** Attempts that landed. `attempts - succeeded` is the loss. */
13560
- succeeded: number().int().nonnegative(),
13561
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
13562
- reasons: array(FailureReasonCountSchema).readonly()
13563
- });
13564
- method(_void(), array(FailureContributionSchema).readonly());
13565
- var LoadContributionSchema = object({
13566
- role: _enum([
13567
- "decode",
13568
- "transcode",
13569
- "recording",
13570
- "streaming",
13571
- "detection"
13572
- ]),
13573
- /**
13574
- * The NUMERIC device id — the same value every log line carries as
13575
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13576
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
13577
- * contributor that cannot name its camera must not emit the entry at all,
13578
- * because an unnamed per-camera entry is indistinguishable from a shared one
13579
- * and would quietly turn one camera's cost into everybody's.
13580
- */
13581
- deviceId: number().int().positive().nullable(),
13582
- attribution: _enum([
13583
- "measured",
13584
- "accounted",
13585
- "unattributable"
13586
- ]),
13587
- /**
13588
- * What ONE entry is, in the contributor's own words — `615/high`,
13589
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13590
- * family and inventing a common one would lose the only information that
13591
- * makes two entries for the same camera distinguishable.
13592
- */
13593
- unit: string(),
13594
- /**
13595
- * The OS process this cost lives in, when there is one. Present so a
13596
- * consumer can (a) tell two generations of the same unit apart across a
13597
- * restart, and (b) subtract claimed processes from the node's process
13598
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13599
- * process of its own.
13600
- */
13601
- pid: number().int().positive().optional(),
13602
- /**
13603
- * When this generation started. The pid's incarnation marker: a consumer
13604
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13605
- * window when this changes, because the counter restarted from zero in a new
13606
- * process.
13607
- */
13608
- startedAtMs: number().optional(),
13609
- /**
13610
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13611
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
13612
- * contribution is asked for.
13613
- *
13614
- * Cumulative and not a rate on purpose: a rate needs a window, a window
13615
- * needs a sampler, and a new per-node sampler is the defect half of
13616
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13617
- * by whoever already keeps a history; a rate cannot be un-averaged.
13618
- *
13619
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13620
- * an entry with no process.
13621
- */
13622
- cpuSeconds: number().optional(),
13623
- /** Resident bytes of this unit's process, same source and same rules. */
13624
- rssBytes: number().optional()
13625
- });
13626
- method(_void(), array(LoadContributionSchema).readonly());
13627
- /**
13628
13675
  * `login-method` — collection cap through which auth addons contribute
13629
13676
  * their pre-auth login surfaces to the login page. This is the SINGLE,
13630
13677
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -18284,12 +18331,53 @@ var MediaFileKindEnum = _enum([
18284
18331
  "keyFrameSmall",
18285
18332
  "thumbnailSmall"
18286
18333
  ]);
18334
+ /**
18335
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
18336
+ * ARE — never the bytes themselves.
18337
+ *
18338
+ * ## Why `url` and not `base64`
18339
+ *
18340
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
18341
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
18342
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
18343
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
18344
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
18345
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
18346
+ *
18347
+ * `url` points at the `event-media` data plane
18348
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
18349
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
18350
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
18351
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
18352
+ * no less protected than they were inside a `view`-level cap response — see
18353
+ * `data-plane-access.ts` for the rule and the one gap it does not close
18354
+ * (per-device scoping).
18355
+ *
18356
+ * The URL is built from the row's **stored** key, which is not always its
18357
+ * published `kind`: a track's face/plate crop is stored as `crop` under
18358
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
18359
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
18360
+ *
18361
+ * ## `base64` is TRANSITIONAL and is going away
18362
+ *
18363
+ * It is still populated for one reason: the deployed viewer's track-detail
18364
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
18365
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
18366
+ * triangle — not as absence. Removing the field before that viewer ships is an
18367
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
18368
+ * delete this line and the `withBytes` pass-through in
18369
+ * `analytics-query-facade.ts`; nothing else reads it.
18370
+ */
18287
18371
  var MediaFileSchema = object({
18288
18372
  key: string(),
18289
18373
  kind: MediaFileKindEnum,
18290
- base64: string(),
18291
18374
  sizeBytes: number(),
18292
18375
  timestamp: number()
18376
+ }).extend({
18377
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
18378
+ url: string(),
18379
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
18380
+ base64: string()
18293
18381
  });
18294
18382
  /**
18295
18383
  * One media row WITHOUT its bytes.
@@ -18301,7 +18389,9 @@ var MediaFileSchema = object({
18301
18389
  * blocks the whole view.
18302
18390
  *
18303
18391
  * `sizeBytes` is carried because it is what lets a client decide between the
18304
- * stored blob and a `?variant=thumb` rendering without fetching either.
18392
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
18393
+ * `url` because a client that had to build the plane path itself is a second
18394
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
18305
18395
  */
18306
18396
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18307
18397
  /**
@@ -18990,6 +19080,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
18990
19080
  }), array(MediaFileSchema).readonly()), method(object({
18991
19081
  trackId: string(),
18992
19082
  deviceId: number()
19083
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19084
+ eventId: string(),
19085
+ deviceId: number()
18993
19086
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
18994
19087
  kind: "mutation",
18995
19088
  auth: "admin"
@@ -23310,10 +23403,24 @@ var FaceClusterSchema = object({
23310
23403
  size: number().int(),
23311
23404
  cohesion: number()
23312
23405
  });
23406
+ /**
23407
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
23408
+ * are — never the bytes.
23409
+ *
23410
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
23411
+ * track/event contract) is still populated because a deployed viewer requires
23412
+ * the field to parse a row at all; this method has no such reader. Its ONE
23413
+ * caller is the admin UI's detail modal, which was building
23414
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
23415
+ * dialog already rendering its key FRAME from the `event-media` plane.
23416
+ *
23417
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
23418
+ * media key directly, so this needed no new plane and no new access decision.
23419
+ */
23313
23420
  var MediaFileLiteSchema$1 = object({
23314
23421
  key: string(),
23315
23422
  kind: string(),
23316
- base64: string(),
23423
+ url: string(),
23317
23424
  sizeBytes: number(),
23318
23425
  timestamp: number()
23319
23426
  });
@@ -25565,10 +25672,24 @@ var PlateInfoSchema = object({
25565
25672
  */
25566
25673
  cropUrl: string().optional()
25567
25674
  });
25675
+ /**
25676
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
25677
+ * are — never the bytes.
25678
+ *
25679
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
25680
+ * track/event contract) is still populated because a deployed viewer requires
25681
+ * the field to parse a row at all; this method has no such reader. Its ONE
25682
+ * caller is the admin UI's detail modal, which was building
25683
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
25684
+ * dialog already rendering its key FRAME from the `event-media` plane.
25685
+ *
25686
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
25687
+ * media key directly, so this needed no new plane and no new access decision.
25688
+ */
25568
25689
  var MediaFileLiteSchema = object({
25569
25690
  key: string(),
25570
25691
  kind: string(),
25571
- base64: string(),
25692
+ url: string(),
25572
25693
  sizeBytes: number(),
25573
25694
  timestamp: number()
25574
25695
  });
@@ -31581,6 +31702,12 @@ Object.freeze({
31581
31702
  addonId: null,
31582
31703
  access: "view"
31583
31704
  },
31705
+ "pipelineAnalytics.listEventMedia": {
31706
+ capName: "pipeline-analytics",
31707
+ capScope: "device",
31708
+ addonId: null,
31709
+ access: "view"
31710
+ },
31584
31711
  "pipelineAnalytics.listGroups": {
31585
31712
  capName: "pipeline-analytics",
31586
31713
  capScope: "device",
@@ -35204,6 +35331,11 @@ Object.freeze({
35204
35331
  form: "array",
35205
35332
  optional: false
35206
35333
  }],
35334
+ "pipelineAnalytics.listEventMedia": [{
35335
+ name: "deviceId",
35336
+ form: "single",
35337
+ optional: false
35338
+ }],
35207
35339
  "pipelineAnalytics.listGroups": [{
35208
35340
  name: "deviceIds",
35209
35341
  form: "array",
package/dist/smb.addon.js CHANGED
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_shared = require("./shared-CzYVi403.js");
5
+ const require_shared = require("./shared-DAxSJcnX.js");
6
6
  let node_crypto = require("node:crypto");
7
7
  let node_path = require("node:path");
8
8
  node_path = require_shared.__toESM(node_path);
@@ -1,4 +1,4 @@
1
- import { c as BaseAddon, i as rearmIdleAbort, o as scheduleIdleAbort, s as storageProviderCapability } from "./shared-DsnRUNmJ.mjs";
1
+ import { c as BaseAddon, i as rearmIdleAbort, o as scheduleIdleAbort, s as storageProviderCapability } from "./shared-hUiD7Ohg.mjs";
2
2
  import { randomUUID } from "node:crypto";
3
3
  import * as path from "node:path";
4
4
  import * as fsp from "node:fs/promises";
@@ -2,7 +2,7 @@ Object.defineProperties(exports, {
2
2
  __esModule: { value: true },
3
3
  [Symbol.toStringTag]: { value: "Module" }
4
4
  });
5
- const require_shared = require("./shared-CzYVi403.js");
5
+ const require_shared = require("./shared-DAxSJcnX.js");
6
6
  let node_stream = require("node:stream");
7
7
  let webdav = require("webdav");
8
8
  //#region src/providers/webdav/webdav-config-schema.ts
@@ -1,4 +1,4 @@
1
- import { a as safeJoinRemotePath, c as BaseAddon, i as rearmIdleAbort, o as scheduleIdleAbort, r as getRequiredBasePath, s as storageProviderCapability, t as createSessionId } from "./shared-DsnRUNmJ.mjs";
1
+ import { a as safeJoinRemotePath, c as BaseAddon, i as rearmIdleAbort, o as scheduleIdleAbort, r as getRequiredBasePath, s as storageProviderCapability, t as createSessionId } from "./shared-hUiD7Ohg.mjs";
2
2
  import { PassThrough } from "node:stream";
3
3
  import { AuthType, createClient } from "webdav";
4
4
  //#region src/providers/webdav/webdav-config-schema.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-remote-storage",
3
- "version": "1.2.44",
3
+ "version": "1.2.46",
4
4
  "description": "Remote storage providers (SFTP, S3, WebDAV, SMB) — unifies remote backends behind the storage-provider cap",
5
5
  "keywords": [
6
6
  "camstack",