@camstack/addon-mqtt-broker 1.2.37 → 1.2.39

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.
@@ -5961,6 +5961,40 @@ var BaseAddon = class {
5961
5961
  deviceSettingsSchema() {
5962
5962
  return null;
5963
5963
  }
5964
+ /**
5965
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5966
+ * ARE the configuration of its integration.
5967
+ *
5968
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5969
+ * operator should find on the addon's integration page (System →
5970
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5971
+ * addon. Empty (the default) means the addon has no integration-level
5972
+ * settings and no such surface is offered — this is opt-in, because whether
5973
+ * an addon's configuration IS its integration's configuration depends on the
5974
+ * nature of the integration.
5975
+ *
5976
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5977
+ * the ONE global schema, in the ONE addon store, written by the ONE
5978
+ * `updateGlobalSettings` path. There is deliberately no
5979
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5980
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5981
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5982
+ *
5983
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5984
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5985
+ * removed with the reason recorded at
5986
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5987
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5988
+ * marker sprinkled across sections also has to borrow a field that already
5989
+ * means something else; borrowing `section.tab` put the literal word
5990
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5991
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5992
+ * supersedes D268). One declaration, in one place, next to the schema whose
5993
+ * ids it names.
5994
+ */
5995
+ integrationSettingSections() {
5996
+ return [];
5997
+ }
5964
5998
  async getGlobalSettings(overlay, cap, nodeId) {
5965
5999
  const schema = this.globalSettingsSchema(cap);
5966
6000
  if (!schema) return { sections: [] };
@@ -5971,6 +6005,55 @@ var BaseAddon = class {
5971
6005
  } : projected);
5972
6006
  }
5973
6007
  /**
6008
+ * The integration-level view of this addon's settings: exactly the sections
6009
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6010
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6011
+ *
6012
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6013
+ * no integration settings surface at all, rather than an empty one that reads
6014
+ * as a failed load.
6015
+ *
6016
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6017
+ * and not in whichever UI happens to render this:
6018
+ *
6019
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6020
+ * shown here is the same field, with the same bare key, that the addon's
6021
+ * own page shows. There is no integration-specific writer — callers save
6022
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6023
+ * not merely discouraged.
6024
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6025
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6026
+ * such a field silently picked would be a wrong answer for the operator
6027
+ * who opened the page (D266).
6028
+ * 3. **No silent typo.** A declared id that names no section throws. The
6029
+ * alternative — skip it — turns a rename into a surface that quietly
6030
+ * empties, which looks exactly like an addon with nothing to configure.
6031
+ */
6032
+ async getIntegrationSettings(nodeId) {
6033
+ const declared = this.integrationSettingSections();
6034
+ if (declared.length === 0) return null;
6035
+ const schema = this.globalSettingsSchema();
6036
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6037
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6038
+ const sections = [];
6039
+ for (const id of declared) {
6040
+ const section = byId.get(id);
6041
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6042
+ const fields = dropPerNodeFields(section.fields);
6043
+ if (fields.length === 0) continue;
6044
+ sections.push({
6045
+ ...section,
6046
+ fields
6047
+ });
6048
+ }
6049
+ if (sections.length === 0) return null;
6050
+ const projected = await this.resolveGlobalStore(nodeId);
6051
+ return hydrateSchema({
6052
+ ...schema,
6053
+ sections
6054
+ }, projected);
6055
+ }
6056
+ /**
5974
6057
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5975
6058
  * every `perNode: true` field carries THAT node's scoped value on its bare
5976
6059
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6274,6 +6357,41 @@ var BaseAddon = class {
6274
6357
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6275
6358
  * don't declare `perNode` and are excluded by the `in` narrowing.
6276
6359
  */
