@camstack/addon-provider-velux 0.2.37 → 0.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.
package/dist/addon.js CHANGED
@@ -5916,6 +5916,40 @@ var BaseAddon = class {
5916
5916
  deviceSettingsSchema() {
5917
5917
  return null;
5918
5918
  }
5919
+ /**
5920
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5921
+ * ARE the configuration of its integration.
5922
+ *
5923
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5924
+ * operator should find on the addon's integration page (System →
5925
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5926
+ * addon. Empty (the default) means the addon has no integration-level
5927
+ * settings and no such surface is offered — this is opt-in, because whether
5928
+ * an addon's configuration IS its integration's configuration depends on the
5929
+ * nature of the integration.
5930
+ *
5931
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5932
+ * the ONE global schema, in the ONE addon store, written by the ONE
5933
+ * `updateGlobalSettings` path. There is deliberately no
5934
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5935
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5936
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5937
+ *
5938
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5939
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5940
+ * removed with the reason recorded at
5941
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5942
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5943
+ * marker sprinkled across sections also has to borrow a field that already
5944
+ * means something else; borrowing `section.tab` put the literal word
5945
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5946
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5947
+ * supersedes D268). One declaration, in one place, next to the schema whose
5948
+ * ids it names.
5949
+ */
5950
+ integrationSettingSections() {
5951
+ return [];
5952
+ }
5919
5953
  async getGlobalSettings(overlay, cap, nodeId) {
5920
5954
  const schema = this.globalSettingsSchema(cap);
5921
5955
  if (!schema) return { sections: [] };
@@ -5926,6 +5960,55 @@ var BaseAddon = class {
5926
5960
  } : projected);
5927
5961
  }
5928
5962
  /**
5963
+ * The integration-level view of this addon's settings: exactly the sections
5964
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5965
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5966
+ *
5967
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5968
+ * no integration settings surface at all, rather than an empty one that reads
5969
+ * as a failed load.
5970
+ *
5971
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5972
+ * and not in whichever UI happens to render this:
5973
+ *
5974
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5975
+ * shown here is the same field, with the same bare key, that the addon's
5976
+ * own page shows. There is no integration-specific writer — callers save
5977
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5978
+ * not merely discouraged.
5979
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5980
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5981
+ * such a field silently picked would be a wrong answer for the operator
5982
+ * who opened the page (D266).
5983
+ * 3. **No silent typo.** A declared id that names no section throws. The
5984
+ * alternative — skip it — turns a rename into a surface that quietly
5985
+ * empties, which looks exactly like an addon with nothing to configure.
5986
+ */
5987
+ async getIntegrationSettings(nodeId) {
5988
+ const declared = this.integrationSettingSections();
5989
+ if (declared.length === 0) return null;
5990
+ const schema = this.globalSettingsSchema();
5991
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5992
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5993
+ const sections = [];
5994
+ for (const id of declared) {
5995
+ const section = byId.get(id);
5996
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
5997
+ const fields = dropPerNodeFields(section.fields);
5998
+ if (fields.length === 0) continue;
5999
+ sections.push({
6000
+ ...section,
6001
+ fields
6002
+ });
6003
+ }
6004
+ if (sections.length === 0) return null;
6005
+ const projected = await this.resolveGlobalStore(nodeId);
6006
+ return hydrateSchema({
6007
+ ...schema,
6008
+ sections
6009
+ }, projected);
6010
+ }
6011
+ /**
5929
6012
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5930
6013
  * every `perNode: true` field carries THAT node's scoped value on its bare
5931
6014
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6229,6 +6312,41 @@ var BaseAddon = class {
6229
6312
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6230
6313
  * don't declare `perNode` and are excluded by the `in` narrowing.
6231
6314
  */
