Define interval boundaries, separate planned from actual work and verify dependency logic before drawing bars.
Gantt timelines: make task dates and dependencies auditable
Bars are intervals
A Gantt-style timeline uses a horizontal interval for each task. Decide whether the end timestamp is exclusive or inclusive; an end-exclusive interval allows one task to end exactly when another begins without overlap. State the time zone and whether a displayed day means a calendar day or working day. Calendar semantics matter when a task crosses holidays or daylight-saving changes. Never reduce an actual timestamp to a date label before checking that its start and end still make sense.
Plan and actual are different records
A baseline plan should remain visible after work slips. Store planned start and finish separately from actual start and finish, and mark unfinished work as open rather than inventing an actual end at today. A progress fill is a third measurement, not a substitute for dates. Annotations can identify approvals, outages and scope changes, but placing them near a delay does not establish causation. Report the date at which the displayed project state was captured so a screenshot can be interpreted later.
Dependencies are a graph
A predecessor relationship means the successor has a scheduling constraint, not merely that its bar appears later on the page. Validate referenced task IDs, detect cycles and apply the chosen lag rule before rendering arrows. When a dependency is violated, show the violation rather than nudging a bar into a visually tidy position. Network identity rules apply: stable task IDs are safer than matching labels, which may change. For a crowded plan, show a selected path and a searchable dependency table instead of drawing every connector.
Resource overlap is not always an error
Two tasks can run concurrently on different teams; two tasks assigned to one exclusive machine cannot. Declare resource capacity before flagging overlap. A timeline sorted by start date may be useful for operations, while sorting by workstream may be better for planning; document the order so movement is not mistaken for a schedule change. Linked selection state should preserve which tasks and resources are visible. Provide an accessible task table with interval, status, predecessor and resource fields, and test the mobile view where narrow bars become untappable.
Worked contract
from datetime import datetime
def exclusive_resource_conflicts(
tasks: list[tuple[str, str, datetime, datetime]]
) -> list[tuple[str, str, str]]:
identifiers = [task_id for task_id, _, _, _ in tasks]
if len(identifiers) != len(set(identifiers)):
raise ValueError("task IDs must be unique")
by_resource = {}
for task_id, resource, start, end in tasks:
if not task_id or not resource or start.tzinfo is None or end.tzinfo is None:
raise ValueError("tasks need IDs, resources and zoned dates")
if end <= start:
raise ValueError("end-exclusive interval must have positive duration")
by_resource.setdefault(resource, []).append((start, end, task_id))
conflicts = []
for resource, intervals in by_resource.items():
ordered = sorted(intervals)
for index, previous in enumerate(ordered):
for current in ordered[index + 1:]:
if current[0] >= previous[1]:
break
conflicts.append((resource, previous[2], current[2]))
return conflicts
from datetime import timezone
utc = timezone.utc
inspection = ("inspect-47", "crane-A", datetime(2026, 10, 8, 8, tzinfo=utc),
datetime(2026, 10, 8, 11, tzinfo=utc))
repair = ("repair-59", "crane-A", datetime(2026, 10, 8, 10, tzinfo=utc),
datetime(2026, 10, 8, 13, tzinfo=utc))
assert exclusive_resource_conflicts([inspection, repair]) == [
("crane-A", "inspect-47", "repair-59")
]
short_job = ("check-83", "crane-A", datetime(2026, 10, 8, 10, 30, tzinfo=utc),
datetime(2026, 10, 8, 10, 45, tzinfo=utc))
assert len(exclusive_resource_conflicts([inspection, repair, short_job])) == 3Performance and operating cost
For N tasks, sorting costs O(N log N); enumerating every conflicting pair takes O(N squared) time in the worst case and O(N plus K) space for K reported pairs. When many tasks overlap, K itself can be quadratic. This check is not a dependency scheduler or a capacity planner. Validate dependency references and cycles separately before publishing arrows, and preserve planned and actual intervals in the export.
Common Mistakes
- Mixing inclusive and exclusive task end dates.
- Overwriting the original plan with actual dates.
- Drawing dependency arrows without validating task IDs or cycles.
- Calling every overlap an error without a resource-capacity rule.
Validation drill
Plot 47 maintenance tasks with planned and actual dates, two exclusive machines and three predecessor chains. Flag interval conflicts and an unfinished task without assigning it a fake actual end.
