Address @trek-e's review (Option 2, interim tactical fix) on PR #2168: - Add a fast-check property test (tests/derive-progress.property.test.cjs) asserting deriveProgressFromRoadmap's derived counts are invariant to header column ORDER and COUNT — shuffle the header cells and inject unrelated columns, assert counts match the data. This pins the parser's core new capability (header-name lookup vs. the old position-locked regex). Named derive-progress (not phase-lifecycle) so it isn't greedily attributed to the shorter `phase` prod prefix under lint-test-file-count; like the other *.property.test.cjs files it maps to no module and is cap-exempt. - Add boundary regression tests in state.test.cjs: header+separator only (0 rows -> all-null), exactly 1 row, and ragged rows (extra/short cells, handled without throwing). - Mark the adhoc Progress-table scan as pending the ADR-2143 parseMarkdownTable/TABLE_SCHEMAS seam (re-point pending #1372 -> #2143). - Fix the changeset lead-in to the required bold form. Per the maintainer, reader/writer parity and CONTEXT.md updates are explicitly out of scope for this stopgap — Phase 1 (ADR-2143) owns them. Validated: property test 200 runs green; state.test.cjs #2137 block 8/8; eslint clean; lint-test-file-count green; full `npm test` exit 0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -9650,6 +9650,71 @@ describe('#2137 regression: deriveProgressFromRoadmap parses the milestone-group
|
||||
assert.equal(result.totalPhases, 2, `h2 ## Progress table must be found past the h3 decoy. Got ${result.totalPhases}`);
|
||||
assert.equal(result.completedPhases, 2, `completedPhases must be 2. Got ${result.completedPhases}`);
|
||||
});
|
||||
|
||||
// ── Boundary conditions (#2137 review) ──────────────────────────────────────
|
||||
// The header-driven walk terminates at the first non-`|` line and skips the
|
||||
// separator row, so these edges must not throw and must honour the "0 → null"
|
||||
// contract that lets the consumer leave the existing STATE value untouched.
|
||||
|
||||
test('header + separator only (0 data rows) derives all-null', () => {
|
||||
const roadmap = [
|
||||
'## Progress',
|
||||
'',
|
||||
'| Phase | Milestone | Plans Complete | Status | Completed |',
|
||||
'| --- | --- | --- | --- | --- |',
|
||||
].join('\n');
|
||||
|
||||
const result = deriveProgressFromRoadmap(roadmap);
|
||||
assert.deepEqual(
|
||||
result,
|
||||
{ completedPhases: null, totalPhases: null, totalPlans: null },
|
||||
`an empty table must report all-null (0 counts → null), got ${JSON.stringify(result)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('exactly one data row derives that single row', () => {
|
||||
const roadmap = [
|
||||
'## Progress',
|
||||
'',
|
||||
'| Phase | Milestone | Plans Complete | Status | Completed |',
|
||||
'| --- | --- | --- | --- | --- |',
|
||||
'| 1. Foundation | v1.0 | 4/4 | Complete | 2026-01-01 |',
|
||||
].join('\n');
|
||||
|
||||
const result = deriveProgressFromRoadmap(roadmap);
|
||||
assert.deepEqual(
|
||||
result,
|
||||
{ completedPhases: 1, totalPhases: 1, totalPlans: 4 },
|
||||
`a single Complete row must derive {1,1,4}, got ${JSON.stringify(result)}`,
|
||||
);
|
||||
});
|
||||
|
||||
test('ragged rows (more/fewer cells than the header) are handled without throwing', () => {
|
||||
// The reader indexes cells positionally by header name, so an EXTRA trailing
|
||||
// column is ignored and a SHORT row simply has absent Status/Plans cells
|
||||
// (`cells[idx] ?? ''`) — neither should throw or corrupt the well-formed row.
|
||||
const roadmap = [
|
||||
'## Progress',
|
||||
'',
|
||||
'| Phase | Milestone | Plans Complete | Status | Completed |',
|
||||
'| --- | --- | --- | --- | --- |',
|
||||
'| 1. Alpha | v1.0 | 2/2 | Complete | 2026-01-01 | stray-extra-column |', // 6 cells (extra)
|
||||
'| 2. Beta | v1.0 |', // 2 cells (short: Plans/Status/Completed absent)
|
||||
].join('\n');
|
||||
|
||||
let result;
|
||||
assert.doesNotThrow(() => {
|
||||
result = deriveProgressFromRoadmap(roadmap);
|
||||
}, 'ragged rows must not throw');
|
||||
// Row 1: extra column ignored → counted, Complete, +2 plans.
|
||||
// Row 2: short row → counted as a phase, but Status/Plans cells are absent so
|
||||
// it is neither Complete nor plan-bearing.
|
||||
assert.deepEqual(
|
||||
result,
|
||||
{ completedPhases: 1, totalPhases: 2, totalPlans: 2 },
|
||||
`ragged rows must degrade gracefully to {1,2,2}, got ${JSON.stringify(result)}`,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
// ─── Scenario B: state json total_phases via roadmapPhaseCount ───────────────
|
||||
|
||||
Reference in New Issue
Block a user