Skip to content

API Reference parrot.sdd.scripts.procedure_advice

github-actions[bot] edited this page Dec 2, 2026 · 1 revision

parrot.sdd.scripts.procedure_advice

View source

Hook-side procedure advice (FEAT-891): stdlib only, no parrot import, never raises.

Loads both as parrot.sdd.scripts.procedure_advice and as a script sibling of the guards.

Class Advice

Outcome of the procedure check for one command.

Parameter Type Default Description
decision Literal['none', 'advise', 'deny']
text str ''

Fields:

Field Type Default Description
decision Literal['none', 'advise', 'deny']
text str ''

Attribute CLOSED_STATUSES

Type: frozenset[str]

Attribute ESCAPE_ENV

Attribute INDEX_FILE

Attribute INDEX_SCHEMA_VERSION

Attribute LAUNCHER_MARKERS

Attribute LOCAL_PROBES

Type: dict[str, Probe]

Attribute MAX_ADVICE_CHARS

Attribute MAX_INDEX_BYTES

Attribute PLANE_DIR

Attribute Probe

Function apply_check

Evaluate one index-shaped local check without allowing exceptions to escape.

apply_check(check: Mapping[str, Any], checkout: Path, scope: Mapping[str, str], *, probes: Mapping[str, Probe] | None = None) -> bool | None

Parameter Type Default Description
check Mapping[str, Any]
checkout Path
scope Mapping[str, str]
probes Mapping[str, Probe] | None None

Returns: bool | None

Function checkout_root

Return the nearest ancestor of cwd holding a .git entry.

checkout_root(cwd: Path) -> Path | None

Parameter Type Default Description
cwd Path

Returns: Path | None

Function command_segments

Split a shell command into token lists, one per simple command.

command_segments(command: str) -> list[list[str]]

Parameter Type Default Description
command str

Returns: list[list[str]]

Function current_branch

Return the branch named by the checkout's HEAD, or None when unknown.

current_branch(checkout: Path) -> str | None

Parameter Type Default Description
checkout Path

Returns: str | None

Function evaluate_command

Apply the compiled plane's guard decision table to one shell command.

evaluate_command(command: str, cwd: Path, *, env: Mapping[str, str] | None = None) -> Advice

Parameter Type Default Description
command str
cwd Path
env Mapping[str, str] | None None

Returns: Advice

Function feature_index

Return the per-spec task index identified by scope or None.

feature_index(checkout: Path, scope: Mapping[str, str]) -> dict[str, Any] | None

Parameter Type Default Description
checkout Path
scope Mapping[str, str]

Returns: dict[str, Any] | None

Function leading_command

Return the executable and arguments from the first real command segment.

leading_command(command: str) -> tuple[str, list[str]]

Parameter Type Default Description
command str

Returns: tuple[str, list[str]]

Function load_index

Load a valid compiled procedure index from root without raising.

load_index(root: Path) -> dict[str, Any] | None

Parameter Type Default Description
root Path

Returns: dict[str, Any] | None

Function match_guards

Return index guards matching any command segment, preserving index order.

match_guards(index: Mapping[str, Any], command: str, *, checkout: Path | None = None, cwd: Path | None = None) -> list[dict[str, Any]]

Parameter Type Default Description
index Mapping[str, Any] Compiled procedure index.
command str Shell command to inspect.
checkout Path | None None Checkout root; makes absolute path arguments checkout-relative before the glob test.
cwd Path | None None Directory the command starts in; with checkout it seeds the effective directory.

Returns: list[dict[str, Any]] — One copy of each matching guard per matching segment, with argv set to the segment's arguments after the guard's argv_prefix. Never raises.

Function shared_root

Return the primary checkout for cwd without invoking a subprocess.

A linked worktree's .git file points at an administrative worktree directory. Its commondir file points back to the primary checkout's .git directory.

shared_root(cwd: Path) -> Path | None

Parameter Type Default Description
cwd Path

Returns: Path | None

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