@v11g/agents-rock 1.0.3 → 1.0.5

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 (61) hide show
  1. package/README.md +4 -2
  2. package/package.json +1 -1
  3. package/plugins/business-analyst/.claude-plugin/plugin.json +1 -1
  4. package/plugins/business-analyst/skills/business-analyst/README.md +4 -1
  5. package/plugins/business-analyst/skills/business-analyst/SKILL.md +6 -2
  6. package/plugins/business-analyst/skills/business-analyst/scripts/test/python-parity.test.mjs +50 -0
  7. package/plugins/business-analyst/skills/business-analyst/scripts/validate.py +288 -0
  8. package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
  9. package/plugins/solution-architect/skills/analyze-requirements/assets/viewer-template.html +4 -2
  10. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/chrome.mjs +4 -1
  11. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/viewer-template.test.mjs +3 -2
  12. package/plugins/solution-architect/skills/estimate/README.md +8 -5
  13. package/plugins/solution-architect/skills/estimate/SKILL.md +9 -5
  14. package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +142 -376
  15. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +610 -601
  16. package/plugins/solution-architect/skills/estimate/assets/scores-review-template.html +118 -0
  17. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +5 -9
  18. package/plugins/solution-architect/skills/estimate/references/interview.md +121 -10
  19. package/plugins/solution-architect/skills/estimate/references/scoring-guide.md +23 -0
  20. package/plugins/solution-architect/skills/estimate/references/techniques.md +9 -2
  21. package/plugins/solution-architect/skills/estimate/references/writing.md +21 -5
  22. package/plugins/solution-architect/skills/estimate/scripts/lib/agentic-checks.mjs +1 -1
  23. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +4 -30
  24. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +14 -10
  25. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +6 -8
  26. package/plugins/solution-architect/skills/estimate/scripts/lib/md-tables.mjs +31 -0
  27. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +14 -3
  28. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +5 -4
  29. package/plugins/solution-architect/skills/estimate/scripts/lib/scenario-schema.mjs +39 -0
  30. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +4 -14
  31. package/plugins/solution-architect/skills/estimate/scripts/lib/score-csv.mjs +58 -0
  32. package/plugins/solution-architect/skills/estimate/scripts/lib/score-diff.mjs +30 -0
  33. package/plugins/solution-architect/skills/estimate/scripts/lib/score-html.mjs +17 -0
  34. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring-checks.mjs +24 -0
  35. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring-schema.mjs +48 -0
  36. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring.mjs +45 -0
  37. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +14 -13
  38. package/plugins/solution-architect/skills/estimate/scripts/score-review.mjs +59 -0
  39. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +403 -316
  40. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +25 -1
  41. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +29 -10
  42. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +2 -2
  43. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +21 -3
  44. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +1 -1
  45. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +4 -4
  46. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +61 -6
  47. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +96 -13
  48. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +105 -4
  49. package/plugins/solution-architect/skills/estimate/scripts/test/score-review.test.mjs +187 -0
  50. package/plugins/solution-architect/skills/estimate/scripts/test/scoring.test.mjs +49 -0
  51. package/plugins/solution-architect/skills/estimate/scripts/test/url-state.test.mjs +198 -0
  52. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +38 -0
  53. package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +93 -28
  54. package/plugins/solution-architect/skills/new-lead/assets/dashboard/detail.html +25 -50
  55. package/plugins/solution-architect/skills/new-lead/assets/dashboard/index.html +20 -40
  56. package/plugins/solution-architect/skills/new-lead/scripts/lib/map-nodes.mjs +13 -5
  57. package/plugins/solution-architect/skills/new-lead/scripts/serve.mjs +8 -3
  58. package/plugins/solution-architect/skills/new-lead/scripts/test/map.test.mjs +4 -0
  59. package/plugins/solution-architect/skills/new-lead/scripts/test/serve.test.mjs +25 -21
  60. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +2 -2
  61. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +1 -1
@@ -7,177 +7,35 @@ import { join } from 'node:path';
7
7
  import { pathToFileURL } from 'node:url';
8
8
  import { findChrome } from '../../../analyze-requirements/scripts/lib/chrome.mjs';
9
9
  import { openPage } from '../../../analyze-requirements/scripts/lib/cdp.mjs';
10
- import {
11
- pert, taskHours, scenarioRollup, riskBufferHours, projectBuffer, dominantSeniority,
12
- } from '../lib/estimate-math.mjs';
13
10
 
14
11
  const skip = { skip: !findChrome() && 'no chrome on PATH' };
15
12
  const fixture = new URL('./fixtures/booking-inputs.json', import.meta.url).pathname;
16
13
 
