fix: always ensure tasks/ directory exists for slice units (#900) (#1050)

ensurePreconditions() had two branches: create-slice (which included
tasks/) and slice-exists (which conditionally created tasks/). The
conditional path could miss cases where a slice dir was created
manually or by a previous run without the tasks/ subdirectory.

Simplified to: create slice dir if missing, then always check and
create tasks/ unconditionally. Removes the branching that could
leave tasks/ missing.
This commit is contained in:
Tom Boucher 2026-03-17 20:39:54 -04:00 committed by GitHub
parent 8382e5bfcc
commit 1f9da9ed5f

View file

@ -3318,15 +3318,16 @@ function ensurePreconditions(
const slicesDir = join(mDirResolved, "slices");
const sDir = resolveDir(slicesDir, sid);
if (!sDir) {
// Create slice dir with bare ID
const newSliceDir = join(slicesDir, sid);
mkdirSync(join(newSliceDir, "tasks"), { recursive: true });
} else {
// Ensure tasks/ subdir exists
const tasksDir = join(slicesDir, sDir, "tasks");
if (!existsSync(tasksDir)) {
mkdirSync(tasksDir, { recursive: true });
}
// Create slice dir with bare ID (tasks/ included)
mkdirSync(join(slicesDir, sid, "tasks"), { recursive: true });
}
// Always ensure tasks/ subdir exists — even when slice dir was already
// present. Handles the case where a slice was created manually or by a
// previous run that didn't create tasks/. (#900)
const resolvedSliceDir = resolveDir(slicesDir, sid) ?? sid;
const tasksDir = join(slicesDir, resolvedSliceDir, "tasks");
if (!existsSync(tasksDir)) {
mkdirSync(tasksDir, { recursive: true });
}
}
}