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 inside an isolated container with no network access. This is the exact command and the real output it produced — captured process output, not written by a model.
$ python3 task-dependency-score.py Reliability Score: 0.30
A screenshot of that run.
A clean run proves this does what is shown above, in a CPU-only sandbox. It is a small research demo — not a production tool, and nothing here was published anywhere.
All of it — 68 lines, one file, standard library only.
# task-dependency-score.py # Self-Correcting Task Dependency Score v2
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 and identify involved nodes
cycles = detect_cycles(tasks)
has_cycle = len(cycles) > 0
# Detect oscillations (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
print(f"Detected cycles involving nodes:\n")
for cycle in cycles:
print(" -> ".join(map(str, cycle)))
if oscillation:
score *= 0.8 # Moderate penalty for oscillations
print(f"Reliability Score: {score:.2f}")
def detect_cycles(graph):
visited = set()
path = []
cycles = []
def dfs(node):
nonlocal cycles
if node in path:
idx = path.index(node)
cycles.append(path[idx:])
return True
if node in visited:
return False
visited.add(node)
path.append(node)
for neighbor in graph.get(node, []):
if dfs(neighbor):
return True
path.pop()
return False
for node in graph:
if dfs(node):
return cycles
return None
def detect_oscillation(graph):
# 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()