17
- function buildPage(extra = []) {
14
+ function buildPage(extra = [], inputsPath = fixture) {
18
15
  const dir = mkdtempSync(join(tmpdir(), 'estimate-browser-'));
19
16
  const scripts = new URL('..', import.meta.url).pathname;
20
17
  const passMd = join(scripts, 'test/fixtures/estimation-pass.md');
21
- execFileSync('node', [join(scripts, 'compute.mjs'), '--inputs', fixture, '--out', join(dir, 'estimation.json')]);
18
+ execFileSync('node', [join(scripts, 'compute.mjs'), '--inputs', inputsPath, '--out', join(dir, 'estimation.json')]);
22
19
  execFileSync('node', [join(scripts, 'render.mjs'), '--json', join(dir, 'estimation.json'), '--md', passMd, '--out', dir, ...extra]);
23
20
  return pathToFileURL(join(dir, 'estimate.html')).href;
24
21
  }
25
22
 
26
- function nodeRecompute(p) {
23
+ // The booking inputs with a mutation applied, for pages whose shape depends
24
+ // on the scenarios.
25
+ function buildPageWith(mutate) {
26
+ const dir = mkdtempSync(join(tmpdir(), 'estimate-browser-inputs-'));
27
27
  const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
28
- const tasks = inputs.features.flatMap((f) => f.tasks);
29
- const seniority = dominantSeniority(p.team);
30
- const hoursOf = (t) => taskHours({ e: pert(t).e, seniority, plan: p.plan,
31
- category: t.category, verificationPct: inputs.verificationPct, scale: p.aiScale });
32
- const dev = tasks.reduce((s, t) => s + hoursOf(t), 0);
33
- const buffers = (riskBufferHours(inputs.risks) + projectBuffer(tasks.map((t) => pert(t).sigma))) * p.bufferScale;
34
- const hours = dev + dev * p.overheadPct + buffers;
35
- return { hours, ...scenarioRollup({ hours, team: p.team, plan: p.plan }) };
28
+ mutate(inputs);
29
+ writeFileSync(join(dir, 'inputs.json'), JSON.stringify(inputs));
30
+ return buildPage([], join(dir, 'inputs.json'));
36
31
  }
37
32
 
38
- // A mixed roster on purpose: effort follows the dominant seniority (mid),
39
- // labor cost follows each member's own rate.
40
- const PARAMS = {
41
- team: [{ seniority: 'senior', rate: 60 }, { seniority: 'mid', rate: 45 }, { seniority: 'mid', rate: 45 }],
42
- plan: 'max5x', aiScale: 1, bufferScale: 1, overheadPct: 0.35,
43
- };
44
-
45
- test('page boots without console errors and browser math equals node math', skip, async () => {
46
- const page = await openPage(buildPage());
47
- try {
48
- const got = await page.eval(`window.__recompute(${JSON.stringify(PARAMS)})`);
49
- const want = nodeRecompute(PARAMS);
50
- for (const key of ['hours', 'months', 'totalCost']) {
51
- assert.ok(Math.abs(got[key] - want[key]) < 1e-6, `${key}: ${got[key]} != ${want[key]}`);
52
- }
53
- assert.deepEqual(page.errors, []);
54
- } finally { page.close(); }
55
- });
56
-
57
- // The bug this guards against: the old rail replicated team[0].rate across
58
- // the whole team, so its resting numbers disagreed with the committed card
59
- // it claims to reproduce (2×$60 instead of $60+$45 on the fixture).
60
- test('the rail at rest reproduces the committed recommended scenario', skip, async () => {
61
- const page = await openPage(buildPage());
62
- try {
63
- const { got, want } = await page.eval(`(() => {
64
- const rec = DATA.inputs.scenarios.find((s) => s.id === DATA.inputs.recommendedScenario);
65
- return { got: window.__recompute({ team: rec.team, plan: rec.plan,
66
- aiScale: 1, bufferScale: 1, overheadPct: DATA.inputs.overheadPct }),
67
- want: DATA.computed.scenarios[rec.id] };
68
- })()`);
69
- for (const key of ['hours', 'months', 'totalCost']) {
70
- // committed numbers are round2'd — compare at that grain
71
- assert.ok(Math.abs(got[key] - want[key]) < 0.005, `${key}: ${got[key]} != ${want[key]}`);
72
- }
73
- } finally { page.close(); }
74
- });
75
-
76
- const readRoster = (page) => page.eval(`[...document.querySelectorAll('#ctl-team .team-row')].map((r) => ({
77
- seniority: r.querySelector('select').value, rate: Number(r.querySelector('input').value) }))`);
78
-
79
- test('the roster boots as the recommended team, one row per member', skip, async () => {
80
- const page = await openPage(buildPage());
81
- try {
82
- const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
83
- const rec = inputs.scenarios.find((s) => s.id === inputs.recommendedScenario);
84
- assert.deepEqual(await readRoster(page), rec.team);
85
- // seniority options come from SENIORITY_FACTOR, not a hand-written triple
86
- assert.deepEqual(await page.eval(
87
- `[...document.querySelector('#ctl-team select').options].map((o) => o.value)`),
88
- ['junior', 'mid', 'senior']);
89
- } finally { page.close(); }
90
- });
91
-
92
- // Rates ride with seniority: the committed scenarios are the page's only
93
- // rate table (booking fixture: junior 30, mid 45, senior 60), so switching
94
- // a row's level re-seeds its rate — still hand-editable afterwards.
95
- test('switching a row seniority re-seeds its rate from the committed scenarios', skip, async () => {
96
- const page = await openPage(buildPage());
97
- try {
98
- const readout = () => page.eval(`document.getElementById('whatif-readout').textContent`);
99
- const before = await readout();
100
- await page.eval(`(() => {
101
- const sel = document.querySelector('#ctl-team .team-row select');
102
- sel.value = 'junior'; sel.dispatchEvent(new Event('input', { bubbles: true }));
103
- })()`);
104
- assert.deepEqual((await readRoster(page))[0], { seniority: 'junior', rate: 30 });
105
- assert.notEqual(await readout(), before, 'the readout must follow the re-seeded rate');
106
- } finally { page.close(); }
107
- });
108
-
109
- test('every rate input carries a dollar-sign prefix', skip, async () => {
110
- const page = await openPage(buildPage());
111
- try {
112
- const cur = await page.eval(
113
- `[...document.querySelectorAll('#ctl-team .team-row .cur')].map((c) => c.textContent)`);
114
- assert.deepEqual(cur, ['$', '$']);
115
- } finally { page.close(); }
116
- });
117
-
118
- test('adding and removing a row recalculates with the coordination tax', skip, async () => {
119
- const page = await openPage(buildPage());
120
- try {
121
- const months = () => page.eval(
122
- `parseFloat(document.querySelector('#whatif-readout .num').textContent)`);
123
- const before = await months();
124
- await page.eval(`document.querySelector('#ctl-team .team-add').click()`);
125
- const rows = await readRoster(page);
126
- assert.equal(rows.length, 3);
127
- assert.deepEqual(rows[2], rows[1], 'a new row clones the last one');
128
- assert.ok(await months() < before, `three engineers must finish sooner than two`);
129
- await page.eval(`document.querySelector('#ctl-team .team-row:last-of-type .team-del').click()`);
130
- assert.equal(await months(), before);
131
- } finally { page.close(); }
132
- });
133
33
 
134
- test('the roster is capped between one and eight engineers', skip, async () => {
135
- const page = await openPage(buildPage());
136
- try {
137
- const count = () => page.eval(`document.querySelectorAll('#ctl-team .team-row').length`);
138
- // clicks are synchronous in-page; a disabled button ignores them, so
139
- // over-clicking in one eval is exactly the user mashing the button
140
- await page.eval(`for (let i = 0; i < 10; i++) document.querySelector('#ctl-team .team-add').click()`);
141
- assert.equal(await count(), 8);
142
- assert.equal(await page.eval(`document.querySelector('#ctl-team .team-add').disabled`), true);
143
- await page.eval(
144
- `for (let i = 0; i < 10; i++) document.querySelector('#ctl-team .team-row:last-of-type .team-del').click()`);
145
- assert.equal(await count(), 1);
146
- assert.equal(await page.eval(`document.querySelector('#ctl-team .team-del').disabled`), true);
147
- } finally { page.close(); }
148
- });
149
-
150
- test('the scenario cards show only committed scenarios — the rail owns what-if', skip, async () => {
151
- const page = await openPage(buildPage());
152
- try {
153
- const inputs = JSON.parse(readFileSync(fixture, 'utf8'));
154
- const cards = await page.eval(`[...document.querySelectorAll('#scenario-cards .scenario h3')].map((h) => h.textContent)`);
155
- assert.deepEqual(cards.sort(), inputs.scenarios.map((s) => s.id).sort());
156
- const bars = await page.eval(`[...document.querySelectorAll('#cost-bars .bar-label')].map((b) => b.textContent)`);
157
- assert.ok(!bars.some((b) => b.startsWith('custom')), `custom bar leaked: ${bars}`);
158
- } finally { page.close(); }
159
- });
160
-
161
- test('moving a control shows the banner; reset rebuilds the default roster', skip, async () => {
162
- const page = await openPage(buildPage());
163
- try {
164
- await page.eval(`(() => {
165
- const ctl = document.querySelector('#ctl-team .team-row input');
166
- ctl.value = '80'; ctl.dispatchEvent(new Event('input', { bubbles: true }));
167
- })()`);
168
- assert.equal(await page.eval(`document.getElementById('modified-banner').hidden`), false);
169
- await page.eval(`document.querySelector('#ctl-team .team-add').click()`);
170
- await page.eval(`document.getElementById('reset').click()`);
171
- assert.equal(await page.eval(`document.getElementById('modified-banner').hidden`), true);
172
- assert.equal(await page.eval(`document.querySelectorAll('#ctl-team .team-row').length`), 2);
173
- assert.equal(await page.eval(`document.querySelector('#ctl-team .team-row input').value`), '60');
174
- } finally { page.close(); }
175
- });
176
34
 
177
35
  test('every section explains itself: help icons plus a rendered method section', skip, async () => {
178
36
  const page = await openPage(buildPage());
179
37
  try {
180
- assert.ok(await page.eval(`document.querySelectorAll('details.help').length >= 6`),
38
+ assert.ok(await page.eval(`document.querySelectorAll('details.help').length >= 5`),
181
39
  'expected a help icon per section');
182
40
  const method = await page.eval(`document.getElementById('method').textContent`);
183
41
  assert.match(method, /three-point-pert/); // technique named from inputs
@@ -190,26 +48,12 @@ test('every section explains itself: help icons plus a rendered method section',
190
48
  } finally { page.close(); }
191
49
  });
192
50
 
193
- test('the what-if rail shows a live readout that tracks control changes', skip, async () => {
194
- const page = await openPage(buildPage());
195
- try {
196
- const read = () => page.eval(`document.getElementById('whatif-readout').textContent`);
197
- const before = await read();
198
- assert.match(before, /months/);
199
- await page.eval(`(() => {
200
- const sel = document.querySelector('#ctl-team .team-row select');
201
- sel.value = 'junior'; sel.dispatchEvent(new Event('input', { bubbles: true }));
202
- })()`);
203
- assert.notEqual(await read(), before);
204
- } finally { page.close(); }
205
- });
206
-
207
51
  test('client view hides internals; theme toggle flips the root attribute', skip, async () => {
208
52
  const page = await openPage(buildPage());
209
53
  try {
210
54
  await page.eval(`document.getElementById('view-toggle').click()`);
211
55
  assert.equal(await page.eval(
212
- `getComputedStyle(document.getElementById('controls')).display`), 'none');
56
+ `getComputedStyle(document.querySelector('#summary .alts')).display`), 'none');
213
57
  await page.eval(`document.getElementById('theme-toggle').click()`);
214
58
  assert.equal(await page.eval(`document.documentElement.dataset.theme`), 'light');
215
59
  } finally { page.close(); }
@@ -220,7 +64,7 @@ test('the --client-only page boots clean without its stripped controls', skip, a
220
64
  try {
221
65
  assert.deepEqual(page.errors, []); // stripped nodes must be null-guarded, not assumed
222
66
  assert.equal(await page.eval(`document.getElementById('ctl-team')`), null);
223
- for (const id of ['scenario-cards', 'feature-table', 'register', 'method', 'roadmap', 'containers']) {
67
+ for (const id of ['summary', 'feature-table', 'register', 'method', 'roadmap', 'containers']) {
224
68
  assert.ok(await page.eval(`document.getElementById('${id}').children.length > 0`),
225
69
  `${id} empty on client-only page`);
226
70
  }
@@ -232,13 +76,13 @@ test('feature breakdown absorbs the effort chart and the task register', skip, a
232
76
  try {
233
77
  assert.equal(await page.eval(`document.getElementById('timeline')`), null);
234
78
  const names = await page.eval(
235
- `[...document.querySelectorAll('#feature-table tr.feat-row td:first-child')].map((c) => c.textContent.trim())`);
79
+ `[...document.querySelectorAll('#panel-estimate tr.feat-row td:first-child')].map((c) => c.textContent.trim())`);
236
80
  assert.equal(names.length, 2);
237
81
  assert.match(names[0], /book appointment/); // hours desc by default
238
- assert.equal(await page.eval(`document.querySelectorAll('#feature-table .bd-fill').length`), 2);
82
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-estimate .bd-fill').length`), 2);
239
83
  // per-feature confidence chip is the worst task confidence (booking: HIGH+MED → MED)
240
84
  const conf = await page.eval(
241
- `[...document.querySelectorAll('#feature-table tr.feat-row .conf')].map((c) => c.textContent)`);
85
+ `[...document.querySelectorAll('#panel-estimate tr.feat-row .conf')].map((c) => c.textContent)`);
242
86
  assert.deepEqual(conf, ['MED', 'MED']);
243
87
  // the flat task register is gone; the risk register keeps its own section
244
88
  const captions = await page.eval(
@@ -253,12 +97,12 @@ test('breakdown headers sort: effort toggles to ascending on click', skip, async
253
97
  const page = await openPage(buildPage());
254
98
  try {
255
99
  const firstRow = () => page.eval(
256
- `document.querySelector('#feature-table tr.feat-row td:first-child').textContent.trim()`);
100
+ `document.querySelector('#panel-estimate tr.feat-row td:first-child').textContent.trim()`);
257
101
  assert.match(await firstRow(), /book appointment/);
258
- await page.eval(`document.querySelector('#feature-table th button[data-sort="hours"]').click()`);
102
+ await page.eval(`document.querySelector('#panel-estimate th button[data-sort="hours"]').click()`);
259
103
  assert.match(await firstRow(), /Email reminders/);
260
104
  assert.equal(await page.eval(
261
- `document.querySelector('#feature-table th button[data-sort="hours"]').closest('th').getAttribute('aria-sort')`),
105
+ `document.querySelector('#panel-estimate th button[data-sort="hours"]').closest('th').getAttribute('aria-sort')`),
262
106
  'ascending');
263
107
  } finally { page.close(); }
264
108
  });
@@ -266,83 +110,19 @@ test('breakdown headers sort: effort toggles to ascending on click', skip, async
266
110
  test('expanding a feature reveals its tasks; client view hides the drill-down', skip, async () => {
267
111
  const page = await openPage(buildPage());
268
112
  try {
269
- assert.equal(await page.eval(`document.querySelectorAll('#feature-table tr.task-row').length`), 0);
270
- await page.eval(`document.querySelector('#feature-table tr.feat-row .expand').click()`);
113
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-estimate tr.task-row').length`), 0);
114
+ await page.eval(`document.querySelector('#panel-estimate tr.feat-row .expand').click()`);
271
115
  const tasks = await page.eval(
272
- `[...document.querySelectorAll('#feature-table tr.task-row td:first-child')].map((c) => c.textContent.trim())`);
116
+ `[...document.querySelectorAll('#panel-estimate tr.task-row td:first-child')].map((c) => c.childNodes[0].textContent.trim())`);
273
117
  assert.deepEqual(tasks, ['Booking CRUD API', 'Slot conflict + cancellation rules']);
274
118
  await page.eval(`document.getElementById('view-toggle').click()`);
275
119
  assert.equal(await page.eval(
276
- `getComputedStyle(document.querySelector('#feature-table tr.task-row')).display`), 'none');
120
+ `getComputedStyle(document.querySelector('#panel-estimate tr.task-row')).display`), 'none');
277
121
  assert.equal(await page.eval(
278
- `getComputedStyle(document.querySelector('#feature-table .expand')).display`), 'none');
122
+ `getComputedStyle(document.querySelector('#panel-estimate .expand')).display`), 'none');
279
123
  } finally { page.close(); }
280
124
  });
281
125
 
282
- test('scenario cards carry a month gauge, facts grid, and delta on non-recommended', skip, async () => {
283
- const page = await openPage(buildPage());
284
- try {
285
- assert.equal(await page.eval(
286
- `document.querySelectorAll('#scenario-cards .scenario .gauge span').length`), 2);
287
- const widths = await page.eval(
288
- `[...document.querySelectorAll('#scenario-cards .gauge span')].map((s) => s.style.width)`);
289
- assert.ok(widths.includes('100%'), `longest scenario must fill its gauge: ${widths}`);
290
- assert.equal(await page.eval(
291
- `document.querySelectorAll('#scenario-cards .scenario.recommended .facts dt').length`), 4);
292
- const facts = await page.eval(
293
- `[...document.querySelectorAll('#scenario-cards .scenario:not(.recommended) .facts dd')].map((d) => d.textContent)`);
294
- assert.ok(facts.some((t) => t.includes('2× mid · 1× junior')), `team summary missing: ${facts}`);
295
- assert.equal(await page.eval(
296
- `document.querySelectorAll('#scenario-cards .scenario.recommended .delta').length`), 0);
297
- assert.match(await page.eval(
298
- `document.querySelector('#scenario-cards .scenario:not(.recommended) .delta').textContent`),
299
- /mo · [+-]\$[\d,]+ vs recommended/);
300
- } finally { page.close(); }
301
- });
302
-
303
- test('expand all / collapse all toggle every task row and stay internal-only', skip, async () => {
304
- const page = await openPage(buildPage());
305
- try {
306
- await page.eval(`document.querySelector('#feature-table button[data-expand="all"]').click()`);
307
- assert.equal(await page.eval(`document.querySelectorAll('#feature-table tr.task-row').length`), 3);
308
- await page.eval(`document.querySelector('#feature-table button[data-expand="none"]').click()`);
309
- assert.equal(await page.eval(`document.querySelectorAll('#feature-table tr.task-row').length`), 0);
310
- await page.eval(`document.getElementById('view-toggle').click()`);
311
- assert.equal(await page.eval(
312
- `getComputedStyle(document.querySelector('#feature-table button[data-expand="all"]').closest('.bd-filter-group')).display`), 'none');
313
- } finally { page.close(); }
314
- });
315
-
316
- test('the what-if rail is not sticky and lower sections span the full width', skip, async () => {
317
- const page = await openPage(buildPage());
318
- try {
319
- assert.notEqual(await page.eval(
320
- `getComputedStyle(document.getElementById('controls')).position`), 'sticky');
321
- const width = (id) => page.eval(
322
- `document.getElementById('${id}').getBoundingClientRect().width`);
323
- const narrow = await width('cost-bars');
324
- for (const id of ['method', 'roadmap', 'feature-table', 'register']) {
325
- assert.ok(await width(id) > narrow + 100,
326
- `${id} should outspan the rail-adjacent sections (${await width(id)} vs ${narrow})`);
327
- }
328
- // no hole under the cost bars: the left column stretches to the rail's end
329
- const bottom = (id) => page.eval(
330
- `document.getElementById('${id}').getBoundingClientRect().bottom`);
331
- assert.ok(await bottom('cost-bars') >= await bottom('controls') - 1,
332
- `left column ends above the rail (${await bottom('cost-bars')} vs ${await bottom('controls')})`);
333
- // the rail panel starts level with the scenario cards, not their heading
334
- const railTop = await page.eval(
335
- `document.getElementById('controls').getBoundingClientRect().top`);
336
- const cardTop = await page.eval(
337
- `document.querySelector('#scenario-cards .scenario').getBoundingClientRect().top`);
338
- assert.ok(Math.abs(railTop - cardTop) < 2, `rail top ${railTop} != card top ${cardTop}`);
339
- // the scenario cards own the tall row; the cost bars stay content-sized
340
- const height = (id) => page.eval(
341
- `document.getElementById('${id}').getBoundingClientRect().height`);
342
- assert.ok(await height('scenario-cards') > await height('cost-bars'),
343
- 'scenario cards should be the taller section');
344
- } finally { page.close(); }
345
- });
346
126
 
347
127
  const pickOption = (key, value) => `(() => {
348
128
  const sel = document.querySelector('#feature-table select[data-select="${key}"]');
@@ -350,21 +130,17 @@ const pickOption = (key, value) => `(() => {
350
130
  sel.dispatchEvent(new Event('change', { bubbles: true }));
351
131
  })()`;
352
132
 
353
- test('milestone select and provenance pills scope rows without rescaling bars', skip, async () => {
133
+ test('the milestone filter scopes rows without rescaling bars', skip, async () => {
354
134
  const page = await openPage(buildPage());
355
135
  try {
356
136
  const width = () => page.eval(
357
- `document.querySelector('#feature-table tr.feat-row[data-id="reminders"] .bd-fill').style.width`);
137
+ `document.querySelector('#panel-estimate tr.feat-row[data-id="reminders"] .bd-fill').style.width`);
358
138
  const before = await width();
359
139
  await page.eval(pickOption('milestone', 'M2 - Notifications'));
360
140
  const visible = await page.eval(
361
- `[...document.querySelectorAll('#feature-table tr.feat-row')].map((r) => r.dataset.id)`);
141
+ `[...document.querySelectorAll('#panel-estimate tr.feat-row')].map((r) => r.dataset.id)`);
362
142
  assert.deepEqual(visible, ['reminders']);
363
143
  assert.equal(await width(), before, 'bar must keep its global scale under filters');
364
- await page.eval(pickOption('milestone', ''));
365
- await page.eval(`document.querySelector('#feature-table button[data-prov="stated"]').click()`);
366
- assert.deepEqual(await page.eval(
367
- `[...document.querySelectorAll('#feature-table tr.feat-row')].map((r) => r.dataset.id)`), ['booking']);
368
144
  } finally { page.close(); }
369
145
  });
370
146
 
@@ -425,7 +201,7 @@ test('no roster → the containers section is absent, no placeholder', skip, asy
425
201
  assert.equal(await page.eval(`document.querySelectorAll('#roadmap .roadmap-seg').length`), 0);
426
202
  assert.ok(await page.eval(`document.querySelectorAll('#roadmap .roadmap-band').length > 0`));
427
203
  // and the breakdown rows carry no container stripes
428
- assert.equal(await page.eval(`document.querySelectorAll('#feature-table td.ct-edge').length`), 0);
204
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-estimate td.ct-edge').length`), 0);
429
205
  assert.deepEqual(page.errors, []);
