@camstack/addon-post-analysis 1.2.137 → 1.2.139

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.
@@ -8602,6 +8602,112 @@ var DecoderSessionConfigSchema = object({
8602
8602
  */
8603
8603
  debug: boolean().optional()
8604
8604
  });
8605
+ /**
8606
+ * Distinct (device, family, variant) counters one instance will hold.
8607
+ *
8608
+ * A large fleet x the handful of families any single addon reports, with
8609
+ * slack. At ~200 B per counter this is a ~100 KB ceiling on a process that
8610
+ * already declares an RSS budget in the gigabytes.
8611
+ */
8612
+ var MAX_KEYS = 1024;
8613
+ /**
8614
+ * Where reasons past {@link MAX_REASONS_PER_KEY} go.
8615
+ *
8616
+ * They are FOLDED, never dropped: `attempts - succeeded` must always equal the
8617
+ * sum of the reason counts, or the ratio stops adding up.
8618
+ */
8619
+ var OVERFLOW_REASON = "other";
8620
+ /** `deviceId` + `family` + optional `variant`, flattened into the map key. */
8621
+ function counterKey(deviceId, family, variant) {
8622
+ return variant === void 0 ? `${deviceId}${family}` : `${deviceId}${family}${variant}`;
8623
+ }
8624
+ /**
8625
+ * A bounded set of per-camera, cumulative failure counters.
8626
+ *
8627
+ * One instance per contributing subsystem. `note` is O(1) and allocation-free
8628
+ * on the steady path; `snapshot` reads without mutating anything.
8629
+ */
8630
+ var FailureCounters = class {
8631
+ maxKeys;
8632
+ maxReasons;
8633
+ counters = /* @__PURE__ */ new Map();
8634
+ refused = 0;
8635
+ constructor(maxKeys = MAX_KEYS, maxReasons = 16) {
8636
+ this.maxKeys = maxKeys;
8637
+ this.maxReasons = maxReasons;
8638
+ }
8639
+ /**
8640
+ * Counters refused because {@link MAX_KEYS} was already held.
8641
+ *
8642
+ * Cumulative for the life of the instance: a bound that bit is a fact about
8643
+ * the deployment, and a surface that hid it would under-report a fleet
8644
+ * precisely when the fleet got large enough to matter.
8645
+ */
8646
+ get keysRefused() {
8647
+ return this.refused;
8648
+ }
8649
+ /** Counters currently held. */
8650
+ get size() {
8651
+ return this.counters.size;
8652
+ }
8653
+ /**
8654
+ * Fold one observation in.
8655
+ *
8656
+ * A non-positive or non-integer `deviceId` is REFUSED rather than bucketed:
8657
+ * see the module docblock — an entry that cannot name its camera is worse
8658
+ * than no entry.
8659
+ */
8660
+ note(observation, nowMs) {
8661
+ if (!Number.isInteger(observation.deviceId) || observation.deviceId <= 0) return;
8662
+ const key = counterKey(observation.deviceId, observation.family, observation.variant);
8663
+ let counter = this.counters.get(key);
8664
+ if (counter === void 0) {
8665
+ if (this.counters.size >= this.maxKeys) {
8666
+ this.refused += 1;
8667
+ return;
8668
+ }
8669
+ counter = {
8670
+ deviceId: observation.deviceId,
8671
+ family: observation.family,
8672
+ variant: observation.variant,
8673
+ sinceMs: nowMs,
8674
+ attempts: 0,
8675
+ succeeded: 0,
8676
+ reasons: /* @__PURE__ */ new Map()
8677
+ };
8678
+ this.counters.set(key, counter);
8679
+ }
8680
+ counter.attempts += 1;
8681
+ if (observation.reason === void 0) {
8682
+ counter.succeeded += 1;
8683
+ return;
8684
+ }
8685
+ const reason = counter.reasons.has(observation.reason) || counter.reasons.size < this.maxReasons ? observation.reason : OVERFLOW_REASON;
8686
+ counter.reasons.set(reason, (counter.reasons.get(reason) ?? 0) + 1);
8687
+ }
8688
+ /** Read every counter. Never mutates — see the module docblock. */
8689
+ snapshot(nowMs) {
8690
+ const out = [];
8691
+ for (const counter of this.counters.values()) out.push({
8692
+ deviceId: counter.deviceId,
8693
+ family: counter.family,
8694
+ ...counter.variant !== void 0 ? { variant: counter.variant } : {},
8695
+ sinceMs: counter.sinceMs,
8696
+ atMs: nowMs,
8697
+ attempts: counter.attempts,
8698
+ succeeded: counter.succeeded,
8699
+ reasons: [...counter.reasons.entries()].map(([reason, count]) => ({
8700
+ reason,
8701
+ count
8702
+ })).toSorted((a, b) => b.count - a.count)
8703
+ });
8704
+ return out;
8705
+ }
8706
+ /** Drop everything (host disposal). */
8707
+ clear() {
8708
+ this.counters.clear();
8709
+ }
8710
+ };
8605
8711
  var MODEL_FORMATS = [
8606
8712
  "onnx",
8607
8713
  "coreml",
@@ -13745,6 +13851,133 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13745
13851
  limit: number().optional(),
13746
13852
  tags: record(string(), string()).optional()
13747
13853
  }), array(LogEntrySchema).readonly());
