@ihyeon/error-to-test 0.5.2 → 0.5.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 +13 -0
- package/README.md +13 -0
- package/dist/artifacts.js +25 -0
- package/dist/cli.js +25 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/refinement.d.ts +3 -1
- package/dist/refinement.js +63 -8
- package/dist/reselection-choices.d.ts +6 -0
- package/dist/reselection-choices.js +19 -0
- package/dist/types.d.ts +7 -0
- package/package.json +1 -1
package/README.ko.md
CHANGED
|
@@ -250,6 +250,19 @@ error-to-test refine ./initial-analysis --profile ./review-profile.json --review
|
|
|
250
250
|
|
|
251
251
|
API는 `await refineBundle(directory, profileJsonText)`입니다. JSON 문자열을 받아 새 `Analysis`를 반환하며 파일 저장·검토 승인·종료 코드 변경은 하지 않습니다. 저장하려면 별도 새 경로에 `writeBundle()`을 호출하세요.
|
|
252
252
|
|
|
253
|
+
### 원본 로그 없이 관측된 다른 묶음 선택
|
|
254
|
+
|
|
255
|
+
`reselect`는 처음 분석할 때 `--top`이나 `--min-count`에서 빠졌지만 저장된 분석에 남아 있는 오류 묶음으로 새 검토 번들을 만듭니다. 새로 생성한 `report.md`의 **Saved group reselection options**에서 재선택할 수 있는 묶음 ID와 재분석이 필요한 옛 묶음을 확인하고, 요구사항과 단언을 확인한 전체 프로필을 전달하세요.
|
|
256
|
+
|
|
257
|
+
```sh
|
|
258
|
+
error-to-test reselect ./initial-analysis --group group-0123456789abcdef --profile ./other-profile.json --out ./other-analysis
|
|
259
|
+
error-to-test readiness ./other-analysis
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
지정한 묶음에 대해서만 저장된 순위 순서로 후보를 만들며, 관측된 모든 묶음과 입력 해시·수집 범위는 새 분석에도 남습니다. `analysis.reselection`과 보고서에는 검증된 원본 분석·suite·프로필 해시, 이전 선택과 새 선택을 기록합니다. 새 번들은 검토 대기 상태이며 기존 실행 결과를 복사하지 않습니다. 기대 결과와 미해결 질문을 다시 검토한 다음 실행을 준비하세요. 전달한 프로필의 실제 바이트를 해시에 반영하며 BOM 하나를 허용합니다. 원본 입력 바이트가 있으면 `verify --input`으로 별도 확인하세요.
|
|
263
|
+
|
|
264
|
+
이 명령은 이전 후보에서 빠진 서로 다른 묶음 ID 1~100개와 원본 번들 바깥의 새 출력 경로를 받습니다. 관측되지 않은 ID나 묶음 전체 맥락이 없는 옛 번들은 원본 로그로 다시 분석해야 합니다. `--baseline` 또는 명시적 `--group`으로 만든 번들은 당시 제외 규칙을 저장된 순위만으로 되돌릴 수 없어 재선택을 거부합니다. 재선택한 번들에서 또 다른 묶음을 고를 때는 원래 순위를 기록한 분석 번들을 사용하세요. 재선택한 번들을 `refine`으로 정제한 경우에도 같습니다. 원래 분석 번들을 정제한 결과에서는 재선택할 수 있습니다. 기존 `refine`은 원래 선택된 묶음만 다시 생성합니다. API는 `reselectBundle(directory, groupIds, profileJsonText)`이며 저장할 때는 새 경로에 `writeBundle()`을 호출합니다.
|
|
265
|
+
|
|
253
266
|
```sh
|
|
254
267
|
node bin/error-to-test.mjs verify .error-to-test/example --input examples/errors.json --profile examples/profile.json
|
|
255
268
|
node bin/error-to-test.mjs analyze --input examples/errors.json --profile examples/profile.json --reviewed --out .error-to-test/reviewed
|
package/README.md
CHANGED
|
@@ -318,6 +318,19 @@ await writeBundle('./refined', analysis); // Review remains pending by default.
|
|
|
318
318
|
|
|
319
319
|
`refineBundle(directory, profileText)` accepts JSON text and returns a new `Analysis`. It does not write files, approve cases, or change process exit codes. Use a separate new output directory when writing the result.
|
|
320
320
|
|
|
321
|
+
### Select another observed group without the original logs
|
|
322
|
+
|
|
323
|
+
`reselect` creates a new bundle for explicitly named groups that were observed but excluded from the source bundle's candidates by `--top` or `--min-count`. In a newly generated `report.md`, the **Saved group reselection options** section lists available group IDs and identifies old groups that need reanalysis. Provide a complete replacement profile with reviewed requirements and assertions:
|
|
324
|
+
|
|
325
|
+
```sh
|
|
326
|
+
error-to-test reselect ./initial-analysis --group group-0123456789abcdef --profile ./other-profile.json --out ./other-analysis
|
|
327
|
+
error-to-test readiness ./other-analysis
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
Only the requested groups receive candidates, in their saved rank order. The original groups, input fingerprints and coverage stay in the new analysis. `analysis.reselection` records the verified source analysis, suite and profile hashes, previous selected group IDs and newly selected IDs. The report repeats this lineage. The new bundle has pending review and no linked runs. Recheck every expectation and unresolved question before preparing a run. The supplied profile is parsed and hashed from its exact bytes, including an optional leading BOM. The original input bytes are not rechecked; provide them to `verify --input` if they are available.
|
|
331
|
+
|
|
332
|
+
This command accepts 1–100 distinct, previously excluded IDs and a new output directory outside the source bundle. Unknown IDs and old bundles without full saved group context require the original logs and a fresh analysis. A source created with `--baseline` or an explicit `--group` cannot be expanded from its saved analysis because its exclusion policy is outside ranking limits. To choose another group after a reselection, use the original ranked analysis bundle. This also applies if the reselected bundle was later refined. Refining the original ranked bundle still permits reselection. `refine` continues to regenerate only the source bundle's selected groups. The API is `reselectBundle(directory, groupIds, profileJsonText)`, followed by `writeBundle(newDirectory, analysis)` to save.
|
|
333
|
+
|
|
321
334
|
## Review and use Flow QA
|
|
322
335
|
|
|
323
336
|
Generated files (Flow QA source is limited to 128 KB; suite JSON to 512 KiB):
|
package/dist/artifacts.js
CHANGED
|
@@ -5,6 +5,7 @@ import { exportFlowQa } from "./exports/flow-qa.js";
|
|
|
5
5
|
import { hash, record, text } from "./validation.js";
|
|
6
6
|
import { redactText } from "./redact.js";
|
|
7
7
|
import { inputSource, validateInputSource } from "./input-source.js";
|
|
8
|
+
import { reselectionChoices } from "./reselection-choices.js";
|
|
8
9
|
export function jsonText(value) { return `${JSON.stringify(value, null, 2)}\n`; }
|
|
9
10
|
// Use only after callers have sanitized each untrusted field for its context.
|
|
10
11
|
export function fencedText(value) {
|
|
@@ -39,6 +40,16 @@ export function renderReport(analysis) {
|
|
|
39
40
|
'TCs were regenerated from the verified saved groups and a replacement profile. Original input was not rechecked; selection and source coverage were not expanded.',
|
|
40
41
|
'The new bundle has its own review acknowledgement and suite. Linked run results were not transferred.',
|
|
41
42
|
].join('\n')), '');
|
|
43
|
+
if (analysis.reselection)
|
|
44
|
+
lines.push('## Saved group reselection', '', literal([
|
|
45
|
+
`Source analysis SHA-256: ${analysis.reselection.sourceAnalysisSha256}`,
|
|
46
|
+
...(analysis.reselection.sourceSuiteSha256 ? [`Source suite SHA-256: ${analysis.reselection.sourceSuiteSha256}`] : []),
|
|
47
|
+
...(analysis.reselection.sourceProfileSha256 ? [`Source profile SHA-256: ${analysis.reselection.sourceProfileSha256}`] : []),
|
|
48
|
+
`Previously selected group IDs: ${analysis.reselection.previouslySelectedGroupIds.join(', ')}`,
|
|
49
|
+
`Newly selected group IDs: ${analysis.reselection.selectedGroupIds.join(', ')}`,
|
|
50
|
+
'Candidates were generated from the saved observed groups. Original input was not rechecked; all observed groups and source coverage remain.',
|
|
51
|
+
'The new bundle has its own pending review and suite. Linked run results were not transferred.',
|
|
52
|
+
].join('\n')), '');
|
|
42
53
|
if (analysis.groupFilter)
|
|
43
54
|
lines.push('## Explicit group selection', '', literal([
|
|
44
55
|
`Requested group IDs: ${analysis.groupFilter.groupIds.join(', ')}`,
|
|
@@ -55,6 +66,20 @@ export function renderReport(analysis) {
|
|
|
55
66
|
`Groups excluded as already observed: ${analysis.selection.excludedGroupCount}`,
|
|
56
67
|
'All current groups remain below. Absence from this baseline does not establish when an error was introduced.',
|
|
57
68
|
].join('\n')), '');
|
|
69
|
+
const choices = reselectionChoices(analysis);
|
|
70
|
+
if (choices.restriction === 'selection') {
|
|
71
|
+
lines.push('## Saved group reselection options', '', 'This bundle uses baseline or explicit group selection. Reanalyze the original input to change the TC group scope.', '');
|
|
72
|
+
}
|
|
73
|
+
else if (choices.restriction === 'reselection') {
|
|
74
|
+
lines.push('## Saved group reselection options', '', 'Use the original ranked analysis bundle to select another observed group.', '');
|
|
75
|
+
}
|
|
76
|
+
else if (choices.available.length || choices.missingContext.length) {
|
|
77
|
+
lines.push('## Saved group reselection options', '', `Observed groups available to reselect: ${choices.available.map(group => group.id).join(', ') || 'none'}`, '');
|
|
78
|
+
if (choices.missingContext.length) {
|
|
79
|
+
lines.push(`Older groups requiring reanalysis of the original input: ${choices.missingContext.map(group => group.id).join(', ')}`, '');
|
|
80
|
+
}
|
|
81
|
+
lines.push('Use reselect with an available group ID, a confirmed profile, and a new output directory. Review the new pending bundle before execution.', '');
|
|
82
|
+
}
|
|
58
83
|
if (analysis.warnings.length)
|
|
59
84
|
lines.push('## Coverage and selection notes', '', literal(analysis.warnings.join('\n')), '');
|
|
60
85
|
if (!analysis.groups.length)
|
package/dist/cli.js
CHANGED
|
@@ -13,7 +13,7 @@ import { readRunSummary, renderRunSummary } from "./run-summary.js";
|
|
|
13
13
|
import { readReadiness, renderReadiness, summarizeReadiness } from "./readiness.js";
|
|
14
14
|
import { readCoverage, renderCoverage } from "./coverage.js";
|
|
15
15
|
import { readEventTrace, renderEventTrace } from "./trace.js";
|
|
16
|
-
import { refineBundle } from "./refinement.js";
|
|
16
|
+
import { refineBundle, reselectBundle } from "./refinement.js";
|
|
17
17
|
import { startReview } from "./review-server.js";
|
|
18
18
|
import { writePreparedWorkspace } from "./review-session.js";
|
|
19
19
|
import { readIssueReport } from "./issue-report.js";
|
|
@@ -32,6 +32,7 @@ const help = `Error to Test — local error analysis and regression TC drafts
|
|
|
32
32
|
error-to-test init-profile new-directory --profile existing.json --out extended.json
|
|
33
33
|
error-to-test review BUNDLE --out NEW_REVIEW_DIRECTORY [--input FILE] [--profile ORIGINAL_PROFILE] [--draft SAVED_DRAFT] [--port 0]
|
|
34
34
|
error-to-test refine new-directory --profile updated.json --out refined-directory [--reviewed]
|
|
35
|
+
error-to-test reselect new-directory --group GROUP_ID [--group OTHER_GROUP_ID] --profile updated.json --out selected-directory
|
|
35
36
|
error-to-test issue new-directory --group GROUP_ID [--out issue.md]
|
|
36
37
|
error-to-test link-run new-directory --report path/to/qa-report.json
|
|
37
38
|
error-to-test results new-directory [--format text|json] [--out summary.md] [--target-fingerprint SHA256] [--require-pass | --fail-on STATUS ...]
|
|
@@ -56,6 +57,7 @@ Options:
|
|
|
56
57
|
--target-fingerprint SHA256 Scope trace outcomes to this linked target fingerprint
|
|
57
58
|
--profile FILE Confirmed app scenarios and explicit assertions (analyze/verify); existing profile to extend (init-profile)
|
|
58
59
|
--profile FILE Replacement profile for the bundle's previously selected groups (refine; required)
|
|
60
|
+
--profile FILE Profile for newly selected saved groups (reselect; required)
|
|
59
61
|
--baseline DIRECTORY Select only signatures absent from this verified bundle, before --min-count and --top; retain all groups in analysis.json (analyze only)
|
|
60
62
|
--project NAME Metadata for a manual report
|
|
61
63
|
--environment NAME Metadata for a manual report
|
|
@@ -69,10 +71,11 @@ Options:
|
|
|
69
71
|
--expected-source TEXT Expected-result source (--error only)
|
|
70
72
|
--from ISO --to ISO Filter observed timestamps; undated reports are excluded
|
|
71
73
|
--min-count N Select groups with at least N records after dedup/date filtering (1..10000)
|
|
72
|
-
--group GROUP_ID Analyze: select exact groups before min-count/top (repeat up to 100 times); issue: export
|
|
74
|
+
--group GROUP_ID Analyze: select exact groups before min-count/top; reselect: previously excluded observed groups (repeat up to 100 times); issue: export one group
|
|
73
75
|
--top N Generate TCs for the first N eligible ranked groups (1..100; after --min-count)
|
|
74
76
|
--out DIRECTORY New analyze directory; existing files are never overwritten
|
|
75
77
|
--out DIRECTORY New refine directory outside the source bundle (required; review defaults to pending)
|
|
78
|
+
--out DIRECTORY New reselect directory outside the source bundle (required; review is pending)
|
|
76
79
|
--out FILE New init-profile JSON file; existing files are never overwritten
|
|
77
80
|
--out FILE New issue Markdown file outside the source bundle; no remote issue is filed
|
|
78
81
|
--out FILE New results summary file; existing files are never overwritten
|
|
@@ -202,7 +205,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
202
205
|
}
|
|
203
206
|
if (positionals.length === 0) {
|
|
204
207
|
if (Object.keys(values).length)
|
|
205
|
-
throw new Error('A command is required. Use analyze, init-profile, refine, issue, verify, prepare-run, link-run, results, compare, readiness, coverage, or trace. See --help.');
|
|
208
|
+
throw new Error('A command is required. Use analyze, init-profile, refine, reselect, issue, verify, prepare-run, link-run, results, compare, readiness, coverage, or trace. See --help.');
|
|
206
209
|
process.stdout.write(help);
|
|
207
210
|
return;
|
|
208
211
|
}
|
|
@@ -272,6 +275,24 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
272
275
|
process.stdout.write(`${analysis.groups.length} error groups retained; ${analysis.candidates.length} refined TC candidates (${drafts} drafts, ${analysis.candidates.length - drafts} need context).\nReview ${resolve(out, 'report.md')}\n${files.length} artifacts written. Review acknowledgment: ${values.reviewed ? 'yes' : 'pending'}. Original input was not rechecked.\n`);
|
|
273
276
|
return;
|
|
274
277
|
}
|
|
278
|
+
if (command === 'reselect') {
|
|
279
|
+
if (positionals.length !== 2 || !positionals[1]?.trim() || !values.group?.length || !values.profile?.trim() || !values.out?.trim()) {
|
|
280
|
+
throw new Error('reselect requires one bundle directory, --group GROUP_ID, --profile FILE, and --out DIRECTORY.');
|
|
281
|
+
}
|
|
282
|
+
if (Object.keys(values).some(key => !['group', 'profile', 'out', 'help'].includes(key))) {
|
|
283
|
+
throw new Error('Unsupported option for reselect. Use only --group GROUP_ID, --profile FILE, and --out DIRECTORY.');
|
|
284
|
+
}
|
|
285
|
+
const bundle = resolve(positionals[1]);
|
|
286
|
+
const out = resolve(values.out);
|
|
287
|
+
if (insideBundle(await realpath(bundle), await canonicalOutput(out))) {
|
|
288
|
+
throw new Error('The reselected output must be outside the source bundle. Choose a new --out DIRECTORY path.');
|
|
289
|
+
}
|
|
290
|
+
const analysis = await reselectBundle(bundle, values.group, await readBoundedFile(resolve(values.profile), 1024 * 1024));
|
|
291
|
+
const files = await writeBundle(out, analysis);
|
|
292
|
+
const drafts = analysis.candidates.filter(candidate => candidate.state === 'draft').length;
|
|
293
|
+
process.stdout.write(`${analysis.groups.length} error groups retained; ${analysis.candidates.length} newly selected TC candidates (${drafts} drafts, ${analysis.candidates.length - drafts} need context).\nReview ${resolve(out, 'report.md')}\n${files.length} artifacts written. Review acknowledgment: pending. Original input was not rechecked.\n`);
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
275
296
|
if (command === 'init-profile') {
|
|
276
297
|
if (positionals.length !== 2 || !positionals[1] || !values.out)
|
|
277
298
|
throw new Error('init-profile requires one bundle directory and --out FILE.');
|
|
@@ -551,7 +572,7 @@ export async function main(args = process.argv.slice(2)) {
|
|
|
551
572
|
return;
|
|
552
573
|
}
|
|
553
574
|
if (command !== 'analyze' || positionals.length !== 1)
|
|
554
|
-
throw new Error('Use analyze, init-profile, refine, issue, verify, prepare-run, link-run, results, compare, readiness, coverage, or trace. See --help.');
|
|
575
|
+
throw new Error('Use analyze, init-profile, refine, reselect, issue, verify, prepare-run, link-run, results, compare, readiness, coverage, or trace. See --help.');
|
|
555
576
|
if (values.report)
|
|
556
577
|
throw new Error('--report applies to link-run only.');
|
|
557
578
|
if (values['require-pass'])
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export { writeBundle, verifyBundle, renderReport } from './artifacts.ts';
|
|
|
7
7
|
export { readIssueReport } from './issue-report.ts';
|
|
8
8
|
export { linkFlowQaReport } from './results.ts';
|
|
9
9
|
export { createProfileTemplate, type ProfileTemplateOptions } from './profile-template.ts';
|
|
10
|
-
export { refineBundle } from './refinement.ts';
|
|
10
|
+
export { refineBundle, reselectBundle } from './refinement.ts';
|
|
11
11
|
export { readRunSummary, renderRunSummary, type RunSummary, type ReadRunSummaryOptions, type LinkedRunStatus, type LinkedCaseStatus } from './run-summary.ts';
|
|
12
12
|
export { readReadiness, renderReadiness, type ReadinessSummary } from './readiness.ts';
|
|
13
13
|
export { readCoverage, renderCoverage, type CoverageSummary, type GroupCoverageStatus, type GroupCoverageReason } from './coverage.ts';
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ export { writeBundle, verifyBundle, renderReport } from "./artifacts.js";
|
|
|
7
7
|
export { readIssueReport } from "./issue-report.js";
|
|
8
8
|
export { linkFlowQaReport } from "./results.js";
|
|
9
9
|
export { createProfileTemplate } from "./profile-template.js";
|
|
10
|
-
export { refineBundle } from "./refinement.js";
|
|
10
|
+
export { refineBundle, reselectBundle } from "./refinement.js";
|
|
11
11
|
export { readRunSummary, renderRunSummary } from "./run-summary.js";
|
|
12
12
|
export { readReadiness, renderReadiness } from "./readiness.js";
|
|
13
13
|
export { readCoverage, renderCoverage } from "./coverage.js";
|
package/dist/refinement.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import type { Analysis } from './types.ts';
|
|
2
|
-
/**
|
|
2
|
+
/** Regenerate the source's selected groups with a replacement profile. */
|
|
3
3
|
export declare function refineBundle(directory: string, profile: string): Promise<Analysis>;
|
|
4
|
+
/** Select previously excluded observed groups from a verified saved bundle. */
|
|
5
|
+
export declare function reselectBundle(directory: string, groupIds: readonly string[], profile: string): Promise<Analysis>;
|
package/dist/refinement.js
CHANGED
|
@@ -2,6 +2,7 @@ import { readVerifiedBundle } from "./artifacts.js";
|
|
|
2
2
|
import { createCandidates, parseProfile } from "./candidates.js";
|
|
3
3
|
import { validateInputSource } from "./input-source.js";
|
|
4
4
|
import { redactText } from "./redact.js";
|
|
5
|
+
import { reselectionChoices } from "./reselection-choices.js";
|
|
5
6
|
import { hash, parseWebSteps, record } from "./validation.js";
|
|
6
7
|
const sha256 = /^[a-f0-9]{64}$/;
|
|
7
8
|
const groupId = /^group-[a-f0-9]{16}$/;
|
|
@@ -135,7 +136,7 @@ function group(value, label, requireContext) {
|
|
|
135
136
|
context(raw.context, `${label}.context`, requireContext);
|
|
136
137
|
return raw;
|
|
137
138
|
}
|
|
138
|
-
function checkedAnalysis(value, provenance) {
|
|
139
|
+
function checkedAnalysis(value, provenance, allowEmpty = false) {
|
|
139
140
|
const raw = record(value, 'analysis');
|
|
140
141
|
if (raw.schemaVersion !== 'error-to-test/analysis-1')
|
|
141
142
|
invalid('schemaVersion');
|
|
@@ -184,7 +185,7 @@ function checkedAnalysis(value, provenance) {
|
|
|
184
185
|
candidateIds.add(candidate.id);
|
|
185
186
|
selectedIds.add(candidate.groupId);
|
|
186
187
|
}
|
|
187
|
-
if (!selectedIds.size)
|
|
188
|
+
if (!selectedIds.size && !allowEmpty)
|
|
188
189
|
throw new Error('Refinement requires at least one selected candidate group.');
|
|
189
190
|
const seenGroups = new Set();
|
|
190
191
|
const selectedGroups = [];
|
|
@@ -206,8 +207,7 @@ function checkedAnalysis(value, provenance) {
|
|
|
206
207
|
}
|
|
207
208
|
return { analysis: raw, selectedGroups };
|
|
208
209
|
}
|
|
209
|
-
|
|
210
|
-
export async function refineBundle(directory, profile) {
|
|
210
|
+
function checkedProfile(profile) {
|
|
211
211
|
if (typeof profile !== 'string')
|
|
212
212
|
throw new Error('The profile must be JSON text.');
|
|
213
213
|
if (Buffer.byteLength(profile, 'utf8') > 1024 * 1024)
|
|
@@ -224,9 +224,42 @@ export async function refineBundle(directory, profile) {
|
|
|
224
224
|
(rule.match.groupId !== undefined && redactText(rule.match.groupId) !== rule.match.groupId))) {
|
|
225
225
|
throw new Error('The profile contains sensitive scenario IDs; remove them before refining.');
|
|
226
226
|
}
|
|
227
|
+
return appProfile;
|
|
228
|
+
}
|
|
229
|
+
async function rebuildBundle(directory, profile, requestedGroupIds) {
|
|
230
|
+
const appProfile = checkedProfile(profile);
|
|
231
|
+
if (requestedGroupIds !== undefined && (!Array.isArray(requestedGroupIds) || requestedGroupIds.length < 1 ||
|
|
232
|
+
requestedGroupIds.length > 100 || requestedGroupIds.some(id => typeof id !== 'string' || !groupId.test(id)) ||
|
|
233
|
+
new Set(requestedGroupIds).size !== requestedGroupIds.length)) {
|
|
234
|
+
throw new Error('Provide 1 to 100 distinct observed group IDs.');
|
|
235
|
+
}
|
|
227
236
|
const verified = await readVerifiedBundle(directory);
|
|
228
|
-
const { analysis, selectedGroups } = checkedAnalysis(verified.analysis, verified.provenance);
|
|
229
|
-
const
|
|
237
|
+
const { analysis, selectedGroups } = checkedAnalysis(verified.analysis, verified.provenance, requestedGroupIds !== undefined);
|
|
238
|
+
const choices = requestedGroupIds === undefined ? undefined : reselectionChoices(analysis);
|
|
239
|
+
if (choices?.restriction === 'selection') {
|
|
240
|
+
throw new Error('Saved baseline or explicit group selection cannot be expanded. Reanalyze the original input.');
|
|
241
|
+
}
|
|
242
|
+
if (choices?.restriction === 'reselection') {
|
|
243
|
+
throw new Error('This bundle already reselected observed groups. Use the original ranked analysis bundle to choose another group.');
|
|
244
|
+
}
|
|
245
|
+
let targetGroups = selectedGroups;
|
|
246
|
+
if (requestedGroupIds !== undefined) {
|
|
247
|
+
const previouslySelected = new Set(selectedGroups.map(item => item.id));
|
|
248
|
+
const requested = new Set(requestedGroupIds);
|
|
249
|
+
const available = new Set(choices.available.map(item => item.id));
|
|
250
|
+
const missingContext = new Set(choices.missingContext.map(item => item.id));
|
|
251
|
+
if (requestedGroupIds.some(id => previouslySelected.has(id))) {
|
|
252
|
+
throw new Error('Choose only observed groups excluded from the source candidates.');
|
|
253
|
+
}
|
|
254
|
+
if (requestedGroupIds.some(id => missingContext.has(id))) {
|
|
255
|
+
throw new Error('Selected group lacks full source context. Reanalyze the original input before refining.');
|
|
256
|
+
}
|
|
257
|
+
targetGroups = analysis.groups.filter(item => requested.has(item.id) && available.has(item.id));
|
|
258
|
+
if (targetGroups.length !== requested.size)
|
|
259
|
+
throw new Error('A requested group ID was not observed in the source bundle.');
|
|
260
|
+
targetGroups.forEach((item, index) => group(item, `reselected.groups[${index}]`, true));
|
|
261
|
+
}
|
|
262
|
+
const candidates = createCandidates(targetGroups, appProfile);
|
|
230
263
|
if (candidates.length > 100)
|
|
231
264
|
throw new Error(`Flow QA supports at most 100 cases; received ${candidates.length}. Narrow the selected scenario rules.`);
|
|
232
265
|
const sourceAnalysisSha256 = verified.provenance.analysisSha256;
|
|
@@ -238,12 +271,34 @@ export async function refineBundle(directory, profile) {
|
|
|
238
271
|
const sourceProfileSha256 = verified.provenance.profileSha256;
|
|
239
272
|
if (sourceProfileSha256 !== undefined && (typeof sourceProfileSha256 !== 'string' || !sha256.test(sourceProfileSha256)))
|
|
240
273
|
invalid('provenance.profileSha256');
|
|
274
|
+
const lineage = { sourceAnalysisSha256, ...(sourceSuiteSha256 === undefined ? {} : { sourceSuiteSha256 }),
|
|
275
|
+
...(sourceProfileSha256 === undefined ? {} : { sourceProfileSha256 }) };
|
|
276
|
+
if (requestedGroupIds !== undefined) {
|
|
277
|
+
const { refinement: _previousRefinement, reselection: _previousReselection, ...retained } = analysis;
|
|
278
|
+
return {
|
|
279
|
+
...retained,
|
|
280
|
+
source: { ...analysis.source, profileSha256: hash(profile) },
|
|
281
|
+
candidates,
|
|
282
|
+
warnings: [...analysis.warnings.filter(note => !note.startsWith('Refinement:') && !note.startsWith('Reselection:') &&
|
|
283
|
+
!note.startsWith('TC selection includes') && !note.startsWith('TC selection requires')),
|
|
284
|
+
'Reselection: Candidates were generated only for explicitly requested observed groups in saved rank order. Original input was not rechecked; all observed groups and source coverage remain. Review the new cases before execution.'],
|
|
285
|
+
reselection: { ...lineage, previouslySelectedGroupIds: selectedGroups.map(item => item.id),
|
|
286
|
+
selectedGroupIds: targetGroups.map(item => item.id) },
|
|
287
|
+
};
|
|
288
|
+
}
|
|
241
289
|
return {
|
|
242
290
|
...analysis,
|
|
243
291
|
source: { ...analysis.source, profileSha256: hash(profile) },
|
|
244
292
|
candidates,
|
|
245
293
|
warnings: [...analysis.warnings.filter(note => !note.startsWith('Refinement:')), refinementNote],
|
|
246
|
-
refinement: {
|
|
247
|
-
...(sourceProfileSha256 === undefined ? {} : { sourceProfileSha256 }), selectedGroupIds: selectedGroups.map(item => item.id) },
|
|
294
|
+
refinement: { ...lineage, selectedGroupIds: selectedGroups.map(item => item.id) },
|
|
248
295
|
};
|
|
249
296
|
}
|
|
297
|
+
/** Regenerate the source's selected groups with a replacement profile. */
|
|
298
|
+
export async function refineBundle(directory, profile) {
|
|
299
|
+
return rebuildBundle(directory, profile);
|
|
300
|
+
}
|
|
301
|
+
/** Select previously excluded observed groups from a verified saved bundle. */
|
|
302
|
+
export async function reselectBundle(directory, groupIds, profile) {
|
|
303
|
+
return rebuildBundle(directory, profile, groupIds);
|
|
304
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export function reselectionChoices(analysis) {
|
|
2
|
+
if (analysis.selection || analysis.groupFilter) {
|
|
3
|
+
return { available: [], missingContext: [], restriction: 'selection' };
|
|
4
|
+
}
|
|
5
|
+
if (analysis.reselection) {
|
|
6
|
+
return { available: [], missingContext: [], restriction: 'reselection' };
|
|
7
|
+
}
|
|
8
|
+
const selected = new Set(analysis.candidates.map(candidate => candidate.groupId));
|
|
9
|
+
const excluded = analysis.groups.filter(group => !selected.has(group.id));
|
|
10
|
+
const available = [];
|
|
11
|
+
const missingContext = [];
|
|
12
|
+
for (const group of excluded) {
|
|
13
|
+
if (group.context === undefined)
|
|
14
|
+
missingContext.push(group);
|
|
15
|
+
else
|
|
16
|
+
available.push(group);
|
|
17
|
+
}
|
|
18
|
+
return { available, missingContext };
|
|
19
|
+
}
|
package/dist/types.d.ts
CHANGED
|
@@ -188,6 +188,13 @@ export interface Analysis {
|
|
|
188
188
|
sourceProfileSha256?: string;
|
|
189
189
|
selectedGroupIds: string[];
|
|
190
190
|
};
|
|
191
|
+
reselection?: {
|
|
192
|
+
sourceAnalysisSha256: string;
|
|
193
|
+
sourceSuiteSha256?: string;
|
|
194
|
+
sourceProfileSha256?: string;
|
|
195
|
+
previouslySelectedGroupIds: string[];
|
|
196
|
+
selectedGroupIds: string[];
|
|
197
|
+
};
|
|
191
198
|
}
|
|
192
199
|
export interface FlowQaSuite {
|
|
193
200
|
schemaVersion: 'flow-qa/suite-1';
|
package/package.json
CHANGED