6360
+ /**
6361
+ * The same fields with every `perNode: true` one removed, recursing into layout
6362
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6363
+ * with no child is dropped rather than rendered empty.
6364
+ *
6365
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6366
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6367
+ */
6368
+ function dropPerNodeFields(fields) {
6369
+ const kept = [];
6370
+ for (const field of fields) {
6371
+ if (field.type === "group") {
6372
+ const inner = dropPerNodeFields(field.fields);
6373
+ if (inner.length > 0) kept.push({
6374
+ ...field,
6375
+ fields: inner
6376
+ });
6377
+ continue;
6378
+ }
6379
+ if (field.type === "sub-tabs") {
6380
+ const tabs = field.tabs.map((tab) => ({
6381
+ ...tab,
6382
+ fields: dropPerNodeFields(tab.fields)
6383
+ })).filter((tab) => tab.fields.length > 0);
6384
+ if (tabs.length > 0) kept.push({
6385
+ ...field,
6386
+ tabs
6387
+ });
6388
+ continue;
6389
+ }
6390
+ if ("perNode" in field && field.perNode === true) continue;
6391
+ kept.push(field);
6392
+ }
6393
+ return kept;
6394
+ }
6277
6395
  function collectPerNodeFieldKeys(fields) {
6278
6396
  const collected = [];
6279
6397
  for (const field of fields) {
@@ -9427,6 +9545,9 @@ method(object({
9427
9545
  kind: "mutation",
9428
9546
  auth: "admin"
9429
9547
  }), method(object({
9548
+ addonId: string(),
9549
+ nodeId: string().optional()
9550
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9430
9551
  addonId: string(),
9431
9552
  deviceId: number(),
9432
9553
  nodeId: string().optional()
@@ -13160,6 +13281,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13160
13281
  limit: number().optional(),
13161
13282
  tags: record(string(), string()).optional()
13162
13283
  }), array(LogEntrySchema).readonly());
13284
+ /**
13285
+ * `failure-contribution` — the capability an addon reports its OWN losses
13286
+ * through, per camera, with the denominator attached. It stores nothing.
13287
+ *
13288
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13289
+ *
13290
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13291
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13292
+ * copied: the contributor reports what it already knows, hub-main adds only
13293
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13294
+ * somebody to forget to edit.
13295
+ *
13296
+ * They are not merged, because their invariants are opposites:
13297
+ *
13298
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13299
+ * claim a camera cost nothing, which is a measurement nobody made;
13300
+ * - a `failure-contribution` zero is the **most valuable value on the
13301
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13302
+ * and it is exactly what an absent entry cannot say.
13303
+ *
13304
+ * Putting a loss counter on a cost entry would also break the reconciliation
13305
+ * that gives `load-contribution` its point: contributions are subtracted from
13306
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13307
+ * has no process.
13308
+ *
13309
+ * ## Why not a log line, since the counters already exist
13310
+ *
13311
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13312
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13313
+ * ends in a log line, and a log line is the thing the operator asked to stop
13314
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13315
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13316
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13317
+ * media blackout were both diagnosed. The counters stay; this is where they can
13318
+ * be READ.
13319
+ *
13320
+ * ## The rate is served with its denominator or not at all
13321
+ *
13322
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13323
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13324
+ * than yesterday" and was **flat across twelve hours** once divided by the
13325
+ * successes on the same path. A surface that publishes only the numerator
13326
+ * reproduces that mistake on every read.
13327
+ *
13328
+ * ## Shape
13329
+ *
13330
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13331
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13332
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13333
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13334
+ * a forked runner's entries reach hub-main over transport that already exists.
13335
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13336
+ * result through `system.getFailureContributions`.
13337
+ */
13338
+ var FailureReasonCountSchema = object({
13339
+ /**
13340
+ * Why the attempt did not land, in the contributor's own vocabulary —
13341
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13342
+ * strings that already appear in this repo's logs and, where one exists, the
13343
+ * same string the per-track `previewMissReason` records (D276): a second
13344
+ * vocabulary for the same loss would make the row and the counter
13345
+ * un-joinable.
13346
+ */
13347
+ reason: string(),
13348
+ count: number().int().nonnegative()
13349
+ });
13350
+ var FailureContributionSchema = object({
13351
+ /**
13352
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13353
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13354
+ * `unit` free: the families are owned by different addons and a shared enum
13355
+ * is a central list that rots invisibly.
13356
+ */
13357
+ family: string(),
13358
+ /**
13359
+ * The NUMERIC device id — the same value every log line carries as
13360
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13361
+ * cannot name the camera must not emit the entry, because a fleet total
13362
+ * cannot answer the only question anybody asks of this surface.
13363
+ */
13364
+ deviceId: number().int().positive(),
13365
+ /**
13366
+ * A second dimension inside the family: the model / step id for an inference
13367
+ * timeout, so "which camera AND which model" is one read. Absent when the
13368
+ * family has a single variant.
13369
+ */
13370
+ variant: string().optional(),
13371
+ /**
13372
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13373
+ * differencing two reads must drop the interval when it changes, because the
13374
+ * counter restarted from zero in a respawned runner. Same discipline as
13375
+ * `LoadContribution.startedAtMs`.
13376
+ */
13377
+ sinceMs: number(),
13378
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13379
+ atMs: number(),
13380
+ /**
13381
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13382
+ * window. A failure count published without it is the mistake this schema
13383
+ * exists to make impossible.
13384
+ */
13385
+ attempts: number().int().nonnegative(),
13386
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13387
+ succeeded: number().int().nonnegative(),
13388
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13389
+ reasons: array(FailureReasonCountSchema).readonly()
13390
+ });
13391
+ method(_void(), array(FailureContributionSchema).readonly());
13163
13392
  var LoadContributionSchema = object({
13164
13393
  role: _enum([
13165
13394
  "decode",
@@ -17691,6 +17920,20 @@ var TrackSchema = object({
17691
17920
  * `=== true` and render nothing otherwise — never infer "no rider".
17692
17921
  */
17693
17922
  hasRider: boolean().optional(),
17923
+ /**
17924
+ * WHY this track ended without a NATIVE best-shot tile
17925
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
17926
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
17927
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
17928
+ * the late-keyFrame upgrade when a native tile lands after all. The
17929
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
17930
+ * tile is a face/plate stand-in, a raster crop, or an icon.
17931
+ *
17932
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
17933
+ * that predates the field, and every track whose tile landed native all
17934
+ * omit it. Render nothing when absent.
17935
+ */
17936
+ previewMissReason: string().optional(),
17694
17937
  ...TrackFlagFields,
17695
17938
  ...TrackRetrainFields
17696
17939
  });
@@ -26917,6 +27160,13 @@ var LoggingSettingsPatchSchema = object({
26917
27160
  * anyone but its owner.
26918
27161
  */
26919
27162
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
27163
+ /**
27164
+ * One per-camera failure counter, plus WHO reported it.
27165
+ *
27166
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
27167
+ * the hub as it enumerates providers, never by the contributor.
27168
+ */
27169
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
26920
27170
  var GetLoggingSettingsInputSchema = object({
26921
27171
  scopeNodeId: string().optional(),
26922
27172
  /**
@@ -26975,7 +27225,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
26975
27225
  }), method(_void(), SiteLocationStatusSchema, {
26976
27226
  kind: "mutation",
26977
27227
  auth: "admin"
26978
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
27228
+ }), 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, {
26979
27229
  kind: "mutation",
26980
27230
  auth: "admin"
26981
27231
  });
@@ -27889,6 +28139,12 @@ Object.freeze({
27889
28139
  addonId: null,
27890
28140
  access: "view"
27891
28141
  },
28142
+ "addonSettings.getIntegrationSettings": {
28143
+ capName: "addon-settings",
28144
+ capScope: "system",
28145
+ addonId: null,
28146
+ access: "view"
28147
+ },
27892
28148
  "addonSettings.updateDeviceSettings": {
27893
28149
  capName: "addon-settings",
27894
28150
  capScope: "system",
@@ -29551,6 +29807,12 @@ Object.freeze({
29551
29807
  addonId: null,
29552
29808
  access: "create"
29553
29809
  },
29810
+ "failureContribution.list": {
29811
+ capName: "failure-contribution",
29812
+ capScope: "system",
29813
+ addonId: null,
29814
+ access: "view"
29815
+ },
29554
29816
  "fanControl.setDirection": {
29555
29817
  capName: "fan-control",
29556
29818
  capScope: "device",
@@ -32857,6 +33119,12 @@ Object.freeze({
32857
33119
  addonId: null,
32858
33120
  access: "create"
32859
33121
  },
33122
+ "system.getFailureContributions": {
33123
+ capName: "system",
33124
+ capScope: "system",
33125
+ addonId: null,
33126
+ access: "view"
33127
+ },
32860
33128
  "system.getLoadContributions": {
32861
33129
  capName: "system",
32862
33130
  capScope: "system",
@@ -5956,6 +5956,40 @@ var BaseAddon = class {
5956
5956
  deviceSettingsSchema() {
5957
5957
  return null;
5958
5958
  }
5959
+ /**
5960
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5961
+ * ARE the configuration of its integration.
5962
+ *
5963
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5964
+ * operator should find on the addon's integration page (System →
5965
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5966
+ * addon. Empty (the default) means the addon has no integration-level
5967
+ * settings and no such surface is offered — this is opt-in, because whether
5968
+ * an addon's configuration IS its integration's configuration depends on the
5969
+ * nature of the integration.
5970
+ *
5971
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5972
+ * the ONE global schema, in the ONE addon store, written by the ONE
5973
+ * `updateGlobalSettings` path. There is deliberately no
5974
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5975
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5976
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5977
+ *
5978
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5979
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5980
+ * removed with the reason recorded at
5981
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5982
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5983
+ * marker sprinkled across sections also has to borrow a field that already
5984
+ * means something else; borrowing `section.tab` put the literal word
5985
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5986
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5987
+ * supersedes D268). One declaration, in one place, next to the schema whose
5988
+ * ids it names.
5989
+ */
5990
+ integrationSettingSections() {
5991
+ return [];
5992
+ }
5959
5993
  async getGlobalSettings(overlay, cap, nodeId) {
5960
5994
  const schema = this.globalSettingsSchema(cap);
5961
5995
  if (!schema) return { sections: [] };
@@ -5966,6 +6000,55 @@ var BaseAddon = class {
5966
6000
  } : projected);
5967
6001
  }
5968
6002
  /**
6003
+ * The integration-level view of this addon's settings: exactly the sections
6004
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
6005
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
6006
+ *
6007
+ * Returns `null` when the addon declared nothing — an addon that opts out has
6008
+ * no integration settings surface at all, rather than an empty one that reads
6009
+ * as a failed load.
6010
+ *
6011
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
6012
+ * and not in whichever UI happens to render this:
6013
+ *
6014
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
6015
+ * shown here is the same field, with the same bare key, that the addon's
6016
+ * own page shows. There is no integration-specific writer — callers save
6017
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6018
+ * not merely discouraged.
6019
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6020
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6021
+ * such a field silently picked would be a wrong answer for the operator
6022
+ * who opened the page (D266).
6023
+ * 3. **No silent typo.** A declared id that names no section throws. The
6024
+ * alternative — skip it — turns a rename into a surface that quietly
6025
+ * empties, which looks exactly like an addon with nothing to configure.
6026
+ */
6027
+ async getIntegrationSettings(nodeId) {
6028
+ const declared = this.integrationSettingSections();
6029
+ if (declared.length === 0) return null;
6030
+ const schema = this.globalSettingsSchema();
6031
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6032
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6033
+ const sections = [];
6034
+ for (const id of declared) {
6035
+ const section = byId.get(id);
6036
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6037
+ const fields = dropPerNodeFields(section.fields);
6038
+ if (fields.length === 0) continue;
6039
+ sections.push({
6040
+ ...section,
6041
+ fields
6042
+ });
6043
+ }
6044
+ if (sections.length === 0) return null;
6045
+ const projected = await this.resolveGlobalStore(nodeId);
6046
+ return hydrateSchema({
6047
+ ...schema,
6048
+ sections
6049
+ }, projected);
6050
+ }
6051
+ /**
5969
6052
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5970
6053
  * every `perNode: true` field carries THAT node's scoped value on its bare
5971
6054
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6269,6 +6352,41 @@ var BaseAddon = class {
6269
6352
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6270
6353
  * don't declare `perNode` and are excluded by the `in` narrowing.
6271
6354
  */
6355
+ /**
6356
+ * The same fields with every `perNode: true` one removed, recursing into layout
6357
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6358
+ * with no child is dropped rather than rendered empty.
6359
+ *
6360
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6361
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6362
+ */
6363
+ function dropPerNodeFields(fields) {
6364
+ const kept = [];
6365
+ for (const field of fields) {
6366
+ if (field.type === "group") {
6367
+ const inner = dropPerNodeFields(field.fields);
6368
+ if (inner.length > 0) kept.push({
6369
+ ...field,
6370
+ fields: inner
6371
+ });
6372
+ continue;
6373
+ }
6374
+ if (field.type === "sub-tabs") {
6375
+ const tabs = field.tabs.map((tab) => ({
6376
+ ...tab,
6377
+ fields: dropPerNodeFields(tab.fields)
6378
+ })).filter((tab) => tab.fields.length > 0);
6379
+ if (tabs.length > 0) kept.push({
6380
+ ...field,
6381
+ tabs
6382
+ });
6383
+ continue;
6384
+ }
6385
+ if ("perNode" in field && field.perNode === true) continue;
6386
+ kept.push(field);
6387
+ }
6388
+ return kept;
6389
+ }
6272
6390
  function collectPerNodeFieldKeys(fields) {
6273
6391
  const collected = [];
6274
6392
  for (const field of fields) {
@@ -9422,6 +9540,9 @@ method(object({
9422
9540
  kind: "mutation",
9423
9541
  auth: "admin"
9424
9542
  }), method(object({
9543
+ addonId: string(),
9544
+ nodeId: string().optional()
9545
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9425
9546
  addonId: string(),
9426
9547
  deviceId: number(),
9427
9548
  nodeId: string().optional()
@@ -13155,6 +13276,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13155
13276
  limit: number().optional(),
13156
13277
  tags: record(string(), string()).optional()
13157
13278
  }), array(LogEntrySchema).readonly());
13279
+ /**
13280
+ * `failure-contribution` — the capability an addon reports its OWN losses
13281
+ * through, per camera, with the denominator attached. It stores nothing.
13282
+ *
13283
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13284
+ *
13285
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13286
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13287
+ * copied: the contributor reports what it already knows, hub-main adds only
13288
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13289
+ * somebody to forget to edit.
13290
+ *
13291
+ * They are not merged, because their invariants are opposites:
13292
+ *
13293
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13294
+ * claim a camera cost nothing, which is a measurement nobody made;
13295
+ * - a `failure-contribution` zero is the **most valuable value on the
13296
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13297
+ * and it is exactly what an absent entry cannot say.
13298
+ *
13299
+ * Putting a loss counter on a cost entry would also break the reconciliation
13300
+ * that gives `load-contribution` its point: contributions are subtracted from
13301
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13302
+ * has no process.
13303
+ *
13304
+ * ## Why not a log line, since the counters already exist
13305
+ *
13306
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13307
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13308
+ * ends in a log line, and a log line is the thing the operator asked to stop
13309
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13310
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13311
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13312
+ * media blackout were both diagnosed. The counters stay; this is where they can
13313
+ * be READ.
13314
+ *
13315
+ * ## The rate is served with its denominator or not at all
13316
+ *
13317
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13318
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13319
+ * than yesterday" and was **flat across twelve hours** once divided by the
13320
+ * successes on the same path. A surface that publishes only the numerator
13321
+ * reproduces that mistake on every read.
13322
+ *
13323
+ * ## Shape
13324
+ *
13325
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13326
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13327
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13328
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13329
+ * a forked runner's entries reach hub-main over transport that already exists.
13330
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13331
+ * result through `system.getFailureContributions`.
13332
+ */
13333
+ var FailureReasonCountSchema = object({
13334
+ /**
13335
+ * Why the attempt did not land, in the contributor's own vocabulary —
13336
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13337
+ * strings that already appear in this repo's logs and, where one exists, the
13338
+ * same string the per-track `previewMissReason` records (D276): a second
13339
+ * vocabulary for the same loss would make the row and the counter
13340
+ * un-joinable.
13341
+ */
13342
+ reason: string(),
13343
+ count: number().int().nonnegative()
13344
+ });
13345
+ var FailureContributionSchema = object({
13346
+ /**
13347
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13348
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13349
+ * `unit` free: the families are owned by different addons and a shared enum
13350
+ * is a central list that rots invisibly.
13351
+ */
13352
+ family: string(),
13353
+ /**
13354
+ * The NUMERIC device id — the same value every log line carries as
13355
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13356
+ * cannot name the camera must not emit the entry, because a fleet total
13357
+ * cannot answer the only question anybody asks of this surface.
13358
+ */
13359
+ deviceId: number().int().positive(),
13360
+ /**
13361
+ * A second dimension inside the family: the model / step id for an inference
13362
+ * timeout, so "which camera AND which model" is one read. Absent when the
13363
+ * family has a single variant.
13364
+ */
13365
+ variant: string().optional(),
13366
+ /**
13367
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13368
+ * differencing two reads must drop the interval when it changes, because the
13369
+ * counter restarted from zero in a respawned runner. Same discipline as
13370
+ * `LoadContribution.startedAtMs`.
13371
+ */
13372
+ sinceMs: number(),
13373
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13374
+ atMs: number(),
13375
+ /**
13376
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13377
+ * window. A failure count published without it is the mistake this schema
13378
+ * exists to make impossible.
13379
+ */
13380
+ attempts: number().int().nonnegative(),
13381
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13382
+ succeeded: number().int().nonnegative(),
13383
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13384
+ reasons: array(FailureReasonCountSchema).readonly()
13385
+ });
13386
+ method(_void(), array(FailureContributionSchema).readonly());
13158
13387
  var LoadContributionSchema = object({
13159
13388
  role: _enum([
13160
13389
  "decode",
@@ -17686,6 +17915,20 @@ var TrackSchema = object({
17686
17915
  * `=== true` and render nothing otherwise — never infer "no rider".
17687
17916
  */
17688
17917
  hasRider: boolean().optional(),
17918
+ /**
17919
+ * WHY this track ended without a NATIVE best-shot tile
17920
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
17921
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
17922
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
17923
+ * the late-keyFrame upgrade when a native tile lands after all. The
17924
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
17925
+ * tile is a face/plate stand-in, a raster crop, or an icon.
17926
+ *
17927
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
17928
+ * that predates the field, and every track whose tile landed native all
17929
+ * omit it. Render nothing when absent.
17930
+ */
17931
+ previewMissReason: string().optional(),
17689
17932
  ...TrackFlagFields,
17690
17933
  ...TrackRetrainFields
17691
17934
  });
@@ -26912,6 +27155,13 @@ var LoggingSettingsPatchSchema = object({
26912
27155
  * anyone but its owner.
26913
27156
  */
26914
27157
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
27158
+ /**
27159
+ * One per-camera failure counter, plus WHO reported it.
27160
+ *
27161
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
27162
+ * the hub as it enumerates providers, never by the contributor.
27163
+ */
27164
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
26915
27165
  var GetLoggingSettingsInputSchema = object({
26916
27166
  scopeNodeId: string().optional(),
26917
27167
  /**
@@ -26970,7 +27220,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
26970
27220
  }), method(_void(), SiteLocationStatusSchema, {
26971
27221
  kind: "mutation",
26972
27222
  auth: "admin"
26973
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
27223
+ }), 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, {
26974
27224
  kind: "mutation",
26975
27225
  auth: "admin"
26976
27226
  });
@@ -27884,6 +28134,12 @@ Object.freeze({
27884
28134
  addonId: null,
27885
28135
  access: "view"
27886
28136
  },
28137
+ "addonSettings.getIntegrationSettings": {
28138
+ capName: "addon-settings",
28139
+ capScope: "system",
28140
+ addonId: null,
28141
+ access: "view"
28142
+ },
27887
28143
  "addonSettings.updateDeviceSettings": {
27888
28144
  capName: "addon-settings",
27889
28145
  capScope: "system",
@@ -29546,6 +29802,12 @@ Object.freeze({
29546
29802
  addonId: null,
29547
29803
  access: "create"
29548
29804
  },
29805
+ "failureContribution.list": {
29806
+ capName: "failure-contribution",
29807
+ capScope: "system",
29808
+ addonId: null,
29809
+ access: "view"
29810
+ },
29549
29811
  "fanControl.setDirection": {
29550
29812
  capName: "fan-control",
29551
29813
  capScope: "device",
@@ -32852,6 +33114,12 @@ Object.freeze({
32852
33114
  addonId: null,
32853
33115
  access: "create"
32854
33116
  },
33117
+ "system.getFailureContributions": {
33118
+ capName: "system",
33119
+ capScope: "system",
33120
+ addonId: null,
33121
+ access: "view"
33122
+ },
32855
33123
  "system.getLoadContributions": {
32856
33124
  capName: "system",
32857
33125
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-mqtt-broker",
3
- "version": "1.2.37",
3
+ "version": "1.2.39",
4
4
  "description": "MQTT broker registry addon for CamStack — manages external broker entries + an optional embedded aedes broker. Consumers spin up their own `mqtt.js` clients via the `mqtt-broker` cap.",
5
5
  "keywords": [
6
6
  "camstack",