Skip to content

API Reference parrot.sdd.scripts.prune_intake

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

parrot.sdd.scripts.prune_intake

View source

prune_intake.py — prune stale /sdd-spec intake staging (FEAT-577).

Staged intake runs live under sdd/state/.intake/<slug>-<RUN_ID>/ (git-ignored). A git hook (installed by scripts/sdd/install_hooks.py) calls this with --daily --apply on checkout/merge/commit; --daily lets it run at most once per 24 h. Dry-run by default; only direct, non-symlink child directories of a root that resolves to .../sdd/state/.intake are ever deleted.

Attribute DAILY_INTERVAL

Type: timedelta

Attribute DEFAULT_MAX_AGE_DAYS

Type: int

Attribute DEFAULT_ROOT

Type: Path

Attribute STAMP_NAME

Type: str

Class StaleIntake

One staged run selected for pruning.

Fields:

Field Type Default Description
path Path
age_days float
age_source str

Function claim_daily_slot

True (and touch the stamp) when the last run was ≥ 24 h ago or never; False otherwise.

claim_daily_slot(stamp: Path, now: datetime | None = None) -> bool

Parameter Type Default Description
stamp Path
now datetime | None None

Returns: bool

Function default_stamp

$(git rev-parse --git-common-dir)/sdd-intake-prune.stamp (shared by all worktrees); None outside a repo.

default_stamp() -> Path | None

Returns: Path | None

Function find_stale

Direct child dirs of root (no symlinks) older than max_age_days. Missing root → [].

find_stale(root: Path, max_age_days: int = DEFAULT_MAX_AGE_DAYS, now: datetime | None = None, repo_root: Path | None = None) -> list[StaleIntake]

Parameter Type Default Description
root Path
max_age_days int DEFAULT_MAX_AGE_DAYS
now datetime | None None
repo_root Path | None None

Returns: list[StaleIntake]

Attribute logger

Function main

CLI: --root, --older-than-days (default 10), --apply, --daily, --stamp. Exit 0; 2 on an unsafe root.

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

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

Returns: int

Function prune

Return the stale runs; delete them only when apply. Raises ValueError for an unsafe root.

prune(root: Path, max_age_days: int = DEFAULT_MAX_AGE_DAYS, *, apply: bool = False, now: datetime | None = None, repo_root: Path | None = None) -> list[StaleIntake]

Parameter Type Default Description
root Path
max_age_days int DEFAULT_MAX_AGE_DAYS
apply bool False
now datetime | None None
repo_root Path | None None

Returns: list[StaleIntake]

Function run_age

Age from intake.json updated_at; falls back to the dir mtime when missing/unparsable.

run_age(run_dir: Path, now: datetime) -> tuple[timedelta, str]

Parameter Type Default Description
run_dir Path
now datetime

Returns: tuple[timedelta, str]

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