* test(#4801): failing-first — an archived phase directory must resolve and report complete in init.manager * fix(#4801): init.manager resolves archived phase directories through findPhaseInternal The private current-milestone-only scan (matchPhaseDirs over listMilestonePhaseDirs) counted archived phase directories as missing, so an archived phase with a passed verification reported no_directory/phase_complete:false. findPhaseInternal — already imported, already the shared primitive for five other init commands — searches the live directory first and falls back through the workstream-scoped archive (#2855); the private copy and its single-consumer entries list are retired. * chore(#4801): backfill changeset PR number (4893) --------- Co-authored-by: sim <sim@local>
This commit is contained in:
@@ -204,13 +204,15 @@ function listArchiveVersionDirs(cwd: string, wsOverride?: string | null): Archiv
|
||||
return out;
|
||||
}
|
||||
|
||||
function searchPhaseInDir(baseDir: string, relBase: string, normalized: string): PhaseSearchResult | null {
|
||||
function searchPhaseInDir(baseDir: string, relBase: string, normalized: string, convention?: string | null): PhaseSearchResult | null {
|
||||
try {
|
||||
const dirs = readSubdirectories(baseDir, true);
|
||||
// #2528: canonical two-pass selection (exact token match, then the
|
||||
// bare-integer leading-digit-run fallback) shared with the find-phase and
|
||||
// phase-plan-index scans — see phase-id.cts::matchPhaseDirs.
|
||||
const { matches, usedBareFallback } = matchPhaseDirs(dirs, normalized);
|
||||
// #4801: the convention is threaded (optional) so bracket-convention
|
||||
// consumers get exact token matching here too.
|
||||
const { matches, usedBareFallback } = matchPhaseDirs(dirs, normalized, convention);
|
||||
if (matches.length === 0) return null;
|
||||
|
||||
// #2237: fail loud when multiple directories match the same bare phase
|
||||
@@ -351,14 +353,15 @@ function searchPhaseInDir(baseDir: string, relBase: string, normalized: string):
|
||||
}
|
||||
}
|
||||
|
||||
function findPhaseInternal(cwd: string, phase: unknown): PhaseSearchResult | null {
|
||||
function findPhaseInternal(cwd: string, phase: unknown, convention?: string | null): PhaseSearchResult | null {
|
||||
if (!phase) return null;
|
||||
|
||||
const phasesDir = path.join(planningDir(cwd), 'phases');
|
||||
const normalized = normalizePhaseName(phase);
|
||||
|
||||
const relPhasesDir = toPosixPath(path.relative(cwd, phasesDir));
|
||||
const current = searchPhaseInDir(phasesDir, relPhasesDir, normalized);
|
||||
// #4801: convention threaded through to the matcher (see searchPhaseInDir).
|
||||
const current = searchPhaseInDir(phasesDir, relPhasesDir, normalized, convention);
|
||||
if (current) return current;
|
||||
|
||||
// #2855: scope the archived-milestone fallback to the SAME workstream as the
|
||||
@@ -372,7 +375,7 @@ function findPhaseInternal(cwd: string, phase: unknown): PhaseSearchResult | nul
|
||||
// getArchivedPhaseDirs via listArchiveVersionDirs (see its doc comment).
|
||||
for (const { version, archivePath } of listArchiveVersionDirs(cwd)) {
|
||||
const relBase = toPosixPath(path.relative(cwd, archivePath));
|
||||
const result = searchPhaseInDir(archivePath, relBase, normalized);
|
||||
const result = searchPhaseInDir(archivePath, relBase, normalized, convention);
|
||||
if (result) {
|
||||
result.archived = version;
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user