@camstack/system 1.2.159 → 1.2.161

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 (71) hide show
  1. package/dist/addon-runner.js +1 -1
  2. package/dist/addon-runner.mjs +1 -1
  3. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.js +1 -1
  4. package/dist/builtins/addon-pages-aggregator/addon-pages-aggregator.addon.mjs +1 -1
  5. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.js +1 -1
  6. package/dist/builtins/addon-widgets-aggregator/addon-widgets-aggregator.addon.mjs +1 -1
  7. package/dist/builtins/alerts/alerts.addon.js +1 -1
  8. package/dist/builtins/alerts/alerts.addon.mjs +1 -1
  9. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.d.ts +10 -7
  10. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.js +50 -12
  11. package/dist/builtins/backup-orchestrator/backup-orchestrator.addon.mjs +50 -12
  12. package/dist/builtins/backup-orchestrator/write-targets.d.ts +63 -0
  13. package/dist/builtins/console-logging/index.js +1 -1
  14. package/dist/builtins/console-logging/index.mjs +1 -1
  15. package/dist/builtins/core-blocks/core-blocks.addon.js +1 -1
  16. package/dist/builtins/core-blocks/core-blocks.addon.mjs +1 -1
  17. package/dist/builtins/device-manager/device-bindings-store.d.ts +56 -10
  18. package/dist/builtins/device-manager/device-manager.addon.d.ts +11 -0
  19. package/dist/builtins/device-manager/device-manager.addon.js +216 -81
  20. package/dist/builtins/device-manager/device-manager.addon.mjs +216 -81
  21. package/dist/builtins/device-manager/device-meta-actions.d.ts +9 -3
  22. package/dist/builtins/device-manager/device-meta-store.d.ts +32 -5
  23. package/dist/builtins/device-manager/device-queries.d.ts +7 -3
  24. package/dist/builtins/device-manager/write-lock.d.ts +17 -0
  25. package/dist/builtins/doorbell/virtual-doorbell.addon.js +1 -1
  26. package/dist/builtins/doorbell/virtual-doorbell.addon.mjs +1 -1
  27. package/dist/builtins/hub-forwarder/index.js +1 -1
  28. package/dist/builtins/hub-forwarder/index.mjs +1 -1
  29. package/dist/builtins/liveness-monitor/liveness-monitor.addon.js +1 -1
  30. package/dist/builtins/liveness-monitor/liveness-monitor.addon.mjs +1 -1
  31. package/dist/builtins/local-auth/local-auth.addon.js +1 -1
  32. package/dist/builtins/local-auth/local-auth.addon.mjs +1 -1
  33. package/dist/builtins/local-network/local-network.addon.js +1 -1
  34. package/dist/builtins/local-network/local-network.addon.mjs +1 -1
  35. package/dist/builtins/loki-logging/index.js +1 -1
  36. package/dist/builtins/loki-logging/index.mjs +1 -1
  37. package/dist/builtins/native-metrics/native-metrics.addon.js +1 -1
  38. package/dist/builtins/native-metrics/native-metrics.addon.mjs +1 -1
  39. package/dist/builtins/platform-probe/index.js +1 -1
  40. package/dist/builtins/platform-probe/index.mjs +1 -1
  41. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.js +1 -1
  42. package/dist/builtins/remote-access-orchestrator/remote-access-orchestrator.addon.mjs +1 -1
  43. package/dist/builtins/snapshot/index.js +1 -1
  44. package/dist/builtins/snapshot/index.mjs +1 -1
  45. package/dist/builtins/sqlite-storage/filesystem-storage.addon.js +1 -1
  46. package/dist/builtins/sqlite-storage/filesystem-storage.addon.mjs +1 -1
  47. package/dist/builtins/sqlite-storage/filter-compiler.d.ts +41 -2
  48. package/dist/builtins/sqlite-storage/sqlite-settings-backend.d.ts +15 -7
  49. package/dist/builtins/sqlite-storage/sqlite-settings.addon.js +0 -0
  50. package/dist/builtins/sqlite-storage/sqlite-settings.addon.mjs +0 -0
  51. package/dist/builtins/storage-orchestrator/storage-migration-coordinator.d.ts +3 -2
  52. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.js +63 -8
  53. package/dist/builtins/storage-orchestrator/storage-orchestrator.addon.mjs +63 -8
  54. package/dist/builtins/storage-orchestrator/storage-orchestrator.service.d.ts +19 -0
  55. package/dist/builtins/system-config/system-config.addon.js +1 -1
  56. package/dist/builtins/system-config/system-config.addon.mjs +1 -1
  57. package/dist/builtins/winston-logging/index.js +1 -1
  58. package/dist/builtins/winston-logging/index.mjs +1 -1
  59. package/dist/{dist-DLh4_rn3.mjs → dist-D4xNBlJM.mjs} +383 -214
  60. package/dist/{dist-Ck2jkBZk.js → dist-Keu5TDO7.js} +383 -214
  61. package/dist/index.js +29 -7
  62. package/dist/index.mjs +29 -8
  63. package/dist/kernel/index.d.ts +2 -2
  64. package/dist/kernel/lifecycle/lifecycle-job-engine.d.ts +13 -0
  65. package/dist/kernel/moleculer/cap-usage-registry.d.ts +132 -7
  66. package/dist/kernel/transport/local-child-registry.d.ts +57 -0
  67. package/dist/{manifest-system-deps-tZZYG3RR.mjs → manifest-system-deps-CiCuev2R.mjs} +271 -77
  68. package/dist/{manifest-system-deps-8boi90D9.js → manifest-system-deps-DYv4ZPo2.js} +276 -76
  69. package/dist/{retired-settings-keys-Dp_CyuCW.js → retired-settings-keys-BBohF-eC.js} +1 -1
  70. package/dist/{retired-settings-keys-Bi0ZKBjb.mjs → retired-settings-keys-COQMNlOJ.mjs} +1 -1
  71. package/package.json +1 -1
