@ihyeon/error-to-test 0.4.3 → 0.4.4

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 CHANGED
@@ -285,7 +285,7 @@ Flow QA 설치와 실행 대상 설정은 별도로 필요합니다. 위 `flows/
285
285
 
286
286
  실행 후 `node bin/error-to-test.mjs link-run .error-to-test/reviewed --report /path/to/qa-report.json`으로 결과를 원래 오류 묶음에 연결할 수 있습니다. suite 해시가 일치해야 하며 전체 실행은 모든 case ID를 포함해야 합니다. 일부 케이스만 실행한 Flow QA 보고서는 `selection.caseIds`가 보고된 케이스와 정확히 일치하고 `selection.totalCases`가 전체 suite 크기와 일치할 때 연결합니다. 알 수 없는·중복된 ID와 선택 선언 없는 누락은 거부합니다. 결과는 `results/<runId>.json`에 저장합니다. 원본 e2e 리포트 대신 Flow QA가 정리한 `report-1`을 사용하세요.
287
287
 
288
- 선택 실행 결과에는 `selection: { mode: 'selected', totalCases, selectedCaseIds }`를 기록하며 요약의 최신 실행에도 포함합니다. 기존 전체 실행 결과는 계속 읽을 수 있고, 새 선택 실행 결과는 이 버전 이상의 reader가 필요합니다. 이전 reader는 추가 필드를 거부합니다. 최신 실행에서 빠진 케이스는 과거에 통과했어도 `not-run`이며, 미실행을 CI 실패로 처리하려면 `results --fail-on not-run`을 사용하세요.
288
+ 전체 실행 상태가 `passed`라면 보고된 모든 케이스도 `passed`여야 합니다. 모순된 보고서는 연결하지 않습니다. 선택 실행 결과에는 `selection: { mode: 'selected', totalCases, selectedCaseIds }`를 기록하며 요약의 최신 실행에도 포함합니다. 기존 전체 실행 결과는 계속 읽을 수 있고, 새 선택 실행 결과는 이 버전 이상의 reader가 필요합니다. 이전 reader는 추가 필드를 거부합니다. 최신 실행에서 빠진 케이스는 과거에 통과했어도 `not-run`이며, 미실행을 CI 실패로 처리하려면 `results --fail-on not-run`을 사용하세요.
289
289
 
290
290
  보고서에 필요한 정보가 모두 있는 웹·모바일 실행 대상이 있으면 정제한 `targetName`과 `targetFingerprint`를 저장합니다. fingerprint는 Flow QA와 동일하게 웹 `{ kind: 'web', url }`, 모바일 `{ kind: 'mobile', platform, bundleId, device }`를 이 순서로 직렬화한 SHA-256입니다. 이름이 같아도 대상 정보가 다르면 서로 다른 실행으로 구별합니다. 대상 원본 값은 결과에 복사하지 않고 이름과 사유에서도 제거합니다. 다만 fingerprint는 대상을 아는 사람이 다시 계산해 대조할 수 있는 **안정적인 식별자이며 익명화가 아닙니다**. 이전 reader는 새 필드를 거부합니다. fingerprint가 없는 기존 전체·선택 실행 결과는 계속 읽지만 특정 대상 범위에는 넣지 않습니다. Flow QA가 초기 오류·중단을 빈 웹 URL로 보고하거나, 기기 지정이 없어 차단·중단된 모바일 실행을 빈 device로 보고한 경우에는 정제한 이름만 보존하고 fingerprint를 만들지 않습니다.
291
291
 
@@ -304,6 +304,8 @@ error-to-test results .error-to-test/reviewed --target-fingerprint "$TARGET_FING
304
304
 
305
305
  출력 전에 번들과 연결 결과의 형식·원본/suite 해시·case/group/event 연결·상태·시각을 검사합니다. 오래된 결과라도 잘못된 JSON이 있으면 실패하며, 기존 산출물과 결과 파일은 수정하지 않습니다. 결과 폴더는 최대 1,000개 항목, 각 JSON은 2 MiB, 전체 결과는 64 MiB까지 지원합니다. 다른 확장자의 부수 파일은 무시하고 잘못된 JSON 이름·심볼릭 링크·일반 파일이 아닌 결과·한도 초과는 거부합니다. `--out`은 번들의 `results` 폴더 밖에 있는 새 파일만 허용합니다.
306
306
 
307
+ 이전에 저장한 결과에서 상태 모순 오류가 나면 원본 번들과 보고서를 보관하세요. 번들의 복사본에서 오류가 지목한 파일을 `results/` 밖으로 옮기고, 원래 Flow QA 보고서의 전체 상태와 케이스 결과가 일치하면 다시 연결하세요. 원본 보고서에도 모순이 있으면 테스트를 다시 실행해 새 결과를 연결하세요. 새 결과를 저장하는 파일시스템은 하드 링크를 지원해야 합니다.
308
+
307
309
  API에서는 `await readRunSummary(directory)`로 전체 요약을 읽고 `renderRunSummary(summary)`로 Markdown을 만듭니다. 대상별 조회는 `await readRunSummary(directory, { targetFingerprint: summary.targets[0].fingerprint })`를 사용합니다. `targets`가 비어 있으면 지정할 수 있는 대상이 없습니다.
308
310
 
309
311
  CI에서는 `results --fail-on`으로 **최신 연결 실행의 TC 상태에 따라 실패 여부**를 정할 수 있습니다.
package/README.md CHANGED
@@ -399,7 +399,7 @@ After a Flow QA run, associate its normalized report with the exact exported sui
399
399
  node bin/error-to-test.mjs link-run .error-to-test/reviewed --report /path/to/qa-report.json
400
400
  ```
