@camstack/types 1.2.119 → 1.2.122
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 +2 -1
- package/dist/addon.mjs +2 -1
- package/dist/capabilities/failure-contribution.cap.d.ts +111 -0
- package/dist/capabilities/index.d.ts +5 -2
- package/dist/capabilities/metrics-provider.cap.d.ts +68 -1
- package/dist/capabilities/pipeline-analytics.cap.d.ts +6 -0
- package/dist/capabilities/recording.cap.d.ts +4 -4
- package/dist/capabilities/system.cap.d.ts +57 -1
- package/dist/generated/addon-api.d.ts +23 -0
- package/dist/generated/capability-router-map.d.ts +5 -2
- package/dist/generated/collection-array-methods.d.ts +1 -1
- package/dist/generated/method-access-map.d.ts +1 -1
- package/dist/generated/system-proxy.d.ts +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +453 -9
- package/dist/index.mjs +445 -10
- package/dist/interfaces/event-bus.d.ts +11 -1
- package/dist/interfaces/metrics-provider.d.ts +3 -1
- package/dist/interfaces/recording-config.d.ts +4 -5
- package/dist/metrics/failure-counters.d.ts +173 -0
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ import type { PipelineEngineChoice } from '../types/pipeline.js';
|
|
|
7
7
|
import type { PipelineExecutionTrace, StepCadence } from '../types/pipeline-step.js';
|
|
8
8
|
import type { CameraMetrics } from './api-shared.js';
|
|
9
9
|
import type { FrameHandle } from './frame-handle.js';
|
|
10
|
-
import type { NodeProcess, SystemResourceSnapshot } from './metrics-provider.js';
|
|
10
|
+
import type { ContainerMemorySnapshot, NodeProcess, SystemResourceSnapshot } from './metrics-provider.js';
|
|
11
11
|
import type { RunnerLocalLoad } from './pipeline-runner-capability.js';
|
|
12
12
|
import type { BrokerStats } from './stream-broker.js';
|
|
13
13
|
export interface EventSource {
|
|
@@ -1198,6 +1198,16 @@ export interface EventCatalog {
|
|
|
1198
1198
|
readonly nodeId: string;
|
|
1199
1199
|
readonly processes: ReadonlyArray<NodeProcess>;
|
|
1200
1200
|
readonly timestamp: number;
|
|
1201
|
+
/**
|
|
1202
|
+
* The CONTAINER's memory at the SAME instant as `processes`, or `null`
|
|
1203
|
+
* when this node has no cgroup.
|
|
1204
|
+
*
|
|
1205
|
+
* It rides this event rather than one of its own for a single reason: the
|
|
1206
|
+
* question is a subtraction. The processes above sum to one number and
|
|
1207
|
+
* this is another, and two events would carry two timestamps that never
|
|
1208
|
+
* quite line up. `null` is ABSENT — never a zeroed reading.
|
|
1209
|
+
*/
|
|
1210
|
+
readonly containerMemory: ContainerMemorySnapshot | null;
|
|
1201
1211
|
};
|
|
1202
1212
|
/**
|
|
1203
1213
|
* Per-agent hwaccel override changed (set / cleared / re-probed). Payload
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
|
-
import type { CpuBreakdownSchema, MemoryInfoSchema, DiskIoSnapshotSchema, NetworkIoSnapshotSchema, MetricsGpuInfoSchema, ProcessResourceInfoSchema, PressureInfoSchema, SystemResourceSnapshotSchema, DiskSpaceInfoSchema, PidResourceStatsSchema, AddonInstanceSchema, NodeProcessSchema, DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, LoadPointSchema, LoadFunctionSeriesSchema, NodeLoadSeriesSchema, GetLoadSeriesInputSchema } from '../capabilities/metrics-provider.cap.js';
|
|
2
|
+
import type { CpuBreakdownSchema, MemoryInfoSchema, DiskIoSnapshotSchema, NetworkIoSnapshotSchema, MetricsGpuInfoSchema, ProcessResourceInfoSchema, PressureInfoSchema, SystemResourceSnapshotSchema, DiskSpaceInfoSchema, PidResourceStatsSchema, AddonInstanceSchema, NodeProcessSchema, DumpHeapSnapshotInputSchema, DumpHeapSnapshotResultSchema, LoadPointSchema, LoadFunctionSeriesSchema, ContainerMemorySnapshotSchema, ContainerMemoryPointSchema, NodeLoadSeriesSchema, GetLoadSeriesInputSchema } from '../capabilities/metrics-provider.cap.js';
|
|
3
3
|
export type CpuBreakdown = z.infer<typeof CpuBreakdownSchema>;
|
|
4
4
|
export type MemoryInfo = z.infer<typeof MemoryInfoSchema>;
|
|
5
5
|
export type DiskIoSnapshot = z.infer<typeof DiskIoSnapshotSchema>;
|
|
@@ -16,5 +16,7 @@ export type DumpHeapSnapshotInput = z.infer<typeof DumpHeapSnapshotInputSchema>;
|
|
|
16
16
|
export type DumpHeapSnapshotResult = z.infer<typeof DumpHeapSnapshotResultSchema>;
|
|
17
17
|
export type LoadSeriesPoint = z.infer<typeof LoadPointSchema>;
|
|
18
18
|
export type LoadFunctionSeries = z.infer<typeof LoadFunctionSeriesSchema>;
|
|
19
|
+
export type ContainerMemorySnapshot = z.infer<typeof ContainerMemorySnapshotSchema>;
|
|
20
|
+
export type ContainerMemoryPoint = z.infer<typeof ContainerMemoryPointSchema>;
|
|
19
21
|
export type NodeLoadSeries = z.infer<typeof NodeLoadSeriesSchema>;
|
|
20
22
|
export type GetLoadSeriesInput = z.infer<typeof GetLoadSeriesInputSchema>;
|
|
@@ -6,11 +6,10 @@ import { type CamProfile } from '../capabilities/schemas/streaming-shared.js';
|
|
|
6
6
|
* timestamp + postMs]`). Matches the admin-ui clip window (−5s/+10s).
|
|
7
7
|
*
|
|
8
8
|
* Every consumer derives from this ONE constant so event↔footage boundaries
|
|
9
|
-
* agree everywhere (C1):
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* their `startMs/endMs` with it.
|
|
9
|
+
* agree everywhere (C1): today that is the `videoclips` default provider
|
|
10
|
+
* (addon-post-analysis), which pads its clip windows with it. The recorder used
|
|
11
|
+
* to pad in-RAM playback markers with it too; those markers had no reader
|
|
12
|
+
* anywhere in the repo and were deleted on 2026-08-29.
|
|
14
13
|
*
|
|
15
14
|
* NOTE: this is a UI/JOIN convention, NOT the `events`-band keep/discard gate —
|
|
16
15
|
* that uses the per-device `preBufferSec`/`postBufferSec` config.
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `FailureCounters` — the per-camera counter every "how often does this camera
|
|
3
|
+
* lose work, and why" question is answered from.
|
|
4
|
+
*
|
|
5
|
+
* ## Why a primitive and not four counters
|
|
6
|
+
*
|
|
7
|
+
* Four open failure modes were being triaged on 2026-08-28 and every one of
|
|
8
|
+
* them was measured the same way: grep a log line, count it, and then guess at
|
|
9
|
+
* the denominator. The guess is the defect. `enrichment crop native miss` read
|
|
10
|
+
* as "35x worse than yesterday" and turned out to be **flat all day** the
|
|
11
|
+
* moment it was divided by the successes on the same path — 0.25 misses per
|
|
12
|
+
* landed capture, 0.08–0.33 across twelve hours, no trend. The count moved
|
|
13
|
+
* because the traffic moved.
|
|
14
|
+
*
|
|
15
|
+
* So the unit here is not a counter. It is a **ratio with its denominator
|
|
16
|
+
* attached**: {@link FailureCounterSample.attempts} is incremented on every
|
|
17
|
+
* try, {@link FailureCounterSample.succeeded} on the ones that landed, and the
|
|
18
|
+
* reasons partition the rest. A consumer can always divide; it can never
|
|
19
|
+
* un-divide a bare count.
|
|
20
|
+
*
|
|
21
|
+
* ## Per camera, always
|
|
22
|
+
*
|
|
23
|
+
* The key is the numeric `deviceId` — the same value every log line in this
|
|
24
|
+
* repo carries as `tags.deviceId`. There is no fleet-total mode and no
|
|
25
|
+
* device-less bucket, because the question is always "why is 617 worse than
|
|
26
|
+
* 615?" and a fleet total cannot answer it. A caller that cannot name the
|
|
27
|
+
* camera must not note anything: an unnamed per-camera count is
|
|
28
|
+
* indistinguishable from a shared one, which is how one camera's failures
|
|
29
|
+
* quietly become everybody's.
|
|
30
|
+
*
|
|
31
|
+
* ## Cumulative, never drained
|
|
32
|
+
*
|
|
33
|
+
* A read NEVER resets anything. `load-contribution.cap.ts` already argued this
|
|
34
|
+
* for CPU seconds and the argument carries over verbatim: *"a rate needs a
|
|
35
|
+
* window, a window needs a sampler, and a new per-node sampler is the defect
|
|
36
|
+
* half of `docs/architecture/load-ledger.md` documents. A counter can be
|
|
37
|
+
* differenced by whoever already keeps a history; a rate cannot be
|
|
38
|
+
* un-averaged."* A draining read has a second failure this surface cannot
|
|
39
|
+
* afford — two consumers polling it would each destroy half of the other's
|
|
40
|
+
* numbers, silently.
|
|
41
|
+
*
|
|
42
|
+
* {@link FailureCounterSample.sinceMs} is the incarnation marker: it is when
|
|
43
|
+
* this counter started, and a consumer differencing two reads must drop the
|
|
44
|
+
* interval when it changes, because the counter restarted from zero in a new
|
|
45
|
+
* process.
|
|
46
|
+
*
|
|
47
|
+
* ## Bounded, and the bound is the point
|
|
48
|
+
*
|
|
49
|
+
* This lives in the memory of a process that is already the subject of an RSS
|
|
50
|
+
* budget, so both dimensions are capped: {@link MAX_KEYS} counters and
|
|
51
|
+
* {@link MAX_REASONS_PER_KEY} distinct reasons within one. Past the reason cap
|
|
52
|
+
* the counts are folded into {@link OVERFLOW_REASON} rather than dropped —
|
|
53
|
+
* losing them would make `attempts - succeeded` stop equalling the reason
|
|
54
|
+
* total, and the ratio the whole surface exists to publish would quietly stop
|
|
55
|
+
* adding up. Past the key cap a new key is refused and
|
|
56
|
+
* {@link FailureCounters.keysRefused} says so, so the omission is visible
|
|
57
|
+
* instead of silent.
|
|
58
|
+
*
|
|
59
|
+
* ## No timers, no IO, no logging
|
|
60
|
+
*
|
|
61
|
+
* Pure. It is read on whatever beat the caller already has. A telemetry
|
|
62
|
+
* primitive that schedules its own work is a second sampler, and this repo has
|
|
63
|
+
* paid for one of those already (`docs/architecture/load-ledger.md`).
|
|
64
|
+
*/
|
|
65
|
+
/** Distinct reason strings kept per counter before folding. */
|
|
66
|
+
export declare const MAX_REASONS_PER_KEY = 16;
|
|
67
|
+
/**
|
|
68
|
+
* Distinct (device, family, variant) counters one instance will hold.
|
|
69
|
+
*
|
|
70
|
+
* A large fleet x the handful of families any single addon reports, with
|
|
71
|
+
* slack. At ~200 B per counter this is a ~100 KB ceiling on a process that
|
|
72
|
+
* already declares an RSS budget in the gigabytes.
|
|
73
|
+
*/
|
|
74
|
+
export declare const MAX_KEYS = 1024;
|
|
75
|
+
/**
|
|
76
|
+
* Where reasons past {@link MAX_REASONS_PER_KEY} go.
|
|
77
|
+
*
|
|
78
|
+
* They are FOLDED, never dropped: `attempts - succeeded` must always equal the
|
|
79
|
+
* sum of the reason counts, or the ratio stops adding up.
|
|
80
|
+
*/
|
|
81
|
+
export declare const OVERFLOW_REASON = "other";
|
|
82
|
+
/** One reason and how many times it was the reason. */
|
|
83
|
+
export interface FailureReasonCount {
|
|
84
|
+
readonly reason: string;
|
|
85
|
+
readonly count: number;
|
|
86
|
+
}
|
|
87
|
+
/** One (device, family[, variant]) counter, read. */
|
|
88
|
+
export interface FailureCounterSample {
|
|
89
|
+
readonly deviceId: number;
|
|
90
|
+
/**
|
|
91
|
+
* The failing path, in the contributor's own vocabulary — `enrichment-crop`,
|
|
92
|
+
* `inference`, `plate-ocr`. Free-form because the families are owned by
|
|
93
|
+
* different addons and a shared enum would be a central list that rots
|
|
94
|
+
* invisibly the first time somebody adds a path (the argument
|
|
95
|
+
* `load-contribution.cap.ts` makes about pid maps, applied to reasons).
|
|
96
|
+
*/
|
|
97
|
+
readonly family: string;
|
|
98
|
+
/**
|
|
99
|
+
* An optional second dimension WITHIN the family — the model or step id for
|
|
100
|
+
* an inference timeout, so "which camera AND which model" is answerable
|
|
101
|
+
* without a second surface. Absent when the family has only one variant.
|
|
102
|
+
*/
|
|
103
|
+
readonly variant?: string;
|
|
104
|
+
/**
|
|
105
|
+
* Epoch ms this counter started — the incarnation marker. A consumer
|
|
106
|
+
* differencing two reads drops the interval when it changes, because the
|
|
107
|
+
* counter restarted from zero in a new process.
|
|
108
|
+
*/
|
|
109
|
+
readonly sinceMs: number;
|
|
110
|
+
/** Epoch ms it was read. `atMs - sinceMs` is the interval it covers. */
|
|
111
|
+
readonly atMs: number;
|
|
112
|
+
/** THE DENOMINATOR. Every try, landed or not. */
|
|
113
|
+
readonly attempts: number;
|
|
114
|
+
/** Tries that landed. `attempts - succeeded` is the loss. */
|
|
115
|
+
readonly succeeded: number;
|
|
116
|
+
/** Why the rest did not, partitioned. Sums to `attempts - succeeded`. */
|
|
117
|
+
readonly reasons: readonly FailureReasonCount[];
|
|
118
|
+
}
|
|
119
|
+
/** What one observation says. */
|
|
120
|
+
export interface FailureObservation {
|
|
121
|
+
readonly deviceId: number;
|
|
122
|
+
readonly family: string;
|
|
123
|
+
readonly variant?: string;
|
|
124
|
+
/**
|
|
125
|
+
* `undefined` = the attempt LANDED. A string = it did not, and this is why.
|
|
126
|
+
* There is no third state: a call that cannot say which it was must not be
|
|
127
|
+
* noted, because an attempt with no outcome moves the denominator without
|
|
128
|
+
* moving anything else and silently improves the ratio.
|
|
129
|
+
*/
|
|
130
|
+
readonly reason?: string;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* A bounded set of per-camera, cumulative failure counters.
|
|
134
|
+
*
|
|
135
|
+
* One instance per contributing subsystem. `note` is O(1) and allocation-free
|
|
136
|
+
* on the steady path; `snapshot` reads without mutating anything.
|
|
137
|
+
*/
|
|
138
|
+
export declare class FailureCounters {
|
|
139
|
+
private readonly maxKeys;
|
|
140
|
+
private readonly maxReasons;
|
|
141
|
+
private readonly counters;
|
|
142
|
+
private refused;
|
|
143
|
+
constructor(maxKeys?: number, maxReasons?: number);
|
|
144
|
+
/**
|
|
145
|
+
* Counters refused because {@link MAX_KEYS} was already held.
|
|
146
|
+
*
|
|
147
|
+
* Cumulative for the life of the instance: a bound that bit is a fact about
|
|
148
|
+
* the deployment, and a surface that hid it would under-report a fleet
|
|
149
|
+
* precisely when the fleet got large enough to matter.
|
|
150
|
+
*/
|
|
151
|
+
get keysRefused(): number;
|
|
152
|
+
/** Counters currently held. */
|
|
153
|
+
get size(): number;
|
|
154
|
+
/**
|
|
155
|
+
* Fold one observation in.
|
|
156
|
+
*
|
|
157
|
+
* A non-positive or non-integer `deviceId` is REFUSED rather than bucketed:
|
|
158
|
+
* see the module docblock — an entry that cannot name its camera is worse
|
|
159
|
+
* than no entry.
|
|
160
|
+
*/
|
|
161
|
+
note(observation: FailureObservation, nowMs: number): void;
|
|
162
|
+
/** Read every counter. Never mutates — see the module docblock. */
|
|
163
|
+
snapshot(nowMs: number): readonly FailureCounterSample[];
|
|
164
|
+
/** Drop everything (host disposal). */
|
|
165
|
+
clear(): void;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Losses per attempt, as a ratio — the number the operator actually reads.
|
|
169
|
+
*
|
|
170
|
+
* `null` when there were no attempts: a camera nobody asked anything of has no
|
|
171
|
+
* failure rate, and reporting 0 would say it was perfect.
|
|
172
|
+
*/
|
|
173
|
+
export declare function failureRate(sample: FailureCounterSample): number | null;
|