@camstack/addon-provider-onvif 1.2.36 → 1.2.38

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
@@ -5919,6 +5919,40 @@ var BaseAddon = class {
5919
5919
  deviceSettingsSchema() {
5920
5920
  return null;
5921
5921
  }
5922
+ /**
5923
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5924
+ * ARE the configuration of its integration.
5925
+ *
5926
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5927
+ * operator should find on the addon's integration page (System →
5928
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5929
+ * addon. Empty (the default) means the addon has no integration-level
5930
+ * settings and no such surface is offered — this is opt-in, because whether
5931
+ * an addon's configuration IS its integration's configuration depends on the
5932
+ * nature of the integration.
5933
+ *
5934
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5935
+ * the ONE global schema, in the ONE addon store, written by the ONE
5936
+ * `updateGlobalSettings` path. There is deliberately no
5937
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5938
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5939
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5940
+ *
5941
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5942
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5943
+ * removed with the reason recorded at
5944
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5945
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5946
+ * marker sprinkled across sections also has to borrow a field that already
5947
+ * means something else; borrowing `section.tab` put the literal word
5948
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5949
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5950
+ * supersedes D268). One declaration, in one place, next to the schema whose
5951
+ * ids it names.
5952
+ */
5953
+ integrationSettingSections() {
5954
+ return [];
5955
+ }
5922
5956
  async getGlobalSettings(overlay, cap, nodeId) {
5923
5957
  const schema = this.globalSettingsSchema(cap);
5924
5958
  if (!schema) return { sections: [] };
@@ -5929,6 +5963,55 @@ var BaseAddon = class {
5929
5963
  } : projected);
5930
5964
  }
5931
5965
  /**
5966
+ * The integration-level view of this addon's settings: exactly the sections
5967
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5968
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5969
+ *
5970
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5971
+ * no integration settings surface at all, rather than an empty one that reads
5972
+ * as a failed load.
5973
+ *
5974
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5975
+ * and not in whichever UI happens to render this:
5976
+ *
5977
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5978
+ * shown here is the same field, with the same bare key, that the addon's
5979
+ * own page shows. There is no integration-specific writer — callers save
5980
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5981
+ * not merely discouraged.
5982
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5983
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5984
+ * such a field silently picked would be a wrong answer for the operator
5985
+ * who opened the page (D266).
5986
+ * 3. **No silent typo.** A declared id that names no section throws. The
5987
+ * alternative — skip it — turns a rename into a surface that quietly
5988
+ * empties, which looks exactly like an addon with nothing to configure.
5989
+ */
5990
+ async getIntegrationSettings(nodeId) {
5991
+ const declared = this.integrationSettingSections();
5992
+ if (declared.length === 0) return null;
5993
+ const schema = this.globalSettingsSchema();
5994
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5995
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5996
+ const sections = [];
5997
+ for (const id of declared) {
5998
+ const section = byId.get(id);
5999
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6000
+ const fields = dropPerNodeFields(section.fields);
6001
+ if (fields.length === 0) continue;
6002
+ sections.push({
6003
+ ...section,
6004
+ fields
6005
+ });
6006
+ }
6007
+ if (sections.length === 0) return null;
6008
+ const projected = await this.resolveGlobalStore(nodeId);
6009
+ return hydrateSchema({
6010
+ ...schema,
6011
+ sections
6012
+ }, projected);
6013
+ }
6014
+ /**
5932
6015
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5933
6016
  * every `perNode: true` field carries THAT node's scoped value on its bare
5934
6017
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6232,6 +6315,41 @@ var BaseAddon = class {
6232
6315
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6233
6316
  * don't declare `perNode` and are excluded by the `in` narrowing.
6234
6317
  */
