Skip to content

API Reference parrot.sdd.scripts.check_task_state

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.sdd.scripts.check_task_state

View source

check_task_state.py — read-only backstop for stalled SDD task files.

A task is closed by moving its file from sdd/tasks/active/ to sdd/tasks/completed/ and marking its per-spec index entry done (scripts/sdd/close_task.sh / scripts/sdd/finalize_task.py). When a lane copies instead of moving, or closes on one branch while a merge brings the old active/ copy back, the base branch ends up with a stalled active/ file for a task that is already finished. heal_orphans.sh reaps those, but only when /sdd-done --merge runs it — the default PR flow never did, so orphans accumulated silently.

This check fails CI on the two states that are unambiguous by construction:

  • twin — the same task file exists in both active/ and completed/ (identical basename).
  • closed-but-active — a per-spec index entry marks the task done / done-with-issues while its file still lives in active/.

It deliberately does NOT flag pending / in-progress tasks: whether one of those is abandoned depends on branches and worktrees this script cannot see. Fix a reported violation with scripts/sdd/heal_orphans.sh <feature-slug> (twins) or scripts/sdd/close_task.sh <TASK-ID> <feature-slug> (closed-but-active).

Class TaskStateViolation

One stalled active/ task file and why it is stalled.

Fields:

Field Type Default Description
task_id str
kind Literal['twin', 'closed-but-active']
active_file str
detail str

Function find_violations

Scan active/ for task files that should already be closed.

find_violations(*, index_dir: Path, active_dir: Path, completed_dir: Path) -> list[TaskStateViolation]

Parameter Type Default Description
index_dir Path Directory holding the per-spec indexes.
active_dir Path sdd/tasks/active.
completed_dir Path sdd/tasks/completed.

Returns: list[TaskStateViolation] — Every violation found, ordered by active filename.

Function main

CLI entry point: exit 1 on any non-baselined violation, 0 otherwise.

main(argv: list[str] | None = None) -> int

Parameter Type Default Description
argv list[str] | None None Optional argument list (defaults to sys.argv[1:]).

Returns: int — Process exit code.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally