@v11g/agents-rock 1.0.8 → 1.0.9

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 (117) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/plugins/reasoning/.claude-plugin/plugin.json +1 -1
  4. package/plugins/reasoning/evals/format-handoff-folder/graders/folder-named.md +8 -0
  5. package/plugins/reasoning/evals/format-handoff-folder/graders/skill-fired.md +7 -0
  6. package/plugins/reasoning/evals/format-handoff-folder/prompt.md +9 -0
  7. package/plugins/reasoning/evals/format-ids-and-supports/graders/ids-in-chat.md +8 -0
  8. package/plugins/reasoning/evals/format-ids-and-supports/graders/skill-fired.md +7 -0
  9. package/plugins/reasoning/evals/format-ids-and-supports/graders/supports-resolve.md +11 -0
  10. package/plugins/reasoning/evals/format-ids-and-supports/prompt.md +8 -0
  11. package/plugins/reasoning/evals/format-root-candidate-status/graders/candidate-status.md +11 -0
  12. package/plugins/reasoning/evals/format-root-candidate-status/graders/skill-fired.md +7 -0
  13. package/plugins/reasoning/evals/format-root-candidate-status/prompt.md +8 -0
  14. package/plugins/reasoning/evals/format-unsaved-continues/graders/analysis-completes.md +9 -0
  15. package/plugins/reasoning/evals/format-unsaved-continues/graders/not-saved-stated.md +9 -0
  16. package/plugins/reasoning/evals/format-unsaved-continues/graders/skill-fired.md +7 -0
  17. package/plugins/reasoning/evals/format-unsaved-continues/prompt.md +8 -0
  18. package/plugins/reasoning/skills/problem-router/README.md +6 -0
  19. package/plugins/reasoning/skills/problem-router/SKILL.md +4 -0
  20. package/plugins/reasoning/skills/problem-router/references/contract.md +114 -19
  21. package/plugins/reasoning/skills/problem-solving/README.md +6 -0
  22. package/plugins/reasoning/skills/problem-solving/SKILL.md +2 -0
  23. package/plugins/reasoning/skills/problem-solving/references/contract.md +114 -19
  24. package/plugins/reasoning/skills/problem-solving/references/interview.md +2 -0
  25. package/plugins/reasoning/skills/systemic-design/README.md +3 -0
  26. package/plugins/reasoning/skills/systemic-design/SKILL.md +2 -0
  27. package/plugins/reasoning/skills/systemic-design/references/contract.md +114 -19
  28. package/plugins/reasoning/skills/systemic-design/references/interview.md +2 -0
  29. package/plugins/reasoning/skills/systems-thinking/README.md +3 -0
  30. package/plugins/reasoning/skills/systems-thinking/SKILL.md +2 -0
  31. package/plugins/reasoning/skills/systems-thinking/frameworks/leverage-points.md +15 -6
  32. package/plugins/reasoning/skills/systems-thinking/references/contract.md +114 -19
  33. package/plugins/reasoning/skills/systems-thinking/references/interview.md +2 -0
  34. package/plugins/solution-architect/.claude-plugin/plugin.json +1 -1
  35. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/cdp.mjs +4 -1
  36. package/plugins/solution-architect/skills/analyze-requirements/scripts/lib/quality-gate.mjs +16 -1
  37. package/plugins/solution-architect/skills/analyze-requirements/scripts/test/quality-gate.test.mjs +9 -0
  38. package/plugins/solution-architect/skills/estimate/README.md +20 -15
  39. package/plugins/solution-architect/skills/estimate/SKILL.md +10 -6
  40. package/plugins/solution-architect/skills/estimate/assets/estimate-template-agentic.html +111 -138
  41. package/plugins/solution-architect/skills/estimate/assets/estimate-template.html +361 -247
  42. package/plugins/solution-architect/skills/estimate/assets/scores-review-template.html +5 -4
  43. package/plugins/solution-architect/skills/estimate/evals/evals.json +7 -7
  44. package/plugins/solution-architect/skills/estimate/references/agentic-estimation.md +4 -2
  45. package/plugins/solution-architect/skills/estimate/references/ai-multipliers.md +38 -82
  46. package/plugins/solution-architect/skills/estimate/references/interview.md +56 -35
  47. package/plugins/solution-architect/skills/estimate/references/scoring-guide.md +40 -4
  48. package/plugins/solution-architect/skills/estimate/references/techniques.md +29 -21
  49. package/plugins/solution-architect/skills/estimate/references/writing.md +75 -43
  50. package/plugins/solution-architect/skills/estimate/scripts/lib/checks.mjs +37 -5
  51. package/plugins/solution-architect/skills/estimate/scripts/lib/context-schema.mjs +35 -0
  52. package/plugins/solution-architect/skills/estimate/scripts/lib/estimate-math.mjs +17 -75
  53. package/plugins/solution-architect/skills/estimate/scripts/lib/inline.mjs +5 -5
  54. package/plugins/solution-architect/skills/estimate/scripts/lib/pricing.mjs +78 -0
  55. package/plugins/solution-architect/skills/estimate/scripts/lib/project-price.mjs +96 -0
  56. package/plugins/solution-architect/skills/estimate/scripts/lib/redact.mjs +67 -19
  57. package/plugins/solution-architect/skills/estimate/scripts/lib/roadmap.mjs +4 -5
  58. package/plugins/solution-architect/skills/estimate/scripts/lib/rollup.mjs +48 -73
  59. package/plugins/solution-architect/skills/estimate/scripts/lib/schema.mjs +28 -13
  60. package/plugins/solution-architect/skills/estimate/scripts/lib/score-csv.mjs +2 -2
  61. package/plugins/solution-architect/skills/estimate/scripts/lib/score-html.mjs +1 -1
  62. package/plugins/solution-architect/skills/estimate/scripts/lib/scoring.mjs +2 -2
  63. package/plugins/solution-architect/skills/estimate/scripts/render.mjs +1 -1
  64. package/plugins/solution-architect/skills/estimate/scripts/score-review.mjs +1 -1
  65. package/plugins/solution-architect/skills/estimate/scripts/test/browser-agentic.test.mjs +143 -0
  66. package/plugins/solution-architect/skills/estimate/scripts/test/browser.test.mjs +209 -50
  67. package/plugins/solution-architect/skills/estimate/scripts/test/compute.test.mjs +57 -32
  68. package/plugins/solution-architect/skills/estimate/scripts/test/e2e.test.mjs +52 -0
  69. package/plugins/solution-architect/skills/estimate/scripts/test/estimate-math.test.mjs +25 -112
  70. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-fail.md +0 -10
  71. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-estimation-pass.md +0 -10
  72. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/agentic-inputs.json +1 -7
  73. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/booking-inputs.json +11 -10
  74. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-fail.md +6 -0
  75. package/plugins/solution-architect/skills/estimate/scripts/test/fixtures/estimation-pass.md +17 -21
  76. package/plugins/solution-architect/skills/estimate/scripts/test/pricing.test.mjs +88 -0
  77. package/plugins/solution-architect/skills/estimate/scripts/test/project-price.test.mjs +93 -0
  78. package/plugins/solution-architect/skills/estimate/scripts/test/references.test.mjs +86 -24
  79. package/plugins/solution-architect/skills/estimate/scripts/test/render.test.mjs +185 -31
  80. package/plugins/solution-architect/skills/estimate/scripts/test/schema.test.mjs +114 -61
  81. package/plugins/solution-architect/skills/estimate/scripts/test/score-review.test.mjs +34 -1
  82. package/plugins/solution-architect/skills/estimate/scripts/test/validate.test.mjs +103 -9
  83. package/plugins/solution-architect/skills/estimate/scripts/test/xlsx-export.test.mjs +292 -71
  84. package/plugins/solution-architect/skills/new-lead/SKILL.md +4 -3
  85. package/plugins/solution-architect/skills/proposal/README.md +9 -7
  86. package/plugins/solution-architect/skills/proposal/SKILL.md +10 -7
  87. package/plugins/solution-architect/skills/proposal/evals/evals.json +29 -11
  88. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/ARCHITECTURE.md +65 -0
  89. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/brief.md +21 -0
  90. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/estimation-inputs.json +126 -0
  91. package/plugins/solution-architect/skills/proposal/evals/fixtures/gate-check-unpriced-harborline/estimation.json +215 -0
  92. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation-inputs.json +224 -34
  93. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation.json +103 -114
  94. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-harborline-dispatch/estimation.md +48 -22
  95. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation-inputs.json +211 -33
  96. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation.json +102 -117
  97. package/plugins/solution-architect/skills/proposal/evals/fixtures/pre-fed-meridian-dental/estimation.md +48 -25
  98. package/plugins/solution-architect/skills/proposal/references/interview.md +3 -6
  99. package/plugins/solution-architect/skills/proposal/references/review.md +5 -4
  100. package/plugins/solution-architect/skills/proposal/references/writing.md +33 -31
  101. package/plugins/solution-architect/skills/proposal/scripts/derive.mjs +1 -1
  102. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-client.mjs +5 -22
  103. package/plugins/solution-architect/skills/proposal/scripts/lib/checks-doc.mjs +18 -8
  104. package/plugins/solution-architect/skills/proposal/scripts/lib/checks.mjs +6 -2
  105. package/plugins/solution-architect/skills/proposal/scripts/lib/figures.mjs +24 -33
  106. package/plugins/solution-architect/skills/proposal/scripts/lib/sections.mjs +1 -1
  107. package/plugins/solution-architect/skills/proposal/scripts/test/checks-client.test.mjs +50 -47
  108. package/plugins/solution-architect/skills/proposal/scripts/test/checks-doc.test.mjs +99 -40
  109. package/plugins/solution-architect/skills/proposal/scripts/test/docs.test.mjs +11 -5
  110. package/plugins/solution-architect/skills/proposal/scripts/test/e2e.test.mjs +1 -1
  111. package/plugins/solution-architect/skills/proposal/scripts/test/evals-fixtures.test.mjs +39 -0
  112. package/plugins/solution-architect/skills/proposal/scripts/test/figures.test.mjs +67 -54
  113. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-fail.md +6 -1
  114. package/plugins/solution-architect/skills/proposal/scripts/test/fixtures/proposal-pass.md +8 -12
  115. package/plugins/solution-architect/skills/proposal/scripts/test/render.test.mjs +1 -1
  116. package/plugins/solution-architect/skills/proposal/scripts/test/validate.test.mjs +3 -2
  117. package/plugins/solution-architect/skills/estimate/scripts/lib/scenario-schema.mjs +0 -39
@@ -2,6 +2,7 @@ import { test } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { readFileSync } from 'node:fs';
4
4
  import { checkInputs } from '../lib/schema.mjs';
5
+ import { checkContext } from '../lib/context-schema.mjs';
5
6
 
6
7
  const fixture = () => JSON.parse(
7
8
  readFileSync(new URL('./fixtures/booking-inputs.json', import.meta.url), 'utf8'));
@@ -16,14 +17,14 @@ test('every defect is named with its path', () => {
16
17
  bad.features[0].tasks[1].category = 'ai-magic'; // unknown category
17
18
  bad.features[1].provenance = 'observed'; // valid vocabulary, but scope must be stated|proposed
18
19
  delete bad.features[0].tasks[0].assumptions; // missing register
19
- bad.recommendedScenario = 'ghost'; // not a scenario id
20
+ bad.risks[0].probability = 7; // out of [0, 1]
20
21
  const findings = checkInputs(bad);
21
22
  assert.equal(findings.length, 5);
22
23
  assert.ok(findings.some((f) => f.includes('booking-api') && f.includes('o <= m <= p')));
23
24
  assert.ok(findings.some((f) => f.includes('booking-rules') && f.includes('category')));
24
25
  assert.ok(findings.some((f) => f.includes('reminders') && f.includes('stated|proposed')));
25
26
  assert.ok(findings.some((f) => f.includes('booking-api') && f.includes('assumptions')));
26
- assert.ok(findings.some((f) => f.includes('recommendedScenario')));
27
+ assert.ok(findings.some((f) => f.includes('probability')));
27
28
  });
