From 8818c326b74f04c240498ac0e1ba41c84629902e Mon Sep 17 00:00:00 2001 From: William Valentin Date: Fri, 27 Feb 2026 13:30:56 -0800 Subject: [PATCH] fix(audit): clarify missing drift artifacts-dir errors Replace raw ENOENT from drift artifact directory scans with a clear explicit error message containing the resolved path. Architecture/protocol diagrams reviewed; no updates needed. --- docs/plans/state.json | 11 +++++++++++ scripts/check-phase0-baseline-backend-drift.ts | 10 +++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/docs/plans/state.json b/docs/plans/state.json index cfc067d..28da553 100644 --- a/docs/plans/state.json +++ b/docs/plans/state.json @@ -617,6 +617,17 @@ ], "test_status": "pnpm typecheck + HOME=/tmp path-expansion smoke checks passing" }, + "phase0-live-baseline-drift-missing-dir-error-clarity": { + "status": "completed", + "date": "2026-02-27", + "updated": "2026-02-27", + "summary": "Improved drift CLI operator feedback by translating missing artifacts-directory `ENOENT` failures into a clear explicit error message with the resolved path.", + "files_modified": [ + "scripts/check-phase0-baseline-backend-drift.ts", + "docs/plans/state.json" + ], + "test_status": "pnpm typecheck + node --import tsx/esm scripts/check-phase0-baseline-backend-drift.ts --artifacts-dir --backend native --format json passing (clear error)" + }, "phase0-instrumentation-ticket-checklist": { "status": "completed", "date": "2026-02-25", diff --git a/scripts/check-phase0-baseline-backend-drift.ts b/scripts/check-phase0-baseline-backend-drift.ts index 75ea545..9e206a6 100644 --- a/scripts/check-phase0-baseline-backend-drift.ts +++ b/scripts/check-phase0-baseline-backend-drift.ts @@ -209,7 +209,15 @@ function buildThresholds(values: Record): } async function readArtifactRecords(artifactsDir: string): Promise { - const files = await readdir(artifactsDir); + let files: string[]; + try { + files = await readdir(artifactsDir); + } catch (error) { + if ((error as NodeJS.ErrnoException)?.code === 'ENOENT') { + throw new Error(`Artifacts directory does not exist: ${artifactsDir}`); + } + throw error; + } const records: ArtifactRecord[] = []; for (const file of files) {