@camstack/addon-provider-hikvision 1.2.44 → 1.2.46

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
@@ -5923,6 +5923,40 @@ var BaseAddon = class {
5923
5923
  deviceSettingsSchema() {
5924
5924
  return null;
5925
5925
  }
5926
+ /**
5927
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5928
+ * ARE the configuration of its integration.
5929
+ *
5930
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5931
+ * operator should find on the addon's integration page (System →
5932
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5933
+ * addon. Empty (the default) means the addon has no integration-level
5934
+ * settings and no such surface is offered — this is opt-in, because whether
5935
+ * an addon's configuration IS its integration's configuration depends on the
5936
+ * nature of the integration.
5937
+ *
5938
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5939
+ * the ONE global schema, in the ONE addon store, written by the ONE
5940
+ * `updateGlobalSettings` path. There is deliberately no
5941
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5942
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5943
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5944
+ *
5945
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5946
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5947
+ * removed with the reason recorded at
5948
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5949
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5950
+ * marker sprinkled across sections also has to borrow a field that already
5951
+ * means something else; borrowing `section.tab` put the literal word
5952
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5953
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5954
+ * supersedes D268). One declaration, in one place, next to the schema whose
5955
+ * ids it names.
5956
+ */
5957
+ integrationSettingSections() {
5958
+ return [];
5959
+ }
5926
5960
  async getGlobalSettings(overlay, cap, nodeId) {
5927
5961
  const schema = this.globalSettingsSchema(cap);
5928
5962
  if (!schema) return { sections: [] };
@@ -5933,6 +5967,55 @@ var BaseAddon = class {
5933
5967
  } : projected);
5934
5968
  }
5935
5969
  /**
5970
+ * The integration-level view of this addon's settings: exactly the sections
5971
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5972
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5973
+ *
5974
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5975
+ * no integration settings surface at all, rather than an empty one that reads
5976
+ * as a failed load.
5977
+ *
5978
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5979
+ * and not in whichever UI happens to render this:
5980
+ *
5981
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5982
+ * shown here is the same field, with the same bare key, that the addon's
5983
+ * own page shows. There is no integration-specific writer — callers save
5984
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5985
+ * not merely discouraged.
5986
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5987
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5988
+ * such a field silently picked would be a wrong answer for the operator
5989
+ * who opened the page (D266).
5990
+ * 3. **No silent typo.** A declared id that names no section throws. The
5991
+ * alternative — skip it — turns a rename into a surface that quietly
5992
+ * empties, which looks exactly like an addon with nothing to configure.
5993
+ */
5994
+ async getIntegrationSettings(nodeId) {
5995
+ const declared = this.integrationSettingSections();
5996
+ if (declared.length === 0) return null;
5997
+ const schema = this.globalSettingsSchema();
5998
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
5999
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6000
+ const sections = [];
6001
+ for (const id of declared) {
6002
+ const section = byId.get(id);
6003
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6004
+ const fields = dropPerNodeFields(section.fields);
6005
+ if (fields.length === 0) continue;
6006
+ sections.push({
6007
+ ...section,
6008
+ fields
6009
+ });
6010
+ }
6011
+ if (sections.length === 0) return null;
6012
+ const projected = await this.resolveGlobalStore(nodeId);
6013
+ return hydrateSchema({
6014
+ ...schema,
6015
+ sections
6016
+ }, projected);
6017
+ }
6018
+ /**
5936
6019
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5937
6020
  * every `perNode: true` field carries THAT node's scoped value on its bare
5938
6021
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6236,6 +6319,41 @@ var BaseAddon = class {
6236
6319
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6237
6320
  * don't declare `perNode` and are excluded by the `in` narrowing.
6238
6321
  */
