@camstack/addon-provider-rtsp 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.
package/dist/addon.js CHANGED
@@ -5940,6 +5940,40 @@ var BaseAddon = class {
5940
5940
  deviceSettingsSchema() {
5941
5941
  return null;
5942
5942
  }
5943
+ /**
5944
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5945
+ * ARE the configuration of its integration.
5946
+ *
5947
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5948
+ * operator should find on the addon's integration page (System →
5949
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5950
+ * addon. Empty (the default) means the addon has no integration-level
5951
+ * settings and no such surface is offered — this is opt-in, because whether
5952
+ * an addon's configuration IS its integration's configuration depends on the
5953
+ * nature of the integration.
5954
+ *
5955
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5956
+ * the ONE global schema, in the ONE addon store, written by the ONE
5957
+ * `updateGlobalSettings` path. There is deliberately no
5958
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5959
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5960
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5961
+ *
5962
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5963
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5964
+ * removed with the reason recorded at
5965
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5966
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5967
+ * marker sprinkled across sections also has to borrow a field that already
5968
+ * means something else; borrowing `section.tab` put the literal word
5969
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5970
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5971
+ * supersedes D268). One declaration, in one place, next to the schema whose
5972
+ * ids it names.
5973
+ */
5974
+ integrationSettingSections() {
5975
+ return [];
5976
+ }
5943
5977
  async getGlobalSettings(overlay, cap, nodeId) {
5944
5978
  const schema = this.globalSettingsSchema(cap);
5945
5979
  if (!schema) return { sections: [] };
@@ -5950,6 +5984,55 @@ var BaseAddon = class {
5950
5984
  } : projected);
5951
5985
  }
5952
5986
  /**
5987
+ * The integration-level view of this addon's settings: exactly the sections
5988
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5989
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5990
+ *
5991
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5992
+ * no integration settings surface at all, rather than an empty one that reads
5993
+ * as a failed load.
5994
+ *
5995
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5996
+ * and not in whichever UI happens to render this:
5997
+ *
5998
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5999
+ * shown here is the same field, with the same bare key, that the addon's
6000
+ * own page shows. There is no integration-specific writer — callers save
6001
+ * through `updateGlobalSettings` — so a second store key is unreachable,
6002
+ * not merely discouraged.
6003
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
6004
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
6005
+ * such a field silently picked would be a wrong answer for the operator
6006
+ * who opened the page (D266).
6007
+ * 3. **No silent typo.** A declared id that names no section throws. The
6008
+ * alternative — skip it — turns a rename into a surface that quietly
6009
+ * empties, which looks exactly like an addon with nothing to configure.
6010
+ */
6011
+ async getIntegrationSettings(nodeId) {
6012
+ const declared = this.integrationSettingSections();
6013
+ if (declared.length === 0) return null;
6014
+ const schema = this.globalSettingsSchema();
6015
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6016
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6017
+ const sections = [];
6018
+ for (const id of declared) {
6019
+ const section = byId.get(id);
6020
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6021
+ const fields = dropPerNodeFields(section.fields);
6022
+ if (fields.length === 0) continue;
6023
+ sections.push({
6024
+ ...section,
6025
+ fields
6026
+ });
6027
+ }
6028
+ if (sections.length === 0) return null;
6029
+ const projected = await this.resolveGlobalStore(nodeId);
6030
+ return hydrateSchema({
6031
+ ...schema,
6032
+ sections
6033
+ }, projected);
6034
+ }
6035
+ /**
5953
6036
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5954
6037
  * every `perNode: true` field carries THAT node's scoped value on its bare
5955
6038
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6253,6 +6336,41 @@ var BaseAddon = class {
6253
6336
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6254
6337
  * don't declare `perNode` and are excluded by the `in` narrowing.
6255
6338
  */
