Skip to content

API Reference parrot.sdd.scripts.close_resolved_issues

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

parrot.sdd.scripts.close_resolved_issues

View source

close_resolved_issues.py — close the ledger issues a finished feature fixed.

The /sdd-fix SDD lane only files work (spec → tasks → worktree); the tasks are implemented later, often by sdd-worker in another session. The lane hands the issue's closure to /sdd-done, which historically never ran wikitoolkit ledger close — so every issue fixed through the SDD lane stayed claimed (invisible to ledger plan-fix) or open (re-offered as if still broken) after its fix merged.

This script is the /sdd-done close step. An issue is linked to a feature by

  • a task file line **Discovered-from**: `issue:<id>``` (or the legacy discovered_from: issue:``) — linked to that task, or
  • the spec's YAML frontmatter citing issue:<id> (e.g. source:) — linked to every task of the feature. Issues mentioned only in the spec body are context (related, out of scope) and are ignored.

It closes a linked open/claimed issue only with the same two keys /sdd-fix uses, fail-closed:

  1. every task linked to the issue is done with verification == "verified" in the per-spec index (partial / forced / done-with-issues never count), and
  2. at least one file named by the issue's about refs appears in git diff --name-only <base>...HEAD of the feature worktree.

Anything that fails a key is reported and left untouched.

Prints a JSON report on stdout and exits 0 unless invoked wrongly; a ledger write failure is reported per issue (read-only when the shared ledger is not writable), never raised — closing is bookkeeping and must not fail /sdd-done.

Class CloseReport

The JSON report printed for /sdd-done.

Fields:

Field Type Default Description
feature_id str | None
base str
issues list[IssueOutcome]

Class IssueOutcome

What happened to one linked ledger issue.

Fields:

Field Type Default Description
issue_id str
outcome Literal['closed', 'would-close', 'skipped', 'read-only', 'error']
tasks list[str]
resolved_by str | None None
detail str ''

Attribute LedgerRunner

Function close_resolved_issues

Close every linked issue that passes both keys; report the rest.

close_resolved_issues(*, worktree: Path, index_path: Path, base: str, feature_id: str | None = None, actor: str = 'agent:sdd-done', dry_run: bool = False, changed_files: set[str] | None = None, ledger: LedgerRunner = _default_runner) -> CloseReport

Parameter Type Default Description
worktree Path Feature worktree root.
index_path Path Per-spec index, absolute or relative to worktree.
base str Diff base ref (origin/<base_branch>).
feature_id str | None None Used in the close reason; defaults to the index header.
actor str 'agent:sdd-done' Ledger actor for ledger close.
dry_run bool False Evaluate and report without writing the ledger.
changed_files set[str] | None None Override for git diff --name-only base...HEAD (tests).
ledger LedgerRunner _default_runner Runs wikitoolkit ledger <args>; injectable for tests.

Returns: CloseReport — The per-issue report.

Function collect_links

Map each linked issue:<id> to the task ids that resolve it.

collect_links(worktree: Path, index: dict) -> dict[str, set[str]]

Parameter Type Default Description
worktree Path Feature worktree root.
index dict Parsed per-spec index (header + tasks[]).

Returns: dict[str, set[str]] — {issue_id: {task_id, ...}}.

Function main

CLI entry point; prints the JSON report.

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

Parameter Type Default Description
argv list[str] | None None

Returns: int

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