@mark1russell7/kind 0.1.8 → 0.2.0

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.
@@ -79,6 +79,15 @@ declare const cidrOverlap: (a: string, b: string) => boolean;
79
79
  //#region src/cell.d.ts
80
80
  /** A template is the topology of a cell: T07, the endpoint lifecycle of a Service, or T18, a health-gated fleet. */
81
81
  type Template = "T07" | "T18";
82
+ /**
83
+ * A stack is the server and the clients of a cell:
84
+ * - `service`: the service of this repository with its declaration, and the HTTP client, which opens a
85
+ * new connection for each request. Thus kube-proxy picks a backend for each request.
86
+ * - `grpc`: the server of grpc-go v1.84.0 of the harness, and a client of grpc-js 1.14.6 with one channel
87
+ * at its defaults. The channel holds one connection. It connects again only when that connection
88
+ * ends: at a GOAWAY of the server, or at the end of its socket.
89
+ */
90
+ type Stack = "service" | "grpc";
82
91
  /**
83
92
  * A trigger is the event or the fault of a cell, by the name of the plan:
84
93
  * - `pod-deletion`, `rolling-update`, `node-drain` and `scale-in` stop a pod with its grace.
@@ -157,11 +166,17 @@ interface Declaration {
157
166
  readonly threshold: Quantity;
158
167
  } | null;
159
168
  }
160
- /** A workload is the clients: one pod on each node, each with requests on new connections to the ClusterIP. */
169
+ /**
170
+ * A workload is the clients: one pod on each node, each with requests to the ClusterIP. The HTTP client
171
+ * opens a new connection for each request. The gRPC client sends each call on its one channel.
172
+ */
161
173
  interface Workload {
162
174
  /** This time is the interval between two requests of one client. The clients do not wait for an answer. */
163
175
  readonly every: Quantity;
164
- /** This time is how long a client waits for an answer before the request is a timeout. */
176
+ /**
177
+ * This time is how long a client waits for an answer before the request is a timeout. A call of
178
+ * gRPC has no deadline at the defaults of grpc-js, thus the client cancels it at this time.
179
+ */
165
180
  readonly timeout: Quantity;
166
181
  }
167
182
  /**
@@ -295,13 +310,16 @@ interface KindCell<A = Quantity> {
295
310
  readonly id: string;
296
311
  readonly name: string;
297
312
  readonly template: Template;
313
+ /** This stack is the server and the clients of the cell. Without it, the cell has the service (`service`). */
314
+ readonly stack?: Stack | undefined;
298
315
  /** This text names a system of the plan that the cell replaces with the service of this repository, or null. */
299
316
  readonly substitutes: string | null;
300
317
  readonly mode: KubeProxyMode;
301
318
  readonly workers: number;
302
319
  readonly trigger: Trigger<A>;
303
320
  readonly pod: PodSettings;
304
- readonly declaration: Declaration;
321
+ /** This declaration is the settings of the service, or null for a server that is not the service (the stack `grpc`). */
322
+ readonly declaration: Declaration | null;
305
323
  readonly workload: Workload;
306
324
  readonly prediction: Prediction<A>;
307
325
  /** This flag marks a calibration: its runs measure the propagation of the endpoints, and nothing fails. */
@@ -342,7 +360,7 @@ declare const REDIS = "redis";
342
360
  */
343
361
  /**
344
362
  * A line is one JSON line of a source of a run, with its stamp `t` in milliseconds on
345
- * CLOCK_MONOTONIC. It is a request of a client, a record of the service or a probe answer. It is
363
+ * CLOCK_MONOTONIC. It is a request of a client, a record of the service, a line of grpc-go or a probe answer. It is
346
364
  * also a pod, an EndpointSlice or an event of the API. Or it is the backends of the rules of a
347
365
  * node, a kernel record, or an act of the lab. A record keeps each line as its source wrote it.
348
366
  */
@@ -430,15 +448,32 @@ declare const recordsOf: (lines: readonly Line[]) => RecordLine[];
430
448
  declare const failuresOf: (lines: readonly Line[]) => Request[];
431
449
  /** This function counts the outcomes of the requests, by outcome. */
432
450
  declare const outcomesOf: (requests: readonly Request[]) => Record<string, number>;
451
+ /**
452
+ * This function orders the replicas by how many clients each one answered last, the most first,
453
+ * then by name. `answers` gives the backend of the last answer of each client, by client. A client
454
+ * of gRPC holds its connection to one replica, thus the first replica is the one whose stop the
455
+ * most clients see.
456
+ */
457
+ declare const byClients: <T extends {
458
+ readonly pod: string;
459
+ }>(replicas: readonly T[], answers: ReadonlyMap<string, string>) => T[];
433
460
  /** This function gives the requests of each node, by the name of the node. */
434
461
  declare const byNode: (requests: readonly Request[]) => Map<string, Request[]>;
435
462
  /** This function gives the time that the watcher first received a deletion timestamp of one of the pods, after a time. */
436
463
  declare const deletionOf: (lines: readonly Line[], pods: readonly string[], after: number) => number | null;
437
464
  /** This function gives the stamp of a transition of the service in a pod: the first matching record of a machine, after a time. */
438
465
  declare const transitionOf: (lines: readonly Line[], pod: string, machine: string, match: (record: RecordLine) => boolean, after: number) => number | null;
439
- /** This function gives when the service of a pod stopped its intake: the start of the phase `stop intake`. */
466
+ /**
467
+ * This function gives the line `stopping` of grpc-go in a pod, after a time. The server writes it at
468
+ * SIGTERM. Then GracefulStop closes its listener and sends GOAWAY on each connection.
469
+ */
470
+ declare const stoppingOf: (lines: readonly Line[], pod: string, after: number) => number | null;
471
+ /**
472
+ * This function gives when the server of a pod stopped its intake. That is the start of the phase
473
+ * `stop intake` of the service, or the line `stopping` of grpc-go.
474
+ */
440
475
  declare const intakeOf: (lines: readonly Line[], pod: string, after: number) => number | null;
441
- /** This function gives when the service of a pod received its exit signal. */
476
+ /** This function gives when the server of a pod received its exit signal: a record of the service, or the line `stopping` of grpc-go. */
442
477
  declare const signalOf: (lines: readonly Line[], pod: string, after: number) => number | null;
443
478
  /**
444
479
  * This function gives when the rules of a node stopped the selection of a backend: the first poll
@@ -722,5 +757,5 @@ declare const quantileOf: (sorted: readonly number[], p: number) => number;
722
757
  */
723
758
  declare const medianInterval: (sorted: readonly number[]) => [number, number];
724
759
  //#endregion
725
- export { RulesLine as $, cidrOverlap as $t, TriggerV1 as A, secondsOf as At, RunFacts as B, Reference as Bt, KindCellResult as C, HEALTH_PORT as Ct, PredictionV1 as D, SERVER as Dt, LoadSample as E, REDIS as Et, KindDecision as F, KindRun as Ft, referenceOf as G, TriggerKind as Gt, factsOf as H, ResetReuse as Ht, KindVerdict as I, KubeletProbe as It, Endpoint as J, KindConfig as Jt, reusesReset as K, Workload as Kt, LAST_SLACK as L, PodSettings as Lt, upgrade as M, Band as Mt, upgradeCell as N, Declaration as Nt, RunCheckV1 as O, bandOf as Ot, KIND_NOISE as P, KindCell as Pt, Request as Q, NodeImage as Qt, Propagated as R, Prediction as Rt, KindCellRecordV1 as S, CLIENT as St, KindVerdictV1 as T, PORT as Tt, judgeKind as U, Template as Ut, checkRun as V, Replica as Vt, propagationOf as W, Trigger as Wt, PodLine as X, KubeProxyMode as Xt, Line as Y, KindScenario as Yt, RecordLine as Z, NODE_IMAGES as Zt, ClusterManifest as _, signalsOf as _t, STAGES as a, scenario as an, emptyOf as at, FORMAT_V1 as b, slicesOf as bt, readRecord as c, kernelCounts as ct, calibrationOf as d, podsOf as dt, cidrRange as en, SliceLine as et, cellsTable as f, recordsOf as ft, BandV1 as g, signalOf as gt, timeSpread as h, rulesOf as ht, quantileOf as i, nodeNames as in, dropOf as it, judge as j, showBand as jt, RunFactsV1 as k, seconds as kt, Judged as l, outcomesOf as lt, predictionText as m, restartsAt as mt, medianInterval as n, kindConfig as nn, byNode as nt, kindCellRecordSchema as o, scenarioProblems as on, failuresOf as ot, medianText as p, requestsOf as pt, unitOf as q, KUBE_PROXY_MODES as qt, middle as r, kubeProxyPatch as rn, deletionOf as rt, kindCellRecordV1Schema as s, intakeOf as st, RELATIVE as t, goDuration as tn, backendsAt as tt, TimeSpread as u, podsAt as ut, EnvironmentManifest as v, sliceDropOf as vt, KindCellV1 as w, LOG_LABEL as wt, KindCellRecord as x, transitionOf as xt, FORMAT as y, sliceEmptyOf as yt, RunCheck as z, RedisDeclaration as zt };
726
- //# sourceMappingURL=judge-a7yCzwZc.d.ts.map
760
+ export { RulesLine as $, KubeProxyMode as $t, TriggerV1 as A, bandOf as At, RunFacts as B, Prediction as Bt, KindCellResult as C, transitionOf as Ct, PredictionV1 as D, PORT as Dt, LoadSample as E, LOG_LABEL as Et, KindDecision as F, Declaration as Ft, referenceOf as G, Stack as Gt, factsOf as H, Reference as Ht, KindVerdict as I, KindCell as It, Endpoint as J, TriggerKind as Jt, reusesReset as K, Template as Kt, LAST_SLACK as L, KindRun as Lt, upgrade as M, secondsOf as Mt, upgradeCell as N, showBand as Nt, RunCheckV1 as O, REDIS as Ot, KIND_NOISE as P, Band as Pt, Request as Q, KindScenario as Qt, Propagated as R, KubeletProbe as Rt, KindCellRecordV1 as S, stoppingOf as St, KindVerdictV1 as T, HEALTH_PORT as Tt, judgeKind as U, Replica as Ut, checkRun as V, RedisDeclaration as Vt, propagationOf as W, ResetReuse as Wt, PodLine as X, KUBE_PROXY_MODES as Xt, Line as Y, Workload as Yt, RecordLine as Z, KindConfig as Zt, ClusterManifest as _, signalOf as _t, STAGES as a, kindConfig as an, dropOf as at, FORMAT_V1 as b, sliceEmptyOf as bt, readRecord as c, scenario as cn, intakeOf as ct, calibrationOf as d, podsAt as dt, NODE_IMAGES as en, SliceLine as et, cellsTable as f, podsOf as ft, BandV1 as g, rulesOf as gt, timeSpread as h, restartsAt as ht, quantileOf as i, goDuration as in, deletionOf as it, judge as j, seconds as jt, RunFactsV1 as k, SERVER as kt, Judged as l, scenarioProblems as ln, kernelCounts as lt, predictionText as m, requestsOf as mt, medianInterval as n, cidrOverlap as nn, byClients as nt, kindCellRecordSchema as o, kubeProxyPatch as on, emptyOf as ot, medianText as p, recordsOf as pt, unitOf as q, Trigger as qt, middle as r, cidrRange as rn, byNode as rt, kindCellRecordV1Schema as s, nodeNames as sn, failuresOf as st, RELATIVE as t, NodeImage as tn, backendsAt as tt, TimeSpread as u, outcomesOf as ut, EnvironmentManifest as v, signalsOf as vt, KindCellV1 as w, CLIENT as wt, KindCellRecord as x, slicesOf as xt, FORMAT as y, sliceDropOf as yt, RunCheck as z, PodSettings as zt };
761
+ //# sourceMappingURL=judge-D5SBTJ-V.d.ts.map
@@ -50,6 +50,16 @@ const outcomesOf = (requests) => {
50
50
  for (const request of requests) out[request.o] = (out[request.o] ?? 0) + 1;
51
51
  return out;
52
52
  };