28
29
 
29
30
  test('zero estimates are refused — the honest absence is "not estimated"', () => {
@@ -34,19 +35,17 @@ test('zero estimates are refused — the honest absence is "not estimated"', ()
34
35
 
35
36
  test('anything compute would turn into NaN is refused up front', () => {
36
37
  const bad = fixture();
37
- bad.scenarios[1].aiAssisted = 'yes';
38
- bad.scenarios[0].team[0].seniority = 'staff';
39
- bad.scenarios[0].team[1].rate = -5;
40
- bad.overheadPct = 1.4;
38
+ bad.features[0].tasks[0].p = 'lots';
39
+ bad.features[1].tasks[0].m = -20;
41
40
  bad.verificationPct = 'lots';
42
41
  bad.risks[0].probability = 7;
42
+ bad.risks[0].impactHours = -10;
43
43
  const findings = checkInputs(bad);
44
- assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('aiAssisted')));
45
- assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('seniority')));
46
- assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('rate')));
47
- assert.ok(findings.some((f) => f.includes('overheadPct')));
44
+ assert.ok(findings.some((f) => f.includes('booking-api') && f.includes('numbers')));
45
+ assert.ok(findings.some((f) => f.includes('reminder-jobs') && f.includes('o <= m <= p')));
48
46
  assert.ok(findings.some((f) => f.includes('verificationPct')));
49
47
  assert.ok(findings.some((f) => f.includes('probability')));
48
+ assert.ok(findings.some((f) => f.includes('impactHours')));
50
49
  });
51
50
 