430
206
  } finally { page.close(); }
431
207
  });
@@ -439,7 +215,7 @@ test('container select filters rows by container', skip, async () => {
439
215
  assert.deepEqual(options, ['all containers', 'Booking API', 'Notification Service']);
440
216
  // each row's first cell carries its container's stripe on the left edge,
441
217
  // named on hover — same palette as the donut
442
- const stripes = await page.eval(`[...document.querySelectorAll('#feature-table tr.feat-row td.ct-edge')]
218
+ const stripes = await page.eval(`[...document.querySelectorAll('#panel-estimate tr.feat-row td.ct-edge')]
443
219
  .map((c) => ({ title: c.title, shadow: getComputedStyle(c).boxShadow, inline: c.style.boxShadow }))`);
444
220
  assert.deepEqual(stripes.map((s) => s.title), ['Booking API', 'Notification Service']);
445
221
  assert.ok(stripes.every((s) => /inset/.test(s.shadow)), 'stripe must be an inset edge, no gap');
@@ -448,13 +224,13 @@ test('container select filters rows by container', skip, async () => {
448
224
  'the shadow lives in the ct-edge class — inline style carries only the color variable');
449
225
  await page.eval(pickOption('component', 'notify'));
450
226
  assert.deepEqual(await page.eval(
451
- `[...document.querySelectorAll('#feature-table tr.feat-row')].map((r) => r.dataset.id)`), ['reminders']);
227
+ `[...document.querySelectorAll('#panel-estimate tr.feat-row')].map((r) => r.dataset.id)`), ['reminders']);
452
228
  await page.eval(pickOption('component', ''));
453
- assert.equal(await page.eval(`document.querySelectorAll('#feature-table tr.feat-row').length`), 2);
229
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-estimate tr.feat-row').length`), 2);
454
230
  // expanded task rows belong to the feature's container — same stripe
455
- await page.eval(`document.querySelector('#feature-table tr.feat-row .expand').click()`);
231
+ await page.eval(`document.querySelector('#panel-estimate tr.feat-row .expand').click()`);
456
232
  const taskStripe = await page.eval(
457
- `getComputedStyle(document.querySelector('#feature-table tr.task-row td.ct-edge')).boxShadow`);
233
+ `getComputedStyle(document.querySelector('#panel-estimate tr.task-row td.ct-edge')).boxShadow`);
458
234
  assert.equal(taskStripe, stripes[0].shadow);
