@ihyeon/error-to-test 0.2.5 → 0.2.7
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 -1
- package/README.md +50 -1
- package/dist/artifacts.d.ts +1 -0
- package/dist/artifacts.js +1 -1
- package/dist/cli.js +71 -9
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/issue-report.d.ts +2 -0
- package/dist/issue-report.js +165 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -150,7 +150,23 @@ error-to-test init-profile ./selected-tcs --out ./selected-profile.json
|
|
|
150
150
|
|
|
151
151
|
지정한 묶음과 `--baseline`의 교집합에 기존 순위대로 `--min-count`, `--top`을 적용합니다. ID를 입력한 순서로 우선순위가 바뀌지 않습니다. 알려진 ID라도 이 조건 때문에 TC가 생성되지 않을 수 있으며, 선택된 TC가 없으면 suite 없는 정상 번들을 만들고 `readiness`는 `empty`와 종료 코드 2를 반환합니다. 한 묶음에 여러 프로필 규칙이 적용되면 기존처럼 여러 TC를 생성할 수 있습니다.
|
|
152
152
|
|
|
153
|
-
전체 오류 묶음·원본 해시·수집 범위는 보존합니다. 요청한 ID는 정렬·중복 제거해 `analysis.groupFilter.groupIds`에 기록하고 분석 해시로 보호하며, 보고서에도 선택 범위를 남깁니다. 비교와 이전 분석 기준의 건수는 전체 묶음을 계속 사용합니다. 맥락 질문과 검토 조건도 유지합니다. `--group`을 생략하면 기존 선택
|
|
153
|
+
전체 오류 묶음·원본 해시·수집 범위는 보존합니다. 요청한 ID는 정렬·중복 제거해 `analysis.groupFilter.groupIds`에 기록하고 분석 해시로 보호하며, 보고서에도 선택 범위를 남깁니다. 비교와 이전 분석 기준의 건수는 전체 묶음을 계속 사용합니다. 맥락 질문과 검토 조건도 유지합니다. `--group`을 생략하면 기존 선택 방식입니다. `issue` 명령에서도 `--group`으로 기존 묶음 하나를 지정할 수 있으며, 이 경우 TC 선택을 변경하지 않고 공유용 보고서만 만듭니다. API는 `analyzeErrors(content, { groupIds: [groupId] })`와 `analyzeWithBaseline()`의 같은 옵션입니다. 비어 있지 않은 최대 100개 항목 배열을 받으며 입력 배열을 변경하지 않습니다.
|
|
154
|
+
|
|
155
|
+
오류 하나를 공유하거나 이슈에 붙여 넣을 때는 **`issue`로 묶음별 Markdown 보고서**를 뽑을 수 있습니다.
|
|
156
|
+
|
|
157
|
+
```sh
|
|
158
|
+
# 예시 ID를 report.md나 analysis.json에 있는 실제 묶음 ID로 바꾸세요.
|
|
159
|
+
error-to-test issue ./analysis --group group-0123456789abcdef --out ./issue.md
|
|
160
|
+
error-to-test issue ./analysis --group group-0123456789abcdef
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
검증된 번들에서 해당 오류 상세·대표 스택·연결 TC의 재현 방법·기대 결과·질문을 발췌합니다. TC 생성에서 제외된 묶음도 내보낼 수 있으며, 이 경우 선택된 TC가 없다고 표시합니다. `--group`은 정확히 하나만 받으며 잘못되거나 존재하지 않는 ID는 파일 생성 전에 거부합니다.
|
|
164
|
+
|
|
165
|
+
원본 입력·분석·보고서 해시와 존재하는 프로필·suite 해시를 남겨 어느 검증된 번들에서 나온 내용인지 추적할 수 있습니다. 수집 범위와 경고는 **원본 번들 전체 기준**이며 해당 오류의 발생률이나 완전한 수집을 뜻하지 않습니다. 다른 묶음의 오류 내용과 전역 선택 정보는 포함하지 않으며, 로그 안에 제목처럼 보이는 문장이 있어도 Markdown 코드 구역을 구분해 발췌합니다.
|
|
166
|
+
|
|
167
|
+
저장된 검토 자료를 내보내는 기능입니다. TC 생성·승인·연결 결과 조회·테스트 실행·원격 이슈 등록·수정 완료 처리는 하지 않습니다. 원본 입력 바이트 재확인은 `verify --input ...`, 실행 차단 사유 확인은 `readiness`로 별도 수행하세요.
|
|
168
|
+
|
|
169
|
+
기본 출력은 stdout이고 `--out`은 경로 별칭을 포함한 원본 번들 전체 바깥의 새 파일만 허용합니다. 파일은 권한 0600으로 만들며 기존 파일과 산출물을 보존합니다. 번들 경로·묶음 ID 하나·선택적인 `--out`만 받습니다. 성공은 종료 코드 0, 변경된 번들·지원하지 않는 저장 보고서 구조·출력 오류는 코드 1입니다. API는 `await readIssueReport(directory, groupId)`이며 검증된 동일 스냅샷에서 Markdown 문자열을 반환하고 파일 저장이나 외부 전송은 하지 않습니다.
|
|
154
170
|
|
|
155
171
|
`report.md` 상단에서 TC 초안 수와 추가 정보가 필요한 TC 수를 확인할 수 있습니다. 초안도 실행 전에 검토해야 합니다. 오류 묶음·수집 건수와 함께 대표 로그의 오류·React 컴포넌트 스택, 재현 방법·사전 조건·테스트 단계·부족한 정보도 표시합니다. 같은 스택은 한 번만 표시하며, 전체 로그의 모든 스택을 나열하지는 않습니다. 재현 단계와 정상 기대 결과, 명시적인 assertion이 없으면 질문이 있는 TC를 생성합니다. 직접 입력한 보고서에는 실제 발생 시각·사용자 수를 만들어 넣지 않습니다. 수집 건수도 실제 발생률을 뜻하지 않으며, 원본 내보내기의 일부 데이터 표시를 유지합니다.
|
|
156
172
|
|
|
@@ -256,6 +272,27 @@ error-to-test results .error-to-test/reviewed --format json --out ./run-summary.
|
|
|
256
272
|
|
|
257
273
|
API에서는 `await readRunSummary(directory)`로 같은 데이터를 읽고 `renderRunSummary(summary)`로 Markdown을 만듭니다.
|
|
258
274
|
|
|
275
|
+
CI에서는 `results --fail-on`으로 **최신 연결 실행의 TC 상태에 따라 실패 여부**를 정할 수 있습니다.
|
|
276
|
+
|
|
277
|
+
```sh
|
|
278
|
+
error-to-test results ./analysis --fail-on failed --fail-on error
|
|
279
|
+
error-to-test results ./analysis --fail-on failed --fail-on error --fail-on not-run --format json --out ./ci-results.json
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
`failed`·`flaky`·`blocked`·`skipped`·`error`·`not-run` 중 정확한 값을 반복 지정합니다. 중복은 한 번만 처리하고 입력 순서와 무관하게 같은 정책을 적용합니다. 쉼표로 합친 값이나 `passed`, 실행 전체 상태인 `interrupted` 등은 번들을 읽기 전에 거부합니다.
|
|
283
|
+
|
|
284
|
+
| 종료 코드 | `--fail-on` 사용 시 의미 |
|
|
285
|
+
| --- | --- |
|
|
286
|
+
| `0` | 선택된 TC가 하나 이상이고 지정한 상태에 해당하는 TC가 없음 |
|
|
287
|
+
| `1` | 잘못된 옵션·잘못되거나 변경된 번들/결과·출력 오류 |
|
|
288
|
+
| `2` | 지정한 상태의 TC가 있거나 선택된 TC가 없음 |
|
|
289
|
+
|
|
290
|
+
전체 보고서를 출력하거나 저장한 뒤 0 또는 2를 반환하고 숫자로 된 판정 요약은 stderr에 씁니다. JSON stdout은 기존 `error-to-test/run-summary-1` 형식이며 판정 필드를 추가하지 않습니다. 출력 오류는 판정 요약 없이 코드 1로 처리하고 기존 파일은 보존합니다.
|
|
291
|
+
|
|
292
|
+
최신 실행 하나의 TC 결과만 평가하며 과거 실패를 합치거나 실행 전체 상태를 별도 조건으로 삼지 않습니다. 연결 실행이 없으면 선택된 TC는 `not-run`이므로 미실행도 실패시킬 때 이 값을 지정하세요. 지정하지 않은 상태는 실패 조건이 아니지만, 선택된 TC가 없는 결과는 항상 코드 2입니다. 검토 대기와 미해결 맥락은 실행 전 `readiness`로 별도 점검하세요. 정책 통과는 검토 승인·브라우저 실행 증명·원본 오류 수정 완료를 의미하지 않습니다.
|
|
293
|
+
|
|
294
|
+
옵션을 생략하면 기존 결과 조회 동작과 종료 코드를 유지합니다. `results`에서만 사용할 수 있고 API·저장 요약 형식은 바뀌지 않습니다. API에서는 `readRunSummary()`가 반환한 `counts`로 정책을 적용할 수 있습니다.
|
|
295
|
+
|
|
259
296
|
직접 입력은 문자열, 텍스트 파일, 표준 입력, `error-to-test/manual-1` JSON을 지원합니다. 파일 구조는 [수동 오류 예제](examples/manual.json), 정상 기대 동작과 단계 연결은 [프로필 예제](examples/profile.json)를 참고하세요. 전체 옵션은 `node bin/error-to-test.mjs --help`로 확인할 수 있습니다.
|
|
260
297
|
|
|
261
298
|
알려진 자격증명·이메일·URL 인증/쿼리 정보는 결과에서 정제합니다. 민감정보가 포함된 실행 단계나 기대 결과는 변경해 통과시키지 않고 질문으로 남깁니다. 모든 개인정보를 제거한다고 보장하지 않으므로 실제 업무 데이터를 입력하기 전에는 별도로 정제하세요. 비공개 오류는 셸 기록에 남는 인자 대신 파일·표준 입력을 사용하세요.
|
package/README.md
CHANGED
|
@@ -187,10 +187,36 @@ Repeat `--group` up to 100 times. Each ID must have the exact `group-` plus 16 l
|
|
|
187
187
|
|
|
188
188
|
Requested groups are intersected with any `--baseline` selection, then `--min-count` and `--top` apply in the original ranked order. Argument order does not change priority. A known group can still be excluded by these conditions; zero selected cases creates a valid bundle without a suite, and `readiness` reports `empty` with exit `2`. A selected group may produce several profile-based TCs as before.
|
|
189
189
|
|
|
190
|
-
The complete observed groups, input hashes, and source coverage remain in the new bundle. `analysis.groupFilter.groupIds` stores the sorted, deduplicated requested IDs, covered by the analysis hash, and the report records the scope. Comparison and baseline counts continue to use all observed groups. Missing-context and review questions still block execution. Omitting `--group` keeps the existing selection behavior
|
|
190
|
+
The complete observed groups, input hashes, and source coverage remain in the new bundle. `analysis.groupFilter.groupIds` stores the sorted, deduplicated requested IDs, covered by the analysis hash, and the report records the scope. Comparison and baseline counts continue to use all observed groups. Missing-context and review questions still block execution. Omitting `--group` keeps the existing selection behavior. The `issue` command also uses `--group` to identify one saved group for a report, without changing TC selection.
|
|
191
191
|
|
|
192
192
|
The API accepts `analyzeErrors(content, { groupIds: [groupId], top: 10 })` and the same option in `analyzeWithBaseline()`. `groupIds` must be a nonempty array of at most 100 entries; it is not mutated.
|
|
193
193
|
|
|
194
|
+
### Export one error group for an issue
|
|
195
|
+
|
|
196
|
+
`issue` creates a local Markdown report for one exact group from a verified bundle:
|
|
197
|
+
|
|
198
|
+
```sh
|
|
199
|
+
# Replace the example ID with an actual ID from report.md or analysis.json.
|
|
200
|
+
error-to-test issue ./analysis --group group-0123456789abcdef --out ./issue.md
|
|
201
|
+
error-to-test issue ./analysis --group group-0123456789abcdef
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
The report includes the saved error details, representative stacks, and any selected TC candidates with their reproduction, expected behavior, and questions. Groups excluded from TC generation can also be exported; they are explicitly marked as having no selected TC candidates. Exactly one `--group` is required, and malformed or unknown IDs are rejected without generating a file.
|
|
205
|
+
|
|
206
|
+
The original input/analysis/report hashes and available profile/suite hashes identify the verified snapshot. Source coverage and warnings describe the **whole original bundle**, not a per-group rate or complete collection. Only the requested group's detail section is copied; other groups' error contents and the original global selection sections are not included. Markdown fences are respected, so heading-like text inside captured logs cannot split the excerpt.
|
|
207
|
+
|
|
208
|
+
This exports saved review material. It does not generate or approve cases, read linked results, execute tests, file a remote issue, or resolve an error. Original input bytes are not rechecked; use `verify --input ...` when originals are available. Use `readiness` to inspect current recorded execution blockers in the exported suite.
|
|
209
|
+
|
|
210
|
+
Output defaults to stdout. `--out` writes an exclusive mode-0600 new file outside the entire source bundle, including path aliases; existing files and source artifacts are preserved. `issue` accepts only a bundle directory, one `--group`, and optional `--out`. Changed bundles, unsupported saved report layouts, and output errors exit `1`; successful export exits `0`.
|
|
211
|
+
|
|
212
|
+
```js
|
|
213
|
+
import { readIssueReport } from '@ihyeon/error-to-test';
|
|
214
|
+
|
|
215
|
+
const markdown = await readIssueReport('./analysis', groupId);
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
The API returns Markdown from one verified snapshot and does not write files or send content anywhere.
|
|
219
|
+
|
|
194
220
|
## Confirm the intended behavior
|
|
195
221
|
|
|
196
222
|
See [examples/profile.json](examples/profile.json). Profiles use `schemaVersion: "error-to-test/profile-1"`, a name, and up to 100 scenarios. Each scenario has a unique ID, title, at least one match predicate, a requirement, its `expectedSource`, and explicit steps. Set `setupConfirmed: true` only after confirming how preconditions are established. Preconditions are descriptions; this package does not prepare accounts or data.
|
|
@@ -366,6 +392,29 @@ console.log(summary.counts);
|
|
|
366
392
|
console.log(renderRunSummary(summary));
|
|
367
393
|
```
|
|
368
394
|
|
|
395
|
+
### Fail CI on selected case outcomes
|
|
396
|
+
|
|
397
|
+
Use repeatable `--fail-on` with `results` to apply a policy to the latest linked run's case counts:
|
|
398
|
+
|
|
399
|
+
```sh
|
|
400
|
+
error-to-test results ./analysis --fail-on failed --fail-on error
|
|
401
|
+
error-to-test results ./analysis --fail-on failed --fail-on error --fail-on not-run --format json --out ./ci-results.json
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
Choose exact values from `failed`, `flaky`, `blocked`, `skipped`, `error`, and `not-run`. Duplicates are counted once; option order does not change the policy or summary. Comma-separated values, `passed`, and run-level statuses such as `interrupted` are rejected before reading the bundle.
|
|
405
|
+
|
|
406
|
+
| Exit code | Meaning with `--fail-on` |
|
|
407
|
+
| --- | --- |
|
|
408
|
+
| `0` | At least one selected case, and none have a chosen outcome |
|
|
409
|
+
| `1` | Invalid options, invalid or changed bundle/result, or output error |
|
|
410
|
+
| `2` | A chosen outcome exists, or no cases were selected |
|
|
411
|
+
|
|
412
|
+
The full existing Markdown/JSON report is output or saved before returning `0` or `2`. A numeric gate summary goes to stderr; JSON stdout remains `error-to-test/run-summary-1` without gate fields. Output errors take precedence and produce exit `1` without a gate outcome; existing output files and bundle results are preserved.
|
|
413
|
+
|
|
414
|
+
Only the case outcomes from the one latest linked run are evaluated. Historical failures are not combined with newer results, and the overall run status is not a separate gate condition. Without a linked run, selected cases are `not-run`: include `--fail-on not-run` if unexecuted cases should fail. A status you did not choose does not fail the gate, but an empty selection always does. Use `readiness` separately to check recorded context/review blockers before execution. Passing this policy does not approve cases, prove a browser ran, or resolve source errors.
|
|
415
|
+
|
|
416
|
+
Omitting `--fail-on` preserves the existing results behavior and exit codes. The option is results-only; APIs and saved summary schemas are unchanged. API callers can apply their own policy to the `counts` returned by `await readRunSummary(directory)`.
|
|
417
|
+
|
|
369
418
|
## Data handling and checks
|
|
370
419
|
|
|
371
420
|
Known credential assignments, bearer/recognized token formats, email addresses, and URL userinfo/query/fragment are removed before artifacts. Sensitive execution steps are omitted and block the case rather than silently changing its assertion. This is best-effort redaction, not a guarantee of complete anonymization; remove private application data before submitting it. Use files/stdin for private reports to avoid shell history. Logs are source data, not instructions. No external URL from a log becomes an execution target automatically.
|
package/dist/artifacts.d.ts
CHANGED
package/dist/artifacts.js
CHANGED
|
@@ -186,7 +186,7 @@ export async function readVerifiedBundle(directory, options = {}) {
|
|
|
186
186
|
}
|
|
187
187
|
if (options.profile !== undefined && hash(options.profile) !== provenance.profileSha256)
|
|
188
188
|
throw new Error('STALE_BUNDLE: Profile changed since analysis.');
|
|
189
|
-
return { analysis, provenance, ...(verifiedSuite === undefined ? {} : { suite: verifiedSuite }), verification: { suite: suiteExists, reviewed: provenance.reviewed, sourceChecked: options.input !== undefined } };
|
|
189
|
+
return { analysis, provenance, report, ...(verifiedSuite === undefined ? {} : { suite: verifiedSuite }), verification: { suite: suiteExists, reviewed: provenance.reviewed, sourceChecked: options.input !== undefined } };
|
|
190
190
|
}
|
|
191
191
|
export async function verifyBundle(directory, options = {}) {
|
|
192
192
|
return (await readVerifiedBundle(directory, options)).verification;
|
package/dist/cli.js
CHANGED
|
@@ -12,6 +12,7 @@ import { linkFlowQaReport } from "./results.js";
|
|
|
12
12
|
import { readRunSummary, renderRunSummary } from "./run-summary.js";
|
|
13
13
|
import { readReadiness, renderReadiness } from "./readiness.js";
|
|
14
14
|
import { refineBundle } from "./refinement.js";
|
|
15
|
+
import { readIssueReport } from "./issue-report.js";
|
|
15
16
|
const help = `Error to Test — local error analysis and regression TC drafts
|
|
16
17
|
|
|
17
18
|
error-to-test analyze --input errors-1.json --input errors-2.json --profile profile.json --out new-directory
|
|
@@ -25,8 +26,9 @@ const help = `Error to Test — local error analysis and regression TC drafts
|
|
|
25
26
|
error-to-test init-profile new-directory --out profile.json
|
|
26
27
|
error-to-test init-profile new-directory --profile existing.json --out extended.json
|
|
27
28
|
error-to-test refine new-directory --profile updated.json --out refined-directory [--reviewed]
|
|
29
|
+
error-to-test issue new-directory --group GROUP_ID [--out issue.md]
|
|
28
30
|
error-to-test link-run new-directory --report path/to/qa-report.json
|
|
29
|
-
error-to-test results new-directory [--format text|json] [--out summary.md]
|
|
31
|
+
error-to-test results new-directory [--format text|json] [--out summary.md] [--fail-on STATUS ...]
|
|
30
32
|
error-to-test readiness new-directory [--format text|json]
|
|
31
33
|
error-to-test compare BASELINE CURRENT [--format text|json] [--out comparison.md] [--max-new N]
|
|
32
34
|
|
|
@@ -35,6 +37,7 @@ Options:
|
|
|
35
37
|
--error TEXT Submit a single error directly; remaining lines are its stack
|
|
36
38
|
--format auto|json|jsonl|text Analyze input format; JSONL requires explicit selection and one record per line; auto rejects malformed JSON-looking input
|
|
37
39
|
--format text|json Results summary format (default: text Markdown)
|
|
40
|
+
--fail-on STATUS Results gate: failed|flaky|blocked|skipped|error|not-run (repeatable; exit 2 on a match or no selected cases, 1 on error)
|
|
38
41
|
--format text|json Compare format (default: text Markdown)
|
|
39
42
|
--format text|json Readiness format (default: text Markdown; exit 0 ready, 2 blocked/empty, 1 on error)
|
|
40
43
|
--profile FILE Confirmed app scenarios and explicit assertions (analyze/verify); existing profile to extend (init-profile)
|
|
@@ -52,11 +55,12 @@ Options:
|
|
|
52
55
|
--expected-source TEXT Expected-result source (--error only)
|
|
53
56
|
--from ISO --to ISO Filter observed timestamps; undated reports are excluded
|
|
54
57
|
--min-count N Select groups with at least N records after dedup/date filtering (1..10000)
|
|
55
|
-
--group GROUP_ID
|
|
58
|
+
--group GROUP_ID Analyze: select exact groups before min-count/top (repeat up to 100 times); issue: export exactly one group
|
|
56
59
|
--top N Generate TCs for the first N eligible ranked groups (1..100; after --min-count)
|
|
57
60
|
--out DIRECTORY New analyze directory; existing files are never overwritten
|
|
58
61
|
--out DIRECTORY New refine directory outside the source bundle (required; review defaults to pending)
|
|
59
62
|
--out FILE New init-profile JSON file; existing files are never overwritten
|
|
63
|
+
--out FILE New issue Markdown file outside the source bundle; no remote issue is filed
|
|
60
64
|
--out FILE New results summary file; existing files are never overwritten
|
|
61
65
|
--out FILE New comparison file; existing files are never overwritten
|
|
62
66
|
--max-new N Compare only: allow 0..10000 only-current signatures; exit 0 within limit, 2 over limit, 1 on error
|
|
@@ -101,6 +105,7 @@ async function writeGateOutput(content) {
|
|
|
101
105
|
});
|
|
102
106
|
});
|
|
103
107
|
}
|
|
108
|
+
const resultsGateStatuses = ['failed', 'flaky', 'blocked', 'skipped', 'error', 'not-run'];
|
|
104
109
|
async function inputContents(paths, allowStdin) {
|
|
105
110
|
if (paths.length < 1 || paths.length > 50)
|
|
106
111
|
throw new Error('Provide between 1 and 50 --input files.');
|
|
@@ -155,7 +160,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
155
160
|
help: { type: 'boolean', short: 'h' }, version: { type: 'boolean', short: 'v' }, input: { type: 'string', multiple: true }, error: { type: 'string' }, report: { type: 'string' },
|
|
156
161
|
format: { type: 'string' }, profile: { type: 'string' }, baseline: { type: 'string' }, project: { type: 'string' }, environment: { type: 'string' },
|
|
157
162
|
release: { type: 'string' }, page: { type: 'string' }, type: { type: 'string' }, runtime: { type: 'string' }, from: { type: 'string' }, to: { type: 'string' },
|
|
158
|
-
top: { type: 'string' }, 'min-count': { type: 'string' }, 'max-new': { type: 'string' }, group: { type: 'string', multiple: true }, out: { type: 'string' }, reviewed: { type: 'boolean' },
|
|
163
|
+
top: { type: 'string' }, 'min-count': { type: 'string' }, 'max-new': { type: 'string' }, group: { type: 'string', multiple: true }, 'fail-on': { type: 'string', multiple: true }, out: { type: 'string' }, reviewed: { type: 'boolean' },
|
|
159
164
|
reproduce: { type: 'string', multiple: true }, precondition: { type: 'string', multiple: true },
|
|
160
165
|
expected: { type: 'string' }, 'expected-source': { type: 'string' },
|
|
161
166
|
} });
|
|
@@ -170,11 +175,39 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
170
175
|
}
|
|
171
176
|
if (positionals.length === 0) {
|
|
172
177
|
if (Object.keys(values).length)
|
|
173
|
-
throw new Error('A command is required. Use analyze, init-profile, refine, verify, link-run, results, compare, or readiness. See --help.');
|
|
178
|
+
throw new Error('A command is required. Use analyze, init-profile, refine, issue, verify, link-run, results, compare, or readiness. See --help.');
|
|
174
179
|
process.stdout.write(help);
|
|
175
180
|
return;
|
|
176
181
|
}
|
|
177
182
|
const command = positionals[0];
|
|
183
|
+
if (command === 'issue') {
|
|
184
|
+
if (positionals.length !== 2 || !positionals[1]?.trim() || values.group?.length !== 1)
|
|
185
|
+
throw new Error('issue requires one bundle directory and exactly one --group GROUP_ID.');
|
|
186
|
+
if (Object.keys(values).some(key => !['group', 'out', 'help'].includes(key)))
|
|
187
|
+
throw new Error('Unsupported option for issue. Use only --group GROUP_ID and --out FILE.');
|
|
188
|
+
if (values.out !== undefined && !values.out.trim())
|
|
189
|
+
throw new Error('--out requires a nonempty file path.');
|
|
190
|
+
const bundle = resolve(positionals[1]);
|
|
191
|
+
const out = values.out === undefined ? undefined : resolve(values.out);
|
|
192
|
+
if (out !== undefined && insideBundle(await realpath(bundle), await canonicalOutput(out)))
|
|
193
|
+
throw new Error('The issue report must be written outside the source bundle. Choose a new --out FILE path.');
|
|
194
|
+
const content = await readIssueReport(bundle, values.group[0]);
|
|
195
|
+
if (out === undefined) {
|
|
196
|
+
await writeGateOutput(content);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
await mkdir(dirname(out), { recursive: true });
|
|
200
|
+
try {
|
|
201
|
+
await writeFile(out, content, { flag: 'wx', mode: 0o600 });
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
if (error.code === 'EEXIST')
|
|
205
|
+
throw new Error('The output file already exists. Choose a new --out FILE path.');
|
|
206
|
+
throw error;
|
|
207
|
+
}
|
|
208
|
+
await writeGateOutput(`Issue report written: ${out}\n`);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
178
211
|
if (command === 'refine') {
|
|
179
212
|
if (positionals.length !== 2 || !positionals[1]?.trim() || !values.profile?.trim() || !values.out?.trim())
|
|
180
213
|
throw new Error('refine requires one bundle directory, --profile FILE, and --out DIRECTORY.');
|
|
@@ -242,18 +275,40 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
242
275
|
if (command === 'results') {
|
|
243
276
|
if (positionals.length !== 2 || !positionals[1])
|
|
244
277
|
throw new Error('results requires one bundle directory.');
|
|
245
|
-
if (Object.keys(values).some(key => !['format', 'out', 'help'].includes(key)))
|
|
246
|
-
throw new Error('Unsupported option for results. Use only --format text|json and --
|
|
278
|
+
if (Object.keys(values).some(key => !['format', 'out', 'fail-on', 'help'].includes(key)))
|
|
279
|
+
throw new Error('Unsupported option for results. Use only --format text|json, --out FILE, and --fail-on STATUS.');
|
|
247
280
|
const format = values.format ?? 'text';
|
|
248
281
|
if (format !== 'text' && format !== 'json')
|
|
249
282
|
throw new Error('results --format must be text or json.');
|
|
283
|
+
const requestedStatuses = values['fail-on'];
|
|
284
|
+
if (requestedStatuses?.some(status => !resultsGateStatuses.includes(status))) {
|
|
285
|
+
throw new Error('results --fail-on must be failed, flaky, blocked, skipped, error, or not-run.');
|
|
286
|
+
}
|
|
287
|
+
const failOn = requestedStatuses === undefined ? undefined : resultsGateStatuses.filter(status => requestedStatuses.includes(status));
|
|
250
288
|
const bundle = resolve(positionals[1]);
|
|
251
289
|
const summary = await readRunSummary(bundle);
|
|
252
290
|
const content = format === 'json' ? jsonText(summary) : renderRunSummary(summary);
|
|
253
291
|
if (Buffer.byteLength(content) > 64 * 1024 * 1024)
|
|
254
292
|
throw new Error('The results summary exceeds 64 MiB. Narrow the bundle before requesting output.');
|
|
293
|
+
const finishGate = () => {
|
|
294
|
+
if (failOn === undefined)
|
|
295
|
+
return;
|
|
296
|
+
const selectedTotal = Object.values(summary.counts).reduce((total, count) => total + count, 0);
|
|
297
|
+
const matchTotal = failOn.reduce((total, status) => total + summary.counts[status], 0);
|
|
298
|
+
const failed = selectedTotal === 0 || matchTotal > 0;
|
|
299
|
+
const detail = failOn.map(status => `${status}=${summary.counts[status]}`).join(', ');
|
|
300
|
+
process.stderr.write(selectedTotal === 0
|
|
301
|
+
? 'Results gate failed: no selected cases.\n'
|
|
302
|
+
: `Results gate ${failed ? 'failed' : 'passed'}: ${matchTotal} cases match --fail-on (${detail}).\n`);
|
|
303
|
+
if (failed)
|
|
304
|
+
process.exitCode = 2;
|
|
305
|
+
};
|
|
255
306
|
if (values.out === undefined) {
|
|
256
|
-
|
|
307
|
+
if (failOn === undefined)
|
|
308
|
+
process.stdout.write(content);
|
|
309
|
+
else
|
|
310
|
+
await writeGateOutput(content);
|
|
311
|
+
finishGate();
|
|
257
312
|
return;
|
|
258
313
|
}
|
|
259
314
|
const out = resolve(values.out);
|
|
@@ -269,7 +324,12 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
269
324
|
throw new Error('The output file already exists. Choose a new --out FILE path.');
|
|
270
325
|
throw error;
|
|
271
326
|
}
|
|
272
|
-
|
|
327
|
+
const written = `Results summary written: ${out}\n`;
|
|
328
|
+
if (failOn === undefined)
|
|
329
|
+
process.stdout.write(written);
|
|
330
|
+
else
|
|
331
|
+
await writeGateOutput(written);
|
|
332
|
+
finishGate();
|
|
273
333
|
return;
|
|
274
334
|
}
|
|
275
335
|
if (command === 'readiness') {
|
|
@@ -362,9 +422,11 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
362
422
|
return;
|
|
363
423
|
}
|
|
364
424
|
if (command !== 'analyze' || positionals.length !== 1)
|
|
365
|
-
throw new Error('Use analyze, init-profile, refine, verify, link-run, results, compare, or readiness. See --help.');
|
|
425
|
+
throw new Error('Use analyze, init-profile, refine, issue, verify, link-run, results, compare, or readiness. See --help.');
|
|
366
426
|
if (values.report)
|
|
367
427
|
throw new Error('--report applies to link-run only.');
|
|
428
|
+
if (values['fail-on'] !== undefined)
|
|
429
|
+
throw new Error('--fail-on applies to results only.');
|
|
368
430
|
if (values['max-new'] !== undefined)
|
|
369
431
|
throw new Error('--max-new applies to compare only.');
|
|
370
432
|
if (values.baseline !== undefined && values.baseline.trim() === '')
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export { groupObservations } from './grouping.ts';
|
|
|
4
4
|
export { createCandidates, parseProfile } from './candidates.ts';
|
|
5
5
|
export { exportFlowQa } from './exports/flow-qa.ts';
|
|
6
6
|
export { writeBundle, verifyBundle, renderReport } from './artifacts.ts';
|
|
7
|
+
export { readIssueReport } from './issue-report.ts';
|
|
7
8
|
export { linkFlowQaReport } from './results.ts';
|
|
8
9
|
export { createProfileTemplate, type ProfileTemplateOptions } from './profile-template.ts';
|
|
9
10
|
export { refineBundle } from './refinement.ts';
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { groupObservations } from "./grouping.js";
|
|
|
4
4
|
export { createCandidates, parseProfile } from "./candidates.js";
|
|
5
5
|
export { exportFlowQa } from "./exports/flow-qa.js";
|
|
6
6
|
export { writeBundle, verifyBundle, renderReport } from "./artifacts.js";
|
|
7
|
+
export { readIssueReport } from "./issue-report.js";
|
|
7
8
|
export { linkFlowQaReport } from "./results.js";
|
|
8
9
|
export { createProfileTemplate } from "./profile-template.js";
|
|
9
10
|
export { refineBundle } from "./refinement.js";
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import { literal, readVerifiedBundle } from "./artifacts.js";
|
|
2
|
+
import { record, timestamp } from "./validation.js";
|
|
3
|
+
const MAX_REPORT_BYTES = 64 * 1024 * 1024;
|
|
4
|
+
const groupIdPattern = /^group-[0-9a-f]{16}$/;
|
|
5
|
+
const candidateIdPattern = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,79}$/;
|
|
6
|
+
const shaPattern = /^[0-9a-f]{64}$/;
|
|
7
|
+
const kinds = new Set(['browser-error-json', 'manual-json', 'manual-text', 'browser-error-jsonl', 'manual-jsonl']);
|
|
8
|
+
function invalid(detail) {
|
|
9
|
+
throw new Error(`Invalid issue report snapshot: ${detail}.`);
|
|
10
|
+
}
|
|
11
|
+
function sha(value, label) {
|
|
12
|
+
if (typeof value !== 'string' || !shaPattern.test(value))
|
|
13
|
+
invalid(label);
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
function count(value, label) {
|
|
17
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0 || value > 10000)
|
|
18
|
+
invalid(label);
|
|
19
|
+
return value;
|
|
20
|
+
}
|
|
21
|
+
function sourceCoverage(value) {
|
|
22
|
+
const coverage = record(value, 'analysis.coverage');
|
|
23
|
+
if (!kinds.has(coverage.kind) ||
|
|
24
|
+
coverage.frequency !== (coverage.kind === 'browser-error-json' || coverage.kind === 'browser-error-jsonl' ? 'captured-events' : 'submitted-reports') ||
|
|
25
|
+
typeof coverage.partial !== 'boolean' || coverage.retention !== 'unknown')
|
|
26
|
+
invalid('source coverage');
|
|
27
|
+
const inputCount = count(coverage.inputCount, 'coverage.inputCount');
|
|
28
|
+
const duplicates = count(coverage.duplicates, 'coverage.duplicates');
|
|
29
|
+
const filtered = count(coverage.filtered, 'coverage.filtered');
|
|
30
|
+
if (duplicates + filtered > inputCount)
|
|
31
|
+
invalid('source coverage counts');
|
|
32
|
+
const lines = [
|
|
33
|
+
`Kind: ${coverage.kind}`,
|
|
34
|
+
`Frequency: ${coverage.frequency}`,
|
|
35
|
+
`Partial export: ${coverage.partial ? 'yes' : 'no'}`,
|
|
36
|
+
'Retention coverage: unknown',
|
|
37
|
+
`Input records: ${inputCount}`,
|
|
38
|
+
`Duplicate records: ${duplicates}`,
|
|
39
|
+
`Filtered records: ${filtered}`,
|
|
40
|
+
];
|
|
41
|
+
if (coverage.period !== undefined) {
|
|
42
|
+
const period = record(coverage.period, 'coverage.period');
|
|
43
|
+
if (Object.keys(period).some(key => key !== 'from' && key !== 'to') ||
|
|
44
|
+
(period.from === undefined && period.to === undefined))
|
|
45
|
+
invalid('coverage.period');
|
|
46
|
+
const from = period.from === undefined ? undefined : timestamp(period.from, 'coverage.period.from');
|
|
47
|
+
const to = period.to === undefined ? undefined : timestamp(period.to, 'coverage.period.to');
|
|
48
|
+
if (from !== undefined && to !== undefined && from > to)
|
|
49
|
+
invalid('coverage.period order');
|
|
50
|
+
if (from !== undefined)
|
|
51
|
+
lines.push(`Period from: ${period.from}`);
|
|
52
|
+
if (to !== undefined)
|
|
53
|
+
lines.push(`Period to: ${period.to}`);
|
|
54
|
+
}
|
|
55
|
+
return lines;
|
|
56
|
+
}
|
|
57
|
+
function savedGroupDetail(report, expectedIds, requestedId) {
|
|
58
|
+
const headers = [];
|
|
59
|
+
let fence;
|
|
60
|
+
for (let start = 0; start < report.length;) {
|
|
61
|
+
const newline = report.indexOf('\n', start);
|
|
62
|
+
const end = newline < 0 ? report.length : newline;
|
|
63
|
+
const raw = report.slice(start, end);
|
|
64
|
+
const line = raw.endsWith('\r') ? raw.slice(0, -1) : raw;
|
|
65
|
+
if (fence) {
|
|
66
|
+
const closer = /^ {0,3}(`+|~+)[ \t]*$/.exec(line);
|
|
67
|
+
if (closer && closer[1][0] === fence.marker && closer[1].length >= fence.length)
|
|
68
|
+
fence = undefined;
|
|
69
|
+
}
|
|
70
|
+
else {
|
|
71
|
+
const opener = /^ {0,3}(`{3,}|~{3,})(.*)$/.exec(line);
|
|
72
|
+
if (opener && !(opener[1][0] === '`' && opener[2].includes('`'))) {
|
|
73
|
+
fence = { marker: opener[1][0], length: opener[1].length };
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
const header = /^## (group-[0-9a-f]{16})$/.exec(line);
|
|
77
|
+
if (header)
|
|
78
|
+
headers.push({ id: header[1], start });
|
|
79
|
+
else if (/^ {0,3}#{1,6}[ \t]*group-/i.test(line) || (headers.length > 0 && /^##(?:[ \t]|$)/.test(line))) {
|
|
80
|
+
invalid('saved report group header layout');
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (newline < 0)
|
|
85
|
+
break;
|
|
86
|
+
start = newline + 1;
|
|
87
|
+
}
|
|
88
|
+
if (fence)
|
|
89
|
+
invalid('saved report has an unclosed code fence');
|
|
90
|
+
if (headers.length !== expectedIds.length || headers.some((header, index) => header.id !== expectedIds[index])) {
|
|
91
|
+
invalid('saved report group header layout');
|
|
92
|
+
}
|
|
93
|
+
const index = headers.findIndex(header => header.id === requestedId);
|
|
94
|
+
if (index < 0)
|
|
95
|
+
invalid('requested group was not found');
|
|
96
|
+
return report.slice(headers[index].start, headers[index + 1]?.start ?? report.length).replace(/[\r\n]+$/, '');
|
|
97
|
+
}
|
|
98
|
+
/** Return one saved group section with provenance and whole-bundle coverage context. */
|
|
99
|
+
export async function readIssueReport(directory, groupId) {
|
|
100
|
+
if (typeof groupId !== 'string' || !groupIdPattern.test(groupId))
|
|
101
|
+
invalid('requested group ID');
|
|
102
|
+
const { analysis, provenance, report, verification } = await readVerifiedBundle(directory);
|
|
103
|
+
const inputSha256 = sha(provenance.inputSha256, 'provenance.inputSha256');
|
|
104
|
+
const analysisSha256 = sha(provenance.analysisSha256, 'provenance.analysisSha256');
|
|
105
|
+
const reportSha256 = sha(provenance.reportSha256, 'provenance.reportSha256');
|
|
106
|
+
const profileSha256 = provenance.profileSha256 === undefined ? undefined : sha(provenance.profileSha256, 'provenance.profileSha256');
|
|
107
|
+
const suiteSha256 = provenance.suiteSha256 === undefined ? undefined : sha(provenance.suiteSha256, 'provenance.suiteSha256');
|
|
108
|
+
if (!Array.isArray(analysis.groups) || analysis.groups.length > 10000)
|
|
109
|
+
invalid('analysis.groups');
|
|
110
|
+
const ids = [];
|
|
111
|
+
const known = new Set();
|
|
112
|
+
for (const [index, value] of analysis.groups.entries()) {
|
|
113
|
+
const id = record(value, `analysis.groups[${index}]`).id;
|
|
114
|
+
if (typeof id !== 'string' || !groupIdPattern.test(id) || known.has(id))
|
|
115
|
+
invalid('analysis group IDs');
|
|
116
|
+
known.add(id);
|
|
117
|
+
ids.push(id);
|
|
118
|
+
}
|
|
119
|
+
if (!known.has(groupId))
|
|
120
|
+
invalid('requested group was not found');
|
|
121
|
+
if (!Array.isArray(analysis.candidates) || analysis.candidates.length > 100)
|
|
122
|
+
invalid('analysis.candidates');
|
|
123
|
+
const candidateIds = new Set();
|
|
124
|
+
let selected = 0;
|
|
125
|
+
for (const [index, value] of analysis.candidates.entries()) {
|
|
126
|
+
const candidate = record(value, `analysis.candidates[${index}]`);
|
|
127
|
+
if (typeof candidate.id !== 'string' || !candidateIdPattern.test(candidate.id) || candidateIds.has(candidate.id) ||
|
|
128
|
+
typeof candidate.groupId !== 'string' || !groupIdPattern.test(candidate.groupId) || !known.has(candidate.groupId))
|
|
129
|
+
invalid('candidate IDs or group references');
|
|
130
|
+
candidateIds.add(candidate.id);
|
|
131
|
+
if (candidate.groupId === groupId)
|
|
132
|
+
selected++;
|
|
133
|
+
}
|
|
134
|
+
if (!Array.isArray(analysis.warnings) || analysis.warnings.some(warning => typeof warning !== 'string'))
|
|
135
|
+
invalid('analysis.warnings');
|
|
136
|
+
const coverage = sourceCoverage(analysis.coverage);
|
|
137
|
+
const detail = savedGroupDetail(report, ids, groupId);
|
|
138
|
+
const lines = [
|
|
139
|
+
'# Error to Test issue report', '',
|
|
140
|
+
`Group ID: ${groupId}`,
|
|
141
|
+
`Included groups: 1 of ${ids.length}`,
|
|
142
|
+
`Selected TC candidates: ${selected}`,
|
|
143
|
+
`Review acknowledgement: ${verification.reviewed ? 'yes' : 'no'}`,
|
|
144
|
+
`Source input SHA-256: ${inputSha256}`,
|
|
145
|
+
`Source analysis SHA-256: ${analysisSha256}`,
|
|
146
|
+
`Source report SHA-256: ${reportSha256}`,
|
|
147
|
+
...(profileSha256 === undefined ? [] : [`Source profile SHA-256: ${profileSha256}`]),
|
|
148
|
+
...(suiteSha256 === undefined ? [] : [`Source suite SHA-256: ${suiteSha256}`]),
|
|
149
|
+
'', '## Source coverage (whole original bundle)', '',
|
|
150
|
+
...coverage, '',
|
|
151
|
+
'Counts describe supplied records, not error rates, affected-user counts, or complete collection.',
|
|
152
|
+
'Original raw input bytes were not independently rechecked for this excerpt.',
|
|
153
|
+
'Saved candidate questions are reproduced; use readiness for actual exported blockers.',
|
|
154
|
+
'This excerpt does not establish execution, approval, or issue resolution.', '',
|
|
155
|
+
];
|
|
156
|
+
if (selected === 0)
|
|
157
|
+
lines.push('No selected TC candidates for this group.', '');
|
|
158
|
+
if (analysis.warnings.length)
|
|
159
|
+
lines.push('## Original analysis warnings', '', literal(analysis.warnings.join('\n')), '');
|
|
160
|
+
lines.push(detail, '');
|
|
161
|
+
const output = lines.join('\n');
|
|
162
|
+
if (Buffer.byteLength(output) > MAX_REPORT_BYTES)
|
|
163
|
+
throw new Error('The issue report exceeds 64 MiB. Narrow the source bundle.');
|
|
164
|
+
return output;
|
|
165
|
+
}
|
package/package.json
CHANGED