When planning complex projects with many nested steps, it is difficult to see if the logic is flawed because of circular dependencies. This makes it hard to tell if a sequence of tasks can actually be completed.
It analyzes a list of tasks to identify circular loops and assigns a reliability score based on how well the sequence flows. It flags logical errors where steps depend on each other in a way that creates a deadlock.
It identifies broken logic in a project plan before any work actually begins.
It was run in the sandbox and it failed. run produced no meaningful output (empty or near-empty).
$ python3 task-dependency-score.py Reliability Score: 0.30
No screenshot — there is nothing working to show. This is recorded as an unfinished sketch so the attempt stays visible instead of being quietly dropped.
All of it — 62 lines, one file, standard library only.
# Self-Correcting Task Dependency Score
import sys
from collections import defaultdict
def main():
# Example task dependencies (replace with actual input)
tasks = {
1: [2],
2: [3],
3: [1], # Cycle detected here
4: [5],
5: []
}
# Detect cycles
has_cycle = detect_cycles(tasks)
# Detect oscillations (simplified: checks for bidirectional dependencies)
oscillation = detect_oscillation(tasks)
# Calculate reliability score (0.0-1.0, lower is worse)
score = 1.0
if has_cycle:
score *= 0.3 # Heavy penalty for cycles
if oscillation:
score *= 0.8 # Moderate penalty for oscillations
print(f"Reliability Score: {score:.2f}")
def detect_cycles(graph):
visited = set()
recursion_stack = set()
def dfs(node):
if node in recursion_stack:
return True
if node in visited:
return False
visited.add(node)
recursion_stack.add(node)
for neighbor in graph.get(node, []):
if dfs(neighbor):
return True
recursion_stack.remove(node)
return False
for node in graph:
if dfs(node):
return True
return False
def detect_oscillation(graph):
# Simplified: checks for bidirectional dependencies
for node in graph:
for dependency in graph[node]:
if node in graph.get(dependency, []):
return True
return False
if __name__ == "__main__":
main()