@ihyeon/error-to-test 0.1.15 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ko.md +41 -0
- package/README.md +45 -0
- package/dist/analysis.d.ts +2 -2
- package/dist/analysis.js +5 -1
- package/dist/artifacts.d.ts +2 -2
- package/dist/artifacts.js +29 -5
- package/dist/cli.js +36 -10
- package/dist/comparison.js +2 -2
- package/dist/input-source.d.ts +8 -0
- package/dist/input-source.js +61 -0
- package/dist/input.d.ts +2 -2
- package/dist/input.js +115 -32
- package/dist/types.d.ts +7 -1
- package/docs/releases.md +6 -0
- package/examples/manual.jsonl +3 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -44,6 +44,47 @@ error-to-test analyze --input errors.json --min-count 3 --top 10 --out ./recurri
|
|
|
44
44
|
|
|
45
45
|
JavaScript API에서는 `analyzeErrors(content, { minCount: 3, top: 10 })`으로 같은 기준을 적용합니다.
|
|
46
46
|
|
|
47
|
+
`--input`을 반복하면 **여러 로그 파일을 함께 분석**할 수 있습니다.
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
error-to-test analyze --input morning.json --input afternoon.json --min-count 3 --top 10 --out ./combined
|
|
51
|
+
error-to-test verify ./combined --input morning.json --input afternoon.json
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
최대 50개 파일, 합산 10 MiB·원본 10,000건까지 받습니다. 중복도 한도에 포함합니다. SDK JSON 내보내기·배열끼리, 수동 JSON끼리, 텍스트끼리, 같은 종류의 JSONL끼리처럼 같은 입력 형식끼리 합칩니다. 텍스트는 파일 하나가 보고서 한 건이며, `--format`과 메타데이터·필터는 모든 파일에 적용합니다. 표준 입력(`--input -`)은 `analyze`에서 단독으로 사용하고, `verify`에는 원본 파일을 지정하세요.
|
|
55
|
+
|
|
56
|
+
파일과 표준 입력은 올바른 UTF-8이어야 합니다. 잘못된 바이트가 같은 대체 문자로 변환되어 원본 변경을 놓치지 않도록 해시 계산 전에 잘못된 인코딩을 거부합니다.
|
|
57
|
+
|
|
58
|
+
파일 전체에서 프로젝트·레코드 ID 중복을 먼저 검사한 뒤 필터·그룹 순위·TC 선택을 적용합니다. 동일한 레코드는 한 번만 세며, 같은 ID의 원본 내용이 다르면 정제 후 같아 보이거나 필터로 제외될 데이터여도 거부합니다. 하나라도 부분 내보내기이면 전체 결과에도 부분 입력으로 표시합니다. 건수는 제공한 로그 기준이며 실제 발생률을 의미하지 않습니다.
|
|
59
|
+
|
|
60
|
+
여러 파일의 원본 SHA-256과 UTF-8 바이트 수를 입력 순서대로 `analysis.source.inputs`와 보고서에 남깁니다. 파일명과 원문은 저장하지 않습니다. `source.sha256`은 `JSON.stringify({ schemaVersion: 'error-to-test/inputs-1', inputs })`의 SHA-256이며, 각 항목은 `{ sha256, byteLength }` 순서입니다. 이 목록도 분석 해시로 검증합니다. 원본 확인에는 BOM·공백까지 동일한 모든 파일을 같은 순서로 지정해야 합니다. 단일 입력의 기존 바이트 해시와 결과 형식은 유지합니다.
|
|
61
|
+
|
|
62
|
+
API에서도 `analyzeErrors([firstContent, secondContent], options)`, `parseInput([firstContent, secondContent], options)`, `await analyzeWithBaseline([firstContent, secondContent], baselineDirectory, options)`으로 사용합니다. 원본 검증은 `await verifyBundle(directory, { input: [firstContent, secondContent] })`입니다. 원소 하나의 배열은 문자열 하나와 동일합니다. 프로필 보완·이전 분석 대비 선택에도 같은 입력 순서를 유지하고, 기존 맥락 질문과 검토 조건을 적용합니다.
|
|
63
|
+
|
|
64
|
+
한 줄에 오류 한 건을 저장한 **JSONL 로그**는 `--format jsonl`로 분석합니다.
|
|
65
|
+
|
|
66
|
+
```sh
|
|
67
|
+
error-to-test analyze --input errors.jsonl --format jsonl --out ./jsonl-analysis
|
|
68
|
+
error-to-test analyze --input morning.jsonl --input afternoon.jsonl --format jsonl --min-count 3 --out ./combined-jsonl
|
|
69
|
+
cat errors.jsonl | error-to-test analyze --input - --format jsonl --out ./piped-jsonl
|
|
70
|
+
error-to-test verify ./jsonl-analysis --input errors.jsonl
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
각 줄은 `schemaVersion: 1`인 완전한 SDK 이벤트 객체이거나, `schemaVersion` 없이 `message`를 필수로 가진 수동 오류 객체입니다. 한 파일과 함께 분석할 여러 파일에서 두 종류를 섞을 수 없습니다. 수동 오류는 다음처럼 작성합니다.
|
|
74
|
+
|
|
75
|
+
```jsonl
|
|
76
|
+
{"id":"first","message":"TypeError: item is undefined","page":"/items","runtime":"browser"}
|
|
77
|
+
{"id":"second","message":"TypeError: item is undefined","page":"/items","runtime":"browser"}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
[JSONL 예제](examples/manual.jsonl)는 `node bin/error-to-test.mjs analyze --input examples/manual.jsonl --format jsonl --min-count 2`로 실행합니다. 반복된 묶음 하나를 TC 대상으로 선택하고 전체 두 묶음을 남깁니다. 기대 결과나 실행할 assertion은 추측하지 않습니다.
|
|
81
|
+
|
|
82
|
+
LF·CRLF, 빈 줄, 문자열 안의 이스케이프된 줄바꿈과 파일 맨 앞의 BOM 하나를 지원합니다. 각 유효 줄은 완전한 JSON 객체 하나여야 합니다. 배열·내보내기 래퍼(`events`/`errors`)·줄별 `partial` 정보·알 수 없는 스키마는 거부합니다. 잘못된 줄은 건너뛰지 않고 1부터 시작하는 입력 파일 번호·실제 줄 번호로 알리며, 오류 원문은 진단 메시지에 넣지 않습니다. JSONL 자동 감지는 하지 않으므로 `--format jsonl`을 지정하세요. 기존 `auto`·`json`·`text` 동작은 유지합니다.
|
|
83
|
+
|
|
84
|
+
수집 범위는 `browser-error-jsonl`의 수집 이벤트 또는 `manual-jsonl`의 제출 보고서로 기록합니다. JSONL에는 내보내기의 부분 수집 정보가 없으므로 `partial: false`는 표시가 제공되지 않았다는 의미이며, 수집 완전성·보존 범위 미상 경고를 남깁니다. 완전한 수집을 뜻하지 않습니다. 기존 합산 한도·중복 제거·필터·원본 바이트 해시·프로필·검토 조건을 적용하고, 빈 줄은 건수에 넣지 않습니다.
|
|
85
|
+
|
|
86
|
+
API는 `analyzeErrors(content, { format: 'jsonl' })`이며 여러 파일의 문자열 배열도 지원합니다. 같은 건수 기준의 JSON·JSONL 번들은 `compare`와 `--baseline`으로 연결하며 형식 차이 경고를 유지합니다. 수집 이벤트와 제출 보고서는 비교할 수 없습니다. 기존 0.1.x 번들은 계속 읽을 수 있고, JSONL 번들은 0.2.0 이상이 필요합니다.
|
|
87
|
+
|
|
47
88
|
두 분석 결과는 `compare`로 비교할 수 있습니다. 릴리스가 바뀐 뒤 어떤 오류 서명이 다시 관측됐는지 확인할 때 사용합니다.
|
|
48
89
|
|
|
49
90
|
```sh
|
package/README.md
CHANGED
|
@@ -67,6 +67,51 @@ Use `--min-count N` (1..10,000; default 1) to generate TCs only for groups with
|
|
|
67
67
|
error-to-test analyze --input errors.json --min-count 3 --top 10 --out ./recurring-errors
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
+
### Analyze several log files together
|
|
71
|
+
|
|
72
|
+
Repeat `--input` to combine exports before deduplication, filters, ranking, and TC selection:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
error-to-test analyze --input morning.json --input afternoon.json --min-count 3 --top 10 --out ./combined
|
|
76
|
+
error-to-test verify ./combined --input morning.json --input afternoon.json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Supply up to 50 files with a combined limit of 10 MiB and 10,000 raw records, including duplicates. Files must have the same input kind: SDK JSON exports/arrays together, manual JSON files together, text reports together, or JSONL files of the same record kind together. Each text file is one report. `--format` and metadata/filter options apply to every file. Standard input (`--input -`) must be the only input to `analyze`; `verify` requires original files.
|
|
80
|
+
|
|
81
|
+
Files and standard input must be valid UTF-8. Malformed encoding is rejected before hashing, so distinct invalid bytes cannot silently become the same replacement character.
|
|
82
|
+
|
|
83
|
+
Duplicate project/record IDs are resolved across all files before filtering. Identical records count once; conflicting raw records are rejected even if redaction would make them look alike or filters would exclude them. The partial-export flag is true if any source is partial. Counts describe supplied records, not a global occurrence rate.
|
|
84
|
+
|
|
85
|
+
For multiple files, `analysis.source.inputs` records each original SHA-256 and UTF-8 byte length in the supplied order. Filenames and raw contents are not stored. `source.sha256` is the SHA-256 of `JSON.stringify({ schemaVersion: 'error-to-test/inputs-1', inputs })`, with each descriptor ordered as `{ sha256, byteLength }`. The analysis hash protects the manifest, and the report lists it. Verification requires every original file in the same order, including its BOM and whitespace. A single input retains its original byte hash and existing output contract.
|
|
86
|
+
|
|
87
|
+
The API accepts ordered content arrays: `analyzeErrors([firstContent, secondContent], options)`, `parseInput([firstContent, secondContent], options)`, and `await analyzeWithBaseline([firstContent, secondContent], baselineDirectory, options)`. Verify with `await verifyBundle(directory, { input: [firstContent, secondContent] })`. A one-element array is equivalent to its single string. Profile refinement and baseline selection work with the same ordered inputs and existing review gates.
|
|
88
|
+
|
|
89
|
+
### Read JSONL logs
|
|
90
|
+
|
|
91
|
+
Use explicit `--format jsonl` for one error object per line:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
error-to-test analyze --input errors.jsonl --format jsonl --out ./jsonl-analysis
|
|
95
|
+
error-to-test analyze --input morning.jsonl --input afternoon.jsonl --format jsonl --min-count 3 --out ./combined-jsonl
|
|
96
|
+
cat errors.jsonl | error-to-test analyze --input - --format jsonl --out ./piped-jsonl
|
|
97
|
+
error-to-test verify ./jsonl-analysis --input errors.jsonl
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Each record is either a full Browser Error Log v1 event with `schemaVersion: 1`, or a plain manual error object with a required `message` and no `schemaVersion`. For manual reports:
|
|
101
|
+
|
|
102
|
+
```jsonl
|
|
103
|
+
{"id":"first","message":"TypeError: item is undefined","page":"/items","runtime":"browser"}
|
|
104
|
+
{"id":"second","message":"TypeError: item is undefined","page":"/items","runtime":"browser"}
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
See [examples/manual.jsonl](examples/manual.jsonl) for a complete sample: `node bin/error-to-test.mjs analyze --input examples/manual.jsonl --format jsonl --min-count 2` selects one recurring group and retains both groups for review. No expectation or runnable assertion is invented.
|
|
108
|
+
|
|
109
|
+
LF and CRLF, blank lines, escaped newlines in strings, and one leading file BOM are supported. Each nonblank physical line must contain one complete JSON object. Arrays, export envelopes (`events`/`errors`), record-level `partial` metadata, unknown schema versions, and mixed browser/manual records are rejected. Syntax and record errors identify the 1-based input file and physical line without echoing the record. `auto`, `json`, and `text` retain their existing behavior; JSONL is never auto-detected.
|
|
110
|
+
|
|
111
|
+
Coverage records `browser-error-jsonl` / `captured-events` or `manual-jsonl` / `submitted-reports`. JSONL carries no export coverage metadata: `partial: false` means no partial flag was supplied, and a warning keeps collection completeness and retention unknown. JSONL does not establish complete collection. The same combined byte/file/record limits, raw-record deduplication, filters, original-byte hashes, review gates, and profile rules apply. Empty lines are not records; malformed lines are never silently skipped.
|
|
112
|
+
|
|
113
|
+
Use `analyzeErrors(content, { format: 'jsonl' })` or ordered content arrays in the API. Comparison and `--baseline` can read JSON and JSONL bundles of matching count frequency, preserving the kind-difference warning. Captured events and submitted reports still cannot be compared. Existing 0.1.x bundles remain readable; JSONL bundles require 0.2.0 or newer.
|
|
114
|
+
|
|
70
115
|
### Compare two analyses
|
|
71
116
|
|
|
72
117
|
Compare verified snapshots, including snapshots from different releases:
|
package/dist/analysis.d.ts
CHANGED
|
@@ -5,5 +5,5 @@ export interface AnalyzeOptions extends ParseInputOptions {
|
|
|
5
5
|
top?: number;
|
|
6
6
|
minCount?: number;
|
|
7
7
|
}
|
|
8
|
-
export declare function analyzeErrors(content: string, options?: AnalyzeOptions): Analysis;
|
|
9
|
-
export declare function analyzeWithBaseline(content: string, baselineDirectory: string, options?: AnalyzeOptions): Promise<Analysis>;
|
|
8
|
+
export declare function analyzeErrors(content: string | readonly string[], options?: AnalyzeOptions): Analysis;
|
|
9
|
+
export declare function analyzeWithBaseline(content: string | readonly string[], baselineDirectory: string, options?: AnalyzeOptions): Promise<Analysis>;
|
package/dist/analysis.js
CHANGED
|
@@ -26,7 +26,8 @@ function analyze(content, options, baseline) {
|
|
|
26
26
|
const profile = rawProfile === undefined ? undefined : parseProfile(rawProfile);
|
|
27
27
|
const input = parseInput(content, options);
|
|
28
28
|
const groups = groupObservations(input.observations);
|
|
29
|
-
const source = { sha256: input.sha256, ...(
|
|
29
|
+
const source = { sha256: input.sha256, ...(input.inputs ? { inputs: input.inputs } : {}),
|
|
30
|
+
...(profileSource !== undefined ? { profileSha256: hash(profileSource) } : {}) };
|
|
30
31
|
const warnings = [...input.warnings];
|
|
31
32
|
let selectedGroups = groups;
|
|
32
33
|
let selection;
|
|
@@ -54,6 +55,9 @@ function analyze(content, options, baseline) {
|
|
|
54
55
|
if (comparison.baseline.coverage.period) {
|
|
55
56
|
warnings.push('Baseline date filtering applies only to reports with observed timestamps; undated reports may have been excluded.');
|
|
56
57
|
}
|
|
58
|
+
if (comparison.baseline.coverage.kind === 'browser-error-jsonl' || comparison.baseline.coverage.kind === 'manual-jsonl') {
|
|
59
|
+
warnings.push('Baseline JSONL has no export coverage metadata; partial false means unmarked, and collection completeness and retention are unknown.');
|
|
60
|
+
}
|
|
57
61
|
}
|
|
58
62
|
const eligibleGroups = selectedGroups.filter(group => group.count >= minCount);
|
|
59
63
|
if (eligibleGroups.length < selectedGroups.length)
|
package/dist/artifacts.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare function writeBundle(directory: string, analysis: Analysis, optio
|
|
|
8
8
|
}): Promise<string[]>;
|
|
9
9
|
export declare function readBoundedFile(path: string, maxBytes?: number): Promise<string>;
|
|
10
10
|
export declare function readVerifiedBundle(directory: string, options?: {
|
|
11
|
-
input?: string;
|
|
11
|
+
input?: string | readonly string[];
|
|
12
12
|
profile?: string;
|
|
13
13
|
}): Promise<{
|
|
14
14
|
analysis: Record<string, unknown>;
|
|
@@ -20,7 +20,7 @@ export declare function readVerifiedBundle(directory: string, options?: {
|
|
|
20
20
|
};
|
|
21
21
|
}>;
|
|
22
22
|
export declare function verifyBundle(directory: string, options?: {
|
|
23
|
-
input?: string;
|
|
23
|
+
input?: string | readonly string[];
|
|
24
24
|
profile?: string;
|
|
25
25
|
}): Promise<{
|
|
26
26
|
suite: boolean;
|
package/dist/artifacts.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { mkdir, readFile, stat, writeFile } from 'node:fs/promises';
|
|
2
|
+
import { isUtf8 } from 'node:buffer';
|
|
2
3
|
import { dirname, resolve } from 'node:path';
|
|
3
4
|
import { exportFlowQa } from "./exports/flow-qa.js";
|
|
4
5
|
import { hash, record, text } from "./validation.js";
|
|
5
6
|
import { redactText } from "./redact.js";
|
|
7
|
+
import { inputSource, validateInputSource } from "./input-source.js";
|
|
6
8
|
export function jsonText(value) { return `${JSON.stringify(value, null, 2)}\n`; }
|
|
7
9
|
// Use only after callers have sanitized each untrusted field for its context.
|
|
8
10
|
export function fencedText(value) {
|
|
@@ -22,6 +24,12 @@ export function renderReport(analysis) {
|
|
|
22
24
|
`Duplicate records: ${analysis.coverage.duplicates} · Filtered records: ${analysis.coverage.filtered}`, '',
|
|
23
25
|
'Counts describe the supplied records. They are not error rates, affected-user counts, or proof of complete collection.',
|
|
24
26
|
'Drafts require review. A passing TC proves only its assertions; it does not automatically close the source issue.', ''];
|
|
27
|
+
if (analysis.source.inputs)
|
|
28
|
+
lines.push('## Input files', '', literal([
|
|
29
|
+
`Files: ${analysis.source.inputs.length} · Order: the supplied --input order`,
|
|
30
|
+
'The source SHA-256 commits to the ordered file hashes and byte lengths. Verify with every original file in the same order.',
|
|
31
|
+
...analysis.source.inputs.map((input, index) => `${index + 1}. SHA-256: ${input.sha256} · Bytes: ${input.byteLength}`),
|
|
32
|
+
].join('\n')), '');
|
|
25
33
|
if (analysis.selection)
|
|
26
34
|
lines.push('## Baseline candidate selection', '', literal([
|
|
27
35
|
'Mode: only-current (signatures absent from the supplied baseline)',
|
|
@@ -92,10 +100,12 @@ export async function readBoundedFile(path, maxBytes = 10 * 1024 * 1024) {
|
|
|
92
100
|
const info = await stat(path);
|
|
93
101
|
if (!info.isFile() || info.size > maxBytes)
|
|
94
102
|
throw new Error('Input must be a regular file within the size limit.');
|
|
95
|
-
const content = await readFile(path
|
|
96
|
-
if (
|
|
103
|
+
const content = await readFile(path);
|
|
104
|
+
if (content.length > maxBytes)
|
|
97
105
|
throw new Error('Input exceeded the size limit while reading.');
|
|
98
|
-
|
|
106
|
+
if (!isUtf8(content))
|
|
107
|
+
throw new Error('Input must be valid UTF-8.');
|
|
108
|
+
return content.toString('utf8');
|
|
99
109
|
}
|
|
100
110
|
export async function readVerifiedBundle(directory, options = {}) {
|
|
101
111
|
const root = resolve(directory);
|
|
@@ -120,6 +130,14 @@ export async function readVerifiedBundle(directory, options = {}) {
|
|
|
120
130
|
if (analysis.schemaVersion !== 'error-to-test/analysis-1')
|
|
121
131
|
throw new Error('Unsupported analysis contract.');
|
|
122
132
|
const source = record(analysis.source, 'analysis.source');
|
|
133
|
+
if (source.inputs !== undefined) {
|
|
134
|
+
try {
|
|
135
|
+
validateInputSource(source);
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
throw new Error('STALE_BUNDLE: The ordered input manifest is invalid or does not match the source hash.');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
123
141
|
const flow = await readBoundedFile(resolve(root, 'flows/error-to-test.md'), 8 * 1024 * 1024);
|
|
124
142
|
if (hash(flow) !== provenance.flowSha256 || source.sha256 !== provenance.inputSha256 || source.profileSha256 !== provenance.profileSha256)
|
|
125
143
|
throw new Error('STALE_BUNDLE: Analysis, flow, and provenance no longer match.');
|
|
@@ -141,8 +159,14 @@ export async function readVerifiedBundle(directory, options = {}) {
|
|
|
141
159
|
throw new Error('STALE_BUNDLE: Suite source no longer matches the flow.');
|
|
142
160
|
suiteExists = true;
|
|
143
161
|
}
|
|
144
|
-
if (options.input !== undefined
|
|
145
|
-
|
|
162
|
+
if (options.input !== undefined) {
|
|
163
|
+
const provided = inputSource(options.input);
|
|
164
|
+
const stored = source.inputs;
|
|
165
|
+
const sameFiles = provided.inputs === undefined ? stored === undefined : stored !== undefined &&
|
|
166
|
+
provided.inputs.length === stored.length && provided.inputs.every((input, index) => input.sha256 === stored[index].sha256 && input.byteLength === stored[index].byteLength);
|
|
167
|
+
if (!sameFiles || provided.sha256 !== text(provenance.inputSha256, 'provenance.inputSha256'))
|
|
168
|
+
throw new Error('STALE_BUNDLE: Input changed since analysis. Supply every original file in the same order.');
|
|
169
|
+
}
|
|
146
170
|
if (options.profile !== undefined && hash(options.profile) !== provenance.profileSha256)
|
|
147
171
|
throw new Error('STALE_BUNDLE: Profile changed since analysis.');
|
|
148
172
|
return { analysis, provenance, verification: { suite: suiteExists, reviewed: provenance.reviewed, sourceChecked: options.input !== undefined } };
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseArgs } from 'node:util';
|
|
2
|
+
import { isUtf8 } from 'node:buffer';
|
|
2
3
|
import { randomUUID } from 'node:crypto';
|
|
3
4
|
import { lstat, mkdir, readFile, realpath, writeFile } from 'node:fs/promises';
|
|
4
5
|
import { dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
@@ -11,21 +12,22 @@ import { linkFlowQaReport } from "./results.js";
|
|
|
11
12
|
import { readRunSummary, renderRunSummary } from "./run-summary.js";
|
|
12
13
|
const help = `Error to Test — local error analysis and regression TC drafts
|
|
13
14
|
|
|
14
|
-
error-to-test analyze --input errors.json --profile profile.json --out new-directory
|
|
15
|
+
error-to-test analyze --input errors-1.json --input errors-2.json --profile profile.json --out new-directory
|
|
15
16
|
error-to-test analyze --input errors.json --baseline previous-bundle --out new-directory
|
|
16
17
|
error-to-test analyze --input error.txt --format text --page /items --out new-directory
|
|
18
|
+
error-to-test analyze --input errors.jsonl --format jsonl --out new-directory
|
|
17
19
|
error-to-test analyze --error "TypeError: item is undefined" --page /items --out new-directory
|
|
18
20
|
cat error.txt | error-to-test analyze --input - --format text --out new-directory
|
|
19
|
-
error-to-test verify new-directory [--input errors.json] [--profile profile.json]
|
|
21
|
+
error-to-test verify new-directory [--input errors-1.json --input errors-2.json] [--profile profile.json]
|
|
20
22
|
error-to-test init-profile new-directory --out profile.json
|
|
21
23
|
error-to-test link-run new-directory --report path/to/qa-report.json
|
|
22
24
|
error-to-test results new-directory [--format text|json] [--out summary.md]
|
|
23
25
|
error-to-test compare BASELINE CURRENT [--format text|json] [--out comparison.md]
|
|
24
26
|
|
|
25
27
|
Options:
|
|
26
|
-
--input FILE SDK export, manual JSON, or plain error text (- for stdin)
|
|
28
|
+
--input FILE SDK export, manual JSON, JSONL, or plain error text; repeat for same-format files in order (analyze: sole - for stdin)
|
|
27
29
|
--error TEXT Submit a single error directly; remaining lines are its stack
|
|
28
|
-
--format auto|json|text Analyze input format; auto rejects malformed JSON-looking input
|
|
30
|
+
--format auto|json|jsonl|text Analyze input format; JSONL requires explicit selection and one record per line; auto rejects malformed JSON-looking input
|
|
29
31
|
--format text|json Results summary format (default: text Markdown)
|
|
30
32
|
--format text|json Compare format (default: text Markdown)
|
|
31
33
|
--profile FILE Confirmed app scenarios and explicit assertions (optional)
|
|
@@ -66,7 +68,31 @@ async function stdinText() {
|
|
|
66
68
|
throw new Error('Input must be 10 MiB or smaller.');
|
|
67
69
|
chunks.push(buffer);
|
|
68
70
|
}
|
|
69
|
-
|
|
71
|
+
const input = Buffer.concat(chunks);
|
|
72
|
+
if (!isUtf8(input))
|
|
73
|
+
throw new Error('Input must be valid UTF-8.');
|
|
74
|
+
return input.toString('utf8');
|
|
75
|
+
}
|
|
76
|
+
async function inputContents(paths, allowStdin) {
|
|
77
|
+
if (paths.length < 1 || paths.length > 50)
|
|
78
|
+
throw new Error('Provide between 1 and 50 --input files.');
|
|
79
|
+
if (paths.some(path => !path.trim()))
|
|
80
|
+
throw new Error('--input requires a nonempty file path.');
|
|
81
|
+
if (paths.includes('-')) {
|
|
82
|
+
if (!allowStdin)
|
|
83
|
+
throw new Error('verify --input - is not supported. Supply the original file.');
|
|
84
|
+
if (paths.length !== 1)
|
|
85
|
+
throw new Error('--input - must be the sole input.');
|
|
86
|
+
return stdinText();
|
|
87
|
+
}
|
|
88
|
+
let remaining = 10 * 1024 * 1024;
|
|
89
|
+
const contents = [];
|
|
90
|
+
for (const path of paths) {
|
|
91
|
+
const content = await readBoundedFile(resolve(path), remaining);
|
|
92
|
+
remaining -= Buffer.byteLength(content);
|
|
93
|
+
contents.push(content);
|
|
94
|
+
}
|
|
95
|
+
return contents.length === 1 ? contents[0] : contents;
|
|
70
96
|
}
|
|
71
97
|
async function canonicalOutput(path) {
|
|
72
98
|
let existing = path;
|
|
@@ -94,7 +120,7 @@ function insideBundleResults(bundleRoot, path) {
|
|
|
94
120
|
}
|
|
95
121
|
export async function main(args = process.argv.slice(2)) {
|
|
96
122
|
const { values, positionals } = parseArgs({ args, allowPositionals: true, strict: true, options: {
|
|
97
|
-
help: { type: 'boolean', short: 'h' }, version: { type: 'boolean', short: 'v' }, input: { type: 'string' }, error: { type: 'string' }, report: { type: 'string' },
|
|
123
|
+
help: { type: 'boolean', short: 'h' }, version: { type: 'boolean', short: 'v' }, input: { type: 'string', multiple: true }, error: { type: 'string' }, report: { type: 'string' },
|
|
98
124
|
format: { type: 'string' }, profile: { type: 'string' }, baseline: { type: 'string' }, project: { type: 'string' }, environment: { type: 'string' },
|
|
99
125
|
release: { type: 'string' }, page: { type: 'string' }, type: { type: 'string' }, runtime: { type: 'string' }, from: { type: 'string' }, to: { type: 'string' },
|
|
100
126
|
top: { type: 'string' }, 'min-count': { type: 'string' }, out: { type: 'string' }, reviewed: { type: 'boolean' },
|
|
@@ -234,7 +260,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
234
260
|
if (Object.keys(values).some(key => !['input', 'profile', 'help'].includes(key)))
|
|
235
261
|
throw new Error('Unsupported option for verify.');
|
|
236
262
|
const result = await verifyBundle(resolve(positionals[1]), {
|
|
237
|
-
...(values.input ? { input: await
|
|
263
|
+
...(values.input ? { input: await inputContents(values.input, false) } : {}),
|
|
238
264
|
...(values.profile ? { profile: await readBoundedFile(resolve(values.profile), 1024 * 1024) } : {}),
|
|
239
265
|
});
|
|
240
266
|
process.stdout.write(`Bundle verified. Suite: ${result.suite ? 'present' : 'none'}; review: ${result.reviewed ? 'acknowledged' : 'pending'}; original input: ${result.sourceChecked ? 'checked' : 'not supplied'}.\n`);
|
|
@@ -249,8 +275,8 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
249
275
|
if ((values.input === undefined) === (values.error === undefined))
|
|
250
276
|
throw new Error('Provide exactly one of --input or --error.');
|
|
251
277
|
const format = values.format ?? 'auto';
|
|
252
|
-
if (format !== 'auto' && format !== 'json' && format !== 'text')
|
|
253
|
-
throw new Error('--format must be auto, json, or text.');
|
|
278
|
+
if (format !== 'auto' && format !== 'json' && format !== 'jsonl' && format !== 'text')
|
|
279
|
+
throw new Error('--format must be auto, json, jsonl, or text.');
|
|
254
280
|
const types = ['javascript', 'promise', 'react', 'console', 'http', 'network', 'manual'];
|
|
255
281
|
if (values.type !== undefined && !types.includes(values.type))
|
|
256
282
|
throw new Error('--type is not supported.');
|
|
@@ -275,7 +301,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
275
301
|
else {
|
|
276
302
|
if (values.reproduce || values.precondition || values.expected || values['expected-source'])
|
|
277
303
|
throw new Error('Reported context options require --error. Use manual JSON or a profile for file input.');
|
|
278
|
-
content =
|
|
304
|
+
content = await inputContents(values.input, true);
|
|
279
305
|
}
|
|
280
306
|
const options = {
|
|
281
307
|
format: inputFormat, ...(values.profile ? { profile: await readBoundedFile(resolve(values.profile), 1024 * 1024) } : {}),
|
package/dist/comparison.js
CHANGED
|
@@ -4,7 +4,7 @@ import { hash, record, timestamp } from "./validation.js";
|
|
|
4
4
|
const statuses = ['only-current', 'both', 'only-baseline'];
|
|
5
5
|
const runtimes = ['browser', 'webview-ios', 'webview-android', 'unknown'];
|
|
6
6
|
const types = ['javascript', 'promise', 'react', 'console', 'http', 'network', 'manual'];
|
|
7
|
-
const kinds = ['browser-error-json', 'manual-json', 'manual-text'];
|
|
7
|
+
const kinds = ['browser-error-json', 'browser-error-jsonl', 'manual-json', 'manual-jsonl', 'manual-text'];
|
|
8
8
|
const normalizedMax = 128 * 1024;
|
|
9
9
|
const hex64 = /^[0-9a-f]{64}$/;
|
|
10
10
|
const groupId = /^group-[0-9a-f]{16}$/;
|
|
@@ -24,7 +24,7 @@ function coverage(value, label) {
|
|
|
24
24
|
if (!kinds.includes(raw.kind))
|
|
25
25
|
throw new Error(`${label}.kind is unsupported.`);
|
|
26
26
|
const kind = raw.kind;
|
|
27
|
-
const frequency = kind === 'browser-error-json' ? 'captured-events' : 'submitted-reports';
|
|
27
|
+
const frequency = kind === 'browser-error-json' || kind === 'browser-error-jsonl' ? 'captured-events' : 'submitted-reports';
|
|
28
28
|
if (raw.frequency !== frequency)
|
|
29
29
|
throw new Error(`${label}.frequency is incompatible with kind.`);
|
|
30
30
|
if (typeof raw.partial !== 'boolean' || raw.retention !== 'unknown')
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { InputFileFingerprint } from './types.ts';
|
|
2
|
+
/** Internal source fingerprint used by the parser and bundle verifier. */
|
|
3
|
+
export declare function inputSource(content: string | readonly string[]): {
|
|
4
|
+
sha256: string;
|
|
5
|
+
inputs?: InputFileFingerprint[];
|
|
6
|
+
};
|
|
7
|
+
/** Validate persisted source metadata without reading or retaining original input. */
|
|
8
|
+
export declare function validateInputSource(value: unknown): void;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
const MAX_FILES = 50;
|
|
3
|
+
const MAX_BYTES = 10 * 1024 * 1024;
|
|
4
|
+
const SHA256 = /^[a-f0-9]{64}$/;
|
|
5
|
+
function hash(value) {
|
|
6
|
+
return createHash('sha256').update(value).digest('hex');
|
|
7
|
+
}
|
|
8
|
+
function descriptor(inputs) {
|
|
9
|
+
return JSON.stringify({ schemaVersion: 'error-to-test/inputs-1', inputs });
|
|
10
|
+
}
|
|
11
|
+
/** Internal source fingerprint used by the parser and bundle verifier. */
|
|
12
|
+
export function inputSource(content) {
|
|
13
|
+
if (typeof content !== 'string' && !Array.isArray(content))
|
|
14
|
+
throw new Error('Input must be a string or an array of strings.');
|
|
15
|
+
const files = typeof content === 'string' ? [content] : content;
|
|
16
|
+
if (files.length < 1 || files.length > MAX_FILES)
|
|
17
|
+
throw new Error('Input must contain 1 to 50 files.');
|
|
18
|
+
let totalBytes = 0;
|
|
19
|
+
const inputs = files.map((file) => {
|
|
20
|
+
if (typeof file !== 'string')
|
|
21
|
+
throw new Error('Every input file must be a string.');
|
|
22
|
+
const byteLength = Buffer.byteLength(file, 'utf8');
|
|
23
|
+
totalBytes += byteLength;
|
|
24
|
+
if (totalBytes > MAX_BYTES)
|
|
25
|
+
throw new Error('Input exceeds 10 MiB.');
|
|
26
|
+
return { sha256: hash(file), byteLength };
|
|
27
|
+
});
|
|
28
|
+
return inputs.length === 1 ? { sha256: inputs[0].sha256 } : { sha256: hash(descriptor(inputs)), inputs };
|
|
29
|
+
}
|
|
30
|
+
/** Validate persisted source metadata without reading or retaining original input. */
|
|
31
|
+
export function validateInputSource(value) {
|
|
32
|
+
const invalid = () => { throw new Error('STALE_BUNDLE: Invalid input source fingerprint.'); };
|
|
33
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
34
|
+
invalid();
|
|
35
|
+
const source = value;
|
|
36
|
+
if (typeof source.sha256 !== 'string' || !SHA256.test(source.sha256))
|
|
37
|
+
invalid();
|
|
38
|
+
if (source.inputs === undefined)
|
|
39
|
+
return;
|
|
40
|
+
const rawInputs = source.inputs;
|
|
41
|
+
if (!Array.isArray(rawInputs))
|
|
42
|
+
throw new Error('STALE_BUNDLE: Invalid input source fingerprint.');
|
|
43
|
+
if (rawInputs.length < 2 || rawInputs.length > MAX_FILES)
|
|
44
|
+
invalid();
|
|
45
|
+
let totalBytes = 0;
|
|
46
|
+
const inputs = rawInputs.map((value) => {
|
|
47
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value))
|
|
48
|
+
invalid();
|
|
49
|
+
const file = value;
|
|
50
|
+
if (typeof file.sha256 !== 'string' || !SHA256.test(file.sha256) ||
|
|
51
|
+
typeof file.byteLength !== 'number' || !Number.isInteger(file.byteLength) ||
|
|
52
|
+
file.byteLength < 0 || file.byteLength > MAX_BYTES)
|
|
53
|
+
invalid();
|
|
54
|
+
totalBytes += file.byteLength;
|
|
55
|
+
if (totalBytes > MAX_BYTES)
|
|
56
|
+
invalid();
|
|
57
|
+
return { sha256: file.sha256, byteLength: file.byteLength };
|
|
58
|
+
});
|
|
59
|
+
if (hash(descriptor(inputs)) !== source.sha256)
|
|
60
|
+
invalid();
|
|
61
|
+
}
|
package/dist/input.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { EventType, ParsedInput, Runtime } from './types.ts';
|
|
2
2
|
export interface ParseInputOptions {
|
|
3
|
-
format?: 'auto' | 'json' | 'text';
|
|
3
|
+
format?: 'auto' | 'json' | 'text' | 'jsonl';
|
|
4
4
|
project?: string;
|
|
5
5
|
environment?: string;
|
|
6
6
|
release?: string;
|
|
@@ -10,4 +10,4 @@ export interface ParseInputOptions {
|
|
|
10
10
|
from?: string;
|
|
11
11
|
to?: string;
|
|
12
12
|
}
|
|
13
|
-
export declare function parseInput(content: string, options?: ParseInputOptions): ParsedInput;
|
|
13
|
+
export declare function parseInput(content: string | readonly string[], options?: ParseInputOptions): ParsedInput;
|
package/dist/input.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { createHash } from 'node:crypto';
|
|
2
1
|
import { record, text, optionalText, strings, timestamp, parseWebSteps, hash } from "./validation.js";
|
|
3
2
|
import { redactText, safeUrl } from "./redact.js";
|
|
3
|
+
import { inputSource } from "./input-source.js";
|
|
4
4
|
const TYPES = new Set(['javascript', 'promise', 'react', 'console', 'http', 'network', 'manual']);
|
|
5
5
|
const RUNTIMES = new Set(['browser', 'webview-ios', 'webview-android', 'unknown']);
|
|
6
|
-
const MAX_BYTES = 10 * 1024 * 1024;
|
|
7
6
|
const MAX_RECORDS = 10_000;
|
|
8
7
|
const LOGGER_PREFIX = /^\[(?:ERROR|WARN|WARNING|INFO|DEBUG|TRACE|FATAL|vite|timestamp|\d{4}-\d{2}-\d{2}(?:[ T]\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})?)?|\d{2}:\d{2}:\d{2})\][ \t]+\S/i;
|
|
9
8
|
function eventType(value, label) {
|
|
@@ -152,24 +151,55 @@ function manualError(value, index, defaults) {
|
|
|
152
151
|
...(!alteredExpected && expectedSource !== undefined ? { expectedSource } : {}), steps: stepResult.steps,
|
|
153
152
|
};
|
|
154
153
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
const
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
166
|
-
|
|
154
|
+
function jsonlError(fileIndex, lineNumber, reason) {
|
|
155
|
+
return new Error(`JSONL input file ${fileIndex}, line ${lineNumber}: ${reason}`);
|
|
156
|
+
}
|
|
157
|
+
function decodeJsonl(content, fileIndex, remainingRecords) {
|
|
158
|
+
// A single file-leading BOM affects parsing only; inputSource hashes the original content.
|
|
159
|
+
const lines = content.replace(/^\uFEFF/, '').split('\n');
|
|
160
|
+
const raw = [];
|
|
161
|
+
const lineNumbers = [];
|
|
162
|
+
let kind;
|
|
163
|
+
for (const [index, line] of lines.entries()) {
|
|
164
|
+
if (/^[ \t\r]*$/.test(line))
|
|
165
|
+
continue;
|
|
166
|
+
const lineNumber = index + 1;
|
|
167
|
+
if (raw.length >= remainingRecords)
|
|
168
|
+
throw new Error('Input exceeds 10000 records');
|
|
169
|
+
let item;
|
|
170
|
+
try {
|
|
171
|
+
item = JSON.parse(line);
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
throw jsonlError(fileIndex, lineNumber, 'Malformed JSON record.');
|
|
175
|
+
}
|
|
176
|
+
if (item === null || typeof item !== 'object' || Array.isArray(item)) {
|
|
177
|
+
throw jsonlError(fileIndex, lineNumber, 'Record must be a JSON object.');
|
|
178
|
+
}
|
|
179
|
+
const value = item;
|
|
180
|
+
if (Object.hasOwn(value, 'events') || Object.hasOwn(value, 'errors') || Object.hasOwn(value, 'partial')) {
|
|
181
|
+
throw jsonlError(fileIndex, lineNumber, 'Export envelopes and coverage metadata are unsupported.');
|
|
182
|
+
}
|
|
183
|
+
const lineKind = Object.hasOwn(value, 'schemaVersion') ? 'browser-error-jsonl' : 'manual-jsonl';
|
|
184
|
+
if (lineKind === 'browser-error-jsonl' && value.schemaVersion !== 1) {
|
|
185
|
+
throw jsonlError(fileIndex, lineNumber, 'Unsupported schemaVersion.');
|
|
186
|
+
}
|
|
187
|
+
if (kind !== undefined && kind !== lineKind) {
|
|
188
|
+
throw jsonlError(fileIndex, lineNumber, 'Mixed browser and manual records are unsupported.');
|
|
189
|
+
}
|
|
190
|
+
kind = lineKind;
|
|
191
|
+
raw.push(item);
|
|
192
|
+
lineNumbers.push(lineNumber);
|
|
193
|
+
}
|
|
194
|
+
if (kind === undefined)
|
|
195
|
+
throw new Error(`JSONL input file ${fileIndex}: Input has no records.`);
|
|
196
|
+
return { kind, partial: false, raw, lineNumbers };
|
|
197
|
+
}
|
|
198
|
+
function decodeDocument(content, format, fileIndex, remainingRecords) {
|
|
199
|
+
if (format === 'jsonl')
|
|
200
|
+
return decodeJsonl(content, fileIndex, remainingRecords);
|
|
167
201
|
const trimmed = content.trimStart();
|
|
168
202
|
const isJson = format === 'json' || (format === 'auto' && /^[\[{]/.test(trimmed) && !LOGGER_PREFIX.test(trimmed));
|
|
169
|
-
let observations;
|
|
170
|
-
let kind;
|
|
171
|
-
let partial = false;
|
|
172
|
-
let raw;
|
|
173
203
|
if (isJson) {
|
|
174
204
|
let parsed;
|
|
175
205
|
// Ignore a file's BOM only while parsing; provenance hashes the original content.
|
|
@@ -179,6 +209,9 @@ export function parseInput(content, options = {}) {
|
|
|
179
209
|
catch {
|
|
180
210
|
throw new Error('Malformed JSON input');
|
|
181
211
|
}
|
|
212
|
+
let kind;
|
|
213
|
+
let partial = false;
|
|
214
|
+
let raw;
|
|
182
215
|
if (Array.isArray(parsed)) {
|
|
183
216
|
kind = 'browser-error-json';
|
|
184
217
|
raw = parsed;
|
|
@@ -205,19 +238,60 @@ export function parseInput(content, options = {}) {
|
|
|
205
238
|
}
|
|
206
239
|
if (raw.length === 0)
|
|
207
240
|
throw new Error('Input has no records');
|
|
208
|
-
|
|
209
|
-
throw new Error('Input exceeds 10000 records');
|
|
210
|
-
observations = raw.map((item, index) => kind === 'browser-error-json' ? browserEvent(item, index) : manualError(item, index, options));
|
|
241
|
+
return { kind, partial, raw };
|
|
211
242
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
raw
|
|
243
|
+
const lines = content.trim().split(/\r?\n/);
|
|
244
|
+
const message = lines.shift().trim();
|
|
245
|
+
if (!message)
|
|
246
|
+
throw new Error('Error message is empty');
|
|
247
|
+
// Text is one logical report. Its canonical raw identity must not depend on
|
|
248
|
+
// whitespace outside the parsed message and stack.
|
|
249
|
+
return { kind: 'manual-text', partial: false,
|
|
250
|
+
raw: [{ message, ...(lines.length ? { stack: lines.join('\n') } : {}) }] };
|
|
251
|
+
}
|
|
252
|
+
export function parseInput(content, options = {}) {
|
|
253
|
+
const source = inputSource(content);
|
|
254
|
+
const files = typeof content === 'string' ? [content] : content;
|
|
255
|
+
const format = options.format ?? 'auto';
|
|
256
|
+
if (format !== 'jsonl' && files.some(file => !file.trim()))
|
|
257
|
+
throw new Error('Input is empty');
|
|
258
|
+
const from = options.from === undefined ? undefined : timestamp(options.from, 'from');
|
|
259
|
+
const to = options.to === undefined ? undefined : timestamp(options.to, 'to');
|
|
260
|
+
if (from && to && from > to)
|
|
261
|
+
throw new Error('from must not exceed to');
|
|
262
|
+
if (!['auto', 'json', 'text', 'jsonl'].includes(format))
|
|
263
|
+
throw new Error('Invalid input format');
|
|
264
|
+
let kind;
|
|
265
|
+
let partial = false;
|
|
266
|
+
const raw = [];
|
|
267
|
+
const jsonlLocations = [];
|
|
268
|
+
for (const [fileIndex, file] of files.entries()) {
|
|
269
|
+
const document = decodeDocument(file, format, fileIndex + 1, MAX_RECORDS - raw.length);
|
|
270
|
+
if (kind !== undefined && document.kind !== kind) {
|
|
271
|
+
if (format === 'jsonl')
|
|
272
|
+
throw jsonlError(fileIndex + 1, document.lineNumbers[0], 'Input files must have the same source kind.');
|
|
273
|
+
throw new Error('Input files must have the same source kind.');
|
|
274
|
+
}
|
|
275
|
+
kind = document.kind;
|
|
276
|
+
partial ||= document.partial;
|
|
277
|
+
if (raw.length + document.raw.length > MAX_RECORDS)
|
|
278
|
+
throw new Error('Input exceeds 10000 records');
|
|
279
|
+
raw.push(...document.raw);
|
|
280
|
+
if (document.lineNumbers)
|
|
281
|
+
jsonlLocations.push(...document.lineNumbers.map(lineNumber => ({ fileIndex: fileIndex + 1, lineNumber })));
|
|
220
282
|
}
|
|
283
|
+
const browser = kind === 'browser-error-json' || kind === 'browser-error-jsonl';
|
|
284
|
+
const observations = raw.map((item, index) => {
|
|
285
|
+
if (format !== 'jsonl')
|
|
286
|
+
return browser ? browserEvent(item, index) : manualError(item, index, options);
|
|
287
|
+
try {
|
|
288
|
+
return browser ? browserEvent(item, index) : manualError(item, index, options);
|
|
289
|
+
}
|
|
290
|
+
catch {
|
|
291
|
+
const location = jsonlLocations[index];
|
|
292
|
+
throw jsonlError(location.fileIndex, location.lineNumber, browser ? 'Invalid browser record.' : 'Invalid manual record.');
|
|
293
|
+
}
|
|
294
|
+
});
|
|
221
295
|
const inputCount = raw.length;
|
|
222
296
|
const seen = new Map();
|
|
223
297
|
const unique = [];
|
|
@@ -228,8 +302,13 @@ export function parseInput(content, options = {}) {
|
|
|
228
302
|
const source = canonical(raw[index]);
|
|
229
303
|
const previous = seen.get(key);
|
|
230
304
|
if (previous !== undefined) {
|
|
231
|
-
if (previous !== source)
|
|
305
|
+
if (previous !== source) {
|
|
306
|
+
if (format === 'jsonl') {
|
|
307
|
+
const location = jsonlLocations[index];
|
|
308
|
+
throw jsonlError(location.fileIndex, location.lineNumber, 'Conflicting duplicate ID.');
|
|
309
|
+
}
|
|
232
310
|
throw new Error(`Conflicting duplicate ID: ${item.id}`);
|
|
311
|
+
}
|
|
233
312
|
duplicates++;
|
|
234
313
|
}
|
|
235
314
|
else {
|
|
@@ -238,6 +317,10 @@ export function parseInput(content, options = {}) {
|
|
|
238
317
|
}
|
|
239
318
|
}
|
|
240
319
|
const warnings = [];
|
|
320
|
+
if (source.inputs)
|
|
321
|
+
warnings.push(`Combined ${source.inputs.length} input files in supplied order; counts describe the supplied records across files, not global rates.`);
|
|
322
|
+
if (format === 'jsonl')
|
|
323
|
+
warnings.push('JSONL has no export coverage metadata; collection completeness and retention are unknown.');
|
|
241
324
|
if (partial)
|
|
242
325
|
warnings.push('Source export is partial; observed counts may be incomplete.');
|
|
243
326
|
if (duplicates)
|
|
@@ -263,9 +346,9 @@ export function parseInput(content, options = {}) {
|
|
|
263
346
|
warnings.push('Undated manual reports were excluded by date filters.');
|
|
264
347
|
return {
|
|
265
348
|
observations: selected,
|
|
266
|
-
coverage: { kind, frequency:
|
|
349
|
+
coverage: { kind: kind, frequency: browser ? 'captured-events' : 'submitted-reports',
|
|
267
350
|
partial, inputCount, duplicates, filtered, retention: 'unknown',
|
|
268
351
|
...(from || to ? { period: { ...(from ? { from } : {}), ...(to ? { to } : {}) } } : {}) },
|
|
269
|
-
sha256:
|
|
352
|
+
sha256: source.sha256, ...(source.inputs ? { inputs: source.inputs } : {}), warnings,
|
|
270
353
|
};
|
|
271
354
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -66,7 +66,7 @@ export interface ErrorObservation {
|
|
|
66
66
|
steps: WebStep[];
|
|
67
67
|
}
|
|
68
68
|
export interface SourceCoverage {
|
|
69
|
-
kind: 'browser-error-json' | 'manual-json' | 'manual-text';
|
|
69
|
+
kind: 'browser-error-json' | 'manual-json' | 'manual-text' | 'browser-error-jsonl' | 'manual-jsonl';
|
|
70
70
|
frequency: 'captured-events' | 'submitted-reports';
|
|
71
71
|
partial: boolean;
|
|
72
72
|
inputCount: number;
|
|
@@ -78,10 +78,15 @@ export interface SourceCoverage {
|
|
|
78
78
|
to?: string;
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
|
+
export interface InputFileFingerprint {
|
|
82
|
+
sha256: string;
|
|
83
|
+
byteLength: number;
|
|
84
|
+
}
|
|
81
85
|
export interface ParsedInput {
|
|
82
86
|
observations: ErrorObservation[];
|
|
83
87
|
coverage: SourceCoverage;
|
|
84
88
|
sha256: string;
|
|
89
|
+
inputs?: InputFileFingerprint[];
|
|
85
90
|
warnings: string[];
|
|
86
91
|
}
|
|
87
92
|
export interface IssueGroup {
|
|
@@ -157,6 +162,7 @@ export interface Analysis {
|
|
|
157
162
|
schemaVersion: 'error-to-test/analysis-1';
|
|
158
163
|
source: {
|
|
159
164
|
sha256: string;
|
|
165
|
+
inputs?: InputFileFingerprint[];
|
|
160
166
|
profileSha256?: string;
|
|
161
167
|
};
|
|
162
168
|
coverage: SourceCoverage;
|
package/docs/releases.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
Package: `@ihyeon/error-to-test` · Repository: [hyeonse-swing/error-to-test](https://github.com/hyeonse-swing/error-to-test) · Workflow: `.github/workflows/ci.yml`.
|
|
4
4
|
|
|
5
|
+
## 0.2.0
|
|
6
|
+
|
|
7
|
+
JSONL inputs add explicit `--format jsonl`, line-numbered validation, and browser/manual record kinds while preserving original bytes, multi-file provenance, comparison/baseline selection, and review gates. Existing 0.1.x bundles and formats remain supported. Integrations with exhaustive `SourceCoverage.kind` handling should include `browser-error-jsonl` and `manual-jsonl`.
|
|
8
|
+
|
|
9
|
+
This minor release sets both package manifests to `0.2.0` before verification. The workflow publishes that exact source commit without creating an additional patch bump.
|
|
10
|
+
|
|
5
11
|
## Automatic publication
|
|
6
12
|
|
|
7
13
|
Pull requests and main pushes verify the package on Ubuntu and macOS. A verified main push then prepares an immutable release source:
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
{"id":"jsonl-1","project":"demo","environment":"test","release":"r1","runtime":"browser","type":"javascript","page":"/items","message":"TypeError: item is undefined","stack":" at render (/app.js:10:2)"}
|
|
2
|
+
{"id":"jsonl-2","project":"demo","environment":"test","release":"r1","runtime":"browser","type":"javascript","page":"/items","message":"TypeError: item is undefined","stack":" at render (/app.js:10:2)"}
|
|
3
|
+
{"id":"jsonl-3","project":"demo","environment":"test","release":"r1","runtime":"browser","type":"javascript","page":"/settings","message":"ReferenceError: settings is not defined","stack":" at showSettings (/settings.js:4:1)"}
|
package/package.json
CHANGED