@camstack/addon-matter-broker 0.2.45 → 0.2.47

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 +331 -174
  2. package/dist/addon.mjs +331 -174
  3. package/package.json +1 -1
package/dist/addon.js CHANGED
@@ -13264,6 +13264,114 @@ method(object({
13264
13264
  height: number()
13265
13265
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string$2() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13266
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
+ /**
13267
13375
  * filesystem-browse — per-node capability for browsing the node's local
13268
13376
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13269
13377
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -13785,6 +13893,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13785
13893
  kind: "mutation",
13786
13894
  auth: "admin"
13787
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());
13788
13958
  /**
13789
13959
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
13790
13960
  * through. It stores nothing.
@@ -13861,176 +14031,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13861
14031
  tags: record(string$2(), string$2()).optional()
13862
14032
  }), array(LogEntrySchema).readonly());
13863
14033
  /**
13864
- * `failure-contribution` — the capability an addon reports its OWN losses
13865
- * through, per camera, with the denominator attached. It stores nothing.
13866
- *
13867
- * ## The twin of `load-contribution`, and why it is a twin and not a field
13868
- *
13869
- * `load-contribution` answers *what did this camera COST*. This answers *what
13870
- * did this camera LOSE*. The reporting discipline is identical and deliberately
13871
- * copied: the contributor reports what it already knows, hub-main adds only
13872
- * `addonId`, nothing needs global knowledge, and there is no central list for
13873
- * somebody to forget to edit.
13874
- *
13875
- * They are not merged, because their invariants are opposites:
13876
- *
13877
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
13878
- * claim a camera cost nothing, which is a measurement nobody made;
13879
- * - a `failure-contribution` zero is the **most valuable value on the
13880
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13881
- * and it is exactly what an absent entry cannot say.
13882
- *
13883
- * Putting a loss counter on a cost entry would also break the reconciliation
13884
- * that gives `load-contribution` its point: contributions are subtracted from
13885
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13886
- * has no process.
13887
- *
13888
- * ## Why not a log line, since the counters already exist
13889
- *
13890
- * Several of these paths already counted themselves — `CaptureScheduler`'s
13891
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13892
- * ends in a log line, and a log line is the thing the operator asked to stop
13893
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13894
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13895
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13896
- * media blackout were both diagnosed. The counters stay; this is where they can
13897
- * be READ.
13898
- *
13899
- * ## The rate is served with its denominator or not at all
13900
- *
13901
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
13902
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13903
- * than yesterday" and was **flat across twelve hours** once divided by the
13904
- * successes on the same path. A surface that publishes only the numerator
13905
- * reproduces that mistake on every read.
13906
- *
13907
- * ## Shape
13908
- *
13909
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13910
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13911
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13912
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13913
- * a forked runner's entries reach hub-main over transport that already exists.
13914
- * No new UDS message, no second registry (D3). The operator reads the assembled
13915
- * result through `system.getFailureContributions`.
13916
- */
13917
- var FailureReasonCountSchema = object({
13918
- /**
13919
- * Why the attempt did not land, in the contributor's own vocabulary —
13920
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13921
- * strings that already appear in this repo's logs and, where one exists, the
13922
- * same string the per-track `previewMissReason` records (D276): a second
13923
- * vocabulary for the same loss would make the row and the counter
13924
- * un-joinable.
13925
- */
13926
- reason: string$2(),
13927
- count: number().int().nonnegative()
13928
- });
13929
- var FailureContributionSchema = object({
13930
- /**
13931
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13932
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13933
- * `unit` free: the families are owned by different addons and a shared enum
13934
- * is a central list that rots invisibly.
13935
- */
13936
- family: string$2(),
13937
- /**
13938
- * The NUMERIC device id — the same value every log line carries as
13939
- * `tags.deviceId`. Never nullable and never absent: a contributor that
13940
- * cannot name the camera must not emit the entry, because a fleet total
13941
- * cannot answer the only question anybody asks of this surface.
13942
- */
13943
- deviceId: number().int().positive(),
13944
- /**
13945
- * A second dimension inside the family: the model / step id for an inference
13946
- * timeout, so "which camera AND which model" is one read. Absent when the
13947
- * family has a single variant.
13948
- */
13949
- variant: string$2().optional(),
13950
- /**
13951
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13952
- * differencing two reads must drop the interval when it changes, because the
13953
- * counter restarted from zero in a respawned runner. Same discipline as
13954
- * `LoadContribution.startedAtMs`.
13955
- */
13956
- sinceMs: number(),
13957
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13958
- atMs: number(),
13959
- /**
13960
- * THE DENOMINATOR — every attempt on this path for this camera in the
13961
- * window. A failure count published without it is the mistake this schema
13962
- * exists to make impossible.
13963
- */
13964
- attempts: number().int().nonnegative(),
13965
- /** Attempts that landed. `attempts - succeeded` is the loss. */
13966
- succeeded: number().int().nonnegative(),
13967
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
13968
- reasons: array(FailureReasonCountSchema).readonly()
13969
- });
13970
- method(_void(), array(FailureContributionSchema).readonly());
13971
- var LoadContributionSchema = object({
13972
- role: _enum([
13973
- "decode",
13974
- "transcode",
13975
- "recording",
13976
- "streaming",
13977
- "detection"
13978
- ]),
13979
- /**
13980
- * The NUMERIC device id — the same value every log line carries as
13981
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13982
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
13983
- * contributor that cannot name its camera must not emit the entry at all,
13984
- * because an unnamed per-camera entry is indistinguishable from a shared one
13985
- * and would quietly turn one camera's cost into everybody's.
13986
- */
13987
- deviceId: number().int().positive().nullable(),
13988
- attribution: _enum([
13989
- "measured",
13990
- "accounted",
13991
- "unattributable"
13992
- ]),
13993
- /**
13994
- * What ONE entry is, in the contributor's own words — `615/high`,
13995
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13996
- * family and inventing a common one would lose the only information that
13997
- * makes two entries for the same camera distinguishable.
13998
- */
13999
- unit: string$2(),
14000
- /**
14001
- * The OS process this cost lives in, when there is one. Present so a
14002
- * consumer can (a) tell two generations of the same unit apart across a
14003
- * restart, and (b) subtract claimed processes from the node's process
14004
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14005
- * process of its own.
14006
- */
14007
- pid: number().int().positive().optional(),
14008
- /**
14009
- * When this generation started. The pid's incarnation marker: a consumer
14010
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14011
- * window when this changes, because the counter restarted from zero in a new
14012
- * process.
14013
- */
14014
- startedAtMs: number().optional(),
14015
- /**
14016
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14017
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
14018
- * contribution is asked for.
14019
- *
14020
- * Cumulative and not a rate on purpose: a rate needs a window, a window
14021
- * needs a sampler, and a new per-node sampler is the defect half of
14022
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14023
- * by whoever already keeps a history; a rate cannot be un-averaged.
14024
- *
14025
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14026
- * an entry with no process.
14027
- */
14028
- cpuSeconds: number().optional(),
14029
- /** Resident bytes of this unit's process, same source and same rules. */
14030
- rssBytes: number().optional()
14031
- });
14032
- method(_void(), array(LoadContributionSchema).readonly());
14033
- /**
14034
14034
  * `login-method` — collection cap through which auth addons contribute
14035
14035
  * their pre-auth login surfaces to the login page. This is the SINGLE,
14036
14036
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -18768,12 +18768,53 @@ var MediaFileKindEnum = _enum([
18768
18768
  "keyFrameSmall",
18769
18769
  "thumbnailSmall"
18770
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
+ */
18771
18808
  var MediaFileSchema = object({
18772
18809
  key: string$2(),
18773
18810
  kind: MediaFileKindEnum,
18774
- base64: string$2(),
18775
18811
  sizeBytes: number(),
18776
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()
18777
18818
  });
18778
18819
  /**
18779
18820
  * One media row WITHOUT its bytes.
@@ -18785,7 +18826,9 @@ var MediaFileSchema = object({
18785
18826
  * blocks the whole view.
18786
18827
  *
18787
18828
  * `sizeBytes` is carried because it is what lets a client decide between the
18788
- * 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.
18789
18832
  */
18790
18833
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18791
18834
  /**
@@ -19132,6 +19175,50 @@ var EventStoreFootprintSchema = object({
19132
19175
  totalBytes: number().int(),
19133
19176
  devices: array(EventStoreDeviceFootprintSchema).readonly()
19134
19177
  });
19178
+ /** Event-media footprint for one {@link MediaFileKind}. */
19179
+ var EventMediaKindFootprintSchema = object({
19180
+ kind: MediaFileKindEnum,
19181
+ /** Media rows of this kind. */
19182
+ rows: number().int(),
19183
+ /** Bytes on disk held by those rows. */
19184
+ bytes: number().int()
19185
+ });
19186
+ /**
19187
+ * The media footprint broken down by KIND — the axis a deletion decision
19188
+ * actually turns on.
19189
+ *
19190
+ * A byte total says how much there is; it cannot say what is safe to remove.
19191
+ * The deletable set (the periodic `snapshot` filmstrip, the surplus per-edge
19192
+ * motion stills) and the keep set (`firstFrame`, rolling `lastFrame`,
19193
+ * `thumbnail`/`thumbnailSmall`, `keyFrame`/`keyFrameSmall`, the face/plate
19194
+ * buffers, gallery media, the CLIP `crop`) are distinguished by `kind` and by
19195
+ * nothing else, so sizing a deletion means summing per kind.
19196
+ *
19197
+ * ## Why `unaccounted*` exists
19198
+ *
19199
+ * `kinds` is enumerated from {@link MediaFileKindEnum} — the closed set the
19200
+ * writers use — and summed one kind at a time. `totalRows` / `totalBytes` come
19201
+ * from a SEPARATE unfiltered aggregate over the same rows, never from adding
19202
+ * `kinds` up. A row whose stored `kind` is not in the enum (written by a
19203
+ * retired code path, or by a version that knew a kind this one does not) would
19204
+ * otherwise vanish from the total silently, and an operator would delete
19205
+ * against a denominator smaller than the disk.
19206
+ *
19207
+ * `unaccountedRows` / `unaccountedBytes` are the difference. They are normally
19208
+ * zero; a non-zero value is a real finding and must be shown, not rounded away.
19209
+ */
19210
+ var EventMediaKindBreakdownSchema = object({
19211
+ /** Every media row in scope, from one unfiltered aggregate. */
19212
+ totalRows: number().int(),
19213
+ /** Every media byte in scope, from that same aggregate. */
19214
+ totalBytes: number().int(),
19215
+ /** Per-kind footprint, ordered by bytes descending. */
19216
+ kinds: array(EventMediaKindFootprintSchema).readonly(),
19217
+ /** `totalRows` minus the summed `kinds` rows — see the schema note. */
19218
+ unaccountedRows: number().int(),
19219
+ /** `totalBytes` minus the summed `kinds` bytes — see the schema note. */
19220
+ unaccountedBytes: number().int()
19221
+ });
19135
19222
  /** Per-kind counts returned by the event-prune / device-delete mutations. */
19136
19223
  var EventPruneCountsSchema = object({
19137
19224
  motion: number().int(),
@@ -19335,6 +19422,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19335
19422
  }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19336
19423
  kind: "query",
19337
19424
  auth: "admin"
19425
+ }), method(object({ deviceId: number().int().optional() }), EventMediaKindBreakdownSchema, {
19426
+ kind: "query",
19427
+ auth: "admin"
19338
19428
  }), method(object({
19339
19429
  olderThanMs: number(),
19340
19430
  reason: OpsLogReasonSchema.optional()
@@ -19474,6 +19564,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19474
19564
  }), array(MediaFileSchema).readonly()), method(object({
19475
19565
  trackId: string$2(),
19476
19566
  deviceId: number()
19567
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19568
+ eventId: string$2(),
19569
+ deviceId: number()
19477
19570
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19478
19571
  kind: "mutation",
19479
19572
  auth: "admin"
@@ -21283,6 +21376,20 @@ method(object({
21283
21376
  error: string$2().optional()
21284
21377
  }), { auth: "admin" }), method(_void(), array(ProviderListEntrySchema).readonly()), method(object({
21285
21378
  providerId: string$2(),
21379
+ /**
21380
+ * The location this config is an UNSAVED edit of, when there is one.
21381
+ *
21382
+ * `listLocations` replaces every declared secret with the redaction
21383
+ * sentinel, so the edit modal's form state holds the sentinel for any
21384
+ * credential the operator did not retype — and posting that here
21385
+ * without a way to resolve it makes the provider try to authenticate
21386
+ * as `__camstack_redacted__` and report the operator's own working
21387
+ * password as wrong. Given this id, the orchestrator restores each
21388
+ * sentinel from the stored config (same rule as `upsertLocation`)
21389
+ * before dispatching. Omitted by the "Add location" wizard, where
21390
+ * every value was typed just now and nothing is stored yet.
21391
+ */
21392
+ locationId: string$2().optional(),
21286
21393
  config: record(string$2(), unknown())
21287
21394
  }), object({
21288
21395
  ok: boolean(),
@@ -24481,10 +24588,24 @@ var FaceClusterSchema = object({
24481
24588
  size: number().int(),
24482
24589
  cohesion: number()
24483
24590
  });
24591
+ /**
24592
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
24593
+ * are — never the bytes.
24594
+ *
24595
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
24596
+ * track/event contract) is still populated because a deployed viewer requires
24597
+ * the field to parse a row at all; this method has no such reader. Its ONE
24598
+ * caller is the admin UI's detail modal, which was building
24599
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
24600
+ * dialog already rendering its key FRAME from the `event-media` plane.
24601
+ *
24602
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
24603
+ * media key directly, so this needed no new plane and no new access decision.
24604
+ */
24484
24605
  var MediaFileLiteSchema$1 = object({
24485
24606
  key: string$2(),
24486
24607
  kind: string$2(),
24487
- base64: string$2(),
24608
+ url: string$2(),
24488
24609
  sizeBytes: number(),
24489
24610
  timestamp: number()
24490
24611
  });
@@ -27506,10 +27627,24 @@ var PlateInfoSchema = object({
27506
27627
  */
27507
27628
  cropUrl: string$2().optional()
27508
27629
  });
27630
+ /**
27631
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
27632
+ * are — never the bytes.
27633
+ *
27634
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
27635
+ * track/event contract) is still populated because a deployed viewer requires
27636
+ * the field to parse a row at all; this method has no such reader. Its ONE
27637
+ * caller is the admin UI's detail modal, which was building
27638
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
27639
+ * dialog already rendering its key FRAME from the `event-media` plane.
27640
+ *
27641
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
27642
+ * media key directly, so this needed no new plane and no new access decision.
27643
+ */
27509
27644
  var MediaFileLiteSchema = object({
27510
27645
  key: string$2(),
27511
27646
  kind: string$2(),
27512
- base64: string$2(),
27647
+ url: string$2(),
27513
27648
  sizeBytes: number(),
27514
27649
  timestamp: number()
27515
27650
  });
@@ -35310,6 +35445,12 @@ Object.freeze({
35310
35445
  addonId: null,
35311
35446
  access: "view"
35312
35447
  },
35448
+ "pipelineAnalytics.getEventMediaFootprintByKind": {
35449
+ capName: "pipeline-analytics",
35450
+ capScope: "device",
35451
+ addonId: null,
35452
+ access: "view"
35453
+ },
35313
35454
  "pipelineAnalytics.getEventStoreFootprint": {
35314
35455
  capName: "pipeline-analytics",
35315
35456
  capScope: "device",
@@ -35406,6 +35547,12 @@ Object.freeze({
35406
35547
  addonId: null,
35407
35548
  access: "view"
35408
35549
  },
35550
+ "pipelineAnalytics.listEventMedia": {
35551
+ capName: "pipeline-analytics",
35552
+ capScope: "device",
35553
+ addonId: null,
35554
+ access: "view"
35555
+ },
35409
35556
  "pipelineAnalytics.listGroups": {
35410
35557
  capName: "pipeline-analytics",
35411
35558
  capScope: "device",
@@ -38969,6 +39116,11 @@ Object.freeze({
38969
39116
  form: "single",
38970
39117
  optional: false
38971
39118
  }],
39119
+ "pipelineAnalytics.getEventMediaFootprintByKind": [{
39120
+ name: "deviceId",
39121
+ form: "single",
39122
+ optional: true
39123
+ }],
38972
39124
  "pipelineAnalytics.getGroup": [{
38973
39125
  name: "deviceId",
38974
39126
  form: "single",
@@ -39029,6 +39181,11 @@ Object.freeze({
39029
39181
  form: "array",
39030
39182
  optional: false
39031
39183
  }],
39184
+ "pipelineAnalytics.listEventMedia": [{
39185
+ name: "deviceId",
39186
+ form: "single",
39187
+ optional: false
39188
+ }],
39032
39189
  "pipelineAnalytics.listGroups": [{
39033
39190
  name: "deviceIds",
39034
39191
  form: "array",
package/dist/addon.mjs CHANGED
@@ -13262,6 +13262,114 @@ method(object({
13262
13262
  height: number()
13263
13263
  }), EmbeddingResultSchema, { auth: "admin" }), method(object({ text: string$2() }), EmbeddingResultSchema, { auth: "admin" }), method(_void(), EmbeddingInfoSchema, { auth: "admin" });
13264
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
+ /**
13265
13373
  * filesystem-browse — per-node capability for browsing the node's local
13266
13374
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
13267
13375
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -13783,6 +13891,68 @@ method(LlmGenerateBaseInputSchema, LlmGenerateResultSchema, { kind: "mutation" }
13783
13891
  kind: "mutation",
13784
13892
  auth: "admin"
13785
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());
13786
13956
  /**
13787
13957
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
13788
13958
  * through. It stores nothing.
@@ -13859,176 +14029,6 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13859
14029
  tags: record(string$2(), string$2()).optional()
13860
14030
  }), array(LogEntrySchema).readonly());
13861
14031
  /**
13862
- * `failure-contribution` — the capability an addon reports its OWN losses
13863
- * through, per camera, with the denominator attached. It stores nothing.
13864
- *
13865
- * ## The twin of `load-contribution`, and why it is a twin and not a field
13866
- *
13867
- * `load-contribution` answers *what did this camera COST*. This answers *what
13868
- * did this camera LOSE*. The reporting discipline is identical and deliberately
13869
- * copied: the contributor reports what it already knows, hub-main adds only
13870
- * `addonId`, nothing needs global knowledge, and there is no central list for
13871
- * somebody to forget to edit.
13872
- *
13873
- * They are not merged, because their invariants are opposites:
13874
- *
13875
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
13876
- * claim a camera cost nothing, which is a measurement nobody made;
13877
- * - a `failure-contribution` zero is the **most valuable value on the
13878
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13879
- * and it is exactly what an absent entry cannot say.
13880
- *
13881
- * Putting a loss counter on a cost entry would also break the reconciliation
13882
- * that gives `load-contribution` its point: contributions are subtracted from
13883
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13884
- * has no process.
13885
- *
13886
- * ## Why not a log line, since the counters already exist
13887
- *
13888
- * Several of these paths already counted themselves — `CaptureScheduler`'s
13889
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13890
- * ends in a log line, and a log line is the thing the operator asked to stop
13891
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13892
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13893
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13894
- * media blackout were both diagnosed. The counters stay; this is where they can
13895
- * be READ.
13896
- *
13897
- * ## The rate is served with its denominator or not at all
13898
- *
13899
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
13900
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13901
- * than yesterday" and was **flat across twelve hours** once divided by the
13902
- * successes on the same path. A surface that publishes only the numerator
13903
- * reproduces that mistake on every read.
13904
- *
13905
- * ## Shape
13906
- *
13907
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13908
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13909
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13910
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13911
- * a forked runner's entries reach hub-main over transport that already exists.
13912
- * No new UDS message, no second registry (D3). The operator reads the assembled
13913
- * result through `system.getFailureContributions`.
13914
- */
13915
- var FailureReasonCountSchema = object({
13916
- /**
13917
- * Why the attempt did not land, in the contributor's own vocabulary —
13918
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13919
- * strings that already appear in this repo's logs and, where one exists, the
13920
- * same string the per-track `previewMissReason` records (D276): a second
13921
- * vocabulary for the same loss would make the row and the counter
13922
- * un-joinable.
13923
- */
13924
- reason: string$2(),
13925
- count: number().int().nonnegative()
13926
- });
13927
- var FailureContributionSchema = object({
13928
- /**
13929
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13930
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13931
- * `unit` free: the families are owned by different addons and a shared enum
13932
- * is a central list that rots invisibly.
13933
- */
13934
- family: string$2(),
13935
- /**
13936
- * The NUMERIC device id — the same value every log line carries as
13937
- * `tags.deviceId`. Never nullable and never absent: a contributor that
13938
- * cannot name the camera must not emit the entry, because a fleet total
13939
- * cannot answer the only question anybody asks of this surface.
13940
- */
13941
- deviceId: number().int().positive(),
13942
- /**
13943
- * A second dimension inside the family: the model / step id for an inference
13944
- * timeout, so "which camera AND which model" is one read. Absent when the
13945
- * family has a single variant.
13946
- */
13947
- variant: string$2().optional(),
13948
- /**
13949
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13950
- * differencing two reads must drop the interval when it changes, because the
13951
- * counter restarted from zero in a respawned runner. Same discipline as
13952
- * `LoadContribution.startedAtMs`.
13953
- */
13954
- sinceMs: number(),
13955
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13956
- atMs: number(),
13957
- /**
13958
- * THE DENOMINATOR — every attempt on this path for this camera in the
13959
- * window. A failure count published without it is the mistake this schema
13960
- * exists to make impossible.
13961
- */
13962
- attempts: number().int().nonnegative(),
13963
- /** Attempts that landed. `attempts - succeeded` is the loss. */
13964
- succeeded: number().int().nonnegative(),
13965
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
13966
- reasons: array(FailureReasonCountSchema).readonly()
13967
- });
13968
- method(_void(), array(FailureContributionSchema).readonly());
13969
- var LoadContributionSchema = object({
13970
- role: _enum([
13971
- "decode",
13972
- "transcode",
13973
- "recording",
13974
- "streaming",
13975
- "detection"
13976
- ]),
13977
- /**
13978
- * The NUMERIC device id — the same value every log line carries as
13979
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
13980
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
13981
- * contributor that cannot name its camera must not emit the entry at all,
13982
- * because an unnamed per-camera entry is indistinguishable from a shared one
13983
- * and would quietly turn one camera's cost into everybody's.
13984
- */
13985
- deviceId: number().int().positive().nullable(),
13986
- attribution: _enum([
13987
- "measured",
13988
- "accounted",
13989
- "unattributable"
13990
- ]),
13991
- /**
13992
- * What ONE entry is, in the contributor's own words — `615/high`,
13993
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
13994
- * family and inventing a common one would lose the only information that
13995
- * makes two entries for the same camera distinguishable.
13996
- */
13997
- unit: string$2(),
13998
- /**
13999
- * The OS process this cost lives in, when there is one. Present so a
14000
- * consumer can (a) tell two generations of the same unit apart across a
14001
- * restart, and (b) subtract claimed processes from the node's process
14002
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
14003
- * process of its own.
14004
- */
14005
- pid: number().int().positive().optional(),
14006
- /**
14007
- * When this generation started. The pid's incarnation marker: a consumer
14008
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
14009
- * window when this changes, because the counter restarted from zero in a new
14010
- * process.
14011
- */
14012
- startedAtMs: number().optional(),
14013
- /**
14014
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
14015
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
14016
- * contribution is asked for.
14017
- *
14018
- * Cumulative and not a rate on purpose: a rate needs a window, a window
14019
- * needs a sampler, and a new per-node sampler is the defect half of
14020
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
14021
- * by whoever already keeps a history; a rate cannot be un-averaged.
14022
- *
14023
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
14024
- * an entry with no process.
14025
- */
14026
- cpuSeconds: number().optional(),
14027
- /** Resident bytes of this unit's process, same source and same rules. */
14028
- rssBytes: number().optional()
14029
- });
14030
- method(_void(), array(LoadContributionSchema).readonly());
14031
- /**
14032
14032
  * `login-method` — collection cap through which auth addons contribute
14033
14033
  * their pre-auth login surfaces to the login page. This is the SINGLE,
14034
14034
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -18766,12 +18766,53 @@ var MediaFileKindEnum = _enum([
18766
18766
  "keyFrameSmall",
18767
18767
  "thumbnailSmall"
18768
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
+ */
18769
18806
  var MediaFileSchema = object({
18770
18807
  key: string$2(),
18771
18808
  kind: MediaFileKindEnum,
18772
- base64: string$2(),
18773
18809
  sizeBytes: number(),
18774
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()
18775
18816
  });
18776
18817
  /**
18777
18818
  * One media row WITHOUT its bytes.
@@ -18783,7 +18824,9 @@ var MediaFileSchema = object({
18783
18824
  * blocks the whole view.
18784
18825
  *
18785
18826
  * `sizeBytes` is carried because it is what lets a client decide between the
18786
- * 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.
18787
18830
  */
18788
18831
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
18789
18832
  /**
@@ -19130,6 +19173,50 @@ var EventStoreFootprintSchema = object({
19130
19173
  totalBytes: number().int(),
19131
19174
  devices: array(EventStoreDeviceFootprintSchema).readonly()
19132
19175
  });
19176
+ /** Event-media footprint for one {@link MediaFileKind}. */
19177
+ var EventMediaKindFootprintSchema = object({
19178
+ kind: MediaFileKindEnum,
19179
+ /** Media rows of this kind. */
19180
+ rows: number().int(),
19181
+ /** Bytes on disk held by those rows. */
19182
+ bytes: number().int()
19183
+ });
19184
+ /**
19185
+ * The media footprint broken down by KIND — the axis a deletion decision
19186
+ * actually turns on.
19187
+ *
19188
+ * A byte total says how much there is; it cannot say what is safe to remove.
19189
+ * The deletable set (the periodic `snapshot` filmstrip, the surplus per-edge
19190
+ * motion stills) and the keep set (`firstFrame`, rolling `lastFrame`,
19191
+ * `thumbnail`/`thumbnailSmall`, `keyFrame`/`keyFrameSmall`, the face/plate
19192
+ * buffers, gallery media, the CLIP `crop`) are distinguished by `kind` and by
19193
+ * nothing else, so sizing a deletion means summing per kind.
19194
+ *
19195
+ * ## Why `unaccounted*` exists
19196
+ *
19197
+ * `kinds` is enumerated from {@link MediaFileKindEnum} — the closed set the
19198
+ * writers use — and summed one kind at a time. `totalRows` / `totalBytes` come
19199
+ * from a SEPARATE unfiltered aggregate over the same rows, never from adding
19200
+ * `kinds` up. A row whose stored `kind` is not in the enum (written by a
19201
+ * retired code path, or by a version that knew a kind this one does not) would
19202
+ * otherwise vanish from the total silently, and an operator would delete
19203
+ * against a denominator smaller than the disk.
19204
+ *
19205
+ * `unaccountedRows` / `unaccountedBytes` are the difference. They are normally
19206
+ * zero; a non-zero value is a real finding and must be shown, not rounded away.
19207
+ */
19208
+ var EventMediaKindBreakdownSchema = object({
19209
+ /** Every media row in scope, from one unfiltered aggregate. */
19210
+ totalRows: number().int(),
19211
+ /** Every media byte in scope, from that same aggregate. */
19212
+ totalBytes: number().int(),
19213
+ /** Per-kind footprint, ordered by bytes descending. */
19214
+ kinds: array(EventMediaKindFootprintSchema).readonly(),
19215
+ /** `totalRows` minus the summed `kinds` rows — see the schema note. */
19216
+ unaccountedRows: number().int(),
19217
+ /** `totalBytes` minus the summed `kinds` bytes — see the schema note. */
19218
+ unaccountedBytes: number().int()
19219
+ });
19133
19220
  /** Per-kind counts returned by the event-prune / device-delete mutations. */
19134
19221
  var EventPruneCountsSchema = object({
19135
19222
  motion: number().int(),
@@ -19333,6 +19420,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19333
19420
  }), TrackFlagsSchema, { kind: "mutation" }), method(object({}), EventStoreFootprintSchema, {
19334
19421
  kind: "query",
19335
19422
  auth: "admin"
19423
+ }), method(object({ deviceId: number().int().optional() }), EventMediaKindBreakdownSchema, {
19424
+ kind: "query",
19425
+ auth: "admin"
19336
19426
  }), method(object({
19337
19427
  olderThanMs: number(),
19338
19428
  reason: OpsLogReasonSchema.optional()
@@ -19472,6 +19562,9 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
19472
19562
  }), array(MediaFileSchema).readonly()), method(object({
19473
19563
  trackId: string$2(),
19474
19564
  deviceId: number()
19565
+ }), array(MediaFileInfoSchema).readonly()), method(object({
19566
+ eventId: string$2(),
19567
+ deviceId: number()
19475
19568
  }), array(MediaFileInfoSchema).readonly()), method(SearchObjectEventsInput, array(ScoredObjectEventSchema).readonly()), method(object({}), WipeObjectEmbeddingsResultSchema, {
19476
19569
  kind: "mutation",
19477
19570
  auth: "admin"
@@ -21281,6 +21374,20 @@ method(object({
21281
21374
  error: string$2().optional()
21282
21375
  }), { auth: "admin" }), method(_void(), array(ProviderListEntrySchema).readonly()), method(object({
21283
21376
  providerId: string$2(),
21377
+ /**
21378
+ * The location this config is an UNSAVED edit of, when there is one.
21379
+ *
21380
+ * `listLocations` replaces every declared secret with the redaction
21381
+ * sentinel, so the edit modal's form state holds the sentinel for any
21382
+ * credential the operator did not retype — and posting that here
21383
+ * without a way to resolve it makes the provider try to authenticate
21384
+ * as `__camstack_redacted__` and report the operator's own working
21385
+ * password as wrong. Given this id, the orchestrator restores each
21386
+ * sentinel from the stored config (same rule as `upsertLocation`)
21387
+ * before dispatching. Omitted by the "Add location" wizard, where
21388
+ * every value was typed just now and nothing is stored yet.
21389
+ */
21390
+ locationId: string$2().optional(),
21284
21391
  config: record(string$2(), unknown())
21285
21392
  }), object({
21286
21393
  ok: boolean(),
@@ -24479,10 +24586,24 @@ var FaceClusterSchema = object({
24479
24586
  size: number().int(),
24480
24587
  cohesion: number()
24481
24588
  });
24589
+ /**
24590
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
24591
+ * are — never the bytes.
24592
+ *
24593
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
24594
+ * track/event contract) is still populated because a deployed viewer requires
24595
+ * the field to parse a row at all; this method has no such reader. Its ONE
24596
+ * caller is the admin UI's detail modal, which was building
24597
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
24598
+ * dialog already rendering its key FRAME from the `event-media` plane.
24599
+ *
24600
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
24601
+ * media key directly, so this needed no new plane and no new access decision.
24602
+ */
24482
24603
  var MediaFileLiteSchema$1 = object({
24483
24604
  key: string$2(),
24484
24605
  kind: string$2(),
24485
- base64: string$2(),
24606
+ url: string$2(),
24486
24607
  sizeBytes: number(),
24487
24608
  timestamp: number()
24488
24609
  });
@@ -27504,10 +27625,24 @@ var PlateInfoSchema = object({
27504
27625
  */
27505
27626
  cropUrl: string$2().optional()
27506
27627
  });
27628
+ /**
27629
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
27630
+ * are — never the bytes.
27631
+ *
27632
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
27633
+ * track/event contract) is still populated because a deployed viewer requires
27634
+ * the field to parse a row at all; this method has no such reader. Its ONE
27635
+ * caller is the admin UI's detail modal, which was building
27636
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
27637
+ * dialog already rendering its key FRAME from the `event-media` plane.
27638
+ *
27639
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
27640
+ * media key directly, so this needed no new plane and no new access decision.
27641
+ */
27507
27642
  var MediaFileLiteSchema = object({
27508
27643
  key: string$2(),
27509
27644
  kind: string$2(),
27510
- base64: string$2(),
27645
+ url: string$2(),
27511
27646
  sizeBytes: number(),
27512
27647
  timestamp: number()
27513
27648
  });
@@ -35308,6 +35443,12 @@ Object.freeze({
35308
35443
  addonId: null,
35309
35444
  access: "view"
35310
35445
  },
35446
+ "pipelineAnalytics.getEventMediaFootprintByKind": {
35447
+ capName: "pipeline-analytics",
35448
+ capScope: "device",
35449
+ addonId: null,
35450
+ access: "view"
35451
+ },
35311
35452
  "pipelineAnalytics.getEventStoreFootprint": {
35312
35453
  capName: "pipeline-analytics",
35313
35454
  capScope: "device",
@@ -35404,6 +35545,12 @@ Object.freeze({
35404
35545
  addonId: null,
35405
35546
  access: "view"
35406
35547
  },
35548
+ "pipelineAnalytics.listEventMedia": {
35549
+ capName: "pipeline-analytics",
35550
+ capScope: "device",
35551
+ addonId: null,
35552
+ access: "view"
35553
+ },
35407
35554
  "pipelineAnalytics.listGroups": {
35408
35555
  capName: "pipeline-analytics",
35409
35556
  capScope: "device",
@@ -38967,6 +39114,11 @@ Object.freeze({
38967
39114
  form: "single",
38968
39115
  optional: false
38969
39116
  }],
39117
+ "pipelineAnalytics.getEventMediaFootprintByKind": [{
39118
+ name: "deviceId",
39119
+ form: "single",
39120
+ optional: true
39121
+ }],
38970
39122
  "pipelineAnalytics.getGroup": [{
38971
39123
  name: "deviceId",
38972
39124
  form: "single",
@@ -39027,6 +39179,11 @@ Object.freeze({
39027
39179
  form: "array",
39028
39180
  optional: false
39029
39181
  }],
39182
+ "pipelineAnalytics.listEventMedia": [{
39183
+ name: "deviceId",
39184
+ form: "single",
39185
+ optional: false
39186
+ }],
39030
39187
  "pipelineAnalytics.listGroups": [{
39031
39188
  name: "deviceIds",
39032
39189
  form: "array",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-matter-broker",
3
- "version": "0.2.45",
3
+ "version": "0.2.47",
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",