@mark1russell7/algebra 0.8.5 → 0.8.7

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/build/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as Realization, c as Unit, d as machineProblems, f as readsFired, i as Over, l as Vantage, n as FIRED, o as Timer, r as Machine, s as TransitionDef, t as Expr, u as exprKnobs } from "./machine-yGpVFyfh.js";
2
2
  import { i as replay, n as Replayable, r as Transition, t as ReplayOptions } from "./replay-DRTZc7Pw.js";
3
- import { Extent, Quantity, Rational, Unknown } from "@mark1russell7/quantity";
3
+ import { A as timerBand, C as parseExpr, D as recovery, E as realizationOf, M as timerUnder, N as transitionOn, O as stackedDetection, S as overValues, T as realizationKnobs, _ as detection, a as Detection, b as firings, c as KnobValues, d as Recovery, f as ScheduleOptions, g as algebraProblems, h as TimerBounds, i as Band, j as timerOf, k as synGiveUpSends, l as Manifestation, m as Situation, n as RunMachineOptions, o as Detector, p as Scheduled, r as runMachine, s as Firing, t as MachineRun, u as Node, v as errnoOf, w as probeTrain, x as modelSource, y as evaluate } from "./run-yLPq18NQ.js";
4
4
  /** This function gives one value or many values as an array. */
5
5
  export declare const arr: <T>(value: T | readonly T[]) => readonly T[];
6
6
  /** This function gives the states that a transition leaves. The state "*" is each state that is not final. */
