@sun-asterisk/sungen 3.2.16-beta.7 → 3.2.17

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.
Files changed (95) hide show
  1. package/dist/cli/commands/delivery.d.ts.map +1 -1
  2. package/dist/cli/commands/delivery.js +13 -197
  3. package/dist/cli/commands/delivery.js.map +1 -1
  4. package/dist/cli/commands/ingest.d.ts.map +1 -1
  5. package/dist/cli/commands/ingest.js +56 -4
  6. package/dist/cli/commands/ingest.js.map +1 -1
  7. package/dist/dashboard/templates/index.html +1 -1
  8. package/dist/exporters/feature-parser.js +1 -1
  9. package/dist/exporters/feature-parser.js.map +1 -1
  10. package/dist/exporters/scenario-merger.js +1 -1
  11. package/dist/exporters/scenario-merger.js.map +1 -1
  12. package/dist/exporters/spec-parser.js +1 -1
  13. package/dist/exporters/spec-parser.js.map +1 -1
  14. package/dist/exporters/xlsx-report-builder.d.ts +1 -1
  15. package/dist/exporters/xlsx-report-builder.d.ts.map +1 -1
  16. package/dist/exporters/xlsx-report-builder.js +3 -3
  17. package/dist/exporters/xlsx-report-builder.js.map +1 -1
  18. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/click-action.hbs +1 -1
  19. package/dist/generators/test-generator/adapters/playwright/templates/steps/actions/click-element-with-text.hbs +1 -1
  20. package/dist/generators/test-generator/adapters/playwright/templates/steps/navigation/wait-timeout.hbs +1 -1
  21. package/dist/generators/test-generator/utils/runtime-data-transformer.d.ts.map +1 -1
  22. package/dist/generators/test-generator/utils/runtime-data-transformer.js +28 -17
  23. package/dist/generators/test-generator/utils/runtime-data-transformer.js.map +1 -1
  24. package/dist/ingest/legacy-parser.d.ts +3 -0
  25. package/dist/ingest/legacy-parser.d.ts.map +1 -1
  26. package/dist/ingest/legacy-parser.js +52 -3
  27. package/dist/ingest/legacy-parser.js.map +1 -1
  28. package/dist/orchestrator/templates/ai-src/commands/delivery.md +120 -202
  29. package/dist/orchestrator/templates/ai-src/config/claude.md +1 -1
  30. package/dist/orchestrator/templates/ai-src/config/copilot.md +1 -1
  31. package/dist/orchestrator/templates/ai-src/skills/sungen-delivery/SKILL.md +6 -92
  32. package/dist/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +7 -0
  33. package/package.json +4 -4
  34. package/src/cli/commands/delivery.ts +15 -227
  35. package/src/cli/commands/ingest.ts +57 -5
  36. package/src/dashboard/templates/index.html +1 -1
  37. package/src/exporters/feature-parser.ts +1 -1
  38. package/src/exporters/scenario-merger.ts +1 -1
  39. package/src/exporters/spec-parser.ts +1 -1
  40. package/src/exporters/xlsx-report-builder.ts +2 -3
  41. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/click-action.hbs +1 -1
  42. package/src/generators/test-generator/adapters/playwright/templates/steps/actions/click-element-with-text.hbs +1 -1
  43. package/src/generators/test-generator/adapters/playwright/templates/steps/navigation/wait-timeout.hbs +1 -1
  44. package/src/generators/test-generator/utils/runtime-data-transformer.ts +29 -18
  45. package/src/ingest/legacy-parser.ts +48 -3
  46. package/src/orchestrator/templates/ai-src/commands/delivery.md +120 -202
  47. package/src/orchestrator/templates/ai-src/config/claude.md +1 -1
  48. package/src/orchestrator/templates/ai-src/config/copilot.md +1 -1
  49. package/src/orchestrator/templates/ai-src/skills/sungen-delivery/SKILL.md +6 -92
  50. package/src/orchestrator/templates/ai-src/skills/sungen-gherkin-syntax/SKILL.md +7 -0
  51. package/dist/exporters/matrix/build.d.ts +0 -61
  52. package/dist/exporters/matrix/build.d.ts.map +0 -1
  53. package/dist/exporters/matrix/build.js +0 -472
  54. package/dist/exporters/matrix/build.js.map +0 -1
  55. package/dist/exporters/matrix/export.d.ts +0 -50
  56. package/dist/exporters/matrix/export.d.ts.map +0 -1
  57. package/dist/exporters/matrix/export.js +0 -152
  58. package/dist/exporters/matrix/export.js.map +0 -1
  59. package/dist/exporters/matrix/fingerprint.d.ts +0 -20
  60. package/dist/exporters/matrix/fingerprint.d.ts.map +0 -1
  61. package/dist/exporters/matrix/fingerprint.js +0 -83
  62. package/dist/exporters/matrix/fingerprint.js.map +0 -1
  63. package/dist/exporters/matrix/gates.d.ts +0 -21
  64. package/dist/exporters/matrix/gates.d.ts.map +0 -1
  65. package/dist/exporters/matrix/gates.js +0 -358
  66. package/dist/exporters/matrix/gates.js.map +0 -1
  67. package/dist/exporters/matrix/map-loader.d.ts +0 -22
  68. package/dist/exporters/matrix/map-loader.d.ts.map +0 -1
  69. package/dist/exporters/matrix/map-loader.js +0 -193
  70. package/dist/exporters/matrix/map-loader.js.map +0 -1
  71. package/dist/exporters/matrix/render-csv.d.ts +0 -9
  72. package/dist/exporters/matrix/render-csv.d.ts.map +0 -1
  73. package/dist/exporters/matrix/render-csv.js +0 -92
  74. package/dist/exporters/matrix/render-csv.js.map +0 -1
  75. package/dist/exporters/matrix/render-xlsx.d.ts +0 -41
  76. package/dist/exporters/matrix/render-xlsx.d.ts.map +0 -1
  77. package/dist/exporters/matrix/render-xlsx.js +0 -430
  78. package/dist/exporters/matrix/render-xlsx.js.map +0 -1
  79. package/dist/exporters/matrix/types.d.ts +0 -196
  80. package/dist/exporters/matrix/types.d.ts.map +0 -1
  81. package/dist/exporters/matrix/types.js +0 -15
  82. package/dist/exporters/matrix/types.js.map +0 -1
  83. package/dist/exporters/matrix/wording.d.ts +0 -51
  84. package/dist/exporters/matrix/wording.d.ts.map +0 -1
  85. package/dist/exporters/matrix/wording.js +0 -169
  86. package/dist/exporters/matrix/wording.js.map +0 -1
  87. package/src/exporters/matrix/build.ts +0 -503
  88. package/src/exporters/matrix/export.ts +0 -149
  89. package/src/exporters/matrix/fingerprint.ts +0 -49
  90. package/src/exporters/matrix/gates.ts +0 -391
  91. package/src/exporters/matrix/map-loader.ts +0 -163
  92. package/src/exporters/matrix/render-csv.ts +0 -94
  93. package/src/exporters/matrix/render-xlsx.ts +0 -420
  94. package/src/exporters/matrix/types.ts +0 -223
  95. package/src/exporters/matrix/wording.ts +0 -174
@@ -1,94 +0,0 @@
1
- /**
2
- * Flat CSV rendering of the matrix — same model as the workbook, one row per
3
- * delivery item (`Level: item`) followed by its variant rows (`Level: variant`;
4
- * every item has them — the variant row carries the source scenario id, data,
5
- * and result), so downstream pipelines can re-derive both views from one file.
6
- */
7
-
8
- import { variantState } from './build';
9
- import { coverageSummary, itemModeLabel, itemResultLabel } from './render-xlsx';
10
- import { MatrixModel } from './types';
11
-
12
- const HEADERS = [
13
- 'Level', 'ID', 'Target', 'Test Intent / Condition', 'Category', 'Priority',
14
- 'Precondition', 'Coverage / Test Data', 'Action / Trigger', 'Expected Result',
15
- 'Mode', 'Trace', 'Result', 'Executed Date', 'Note / Evidence', 'Defect ID',
16
- ];
17
-
18
- function esc(value: string): string {
19
- if (/[",\n]/.test(value)) return `"${value.replace(/"/g, '""')}"`;
20
- return value;
21
- }
22
-
23
- function isoDate(startTime: string | undefined): string {
24
- if (!startTime) return '';
25
- const d = new Date(startTime);
26
- if (isNaN(d.getTime())) return '';
27
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
28
- }
29
-
30
- export function renderMatrixCsv(model: MatrixModel): string {
31
- const BOM = '\ufeff'; // Excel compatibility (Vietnamese/Japanese content)
32
- const lines: string[] = [];
33
- lines.push(`# Test Case & Coverage Matrix — ${model.unit}`);
34
- lines.push(`# delivery items: ${model.manifest.itemCount} · coverage variants: ${model.manifest.variantCount} · state: ${model.manifest.approvalState}`);
35
- lines.push(HEADERS.map(esc).join(','));
36
-
37
- for (const item of model.items) {
38
- lines.push([
39
- 'item',
40
- item.id,
41
- item.target,
42
- item.intent,
43
- item.category,
44
- item.priority,
45
- item.precondition.join('\n'),
46
- coverageSummary(item),
47
- // Shared leading steps only; each variant row carries its remaining steps.
48
- item.trigger.join('\n'),
49
- item.oracle,
50
- itemModeLabel(item),
51
- item.traces.join(' '),
52
- itemResultLabel(item),
53
- '',
54
- item.review === 'proposed' ? 'REVIEW REQUIRED' : '',
55
- '',
56
- ].map(esc).join(','));
57
-
58
- for (const v of item.variants) {
59
- const expected = v.verification.length > 0
60
- ? `${v.oracle.join('\n')}\nVerification method: ${v.verification.join(' ')}`
61
- : v.oracle.join('\n');
62
- lines.push([
63
- 'variant',
64
- v.ref,
65
- '',
66
- v.condition,
67
- '', '',
68
- // Precondition DELTA — variant-specific setup only (review GAP-03).
69
- (item.preconditionDeltas[v.ref] ?? []).join('\n'),
70
- v.data.join('\n'),
71
- // Steps after the parent's shared prefix only.
72
- (item.triggerDeltas[v.ref] ?? []).join('\n'),
73
- expected,
74
- v.mode === 'manual' ? 'Manual' : 'Auto',
75
- v.traces.join(' '),
76
- variantState(v),
77
- isoDate(v.result?.startTime),
78
- v.result?.error ? String(v.result.error).slice(0, 200) : '',
79
- '',
80
- ].map(esc).join(','));
81
- }
82
- }
83
-
84
- // Requirement coverage appendix — keeps the CSV self-contained for pipelines.
85
- if (model.requirements.length > 0) {
86
- lines.push('');
87
- lines.push('# Requirement coverage');
88
- lines.push(['Requirement', 'Status', 'Delivery items', 'Variants', 'Note'].join(','));
89
- for (const r of model.requirements) {
90
- lines.push([r.id, r.status, r.items.join(' '), String(r.variantCount), r.note].map(esc).join(','));
91
- }
92
- }
93
- return BOM + lines.join('\n') + '\n';
94
- }
@@ -1,420 +0,0 @@
1
- /**
2
- * Render the Test Case & Coverage Matrix workbook.
3
- *
4
- * Sheets:
5
- * 1. Testcases — one parent row per delivery item; EVERY item (including
6
- * single-variant ones) carries variant sub-rows on Excel outline level 1 —
7
- * the sub-row is where source traceability (VP-id), test data, and the
8
- * manual result/evidence entry live (review B-05/B-06). Collapse outline
9
- * level 1 for the customer/review view; expand to execute.
10
- * 2. Coverage — requirement coverage (id ↔ items ↔ status), the target ×
11
- * category grid (explicit `—` gaps), dispositions, and the manifest.
12
- *
13
- * Manual-execution support: variant Result cells carry a dropdown
14
- * (Passed/Failed/Blocked/Pending/N/A) and the parent Result is a live Excel
15
- * formula derived from its children — a parent can never contradict its
16
- * variants, even after QA edits results by hand (review B-06).
17
- *
18
- * Every sheet keeps the company ISO masthead. A draft matrix (unapproved
19
- * groups / review findings) carries a red DRAFT banner.
20
- */
21
-
22
- import * as ExcelJS from 'exceljs';
23
- import {
24
- renderReportHeaderBand,
25
- allBordersBlack,
26
- ARIAL_FONT,
27
- BLACK,
28
- LAVENDER,
29
- } from '../xlsx-report-builder';
30
- import { variantState } from './build';
31
- import { DeliveryItem, MatrixModel, MapCategory } from './types';
32
-
33
- const CATEGORY_ORDER: MapCategory[] = ['normal', 'abnormal', 'security', 'nfr'];
34
- const SOFT_BLUE = { argb: 'FFDCE6F1' };
35
- const DRAFT_RED = { argb: 'FFC00000' };
36
- const GAP_FILL = { argb: 'FFFCE4EC' };
37
- const RESULT_STATES = 'Passed,Failed,Blocked,Pending,N/A';
38
-
39
- function headerCell(c: ExcelJS.Cell, label: string): void {
40
- c.value = label;
41
- c.font = { bold: true, size: 10, color: BLACK, name: ARIAL_FONT };
42
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: LAVENDER };
43
- c.alignment = { horizontal: 'center', vertical: 'middle', wrapText: true };
44
- c.border = allBordersBlack;
45
- }
46
-
47
- function dataCell(c: ExcelJS.Cell, value: ExcelJS.CellValue, opts?: { bold?: boolean; fill?: { argb: string }; center?: boolean; color?: { argb: string } }): void {
48
- // An empty value stays a genuinely blank cell — never an empty shared string,
49
- // which some renderers display as its string-table index (review M-03).
50
- if (value !== '' && value !== undefined && value !== null) c.value = value;
51
- c.font = { bold: opts?.bold ?? false, size: 10, name: ARIAL_FONT, ...(opts?.color ? { color: opts.color } : {}) };
52
- c.alignment = { horizontal: opts?.center ? 'center' : 'left', vertical: 'top', wrapText: true };
53
- c.border = allBordersBlack;
54
- if (opts?.fill) c.fill = { type: 'pattern', pattern: 'solid', fgColor: opts.fill };
55
- }
56
-
57
- /** Mode is a coverage dimension: mixed items show both counts. */
58
- export function itemModeLabel(item: DeliveryItem): string {
59
- if (item.mode === 'mixed') {
60
- const auto = item.variants.filter((v) => v.mode === 'auto').length;
61
- return `Auto ${auto} · Manual ${item.variants.length - auto}`;
62
- }
63
- return item.mode === 'manual' ? 'Manual' : 'Auto';
64
- }
65
-
66
- /**
67
- * Parent roll-up label. It must NEVER be exactly one of the variant state words
68
- * (`Passed`/`Failed`/`Blocked`/`Pending`/`N/A`) — the summary band counts the
69
- * Result column with exact-match COUNTIF over parent AND child rows, so a parent
70
- * reading plain "Pending" was counted as an extra pending variant (109 instead
71
- * of 77 on st-login).
72
- */
73
- export function itemResultLabel(item: DeliveryItem): string {
74
- const { passed, failed, blocked, na } = item.resultCounts;
75
- const eff = item.variants.length - na;
76
- const suffix = na > 0 ? ` · ${na} N/A` : '';
77
- if (item.result === 'na') return 'All N/A';
78
- if (item.result === 'failed') return `${passed}/${eff} Passed · ${failed} Failed${suffix}`;
79
- if (item.result === 'blocked') return `${passed}/${eff} Passed · ${blocked} Blocked${suffix}`;
80
- return `${passed}/${eff} Passed${suffix}`;
81
- }
82
-
83
- /** ISO date (2026-08-04) — unambiguous across locales (review §9). */
84
- function isoDate(startTime: string | undefined): string {
85
- if (!startTime) return '';
86
- const d = new Date(startTime);
87
- if (isNaN(d.getTime())) return '';
88
- return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`;
89
- }
90
-
91
- function numbered(lines: string[], start = 1): string {
92
- if (lines.length === 0) return '';
93
- if (lines.length === 1 && start === 1) return lines[0];
94
- return lines.map((l, i) => `${start + i}. ${l}`).join('\n');
95
- }
96
-
97
- /**
98
- * Compact coverage summary for the parent row. A declared `dimensions:` digest
99
- * wins ("15 variants — required ×3 · format ×9 …"); otherwise a single variant
100
- * shows its condition and a group falls back to its variant REFS. Concatenating
101
- * every variant's full title turned this cell into an 800-character paragraph.
102
- */
103
- export function coverageSummary(item: DeliveryItem): string {
104
- const n = item.variants.length;
105
- const head = `${n} variant${n === 1 ? '' : 's'}:`;
106
- if (item.dimensions) return `${head} ${item.dimensions}`;
107
- if (n === 1) return `${head} ${item.variants[0].condition}`;
108
- return `${head} ${item.variants.map((v) => v.ref).join(' · ')}`;
109
- }
110
-
111
- /** Expected cell = observable outcomes; the HOW moves under a separate heading. */
112
- function expectedWithVerification(oracle: string[], verification: string[]): string {
113
- const expected = numbered(oracle);
114
- if (verification.length === 0) return expected;
115
- return `${expected}\nVerification method: ${verification.join(' ')}`;
116
- }
117
-
118
- /** Red DRAFT banner on row 5 when the matrix is not approved for official delivery. */
119
- function draftBanner(ws: ExcelJS.Worksheet, model: MatrixModel): void {
120
- if (model.manifest.approvalState !== 'draft') return;
121
- ws.mergeCells('B5:H5');
122
- const c = ws.getCell('B5');
123
- c.value = 'DRAFT — NOT APPROVED FOR OFFICIAL DELIVERY (review-required findings or proposed groups remain)';
124
- c.font = { bold: true, size: 11, name: ARIAL_FONT, color: { argb: 'FFFFFFFF' } };
125
- c.fill = { type: 'pattern', pattern: 'solid', fgColor: DRAFT_RED };
126
- c.alignment = { horizontal: 'center', vertical: 'middle' };
127
- }
128
-
129
- // ---------------------------------------------------------------------------
130
- // Sheet 1 — Testcases (the matrix)
131
- // ---------------------------------------------------------------------------
132
-
133
- const MATRIX_HEADERS = [
134
- 'ID', 'Target', 'Test Intent / Condition', 'Category', 'Priority', 'Precondition',
135
- 'Coverage / Test Data', 'Action / Trigger', 'Expected Result', 'Mode', 'Trace',
136
- 'Result', 'Executed Date', 'Executor', 'Note / Evidence', 'Defect ID',
137
- ];
138
- const RESULT_COL = 13; // column M
139
-
140
- function addMatrixSheet(wb: ExcelJS.Workbook, model: MatrixModel, sungenVersion?: string): void {
141
- const ws = wb.addWorksheet('Testcases');
142
- ws.properties.outlineLevelRow = 1;
143
-
144
- ws.columns = [
145
- { width: 3 }, // A margin
146
- { width: 22 }, // B ID
147
- { width: 18 }, // C Target
148
- { width: 42 }, // D Intent / Condition
149
- { width: 11 }, // E Category
150
- { width: 9 }, // F Priority
151
- { width: 26 }, // G Precondition
152
- { width: 34 }, // H Coverage / Data
153
- { width: 34 }, // I Trigger
154
- { width: 42 }, // J Expected
155
- { width: 11 }, // K Mode
156
- { width: 13 }, // L Trace
157
- { width: 22 }, // M Result
158
- { width: 12 }, // N Executed
159
- { width: 13 }, // O Executor
160
- { width: 22 }, // P Note / Evidence
161
- { width: 12 }, // Q Defect ID
162
- ];
163
-
164
- renderReportHeaderBand(wb, ws, `${model.unit.toUpperCase()} TEST CASE & COVERAGE MATRIX`, sungenVersion, model.formNo);
165
- draftBanner(ws, model);
166
-
167
- // Summary band (row 6) — items vs variants stay separate metrics by design (I8).
168
- // The execution counters are LIVE formulas over the variant Result cells, so
169
- // hand-entered results update the totals (review GAP-06). Variant cells hold the
170
- // exact state words and parent cells NEVER do (itemResultLabel + the roll-up
171
- // formula always compose a "n/m Passed …" label), so exact-match COUNTIF over
172
- // the whole column counts variants only.
173
- const sum = (k: 'passed' | 'failed' | 'blocked' | 'notRun' | 'na'): number =>
174
- model.items.reduce((a, i) => a + i.resultCounts[k], 0);
175
- const passed = sum('passed');
176
- const failed = sum('failed');
177
- const blocked = sum('blocked');
178
- const notRun = sum('notRun');
179
- const na = sum('na');
180
- const RANGE = 'M9:M10000';
181
- const band = ws.getRow(6);
182
- const bandCells: Array<[string, ExcelJS.CellValue]> = [
183
- ['items', `Delivery items: ${model.manifest.itemCount}`],
184
- ['variants', `Coverage variants: ${model.manifest.variantCount}`],
185
- ['passed', { formula: `"Passed: "&COUNTIF(${RANGE},"Passed")`, result: `Passed: ${passed}` } as ExcelJS.CellValue],
186
- ['failed', { formula: `"Failed: "&COUNTIF(${RANGE},"Failed")`, result: `Failed: ${failed}` } as ExcelJS.CellValue],
187
- ['blocked', { formula: `"Blocked: "&COUNTIF(${RANGE},"Blocked")`, result: `Blocked: ${blocked}` } as ExcelJS.CellValue],
188
- ['pending', { formula: `"Pending: "&COUNTIF(${RANGE},"Pending")`, result: `Pending: ${notRun}` } as ExcelJS.CellValue],
189
- ['na', { formula: `"N/A: "&COUNTIF(${RANGE},"N/A")`, result: `N/A: ${na}` } as ExcelJS.CellValue],
190
- ];
191
- bandCells.forEach(([, v], i) => {
192
- const c = band.getCell(2 + i);
193
- dataCell(c, v, { bold: true, fill: SOFT_BLUE, center: true });
194
- });
195
-
196
- const HEADER_ROW = 8;
197
- const hr = ws.getRow(HEADER_ROW);
198
- hr.height = 28;
199
- MATRIX_HEADERS.forEach((label, i) => headerCell(hr.getCell(2 + i), label));
200
-
201
- let rowIdx = HEADER_ROW + 1;
202
- for (const item of model.items) {
203
- const parentRowIdx = rowIdx++;
204
-
205
- // --- Variant sub-rows FIRST (to know their cell range for the parent formula).
206
- // Every item gets sub-rows — the sub-row is where the source scenario id, the
207
- // resolved data, and the manual result/evidence entry live (review B-05).
208
- const firstChild = rowIdx;
209
- // Delta-only sub-rows (review GAP-01): content identical across the whole
210
- // item lives ONCE on the parent — a child repeats only what distinguishes it.
211
- // The child's Expected Result is always kept: it is the precise source
212
- // oracle (the semantic anchor), not a repetition of the parent's summary.
213
- for (const v of item.variants) {
214
- const vr = ws.getRow(rowIdx++);
215
- vr.outlineLevel = 1;
216
- const vValues: ExcelJS.CellValue[] = [
217
- v.ref,
218
- '',
219
- v.condition,
220
- '', '',
221
- numbered(item.preconditionDeltas[v.ref] ?? []),
222
- numbered(v.data),
223
- // Only the steps after the parent's shared prefix, numbered so the
224
- // parent's steps + these read as one continuous procedure.
225
- numbered(item.triggerDeltas[v.ref] ?? [], item.trigger.length + 1),
226
- expectedWithVerification(v.oracle, v.verification),
227
- v.mode === 'manual' ? `Manual${v.manualReason ? ` (${v.manualReason})` : ''}` : 'Auto',
228
- v.traces.join(', '),
229
- variantState(v),
230
- isoDate(v.result?.startTime),
231
- '',
232
- v.result?.error ? String(v.result.error).slice(0, 200) : '',
233
- '',
234
- ];
235
- vValues.forEach((val, i) => dataCell(vr.getCell(2 + i), val, { center: i === 9 }));
236
- // Manual-execution entry: constrain the Result cell to the known states.
237
- vr.getCell(2 + 11).dataValidation = {
238
- type: 'list', allowBlank: true, formulae: [`"${RESULT_STATES}"`],
239
- };
240
- }
241
- const lastChild = rowIdx - 1;
242
-
243
- // --- Parent row: only values that are genuinely COMMON to the whole item
244
- // (review M-04); everything variant-specific stays on the sub-rows.
245
- const pr = ws.getRow(parentRowIdx);
246
- const coverage = coverageSummary(item);
247
-
248
- // Live roll-up derived from the child Result cells — precedence
249
- // failed → blocked → pending → partial → passed. N/A variants leave the
250
- // denominator (review GAP-06): eff = n − COUNTIF(N/A); all-N/A → "N/A".
251
- const rng = `M${firstChild}:M${lastChild}`;
252
- const n = item.variants.length;
253
- const EFF = `(${n}-COUNTIF(${rng},"N/A"))`;
254
- const NA = `IF(COUNTIF(${rng},"N/A")>0," · "&COUNTIF(${rng},"N/A")&" N/A","")`;
255
- // Mirrors itemResultLabel exactly — and never yields a bare state word.
256
- const rollUpFormula =
257
- `IF(COUNTIF(${rng},"Failed")>0,COUNTIF(${rng},"Passed")&"/"&${EFF}&" Passed · "&COUNTIF(${rng},"Failed")&" Failed"&${NA},` +
258
- `IF(COUNTIF(${rng},"Blocked")>0,COUNTIF(${rng},"Passed")&"/"&${EFF}&" Passed · "&COUNTIF(${rng},"Blocked")&" Blocked"&${NA},` +
259
- `IF(${EFF}=0,"All N/A",` +
260
- `COUNTIF(${rng},"Passed")&"/"&${EFF}&" Passed"&${NA})))`;
261
-
262
- const values: ExcelJS.CellValue[] = [
263
- item.id,
264
- item.target,
265
- item.intent,
266
- item.category,
267
- item.priority,
268
- numbered(item.precondition),
269
- coverage,
270
- // The shared leading steps; each variant's remaining steps sit on its sub-row.
271
- numbered(item.trigger),
272
- item.oracle,
273
- itemModeLabel(item),
274
- item.traces.join(', '),
275
- { formula: rollUpFormula, result: itemResultLabel(item) } as ExcelJS.CellValue,
276
- '',
277
- '',
278
- item.review === 'proposed' ? 'REVIEW REQUIRED' : '',
279
- '',
280
- ];
281
- values.forEach((v, i) => dataCell(pr.getCell(2 + i), v, {
282
- bold: true,
283
- fill: SOFT_BLUE,
284
- center: i === 3 || i === 4 || i === 9,
285
- ...(i === 14 && item.review === 'proposed' ? { color: DRAFT_RED } : {}),
286
- }));
287
- }
288
-
289
- ws.autoFilter = { from: { row: HEADER_ROW, column: 2 }, to: { row: rowIdx - 1, column: 17 } };
290
- // Freeze the header band AND the ID + Target columns (review §9).
291
- ws.views = [{ state: 'frozen', xSplit: 3, ySplit: HEADER_ROW }];
292
- // Print: landscape, fit width only (never squash all rows into one page),
293
- // repeat the masthead + header rows on every page (review GAP-08).
294
- ws.pageSetup = {
295
- orientation: 'landscape',
296
- fitToPage: true,
297
- fitToWidth: 1,
298
- fitToHeight: 0,
299
- printTitlesRow: '1:8',
300
- };
301
- }
302
-
303
- // ---------------------------------------------------------------------------
304
- // Sheet 2 — Coverage (requirements + overview grid + dispositions + manifest)
305
- // ---------------------------------------------------------------------------
306
-
307
- function addCoverageSheet(wb: ExcelJS.Workbook, model: MatrixModel, sungenVersion?: string): void {
308
- const ws = wb.addWorksheet('Coverage');
309
- ws.columns = [
310
- { width: 3 }, { width: 22 }, { width: 18 }, { width: 16 }, { width: 16 }, { width: 16 },
311
- { width: 16 }, { width: 44 },
312
- ];
313
- renderReportHeaderBand(wb, ws, `${model.unit.toUpperCase()} COVERAGE OVERVIEW`, sungenVersion, model.formNo);
314
- draftBanner(ws, model);
315
-
316
- let rowIdx = 7;
317
-
318
- // --- Requirement coverage (review §6): every requirement id gets ONE explicit status.
319
- if (model.requirements.length > 0) {
320
- dataCell(ws.getRow(rowIdx).getCell(2), 'Requirement coverage — every id has an explicit status', { bold: true });
321
- rowIdx += 1;
322
- const rh = ws.getRow(rowIdx);
323
- ws.mergeCells(rowIdx, 4, rowIdx, 6);
324
- headerCell(rh.getCell(2), 'Requirement');
325
- headerCell(rh.getCell(3), 'Status');
326
- headerCell(rh.getCell(4), 'Delivery items');
327
- headerCell(rh.getCell(7), 'Variants');
328
- headerCell(rh.getCell(8), 'Note');
329
- rowIdx += 1;
330
- for (const r of model.requirements) {
331
- const row = ws.getRow(rowIdx++);
332
- dataCell(row.getCell(2), r.id, { bold: true });
333
- dataCell(row.getCell(3), r.status, {
334
- center: true,
335
- ...(r.status === 'gap' ? { fill: GAP_FILL, bold: true } : {}),
336
- });
337
- ws.mergeCells(rowIdx - 1, 4, rowIdx - 1, 6);
338
- dataCell(row.getCell(4), r.items.join(', '));
339
- dataCell(row.getCell(7), r.variantCount > 0 ? String(r.variantCount) : '', { center: true });
340
- dataCell(row.getCell(8), r.note);
341
- }
342
- rowIdx += 1;
343
- }
344
-
345
- // --- Target × category grid ---
346
- dataCell(ws.getRow(rowIdx).getCell(2), 'Coverage matrix — delivery items (coverage variants) per target × category', { bold: true });
347
- rowIdx += 1;
348
- const gridHeader = ws.getRow(rowIdx++);
349
- headerCell(gridHeader.getCell(2), 'Target');
350
- CATEGORY_ORDER.forEach((cat, i) => headerCell(gridHeader.getCell(3 + i), cat));
351
- headerCell(gridHeader.getCell(3 + CATEGORY_ORDER.length), 'Total');
352
-
353
- const targets = Array.from(new Set(model.items.map((i) => i.target)));
354
- for (const target of targets) {
355
- const row = ws.getRow(rowIdx++);
356
- dataCell(row.getCell(2), target, { bold: true });
357
- let totalItems = 0;
358
- let totalVariants = 0;
359
- CATEGORY_ORDER.forEach((cat, i) => {
360
- const cell = row.getCell(3 + i);
361
- const items = model.items.filter((it) => it.target === target && it.category === cat);
362
- const variants = items.reduce((a, it) => a + it.variants.length, 0);
363
- totalItems += items.length;
364
- totalVariants += variants;
365
- // `—` is an explicit statement: this target × category cell has NO coverage.
366
- dataCell(cell, items.length === 0 ? '—' : `${items.length} (${variants})`, {
367
- center: true,
368
- ...(items.length === 0 ? { fill: GAP_FILL } : {}),
369
- });
370
- });
371
- dataCell(row.getCell(3 + CATEGORY_ORDER.length), `${totalItems} (${totalVariants})`, { center: true, bold: true });
372
- }
373
-
374
- // --- Dispositions ---
375
- if (model.dispositions.length > 0) {
376
- rowIdx += 1;
377
- dataCell(ws.getRow(rowIdx).getCell(2), 'Not in the matrix (explicit dispositions)', { bold: true });
378
- rowIdx += 1;
379
- const dh = ws.getRow(rowIdx++);
380
- ['Source', 'Disposition', 'Reason', 'Title'].forEach((l, i) => headerCell(dh.getCell(2 + i), l));
381
- for (const d of model.dispositions) {
382
- const row = ws.getRow(rowIdx++);
383
- dataCell(row.getCell(2), d.vpId);
384
- dataCell(row.getCell(3), d.as, { center: true });
385
- dataCell(row.getCell(4), d.reason);
386
- dataCell(row.getCell(5), d.title);
387
- }
388
- }
389
-
390
- // --- Manifest ---
391
- rowIdx += 1;
392
- dataCell(ws.getRow(rowIdx).getCell(2), 'Generation manifest', { bold: true });
393
- rowIdx += 1;
394
- const m = model.manifest;
395
- const manifestRows: Array<[string, string]> = [
396
- ['Unit', m.unit],
397
- ['Approval state', m.approvalState],
398
- ['Delivery items', String(m.itemCount)],
399
- ['Coverage variants', String(m.variantCount)],
400
- ['Source fingerprint', m.sourceFingerprint],
401
- ['Map fingerprint', m.mapFingerprint],
402
- ['Transformer version', m.transformerVersion],
403
- ['Max variants / item (warn)', String(m.thresholds.maxVariantsPerItem)],
404
- ];
405
- for (const [k, v] of manifestRows) {
406
- const row = ws.getRow(rowIdx++);
407
- dataCell(row.getCell(2), k, { bold: true, fill: SOFT_BLUE });
408
- ws.mergeCells(rowIdx - 1, 3, rowIdx - 1, 7);
409
- dataCell(row.getCell(3), v);
410
- }
411
- }
412
-
413
- // ---------------------------------------------------------------------------
414
-
415
- export function renderMatrixXlsx(model: MatrixModel, sungenVersion?: string): ExcelJS.Workbook {
416
- const wb = new ExcelJS.Workbook();
417
- addMatrixSheet(wb, model, sungenVersion);
418
- addCoverageSheet(wb, model, sungenVersion);
419
- return wb;
420
- }