@mark1russell7/harness 0.16.7 → 0.16.9

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
@@ -396,7 +396,7 @@ const STEPS = [
396
396
  22,
397
397
  44
398
398
  ];
399
- const s = (value) => quantity(Math.round(value * 1e6) / 1e6, "s");
399
+ const s$1 = (value) => quantity(Math.round(value * 1e6) / 1e6, "s");
400
400
  const name = (run) => `env ${run.environment} run ${run.index}`;
401
401
  /**
402
402
  * This function gives the value at quantile p of sorted values, by nearest rank: x_(⌈p·n⌉). It is
@@ -409,10 +409,10 @@ const spreadOf = (times) => {
409
409
  const sorted = times.map((time) => valueIn(time, "s")).sort((a, b) => a - b);
410
410
  return {
411
411
  count: sorted.length,
412
- median: s(median(sorted)),
413
- p99: s(quantileOf(sorted, .99)),
414
- p999: s(quantileOf(sorted, .999)),
415
- max: s(sorted.at(-1))
412
+ median: s$1(median(sorted)),
413
+ p99: s$1(quantileOf(sorted, .99)),
414
+ p999: s$1(quantileOf(sorted, .999)),
415
+ max: s$1(sorted.at(-1))
416
416
  };
417
417
  };
418
418
  /** This function adds the reordering records of runs: the counts add, and each largest value is the largest of all. */
@@ -548,8 +548,8 @@ const groupVerdictOf = (prediction, counted, delta = NOISE) => {
548
548
  const stamps = prediction.group?.stamps === void 0 ? 0 : valueIn(prediction.group.stamps, "s");
549
549
  const stages = (prediction.group?.stages ?? []).map((band) => {
550
550
  const interval = {
551
- low: s(valueIn(band.low, "s") - noise),
552
- high: s(valueIn(band.high, "s") + stamps + noise)
551
+ low: s$1(valueIn(band.low, "s") - noise),
552
+ high: s$1(valueIn(band.high, "s") + stamps + noise)
553
553
  };
554
554
  const outside = [];
555
555
  const values = [];
@@ -574,7 +574,7 @@ const groupVerdictOf = (prediction, counted, delta = NOISE) => {
574
574
  return {
575
575
  stage: band.stage,
576
576
  band: interval,
577
- median: values.length === 0 ? null : s(median(values)),
577
+ median: values.length === 0 ? null : s$1(median(values)),
578
578
  outside,
579
579
  decision: outside.length === 0 && values.length > 0 ? "holds" : "fails"
580
580
  };
@@ -586,7 +586,7 @@ const groupVerdictOf = (prediction, counted, delta = NOISE) => {
586
586
  const at = run.group?.stages[stage];
587
587
  return at === void 0 ? [] : [valueIn(at, "s")];
588
588
  });
589
- medians[stage] = s(median(values.sort((a, b) => a - b)));
589
+ medians[stage] = s$1(median(values.sort((a, b) => a - b)));
590
590
  }
591
591
  const lostCounts = counted.flatMap((run) => run.group?.writes.lost === null || run.group === void 0 ? [] : [run.group.writes.lost.length]);
592
592
  const oldCounts = counted.flatMap((run) => run.group === void 0 ? [] : [run.group.writes.old]);
@@ -618,7 +618,7 @@ const groupVerdictOf = (prediction, counted, delta = NOISE) => {
618
618
  errors: [...errors].map(([error, firsts]) => ({
619
619
  name: error,
620
620
  runs: firsts.length,
621
- first: s(median(firsts.sort((a, b) => a - b)))
621
+ first: s$1(median(firsts.sort((a, b) => a - b)))
622
622
  })),
623
623
  ...lags.length === 0 ? {} : { lags: spreadOf(lags) },
624
624
  ...prediction.group?.duplicates === void 0 ? {} : { duplicates: {
@@ -651,7 +651,7 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
651
651
  why: "no run counted"
652
652
  };
653
653
  if (prediction.detects === null) {
654
- const law = prediction.queue !== void 0 ? "queue" : prediction.ports !== void 0 ? "port range" : prediction.pause !== void 0 ? "paused consumer" : prediction.conntrack !== void 0 ? "conntrack table" : prediction.memory !== void 0 ? "memory limit" : void 0;
654
+ const law = prediction.queue !== void 0 ? "queue" : prediction.ports !== void 0 ? "port range" : prediction.pause !== void 0 ? "paused consumer" : prediction.conntrack !== void 0 ? "conntrack table" : prediction.memory !== void 0 ? "memory limit" : prediction.egress !== void 0 ? "egress qdisc" : void 0;
655
655
  if (law !== void 0) {
656
656
  const off = new Set(outside.map((each) => each.run)).size;
657
657
  return {
@@ -689,7 +689,7 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
689
689
  kinds.set(kind, (kinds.get(kind) ?? 0) + 1);
690
690
  }
691
691
  const outcomes = [...kinds].map(([kind, n]) => `${n} ${kind}`).join(", ");
692
- const timed = times.length === 0 ? "no time" : `median ${s(median(times)).value} s from ${prediction.from}, range [${s(times[0]).value}, ${s(times.at(-1)).value}] s`;
692
+ const timed = times.length === 0 ? "no time" : `median ${s$1(median(times)).value} s from ${prediction.from}, range [${s$1(times[0]).value}, ${s$1(times.at(-1)).value}] s`;
693
693
  const { counts } = prediction;
694
694
  if (counts !== void 0) {
695
695
  const exact = counts.map((each) => `${each.what} ${each.count}`).join(", ");
@@ -698,7 +698,7 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
698
698
  decision: outside.length === 0 ? "holds" : "fails",
699
699
  band: null,
700
700
  outside,
701
- median: times.length === 0 ? null : s(median(times)),
701
+ median: times.length === 0 ? null : s$1(median(times)),
702
702
  why: `${counted.length - outside.length} of ${counted.length} runs gave the exact counts (${exact}); ${outcomes}; ${timed}. ${prediction.why}`
703
703
  };
704
704
  }
@@ -712,7 +712,7 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
712
712
  decision: off === 0 ? "holds" : "fails",
713
713
  band: null,
714
714
  outside,
715
- median: times.length === 0 ? null : s(median(times)),
715
+ median: times.length === 0 ? null : s$1(median(times)),
716
716
  why: `${counted.length - off} of ${counted.length} runs inside the band of ${bands.join(" and the band of ")}; ${outcomes}; ${timed}. ${prediction.why}`
717
717
  };
718
718
  }
@@ -723,7 +723,7 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
723
723
  decision: "measured",
724
724
  band: null,
725
725
  outside: missed,
726
- median: times.length === 0 ? null : s(median(times)),
726
+ median: times.length === 0 ? null : s$1(median(times)),
727
727
  why: `${counted.length} runs measured: ${outcomes}; ${timed}.${late} ${prediction.why}`
728
728
  };
729
729
  }
@@ -748,8 +748,8 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
748
748
  decision: prediction.load === void 0 ? "measured" : judged.holds ? "holds" : "fails",
749
749
  band: null,
750
750
  outside: judged.outside,
751
- median: middleOfLoad === void 0 ? null : s(valueIn(middleOfLoad, "s")),
752
- ...judged.load.latency === null ? {} : { slowest: s(valueIn(judged.load.latency.max, "s")) },
751
+ median: middleOfLoad === void 0 ? null : s$1(valueIn(middleOfLoad, "s")),
752
+ ...judged.load.latency === null ? {} : { slowest: s$1(valueIn(judged.load.latency.max, "s")) },
753
753
  load: judged.load,
754
754
  why: read
755
755
  };
