@ihyeon/error-to-test 0.2.6 → 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 +17 -1
- package/README.md +27 -1
- package/dist/artifacts.d.ts +1 -0
- package/dist/artifacts.js +1 -1
- package/dist/cli.js +34 -3
- 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
|
|
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.
|
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,6 +26,7 @@ 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
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]
|
|
@@ -53,11 +55,12 @@ Options:
|
|
|
53
55
|
--expected-source TEXT Expected-result source (--error only)
|
|
54
56
|
--from ISO --to ISO Filter observed timestamps; undated reports are excluded
|
|
55
57
|
--min-count N Select groups with at least N records after dedup/date filtering (1..10000)
|
|
56
|
-
--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
|
|
57
59
|
--top N Generate TCs for the first N eligible ranked groups (1..100; after --min-count)
|
|
58
60
|
--out DIRECTORY New analyze directory; existing files are never overwritten
|
|
59
61
|
--out DIRECTORY New refine directory outside the source bundle (required; review defaults to pending)
|
|
60
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
|
|
61
64
|
--out FILE New results summary file; existing files are never overwritten
|
|
62
65
|
--out FILE New comparison file; existing files are never overwritten
|
|
63
66
|
--max-new N Compare only: allow 0..10000 only-current signatures; exit 0 within limit, 2 over limit, 1 on error
|
|
@@ -172,11 +175,39 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
172
175
|
}
|
|
173
176
|
if (positionals.length === 0) {
|
|
174
177
|
if (Object.keys(values).length)
|
|
175
|
-
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.');
|
|
176
179
|
process.stdout.write(help);
|
|
177
180
|
return;
|
|
178
181
|
}
|
|
179
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
|
+
}
|
|
180
211
|
if (command === 'refine') {
|
|
181
212
|
if (positionals.length !== 2 || !positionals[1]?.trim() || !values.profile?.trim() || !values.out?.trim())
|
|
182
213
|
throw new Error('refine requires one bundle directory, --profile FILE, and --out DIRECTORY.');
|
|
@@ -391,7 +422,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
391
422
|
return;
|
|
392
423
|
}
|
|
393
424
|
if (command !== 'analyze' || positionals.length !== 1)
|
|
394
|
-
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.');
|
|
395
426
|
if (values.report)
|
|
396
427
|
throw new Error('--report applies to link-run only.');
|
|
397
428
|
if (values['fail-on'] !== undefined)
|
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