Skip to content

API Reference parrot.sdd.scripts.worktree_sync

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

parrot.sdd.scripts.worktree_sync

View source

Safely integrate base commits into a registered SDD linked worktree.

Alias BACKEND_ENV

Re-exported from parrot.sdd.scripts.native_claude_sandbox.BACKEND_ENV.

Class SyncError

Operator-facing refusal with a stable exit code.

Parameter Type Default Description
exit_code int
message str

Class SyncResult

Machine-readable synchronization outcome.

Fields:

Field Type Default Description
worktree str
branch str | None
base_branch str
transport Literal['host-git', 'sandbox-gh']
mode Literal['merge', 'ff-only', 'cherry-pick']
dry_run bool
before str
after str
commits list[str]
status Literal['synced', 'up-to-date', 'refused', 'conflict', 'error']
exit_code int
message str
conflicts list[str]

Attribute TIMEOUT_ENV

Function check_guards

Reject detached heads, dirty trees and foreign live processes using stable refusal codes.

On the host any porcelain entry, untracked files included, makes the tree dirty. Inside the sandbox only tracked changes count: Claude Code's native sandbox runtime places mount placeholders for its protected paths (.bashrc, .claude/…, .mcp.json, .gitconfig, …) in the working directory, so untracked entries there are not the operator's work. Ignoring them is safe because git am -3 refuses to overwrite an untracked file, and that refusal is reported as refused (exit 6) without any abort.

check_guards(wt: Path) -> None

Parameter Type Default Description
wt Path

Alias discover

Re-exported from parrot.sdd.scripts.remove_worktree.discover.

Function in_sandbox

Return whether BACKEND_ENV selects a sandbox.

in_sandbox() -> bool

Returns: bool

Alias live_processes_in

Re-exported from parrot.sdd.scripts.remove_worktree.live_processes_in.

Attribute logger

Function main

Parse target and sync flags, emit human/JSON output and return the result code.

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

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

Returns: int

Function network_timeout

Return the network-call timeout in seconds, honouring PARROT_SDD_SYNC_TIMEOUT.

network_timeout() -> int

Returns: int — The configured positive number of seconds, or the 120-second default when the variable is unset or not a positive integer.

Function own_ancestry

Return this process and ancestors by walking Linux proc stat parent fields.

own_ancestry() -> set[int]

Returns: set[int]

Function owner_repo

Parse owner/repo from SSH or HTTPS origin URLs.

owner_repo(wt: Path) -> str

Parameter Type Default Description
wt Path

Returns: str

Alias parse

Re-exported from parrot.sdd.scripts.sdd_meta.parse.

Function push_protection_ok

Return whether worktree config is enabled and no_push is the sole effective push URL.

push_protection_ok(wt: Path) -> bool

Parameter Type Default Description
wt Path

Returns: bool

Function resolve_base_branch

Resolve override, selected per-spec index, brief frontmatter, then dev.

resolve_base_branch(wt: Path, override: str | None) -> str

Parameter Type Default Description
wt Path
override str | None

Returns: str

Function resolve_target

Require one registered non-primary linked worktree with matching Git top-level.

resolve_target(target: str) -> Path

Parameter Type Default Description
target str

Returns: Path

Function stale_base_summary

Return an advisory host dry-run summary or a skipped reason; never raise.

stale_base_summary(wt: Path, base: str | None = None) -> str

Parameter Type Default Description
wt Path
base str | None None

Returns: str

Function sync

Integrate safely; only report conflict after verified rollback.

sync(wt: Path, base: str, *, cherry_picks: Sequence[str] = (), ff_only: bool = False, dry_run: bool = False) -> SyncResult

Parameter Type Default Description
wt Path
base str
cherry_picks Sequence[str] ()
ff_only bool False
dry_run bool False

Returns: SyncResult

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