401
401
 
402
- The run's suite hash and reported case IDs must match. Safe case results are stored under `results/<runId>.json`, linked to their source groups/events. Full reports must account for every exported case. Flow QA selected runs are accepted only when their explicit `selection.caseIds` exactly matches the reported cases and `selection.totalCases` matches the full exported suite. Unknown, duplicate, or undeclared missing cases are rejected; existing results are never overwritten. A raw e2e report is not accepted. Failed, blocked, and passed results remain distinct; no issue is automatically marked fixed.
402
+ The run's suite hash and reported case IDs must match. Safe case results are stored under `results/<runId>.json`, linked to their source groups/events. Full reports must account for every exported case. Flow QA selected runs are accepted only when their explicit `selection.caseIds` exactly matches the reported cases and `selection.totalCases` matches the full exported suite. Unknown, duplicate, or undeclared missing cases are rejected; existing results are never overwritten. A `passed` run must report every included case as passed. A raw e2e report is not accepted. Failed, blocked, and passed results remain distinct; no issue is automatically marked fixed.
403
403
 
404
404
  Selected results add `selection: { mode: 'selected', totalCases, selectedCaseIds }` to `error-to-test/results-1` and the latest run in `error-to-test/run-summary-1`. Older full result files remain supported. Use this version or newer to read selected result files; older readers reject the added selection field. Unselected cases are `not-run`, including when a previous full run passed. Use `results --fail-on not-run` when incomplete execution should fail a CI gate.
405
405
 
@@ -422,6 +422,8 @@ Latest means the greatest reported `finishedAt`, then `startedAt`, then lexical
422
422
 
423
423
  The bundle and every linked JSON result are checked before output: schema, source/suite hashes, exact case/group/event mappings, statuses, and timestamps must agree. Invalid older runs also fail the request. The reader accepts up to 1,000 directory entries, 2 MiB per result file, and 64 MiB total result bytes. Non-JSON incidental files are ignored; malformed JSON filenames, symlinks, non-regular result files, and limit violations are rejected. `--out` requires a new file outside the bundle's `results` directory and never overwrites existing content. Analysis artifacts and linked results remain unchanged.
424
424
 
425
+ If an older result is flagged as contradictory, keep the original bundle and report. In a copy of the bundle, move the named result outside `results/` and relink the original Flow QA report if its case outcomes agree with its run status. If that report also disagrees, rerun the suite and link the new report. Writing new links requires a filesystem that supports hard links.
426
+
425
427
  The API provides the same data and Markdown renderer:
426
428
 
