@mark1russell7/harness 0.15.4 → 0.15.6

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.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as unlockedManifests, B as environmentProblems, C as programOf, D as subjectProblems, E as subjectClient, F as jarVersions, H as latestEndOf, I as locksOf, L as npmVersions, M as LOCK_NAMES, N as cargoVersions, O as targetImageOf, P as goVersions, R as versionsOf, S as planOf, T as shippedSource, U as requestFirst, V as isHopPlace, _ as kafkaClientImage, a as SHIPPED_NAMES, b as nodeHttpImage, c as buildRecordOf, d as harnessImage, f as harnessVersion, g as inContext, h as imageProblems, i as SHIPPED_CLIENTS, j as unpinnedBases, k as targetSourceOf, l as goHttpImage, m as imageOf, n as PINNED, o as amqpClientImage, p as hikariClientImage, r as REPOSITORY, s as basesOf, t as CLIENT_NAMES, u as grpcClientImage, v as mongoClientImage, w as routerImage, x as pgClientImage, y as nodeClientImage, z as CLIENT_CAPABILITIES } from "./image-D88I5WA_.js";
1
+ import { A as unlockedManifests, B as environmentProblems, C as programOf, D as subjectProblems, E as subjectClient, F as jarVersions, H as latestEndOf, I as locksOf, L as npmVersions, M as LOCK_NAMES, N as cargoVersions, O as targetImageOf, P as goVersions, R as versionsOf, S as planOf, T as shippedSource, U as requestFirst, V as isHopPlace, _ as kafkaClientImage, a as SHIPPED_NAMES, b as nodeHttpImage, c as buildRecordOf, d as harnessImage, f as harnessVersion, g as inContext, h as imageProblems, i as SHIPPED_CLIENTS, j as unpinnedBases, k as targetSourceOf, l as goHttpImage, m as imageOf, n as PINNED, o as amqpClientImage, p as hikariClientImage, r as REPOSITORY, s as basesOf, t as CLIENT_NAMES, u as grpcClientImage, v as mongoClientImage, w as routerImage, x as pgClientImage, y as nodeClientImage, z as CLIENT_CAPABILITIES } from "./image-CsPgXjcZ.js";
2
2
  import { quantity, valueIn } from "@mark1russell7/quantity";
3
3
  import { median, medianInterval as medianInterval$1, quantile, quantileSorted } from "@mark1russell7/rigor-statistics";
4
4
  import { rungVerdict } from "@mark1russell7/rigor-bench";
@@ -9,7 +9,7 @@ import { mkdtemp, rm, writeFile } from "node:fs/promises";
9
9
  import { release, tmpdir } from "node:os";
10
10
  import { join } from "node:path";
11
11
  import { existsSync, readFileSync } from "node:fs";
12
- //#region src/load.ts
12
+ // src/load.ts
13
13
  /**
14
14
  * The measure and the verdict of an open-loop cell (SYS-68). A client on a schedule sends each
15
15
  * arrival at its time, thus a stall counts in each arrival that it delayed. The package rigor-chaos
@@ -303,8 +303,7 @@ const estimateVerdict = (estimates) => {
303
303
  words: `The estimate of the open loop puts back ${hidden} hidden sends, with ${gaps}: ${spread}.`
304
304
  };
305
305
  };
306
- //#endregion
307
- //#region src/verdict.ts
306
+ // src/verdict.ts
308
307
  /** This function gives the words of the outcome of a second request: its connection, a retry, and its end. */
309
308
  const requestWords = (outcome) => `${outcome.connection}${outcome.retried ? ", a retry" : ""}, ${outcome.pending === true ? "pending" : outcome.error ?? "a reply"}`;
310
309
  /**
@@ -321,6 +320,28 @@ const NOISE = quantity(4, "ms");
321
320
  * 2.75 ms at 4 environments, where δ_abs is 1 ms. Thus a cell's δ_abs does not change it.
322
321
  */
323
322
  const INJECT = NOISE;
323
+ /**
324
+ * This function gives the void of a run from the commit of its fault, or null (SYS-99). A fault
325
+ * starts somewhere in its commit, thus each time from the start of the commit is too long by the
326
+ * commit or less. A commit up to `INJECT` is in the noise. A longer commit voids the run only when
327
+ * that shift can move a time across an edge of its band. Thus a drill with a band of minutes keeps
328
+ * a run with a commit of 8 ms. `times` holds each time that a band judges, with the edges of the
329
+ * verdict. A run with no time is void.
330
+ */
331
+ const commitVoid = (commit, times) => {
332
+ const took = valueIn(commit, "s");
333
+ if (took <= valueIn(INJECT, "s")) return null;
334
+ const crosses = (time) => {
335
+ const at = valueIn(time.at, "s");
336
+ const low = valueIn(time.low, "s");
337
+ const high = valueIn(time.high, "s");
338
+ const inside = at - took >= low && at <= high;
339
+ const outside = at < low || at - took > high;
340
+ return !inside && !outside;
341
+ };
342
+ if (times.length > 0 && !times.some(crosses)) return null;
343
+ return `the commit of the fault took ${Math.round(valueIn(commit, "ms") * 10) / 10} ms, longer than the noise of the pipeline: its start is not known`;
344
+ };
324
345
  /** This function gives the δ_abs of a cell: its own, or `NOISE` for a cell that gives none. */
325
346
  const noiseOf = (cell) => cell.noise ?? NOISE;