52
51
  test('a string estimate is refused, not silently coerced by pert()', () => {
@@ -63,62 +62,17 @@ test('a feature with no tasks is refused — the zero-spread exemption must not
63
62
  assert.ok(findings.some((f) => f.includes('reminders') && f.includes('task')));
64
63
  });
65
64
 
65
+ // category is the only object-keyed enum left in the schema subsystem
66
+ // (Object.hasOwn(AI_CATEGORIES, ...)) — every other vocabulary (PROVENANCE,
67
+ // CONFIDENCE, DELIVERY_MODES, TASK_SHAPES, SOURCES) is an array checked with
68
+ // .includes(), which has no prototype-chain hazard. This is therefore the
69
+ // only field where an inherited key like "toString" could slip past an enum
70
+ // check — do not "balance" this test with a second field.
66
71
  test('inherited object keys do not pass the enum checks', () => {
67
72
  const bad = fixture();
68
73
  bad.features[0].tasks[0].category = 'toString';
69
- bad.scenarios[0].team[0].seniority = 'toString';
70
74
  const findings = checkInputs(bad);
71
75
  assert.ok(findings.some((f) => f.includes('booking-api') && f.includes('category')));
72
- assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('seniority')));
73
- });
74
-
75
- // The Claude-plan enum is gone: a scenario says whether the team has AI
76
- // help (drives hours) and what a tooling seat costs (drives cost, nullable).
77
- test('a legacy "plan" key is refused and the finding names its replacement', () => {
78
- const bad = fixture();
79
- bad.scenarios[1].plan = 'max5x';
80
- const findings = checkInputs(bad);
81
- assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('plan') && f.includes('aiAssisted')));
82
- });
83
-
84
- test('aiAssisted must be a boolean and toolingCostPerSeat a positive number or null', () => {
85
- const bad = fixture();
86
- delete bad.scenarios[0].aiAssisted;
87
- bad.scenarios[1].toolingCostPerSeat = '100';
88
- let findings = checkInputs(bad);
89
- assert.ok(findings.some((f) => f.includes('3eng-noai') && f.includes('aiAssisted')));
90
- assert.ok(findings.some((f) => f.includes('2eng-max5x') && f.includes('toolingCostPerSeat')));
91
- const zero = fixture();
92
- zero.scenarios[1].toolingCostPerSeat = 0;
93
- assert.ok(checkInputs(zero).some((f) => f.includes('2eng-max5x') && f.includes('toolingCostPerSeat')));
94
- const missing = fixture();
95
- delete missing.scenarios[1].toolingCostPerSeat;
96
- assert.ok(checkInputs(missing).some((f) => f.includes('2eng-max5x') && f.includes('toolingCostPerSeat')));
97
- });
98
-
99
- // Skipping the seat price is allowed — the client may mandate a vendor — but
100
- // only as a recorded gap: an AI-assisted scenario with a null seat cost needs
101
- // an assumption that says so, or the page would show a total silently missing
102
- // a line item.
103
- test('a null seat cost on an AI-assisted scenario needs a tooling assumption', () => {
104
- const gap = fixture();
105
- gap.scenarios[1].toolingCostPerSeat = null;
106
- assert.ok(checkInputs(gap).some((f) => f.includes('2eng-max5x') && f.includes('tooling') && f.includes('assumption')));
107
- gap.assumptions.push({ text: 'AI tooling cost per seat not yet set — client may mandate a vendor',
108
- impactIfWrong: 'adds ~2% to total at $100-200/seat/month' });
109
- assert.deepEqual(checkInputs(gap), []);
110
- const unaided = fixture();
111
- unaided.scenarios[0].toolingCostPerSeat = null; // 3eng-noai is aiAssisted: false — no gap to record
112
- assert.deepEqual(checkInputs(unaided), []);
113
- });
114
-
115
- test('recommendedReason, when present, is a non-empty string', () => {
116
- const ok = fixture();
117
- ok.recommendedReason = 'client has one senior available';
118
- assert.deepEqual(checkInputs(ok), []);
119
- const bad = fixture();
120
- bad.recommendedReason = ' ';
121
- assert.ok(checkInputs(bad).some((f) => f.includes('recommendedReason')));
122
76
  });
123
77
 