459
235
  assert.deepEqual(page.errors, []);
460
236
  } finally { page.close(); }
@@ -470,14 +246,14 @@ test('roadmap bands segment by container; clicking a row drives the breakdown',
470
246
  await page.eval(pickOption('component', 'api'));
471
247
  await page.eval(`document.querySelector('#roadmap .roadmap-row[data-milestone="M2 - Notifications"]').click()`);
472
248
  assert.deepEqual(await page.eval(
473
- `[...document.querySelectorAll('#feature-table tr.feat-row')].map((r) => r.dataset.id)`), ['reminders']);
249
+ `[...document.querySelectorAll('#panel-estimate tr.feat-row')].map((r) => r.dataset.id)`), ['reminders']);
474
250
  assert.equal(await page.eval(
475
251
  `document.querySelector('#feature-table select[data-select="milestone"]').value`), 'M2 - Notifications');
476
252
  assert.equal(await page.eval(
477
253
  `document.querySelector('#feature-table select[data-select="component"]').value`), '');
478
254
  // same row again → the filter clears, every feature returns
479
255
  await page.eval(`document.querySelector('#roadmap .roadmap-row[data-milestone="M2 - Notifications"]').click()`);
480
- assert.equal(await page.eval(`document.querySelectorAll('#feature-table tr.feat-row').length`), 2);
256
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-estimate tr.feat-row').length`), 2);
481
257
  assert.deepEqual(page.errors, []);
482
258
  } finally { page.close(); }
483
259
  });
