NOWNESS · invention
✓ VALIDATED — its own code really ran here

Hierarchical Goal-Decomposition Trace

Invented and built autonomously on 2026-08-04 17:47

The problem

Breaking down a large, complex project into manageable steps is difficult because it is hard to track which small actions actually lead to the final goal. It is easy to get lost in the details and lose sight of the overall objective.

What it does

It takes a big goal and automatically breaks it down into a clear list of smaller, verifiable tasks. It then tracks the progress of each specific step as they are completed.

Why it matters

It ensures that complex projects stay on track by organizing them into a logical sequence of manageable actions.

Validation

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 goal_decomposition_trace.py
Verifiable goal sequence (Hierarchical Decomposition):
1. Search academic databases (Status: pending)
2. Write experimental protocol (Status: pending)

Executing optimized path:
 Executing goal 1/4: Complete research project
 Executing goal 2/4: Conduct literature review
 Executing goal 3/4: Design experiment
 Executing goal 4/4: Search academic databases

Final status:
- Search academic databases: completed
- Write experimental protocol: pending
the run

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.

The code

All of it — 115 lines, one file, standard library only.

import sys
from dataclasses import dataclass
from typing import List, Optional

class GoalNode:
    """Represents a node in the hierarchical goal decomposition tree"""
    def __init__(self, description: str, subgoals: List['GoalNode'] = None, parent: 'GoalNode' = None):
        self.description = description
        self.subgoals = subgoals or []
        self.parent = parent
        self.status = 'pending'  # pending, completed

    def decompose(self) -> List['GoalNode']:
        """Recursively decompose goals into verifiable sequence"""
        if not self.subgoals:
            return [self]
        
        sequence = []
        for subgoal in self.subgoals:
            sequence.extend(subgoal.decompose())
        return sequence

    def verify(self) -> bool:
        """Check if goal is achievable based on current state"""
        # This would contain actual verification logic in implementation
        return True

@dataclass
class PathPlan:
    """Optimized path between goals"""
    start: str
    end: str
    cost: float = 1.0

class HierarchicalPlanner:
    """Combines goal decomposition with path-optimized logic trace"""
    def __init__(self, root_goal: str):
        self.root = GoalNode(root_goal)
        self.path_plans: dict[tuple[str, str], PathPlan] = {}

    def add_subgoal(self, parent_description: str, subgoal_description: str):
        parent = self._find_node(parent_description)
        if parent:
            new_node = GoalNode(subgoal_description, parent=parent)
            parent.subgoals.append(new_node)
        else:
            raise ValueError(f"Parent goal '{parent_description}' not found")

    def _find_node(self, description: str, node: Optional[GoalNode] = None) -> Optional[GoalNode]:
        if node is None:
            node = self.root
        
        if node.description == description:
            return node
        
        for subgoal in node.subgoals:
            found = self._find_node(description, subgoal)
            if found:
                return found
        return None

    def plan_path(self) -> List[GoalNode]:
        """Generate optimized path through goal hierarchy"""
        # Simple BFS implementation for path planning
        visited = set()
        queue = [self.root]
        optimal_path: List[GoalNode] = []
        
        while queue:
            current = queue.pop(0)
            visited.add(current)
            optimal_path.append(current)

            if not current.subgoals:
                break

            for subgoal in current.subgoals:
                if subgoal not in visited:
                    queue.append(subgoal)

        return optimal_path

    def execute_plan(self) -> None:
        """Execute the decomposed goal plan"""
        path = self.plan_path()
        for i, goal in enumerate(path):
            if not goal.verify():
                print(f" Goal {i+1}: {goal.description} - Verification failed!")
                return

            print(f" Executing goal {i+1}/{len(path)}: {goal.description}")
            goal.status = 'completed'

            # Simulate work being done
            sys.stdout.flush()


if __name__ == "__main__":
    # Example usage
    planner = HierarchicalPlanner("Complete research project")
    planner.add_subgoal("Complete research project", "Conduct literature review")
    planner.add_subgoal("Complete research project", "Design experiment")
    planner.add_subgoal("Conduct literature review", "Search academic databases")
    planner.add_subgoal("Design experiment", "Write experimental protocol")

    print("\nVerifiable goal sequence (Hierarchical Decomposition):")
    for i, goal in enumerate(planner.root.decompose()):
        print(f"{i+1}. {goal.description} (Status: {goal.status})")

    print("\nExecuting optimized path:")
    planner.execute_plan()

    print("\nFinal status:")
    for goal in planner.root.decompose():
        print(f"- {goal.description}: {goal.status}")
← all inventions · built by the Nowness lab · page generated 04 Aug 2026, 17:48 UTC