6339
+ /**
6340
+ * The same fields with every `perNode: true` one removed, recursing into layout
6341
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6342
+ * with no child is dropped rather than rendered empty.
6343
+ *
6344
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6345
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6346
+ */
6347
+ function dropPerNodeFields(fields) {
6348
+ const kept = [];
6349
+ for (const field of fields) {
6350
+ if (field.type === "group") {
6351
+ const inner = dropPerNodeFields(field.fields);
6352
+ if (inner.length > 0) kept.push({
6353
+ ...field,
6354
+ fields: inner
6355
+ });
6356
+ continue;
6357
+ }
6358
+ if (field.type === "sub-tabs") {
6359
+ const tabs = field.tabs.map((tab) => ({
6360
+ ...tab,
6361
+ fields: dropPerNodeFields(tab.fields)
6362
+ })).filter((tab) => tab.fields.length > 0);
6363
+ if (tabs.length > 0) kept.push({
6364
+ ...field,
6365
+ tabs
6366
+ });
6367
+ continue;
6368
+ }
6369
+ if ("perNode" in field && field.perNode === true) continue;
6370
+ kept.push(field);
6371
+ }
6372
+ return kept;
6373
+ }
6256
6374
  function collectPerNodeFieldKeys(fields) {
6257
6375
  const collected = [];
6258
6376
  for (const field of fields) {
@@ -9454,6 +9572,9 @@ method(object({
9454
9572
  kind: "mutation",
9455
9573
  auth: "admin"
9456
9574
  }), method(object({
9575
+ addonId: string(),
9576
+ nodeId: string().optional()
9577
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9457
9578
  addonId: string(),
9458
9579
  deviceId: number(),
9459
9580
  nodeId: string().optional()
@@ -13402,6 +13523,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13402
13523
  limit: number().optional(),
13403
13524
  tags: record(string(), string()).optional()
13404
13525
  }), array(LogEntrySchema).readonly());
13526
+ /**
13527
+ * `failure-contribution` — the capability an addon reports its OWN losses
13528
+ * through, per camera, with the denominator attached. It stores nothing.
13529
+ *
13530
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13531
+ *
13532
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13533
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13534
+ * copied: the contributor reports what it already knows, hub-main adds only
13535
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13536
+ * somebody to forget to edit.
13537
+ *
13538
+ * They are not merged, because their invariants are opposites:
13539
+ *
13540
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13541
+ * claim a camera cost nothing, which is a measurement nobody made;
13542
+ * - a `failure-contribution` zero is the **most valuable value on the
13543
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13544
+ * and it is exactly what an absent entry cannot say.
13545
+ *
13546
+ * Putting a loss counter on a cost entry would also break the reconciliation
13547
+ * that gives `load-contribution` its point: contributions are subtracted from
13548
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13549
+ * has no process.
13550
+ *
13551
+ * ## Why not a log line, since the counters already exist
13552
+ *
13553
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13554
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13555
+ * ends in a log line, and a log line is the thing the operator asked to stop
13556
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13557
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13558
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13559
+ * media blackout were both diagnosed. The counters stay; this is where they can
13560
+ * be READ.
13561
+ *
13562
+ * ## The rate is served with its denominator or not at all
13563
+ *
13564
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13565
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13566
+ * than yesterday" and was **flat across twelve hours** once divided by the
13567
+ * successes on the same path. A surface that publishes only the numerator
13568
+ * reproduces that mistake on every read.
13569
+ *
13570
+ * ## Shape
13571
+ *
13572
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13573
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13574
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13575
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13576
+ * a forked runner's entries reach hub-main over transport that already exists.
13577
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13578
+ * result through `system.getFailureContributions`.
13579
+ */
13580
+ var FailureReasonCountSchema = object({
13581
+ /**
13582
+ * Why the attempt did not land, in the contributor's own vocabulary —
13583
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13584
+ * strings that already appear in this repo's logs and, where one exists, the
13585
+ * same string the per-track `previewMissReason` records (D276): a second
13586
+ * vocabulary for the same loss would make the row and the counter
13587
+ * un-joinable.
13588
+ */
13589
+ reason: string(),
13590
+ count: number().int().nonnegative()
13591
+ });
13592
+ var FailureContributionSchema = object({
13593
+ /**
13594
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13595
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13596
+ * `unit` free: the families are owned by different addons and a shared enum
13597
+ * is a central list that rots invisibly.
13598
+ */
13599
+ family: string(),
13600
+ /**
13601
+ * The NUMERIC device id — the same value every log line carries as
13602
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13603
+ * cannot name the camera must not emit the entry, because a fleet total
13604
+ * cannot answer the only question anybody asks of this surface.
13605
+ */
13606
+ deviceId: number().int().positive(),
13607
+ /**
13608
+ * A second dimension inside the family: the model / step id for an inference
13609
+ * timeout, so "which camera AND which model" is one read. Absent when the
13610
+ * family has a single variant.
13611
+ */
13612
+ variant: string().optional(),
13613
+ /**
13614
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13615
+ * differencing two reads must drop the interval when it changes, because the
13616
+ * counter restarted from zero in a respawned runner. Same discipline as
13617
+ * `LoadContribution.startedAtMs`.
13618
+ */
13619
+ sinceMs: number(),
13620
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13621
+ atMs: number(),
13622
+ /**
13623
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13624
+ * window. A failure count published without it is the mistake this schema
13625
+ * exists to make impossible.
13626
+ */
13627
+ attempts: number().int().nonnegative(),
13628
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13629
+ succeeded: number().int().nonnegative(),
13630
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13631
+ reasons: array(FailureReasonCountSchema).readonly()
13632
+ });
13633
+ method(_void(), array(FailureContributionSchema).readonly());
13405
13634
  var LoadContributionSchema = object({
13406
13635
  role: _enum([
13407
13636
  "decode",
@@ -17992,6 +18221,20 @@ var TrackSchema = object({
17992
18221
  * `=== true` and render nothing otherwise — never infer "no rider".
17993
18222
  */
17994
18223
  hasRider: boolean().optional(),
18224
+ /**
18225
+ * WHY this track ended without a NATIVE best-shot tile
18226
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18227
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18228
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18229
+ * the late-keyFrame upgrade when a native tile lands after all. The
18230
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18231
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18232
+ *
18233
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18234
+ * that predates the field, and every track whose tile landed native all
18235
+ * omit it. Render nothing when absent.
18236
+ */
18237
+ previewMissReason: string().optional(),
17995
18238
  ...TrackFlagFields,
17996
18239
  ...TrackRetrainFields
17997
18240
  });
@@ -29279,6 +29522,13 @@ var LoggingSettingsPatchSchema = object({
29279
29522
  * anyone but its owner.
29280
29523
  */
29281
29524
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29525
+ /**
29526
+ * One per-camera failure counter, plus WHO reported it.
29527
+ *
29528
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29529
+ * the hub as it enumerates providers, never by the contributor.
29530
+ */
29531
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29282
29532
  var GetLoggingSettingsInputSchema = object({
29283
29533
  scopeNodeId: string().optional(),
29284
29534
  /**
@@ -29337,7 +29587,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29337
29587
  }), method(_void(), SiteLocationStatusSchema, {
29338
29588
  kind: "mutation",
29339
29589
  auth: "admin"
29340
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29590
+ }), 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, {
29341
29591
  kind: "mutation",
29342
29592
  auth: "admin"
29343
29593
  });
@@ -31725,6 +31975,12 @@ Object.freeze({
31725
31975
  addonId: null,
31726
31976
  access: "view"
31727
31977
  },
31978
+ "addonSettings.getIntegrationSettings": {
31979
+ capName: "addon-settings",
31980
+ capScope: "system",
31981
+ addonId: null,
31982
+ access: "view"
31983
+ },
31728
31984
  "addonSettings.updateDeviceSettings": {
31729
31985
  capName: "addon-settings",
31730
31986
  capScope: "system",
@@ -33387,6 +33643,12 @@ Object.freeze({
33387
33643
  addonId: null,
33388
33644
  access: "create"
33389
33645
  },
33646
+ "failureContribution.list": {
33647
+ capName: "failure-contribution",
33648
+ capScope: "system",
33649
+ addonId: null,
33650
+ access: "view"
33651
+ },
33390
33652
  "fanControl.setDirection": {
33391
33653
  capName: "fan-control",
33392
33654
  capScope: "device",
@@ -36693,6 +36955,12 @@ Object.freeze({
36693
36955
  addonId: null,
36694
36956
  access: "create"
36695
36957
  },
36958
+ "system.getFailureContributions": {
36959
+ capName: "system",
36960
+ capScope: "system",
36961
+ addonId: null,
36962
+ access: "view"
36963
+ },
36696
36964
  "system.getLoadContributions": {
36697
36965
  capName: "system",
36698
36966
  capScope: "system",
package/dist/addon.mjs 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) {
@@ -9430,6 +9548,9 @@ method(object({
9430
9548
  kind: "mutation",
9431
9549
  auth: "admin"
9432
9550
  }), method(object({
9551
+ addonId: string(),
9552
+ nodeId: string().optional()
9553
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9433
9554
  addonId: string(),
9434
9555
  deviceId: number(),
9435
9556
  nodeId: string().optional()
@@ -13378,6 +13499,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13378
13499
  limit: number().optional(),
13379
13500
  tags: record(string(), string()).optional()
13380
13501
  }), array(LogEntrySchema).readonly());
13502
+ /**
13503
+ * `failure-contribution` — the capability an addon reports its OWN losses
13504
+ * through, per camera, with the denominator attached. It stores nothing.
13505
+ *
13506
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13507
+ *
13508
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13509
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13510
+ * copied: the contributor reports what it already knows, hub-main adds only
13511
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13512
+ * somebody to forget to edit.
13513
+ *
13514
+ * They are not merged, because their invariants are opposites:
13515
+ *
13516
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13517
+ * claim a camera cost nothing, which is a measurement nobody made;
13518
+ * - a `failure-contribution` zero is the **most valuable value on the
13519
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13520
+ * and it is exactly what an absent entry cannot say.
13521
+ *
13522
+ * Putting a loss counter on a cost entry would also break the reconciliation
13523
+ * that gives `load-contribution` its point: contributions are subtracted from
13524
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13525
+ * has no process.
13526
+ *
13527
+ * ## Why not a log line, since the counters already exist
13528
+ *
13529
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13530
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13531
+ * ends in a log line, and a log line is the thing the operator asked to stop
13532
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13533
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13534
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13535
+ * media blackout were both diagnosed. The counters stay; this is where they can
13536
+ * be READ.
13537
+ *
13538
+ * ## The rate is served with its denominator or not at all
13539
+ *
13540
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13541
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13542
+ * than yesterday" and was **flat across twelve hours** once divided by the
13543
+ * successes on the same path. A surface that publishes only the numerator
13544
+ * reproduces that mistake on every read.
13545
+ *
13546
+ * ## Shape
13547
+ *
13548
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13549
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13550
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13551
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13552
+ * a forked runner's entries reach hub-main over transport that already exists.
13553
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13554
+ * result through `system.getFailureContributions`.
13555
+ */
13556
+ var FailureReasonCountSchema = object({
13557
+ /**
13558
+ * Why the attempt did not land, in the contributor's own vocabulary —
13559
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13560
+ * strings that already appear in this repo's logs and, where one exists, the
13561
+ * same string the per-track `previewMissReason` records (D276): a second
13562
+ * vocabulary for the same loss would make the row and the counter
13563
+ * un-joinable.
13564
+ */
13565
+ reason: string(),
13566
+ count: number().int().nonnegative()
13567
+ });
13568
+ var FailureContributionSchema = object({
13569
+ /**
13570
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13571
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13572
+ * `unit` free: the families are owned by different addons and a shared enum
13573
+ * is a central list that rots invisibly.
13574
+ */
13575
+ family: string(),
13576
+ /**
13577
+ * The NUMERIC device id — the same value every log line carries as
13578
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13579
+ * cannot name the camera must not emit the entry, because a fleet total
13580
+ * cannot answer the only question anybody asks of this surface.
13581
+ */
13582
+ deviceId: number().int().positive(),
13583
+ /**
13584
+ * A second dimension inside the family: the model / step id for an inference
13585
+ * timeout, so "which camera AND which model" is one read. Absent when the
13586
+ * family has a single variant.
13587
+ */
13588
+ variant: string().optional(),
13589
+ /**
13590
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13591
+ * differencing two reads must drop the interval when it changes, because the
13592
+ * counter restarted from zero in a respawned runner. Same discipline as
13593
+ * `LoadContribution.startedAtMs`.
13594
+ */
13595
+ sinceMs: number(),
13596
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13597
+ atMs: number(),
13598
+ /**
13599
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13600
+ * window. A failure count published without it is the mistake this schema
13601
+ * exists to make impossible.
13602
+ */
13603
+ attempts: number().int().nonnegative(),
13604
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13605
+ succeeded: number().int().nonnegative(),
13606
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13607
+ reasons: array(FailureReasonCountSchema).readonly()
13608
+ });
13609
+ method(_void(), array(FailureContributionSchema).readonly());
13381
13610
  var LoadContributionSchema = object({
13382
13611
  role: _enum([
13383
13612
  "decode",
@@ -17968,6 +18197,20 @@ var TrackSchema = object({
17968
18197
  * `=== true` and render nothing otherwise — never infer "no rider".
17969
18198
  */
17970
18199
  hasRider: boolean().optional(),
18200
+ /**
18201
+ * WHY this track ended without a NATIVE best-shot tile
18202
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18203
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18204
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18205
+ * the late-keyFrame upgrade when a native tile lands after all. The
18206
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18207
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18208
+ *
18209
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18210
+ * that predates the field, and every track whose tile landed native all
18211
+ * omit it. Render nothing when absent.
18212
+ */
18213
+ previewMissReason: string().optional(),
17971
18214
  ...TrackFlagFields,
17972
18215
  ...TrackRetrainFields
17973
18216
  });
@@ -29255,6 +29498,13 @@ var LoggingSettingsPatchSchema = object({
29255
29498
  * anyone but its owner.
29256
29499
  */
29257
29500
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29501
+ /**
29502
+ * One per-camera failure counter, plus WHO reported it.
29503
+ *
29504
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29505
+ * the hub as it enumerates providers, never by the contributor.
29506
+ */
29507
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29258
29508
  var GetLoggingSettingsInputSchema = object({
29259
29509
  scopeNodeId: string().optional(),
29260
29510
  /**
@@ -29313,7 +29563,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29313
29563
  }), method(_void(), SiteLocationStatusSchema, {
29314
29564
  kind: "mutation",
29315
29565
  auth: "admin"
29316
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
29566
+ }), 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, {
29317
29567
  kind: "mutation",
29318
29568
  auth: "admin"
29319
29569
  });
@@ -31701,6 +31951,12 @@ Object.freeze({
31701
31951
  addonId: null,
31702
31952
  access: "view"
31703
31953
  },
31954
+ "addonSettings.getIntegrationSettings": {
31955
+ capName: "addon-settings",
31956
+ capScope: "system",
31957
+ addonId: null,
31958
+ access: "view"
31959
+ },
31704
31960
  "addonSettings.updateDeviceSettings": {
31705
31961
  capName: "addon-settings",
31706
31962
  capScope: "system",
@@ -33363,6 +33619,12 @@ Object.freeze({
33363
33619
  addonId: null,
33364
33620
  access: "create"
33365
33621
  },
33622
+ "failureContribution.list": {
33623
+ capName: "failure-contribution",
33624
+ capScope: "system",
33625
+ addonId: null,
33626
+ access: "view"
33627
+ },
33366
33628
  "fanControl.setDirection": {
33367
33629
  capName: "fan-control",
33368
33630
  capScope: "device",
@@ -36669,6 +36931,12 @@ Object.freeze({
36669
36931
  addonId: null,
36670
36932
  access: "create"
36671
36933
  },
36934
+ "system.getFailureContributions": {
36935
+ capName: "system",
36936
+ capScope: "system",
36937
+ addonId: null,
36938
+ access: "view"
36939
+ },
36672
36940
  "system.getLoadContributions": {
36673
36941
  capName: "system",
36674
36942
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-rtsp",
3
- "version": "1.2.37",
3
+ "version": "1.2.39",
4
4
  "description": "Generic RTSP camera device provider addon for CamStack",
5
5
  "keywords": [
6
6
  "camstack",