@@ -492,6 +268,15 @@ test('a roadmap click groups the breakdown rows by container', skip, async () =>
492
268
  inputs.features.push({
493
269
  id: 'audit', name: 'Booking audit log', provenance: 'proposed',
494
270
  component: 'api', milestone: 'M2 - Notifications',
271
+ scores: {
272
+ tech: { n: 1, anchor: 'Standard CRUD, well-documented library usage, copy-paste patterns', cite: 'append-only log write' },
273
+ size: { n: 1, anchor: 'Single UI element or micro-function, <1 day of work', cite: 'one write call' },
274
+ deps: { n: 2, anchor: 'One internal dependency (e.g. auth check)', cite: 'writes to the booking API' },
275
+ unc: { n: 1, anchor: 'Fully defined spec, clear acceptance criteria, precedent exists', cite: 'standard audit log shape' },
276
+ risk: { n: 2, anchor: 'Low stakes, easy rollback, minimal user impact', cite: 'log-only, no user-facing effect' },
277
+ },
278
+ scoreNote: 'Writes an append-only audit log entry alongside booking changes',
279
+ scoreProvenance: 'proposed',
495
280
  tasks: [{ id: 'audit-log', name: 'Audit log writes', category: 'boilerplate',
496
281
  o: 4, m: 6, p: 10, confidence: 'MED', assumptions: [], provenance: 'proposed' }],
497
282
  });
@@ -501,20 +286,21 @@ test('a roadmap click groups the breakdown rows by container', skip, async () =>
501
286
  const page = await openPage(pathToFileURL(join(dir, 'estimate.html')).href);
502
287
  try {
503
288
  const ids = () => page.eval(
504
- `[...document.querySelectorAll('#feature-table tr.feat-row')].map((r) => r.dataset.id)`);
289
+ `[...document.querySelectorAll('#panel-estimate tr.feat-row')].map((r) => r.dataset.id)`);
505
290
  await page.eval(`document.querySelector('#roadmap .roadmap-row[data-milestone="M2 - Notifications"]').click()`);
506
291
  // hours desc would put reminders first; container grouping puts the api row first
507
292
  assert.deepEqual(await ids(), ['audit', 'reminders']);
508
- // no header may claim a sort the grouping just overrode
509
- assert.deepEqual(await page.eval(
510
- `[...document.querySelectorAll('#feature-table th')].map((t) => t.getAttribute('aria-sort'))`),
511
- ['none', 'none', 'none', 'none', 'none']);
293
+ // no header on either tab may claim a sort the grouping just overrode
294
+ const sortStates = (sel) => page.eval(
295
+ `[...document.querySelectorAll('${sel}')].map((t) => t.getAttribute('aria-sort'))`);
296
+ assert.deepEqual(await sortStates(BD_HEAD), Array(4).fill('none'));
297
+ assert.deepEqual(await sortStates(SCORE_HEAD), Array(8).fill('none'));
512
298
  // an explicit header sort takes control back from the grouping, starting
513
299
  // fresh at the column's default direction — not toggling a stale one
514
- await page.eval(`document.querySelector('#feature-table th button[data-sort="hours"]').click()`);
300
+ await page.eval(`document.querySelector('#panel-estimate th button[data-sort="hours"]').click()`);
515
301
  assert.deepEqual(await ids(), ['reminders', 'audit']);
516
302
  assert.equal(await page.eval(
517
- `document.querySelector('#feature-table th button[data-sort="hours"]').closest('th').getAttribute('aria-sort')`),
303
+ `document.querySelector('#panel-estimate th button[data-sort="hours"]').closest('th').getAttribute('aria-sort')`),
518
304
  'descending');
519
305
  assert.deepEqual(page.errors, []);
520
306
  } finally { page.close(); }
@@ -529,7 +315,7 @@ test('the container donut and roadmap sit directly above the feature breakdown',
529
315
  } finally { page.close(); }
530
316
  });
531
317
 
