@ihyeon/error-to-test 0.2.1 → 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 +38 -0
- package/README.md +48 -0
- package/dist/artifacts.d.ts +1 -0
- package/dist/artifacts.js +3 -1
- package/dist/cli.js +71 -8
- 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
|
@@ -102,6 +102,25 @@ TC 생성 대상에서 제외된 묶음도 모두 비교합니다. 한쪽에 여
|
|
|
102
102
|
|
|
103
103
|
양쪽 번들을 검증한 뒤 읽으며 원래 산출물·TC 상태·검토 조건·연결 결과는 수정하지 않습니다. 기본 출력은 Markdown이고, `--format json`은 `error-to-test/comparison-1`을 반환합니다. `--out`은 양쪽 번들의 `results` 폴더 밖에 있는 새 파일만 허용합니다. API는 `compareBundles()`와 `renderComparison()`입니다.
|
|
104
104
|
|
|
105
|
+
CI에서는 `--max-new N`으로 **현재에만 있는 오류 서명의 허용 개수**를 정할 수 있습니다.
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
error-to-test compare ./before ./current --max-new 0
|
|
109
|
+
error-to-test compare ./before ./current --max-new 2 --format json --out ./comparison.json
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
0~10,000의 십진 정수를 받습니다. TC 생성에서 제외된 묶음을 포함한 전체 비교 결과의 `only-current` 서명 수를 기준으로 합니다. 릴리스만 다른 동일 비교 키는 한 번 세며, 로그 건수나 건수 증가는 한도에 포함하지 않습니다.
|
|
113
|
+
|
|
114
|
+
| 종료 코드 | 의미 |
|
|
115
|
+
| --- | --- |
|
|
116
|
+
| `0` | 비교 성공, 한도 이내 또는 한도 옵션 미사용 |
|
|
117
|
+
| `1` | 잘못된 옵션·입력 형식 불일치·번들 변조·출력 오류 |
|
|
118
|
+
| `2` | 비교 성공, 현재에만 있는 서명 수가 한도 초과 |
|
|
119
|
+
|
|
120
|
+
한도를 넘겨도 전체 비교 보고서를 출력하거나 저장하므로 CI에서 검토 자료로 남길 수 있습니다. 숫자로 된 통과·실패 요약은 stderr에 쓰고, JSON stdout은 기존 `error-to-test/comparison-1` 형식을 유지합니다. 출력 오류는 코드 1로 처리하고 기존 파일을 보존합니다. 옵션을 생략하면 기존 비교 동작을 유지하며, `--max-new`는 `compare`에서만 사용할 수 있습니다.
|
|
121
|
+
|
|
122
|
+
프로젝트·환경·기간·수집 범위를 맞춘 분석을 기준으로 사용하세요. 부분 내보내기와 수집 범위 경고는 보고서에 남습니다. 이 값은 제공한 이전 분석에 없던 서명 수이며 실제 유입 시점이나 회귀 원인을 확정하지 않습니다. TC 실행·검토 상태는 변경하지 않습니다. API에서는 `comparison.counts['only-current']`로 같은 기준을 적용할 수 있습니다.
|
|
123
|
+
|
|
105
124
|
`analyze --baseline`을 쓰면 **이전 분석에서 관측되지 않은 서명만 골라 TC를 생성**할 수 있습니다.
|
|
106
125
|
|
|
107
126
|
```sh
|
|
@@ -164,6 +183,25 @@ flow-qa init
|
|
|
164
183
|
flow-qa ui
|
|
165
184
|
```
|
|
166
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
|
+
|
|
167
205
|
Flow QA 설치와 실행 대상 설정은 별도로 필요합니다. 위 `flows/`·`cases/` 구조를 기존 검토 화면에서 읽을 수 있습니다. 분석 명령은 브라우저를 실행하거나 외부 모델에 요청하지 않습니다. TC 통과만으로 원래 오류를 수정 완료 처리하지 않습니다.
|
|
168
206
|
|
|
169
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
|
@@ -131,6 +131,27 @@ All source groups participate, including groups excluded from TC generation by `
|
|
|
131
131
|
|
|
132
132
|
Both bundles must pass consistency verification. The command reads their verified snapshots without editing artifacts, TC states, review gates, or linked results. Markdown is the default; `--format json` returns `error-to-test/comparison-1`. `--out` requires a new file outside either bundle's `results` directory. The API equivalents are `await compareBundles(baselineDirectory, currentDirectory)` and `renderComparison(comparison)`.
|
|
133
133
|
|
|
134
|
+
### Limit newly observed signatures in CI
|
|
135
|
+
|
|
136
|
+
Set `--max-new N` to fail a CI step when the supplied current analysis has more than N `only-current` signatures:
|
|
137
|
+
|
|
138
|
+
```sh
|
|
139
|
+
error-to-test compare ./before ./current --max-new 0
|
|
140
|
+
error-to-test compare ./before ./current --max-new 2 --format json --out ./comparison.json
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
The limit accepts decimal integers from 0 to 10,000. It counts distinct comparison signatures across all retained groups, including groups excluded from TC generation. Release groups sharing the same comparison key count once. Record counts and count increases do not affect this limit.
|
|
144
|
+
|
|
145
|
+
| Exit code | Result |
|
|
146
|
+
| --- | --- |
|
|
147
|
+
| `0` | Comparison succeeded and the limit was met, or no limit was requested |
|
|
148
|
+
| `1` | Invalid options, incompatible/stale inputs, or an output error |
|
|
149
|
+
| `2` | Comparison succeeded and the `only-current` count exceeded the limit |
|
|
150
|
+
|
|
151
|
+
On limit failure the full report is still printed or saved, so CI can retain it for review. A numeric pass/fail summary goes to stderr; JSON stdout remains the unchanged `error-to-test/comparison-1` object. Output errors take precedence and preserve existing files. Without `--max-new`, existing comparison behavior is unchanged. The option is available only on `compare`.
|
|
152
|
+
|
|
153
|
+
Choose snapshots with the intended project, environment, period, and collection scope. Partial-export and coverage warnings remain in the report. This limit describes signatures absent from the supplied baseline; it does not establish when an error was introduced, execute TCs, or change their review state. API callers can apply their own threshold to `comparison.counts['only-current']`.
|
|
154
|
+
|
|
134
155
|
### Generate TCs for signatures absent from a baseline
|
|
135
156
|
|
|
136
157
|
Pass a verified analysis bundle to `analyze --baseline` to focus TC generation on current signatures that were not observed in that baseline:
|
|
@@ -217,6 +238,33 @@ flow-qa ui
|
|
|
217
238
|
|
|
218
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.
|
|
219
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
|
+
|
|
220
268
|
## JavaScript API
|
|
221
269
|
|
|
222
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,7 +24,8 @@ 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]
|
|
26
|
-
error-to-test
|
|
27
|
+
error-to-test readiness new-directory [--format text|json]
|
|
28
|
+
error-to-test compare BASELINE CURRENT [--format text|json] [--out comparison.md] [--max-new N]
|
|
27
29
|
|
|
28
30
|
Options:
|
|
29
31
|
--input FILE SDK export, manual JSON, JSONL, or plain error text; repeat for same-format files in order (analyze: sole - for stdin)
|
|
@@ -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
|
|
@@ -50,6 +53,7 @@ Options:
|
|
|
50
53
|
--out FILE New init-profile JSON file; existing files are never overwritten
|
|
51
54
|
--out FILE New results summary file; existing files are never overwritten
|
|
52
55
|
--out FILE New comparison file; existing files are never overwritten
|
|
56
|
+
--max-new N Compare only: allow 0..10000 only-current signatures; exit 0 within limit, 2 over limit, 1 on error
|
|
53
57
|
--reviewed Acknowledge review; unresolved questions still block cases
|
|
54
58
|
--report FILE Normalized Flow QA report (link-run only)
|
|
55
59
|
--version, -v Print the package version
|
|
@@ -74,6 +78,23 @@ async function stdinText() {
|
|
|
74
78
|
throw new Error('Input must be valid UTF-8.');
|
|
75
79
|
return input.toString('utf8');
|
|
76
80
|
}
|
|
81
|
+
async function writeGateOutput(content) {
|
|
82
|
+
await new Promise((resolveWrite, rejectWrite) => {
|
|
83
|
+
const onError = (error) => { process.stdout.off('error', onError); rejectWrite(error); };
|
|
84
|
+
process.stdout.on('error', onError);
|
|
85
|
+
process.stdout.write(content, (error) => {
|
|
86
|
+
if (error) {
|
|
87
|
+
rejectWrite(error);
|
|
88
|
+
// Writable can emit 'error' after invoking the failed write callback.
|
|
89
|
+
setImmediate(() => process.stdout.off('error', onError));
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
process.stdout.off('error', onError);
|
|
93
|
+
resolveWrite();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
}
|
|
77
98
|
async function inputContents(paths, allowStdin) {
|
|
78
99
|
if (paths.length < 1 || paths.length > 50)
|
|
79
100
|
throw new Error('Provide between 1 and 50 --input files.');
|
|
@@ -124,7 +145,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
124
145
|
help: { type: 'boolean', short: 'h' }, version: { type: 'boolean', short: 'v' }, input: { type: 'string', multiple: true }, error: { type: 'string' }, report: { type: 'string' },
|
|
125
146
|
format: { type: 'string' }, profile: { type: 'string' }, baseline: { type: 'string' }, project: { type: 'string' }, environment: { type: 'string' },
|
|
126
147
|
release: { type: 'string' }, page: { type: 'string' }, type: { type: 'string' }, runtime: { type: 'string' }, from: { type: 'string' }, to: { type: 'string' },
|
|
127
|
-
top: { type: 'string' }, 'min-count': { type: 'string' }, out: { type: 'string' }, reviewed: { type: 'boolean' },
|
|
148
|
+
top: { type: 'string' }, 'min-count': { type: 'string' }, 'max-new': { type: 'string' }, out: { type: 'string' }, reviewed: { type: 'boolean' },
|
|
128
149
|
reproduce: { type: 'string', multiple: true }, precondition: { type: 'string', multiple: true },
|
|
129
150
|
expected: { type: 'string' }, 'expected-source': { type: 'string' },
|
|
130
151
|
} });
|
|
@@ -139,7 +160,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
139
160
|
}
|
|
140
161
|
if (positionals.length === 0) {
|
|
141
162
|
if (Object.keys(values).length)
|
|
142
|
-
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.');
|
|
143
164
|
process.stdout.write(help);
|
|
144
165
|
return;
|
|
145
166
|
}
|
|
@@ -226,22 +247,57 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
226
247
|
process.stdout.write(`Results summary written: ${out}\n`);
|
|
227
248
|
return;
|
|
228
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
|
+
}
|
|
229
267
|
if (command === 'compare') {
|
|
230
268
|
if (positionals.length !== 3 || !positionals[1] || !positionals[2])
|
|
231
269
|
throw new Error('compare requires BASELINE and CURRENT bundle directories.');
|
|
232
|
-
if (Object.keys(values).some(key => !['format', 'out', 'help'].includes(key)))
|
|
233
|
-
throw new Error('Unsupported option for compare. Use only --format text|json and --
|
|
270
|
+
if (Object.keys(values).some(key => !['format', 'out', 'max-new', 'help'].includes(key)))
|
|
271
|
+
throw new Error('Unsupported option for compare. Use only --format text|json, --out FILE, and --max-new N.');
|
|
234
272
|
const format = values.format ?? 'text';
|
|
235
273
|
if (format !== 'text' && format !== 'json')
|
|
236
274
|
throw new Error('compare --format must be text or json.');
|
|
275
|
+
const maxNewRaw = values['max-new'];
|
|
276
|
+
if (maxNewRaw !== undefined && (!/^[0-9]+$/.test(maxNewRaw) || Number(maxNewRaw) > 10000)) {
|
|
277
|
+
throw new Error('compare --max-new must be a decimal integer between 0 and 10000.');
|
|
278
|
+
}
|
|
279
|
+
const maxNew = maxNewRaw === undefined ? undefined : Number(maxNewRaw);
|
|
237
280
|
const baseline = resolve(positionals[1]);
|
|
238
281
|
const current = resolve(positionals[2]);
|
|
239
282
|
const comparison = await compareBundles(baseline, current);
|
|
240
283
|
const content = format === 'json' ? jsonText(comparison) : renderComparison(comparison);
|
|
241
284
|
if (Buffer.byteLength(content) > 64 * 1024 * 1024)
|
|
242
285
|
throw new Error('The comparison exceeds 64 MiB. Narrow the bundles before requesting output.');
|
|
286
|
+
const finishGate = () => {
|
|
287
|
+
if (maxNew === undefined)
|
|
288
|
+
return;
|
|
289
|
+
const count = comparison.counts['only-current'];
|
|
290
|
+
const passed = count <= maxNew;
|
|
291
|
+
process.stderr.write(`Comparison gate ${passed ? 'passed' : 'failed'}: ${count} only-current signatures ${passed ? `(maximum ${maxNew}).` : `exceed maximum ${maxNew}.`}\n`);
|
|
292
|
+
if (!passed)
|
|
293
|
+
process.exitCode = 2;
|
|
294
|
+
};
|
|
243
295
|
if (values.out === undefined) {
|
|
244
|
-
|
|
296
|
+
if (maxNew === undefined)
|
|
297
|
+
process.stdout.write(content);
|
|
298
|
+
else
|
|
299
|
+
await writeGateOutput(content);
|
|
300
|
+
finishGate();
|
|
245
301
|
return;
|
|
246
302
|
}
|
|
247
303
|
const out = resolve(values.out);
|
|
@@ -260,7 +316,12 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
260
316
|
throw new Error('The output file already exists. Choose a new --out FILE path.');
|
|
261
317
|
throw error;
|
|
262
318
|
}
|
|
263
|
-
|
|
319
|
+
const written = `Comparison written: ${out}\n`;
|
|
320
|
+
if (maxNew === undefined)
|
|
321
|
+
process.stdout.write(written);
|
|
322
|
+
else
|
|
323
|
+
await writeGateOutput(written);
|
|
324
|
+
finishGate();
|
|
264
325
|
return;
|
|
265
326
|
}
|
|
266
327
|
if (command === 'verify') {
|
|
@@ -276,9 +337,11 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
276
337
|
return;
|
|
277
338
|
}
|
|
278
339
|
if (command !== 'analyze' || positionals.length !== 1)
|
|
279
|
-
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.');
|
|
280
341
|
if (values.report)
|
|
281
342
|
throw new Error('--report applies to link-run only.');
|
|
343
|
+
if (values['max-new'] !== undefined)
|
|
344
|
+
throw new Error('--max-new applies to compare only.');
|
|
282
345
|
if (values.baseline !== undefined && values.baseline.trim() === '')
|
|
283
346
|
throw new Error('--baseline requires a bundle directory.');
|
|
284
347
|
if ((values.input === undefined) === (values.error === 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