326
347
  /**
@@ -836,8 +857,7 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
836
857
  why: `${counts}; ${centre} straddles the band`
837
858
  };
838
859
  };
839
- //#endregion
840
- //#region src/application.ts
860
+ // src/application.ts
841
861
  /**
842
862
  * This module reads the acts of the program of the observer: its heartbeat, its drop of the
843
863
  * connection, its reconnect and its call in flight. The kernel has no report of a detection by
@@ -985,6 +1005,11 @@ const jitterOfLines = (lines, socket, local, until) => {
985
1005
  /** This function gives each ping of the program on the connection, with the kernel's stamp of its write in the pairing window (`delta`). */
986
1006
  const pingsOf = (lines, socket, local, delta = NOISE) => lines.filter((line) => line.ev === "ping" && onConnection(line, local)).map((line) => eventOf(socket, line, isWrite, delta));
987
1007
  /**
1008
+ * This function gives each pong of the program on the connection: each `write` line with the type
1009
+ * `pong`. Each pong has the kernel's stamp of its write in the pairing window (`delta`).
1010
+ */
1011
+ const pongsOf = (lines, socket, local, delta = NOISE) => lines.filter((line) => line.ev === "write" && line["type"] === "pong" && onConnection(line, local)).map((line) => eventOf(socket, line, isWrite, delta));
1012
+ /**
988
1013
  * This function gives the first ping that got no answer: no segment with data reached the socket
989
1014
  * after its write, up to `until`. Its write starts the wait of the heartbeat that the fault met.
990
1015
  */
@@ -1053,8 +1078,63 @@ const callOf = (events, request, detected) => {
1053
1078
  after: detected === void 0 ? null : between$4(detected, end.t)
1054
1079
  };
1055
1080
  };
1056
- //#endregion
1057
- //#region src/driver.ts
1081
+ // src/delivery.ts
1082
+ /**
1083
+ * This function gives the stream of a cell with a delivery law. It throws for a cell with no count
1084
+ * of events: the law has no last event without it. It also throws for a target without its lines
1085
+ * (`Target.lines`): the law reads the lines of the two programs.
1086
+ */
1087
+ const streamOf = (cell) => {
1088
+ const { count, sender } = cell.probe;
1089
+ if (cell.probe.mode !== "stream" || count === void 0 || count < 1) throw new RangeError(`${cell.name}: a delivery law needs a stream of 1 or more events (probe.mode "stream" and probe.count)`);
1090
+ if (cell.target.lines !== true) throw new RangeError(`${cell.name}: a delivery law needs the lines of the target (target.lines)`);
1091
+ return {
1092
+ count,
1093
+ sender: sender ?? "client"
1094
+ };
1095
+ };
1096
+ /** This function gives the numbers of the lines `ev` of a program: the field `n` of each. */
1097
+ const numbersOf$1 = (lines, ev) => lines.filter((line) => line.ev === ev && typeof line["n"] === "number").map((line) => line["n"]);
1098
+ /** This function gives the lines of the sender and of the receiver of a stream, in that sequence. */
1099
+ const sidesOf = (run, stream) => stream.sender === "client" ? [run.events, run.server ?? []] : [run.server ?? [], run.events];
1100
+ /** This function tells that the receiver of a stream got its last event: the end of the wait of a run. */
1101
+ const streamEnded = (run, stream) => numbersOf$1(sidesOf(run, stream)[1], "got").includes(stream.count);
1102
+ /** This function gives what a run of a stream delivered. */
1103
+ const deliveryOf = (run, stream) => {
1104
+ const [sender, receiver] = sidesOf(run, stream);
1105
+ const emitted = new Set(numbersOf$1(sender, "emitted"));
1106
+ const got = numbersOf$1(receiver, "got");
1107
+ const distinct = new Set(got);
1108
+ const second = run.events.filter((line) => line.ev === "status" && line["status"] === "connected")[1];
1109
+ return {
1110
+ emitted: emitted.size,
1111
+ got: distinct.size,
1112
+ lost: [...emitted].filter((n) => !distinct.has(n)).length,
1113
+ duplicates: got.length - distinct.size,
1114
+ unknown: [...distinct].filter((n) => !emitted.has(n)).length,
1115
+ recovered: second === void 0 ? null : second["recovered"] === true,
1116
+ ended: distinct.has(stream.count)
1117
+ };
1118
+ };
1119
+ /** This function tells that a count is outside its band. */
1120
+ const outside = (band, value) => value < band.low || value > band.high;
1121
+ /** This function gives the words of a count band. */
1122
+ const bandWords$1 = (band) => band.low === band.high ? `${band.low}` : `${band.low} to ${band.high}`;
1123
+ /** This function gives the finding of a run of a stream against its law, or null when the run holds it. */
1124
+ const deliveryFinding = (prediction, stream, read) => {
1125
+ const sender = `the ${stream.sender}`;
1126
+ const receiver = stream.sender === "client" ? "the target" : "the client";
1127
+ const found = [
1128
+ read.emitted === stream.count ? null : `${sender} emitted ${read.emitted} of the ${stream.count} events of the stream`,
1129
+ read.ended ? null : `${receiver} did not get event ${stream.count}, the last of the stream`,
1130
+ read.unknown === 0 ? null : `${receiver} got ${read.unknown} events that ${sender} did not emit`,
1131
+ outside(prediction.lost, read.lost) ? `${receiver} lost ${read.lost} events, outside ${bandWords$1(prediction.lost)}` : null,
1132
+ outside(prediction.duplicates, read.duplicates) ? `${receiver} got ${read.duplicates} extra copies, outside ${bandWords$1(prediction.duplicates)}` : null,
1133
+ prediction.recovered === void 0 || read.recovered === prediction.recovered ? null : read.recovered === null ? "the client made no second connection, thus it gave no value of recovered" : `the second connection of the client has recovered ${read.recovered}, not ${prediction.recovered}`
1134
+ ].filter((each) => each !== null);
1135
+ return found.length === 0 ? null : found.join(". ");
1136
+ };
1137
+ // src/driver.ts
1058
1138
  /** These are the errno numbers that the kernel reports to a socket, by the names that predictions use. */
