#632·Trellis

task.py remove-subtask clears a child's parent even when linked to a different parent

Author: wl336Created Sep 24, 2026Updated Sep 24, 2026

Summary

task.py remove-subtask <parent> <child> clears the child's parent even when the child is linked to a different parent. It reports success, removes nothing from the supplied parent, and leaves the real parent's children list pointing at a child that now claims to be top-level, so the bidirectional task graph is corrupted.

Reproduction (main @ e77ae89)

bash
# 09-23-child is linked to 09-23-parent; 09-23-other is unrelated
python3 .trellis/scripts/task.py remove-subtask .trellis/tasks/09-23-other .trellis/tasks/09-23-child
# -> "Unlinked: 09-23-child from 09-23-other", exit 0
python3 -c "import json;print(json.load(open('.trellis/tasks/09-23-parent/task.json'))['children'], json.load(open('.trellis/tasks/09-23-child/task.json'))['parent'])"
# -> ['09-23-child'] None

Expected: an error and no writes, because 09-23-child is not a child of 09-23-other.

Proposed fix

In common/task_store.py cmd_remove_subtask, verify the relationship before writing:

python
if child_data.get("parent") != parent_dir.name:
    print(colored(
        f"Error: {child_dir.name} is not a child of {parent_dir.name} "
        f"(its parent is {child_data.get('parent') or 'none'})",
        Colors.RED), file=sys.stderr)
    return 1