6318
+ /**
6319
+ * The same fields with every `perNode: true` one removed, recursing into layout
6320
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6321
+ * with no child is dropped rather than rendered empty.
6322
+ *
6323
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6324
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6325
+ */
6326
+ function dropPerNodeFields(fields) {
6327
+ const kept = [];
6328
+ for (const field of fields) {
6329
+ if (field.type === "group") {
6330
+ const inner = dropPerNodeFields(field.fields);
6331
+ if (inner.length > 0) kept.push({
6332
+ ...field,
6333
+ fields: inner
6334
+ });
6335
+ continue;
6336
+ }
6337
+ if (field.type === "sub-tabs") {
6338
+ const tabs = field.tabs.map((tab) => ({
6339
+ ...tab,
6340
+ fields: dropPerNodeFields(tab.fields)
6341
+ })).filter((tab) => tab.fields.length > 0);
6342
+ if (tabs.length > 0) kept.push({
6343
+ ...field,
6344
+ tabs
6345
+ });
6346
+ continue;
6347
+ }
6348
+ if ("perNode" in field && field.perNode === true) continue;
6349
+ kept.push(field);
6350
+ }
6351
+ return kept;
6352
+ }
6235
6353
  function collectPerNodeFieldKeys(fields) {
6236
6354
  const collected = [];
6237
6355
  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()
@@ -13136,6 +13257,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13136
13257
  limit: number().optional(),
13137
13258
  tags: record(string(), string()).optional()
13138
13259
  }), array(LogEntrySchema).readonly());