53
+ /**
54
+ * This function orders the replicas by how many clients each one answered last, the most first,
55
+ * then by name. `answers` gives the backend of the last answer of each client, by client. A client
56
+ * of gRPC holds its connection to one replica, thus the first replica is the one whose stop the
57
+ * most clients see.
58
+ */
59
+ const byClients = (replicas, answers) => {
60
+ const count = (pod) => [...answers.values()].filter((backend) => backend === pod).length;
61
+ return [...replicas].sort((a, b) => count(b.pod) - count(a.pod) || a.pod.localeCompare(b.pod));
62
+ };
53
63
  /** This function gives the requests of each node, by the name of the node. */
54
64
  const byNode = (requests) => {
55
65
  const out = /* @__PURE__ */ new Map();
@@ -60,10 +70,18 @@ const byNode = (requests) => {
60
70
  const deletionOf = (lines, pods, after) => podsOf(lines).find((pod) => pods.includes(pod.name) && pod.del && pod.t >= after)?.t ?? null;
61
71
  /** This function gives the stamp of a transition of the service in a pod: the first matching record of a machine, after a time. */
62
72
  const transitionOf = (lines, pod, machine, match, after) => recordsOf(lines).find((record) => record.p === pod && record.m === machine && record.at >= after && match(record))?.at ?? null;
63
- /** This function gives when the service of a pod stopped its intake: the start of the phase `stop intake`. */
64
- const intakeOf = (lines, pod, after) => transitionOf(lines, pod, "drain", (record) => record.to === "stop intake", after);
65
- /** This function gives when the service of a pod received its exit signal. */
66
- const signalOf = (lines, pod, after) => transitionOf(lines, pod, "exit", (record) => record.on === "exit.request", after);
73
+ /**
74
+ * This function gives the line `stopping` of grpc-go in a pod, after a time. The server writes it at
75
+ * SIGTERM. Then GracefulStop closes its listener and sends GOAWAY on each connection.
76
+ */
77
+ const stoppingOf = (lines, pod, after) => lines.find((line) => line.ev === "stopping" && line["p"] === pod && line.t >= after)?.t ?? null;
78
+ /**
79
+ * This function gives when the server of a pod stopped its intake. That is the start of the phase
80
+ * `stop intake` of the service, or the line `stopping` of grpc-go.
81
+ */
82
+ const intakeOf = (lines, pod, after) => transitionOf(lines, pod, "drain", (record) => record.to === "stop intake", after) ?? stoppingOf(lines, pod, after);
83
+ /** This function gives when the server of a pod received its exit signal: a record of the service, or the line `stopping` of grpc-go. */
84
+ const signalOf = (lines, pod, after) => transitionOf(lines, pod, "exit", (record) => record.on === "exit.request", after) ?? stoppingOf(lines, pod, after);
67
85
  /**
68
86
  * This function gives when the rules of a node stopped the selection of a backend: the first poll
69
87
  * after a time without it. The change came after `prev`, the poll before it, and at the latest at `t`.
@@ -964,6 +982,7 @@ const recordOf = (a, main) => {
964
982
  id: z.string(),
965
983
  name: z.string(),
966
984
  template: z.enum(["T07", "T18"]),
985
+ stack: z.enum(["service", "grpc"]).optional(),
967
986
  substitutes: z.string().nullable(),
968
987
  mode: z.enum(MODES),
969
988
  workers: count,
@@ -984,7 +1003,7 @@ const recordOf = (a, main) => {
984
1003
  liveness: probe,
985
1004
  startup: probe.nullable()
986
1005
  }),
987
- declaration,
1006
+ declaration: declaration.nullable(),
988
1007
  workload: z.object({
989
1008
  every: time,
990
1009
  timeout: time
@@ -1071,6 +1090,6 @@ const readRecord = (data) => {
1071
1090
  throw new Error(`a kind cell record has the format ${FORMAT} or ${FORMAT_V1}, not ${String(format)}`);
1072
1091
  };
1073
1092
  //#endregion
1074
- export { REDIS as $, deletionOf as A, requestsOf as B, unitOf as C, quantileOf as D, middle as E, kernelCounts as F, sliceDropOf as G, rulesOf as H, outcomesOf as I, transitionOf as J, sliceEmptyOf as K, podsAt as L, emptyOf as M, failuresOf as N, backendsAt as O, intakeOf as P, PORT as Q, podsOf as R, reusesReset as S, medianInterval as T, signalOf as U, restartsAt as V, signalsOf as W, HEALTH_PORT as X, CLIENT as Y, LOG_LABEL as Z, checkRun as _, calibrationOf as a, propagationOf as b, predictionText as c, FORMAT_V1 as d, SERVER as et, judge as f, LAST_SLACK as g, KIND_NOISE as h, readRecord as i, showBand as it, dropOf as j, byNode as k, timeSpread as l, upgradeCell as m, kindCellRecordSchema as n, seconds as nt, cellsTable as o, upgrade as p, slicesOf as q, kindCellRecordV1Schema as r, secondsOf as rt, medianText as s, STAGES as t, bandOf as tt, FORMAT as u, factsOf as v, RELATIVE as w, referenceOf as x, judgeKind as y, recordsOf as z };
1093
+ export { LOG_LABEL as $, byNode as A, recordsOf as B, unitOf as C, quantileOf as D, middle as E, intakeOf as F, signalsOf as G, restartsAt as H, kernelCounts as I, slicesOf as J, sliceDropOf as K, outcomesOf as L, dropOf as M, emptyOf as N, backendsAt as O, failuresOf as P, HEALTH_PORT as Q, podsAt as R, reusesReset as S, medianInterval as T, rulesOf as U, requestsOf as V, signalOf as W, transitionOf as X, stoppingOf as Y, CLIENT as Z, checkRun as _, calibrationOf as a, secondsOf as at, propagationOf as b, predictionText as c, FORMAT_V1 as d, PORT as et, judge as f, LAST_SLACK as g, KIND_NOISE as h, readRecord as i, seconds as it, deletionOf as j, byClients as k, timeSpread as l, upgradeCell as m, kindCellRecordSchema as n, SERVER as nt, cellsTable as o, showBand as ot, upgrade as p, sliceEmptyOf as q, kindCellRecordV1Schema as r, bandOf as rt, medianText as s, STAGES as t, REDIS as tt, FORMAT as u, factsOf as v, RELATIVE as w, referenceOf as x, judgeKind as y, podsOf as z };
1075
1094
 
1076
- //# sourceMappingURL=judge-BbTAxRSd.js.map
1095
+ //# sourceMappingURL=judge-DlmmZHcI.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"judge-DlmmZHcI.js","names":["time","time"],"sources":["../src/bands.ts","../src/names.ts","../src/observe.ts","../src/stats.ts","../src/verdict.ts","../src/record.ts","../src/report.ts","../src/schema.ts"],"sourcesContent":["import type { Quantity } from \"@mark1russell7/quantity\";\nimport { valueIn } from \"@mark1russell7/quantity\";\nimport type { Band } from \"./cell.ts\";\n\n/** This module makes and prints the bands of the predictions. It imports only the amounts. */\n\n/** This function gives a time in seconds as a quantity. */\nexport const seconds = (value: number): Quantity => ({ value, unit: \"s\" });\n\n/** This function gives a band from its two ends in seconds. */\nexport const bandOf = (lo: number, hi: number): Band => ({ lo: seconds(lo), hi: seconds(hi) });\n\n/** This function gives the two ends of a band as numbers of seconds, for arithmetic. */\nexport const secondsOf = (band: Band): { readonly lo: number; readonly hi: number } => ({\n lo: valueIn(band.lo, \"s\"),\n hi: valueIn(band.hi, \"s\"),\n});\n\n/** This function gives a band in a short form for a name or a table: `[28, 49] s`. */\nexport const showBand = (band: Band): string => {\n const { lo, hi } = secondsOf(band);\n return `[${lo}, ${hi}] s`;\n};\n","// The names and the ports of the objects of a cell. The judge reads them, thus this module imports\n// nothing.\n\n/** These are the ports of the app: its server, and its health server for the probes. */\nexport const PORT = 8080;\nexport const HEALTH_PORT = 9000;\n/** This label makes the watcher follow the log of a pod. */\nexport const LOG_LABEL = \"lab.systems/log\";\n/** These are the names of the objects of a cell. */\nexport const SERVER = \"lab\";\nexport const CLIENT = \"client\";\nexport const REDIS = \"redis\";\n","/**\n * This module reads a run from its lines. Each time is in milliseconds on CLOCK_MONOTONIC. All the\n * containers of the VM share that clock: the clients, the service, the agents, the injector, the\n * watcher and the prober.\n */\n\n/**\n * A line is one JSON line of a source of a run, with its stamp `t` in milliseconds on\n * CLOCK_MONOTONIC. It is a request of a client, a record of the service, a line of grpc-go or a probe answer. It is\n * also a pod, an EndpointSlice or an event of the API. Or it is the backends of the rules of a\n * node, a kernel record, or an act of the lab. A record keeps each line as its source wrote it.\n */\nexport interface Line {\n readonly ev: string;\n readonly t: number;\n readonly [field: string]: unknown;\n}\n\n/**\n * A request is one request of a client: its start, its duration in ms, its outcome, its client and\n * the node of the client. The backend (`b`) is the pod that answered. The local port (`lp`) is on\n * each request from 0.1.3, and on the failed ones before it. A conntrack entry is per port, thus the\n * requests on one port show which connection a stale entry came from.\n */\nexport interface Request {\n readonly t: number;\n readonly d: number;\n readonly o: string;\n readonly p: string;\n readonly n: string;\n readonly b?: string;\n readonly lp?: number | null;\n}\n\n/** A pod line is one state of a pod, as the watcher received it. */\nexport interface PodLine {\n readonly t: number;\n readonly type: string;\n readonly name: string;\n readonly node: string | null;\n readonly ip: string | null;\n readonly del: boolean;\n readonly ready: boolean;\n readonly phase: string | null;\n readonly cs: ReadonlyArray<{ readonly n: string; readonly r: boolean; readonly rc: number; readonly st: string; readonly id: string | null }>;\n readonly labels: Readonly<Record<string, string>>;\n}\n\n/** An endpoint is one endpoint of an EndpointSlice: its address, its conditions and its pod. */\nexport interface Endpoint {\n readonly ip: string | null;\n readonly r: boolean | null;\n readonly s: boolean | null;\n readonly x: boolean | null;\n readonly pod: string | null;\n readonly node: string | null;\n}\n\n/** A slice line is one state of an EndpointSlice. */\nexport interface SliceLine {\n readonly t: number;\n readonly type: string;\n readonly name: string;\n readonly svc: string | null;\n readonly eps: readonly Endpoint[];\n}\n\n/** A rules line is the backends of the Service in the rules of one node, after a change. `prev` is the start of the poll before it. */\nexport interface RulesLine {\n readonly t: number;\n readonly prev: number | null;\n readonly node: string;\n readonly b: readonly string[];\n}\n\n/** A record line is one transition of a machine of the service, with its own stamp `at`. */\nexport interface RecordLine {\n readonly t: number;\n readonly at: number;\n readonly p: string;\n readonly m: string;\n readonly i: string;\n readonly from: string;\n readonly to: string;\n readonly on: string;\n readonly d: string | null;\n}\n\nconst of = <T>(lines: readonly Line[], ev: string): T[] => lines.filter((line) => line.ev === ev) as unknown as T[];\n\nexport const requestsOf = (lines: readonly Line[]): Request[] => of<Request>(lines, \"req\");\nexport const podsOf = (lines: readonly Line[]): PodLine[] => of<PodLine>(lines, \"pod\").sort((a, b) => a.t - b.t);\nexport const slicesOf = (lines: readonly Line[], svc: string): SliceLine[] =>\n of<SliceLine>(lines, \"slice\").filter((line) => line.svc === svc);\nexport const rulesOf = (lines: readonly Line[]): RulesLine[] => of<RulesLine>(lines, \"rules\").sort((a, b) => a.t - b.t);\nexport const recordsOf = (lines: readonly Line[]): RecordLine[] => of<RecordLine>(lines, \"rec\");\n\n/** This function gives the requests that did not succeed, in sequence of their start. */\nexport const failuresOf = (lines: readonly Line[]): Request[] =>\n requestsOf(lines)\n .filter((request) => request.o !== \"ok\")\n .sort((a, b) => a.t - b.t);\n\n/** This function counts the outcomes of the requests, by outcome. */\nexport const outcomesOf = (requests: readonly Request[]): Record<string, number> => {\n const out: Record<string, number> = {};\n for (const request of requests) out[request.o] = (out[request.o] ?? 0) + 1;\n return out;\n};\n\n/**\n * This function orders the replicas by how many clients each one answered last, the most first,\n * then by name. `answers` gives the backend of the last answer of each client, by client. A client\n * of gRPC holds its connection to one replica, thus the first replica is the one whose stop the\n * most clients see.\n */\nexport const byClients = <T extends { readonly pod: string }>(replicas: readonly T[], answers: ReadonlyMap<string, string>): T[] => {\n const count = (pod: string): number => [...answers.values()].filter((backend) => backend === pod).length;\n return [...replicas].sort((a, b) => count(b.pod) - count(a.pod) || a.pod.localeCompare(b.pod));\n};\n\n/** This function gives the requests of each node, by the name of the node. */\nexport const byNode = (requests: readonly Request[]): Map<string, Request[]> => {\n const out = new Map<string, Request[]>();\n for (const request of requests) out.set(request.n, [...(out.get(request.n) ?? []), request]);\n return out;\n};\n\n/** This function gives the time that the watcher first received a deletion timestamp of one of the pods, after a time. */\nexport const deletionOf = (lines: readonly Line[], pods: readonly string[], after: number): number | null =>\n podsOf(lines).find((pod) => pods.includes(pod.name) && pod.del && pod.t >= after)?.t ?? null;\n\n/** This function gives the stamp of a transition of the service in a pod: the first matching record of a machine, after a time. */\nexport const transitionOf = (\n lines: readonly Line[],\n pod: string,\n machine: string,\n match: (record: RecordLine) => boolean,\n after: number,\n): number | null =>\n recordsOf(lines).find((record) => record.p === pod && record.m === machine && record.at >= after && match(record))?.at ?? null;\n\n/**\n * This function gives the line `stopping` of grpc-go in a pod, after a time. The server writes it at\n * SIGTERM. Then GracefulStop closes its listener and sends GOAWAY on each connection.\n */\nexport const stoppingOf = (lines: readonly Line[], pod: string, after: number): number | null =>\n lines.find((line) => line.ev === \"stopping\" && line[\"p\"] === pod && line.t >= after)?.t ?? null;\n\n/**\n * This function gives when the server of a pod stopped its intake. That is the start of the phase\n * `stop intake` of the service, or the line `stopping` of grpc-go.\n */\nexport const intakeOf = (lines: readonly Line[], pod: string, after: number): number | null =>\n transitionOf(lines, pod, \"drain\", (record) => record.to === \"stop intake\", after) ?? stoppingOf(lines, pod, after);\n\n/** This function gives when the server of a pod received its exit signal: a record of the service, or the line `stopping` of grpc-go. */\nexport const signalOf = (lines: readonly Line[], pod: string, after: number): number | null =>\n transitionOf(lines, pod, \"exit\", (record) => record.on === \"exit.request\", after) ?? stoppingOf(lines, pod, after);\n\n/**\n * This function gives when the rules of a node stopped the selection of a backend: the first poll\n * after a time without it. The change came after `prev`, the poll before it, and at the latest at `t`.\n */\nexport const dropOf = (lines: readonly Line[], node: string, backend: string, after: number): RulesLine | null =>\n rulesOf(lines).find((line) => line.node === node && line.t >= after && !line.b.includes(backend)) ?? null;\n\n/** This function gives when the rules of a node had no backend of the Service, after a time. */\nexport const emptyOf = (lines: readonly Line[], node: string, after: number): RulesLine | null =>\n rulesOf(lines).find((line) => line.node === node && line.t >= after && line.b.length === 0) ?? null;\n\n/** This function gives when an EndpointSlice of the Service first had no ready endpoint, after a time. */\nexport const sliceEmptyOf = (lines: readonly Line[], svc: string, after: number): number | null =>\n slicesOf(lines, svc).find((slice) => slice.t >= after && !slice.eps.some((endpoint) => endpoint.r === true))?.t ?? null;\n\n/** This function gives when the endpoint of an address was first not ready in the EndpointSlice of the Service, after a time. */\nexport const sliceDropOf = (lines: readonly Line[], svc: string, ip: string, after: number): number | null =>\n slicesOf(lines, svc).find((slice) => slice.t >= after && !slice.eps.some((endpoint) => endpoint.ip === ip && endpoint.r === true))?.t ?? null;\n\n/** This function gives the latest state of each pod at a time, by its name. A deleted pod is not in it. */\nexport const podsAt = (lines: readonly Line[], at: number): Map<string, PodLine> => {\n const out = new Map<string, PodLine>();\n for (const pod of podsOf(lines)) {\n if (pod.t > at) break;\n if (pod.type === \"DELETED\") out.delete(pod.name);\n else out.set(pod.name, pod);\n }\n return out;\n};\n\n/** This function gives the latest backends of each node at a time, by node. */\nexport const backendsAt = (lines: readonly Line[], at: number): Map<string, readonly string[]> => {\n const out = new Map<string, readonly string[]>();\n for (const line of rulesOf(lines)) {\n if (line.t > at) break;\n out.set(line.node, line.b);\n }\n return out;\n};\n\n/** This function gives the kernel records of the kinds that the lab keeps, counted by kind. */\nexport const kernelCounts = (lines: readonly Line[]): Record<string, number> => {\n const out: Record<string, number> = {};\n for (const line of lines) if (line.ev.startsWith(\"kernel.\")) out[line.ev.slice(7)] = (out[line.ev.slice(7)] ?? 0) + 1;\n return out;\n};\n\n/** This function gives the SIGTERM of each pod in a set after a time, by pod. A pod without one is not in it. */\nexport const signalsOf = (lines: readonly Line[], pods: readonly string[], after: number): Map<string, number> => {\n const out = new Map<string, number>();\n for (const pod of pods) {\n const at = signalOf(lines, pod, after);\n if (at !== null) out.set(pod, at);\n }\n return out;\n};\n\n/** This function gives the restart count of each container of each pod at a time, summed by pod. */\nexport const restartsAt = (lines: readonly Line[], at: number): Map<string, number> => {\n const out = new Map<string, number>();\n for (const [name, pod] of podsAt(lines, at)) out.set(name, pod.cs.reduce((sum, status) => sum + status.rc, 0));\n return out;\n};\n","// The statistics of a kind verdict: the median, the interval of the median and a quantile. They are\n// the statistics of the verdict of the harness, and a test holds them to it. The judge reads a\n// record without the harness, because the harness loads its Docker lab.\n\n/** This fraction, δ_rel, is how far the median of a cell can be outside its band and stay equivalent. */\nexport const RELATIVE = 0.05;\n\n/** This function gives the median of sorted values: the middle value, or the mean of the two middle values. */\nexport const middle = (sorted: readonly number[]): number => {\n const half = Math.floor(sorted.length / 2);\n return sorted.length % 2 === 1 ? sorted[half]! : (sorted[half - 1]! + sorted[half]!) / 2;\n};\n\n/** This function gives the value at quantile p of sorted values, by nearest rank: x_(⌈p·n⌉). */\nexport const quantileOf = (sorted: readonly number[], p: number): number =>\n sorted[Math.min(sorted.length, Math.max(1, Math.ceil(p * sorted.length))) - 1]!;\n\n/** This function gives P(X ≤ j) for X ~ Binomial(n, 1/2), exactly. */\nconst below = (n: number, j: number): number => {\n let term = 1;\n let sum = 0;\n for (let i = 0; i <= j; i += 1) {\n sum += term;\n term = (term * (n - i)) / (i + 1);\n }\n return sum / 2 ** n;\n};\n\n/**\n * This function gives the distribution-free interval of a median: [x_(k), x_(n+1−k)], for the\n * largest k whose two tails each hold 2.5 % or less. For eleven runs, it gives [x_(2), x_(10)],\n * at 98.8 %.\n */\nexport const medianInterval = (sorted: readonly number[]): [number, number] => {\n const n = sorted.length;\n let k = 0;\n while (k + 1 <= n / 2 && below(n, k) <= 0.025) k += 1;\n return k === 0 ? [sorted[0]!, sorted[n - 1]!] : [sorted[k - 1]!, sorted[n - k]!];\n};\n","import type { Quantity } from \"@mark1russell7/quantity\";\nimport { valueIn } from \"@mark1russell7/quantity\";\nimport { seconds, secondsOf } from \"./bands.ts\";\nimport type { KindCell, KindRun, Prediction, Reference, ResetReuse } from \"./cell.ts\";\nimport { PORT, SERVER } from \"./names.ts\";\nimport type { Line, Request } from \"./observe.ts\";\nimport {\n byNode,\n deletionOf,\n dropOf,\n emptyOf,\n failuresOf,\n intakeOf,\n outcomesOf,\n podsOf,\n signalsOf,\n sliceDropOf,\n sliceEmptyOf,\n} from \"./observe.ts\";\nimport { RELATIVE, medianInterval, middle } from \"./stats.ts\";\n\n/**\n * This time is δ for kind: each time of a run lands in its band ± δ. Its parts are the interval of\n * the poll of the rules (50 ms) and the delay of the watcher. The watcher receives each change after\n * the API server writes it.\n */\nexport const KIND_NOISE: Quantity = { value: 100, unit: \"ms\" };\n/**\n * This time is how much earlier than the end of its window the last failed request can start. A\n * request goes to the closed pod by the choice of the rules, thus the last ones before the end can\n * go to another pod. At 50 requests a second and two pods, 12 requests in sequence miss the closed\n * pod with a chance of 1 in 4096.\n */\nexport const LAST_SLACK: Quantity = { value: 250, unit: \"ms\" };\n\n/** These are δ and the slack in milliseconds, the unit of the stamps. */\nconst NOISE = valueIn(KIND_NOISE, \"ms\");\nconst SLACK = valueIn(LAST_SLACK, \"ms\");\n\n/** A propagated change is when the rules of a node first had it: after the poll `after`, and by the poll `by`. */\nexport interface Propagated<A = Quantity> {\n readonly after: A | null;\n readonly by: A;\n}\n\n/**\n * The facts of a run are what each table reads: its failures by outcome and node, and the times of\n * its target. A count stays a number, and so does a stamp: `first`, `last` and `deletion` are\n * readings of CLOCK_MONOTONIC in milliseconds. Each other time is an amount after a reference. The\n * parameter `A` is the form of an amount: a quantity in the format `/2`, seconds in the format `/1`.\n */\nexport interface RunFacts<A = Quantity> {\n readonly failures: number;\n readonly outcomes: Readonly<Record<string, number>>;\n readonly byNode: Readonly<Record<string, number>>;\n readonly first: number | null;\n readonly last: number | null;\n readonly deletion: number | null;\n readonly intakeAfterDeletion: A | null;\n readonly sliceAfter: A | null;\n /** This record is the propagation of the target to the rules of each node, by node. */\n readonly propagation: Readonly<Record<string, Propagated<A> | null>>;\n /** This time is when the EndpointSlice had no ready endpoint, after the fault (`removal`). */\n readonly sliceEmpty?: A | undefined;\n /** These times are when the rules of each node had no backend, after the fault (`removal`). */\n readonly rules?: Readonly<Record<string, A | null>> | undefined;\n /** This time is when the target left the EndpointSlice, after the fault (`leaves`). */\n readonly left?: A | undefined;\n /** These times are the SIGTERM of each replica, after the fault (`restarts`). */\n readonly signals?: ReadonlyArray<A | null> | undefined;\n}\n\n/**\n * A run check is the judgement of one run: if it agrees with the prediction, why, its main value,\n * and its facts. The main value is a time, or a count of requests or of replicas (`unitOf`).\n */\nexport interface RunCheck<A = Quantity> {\n readonly ok: boolean;\n readonly why: string;\n readonly value: A | null;\n readonly facts: RunFacts<A>;\n /**\n * This text tells why a run that agrees with the law is past its calibrated band. A request failed\n * after the window, but before the rules of its node dropped the target. Such a run makes its cell\n * `extend`, and the cell does not hold (D-EXTEND).\n */\n readonly tail?: string | undefined;\n}\n\n/** A kind decision is the result of a kind cell. */\nexport type KindDecision = \"holds\" | \"fails\" | \"extend\" | \"measured\" | \"calibration\" | \"void\";\n\n/** A kind verdict is the judgement of a cell on its counted runs. */\nexport interface KindVerdict<A = Quantity> {\n readonly decision: KindDecision;\n readonly counted: number;\n readonly voided: number;\n readonly failed: number;\n /** This amount is the median of the main value of the counted runs, or null. */\n readonly median: A | null;\n readonly why: string;\n readonly checks: ReadonlyArray<RunCheck<A>>;\n}\n\n/**\n * This function gives the unit of the main value of a cell, from its prediction:\n * - `s` for a time: the removal, the departure or the restart of a band, and the end of a stall.\n * - `{request}` for the failed requests: no failure, a window, a fleet that stays, and a measurement.\n * - `{replica}` for the replicas that received SIGTERM, when no replica must restart.\n */\nexport const unitOf = (prediction: { readonly kind: Prediction[\"kind\"]; readonly band?: unknown }): string => {\n switch (prediction.kind) {\n case \"removal\":\n case \"leaves\":\n case \"stalls\":\n return \"s\";\n case \"restarts\":\n return prediction.band === null ? \"{replica}\" : \"s\";\n default:\n return \"{request}\";\n }\n};\n\nconst sec = (ms: number): number => Math.round(ms) / 1000;\nconst inBand = (value: number, band: { readonly lo: number; readonly hi: number }): boolean =>\n value >= band.lo - NOISE / 1000 && value <= band.hi + NOISE / 1000;\nconst time = (value: number | null): Quantity | null => (value === null ? null : seconds(value));\n\n/**\n * This function tells if a failed request is the reuse of a port that a reset closed. The same\n * client had a reset on the same port, up to `life` before the request. The request ends with\n * `outcome`.\n */\nexport const reusesReset = (request: Request, requests: readonly Request[], reuse: ResetReuse): boolean => {\n if (request.o !== reuse.outcome || request.lp === undefined || request.lp === null) return false;\n const life = valueIn(reuse.life, \"ms\") + NOISE;\n return requests.some(\n (earlier) =>\n earlier.o === \"reset\" &&\n earlier.p === request.p &&\n earlier.lp === request.lp &&\n earlier.t + earlier.d <= request.t &&\n request.t - (earlier.t + earlier.d) <= life,\n );\n};\n\n/** This function gives a reference event of a run, as a stamp, or null when the run does not have it. */\nexport const referenceOf = (run: KindRun, from: Reference): number | null => {\n const lines = run.lines as readonly Line[];\n if (from === \"fault\") return run.acts.fault;\n if (from === \"resume\") return run.acts.resume;\n if (run.target === null) return null;\n const deletion = deletionOf(lines, [run.target.pod], run.start);\n if (from === \"deletion\") return deletion;\n return intakeOf(lines, run.target.pod, run.start);\n};\n\n/**\n * This function gives the propagation of each node for the target of a run. It is the time from\n * its deletion (or its crash) to the first poll of the rules of the node without it. The change\n * came between the poll before (`after`) and that poll (`by`).\n */\nexport const propagationOf = (run: KindRun, from: number | null): Record<string, Propagated | null> => {\n const out: Record<string, Propagated | null> = {};\n if (run.target === null || from === null) return out;\n const nodes = [...new Set((run.lines as readonly Line[]).filter((line) => line.ev === \"rules\").map((line) => String(line[\"node\"])))].sort();\n for (const node of nodes) {\n const drop = dropOf(run.lines as readonly Line[], node, `${run.target.ip}:${PORT}`, from);\n out[node] = drop === null ? null : { after: drop.prev === null ? null : seconds(sec(Math.max(0, drop.prev - from))), by: seconds(sec(drop.t - from)) };\n }\n return out;\n};\n\n/** This function gives the facts of a run that each table reads: its failures by outcome and node, and the times of its target. */\nexport const factsOf = (cell: KindCell, run: KindRun): RunFacts => {\n const lines = run.lines as readonly Line[];\n const failures = failuresOf(lines).filter((request) => request.t >= run.start && request.t <= run.end);\n const deletion = referenceOf(run, \"deletion\");\n const intake = referenceOf(run, \"intake\");\n const crash = cell.trigger.kind === \"crash\" ? run.acts.fault : null;\n const from = deletion ?? crash;\n return {\n failures: failures.length,\n outcomes: outcomesOf(failures),\n byNode: Object.fromEntries([...byNode(failures)].map(([node, list]) => [node, list.length])),\n first: failures.length === 0 ? null : failures[0]!.t,\n last: failures.length === 0 ? null : failures.at(-1)!.t,\n deletion,\n intakeAfterDeletion: deletion === null || intake === null ? null : seconds(sec(intake - deletion)),\n sliceAfter: run.target === null || from === null ? null : time((() => {\n const at = sliceDropOf(lines, SERVER, run.target!.ip, from);\n return at === null ? null : sec(at - from);\n })()),\n propagation: propagationOf(run, from),\n };\n};\n\n/** This function judges one run against the prediction of its cell. */\nexport const checkRun = (cell: KindCell, run: KindRun): RunCheck => {\n const lines = run.lines as readonly Line[];\n const facts = factsOf(cell, run);\n const failures = failuresOf(lines).filter((request) => request.t >= run.start && request.t <= run.end);\n const prediction = cell.prediction;\n const unit = unitOf(prediction);\n const done = (ok: boolean, why: string, value: number | null, more: Partial<RunFacts> = {}): RunCheck => ({\n ok,\n why,\n value: value === null ? null : { value, unit },\n facts: { ...facts, ...more },\n });\n switch (prediction.kind) {\n case \"none\": {\n const excluded = prediction.outcomes;\n const counted = excluded === undefined ? failures : failures.filter((request) => excluded.includes(request.o));\n const what = excluded === undefined ? \"requests failed\" : `requests ended ${excluded.join(\", \")}`;\n return done(counted.length === 0, counted.length === 0 ? `no ${excluded === undefined ? \"request failed\" : `request ended ${excluded.join(\", \")}`}` : `${counted.length} ${what}: ${JSON.stringify(facts.outcomes)}`, counted.length);\n }\n case \"window\": {\n const start = referenceOf(run, prediction.start.from);\n const end = prediction.end === null ? null : referenceOf(run, prediction.end.from);\n if (start === null || (prediction.end !== null && end === null))\n return done(false, `the run has no ${start === null ? prediction.start.from : prediction.end!.from} reference`, null);\n const opens = secondsOf(prediction.start.band);\n const closes = prediction.end === null ? null : secondsOf(prediction.end.band);\n const lo = start + opens.lo * 1000 - NOISE;\n const hi = end === null ? Number.POSITIVE_INFINITY : end + closes!.hi * 1000 + NOISE;\n const relevant: Request[] = prediction.nodes === \"paused\" ? failures.filter((request) => request.n === run.paused) : failures;\n const others = prediction.nodes === \"paused\" ? failures.filter((request) => request.n !== run.paused) : [];\n const reuse = prediction.afterReset;\n const late = relevant.filter((request) => request.t < lo || request.t > hi);\n // a request outside the window that reuses the port of a reset is the CLOSE entry of that reset\n const reused = reuse === undefined ? [] : late.filter((request) => reusesReset(request, failures, reuse));\n // a request after the window that started before the rules of its node dropped the target agrees\n // with the law: only the calibrated band is short (D-EXTEND). A request after the drop is still late\n const origin = facts.deletion ?? (cell.trigger.kind === \"crash\" ? run.acts.fault : null);\n const dropped = (node: string): number | null => {\n const propagated = facts.propagation[node];\n return origin === null || propagated === undefined || propagated === null ? null : origin + valueIn(propagated.by, \"ms\");\n };\n const tail = late.filter((request) => {\n const drop = request.t > hi && !reused.includes(request) ? dropped(request.n) : null;\n return drop !== null && request.t <= drop + NOISE;\n });\n const outside = late.filter((request) => !reused.includes(request) && !tail.includes(request));\n const problems: string[] = [];\n if (outside.length > 0) problems.push(`${outside.length} failed requests outside [${sec(lo - start)}, ${sec(hi - start)}] s after ${prediction.start.from}`);\n if (others.length > 0) problems.push(`${others.length} failed requests on nodes whose kube-proxy did not pause`);\n if (prediction.certain && relevant.length === 0) problems.push(\"no request failed in a window that the law opens\");\n if (prediction.certain && end !== null && relevant.length > 0) {\n const last = relevant.at(-1)!.t;\n const earliest = end + closes!.lo * 1000 - NOISE - SLACK;\n if (last < earliest) problems.push(`the last failed request started ${sec(earliest - last)} s before the window can end`);\n }\n const inside = relevant.filter((request) => !late.includes(request));\n const span = inside.length === 0 ? 0 : sec(inside.at(-1)!.t - inside[0]!.t);\n const agrees =\n reused.length === 0\n ? `${relevant.length} failed requests, all in the window (span ${span} s)`\n : `${inside.length} failed requests in the window (span ${span} s), and ${reused.length} on a port that a reset closed`;\n const checked = done(problems.length === 0, problems.length === 0 ? agrees : problems.join(\"; \"), relevant.length);\n if (problems.length > 0 || tail.length === 0) return checked;\n const last = tail.at(-1)!;\n return { ...checked, tail: `${tail.length} failed requests after the window, the last ${sec(last.t - hi + NOISE)} s after it on ${last.n}, before the rules of ${last.n} dropped the target` };\n }\n case \"removal\": {\n const fault = run.acts.fault;\n if (fault === null) return done(false, \"the run has no fault stamp\", null);\n const empty = sliceEmptyOf(lines, SERVER, fault);\n if (empty === null) return done(false, \"the Service kept a ready endpoint\", null);\n const value = sec(empty - fault);\n const band = secondsOf(prediction.band);\n const problems: string[] = [];\n if (!inBand(value, band)) problems.push(`the EndpointSlice had no ready endpoint at ${value} s`);\n const nodes = [...new Set(lines.filter((line) => line.ev === \"rules\").map((line) => String(line[\"node\"])))].sort();\n const rules: Record<string, Quantity | null> = {};\n for (const node of nodes) {\n const drop = emptyOf(lines, node, fault);\n rules[node] = drop === null ? null : seconds(sec(drop.t - fault));\n if (drop === null) problems.push(`the rules of ${node} kept a backend`);\n else if (!inBand(sec(drop.t - fault), { lo: band.lo, hi: band.hi + 0.05 }))\n problems.push(`the rules of ${node} had no backend at ${sec(drop.t - fault)} s`);\n }\n return done(problems.length === 0, problems.length === 0 ? `the Service was empty at ${value} s` : problems.join(\"; \"), value, { sliceEmpty: seconds(value), rules });\n }\n case \"leaves\": {\n const fault = run.acts.fault;\n if (fault === null || run.target === null) return done(false, \"the run has no fault stamp or no target\", null);\n const at = sliceDropOf(lines, SERVER, run.target.ip, fault);\n if (at === null) return done(false, `${run.target.pod} stayed ready in the EndpointSlice`, null);\n const value = sec(at - fault);\n const band = secondsOf(prediction.band);\n const problems: string[] = [];\n if (!inBand(value, band)) problems.push(`${run.target.pod} left the EndpointSlice at ${value} s`);\n const propagation = propagationOf(run, fault);\n for (const [node, drop] of Object.entries(propagation)) {\n const by = drop === null ? null : valueIn(drop.by, \"s\");\n if (by === null) problems.push(`the rules of ${node} kept ${run.target.pod}`);\n else if (!inBand(by, { lo: band.lo, hi: band.hi + 0.05 })) problems.push(`the rules of ${node} dropped it at ${by} s`);\n }\n return done(problems.length === 0, problems.length === 0 ? `${run.target.pod} left at ${value} s` : problems.join(\"; \"), value, { left: seconds(value), propagation });\n }\n case \"restarts\": {\n const fault = run.acts.fault;\n if (fault === null) return done(false, \"the run has no fault stamp\", null);\n const until = run.acts.heal ?? run.end;\n const pods = run.replicas.map((replica) => replica.pod);\n const signals = signalsOf(lines, pods, fault);\n const inside = [...signals].filter(([, at]) => at <= until);\n if (prediction.band === null)\n return done(inside.length === 0, inside.length === 0 ? \"no replica received SIGTERM\" : `${inside.length} replicas received SIGTERM`, inside.length);\n const band = secondsOf(prediction.band);\n const times = pods.map((pod) => {\n const at = signals.get(pod);\n return at === undefined ? null : sec(at - fault);\n });\n const missing = times.filter((each) => each === null).length;\n const off = times.filter((each): each is number => each !== null && !inBand(each, band));\n const known = times.filter((each): each is number => each !== null).sort((a, b) => a - b);\n const ok = missing === 0 && off.length === 0;\n return done(ok, ok ? `each replica received SIGTERM, at ${known.join(\", \")} s` : `${missing} replicas without SIGTERM, ${off.length} outside the band (${known.join(\", \")} s)`, known.length === 0 ? null : middle(known), { signals: times.map(time) });\n }\n case \"stays\": {\n const fault = run.acts.fault;\n if (fault === null) return done(false, \"the run has no fault stamp\", null);\n const until = run.end;\n const dropped = run.replicas.filter((replica) => {\n const at = sliceDropOf(lines, SERVER, replica.ip, fault);\n return at !== null && at <= until;\n });\n const refused = failures.filter((request) => request.o === \"refused\" && request.t >= fault);\n const problems: string[] = [];\n if (dropped.length > 0) problems.push(`${dropped.length} replicas left the EndpointSlice`);\n if (refused.length > 0) problems.push(`${refused.length} requests were refused`);\n return done(problems.length === 0, problems.length === 0 ? `the replicas stayed ready, ${failures.length} requests failed by their dependency` : problems.join(\"; \"), failures.length);\n }\n case \"stalls\": {\n const fault = run.acts.fault;\n const heal = run.acts.heal;\n if (fault === null || heal === null) return done(false, \"the run has no fault or heal stamp\", null);\n const old = new Set(run.replicas.map((replica) => replica.pod));\n // only the replicas of the service: the pod of Redis is not a part of the rollout\n const servers = podsOf(lines).filter((pod) => pod.labels[\"app\"] === SERVER);\n const pods = servers.filter((pod) => pod.t >= fault && pod.t <= heal);\n const deleted = pods.filter((pod) => old.has(pod.name) && pod.del);\n const newReady = pods.filter((pod) => !old.has(pod.name) && pod.ready);\n const after = servers.filter((pod) => pod.t > heal);\n const firstReady = after.find((pod) => !old.has(pod.name) && pod.ready);\n const finished = firstReady !== undefined && after.some((pod) => old.has(pod.name) && pod.type === \"DELETED\");\n const problems: string[] = [];\n if (deleted.length > 0) problems.push(`${new Set(deleted.map((pod) => pod.name)).size} old pods were deleted while Redis was down`);\n if (newReady.length > 0) problems.push(\"a new pod became ready while Redis was down\");\n if (!finished) problems.push(\"the rollout did not continue after Redis came back\");\n if (problems.length === 0)\n return done(true, `the rollout waited for Redis, and its first new pod was ready ${sec(firstReady!.t - heal)} s after Redis came back`, sec(firstReady!.t - heal));\n return done(false, problems.join(\"; \"), null);\n }\n case \"measured\":\n return done(true, \"measured\", facts.failures);\n }\n};\n\n/** This function judges a cell on its runs: each counted run must agree, and a median in a band must be equivalent to it. */\nexport const judgeKind = (cell: KindCell, runs: readonly KindRun[]): KindVerdict => {\n const counted = runs.filter((run) => !run.warmup && run.void === null);\n const voided = runs.filter((run) => !run.warmup && run.void !== null).length;\n const checks = counted.map((run) => checkRun(cell, run));\n // the main values of one cell share the unit of its prediction\n const values = checks.flatMap((check) => (check.value === null ? [] : [check.value.value])).sort((a, b) => a - b);\n const median: Quantity | null = values.length === 0 ? null : { value: middle(values), unit: unitOf(cell.prediction) };\n const failed = checks.filter((check) => !check.ok).length;\n if (counted.length === 0) return { decision: \"void\", counted: 0, voided, failed: 0, median: null, why: \"no counted run\", checks };\n if (cell.calibrates) return { decision: \"calibration\", counted: counted.length, voided, failed, median, why: \"a calibration of the propagation\", checks };\n if (cell.prediction.kind === \"measured\") return { decision: \"measured\", counted: counted.length, voided, failed: 0, median, why: cell.prediction.why, checks };\n const prediction = cell.prediction;\n const band = prediction.kind === \"removal\" || prediction.kind === \"leaves\" || prediction.kind === \"restarts\" ? prediction.band : null;\n if (failed > 0) {\n const first = checks.find((check) => !check.ok)!;\n return { decision: \"fails\", counted: counted.length, voided, failed, median, why: `${failed} of ${counted.length} runs disagree, the first: ${first.why}`, checks };\n }\n // a run past its calibrated band agrees with the law, but the band is short: the cell needs a longer one\n const tails = checks.filter((check) => check.tail !== undefined);\n if (tails.length > 0)\n return { decision: \"extend\", counted: counted.length, voided, failed, median, why: `${tails.length} of ${counted.length} runs are past the calibrated band, the first: ${tails[0]!.tail}`, checks };\n if (band !== null && values.length > 0) {\n const ends = secondsOf(band);\n const [from, to] = medianInterval(values);\n const wide = { lo: ends.lo * (1 - RELATIVE), hi: ends.hi * (1 + RELATIVE) };\n if (to < wide.lo || from > wide.hi)\n return { decision: \"fails\", counted: counted.length, voided, failed, median, why: `the median interval [${from}, ${to}] s is outside the band`, checks };\n if (from < wide.lo || to > wide.hi)\n return { decision: \"extend\", counted: counted.length, voided, failed, median, why: `the median interval [${from}, ${to}] s crosses the edge of the band`, checks };\n }\n return { decision: \"holds\", counted: counted.length, voided, failed, median, why: `${counted.length} of ${counted.length} runs agree`, checks };\n};\n","import type { Quantity } from \"@mark1russell7/quantity\";\nimport { seconds } from \"./bands.ts\";\nimport type { Band, KindCell, KindRun, Prediction, Trigger } from \"./cell.ts\";\nimport type { KindScenario } from \"./scenario.ts\";\nimport type { KindVerdict, Propagated, RunCheck, RunFacts } from \"./verdict.ts\";\nimport { judgeKind, unitOf } from \"./verdict.ts\";\n\n/**\n * This module is the raw record of a kind cell: its formats, and the upgrade from the format `/1`\n * to the format `/2`. The lab writes `/2`, and it does not write `/1` again. A reader reads a record\n * of `/1` through `upgrade`, and the meaning of each value stays the same.\n */\n\n/** This format is the format that the lab writes. Each amount in it is a quantity. */\nexport const FORMAT = \"systems.kind-cell-record/2\";\n/** This format is the first format. Its bands, its medians and its times are numbers. */\nexport const FORMAT_V1 = \"systems.kind-cell-record/1\";\n\n/** A load sample is what the VM did in 4 s before a run: when (a stamp of the wall clock in milliseconds), its idle share, and its busiest processes. */\nexport interface LoadSample {\n readonly t: number;\n readonly idle: number;\n readonly top: readonly string[];\n readonly foreign: readonly string[];\n}\n\n/** A cluster manifest is what a run records about its cluster: the versions, the images, the nodes and the mode as read back. */\nexport interface ClusterManifest {\n readonly kind: string;\n readonly nodeImage: string;\n readonly server: string;\n readonly mode: string;\n readonly docker: string;\n readonly nodes: ReadonlyArray<{\n readonly name: string;\n readonly kubelet: string;\n readonly kernel: string;\n readonly runtime: string;\n readonly os: string;\n }>;\n}\n\n/** An environment manifest is one cluster of a cell: its scenario, what the cluster was, and the images of the lab. */\nexport interface EnvironmentManifest {\n readonly env: number;\n readonly scenario: KindScenario;\n readonly cluster: ClusterManifest;\n readonly images: Readonly<Record<string, string>>;\n}\n\n/**\n * A kind cell result is a cell, its runs over its environments, the manifest of each environment,\n * and its verdict. The parameter `A` is the form of an amount.\n */\nexport interface KindCellResult<A = Quantity> {\n readonly cell: KindCell<A>;\n readonly runs: readonly KindRun[];\n readonly manifests: readonly EnvironmentManifest[];\n readonly loads: readonly LoadSample[];\n readonly verdict: KindVerdict<A>;\n /** This text is the time of the verdict, in ISO 8601. */\n readonly at: string;\n}\n\n/** A kind cell record is the raw record of a cell in the format `/2`: a result with its format. */\nexport interface KindCellRecord extends KindCellResult {\n readonly format: typeof FORMAT;\n}\n\n/** A kind cell record of the format `/1` gives each band, median, main value and time of a fact as a number. */\nexport interface KindCellRecordV1 extends KindCellResult<number> {\n readonly format: typeof FORMAT_V1;\n}\n\n/** These are the parts of the format `/1`, with numbers for amounts. */\nexport type BandV1 = Band<number>;\nexport type PredictionV1 = Prediction<number>;\nexport type TriggerV1 = Trigger<number>;\nexport type KindCellV1 = KindCell<number>;\nexport type KindVerdictV1 = KindVerdict<number>;\nexport type RunCheckV1 = RunCheck<number>;\nexport type RunFactsV1 = RunFacts<number>;\n\nconst time = (value: number | null): Quantity | null => (value === null ? null : seconds(value));\nconst band = (old: BandV1): Band => ({ lo: seconds(old.lo), hi: seconds(old.hi) });\n/** The format `/1` gives each part of `cpu.max` in microseconds. */\nconst microseconds = (value: number): Quantity => ({ value, unit: \"us\" });\n\nconst upgradeTrigger = (trigger: TriggerV1): Trigger => {\n const { cpuMax, ...rest } = trigger;\n return cpuMax === undefined ? rest : { ...rest, cpuMax: { quota: microseconds(cpuMax.quota), period: microseconds(cpuMax.period) } };\n};\n\nconst upgradePrediction = (prediction: PredictionV1): Prediction => {\n switch (prediction.kind) {\n case \"window\": {\n const { afterReset, ...rest } = prediction;\n return {\n ...rest,\n start: { from: prediction.start.from, band: band(prediction.start.band) },\n end: prediction.end === null ? null : { from: prediction.end.from, band: band(prediction.end.band) },\n ...(afterReset === undefined ? {} : { afterReset: { life: seconds(afterReset.life), outcome: afterReset.outcome } }),\n };\n }\n case \"removal\":\n case \"leaves\":\n return { ...prediction, band: band(prediction.band) };\n case \"restarts\":\n return { ...prediction, band: prediction.band === null ? null : band(prediction.band) };\n default:\n return prediction;\n }\n};\n\n/** This function gives a cell of the format `/1` in the format `/2`: its bands in seconds, and its `cpu.max` in microseconds. */\nexport const upgradeCell = (cell: KindCellV1): KindCell => ({\n ...cell,\n trigger: upgradeTrigger(cell.trigger),\n prediction: upgradePrediction(cell.prediction),\n});\n\nconst upgradeFacts = (facts: RunFactsV1): RunFacts => {\n const propagated = (old: Propagated<number> | null): Propagated | null => (old === null ? null : { after: time(old.after), by: seconds(old.by) });\n const { sliceEmpty, rules, left, signals, ...rest } = facts;\n return {\n ...rest,\n intakeAfterDeletion: time(facts.intakeAfterDeletion),\n sliceAfter: time(facts.sliceAfter),\n propagation: Object.fromEntries(Object.entries(facts.propagation).map(([node, old]) => [node, propagated(old)])),\n ...(sliceEmpty === undefined ? {} : { sliceEmpty: seconds(sliceEmpty) }),\n ...(rules === undefined ? {} : { rules: Object.fromEntries(Object.entries(rules).map(([node, old]) => [node, time(old)])) }),\n ...(left === undefined ? {} : { left: seconds(left) }),\n ...(signals === undefined ? {} : { signals: signals.map((old) => time(old)) }),\n };\n};\n\n/**\n * This function gives a record in the format `/2`. A record of `/2` comes back as it is. A record\n * of `/1` gets each amount as a quantity, and each value stays the same:\n * - Each band and each time of a fact is in seconds, as `/1` gives it.\n * - The `cpu.max` of a throttle is in microseconds, as `/1` gives it.\n * - The median and the main value of each run get the unit of the prediction (`unitOf`): seconds,\n * failed requests (`{request}`) or replicas (`{replica}`).\n */\nexport const upgrade = (record: KindCellRecordV1 | KindCellRecord): KindCellRecord => {\n if (record.format === FORMAT) return record;\n const unit = unitOf(record.cell.prediction);\n const amount = (value: number | null): Quantity | null => (value === null ? null : { value, unit });\n const verdict = record.verdict;\n return {\n format: FORMAT,\n cell: upgradeCell(record.cell),\n runs: record.runs,\n manifests: record.manifests,\n loads: record.loads,\n verdict: {\n ...verdict,\n median: amount(verdict.median),\n checks: verdict.checks.map((check) => ({ ...check, value: amount(check.value), facts: upgradeFacts(check.facts) })),\n },\n at: record.at,\n };\n};\n\n/**\n * This function judges a record again, from its cell and its runs, with the judge of this version.\n * It reads a record of `/1` through `upgrade`. The verdict is in the format `/2`.\n */\nexport const judge = (record: KindCellRecordV1 | KindCellRecord): KindVerdict => {\n const current = upgrade(record);\n return judgeKind(current.cell, current.runs);\n};\n","import type { Quantity } from \"@mark1russell7/quantity\";\nimport { format, valueIn } from \"@mark1russell7/quantity\";\nimport { seconds, secondsOf, showBand } from \"./bands.ts\";\nimport type { Band, KindCell, KindRun, Prediction } from \"./cell.ts\";\nimport { quantileOf } from \"./stats.ts\";\nimport type { KindVerdict } from \"./verdict.ts\";\nimport { factsOf, propagationOf, referenceOf } from \"./verdict.ts\";\n\n/** A judged cell is a cell, its runs and its verdict: the part of a result that a report reads. */\nexport interface Judged {\n readonly cell: KindCell;\n readonly runs: readonly KindRun[];\n readonly verdict: KindVerdict;\n}\n\n/** A spread is the count, the extremes, the median and the 99th percentile of a set of times. */\nexport interface TimeSpread {\n readonly count: number;\n readonly min: Quantity;\n readonly median: Quantity;\n readonly p99: Quantity;\n readonly max: Quantity;\n}\n\n/** This function gives the spread of a set of times, or null for none. The percentile is by nearest rank. */\nexport const timeSpread = (times: readonly Quantity[]): TimeSpread | null => {\n if (times.length === 0) return null;\n const sorted = times.map((each) => valueIn(each, \"s\")).sort((a, b) => a - b);\n const half = Math.floor(sorted.length / 2);\n const median = sorted.length % 2 === 1 ? sorted[half]! : (sorted[half - 1]! + sorted[half]!) / 2;\n return {\n count: sorted.length,\n min: seconds(sorted[0]!),\n median: seconds(Math.round(median * 1000) / 1000),\n p99: seconds(quantileOf(sorted, 0.99)),\n max: seconds(sorted.at(-1)!),\n };\n};\n\n/** This function gives a reference with its band, and only the reference when the band is [0, 0] s. */\nconst atBand = (from: string, band: Band): string => {\n const { lo, hi } = secondsOf(band);\n return lo === 0 && hi === 0 ? `the ${from}` : `the ${from} + ${showBand(band)}`;\n};\n\n/** This function gives the prediction of a cell in a short form for a table. */\nexport const predictionText = (prediction: Prediction): string => {\n switch (prediction.kind) {\n case \"none\":\n return prediction.outcomes === undefined ? \"no failure\" : `no ${prediction.outcomes.join(\", \")}`;\n case \"window\":\n // a window can open before its reference: a stale SYN_SENT entry fails the paused node up to its life before the intake\n return `failures only from ${atBand(prediction.start.from, prediction.start.band)}${prediction.end === null ? \"\" : ` to ${atBand(prediction.end.from, prediction.end.band)}`}${prediction.nodes === \"paused\" ? \", on the paused node\" : \"\"}${prediction.certain ? \", at least one\" : \"\"}${prediction.afterReset === undefined ? \"\" : `, or a ${prediction.afterReset.outcome} up to ${format(prediction.afterReset.life)} after a reset on its port`}`;\n case \"removal\":\n return `Service empty in ${showBand(prediction.band)}`;\n case \"leaves\":\n return `the replica leaves in ${showBand(prediction.band)}`;\n case \"restarts\":\n return prediction.band === null ? \"no restart\" : `each replica SIGTERM in ${showBand(prediction.band)}`;\n case \"stays\":\n return \"stays ready, no refusal\";\n case \"stalls\":\n return \"the rollout waits for Redis\";\n case \"measured\":\n return \"measured\";\n }\n};\n\n/**\n * This function gives the main measurement of a cell in a short form: its median and what it\n * counts. For failed requests, it is the middle count of the counted runs.\n */\nexport const medianText = (judged: Judged): string => {\n const { cell, verdict } = judged;\n if (verdict.median === null) return \"\";\n if (verdict.median.unit === \"{request}\") {\n const counted = judged.runs.filter((run) => !run.warmup && run.void === null);\n const failures = counted.map((run) => factsOf(cell, run).failures).sort((a, b) => a - b);\n return `${failures.length === 0 ? 0 : failures[Math.floor(failures.length / 2)]} failed requests`;\n }\n return format(verdict.median, { digits: 4 });\n};\n\n/** This function gives the table of the cells in Markdown. Each row has the cell, its plan cell, its mode, its trigger, the prediction, the verdict, its runs and its median. */\nexport const cellsTable = (judged: readonly Judged[]): string =>\n [\n \"| Cell | Plan id | Mode | Trigger | Prediction | Verdict | Runs | Median |\",\n \"| --- | --- | --- | --- | --- | --- | --- | --- |\",\n ...judged.map((each) => {\n const { cell, verdict } = each;\n const runs = verdict.voided === 0 ? `${verdict.counted}` : `${verdict.counted} (+${verdict.voided} void)`;\n return `| ${cell.name} | ${cell.id} | ${cell.mode} | ${cell.trigger.kind} | ${predictionText(cell.prediction)} | ${verdict.decision} | ${runs} | ${medianText(each)} |`;\n }),\n ].join(\"\\n\");\n\n/**\n * This function gives the propagation of each calibration, by node. It is the time from the\n * deletion to the poll of the rules of each node without the pod. It also gives the time to the\n * EndpointSlice and to the stop of the intake.\n */\nexport const calibrationOf = (judged: Judged): {\n readonly nodes: Readonly<Record<string, TimeSpread | null>>;\n readonly all: TimeSpread | null;\n readonly slice: TimeSpread | null;\n readonly intake: TimeSpread | null;\n} => {\n const byNode: Record<string, Quantity[]> = {};\n const slice: Quantity[] = [];\n const intake: Quantity[] = [];\n for (const run of judged.runs.filter((each) => !each.warmup && each.void === null)) {\n const deletion = referenceOf(run, \"deletion\");\n for (const [node, drop] of Object.entries(propagationOf(run, deletion))) if (drop !== null) (byNode[node] ??= []).push(drop.by);\n const facts = factsOf(judged.cell, run);\n if (facts.sliceAfter !== null) slice.push(facts.sliceAfter);\n if (facts.intakeAfterDeletion !== null) intake.push(facts.intakeAfterDeletion);\n }\n const nodes = Object.fromEntries(Object.entries(byNode).map(([node, values]) => [node, timeSpread(values)]));\n return { nodes, all: timeSpread(Object.values(byNode).flat()), slice: timeSpread(slice), intake: timeSpread(intake) };\n};\n","import type { Quantity } from \"@mark1russell7/quantity\";\nimport { extentSchema, quantitySchema } from \"@mark1russell7/quantity/schema\";\nimport type { Stage } from \"@mark1russell7/service\";\nimport { z } from \"zod\";\nimport type { KindRun, TriggerKind } from \"./cell.ts\";\nimport type { KindCellRecord, KindCellRecordV1 } from \"./record.ts\";\nimport { FORMAT, FORMAT_V1, upgrade } from \"./record.ts\";\nimport type { KubeProxyMode } from \"./scenario.ts\";\nimport { unitOf } from \"./verdict.ts\";\n\n/**\n * This module holds the zod schemas of a kind cell record, in the formats `/1` and `/2`. It names\n * the stages of the shutdown itself, thus it does not load the service. A test holds the names to\n * the service.\n */\n\n/** These are the stages of the shutdown of the service, in their sequence. */\nexport const STAGES: readonly [Stage, ...Stage[]] = [\n \"fail readiness\",\n \"stop intake\",\n \"drain\",\n \"close transports\",\n \"stop the poller\",\n \"tear down dependencies\",\n \"close the health server\",\n \"flush the output\",\n];\n\nconst TRIGGERS = [\n \"pod-deletion\",\n \"rolling-update\",\n \"node-drain\",\n \"scale-in\",\n \"crash\",\n \"liveness-restart\",\n \"freeze-process\",\n \"rst\",\n \"blackhole\",\n \"peer-gone-without-close\",\n \"app-stall\",\n \"rollout\",\n \"cpu-throttle\",\n] as const satisfies readonly TriggerKind[];\nconst MODES = [\"iptables\", \"ipvs\", \"nftables\"] as const satisfies readonly KubeProxyMode[];\n\nconst time = quantitySchema(\"time\");\nconst extent = extentSchema(\"time\");\nconst count = z.number().int().nonnegative();\nconst gate = z.enum([\"readiness\", \"liveness\"]);\nconst reference = z.enum([\"deletion\", \"intake\", \"fault\", \"resume\"]);\n\nconst probe = z.object({ period: time, threshold: count, timeout: time });\nconst timing = z.discriminatedUnion(\"type\", [\n z.object({ type: z.literal(\"debounce\"), interval: time, failAfter: count, recoverAfter: count }),\n z.object({ type: z.literal(\"window\"), failAfter: time, recoverAfter: time.optional() }),\n]);\nconst knobs = z.object({\n connect_bound: time,\n request_timeout: time,\n driver_writeoff_time: extent,\n keepalive_idle: extent,\n heartbeat_interval: extent,\n heartbeat_timeout: time,\n client_retry_window: extent,\n retry_base: time,\n retry_cap: time,\n close_bound: time,\n max_connection_age: extent,\n retrans_giveup_time: extent,\n});\nconst declaration = z.object({\n poll: z.object({ interval: time, jitter: z.number().min(0).lt(1), timeout: time }),\n readiness: timing,\n liveness: timing,\n startup: time,\n phases: z.array(z.tuple([z.enum(STAGES), time])),\n cooperativeWindow: extent,\n couplings: z.array(z.object({ from: gate, to: gate, effect: z.literal(\"fails\") })),\n redis: z.object({ gates: gate.nullable(), knobs, misses: count }).nullable(),\n flag: gate.nullable(),\n watchdog: z.object({ tick: time, threshold: time }).nullable(),\n});\n\nconst replica = z.object({ pod: z.string(), node: z.string(), ip: z.string(), version: z.string() });\n/** A line keeps each field that its source wrote. The judge reads `ev`, `t` and the fields of its kind. */\nconst line = z.object({ ev: z.string(), t: z.number() }).catchall(z.unknown());\nconst run: z.ZodType<KindRun> = z.object({\n env: count,\n index: z.number().int(),\n warmup: z.boolean(),\n start: z.number(),\n end: z.number(),\n acts: z.object({ fault: z.number().nullable(), heal: z.number().nullable(), resume: z.number().nullable() }),\n target: replica.nullable(),\n paused: z.string().nullable(),\n replicas: z.array(replica),\n void: z.string().nullable(),\n lines: z.array(line),\n dropped: z.record(z.string(), count),\n notes: z.array(z.string()).optional(),\n});\nconst manifest = z.object({\n env: count,\n scenario: z.object({\n name: z.string(),\n kubernetes: z.string(),\n workers: count,\n kubeProxy: z.object({ mode: z.enum(MODES), minSyncPeriod: time, syncPeriod: time }),\n cni: z.literal(\"kindnet\"),\n podSubnet: z.string(),\n serviceSubnet: z.string(),\n }),\n cluster: z.object({\n kind: z.string(),\n nodeImage: z.string(),\n server: z.string(),\n mode: z.string(),\n docker: z.string(),\n nodes: z.array(z.object({ name: z.string(), kubelet: z.string(), kernel: z.string(), runtime: z.string(), os: z.string() })),\n }),\n images: z.record(z.string(), z.string()),\n});\nconst load = z.object({ t: z.number(), idle: z.number(), top: z.array(z.string()), foreign: z.array(z.string()) });\n\n/**\n * This function gives the schema of a record whose amounts have one form. The schema `a` is for a\n * time. The schema `main` is for the main value of a run: a time or a count.\n */\nconst recordOf = <A>(a: z.ZodType<A>, main: z.ZodType<A>) => {\n const band = z.object({ lo: a, hi: a });\n const prediction = z.discriminatedUnion(\"kind\", [\n z.object({ kind: z.literal(\"none\"), outcomes: z.array(z.string()).optional(), why: z.string() }),\n z.object({\n kind: z.literal(\"window\"),\n nodes: z.enum([\"all\", \"paused\"]),\n start: z.object({ from: reference, band }),\n end: z.object({ from: reference, band }).nullable(),\n certain: z.boolean(),\n afterReset: z.object({ life: a, outcome: z.string() }).optional(),\n why: z.string(),\n }),\n z.object({ kind: z.literal(\"removal\"), band, why: z.string() }),\n z.object({ kind: z.literal(\"leaves\"), band, why: z.string() }),\n z.object({ kind: z.literal(\"restarts\"), band: band.nullable(), why: z.string() }),\n z.object({ kind: z.literal(\"stays\"), why: z.string() }),\n z.object({ kind: z.literal(\"stalls\"), why: z.string() }),\n z.object({ kind: z.literal(\"measured\"), why: z.string() }),\n ]);\n const cell = z.object({\n id: z.string(),\n name: z.string(),\n template: z.enum([\"T07\", \"T18\"]),\n stack: z.enum([\"service\", \"grpc\"]).optional(),\n substitutes: z.string().nullable(),\n mode: z.enum(MODES),\n workers: count,\n trigger: z.object({\n kind: z.enum(TRIGGERS),\n hold: time.optional(),\n lead: time.optional(),\n cpuMax: z.object({ quota: a, period: a }).optional(),\n }),\n pod: z.object({ replicas: count, grace: time, preStop: time, readiness: probe, liveness: probe, startup: probe.nullable() }),\n declaration: declaration.nullable(),\n workload: z.object({ every: time, timeout: time }),\n prediction,\n calibrates: z.boolean(),\n runs: count,\n });\n const facts = z.object({\n failures: count,\n outcomes: z.record(z.string(), count),\n byNode: z.record(z.string(), count),\n first: z.number().nullable(),\n last: z.number().nullable(),\n deletion: z.number().nullable(),\n intakeAfterDeletion: a.nullable(),\n sliceAfter: a.nullable(),\n propagation: z.record(z.string(), z.object({ after: a.nullable(), by: a }).nullable()),\n sliceEmpty: a.optional(),\n rules: z.record(z.string(), a.nullable()).optional(),\n left: a.optional(),\n signals: z.array(a.nullable()).optional(),\n });\n const verdict = z.object({\n decision: z.enum([\"holds\", \"fails\", \"extend\", \"measured\", \"calibration\", \"void\"]),\n counted: count,\n voided: count,\n failed: count,\n median: main.nullable(),\n why: z.string(),\n checks: z.array(z.object({ ok: z.boolean(), why: z.string(), value: main.nullable(), facts, tail: z.string().optional() })),\n });\n return { cell, verdict, runs: z.array(run), manifests: z.array(manifest), loads: z.array(load), at: z.string() };\n};\n\nconst v2 = recordOf<Quantity>(time, quantitySchema([\"time\", \"count\"]));\nconst v1 = recordOf<number>(z.number(), z.number());\n\n/**\n * This schema accepts a record in the format `/2`. The median and the main value of each run must\n * have the unit of the prediction of the cell (`unitOf`).\n */\nexport const kindCellRecordSchema: z.ZodType<KindCellRecord> = z\n .object({ format: z.literal(FORMAT), ...v2 })\n .superRefine((record, ctx) => {\n const unit = unitOf(record.cell.prediction);\n const values = [record.verdict.median, ...record.verdict.checks.map((check) => check.value)];\n for (const value of values) {\n if (value !== null && value.unit !== unit)\n ctx.addIssue({ code: \"custom\", message: `the main value is in ${value.unit}, and the prediction ${record.cell.prediction.kind} gives ${unit}` });\n }\n });\n\n/** This schema accepts a record in the format `/1`. */\nexport const kindCellRecordV1Schema: z.ZodType<KindCellRecordV1> = z.object({ format: z.literal(FORMAT_V1), ...v1 });\n\n/** This function reads a record of either format from parsed JSON, and gives it in the format `/2`. */\nexport const readRecord = (data: unknown): KindCellRecord => {\n const format = typeof data === \"object\" && data !== null ? (data as { format?: unknown }).format : undefined;\n if (format === FORMAT_V1) return upgrade(kindCellRecordV1Schema.parse(data));\n if (format === FORMAT) return kindCellRecordSchema.parse(data);\n throw new Error(`a kind cell record has the format ${FORMAT} or ${FORMAT_V1}, not ${String(format)}`);\n};\n"],"mappings":";;;;;;AAOA,MAAa,WAAW,WAA6B;CAAE;CAAO,MAAM;AAAI;;AAGxE,MAAa,UAAU,IAAY,QAAsB;CAAE,IAAI,QAAQ,EAAE;CAAG,IAAI,QAAQ,EAAE;AAAE;;AAG5F,MAAa,aAAa,UAA8D;CACtF,IAAI,QAAQ,KAAK,IAAI,GAAG;CACxB,IAAI,QAAQ,KAAK,IAAI,GAAG;AAC1B;;AAGA,MAAa,YAAY,SAAuB;CAC9C,MAAM,EAAE,IAAI,OAAO,UAAU,IAAI;CACjC,OAAO,IAAI,GAAG,IAAI,GAAG;AACvB;;;;AClBA,MAAa,OAAO;AACpB,MAAa,cAAc;;AAE3B,MAAa,YAAY;;AAEzB,MAAa,SAAS;AACtB,MAAa,SAAS;AACtB,MAAa,QAAQ;;;AC6ErB,MAAM,MAAS,OAAwB,OAAoB,MAAM,QAAQ,SAAS,KAAK,OAAO,EAAE;AAEhG,MAAa,cAAc,UAAsC,GAAY,OAAO,KAAK;AACzF,MAAa,UAAU,UAAsC,GAAY,OAAO,KAAK,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,IAAI,EAAE,CAAC;AAC/G,MAAa,YAAY,OAAwB,QAC/C,GAAc,OAAO,OAAO,CAA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uBAAuB,OAAO,KAAK,WAAW,KAAK,SAAS;CAAO,CAAC;AAErJ,CAAC;;AAGH,MAAa,yBAAsD,EAAE,OAAO;CAAE,QAAQ,EAAE,QAAQ,SAAS;CAAG,GAAG;AAAG,CAAC;;AAGnH,MAAa,cAAc,SAAkC;CAC3D,MAAM,SAAS,OAAO,SAAS,YAAY,SAAS,OAAQ,KAA8B,SAAS,KAAA;CACnG,IAAI,WAAA,8BAAsB,OAAO,QAAQ,uBAAuB,MAAM,IAAI,CAAC;CAC3E,IAAI,WAAA,8BAAmB,OAAO,qBAAqB,MAAM,IAAI;CAC7D,MAAM,IAAI,MAAM,qCAAqC,OAAO,MAAM,UAAU,QAAQ,OAAO,MAAM,GAAG;AACtG"}
package/build/judge.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as RulesLine, A as TriggerV1, At as secondsOf, B as RunFacts, Bt as Reference, C as KindCellResult, Ct as HEALTH_PORT, D as PredictionV1, Dt as SERVER, E as LoadSample, Et as REDIS, F as KindDecision, Ft as KindRun, G as referenceOf, Gt as TriggerKind, H as factsOf, Ht as ResetReuse, I as KindVerdict, It as KubeletProbe, J as Endpoint, K as reusesReset, Kt as Workload, L as LAST_SLACK, Lt as PodSettings, M as upgrade, Mt as Band, N as upgradeCell, Nt as Declaration, O as RunCheckV1, Ot as bandOf, P as KIND_NOISE, Pt as KindCell, Q as Request, R as Propagated, Rt as Prediction, S as KindCellRecordV1, St as CLIENT, T as KindVerdictV1, Tt as PORT, U as judgeKind, Ut as Template, V as checkRun, Vt as Replica, W as propagationOf, Wt as Trigger, X as PodLine, Xt as KubeProxyMode, Y as Line, Z as RecordLine, _ as ClusterManifest, _t as signalsOf, a as STAGES, at as emptyOf, b as FORMAT_V1, bt as slicesOf, c as readRecord, ct as kernelCounts, d as calibrationOf, dt as podsOf, et as SliceLine, f as cellsTable, ft as recordsOf, g as BandV1, gt as signalOf, h as timeSpread, ht as rulesOf, i as quantileOf, it as dropOf, j as judge, jt as showBand, k as RunFactsV1, kt as seconds, l as Judged, lt as outcomesOf, m as predictionText, mt as restartsAt, n as medianInterval, nt as byNode, o as kindCellRecordSchema, ot as failuresOf, p as medianText, pt as requestsOf, q as unitOf, r as middle, rt as deletionOf, s as kindCellRecordV1Schema, st as intakeOf, t as RELATIVE, tt as backendsAt, u as TimeSpread, ut as podsAt, v as EnvironmentManifest, vt as sliceDropOf, w as KindCellV1, wt as LOG_LABEL, x as KindCellRecord, xt as transitionOf, y as FORMAT, yt as sliceEmptyOf, z as RunCheck, zt as RedisDeclaration } from "./judge-a7yCzwZc.js";
2
- export { type Band, type BandV1, CLIENT, type ClusterManifest, type Declaration, Endpoint, type EnvironmentManifest, FORMAT, FORMAT_V1, HEALTH_PORT, type Judged, KIND_NOISE, type KindCell, type KindCellRecord, type KindCellRecordV1, type KindCellResult, type KindCellV1, type KindDecision, type KindRun, type KindVerdict, type KindVerdictV1, type KubeProxyMode, type KubeletProbe, LAST_SLACK, LOG_LABEL, Line, type LoadSample, PORT, PodLine, type PodSettings, type Prediction, type PredictionV1, type Propagated, REDIS, RELATIVE, RecordLine, type RedisDeclaration, type Reference, type Replica, Request, type ResetReuse, RulesLine, type RunCheck, type RunCheckV1, type RunFacts, type RunFactsV1, SERVER, STAGES, SliceLine, type Template, type TimeSpread, type Trigger, type TriggerKind, type TriggerV1, type Workload, backendsAt, bandOf, byNode, calibrationOf, cellsTable, checkRun, deletionOf, dropOf, emptyOf, factsOf, failuresOf, intakeOf, judge, judgeKind, kernelCounts, kindCellRecordSchema, kindCellRecordV1Schema, medianInterval, medianText, middle, outcomesOf, podsAt, podsOf, predictionText, propagationOf, quantileOf, readRecord, recordsOf, referenceOf, requestsOf, restartsAt, reusesReset, rulesOf, seconds, secondsOf, showBand, signalOf, signalsOf, sliceDropOf, sliceEmptyOf, slicesOf, timeSpread, transitionOf, unitOf, upgrade, upgradeCell };
1
+ import { $ as RulesLine, $t as KubeProxyMode, A as TriggerV1, At as bandOf, B as RunFacts, Bt as Prediction, C as KindCellResult, Ct as transitionOf, D as PredictionV1, Dt as PORT, E as LoadSample, Et as LOG_LABEL, F as KindDecision, Ft as Declaration, G as referenceOf, Gt as Stack, H as factsOf, Ht as Reference, I as KindVerdict, It as KindCell, J as Endpoint, Jt as TriggerKind, K as reusesReset, Kt as Template, L as LAST_SLACK, Lt as KindRun, M as upgrade, Mt as secondsOf, N as upgradeCell, Nt as showBand, O as RunCheckV1, Ot as REDIS, P as KIND_NOISE, Pt as Band, Q as Request, R as Propagated, Rt as KubeletProbe, S as KindCellRecordV1, St as stoppingOf, T as KindVerdictV1, Tt as HEALTH_PORT, U as judgeKind, Ut as Replica, V as checkRun, Vt as RedisDeclaration, W as propagationOf, Wt as ResetReuse, X as PodLine, Y as Line, Yt as Workload, Z as RecordLine, _ as ClusterManifest, _t as signalOf, a as STAGES, at as dropOf, b as FORMAT_V1, bt as sliceEmptyOf, c as readRecord, ct as intakeOf, d as calibrationOf, dt as podsAt, et as SliceLine, f as cellsTable, ft as podsOf, g as BandV1, gt as rulesOf, h as timeSpread, ht as restartsAt, i as quantileOf, it as deletionOf, j as judge, jt as seconds, k as RunFactsV1, kt as SERVER, l as Judged, lt as kernelCounts, m as predictionText, mt as requestsOf, n as medianInterval, nt as byClients, o as kindCellRecordSchema, ot as emptyOf, p as medianText, pt as recordsOf, q as unitOf, qt as Trigger, r as middle, rt as byNode, s as kindCellRecordV1Schema, st as failuresOf, t as RELATIVE, tt as backendsAt, u as TimeSpread, ut as outcomesOf, v as EnvironmentManifest, vt as signalsOf, w as KindCellV1, wt as CLIENT, x as KindCellRecord, xt as slicesOf, y as FORMAT, yt as sliceDropOf, z as RunCheck, zt as PodSettings } from "./judge-D5SBTJ-V.js";
2
+ export { type Band, type BandV1, CLIENT, type ClusterManifest, type Declaration, Endpoint, type EnvironmentManifest, FORMAT, FORMAT_V1, HEALTH_PORT, type Judged, KIND_NOISE, type KindCell, type KindCellRecord, type KindCellRecordV1, type KindCellResult, type KindCellV1, type KindDecision, type KindRun, type KindVerdict, type KindVerdictV1, type KubeProxyMode, type KubeletProbe, LAST_SLACK, LOG_LABEL, Line, type LoadSample, PORT, PodLine, type PodSettings, type Prediction, type PredictionV1, type Propagated, REDIS, RELATIVE, RecordLine, type RedisDeclaration, type Reference, type Replica, Request, type ResetReuse, RulesLine, type RunCheck, type RunCheckV1, type RunFacts, type RunFactsV1, SERVER, STAGES, SliceLine, type Stack, type Template, type TimeSpread, type Trigger, type TriggerKind, type TriggerV1, type Workload, backendsAt, bandOf, byClients, byNode, calibrationOf, cellsTable, checkRun, deletionOf, dropOf, emptyOf, factsOf, failuresOf, intakeOf, judge, judgeKind, kernelCounts, kindCellRecordSchema, kindCellRecordV1Schema, medianInterval, medianText, middle, outcomesOf, podsAt, podsOf, predictionText, propagationOf, quantileOf, readRecord, recordsOf, referenceOf, requestsOf, restartsAt, reusesReset, rulesOf, seconds, secondsOf, showBand, signalOf, signalsOf, sliceDropOf, sliceEmptyOf, slicesOf, stoppingOf, timeSpread, transitionOf, unitOf, upgrade, upgradeCell };
package/build/judge.js CHANGED
@@ -1 +1 @@
1
- export { Y as CLIENT, u as FORMAT, d as FORMAT_V1, X as HEALTH_PORT, h as KIND_NOISE, g as LAST_SLACK, Z as LOG_LABEL, Q as PORT, $ as REDIS, w as RELATIVE, et as SERVER, t as STAGES, O as backendsAt, tt as bandOf, k as byNode, a as calibrationOf, o as cellsTable, _ as checkRun, A as deletionOf, j as dropOf, M as emptyOf, v as factsOf, N as failuresOf, P as intakeOf, f as judge, y as judgeKind, F as kernelCounts, n as kindCellRecordSchema, r as kindCellRecordV1Schema, T as medianInterval, s as medianText, E as middle, I as outcomesOf, L as podsAt, R as podsOf, c as predictionText, b as propagationOf, D as quantileOf, i as readRecord, z as recordsOf, x as referenceOf, B as requestsOf, V as restartsAt, S as reusesReset, H as rulesOf, nt as seconds, rt as secondsOf, it as showBand, U as signalOf, W as signalsOf, G as sliceDropOf, K as sliceEmptyOf, q as slicesOf, l as timeSpread, J as transitionOf, C as unitOf, p as upgrade, m as upgradeCell } from "./judge-BbTAxRSd.js";
1
+ export { Z as CLIENT, u as FORMAT, d as FORMAT_V1, Q as HEALTH_PORT, h as KIND_NOISE, g as LAST_SLACK, $ as LOG_LABEL, et as PORT, tt as REDIS, w as RELATIVE, nt as SERVER, t as STAGES, O as backendsAt, rt as bandOf, k as byClients, A as byNode, a as calibrationOf, o as cellsTable, _ as checkRun, j as deletionOf, M as dropOf, N as emptyOf, v as factsOf, P as failuresOf, F as intakeOf, f as judge, y as judgeKind, I as kernelCounts, n as kindCellRecordSchema, r as kindCellRecordV1Schema, T as medianInterval, s as medianText, E as middle, L as outcomesOf, R as podsAt, z as podsOf, c as predictionText, b as propagationOf, D as quantileOf, i as readRecord, B as recordsOf, x as referenceOf, V as requestsOf, H as restartsAt, S as reusesReset, U as rulesOf, it as seconds, at as secondsOf, ot as showBand, W as signalOf, G as signalsOf, K as sliceDropOf, q as sliceEmptyOf, J as slicesOf, Y as stoppingOf, l as timeSpread, X as transitionOf, C as unitOf, p as upgrade, m as upgradeCell } from "./judge-DlmmZHcI.js";
package/image/Dockerfile CHANGED
@@ -1,8 +1,8 @@
1
- # The image of a kind cell: the service on @mark1russell7/service, its clients, the agent of each
2
- # node and the watcher of the API, on Node 24.21.0. The base is pinned by digest, and npm-lock.json
3
- # pins the packages from npm. The packages of the workspace come as the tarballs that pnpm packs,
4
- # and the build unpacks them over node_modules, as npm would install them. image.ts stages the
5
- # context and tags the image by its content.
1
+ # The image of a kind cell: the service on @mark1russell7/service, its clients (HTTP and grpc-js),
2
+ # the agent of each node and the watcher of the API, on Node 24.21.0. The base is pinned by digest,
3
+ # and npm-lock.json pins the packages from npm. The packages of the workspace come as the tarballs
4
+ # that pnpm packs, and the build unpacks them over node_modules, as npm would install them. image.ts
5
+ # stages the context and tags the image by its content.
6
6
  FROM node:24.21.0-alpine@sha256:ebfe2f90462722a7a4de65e91990e97fe0d401c70e0e762c5b53302f905ec1c1
7
7
  WORKDIR /opt/lab
8
8
  COPY package.json ./
@@ -14,5 +14,5 @@ RUN for name in quantity algebra service; do \
14
14
  && tar -xzf /tmp/workspace/mark1russell7-$name-*.tgz -C "node_modules/@mark1russell7/$name" --strip-components=1; \
15
15
  done \
16
16
  && rm -rf /tmp/workspace
17
- COPY app.mjs client.mjs agent.mjs watch.mjs compose.ts backends.ts conntrack.ts drops.ts ./
17
+ COPY app.mjs client.mjs client-grpc.mjs agent.mjs watch.mjs compose.ts backends.ts conntrack.ts drops.ts ./
18
18
  CMD ["node", "app.mjs"]
@@ -0,0 +1,97 @@
1
+ // A gRPC client of a kind cell: grpc-js 1.14.6 with one channel to the ClusterIP of the server, at
2
+ // the defaults of grpc-js. An open loop sends a unary call of grpc.health.v1.Health/Check each
3
+ // EVERY_MS on that channel. The channel holds one connection, thus kube-proxy picks a backend only
4
+ // when grpc-js connects again: after a GOAWAY of the server or the end of the socket.
5
+ //
6
+ // Each call is one JSON line, as the lines of client.mjs: its start on CLOCK_MONOTONIC (`t`, ms), its
7
+ // duration (`d`, ms), its outcome, the pod that answered (`b`, from the header x-pod of grpc-go), and
8
+ // the local port of the last socket of the channel (`lp`). The outcomes:
9
+ // - ok: the reply.
10
+ // - refused, reset, unreachable: a status whose details name ECONNREFUSED, ECONNRESET or EPIPE, or
11
+ // EHOSTUNREACH or ENETUNREACH. A call that finds the channel in TRANSIENT_FAILURE fails at once
12
+ // with the error of the last connect (load-balancing-call.ts:338-345), thus it names that errno.
13
+ // - timeout: no answer in TIMEOUT_MS. A call of grpc-js has no deadline at the defaults, thus the client
14
+ // cancels it at that time.
15
+ // - error: each other status, with its name and its details in `e`.
16
+ import net from "node:net";
17
+
18
+ const [host, port] = (process.env.TARGET ?? "").split(":");
19
+ const every = Number(process.env.EVERY_MS ?? 20);
20
+ const timeout = Number(process.env.TIMEOUT_MS ?? 1000);
21
+ const pod = process.env.POD_NAME ?? "client";
22
+ const node = process.env.NODE_NAME ?? "";
23
+ const now = () => Number(process.hrtime.bigint()) / 1e6;
24
+
25
+ let pending = [];
26
+ const flush = () => {
27
+ if (pending.length === 0) return;
28
+ process.stdout.write(pending.join(""));
29
+ pending = [];
30
+ };
31
+ setInterval(flush, 100);
32
+ const say = (line) => pending.push(`${JSON.stringify({ ...line, p: pod, n: node })}\n`);
33
+
34
+ // the local port of a socket, or null once its handle is closed (as in client.mjs)
35
+ const portOf = (socket) => {
36
+ const out = {};
37
+ socket?._handle?.getsockname?.(out);
38
+ return typeof out.port === "number" ? out.port : null;
39
+ };
40
+
41
+ // grpc-js connects with net.connect (transport.ts:830), on the module object that this patch changes.
42
+ // It loads after the patch. With an address and no host name, connect() comes before net.connect
43
+ // returns, thus the handle has the port at once, a refused connection's too
44
+ let lp = null;
45
+ const connect = net.connect;
46
+ net.connect = function (...args) {
47
+ const socket = connect.apply(this, args);
48
+ lp = portOf(socket) ?? lp;
49
+ socket.once("connect", () => {
50
+ lp = portOf(socket) ?? lp;
51
+ });
52
+ return socket;
53
+ };
54
+
55
+ const grpc = await import("@grpc/grpc-js");
56
+
57
+ // ---- the messages of grpc.health.v1, encoded by hand: the request of the service "", and the status of the reply
58
+ const encodeRequest = () => Buffer.alloc(0);
59
+ const decodeResponse = (buffer) => (buffer.length >= 2 && buffer[0] === 0x08 ? buffer[1] : 0);
60
+
61
+ const outcomeOf = (error) => {
62
+ const text = `${error.details ?? ""} ${error.message ?? ""}`;
63
+ if (/ECONNREFUSED/.test(text)) return "refused";
64
+ if (/ECONNRESET|EPIPE/.test(text)) return "reset";
65
+ if (/EHOSTUNREACH|ENETUNREACH/.test(text)) return "unreachable";
66
+ if (error.code === grpc.status.DEADLINE_EXCEEDED) return "timeout";
67
+ return "error";
68
+ };
69
+
70
+ const client = new grpc.Client(`${host}:${port}`, grpc.credentials.createInsecure(), {});
71
+
72
+ const fire = () => {
73
+ const t = now();
74
+ let done = false;
75
+ let backend = null;
76
+ const finish = (o, extra = {}) => {
77
+ if (done) return;
78
+ done = true;
79
+ clearTimeout(timer);
80
+ say({ ev: "req", t, d: Math.round((now() - t) * 1000) / 1000, o, ...(backend === null ? {} : { b: backend }), ...extra, lp });
81
+ };
82
+ const call = client.makeUnaryRequest("/grpc.health.v1.Health/Check", encodeRequest, decodeResponse, null, new grpc.Metadata(), {}, (error, status) => {
83
+ if (error === null || error === undefined) finish(status === 1 ? "ok" : `status-${status}`);
84
+ else finish(outcomeOf(error), { e: `${grpc.status[error.code] ?? error.code}: ${error.details ?? error.message}`.slice(0, 200) });
85
+ });
86
+ call.on("metadata", (metadata) => {
87
+ const named = metadata.get("x-pod")[0];
88
+ if (named !== undefined) backend = String(named);
89
+ });
90
+ const timer = setTimeout(() => {
91
+ finish("timeout", { e: "LAB_TIMEOUT" });
92
+ call.cancel();
93
+ }, timeout);
94
+ };
95
+
96
+ say({ ev: "client", what: "start", t: now(), target: `${host}:${port}`, every, timeout, client: "grpc-js" });
97
+ setInterval(fire, every);