124
78
  test('milestones are all-or-nothing across features', () => {
@@ -175,6 +129,15 @@ test('a blank milestone is refused; none at all is fine', () => {
175
129
  assert.deepEqual(checkInputs(bare), []); // no milestones at all → still valid
176
130
  });
177
131
 
132
+ test('a bare true deepEstimateWaiver does not buy a pass; a reason does', () => {
133
+ const bad = fixture();
134
+ bad.features[0].deepEstimateWaiver = true;
135
+ assert.ok(checkInputs(bad).some((f) => f.includes('booking') && f.includes('deepEstimateWaiver')));
136
+ const good = fixture();
137
+ good.features[0].deepEstimateWaiver = 'client capped this feature at the band price';
138
+ assert.deepEqual(checkInputs(good), []);
139
+ });
140
+
178
141
  // Agentic-mode schema branch.
179
142
  const agenticFixturePath = new URL('./fixtures/agentic-inputs.json', import.meta.url).pathname;
180
143
  const agenticFixture = () => JSON.parse(readFileSync(agenticFixturePath, 'utf8'));
@@ -287,3 +250,93 @@ test('depth must be one of the three named depths', () => {
287
250
  bad.depth = 'SCORING';
288
251
  assert.ok(checkInputs(bad).some((f) => f === 'depth must be QUICK|STANDARD|DEEP'));
289
252
  });
253
+
254
+ // Context factors: five project-wide multipliers that replaced scenarios.
255
+ const contextBase = () => ({
256
+ project: 'x', technique: 't', depth: 'STANDARD', features: [], risks: [],
257
+ assumptions: [], verificationPct: 0.12,
258
+ contextLevels: {
259
+ codebaseMaturity: 2, stackFamiliarity: 1, specQuality: 3, compliance: 1, clientDecisions: 2,
260
+ },
261
+ contextProvenance: {
262
+ codebaseMaturity: { level: 2, anchor: 'young and clean', cite: 'ARCHITECTURE.md §3', source: 'derived' },
263
+ stackFamiliarity: { level: 1, anchor: 'core stack, done before', cite: 'interview', source: 'stated' },
264
+ specQuality: { level: 3, anchor: 'outline or slide deck', cite: 'requirements.json readiness 62', source: 'derived' },
265
+ compliance: { level: 1, anchor: 'none', cite: 'ARCHITECTURE.md §8 no PII', source: 'derived' },
266
+ clientDecisions: { level: 2, anchor: 'two or three', cite: 'requirements.md Part 1', source: 'derived' },
267
+ },
268
+ });
269
+
270
+ test('scenarios are no longer a required top-level key', () => {
271
+ const out = checkInputs(contextBase());
272
+ assert.ok(!out.some((f) => /scenarios|recommendedScenario/.test(f)), out.join('\n'));
273
+ });
274
+
275
+ test('a leftover scenarios key is refused, not ignored', () => {
276
+ const out = checkInputs({ ...contextBase(), scenarios: [{ id: 'a' }] });
277
+ assert.ok(out.some((f) => /scenarios.*removed/i.test(f)), out.join('\n'));
278
+ });
279
+
280
+ test('every context factor is required at STANDARD depth', () => {
281
+ const inputs = contextBase();
282
+ delete inputs.contextLevels.compliance;
283
+ const out = [];
284
+ checkContext(inputs, out);
285
+ assert.ok(out.some((f) => /compliance/.test(f)), out.join('\n'));
286
+ });
287
+
288
+ test('a context level outside 1-4 is refused', () => {
289
+ const inputs = contextBase();
290
+ inputs.contextLevels.compliance = 5;
291
+ const out = [];
292
+ checkContext(inputs, out);
293
+ assert.ok(out.some((f) => /compliance.*1-4/.test(f)), out.join('\n'));
294
+ });
295
+
296
+ test('every context factor carries an anchor, a cite and a source', () => {
297
+ const inputs = contextBase();
298
+ delete inputs.contextProvenance.specQuality.cite;
299
+ const out = [];
300
+ checkContext(inputs, out);
301
+ assert.ok(out.some((f) => /specQuality.*cite/.test(f)), out.join('\n'));
302
+ });
303
+
304
+ test('a context factor with no anchor is refused', () => {
305
+ const inputs = contextBase();
306
+ delete inputs.contextProvenance.specQuality.anchor;
307
+ const out = [];
308
+ checkContext(inputs, out);
309
+ assert.ok(out.some((f) => /specQuality.*anchor/.test(f)), out.join('\n'));
310
+ });
311
+
312
+ test('a provenance level that disagrees with contextLevels is refused, both values named', () => {
313
+ const inputs = contextBase();
314
+ inputs.contextProvenance.compliance.level = 3; // contextLevels.compliance stays 1
315
+ const out = [];
316
+ checkContext(inputs, out);
317
+ assert.ok(out.some((f) => f.includes('compliance') && f.includes('3') && f.includes('contextLevels.compliance = 1')), out.join('\n'));
318
+ });
319
+
320
+ test('context source must be derived or stated', () => {
321
+ const inputs = contextBase();
322
+ inputs.contextProvenance.compliance.source = 'guessed';
323
+ const out = [];
324
+ checkContext(inputs, out);
325
+ assert.ok(out.some((f) => /compliance.*derived\|stated/.test(f)), out.join('\n'));
326
+ });
327
+
328
+ test('QUICK depth needs no context factors', () => {
329
+ const inputs = { ...contextBase(), depth: 'QUICK' };
330
+ delete inputs.contextLevels;
331
+ delete inputs.contextProvenance;
332
+ const out = [];
333
+ checkContext(inputs, out);
334
+ assert.deepEqual(out, []);
335
+ });
336
+
337
+ test('agentic depth STANDARD needs no context factors either', () => {
338
+ const inputs = agenticFixture();
339
+ const out = [];
340
+ checkContext(inputs, out);
341
+ assert.deepEqual(out, []);
342
+ });
@@ -7,12 +7,17 @@ import { join } from 'node:path';
7
7
  import { pathToFileURL } from 'node:url';
8
8
  import { toCsv, parseCsv, fromCsv, CSV_HEADERS } from '../lib/score-csv.mjs';
9
9
  import { diffScores, applyDiff } from '../lib/score-diff.mjs';
10
- import { loadGuide } from '../lib/scoring.mjs';
10
+ import { loadGuide, guideTableHtml } from '../lib/scoring.mjs';
11
+ import { toHtml } from '../lib/score-html.mjs';
12
+ import { tierFor } from '../lib/pricing.mjs';
11
13
  import { findChrome } from '../../../analyze-requirements/scripts/lib/chrome.mjs';
12
14
  import { openPage } from '../../../analyze-requirements/scripts/lib/cdp.mjs';
13
15
 
14
16
  const cli = new URL('../score-review.mjs', import.meta.url).pathname;
15
17
  const skip = { skip: !findChrome() && 'no chrome on PATH' };
18
+ const templatePath = new URL('../../assets/scores-review-template.html', import.meta.url).pathname;
19
+ const pricingPath = new URL('../lib/pricing.mjs', import.meta.url).pathname;
20
+ const nums = (tech, size, deps, unc, risk) => ({ tech, size, deps, unc, risk });
16
21
 
17
22
  const inputs = () => JSON.parse(readFileSync(new URL('./fixtures/booking-inputs.json', import.meta.url), 'utf8'));
18
23
  const draft = () => {
@@ -185,3 +190,31 @@ test('review page: a feature id with a quote in it cannot inject attributes', sk
185
190
  assert.equal(await page.eval(`window.__pwned === undefined`), true);
186
191
  } finally { page.close(); }
187
192
  });
193
+
194
+ test('tierFor returns the weighted total, rounded, with its tier', () => {
195
+ assert.deepEqual(tierFor(nums(1, 3, 3, 3, 3)), { total: 13, tier: 'M' });
196
+ assert.deepEqual(tierFor(nums(3, 3, 4, 2, 4)), { total: 15.5, tier: 'M' });
197
+ assert.deepEqual(tierFor(nums(2, 3, 2, 1, 1)), { total: 8, tier: 'S' });
198
+ });
199
+
200
+ test('two features with the same scores group on an identical total', () => {
201
+ assert.equal(tierFor(nums(4, 2, 3, 3, 2)).total, tierFor(nums(4, 2, 3, 3, 2)).total);
202
+ });
203
+
204
+ test('the review page inlines the weighted scale, not the old breaks', () => {
205
+ const html = toHtml({
206
+ draft: draft(),
207
+ template: readFileSync(templatePath, 'utf8'),
208
+ guideHtml: guideTableHtml(loadGuide()),
209
+ mathSrc: readFileSync(pricingPath, 'utf8'),
210
+ });
211
+ assert.ok(html.includes('BANDS'), 'BANDS must be inlined');
212
+ assert.ok(!html.includes('TIER_BREAKS'), 'TIER_BREAKS must be gone');
213
+ assert.ok(html.includes('weightedScore'), 'weightedScore must be inlined');
214
+ });
215
+
216
+ test('the csv carries the weighted total', () => {
217
+ const csv = toCsv(draft());
218
+ const [, booking] = csv.trim().split('\n');
219
+ assert.match(booking, /,14,M,/, csv.split('\n').slice(0, 3).join('\n'));
220
+ });
@@ -2,13 +2,19 @@ import { test } from 'node:test';
2
2
  import assert from 'node:assert/strict';
3
3
  import { readFileSync } from 'node:fs';
4
4
  import { execFileSync } from 'node:child_process';
5
- import { checkDeliverables } from '../lib/checks.mjs';
5
+ import { checkDeliverables, checkDeepEstimates } from '../lib/checks.mjs';
6
6
  import { computeEstimation } from '../lib/rollup.mjs';
7
7
  import { loadMeasurements } from '../lib/measurements.mjs';
8
8
 
9
9
  const read = (f) => readFileSync(new URL(`./fixtures/${f}`, import.meta.url), 'utf8');
10
10
  const inputs = () => JSON.parse(read('booking-inputs.json'));
11
11
  const stripRoadmap = (md) => md.replace(/### Roadmap[\s\S]*?(?=### Assumptions)/, '');
12
+ // checkDeliverables under another name, for the price/roadmap tests below.
13
+ const findings = checkDeliverables;
14
+ // The booking fixture already carries milestones and scored features, so
15
+ // one fully computed estimation object serves both the price tests and the
16
+ // roadmap tests below.
17
+ const priced = () => computeEstimation(inputs());
12
18
 
13
19
  test('the pass fixture passes', () => {
14
20
  assert.deepEqual(
@@ -26,17 +32,21 @@ test('neither deliverable fixture names a vendor AI plan', () => {
26
32
 
27
33
  test('each seeded violation is caught by name', () => {
28
34
  const findings = checkDeliverables({ md: read('estimation-fail.md'), estimation: computeEstimation(inputs()) });
29
- for (const needle of ['never 0', 'src', 'assumptions cell', 'assumptions register', 'buffer', 'out of scope', 'scenario', 'roadmap']) {
35
+ for (const needle of ['never 0', 'src', 'assumptions cell', 'assumptions register', 'out of scope', 'scenario', 'roadmap']) {
30
36
  assert.ok(findings.some((f) => f.toLowerCase().includes(needle)), `no finding for: ${needle}`);
31
37
  }
32
38
  });
33
39
 
34
- // One team is the default interview answer now; a comparison table with a
35
- // single row is a complete deliverable, not a missing comparison.
36
- test('a scenario table with one row validates', () => {
37
- const md = read('estimation-pass.md').replace(/\n\| 3eng-noai \|[^\n]*/, '');
40
+ // The price block replaces the scenario table outright — a lingering one is
41
+ // refused even when it sits beside an otherwise-clean, fully priced doc.
42
+ test('a lingering scenario table is refused even in an otherwise-clean deliverable', () => {
43
+ const scenarioTable = '### Scenario comparison\n\n'
44
+ + '| Scenario | Team | AI-assisted | Months | Cost | Notes |\n'
45
+ + '| --- | --- | --- | --- | --- | --- |\n'
46
+ + '| 3eng-noai | 2 mid + 1 junior | no | 0.43 | $7,266 | — |\n\n';
47
+ const md = read('estimation-pass.md').replace('### Price', `${scenarioTable}### Price`);
38
48
  const findings = checkDeliverables({ md, estimation: computeEstimation(inputs()) });
39
- assert.ok(!findings.some((f) => f.includes('scenario')), findings.join('\n'));
49
+ assert.ok(findings.some((f) => /scenario table was removed/i.test(f)), findings.join('\n'));
40
50
  });
41
51
 
42
52
  test('hand-edited totals are refused', () => {
@@ -84,9 +94,9 @@ test('no milestones and no Roadmap section is clean', () => {
84
94
  });
85
95
 
86
96
  test('the roadmap honesty line is mandatory', () => {
87
- const md = read('estimation-pass.md').replace(/not calendar dates/, 'roughly');
97
+ const md = read('estimation-pass.md').replace(/relative shares/, 'roughly');
88
98
  const findings = checkDeliverables({ md, estimation: computeEstimation(inputs()) });
89
- assert.ok(findings.some((f) => f.includes('not calendar dates')));
99
+ assert.ok(findings.some((f) => f.includes('relative shares')));
90
100
  });
91
101
 
92
102
  // Agentic deliverable checks.
@@ -145,3 +155,87 @@ test('the Tier column is required at STANDARD depth and ignored at QUICK', () =>
145
155
  const md = read('estimation-pass.md').replace('| User can book appointment | M |', '| User can book appointment | XL |');
146
156
  assert.ok(!checkDeliverables({ md, estimation: computeEstimation(quick) }).some((f) => f.includes('Tier')));
147
157
  });
158
+
159
+ // Price block / deep-estimate checks (Task 6).
160
+ test('the roadmap must say bands are relative shares, not durations', () => {
161
+ const md = '### Roadmap\n\n| Milestone | Share |\n|---|---|\n| M1 | 75% |\n\nBands are relative shares.\n';
162
+ const out = findings({ md, estimation: priced() });
163
+ assert.ok(!out.some((f) => /relative shares/.test(f)), out.join('\n'));
164
+ });
165
+
166
+ test('a roadmap claiming durations is refused', () => {
167
+ const md = '### Roadmap\n\n| Milestone | Months |\n|---|---|\n| M1 | 0.4 |\n\nBands are relative months.\n';
168
+ const out = findings({ md, estimation: priced() });
169
+ assert.ok(out.some((f) => /relative shares/.test(f)), out.join('\n'));
170
+ });
171
+
172
+ test('a scenario comparison table in the md is refused', () => {
173
+ const md = '## Summary\n\n| Scenario | Team | AI-assisted | Months | Cost |\n|---|---|---|---|---|\n';
174
+ const out = findings({ md, estimation: priced() });
175
+ assert.ok(out.some((f) => /scenario table was removed/i.test(f)), out.join('\n'));
176
+ });
177
+
178
+ test('the presented range must appear in the md', () => {
179
+ const out = findings({ md: '## Summary\n\nNo numbers here.\n', estimation: priced() });
180
+ assert.ok(out.some((f) => /presented range/i.test(f)), out.join('\n'));
181
+ });
182
+
183
+ test('a feature flagged for a deep estimate needs a breakdown or a waiver', () => {
184
+ const est = priced();
185
+ const id = Object.keys(est.computed.features)[0];
186
+ est.computed.features[id].flag = 'Deep estimate required';
187
+ est.inputs.features.find((f) => f.id === id).tasks = [];
188
+ const out = [];
189
+ checkDeepEstimates(est, out);
190
+ assert.ok(out.some((f) => new RegExp(id).test(f)), out.join('\n'));
191
+ });
192
+
193
+ // schema.mjs makes every feature carry at least one task, so "has tasks"
194
+ // can never fail. One task is not a breakdown (R58): the deep pass needs two
195
+ // or more, or a waiver.
196
+ test('a flagged feature with a single ordinary task is refused; two tasks pass', () => {
197
+ const est = priced();
198
+ const id = 'reminders';
199
+ est.computed.features[id].flag = 'Deep estimate required';
200
+ const feature = est.inputs.features.find((f) => f.id === id);
201
+ assert.equal(feature.tasks.length, 1, 'fixture precondition: reminders has one task');
202
+ const one = [];
203
+ checkDeepEstimates(est, one);
204
+ assert.ok(one.some((f) => f.includes(id)), 'one task must not satisfy the deep-estimate gate');
205
+ feature.tasks = [feature.tasks[0], { ...feature.tasks[0], name: 'second task' }];
206
+ const two = [];
207
+ checkDeepEstimates(est, two);
208
+ assert.deepEqual(two, []);
209
+ });
210
+
211
+ test('a waived deep estimate passes', () => {
212
+ const est = priced();
213
+ const id = Object.keys(est.computed.features)[0];
214
+ est.computed.features[id].flag = 'Deep estimate required';
215
+ est.inputs.features.find((f) => f.id === id).deepEstimateWaiver = 'client capped this feature at the band price';
216
+ const out = [];
217
+ checkDeepEstimates(est, out);
218
+ assert.deepEqual(out, []);
219
+ });
220
+
221
+ // Through the real gate (checkDeliverables, the path validate.mjs actually
222
+ // takes) rather than the helper in isolation: validate.mjs reads
223
+ // estimation.json straight off disk and never runs checkInputs, so a bare
224
+ // `true` hand-edited into inputs.deepEstimateWaiver after compute must still
225
+ // be refused here, not just at schema.mjs's compute-time gate.
226
+ test('a bare true deepEstimateWaiver does not pass the real gate; a reason does', () => {
227
+ const est = priced();
228
+ const id = Object.keys(est.computed.features)[0];
229
+ est.computed.features[id].flag = 'Deep estimate required';
230
+ const feature = est.inputs.features.find((f) => f.id === id);
231
+ feature.tasks = [];
232
+ const md = read('estimation-pass.md');
233
+
234
+ feature.deepEstimateWaiver = true;
235
+ const tampered = checkDeliverables({ md, estimation: est });
236
+ assert.ok(tampered.some((f) => f.includes(id) && f.includes('deepEstimateWaiver')), tampered.join('\n'));
237
+
238
+ feature.deepEstimateWaiver = 'client capped this feature at the band price';
239
+ const passing = checkDeliverables({ md, estimation: est });
240
+ assert.ok(!passing.some((f) => f.includes(id) && f.includes('deepEstimateWaiver')), passing.join('\n'));
241
+ });