13260
+ /**
13261
+ * `failure-contribution` — the capability an addon reports its OWN losses
13262
+ * through, per camera, with the denominator attached. It stores nothing.
13263
+ *
13264
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13265
+ *
13266
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13267
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13268
+ * copied: the contributor reports what it already knows, hub-main adds only
13269
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13270
+ * somebody to forget to edit.
13271
+ *
13272
+ * They are not merged, because their invariants are opposites:
13273
+ *
13274
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13275
+ * claim a camera cost nothing, which is a measurement nobody made;
13276
+ * - a `failure-contribution` zero is the **most valuable value on the
13277
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13278
+ * and it is exactly what an absent entry cannot say.
13279
+ *
13280
+ * Putting a loss counter on a cost entry would also break the reconciliation
13281
+ * that gives `load-contribution` its point: contributions are subtracted from
13282
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13283
+ * has no process.
13284
+ *
13285
+ * ## Why not a log line, since the counters already exist
13286
+ *
13287
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13288
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13289
+ * ends in a log line, and a log line is the thing the operator asked to stop
13290
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13291
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13292
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13293
+ * media blackout were both diagnosed. The counters stay; this is where they can
13294
+ * be READ.
13295
+ *
13296
+ * ## The rate is served with its denominator or not at all
13297
+ *
13298
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13299
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13300
+ * than yesterday" and was **flat across twelve hours** once divided by the
13301
+ * successes on the same path. A surface that publishes only the numerator
13302
+ * reproduces that mistake on every read.
13303
+ *
13304
+ * ## Shape
13305
+ *
13306
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13307
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13308
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13309
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13310
+ * a forked runner's entries reach hub-main over transport that already exists.
13311
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13312
+ * result through `system.getFailureContributions`.
13313
+ */
13314
+ var FailureReasonCountSchema = object({
13315
+ /**
13316
+ * Why the attempt did not land, in the contributor's own vocabulary —
13317
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13318
+ * strings that already appear in this repo's logs and, where one exists, the
13319
+ * same string the per-track `previewMissReason` records (D276): a second
13320
+ * vocabulary for the same loss would make the row and the counter
13321
+ * un-joinable.
13322
+ */
13323
+ reason: string(),
13324
+ count: number().int().nonnegative()
13325
+ });
13326
+ var FailureContributionSchema = object({
13327
+ /**
13328
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13329
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13330
+ * `unit` free: the families are owned by different addons and a shared enum
13331
+ * is a central list that rots invisibly.
13332
+ */
13333
+ family: string(),
13334
+ /**
13335
+ * The NUMERIC device id — the same value every log line carries as
13336
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13337
+ * cannot name the camera must not emit the entry, because a fleet total
13338
+ * cannot answer the only question anybody asks of this surface.
13339
+ */
13340
+ deviceId: number().int().positive(),
13341
+ /**
13342
+ * A second dimension inside the family: the model / step id for an inference
13343
+ * timeout, so "which camera AND which model" is one read. Absent when the
13344
+ * family has a single variant.
13345
+ */
13346
+ variant: string().optional(),
13347
+ /**
13348
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13349
+ * differencing two reads must drop the interval when it changes, because the
13350
+ * counter restarted from zero in a respawned runner. Same discipline as
13351
+ * `LoadContribution.startedAtMs`.
13352
+ */
13353
+ sinceMs: number(),
13354
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13355
+ atMs: number(),
13356
+ /**
13357
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13358
+ * window. A failure count published without it is the mistake this schema
13359
+ * exists to make impossible.
13360
+ */
13361
+ attempts: number().int().nonnegative(),
13362
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13363
+ succeeded: number().int().nonnegative(),
13364
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13365
+ reasons: array(FailureReasonCountSchema).readonly()
13366
+ });
13367
+ method(_void(), array(FailureContributionSchema).readonly());
13139
13368
  var LoadContributionSchema = object({
13140
13369
  role: _enum([
13141
13370
  "decode",
@@ -17648,6 +17877,20 @@ var TrackSchema = object({
17648
17877
  * `=== true` and render nothing otherwise — never infer "no rider".
17649
17878
  */
17650
17879
  hasRider: boolean().optional(),
17880
+ /**
17881
+ * WHY this track ended without a NATIVE best-shot tile
17882
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
17883
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
17884
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
17885
+ * the late-keyFrame upgrade when a native tile lands after all. The
17886
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
17887
+ * tile is a face/plate stand-in, a raster crop, or an icon.
17888
+ *
17889
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
17890
+ * that predates the field, and every track whose tile landed native all
17891
+ * omit it. Render nothing when absent.
17892
+ */
17893
+ previewMissReason: string().optional(),
17651
17894
  ...TrackFlagFields,
17652
17895
  ...TrackRetrainFields
17653
17896
  });
@@ -27020,6 +27263,13 @@ var LoggingSettingsPatchSchema = object({
27020
27263
  * anyone but its owner.
27021
27264
  */
27022
27265
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
27266
+ /**
27267
+ * One per-camera failure counter, plus WHO reported it.
27268
+ *
27269
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
27270
+ * the hub as it enumerates providers, never by the contributor.
27271
+ */
27272
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
27023
27273
  var GetLoggingSettingsInputSchema = object({
27024
27274
  scopeNodeId: string().optional(),
27025
27275
  /**
@@ -27078,7 +27328,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
27078
27328
  }), method(_void(), SiteLocationStatusSchema, {
27079
27329
  kind: "mutation",
27080
27330
  auth: "admin"
27081
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
27331
+ }), 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, {
27082
27332
  kind: "mutation",
27083
27333
  auth: "admin"
27084
27334
  });
@@ -28402,6 +28652,12 @@ Object.freeze({
28402
28652
  addonId: null,
28403
28653
  access: "view"
28404
28654
  },
28655
+ "addonSettings.getIntegrationSettings": {
28656
+ capName: "addon-settings",
28657
+ capScope: "system",
28658
+ addonId: null,
28659
+ access: "view"
28660
+ },
28405
28661
  "addonSettings.updateDeviceSettings": {
28406
28662
  capName: "addon-settings",
28407
28663
  capScope: "system",
@@ -30064,6 +30320,12 @@ Object.freeze({
30064
30320
  addonId: null,
30065
30321
  access: "create"
30066
30322
  },
30323
+ "failureContribution.list": {
30324
+ capName: "failure-contribution",
30325
+ capScope: "system",
30326
+ addonId: null,
30327
+ access: "view"
30328
+ },
30067
30329
  "fanControl.setDirection": {
30068
30330
  capName: "fan-control",
30069
30331
  capScope: "device",
@@ -33370,6 +33632,12 @@ Object.freeze({
33370
33632
  addonId: null,
33371
33633
  access: "create"
33372
33634
  },
33635
+ "system.getFailureContributions": {
33636
+ capName: "system",
33637
+ capScope: "system",
33638
+ addonId: null,
33639
+ access: "view"
33640
+ },
33373
33641
  "system.getLoadContributions": {
33374
33642
  capName: "system",
33375
33643
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5920,6 +5920,40 @@ var BaseAddon = class {
5920
5920
  deviceSettingsSchema() {
5921
5921
  return null;
5922
5922
  }
5923
+ /**
5924
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5925
+ * ARE the configuration of its integration.
5926
+ *
5927
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5928
+ * operator should find on the addon's integration page (System →
5929
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5930
+ * addon. Empty (the default) means the addon has no integration-level
5931
+ * settings and no such surface is offered — this is opt-in, because whether
5932
+ * an addon's configuration IS its integration's configuration depends on the
5933
+ * nature of the integration.
5934
+ *
5935
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5936
+ * the ONE global schema, in the ONE addon store, written by the ONE
5937
+ * `updateGlobalSettings` path. There is deliberately no
5938
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5939
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5940
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5941
+ *
5942
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5943
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5944
+ * removed with the reason recorded at
5945
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5946
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5947
+ * marker sprinkled across sections also has to borrow a field that already
5948
+ * means something else; borrowing `section.tab` put the literal word
5949
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5950
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5951
+ * supersedes D268). One declaration, in one place, next to the schema whose
5952
+ * ids it names.
5953
+ */
5954
+ integrationSettingSections() {
5955
+ return [];
5956
+ }
5923
5957
  async getGlobalSettings(overlay, cap, nodeId) {
5924
5958
  const schema = this.globalSettingsSchema(cap);
5925
5959
  if (!schema) return { sections: [] };
@@ -5930,6 +5964,55 @@ var BaseAddon = class {
5930
5964
  } : projected);
5931
5965
  }
5932
5966
  /**
5967
+ * The integration-level view of this addon's settings: exactly the sections
5968
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5969
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5970
+ *
5971
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5972
+ * no integration settings surface at all, rather than an empty one that reads
5973
+ * as a failed load.
5974
+ *
5975
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5976
+ * and not in whichever UI happens to render this:
5977
+ *
5978
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5979
+ * shown here is the same field, with the same bare key, that the addon's
5980
+ * own page shows. There is no integration-specific writer — callers save
5981
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5982
+ * not merely discouraged.
5983
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5984
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5985
+ * such a field silently picked would be a wrong answer for the operator
5986
+ * who opened the page (D266).
5987
+ * 3. **No silent typo.** A declared id that names no section throws. The
5988
+ * alternative — skip it — turns a rename into a surface that quietly
5989
+ * empties, which looks exactly like an addon with nothing to configure.
5990
+ */
5991
+ async getIntegrationSettings(nodeId) {
5992
+ const declared = this.integrationSettingSections();
5993
+ if (declared.length === 0) return null;
5994
+ const schema = this.globalSettingsSchema();
5995
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5996
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
5997
+ const sections = [];
5998
+ for (const id of declared) {
5999
+ const section = byId.get(id);
6000
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6001
+ const fields = dropPerNodeFields(section.fields);
6002
+ if (fields.length === 0) continue;
6003
+ sections.push({
6004
+ ...section,
6005
+ fields
6006
+ });
6007
+ }
6008
+ if (sections.length === 0) return null;
6009
+ const projected = await this.resolveGlobalStore(nodeId);
6010
+ return hydrateSchema({
6011
+ ...schema,
6012
+ sections
6013
+ }, projected);
6014
+ }
6015
+ /**
5933
6016
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5934
6017
  * every `perNode: true` field carries THAT node's scoped value on its bare
5935
6018
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6233,6 +6316,41 @@ var BaseAddon = class {
6233
6316
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6234
6317
  * don't declare `perNode` and are excluded by the `in` narrowing.
6235
6318
  */
6319
+ /**
6320
+ * The same fields with every `perNode: true` one removed, recursing into layout
6321
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6322
+ * with no child is dropped rather than rendered empty.
6323
+ *
6324
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6325
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6326
+ */
6327
+ function dropPerNodeFields(fields) {
6328
+ const kept = [];
6329
+ for (const field of fields) {
6330
+ if (field.type === "group") {
6331
+ const inner = dropPerNodeFields(field.fields);
6332
+ if (inner.length > 0) kept.push({
6333
+ ...field,
6334
+ fields: inner
6335
+ });
6336
+ continue;
6337
+ }
6338
+ if (field.type === "sub-tabs") {
6339
+ const tabs = field.tabs.map((tab) => ({
6340
+ ...tab,
6341
+ fields: dropPerNodeFields(tab.fields)
6342
+ })).filter((tab) => tab.fields.length > 0);
6343
+ if (tabs.length > 0) kept.push({
6344
+ ...field,
6345
+ tabs
6346
+ });
6347
+ continue;
6348
+ }
6349
+ if ("perNode" in field && field.perNode === true) continue;
6350
+ kept.push(field);
6351
+ }
6352
+ return kept;
6353
+ }
6236
6354
  function collectPerNodeFieldKeys(fields) {
6237
6355
  const collected = [];
6238
6356
  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()
@@ -13137,6 +13258,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13137
13258
  limit: number().optional(),
13138
13259
  tags: record(string(), string()).optional()
13139
13260
  }), array(LogEntrySchema).readonly());
13261
+ /**
13262
+ * `failure-contribution` — the capability an addon reports its OWN losses
13263
+ * through, per camera, with the denominator attached. It stores nothing.
13264
+ *
13265
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13266
+ *
13267
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13268
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13269
+ * copied: the contributor reports what it already knows, hub-main adds only
13270
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13271
+ * somebody to forget to edit.
13272
+ *
13273
+ * They are not merged, because their invariants are opposites:
13274
+ *
13275
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13276
+ * claim a camera cost nothing, which is a measurement nobody made;
13277
+ * - a `failure-contribution` zero is the **most valuable value on the
13278
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13279
+ * and it is exactly what an absent entry cannot say.
13280
+ *
13281
+ * Putting a loss counter on a cost entry would also break the reconciliation
13282
+ * that gives `load-contribution` its point: contributions are subtracted from
13283
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13284
+ * has no process.
13285
+ *
13286
+ * ## Why not a log line, since the counters already exist
13287
+ *
13288
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13289
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13290
+ * ends in a log line, and a log line is the thing the operator asked to stop
13291
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13292
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13293
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13294
+ * media blackout were both diagnosed. The counters stay; this is where they can
13295
+ * be READ.
13296
+ *
13297
+ * ## The rate is served with its denominator or not at all
13298
+ *
13299
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13300
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13301
+ * than yesterday" and was **flat across twelve hours** once divided by the
13302
+ * successes on the same path. A surface that publishes only the numerator
13303
+ * reproduces that mistake on every read.
13304
+ *
13305
+ * ## Shape
13306
+ *
13307
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13308
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13309
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13310
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13311
+ * a forked runner's entries reach hub-main over transport that already exists.
13312
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13313
+ * result through `system.getFailureContributions`.
13314
+ */
13315
+ var FailureReasonCountSchema = object({
13316
+ /**
13317
+ * Why the attempt did not land, in the contributor's own vocabulary —
13318
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13319
+ * strings that already appear in this repo's logs and, where one exists, the
13320
+ * same string the per-track `previewMissReason` records (D276): a second
13321
+ * vocabulary for the same loss would make the row and the counter
13322
+ * un-joinable.
13323
+ */
13324
+ reason: string(),
13325
+ count: number().int().nonnegative()
13326
+ });
13327
+ var FailureContributionSchema = object({
13328
+ /**
13329
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13330
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13331
+ * `unit` free: the families are owned by different addons and a shared enum
13332
+ * is a central list that rots invisibly.
13333
+ */
13334
+ family: string(),
13335
+ /**
13336
+ * The NUMERIC device id — the same value every log line carries as
13337
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13338
+ * cannot name the camera must not emit the entry, because a fleet total
13339
+ * cannot answer the only question anybody asks of this surface.
13340
+ */
13341
+ deviceId: number().int().positive(),
13342
+ /**
13343
+ * A second dimension inside the family: the model / step id for an inference
13344
+ * timeout, so "which camera AND which model" is one read. Absent when the
13345
+ * family has a single variant.
13346
+ */
13347
+ variant: string().optional(),
13348
+ /**
13349
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13350
+ * differencing two reads must drop the interval when it changes, because the
13351
+ * counter restarted from zero in a respawned runner. Same discipline as
13352
+ * `LoadContribution.startedAtMs`.
13353
+ */
13354
+ sinceMs: number(),
13355
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13356
+ atMs: number(),
13357
+ /**
13358
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13359
+ * window. A failure count published without it is the mistake this schema
13360
+ * exists to make impossible.
13361
+ */
13362
+ attempts: number().int().nonnegative(),
13363
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13364
+ succeeded: number().int().nonnegative(),
13365
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13366
+ reasons: array(FailureReasonCountSchema).readonly()
13367
+ });
13368
+ method(_void(), array(FailureContributionSchema).readonly());
13140
13369
  var LoadContributionSchema = object({
13141
13370
  role: _enum([
13142
13371
  "decode",
@@ -17649,6 +17878,20 @@ var TrackSchema = object({
17649
17878
  * `=== true` and render nothing otherwise — never infer "no rider".
17650
17879
  */
17651
17880
  hasRider: boolean().optional(),
17881
+ /**
17882
+ * WHY this track ended without a NATIVE best-shot tile
17883
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
17884
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
17885
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
17886
+ * the late-keyFrame upgrade when a native tile lands after all. The
17887
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
17888
+ * tile is a face/plate stand-in, a raster crop, or an icon.
17889
+ *
17890
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
17891
+ * that predates the field, and every track whose tile landed native all
17892
+ * omit it. Render nothing when absent.
17893
+ */
17894
+ previewMissReason: string().optional(),
17652
17895
  ...TrackFlagFields,
17653
17896
  ...TrackRetrainFields
17654
17897
  });
@@ -27021,6 +27264,13 @@ var LoggingSettingsPatchSchema = object({
27021
27264
  * anyone but its owner.
27022
27265
  */
27023
27266
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
27267
+ /**
27268
+ * One per-camera failure counter, plus WHO reported it.
27269
+ *
27270
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
27271
+ * the hub as it enumerates providers, never by the contributor.
27272
+ */
27273
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
27024
27274
  var GetLoggingSettingsInputSchema = object({
27025
27275
  scopeNodeId: string().optional(),
27026
27276
  /**
@@ -27079,7 +27329,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
27079
27329
  }), method(_void(), SiteLocationStatusSchema, {
27080
27330
  kind: "mutation",
27081
27331
  auth: "admin"
27082
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
27332
+ }), 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, {
27083
27333
  kind: "mutation",
27084
27334
  auth: "admin"
27085
27335
  });
@@ -28403,6 +28653,12 @@ Object.freeze({
28403
28653
  addonId: null,
28404
28654
  access: "view"
28405
28655
  },
28656
+ "addonSettings.getIntegrationSettings": {
28657
+ capName: "addon-settings",
28658
+ capScope: "system",
28659
+ addonId: null,
28660
+ access: "view"
28661
+ },
28406
28662
  "addonSettings.updateDeviceSettings": {
28407
28663
  capName: "addon-settings",
28408
28664
  capScope: "system",
@@ -30065,6 +30321,12 @@ Object.freeze({
30065
30321
  addonId: null,
30066
30322
  access: "create"
30067
30323
  },
30324
+ "failureContribution.list": {
30325
+ capName: "failure-contribution",
30326
+ capScope: "system",
30327
+ addonId: null,
30328
+ access: "view"
30329
+ },
30068
30330
  "fanControl.setDirection": {
30069
30331
  capName: "fan-control",
30070
30332
  capScope: "device",
@@ -33371,6 +33633,12 @@ Object.freeze({
33371
33633
  addonId: null,
33372
33634
  access: "create"
33373
33635
  },
33636
+ "system.getFailureContributions": {
33637
+ capName: "system",
33638
+ capScope: "system",
33639
+ addonId: null,
33640
+ access: "view"
33641
+ },
33374
33642
  "system.getLoadContributions": {
33375
33643
  capName: "system",
33376
33644
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-onvif",
3
- "version": "1.2.36",
3
+ "version": "1.2.38",
4
4
  "description": "ONVIF camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",