1059
1139
  const ERRNO$1 = {
1060
1140
  32: "EPIPE",
@@ -1502,8 +1582,7 @@ const measureDriver = (cell, run) => {
1502
1582
  finding: findings[0] ?? null
1503
1583
  };
1504
1584
  };
1505
- //#endregion
1506
- //#region src/queue.ts
1585
+ // src/queue.ts
1507
1586
  /** This bit is the SYN of the flags of an `rx` record of the prober. */
1508
1587
  const SYN = 2;
1509
1588
  /** This function gives the time between two stamps of CLOCK_MONOTONIC. */
@@ -1664,8 +1743,7 @@ const measureQueue = (run, expected) => {
1664
1743
  queue
1665
1744
  };
1666
1745
  };
1667
- //#endregion
1668
- //#region src/conntrack.ts
1746
+ // src/conntrack.ts
1669
1747
  /** This errno tells that a connect got a slot. */
1670
1748
  const NONE = "none";
1671
1749
  const numberOr = (line, field) => {
@@ -1780,8 +1858,7 @@ const measureConntrack = (run, expected) => {
1780
1858
  conntrack
1781
1859
  };
1782
1860
  };
1783
- //#endregion
1784
- //#region src/pause.ts
1861
+ // src/pause.ts
1785
1862
  /** This expression finds the stamp of a log line of a broker, as its console writes it, on UTC. */
1786
1863
  const LOG_TIME = /\[(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d),(\d{3})\]/;
1787
1864
  /** This function gives the time of a log line on the monotonic clock of a member, in ns, from the `start` line of that member. It is null for a line with no stamp. */
@@ -1943,8 +2020,7 @@ const measurePause = (run, prediction) => {
1943
2020
  pause: pauseReading
1944
2021
  };
1945
2022
  };
1946
- //#endregion
1947
- //#region src/ports.ts
2023
+ // src/ports.ts
1948
2024
  /** This errno ends a search that found no port. */
1949
2025
  const NO_PORT = "EADDRNOTAVAIL";
1950
2026
  const portsOf = (line) => Array.isArray(line["ports"]) ? line["ports"].filter((port) => typeof port === "number") : [];
@@ -2032,8 +2108,7 @@ const measurePorts = (run, expected) => {
2032
2108
  ports
2033
2109
  };
2034
2110
  };
2035
- //#endregion
2036
- //#region src/recovery.ts
2111
+ // src/recovery.ts
2037
2112
  /**
2038
2113
  * This module holds the pure parts of a recovery drill. These are the scripts of the shell, the reader
2039
2114
  * of the output of `bsondump`, and the set check of a recovery. It has no container, thus unit tests
@@ -2227,8 +2302,7 @@ const recoveryFindings = (measured, writes) => {
2227
2302
  if (measured.afterBackup !== null && lost !== null && Math.abs(lost - measured.afterBackup) > 2) findings.push(`the restore lost ${lost} accepted writes, and ${measured.afterBackup} came after the last backup`);
2228
2303
  return findings;
2229
2304
  };
2230
- //#endregion
2231
- //#region src/timeline.ts
2305
+ // src/timeline.ts
2232
2306
  /**
2233
2307
  * This module measures a run of a group cell. It gives the first write that a primary accepted
2234
2308
  * after the fault, and the timeline of the group. The Sentinels of a group announce its timeline.
@@ -2623,7 +2697,31 @@ const measureGroup = (cell, run) => {
2623
2697
  const first = kernel.find((record) => record.netns === run.netns && record.dst === firstAddress && record.tcp?.srtt !== void 0);
2624
2698
  const rtt = first?.tcp?.srtt === void 0 ? null : valueIn(first.tcp.srtt, "us") / 1e3;
2625
2699
  if (voided === null && assumed !== void 0 && rtt !== null && rtt > valueIn(assumed.high, "ms")) voided = `rtt-over-assumption: its first round trip was ${rtt} ms, above the ${valueIn(assumed.high, "ms")} ms that the prediction assumes`;
2626
- if (voided === null && prediction.detects === true && prediction.from === "fault" && (run.fault.t1 - run.fault.t0) / 1e6 > valueIn(INJECT, "ms")) voided = `the commit of the fault took ${Math.round((run.fault.t1 - run.fault.t0) / 1e5) / 10} ms, longer than the noise of the pipeline: its start is not known`;
2700
+ const commit = quantity((run.fault.t1 - run.fault.t0) / 1e9, "s");
2701
+ const noise = valueIn(noiseOf(cell), "s");
2702
+ const stamps = prediction.group?.stamps === void 0 ? 0 : valueIn(prediction.group.stamps, "s");
2703
+ const commitOf = (elapsed) => {
2704
+ if (prediction.detects !== true || prediction.from !== "fault") return null;
2705
+ const widened = (at, low, high, extra = 0) => ({
2706
+ at,
2707
+ low: quantity(valueIn(low, "s") - noise, "s"),
2708
+ high: quantity(valueIn(high, "s") + extra + noise, "s")
2709
+ });
2710
+ const stageTimes = (prediction.group?.stages ?? []).flatMap((band) => {
2711
+ const at = stages[band.stage];
2712
+ return at === void 0 ? [] : [widened(at, band.low, band.high, stamps)];
2713
+ });
2714
+ const errorTimes = (expected?.errors ?? []).flatMap((error) => {
2715
+ const met = group.errors.find((each) => each.name === error.name);
2716
+ return met === void 0 ? [] : [widened(met.first, error.low, error.high)];
2717
+ });
2718
+ if (elapsed === null) return commitVoid(commit, []);
2719
+ return commitVoid(commit, [
2720
+ widened(elapsed, prediction.low, prediction.high),
2721
+ ...stageTimes,
2722
+ ...errorTimes
2723
+ ]);
2724
+ };
2627
2725
  let reference = t0;
2628
2726
  if (prediction.detects === false && prediction.recovers !== void 0) {
2629
2727
  const into = events.find((event) => event.ev === "sent" && event.t > run.fault.t1);
@@ -2675,7 +2773,7 @@ const measureGroup = (cell, run) => {
2675
2773
  if (prediction.detects !== null || kafka) findings.push(lands === "new" ? "the client never wrote to a new primary in the window" : "the client never wrote again in the window");
2676
2774
  return {
2677
2775
  ...silent,
2678
- void: voided,
2776
+ void: voided ?? commitOf(null),
2679
2777
  finding: findings[0] ?? null,
2680
2778
  group
2681
2779
  };
@@ -2684,18 +2782,18 @@ const measureGroup = (cell, run) => {
2684
2782
  const others = new Set(socketsOf(events).filter((socket) => socket.role !== "pool").map((socket) => socket.local));
2685
2783
  const segment = kernel.filter((record) => record.netns === run.netns && record.ev === "rx" && record.dst === address && !others.has(String(record.src)) && (record.seg?.len.value ?? 0) > 0 && record.mono <= accepted.t && record.mono > after).at(-1);
2686
2784
  const at = segment?.mono ?? accepted.t;
2785
+ const elapsed = between$1(reference, at);
2687
2786
  return {
2688
2787
  outcome: { kind: "answered" },
2689
- elapsed: between$1(reference, at),
2788
+ elapsed,
2690
2789
  socket: between$1(reference, accepted.t),
2691
2790
  noticed: segment === void 0 ? null : between$1(segment.mono, accepted.t),
2692
- void: voided,
2791
+ void: voided ?? commitOf(elapsed),
2693
2792
  finding: findings[0] ?? null,
2694
2793
  group
2695
2794
  };
2696
2795
  };
2697
- //#endregion
2698
- //#region src/observe.ts
2796
+ // src/observe.ts
2699
2797
  /** These are the errno numbers that the kernel reports to a socket, by the names that predictions use. */