427
429
  ```js
package/dist/results.js CHANGED
@@ -1,9 +1,11 @@
1
- import { lstat, mkdir, writeFile } from 'node:fs/promises';
1
+ import { randomUUID } from 'node:crypto';
2
+ import { link, lstat, mkdir, rm, writeFile } from 'node:fs/promises';
2
3
  import { resolve } from 'node:path';
3
4
  import { jsonText, readVerifiedBundle } from "./artifacts.js";
4
5
  import { record, text, timestamp } from "./validation.js";
5
6
  import { redactText } from "./redact.js";
6
7
  import { reportedTargetIdentity, validateResultSelection } from "./result-selection.js";
8
+ import { MAX_LINKED_RESULT_BYTES } from "./run-summary.js";
7
9
  const runStatuses = new Set(['passed', 'failed', 'blocked', 'error', 'interrupted']);
8
10
  const caseStatuses = new Set(['passed', 'failed', 'flaky', 'blocked', 'skipped', 'error']);
9
11
  /** Associate a normalized Flow QA report with the exact exported immutable suite. */
@@ -54,7 +56,7 @@ export async function linkFlowQaReport(directory, rawReport) {
54
56
  return { ...mapping, status: caseStatus, ...(reason === undefined ? {} : { reason }) };
55
57
  });
56
58
  const selection = validateResultSelection(report.selection, Object.hasOwn(report, 'selection'), reportCaseIds, new Set(expected.keys()), 'Flow QA report');
57
- if (status === 'passed' && cases.some(item => item.status === 'failed' || item.status === 'error'))
59
+ if (status === 'passed' && cases.some(item => item.status !== 'passed'))
58
60
  throw new Error('The report status contradicts its case results.');
59
61
  const startedAt = timestamp(report.startedAt, 'report.startedAt'), finishedAt = timestamp(report.finishedAt, 'report.finishedAt');
60
62
  if (finishedAt < startedAt)
@@ -67,6 +69,9 @@ export async function linkFlowQaReport(directory, rawReport) {
67
69
  ...(selection === undefined ? {} : { selection }), cases,
68
70
  note: 'These results cover the specified assertions. No source issue was automatically closed.',
69
71
  };
72
+ const content = jsonText(output);
73
+ if (Buffer.byteLength(content) > MAX_LINKED_RESULT_BYTES)
74
+ throw new Error('Linked result exceeds 2 MiB.');
70
75
  const resultsRoot = resolve(root, 'results');
71
76
  try {
72
77
  await mkdir(resultsRoot, { mode: 0o700 });
@@ -79,6 +84,22 @@ export async function linkFlowQaReport(directory, rawReport) {
79
84
  throw new Error('Results must be stored in a real directory inside this bundle.');
80
85
  }
81
86
  const file = resolve(resultsRoot, `${runId}.json`);
82
- await writeFile(file, jsonText(output), { flag: 'wx', mode: 0o600 });
87
+ const pending = resolve(resultsRoot, `.${runId}-${randomUUID()}.pending`);
88
+ let published = false;
89
+ try {
90
+ await writeFile(pending, content, { flag: 'wx', mode: 0o600 });
91
+ // A hard link publishes the complete file without replacing a concurrent run ID.
92
+ await link(pending, file);
93
+ published = true;
94
+ }
95
+ finally {
96
+ try {
97
+ await rm(pending, { force: true });
98
+ }
99
+ catch (error) {
100
+ if (!published)
101
+ throw error;
102
+ }
103
+ }
83
104
  return file;
84
105
  }
@@ -45,6 +45,7 @@ export interface RunSummary {
45
45
  export interface ReadRunSummaryOptions {
46
46
  targetFingerprint?: string;
47
47
  }
48
+ export declare const MAX_LINKED_RESULT_BYTES: number;
48
49
  export declare function readRunSummary(directory: string, options?: ReadRunSummaryOptions): Promise<RunSummary>;
49
50
  /** Read linked results against an already verified bundle snapshot. */
50
51
  export declare function summarizeRunSummary(directory: string, snapshot: Awaited<ReturnType<typeof readVerifiedBundle>>, options?: ReadRunSummaryOptions): Promise<RunSummary>;
@@ -12,7 +12,7 @@ const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
12
12
  const safeIdPattern = /^[a-zA-Z0-9][a-zA-Z0-9_-]{0,79}$/;
13
13
  const shaPattern = /^[0-9a-f]{64}$/;
14
14
  const maxEntries = 1000;
15
- const maxResultBytes = 2 * 1024 * 1024;
15
+ export const MAX_LINKED_RESULT_BYTES = 2 * 1024 * 1024;
16
16
  const maxTotalBytes = 64 * 1024 * 1024;
17
17
  function safeId(value, label) {
18
18
  const id = text(value, label);
@@ -43,24 +43,24 @@ async function readResultFile(path, name) {
43
43
  const before = await lstat(path);
44
44
  if (!before.isFile() || before.isSymbolicLink())
45
45
  throw new Error(`Linked result ${name} must be a regular file, not a link or directory.`);
46
- if (before.size > maxResultBytes)
46
+ if (before.size > MAX_LINKED_RESULT_BYTES)
47
47
  throw new Error(`Linked result ${name} exceeds 2 MiB.`);
48
48
  const handle = await open(path, constants.O_RDONLY | (constants.O_NOFOLLOW ?? 0) | (constants.O_NONBLOCK ?? 0));
49
49
  try {
50
50
  const opened = await handle.stat();
51
51
  if (!opened.isFile() || !sameFile(before, opened))
52
52
  throw new Error(`Linked result ${name} changed while opening.`);
53
- if (opened.size > maxResultBytes)
53
+ if (opened.size > MAX_LINKED_RESULT_BYTES)
54
54
  throw new Error(`Linked result ${name} exceeds 2 MiB.`);
55
55
  const chunks = [];
56
56
  const buffer = Buffer.allocUnsafe(64 * 1024);
57
57
  let bytes = 0;
58
58
  while (true) {
59
- const { bytesRead } = await handle.read(buffer, 0, Math.min(buffer.length, maxResultBytes + 1 - bytes), null);
59
+ const { bytesRead } = await handle.read(buffer, 0, Math.min(buffer.length, MAX_LINKED_RESULT_BYTES + 1 - bytes), null);
60
60
  if (!bytesRead)
61
61
  break;
62
62
  bytes += bytesRead;
63
- if (bytes > maxResultBytes)
63
+ if (bytes > MAX_LINKED_RESULT_BYTES)
64
64
  throw new Error(`Linked result ${name} exceeds 2 MiB.`);
65
65
  chunks.push(Buffer.from(buffer.subarray(0, bytesRead)));
66
66
  }
@@ -124,7 +124,7 @@ function parseResult(content, name, inputSha256, suiteSha256, expected) {
124
124
  return { ...mapping, eventIds: mapping.eventIds.map(redactText), status: caseStatus, ...(reason === undefined ? {} : { reason }) };
125
125
  });
126
126
  const selection = validateResultSelection(raw.selection, Object.hasOwn(raw, 'selection'), cases.map(item => item.caseId), new Set(expected.keys()), 'Linked result');
127
- if (status === 'passed' && cases.some(item => item.status === 'failed' || item.status === 'error')) {
127
+ if (status === 'passed' && cases.some(item => item.status !== 'passed')) {
128
128
  throw new Error(`Linked result ${name} contradicts its case results.`);
129
129
  }
130
130
  return { runId, status: status, startedAt, finishedAt,
package/dist/trace.js CHANGED
@@ -71,11 +71,14 @@ export async function readEventTrace(directory, eventId, options = {}) {
71
71
  if (covered.caseIds.length !== cases.length || covered.caseIds.some(id => !cases.some(item => item.caseId === id))) {
72
72
  throw new Error('STALE_BUNDLE: The event case selection is inconsistent.');
73
73
  }
74
+ const nextAction = covered.status === 'review-ready' && cases.some(item => item.status !== 'not-run')
75
+ ? 'Review the latest linked case outcome and its target scope before deciding whether to rerun.'
76
+ : covered.nextAction;
74
77
  matches.push({ groupId, project: redactText(text(group.project, `analysis.groups[${index}].project`)),
75
78
  environment: redactText(text(group.environment, `analysis.groups[${index}].environment`)),
76
79
  release: redactText(text(group.release, `analysis.groups[${index}].release`)),
77
80
  suppliedRecords: covered.suppliedRecords, status: covered.status, reasons: covered.reasons,
78
- nextAction: covered.nextAction, cases });
81
+ nextAction, cases });
79
82
  });
80
83
  const warnings = [...new Set([
81
84
  ...coverage.warnings, ...runs.warnings,
package/docs/releases.md CHANGED
@@ -2,6 +2,10 @@
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.4.4 — linked result consistency and publication
6
+
7
+ `link-run` rejects a `passed` run containing a failed, flaky, blocked, skipped, or error case; stored result readers apply the same check. Completed results are written under a temporary name and published atomically without replacing a concurrent run ID. A result larger than the reader's 2 MiB limit is rejected before publication. `trace` directs readers to the linked outcome once a case has a result instead of suggesting the case has not run. Existing blocked, failed, interrupted, and error runs retain their established meaning.
8
+
5
9
  ## 0.4.3 — saved event ID trace
6
10
 
7
11
  `trace` and `readEventTrace()` connect a Browser Error Log ID to all matching observed groups, selected TC candidates, review blockers, and the latest linked case outcome. Matching across projects, unselected groups, partial input, unknown IDs, and target-scoped results remain explicit. The read-only `error-to-test/trace-1` output omits raw error messages and stacks; an absent ID means only that it was not in the saved analysis input. See [the research record](event-trace-research-2026-11-18.md) for the observed gap and choice. The local check passed 209 tests, type checking and build. The installed tarball smoke exercised the CLI and API. A saved 0.4.2 bundle also resolved an event ID to its latest linked passing case.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ihyeon/error-to-test",
3
- "version": "0.4.3",
3
+ "version": "0.4.4",
4
4
  "description": "Turn captured browser errors and pasted error reports into traceable regression test candidates.",
5
5
  "license": "MIT",
6
6
  "author": "Hyeonse Im",