fix(gsd): ignore pre-existing files in task ordering

This commit is contained in:
mastertyko 2026-04-11 17:30:22 +02:00
parent 64359306c0
commit cfd4d1d13a
2 changed files with 36 additions and 2 deletions

View file

@ -354,7 +354,7 @@ export function checkFilePathConsistency(
*/
export function checkTaskOrdering(
tasks: TaskRow[],
_basePath: string
basePath: string
): PreExecutionCheckJSON[] {
const results: PreExecutionCheckJSON[] = [];
@ -380,7 +380,9 @@ export function checkTaskOrdering(
for (const file of filesToCheck) {
const normalizedFile = normalizeFilePath(file);
const creator = fileCreators.get(normalizedFile);
if (creator && creator.index > i) {
const absolutePath = resolve(basePath, normalizedFile);
const existsOnDisk = existsSync(absolutePath);
if (creator && creator.index > i && !existsOnDisk) {
// Task reads file that is created later — impossible ordering
results.push({
category: "file",

View file

@ -1107,6 +1107,38 @@ describe("checkTaskOrdering false positive regression (#3677)", () => {
assert.equal(results[0].target, "`later.ts` — needed first");
assert.ok(results[0].message.includes("sequence violation"));
});
test("existing on-disk files do not trigger ordering violations just because a later task modifies them", () => {
const tempDir = join(tmpdir(), `pre-exec-ordering-existing-file-${Date.now()}`);
const existingFile = "frontend/src/__tests__/ProcurementPage29.test.tsx";
mkdirSync(join(tempDir, "frontend", "src", "__tests__"), { recursive: true });
writeFileSync(join(tempDir, existingFile), "// existing file");
try {
const tasks = [
createTask({
id: "T01",
sequence: 0,
files: [],
inputs: ["`frontend/src/__tests__/ProcurementPage29.test.tsx` — contains matchMedia stub to remove"],
expected_output: [],
}),
createTask({
id: "T03",
sequence: 2,
files: [],
inputs: [],
expected_output: ["frontend/src/__tests__/ProcurementPage29.test.tsx"],
}),
];
const results = checkTaskOrdering(tasks, tempDir);
assert.equal(results.length, 0, "Pre-existing files should not be treated as created by later tasks");
} finally {
rmSync(tempDir, { recursive: true, force: true });
}
});
});
// ─── checkFilePathConsistency additional edge cases ──────────────────────────