2700
2798
  const ERRNO = {
2701
2799
  32: "EPIPE",
@@ -2715,7 +2813,7 @@ const count = (event, field) => event === void 0 ? 0 : Number(event[field] ?? 0)
2715
2813
  /** This function gives the view of the client on the same interval: TCP_INFO, with a sample each 2 ms. */
2716
2814
  const socketVantage = (cell, events, ready, request) => {
2717
2815
  const { from } = cell.prediction.detects === true ? cell.prediction : { from: void 0 };
2718
- if (from === void 0 || from === "peer-closed" || from === "fault" || from === "ping-sent" || from === "first-sent" || from === "last-data" || from === "last-reply") return null;
2816
+ if (from === void 0 || from === "peer-closed" || from === "fault" || from === "ping-sent" || from === "pong-sent" || from === "first-sent" || from === "last-data" || from === "last-reply") return null;
2719
2817
  const ended = events.find((event) => event.ev === "error" || event.ev === "eof");
2720
2818
  const reference = from === "last-received" ? ready : from === "request-sent" ? request : events.find((event) => event.ev === "kernel" && event.t >= request.t && count(event, "retransmits") > 0);
2721
2819
  return ended === void 0 || reference === void 0 ? null : between(reference.t, ended.t);
@@ -3097,6 +3195,7 @@ const measureSocket = (cell, run) => {
3097
3195
  if (from === "fault") return run.fault?.t0;
3098
3196
  if (from === "client-start") return (events.find((event) => event.ev === "connecting") ?? events[0])?.t;
3099
3197
  if (from === "ping-sent") return firstUnanswered(pings, socket, ended)?.at;
3198
+ if (from === "pong-sent") return pongsOf(lines, socket, named, paired).filter((pong) => pong.at <= before).at(-1)?.at;
3100
3199
  const record = from === "last-received" ? socket.filter((each) => each.ev === "rx" && each.mono <= before).at(-1) : from === "last-data" ? socket.filter((each) => each.ev === "rx" && (each.seg?.len.value ?? 0) > 0 && each.mono <= (ended ?? before)).at(-1) : from === "last-reply" ? socket.filter((each) => each.ev === "rx" && (each.seg?.len.value ?? 0) > 0 && each.mono < (ended ?? Infinity)).at(-1) : from === "first-retransmission" ? retransmitted.find((each) => each.why === "rto" && each.mono > before) : from === "first-sent" ? socket.find((each) => each.ev === "tx" && each.mono > before && (each.seg?.len.value ?? 0) > 0) : from === "syn-sent" ? socket.find((each) => each.ev === "state" && newState(each) === 2) : from === "peer-closed" ? kernel.find((each) => each.netns === peerNetns && each.cookie === peerCookie && each.ev === "state" && oldState(each) === 1) : void 0;
3101
3200
  if (record === void 0 && from === "peer-closed" && peerCookie === void 0) return proxiedClose(run);
3102
3201
  return record?.mono;
@@ -3299,10 +3398,14 @@ const measureSocket = (cell, run) => {
3299
3398
  exited: void 0
3300
3399
  } : closeOrExit(drop.line, closed, exitOf(run, cookie), noiseOf(cell));
3301
3400
  const how = prediction.drop === void 0 || drop === void 0 || left === void 0 ? null : dropFinding(prediction.drop, drop, left, paired, exited);
3401
+ const stream = prediction.delivery === void 0 ? void 0 : streamOf(cell);
3402
+ const delivery = stream === void 0 ? void 0 : deliveryOf(run, stream);
3403
+ const delivered = prediction.delivery === void 0 || stream === void 0 || delivery === void 0 ? null : deliveryFinding(prediction.delivery, stream, delivery);
3302
3404
  const found = [
3303
3405
  matches ? null : `it ended with ${words}, not ${prediction.errno}`,
3304
3406
  late,
3305
- how
3407
+ how,
3408
+ delivered
3306
3409
  ].filter((each) => each !== null);
3307
3410
  const finding = found.length === 0 ? null : found.join(". ");
3308
3411
  const programTimer = cell.probe.http !== void 0 && prediction.from === "last-received" && prediction.timer !== "keepalive";
@@ -3311,8 +3414,17 @@ const measureSocket = (cell, run) => {
3311
3414
  const lag = (valueIn(prediction.high, "s") - valueIn(prediction.low, "s")) * 1e9;
3312
3415
  const slow = prediction.timer.startsWith("expire_") ? (run.middlebox ?? []).find((line) => line.ev === "pump-slow" && line.t <= ended && line.t + Number(line["took"]) * 1e9 >= ended - lag) : void 0;
3313
3416
  if (slow !== void 0) voided ??= `a listing of the router took ${Math.round(Number(slow["took"]) * 1e4) / 10} ms, longer than the bound of its prediction`;
3314
- const commit = run.fault === null ? 0 : (run.fault.t1 - run.fault.t0) / 1e6;
3315
- if (prediction.from === "fault" && commit > valueIn(INJECT, "ms")) voided ??= `the commit of the fault took ${Math.round(commit * 10) / 10} ms, longer than the noise of the pipeline: its start is not known`;
3417
+ const elapsed = between(reference, ended);
3418
+ if (prediction.from === "fault" && run.fault !== null) {
3419
+ const noise = valueIn(noiseOf(cell), "s");
3420
+ const commit = quantity((run.fault.t1 - run.fault.t0) / 1e9, "s");
3421
+ const times = prediction.detects === true ? [{
3422
+ at: elapsed,
3423
+ low: quantity(valueIn(prediction.low, "s") - noise, "s"),
3424
+ high: quantity(valueIn(prediction.high, "s") + noise, "s")
3425
+ }] : [];
3426
+ voided ??= commitVoid(commit, times);
3427
+ }
3316
3428
  const unanswered = prediction.from === "ping-sent" ? firstUnanswered(pings, socket, ended) : void 0;
3317
3429
  const endLine = drop?.line ?? seen;
3318
3430
  const view = unanswered !== void 0 ? endLine === void 0 ? null : between(unanswered.line.t, endLine.t) : remote ? null : socketVantage(cell, events, ready, request);
@@ -3320,11 +3432,12 @@ const measureSocket = (cell, run) => {
3320
3432
  ...base,
3321
3433
  ...chain,
3322
3434
  outcome,
3323
- elapsed: between(reference, ended),
3435
+ elapsed,
3324
3436
  socket: view,
3325
3437
  noticed,
3326
3438
  steps,
3327
3439
  ...reconnect === void 0 ? {} : { reconnect },
3440
+ ...delivery === void 0 ? {} : { delivery },
3328
3441
  ...left === void 0 ? {} : { left },
3329
3442
  ...exited === void 0 ? {} : { exited },
3330
3443
  ...cell.probe.ws !== void 0 && inflight ? { call: callOf(events, request, ended) } : {},
@@ -3332,8 +3445,7 @@ const measureSocket = (cell, run) => {
3332
3445
  finding
3333
3446
  };
3334
3447
  };
3335
- //#endregion
3336
- //#region src/fabric.ts
3448
+ // src/fabric.ts
3337
3449
  /**
3338
3450
  * A fabric is a routed network between the client and the target, on layer E3 (docs/S7.md). Four
3339
3451
  * routers of FRRouting, two leaves and two spines, run real BGP over veth pairs that containerlab
@@ -3766,8 +3878,7 @@ const openFabric = async (parts) => {
3766
3878
  throw error;
3767
3879
  }
3768
3880
  };
3769
- //#endregion
3770
- //#region src/substrate.ts
3881
+ // src/substrate.ts
3771
3882
  /**
3772
3883
  * A layer is a rung of the laboratory (`docs/S7.md`). E1 is containers on one kernel, and E2 is a
3773
3884
  * cluster of containers on one kernel. A lab with `Topology.fabric` writes E3: routers in containers.
@@ -3894,8 +4005,7 @@ const unpoolable = (substrates) => {
3894
4005
  if (b !== void 0) return [a, b];
3895
4006
  }
3896
4007
  };
3897
- //#endregion
3898
- //#region src/lab.ts
4008
+ // src/lab.ts
3899
4009
  /** This function loads Testcontainers when a lab first opens. Code that only measures and judges does not load it. */
3900
4010
  const containers = () => import("testcontainers");
3901
4011
  /**
@@ -3945,7 +4055,8 @@ const LIFT = {
3945
4055
  blackhole: "clear",
3946
4056
  rst: "clear-rst",
3947
4057
  reject: "clear-reject",
3948
- mtu: "clear-mtu"
4058
+ mtu: "clear-mtu",
4059
+ "fin-ack": "clear-fin-ack"
3949
4060
  };
3950
4061
  /** This function collects the JSON lines of a program. It gives each line to `also` too, when the caller gives it. */
3951
4062
  const lines = (also) => {
@@ -4971,8 +5082,7 @@ const openLab = async (target, kind = "tcp", topology) => {
4971
5082
  throw error;
4972
5083
  }
4973
5084
  };
4974
- //#endregion
4975
- //#region src/standby.ts
5085
+ // src/standby.ts
4976
5086
  /**
4977
5087
  * This module is the second server of a pair (`Cell.pair`). The lab of the cell has the primary, the
4978
5088
  * topology in front of it, the injector and the prober. This module adds one standby on the network
@@ -5178,8 +5288,7 @@ const pairOnce = async (lab, standby, cell, environment, index, dry = false) =>
5178
5288
  }
5179
5289
  };
5180
5290
  };
5181
- //#endregion
5182
- //#region src/pins.ts
5291
+ // src/pins.ts
5183
5292
  /**
5184
5293
  * This module tells if a manifest pins each program that a run operated. A record that does not pin
5185
5294
  * them is not a record. A later run cannot operate the same programs, thus nobody can reproduce
@@ -5241,8 +5350,7 @@ const recordProblems = (record) => [.../* @__PURE__ */ new Set([
5241
5350
  ...record.manifests.flatMap((manifest) => manifestProblems(manifest)),
5242
5351
  ...record.debug === true ? [DEBUG] : []
5243
5352
  ])];
5244
- //#endregion
5245
- //#region src/group.ts
5353
+ // src/group.ts
5246
5354
  /** This function gives the configuration file of a member: its port, its settings, and the primary that a replica follows. */
5247
5355
  const memberConfig = (group, primary) => [
5248
5356
  `port ${group.port}`,
@@ -5927,8 +6035,7 @@ const groupOnce = async (lab, cell, environment, index) => {
5927
6035
  }
5928
6036
  };
5929
6037
  };
5930
- //#endregion
5931
- //#region src/replset.ts
6038
+ // src/replset.ts
5932
6039
  /** These are the components of the log of mongod that a run keeps: replication, its heartbeats, the elections, the rollbacks and the commands. */
5933
6040
  const KEPT = /* @__PURE__ */ new Set([
5934
6041
  "REPL",
@@ -6573,8 +6680,7 @@ const replicaSetOnce = async (lab, cell, environment, index) => {
6573
6680
  }
6574
6681
  };
6575
6682
  };
6576
- //#endregion
6577
- //#region src/drill.ts
6683
+ // src/drill.ts
6578
6684
  /**
6579
6685
  * This module does one run of a recovery drill on the lab of a replica set. A drill stops the store
6580
6686
  * during writes, removes its disk, and recovers from real backups, or by an election.
@@ -6923,8 +7029,7 @@ const drillOnce = async (lab, cell, environment, index) => {
6923
7029
  }
6924
7030
  };
6925
7031
  };
6926
- //#endregion
6927
- //#region src/cluster.ts
7032
+ // src/cluster.ts
6928
7033
  /** This form is a line of the console log of RabbitMQ 4.3: the time with its offset, the level, the process and the message. */
6929
7034
  const LINE = /^(\d{4}-\d\d-\d\d) (\d\d:\d\d:\d\d)\.(\d{3})(\d*)([+-]\d\d:\d\d) \[(\w+)\] <[^>]*> (.*)$/;
6930
7035
  /** This form is an escape of ANSI: RabbitMQ colors each line of its console by its level. */
@@ -7665,8 +7770,7 @@ const clusterOnce = async (lab, cell, environment, index) => {
7665
7770
  }
7666
7771
  };
7667
7772
  };