@@ -22,275 +22,4 @@ export declare const fromStates: (m: Pick<Machine, "states">, from: string | rea
22
22
  * lowest floor. On a host with other flows, a scan can find some, and the floor is higher.
23
23
  */
24
24
  export declare const conntrackFloor: (max: number, hz: number, expired?: number) => number;
25
- /**
26
- * This module has the closed forms of the algebra. They give the duration of a timer of a
27
- * machine, and how late and how early it can fire, from the values of its knobs.
28
- *
29
- * A machine document writes each duration in one of four forms (`machine.ts`): a constant, a knob,
30
- * arithmetic over its knobs, or a named model. The arithmetic uses the value of each knob in the
31
- * unit that the document gives to that knob. Thus `tcp_keepalive / 3` of Redis divides whole
32
- * seconds, as Redis does. A model is the formula of the implementation itself, for example the
33
- * retransmission budget of the kernel. The values are exact rationals, not floats: 0.2 s × 1023
34
- * is 204.6 s, not 204.60000000000002.
35
- *
36
- * A knob without a value makes the result unknown, and the result names the knob. A knob that
37
- * nothing sets (no bound) makes a duration without an end.
38
- */
39
- /** This function gives the value of each knob, by the name of the machine for it: an amount, no bound, or unknown and the reason. */
40
- type KnobValues = (name: string) => Extent | Unknown | undefined;
41
- /** Timer bounds tell how long a timer operates, how late it can fire and how early, each in the unit of its document. */
42
- interface TimerBounds {
43
- readonly duration: Extent | Unknown;
44
- readonly lateness?: Extent | Unknown | undefined;
45
- readonly early?: Extent | Unknown | undefined;
46
- }
47
- /** A node is the arithmetic of a document, after the parse. */
48
- type Node = {
49
- readonly op: "num";
50
- readonly n: Rational;
51
- } | {
52
- readonly op: "knob";
53
- readonly name: string;
54
- } | {
55
- readonly op: "+" | "-" | "*" | "/";
56
- readonly a: Node;
57
- readonly b: Node;
58
- } | {
59
- readonly op: "neg";
60
- readonly a: Node;
61
- } | {
62
- readonly op: "min" | "max" | "floor" | "ceil" | "pow";
63
- readonly args: readonly Node[];
64
- };
65
- /** This function parses the arithmetic of a document, or it throws an error that tells where the text stops making sense. */
66
- export declare const parseExpr: (text: string) => Node;
67
- /**
68
- * This function gives the SYNs that a connect sends before it gives up: the first SYN and each
69
- * retransmission (`synGiveUpWaits`). A connect whose SYN does not leave adds each of them to the field
70
- * `drop` of conntrack, and each retransmission to `TCPRetransFail`.
71
- */
72
- export declare const synGiveUpSends: (retries: number, linear: number) => number;
73
- /**
74
- * This function evaluates one duration of a timer of a machine, in the unit that its document
75
- * gives it. The waits of a backoff timer read `fired`, which tells which wait.
76
- */
77
- export declare const evaluate: (doc: Machine, expr: Expr, values: KnobValues, fired?: number) => Extent | Unknown;
78
- /**
79
- * This function gives the bounds of a timer of a machine: how long it operates, how late it can
80
- * fire, how early. For a backoff timer, it gives one of its waits: the wait after `fired` firings.
81
- */
82
- export declare const timerOf: (doc: Machine, timer: string, values: KnobValues, fired?: number) => TimerBounds;
83
- /** A firing is one firing of a backoff timer, after `fired` firings: its time from the arming. */
84
- interface Firing {
85
- readonly fired: number;
86
- /** This time is the sum of the waits to this firing, each less how early it can fire. */
87
- readonly low: Quantity;
88
- /** This time is the sum of the waits to this firing, each plus how late it can fire. */
89
- readonly high: Quantity;
90
- }
91
- /** A recovery tells when the firings of a backoff timer move a connection again after a stall. */
92
- interface Recovery {
93
- /** These are its firings from its arming, up to the first one that surely comes after the end of the stall. */
94
- readonly firings: readonly Firing[];
95
- /**
96
- * These are the firings that can be the first after the end of the stall. There is more than one
97
- * when the end falls in the bounds of a firing: that firing can come before the end or after it.
98
- */
99
- readonly first: readonly number[];
100
- /** This time is the earliest time of the first firing after the end of the stall, from the arming. */
101
- readonly low: Quantity;
102
- /** This time is the latest time of that firing, from the arming. */
103
- readonly high: Quantity;
104
- }
105
- /**
106
- * This function gives the recovery from a stall. A backoff timer continues to fire through a
107
- * stall, and what each firing sends gets through only after the stall ends. Thus the connection
108
- * moves again at the first firing at the end or after it. That firing can be most of a wait after
109
- * the end. A stall that stops immediately after one firing costs almost all of the next, longer
110
- * wait.
111
- *
112
- * The stall counts from the arming of the timer, which is the send that the stall first lost. The
113
- * waits add, and so do how early and how late each can fire.
114
- */
115
- export declare const recovery: (doc: Machine, timer: string, values: KnobValues, stall: Extent) => Recovery | Unknown;
116
- /** A band is the range of times in which a timer fires, from its arming. */
117
- interface Band {
118
- /** This time is the duration less how early the timer can fire. */
119
- readonly low: Extent;
120
- /** This time is the duration plus how late the timer can fire. */
121
- readonly high: Extent;
122
- }
123
- /**
124
- * This function gives the band of a timer from its bounds, exactly, in `unit`. The band goes from
125
- * its duration less its early bound to its duration plus its lateness. A bound that the document
126
- * does not give is zero. A duration without an end gives a band without an end. A keepalive of 11 s, 4 ms early and 352 ms
127
- * late, gives 10.996 s to 11.352 s.
128
- */
129
- export declare const timerBand: (bounds: TimerBounds, unit?: string) => Band | Unknown;
130
- /** A scheduled firing is one firing of a backoff timer, and its time on the timeline. */
131
- interface Scheduled {
132
- /** This count is the wait that ends in this firing: the wait after `fired` firings. */
133
- readonly fired: number;
134
- /** This time is the sum of the waits to this firing, from the first wait of the schedule, in seconds. */
135
- readonly at: Quantity;
136
- }
137
- /** These options tell where the firings of a schedule start and stop. Each stop that they give applies. */
138
- interface ScheduleOptions {
139
- /** This count is the first wait of the schedule. The default is 0, the wait from the arming. */
140
- readonly from?: number | undefined;
141
- /** This count is the most firings to give. */
142
- readonly count?: number | undefined;
143
- /** This time stops the schedule: the schedule keeps no firing after it. */
144
- readonly until?: Extent | undefined;
145
- /** This time stops the schedule after the first firing at it or after it. That firing is in the schedule. */
146
- readonly reach?: Extent | undefined;
147
- }
148
- /**
149
- * This function gives the firings of a backoff timer on a timeline: the sum of its waits, exactly,
150
- * from the wait `from`. It stops at the first wait that is not a known amount, or at a stop of the
151
- * options, or after 4096 firings. Each time is the duration of the waits, without how early or
152
- * late each can fire.
153
- *
154
- * Two examples: the retransmission timer of Linux gives the send of each retransmission. The
155
- * retry of a call with a deadline gives the start of each try.
156
- */
157
- export declare const firings: (doc: Machine, timer: string, values: KnobValues, options: ScheduleOptions) => Scheduled[];
158
- /**
159
- * This function gives the times of a train of probes, exactly, in seconds. The first probe is at
160
- * `first`, and each next probe is one `interval` later, `count` probes in all. A first time without
161
- * an end gives no probe. An interval without an end gives only the first probe. Keepalive at its
162
- * defaults sends its probes at 7200 s, 7275 s, and so on to 7800 s.
163
- */
164
- export declare const probeTrain: (first: Extent, interval: Extent, count: number) => Quantity[];
165
- /**
166
- * This function gives how long a mechanism takes where a machine operates, from the realization
167
- * of its document. The realization is one of its timers, whole, or its own duration, lateness and
168
- * early bound over the knobs of the machine. It gives undefined when the document does not realize the mechanism.
169
- */
170
- export declare const realizationOf: (doc: Machine, mechanism: string, values: KnobValues) => TimerBounds | undefined;
171
- /** This function gives the knobs that a realization reads, by the names of the machine for them. */
172
- export declare const realizationKnobs: (doc: Machine, mechanism: string) => string[];
173
- /** This function gives what in a document the algebra cannot read: arithmetic that does not parse, or a model that it does not have. */
174
- export declare const algebraProblems: (doc: Machine) => string[];
175
- /** This function gives the source of the formula of a named model, for a reader of a result. */
176
- export declare const modelSource: (name: string) => string | undefined;
177
- /**
178
- * A manifestation is what a failure lets back to the machine: the incoming events that continue
179
- * to arrive while it lasts. A black hole lets nothing back. The kernel of a frozen process
180
- * continues to acknowledge what it gets and to answer keepalive probes, thus its ACKs continue to
181
- * arrive.
182
- */
183
- interface Manifestation {
184
- readonly name: string;
185
- readonly passes: readonly string[];
186
- /**
187
- * These are the events that the failure itself sends one time, for example the FIN of a process
188
- * that stopped with SIGKILL. A delivered event that a transition takes from the state of the connection detects the
189
- * failure at once.
190
- */
191
- readonly delivers?: readonly string[] | undefined;
192
- /**
193
- * This errno replaces ETIMEDOUT when one of these timers gives up. Linux keeps an ICMP error on
194
- * an established socket as a soft error, and the timeout reports it (`tcp_write_err`). An ICMP
195
- * counts only when it quotes a segment in the window (`tcp_v4_err`). A retransmission is in the
196
- * window. A keepalive probe uses the sequence number before `snd_una`, thus its ICMP does not count.
197
- */
198
- readonly errno?: {
199
- readonly errno: string;
200
- readonly timers: readonly string[];
201
- } | undefined;
202
- /**
203
- * These are the durations that the failure changes, by timer. For example, an ICMP host
204
- * unreachable for each retransmission reverts the backoff of the retransmission timer.
205
- */
206
- readonly replaces?: Readonly<Record<string, {
207
- readonly duration?: Expr;
208
- readonly lateness?: Expr;
209
- readonly early?: Expr;
210
- }>> | undefined;
211
- }
212
- /** A situation is the activity of the connection when the failure started. */
213
- interface Situation {
214
- /** This name is the state of the machine, for example ESTABLISHED. */
215
- readonly state: string;
216
- /** This flag tells if it had sent data that the peer had not acknowledged. */
217
- readonly inFlight: boolean;
218
- }
219
- /** A detector is a timer that can still fire, how long it operates, and the event that it fires. */
220
- interface Detector {
221
- readonly timer: string;
222
- readonly fires: string;
223
- readonly duration: Extent | Unknown;
224
- /** This identifier is the machine below whose timer it is, when the timer is not of the machine itself (`over`). */
225
- readonly beneath?: string | undefined;
226
- }
227
- /** A detection is the result of the minimum over the live detectors. */
228
- interface Detection {
229
- /** These are the timers that can still fire, the soonest first. */
230
- readonly detectors: readonly Detector[];
231
- /** This detector is the first to fire, or null when none can fire in a known time: a silent failure. */
232
- readonly first: Detector | null;
233
- /** These are the live detectors whose time nothing gives. Then `first` is only an upper bound. */
234
- readonly unsettled: readonly string[];
235
- /** These are the timers that are armed but cannot fire, and the reason for each. */
236
- readonly held: ReadonlyArray<{
237
- readonly timer: string;
238
- readonly why: string;
239
- }>;
240
- /**
241
- * These are the events that the failure delivers and that a transition takes from the state:
242
- * each detects the failure at once, before any timer. The errno is the errno of the transition,
243
- * or null for an end of file.
244
- */
245
- readonly delivered: ReadonlyArray<{
246
- readonly event: string;
247
- readonly to: string;
248
- readonly errno: string | null;
249
- }>;
250
- }
251
- /**
252
- * This function gives the detection: the minimum over the detectors that are live in the
253
- * situation. The entry to the state arms a timer, and so does what the failure causes: data in
254
- * flight without an acknowledgment gets a retransmission. An event that occurs cancels a timer.
255
- *
256
- * An event that arms the timer again, and that the failure continues to let through, stops it
257
- * before it fires. For example, the kernel of a frozen process answers each keepalive probe.
258
- * Without a live detector, the failure is silent at the level of this machine. Only something
259
- * above it, the timeout of an application or a heartbeat, can find it. The result is only as good
260
- * as the events that the document names.
261
- */
262
- export declare const detection: (doc: Machine, situation: Situation, manifestation: Manifestation, values: KnobValues) => Detection;
263
- /**
264
- * This function gives the bounds of a timer of a machine under a failure: its own bounds, with each
265
- * duration that the manifestation replaces.
266
- */
267
- export declare const timerUnder: (doc: Machine, timer: string, values: KnobValues, manifestation: Manifestation, fired?: number) => TimerBounds;
268
- /**
269
- * This function gives the errno of a detection by a timer: the errno of the transition that its
270
- * event takes from the state. A soft error of the manifestation replaces ETIMEDOUT, but only for
271
- * the timers whose segments its ICMP quotes in the window.
272
- */
273
- export declare const errnoOf: (doc: Machine, state: string, detector: {
274
- readonly timer: string;
275
- readonly fires: string;
276
- }, manifestation: Manifestation) => string | null;
277
- /** This function gives the transition that a machine takes from a state on an event, by its document. */
278
- export declare const transitionOn: (doc: Machine, state: string, event: string) => TransitionDef | undefined;
279
- /**
280
- * This function gives the values of a machine for the machine that it operates on. These are the
281
- * knobs that it sets, evaluated over its own knobs, and the other knobs of the lower machine. The
282
- * keepAlive of ioredis at 5000 ms is the keepidle of the kernel at 5 s.
283
- */
284
- export declare const overValues: (upper: Machine, upperValues: KnobValues, lowerValues: KnobValues) => KnobValues;
285
- /**
286
- * This function gives the detection through the machine that a machine operates on. The detectors
287
- * of the lower machine are live in the state below the state of this machine. They use the knobs
288
- * that this machine sets.
289
- *
290
- * Each one reaches this machine as the event that the end of the lower
291
- * machine gives. They are beside the timers of this machine, and the first of all of them is the
292
- * first detection. A failure lets nothing new through to a machine above the socket, only the end
293
- * of the socket. Thus the timers of this machine see only what its state arms.
294
- */
295
- export declare const stackedDetection: (upper: Machine, lower: Machine, situation: Situation, manifestation: Manifestation, upperValues: KnobValues, lowerValues: KnobValues) => Detection;
296
- export { type Band, type Detection, type Detector, type Expr, FIRED, type Firing, type KnobValues, type Machine, type Manifestation, type Node, type Over, type Realization, type Recovery, type ReplayOptions, type Replayable, type ScheduleOptions, type Scheduled, type Situation, type Timer, type TimerBounds, type Transition, type TransitionDef, type Unit, type Vantage, exprKnobs, machineProblems, readsFired, replay };
25
+ export { type Band, type Detection, type Detector, type Expr, FIRED, type Firing, type KnobValues, type Machine, type MachineRun, type Manifestation, type Node, type Over, type Realization, type Recovery, type ReplayOptions, type Replayable, type RunMachineOptions, type ScheduleOptions, type Scheduled, type Situation, type Timer, type TimerBounds, type Transition, type TransitionDef, type Unit, type Vantage, algebraProblems, detection, errnoOf, evaluate, exprKnobs, firings, machineProblems, modelSource, overValues, parseExpr, probeTrain, readsFired, realizationKnobs, realizationOf, recovery, replay, runMachine, stackedDetection, synGiveUpSends, timerBand, timerOf, timerUnder, transitionOn };