532
- test('roadmap renders committed bands and ignores the what-if rail', skip, async () => {
318
+ test('roadmap renders the committed milestone bands', skip, async () => {
533
319
  const page = await openPage(buildPage());
534
320
  try {
535
321
  const labels = await page.eval(
@@ -537,13 +323,6 @@ test('roadmap renders committed bands and ignores the what-if rail', skip, async
537
323
  assert.equal(labels.length, 2);
538
324
  assert.match(labels[0], /M1 - Booking core/);
539
325
  assert.match(labels[1], /M2 - Notifications/);
540
- const before = await page.eval(`document.getElementById('roadmap').innerHTML`);
541
- await page.eval(`(() => {
542
- const ctl = document.querySelector('#ctl-team .team-row input');
543
- ctl.value = '90'; ctl.dispatchEvent(new Event('input', { bubbles: true }));
544
- })()`);
545
- assert.equal(await page.eval(`document.getElementById('roadmap').innerHTML`), before,
546
- 'roadmap must stay frozen at the committed estimate');
547
326
  } finally { page.close(); }
548
327
  });
549
328
 
@@ -622,71 +401,379 @@ test('no milestones → the roadmap section is absent, no placeholder', skip, as
622
401
  } finally { page.close(); }
623
402
  });
624
403
 
625
- // --- breakdown scoring mode: the workbook's five scores rendered in-page ---
404
+ // --- breakdown scores: the interview's five judgments rendered in-page ---
626
405
 
627
- const HEADS = `[...document.querySelectorAll('#feature-table th')].map((h) => h.textContent.trim())`;
628
- const enterScoring = (page) => page.eval(`document.querySelector('#feature-table [data-mode="scores"]').click()`);
406
+ const cellTexts = (sel) => `[...document.querySelectorAll('${sel}')].map((n) => n.textContent.trim())`;
407
+ // Each tab's table is the direct .bd-scroll child of its panel — the
408
+ // scoring-guide fold sits inside the scoring panel too and carries its own
409
+ // header row. The active column's label ends in a sort arrow, which is not
410
+ // part of the column name.
411
+ const BD_HEAD = '#panel-estimate > .bd-scroll th';
412
+ const SCORE_HEAD = '#panel-scoring > .bd-scroll th';
413
+ const stripArrow = (sel) => `${cellTexts(sel)}.map((t) => t.replace(/ [▲▼]$/, ''))`;
414
+ const headTexts = stripArrow(BD_HEAD);
415
+ const scoreHeadTexts = stripArrow(SCORE_HEAD);
416
+ const clickTab = (tab) => `document.querySelector('#feature-table [role="tab"][data-tab="${tab}"]').click()`;
629
417
 
630
- test('a columns pill swaps the breakdown to workbook scores and back', skip, async () => {
418
+ test('the scoring tab carries the five factors, Σ and tier; values verbatim from inputs', skip, async () => {
631
419
  const page = await openPage(buildPage());
632
420
  try {
633
- assert.ok((await page.eval(HEADS)).includes('Range'), 'estimate columns by default');
634
- await enterScoring(page);
635
- const heads = await page.eval(HEADS);
636
- for (const h of ['Tech', 'Size', 'Deps', 'Unc', 'Risk', 'Σ', 'Tier']) {
637
- assert.ok(heads.includes(h), `scoring header ${h} missing: ${heads}`);
638
- }
639
- assert.ok(!heads.includes('Range'), 'estimate columns must swap out');
640
- const booking = await page.eval(
641
- `[...document.querySelectorAll('#feature-table tr.feat-row')[0].querySelectorAll('td.score')].map((c) => c.textContent.trim())`);
642
- assert.deepEqual(booking, ['2', '4', '2', '4', '3', '15', 'M']);
643
- await page.eval(`document.querySelector('#feature-table [data-mode="estimate"]').click()`);
644
- assert.ok((await page.eval(HEADS)).includes('Range'), 'estimate pill must swap back');
421
+ assert.deepEqual(await page.eval(scoreHeadTexts),
422
+ ['Feature', 'Tech', 'Size', 'Deps', 'Unc', 'Risk', 'Σ', 'Tier']);
423
+ const booking = await page.eval(cellTexts('#panel-scoring tr[data-id="booking"] td.score'));
424
+ assert.deepEqual(booking.slice(0, 5), ['3', '3', '2', '3', '3']);
425
+ assert.equal(booking[5], '14');
426
+ assert.equal(booking[6], 'M');
427
+ assert.equal(await page.eval(`document.querySelector('#feature-table [data-mode]')`), null, 'mode toggle is gone');
645
428
  assert.deepEqual(page.errors, []);
646
429
  } finally { page.close(); }
647
430
  });
648
431
 
649
- test('scoring-mode task rows show each task\'s input to every score', skip, async () => {
432
+ test('score cells explain themselves: anchor + cite on hover, note under the name, ⚑ on a tier edge', skip, async () => {
650
433
  const page = await openPage(buildPage());
651
434
  try {
652
- await enterScoring(page);
653
- await page.eval(`document.querySelector('#feature-table tr.feat-row .expand').click()`);
654
- const rows = await page.eval(
655
- `[...document.querySelectorAll('#feature-table tr.task-row')].map((r) => r.textContent.replace(/\\s+/g, ' ').trim())`);
656
- assert.equal(rows.length, 2);
657
- assert.match(rows[0], /boilerplate ×1\.5/);
658
- assert.match(rows[0], /25\.3h/);
659
- assert.match(rows[1], /logic ×3/);
660
- assert.match(rows[1], /44(\.0)?h/);
435
+ const title = await page.eval(`document.querySelector('#panel-scoring tr[data-id="reminders"] td.score').title`);
436
+ assert.match(title, /Minor customisation of standard patterns/);
437
+ assert.match(title, /scheduled job \+ template/);
438
+ const note = await page.eval(`document.querySelector('#panel-scoring tr[data-id="booking"] .feat-note').textContent`);
439
+ assert.match(note, /open questions/);
440
+ assert.ok(await page.eval(`!!document.querySelector('#panel-scoring tr[data-id="reminders"] .edge')`), 'Σ 11 sits on a tier edge');
441
+ assert.equal(await page.eval(`!!document.querySelector('#panel-scoring tr[data-id="booking"] .edge')`), false);
442
+ assert.deepEqual(page.errors, []);
661
443
  } finally { page.close(); }
662
444
  });
663
445
 
664
- test('the scoring guide fold explains the anchors in the workbook\'s words', skip, async () => {
446
+ test('⚠ marks a feature whose PERT hours fall outside its tier band', skip, async () => {
447
+ const page = await openPage(buildPageWith((inputs) => {
448
+ // reminders is S (20–60 h); push its only task to ~120 h
449
+ inputs.features[1].tasks[0] = { ...inputs.features[1].tasks[0], o: 90, m: 120, p: 160 };
450
+ }));
451
+ try {
452
+ const warn = await page.eval(`document.querySelector('#panel-estimate tr[data-id="reminders"] .oob')?.title ?? ''`);
453
+ assert.match(warn, /outside S band 20–60 h/);
454
+ assert.equal(await page.eval(`!!document.querySelector('#panel-estimate tr[data-id="booking"] .oob')`), false);
455
+ assert.deepEqual(page.errors, []);
456
+ } finally { page.close(); }
457
+ });
458
+
459
+ test('the scoring guide fold shows the reference table, open on first view', skip, async () => {
665
460
  const page = await openPage(buildPage());
666
461
  try {
667
- assert.equal(await page.eval(`document.querySelector('#feature-table details.guide')`), null,
668
- 'no guide fold in estimate mode');
669
- await enterScoring(page);
670
- assert.ok(await page.eval(`document.querySelector('#feature-table details.guide').open`),
671
- 'guide must open on first switch');
672
- const text = await page.eval(`document.querySelector('#feature-table details.guide').textContent`);
673
- for (const anchor of ['Standard CRUD, well-documented library usage',
674
- 'Epic-scale feature', 'Deep cross-system dependencies', 'Highly experimental',
675
- 'Core infrastructure, compliance requirements']) {
676
- assert.ok(text.includes(anchor), `guide missing workbook anchor: ${anchor}`);
462
+ assert.equal(await page.eval(`document.querySelector('#panel-scoring details.guide').open`), true);
463
+ assert.match(await page.eval(`document.querySelector('#panel-scoring details.guide').textContent`), /Tech complexity/);
464
+ assert.deepEqual(page.errors, []);
465
+ } finally { page.close(); }
466
+ });
467
+
468
+ // Sorting rebuilds the whole section, so the fold's open state has to live in
469
+ // bdState — otherwise every click either slams it shut or re-opens it.
470
+ test('the scoring guide fold keeps its open state across a re-render', skip, async () => {
471
+ const page = await openPage(buildPage());
472
+ const fold = `document.querySelector('#panel-scoring details.guide')`;
473
+ const sort = `document.querySelector('#panel-estimate th button[data-sort="name"]').click()`;
474
+ try {
475
+ assert.equal(await page.eval(`${fold}.open`), true);
476
+ await page.eval(sort);
477
+ assert.equal(await page.eval(`${fold}.open`), true, 'a sort must not fold the guide shut');
478
+ await page.eval(`(() => { const d = ${fold}; d.open = false; d.dispatchEvent(new Event('toggle')); })()`);
479
+ await page.eval(sort);
480
+ assert.equal(await page.eval(`${fold}.open`), false, 'a closed guide stays closed');
481
+ assert.deepEqual(page.errors, []);
482
+ } finally { page.close(); }
483
+ });
484
+
485
+ test('QUICK inputs render four columns, no tabs and no guide', skip, async () => {
486
+ const page = await openPage(buildPageWith((inputs) => {
487
+ inputs.depth = 'QUICK';
488
+ for (const f of inputs.features) {
489
+ delete f.scores; delete f.scoreNote; delete f.scoreProvenance;
490
+ f.tasks = [{ ...f.tasks[0], id: `${f.id}-band`, o: 60, m: 110, p: 160 }];
677
491
  }
678
- assert.match(text, /hours-weighted/); // each dimension states its derivation
492
+ }));
493
+ try {
494
+ assert.deepEqual(await page.eval(headTexts), ['Feature', 'Effort (h)', 'Confidence', 'Source']);
495
+ assert.equal(await page.eval(`document.querySelector('#feature-table [role="tablist"]')`), null,
496
+ 'one view needs no tab strip');
497
+ assert.equal(await page.eval(`document.getElementById('panel-scoring')`), null);
498
+ assert.equal(await page.eval(`document.querySelector('#feature-table details.guide')`), null);
499
+ assert.deepEqual(page.errors, []);
679
500
  } finally { page.close(); }
680
501
  });
681
502
 
682
- test('scoring mode is internal-only: client view resets and hides the pill', skip, async () => {
503
+ // Tasks live on the estimate tab, which never carries score columns, so a
504
+ // task row fills the same four columns as the feature above it — the spacer
505
+ // cell that used to span the scores is gone.
506
+ test('expanded task rows line up under the estimate header', skip, async () => {
683
507
  const page = await openPage(buildPage());
684
508
  try {
685
- await enterScoring(page);
509
+ await page.eval(`document.querySelector('#panel-estimate tr[data-id="booking"] button.expand').click()`);
510
+ const cells = await page.eval(`document.querySelectorAll('#panel-estimate tr.task-row td').length`);
511
+ // name + o/m/p + confidence + category = 4 per row × 2 tasks
512
+ assert.equal(cells, 8);
513
+ assert.equal(await page.eval(
514
+ `document.querySelector('#panel-estimate tr.task-row td:nth-child(1)').colSpan`), 1);
515
+ assert.deepEqual(page.errors, []);
516
+ } finally { page.close(); }
517
+ });
518
+
519
+ // --- the two tabs: effort on one, judgment on the other ---
520
+
521
+ test('estimate and scoring are real tabs, estimate selected first', skip, async () => {
522
+ const page = await openPage(buildPage());
523
+ try {
524
+ const tabs = await page.eval(`[...document.querySelectorAll('#feature-table [role="tab"]')]
525
+ .map((t) => ({ label: t.textContent.trim(), selected: t.getAttribute('aria-selected'),
526
+ controls: t.getAttribute('aria-controls'), tabindex: t.getAttribute('tabindex') }))`);
527
+ assert.deepEqual(tabs.map((t) => t.label), ['Estimate', 'Scoring']);
528
+ assert.deepEqual(tabs.map((t) => t.selected), ['true', 'false']);
529
+ assert.deepEqual(tabs.map((t) => t.controls), ['panel-estimate', 'panel-scoring']);
530
+ // roving tabindex: one stop in the strip, arrows move within it
531
+ assert.deepEqual(tabs.map((t) => t.tabindex), ['0', '-1']);
532
+ assert.equal(await page.eval(
533
+ `document.querySelector('#feature-table [role="tablist"]').children.length`), 2);
534
+ // every tab points at a panel that exists, and the idle one is hidden
535
+ assert.equal(await page.eval(`document.getElementById('panel-scoring').hidden`), true);
536
+ assert.equal(await page.eval(`document.getElementById('panel-estimate').hidden`), false);
537
+ assert.deepEqual(page.errors, []);
538
+ } finally { page.close(); }
539
+ });
540
+
541
+ test('each tab shows only its own columns', skip, async () => {
542
+ const page = await openPage(buildPage());
543
+ try {
544
+ assert.deepEqual(await page.eval(headTexts), ['Feature', 'Effort (h)', 'Confidence', 'Source']);
545
+ assert.deepEqual(await page.eval(scoreHeadTexts),
546
+ ['Feature', 'Tech', 'Size', 'Deps', 'Unc', 'Risk', 'Σ', 'Tier']);
547
+ await page.eval(clickTab('scoring'));
548
+ assert.equal(await page.eval(`document.getElementById('panel-scoring').hidden`), false);
549
+ assert.equal(await page.eval(`document.getElementById('panel-estimate').hidden`), true);
550
+ assert.equal(await page.eval(
551
+ `document.querySelector('#feature-table [role="tab"][data-tab="scoring"]').getAttribute('aria-selected')`), 'true');
552
+ assert.deepEqual(page.errors, []);
553
+ } finally { page.close(); }
554
+ });
555
+
556
+ test('arrow keys move between tabs and take the focus with them', skip, async () => {
557
+ const page = await openPage(buildPage());
558
+ const key = (k) => `(() => {
559
+ const on = document.querySelector('#feature-table [role="tab"][aria-selected="true"]');
560
+ on.focus();
561
+ on.dispatchEvent(new KeyboardEvent('keydown', { key: ${JSON.stringify(k)}, bubbles: true }));
562
+ })()`;
563
+ try {
564
+ await page.eval(key('ArrowRight'));
565
+ assert.equal(await page.eval(`document.activeElement.dataset.tab`), 'scoring');
566
+ assert.equal(await page.eval(`document.getElementById('panel-scoring').hidden`), false);
567
+ await page.eval(key('ArrowLeft'));
568
+ assert.equal(await page.eval(`document.activeElement.dataset.tab`), 'estimate');
569
+ assert.deepEqual(page.errors, []);
570
+ } finally { page.close(); }
571
+ });
572
+
573
+ // Every score carries a rubric anchor and the evidence it rests on; both were
574
+ // tooltip-only, which never survived touch, print, or a find-in-page.
575
+ test('expanding on the scoring tab prints each score\'s rubric sentence and evidence', skip, async () => {
576
+ const page = await openPage(buildPage());
577
+ try {
578
+ await page.eval(clickTab('scoring'));
579
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring tr.rat-row').length`), 0);
580
+ await page.eval(`document.querySelector('#panel-scoring tr[data-id="reminders"] button.expand').click()`);
581
+ const terms = await page.eval(cellTexts('#panel-scoring tr.rat-row dt'));
582
+ assert.deepEqual(terms, ['Tech 2', 'Size 2', 'Deps 3', 'Unc 2', 'Risk 2']);
583
+ const first = await page.eval(
584
+ `document.querySelector('#panel-scoring tr.rat-row dd').textContent`);
585
+ assert.match(first, /Minor customisation of standard patterns/);
586
+ assert.match(first, /scheduled job \+ template/);
587
+ // the block spans the whole row, stripe included
588
+ assert.equal(await page.eval(
589
+ `document.querySelector('#panel-scoring tr.rat-row td').colSpan`), 8);
590
+ assert.ok(await page.eval(
591
+ `document.querySelector('#panel-scoring tr.rat-row td').classList.contains('ct-edge')`));
592
+ assert.deepEqual(page.errors, []);
593
+ } finally { page.close(); }
594
+ });
595
+
596
+ // redact.mjs blanks a cite and keeps the anchor: the client still reads why
597
+ // each score is what it is, without the internal shorthand behind it.
598
+ test('a client render keeps the rubric sentences and drops the evidence', skip, async () => {
599
+ const page = await openPage(buildPage(['--client-only']));
600
+ try {
601
+ await page.eval(clickTab('scoring'));
602
+ await page.eval(`document.querySelector('#panel-scoring tr[data-id="reminders"] button.expand').click()`);
603
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring tr.rat-row dd').length`), 5);
604
+ assert.match(await page.eval(`document.querySelector('#panel-scoring tr.rat-row dd').textContent`),
605
+ /Minor customisation of standard patterns/);
606
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring tr.rat-row .cite').length`), 0);
607
+ assert.deepEqual(page.errors, []);
608
+ } finally { page.close(); }
609
+ });
610
+
611
+ // The view toggle previews the client render without re-rendering, so it has
612
+ // to hide the evidence the client render would never have carried.
613
+ test('the client view toggle hides the evidence under each anchor', skip, async () => {
614
+ const page = await openPage(buildPage());
615
+ try {
616
+ await page.eval(clickTab('scoring'));
617
+ await page.eval(`document.querySelector('#panel-scoring tr[data-id="reminders"] button.expand').click()`);
618
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring .rationale .cite').length`), 5);
686
619
  await page.eval(`document.getElementById('view-toggle').click()`);
687
- assert.ok((await page.eval(HEADS)).includes('Range'), 'client view must reset to estimate columns');
688
620
  assert.equal(await page.eval(
689
- `getComputedStyle(document.querySelector('#feature-table [data-mode="scores"]').closest('.bd-filter-group')).display`),
690
- 'none');
621
+ `getComputedStyle(document.querySelector('#panel-scoring .rationale .cite')).display`), 'none');
622
+ assert.notEqual(await page.eval(
623
+ `getComputedStyle(document.querySelector('#panel-scoring .rationale dd')).display`), 'none',
624
+ 'the rubric sentence is the client\'s to read');
625
+ assert.deepEqual(page.errors, []);
626
+ } finally { page.close(); }
627
+ });
628
+
629
+ // The chevron opens tasks on one tab and reasoning on the other, so it is
630
+ // internal-only for tasks and visible for reasoning.
631
+ test('expand all opens tasks on estimate and rationale on scoring', skip, async () => {
632
+ const page = await openPage(buildPage());
633
+ const expandAll = `document.querySelector('#feature-table button[data-expand="all"]').click()`;
634
+ try {
635
+ await page.eval(expandAll);
636
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-estimate tr.task-row').length`), 3);
637
+ await page.eval(clickTab('scoring'));
638
+ // one expanded set: the features opened on estimate are open here too
639
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring tr.rat-row').length`), 2);
640
+ await page.eval(`document.querySelector('#feature-table button[data-expand="none"]').click()`);
641
+ assert.equal(await page.eval(`document.querySelectorAll('#panel-scoring tr.rat-row').length`), 0);
642
+ assert.deepEqual(page.errors, []);
643
+ } finally { page.close(); }
644
+ });
645
+
646
+ test('the expand controls hide in a client view on estimate and stay on scoring', skip, async () => {
647
+ const page = await openPage(buildPage());
648
+ const groupDisplay = `getComputedStyle(
649
+ document.querySelector('#feature-table button[data-expand="all"]').closest('.bd-filter-group')).display`;
650
+ try {
651
+ await page.eval(`document.getElementById('view-toggle').click()`);
652
+ assert.equal(await page.eval(groupDisplay), 'none', 'tasks are internal, so is the control that opens them');
653
+ await page.eval(clickTab('scoring'));
654
+ assert.notEqual(await page.eval(groupDisplay), 'none', 'the client may open the reasoning');
655
+ assert.deepEqual(page.errors, []);
656
+ } finally { page.close(); }
657
+ });
658
+
659
+ test('the three filters are selects in one row and scope both tabs', skip, async () => {
660
+ const page = await openPage(buildPage());
661
+ try {
662
+ assert.deepEqual(await page.eval(
663
+ `[...document.querySelectorAll('#feature-table .bd-filters select')].map((s) => s.dataset.select)`),
664
+ ['milestone', 'component', 'prov']);
665
+ assert.equal(await page.eval(`document.querySelector('#feature-table [data-prov]')`), null,
666
+ 'source is a select now, not a pill group');
667
+ await page.eval(pickOption('prov', 'stated'));
668
+ const ids = (panel) => page.eval(`[...document.querySelectorAll('#panel-${panel} tr.feat-row')].map((r) => r.dataset.id)`);
669
+ assert.deepEqual(await ids('estimate'), ['booking']);
670
+ assert.deepEqual(await ids('scoring'), ['booking'], 'one filter bar, both tabs');
671
+ assert.deepEqual(page.errors, []);
672
+ } finally { page.close(); }
673
+ });
674
+
675
+ test('the filter row counts what survives and clears back to everything', skip, async () => {
676
+ const page = await openPage(buildPage());
677
+ const count = `document.querySelector('#feature-table .bd-count').textContent.trim()`;
678
+ try {
679
+ assert.match(await page.eval(count), /^2 features$/);
680
+ await page.eval(pickOption('prov', 'stated'));
681
+ assert.match(await page.eval(count), /^1 of 2 features$/);
682
+ await page.eval(`document.querySelector('#feature-table button[data-clear]').click()`);
683
+ assert.match(await page.eval(count), /^2 features$/);
684
+ assert.equal(await page.eval(
685
+ `document.querySelector('#feature-table select[data-select="prov"]').value`), '');
686
+ assert.deepEqual(page.errors, []);
687
+ } finally { page.close(); }
688
+ });
689
+
690
+ // The workbook carries a Task Breakdown sheet and a Score Rationale sheet, so
691
+ // the export belongs to the section, not to either tab.
692
+ test('download xlsx sits on the section heading, outside both tabs', skip, async () => {
693
+ const page = await openPage(buildPage());
694
+ try {
695
+ assert.ok(await page.eval(`!!document.querySelector('#feature-table .sec-head button[data-download]')`));
696
+ assert.equal(await page.eval(`document.querySelector('#panel-estimate button[data-download]')`), null);
697
+ assert.equal(await page.eval(`document.querySelector('#panel-scoring button[data-download]')`), null);
698
+ assert.deepEqual(page.errors, []);
699
+ } finally { page.close(); }
700
+ });
701
+
702
+ test('each tab keeps its own sort', skip, async () => {
703
+ const page = await openPage(buildPage());
704
+ const firstOf = (panel) => page.eval(
705
+ `document.querySelector('#panel-${panel} tr.feat-row td:first-child').textContent.trim()`);
706
+ try {
707
+ assert.match(await firstOf('estimate'), /book appointment/, 'effort descending');
708
+ assert.match(await firstOf('scoring'), /book appointment/, 'Σ descending');
709
+ await page.eval(`document.querySelector('#panel-scoring th button[data-sort="total"]').click()`);
710
+ assert.match(await firstOf('scoring'), /Email reminders/, 'Σ ascending');
711
+ assert.match(await firstOf('estimate'), /book appointment/, 'the estimate sort is untouched');
712
+ assert.deepEqual(page.errors, []);
713
+ } finally { page.close(); }
714
+ });
715
+
716
+ // A tab is a screen affordance. On paper both tables print in full, each
717
+ // named by its caption, with the guide open behind them.
718
+ test('printing shows both tables, named', skip, async () => {
719
+ const page = await openPage(buildPage());
720
+ try {
721
+ await page.eval(`(() => {
722
+ const s = document.createElement('style');
723
+ s.textContent = '@media screen { .print-probe { display: none } }';
724
+ document.head.append(s);
725
+ })()`);
726
+ const captions = await page.eval(cellTexts('#feature-table caption'));
727
+ assert.deepEqual(captions, ['Estimate', 'Scoring']);
728
+ assert.equal(await page.eval(
729
+ `[...document.styleSheets].some((s) => [...s.cssRules].some((r) => /print/.test(r.conditionText ?? '')
730
+ && /tabpanel/.test(r.cssText)))`), true, 'print must unhide the idle panel');
731
+ assert.deepEqual(page.errors, []);
732
+ } finally { page.close(); }
733
+ });
734
+
735
+ // The Summary is the one place team, months and cost appear. The booking
736
+ // fixture recommends the AI-assisted senior+mid pair; the unaided trio is a
737
+ // different roster, so it is an alternative row, not a collapsed line.
738
+ test('the summary states the recommended scenario once and lists team alternatives', skip, async () => {
739
+ const page = await openPage(buildPage());
740
+ try {
741
+ const lead = await page.eval(`document.querySelector('#summary .lead').textContent`);
742
+ assert.equal(lead, '2 engineers (senior · mid), AI-assisted');
743
+ const figures = await page.eval(`document.querySelector('#summary .figures').textContent`);
744
+ assert.match(figures, /0\.40 months/);
745
+ assert.match(figures, /\$5,993/);
746
+ const alts = await page.eval(`[...document.querySelectorAll('#summary .alts tbody tr td:first-child')].map((c) => c.textContent)`);
747
+ assert.deepEqual(alts, ['3 engineers (mid · mid · junior), humans unaided']);
748
+ assert.equal(await page.eval(`document.querySelector('#summary .insight')`), null); // slower and pricier: no insight
749
+ assert.deepEqual(page.errors, []);
750
+ } finally { page.close(); }
751
+ });
752
+
753
+ // Same roster, AI on vs off: not a staffing choice, so it collapses to one
754
+ // line under the recommendation instead of an alternatives table.
755
+ test('a same-team AI-only variant collapses to one line, not a table', skip, async () => {
756
+ const page = await openPage(buildPageWith((inputs) => {
757
+ const rec = inputs.scenarios.find((s) => s.id === inputs.recommendedScenario);
758
+ const other = inputs.scenarios.find((s) => s.id !== rec.id);
759
+ other.team = rec.team.map((m) => ({ ...m }));
760
+ }));
761
+ try {
762
+ assert.equal(await page.eval(`document.querySelector('#summary .alts table')`), null);
763
+ const line = await page.eval(`document.querySelector('#summary .alts .meta').textContent`);
764
+ assert.match(line, /^Without AI assistance: 0\.\d\d months · \$[\d,]+ \(\+0\.\d\d mo · \+\$[\d,]+\)$/);
765
+ assert.deepEqual(page.errors, []);
766
+ } finally { page.close(); }
767
+ });
768
+
769
+ // One scenario is the default interview answer: no alternatives block at all.
770
+ test('a single-scenario estimate shows the summary with no alternatives block', skip, async () => {
771
+ const page = await openPage(buildPageWith((inputs) => {
772
+ inputs.scenarios = inputs.scenarios.filter((s) => s.id === inputs.recommendedScenario);
773
+ }));
774
+ try {
775
+ assert.equal(await page.eval(`document.querySelector('#summary .alts')`), null);
776
+ assert.equal(await page.eval(`document.querySelector('#summary .lead').textContent`), '2 engineers (senior · mid), AI-assisted');
777
+ assert.deepEqual(page.errors, []);
691
778
  } finally { page.close(); }
692
779
  });