refactor(#3309): migrate cmdValidateHealth onto the rule table
Replaces cmdValidateHealth's hand-rolled addIssue/switch accumulation
(961 lines) with buildPlanningSnapshot -> evaluateRules -> map to the
legacy {code, message, fix, repairable} shape, bucketed by severity.
Two pre-checks (home-dir E010/I010, .planning/-root-missing E001) stay
outside the rule table entirely, per ADR-3180 §8.2 rule 4 ("no
precedence system") — building "some rules suppress others" into the
table would itself be the forbidden precedence system.
W024 (STATE.md commit-age freshness) also stays outside the table:
its committed rule is a documented permanent no-op (readStateHeadFreshness's
git-log shell-out is ambient I/O a Rule.check may never perform, and no
PlanningSnapshot field carries a commits-behind count). Migrating onto
the rule table as designed would have silently regressed 7 passing
tests in tests/health-validation.test.cjs — found while wiring this
function, kept as a real check in the wrapper instead (same I/O
license applyRepairs already relies on), fixed inline per this repo's
no-defer policy rather than accepted as a silent loss.
Ports the real repair-handler bodies (createConfig/resetConfig,
regenerateState, addNyquistKey/addAiIntegrationPhaseKey,
backfillMilestones) into health-diagnostic.cts's applyRepairs,
replacing the skeleton's stub. DESTRUCTIVE-risk remedies
(resetConfig/regenerateState) are refused by --repair — a disclosed
breaking change; repairable now means "an automatic repair will
actually run," not merely "a remedy exists to describe," so E004/E005
now report repairable:false. --backfill alone now actually triggers
backfillMilestones, fixing a latent bug where its gate was unreachable
without --repair also being set (verify.cts:2504, confirmed dead code
pre-migration).
Test updates distinguish the two explicitly-authorized behavior
changes (DESTRUCTIVE refusal, backfill-alone fix, W021->W026 split)
from preservation — every changed assertion is commented with why, and
new regression tests were added for both changes plus W021/W026
mutual independence. Drift-guard bookkeeping (bypass-baseline shrunk
to the one disclosed W024 exception, milestone-window and
phase-enumeration exemptions, test-file-count allowlist) updated for
the relocated/new functions this migration introduces.
This commit is contained in:
@@ -1,109 +1,11 @@
|
||||
{
|
||||
"$comment": "ADR-3180 §8.1 rule 2 ratchet, owned by Phase 11 (#3309). See scripts/lint-planning-snapshot-bypass-drift.cjs. SHRINK-ONLY: entries are removed as cmdValidateHealth migrates onto src/planning-snapshot.cts; new or changed entries fail lint:ci. `count` is the number of byte-identical (file, text) occurrences acknowledged at this site — a run producing fewer fails as a partial migration, more fails as an unacknowledged new copy.",
|
||||
"entries": [
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": ".readdirSync(phasesDir, { withFileTypes: true })",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "? fs.readFileSync(milestonesPath, 'utf-8')",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 2
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const archiveFiles = fs.readdirSync(milestonesArchiveDir);",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const configRaw = fs.readFileSync(configPath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 4
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const content = fs.readFileSync(projectPath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const entries = fs.readdirSync(rootBase, { withFileTypes: true });",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const rawCfg = fs.readFileSync(configPath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const researchContent = fs.readFileSync(",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const roadmapContent = fs.readFileSync(roadmapPath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const roadmapContentFull = fs.readFileSync(roadmapPath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const roadmapContentRaw = fs.readFileSync(roadmapPath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const roadmapRaw = fs.readFileSync(roadmapPath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 2
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const stateContent = fs.readFileSync(statePath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 2
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "const stateRaw = fs.readFileSync(statePath, 'utf-8');",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
},
|
||||
{
|
||||
"file": "src/verify.cts",
|
||||
"text": "phaseDirFiles.set(e.name, fs.readdirSync(path.join(phasesDir, e.name)));",
|
||||
"derivation": "planning-snapshot-bypass",
|
||||
"owner_issue": "#3309",
|
||||
"count": 1
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user