7668
- //#endregion
7669
- //#region src/kafka.ts
7773
+ // src/kafka.ts
7670
7774
  /**
7671
7775
  * This module is the lab of a group of Kafka brokers in KRaft mode with one controller. It opens one
7672
7776
  * environment for a Kafka cell, for the runs of the cell. Each node is a container from the stock
@@ -8311,8 +8415,7 @@ const kafkaPauseOnce = async (lab, cell, environment, index) => {
8311
8415
  }
8312
8416
  };
8313
8417
  };
8314
- //#endregion
8315
- //#region src/run.ts
8418
+ // src/run.ts
8316
8419
  /**
8317
8420
  * This function measures and judges the raw records of a cell, with the code of the harness at
8318
8421
  * this time. `runCell` uses it during a cell. A holder of the raw records of a cell can use it
@@ -8330,6 +8433,15 @@ const droppedSoFar = (records) => {
8330
8433
  for (let at = records.length - 1; at >= 0; at -= 1) if (records[at].ev === "clock") return Number(records[at]["lost"] ?? 0);
8331
8434
  return 0;
8332
8435
  };
8436
+ /**
8437
+ * This function gives the length in seconds of the stream of a WebSocket client: `count` events,
8438
+ * one each `interval`. It throws for a stream without them.
8439
+ */
8440
+ const streamLength = (cell) => {
8441
+ const { count, interval } = cell.probe;
8442
+ if (count === void 0 || interval === void 0) throw new RangeError(`${cell.name}: a stream of a WebSocket client needs probe.count and probe.interval`);
8443
+ return count * valueIn(interval, "s");
8444
+ };
8333
8445
  /** This function gives the argv of the client for a cell, with a deadline far after all that it waits for. */