6315
+ /**
6316
+ * The same fields with every `perNode: true` one removed, recursing into layout
6317
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6318
+ * with no child is dropped rather than rendered empty.
6319
+ *
6320
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6321
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6322
+ */
6323
+ function dropPerNodeFields(fields) {
6324
+ const kept = [];
6325
+ for (const field of fields) {
6326
+ if (field.type === "group") {
6327
+ const inner = dropPerNodeFields(field.fields);
6328
+ if (inner.length > 0) kept.push({
6329
+ ...field,
6330
+ fields: inner
6331
+ });
6332
+ continue;
6333
+ }
6334
+ if (field.type === "sub-tabs") {
6335
+ const tabs = field.tabs.map((tab) => ({
6336
+ ...tab,
6337
+ fields: dropPerNodeFields(tab.fields)
6338
+ })).filter((tab) => tab.fields.length > 0);
6339
+ if (tabs.length > 0) kept.push({
6340
+ ...field,
6341
+ tabs
6342
+ });
6343
+ continue;
6344
+ }
6345
+ if ("perNode" in field && field.perNode === true) continue;
6346
+ kept.push(field);
6347
+ }
6348
+ return kept;
6349
+ }
6232
6350
  function collectPerNodeFieldKeys(fields) {
6233
6351
  const collected = [];
6234
6352
  for (const field of fields) {
@@ -9398,6 +9516,9 @@ method(object({
9398
9516
  kind: "mutation",
9399
9517
  auth: "admin"
9400
9518
  }), method(object({
9519
+ addonId: string(),
9520
+ nodeId: string().optional()
9521
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9401
9522
  addonId: string(),
9402
9523
  deviceId: number(),
9403
9524
  nodeId: string().optional()
@@ -13346,6 +13467,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13346
13467
  limit: number().optional(),
13347
13468
  tags: record(string(), string()).optional()
13348
13469
  }), array(LogEntrySchema).readonly());
13470
+ /**
13471
+ * `failure-contribution` — the capability an addon reports its OWN losses
13472
+ * through, per camera, with the denominator attached. It stores nothing.
13473
+ *
13474
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13475
+ *
13476
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13477
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13478
+ * copied: the contributor reports what it already knows, hub-main adds only
13479
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13480
+ * somebody to forget to edit.
13481
+ *
13482
+ * They are not merged, because their invariants are opposites:
13483
+ *
13484
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13485
+ * claim a camera cost nothing, which is a measurement nobody made;
13486
+ * - a `failure-contribution` zero is the **most valuable value on the
13487
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13488
+ * and it is exactly what an absent entry cannot say.
13489
+ *
13490
+ * Putting a loss counter on a cost entry would also break the reconciliation
13491
+ * that gives `load-contribution` its point: contributions are subtracted from
13492
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13493
+ * has no process.
13494
+ *
13495
+ * ## Why not a log line, since the counters already exist
13496
+ *
13497
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13498
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13499
+ * ends in a log line, and a log line is the thing the operator asked to stop
13500
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13501
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13502
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13503
+ * media blackout were both diagnosed. The counters stay; this is where they can
13504
+ * be READ.
13505
+ *
13506
+ * ## The rate is served with its denominator or not at all
13507
+ *
13508
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13509
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13510
+ * than yesterday" and was **flat across twelve hours** once divided by the
13511
+ * successes on the same path. A surface that publishes only the numerator
13512
+ * reproduces that mistake on every read.
13513
+ *
13514
+ * ## Shape
13515
+ *
13516
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13517
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13518
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13519
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13520
+ * a forked runner's entries reach hub-main over transport that already exists.
13521
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13522
+ * result through `system.getFailureContributions`.
13523
+ */
13524
+ var FailureReasonCountSchema = object({
13525
+ /**
13526
+ * Why the attempt did not land, in the contributor's own vocabulary —
13527
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13528
+ * strings that already appear in this repo's logs and, where one exists, the
13529
+ * same string the per-track `previewMissReason` records (D276): a second
13530
+ * vocabulary for the same loss would make the row and the counter
13531
+ * un-joinable.
13532
+ */
13533
+ reason: string(),
13534
+ count: number().int().nonnegative()
13535
+ });
13536
+ var FailureContributionSchema = object({
13537
+ /**
13538
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13539
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13540
+ * `unit` free: the families are owned by different addons and a shared enum
13541
+ * is a central list that rots invisibly.
13542
+ */
13543
+ family: string(),
13544
+ /**
13545
+ * The NUMERIC device id — the same value every log line carries as
13546
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13547
+ * cannot name the camera must not emit the entry, because a fleet total
13548
+ * cannot answer the only question anybody asks of this surface.
13549
+ */
13550
+ deviceId: number().int().positive(),
13551
+ /**
13552
+ * A second dimension inside the family: the model / step id for an inference
13553
+ * timeout, so "which camera AND which model" is one read. Absent when the
13554
+ * family has a single variant.
13555
+ */
13556
+ variant: string().optional(),
13557
+ /**
13558
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13559
+ * differencing two reads must drop the interval when it changes, because the
13560
+ * counter restarted from zero in a respawned runner. Same discipline as
13561
+ * `LoadContribution.startedAtMs`.
13562
+ */
13563
+ sinceMs: number(),
13564
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13565
+ atMs: number(),
13566
+ /**
13567
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13568
+ * window. A failure count published without it is the mistake this schema
13569
+ * exists to make impossible.
13570
+ */
13571
+ attempts: number().int().nonnegative(),
13572
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13573
+ succeeded: number().int().nonnegative(),
13574
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13575
+ reasons: array(FailureReasonCountSchema).readonly()
13576
+ });
13577
+ method(_void(), array(FailureContributionSchema).readonly());
13349
13578
  var LoadContributionSchema = object({
13350
13579
  role: _enum([
13351
13580
  "decode",
@@ -17936,6 +18165,20 @@ var TrackSchema = object({
17936
18165
  * `=== true` and render nothing otherwise — never infer "no rider".
17937
18166
  */
17938
18167
  hasRider: boolean().optional(),
18168
+ /**
18169
+ * WHY this track ended without a NATIVE best-shot tile
18170
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18171
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18172
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18173
+ * the late-keyFrame upgrade when a native tile lands after all. The
18174
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18175
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18176
+ *
18177
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18178
+ * that predates the field, and every track whose tile landed native all
18179
+ * omit it. Render nothing when absent.
18180
+ */
18181
+ previewMissReason: string().optional(),
17939
18182
  ...TrackFlagFields,
17940
18183
  ...TrackRetrainFields
17941
18184
  });
@@ -29111,6 +29354,13 @@ var LoggingSettingsPatchSchema = object({
29111
29354
  * anyone but its owner.
29112
29355
  */
29113
29356
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29357
+ /**
29358
+ * One per-camera failure counter, plus WHO reported it.
29359
+ *
29360
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29361
+ * the hub as it enumerates providers, never by the contributor.
29362
+ */
29363
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29114
29364
  var GetLoggingSettingsInputSchema = object({
29115
29365
  scopeNodeId: string().optional(),
29116
29366
  /**
@@ -29169,7 +29419,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29169
29419
  }), method(_void(), SiteLocationStatusSchema, {
29170
29420
  kind: "mutation",
29171
29421
  auth: "admin"
29172
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29422
+ }), 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, {
29173
29423
  kind: "mutation",
29174
29424
  auth: "admin"
29175
29425
  });
@@ -31491,6 +31741,12 @@ Object.freeze({
31491
31741
  addonId: null,
31492
31742
  access: "view"
31493
31743
  },
31744
+ "addonSettings.getIntegrationSettings": {
31745
+ capName: "addon-settings",
31746
+ capScope: "system",
31747
+ addonId: null,
31748
+ access: "view"
31749
+ },
31494
31750
  "addonSettings.updateDeviceSettings": {
31495
31751
  capName: "addon-settings",
31496
31752
  capScope: "system",
@@ -33153,6 +33409,12 @@ Object.freeze({
33153
33409
  addonId: null,
33154
33410
  access: "create"
33155
33411
  },
33412
+ "failureContribution.list": {
33413
+ capName: "failure-contribution",
33414
+ capScope: "system",
33415
+ addonId: null,
33416
+ access: "view"
33417
+ },
33156
33418
  "fanControl.setDirection": {
33157
33419
  capName: "fan-control",
33158
33420
  capScope: "device",
@@ -36459,6 +36721,12 @@ Object.freeze({
36459
36721
  addonId: null,
36460
36722
  access: "create"
36461
36723
  },
36724
+ "system.getFailureContributions": {
36725
+ capName: "system",
36726
+ capScope: "system",
36727
+ addonId: null,
36728
+ access: "view"
36729
+ },
36462
36730
  "system.getLoadContributions": {
36463
36731
  capName: "system",
36464
36732
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5915,6 +5915,40 @@ var BaseAddon = class {
5915
5915
  deviceSettingsSchema() {
5916
5916
  return null;
5917
5917
  }
5918
+ /**
5919
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5920
+ * ARE the configuration of its integration.
5921
+ *
5922
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5923
+ * operator should find on the addon's integration page (System →
5924
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5925
+ * addon. Empty (the default) means the addon has no integration-level
5926
+ * settings and no such surface is offered — this is opt-in, because whether
5927
+ * an addon's configuration IS its integration's configuration depends on the
5928
+ * nature of the integration.
5929
+ *
5930
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5931
+ * the ONE global schema, in the ONE addon store, written by the ONE
5932
+ * `updateGlobalSettings` path. There is deliberately no
5933
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5934
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5935
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5936
+ *
5937
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5938
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5939
+ * removed with the reason recorded at
5940
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5941
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5942
+ * marker sprinkled across sections also has to borrow a field that already
5943
+ * means something else; borrowing `section.tab` put the literal word
5944
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5945
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5946
+ * supersedes D268). One declaration, in one place, next to the schema whose
5947
+ * ids it names.
5948
+ */
5949
+ integrationSettingSections() {
5950
+ return [];
5951
+ }
5918
5952
  async getGlobalSettings(overlay, cap, nodeId) {
5919
5953
  const schema = this.globalSettingsSchema(cap);
5920
5954
  if (!schema) return { sections: [] };
@@ -5925,6 +5959,55 @@ var BaseAddon = class {
5925
5959
  } : projected);
5926
5960
  }
5927
5961
  /**
5962
+ * The integration-level view of this addon's settings: exactly the sections
5963
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5964
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5965
+ *
5966
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5967
+ * no integration settings surface at all, rather than an empty one that reads
5968
+ * as a failed load.
5969
+ *
5970
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5971
+ * and not in whichever UI happens to render this:
5972
+ *
5973
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5974
+ * shown here is the same field, with the same bare key, that the addon's
5975
+ * own page shows. There is no integration-specific writer — callers save
5976
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5977
+ * not merely discouraged.
5978
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5979
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5980
+ * such a field silently picked would be a wrong answer for the operator
5981
+ * who opened the page (D266).
5982
+ * 3. **No silent typo.** A declared id that names no section throws. The
5983
+ * alternative — skip it — turns a rename into a surface that quietly
5984
+ * empties, which looks exactly like an addon with nothing to configure.
5985
+ */
5986
+ async getIntegrationSettings(nodeId) {
5987
+ const declared = this.integrationSettingSections();
5988
+ if (declared.length === 0) return null;
5989
+ const schema = this.globalSettingsSchema();
5990
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5991
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5992
+ const sections = [];
5993
+ for (const id of declared) {
5994
+ const section = byId.get(id);
5995
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
5996
+ const fields = dropPerNodeFields(section.fields);
5997
+ if (fields.length === 0) continue;
5998
+ sections.push({
5999
+ ...section,
6000
+ fields
6001
+ });
6002
+ }
6003
+ if (sections.length === 0) return null;
6004
+ const projected = await this.resolveGlobalStore(nodeId);
6005
+ return hydrateSchema({
6006
+ ...schema,
6007
+ sections
6008
+ }, projected);
6009
+ }
6010
+ /**
5928
6011
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5929
6012
  * every `perNode: true` field carries THAT node's scoped value on its bare
5930
6013
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6228,6 +6311,41 @@ var BaseAddon = class {
6228
6311
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6229
6312
  * don't declare `perNode` and are excluded by the `in` narrowing.
6230
6313
  */
6314
+ /**
6315
+ * The same fields with every `perNode: true` one removed, recursing into layout
6316
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6317
+ * with no child is dropped rather than rendered empty.
6318
+ *
6319
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6320
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6321
+ */
6322
+ function dropPerNodeFields(fields) {
6323
+ const kept = [];
6324
+ for (const field of fields) {
6325
+ if (field.type === "group") {
6326
+ const inner = dropPerNodeFields(field.fields);
6327
+ if (inner.length > 0) kept.push({
6328
+ ...field,
6329
+ fields: inner
6330
+ });
6331
+ continue;
6332
+ }
6333
+ if (field.type === "sub-tabs") {
6334
+ const tabs = field.tabs.map((tab) => ({
6335
+ ...tab,
6336
+ fields: dropPerNodeFields(tab.fields)
6337
+ })).filter((tab) => tab.fields.length > 0);
6338
+ if (tabs.length > 0) kept.push({
6339
+ ...field,
6340
+ tabs
6341
+ });
6342
+ continue;
6343
+ }
6344
+ if ("perNode" in field && field.perNode === true) continue;
6345
+ kept.push(field);
6346
+ }
6347
+ return kept;
6348
+ }
6231
6349
  function collectPerNodeFieldKeys(fields) {
6232
6350
  const collected = [];
6233
6351
  for (const field of fields) {
@@ -9397,6 +9515,9 @@ method(object({
9397
9515
  kind: "mutation",
9398
9516
  auth: "admin"
9399
9517
  }), method(object({
9518
+ addonId: string(),
9519
+ nodeId: string().optional()
9520
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9400
9521
  addonId: string(),
9401
9522
  deviceId: number(),
9402
9523
  nodeId: string().optional()
@@ -13345,6 +13466,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13345
13466
  limit: number().optional(),
13346
13467
  tags: record(string(), string()).optional()
13347
13468
  }), array(LogEntrySchema).readonly());
13469
+ /**
13470
+ * `failure-contribution` — the capability an addon reports its OWN losses
13471
+ * through, per camera, with the denominator attached. It stores nothing.
13472
+ *
13473
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13474
+ *
13475
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13476
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13477
+ * copied: the contributor reports what it already knows, hub-main adds only
13478
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13479
+ * somebody to forget to edit.
13480
+ *
13481
+ * They are not merged, because their invariants are opposites:
13482
+ *
13483
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13484
+ * claim a camera cost nothing, which is a measurement nobody made;
13485
+ * - a `failure-contribution` zero is the **most valuable value on the
13486
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13487
+ * and it is exactly what an absent entry cannot say.
13488
+ *
13489
+ * Putting a loss counter on a cost entry would also break the reconciliation
13490
+ * that gives `load-contribution` its point: contributions are subtracted from
13491
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13492
+ * has no process.
13493
+ *
13494
+ * ## Why not a log line, since the counters already exist
13495
+ *
13496
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13497
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13498
+ * ends in a log line, and a log line is the thing the operator asked to stop
13499
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13500
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13501
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13502
+ * media blackout were both diagnosed. The counters stay; this is where they can
13503
+ * be READ.
13504
+ *
13505
+ * ## The rate is served with its denominator or not at all
13506
+ *
13507
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13508
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13509
+ * than yesterday" and was **flat across twelve hours** once divided by the
13510
+ * successes on the same path. A surface that publishes only the numerator
13511
+ * reproduces that mistake on every read.
13512
+ *
13513
+ * ## Shape
13514
+ *
13515
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13516
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13517
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13518
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13519
+ * a forked runner's entries reach hub-main over transport that already exists.
13520
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13521
+ * result through `system.getFailureContributions`.
13522
+ */
13523
+ var FailureReasonCountSchema = object({
13524
+ /**
13525
+ * Why the attempt did not land, in the contributor's own vocabulary —
13526
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13527
+ * strings that already appear in this repo's logs and, where one exists, the
13528
+ * same string the per-track `previewMissReason` records (D276): a second
13529
+ * vocabulary for the same loss would make the row and the counter
13530
+ * un-joinable.
13531
+ */
13532
+ reason: string(),
13533
+ count: number().int().nonnegative()
13534
+ });
13535
+ var FailureContributionSchema = object({
13536
+ /**
13537
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13538
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13539
+ * `unit` free: the families are owned by different addons and a shared enum
13540
+ * is a central list that rots invisibly.
13541
+ */
13542
+ family: string(),
13543
+ /**
13544
+ * The NUMERIC device id — the same value every log line carries as
13545
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13546
+ * cannot name the camera must not emit the entry, because a fleet total
13547
+ * cannot answer the only question anybody asks of this surface.
13548
+ */
13549
+ deviceId: number().int().positive(),
13550
+ /**
13551
+ * A second dimension inside the family: the model / step id for an inference
13552
+ * timeout, so "which camera AND which model" is one read. Absent when the
13553
+ * family has a single variant.
13554
+ */
13555
+ variant: string().optional(),
13556
+ /**
13557
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13558
+ * differencing two reads must drop the interval when it changes, because the
13559
+ * counter restarted from zero in a respawned runner. Same discipline as
13560
+ * `LoadContribution.startedAtMs`.
13561
+ */
13562
+ sinceMs: number(),
13563
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13564
+ atMs: number(),
13565
+ /**
13566
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13567
+ * window. A failure count published without it is the mistake this schema
13568
+ * exists to make impossible.
13569
+ */
13570
+ attempts: number().int().nonnegative(),
13571
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13572
+ succeeded: number().int().nonnegative(),
13573
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13574
+ reasons: array(FailureReasonCountSchema).readonly()
13575
+ });
13576
+ method(_void(), array(FailureContributionSchema).readonly());
13348
13577
  var LoadContributionSchema = object({
13349
13578
  role: _enum([
13350
13579
  "decode",
@@ -17935,6 +18164,20 @@ var TrackSchema = object({
17935
18164
  * `=== true` and render nothing otherwise — never infer "no rider".
17936
18165
  */
17937
18166
  hasRider: boolean().optional(),
18167
+ /**
18168
+ * WHY this track ended without a NATIVE best-shot tile
18169
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18170
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18171
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18172
+ * the late-keyFrame upgrade when a native tile lands after all. The
18173
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18174
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18175
+ *
18176
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18177
+ * that predates the field, and every track whose tile landed native all
18178
+ * omit it. Render nothing when absent.
18179
+ */
18180
+ previewMissReason: string().optional(),
17938
18181
  ...TrackFlagFields,
17939
18182
  ...TrackRetrainFields
17940
18183
  });
@@ -29110,6 +29353,13 @@ var LoggingSettingsPatchSchema = object({
29110
29353
  * anyone but its owner.
29111
29354
  */
29112
29355
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29356
+ /**
29357
+ * One per-camera failure counter, plus WHO reported it.
29358
+ *
29359
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29360
+ * the hub as it enumerates providers, never by the contributor.
29361
+ */
29362
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29113
29363
  var GetLoggingSettingsInputSchema = object({
29114
29364
  scopeNodeId: string().optional(),
29115
29365
  /**
@@ -29168,7 +29418,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29168
29418
  }), method(_void(), SiteLocationStatusSchema, {
29169
29419
  kind: "mutation",
29170
29420
  auth: "admin"
29171
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29421
+ }), 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, {
29172
29422
  kind: "mutation",
29173
29423
  auth: "admin"
29174
29424
  });
@@ -31490,6 +31740,12 @@ Object.freeze({
31490
31740
  addonId: null,
31491
31741
  access: "view"
31492
31742
  },
31743
+ "addonSettings.getIntegrationSettings": {
31744
+ capName: "addon-settings",
31745
+ capScope: "system",
31746
+ addonId: null,
31747
+ access: "view"
31748
+ },
31493
31749
  "addonSettings.updateDeviceSettings": {
31494
31750
  capName: "addon-settings",
31495
31751
  capScope: "system",
@@ -33152,6 +33408,12 @@ Object.freeze({
33152
33408
  addonId: null,
33153
33409
  access: "create"
33154
33410
  },
33411
+ "failureContribution.list": {
33412
+ capName: "failure-contribution",
33413
+ capScope: "system",
33414
+ addonId: null,
33415
+ access: "view"
33416
+ },
33155
33417
  "fanControl.setDirection": {
33156
33418
  capName: "fan-control",
33157
33419
  capScope: "device",
@@ -36458,6 +36720,12 @@ Object.freeze({
36458
36720
  addonId: null,
36459
36721
  access: "create"
36460
36722
  },
36723
+ "system.getFailureContributions": {
36724
+ capName: "system",
36725
+ capScope: "system",
36726
+ addonId: null,
36727
+ access: "view"
36728
+ },
36461
36729
  "system.getLoadContributions": {
36462
36730
  capName: "system",
36463
36731
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-velux",
3
- "version": "0.2.37",
3
+ "version": "0.2.39",
4
4
  "description": "Velux KLF-200 device-provider addon for CamStack — local-gateway window + shutter covers (positional, no tilt)",
5
5
  "keywords": [
6
6
  "camstack",