@yokla/report 0.0.0-stage → 0.3.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/LICENSE +202 -0
- package/README.md +11 -2
- package/dist/format.d.ts +17 -0
- package/dist/format.d.ts.map +1 -0
- package/dist/format.js +60 -0
- package/dist/format.js.map +1 -0
- package/dist/html.d.ts +5 -0
- package/dist/html.d.ts.map +1 -0
- package/dist/html.js +372 -0
- package/dist/html.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/junit.d.ts +5 -0
- package/dist/junit.d.ts.map +1 -0
- package/dist/junit.js +105 -0
- package/dist/junit.js.map +1 -0
- package/dist/problems.d.ts +25 -0
- package/dist/problems.d.ts.map +1 -0
- package/dist/problems.js +80 -0
- package/dist/problems.js.map +1 -0
- package/dist/terminal.d.ts +7 -0
- package/dist/terminal.d.ts.map +1 -0
- package/dist/terminal.js +80 -0
- package/dist/terminal.js.map +1 -0
- package/package.json +45 -3
- package/src/format.ts +73 -0
- package/src/html.ts +508 -0
- package/src/index.ts +7 -0
- package/src/junit.ts +129 -0
- package/src/problems.ts +104 -0
- package/src/terminal.ts +98 -0
package/src/problems.ts
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// What went wrong in a case, read from results.v1 alone (ADR-0007): the
|
|
2
|
+
// failing findings of its failing dimensions, split into deciding and
|
|
3
|
+
// advisory ones, and the errors of its turns and checks.
|
|
4
|
+
|
|
5
|
+
import type { Results } from '@yokla/core';
|
|
6
|
+
import { withOrigin } from './format.ts';
|
|
7
|
+
|
|
8
|
+
export type CaseResult = Results['cases'][number];
|
|
9
|
+
|
|
10
|
+
export interface Problem {
|
|
11
|
+
readonly sample: number;
|
|
12
|
+
readonly turn: number;
|
|
13
|
+
readonly check: string;
|
|
14
|
+
readonly dimension: string;
|
|
15
|
+
readonly message: string;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface CaseProblems {
|
|
19
|
+
/** Failing findings in dimensions that failed and decide the case. */
|
|
20
|
+
readonly deciding: readonly Problem[];
|
|
21
|
+
/** Failing findings in advisory dimensions; reported, never deciding. */
|
|
22
|
+
readonly advisory: readonly Problem[];
|
|
23
|
+
/** Turn errors and check errors. */
|
|
24
|
+
readonly errors: readonly string[];
|
|
25
|
+
/** Thresholds checks couldn't measure, as "dimension: reason", once each (ADR-0014). */
|
|
26
|
+
readonly unmeasured: readonly string[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function caseProblems(c: CaseResult): CaseProblems {
|
|
30
|
+
const failed = c.dimensions.filter((d) => d.verdict === 'fail');
|
|
31
|
+
const deciding = new Set(failed.filter((d) => d.policy !== 'advisory').map((d) => d.dimension));
|
|
32
|
+
const advisory = new Set(failed.filter((d) => d.policy === 'advisory').map((d) => d.dimension));
|
|
33
|
+
const found: {
|
|
34
|
+
deciding: Problem[];
|
|
35
|
+
advisory: Problem[];
|
|
36
|
+
errors: string[];
|
|
37
|
+
unmeasured: string[];
|
|
38
|
+
} = {
|
|
39
|
+
deciding: [],
|
|
40
|
+
advisory: [],
|
|
41
|
+
errors: [],
|
|
42
|
+
unmeasured: [],
|
|
43
|
+
};
|
|
44
|
+
for (const sample of c.samples) {
|
|
45
|
+
for (const [turn, result] of sample.turns.entries()) {
|
|
46
|
+
const where = `sample ${String(sample.index)}, turn ${String(turn)}`;
|
|
47
|
+
if (result.error !== undefined) found.errors.push(`${where}: ${result.error}`);
|
|
48
|
+
for (const check of result.checks) {
|
|
49
|
+
for (const gap of check.unmeasured ?? []) {
|
|
50
|
+
const line = `${gap.dimension}: ${gap.reason}`;
|
|
51
|
+
if (!found.unmeasured.includes(line)) found.unmeasured.push(line);
|
|
52
|
+
}
|
|
53
|
+
for (const finding of check.findings) {
|
|
54
|
+
if (finding.verdict === 'error') found.errors.push(`${where}: ${finding.message}`);
|
|
55
|
+
if (finding.verdict !== 'fail') continue;
|
|
56
|
+
const problem = {
|
|
57
|
+
sample: sample.index,
|
|
58
|
+
turn,
|
|
59
|
+
check: check.check,
|
|
60
|
+
dimension: finding.dimension,
|
|
61
|
+
// Where the value it is about came from, when known (ADR-0033).
|
|
62
|
+
message: withOrigin(finding),
|
|
63
|
+
};
|
|
64
|
+
if (deciding.has(finding.dimension)) found.deciding.push(problem);
|
|
65
|
+
else if (advisory.has(finding.dimension)) found.advisory.push(problem);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
return found;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** "filter-honesty 1/3: <first message>; fabrication 2/3: …" */
|
|
74
|
+
export function dimensionSummary(c: CaseResult, problems: readonly Problem[], advisory: boolean) {
|
|
75
|
+
return c.dimensions
|
|
76
|
+
.filter((d) => d.verdict === 'fail' && (d.policy === 'advisory') === advisory)
|
|
77
|
+
.map((d) => {
|
|
78
|
+
const first = problems.find((p) => p.dimension === d.dimension);
|
|
79
|
+
const counts = `${d.dimension} ${String(d.failed)}/${String(d.samples)}`;
|
|
80
|
+
return first === undefined ? counts : `${counts}: ${first.message}`;
|
|
81
|
+
})
|
|
82
|
+
.join('; ');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** One line on why a case did not pass, or undefined for a plain pass. */
|
|
86
|
+
export function caseReason(c: CaseResult, problems: CaseProblems): string | undefined {
|
|
87
|
+
switch (c.status) {
|
|
88
|
+
case 'pass':
|
|
89
|
+
return undefined;
|
|
90
|
+
case 'fail':
|
|
91
|
+
return dimensionSummary(c, problems.deciding, false);
|
|
92
|
+
case 'error':
|
|
93
|
+
case 'fixture-missing':
|
|
94
|
+
return problems.errors[0] ?? c.status;
|
|
95
|
+
case 'unmeasured':
|
|
96
|
+
return problems.unmeasured.length > 0
|
|
97
|
+
? `unmeasured ${problems.unmeasured.join('; ')}`
|
|
98
|
+
: 'no check applied to any turn';
|
|
99
|
+
case 'known-gap':
|
|
100
|
+
return `known gap: ${c.knownGap?.reason ?? 'no reason given'}${c.knownGap?.issue === undefined ? '' : ` (${c.knownGap.issue})`}`;
|
|
101
|
+
case 'gap-closed':
|
|
102
|
+
return 'passes now; remove the known-gap marker and update the baseline';
|
|
103
|
+
}
|
|
104
|
+
}
|
package/src/terminal.ts
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// The terminal summary of a run (design §16): the status counts, one line per
|
|
2
|
+
// case that did not plainly pass, advisory findings, and what the target's
|
|
3
|
+
// logs observed. Errors and run issues go to stderr.
|
|
4
|
+
|
|
5
|
+
import { CASE_STATUSES, type Results } from '@yokla/core';
|
|
6
|
+
import { counted, observedTotals } from './format.ts';
|
|
7
|
+
import { caseProblems, caseReason, dimensionSummary } from './problems.ts';
|
|
8
|
+
|
|
9
|
+
export interface TerminalSummary {
|
|
10
|
+
readonly out: readonly string[];
|
|
11
|
+
readonly err: readonly string[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function terminalSummary(results: Results): TerminalSummary {
|
|
15
|
+
const out: string[] = [];
|
|
16
|
+
const err: string[] = [];
|
|
17
|
+
|
|
18
|
+
const counts = CASE_STATUSES.flatMap((status) => {
|
|
19
|
+
const count = results.summary.statuses[status];
|
|
20
|
+
return count === undefined ? [] : [`${status} ${String(count)}`];
|
|
21
|
+
});
|
|
22
|
+
out.push(`${String(results.summary.cases)} cases: ${counts.join(', ')}`);
|
|
23
|
+
if (results.run.sampling?.stopEarly === true) {
|
|
24
|
+
// How many samples --stop-early saved (ADR-0038).
|
|
25
|
+
const ran = results.cases.reduce((n, c) => n + c.samples.length, 0);
|
|
26
|
+
const planned = results.cases.reduce((n, c) => n + (c.samplesPlanned ?? c.samples.length), 0);
|
|
27
|
+
out.push(` --stop-early: ${counted(ran, 'sample')} ran of ${String(planned)} planned`);
|
|
28
|
+
}
|
|
29
|
+
const proposed = results.cases.filter((c) => c.review === 'proposed').length;
|
|
30
|
+
if (proposed > 0) {
|
|
31
|
+
out.push(
|
|
32
|
+
` ${String(proposed)} proposed: they ran, and gate once a person sets their status to approved`,
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const rows: [string, string, string][] = [];
|
|
37
|
+
for (const c of results.cases) {
|
|
38
|
+
const problems = caseProblems(c);
|
|
39
|
+
const reason = caseReason(c, problems);
|
|
40
|
+
if (reason !== undefined) {
|
|
41
|
+
const stopped =
|
|
42
|
+
c.samplesPlanned === undefined
|
|
43
|
+
? ''
|
|
44
|
+
: ` [stopped after ${String(c.samples.length)} of ${String(c.samplesPlanned)} samples]`;
|
|
45
|
+
const marks = `${c.unstable ? ' [unstable]' : ''}${stopped}${c.review === 'proposed' ? ' [proposed]' : ''}`;
|
|
46
|
+
rows.push([c.status, c.id, `${reason}${marks}`]);
|
|
47
|
+
}
|
|
48
|
+
const advisory = dimensionSummary(c, problems.advisory, true);
|
|
49
|
+
if (advisory !== '') rows.push(['advisory', c.id, advisory]);
|
|
50
|
+
for (const sample of c.samples) {
|
|
51
|
+
for (const turn of sample.turns) {
|
|
52
|
+
if (turn.error !== undefined)
|
|
53
|
+
err.push(` ${c.id} [sample ${String(sample.index)}]: ${turn.error}`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const statusWidth = Math.max(0, ...rows.map(([status]) => status.length));
|
|
58
|
+
const idWidth = Math.max(0, ...rows.map(([, id]) => id.length));
|
|
59
|
+
for (const [status, id, reason] of rows) {
|
|
60
|
+
out.push(` ${status.padEnd(statusWidth)} ${id.padEnd(idWidth)} ${reason}`);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const observation = results.run.observation;
|
|
64
|
+
if (observation !== undefined) {
|
|
65
|
+
const totals = observedTotals(observation.totals, observation.missing, 'turn');
|
|
66
|
+
const all = observation.matched + observation.unmatched;
|
|
67
|
+
out.push(
|
|
68
|
+
`target logs: ${String(observation.matched)} of ${String(all)} turns matched` +
|
|
69
|
+
(totals === '' ? '' : `; ${totals}`),
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
const proxy = results.run.proxy;
|
|
73
|
+
if (proxy !== undefined) {
|
|
74
|
+
const { calls: _calls, ...sums } = proxy.totals;
|
|
75
|
+
const totals = observedTotals(sums, proxy.missing, 'call');
|
|
76
|
+
out.push(
|
|
77
|
+
`model proxy (${proxy.correlation}): ${counted(proxy.records, 'call')}, ${String(proxy.unattributed)} unattributed` +
|
|
78
|
+
(totals === '' ? '' : `; ${totals}`),
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
const spans = results.run.spans;
|
|
82
|
+
if (spans !== undefined) {
|
|
83
|
+
const { calls: _calls, ...sums } = spans.totals;
|
|
84
|
+
const totals = observedTotals(sums, spans.missing, 'call');
|
|
85
|
+
out.push(
|
|
86
|
+
`spans (traceparent): ${counted(spans.received, 'call')}, ${String(spans.unattributed)} unattributed${spans.settled ? '' : ', still coming when the wait ran out'}` +
|
|
87
|
+
(totals === '' ? '' : `; ${totals}`),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
const own = results.run.own;
|
|
91
|
+
if (own !== undefined) {
|
|
92
|
+
out.push(
|
|
93
|
+
`yokla's own model: ${counted(own.calls, 'call')}, ${String(own.cached)} from the cache; costUsd ${own.costUsd === null ? 'unknown' : String(Math.round(own.costUsd * 1e6) / 1e6)}`,
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
for (const issue of results.run.issues ?? []) err.push(` run: ${issue}`);
|
|
97
|
+
return { out, err };
|
|
98
|
+
}
|