@yokla/report 0.4.3 → 0.6.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.
package/dist/terminal.js CHANGED
@@ -1,52 +1,144 @@
1
1
  // The terminal summary of a run (design §16): the status counts, one line per
2
2
  // case that did not plainly pass, advisory findings, and what the target's
3
3
  // logs observed. Errors and run issues go to stderr.
4
- import { CASE_STATUSES } from '@yokla/core';
5
- import { counted, observedTotals } from './format.js';
4
+ import { CASE_STATUSES, failingCategories } from '@yokla/core';
5
+ import { byWeight, categoryCode, counted, MAPPING_NOTE, scoreText, observedTotals, passRateText, tagsByFailures, hasWeights, } from './format.js';
6
6
  import { caseProblems, caseReason, dimensionSummary } from './problems.js';
7
- export function terminalSummary(results) {
8
- const out = [];
9
- const err = [];
7
+ /** The attacker's bounds, as the summary words them (ADR-0087, ADR-0088). */
8
+ function attackerBound(attacker) {
9
+ switch (attacker.strategy) {
10
+ case 'escalation': {
11
+ return `at most ${counted(attacker.limit, 'turn')}`;
12
+ }
13
+ case 'tree': {
14
+ const { branches, depth } = attacker;
15
+ const shape = branches === undefined || depth === undefined
16
+ ? ''
17
+ : `${String(branches)} ${branches === 1 ? 'branch' : 'branches'} to depth ${String(depth)}, `;
18
+ return `${shape}at most ${counted(attacker.limit, 'attempt')}`;
19
+ }
20
+ case 'translate': {
21
+ return `into ${counted(attacker.limit, 'other language')}`;
22
+ }
23
+ case 'best-of-n':
24
+ case 'iterative': {
25
+ return counted(attacker.limit, 'attempt');
26
+ }
27
+ }
28
+ }
29
+ /**
30
+ * What the failing findings map to, per framework, and each attack kind
31
+ * that scored above 0 (ADR-0089); nothing when no finding failed.
32
+ */
33
+ function frameworkLines(results) {
34
+ const failing = new Map(failingCategories(results).map((row) => [row.category, row.cases]));
35
+ if (failing.size === 0)
36
+ return [];
37
+ const lines = [`frameworks, ${MAPPING_NOTE}:`];
38
+ for (const framework of results.taxonomy?.frameworks ?? []) {
39
+ const named = framework.categories.flatMap((category) => {
40
+ const cases = failing.get(category.id);
41
+ return cases === undefined
42
+ ? []
43
+ : [
44
+ `${categoryCode(framework.id, category.id)} ${category.name} (${counted(cases.length, 'case')})`,
45
+ ];
46
+ });
47
+ if (named.length > 0) {
48
+ lines.push(` ${framework.name} ${framework.version}: ${named.join(', ')}`);
49
+ }
50
+ }
51
+ const scored = (results.summary.risk ?? []).filter((risk) => (risk.score ?? 0) > 0);
52
+ if (scored.length > 0)
53
+ lines.push('risk by attack kind, from 0 to 10:');
54
+ for (const risk of scored) {
55
+ lines.push(` ${risk.kind} (${risk.severity}): ${scoreText(risk) ?? ''}; ${String(risk.succeeded)} of ${counted(risk.trials, 'trial')} succeeded`);
56
+ }
57
+ return lines;
58
+ }
59
+ /**
60
+ * The lines that open a run's summary: the status counts and pass rate, then
61
+ * what --stop-early saved and how many cases are proposed.
62
+ */
63
+ export function countLines(results) {
64
+ const lines = [];
10
65
  const counts = CASE_STATUSES.flatMap((status) => {
11
66
  const count = results.summary.statuses[status];
12
67
  return count === undefined ? [] : [`${status} ${String(count)}`];
13
68
  });
14
- out.push(`${String(results.summary.cases)} cases: ${counts.join(', ')}`);
69
+ const passRate = results.summary.passRate;
70
+ lines.push(`${String(results.summary.cases)} cases: ${counts.join(', ')}` +
71
+ (passRate === undefined ? '' : `; ${passRateText(passRate)}`));
15
72
  if (results.run.sampling?.stopEarly === true) {
16
73
  // How many samples --stop-early saved (ADR-0038).
17
74
  const ran = results.cases.reduce((n, c) => n + c.samples.length, 0);
18
75
  const planned = results.cases.reduce((n, c) => n + (c.samplesPlanned ?? c.samples.length), 0);
19
- out.push(` --stop-early: ${counted(ran, 'sample')} ran of ${String(planned)} planned`);
76
+ lines.push(`--stop-early: ${counted(ran, 'sample')} ran of ${String(planned)} planned`);
20
77
  }
21
78
  const proposed = results.cases.filter((c) => c.review === 'proposed').length;
22
79
  if (proposed > 0) {
23
- out.push(` ${String(proposed)} proposed: they ran, and gate once a person sets their status to approved`);
80
+ lines.push(`${String(proposed)} proposed: they ran, and gate once a person sets their status to approved`);
24
81
  }
82
+ return lines;
83
+ }
84
+ /** The cases that didn't plainly pass, and advisory findings, heaviest first with weights (ADR-0076). */
85
+ export function caseRows(results) {
25
86
  const rows = [];
26
- for (const c of results.cases) {
87
+ const weights = hasWeights(results);
88
+ for (const c of byWeight(results, results.cases)) {
27
89
  const problems = caseProblems(c);
28
90
  const reason = caseReason(c, problems);
29
91
  if (reason !== undefined) {
30
92
  const stopped = c.samplesPlanned === undefined
31
93
  ? ''
32
94
  : ` [stopped after ${String(c.samples.length)} of ${String(c.samplesPlanned)} samples]`;
33
- const marks = `${c.unstable ? ' [unstable]' : ''}${stopped}${c.review === 'proposed' ? ' [proposed]' : ''}`;
95
+ const marks = `${c.unstable ? ' [unstable]' : ''}${stopped}${c.review === 'proposed' ? ' [proposed]' : ''}` +
96
+ (weights ? ` [weight ${String(c.weight ?? 1)}]` : '') +
97
+ (c.tags === undefined ? '' : ` [tags: ${c.tags.join(', ')}]`);
34
98
  rows.push([c.status, c.id, `${reason}${marks}`]);
35
99
  }
36
100
  const advisory = dimensionSummary(c, problems.advisory, true);
37
101
  if (advisory !== '')
38
102
  rows.push(['advisory', c.id, advisory]);
103
+ }
104
+ return rows;
105
+ }
106
+ /** Each turn that ended in an error, and each problem of the run itself. */
107
+ export function errorLines(results) {
108
+ const lines = [];
109
+ for (const c of byWeight(results, results.cases)) {
39
110
  for (const sample of c.samples) {
40
111
  for (const turn of sample.turns) {
41
- if (turn.error !== undefined)
42
- err.push(` ${c.id} [sample ${String(sample.index)}]: ${turn.error}`);
112
+ if (turn.error !== undefined) {
113
+ lines.push(`${c.id} [sample ${String(sample.index)}]: ${turn.error}`);
114
+ }
43
115
  }
44
116
  }
45
117
  }
46
- const statusWidth = Math.max(0, ...rows.map(([status]) => status.length));
47
- const idWidth = Math.max(0, ...rows.map(([, id]) => id.length));
48
- for (const [status, id, reason] of rows) {
49
- out.push(` ${status.padEnd(statusWidth)} ${id.padEnd(idWidth)} ${reason}`);
118
+ for (const issue of results.run.issues ?? [])
119
+ lines.push(`run: ${issue}`);
120
+ return lines;
121
+ }
122
+ /**
123
+ * The rest of a run's summary: the cases by tag, what the target's logs, the
124
+ * model proxy and the spans observed, yokla's own models, the run's
125
+ * transforms, strategy, attacker and judge, and the frameworks.
126
+ */
127
+ export function noteLines(results) {
128
+ const out = [];
129
+ // Per tag, the most failing first (ADR-0077).
130
+ const tags = tagsByFailures(results);
131
+ if (tags.length > 0) {
132
+ out.push('by tag:');
133
+ const tagWidth = Math.max(...tags.map((group) => group.tag.length));
134
+ for (const group of tags) {
135
+ const statuses = CASE_STATUSES.flatMap((status) => {
136
+ const count = group.statuses[status];
137
+ return count === undefined ? [] : [`${status} ${String(count)}`];
138
+ });
139
+ out.push(` ${group.tag.padEnd(tagWidth)} ${counted(group.cases, 'case')}: ${statuses.join(', ')}` +
140
+ (group.passRate === undefined ? '' : `; ${passRateText(group.passRate)}`));
141
+ }
50
142
  }
51
143
  const observation = results.run.observation;
52
144
  if (observation !== undefined) {
@@ -79,8 +171,40 @@ export function terminalSummary(results) {
79
171
  .map((transform) => `${transform.kind} (${counted(transform.messages, 'message')})`)
80
172
  .join(', ')}`);
81
173
  }
82
- for (const issue of results.run.issues ?? [])
83
- err.push(` run: ${issue}`);
84
- return { out, err };
174
+ const { strategy } = results.run;
175
+ if (strategy !== undefined) {
176
+ out.push(`strategy: ${strategy.name} (${counted(strategy.messages, 'message')})`);
177
+ }
178
+ // The attacker's strategy, its bounds, and the cases it adapted (ADR-0087, ADR-0088).
179
+ const { attacker } = results.run;
180
+ if (attacker !== undefined) {
181
+ out.push(`attacker: ${attacker.strategy}, ${attackerBound(attacker)}, ${counted(attacker.cases, 'case')}`);
182
+ }
183
+ // The judge: its model, its dimensions, and its calibration (ADR-0090).
184
+ const { judge } = results.run;
185
+ if (judge !== undefined) {
186
+ const dimensions = judge.dimensions
187
+ .map((dimension) => `${dimension} (${judge.gated.includes(dimension) ? 'gating' : 'advisory'})`)
188
+ .join(', ');
189
+ const calibrated = `${String(judge.calibration.items - judge.calibration.misjudged.length)} of ${counted(judge.calibration.items, 'calibration item')} judged right`;
190
+ out.push(`judge: ${judge.model ?? 'none'}, ${dimensions}; ${judge.unmeasured === undefined ? calibrated : `unmeasured: ${judge.unmeasured}`}`);
191
+ }
192
+ out.push(...frameworkLines(results));
193
+ return out;
194
+ }
195
+ export function terminalSummary(results) {
196
+ const [first = '', ...more] = countLines(results);
197
+ const rows = caseRows(results);
198
+ const statusWidth = Math.max(0, ...rows.map(([status]) => status.length));
199
+ const idWidth = Math.max(0, ...rows.map(([, id]) => id.length));
200
+ return {
201
+ out: [
202
+ first,
203
+ ...more.map((line) => ` ${line}`),
204
+ ...rows.map(([status, id, reason]) => ` ${status.padEnd(statusWidth)} ${id.padEnd(idWidth)} ${reason}`),
205
+ ...noteLines(results),
206
+ ],
207
+ err: errorLines(results).map((line) => ` ${line}`),
208
+ };
85
209
  }
86
210
  //# sourceMappingURL=terminal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"terminal.js","sourceRoot":"","sources":["../src/terminal.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,2EAA2E;AAC3E,qDAAqD;AAErD,OAAO,EAAE,aAAa,EAAgB,MAAM,aAAa,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAO3E,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,MAAM,GAAG,GAAa,EAAE,CAAC;IAEzB,MAAM,MAAM,GAAG,aAAa,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE;QAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC/C,OAAO,KAAK,KAAK,SAAS,CA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CAAC;YAClC,GAAG,IAAI,CAAC,GAAG,CACT,CAAC,CAAC,MAAM,EAAE,EAAE,EAAE,MAAM,CAAC,EAAE,EAAE,CACvB,KAAK,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,KAAK,MAAM,EAAE,CACtE;YACD,GAAG,SAAS,CAAC,OAAO,CAAC;SACtB;QACD,GAAG,EAAE,UAAU,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC;KACpD,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yokla/report",
3
- "version": "0.4.3",
3
+ "version": "0.6.0",
4
4
  "description": "Terminal, JUnit XML and HTML reports.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -43,6 +43,6 @@
43
43
  ],
44
44
  "sideEffects": false,
45
45
  "dependencies": {
46
- "@yokla/core": "0.4.3"
46
+ "@yokla/core": "0.6.0"
47
47
  }
48
48
  }
@@ -0,0 +1,220 @@
1
+ // The comparison page (ADR-0095): runs of the same cases side by side, under
2
+ // the HTML report's rules (ADR-0023): no script, nothing loaded, every value
3
+ // escaped. The cases that changed come first and open. Each shows its status,
4
+ // cost and latency per run, the findings each later run gained or lost
5
+ // against the first, and turn by turn the user's message with each run's
6
+ // answer next to the others and the findings that failed under it. It holds
7
+ // the target's answers, as the results files do.
8
+
9
+ import type { Comparison, Results } from '@yokla/core';
10
+ import { changeOf, runLetter, type FindingRow } from './compare.ts';
11
+ import {
12
+ answerBlock,
13
+ badge,
14
+ CONTENT_SECURITY_POLICY,
15
+ h,
16
+ list,
17
+ ms,
18
+ STATUS_TONE,
19
+ STYLE,
20
+ table,
21
+ usd,
22
+ type Html,
23
+ } from './html.ts';
24
+ import type { CaseResult } from './problems.ts';
25
+
26
+ type CaseRow = Comparison['cases'][number];
27
+ type Sample = CaseResult['samples'][number];
28
+
29
+ const SIDE_STYLE = `
30
+ .side { display: grid; grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr)); gap: .75rem; }
31
+ .side > div { min-width: 0; }
32
+ .new { color: var(--bad); }
33
+ .gone { color: var(--good); }
34
+ .kept { color: var(--warn); }
35
+ `;
36
+
37
+ function statusBadge(status: CaseResult['status'] | null): Html {
38
+ return status === null
39
+ ? h`<span class="muted">missing</span>`
40
+ : badge(status, STATUS_TONE[status]);
41
+ }
42
+
43
+ function latency(value: number | null): string {
44
+ return value === null ? '-' : ms(value);
45
+ }
46
+
47
+ /** Whether the runs differ on the case: its status, its findings, or its definition. */
48
+ function moved(c: CaseRow): boolean {
49
+ return c.differs || c.changed || c.findingsDiffer === true;
50
+ }
51
+
52
+ /** What each later run gained and lost against the first, in a few words. */
53
+ function changesText(c: CaseRow, runs: number): string {
54
+ const rows = c.findings ?? [];
55
+ const parts: string[] = [];
56
+ for (let run = 1; run < runs; run += 1) {
57
+ const changes = rows.map((row) => changeOf(row, run));
58
+ const added = changes.filter((change) => change === 'new').length;
59
+ const lost = changes.filter((change) => change === 'gone').length;
60
+ if (added + lost > 0) {
61
+ parts.push(`${runLetter(run)}: ${String(added)} new, ${String(lost)} gone`);
62
+ }
63
+ }
64
+ return parts.join('; ');
65
+ }
66
+
67
+ function runsSection(comparison: Comparison): Html {
68
+ const rows = comparison.runs.map(
69
+ (run, index) =>
70
+ h`<tr><td><strong>${runLetter(index)}</strong></td><td>${run.label}</td><td><code>${run.id}</code></td><td>${badge(
71
+ run.gate.verdict,
72
+ run.gate.verdict === 'pass' ? 'good' : 'bad',
73
+ )}</td><td>${Object.entries(run.statuses)
74
+ .map(([status, count]) => `${status} ${String(count)}`)
75
+ .join(', ')}</td><td class="num">${usd(run.costUsd)}</td><td class="num">${latency(
76
+ run.latencyP50Ms,
77
+ )}</td><td class="num">${latency(run.latencyP95Ms)}</td></tr>`,
78
+ );
79
+ return h`<section id="runs"><h2>Runs</h2>${table(
80
+ ['', 'Run', 'Id', 'Gate', 'Cases', 'Cost', 'Latency p50', 'p95'],
81
+ rows,
82
+ [5, 6, 7],
83
+ )}${comparison.notices.length === 0 ? undefined : list(comparison.notices, 'muted')}</section>`;
84
+ }
85
+
86
+ function casesSection(comparison: Comparison): Html {
87
+ const rows = comparison.cases.map(
88
+ (c) =>
89
+ h`<tr><td><a href="#case-${c.id}"><code>${c.id}</code></a></td><td>${c.statuses.map(
90
+ (status, index) => h`${index === 0 ? '' : ' '}${statusBadge(status)}`,
91
+ )}</td><td>${c.changed ? 'definition differs: not compared' : changesText(c, comparison.runs.length)}</td><td class="num">${(
92
+ c.costUsd ?? []
93
+ )
94
+ .map((cost) => usd(cost))
95
+ .join(' / ')}</td><td class="num">${(c.latencyMs ?? [])
96
+ .map((value) => latency(value))
97
+ .join(' / ')}</td></tr>`,
98
+ );
99
+ return h`<section id="cases"><h2>Cases</h2>${table(
100
+ [
101
+ 'Case',
102
+ comparison.runs.map((_run, index) => runLetter(index)).join(' / '),
103
+ 'Findings',
104
+ 'Cost',
105
+ 'Latency',
106
+ ],
107
+ rows,
108
+ [3, 4],
109
+ )}</section>`;
110
+ }
111
+
112
+ /** A row's cell for one run: how many samples failed it, and how it changed against the first. */
113
+ function rowCell(row: FindingRow, run: number): Html {
114
+ const failed = row.failed[run];
115
+ if (failed === null || failed === undefined) return h`<td class="muted">-</td>`;
116
+ const change = run === 0 ? undefined : changeOf(row, run);
117
+ const message = row.messages[run];
118
+ return h`<td>${failed === 0 ? h`<span class="muted">passed</span>` : `failed in ${String(failed)}`}${
119
+ change === undefined ? undefined : h` <span class="${change}">${change}</span>`
120
+ }${message === null || message === undefined ? undefined : h`<br><span class="muted">${message}</span>`}</td>`;
121
+ }
122
+
123
+ function findingsTable(c: CaseRow, runs: number): Html | undefined {
124
+ const rows = c.findings ?? [];
125
+ if (rows.length === 0) return undefined;
126
+ const letters = Array.from({ length: runs }, (_unused, index) => runLetter(index));
127
+ return table(
128
+ ['Turn', 'Check', 'Dimension', ...letters],
129
+ rows.map(
130
+ (row) =>
131
+ h`<tr><td class="num">${row.turn}</td><td><code>${row.check}</code></td><td>${row.dimension}</td>${letters.map(
132
+ (_letter, run) => rowCell(row, run),
133
+ )}</tr>`,
134
+ ),
135
+ [0],
136
+ );
137
+ }
138
+
139
+ /** The sample a run shows: its first that failed a finding, or else its first. */
140
+ function shownSample(c: CaseResult): Sample | undefined {
141
+ const failing = c.samples.find((sample) =>
142
+ sample.turns.some((turn) =>
143
+ turn.checks.some((check) => check.findings.some((finding) => finding.verdict === 'fail')),
144
+ ),
145
+ );
146
+ return failing ?? c.samples[0];
147
+ }
148
+
149
+ /** The findings that failed on a turn, as lines. */
150
+ function failedLines(turn: Sample['turns'][number]): string[] {
151
+ return turn.checks.flatMap((check) =>
152
+ check.findings
153
+ .filter((finding) => finding.verdict === 'fail')
154
+ .map((finding) => `${check.check} (${finding.dimension}): ${finding.message}`),
155
+ );
156
+ }
157
+
158
+ function turnsBlock(found: readonly (CaseResult | undefined)[]): Html[] {
159
+ const samples = found.map((c) => (c === undefined ? undefined : shownSample(c)));
160
+ const turns = Math.max(0, ...samples.map((sample) => sample?.turns.length ?? 0));
161
+ return Array.from({ length: turns }, (_unused, index) => {
162
+ const users = [...new Set(samples.flatMap((sample) => sample?.turns[index]?.user ?? []))];
163
+ const columns = samples.map((sample, run) => {
164
+ const turn = sample?.turns[index];
165
+ const head = h`<h4>${runLetter(run)}${sample === undefined ? '' : `, sample ${String(sample.index)}`}</h4>`;
166
+ if (turn === undefined)
167
+ return h`<div>${head}<p class="muted">No such turn in this run.</p></div>`;
168
+ const failed = failedLines(turn);
169
+ return h`<div>${head}${
170
+ users.length > 1
171
+ ? h`<div class="label">User</div><pre class="text">${turn.user}</pre>`
172
+ : undefined
173
+ }${answerBlock(turn)}${turn.error === undefined ? undefined : h`<p class="bad">Error: ${turn.error}</p>`}${
174
+ failed.length === 0 ? h`<p class="muted">No finding failed.</p>` : list(failed, 'bad')
175
+ }</div>`;
176
+ });
177
+ return h`<div class="turn"><h3>Turn ${index}</h3>${
178
+ users.length === 1
179
+ ? h`<div class="label">User</div><pre class="text">${users[0]}</pre>`
180
+ : undefined
181
+ }<div class="side">${columns}</div></div>`;
182
+ });
183
+ }
184
+
185
+ function caseBlock(c: CaseRow, runs: readonly Results[]): Html {
186
+ const found = runs.map((results) => results.cases.find((one) => one.id === c.id));
187
+ const changes = c.changed ? '' : changesText(c, runs.length);
188
+ return h`<details class="case" id="case-${c.id}"${moved(c) ? h` open` : undefined}><summary><code>${c.id}</code> ${c.statuses.map(
189
+ (status, index) => h`${runLetter(index)} ${statusBadge(status)} `,
190
+ )}<span class="muted">${c.suite}</span>${changes === '' ? undefined : h` · ${changes}`}</summary><div>${
191
+ c.changed
192
+ ? h`<p class="warn">The case's definition differs between the runs, so its findings aren't compared (ADR-0011).</p>`
193
+ : undefined
194
+ }${findingsTable(c, runs.length)}${turnsBlock(found)}</div></details>`;
195
+ }
196
+
197
+ /** The comparison as one HTML document, from the comparison and its runs' results, in the same order. */
198
+ export function comparisonHtml(comparison: Comparison, runs: readonly Results[]): string {
199
+ const page = h`<!doctype html>
200
+ <html lang="en">
201
+ <head>
202
+ <meta charset="utf-8">
203
+ <meta http-equiv="Content-Security-Policy" content="${{ markup: CONTENT_SECURITY_POLICY }}">
204
+ <meta name="referrer" content="no-referrer">
205
+ <meta name="viewport" content="width=device-width, initial-scale=1">
206
+ <title>yokla comparison of ${comparison.runs.length} runs</title>
207
+ <style>${{ markup: STYLE + SIDE_STYLE }}</style>
208
+ </head>
209
+ <body>
210
+ <h1>yokla comparison</h1>
211
+ <p class="muted">This page holds the target's answers. Keep it as private as the results files. Each later run is read against run A.</p>
212
+ ${runsSection(comparison)}
213
+ ${casesSection(comparison)}
214
+ <section id="details"><h2>Case details</h2>
215
+ ${comparison.cases.map((c) => h`${caseBlock(c, runs)}\n`)}</section>
216
+ </body>
217
+ </html>
218
+ `;
219
+ return page.markup;
220
+ }
package/src/compare.ts CHANGED
@@ -1,8 +1,59 @@
1
1
  // The terminal view of a comparison of runs (ADR-0042): each run with its
2
- // gate verdict, cost and latency, the cases whose status differs, and the
3
- // cheapest run that passes the gate.
2
+ // gate verdict, cost and latency, the cases whose status differs, the
3
+ // findings each later run gained or lost against the first (ADR-0095), and
4
+ // the cheapest run that passes the gate.
4
5
 
5
6
  import type { Comparison } from '@yokla/core';
7
+ import { counted } from './format.ts';
8
+
9
+ export type FindingRow = NonNullable<Comparison['cases'][number]['findings']>[number];
10
+
11
+ /** How a row changed in a later run against the first, the base (ADR-0095). */
12
+ export type FindingChange = 'new' | 'gone' | 'kept';
13
+
14
+ /**
15
+ * A row in run `run` against the base: new when it fails only there, gone
16
+ * when it fails only in the base, kept when in both; undefined when it fails
17
+ * in neither, or the run doesn't have it.
18
+ */
19
+ export function changeOf(row: FindingRow, run: number): FindingChange | undefined {
20
+ const now = row.failed[run];
21
+ if (now === null || now === undefined) return undefined;
22
+ const before = (row.failed[0] ?? 0) > 0;
23
+ if (now > 0) return before ? 'kept' : 'new';
24
+ return before ? 'gone' : undefined;
25
+ }
26
+
27
+ /** The letter a comparison gives a run: A, B, C… */
28
+ export function runLetter(index: number): string {
29
+ return String.fromCodePoint(65 + index);
30
+ }
31
+
32
+ /** Each later run's new and gone findings of the cases whose findings differ. */
33
+ function findingLines(comparison: Comparison): string[] {
34
+ const inside = comparison.cases.filter((c) => c.findingsDiffer === true);
35
+ if (inside.length === 0) return ['every case fails the same findings in every run'];
36
+ const out = [`${counted(inside.length, 'case')} with findings that differ, each run against A:`];
37
+ for (const c of inside) {
38
+ const rows = c.findings ?? [];
39
+ for (let run = 1; run < comparison.runs.length; run += 1) {
40
+ const changes = rows.map((row) => ({ row, change: changeOf(row, run) }));
41
+ const count = (change: FindingChange) => changes.filter((one) => one.change === change);
42
+ const moved = [...count('new'), ...count('gone')];
43
+ if (moved.length === 0) continue;
44
+ out.push(
45
+ ` ${c.id} ${runLetter(run)}: ${String(count('new').length)} new, ${String(count('gone').length)} gone, ${String(count('kept').length)} kept`,
46
+ );
47
+ for (const { row, change } of moved) {
48
+ const message = change === 'new' ? row.messages[run] : row.messages[0];
49
+ out.push(
50
+ ` ${(change ?? '').padEnd(4)} turn ${String(row.turn)} ${row.check} (${row.dimension}): ${message ?? ''}`,
51
+ );
52
+ }
53
+ }
54
+ }
55
+ return out;
56
+ }
6
57
 
7
58
  function usd(value: number | null): string {
8
59
  return value === null ? 'cost unknown' : `${value.toFixed(6)} USD`;
@@ -14,7 +65,7 @@ function ms(value: number | null): string {
14
65
 
15
66
  export function comparisonText(comparison: Comparison): string[] {
16
67
  const out: string[] = [];
17
- const letters = comparison.runs.map((_run, index) => String.fromCodePoint(65 + index));
68
+ const letters = comparison.runs.map((_run, index) => runLetter(index));
18
69
  out.push(`${String(comparison.runs.length)} runs compared:`);
19
70
  comparison.runs.forEach((run, index) => {
20
71
  const statuses = Object.entries(run.statuses)
@@ -41,6 +92,8 @@ export function comparisonText(comparison: Comparison): string[] {
41
92
  }
42
93
  }
43
94
 
95
+ out.push(...findingLines(comparison));
96
+
44
97
  if (comparison.cheapest === null) {
45
98
  out.push(`cheapest passing run: none named: ${comparison.noCheapest ?? ''}`);
46
99
  } else {
package/src/format.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { FindingOrigin } from '@yokla/core';
1
+ import type { FindingOrigin, KindRisk, Results } from '@yokla/core';
2
2
 
3
3
  // Number formatting the reports share. It never depends on the locale, so the
4
4
  // same results give the same report everywhere (ADR-0023).
@@ -71,3 +71,61 @@ export function withOrigin(finding: {
71
71
  ? finding.message
72
72
  : `${finding.message}; ${originText(finding.origin)}`;
73
73
  }
74
+
75
+ type PassRate = NonNullable<Results['summary']['passRate']>;
76
+ type CaseResult = Results['cases'][number];
77
+
78
+ /** A rate or an interval bound, with three decimals. */
79
+ export function rate(value: number): string {
80
+ return value.toFixed(3);
81
+ }
82
+
83
+ /** "pass rate 0.667 (2 of 3, 95 % 0.208 to 0.939), weighted 0.912" (ADR-0076). */
84
+ export function passRateText(passRate: PassRate): string {
85
+ const { interval, weighted } = passRate;
86
+ return (
87
+ `pass rate ${rate(passRate.rate)} (${String(passRate.passed)} of ${String(passRate.measured)}, 95 % ${rate(interval.lower)} to ${rate(interval.upper)})` +
88
+ (weighted === undefined ? '' : `, weighted ${rate(weighted.rate)}`)
89
+ );
90
+ }
91
+
92
+ /** Whether a case of the run has a weight other than 1 (ADR-0076). */
93
+ export function hasWeights(results: Results): boolean {
94
+ return results.cases.some((c) => c.weight !== undefined && c.weight !== 1);
95
+ }
96
+
97
+ /**
98
+ * When the run has weights, the failing cases first, heaviest first, and the
99
+ * others after them as they came (ADR-0076); else the cases as they came. The
100
+ * sort keeps the order of failing cases of the same weight.
101
+ */
102
+ export function byWeight(results: Results, cases: readonly CaseResult[]): CaseResult[] {
103
+ if (!hasWeights(results)) return [...cases];
104
+ const failing = cases.filter((c) => c.status === 'fail');
105
+ return [
106
+ ...failing.toSorted((a, b) => (b.weight ?? 1) - (a.weight ?? 1)),
107
+ ...cases.filter((c) => c.status !== 'fail'),
108
+ ];
109
+ }
110
+
111
+ /** The summary's tag groups, the most failing cases first, then by name (ADR-0077). */
112
+ export function tagsByFailures(results: Results): NonNullable<Results['summary']['tags']> {
113
+ return (results.summary.tags ?? []).toSorted(
114
+ (a, b) => (b.statuses.fail ?? 0) - (a.statuses.fail ?? 0) || a.tag.localeCompare(b.tag),
115
+ );
116
+ }
117
+
118
+ /** What the reports say of the frameworks' mapping (ADR-0089). */
119
+ export const MAPPING_NOTE = 'mapped by yokla, not a compliance assessment';
120
+
121
+ /** A category's code: its id without its framework's (ADR-0089). */
122
+ export function categoryCode(framework: string, category: string): string {
123
+ return category.slice(framework.length + 1);
124
+ }
125
+
126
+ /** "7.5 of 10, 95 % 4.1 to 9" (ADR-0089); undefined for a kind without a score. */
127
+ export function scoreText(risk: KindRisk): string | undefined {
128
+ const { score, scoreInterval } = risk;
129
+ if (score === undefined || scoreInterval === undefined) return undefined;
130
+ return `${String(score)} of 10, 95 % ${String(scoreInterval.lower)} to ${String(scoreInterval.upper)}`;
131
+ }