@camstack/addon-matter-broker 0.2.44 → 0.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.
Files changed (3) hide show
  1. package/dist/addon.js +313 -181
  2. package/dist/addon.mjs +313 -181
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -8017,6 +8017,21 @@ var RelocateJobSchema = object({
8017
8017
  bytesMoved: number().int(),
8018
8018
  /** Total files discovered up front; null while (or when) unknown. */
8019
8019
  filesTotal: number().int().nullable(),
8020
+ /**
8021
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8022
+ * made that nobody asked for, so it is reported where the operator reads the
8023
+ * job rather than only in a log line.
8024
+ *
8025
+ * A footage segment records its byte count in its own NAME, and the durable
8026
+ * hour row derives its aggregates from those names. A file that does not
8027
+ * match its name therefore makes the ledger's sums — and with them quota and
8028
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8029
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8030
+ *
8031
+ * Absent on lanes where the question has no meaning: a media blob's size is
8032
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8033
+ */
8034
+ rowsReconciled: number().int().nonnegative().optional(),
8020
8035
  startedAt: number(),
8021
8036
  finishedAt: number().nullable(),
8022
8037
  error: string$2().nullable()
@@ -8085,14 +8100,42 @@ var RelocateMediaInputSchema = object({
8085
8100
  /** Omitted = `move`, the pre-existing behaviour. */
8086
8101
  mode: MediaRelocateModeSchema.optional()
8087
8102
  });
8088
- /** How many rows still carry NO `locationId` — the population a repoint would
8089
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8090
- * value that permits a non-blocking `eventMedia` cutover. */
8091
- var UnstampedEventMediaCountSchema = object({
8092
- media: number().int().nonnegative(),
8093
- retrainFrames: number().int().nonnegative(),
8094
- total: number().int().nonnegative()
8103
+ /**
8104
+ * The unstamped population of ONE collection — split, because the gate and the
8105
+ * operator ask two different questions and only one of them has to be cheap.
8106
+ *
8107
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8108
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8109
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8110
+ * that matters — after a seal, when the population is empty.
8111
+ *
8112
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8113
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8114
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8115
+ * and useful answer: "there are some, and this read could not say how many"
8116
+ * still refuses the cutover, which is the whole job.
8117
+ */
8118
+ var UnstampedRowsSchema = object({
8119
+ present: boolean(),
8120
+ rows: number().int().nonnegative().nullable()
8095
8121
  });
8122
+ /**
8123
+ * How many rows still carry NO `locationId` — the population a repoint would
8124
+ * silently re-aim at a disk that does not hold their bytes.
8125
+ *
8126
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8127
+ * over. The gate opens on a measured absence and on nothing else; an unread
8128
+ * collection and an empty one are different facts, and this repo has already
8129
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8130
+ */
8131
+ var UnstampedEventMediaCountSchema = object({
8132
+ media: UnstampedRowsSchema,
8133
+ retrainFrames: UnstampedRowsSchema,
8134
+ /** True when EITHER collection holds one. The refusal reads this. */
8135
+ anyPresent: boolean(),
8136
+ /** Sum across both, or `null` when either lane could not be counted. */
8137
+ total: number().int().nonnegative().nullable()
8138
+ }).nullable();
8096
8139
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string$2().min(1) });
8097
8140
  /** The independently selectable logical storage classes — every class
8098
8141
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8203,6 +8246,10 @@ var StorageMigrationMoveProgressSchema = object({
8203
8246
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8204
8247
  filesTotal: number().int().nonnegative().nullable(),
8205
8248
  bytesMoved: number().int().nonnegative(),
8249
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8250
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8251
+ * rows would be the same failure as one that silently skipped them. */
8252
+ rowsReconciled: number().int().nonnegative().optional(),
8206
8253
  /** The MOVER's start, not the migration's: a drain restarted after an addon
8207
8254
  * crash gets a new mover, and a rate computed from the migration's start
8208
8255
  * would silently average in the time nothing was running. */
@@ -13217,6 +13264,114 @@ method(object({
13217
13264
  height: number()
13218
13265
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string$2() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13219
13266
  /**
13267
+ * `failure-contribution` — the capability an addon reports its OWN losses
13268
+ * through, per camera, with the denominator attached. It stores nothing.
13269
+ *
13270
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13271
+ *
13272
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13273
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13274
+ * copied: the contributor reports what it already knows, hub-main adds only
13275
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13276
+ * somebody to forget to edit.
13277
+ *
13278
+ * They are not merged, because their invariants are opposites:
13279
+ *
13280
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13281
+ * claim a camera cost nothing, which is a measurement nobody made;
13282
+ * - a `failure-contribution` zero is the **most valuable value on the
13283
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13284
+ * and it is exactly what an absent entry cannot say.
13285
+ *
13286
+ * Putting a loss counter on a cost entry would also break the reconciliation
13287
+ * that gives `load-contribution` its point: contributions are subtracted from
13288
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13289
+ * has no process.
13290
+ *
13291
+ * ## Why not a log line, since the counters already exist
13292
+ *
13293
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13294
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13295
+ * ends in a log line, and a log line is the thing the operator asked to stop
13296
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13297
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13298
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13299
+ * media blackout were both diagnosed. The counters stay; this is where they can
13300
+ * be READ.
13301
+ *
13302
+ * ## The rate is served with its denominator or not at all
13303
+ *
13304
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13305
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13306
+ * than yesterday" and was **flat across twelve hours** once divided by the
13307
+ * successes on the same path. A surface that publishes only the numerator
13308
+ * reproduces that mistake on every read.
13309
+ *
13310
+ * ## Shape
13311
+ *
13312
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13313
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13314
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13315
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13316
+ * a forked runner's entries reach hub-main over transport that already exists.
13317
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13318
+ * result through `system.getFailureContributions`.
13319
+ */
13320
+ var FailureReasonCountSchema = object({
13321
+ /**
13322
+ * Why the attempt did not land, in the contributor's own vocabulary —
13323
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13324
+ * strings that already appear in this repo's logs and, where one exists, the
13325
+ * same string the per-track `previewMissReason` records (D276): a second
13326
+ * vocabulary for the same loss would make the row and the counter
13327
+ * un-joinable.
13328
+ */
13329
+ reason: string$2(),
13330
+ count: number().int().nonnegative()
13331
+ });
13332
+ var FailureContributionSchema = object({
13333
+ /**
13334
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13335
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13336
+ * `unit` free: the families are owned by different addons and a shared enum
13337
+ * is a central list that rots invisibly.
13338
+ */
13339
+ family: string$2(),
13340
+ /**
13341
+ * The NUMERIC device id — the same value every log line carries as
13342
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13343
+ * cannot name the camera must not emit the entry, because a fleet total
13344
+ * cannot answer the only question anybody asks of this surface.
13345
+ */
13346
+ deviceId: number().int().positive(),
13347
+ /**
13348
+ * A second dimension inside the family: the model / step id for an inference
13349
+ * timeout, so "which camera AND which model" is one read. Absent when the
13350
+ * family has a single variant.
13351
+ */
13352
+ variant: string$2().optional(),
13353
+ /**
13354
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13355
+ * differencing two reads must drop the interval when it changes, because the
13356
+ * counter restarted from zero in a respawned runner. Same discipline as
13357
+ * `LoadContribution.startedAtMs`.
13358
+ */
13359
+ sinceMs: number(),
13360
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13361
+ atMs: number(),
13362
+ /**
13363
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13364
+ * window. A failure count published without it is the mistake this schema
13365
+ * exists to make impossible.
13366
+ */
13367
+ attempts: number().int().nonnegative(),
13368
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13369
+ succeeded: number().int().nonnegative(),
13370
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13371
+ reasons: array(FailureReasonCountSchema).readonly()
13372
+ });
13373
+ method(_void(), array(FailureContributionSchema).readonly());
13374
+ /**
13220
13375
  * filesystem-browse — per-node capability for browsing the node's local
13221
13376
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13222
13377
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -13738,6 +13893,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13738
13893
  kind: "mutation",
13739
13894
  auth: "admin"
13740
13895
  });
13896
+ var LoadContributionSchema = object({
13897
+ role: _enum([
13898
+ "decode",
13899
+ "transcode",
13900
+ "recording",
13901
+ "streaming",
13902
+ "detection"
13903
+ ]),
13904
+ /**
13905
+ * The NUMERIC device id — the same value every log line carries as
13906
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13907
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
13908
+ * contributor that cannot name its camera must not emit the entry at all,
13909
+ * because an unnamed per-camera entry is indistinguishable from a shared one
13910
+ * and would quietly turn one camera's cost into everybody's.
13911
+ */
13912
+ deviceId: number().int().positive().nullable(),
13913
+ attribution: _enum([
13914
+ "measured",
13915
+ "accounted",
13916
+ "unattributable"
13917
+ ]),
13918
+ /**
13919
+ * What ONE entry is, in the contributor's own words — `615/high`,
13920
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13921
+ * family and inventing a common one would lose the only information that
13922
+ * makes two entries for the same camera distinguishable.
13923
+ */
13924
+ unit: string$2(),
13925
+ /**
13926
+ * The OS process this cost lives in, when there is one. Present so a
13927
+ * consumer can (a) tell two generations of the same unit apart across a
13928
+ * restart, and (b) subtract claimed processes from the node's process
13929
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13930
+ * process of its own.
13931
+ */
13932
+ pid: number().int().positive().optional(),
13933
+ /**
13934
+ * When this generation started. The pid's incarnation marker: a consumer
13935
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13936
+ * window when this changes, because the counter restarted from zero in a new
13937
+ * process.
13938
+ */
13939
+ startedAtMs: number().optional(),
13940
+ /**
13941
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13942
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
13943
+ * contribution is asked for.
13944
+ *
13945
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
13946
+ * needs a sampler, and a new per-node sampler is the defect half of
13947
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13948
+ * by whoever already keeps a history; a rate cannot be un-averaged.
13949
+ *
13950
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13951
+ * an entry with no process.
13952
+ */
13953
+ cpuSeconds: number().optional(),
13954
+ /** Resident bytes of this unit's process, same source and same rules. */
13955
+ rssBytes: number().optional()
13956
+ });
13957
+ method(_void(), array(LoadContributionSchema).readonly());
13741
13958
  /**
13742
13959
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
13743
13960
  * through. It stores nothing.
@@ -13814,176 +14031,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13814
14031
  tags: record(string$2(), string$2()).optional()
13815
14032
  }), array(LogEntrySchema).readonly());
13816
14033
  /**
13817
- * `failure-contribution` — the capability an addon reports its OWN losses
13818
- * through, per camera, with the denominator attached. It stores nothing.
13819
- *
13820
- * ## The twin of `load-contribution`, and why it is a twin and not a field
13821
- *
13822
- * `load-contribution` answers *what did this camera COST*. This answers *what
13823
- * did this camera LOSE*. The reporting discipline is identical and deliberately
13824
- * copied: the contributor reports what it already knows, hub-main adds only
13825
- * `addonId`, nothing needs global knowledge, and there is no central list for
13826
- * somebody to forget to edit.
13827
- *
13828
- * They are not merged, because their invariants are opposites:
13829
- *
13830
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
13831
- * claim a camera cost nothing, which is a measurement nobody made;
13832
- * - a `failure-contribution` zero is the **most valuable value on the
13833
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13834
- * and it is exactly what an absent entry cannot say.
13835
- *
13836
- * Putting a loss counter on a cost entry would also break the reconciliation
13837
- * that gives `load-contribution` its point: contributions are subtracted from
13838
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13839
- * has no process.
13840
- *
13841
- * ## Why not a log line, since the counters already exist
13842
- *
13843
- * Several of these paths already counted themselves — `CaptureScheduler`'s
13844
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13845
- * ends in a log line, and a log line is the thing the operator asked to stop
13846
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13847
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13848
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13849
- * media blackout were both diagnosed. The counters stay; this is where they can
13850
- * be READ.
13851
- *
13852
- * ## The rate is served with its denominator or not at all
13853
- *
13854
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
13855
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13856
- * than yesterday" and was **flat across twelve hours** once divided by the
13857
- * successes on the same path. A surface that publishes only the numerator
13858
- * reproduces that mistake on every read.
13859
- *
13860
- * ## Shape
13861
- *
13862
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13863
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13864
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13865
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13866
- * a forked runner's entries reach hub-main over transport that already exists.
13867
- * No new UDS message, no second registry (D3). The operator reads the assembled
13868
- * result through `system.getFailureContributions`.
13869
- */
13870
- var FailureReasonCountSchema = object({
13871
- /**
13872
- * Why the attempt did not land, in the contributor's own vocabulary —
13873
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13874
- * strings that already appear in this repo's logs and, where one exists, the
13875
- * same string the per-track `previewMissReason` records (D276): a second
13876
- * vocabulary for the same loss would make the row and the counter
13877
- * un-joinable.
13878
- */
13879
- reason: string$2(),
13880
- count: number().int().nonnegative()
13881
- });
13882
- var FailureContributionSchema = object({
13883
- /**
13884
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13885
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13886
- * `unit` free: the families are owned by different addons and a shared enum
13887
- * is a central list that rots invisibly.
13888
- */
13889
- family: string$2(),
13890
- /**
13891
- * The NUMERIC device id — the same value every log line carries as
13892
- * `tags.deviceId`. Never nullable and never absent: a contributor that
13893
- * cannot name the camera must not emit the entry, because a fleet total
13894
- * cannot answer the only question anybody asks of this surface.
13895
- */
13896
- deviceId: number().int().positive(),
13897
- /**
13898
- * A second dimension inside the family: the model / step id for an inference
13899
- * timeout, so "which camera AND which model" is one read. Absent when the
13900
- * family has a single variant.
13901
- */
13902
- variant: string$2().optional(),
13903
- /**
13904
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13905
- * differencing two reads must drop the interval when it changes, because the
13906
- * counter restarted from zero in a respawned runner. Same discipline as
13907
- * `LoadContribution.startedAtMs`.
13908
- */
13909
- sinceMs: number(),
13910
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13911
- atMs: number(),
13912
- /**
13913
- * THE DENOMINATOR — every attempt on this path for this camera in the
13914
- * window. A failure count published without it is the mistake this schema
13915
- * exists to make impossible.
13916
- */
13917
- attempts: number().int().nonnegative(),
13918
- /** Attempts that landed. `attempts - succeeded` is the loss. */
13919
- succeeded: number().int().nonnegative(),
13920
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
13921
- reasons: array(FailureReasonCountSchema).readonly()
13922
- });
13923
- method(_void(), array(FailureContributionSchema).readonly());
13924
- var LoadContributionSchema = object({
13925
- role: _enum([
13926
- "decode",
13927
- "transcode",
13928
- "recording",
13929
- "streaming",
13930
- "detection"
13931
- ]),
13932
- /**
13933
- * The NUMERIC device id — the same value every log line carries as
13934
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13935
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
13936
- * contributor that cannot name its camera must not emit the entry at all,
13937
- * because an unnamed per-camera entry is indistinguishable from a shared one
13938
- * and would quietly turn one camera's cost into everybody's.
13939
- */
13940
- deviceId: number().int().positive().nullable(),
13941
- attribution: _enum([
13942
- "measured",
13943
- "accounted",
13944
- "unattributable"
13945
- ]),
13946
- /**
13947
- * What ONE entry is, in the contributor's own words — `615/high`,
13948
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13949
- * family and inventing a common one would lose the only information that
13950
- * makes two entries for the same camera distinguishable.
13951
- */
13952
- unit: string$2(),
13953
- /**
13954
- * The OS process this cost lives in, when there is one. Present so a
13955
- * consumer can (a) tell two generations of the same unit apart across a
13956
- * restart, and (b) subtract claimed processes from the node's process
13957
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13958
- * process of its own.
13959
- */
13960
- pid: number().int().positive().optional(),
13961
- /**
13962
- * When this generation started. The pid's incarnation marker: a consumer
13963
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13964
- * window when this changes, because the counter restarted from zero in a new
13965
- * process.
13966
- */
13967
- startedAtMs: number().optional(),
13968
- /**
13969
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13970
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
13971
- * contribution is asked for.
13972
- *
13973
- * Cumulative and not a rate on purpose: a rate needs a window, a window
13974
- * needs a sampler, and a new per-node sampler is the defect half of
13975
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13976
- * by whoever already keeps a history; a rate cannot be un-averaged.
13977
- *
13978
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13979
- * an entry with no process.
13980
- */
13981
- cpuSeconds: number().optional(),
13982
- /** Resident bytes of this unit's process, same source and same rules. */
13983
- rssBytes: number().optional()
13984
- });
13985
- method(_void(), array(LoadContributionSchema).readonly());
13986
- /**
13987
14034
  * `login-method` — collection cap through which auth addons contribute
13988
14035
  * their pre-auth login surfaces to the login page. This is the SINGLE,
13989
14036
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -18721,12 +18768,53 @@ var MediaFileKindEnum = _enum([
18721
18768
  "keyFrameSmall",
18722
18769
  "thumbnailSmall"
18723
18770
  ]);
18771
+ /**
18772
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
18773
+ * ARE — never the bytes themselves.
18774
+ *
18775
+ * ## Why `url` and not `base64`
18776
+ *
18777
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
18778
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
18779
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
18780
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
18781
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
18782
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
18783
+ *
18784
+ * `url` points at the `event-media` data plane
18785
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
18786
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
18787
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
18788
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
18789
+ * no less protected than they were inside a `view`-level cap response — see
18790
+ * `data-plane-access.ts` for the rule and the one gap it does not close
18791
+ * (per-device scoping).
18792
+ *
18793
+ * The URL is built from the row's **stored** key, which is not always its
18794
+ * published `kind`: a track's face/plate crop is stored as `crop` under
18795
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
18796
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
18797
+ *
18798
+ * ## `base64` is TRANSITIONAL and is going away
18799
+ *
18800
+ * It is still populated for one reason: the deployed viewer's track-detail
18801
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
18802
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
18803
+ * triangle — not as absence. Removing the field before that viewer ships is an
18804
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
18805
+ * delete this line and the `withBytes` pass-through in
18806
+ * `analytics-query-facade.ts`; nothing else reads it.
18807
+ */
18724
18808
  var MediaFileSchema = object({
18725
18809
  key: string$2(),
18726
18810
  kind: MediaFileKindEnum,
18727
- base64: string$2(),
18728
18811
  sizeBytes: number(),
18729
18812
  timestamp: number()
18813
+ }).extend({
18814
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
18815
+ url: string$2(),
18816
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
18817
+ base64: string$2()
18730
18818
  });
18731
18819
  /**
18732
18820
  * One media row WITHOUT its bytes.
@@ -18738,7 +18826,9 @@ var MediaFileSchema = object({
18738
18826
  * blocks the whole view.
18739
18827
  *
18740
18828
  * `sizeBytes` is carried because it is what lets a client decide between the
18741
- * stored blob and a `?variant=thumb` rendering without fetching either.
18829
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
18830
+ * `url` because a client that had to build the plane path itself is a second
18831
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
18742
18832
  */
18743
18833
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18744
18834
  /**
@@ -19427,6 +19517,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19427
19517
  }), array(MediaFileSchema).readonly()), method(object({
19428
19518
  trackId: string$2(),
19429
19519
  deviceId: number()
19520
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19521
+ eventId: string$2(),
19522
+ deviceId: number()
19430
19523
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19431
19524
  kind: "mutation",
19432
19525
  auth: "admin"
@@ -24434,10 +24527,24 @@ var FaceClusterSchema = object({
24434
24527
  size: number().int(),
24435
24528
  cohesion: number()
24436
24529
  });
24530
+ /**
24531
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
24532
+ * are — never the bytes.
24533
+ *
24534
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
24535
+ * track/event contract) is still populated because a deployed viewer requires
24536
+ * the field to parse a row at all; this method has no such reader. Its ONE
24537
+ * caller is the admin UI's detail modal, which was building
24538
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
24539
+ * dialog already rendering its key FRAME from the `event-media` plane.
24540
+ *
24541
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
24542
+ * media key directly, so this needed no new plane and no new access decision.
24543
+ */
24437
24544
  var MediaFileLiteSchema$1 = object({
24438
24545
  key: string$2(),
24439
24546
  kind: string$2(),
24440
- base64: string$2(),
24547
+ url: string$2(),
24441
24548
  sizeBytes: number(),
24442
24549
  timestamp: number()
24443
24550
  });
@@ -27459,10 +27566,24 @@ var PlateInfoSchema = object({
27459
27566
  */
27460
27567
  cropUrl: string$2().optional()
27461
27568
  });
27569
+ /**
27570
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
27571
+ * are — never the bytes.
27572
+ *
27573
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
27574
+ * track/event contract) is still populated because a deployed viewer requires
27575
+ * the field to parse a row at all; this method has no such reader. Its ONE
27576
+ * caller is the admin UI's detail modal, which was building
27577
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
27578
+ * dialog already rendering its key FRAME from the `event-media` plane.
27579
+ *
27580
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
27581
+ * media key directly, so this needed no new plane and no new access decision.
27582
+ */
27462
27583
  var MediaFileLiteSchema = object({
27463
27584
  key: string$2(),
27464
27585
  kind: string$2(),
27465
- base64: string$2(),
27586
+ url: string$2(),
27466
27587
  sizeBytes: number(),
27467
27588
  timestamp: number()
27468
27589
  });
@@ -35359,6 +35480,12 @@ Object.freeze({
35359
35480
  addonId: null,
35360
35481
  access: "view"
35361
35482
  },
35483
+ "pipelineAnalytics.listEventMedia": {
35484
+ capName: "pipeline-analytics",
35485
+ capScope: "device",
35486
+ addonId: null,
35487
+ access: "view"
35488
+ },
35362
35489
  "pipelineAnalytics.listGroups": {
35363
35490
  capName: "pipeline-analytics",
35364
35491
  capScope: "device",
@@ -38982,6 +39109,11 @@ Object.freeze({
38982
39109
  form: "array",
38983
39110
  optional: false
38984
39111
  }],
39112
+ "pipelineAnalytics.listEventMedia": [{
39113
+ name: "deviceId",
39114
+ form: "single",
39115
+ optional: false
39116
+ }],
38985
39117
  "pipelineAnalytics.listGroups": [{
38986
39118
  name: "deviceIds",
38987
39119
  form: "array",
package/dist/addon.mjs CHANGED
@@ -8015,6 +8015,21 @@ var RelocateJobSchema = object({
8015
8015
  bytesMoved: number().int(),
8016
8016
  /** Total files discovered up front; null while (or when) unknown. */
8017
8017
  filesTotal: number().int().nullable(),
8018
+ /**
8019
+ * Rows this run CORRECTED while moving them — a durable mutation the move
8020
+ * made that nobody asked for, so it is reported where the operator reads the
8021
+ * job rather than only in a log line.
8022
+ *
8023
+ * A footage segment records its byte count in its own NAME, and the durable
8024
+ * hour row derives its aggregates from those names. A file that does not
8025
+ * match its name therefore makes the ledger's sums — and with them quota and
8026
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
8027
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
8028
+ *
8029
+ * Absent on lanes where the question has no meaning: a media blob's size is
8030
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
8031
+ */
8032
+ rowsReconciled: number().int().nonnegative().optional(),
8018
8033
  startedAt: number(),
8019
8034
  finishedAt: number().nullable(),
8020
8035
  error: string$2().nullable()
@@ -8083,14 +8098,42 @@ var RelocateMediaInputSchema = object({
8083
8098
  /** Omitted = `move`, the pre-existing behaviour. */
8084
8099
  mode: MediaRelocateModeSchema.optional()
8085
8100
  });
8086
- /** How many rows still carry NO `locationId` — the population a repoint would
8087
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
8088
- * value that permits a non-blocking `eventMedia` cutover. */
8089
- var UnstampedEventMediaCountSchema = object({
8090
- media: number().int().nonnegative(),
8091
- retrainFrames: number().int().nonnegative(),
8092
- total: number().int().nonnegative()
8101
+ /**
8102
+ * The unstamped population of ONE collection — split, because the gate and the
8103
+ * operator ask two different questions and only one of them has to be cheap.
8104
+ *
8105
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
8106
+ * repoint". It is a single indexed seek to the first matching row, so it stays
8107
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
8108
+ * that matters — after a seal, when the population is empty.
8109
+ *
8110
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
8111
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
8112
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
8113
+ * and useful answer: "there are some, and this read could not say how many"
8114
+ * still refuses the cutover, which is the whole job.
8115
+ */
8116
+ var UnstampedRowsSchema = object({
8117
+ present: boolean(),
8118
+ rows: number().int().nonnegative().nullable()
8093
8119
  });
8120
+ /**
8121
+ * How many rows still carry NO `locationId` — the population a repoint would
8122
+ * silently re-aim at a disk that does not hold their bytes.
8123
+ *
8124
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
8125
+ * over. The gate opens on a measured absence and on nothing else; an unread
8126
+ * collection and an empty one are different facts, and this repo has already
8127
+ * paid for conflating them (`RelocateResidueSchema`, D295).
8128
+ */
8129
+ var UnstampedEventMediaCountSchema = object({
8130
+ media: UnstampedRowsSchema,
8131
+ retrainFrames: UnstampedRowsSchema,
8132
+ /** True when EITHER collection holds one. The refusal reads this. */
8133
+ anyPresent: boolean(),
8134
+ /** Sum across both, or `null` when either lane could not be counted. */
8135
+ total: number().int().nonnegative().nullable()
8136
+ }).nullable();
8094
8137
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: string$2().min(1) });
8095
8138
  /** The independently selectable logical storage classes — every class
8096
8139
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -8201,6 +8244,10 @@ var StorageMigrationMoveProgressSchema = object({
8201
8244
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
8202
8245
  filesTotal: number().int().nonnegative().nullable(),
8203
8246
  bytesMoved: number().int().nonnegative(),
8247
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
8248
+ * a lane that cannot reconcile. A migration that silently rewrote durable
8249
+ * rows would be the same failure as one that silently skipped them. */
8250
+ rowsReconciled: number().int().nonnegative().optional(),
8204
8251
  /** The MOVER's start, not the migration's: a drain restarted after an addon
8205
8252
  * crash gets a new mover, and a rate computed from the migration's start
8206
8253
  * would silently average in the time nothing was running. */
@@ -13215,6 +13262,114 @@ method(object({
13215
13262
  height: number()
13216
13263
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string$2() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13217
13264
  /**
13265
+ * `failure-contribution` — the capability an addon reports its OWN losses
13266
+ * through, per camera, with the denominator attached. It stores nothing.
13267
+ *
13268
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13269
+ *
13270
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13271
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13272
+ * copied: the contributor reports what it already knows, hub-main adds only
13273
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13274
+ * somebody to forget to edit.
13275
+ *
13276
+ * They are not merged, because their invariants are opposites:
13277
+ *
13278
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13279
+ * claim a camera cost nothing, which is a measurement nobody made;
13280
+ * - a `failure-contribution` zero is the **most valuable value on the
13281
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13282
+ * and it is exactly what an absent entry cannot say.
13283
+ *
13284
+ * Putting a loss counter on a cost entry would also break the reconciliation
13285
+ * that gives `load-contribution` its point: contributions are subtracted from
13286
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13287
+ * has no process.
13288
+ *
13289
+ * ## Why not a log line, since the counters already exist
13290
+ *
13291
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13292
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13293
+ * ends in a log line, and a log line is the thing the operator asked to stop
13294
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13295
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13296
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13297
+ * media blackout were both diagnosed. The counters stay; this is where they can
13298
+ * be READ.
13299
+ *
13300
+ * ## The rate is served with its denominator or not at all
13301
+ *
13302
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13303
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13304
+ * than yesterday" and was **flat across twelve hours** once divided by the
13305
+ * successes on the same path. A surface that publishes only the numerator
13306
+ * reproduces that mistake on every read.
13307
+ *
13308
+ * ## Shape
13309
+ *
13310
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13311
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13312
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13313
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13314
+ * a forked runner's entries reach hub-main over transport that already exists.
13315
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13316
+ * result through `system.getFailureContributions`.
13317
+ */
13318
+ var FailureReasonCountSchema = object({
13319
+ /**
13320
+ * Why the attempt did not land, in the contributor's own vocabulary —
13321
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13322
+ * strings that already appear in this repo's logs and, where one exists, the
13323
+ * same string the per-track `previewMissReason` records (D276): a second
13324
+ * vocabulary for the same loss would make the row and the counter
13325
+ * un-joinable.
13326
+ */
13327
+ reason: string$2(),
13328
+ count: number().int().nonnegative()
13329
+ });
13330
+ var FailureContributionSchema = object({
13331
+ /**
13332
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13333
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13334
+ * `unit` free: the families are owned by different addons and a shared enum
13335
+ * is a central list that rots invisibly.
13336
+ */
13337
+ family: string$2(),
13338
+ /**
13339
+ * The NUMERIC device id — the same value every log line carries as
13340
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13341
+ * cannot name the camera must not emit the entry, because a fleet total
13342
+ * cannot answer the only question anybody asks of this surface.
13343
+ */
13344
+ deviceId: number().int().positive(),
13345
+ /**
13346
+ * A second dimension inside the family: the model / step id for an inference
13347
+ * timeout, so "which camera AND which model" is one read. Absent when the
13348
+ * family has a single variant.
13349
+ */
13350
+ variant: string$2().optional(),
13351
+ /**
13352
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13353
+ * differencing two reads must drop the interval when it changes, because the
13354
+ * counter restarted from zero in a respawned runner. Same discipline as
13355
+ * `LoadContribution.startedAtMs`.
13356
+ */
13357
+ sinceMs: number(),
13358
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13359
+ atMs: number(),
13360
+ /**
13361
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13362
+ * window. A failure count published without it is the mistake this schema
13363
+ * exists to make impossible.
13364
+ */
13365
+ attempts: number().int().nonnegative(),
13366
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13367
+ succeeded: number().int().nonnegative(),
13368
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13369
+ reasons: array(FailureReasonCountSchema).readonly()
13370
+ });
13371
+ method(_void(), array(FailureContributionSchema).readonly());
13372
+ /**
13218
13373
  * filesystem-browse — per-node capability for browsing the node's local
13219
13374
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13220
13375
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -13736,6 +13891,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13736
13891
  kind: "mutation",
13737
13892
  auth: "admin"
13738
13893
  });
13894
+ var LoadContributionSchema = object({
13895
+ role: _enum([
13896
+ "decode",
13897
+ "transcode",
13898
+ "recording",
13899
+ "streaming",
13900
+ "detection"
13901
+ ]),
13902
+ /**
13903
+ * The NUMERIC device id — the same value every log line carries as
13904
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13905
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
13906
+ * contributor that cannot name its camera must not emit the entry at all,
13907
+ * because an unnamed per-camera entry is indistinguishable from a shared one
13908
+ * and would quietly turn one camera's cost into everybody's.
13909
+ */
13910
+ deviceId: number().int().positive().nullable(),
13911
+ attribution: _enum([
13912
+ "measured",
13913
+ "accounted",
13914
+ "unattributable"
13915
+ ]),
13916
+ /**
13917
+ * What ONE entry is, in the contributor's own words — `615/high`,
13918
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13919
+ * family and inventing a common one would lose the only information that
13920
+ * makes two entries for the same camera distinguishable.
13921
+ */
13922
+ unit: string$2(),
13923
+ /**
13924
+ * The OS process this cost lives in, when there is one. Present so a
13925
+ * consumer can (a) tell two generations of the same unit apart across a
13926
+ * restart, and (b) subtract claimed processes from the node's process
13927
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13928
+ * process of its own.
13929
+ */
13930
+ pid: number().int().positive().optional(),
13931
+ /**
13932
+ * When this generation started. The pid's incarnation marker: a consumer
13933
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13934
+ * window when this changes, because the counter restarted from zero in a new
13935
+ * process.
13936
+ */
13937
+ startedAtMs: number().optional(),
13938
+ /**
13939
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13940
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
13941
+ * contribution is asked for.
13942
+ *
13943
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
13944
+ * needs a sampler, and a new per-node sampler is the defect half of
13945
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13946
+ * by whoever already keeps a history; a rate cannot be un-averaged.
13947
+ *
13948
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13949
+ * an entry with no process.
13950
+ */
13951
+ cpuSeconds: number().optional(),
13952
+ /** Resident bytes of this unit's process, same source and same rules. */
13953
+ rssBytes: number().optional()
13954
+ });
13955
+ method(_void(), array(LoadContributionSchema).readonly());
13739
13956
  /**
13740
13957
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
13741
13958
  * through. It stores nothing.
@@ -13812,176 +14029,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13812
14029
  tags: record(string$2(), string$2()).optional()
13813
14030
  }), array(LogEntrySchema).readonly());
13814
14031
  /**
13815
- * `failure-contribution` — the capability an addon reports its OWN losses
13816
- * through, per camera, with the denominator attached. It stores nothing.
13817
- *
13818
- * ## The twin of `load-contribution`, and why it is a twin and not a field
13819
- *
13820
- * `load-contribution` answers *what did this camera COST*. This answers *what
13821
- * did this camera LOSE*. The reporting discipline is identical and deliberately
13822
- * copied: the contributor reports what it already knows, hub-main adds only
13823
- * `addonId`, nothing needs global knowledge, and there is no central list for
13824
- * somebody to forget to edit.
13825
- *
13826
- * They are not merged, because their invariants are opposites:
13827
- *
13828
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
13829
- * claim a camera cost nothing, which is a measurement nobody made;
13830
- * - a `failure-contribution` zero is the **most valuable value on the
13831
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13832
- * and it is exactly what an absent entry cannot say.
13833
- *
13834
- * Putting a loss counter on a cost entry would also break the reconciliation
13835
- * that gives `load-contribution` its point: contributions are subtracted from
13836
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13837
- * has no process.
13838
- *
13839
- * ## Why not a log line, since the counters already exist
13840
- *
13841
- * Several of these paths already counted themselves — `CaptureScheduler`'s
13842
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13843
- * ends in a log line, and a log line is the thing the operator asked to stop
13844
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13845
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13846
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13847
- * media blackout were both diagnosed. The counters stay; this is where they can
13848
- * be READ.
13849
- *
13850
- * ## The rate is served with its denominator or not at all
13851
- *
13852
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
13853
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13854
- * than yesterday" and was **flat across twelve hours** once divided by the
13855
- * successes on the same path. A surface that publishes only the numerator
13856
- * reproduces that mistake on every read.
13857
- *
13858
- * ## Shape
13859
- *
13860
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13861
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13862
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13863
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13864
- * a forked runner's entries reach hub-main over transport that already exists.
13865
- * No new UDS message, no second registry (D3). The operator reads the assembled
13866
- * result through `system.getFailureContributions`.
13867
- */
13868
- var FailureReasonCountSchema = object({
13869
- /**
13870
- * Why the attempt did not land, in the contributor's own vocabulary —
13871
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13872
- * strings that already appear in this repo's logs and, where one exists, the
13873
- * same string the per-track `previewMissReason` records (D276): a second
13874
- * vocabulary for the same loss would make the row and the counter
13875
- * un-joinable.
13876
- */
13877
- reason: string$2(),
13878
- count: number().int().nonnegative()
13879
- });
13880
- var FailureContributionSchema = object({
13881
- /**
13882
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13883
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13884
- * `unit` free: the families are owned by different addons and a shared enum
13885
- * is a central list that rots invisibly.
13886
- */
13887
- family: string$2(),
13888
- /**
13889
- * The NUMERIC device id — the same value every log line carries as
13890
- * `tags.deviceId`. Never nullable and never absent: a contributor that
13891
- * cannot name the camera must not emit the entry, because a fleet total
13892
- * cannot answer the only question anybody asks of this surface.
13893
- */
13894
- deviceId: number().int().positive(),
13895
- /**
13896
- * A second dimension inside the family: the model / step id for an inference
13897
- * timeout, so "which camera AND which model" is one read. Absent when the
13898
- * family has a single variant.
13899
- */
13900
- variant: string$2().optional(),
13901
- /**
13902
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13903
- * differencing two reads must drop the interval when it changes, because the
13904
- * counter restarted from zero in a respawned runner. Same discipline as
13905
- * `LoadContribution.startedAtMs`.
13906
- */
13907
- sinceMs: number(),
13908
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13909
- atMs: number(),
13910
- /**
13911
- * THE DENOMINATOR — every attempt on this path for this camera in the
13912
- * window. A failure count published without it is the mistake this schema
13913
- * exists to make impossible.
13914
- */
13915
- attempts: number().int().nonnegative(),
13916
- /** Attempts that landed. `attempts - succeeded` is the loss. */
13917
- succeeded: number().int().nonnegative(),
13918
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
13919
- reasons: array(FailureReasonCountSchema).readonly()
13920
- });
13921
- method(_void(), array(FailureContributionSchema).readonly());
13922
- var LoadContributionSchema = object({
13923
- role: _enum([
13924
- "decode",
13925
- "transcode",
13926
- "recording",
13927
- "streaming",
13928
- "detection"
13929
- ]),
13930
- /**
13931
- * The NUMERIC device id — the same value every log line carries as
13932
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13933
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
13934
- * contributor that cannot name its camera must not emit the entry at all,
13935
- * because an unnamed per-camera entry is indistinguishable from a shared one
13936
- * and would quietly turn one camera's cost into everybody's.
13937
- */
13938
- deviceId: number().int().positive().nullable(),
13939
- attribution: _enum([
13940
- "measured",
13941
- "accounted",
13942
- "unattributable"
13943
- ]),
13944
- /**
13945
- * What ONE entry is, in the contributor's own words — `615/high`,
13946
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13947
- * family and inventing a common one would lose the only information that
13948
- * makes two entries for the same camera distinguishable.
13949
- */
13950
- unit: string$2(),
13951
- /**
13952
- * The OS process this cost lives in, when there is one. Present so a
13953
- * consumer can (a) tell two generations of the same unit apart across a
13954
- * restart, and (b) subtract claimed processes from the node's process
13955
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
13956
- * process of its own.
13957
- */
13958
- pid: number().int().positive().optional(),
13959
- /**
13960
- * When this generation started. The pid's incarnation marker: a consumer
13961
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
13962
- * window when this changes, because the counter restarted from zero in a new
13963
- * process.
13964
- */
13965
- startedAtMs: number().optional(),
13966
- /**
13967
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
13968
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
13969
- * contribution is asked for.
13970
- *
13971
- * Cumulative and not a rate on purpose: a rate needs a window, a window
13972
- * needs a sampler, and a new per-node sampler is the defect half of
13973
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
13974
- * by whoever already keeps a history; a rate cannot be un-averaged.
13975
- *
13976
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
13977
- * an entry with no process.
13978
- */
13979
- cpuSeconds: number().optional(),
13980
- /** Resident bytes of this unit's process, same source and same rules. */
13981
- rssBytes: number().optional()
13982
- });
13983
- method(_void(), array(LoadContributionSchema).readonly());
13984
- /**
13985
14032
  * `login-method` — collection cap through which auth addons contribute
13986
14033
  * their pre-auth login surfaces to the login page. This is the SINGLE,
13987
14034
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -18719,12 +18766,53 @@ var MediaFileKindEnum = _enum([
18719
18766
  "keyFrameSmall",
18720
18767
  "thumbnailSmall"
18721
18768
  ]);
18769
+ /**
18770
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
18771
+ * ARE — never the bytes themselves.
18772
+ *
18773
+ * ## Why `url` and not `base64`
18774
+ *
18775
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
18776
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
18777
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
18778
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
18779
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
18780
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
18781
+ *
18782
+ * `url` points at the `event-media` data plane
18783
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
18784
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
18785
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
18786
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
18787
+ * no less protected than they were inside a `view`-level cap response — see
18788
+ * `data-plane-access.ts` for the rule and the one gap it does not close
18789
+ * (per-device scoping).
18790
+ *
18791
+ * The URL is built from the row's **stored** key, which is not always its
18792
+ * published `kind`: a track's face/plate crop is stored as `crop` under
18793
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
18794
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
18795
+ *
18796
+ * ## `base64` is TRANSITIONAL and is going away
18797
+ *
18798
+ * It is still populated for one reason: the deployed viewer's track-detail
18799
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
18800
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
18801
+ * triangle — not as absence. Removing the field before that viewer ships is an
18802
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
18803
+ * delete this line and the `withBytes` pass-through in
18804
+ * `analytics-query-facade.ts`; nothing else reads it.
18805
+ */
18722
18806
  var MediaFileSchema = object({
18723
18807
  key: string$2(),
18724
18808
  kind: MediaFileKindEnum,
18725
- base64: string$2(),
18726
18809
  sizeBytes: number(),
18727
18810
  timestamp: number()
18811
+ }).extend({
18812
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
18813
+ url: string$2(),
18814
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
18815
+ base64: string$2()
18728
18816
  });
18729
18817
  /**
18730
18818
  * One media row WITHOUT its bytes.
@@ -18736,7 +18824,9 @@ var MediaFileSchema = object({
18736
18824
  * blocks the whole view.
18737
18825
  *
18738
18826
  * `sizeBytes` is carried because it is what lets a client decide between the
18739
- * stored blob and a `?variant=thumb` rendering without fetching either.
18827
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
18828
+ * `url` because a client that had to build the plane path itself is a second
18829
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
18740
18830
  */
18741
18831
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18742
18832
  /**
@@ -19425,6 +19515,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19425
19515
  }), array(MediaFileSchema).readonly()), method(object({
19426
19516
  trackId: string$2(),
19427
19517
  deviceId: number()
19518
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19519
+ eventId: string$2(),
19520
+ deviceId: number()
19428
19521
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19429
19522
  kind: "mutation",
19430
19523
  auth: "admin"
@@ -24432,10 +24525,24 @@ var FaceClusterSchema = object({
24432
24525
  size: number().int(),
24433
24526
  cohesion: number()
24434
24527
  });
24528
+ /**
24529
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
24530
+ * are — never the bytes.
24531
+ *
24532
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
24533
+ * track/event contract) is still populated because a deployed viewer requires
24534
+ * the field to parse a row at all; this method has no such reader. Its ONE
24535
+ * caller is the admin UI's detail modal, which was building
24536
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
24537
+ * dialog already rendering its key FRAME from the `event-media` plane.
24538
+ *
24539
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
24540
+ * media key directly, so this needed no new plane and no new access decision.
24541
+ */
24435
24542
  var MediaFileLiteSchema$1 = object({
24436
24543
  key: string$2(),
24437
24544
  kind: string$2(),
24438
- base64: string$2(),
24545
+ url: string$2(),
24439
24546
  sizeBytes: number(),
24440
24547
  timestamp: number()
24441
24548
  });
@@ -27457,10 +27564,24 @@ var PlateInfoSchema = object({
27457
27564
  */
27458
27565
  cropUrl: string$2().optional()
27459
27566
  });
27567
+ /**
27568
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
27569
+ * are — never the bytes.
27570
+ *
27571
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
27572
+ * track/event contract) is still populated because a deployed viewer requires
27573
+ * the field to parse a row at all; this method has no such reader. Its ONE
27574
+ * caller is the admin UI's detail modal, which was building
27575
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
27576
+ * dialog already rendering its key FRAME from the `event-media` plane.
27577
+ *
27578
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
27579
+ * media key directly, so this needed no new plane and no new access decision.
27580
+ */
27460
27581
  var MediaFileLiteSchema = object({
27461
27582
  key: string$2(),
27462
27583
  kind: string$2(),
27463
- base64: string$2(),
27584
+ url: string$2(),
27464
27585
  sizeBytes: number(),
27465
27586
  timestamp: number()
27466
27587
  });
@@ -35357,6 +35478,12 @@ Object.freeze({
35357
35478
  addonId: null,
35358
35479
  access: "view"
35359
35480
  },
35481
+ "pipelineAnalytics.listEventMedia": {
35482
+ capName: "pipeline-analytics",
35483
+ capScope: "device",
35484
+ addonId: null,
35485
+ access: "view"
35486
+ },
35360
35487
  "pipelineAnalytics.listGroups": {
35361
35488
  capName: "pipeline-analytics",
35362
35489
  capScope: "device",
@@ -38980,6 +39107,11 @@ Object.freeze({
38980
39107
  form: "array",
38981
39108
  optional: false
38982
39109
  }],
39110
+ "pipelineAnalytics.listEventMedia": [{
39111
+ name: "deviceId",
39112
+ form: "single",
39113
+ optional: false
39114
+ }],
38983
39115
  "pipelineAnalytics.listGroups": [{
38984
39116
  name: "deviceIds",
38985
39117
  form: "array",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-matter-broker",
3
- "version": "0.2.44",
3
+ "version": "0.2.46",
4
4
  "description": "Matter broker addon for CamStack — owns a Matter fabric (commissioning + the long-lived controller) via the matter.js controller and brokers commissioned Matter nodes into CamStack",
5
5
  "keywords": [
6
6
  "camstack",