@ihyeon/error-to-test 0.2.2 → 0.2.3
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/README.ko.md +19 -0
- package/README.md +27 -0
- package/dist/artifacts.d.ts +1 -0
- package/dist/artifacts.js +3 -1
- package/dist/cli.js +22 -2
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/readiness.d.ts +27 -0
- package/dist/readiness.js +134 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -183,6 +183,25 @@ flow-qa init
|
|
|
183
183
|
flow-qa ui
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
+
실행 전에는 `readiness`로 **선택된 TC의 기록된 차단 사유**를 모아 확인할 수 있습니다.
|
|
187
|
+
|
|
188
|
+
```sh
|
|
189
|
+
error-to-test readiness ./review-analysis
|
|
190
|
+
error-to-test readiness ./review-analysis --format json
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
번들을 검증한 뒤 초안·추가 정보 필요·실행 차단 건수, 검토 확인 여부와 TC별 미해결 질문을 표시합니다. 실제 내보낸 Flow QA suite의 질문도 반영하므로 검토 대기나 민감한 실행 단계 때문에 차단된 경우도 남습니다.
|
|
194
|
+
|
|
195
|
+
| 종료 코드 | 의미 |
|
|
196
|
+
| --- | --- |
|
|
197
|
+
| `0` | 선택된 TC가 하나 이상이고, 모두 검토된 초안이며 기록된 차단 사유가 없음 |
|
|
198
|
+
| `1` | 잘못된 옵션·잘못되거나 변경된 번들·출력 오류 |
|
|
199
|
+
| `2` | 차단된 TC가 있거나 선택된 TC가 없음 |
|
|
200
|
+
|
|
201
|
+
전체 보고서를 stdout에 출력한 뒤 0 또는 2를 반환합니다. JSON은 `error-to-test/readiness-1`이며 `status`(`ready`·`blocked`·`empty`), 검토 상태·건수·TC별 `blockers`·입력/분석/suite 해시를 제공합니다. API는 `await readReadiness(directory)`와 `renderReadiness(summary)`이며 API 호출은 종료 코드를 변경하지 않습니다.
|
|
202
|
+
|
|
203
|
+
저장된 번들의 질문과 검토 상태를 점검하는 기능입니다. 브라우저 실행·계정·준비 데이터·수집 범위를 확인하거나 연결 실행 결과를 읽지는 않습니다. `--top`·`--min-count`·이전 분석 기준으로 제외된 묶음은 선택 TC 건수에 포함되지 않습니다. 검토 확인만으로 미해결 맥락이 사라지지 않으며, 빈 선택도 통과시키지 않습니다. 원본 입력·프로필 바이트 확인은 `verify --input ... --profile ...`로 별도 수행하세요. 번들 경로와 선택적인 `--format text|json`만 받으며 파일을 저장하거나 기존 TC를 승인하지 않습니다.
|
|
204
|
+
|
|
186
205
|
Flow QA 설치와 실행 대상 설정은 별도로 필요합니다. 위 `flows/`·`cases/` 구조를 기존 검토 화면에서 읽을 수 있습니다. 분석 명령은 브라우저를 실행하거나 외부 모델에 요청하지 않습니다. TC 통과만으로 원래 오류를 수정 완료 처리하지 않습니다.
|
|
187
206
|
|
|
188
207
|
실행 후 `node bin/error-to-test.mjs link-run .error-to-test/reviewed --report /path/to/qa-report.json`으로 결과를 원래 오류 묶음에 연결할 수 있습니다. suite 해시와 모든 case ID가 일치해야 하며, 결과는 `results/<runId>.json`에 저장합니다. 원본 e2e 리포트 대신 Flow QA가 정리한 `report-1`을 사용하세요.
|
package/README.md
CHANGED
|
@@ -238,6 +238,33 @@ flow-qa ui
|
|
|
238
238
|
|
|
239
239
|
Flow QA is installed/configured separately. Its UI can read this `flows/` + `cases/` layout. Select the intended test target, review the cases in Flow QA, and execute there or with its CLI. Source changes invalidate existing bundles/suites; regenerate after review. `verify` checks artifact consistency, and checks original input/profile bytes only when supplied. It is not a signature or proof that a testcase fixes the reported cause. A passing functional assertion does not automatically close an error issue.
|
|
240
240
|
|
|
241
|
+
### Check recorded execution blockers
|
|
242
|
+
|
|
243
|
+
`readiness` verifies an existing bundle and summarizes the selected TCs before execution. It shows draft/needs-context counts, review acknowledgement, and each case's outstanding questions, including blockers recorded in the exported Flow QA suite.
|
|
244
|
+
|
|
245
|
+
```sh
|
|
246
|
+
error-to-test readiness ./analysis
|
|
247
|
+
error-to-test readiness ./analysis --format json
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
| Exit code | Meaning |
|
|
251
|
+
| --- | --- |
|
|
252
|
+
| `0` | At least one selected case; every case is a reviewed draft with no recorded blockers |
|
|
253
|
+
| `1` | Invalid options, invalid or changed bundle, or output error |
|
|
254
|
+
| `2` | Some selected cases are blocked, or no cases were selected |
|
|
255
|
+
|
|
256
|
+
The full Markdown/JSON report is written to stdout before returning `0` or `2`. JSON uses `error-to-test/readiness-1`, with `status` (`ready`, `blocked`, or `empty`), `reviewed`, candidate counts, per-case `blockers`, and input/analysis/suite hashes. An empty selection is never a successful readiness check. `--reviewed` is an analyze option; it cannot approve an existing bundle through `readiness`.
|
|
257
|
+
|
|
258
|
+
This checks recorded blockers in the verified snapshot. It does not execute a browser, test credentials or setup, read linked run results, or establish source collection completeness. Groups excluded by `--top`, `--min-count`, or baseline selection are outside the selected-case counts. Drafts still need review; acknowledging review does not clear missing context. Original input/profile bytes are not rechecked by this command; use `verify --input ... --profile ...` for that. The command accepts only a bundle directory and optional `--format text|json`, writes no files, and preserves all artifacts.
|
|
259
|
+
|
|
260
|
+
```js
|
|
261
|
+
import { readReadiness, renderReadiness } from '@ihyeon/error-to-test';
|
|
262
|
+
|
|
263
|
+
const summary = await readReadiness('./analysis');
|
|
264
|
+
console.log(renderReadiness(summary));
|
|
265
|
+
// API calls return a summary; only the CLI assigns readiness exit codes.
|
|
266
|
+
```
|
|
267
|
+
|
|
241
268
|
## JavaScript API
|
|
242
269
|
|
|
243
270
|
```js
|
package/dist/artifacts.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare function readVerifiedBundle(directory: string, options?: {
|
|
|
13
13
|
}): Promise<{
|
|
14
14
|
analysis: Record<string, unknown>;
|
|
15
15
|
provenance: Record<string, unknown>;
|
|
16
|
+
suite?: Record<string, unknown>;
|
|
16
17
|
verification: {
|
|
17
18
|
suite: boolean;
|
|
18
19
|
reviewed: boolean;
|
package/dist/artifacts.js
CHANGED
|
@@ -150,6 +150,7 @@ export async function readVerifiedBundle(directory, options = {}) {
|
|
|
150
150
|
if (JSON.stringify(mappings) !== JSON.stringify(provenance.mappings))
|
|
151
151
|
throw new Error('STALE_BUNDLE: Case provenance mappings no longer match the analysis.');
|
|
152
152
|
let suiteExists = false;
|
|
153
|
+
let verifiedSuite;
|
|
153
154
|
if (provenance.suiteSha256 !== undefined) {
|
|
154
155
|
const content = await readBoundedFile(resolve(root, 'cases/error-to-test.json'), 8 * 1024 * 1024);
|
|
155
156
|
if (hash(content) !== provenance.suiteSha256)
|
|
@@ -158,6 +159,7 @@ export async function readVerifiedBundle(directory, options = {}) {
|
|
|
158
159
|
if (suite.schemaVersion !== 'flow-qa/suite-1' || suiteSource.file !== 'flows/error-to-test.md' || suiteSource.sha256 !== provenance.flowSha256)
|
|
159
160
|
throw new Error('STALE_BUNDLE: Suite source no longer matches the flow.');
|
|
160
161
|
suiteExists = true;
|
|
162
|
+
verifiedSuite = suite;
|
|
161
163
|
}
|
|
162
164
|
if (options.input !== undefined) {
|
|
163
165
|
const provided = inputSource(options.input);
|
|
@@ -169,7 +171,7 @@ export async function readVerifiedBundle(directory, options = {}) {
|
|
|
169
171
|
}
|
|
170
172
|
if (options.profile !== undefined && hash(options.profile) !== provenance.profileSha256)
|
|
171
173
|
throw new Error('STALE_BUNDLE: Profile changed since analysis.');
|
|
172
|
-
return { analysis, provenance, verification: { suite: suiteExists, reviewed: provenance.reviewed, sourceChecked: options.input !== undefined } };
|
|
174
|
+
return { analysis, provenance, ...(verifiedSuite === undefined ? {} : { suite: verifiedSuite }), verification: { suite: suiteExists, reviewed: provenance.reviewed, sourceChecked: options.input !== undefined } };
|
|
173
175
|
}
|
|
174
176
|
export async function verifyBundle(directory, options = {}) {
|
|
175
177
|
return (await readVerifiedBundle(directory, options)).verification;
|
package/dist/cli.js
CHANGED
|
@@ -10,6 +10,7 @@ import { createProfileTemplate } from "./profile-template.js";
|
|
|
10
10
|
import { redactText } from "./redact.js";
|
|
11
11
|
import { linkFlowQaReport } from "./results.js";
|
|
12
12
|
import { readRunSummary, renderRunSummary } from "./run-summary.js";
|
|
13
|
+
import { readReadiness, renderReadiness } from "./readiness.js";
|
|
13
14
|
const help = `Error to Test — local error analysis and regression TC drafts
|
|
14
15
|
|
|
15
16
|
error-to-test analyze --input errors-1.json --input errors-2.json --profile profile.json --out new-directory
|
|
@@ -23,6 +24,7 @@ const help = `Error to Test — local error analysis and regression TC drafts
|
|
|
23
24
|
error-to-test init-profile new-directory --profile existing.json --out extended.json
|
|
24
25
|
error-to-test link-run new-directory --report path/to/qa-report.json
|
|
25
26
|
error-to-test results new-directory [--format text|json] [--out summary.md]
|
|
27
|
+
error-to-test readiness new-directory [--format text|json]
|
|
26
28
|
error-to-test compare BASELINE CURRENT [--format text|json] [--out comparison.md] [--max-new N]
|
|
27
29
|
|
|
28
30
|
Options:
|
|
@@ -31,6 +33,7 @@ Options:
|
|
|
31
33
|
--format auto|json|jsonl|text Analyze input format; JSONL requires explicit selection and one record per line; auto rejects malformed JSON-looking input
|
|
32
34
|
--format text|json Results summary format (default: text Markdown)
|
|
33
35
|
--format text|json Compare format (default: text Markdown)
|
|
36
|
+
--format text|json Readiness format (default: text Markdown; exit 0 ready, 2 blocked/empty, 1 on error)
|
|
34
37
|
--profile FILE Confirmed app scenarios and explicit assertions (analyze/verify); existing profile to extend (init-profile)
|
|
35
38
|
--baseline DIRECTORY Select only signatures absent from this verified bundle, before --min-count and --top; retain all groups in analysis.json (analyze only)
|
|
36
39
|
--project NAME Metadata for a manual report
|
|
@@ -157,7 +160,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
157
160
|
}
|
|
158
161
|
if (positionals.length === 0) {
|
|
159
162
|
if (Object.keys(values).length)
|
|
160
|
-
throw new Error('A command is required. Use analyze, init-profile, verify, link-run, results, or
|
|
163
|
+
throw new Error('A command is required. Use analyze, init-profile, verify, link-run, results, compare, or readiness. See --help.');
|
|
161
164
|
process.stdout.write(help);
|
|
162
165
|
return;
|
|
163
166
|
}
|
|
@@ -244,6 +247,23 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
244
247
|
process.stdout.write(`Results summary written: ${out}\n`);
|
|
245
248
|
return;
|
|
246
249
|
}
|
|
250
|
+
if (command === 'readiness') {
|
|
251
|
+
if (positionals.length !== 2 || !positionals[1]?.trim())
|
|
252
|
+
throw new Error('readiness requires one bundle directory.');
|
|
253
|
+
if (Object.keys(values).some(key => !['format', 'help'].includes(key)))
|
|
254
|
+
throw new Error('Unsupported option for readiness. Use only --format text|json.');
|
|
255
|
+
const format = values.format ?? 'text';
|
|
256
|
+
if (format !== 'text' && format !== 'json')
|
|
257
|
+
throw new Error('readiness --format must be text or json.');
|
|
258
|
+
const summary = await readReadiness(resolve(positionals[1]));
|
|
259
|
+
const content = format === 'json' ? jsonText(summary) : renderReadiness(summary);
|
|
260
|
+
if (Buffer.byteLength(content) > 64 * 1024 * 1024)
|
|
261
|
+
throw new Error('The readiness summary exceeds 64 MiB. Narrow the bundle before requesting output.');
|
|
262
|
+
await writeGateOutput(content);
|
|
263
|
+
if (summary.status !== 'ready')
|
|
264
|
+
process.exitCode = 2;
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
247
267
|
if (command === 'compare') {
|
|
248
268
|
if (positionals.length !== 3 || !positionals[1] || !positionals[2])
|
|
249
269
|
throw new Error('compare requires BASELINE and CURRENT bundle directories.');
|
|
@@ -317,7 +337,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
317
337
|
return;
|
|
318
338
|
}
|
|
319
339
|
if (command !== 'analyze' || positionals.length !== 1)
|
|
320
|
-
throw new Error('Use analyze, init-profile, verify, link-run, results, or
|
|
340
|
+
throw new Error('Use analyze, init-profile, verify, link-run, results, compare, or readiness. See --help.');
|
|
321
341
|
if (values.report)
|
|
322
342
|
throw new Error('--report applies to link-run only.');
|
|
323
343
|
if (values['max-new'] !== undefined)
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export { writeBundle, verifyBundle, renderReport } from './artifacts.ts';
|
|
|
7
7
|
export { linkFlowQaReport } from './results.ts';
|
|
8
8
|
export { createProfileTemplate, type ProfileTemplateOptions } from './profile-template.ts';
|
|
9
9
|
export { readRunSummary, renderRunSummary, type RunSummary, type LinkedRunStatus, type LinkedCaseStatus } from './run-summary.ts';
|
|
10
|
+
export { readReadiness, renderReadiness, type ReadinessSummary } from './readiness.ts';
|
|
10
11
|
export { compareBundles, renderComparison, type AnalysisComparison, type ComparisonStatus, type ComparisonSide, type ComparisonOccurrence, type ComparisonIssue } from './comparison.ts';
|
|
11
12
|
export type * from './types.ts';
|
package/dist/index.js
CHANGED
|
@@ -7,4 +7,5 @@ export { writeBundle, verifyBundle, renderReport } from "./artifacts.js";
|
|
|
7
7
|
export { linkFlowQaReport } from "./results.js";
|
|
8
8
|
export { createProfileTemplate } from "./profile-template.js";
|
|
9
9
|
export { readRunSummary, renderRunSummary } from "./run-summary.js";
|
|
10
|
+
export { readReadiness, renderReadiness } from "./readiness.js";
|
|
10
11
|
export { compareBundles, renderComparison } from "./comparison.js";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface ReadinessSummary {
|
|
2
|
+
schemaVersion: 'error-to-test/readiness-1';
|
|
3
|
+
inputSha256: string;
|
|
4
|
+
analysisSha256: string;
|
|
5
|
+
suiteSha256?: string;
|
|
6
|
+
reviewed: boolean;
|
|
7
|
+
status: 'ready' | 'blocked' | 'empty';
|
|
8
|
+
counts: {
|
|
9
|
+
groups: number;
|
|
10
|
+
selected: number;
|
|
11
|
+
draft: number;
|
|
12
|
+
needsContext: number;
|
|
13
|
+
ready: number;
|
|
14
|
+
blocked: number;
|
|
15
|
+
};
|
|
16
|
+
cases: {
|
|
17
|
+
caseId: string;
|
|
18
|
+
candidateId: string;
|
|
19
|
+
groupId: string;
|
|
20
|
+
state: 'draft' | 'needs-context';
|
|
21
|
+
title: string;
|
|
22
|
+
blockers: string[];
|
|
23
|
+
}[];
|
|
24
|
+
warnings: string[];
|
|
25
|
+
}
|
|
26
|
+
export declare function readReadiness(directory: string): Promise<ReadinessSummary>;
|
|
27
|
+
export declare function renderReadiness(summary: ReadinessSummary): string;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { literal, readVerifiedBundle } from "./artifacts.js";
|
|
2
|
+
import { redactText } from "./redact.js";
|
|
3
|
+
import { record, text } from "./validation.js";
|
|
4
|
+
const idPattern = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,79}$/;
|
|
5
|
+
const shaPattern = /^[0-9a-f]{64}$/;
|
|
6
|
+
const notes = [
|
|
7
|
+
'Readiness means only that no selected-case blockers are recorded in this snapshot. It does not prove runtime access, credentials, coverage, or execution.',
|
|
8
|
+
'Original input files were not supplied for this check; source content was not independently verified.',
|
|
9
|
+
'No browser execution was performed.',
|
|
10
|
+
];
|
|
11
|
+
function id(value, label) {
|
|
12
|
+
const result = text(value, label);
|
|
13
|
+
if (!idPattern.test(result))
|
|
14
|
+
throw new Error(`${label} must be a Flow QA-compatible ID.`);
|
|
15
|
+
return result;
|
|
16
|
+
}
|
|
17
|
+
function sha(value, label) {
|
|
18
|
+
const result = text(value, label);
|
|
19
|
+
if (!shaPattern.test(result))
|
|
20
|
+
throw new Error(`${label} must be a SHA-256 digest.`);
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
function strings(value, label) {
|
|
24
|
+
if (!Array.isArray(value))
|
|
25
|
+
throw new Error(`${label} must be a string array.`);
|
|
26
|
+
return value.map((item, index) => redactText(text(item, `${label}[${index}]`)));
|
|
27
|
+
}
|
|
28
|
+
function count(value, label) {
|
|
29
|
+
if (!Number.isSafeInteger(value) || value < 0)
|
|
30
|
+
throw new Error(`${label} must be a non-negative integer.`);
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
export async function readReadiness(directory) {
|
|
34
|
+
const { analysis, provenance, suite, verification } = await readVerifiedBundle(directory);
|
|
35
|
+
const inputSha256 = sha(provenance.inputSha256, 'provenance.inputSha256');
|
|
36
|
+
const analysisSha256 = sha(provenance.analysisSha256, 'provenance.analysisSha256');
|
|
37
|
+
const suiteSha256 = provenance.suiteSha256 === undefined ? undefined : sha(provenance.suiteSha256, 'provenance.suiteSha256');
|
|
38
|
+
if (verification.suite !== Boolean(suite) || verification.suite !== Boolean(suiteSha256))
|
|
39
|
+
throw new Error('STALE_BUNDLE: Suite provenance is inconsistent.');
|
|
40
|
+
if (!Array.isArray(analysis.groups) || analysis.groups.length > 10000 || !Array.isArray(analysis.candidates) || analysis.candidates.length > 100) {
|
|
41
|
+
throw new Error('STALE_BUNDLE: Analysis groups or selected candidates are invalid.');
|
|
42
|
+
}
|
|
43
|
+
const groups = new Set();
|
|
44
|
+
analysis.groups.forEach((raw, index) => {
|
|
45
|
+
const groupId = id(record(raw, `analysis.groups[${index}]`).id, `analysis.groups[${index}].id`);
|
|
46
|
+
if (groups.has(groupId))
|
|
47
|
+
throw new Error('STALE_BUNDLE: Analysis group IDs are duplicated.');
|
|
48
|
+
groups.add(groupId);
|
|
49
|
+
});
|
|
50
|
+
const candidates = new Map();
|
|
51
|
+
analysis.candidates.forEach((raw, index) => {
|
|
52
|
+
const candidate = record(raw, `analysis.candidates[${index}]`);
|
|
53
|
+
const candidateId = id(candidate.id, `analysis.candidates[${index}].id`);
|
|
54
|
+
const groupId = id(candidate.groupId, `analysis.candidates[${index}].groupId`);
|
|
55
|
+
if (!groups.has(groupId))
|
|
56
|
+
throw new Error('STALE_BUNDLE: A selected candidate refers to a missing group.');
|
|
57
|
+
if (candidates.has(candidateId))
|
|
58
|
+
throw new Error('STALE_BUNDLE: Candidate IDs are duplicated.');
|
|
59
|
+
if (candidate.state !== 'draft' && candidate.state !== 'needs-context')
|
|
60
|
+
throw new Error('STALE_BUNDLE: A selected candidate has an invalid state.');
|
|
61
|
+
candidates.set(candidateId, { groupId, state: candidate.state, title: redactText(text(candidate.title, `analysis.candidates[${index}].title`)), questions: strings(candidate.questions, `analysis.candidates[${index}].questions`) });
|
|
62
|
+
});
|
|
63
|
+
if (Boolean(suite) !== Boolean(candidates.size))
|
|
64
|
+
throw new Error('STALE_BUNDLE: Suite presence does not match selected candidates.');
|
|
65
|
+
if (!Array.isArray(provenance.mappings) || provenance.mappings.length !== candidates.size)
|
|
66
|
+
throw new Error('STALE_BUNDLE: Case mappings are invalid.');
|
|
67
|
+
const mappings = new Map();
|
|
68
|
+
provenance.mappings.forEach((raw, index) => {
|
|
69
|
+
const mapping = record(raw, `provenance.mappings[${index}]`);
|
|
70
|
+
const caseId = id(mapping.caseId, `provenance.mappings[${index}].caseId`);
|
|
71
|
+
const candidateId = id(mapping.candidateId, `provenance.mappings[${index}].candidateId`);
|
|
72
|
+
const groupId = id(mapping.groupId, `provenance.mappings[${index}].groupId`);
|
|
73
|
+
if (mappings.has(caseId) || caseId !== candidateId || candidates.get(candidateId)?.groupId !== groupId)
|
|
74
|
+
throw new Error('STALE_BUNDLE: Case mappings are inconsistent.');
|
|
75
|
+
mappings.set(caseId, { candidateId, groupId });
|
|
76
|
+
});
|
|
77
|
+
const cases = [];
|
|
78
|
+
if (suite) {
|
|
79
|
+
if (!Array.isArray(suite.cases) || suite.cases.length !== candidates.size)
|
|
80
|
+
throw new Error('STALE_BUNDLE: Suite cases do not match selected candidates.');
|
|
81
|
+
const seen = new Set();
|
|
82
|
+
suite.cases.forEach((raw, index) => {
|
|
83
|
+
const suiteCase = record(raw, `suite.cases[${index}]`);
|
|
84
|
+
const caseId = id(suiteCase.id, `suite.cases[${index}].id`);
|
|
85
|
+
const mapping = mappings.get(caseId);
|
|
86
|
+
if (!mapping || seen.has(caseId))
|
|
87
|
+
throw new Error('STALE_BUNDLE: Suite contains an unknown or duplicate case ID.');
|
|
88
|
+
seen.add(caseId);
|
|
89
|
+
const candidate = candidates.get(mapping.candidateId);
|
|
90
|
+
const suiteQuestions = strings(suiteCase.questions, `suite.cases[${index}].questions`);
|
|
91
|
+
const blockers = [...new Set([...suiteQuestions, ...candidate.questions])];
|
|
92
|
+
if (candidate.state === 'needs-context' && blockers.length === 0)
|
|
93
|
+
blockers.push('Resolve missing context before running this case.');
|
|
94
|
+
if (!verification.reviewed && suiteQuestions.length === 0)
|
|
95
|
+
blockers.push('Bundle review is pending.');
|
|
96
|
+
cases.push({ caseId, candidateId: mapping.candidateId, groupId: mapping.groupId, state: candidate.state, title: candidate.title, blockers: [...new Set(blockers)] });
|
|
97
|
+
});
|
|
98
|
+
if (seen.size !== candidates.size)
|
|
99
|
+
throw new Error('STALE_BUNDLE: Suite is missing selected cases.');
|
|
100
|
+
}
|
|
101
|
+
const draft = cases.filter(item => item.state === 'draft').length;
|
|
102
|
+
const needsContext = cases.length - draft;
|
|
103
|
+
const ready = cases.filter(item => item.state === 'draft' && verification.reviewed && item.blockers.length === 0).length;
|
|
104
|
+
const blocked = cases.length - ready;
|
|
105
|
+
const warnings = [...strings(analysis.warnings, 'analysis.warnings'), ...notes];
|
|
106
|
+
return {
|
|
107
|
+
schemaVersion: 'error-to-test/readiness-1', inputSha256, analysisSha256,
|
|
108
|
+
...(suiteSha256 === undefined ? {} : { suiteSha256 }), reviewed: verification.reviewed,
|
|
109
|
+
status: cases.length === 0 ? 'empty' : blocked === 0 ? 'ready' : 'blocked',
|
|
110
|
+
counts: { groups: groups.size, selected: cases.length, draft, needsContext, ready, blocked }, cases, warnings,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export function renderReadiness(summary) {
|
|
114
|
+
if (summary.schemaVersion !== 'error-to-test/readiness-1' || !['ready', 'blocked', 'empty'].includes(summary.status) || typeof summary.reviewed !== 'boolean')
|
|
115
|
+
throw new Error('Invalid readiness summary.');
|
|
116
|
+
const lines = ['# Error to Test readiness', '', `Status: ${summary.status}`, `Review acknowledged: ${summary.reviewed ? 'yes' : 'no'}`,
|
|
117
|
+
`Input SHA-256: ${sha(summary.inputSha256, 'summary.inputSha256')}`,
|
|
118
|
+
`Analysis SHA-256: ${sha(summary.analysisSha256, 'summary.analysisSha256')}`];
|
|
119
|
+
if (summary.suiteSha256 !== undefined)
|
|
120
|
+
lines.push(`Suite SHA-256: ${sha(summary.suiteSha256, 'summary.suiteSha256')}`);
|
|
121
|
+
lines.push('', '## Counts', '');
|
|
122
|
+
for (const key of ['groups', 'selected', 'draft', 'needsContext', 'ready', 'blocked'])
|
|
123
|
+
lines.push(`- ${key}: ${count(summary.counts[key], `summary.counts.${key}`)}`);
|
|
124
|
+
lines.push('', '## Cases', '');
|
|
125
|
+
if (!summary.cases.length)
|
|
126
|
+
lines.push('No selected cases.', '');
|
|
127
|
+
for (const item of summary.cases) {
|
|
128
|
+
if (item.state !== 'draft' && item.state !== 'needs-context')
|
|
129
|
+
throw new Error('Invalid readiness case state.');
|
|
130
|
+
lines.push(`### ${id(item.caseId, 'summary.caseId')}`, '', `Candidate ID: ${id(item.candidateId, 'summary.candidateId')}`, `Group ID: ${id(item.groupId, 'summary.groupId')}`, `State: ${item.state}`, '', 'Title:', '', literal(text(item.title, 'summary.title')), '', 'Recorded blockers:', '', literal(strings(item.blockers, 'summary.blockers').join('\n') || 'None'), '');
|
|
131
|
+
}
|
|
132
|
+
lines.push('## Warnings and limits', '', literal(strings(summary.warnings, 'summary.warnings').join('\n') || 'None'), '');
|
|
133
|
+
return `${lines.join('\n')}\n`;
|
|
134
|
+
}
|
package/package.json
CHANGED