@@ -769,14 +769,14 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
769
769
  ].some((count) => (count ?? 0) > 0) ? ` Reordering: ${reorderingWords(reordering)}.` : "";
770
770
  const estimate = estimateVerdict(counted.map((run) => run.estimate));
771
771
  const estimated = estimate === void 0 ? "" : ` ${estimate.words}`;
772
- const why = samples.length === 0 ? `${counted.length} runs measured, with no reply: ${prediction.why}` : `${counted.length} runs, ${samples.length} replies: median ${s(median(samples)).value} s, p99 ${s(quantileOf(samples, .99)).value} s, slowest ${s(samples.at(-1)).value} s, ${retransmissions} retransmissions, ${ended.length} connections ended.${reordered}${estimated} ${prediction.why}`;
772
+ const why = samples.length === 0 ? `${counted.length} runs measured, with no reply: ${prediction.why}` : `${counted.length} runs, ${samples.length} replies: median ${s$1(median(samples)).value} s, p99 ${s$1(quantileOf(samples, .99)).value} s, slowest ${s$1(samples.at(-1)).value} s, ${retransmissions} retransmissions, ${ended.length} connections ended.${reordered}${estimated} ${prediction.why}`;
773
773
  return {
774
774
  ...empty,
775
775
  decision: "measured",
776
776
  band: null,
777
777
  outside: [],
778
- median: samples.length === 0 ? null : s(median(samples)),
779
- ...samples.length === 0 ? {} : { slowest: s(samples.at(-1)) },
778
+ median: samples.length === 0 ? null : s$1(median(samples)),
779
+ ...samples.length === 0 ? {} : { slowest: s$1(samples.at(-1)) },
780
780
  ...reordering === void 0 ? {} : { reordering },
781
781
  ...estimate === void 0 ? {} : { estimate },
782
782
  why
@@ -798,8 +798,8 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
798
798
  const low = valueIn(timed.low, "s");
799
799
  const high = valueIn(timed.high, "s");
800
800
  const band = {
801
- low: s(low - noise),
802
- high: s(high + noise)
801
+ low: s$1(low - noise),
802
+ high: s$1(high + noise)
803
803
  };
804
804
  const values = [];
805
805
  for (const run of counted) {
@@ -820,10 +820,10 @@ const verdictOfBand = (prediction, runs, delta = NOISE) => {
820
820
  why: "no run measured its time"
821
821
  };
822
822
  const [from, to] = medianInterval(values);
823
- const median$1 = s(median(values));
823
+ const median$1 = s$1(median(values));
824
824
  const interval = {
825
- low: s(from),
826
- high: s(to)
825
+ low: s$1(from),
826
+ high: s$1(to)
827
827
  };
828
828
  const wide = {
829
829
  low: low * .95,
@@ -1154,11 +1154,11 @@ const fieldOf = (line, path) => path.split(".").reduce((value, key) => value !==
1154
1154
  /** This function tells if a line of the client matches a line match: its `ev`, and each field that the match names. */
1155
1155
  const matches = (line, match) => line.ev === match.ev && Object.entries(match.where ?? {}).every(([path, value]) => fieldOf(line, path) === value);
1156
1156
  /** This function gives the count of the lines that match. */
1157
- const countOf = (lines, match) => lines.filter((line) => matches(line, match)).length;
1157
+ const countOf$1 = (lines, match) => lines.filter((line) => matches(line, match)).length;
1158
1158
  /** This function gives the finding of the line counts of a run, or null when each count is the exact one. */
1159
1159
  const countFinding = (counts, lines) => {
1160
1160
  const off = counts.flatMap((each) => {
1161
- const seen = countOf(lines, each.match);
1161
+ const seen = countOf$1(lines, each.match);
1162
1162
  return seen === each.count ? [] : [`${each.what}: ${seen} lines, and the law gives ${each.count}`];
1163
1163
  });
1164
1164
  return off.length === 0 ? null : off.join("; ");
@@ -1748,20 +1748,20 @@ const measureQueue = (run, expected) => {
1748
1748
  // src/conntrack.ts
1749
1749
  /** This errno tells that a connect got a slot. */
1750
1750
  const NONE = "none";
1751
- const numberOr$1 = (line, field) => {
1751
+ const numberOr$2 = (line, field) => {
1752
1752
  const value = line?.[field];
1753
1753
  return typeof value === "number" ? value : null;
1754
1754
  };
1755
1755
  /** This function gives the time from one stamp to a stamp of a field of a line, when the line has it. */
1756
1756
  const untilField = (from, line, field) => {
1757
- const stamp = numberOr$1(line, field);
1757
+ const stamp = numberOr$2(line, field);
1758
1758
  return from === void 0 || stamp === null ? null : between$2(from.t, stamp);
1759
1759
  };
1760
1760
  const stallOf = (line) => line === void 0 ? null : {
1761
1761
  errno: String(line["errno"]),
1762
- time: quantity(Math.round((numberOr$1(line, "elapsed") ?? 0) / 1e3) / 1e6, "s"),
1763
- drops: numberOr$1(line, "drops") ?? 0,
1764
- retransFail: numberOr$1(line, "retrans_fail") ?? 0
1762
+ time: quantity(Math.round((numberOr$2(line, "elapsed") ?? 0) / 1e3) / 1e6, "s"),
1763
+ drops: numberOr$2(line, "drops") ?? 0,
1764
+ retransFail: numberOr$2(line, "retrans_fail") ?? 0
1765
1765
  };
1766
1766
  /** This function tells where a reading differs from the law of its cell. */
1767
1767
  const findingsOf$1 = (read, failed, expected) => {
@@ -1842,15 +1842,15 @@ const measureConntrack = (run, expected) => {
1842
1842
  const closed = events.find((event) => event.ev === "closed");
1843
1843
  const neighbor = (run.server ?? []).filter((line) => line.ev === "count" && line.t >= full.t && (stall === void 0 || line.t <= stall.t)).at(-1);
1844
1844
  const conntrack = {
1845
- flows: numberOr$1(full, "flows") ?? 0,
1846
- count: numberOr$1(full, "count") ?? 0,
1847
- neighbor: numberOr$1(neighbor, "count"),
1845
+ flows: numberOr$2(full, "flows") ?? 0,
1846
+ count: numberOr$2(full, "count") ?? 0,
1847
+ neighbor: numberOr$2(neighbor, "count"),
1848
1848
  stall: stallOf(stall),
1849
1849
  firstFall: untilField(closing, drained, "first_fall"),
1850
1850
  zero: untilField(closing, drained, "zero"),
1851
- closed: numberOr$1(closed, "count"),
1852
- lowest: numberOr$1(drained ?? stall, "lowest"),
1853
- after: numberOr$1(stall, "after")
1851
+ closed: numberOr$2(closed, "count"),
1852
+ lowest: numberOr$2(drained ?? stall, "lowest"),
1853
+ after: numberOr$2(stall, "after")
1854
1854
  };
1855
1855
  const found = findingsOf$1(conntrack, full["errno"], expected);
1856
1856
  return {
@@ -1861,7 +1861,7 @@ const measureConntrack = (run, expected) => {
1861
1861
  };
1862
1862
  };
1863
1863
  // src/memory.ts
1864
- const numberOr = (line, field) => {
1864
+ const numberOr$1 = (line, field) => {
1865
1865
  const value = line?.[field];
1866
1866
  return typeof value === "number" ? value : null;
1867
1867
  };
@@ -1917,7 +1917,7 @@ const stepBand = (expected, usage) => {
1917
1917
  }
1918
1918
  };
1919
1919
  };
1920
- const seconds = (time) => valueIn(time, "s");
1920
+ const seconds$1 = (time) => valueIn(time, "s");
1921
1921
  /** This function reads each step of a growth: its usage, its time, and the rise of its events `high`. */
1922
1922
  const stepsOf = (events, start, startHigh, batch, drift) => {
1923
1923
  let usage = start;
@@ -1925,12 +1925,12 @@ const stepsOf = (events, start, startHigh, batch, drift) => {
1925
1925
  const out = [];
1926
1926
  for (const line of events) {
1927
1927
  if (line.ev !== "step") continue;
1928
- const now = numberOr(line, "current") ?? usage;
1929
- const events = numberOr(line, "high") ?? high;
1928
+ const now = numberOr$1(line, "current") ?? usage;
1929
+ const events = numberOr$1(line, "high") ?? high;
1930
1930
  const rise = now - usage;
1931
1931
  out.push({
1932
1932
  usage: now,
1933
- time: quantity(Math.round((numberOr(line, "ns") ?? 0) / 1e3) / 1e6, "s"),
1933
+ time: quantity(Math.round((numberOr$1(line, "ns") ?? 0) / 1e3) / 1e6, "s"),
1934
1934
  high: events - high,
1935
1935
  read: Math.abs(rise - batch) <= drift
1936
1936
  });
@@ -1940,7 +1940,7 @@ const stepsOf = (events, start, startHigh, batch, drift) => {
1940
1940
  return out;
1941
1941
  };
1942
1942
  /** These are the first findings of a run that the words of its finding name, one for each step. */
1943
- const NAMED = 5;
1943
+ const NAMED$1 = 5;
1944
1944
  const throttleFindings = (read, expected) => {
1945
1945
  const found = [];
1946
1946
  const off = [];
@@ -1948,12 +1948,12 @@ const throttleFindings = (read, expected) => {
1948
1948
  for (const step of read.steps) {
1949
1949
  if (!step.read) continue;
1950
1950
  const { band, high } = stepBand(expected, step.usage);
1951
- if (!inside(step.time, band)) off.push(`the step to ${step.usage} pages took ${seconds(step.time)} s, outside ${bandWords(band)}`);
1951
+ if (!inside(step.time, band)) off.push(`the step to ${step.usage} pages took ${seconds$1(step.time)} s, outside ${bandWords(band)}`);
1952
1952
  if (step.high < high.low || step.high > high.high) off.push(`the step to ${step.usage} pages added ${step.high} events high, not ${high.low === high.high ? high.low : `${high.low} to ${high.high}`}`);
1953
- least += seconds(band.low);
1953
+ least += seconds$1(band.low);
1954
1954
  }
1955
- if (off.length > 0) found.push(`${off.length} terms of the steps are outside the law: ${off.slice(0, NAMED).join("; ")}`);
1956
- if (read.stall !== null && seconds(read.stall) < least) found.push(`memory.pressure counts a stall of ${seconds(read.stall)} s, less than the ${Math.round(least * 1e6) / 1e6} s of the sleeps`);
1955
+ if (off.length > 0) found.push(`${off.length} terms of the steps are outside the law: ${off.slice(0, NAMED$1).join("; ")}`);
1956
+ if (read.stall !== null && seconds$1(read.stall) < least) found.push(`memory.pressure counts a stall of ${seconds$1(read.stall)} s, less than the ${Math.round(least * 1e6) / 1e6} s of the sleeps`);
1957
1957
  return found;
1958
1958
  };
1959
1959
  const oomFindings = (read, expected) => {
@@ -2005,11 +2005,11 @@ const measureMemory = (run, expected) => {
2005
2005
  }
2006
2006
  const differs = limitsDiffer(ready, expected.limits);
2007
2007
  if (differs !== null) return voided(differs);
2008
- const start = numberOr(ready, "current") ?? 0;
2008
+ const start = numberOr$1(ready, "current") ?? 0;
2009
2009
  const atReady = countsOf(ready["events"]);
2010
2010
  const last = events.filter((event) => event.ev === "events").at(-1);
2011
2011
  const pressure = events.find((event) => event.ev === "pressure");
2012
- const some = numberOr(pressure, "some");
2012
+ const some = numberOr$1(pressure, "some");
2013
2013
  const throttle = expected.kind === "throttle";
2014
2014
  const memory = {
2015
2015
  limits: {
@@ -2022,7 +2022,7 @@ const measureMemory = (run, expected) => {
2022
2022
  tasks: events.filter((event) => event.ev === "task").map((event) => ({
2023
2023
  name: String(event["name"]),
2024
2024
  outcome: String(event["outcome"]),
2025
- signal: numberOr(event, "signal")
2025
+ signal: numberOr$1(event, "signal")
2026
2026
  })),
2027
2027
  events: Object.fromEntries(Object.entries(countsOf(last)).filter(([name]) => name !== "t")),
2028
2028
  stall: some === null ? null : quantity(some / 1e6, "s")
@@ -2049,6 +2049,140 @@ const measureMemory = (run, expected) => {
2049
2049
  memory
2050
2050
  };
2051
2051
  };
2052
+ // src/egress.ts
2053
+ /**
2054
+ * This time is the largest step of CLOCK_REALTIME in a run that the judge accepts. The kernel stamps
2055
+ * each datagram on CLOCK_REALTIME, and the client moves the stamps to CLOCK_MONOTONIC with one
2056
+ * offset. A step of the clock moves each later stamp by the step. A step of 100 µs is less than one
2057
+ * tenth of the smallest band of the catalog.
2058
+ */
2059
+ const MOST_STEP_NS = 1e5;
2060
+ /** These are the first findings of a run that the words of its finding name. */
2061
+ const NAMED = 5;
2062
+ const numberOr = (line, field) => {
2063
+ const value = line?.[field];
2064
+ return typeof value === "number" ? value : null;
2065
+ };
2066
+ /** This function gives one field of an object of a line, or undefined. */
2067
+ const fieldOf$1 = (value, field) => typeof value === "object" && value !== null ? value[field] : void 0;
2068
+ const countOf = (value, field) => {
2069
+ const count = fieldOf$1(value, field);
2070
+ return typeof count === "number" ? count : null;
2071
+ };
2072
+ const seconds = (ns) => quantity(Math.round(ns) / 1e9, "s");
2073
+ const s = (time) => valueIn(time, "s");
2074
+ /** This function gives the words of the law of one datagram. */
2075
+ const lawWords = (law) => law.kind === "sent" ? `leaves in ${bandWords(law.left)}` : `is dropped at the ${law.why}`;
2076
+ /** This function gives the findings of the datagrams that differ from their laws. */
2077
+ const packetFindings = (read, expected) => {
2078
+ const off = [];
2079
+ for (const packet of read.packets) {
2080
+ const law = expected.packets[packet.key];
2081
+ if (law === void 0 || packet.outcome === "unread") continue;
2082
+ if (law.kind === "dropped" && packet.outcome === "sent") off.push(`the datagram ${packet.key} left at ${s(packet.left)} s, and the law drops it at the ${law.why}`);
2083
+ else if (law.kind === "sent" && packet.outcome === "dropped") off.push(`the qdisc dropped the datagram ${packet.key}, and the law ${lawWords(law)}`);
2084
+ else if (law.kind === "sent" && packet.left !== null && !inside(packet.left, law.left)) off.push(`the datagram ${packet.key} left at ${s(packet.left)} s, outside ${bandWords(law.left)}`);
2085
+ }
2086
+ return off.length === 0 ? [] : [`${off.length} of the ${read.packets.length} datagrams are outside the law: ${off.slice(0, NAMED).join("; ")}`];
2087
+ };
2088
+ /**
2089
+ * This function reads one run of an egress cell from the lines of the egress client. A run is void
2090
+ * when the client wrote an error or no `done` line, or when the qdisc is of another kind. A neighbour
2091
+ * of the target that is not permanent voids a run too. It is void too when the client sent another count of
2092
+ * datagrams than the law. A send that failed with an error other than ENOBUFS voids its run, and a
2093
+ * datagram with no stamp of its arrival voids it too. The arrivals void a run when one burst spreads more than `spread`, or
2094
+ * when a later burst starts more than `jitter` off its time. The counts of the qdisc void a run when
2095
+ * other traffic went through it. A step of the clock and a read of less than `read` of the
2096
+ * departures void a run too.
2097
+ */
2098
+ const measureEgress = (run, expected) => {
2099
+ const { events, kernel } = run;
2100
+ const base = {
2101
+ environment: run.environment,
2102
+ index: run.index,
2103
+ outcome: { kind: "answered" },
2104
+ elapsed: null,
2105
+ socket: null,
2106
+ noticed: null,
2107
+ steps: [],
2108
+ probes: 0,
2109
+ retransmissions: kernel.filter((record) => record.netns === run.netns && record.ev === "retrans").length,
2110
+ acks: 0
2111
+ };
2112
+ const voided = (why) => ({
2113
+ ...base,
2114
+ void: why,
2115
+ finding: null
2116
+ });
2117
+ const error = events.find((event) => event.ev === "error");
2118
+ if (error !== void 0) return voided(`the client stopped: ${String(error["what"])}`);
2119
+ const ready = events.find((event) => event.ev === "ready");
2120
+ if (ready === void 0) return voided("the client wrote no ready line");
2121
+ if (events.find((event) => event.ev === "done") === void 0) return voided("the client did not reach its end");
2122
+ const kind = String(fieldOf$1(ready["qdisc"], "kind") ?? "none");
2123
+ if (kind !== expected.kind) return voided(`tc reads a root qdisc of the kind ${kind}, not ${expected.kind}`);
2124
+ const states = fieldOf$1(ready["neighbour"], "state");
2125
+ if (!Array.isArray(states) || !states.includes("PERMANENT")) return voided(`the neighbour of the target is ${JSON.stringify(states ?? null)}, not PERMANENT: an ARP packet can go through the qdisc`);
2126
+ const lines = events.filter((event) => event.ev === "packet");
2127
+ if (lines.length !== expected.packets.length) return voided(`the client sent ${lines.length} datagrams, and the law has ${expected.packets.length}`);
2128
+ const failed = lines.find((line) => line["errno"] !== null && line["errno"] !== "ENOBUFS");
2129
+ if (failed !== void 0) return voided(`the send of the datagram ${String(failed["key"])} failed with ${String(failed["errno"])}`);
2130
+ const unstamped = lines.find((line) => numberOr(line, "sched") === null);
2131
+ if (unstamped !== void 0) return voided(`the datagram ${String(unstamped["key"])} has no stamp of its arrival in the qdisc`);
2132
+ const firsts = expected.bursts.map((_, burst) => Math.min(...lines.filter((line) => line["burst"] === burst).map((line) => numberOr(line, "sched"))));
2133
+ const lasts = expected.bursts.map((_, burst) => Math.max(...lines.filter((line) => line["burst"] === burst).map((line) => numberOr(line, "sched"))));
2134
+ const origin = firsts[0];
2135
+ const packets = lines.map((line) => {
2136
+ const burst = numberOr(line, "burst") ?? 0;
2137
+ const first = firsts[burst] ?? origin;
2138
+ const left = numberOr(line, "left");
2139
+ const outcome = line["errno"] === "ENOBUFS" ? "dropped" : left === null ? "unread" : "sent";
2140
+ return {
2141
+ key: numberOr(line, "key") ?? -1,
2142
+ burst,
2143
+ outcome,
2144
+ arrived: seconds(numberOr(line, "sched") - first),
2145
+ left: outcome === "sent" ? seconds(left - first) : null
2146
+ };
2147
+ });
2148
+ const stats = events.find((event) => event.ev === "stats");
2149
+ const rise = (field) => (countOf(stats?.["after"], field) ?? 0) - (countOf(stats?.["before"], field) ?? 0);
2150
+ const egress = {
2151
+ kind,
2152
+ packets,
2153
+ spreads: firsts.map((first, burst) => seconds(lasts[burst] - first)),
2154
+ starts: firsts.map((first) => seconds(first - origin)),
2155
+ counts: {
2156
+ packets: rise("packets"),
2157
+ drops: rise("drops")
2158
+ },
2159
+ step: seconds(numberOr(events.find((event) => event.ev === "clock"), "step") ?? 0)
2160
+ };
2161
+ const voidedWith = (why) => ({
2162
+ ...voided(why),
2163
+ egress
2164
+ });
2165
+ if (stats === void 0) return voidedWith("the client wrote no counts of the qdisc");
2166
+ const stepNs = Math.abs(s(egress.step) * 1e9);
2167
+ if (stepNs > MOST_STEP_NS) return voidedWith(`CLOCK_REALTIME stepped ${Math.round(stepNs / 1e3)} µs in the run, more than ${MOST_STEP_NS / 1e3} µs`);
2168
+ const wide = egress.spreads.findIndex((spread) => s(spread) > s(expected.spread));
2169
+ if (wide >= 0) return voidedWith(`the arrivals of the burst ${wide} spread ${s(egress.spreads[wide])} s, more than ${s(expected.spread)} s`);
2170
+ const at0 = s(expected.bursts[0].at);
2171
+ const late = expected.bursts.findIndex((burst, index) => Math.abs(s(egress.starts[index]) - (s(burst.at) - at0)) > s(expected.jitter));
2172
+ if (late >= 0) return voidedWith(`the burst ${late} started ${s(egress.starts[late])} s after the first, more than ${s(expected.jitter)} s off ${s(expected.bursts[late].at) - at0} s`);
2173
+ const dropped = packets.filter((packet) => packet.outcome === "dropped").length;
2174
+ const taken = packets.length - dropped;
2175
+ if (egress.counts.packets !== taken || egress.counts.drops !== dropped) return voidedWith(`the qdisc counts ${egress.counts.packets} packets and ${egress.counts.drops} drops, and the client counts ${taken} sends and ${dropped} drops: other traffic went through the qdisc`);
2176
+ const sent = packets.filter((packet) => packet.outcome === "sent").length;
2177
+ if (taken > 0 && sent < expected.read * taken) return voidedWith(`the judge read the departure of ${sent} of the ${taken} datagrams that the qdisc took, less than ${expected.read * 100}%`);
2178
+ const found = packetFindings(egress, expected);
2179
+ return {
2180
+ ...base,
2181
+ void: null,
2182
+ finding: found.length === 0 ? null : found.join(". "),
2183
+ egress
2184
+ };
2185
+ };
2052
2186
  // src/pause.ts
2053
2187
  /** This expression finds the stamp of a log line of a broker, as its console writes it, on UTC. */
2054
2188
  const LOG_TIME = /\[(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d),(\d{3})\]/;
@@ -2214,6 +2348,42 @@ const measurePause = (run, prediction) => {
2214
2348
  // src/ports.ts
2215
2349
  /** This errno ends a search that found no port. */
2216
2350
  const NO_PORT = "EADDRNOTAVAIL";
2351
+ /** This pattern names the counters of a drop, a skip, a reset or a retransmission. A finding of a lost segment names them. */
2352
+ const LOSS = /Drop|drop|Skipped|Overflow|Errs|errs|Discards|Challenge|PAWS|Rsts|Retrans/;
2353
+ const countersOf = (line) => {
2354
+ const counters = line?.["counters"];
2355
+ if (counters === null || typeof counters !== "object" || Array.isArray(counters)) return void 0;
2356
+ return Object.fromEntries(Object.entries(counters).filter((entry) => typeof entry[1] === "number"));
2357
+ };
2358
+ /** This function gives the counters of one end that moved from its `stack` line at the start to its line at the end. */
2359
+ const changeOf = (events, side) => {
2360
+ const at = (point) => countersOf(events.find((event) => event.ev === "stack" && event["side"] === side && event["at"] === point));
2361
+ const start = at("start");
2362
+ const end = at("end");
2363
+ if (start === void 0 || end === void 0) return null;
2364
+ return Object.fromEntries(Object.entries(end).flatMap(([name, value]) => {
2365
+ const change = value - (start[name] ?? 0);
2366
+ return change === 0 ? [] : [[name, change]];
2367
+ }));
2368
+ };
2369
+ /** This function gives the stack change of a run, or null when an end has no pair of `stack` lines. */
2370
+ const stackOf = (events) => {
2371
+ const client = changeOf(events, "client");
2372
+ const target = changeOf(events, "target");
2373
+ return client === null || target === null ? null : {
2374
+ client,
2375
+ target
2376
+ };
2377
+ };
2378
+ /** This function gives the words of the counters of a loss that moved at each end. */
2379
+ const lossWords = (stack) => {
2380
+ if (stack === null) return "the run has no stack lines";
2381
+ const words = ["client", "target"].flatMap((side) => {
2382
+ const moved = Object.entries(stack[side]).filter(([name]) => LOSS.test(name));
2383
+ return moved.length === 0 ? [] : [`the ${side}: ${moved.map(([name, change]) => `${name} ${change > 0 ? "+" : ""}${change}`).join(", ")}`];
2384
+ });
2385
+ return words.length === 0 ? "no counter of a loss moved at either end" : words.join("; ");
2386
+ };
2217
2387
  const portsOf = (line) => Array.isArray(line["ports"]) ? line["ports"].filter((port) => typeof port === "number") : [];
2218
2388
  /** This function says if the ports of the parity of the low port come first in one search. */
2219
2389
  const lowFirst = (ports, low) => {
@@ -2269,7 +2439,8 @@ const measurePorts = (run, expected) => {
2269
2439
  firstFreed: closing === void 0 || first === void 0 ? null : between$2(closing.t, first.t),
2270
2440
  lastFreed: closing === void 0 || last === void 0 ? null : between$2(closing.t, last.t),
2271
2441
  freed: freedLines.length,
2272
- tries: last === void 0 || typeof last["tries"] !== "number" ? 0 : last["tries"]
2442
+ tries: last === void 0 || typeof last["tries"] !== "number" ? 0 : last["tries"],
2443
+ stack: stackOf(events)
2273
2444
  };
2274
2445
  const found = [];
2275
2446
  const searches = expected.rounds * expected.destinations;
@@ -2285,7 +2456,7 @@ const measurePorts = (run, expected) => {
2285
2456
  if (share < low || share > high) found.push(`the share of ${count} connects is ${share}, outside [${low}, ${high}]`);
2286
2457
  }
2287
2458
  if (expected.lowFirst === true && !rounds.every((round) => lowFirst(portsOf(round), expected.low))) found.push("a search got a port of the other parity before each port of the parity of the low port");
2288
- if (expected.retransmissions !== void 0 && retransmissions !== expected.retransmissions) found.push(`${retransmissions} retransmissions, not ${expected.retransmissions}`);
2459
+ if (expected.retransmissions !== void 0 && retransmissions !== expected.retransmissions) found.push(`${retransmissions} retransmissions, not ${expected.retransmissions} (${lossWords(ports.stack)})`);
2289
2460
  if (expected.freed !== void 0) {
2290
2461
  const held = Math.max(...expected.counts);
2291
2462
  if (ports.freed !== held) found.push(`${ports.freed} ports came back, not ${held}`);
@@ -3276,6 +3447,7 @@ const measureSocket = (cell, run) => {
3276
3447
  if (cell.prediction.detects === null && cell.prediction.ports !== void 0) return measurePorts(run, cell.prediction.ports);
3277
3448
  if (cell.prediction.detects === null && cell.prediction.conntrack !== void 0) return measureConntrack(run, cell.prediction.conntrack);
3278
3449
  if (cell.prediction.detects === null && cell.prediction.memory !== void 0) return measureMemory(run, cell.prediction.memory);
3450
+ if (cell.prediction.detects === null && cell.prediction.egress !== void 0) return measureEgress(run, cell.prediction.egress);
3279
3451
  if (cell.prediction.detects !== null && cell.prediction.driver !== void 0) return measureDriver(cell, run);
3280
3452
  const { events, kernel } = run;
3281
3453
  const ready = events.find((event) => event.ev === "ready");
@@ -9141,7 +9313,7 @@ const LINES_MS = 5e3;
9141
9313
  */
9142
9314
  const linesCounted = async (lab, from, counts) => {
9143
9315
  const started = Date.now();
9144
- const short = () => counts.some((each) => countOf(lab.server.slice(from), each.match) < each.count);
9316
+ const short = () => counts.some((each) => countOf$1(lab.server.slice(from), each.match) < each.count);
9145
9317
  while (short() && Date.now() - started < LINES_MS) await setTimeout$1(20);
9146
9318
  await setTimeout$1(250);
9147
9319
  };
@@ -9740,6 +9912,6 @@ const runCell = async (cell, say = () => {}) => {
9740
9912
  target = larger;
9741
9913
  }
9742
9914
  };
9743
- export { AWS_FROM, CLIENT_CAPABILITIES, CLIENT_NAMES, CLOSED_TOLERANCE, CLOUDS, CLUSTER_STAGES, CONVERGE_MS, DAEMONS, DEBUG, DIRTY, DISK_MOUNT, DISK_RECORD_FORMAT, DISK_ROOT, DISK_SUBJECT, 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, diskRecordProblems, diskSubjectProblems, drillOnce, drillSpan, dropFinding, dropOf, endpointAfter, envOf, environmentCounts, environmentProblems, errorsOf, estimateOf, estimateVerdict, exitOf, fieldOf, fieldsOf, firstUnanswered, folderDigest, frrConf, goHttpImage, goVersions, groupOnce, groupVerdictOf, grpcClientImage, harnessImage, harnessRecord, harnessVersion, hashOf, highestHeld, hikariClientImage, hzOf, imageOf, imagePinProblems, 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, measureMemory, measurePause, measurePorts, measureQueue, medianInterval, memAvailableOf, memberCommand, memberConfig, memberLineOf, mongoClientImage, monotonicAt, monotonicOf, namesGroup, nodeClientImage, nodeCommand, nodeHttpImage, nodeIdOf, nodeLineOf, nodeNameOf, nodesOnMonotonic, noiseOf, npmVersions, numbersOf, onMonotonic, openClusterLab, openDiskLab, 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, runDiskFault, seedScript, sentinelConfig, sessionsOf, shippedClientRecord, shippedSource, sliceQuery, socketAt, socketOf, socketsOf, spread, spreadOf, stagesOf, standaloneCommand, standbyCommand, statusViewOf, stealShare, stepBand, 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 };
9915
+ export { AWS_FROM, CLIENT_CAPABILITIES, CLIENT_NAMES, CLOSED_TOLERANCE, CLOUDS, CLUSTER_STAGES, CONVERGE_MS, DAEMONS, DEBUG, DIRTY, DISK_MOUNT, DISK_RECORD_FORMAT, DISK_ROOT, DISK_SUBJECT, 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, diskRecordProblems, diskSubjectProblems, drillOnce, drillSpan, dropFinding, dropOf, endpointAfter, envOf, environmentCounts, environmentProblems, errorsOf, estimateOf, estimateVerdict, exitOf, fieldOf, fieldsOf, firstUnanswered, folderDigest, frrConf, goHttpImage, goVersions, groupOnce, groupVerdictOf, grpcClientImage, harnessImage, harnessRecord, harnessVersion, hashOf, highestHeld, hikariClientImage, hzOf, imageOf, imagePinProblems, 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, measureEgress, measureGroup, measureMemory, measurePause, measurePorts, measureQueue, medianInterval, memAvailableOf, memberCommand, memberConfig, memberLineOf, mongoClientImage, monotonicAt, monotonicOf, namesGroup, nodeClientImage, nodeCommand, nodeHttpImage, nodeIdOf, nodeLineOf, nodeNameOf, nodesOnMonotonic, noiseOf, npmVersions, numbersOf, onMonotonic, openClusterLab, openDiskLab, 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, runDiskFault, seedScript, sentinelConfig, sessionsOf, shippedClientRecord, shippedSource, sliceQuery, socketAt, socketOf, socketsOf, spread, spreadOf, stagesOf, standaloneCommand, standbyCommand, statusViewOf, stealShare, stepBand, 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 };
9744
9916
 
9745
9917
  //# sourceMappingURL=index.js.map