8334
8446
  const probeArgs = (cell, lab) => {
8335
8447
  const { prediction, probe } = cell;
@@ -8351,7 +8463,10 @@ const probeArgs = (cell, lab) => {
8351
8463
  args.push("--request-timeout-ms", String(valueIn(ws.requestTimeout, "ms")));
8352
8464
  args.push("--connection-timeout-ms", String(valueIn(ws.connectionTimeout, "ms")));
8353
8465
  if (ws.hold !== void 0) args.push("--hold-ms", String(valueIn(ws.hold, "ms")));
8354
- args.push("--max-s", String(Math.ceil((longest + waits) * 2 + 10)));
8466
+ if (ws.retries !== void 0) args.push("--retries", String(ws.retries));
8467
+ const stream = probe.mode === "stream" ? streamLength(cell) : 0;
8468
+ if (probe.mode === "stream") args.push("--count", String(probe.count), "--interval-ms", String(valueIn(probe.interval, "ms")), "--sender", probe.sender ?? "client");
8469
+ args.push("--max-s", String(Math.ceil((longest + waits + stream) * 2 + 10)));
8355
8470
  return args;
8356
8471
  }
8357
8472
  if (probe.http !== void 0) {
@@ -8680,6 +8795,7 @@ const once = async (lab, cell, environment, index, dry = false) => {
8680
8795
  case "mtu-blackhole": return lab.fault("mtu", cell.faultAt ?? "client", { above: cell.mtu ?? 1200 });
8681
8796
  case "netem": return netemOn(cell.netem);
8682
8797
  case "rst": return lab.fault("rst", faultAt);
8798
+ case "fin-ack": return lab.fault("fin-ack", cell.faultAt ?? "client");
8683
8799
  case "middlebox-forget":
8684
8800
  case "proxy-idle":
8685
8801
  case "app-stall":
@@ -8745,6 +8861,7 @@ const once = async (lab, cell, environment, index, dry = false) => {
8745
8861
  await netemOn(void 0);
8746
8862
  return;
8747
8863
  case "rst": return lab.lift("rst", faultAt);
8864
+ case "fin-ack": return lab.lift("fin-ack", cell.faultAt ?? "client");
8748
8865
  case "toxic":
8749
8866
  await lab.toxic(null);
8750
8867
  return;
@@ -8828,6 +8945,18 @@ const once = async (lab, cell, environment, index, dry = false) => {
8828
8945
  const waits = expected.waits.reduce((sum, wait) => sum + valueIn(wait.high, "s"), 0);
8829
8946
  await dials(probe, 1 + expected.waits.length, waits * 2e3 + 5e3);
8830
8947
  }
8948
+ if ((cell.prediction.detects === true ? cell.prediction.delivery : void 0) !== void 0) {
8949
+ const stream = streamOf(cell);
8950
+ const within = streamLength(cell) * 2e3 + 1e4;
8951
+ const started = Date.now();
8952
+ const stopped = () => probe.events.some((event) => event.ev === "deadline" || event.ev === "fail");
8953
+ const current = () => ({
8954
+ ...partial(),
8955
+ server: lab.server.slice(serverFrom)
8956
+ });
8957
+ while (!streamEnded(current(), stream) && !stopped() && Date.now() - started < within) await sleep(20);
8958
+ await sleep(TAIL_MS);
8959
+ }
8831
8960
  }
8832
8961
  } finally {
8833
8962
  await probe.stop();
@@ -9139,7 +9268,6 @@ const runCell = async (cell, say = () => {}) => {
9139
9268
  target = larger;
9140
9269
  }
9141
9270
  };
9142
- //#endregion
9143
- export { AWS_FROM, CLIENT_CAPABILITIES, CLIENT_NAMES, CLOSED_TOLERANCE, CLOUDS, CLUSTER_STAGES, CONVERGE_MS, DAEMONS, DEBUG, DIRTY, DROP_HANDLING, FABRIC_CLIENT, FABRIC_DEVICE, FABRIC_TARGET, FRR_IMAGE, GIVES_AWAY, HASH_SCRIPT, INJECT, INSERT, KAFKA_TAIL_MS, KEPT, LAYERS, LINGER_MS, LISTING, LOAD_FORMAT, LOAD_PATH, LOCK_NAMES, LOSS_MARGIN, MEMBER_MARKS, MONITOR_DOWN, NODE_MARKS, NOISE, PINNED, PUMP, PUMP_SLACK, QUIET_MS, RELATIVE, REPLICA_SET_STAGES, REPOSITORY, RESTART, ROUTERS, SCHEDULE_PATH, SEED_DOCUMENT, SHIPPED_CLIENTS, SHIPPED_NAMES, STAGES, STANDBY_READY, STATUS_SCRIPT, STEPS, STEP_DOWN, amqpClientImage, basesOf, bootstrapOf, brokerEnv, buildOf, buildRecordOf, callOf, cancelsOf, cargoVersions, clockOffsetOf, closeOrExit, cloudOf, clusterArgs, clusterConf, clusterCutOf, clusterHostsOf, clusterOnce, clusterStagesOf, clusterViewOf, commitProblems, comparable, controllerEnv, crossingsOf, cutOf, deadlineOf, delayVoids, deviceOf, drillOnce, drillSpan, dropFinding, dropOf, endpointAfter, envOf, environmentCounts, environmentProblems, errorsOf, estimateOf, estimateVerdict, exitOf, fieldOf, fieldsOf, firstUnanswered, frrConf, goHttpImage, goVersions, groupOnce, groupVerdictOf, grpcClientImage, harnessImage, harnessRecord, harnessVersion, hashOf, highestHeld, hikariClientImage, hzOf, imageOf, imageProblems, inContext, infoOf, initiateScript, isFenceLine, isHopPlace, jarVersions, jitterOf, jitterOfLines, judge, kafkaArgs, kafkaClientImage, kafkaCutOf, kafkaOnce, kafkaPauseOnce, kafkaViewOf, lagsOf, laterMove, latestEndOf, leafLacks, leftAfter, loadOf, loadPlanOf, loadVerdict, locksOf, logNameOf, logTimeOf, manifestProblems, matches, measure, measureConntrack, measureDriver, measureGroup, measurePause, measurePorts, measureQueue, medianInterval, memAvailableOf, memberCommand, memberConfig, memberLineOf, mongoClientImage, monotonicAt, monotonicOf, namesGroup, nodeClientImage, nodeCommand, nodeHttpImage, nodeIdOf, nodeLineOf, nodeNameOf, nodesOnMonotonic, noiseOf, npmVersions, numbersOf, onMonotonic, openClusterLab, openFabric, openGroupLab, openKafkaLab, openLab, openReplicaSetLab, openStandby, pairArgs, pairOnce, pairingOf, pairingsOf, pauseReady, peersOf, pgClientImage, pingsOf, plainOf, planOf, poolOf, programLines, programOf, quantileOf, readCpu, readHost, readOplog, reconnectFinding, reconnectOf, recordProblems, recoveryFindings, recoveryOf, referenceOf, reorderingOf, replicaSetArgs, replicaSetOnce, replicaSetStagesOf, requestOf, requestWords, restamped, roomNeeded, roomVoidOf, routeLine, routerImage, routesOf, runCell, seedScript, sentinelConfig, sessionsOf, shippedClientRecord, shippedSource, sliceQuery, socketAt, socketOf, socketsOf, spread, spreadOf, stagesOf, standaloneCommand, standbyCommand, statusViewOf, stealShare, stopScript, streamsLoadOf, subjectClient, subjectProblems, subscriptionsOf, substrateHere, substrateKey, substrateOf, substrateOn, targetImageOf, targetSourceOf, templated, toolJsonOf, topicOf, topologyOf, toxicBody, unlockedManifests, unpinnedBases, unpoolable, verdictOf, versionsOf, viewOf, writesOf };
9271
+ export { AWS_FROM, CLIENT_CAPABILITIES, CLIENT_NAMES, CLOSED_TOLERANCE, CLOUDS, CLUSTER_STAGES, CONVERGE_MS, DAEMONS, DEBUG, DIRTY, DROP_HANDLING, FABRIC_CLIENT, FABRIC_DEVICE, FABRIC_TARGET, FRR_IMAGE, GIVES_AWAY, HASH_SCRIPT, INJECT, INSERT, KAFKA_TAIL_MS, KEPT, LAYERS, LINGER_MS, LISTING, LOAD_FORMAT, LOAD_PATH, LOCK_NAMES, LOSS_MARGIN, MEMBER_MARKS, MONITOR_DOWN, NODE_MARKS, NOISE, PINNED, PUMP, PUMP_SLACK, QUIET_MS, RELATIVE, REPLICA_SET_STAGES, REPOSITORY, RESTART, ROUTERS, SCHEDULE_PATH, SEED_DOCUMENT, SHIPPED_CLIENTS, SHIPPED_NAMES, STAGES, STANDBY_READY, STATUS_SCRIPT, STEPS, STEP_DOWN, amqpClientImage, basesOf, bootstrapOf, brokerEnv, buildOf, buildRecordOf, callOf, cancelsOf, cargoVersions, clockOffsetOf, closeOrExit, cloudOf, clusterArgs, clusterConf, clusterCutOf, clusterHostsOf, clusterOnce, clusterStagesOf, clusterViewOf, commitProblems, commitVoid, comparable, controllerEnv, crossingsOf, cutOf, deadlineOf, delayVoids, deliveryFinding, deliveryOf, deviceOf, drillOnce, drillSpan, dropFinding, dropOf, endpointAfter, envOf, environmentCounts, environmentProblems, errorsOf, estimateOf, estimateVerdict, exitOf, fieldOf, fieldsOf, firstUnanswered, frrConf, goHttpImage, goVersions, groupOnce, groupVerdictOf, grpcClientImage, harnessImage, harnessRecord, harnessVersion, hashOf, highestHeld, hikariClientImage, hzOf, imageOf, imageProblems, inContext, infoOf, initiateScript, isFenceLine, isHopPlace, jarVersions, jitterOf, jitterOfLines, judge, kafkaArgs, kafkaClientImage, kafkaCutOf, kafkaOnce, kafkaPauseOnce, kafkaViewOf, lagsOf, laterMove, latestEndOf, leafLacks, leftAfter, loadOf, loadPlanOf, loadVerdict, locksOf, logNameOf, logTimeOf, manifestProblems, matches, measure, measureConntrack, measureDriver, measureGroup, measurePause, measurePorts, measureQueue, medianInterval, memAvailableOf, memberCommand, memberConfig, memberLineOf, mongoClientImage, monotonicAt, monotonicOf, namesGroup, nodeClientImage, nodeCommand, nodeHttpImage, nodeIdOf, nodeLineOf, nodeNameOf, nodesOnMonotonic, noiseOf, npmVersions, numbersOf, onMonotonic, openClusterLab, openFabric, openGroupLab, openKafkaLab, openLab, openReplicaSetLab, openStandby, pairArgs, pairOnce, pairingOf, pairingsOf, pauseReady, peersOf, pgClientImage, pingsOf, plainOf, planOf, pongsOf, poolOf, programLines, programOf, quantileOf, readCpu, readHost, readOplog, reconnectFinding, reconnectOf, recordProblems, recoveryFindings, recoveryOf, referenceOf, reorderingOf, replicaSetArgs, replicaSetOnce, replicaSetStagesOf, requestOf, requestWords, restamped, roomNeeded, roomVoidOf, routeLine, routerImage, routesOf, runCell, seedScript, sentinelConfig, sessionsOf, shippedClientRecord, shippedSource, sliceQuery, socketAt, socketOf, socketsOf, spread, spreadOf, stagesOf, standaloneCommand, standbyCommand, statusViewOf, stealShare, stopScript, streamEnded, streamOf, streamsLoadOf, subjectClient, subjectProblems, subscriptionsOf, substrateHere, substrateKey, substrateOf, substrateOn, targetImageOf, targetSourceOf, templated, toolJsonOf, topicOf, topologyOf, toxicBody, unlockedManifests, unpinnedBases, unpoolable, verdictOf, versionsOf, viewOf, writesOf };
9144
9272
 
9145
9273
  //# sourceMappingURL=index.js.map