6322
+ /**
6323
+ * The same fields with every `perNode: true` one removed, recursing into layout
6324
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6325
+ * with no child is dropped rather than rendered empty.
6326
+ *
6327
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6328
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6329
+ */
6330
+ function dropPerNodeFields(fields) {
6331
+ const kept = [];
6332
+ for (const field of fields) {
6333
+ if (field.type === "group") {
6334
+ const inner = dropPerNodeFields(field.fields);
6335
+ if (inner.length > 0) kept.push({
6336
+ ...field,
6337
+ fields: inner
6338
+ });
6339
+ continue;
6340
+ }
6341
+ if (field.type === "sub-tabs") {
6342
+ const tabs = field.tabs.map((tab) => ({
6343
+ ...tab,
6344
+ fields: dropPerNodeFields(tab.fields)
6345
+ })).filter((tab) => tab.fields.length > 0);
6346
+ if (tabs.length > 0) kept.push({
6347
+ ...field,
6348
+ tabs
6349
+ });
6350
+ continue;
6351
+ }
6352
+ if ("perNode" in field && field.perNode === true) continue;
6353
+ kept.push(field);
6354
+ }
6355
+ return kept;
6356
+ }
6239
6357
  function collectPerNodeFieldKeys(fields) {
6240
6358
  const collected = [];
6241
6359
  for (const field of fields) {
@@ -9568,6 +9686,9 @@ method(object({
9568
9686
  kind: "mutation",
9569
9687
  auth: "admin"
9570
9688
  }), method(object({
9689
+ addonId: string(),
9690
+ nodeId: string().optional()
9691
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9571
9692
  addonId: string(),
9572
9693
  deviceId: number(),
9573
9694
  nodeId: string().optional()
@@ -13528,6 +13649,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13528
13649
  limit: number().optional(),
13529
13650
  tags: record(string(), string()).optional()
13530
13651
  }), array(LogEntrySchema).readonly());
13652
+ /**
13653
+ * `failure-contribution` — the capability an addon reports its OWN losses
13654
+ * through, per camera, with the denominator attached. It stores nothing.
13655
+ *
13656
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13657
+ *
13658
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13659
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13660
+ * copied: the contributor reports what it already knows, hub-main adds only
13661
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13662
+ * somebody to forget to edit.
13663
+ *
13664
+ * They are not merged, because their invariants are opposites:
13665
+ *
13666
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13667
+ * claim a camera cost nothing, which is a measurement nobody made;
13668
+ * - a `failure-contribution` zero is the **most valuable value on the
13669
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13670
+ * and it is exactly what an absent entry cannot say.
13671
+ *
13672
+ * Putting a loss counter on a cost entry would also break the reconciliation
13673
+ * that gives `load-contribution` its point: contributions are subtracted from
13674
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13675
+ * has no process.
13676
+ *
13677
+ * ## Why not a log line, since the counters already exist
13678
+ *
13679
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13680
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13681
+ * ends in a log line, and a log line is the thing the operator asked to stop
13682
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13683
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13684
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13685
+ * media blackout were both diagnosed. The counters stay; this is where they can
13686
+ * be READ.
13687
+ *
13688
+ * ## The rate is served with its denominator or not at all
13689
+ *
13690
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13691
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13692
+ * than yesterday" and was **flat across twelve hours** once divided by the
13693
+ * successes on the same path. A surface that publishes only the numerator
13694
+ * reproduces that mistake on every read.
13695
+ *
13696
+ * ## Shape
13697
+ *
13698
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13699
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13700
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13701
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13702
+ * a forked runner's entries reach hub-main over transport that already exists.
13703
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13704
+ * result through `system.getFailureContributions`.
13705
+ */
13706
+ var FailureReasonCountSchema = object({
13707
+ /**
13708
+ * Why the attempt did not land, in the contributor's own vocabulary —
13709
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13710
+ * strings that already appear in this repo's logs and, where one exists, the
13711
+ * same string the per-track `previewMissReason` records (D276): a second
13712
+ * vocabulary for the same loss would make the row and the counter
13713
+ * un-joinable.
13714
+ */
13715
+ reason: string(),
13716
+ count: number().int().nonnegative()
13717
+ });
13718
+ var FailureContributionSchema = object({
13719
+ /**
13720
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13721
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13722
+ * `unit` free: the families are owned by different addons and a shared enum
13723
+ * is a central list that rots invisibly.
13724
+ */
13725
+ family: string(),
13726
+ /**
13727
+ * The NUMERIC device id — the same value every log line carries as
13728
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13729
+ * cannot name the camera must not emit the entry, because a fleet total
13730
+ * cannot answer the only question anybody asks of this surface.
13731
+ */
13732
+ deviceId: number().int().positive(),
13733
+ /**
13734
+ * A second dimension inside the family: the model / step id for an inference
13735
+ * timeout, so "which camera AND which model" is one read. Absent when the
13736
+ * family has a single variant.
13737
+ */
13738
+ variant: string().optional(),
13739
+ /**
13740
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13741
+ * differencing two reads must drop the interval when it changes, because the
13742
+ * counter restarted from zero in a respawned runner. Same discipline as
13743
+ * `LoadContribution.startedAtMs`.
13744
+ */
13745
+ sinceMs: number(),
13746
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13747
+ atMs: number(),
13748
+ /**
13749
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13750
+ * window. A failure count published without it is the mistake this schema
13751
+ * exists to make impossible.
13752
+ */
13753
+ attempts: number().int().nonnegative(),
13754
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13755
+ succeeded: number().int().nonnegative(),
13756
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13757
+ reasons: array(FailureReasonCountSchema).readonly()
13758
+ });
13759
+ method(_void(), array(FailureContributionSchema).readonly());
13531
13760
  var LoadContributionSchema = object({
13532
13761
  role: _enum([
13533
13762
  "decode",
@@ -18118,6 +18347,20 @@ var TrackSchema = object({
18118
18347
  * `=== true` and render nothing otherwise — never infer "no rider".
18119
18348
  */
18120
18349
  hasRider: boolean().optional(),
18350
+ /**
18351
+ * WHY this track ended without a NATIVE best-shot tile
18352
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18353
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18354
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18355
+ * the late-keyFrame upgrade when a native tile lands after all. The
18356
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18357
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18358
+ *
18359
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18360
+ * that predates the field, and every track whose tile landed native all
18361
+ * omit it. Render nothing when absent.
18362
+ */
18363
+ previewMissReason: string().optional(),
18121
18364
  ...TrackFlagFields,
18122
18365
  ...TrackRetrainFields
18123
18366
  });
@@ -29728,6 +29971,13 @@ var LoggingSettingsPatchSchema = object({
29728
29971
  * anyone but its owner.
29729
29972
  */
29730
29973
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29974
+ /**
29975
+ * One per-camera failure counter, plus WHO reported it.
29976
+ *
29977
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29978
+ * the hub as it enumerates providers, never by the contributor.
29979
+ */
29980
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29731
29981
  var GetLoggingSettingsInputSchema = object({
29732
29982
  scopeNodeId: string().optional(),
29733
29983
  /**
@@ -29786,7 +30036,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29786
30036
  }), method(_void(), SiteLocationStatusSchema, {
29787
30037
  kind: "mutation",
29788
30038
  auth: "admin"
29789
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30039
+ }), 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, {
29790
30040
  kind: "mutation",
29791
30041
  auth: "admin"
29792
30042
  });
@@ -32341,6 +32591,12 @@ Object.freeze({
32341
32591
  addonId: null,
32342
32592
  access: "view"
32343
32593
  },
32594
+ "addonSettings.getIntegrationSettings": {
32595
+ capName: "addon-settings",
32596
+ capScope: "system",
32597
+ addonId: null,
32598
+ access: "view"
32599
+ },
32344
32600
  "addonSettings.updateDeviceSettings": {
32345
32601
  capName: "addon-settings",
32346
32602
  capScope: "system",
@@ -34003,6 +34259,12 @@ Object.freeze({
34003
34259
  addonId: null,
34004
34260
  access: "create"
34005
34261
  },
34262
+ "failureContribution.list": {
34263
+ capName: "failure-contribution",
34264
+ capScope: "system",
34265
+ addonId: null,
34266
+ access: "view"
34267
+ },
34006
34268
  "fanControl.setDirection": {
34007
34269
  capName: "fan-control",
34008
34270
  capScope: "device",
@@ -37309,6 +37571,12 @@ Object.freeze({
37309
37571
  addonId: null,
37310
37572
  access: "create"
37311
37573
  },
37574
+ "system.getFailureContributions": {
37575
+ capName: "system",
37576
+ capScope: "system",
37577
+ addonId: null,
37578
+ access: "view"
37579
+ },
37312
37580
  "system.getLoadContributions": {
37313
37581
  capName: "system",
37314
37582
  capScope: "system",
package/dist/addon.mjs CHANGED
@@ -5924,6 +5924,40 @@ var BaseAddon = class {
5924
5924
  deviceSettingsSchema() {
5925
5925
  return null;
5926
5926
  }
5927
+ /**
5928
+ * INTEGRATION-LEVEL SETTINGS — declare which of this addon's global sections
5929
+ * ARE the configuration of its integration.
5930
+ *
5931
+ * Return the `ConfigSection.id`s, from {@link globalSettingsSchema}, that an
5932
+ * operator should find on the addon's integration page (System →
5933
+ * Integrations → <name>) rather than only in the cluster-wide list of every
5934
+ * addon. Empty (the default) means the addon has no integration-level
5935
+ * settings and no such surface is offered — this is opt-in, because whether
5936
+ * an addon's configuration IS its integration's configuration depends on the
5937
+ * nature of the integration.
5938
+ *
5939
+ * WHAT THIS IS NOT. It is not a scope. The selected sections keep living in
5940
+ * the ONE global schema, in the ONE addon store, written by the ONE
5941
+ * `updateGlobalSettings` path. There is deliberately no
5942
+ * `updateIntegrationSettings`: a second write path is how a surface acquires
5943
+ * a second store key, and this repo has shipped that twice (`btmPath@hub`,
5944
+ * D266). Selecting sections cannot introduce a key that selecting cannot.
5945
+ *
5946
+ * WHY IT IS A LIST OF SECTION IDS AND NOT A MARKER ON THE SECTION.
5947
+ * `ConfigFieldBase` used to carry `scope?: 'device' | 'global'` and it was
5948
+ * removed with the reason recorded at
5949
+ * `packages/types/src/interfaces/config-ui.ts:249` — *"a field's scope is
5950
+ * determined by WHICH schema it lives in, not by a field-level marker."* A
5951
+ * marker sprinkled across sections also has to borrow a field that already
5952
+ * means something else; borrowing `section.tab` put the literal word
5953
+ * "integration" into an operator-facing tab bar, because `tab` means "how to
5954
+ * GROUP this visually" and cannot also mean "where this lives" (D269
5955
+ * supersedes D268). One declaration, in one place, next to the schema whose
5956
+ * ids it names.
5957
+ */
5958
+ integrationSettingSections() {
5959
+ return [];
5960
+ }
5927
5961
  async getGlobalSettings(overlay, cap, nodeId) {
5928
5962
  const schema = this.globalSettingsSchema(cap);
5929
5963
  if (!schema) return { sections: [] };
@@ -5934,6 +5968,55 @@ var BaseAddon = class {
5934
5968
  } : projected);
5935
5969
  }
5936
5970
  /**
5971
+ * The integration-level view of this addon's settings: exactly the sections
5972
+ * named by {@link integrationSettingSections}, hydrated from the SAME store
5973
+ * `getGlobalSettings` reads, and narrowed to cluster-scoped fields.
5974
+ *
5975
+ * Returns `null` when the addon declared nothing — an addon that opts out has
5976
+ * no integration settings surface at all, rather than an empty one that reads
5977
+ * as a failed load.
5978
+ *
5979
+ * Three properties hold BY CONSTRUCTION, which is why they are here in core
5980
+ * and not in whichever UI happens to render this:
5981
+ *
5982
+ * 1. **One key.** The payload is a SUBSET of the global schema, so a field
5983
+ * shown here is the same field, with the same bare key, that the addon's
5984
+ * own page shows. There is no integration-specific writer — callers save
5985
+ * through `updateGlobalSettings` — so a second store key is unreachable,
5986
+ * not merely discouraged.
5987
+ * 2. **No node scope.** `perNode: true` fields are DROPPED. Their store key
5988
+ * is `<key>@<nodeId>` and an integration is not a node; whichever node
5989
+ * such a field silently picked would be a wrong answer for the operator
5990
+ * who opened the page (D266).
5991
+ * 3. **No silent typo.** A declared id that names no section throws. The
5992
+ * alternative — skip it — turns a rename into a surface that quietly
5993
+ * empties, which looks exactly like an addon with nothing to configure.
5994
+ */
5995
+ async getIntegrationSettings(nodeId) {
5996
+ const declared = this.integrationSettingSections();
5997
+ if (declared.length === 0) return null;
5998
+ const schema = this.globalSettingsSchema();
5999
+ if (!schema) throw new Error(`${this.constructor.name}: integrationSettingSections() names [${declared.join(", ")}] but globalSettingsSchema() returns null.`);
6000
+ const byId = new Map(schema.sections.map((section) => [section.id, section]));
6001
+ const sections = [];
6002
+ for (const id of declared) {
6003
+ const section = byId.get(id);
6004
+ if (!section) throw new Error(`${this.constructor.name}: integrationSettingSections() names unknown section "${id}". Known sections: [${[...byId.keys()].join(", ")}].`);
6005
+ const fields = dropPerNodeFields(section.fields);
6006
+ if (fields.length === 0) continue;
6007
+ sections.push({
6008
+ ...section,
6009
+ fields
6010
+ });
6011
+ }
6012
+ if (sections.length === 0) return null;
6013
+ const projected = await this.resolveGlobalStore(nodeId);
6014
+ return hydrateSchema({
6015
+ ...schema,
6016
+ sections
6017
+ }, projected);
6018
+ }
6019
+ /**
5937
6020
  * The raw addon store PROJECTED onto the target node's bare per-node keys:
5938
6021
  * every `perNode: true` field carries THAT node's scoped value on its bare
5939
6022
  * key (absent scoped key ⇒ key absent, so the schema `default` wins — no
@@ -6237,6 +6320,41 @@ var BaseAddon = class {
6237
6320
  * `hydrateSchema` does. Valueless structural fields (separator/info/…)
6238
6321
  * don't declare `perNode` and are excluded by the `in` narrowing.
6239
6322
  */
6323
+ /**
6324
+ * The same fields with every `perNode: true` one removed, recursing into layout
6325
+ * containers exactly as {@link collectPerNodeFieldKeys} does. A container left
6326
+ * with no child is dropped rather than rendered empty.
6327
+ *
6328
+ * Used by `getIntegrationSettings`: an integration is not a node, so a field
6329
+ * whose store key is `<key>@<nodeId>` has no node to belong to there.
6330
+ */
6331
+ function dropPerNodeFields(fields) {
6332
+ const kept = [];
6333
+ for (const field of fields) {
6334
+ if (field.type === "group") {
6335
+ const inner = dropPerNodeFields(field.fields);
6336
+ if (inner.length > 0) kept.push({
6337
+ ...field,
6338
+ fields: inner
6339
+ });
6340
+ continue;
6341
+ }
6342
+ if (field.type === "sub-tabs") {
6343
+ const tabs = field.tabs.map((tab) => ({
6344
+ ...tab,
6345
+ fields: dropPerNodeFields(tab.fields)
6346
+ })).filter((tab) => tab.fields.length > 0);
6347
+ if (tabs.length > 0) kept.push({
6348
+ ...field,
6349
+ tabs
6350
+ });
6351
+ continue;
6352
+ }
6353
+ if ("perNode" in field && field.perNode === true) continue;
6354
+ kept.push(field);
6355
+ }
6356
+ return kept;
6357
+ }
6240
6358
  function collectPerNodeFieldKeys(fields) {
6241
6359
  const collected = [];
6242
6360
  for (const field of fields) {
@@ -9569,6 +9687,9 @@ method(object({
9569
9687
  kind: "mutation",
9570
9688
  auth: "admin"
9571
9689
  }), method(object({
9690
+ addonId: string(),
9691
+ nodeId: string().optional()
9692
+ }), SettingsSchemaWithValuesSchema.nullable()), method(object({
9572
9693
  addonId: string(),
9573
9694
  deviceId: number(),
9574
9695
  nodeId: string().optional()
@@ -13529,6 +13650,114 @@ method(LogEntrySchema, _void(), { kind: "mutation" }), method(object({
13529
13650
  limit: number().optional(),
13530
13651
  tags: record(string(), string()).optional()
13531
13652
  }), array(LogEntrySchema).readonly());
13653
+ /**
13654
+ * `failure-contribution` — the capability an addon reports its OWN losses
13655
+ * through, per camera, with the denominator attached. It stores nothing.
13656
+ *
13657
+ * ## The twin of `load-contribution`, and why it is a twin and not a field
13658
+ *
13659
+ * `load-contribution` answers *what did this camera COST*. This answers *what
13660
+ * did this camera LOSE*. The reporting discipline is identical and deliberately
13661
+ * copied: the contributor reports what it already knows, hub-main adds only
13662
+ * `addonId`, nothing needs global knowledge, and there is no central list for
13663
+ * somebody to forget to edit.
13664
+ *
13665
+ * They are not merged, because their invariants are opposites:
13666
+ *
13667
+ * - a `load-contribution` measurement is **absent, never zero** — a zero would
13668
+ * claim a camera cost nothing, which is a measurement nobody made;
13669
+ * - a `failure-contribution` zero is the **most valuable value on the
13670
+ * surface** — `attempts: 400, succeeded: 400` is the proof a fix landed,
13671
+ * and it is exactly what an absent entry cannot say.
13672
+ *
13673
+ * Putting a loss counter on a cost entry would also break the reconciliation
13674
+ * that gives `load-contribution` its point: contributions are subtracted from
13675
+ * `metrics.node-processes-snapshot` to find processes nobody claims. A failure
13676
+ * has no process.
13677
+ *
13678
+ * ## Why not a log line, since the counters already exist
13679
+ *
13680
+ * Several of these paths already counted themselves — `CaptureScheduler`'s
13681
+ * per-device window, `KeyFrameCaptureLog`, `bumpCropMetric`. Every one of them
13682
+ * ends in a log line, and a log line is the thing the operator asked to stop
13683
+ * needing: *"possiamo armare questi errori intanto? Così al prossimo giro
13684
+ * ricontrolliamo tutti questi punti"*. Reading them meant grepping Loki and
13685
+ * hand-correlating timestamps, which is how a 22% thumbnail gap and a 3-hour
13686
+ * media blackout were both diagnosed. The counters stay; this is where they can
13687
+ * be READ.
13688
+ *
13689
+ * ## The rate is served with its denominator or not at all
13690
+ *
13691
+ * Every entry carries `attempts` and `succeeded`. A miss count alone is
13692
+ * unreadable: on 2026-08-28 the enrichment-crop miss count read as "35x worse
13693
+ * than yesterday" and was **flat across twelve hours** once divided by the
13694
+ * successes on the same path. A surface that publishes only the numerator
13695
+ * reproduces that mistake on every read.
13696
+ *
13697
+ * ## Shape
13698
+ *
13699
+ * Copied from `load-contribution.cap.ts` (`mode: 'collection'`,
13700
+ * `internal: true`, `mount: { kind: 'skip' }`): no tRPC route of its own and no
13701
+ * generated hooks, while `addons.listCapabilityProviders` still enumerates it
13702
+ * and the hub's `CapabilityRegistry` still holds an RPC proxy per provider — so
13703
+ * a forked runner's entries reach hub-main over transport that already exists.
13704
+ * No new UDS message, no second registry (D3). The operator reads the assembled
13705
+ * result through `system.getFailureContributions`.
13706
+ */
13707
+ var FailureReasonCountSchema = object({
13708
+ /**
13709
+ * Why the attempt did not land, in the contributor's own vocabulary —
13710
+ * `worker-lease-gone`, `queue-overflow`, `timeout`, `empty-read`. The same
13711
+ * strings that already appear in this repo's logs and, where one exists, the
13712
+ * same string the per-track `previewMissReason` records (D276): a second
13713
+ * vocabulary for the same loss would make the row and the counter
13714
+ * un-joinable.
13715
+ */
13716
+ reason: string(),
13717
+ count: number().int().nonnegative()
13718
+ });
13719
+ var FailureContributionSchema = object({
13720
+ /**
13721
+ * The failing path — `enrichment-crop`, `inference`, `plate-ocr`,
13722
+ * `person-over-vehicle`. Free text, for the reason `load-contribution` keeps
13723
+ * `unit` free: the families are owned by different addons and a shared enum
13724
+ * is a central list that rots invisibly.
13725
+ */
13726
+ family: string(),
13727
+ /**
13728
+ * The NUMERIC device id — the same value every log line carries as
13729
+ * `tags.deviceId`. Never nullable and never absent: a contributor that
13730
+ * cannot name the camera must not emit the entry, because a fleet total
13731
+ * cannot answer the only question anybody asks of this surface.
13732
+ */
13733
+ deviceId: number().int().positive(),
13734
+ /**
13735
+ * A second dimension inside the family: the model / step id for an inference
13736
+ * timeout, so "which camera AND which model" is one read. Absent when the
13737
+ * family has a single variant.
13738
+ */
13739
+ variant: string().optional(),
13740
+ /**
13741
+ * Epoch ms this counter started — the INCARNATION MARKER. A consumer
13742
+ * differencing two reads must drop the interval when it changes, because the
13743
+ * counter restarted from zero in a respawned runner. Same discipline as
13744
+ * `LoadContribution.startedAtMs`.
13745
+ */
13746
+ sinceMs: number(),
13747
+ /** Epoch ms it was read. `atMs - sinceMs` is the interval this covers. */
13748
+ atMs: number(),
13749
+ /**
13750
+ * THE DENOMINATOR — every attempt on this path for this camera in the
13751
+ * window. A failure count published without it is the mistake this schema
13752
+ * exists to make impossible.
13753
+ */
13754
+ attempts: number().int().nonnegative(),
13755
+ /** Attempts that landed. `attempts - succeeded` is the loss. */
13756
+ succeeded: number().int().nonnegative(),
13757
+ /** The loss, partitioned. Sums to `attempts - succeeded`. */
13758
+ reasons: array(FailureReasonCountSchema).readonly()
13759
+ });
13760
+ method(_void(), array(FailureContributionSchema).readonly());
13532
13761
  var LoadContributionSchema = object({
13533
13762
  role: _enum([
13534
13763
  "decode",
@@ -18119,6 +18348,20 @@ var TrackSchema = object({
18119
18348
  * `=== true` and render nothing otherwise — never infer "no rider".
18120
18349
  */
18121
18350
  hasRider: boolean().optional(),
18351
+ /**
18352
+ * WHY this track ended without a NATIVE best-shot tile
18353
+ * ([D276](../decisions/adr-0276-a-stand-in-tile-is-provisional-and-a-close-says-why.md)) —
18354
+ * a composed token line (`no-key-frame capture=keyframe:native-missx4`,
18355
+ * `derive-returned-null tile=standin`, …) written at close and CLEARED by
18356
+ * the late-keyFrame upgrade when a native tile lands after all. The
18357
+ * operator-facing answer to "perché manca l'immagine?" on a track whose
18358
+ * tile is a face/plate stand-in, a raster crop, or an icon.
18359
+ *
18360
+ * **Absent ≠ "missed silently"**: a row written before the column, a hub
18361
+ * that predates the field, and every track whose tile landed native all
18362
+ * omit it. Render nothing when absent.
18363
+ */
18364
+ previewMissReason: string().optional(),
18122
18365
  ...TrackFlagFields,
18123
18366
  ...TrackRetrainFields
18124
18367
  });
@@ -29729,6 +29972,13 @@ var LoggingSettingsPatchSchema = object({
29729
29972
  * anyone but its owner.
29730
29973
  */
29731
29974
  var ReportedLoadContributionSchema = LoadContributionSchema.extend({ addonId: string() });
29975
+ /**
29976
+ * One per-camera failure counter, plus WHO reported it.
29977
+ *
29978
+ * Same rule as {@link ReportedLoadContributionSchema}: `addonId` is stamped by
29979
+ * the hub as it enumerates providers, never by the contributor.
29980
+ */
29981
+ var ReportedFailureContributionSchema = FailureContributionSchema.extend({ addonId: string() });
29732
29982
  var GetLoggingSettingsInputSchema = object({
29733
29983
  scopeNodeId: string().optional(),
29734
29984
  /**
@@ -29787,7 +30037,7 @@ method(_void(), FeatureManifestSchema), method(_void(), HealthStatusSchema), met
29787
30037
  }), method(_void(), SiteLocationStatusSchema, {
29788
30038
  kind: "mutation",
29789
30039
  auth: "admin"
29790
- }), method(_void(), RequestCensusStatusSchema, { auth: "admin" }), method(_void(), array(ReportedLoadContributionSchema).readonly(), { auth: "admin" }), method(GetLoggingSettingsInputSchema, LoggingSettingsStateSchema, { auth: "admin" }), method(SetLoggingSettingsInputSchema, LoggingSettingsStateSchema, {
30040
+ }), 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, {
29791
30041
  kind: "mutation",
29792
30042
  auth: "admin"
29793
30043
  });
@@ -32342,6 +32592,12 @@ Object.freeze({
32342
32592
  addonId: null,
32343
32593
  access: "view"
32344
32594
  },
32595
+ "addonSettings.getIntegrationSettings": {
32596
+ capName: "addon-settings",
32597
+ capScope: "system",
32598
+ addonId: null,
32599
+ access: "view"
32600
+ },
32345
32601
  "addonSettings.updateDeviceSettings": {
32346
32602
  capName: "addon-settings",
32347
32603
  capScope: "system",
@@ -34004,6 +34260,12 @@ Object.freeze({
34004
34260
  addonId: null,
34005
34261
  access: "create"
34006
34262
  },
34263
+ "failureContribution.list": {
34264
+ capName: "failure-contribution",
34265
+ capScope: "system",
34266
+ addonId: null,
34267
+ access: "view"
34268
+ },
34007
34269
  "fanControl.setDirection": {
34008
34270
  capName: "fan-control",
34009
34271
  capScope: "device",
@@ -37310,6 +37572,12 @@ Object.freeze({
37310
37572
  addonId: null,
37311
37573
  access: "create"
37312
37574
  },
37575
+ "system.getFailureContributions": {
37576
+ capName: "system",
37577
+ capScope: "system",
37578
+ addonId: null,
37579
+ access: "view"
37580
+ },
37313
37581
  "system.getLoadContributions": {
37314
37582
  capName: "system",
37315
37583
  capScope: "system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/addon-provider-hikvision",
3
- "version": "1.2.44",
3
+ "version": "1.2.46",
4
4
  "description": "Hikvision camera device provider addon for CamStack — ISAPI over HTTP(S) with digest auth (snapshot, alarm stream, RTSP discovery)",
5
5
  "keywords": [
6
6
  "camstack",