@@ -4177,6 +4177,21 @@ var RelocateJobSchema = zod.z.object({
4177
4177
  bytesMoved: zod.z.number().int(),
4178
4178
  /** Total files discovered up front; null while (or when) unknown. */
4179
4179
  filesTotal: zod.z.number().int().nullable(),
4180
+ /**
4181
+ * Rows this run CORRECTED while moving them — a durable mutation the move
4182
+ * made that nobody asked for, so it is reported where the operator reads the
4183
+ * job rather than only in a log line.
4184
+ *
4185
+ * A footage segment records its byte count in its own NAME, and the durable
4186
+ * hour row derives its aggregates from those names. A file that does not
4187
+ * match its name therefore makes the ledger's sums — and with them quota and
4188
+ * pressure eviction — wrong by the difference, and only a rename can fix it.
4189
+ * On 2026-08-30 one such row also stalled a 110 749-file drain permanently.
4190
+ *
4191
+ * Absent on lanes where the question has no meaning: a media blob's size is
4192
+ * in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
4193
+ */
4194
+ rowsReconciled: zod.z.number().int().nonnegative().optional(),
4180
4195
  startedAt: zod.z.number(),
4181
4196
  finishedAt: zod.z.number().nullable(),
4182
4197
  error: zod.z.string().nullable()
@@ -4245,14 +4260,42 @@ var RelocateMediaInputSchema = zod.z.object({
4245
4260
  /** Omitted = `move`, the pre-existing behaviour. */
4246
4261
  mode: MediaRelocateModeSchema.optional()
4247
4262
  });
4248
- /** How many rows still carry NO `locationId` — the population a repoint would
4249
- * silently re-aim at a disk that does not hold their bytes. Zero is the only
4250
- * value that permits a non-blocking `eventMedia` cutover. */
4251
- var UnstampedEventMediaCountSchema = zod.z.object({
4252
- media: zod.z.number().int().nonnegative(),
4253
- retrainFrames: zod.z.number().int().nonnegative(),
4254
- total: zod.z.number().int().nonnegative()
4263
+ /**
4264
+ * The unstamped population of ONE collection split, because the gate and the
4265
+ * operator ask two different questions and only one of them has to be cheap.
4266
+ *
4267
+ * `present` is the GATE: "is there at least one row that would be orphaned by a
4268
+ * repoint". It is a single indexed seek to the first matching row, so it stays
4269
+ * answerable on a saturated disk and answers in O(log n) precisely in the state
4270
+ * that matters — after a seal, when the population is empty.
4271
+ *
4272
+ * `rows` is the NUMBER, for the refusal message and the operator's sense of
4273
+ * scale. It is a second, indexed `COUNT(*)`, and `null` means **not
4274
+ * measurable** — never zero. `{ present: true, rows: null }` is a legitimate
4275
+ * and useful answer: "there are some, and this read could not say how many"
4276
+ * still refuses the cutover, which is the whole job.
4277
+ */
4278
+ var UnstampedRowsSchema = zod.z.object({
4279
+ present: zod.z.boolean(),
4280
+ rows: zod.z.number().int().nonnegative().nullable()
4255
4281
  });
4282
+ /**
4283
+ * How many rows still carry NO `locationId` — the population a repoint would
4284
+ * silently re-aim at a disk that does not hold their bytes.
4285
+ *
4286
+ * **`null` = the count could not be taken**, and it is NOT permission to cut
4287
+ * over. The gate opens on a measured absence and on nothing else; an unread
4288
+ * collection and an empty one are different facts, and this repo has already
4289
+ * paid for conflating them (`RelocateResidueSchema`, D295).
4290
+ */
4291
+ var UnstampedEventMediaCountSchema = zod.z.object({
4292
+ media: UnstampedRowsSchema,
4293
+ retrainFrames: UnstampedRowsSchema,
4294
+ /** True when EITHER collection holds one. The refusal reads this. */
4295
+ anyPresent: zod.z.boolean(),
4296
+ /** Sum across both, or `null` when either lane could not be counted. */
4297
+ total: zod.z.number().int().nonnegative().nullable()
4298
+ }).nullable();
4256
4299
  var StorageMigrationMediaMoveInputSchema = RelocateMediaInputSchema.extend({ leaseId: zod.z.string().min(1) });
4257
4300
  /** The independently selectable logical storage classes — every class
4258
4301
  * `storage.listLocationDeclarations` reports, so an operator never meets a
@@ -4363,6 +4406,10 @@ var StorageMigrationMoveProgressSchema = zod.z.object({
4363
4406
  /** The archive census — the **M** of "N of M" (D295). `null` = unknowable. */
4364
4407
  filesTotal: zod.z.number().int().nonnegative().nullable(),
4365
4408
  bytesMoved: zod.z.number().int().nonnegative(),
4409
+ /** Rows the mover corrected while moving them — see `RelocateJob`. Absent on
4410
+ * a lane that cannot reconcile. A migration that silently rewrote durable
4411
+ * rows would be the same failure as one that silently skipped them. */
4412
+ rowsReconciled: zod.z.number().int().nonnegative().optional(),
4366
4413
  /** The MOVER's start, not the migration's: a drain restarted after an addon
4367
4414
  * crash gets a new mover, and a rate computed from the migration's start
4368
4415
  * would silently average in the time nothing was running. */
@@ -10811,6 +10858,15 @@ var deviceManagerCapability = {
10811
10858
  * calls are sync. Bindings change rarely (only on wrapper toggle or
10812
10859
  * device add/remove) — clients invalidate via the
10813
10860
  * `capability.binding-changed` event.
10861
+ *
10862
+ * "A single round-trip" describes the CLIENT's side and used not to
10863
+ * describe the server's: until 2026-08-30 the resolver read the persisted
10864
+ * wrapper activations once per device, so answering this cost one
10865
+ * settings-door RPC per device — 1 020 on the live 1 019-device hub, and
10866
+ * it did not return in 240 s against `SystemMirror.init`'s 15 s budget.
10867
+ * The server side is now two reads for the whole fleet. Anything PERIODIC
10868
+ * still belongs on `getBindings` / `getBindingsBatch` (D12); this remains
10869
+ * a warm seed.
10814
10870
  */
10815
10871
  getAllBindings: method(zod.z.object({}), zod.z.array(DeviceBindingsForDeviceSchema)),
10816
10872
  /**
@@ -11239,6 +11295,133 @@ var embeddingEncoderCapability = {
11239
11295
  }
11240
11296
  };
11241
11297
  /**
11298
+ * `failure-contribution` — the capability an addon reports its OWN losses
11299
+ * through, per camera, with the denominator attached. It stores nothing.
11300
+ *
11301
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
11302
+ *
11303
+ * `load-contribution` answers *what did this camera COST*. This answers *what
11304
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
11305
+ * copied: the contributor reports what it already knows, hub-main adds only
11306
+ * `addonId`, nothing needs global knowledge, and there is no central list for
11307
+ * somebody to forget to edit.
11308
+ *
11309
+ * They are not merged, because their invariants are opposites:
11310
+ *
11311
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
11312
+ * claim a camera cost nothing, which is a measurement nobody made;
11313
+ * - a `failure-contribution` zero is the **most valuable value on the
11314
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
11315
+ * and it is exactly what an absent entry cannot say.
11316
+ *
11317
+ * Putting a loss counter on a cost entry would also break the reconciliation
11318
+ * that gives `load-contribution` its point: contributions are subtracted from
11319
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
11320
+ * has no process.
11321
+ *
11322
+ * ## Why not a log line, since the counters already exist
11323
+ *
11324
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
11325
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
11326
+ * ends in a log line, and a log line is the thing the operator asked to stop
11327
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
11328
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
11329
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
11330
+ * media blackout were both diagnosed. The counters stay; this is where they can
11331
+ * be READ.
11332
+ *
11333
+ * ## The rate is served with its denominator or not at all
11334
+ *
11335
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
11336
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
11337
+ * than yesterday" and was **flat across twelve hours** once divided by the
11338
+ * successes on the same path. A surface that publishes only the numerator
11339
+ * reproduces that mistake on every read.
11340
+ *
11341
+ * ## Shape
11342
+ *
11343
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
11344
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
11345
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
11346
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
11347
+ * a forked runner's entries reach hub-main over transport that already exists.
11348
+ * No new UDS message, no second registry (D3). The operator reads the assembled
11349
+ * result through `system.getFailureContributions`.
11350
+ */
11351
+ var FailureReasonCountSchema = zod.z.object({
11352
+ /**
11353
+ * Why the attempt did not land, in the contributor's own vocabulary —
11354
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
11355
+ * strings that already appear in this repo's logs and, where one exists, the
11356
+ * same string the per-track `previewMissReason` records (D276): a second
11357
+ * vocabulary for the same loss would make the row and the counter
11358
+ * un-joinable.
11359
+ */
11360
+ reason: zod.z.string(),
11361
+ count: zod.z.number().int().nonnegative()
11362
+ });
11363
+ var FailureContributionSchema = zod.z.object({
11364
+ /**
11365
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
11366
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
11367
+ * `unit` free: the families are owned by different addons and a shared enum
11368
+ * is a central list that rots invisibly.
11369
+ */
11370
+ family: zod.z.string(),
11371
+ /**
11372
+ * The NUMERIC device id — the same value every log line carries as
11373
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
11374
+ * cannot name the camera must not emit the entry, because a fleet total
11375
+ * cannot answer the only question anybody asks of this surface.
11376
+ */
11377
+ deviceId: zod.z.number().int().positive(),
11378
+ /**
11379
+ * A second dimension inside the family: the model / step id for an inference
11380
+ * timeout, so "which camera AND which model" is one read. Absent when the
11381
+ * family has a single variant.
11382
+ */
11383
+ variant: zod.z.string().optional(),
11384
+ /**
11385
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
11386
+ * differencing two reads must drop the interval when it changes, because the
11387
+ * counter restarted from zero in a respawned runner. Same discipline as
11388
+ * `LoadContribution.startedAtMs`.
11389
+ */
11390
+ sinceMs: zod.z.number(),
11391
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
11392
+ atMs: zod.z.number(),
11393
+ /**
11394
+ * THE DENOMINATOR — every attempt on this path for this camera in the
11395
+ * window. A failure count published without it is the mistake this schema
11396
+ * exists to make impossible.
11397
+ */
11398
+ attempts: zod.z.number().int().nonnegative(),
11399
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
11400
+ succeeded: zod.z.number().int().nonnegative(),
11401
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
11402
+ reasons: zod.z.array(FailureReasonCountSchema).readonly()
11403
+ });
11404
+ var failureContributionCapability = {
11405
+ name: "failure-contribution",
11406
+ scope: "system",
11407
+ mode: "collection",
11408
+ internal: true,
11409
+ methods: {
11410
+ /**
11411
+ * This addon's per-camera failure counters, read live from bounded in-RAM
11412
+ * state it already keeps. Inert: no persistence, no sampling, no timer.
11413
+ *
11414
+ * READING NEVER RESETS. The counters are CUMULATIVE since `sinceMs`, and a
11415
+ * consumer that wants a rate differences two reads. A draining read would
11416
+ * make two operators with the page open each destroy half of the other's
11417
+ * numbers, and `load-contribution` already settled the same question the
11418
+ * same way for `cpuSeconds`.
11419
+ */
11420
+ list: method(zod.z.void(), zod.z.array(FailureContributionSchema).readonly()) },
11421
+ /** In-process only — enumerated through `addons.listCapabilityProviders`. */
11422
+ mount: { kind: "skip" }
11423
+ };
11424
+ /**
11242
11425
  * filesystem-browse — per-node capability for browsing the node's local
11243
11426
  * filesystem. Reads are unconfined (whole filesystem, from `/` down); WRITES
11244
11427
  * are sandboxed to operator-configured allowed roots (D115). Used by the
@@ -11851,6 +12034,82 @@ var llmCapability = {
11851
12034
  })
11852
12035
  }
11853
12036
  };
12037
+ var LoadContributionSchema = zod.z.object({
12038
+ role: zod.z.enum([
12039
+ "decode",
12040
+ "transcode",
12041
+ "recording",
12042
+ "streaming",
12043
+ "detection"
12044
+ ]),
12045
+ /**
12046
+ * The NUMERIC device id — the same value every log line carries as
12047
+ * `tags.deviceId`. `null` means this cost genuinely belongs to no single
12048
+ * camera (a shared pool), NOT that the contributor forgot to look it up: a
12049
+ * contributor that cannot name its camera must not emit the entry at all,
12050
+ * because an unnamed per-camera entry is indistinguishable from a shared one
12051
+ * and would quietly turn one camera's cost into everybody's.
12052
+ */
12053
+ deviceId: zod.z.number().int().positive().nullable(),
12054
+ attribution: zod.z.enum([
12055
+ "measured",
12056
+ "accounted",
12057
+ "unattributable"
12058
+ ]),
12059
+ /**
12060
+ * What ONE entry is, in the contributor's own words — `615/high`,
12061
+ * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
12062
+ * family and inventing a common one would lose the only information that
12063
+ * makes two entries for the same camera distinguishable.
12064
+ */
12065
+ unit: zod.z.string(),
12066
+ /**
12067
+ * The OS process this cost lives in, when there is one. Present so a
12068
+ * consumer can (a) tell two generations of the same unit apart across a
12069
+ * restart, and (b) subtract claimed processes from the node's process
12070
+ * snapshot to see what NOBODY claimed. Absent for an entry that owns no
12071
+ * process of its own.
12072
+ */
12073
+ pid: zod.z.number().int().positive().optional(),
12074
+ /**
12075
+ * When this generation started. The pid's incarnation marker: a consumer
12076
+ * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
12077
+ * window when this changes, because the counter restarted from zero in a new
12078
+ * process.
12079
+ */
12080
+ startedAtMs: zod.z.number().optional(),
12081
+ /**
12082
+ * CUMULATIVE CPU seconds this unit has consumed since it started — user +
12083
+ * system, read from the child's own `/proc/<pid>/stat` at the moment the
12084
+ * contribution is asked for.
12085
+ *
12086
+ * Cumulative and not a rate on purpose: a rate needs a window, a window
12087
+ * needs a sampler, and a new per-node sampler is the defect half of
12088
+ * `docs/architecture/load-ledger.md` documents. A counter can be differenced
12089
+ * by whoever already keeps a history; a rate cannot be un-averaged.
12090
+ *
12091
+ * Absent — never zero — on a node with no `/proc`, on a read failure, and on
12092
+ * an entry with no process.
12093
+ */
12094
+ cpuSeconds: zod.z.number().optional(),
12095
+ /** Resident bytes of this unit's process, same source and same rules. */
12096
+ rssBytes: zod.z.number().optional()
12097
+ });
12098
+ var loadContributionCapability = {
12099
+ name: "load-contribution",
12100
+ scope: "system",
12101
+ mode: "collection",
12102
+ internal: true,
12103
+ methods: {
12104
+ /**
12105
+ * This addon's own cost entries, computed live from state it already
12106
+ * holds. Inert: no persistence, no sampling, no timer. It is answered on
12107
+ * whatever beat the caller already has.
12108
+ */
12109
+ list: method(zod.z.void(), zod.z.array(LoadContributionSchema).readonly()) },
12110
+ /** In-process only — enumerated through `addons.listCapabilityProviders`. */
12111
+ mount: { kind: "skip" }
12112
+ };
11854
12113
  /**
11855
12114
  * `log-channels` — the capability an addon DECLARES its diagnostic channels
11856
12115
  * through. It stores nothing.
@@ -11959,209 +12218,6 @@ var logDestinationCapability = {
11959
12218
  mount: { kind: "skip" }
11960
12219
  };
11961
12220
  /**
11962
- * `failure-contribution` — the capability an addon reports its OWN losses
11963
- * through, per camera, with the denominator attached. It stores nothing.
11964
- *
11965
- * ## The twin of `load-contribution`, and why it is a twin and not a field
11966
- *
11967
- * `load-contribution` answers *what did this camera COST*. This answers *what
11968
- * did this camera LOSE*. The reporting discipline is identical and deliberately
11969
- * copied: the contributor reports what it already knows, hub-main adds only
11970
- * `addonId`, nothing needs global knowledge, and there is no central list for
11971
- * somebody to forget to edit.
11972
- *
11973
- * They are not merged, because their invariants are opposites:
11974
- *
11975
- * - a `load-contribution` measurement is **absent, never zero** — a zero would
11976
- * claim a camera cost nothing, which is a measurement nobody made;
11977
- * - a `failure-contribution` zero is the **most valuable value on the
11978
- * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
11979
- * and it is exactly what an absent entry cannot say.
11980
- *
11981
- * Putting a loss counter on a cost entry would also break the reconciliation
11982
- * that gives `load-contribution` its point: contributions are subtracted from
11983
- * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
11984
- * has no process.
11985
- *
11986
- * ## Why not a log line, since the counters already exist
11987
- *
11988
- * Several of these paths already counted themselves — `CaptureScheduler`'s
11989
- * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
11990
- * ends in a log line, and a log line is the thing the operator asked to stop
11991
- * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
11992
- * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
11993
- * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
11994
- * media blackout were both diagnosed. The counters stay; this is where they can
11995
- * be READ.
11996
- *
11997
- * ## The rate is served with its denominator or not at all
11998
- *
11999
- * Every entry carries `attempts` and `succeeded`. A miss count alone is
12000
- * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
12001
- * than yesterday" and was **flat across twelve hours** once divided by the
12002
- * successes on the same path. A surface that publishes only the numerator
12003
- * reproduces that mistake on every read.
12004
- *
12005
- * ## Shape
12006
- *
12007
- * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
12008
- * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
12009
- * generated hooks, while `addons.listCapabilityProviders` still enumerates it
12010
- * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
12011
- * a forked runner's entries reach hub-main over transport that already exists.
12012
- * No new UDS message, no second registry (D3). The operator reads the assembled
12013
- * result through `system.getFailureContributions`.
12014
- */
12015
- var FailureReasonCountSchema = zod.z.object({
12016
- /**
12017
- * Why the attempt did not land, in the contributor's own vocabulary —
12018
- * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
12019
- * strings that already appear in this repo's logs and, where one exists, the
12020
- * same string the per-track `previewMissReason` records (D276): a second
12021
- * vocabulary for the same loss would make the row and the counter
12022
- * un-joinable.
12023
- */
12024
- reason: zod.z.string(),
12025
- count: zod.z.number().int().nonnegative()
12026
- });
12027
- var FailureContributionSchema = zod.z.object({
12028
- /**
12029
- * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
12030
- * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
12031
- * `unit` free: the families are owned by different addons and a shared enum
12032
- * is a central list that rots invisibly.
12033
- */
12034
- family: zod.z.string(),
12035
- /**
12036
- * The NUMERIC device id — the same value every log line carries as
12037
- * `tags.deviceId`. Never nullable and never absent: a contributor that
12038
- * cannot name the camera must not emit the entry, because a fleet total
12039
- * cannot answer the only question anybody asks of this surface.
12040
- */
12041
- deviceId: zod.z.number().int().positive(),
12042
- /**
12043
- * A second dimension inside the family: the model / step id for an inference
12044
- * timeout, so "which camera AND which model" is one read. Absent when the
12045
- * family has a single variant.
12046
- */
12047
- variant: zod.z.string().optional(),
12048
- /**
12049
- * Epoch ms this counter started — the INCARNATION MARKER. A consumer
12050
- * differencing two reads must drop the interval when it changes, because the
12051
- * counter restarted from zero in a respawned runner. Same discipline as
12052
- * `LoadContribution.startedAtMs`.
12053
- */
12054
- sinceMs: zod.z.number(),
12055
- /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
12056
- atMs: zod.z.number(),
12057
- /**
12058
- * THE DENOMINATOR — every attempt on this path for this camera in the
12059
- * window. A failure count published without it is the mistake this schema
12060
- * exists to make impossible.
12061
- */
12062
- attempts: zod.z.number().int().nonnegative(),
12063
- /** Attempts that landed. `attempts - succeeded` is the loss. */
12064
- succeeded: zod.z.number().int().nonnegative(),
12065
- /** The loss, partitioned. Sums to `attempts - succeeded`. */
12066
- reasons: zod.z.array(FailureReasonCountSchema).readonly()
12067
- });
12068
- var failureContributionCapability = {
12069
- name: "failure-contribution",
12070
- scope: "system",
12071
- mode: "collection",
12072
- internal: true,
12073
- methods: {
12074
- /**
12075
- * This addon's per-camera failure counters, read live from bounded in-RAM
12076
- * state it already keeps. Inert: no persistence, no sampling, no timer.
12077
- *
12078
- * READING NEVER RESETS. The counters are CUMULATIVE since `sinceMs`, and a
12079
- * consumer that wants a rate differences two reads. A draining read would
12080
- * make two operators with the page open each destroy half of the other's
12081
- * numbers, and `load-contribution` already settled the same question the
12082
- * same way for `cpuSeconds`.
12083
- */
12084
- list: method(zod.z.void(), zod.z.array(FailureContributionSchema).readonly()) },
12085
- /** In-process only — enumerated through `addons.listCapabilityProviders`. */
12086
- mount: { kind: "skip" }
12087
- };
12088
- var LoadContributionSchema = zod.z.object({
12089
- role: zod.z.enum([
12090
- "decode",
12091
- "transcode",
12092
- "recording",
12093
- "streaming",
12094
- "detection"
12095
- ]),
12096
- /**
12097
- * The NUMERIC device id — the same value every log line carries as
12098
- * `tags.deviceId`. `null` means this cost genuinely belongs to no single
12099
- * camera (a shared pool), NOT that the contributor forgot to look it up: a
12100
- * contributor that cannot name its camera must not emit the entry at all,
12101
- * because an unnamed per-camera entry is indistinguishable from a shared one
12102
- * and would quietly turn one camera's cost into everybody's.
12103
- */
12104
- deviceId: zod.z.number().int().positive().nullable(),
12105
- attribution: zod.z.enum([
12106
- "measured",
12107
- "accounted",
12108
- "unattributable"
12109
- ]),
12110
- /**
12111
- * What ONE entry is, in the contributor's own words — `615/high`,
12112
- * `617/native`, `cuda:0 shared pool`. Free text because the unit differs per
12113
- * family and inventing a common one would lose the only information that
12114
- * makes two entries for the same camera distinguishable.
12115
- */
12116
- unit: zod.z.string(),
12117
- /**
12118
- * The OS process this cost lives in, when there is one. Present so a
12119
- * consumer can (a) tell two generations of the same unit apart across a
12120
- * restart, and (b) subtract claimed processes from the node's process
12121
- * snapshot to see what NOBODY claimed. Absent for an entry that owns no
12122
- * process of its own.
12123
- */
12124
- pid: zod.z.number().int().positive().optional(),
12125
- /**
12126
- * When this generation started. The pid's incarnation marker: a consumer
12127
- * differencing {@link LoadContributionSchema.shape.cpuSeconds} must drop the
12128
- * window when this changes, because the counter restarted from zero in a new
12129
- * process.
12130
- */
12131
- startedAtMs: zod.z.number().optional(),
12132
- /**
12133
- * CUMULATIVE CPU seconds this unit has consumed since it started — user +
12134
- * system, read from the child's own `/proc/<pid>/stat` at the moment the
12135
- * contribution is asked for.
12136
- *
12137
- * Cumulative and not a rate on purpose: a rate needs a window, a window
12138
- * needs a sampler, and a new per-node sampler is the defect half of
12139
- * `docs/architecture/load-ledger.md` documents. A counter can be differenced
12140
- * by whoever already keeps a history; a rate cannot be un-averaged.
12141
- *
12142
- * Absent — never zero — on a node with no `/proc`, on a read failure, and on
12143
- * an entry with no process.
12144
- */
12145
- cpuSeconds: zod.z.number().optional(),
12146
- /** Resident bytes of this unit's process, same source and same rules. */
12147
- rssBytes: zod.z.number().optional()
12148
- });
12149
- var loadContributionCapability = {
12150
- name: "load-contribution",
12151
- scope: "system",
12152
- mode: "collection",
12153
- internal: true,
12154
- methods: {
12155
- /**
12156
- * This addon's own cost entries, computed live from state it already
12157
- * holds. Inert: no persistence, no sampling, no timer. It is answered on
12158
- * whatever beat the caller already has.
12159
- */
12160
- list: method(zod.z.void(), zod.z.array(LoadContributionSchema).readonly()) },
12161
- /** In-process only — enumerated through `addons.listCapabilityProviders`. */
12162
- mount: { kind: "skip" }
12163
- };
12164
- /**
12165
12221
  * `login-method` — collection cap through which auth addons contribute
12166
12222
  * their pre-auth login surfaces to the login page. This is the SINGLE,
12167
12223
  * generic mechanism that supersedes the dead `auth.listProviders` reader:
@@ -17413,12 +17469,53 @@ var MediaFileKindEnum = zod.z.enum([
17413
17469
  "keyFrameSmall",
17414
17470
  "thumbnailSmall"
17415
17471
  ]);
17472
+ /**
17473
+ * One media row ON THE WIRE: what it is, how big it is, and WHERE ITS BYTES
17474
+ * ARE — never the bytes themselves.
17475
+ *
17476
+ * ## Why `url` and not `base64`
17477
+ *
17478
+ * Measured on the live hub 2026-08-30: `getTrackMedia {trackId, deviceId}`
17479
+ * with no `kinds` returned 6 rows / **3 597 219 B**, of which `keyFrame` alone
17480
+ * was **2 824 077 B** — one full-resolution frame, base64, so +33 % on the
17481
+ * wire. Forty events is ~144 MB. Every byte of it was read off disk,
17482
+ * base64-encoded, held whole in a unary tRPC envelope, and materialised in
17483
+ * hub-main's heap on the way past — for an `<img>` that would have cached it.
17484
+ *
17485
+ * `url` points at the `event-media` data plane
17486
+ * (`/addon/<addonId>/event-media/<storedKey>`), which serves the same blob
17487
+ * with an ETag and `Cache-Control: immutable`, honours conditional GETs, can
17488
+ * render a `?variant=thumb`, and streams. The hub gate in front of it requires
17489
+ * a bearer or the session cookie (`access: 'authenticated'`), so the bytes are
17490
+ * no less protected than they were inside a `view`-level cap response — see
17491
+ * `data-plane-access.ts` for the rule and the one gap it does not close
17492
+ * (per-device scoping).
17493
+ *
17494
+ * The URL is built from the row's **stored** key, which is not always its
17495
+ * published `kind`: a track's face/plate crop is stored as `crop` under
17496
+ * `('face'|'plate', '<prefix>-<trackId>')` and published as
17497
+ * `faceCrop`/`plateCrop`. `MediaStore.getByKey` knows only the stored key.
17498
+ *
17499
+ * ## `base64` is TRANSITIONAL and is going away
17500
+ *
17501
+ * It is still populated for one reason: the deployed viewer's track-detail
17502
+ * HERO tile reads it (`use-track-media-entry.ts` → `parseMediaFiles`, which
17503
+ * REQUIRES the field), and a row without it parses as a FAILED read — the red
17504
+ * triangle — not as absence. Removing the field before that viewer ships is an
17505
+ * outage, not a cleanup. Once the viewer takes its hero bytes from `url`,
17506
+ * delete this line and the `withBytes` pass-through in
17507
+ * `analytics-query-facade.ts`; nothing else reads it.
17508
+ */
17416
17509
  var MediaFileSchema = zod.z.object({
17417
17510
  key: zod.z.string(),
17418
17511
  kind: MediaFileKindEnum,
17419
- base64: zod.z.string(),
17420
17512
  sizeBytes: zod.z.number(),
17421
17513
  timestamp: zod.z.number()
17514
+ }).extend({
17515
+ /** `/addon/<addonId>/event-media/<encoded stored key>`. Always present. */
17516
+ url: zod.z.string(),
17517
+ /** @deprecated Transitional — see the schema docblock. Use {@link url}. */
17518
+ base64: zod.z.string()
17422
17519
  });
17423
17520
  /**
17424
17521
  * One media row WITHOUT its bytes.
@@ -17430,7 +17527,9 @@ var MediaFileSchema = zod.z.object({
17430
17527
  * blocks the whole view.
17431
17528
  *
17432
17529
  * `sizeBytes` is carried because it is what lets a client decide between the
17433
- * stored blob and a `?variant=thumb` rendering without fetching either.
17530
+ * stored blob and a `?variant=thumb` rendering without fetching either, and
17531
+ * `url` because a client that had to build the plane path itself is a second
17532
+ * copy of a route — the embed, the viewer and the admin UI each grew one.
17434
17533
  */
17435
17534
  var MediaFileInfoSchema = MediaFileSchema.omit({ base64: true });
17436
17535
  /**
@@ -18229,6 +18328,17 @@ var pipelineAnalyticsCapability = {
18229
18328
  * happens to stamp it. This count is what the migration planner's
18230
18329
  * non-blocking gate reads; `relocateMedia({ mode: 'seal' })` is what drives
18231
18330
  * it to zero.
18331
+ *
18332
+ * TWO indexed statements per collection, not a walk. It used to page the
18333
+ * whole collection at 200 rows per RPC ordered by an unindexed column, so
18334
+ * on the live hub — 1 254 576 rows — it hit the 60 s RPC deadline every
18335
+ * time it was called, and the migration it gates could never start. The
18336
+ * cheap question (`present`: is there at least one) is asked first and
18337
+ * separately from the expensive one (`rows`), because only the first has
18338
+ * to be answerable for the gate to do its job.
18339
+ *
18340
+ * **`null` is "not measurable", never zero** — at either level. An
18341
+ * unreadable collection must not read as a sealed one.
18232
18342
  */
18233
18343
  countUnstampedEventMedia: method(zod.z.object({}), UnstampedEventMediaCountSchema, { auth: "admin" }),
18234
18344
  /**
@@ -18552,6 +18662,26 @@ var pipelineAnalyticsCapability = {
18552
18662
  deviceId: zod.z.number()
18553
18663
  }), zod.z.array(MediaFileInfoSchema).readonly()),
18554
18664
  /**
18665
+ * What media an EVENT has, without any of it — the twin `getEventMedia`
18666
+ * never had.
18667
+ *
18668
+ * `listTrackMedia` above got this treatment because a track's media is
18669
+ * 5-8 MB. An event's is worse per row, not better: an old-style event owns
18670
+ * a `crop` AND a native-resolution `fullFrameBoxed`, and the track DETAIL
18671
+ * modal — the one surface that legitimately shows the big kinds — unions
18672
+ * both listings to build its filmstrip. It then renders every tile from
18673
+ * the `event-media` plane by key and throws the bytes away. Measured on
18674
+ * the live hub: one event's `fullFrameBoxed` is 2 824 077 B, base64'd to
18675
+ * ~3.8 MB, allocated whole in hub-main's heap, for a list of keys.
18676
+ *
18677
+ * Same `deviceId` authorization subject as `getEventMedia`, and the same
18678
+ * rows — this is a projection of that method, never a different question.
18679
+ */
18680
+ listEventMedia: method(zod.z.object({
18681
+ eventId: zod.z.string(),
18682
+ deviceId: zod.z.number()
18683
+ }), zod.z.array(MediaFileInfoSchema).readonly()),
18684
+ /**
18555
18685
  * Search object events by text query using CLIP cosine similarity.
18556
18686
  * Encodes `text` via the `embedding-encoder` cap, queries the
18557
18687
  * `ObjectEmbeddingStore` with optional prefilters, ranks all matching
@@ -25005,10 +25135,24 @@ var FaceClusterSchema = zod.z.object({
25005
25135
  size: zod.z.number().int(),
25006
25136
  cohesion: zod.z.number()
25007
25137
  });
25138
+ /**
25139
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
25140
+ * are — never the bytes.
25141
+ *
25142
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
25143
+ * track/event contract) is still populated because a deployed viewer requires
25144
+ * the field to parse a row at all; this method has no such reader. Its ONE
25145
+ * caller is the admin UI's detail modal, which was building
25146
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
25147
+ * dialog already rendering its key FRAME from the `event-media` plane.
25148
+ *
25149
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
25150
+ * media key directly, so this needed no new plane and no new access decision.
25151
+ */
25008
25152
  var MediaFileLiteSchema$1 = zod.z.object({
25009
25153
  key: zod.z.string(),
25010
25154
  kind: zod.z.string(),
25011
- base64: zod.z.string(),
25155
+ url: zod.z.string(),
25012
25156
  sizeBytes: zod.z.number(),
25013
25157
  timestamp: zod.z.number()
25014
25158
  });
@@ -28420,10 +28564,24 @@ var PlateInfoSchema = zod.z.object({
28420
28564
  */
28421
28565
  cropUrl: zod.z.string().optional()
28422
28566
  });
28567
+ /**
28568
+ * One gallery media row: what the crop is, how big it is, and WHERE its bytes
28569
+ * are — never the bytes.
28570
+ *
28571
+ * `base64` was deleted here rather than deprecated. `MediaFile.base64` (the
28572
+ * track/event contract) is still populated because a deployed viewer requires
28573
+ * the field to parse a row at all; this method has no such reader. Its ONE
28574
+ * caller is the admin UI's detail modal, which was building
28575
+ * `data:image/jpeg;base64,…` from a row whose `key` sat right beside it, in a
28576
+ * dialog already rendering its key FRAME from the `event-media` plane.
28577
+ *
28578
+ * `url` is `/addon/<addonId>/event-media/<encoded key>`. The plane resolves a
28579
+ * media key directly, so this needed no new plane and no new access decision.
28580
+ */
28423
28581
  var MediaFileLiteSchema = zod.z.object({
28424
28582
  key: zod.z.string(),
28425
28583
  kind: zod.z.string(),
28426
- base64: zod.z.string(),
28584
+ url: zod.z.string(),
28427
28585
  sizeBytes: zod.z.number(),
28428
28586
  timestamp: zod.z.number()
28429
28587
  });
@@ -36765,6 +36923,12 @@ var METHOD_ACCESS_MAP = Object.freeze({
36765
36923
  addonId: null,
36766
36924
  access: "view"
36767
36925
  },
36926
+ "pipelineAnalytics.listEventMedia": {
36927
+ capName: "pipeline-analytics",
36928
+ capScope: "device",
36929
+ addonId: null,
36930
+ access: "view"
36931
+ },
36768
36932
  "pipelineAnalytics.listGroups": {
36769
36933
  capName: "pipeline-analytics",
36770
36934
  capScope: "device",
@@ -40388,6 +40552,11 @@ Object.freeze({
40388
40552
  form: "array",
40389
40553
  optional: false
40390
40554
  }],
40555
+ "pipelineAnalytics.listEventMedia": [{
40556
+ name: "deviceId",
40557
+ form: "single",
40558
+ optional: false
40559
+ }],
40391
40560
  "pipelineAnalytics.listGroups": [{
40392
40561
  name: "deviceIds",
40393
40562
  form: "array",