Гант: предшественники с отрицательным днём не дают ложного противоречия сроков
All checks were successful
ci / test (push) Successful in 25s
ci / deploy (push) Successful in 2m7s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-23 19:14:03 +03:00
parent 63044fd46b
commit 538849e300
2 changed files with 12 additions and 1 deletions

View File

@@ -113,7 +113,7 @@ export function computeSchedule(rows: ProcessRow[]): Schedule {
const row = byId.get(id);
if (!row) throw new Error(`нет строки ${id}`);
visiting.add(id);
let depEnd = 0;
let depEnd = Number.NEGATIVE_INFINITY; // шаги до точки отсчёта (день < 0) тоже бывают предшественниками
for (const dep of row.dependsOn) {
if (!byId.has(dep)) {
warnings.push({ id, message: `зависимость ${dep} не найдена в процессе` });
@@ -124,6 +124,7 @@ export function computeSchedule(rows: ProcessRow[]): Schedule {
}
}
visiting.delete(id);
if (depEnd === Number.NEGATIVE_INFINITY) depEnd = 0;
const c = parseConstraint(row.dateConstraint);
const d = parseDuration(row.duration);

View File

@@ -180,6 +180,16 @@ describe("computeSchedule", () => {
expect(warnings).toEqual([{ id: "CP-1", message: expect.stringContaining("позже крайнего срока") }]);
});
it("предшественник до точки отсчёта (день < 0) не даёт ложного противоречия", () => {
const rows = [
row({ id: "A", date_constraint: "день -3 → день -2", duration: "1d" }),
row({ id: "B", depends_on: "A", date_constraint: "день -2 → день -1", duration: "1d" }),
];
const sc = computeSchedule(rows);
expect(sc.timings.get("B")).toMatchObject({ start: -2, end: -1 });
expect(sc.warnings).toEqual([]);
});
it("веха с крайним сроком стоит на прогнозе по предшественникам, а крайний срок рисуется красной чертой", () => {
const rows = [
row({ id: "CP-0", stage: "S", date_constraint: "день 0" }),