13854
+ /**
13855
+ * `failure-contribution` — the capability an addon reports its OWN losses
13856
+ * through, per camera, with the denominator attached. It stores nothing.
13857
+ *
13858
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13859
+ *
13860
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13861
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13862
+ * copied: the contributor reports what it already knows, hub-main adds only
13863
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13864
+ * somebody to forget to edit.
13865
+ *
13866
+ * They are not merged, because their invariants are opposites:
13867
+ *
13868
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13869
+ * claim a camera cost nothing, which is a measurement nobody made;
13870
+ * - a `failure-contribution` zero is the **most valuable value on the
13871
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13872
+ * and it is exactly what an absent entry cannot say.
13873
+ *
13874
+ * Putting a loss counter on a cost entry would also break the reconciliation
13875
+ * that gives `load-contribution` its point: contributions are subtracted from
13876
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13877
+ * has no process.
13878
+ *
13879
+ * ## Why not a log line, since the counters already exist
13880
+ *
13881
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13882
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13883
+ * ends in a log line, and a log line is the thing the operator asked to stop
13884
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13885
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13886
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13887
+ * media blackout were both diagnosed. The counters stay; this is where they can
13888
+ * be READ.
13889
+ *
13890
+ * ## The rate is served with its denominator or not at all
13891
+ *
13892
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13893
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13894
+ * than yesterday" and was **flat across twelve hours** once divided by the
13895
+ * successes on the same path. A surface that publishes only the numerator
13896
+ * reproduces that mistake on every read.
13897
+ *
13898
+ * ## Shape
13899
+ *
13900
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13901
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13902
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13903
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13904
+ * a forked runner's entries reach hub-main over transport that already exists.
13905
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13906
+ * result through `system.getFailureContributions`.
13907
+ */
13908
+ var FailureReasonCountSchema = object({
13909
+ /**
13910
+ * Why the attempt did not land, in the contributor's own vocabulary —
13911
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13912
+ * strings that already appear in this repo's logs and, where one exists, the
13913
+ * same string the per-track `previewMissReason` records (D276): a second
13914
+ * vocabulary for the same loss would make the row and the counter
13915
+ * un-joinable.
13916
+ */
13917
+ reason: string(),
13918
+ count: number().int().nonnegative()
13919
+ });
13920
+ var FailureContributionSchema = object({
13921
+ /**
13922
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13923
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13924
+ * `unit` free: the families are owned by different addons and a shared enum
13925
+ * is a central list that rots invisibly.
13926
+ */
13927
+ family: string(),
13928
+ /**
13929
+ * The NUMERIC device id — the same value every log line carries as
13930
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13931
+ * cannot name the camera must not emit the entry, because a fleet total
13932
+ * cannot answer the only question anybody asks of this surface.
13933
+ */
13934
+ deviceId: number().int().positive(),
13935
+ /**
13936
+ * A second dimension inside the family: the model / step id for an inference
13937
+ * timeout, so "which camera AND which model" is one read. Absent when the
13938
+ * family has a single variant.
13939
+ */
13940
+ variant: string().optional(),
13941
+ /**
13942
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13943
+ * differencing two reads must drop the interval when it changes, because the
13944
+ * counter restarted from zero in a respawned runner. Same discipline as
13945
+ * `LoadContribution.startedAtMs`.
13946
+ */
13947
+ sinceMs: number(),
13948
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13949
+ atMs: number(),
13950
+ /**
13951
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13952
+ * window. A failure count published without it is the mistake this schema
13953
+ * exists to make impossible.
13954
+ */
13955
+ attempts: number().int().nonnegative(),
13956
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13957
+ succeeded: number().int().nonnegative(),
13958
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13959
+ reasons: array(FailureReasonCountSchema).readonly()
13960
+ });
13961
+ var failureContributionCapability = {
13962
+ name: "failure-contribution",
13963
+ scope: "system",
13964
+ mode: "collection",
13965
+ internal: true,
13966
+ methods: {
13967
+ /**
13968
+ * This addon's per-camera failure counters, read live from bounded in-RAM
13969
+ * state it already keeps. Inert: no persistence, no sampling, no timer.
13970
+ *
13971
+ * READING NEVER RESETS. The counters are CUMULATIVE since `sinceMs`, and a
13972
+ * consumer that wants a rate differences two reads. A draining read would
13973
+ * make two operators with the page open each destroy half of the other's
13974
+ * numbers, and `load-contribution` already settled the same question the
13975
+ * same way for `cpuSeconds`.
13976
+ */
13977
+ list: method(_void(), array(FailureContributionSchema).readonly()) },
13978
+ /** In-process only — enumerated through `addons.listCapabilityProviders`. */
13979
+ mount: { kind: "skip" }
13980
+ };
13748
13981
  var LoadContributionSchema = object({
13749
13982
  role: _enum([
13750
13983
  "decode",
@@ -18963,6 +19196,20 @@ var TrackSchema = object({
18963
19196
  * `=== true` and render nothing otherwise — never infer "no rider".
18964
19197
  */
18965
19198
  hasRider: boolean().optional(),
19199
+ /**
19200
+ * WHY this track ended without a NATIVE best-shot tile
19201
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
19202
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
19203
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
19204
+ * the late-keyFrame upgrade when a native tile lands after all. The
19205
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
19206
+ * tile is a face/plate stand-in, a raster crop, or an icon.
19207
+ *
19208
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
19209
+ * that predates the field, and every track whose tile landed native all
19210
+ * omit it. Render nothing when absent.
19211
+ */
19212
+ previewMissReason: string().optional(),
18966
19213
  ...TrackFlagFields,
18967
19214
  ...TrackRetrainFields
18968
19215
  });
@@ -30705,6 +30952,13 @@ var LoggingSettingsPatchSchema = object({
30705
30952
  * anyone but its owner.
30706
30953
  */
30707
30954
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
30955
+ /**
30956
+ * One per-camera failure counter, plus WHO reported it.
30957
+ *
30958
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
30959
+ * the hub as it enumerates providers, never by the contributor.
30960
+ */
30961
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
30708
30962
  var GetLoggingSettingsInputSchema = object({
30709
30963
  scopeNodeId: string().optional(),
30710
30964
  /**
@@ -30763,7 +31017,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30763
31017
  }), method(_void(), SiteLocationStatusSchema, {
30764
31018
  kind: "mutation",
30765
31019
  auth: "admin"
30766
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
31020
+ }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30767
31021
  kind: "mutation",
30768
31022
  auth: "admin"
30769
31023
  });
@@ -34805,6 +35059,12 @@ Object.freeze({
34805
35059
  addonId: null,
34806
35060
  access: "create"
34807
35061
  },
35062
+ "failureContribution.list": {
35063
+ capName: "failure-contribution",
35064
+ capScope: "system",
35065
+ addonId: null,
35066
+ access: "view"
35067
+ },
34808
35068
  "fanControl.setDirection": {
34809
35069
  capName: "fan-control",
34810
35070
  capScope: "device",
@@ -38111,6 +38371,12 @@ Object.freeze({
38111
38371
  addonId: null,
38112
38372
  access: "create"
38113
38373
  },
38374
+ "system.getFailureContributions": {
38375
+ capName: "system",
38376
+ capScope: "system",
38377
+ addonId: null,
38378
+ access: "view"
38379
+ },
38114
38380
  "system.getLoadContributions": {
38115
38381
  capName: "system",
38116
38382
  capScope: "system",
@@ -41650,6 +41916,12 @@ Object.defineProperty(exports, "CLUSTER_MODEL_SCOPED_STEPS", {
41650
41916
  return CLUSTER_MODEL_SCOPED_STEPS;
41651
41917
  }
41652
41918
  });
41919
+ Object.defineProperty(exports, "COCO_TO_MACRO", {
41920
+ enumerable: true,
41921
+ get: function() {
41922
+ return COCO_TO_MACRO;
41923
+ }
41924
+ });
41653
41925
  Object.defineProperty(exports, "DEFAULT_EVENT_COLOR", {
41654
41926
  enumerable: true,
41655
41927
  get: function() {
@@ -41710,6 +41982,12 @@ Object.defineProperty(exports, "FULL_IMAGE_BBOX", {
41710
41982
  return FULL_IMAGE_BBOX;
41711
41983
  }
41712
41984
  });
41985
+ Object.defineProperty(exports, "FailureCounters", {
41986
+ enumerable: true,
41987
+ get: function() {
41988
+ return FailureCounters;
41989
+ }
41990
+ });
41713
41991
  Object.defineProperty(exports, "LabelAttributionSchema", {
41714
41992
  enumerable: true,
41715
41993
  get: function() {
@@ -42034,6 +42312,12 @@ Object.defineProperty(exports, "faceGalleryCapability", {
42034
42312
  return faceGalleryCapability;
42035
42313
  }
42036
42314
  });
42315
+ Object.defineProperty(exports, "failureContributionCapability", {
42316
+ enumerable: true,
42317
+ get: function() {
42318
+ return failureContributionCapability;
42319
+ }
42320
+ });
42037
42321
  Object.defineProperty(exports, "hfModelUrl", {
42038
42322
  enumerable: true,
42039
42323
  get: function() {
@@ -8571,6 +8571,112 @@ var DecoderSessionConfigSchema = object({
8571
8571
  */
8572
8572
  debug: boolean().optional()
8573
8573
  });
8574
+ /**
8575
+ * Distinct (device, family, variant) counters one instance will hold.
8576
+ *
8577
+ * A large fleet x the handful of families any single addon reports, with
8578
+ * slack. At ~200 B per counter this is a ~100 KB ceiling on a process that
8579
+ * already declares an RSS budget in the gigabytes.
8580
+ */
8581
+ var MAX_KEYS = 1024;
8582
+ /**
8583
+ * Where reasons past {@link MAX_REASONS_PER_KEY} go.
8584
+ *
8585
+ * They are FOLDED, never dropped: `attempts - succeeded` must always equal the
8586
+ * sum of the reason counts, or the ratio stops adding up.
8587
+ */
8588
+ var OVERFLOW_REASON = "other";
8589
+ /** `deviceId` + `family` + optional `variant`, flattened into the map key. */
8590
+ function counterKey(deviceId, family, variant) {
8591
+ return variant === void 0 ? `${deviceId}${family}` : `${deviceId}${family}${variant}`;
8592
+ }
8593
+ /**
8594
+ * A bounded set of per-camera, cumulative failure counters.
8595
+ *
8596
+ * One instance per contributing subsystem. `note` is O(1) and allocation-free
8597
+ * on the steady path; `snapshot` reads without mutating anything.
8598
+ */
8599
+ var FailureCounters = class {
8600
+ maxKeys;
8601
+ maxReasons;
8602
+ counters = /* @__PURE__ */ new Map();
8603
+ refused = 0;
8604
+ constructor(maxKeys = MAX_KEYS, maxReasons = 16) {
8605
+ this.maxKeys = maxKeys;
8606
+ this.maxReasons = maxReasons;
8607
+ }
8608
+ /**
8609
+ * Counters refused because {@link MAX_KEYS} was already held.
8610
+ *
8611
+ * Cumulative for the life of the instance: a bound that bit is a fact about
8612
+ * the deployment, and a surface that hid it would under-report a fleet
8613
+ * precisely when the fleet got large enough to matter.
8614
+ */
8615
+ get keysRefused() {
8616
+ return this.refused;
8617
+ }
8618
+ /** Counters currently held. */
8619
+ get size() {
8620
+ return this.counters.size;
8621
+ }
8622
+ /**
8623
+ * Fold one observation in.
8624
+ *
8625
+ * A non-positive or non-integer `deviceId` is REFUSED rather than bucketed:
8626
+ * see the module docblock — an entry that cannot name its camera is worse
8627
+ * than no entry.
8628
+ */
8629
+ note(observation, nowMs) {
8630
+ if (!Number.isInteger(observation.deviceId) || observation.deviceId <= 0) return;
8631
+ const key = counterKey(observation.deviceId, observation.family, observation.variant);
8632
+ let counter = this.counters.get(key);
8633
+ if (counter === void 0) {
8634
+ if (this.counters.size >= this.maxKeys) {
8635
+ this.refused += 1;
8636
+ return;
8637
+ }
8638
+ counter = {
8639
+ deviceId: observation.deviceId,
8640
+ family: observation.family,
8641
+ variant: observation.variant,
8642
+ sinceMs: nowMs,
8643
+ attempts: 0,
8644
+ succeeded: 0,
8645
+ reasons: /* @__PURE__ */ new Map()
8646
+ };
8647
+ this.counters.set(key, counter);
8648
+ }
8649
+ counter.attempts += 1;
8650
+ if (observation.reason === void 0) {
8651
+ counter.succeeded += 1;
8652
+ return;
8653
+ }
8654
+ const reason = counter.reasons.has(observation.reason) || counter.reasons.size < this.maxReasons ? observation.reason : OVERFLOW_REASON;
8655
+ counter.reasons.set(reason, (counter.reasons.get(reason) ?? 0) + 1);
8656
+ }
8657
+ /** Read every counter. Never mutates — see the module docblock. */
8658
+ snapshot(nowMs) {
8659
+ const out = [];
8660
+ for (const counter of this.counters.values()) out.push({
8661
+ deviceId: counter.deviceId,
8662
+ family: counter.family,
8663
+ ...counter.variant !== void 0 ? { variant: counter.variant } : {},
8664
+ sinceMs: counter.sinceMs,
8665
+ atMs: nowMs,
8666
+ attempts: counter.attempts,
8667
+ succeeded: counter.succeeded,
8668
+ reasons: [...counter.reasons.entries()].map(([reason, count]) => ({
8669
+ reason,
8670
+ count
8671
+ })).toSorted((a, b) => b.count - a.count)
8672
+ });
8673
+ return out;
8674
+ }
8675
+ /** Drop everything (host disposal). */
8676
+ clear() {
8677
+ this.counters.clear();
8678
+ }
8679
+ };
8574
8680
  var MODEL_FORMATS = [
8575
8681
  "onnx",
8576
8682
  "coreml",
@@ -13714,6 +13820,133 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13714
13820
  limit: number().optional(),
13715
13821
  tags: record(string(), string()).optional()
13716
13822
  }), array(LogEntrySchema).readonly());
13823
+ /**
13824
+ * `failure-contribution` — the capability an addon reports its OWN losses
13825
+ * through, per camera, with the denominator attached. It stores nothing.
13826
+ *
13827
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13828
+ *
13829
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13830
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13831
+ * copied: the contributor reports what it already knows, hub-main adds only
13832
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13833
+ * somebody to forget to edit.
13834
+ *
13835
+ * They are not merged, because their invariants are opposites:
13836
+ *
13837
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13838
+ * claim a camera cost nothing, which is a measurement nobody made;
13839
+ * - a `failure-contribution` zero is the **most valuable value on the
13840
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13841
+ * and it is exactly what an absent entry cannot say.
13842
+ *
13843
+ * Putting a loss counter on a cost entry would also break the reconciliation
13844
+ * that gives `load-contribution` its point: contributions are subtracted from
13845
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13846
+ * has no process.
13847
+ *
13848
+ * ## Why not a log line, since the counters already exist
13849
+ *
13850
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13851
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13852
+ * ends in a log line, and a log line is the thing the operator asked to stop
13853
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13854
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13855
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13856
+ * media blackout were both diagnosed. The counters stay; this is where they can
13857
+ * be READ.
13858
+ *
13859
+ * ## The rate is served with its denominator or not at all
13860
+ *
13861
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13862
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13863
+ * than yesterday" and was **flat across twelve hours** once divided by the
13864
+ * successes on the same path. A surface that publishes only the numerator
13865
+ * reproduces that mistake on every read.
13866
+ *
13867
+ * ## Shape
13868
+ *
13869
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13870
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13871
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13872
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13873
+ * a forked runner's entries reach hub-main over transport that already exists.
13874
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13875
+ * result through `system.getFailureContributions`.
13876
+ */
13877
+ var FailureReasonCountSchema = object({
13878
+ /**
13879
+ * Why the attempt did not land, in the contributor's own vocabulary —
13880
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13881
+ * strings that already appear in this repo's logs and, where one exists, the
13882
+ * same string the per-track `previewMissReason` records (D276): a second
13883
+ * vocabulary for the same loss would make the row and the counter
13884
+ * un-joinable.
13885
+ */
13886
+ reason: string(),
13887
+ count: number().int().nonnegative()
13888
+ });
13889
+ var FailureContributionSchema = object({
13890
+ /**
13891
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13892
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13893
+ * `unit` free: the families are owned by different addons and a shared enum
13894
+ * is a central list that rots invisibly.
13895
+ */
13896
+ family: string(),
13897
+ /**
13898
+ * The NUMERIC device id — the same value every log line carries as
13899
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13900
+ * cannot name the camera must not emit the entry, because a fleet total
13901
+ * cannot answer the only question anybody asks of this surface.
13902
+ */
13903
+ deviceId: number().int().positive(),
13904
+ /**
13905
+ * A second dimension inside the family: the model / step id for an inference
13906
+ * timeout, so "which camera AND which model" is one read. Absent when the
13907
+ * family has a single variant.
13908
+ */
13909
+ variant: string().optional(),
13910
+ /**
13911
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13912
+ * differencing two reads must drop the interval when it changes, because the
13913
+ * counter restarted from zero in a respawned runner. Same discipline as
13914
+ * `LoadContribution.startedAtMs`.
13915
+ */
13916
+ sinceMs: number(),
13917
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13918
+ atMs: number(),
13919
+ /**
13920
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13921
+ * window. A failure count published without it is the mistake this schema
13922
+ * exists to make impossible.
13923
+ */
13924
+ attempts: number().int().nonnegative(),
13925
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13926
+ succeeded: number().int().nonnegative(),
13927
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13928
+ reasons: array(FailureReasonCountSchema).readonly()
13929
+ });
13930
+ var failureContributionCapability = {
13931
+ name: "failure-contribution",
13932
+ scope: "system",
13933
+ mode: "collection",
13934
+ internal: true,
13935
+ methods: {
13936
+ /**
13937
+ * This addon's per-camera failure counters, read live from bounded in-RAM
13938
+ * state it already keeps. Inert: no persistence, no sampling, no timer.
13939
+ *
13940
+ * READING NEVER RESETS. The counters are CUMULATIVE since `sinceMs`, and a
13941
+ * consumer that wants a rate differences two reads. A draining read would
13942
+ * make two operators with the page open each destroy half of the other's
13943
+ * numbers, and `load-contribution` already settled the same question the
13944
+ * same way for `cpuSeconds`.
13945
+ */
13946
+ list: method(_void(), array(FailureContributionSchema).readonly()) },
13947
+ /** In-process only — enumerated through `addons.listCapabilityProviders`. */
13948
+ mount: { kind: "skip" }
13949
+ };
13717
13950
  var LoadContributionSchema = object({
13718
13951
  role: _enum([
13719
13952
  "decode",
@@ -18932,6 +19165,20 @@ var TrackSchema = object({
18932
19165
  * `=== true` and render nothing otherwise — never infer "no rider".
18933
19166
  */
18934
19167
  hasRider: boolean().optional(),
19168
+ /**
19169
+ * WHY this track ended without a NATIVE best-shot tile
19170
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
19171
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
19172
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
19173
+ * the late-keyFrame upgrade when a native tile lands after all. The
19174
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
19175
+ * tile is a face/plate stand-in, a raster crop, or an icon.
19176
+ *
19177
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
19178
+ * that predates the field, and every track whose tile landed native all
19179
+ * omit it. Render nothing when absent.
19180
+ */
19181
+ previewMissReason: string().optional(),
18935
19182
  ...TrackFlagFields,
18936
19183
  ...TrackRetrainFields
18937
19184
  });
@@ -30674,6 +30921,13 @@ var LoggingSettingsPatchSchema = object({
30674
30921
  * anyone but its owner.
30675
30922
  */
30676
30923
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
30924
+ /**
30925
+ * One per-camera failure counter, plus WHO reported it.
30926
+ *
30927
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
30928
+ * the hub as it enumerates providers, never by the contributor.
30929
+ */
30930
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
30677
30931
  var GetLoggingSettingsInputSchema = object({
30678
30932
  scopeNodeId: string().optional(),
30679
30933
  /**
@@ -30732,7 +30986,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
30732
30986
  }), method(_void(), SiteLocationStatusSchema, {
30733
30987
  kind: "mutation",
30734
30988
  auth: "admin"
30735
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30989
+ }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(_void(), array(ReportedFailureContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30736
30990
  kind: "mutation",
30737
30991
  auth: "admin"
30738
30992
  });
@@ -34774,6 +35028,12 @@ Object.freeze({
34774
35028
  addonId: null,
34775
35029
  access: "create"
34776
35030
  },
35031
+ "failureContribution.list": {
35032
+ capName: "failure-contribution",
35033
+ capScope: "system",
35034
+ addonId: null,
35035
+ access: "view"
35036
+ },
34777
35037
  "fanControl.setDirection": {
34778
35038
  capName: "fan-control",
34779
35039
  capScope: "device",
@@ -38080,6 +38340,12 @@ Object.freeze({
38080
38340
  addonId: null,
38081
38341
  access: "create"
38082
38342
  },
38343
+ "system.getFailureContributions": {
38344
+ capName: "system",
38345
+ capScope: "system",
38346
+ addonId: null,
38347
+ access: "view"
38348
+ },
38083
38349
  "system.getLoadContributions": {
38084
38350
  capName: "system",
38085
38351
  capScope: "system",
@@ -41589,4 +41855,4 @@ function vectorDimFromBase64(encoded) {
41589
41855
  return Math.floor(Buffer.from(encoded, "base64").byteLength / 4);
41590
41856
  }
41591
41857
  //#endregion
41592
- export { customAction as $, NcTaxonomySchema as A, sleep as At, TIMELAPSE_DENSE_FLOOR_SEC as B, string as Bt, NcRuleSchema as C, errMsg as Ct, NcSnoozeSchema as D, hydrateSchema as Dt, NcSnoozeInputSchema as E, createEvent as Et, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS as F, literal as Ft, VISIT_MERGE_GAP_MS as G, TimelapseRulePatchSchema as H, EventCategory as Ht, SCENE_DEFAULT_ANCHOR_THRESHOLD as I, number as It, assertTimelapseCadences as J, addonWidgetsSourceCapability as K, SCENE_DEFAULT_UNCOVERED_POLICY as L, object as Lt, PoolMemoryWatchdog as M, array as Mt, RECORDING_EXPORT_MAX_READ_BYTES as N, boolean as Nt, NcSnoozeSuppressedSchema as O, isDeviceScopedCap as Ot, RetrainStatusSchema as P, discriminatedUnion as Pt, cosineSimilarity as Q, SCENE_DIVERGED as R, partialRecord as Rt, NcRulePatchSchema as S, zoneAnalyticsCapability as St, NcScheduleSchema as T, DeviceType as Tt, TimelapseRuleSchema as U, TimelapseRuleInputSchema as V, unknown as Vt, TrackSourceSchema as W, audioModeOf as X, audioMetricsCapability as Y, buildEventKindDescriptor as Z, NC_DEFAULT_SNOOZE_MINUTES as _, sceneMonitorCapability as _t, DEFAULT_EVENT_COLOR as a, hfModelUrl as at, NcConditionDescriptorSchema as b, vectorDimFromBase64 as bt, DETECTION_PIPELINE_CAP_NAME as c, kebabToCamel as ct, EVENT_PAD_MS as d, pickClusterStepModels as dt, defineCustomActions as et, FULL_IMAGE_BBOX as f, pipelineAnalyticsCapability as ft, NC_CONDITION_CATALOG as g, resolvePoolMemoryPolicy as gt, NC_ALARM_SYSTEM_EVENT_KINDS as h, readTimelapseGeneratedAt as ht, CLUSTER_MODEL_SCOPED_STEPS as i, faceGalleryCapability as it, OpsLogEntrySchema as j, _enum as jt, NcSystemEventKindSchema as k, nodePin as kt, DeclaredDevices as l, notificationRulesCapability as lt, MACRO_LABELS as m, readDeviceStateFrom as mt, AnalyticsGroupRecordSchema as n, embeddingEncoderCapability as nt, DEFAULT_TIMELAPSE_PREVIEW_TEXT as o, isDetectionMacroClass as ot, LabelAttributionSchema as p, plateGalleryCapability as pt, alarmPanelCapability as q, BaseDevice as r, encodeVectorBase64 as rt, DETECTION_MACRO_CLASSES as s, isScheduleActive as st, AnalyticsGroupDetailSchema as t, deriveRecordingMode as tt, EVENT_KIND_BY_CAP as u, parseProcStatus as ut, NC_SNOOZE_MAX_MINUTES as v, subKindsOf as vt, NcRuleTargetSchema as w, BaseAddon as wt, NcRuleInputSchema as x, videoclipsCapability as xt, NC_TAXONOMY as y, systemEventFilterApplies as yt, SceneMonitorSchema as z, record as zt };
41858
+ export { buildEventKindDescriptor as $, NcSnoozeSuppressedSchema as A, hydrateSchema as At, SCENE_DIVERGED as B, object as Bt, NcRuleInputSchema as C, vectorDimFromBase64 as Ct, NcScheduleSchema as D, BaseAddon as Dt, NcRuleTargetSchema as E, errMsg as Et, RECORDING_EXPORT_MAX_READ_BYTES as F, array as Ft, TimelapseRuleSchema as G, EventCategory as Gt, TIMELAPSE_DENSE_FLOOR_SEC as H, record as Ht, RetrainStatusSchema as I, boolean as It, addonWidgetsSourceCapability as J, TrackSourceSchema as K, SCENE_CONFIRM_DEFAULT_TIMEOUT_MS as L, discriminatedUnion as Lt, NcTaxonomySchema as M, nodePin as Mt, OpsLogEntrySchema as N, sleep as Nt, NcSnoozeInputSchema as O, DeviceType as Ot, PoolMemoryWatchdog as P, _enum as Pt, audioModeOf as Q, SCENE_DEFAULT_ANCHOR_THRESHOLD as R, literal as Rt, NcConditionDescriptorSchema as S, systemEventFilterApplies as St, NcRuleSchema as T, zoneAnalyticsCapability as Tt, TimelapseRuleInputSchema as U, string as Ut, SceneMonitorSchema as V, partialRecord as Vt, TimelapseRulePatchSchema as W, unknown as Wt, assertTimelapseCadences as X, alarmPanelCapability as Y, audioMetricsCapability as Z, NC_ALARM_SYSTEM_EVENT_KINDS as _, readDeviceStateFrom as _t, COCO_TO_MACRO as a, encodeVectorBase64 as at, NC_SNOOZE_MAX_MINUTES as b, sceneMonitorCapability as bt, DETECTION_MACRO_CLASSES as c, hfModelUrl as ct, EVENT_KIND_BY_CAP as d, kebabToCamel as dt, cosineSimilarity as et, EVENT_PAD_MS as f, notificationRulesCapability as ft, MACRO_LABELS as g, plateGalleryCapability as gt, LabelAttributionSchema as h, pipelineAnalyticsCapability as ht, CLUSTER_MODEL_SCOPED_STEPS as i, embeddingEncoderCapability as it, NcSystemEventKindSchema as j, isDeviceScopedCap as jt, NcSnoozeSchema as k, createEvent as kt, DETECTION_PIPELINE_CAP_NAME as l, isDetectionMacroClass as lt, FailureCounters as m, pickClusterStepModels as mt, AnalyticsGroupRecordSchema as n, defineCustomActions as nt, DEFAULT_EVENT_COLOR as o, faceGalleryCapability as ot, FULL_IMAGE_BBOX as p, parseProcStatus as pt, VISIT_MERGE_GAP_MS as q, BaseDevice as r, deriveRecordingMode as rt, DEFAULT_TIMELAPSE_PREVIEW_TEXT as s, failureContributionCapability as st, AnalyticsGroupDetailSchema as t, customAction as tt, DeclaredDevices as u, isScheduleActive as ut, NC_CONDITION_CATALOG as v, readTimelapseGeneratedAt as vt, NcRulePatchSchema as w, videoclipsCapability as wt, NC_TAXONOMY as x, subKindsOf as xt, NC_DEFAULT_SNOOZE_MINUTES as y, resolvePoolMemoryPolicy as yt, SCENE_DEFAULT_UNCOVERED_POLICY as z, number as zt };