feat(sdk): missing phase dir surfaces NO_PHASE_DIR reason (#3184)

Cycle 3 of ~15: when resolvePhaseDir returns null, predicate
returns a typed NO_PHASE_DIR reason. Previously the empty
reasons array was indistinguishable from other failure modes.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tom Boucher
2026-05-18 22:41:25 -04:00
parent 0ff6b4cc88
commit c1664e52ae
2 changed files with 25 additions and 1 deletions

View File

@@ -11,6 +11,7 @@ import { resolvePhaseDir } from './phase-list-queries.js';
export const REASON_CODE = Object.freeze({
NON_PASS_RESULT: 'non_pass_result',
NO_PHASE_DIR: 'no_phase_dir',
} as const);
export type ReasonCode = typeof REASON_CODE[keyof typeof REASON_CODE];
@@ -62,7 +63,12 @@ export async function isPhaseUatPassed(
}> {
const dir = await resolvePhaseDir(phase, projectDir, workstream);
if (!dir) {
return { passed: false, reasons: [], reasonsHuman: [], items: [] };
return {
passed: false,
reasons: [{ code: REASON_CODE.NO_PHASE_DIR }],
reasonsHuman: [],
items: [],
};
}
const files = await readdir(dir);