Skip to content

API Reference parrot.knowledge.wiki.repo_cache

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

parrot.knowledge.wiki.repo_cache

View source

Repository cache data contracts and asynchronous process locking.

Class BuildOutcome

Outcome of one bounded wiki build subprocess.

Fields:

Field Type Default Description
ok bool
returncode int
timed_out bool
duration_s float
stderr_tail str

Class RepoCachePaths

Resolved layout for one canonical repository.

Fields:

Field Type Default Description
slug str
repository str
clone_dir Path
plane_dir Path
lock_path Path

Class RepoWikiCache

Maintain a local clone and wiki plane for each reviewed repository.

Parameter Type Default Description
git_toolkit Any Git operations provider.
cache_dir Path Root directory containing repos, planes and locks.
max_bytes int 5 * 1024 ** 3 Total cache size allowed before LRU eviction.
clone_branch Optional[str] None Optional explicitly tracked branch.
clone_depth Optional[int] None Optional clone history depth.
build_timeout float 900.0 Bound for git and build subprocesses.
lock_timeout float 600.0 Bound for cache lock acquisition.
logger Optional[logging.Logger] None Logger used for degradation diagnostics.

Method RepoWikiCache.paths_for

Resolve a bare owner/name repository to paths confined below the cache.

paths_for(repository: str) -> RepoCachePaths

Parameter Type Default Description
repository str GitHub repository identifier in owner/name form.

Returns: RepoCachePaths — The canonical repository layout.

Raises:

  • ValueError — If repository is not a bare two-component slug.

Method RepoWikiCache.ensure_fresh

Refresh a repository clone and its complete wiki plane.

Returns None for operational failures so review callers can use their diff-only fallback. Cancellation deliberately propagates.

ensure_fresh(repository: str) -> Optional[RepoCachePaths]

Parameter Type Default Description
repository str

Returns: Optional[RepoCachePaths]

Method RepoWikiCache.read_lease

Hold a shared lock on a usable entry for the duration of a read.

Yields the entry's paths while refresh and eviction are excluded, or None when the slug is invalid, the lock is unavailable within timeout, or the plane is not usable. Never raises for those cases.

read_lease(repository: str, *, timeout: float = 0.0) -> AsyncIterator[Optional[RepoCachePaths]]

Parameter Type Default Description
repository str
timeout float 0.0

Returns: AsyncIterator[Optional[RepoCachePaths]]

Function repo_lock

Acquire an advisory process lock without blocking the event loop.

The lock is held through an open descriptor via nonblocking flock and released in finally (also on exception or cancellation), so the kernel frees it if the holder crashes. Contended acquisition polls with :func:asyncio.sleep. Without :mod:fcntl it is a no-op yielding True.

repo_lock(lock_path: Path, *, timeout: float, shared: bool = False) -> AsyncIterator[bool]

Parameter Type Default Description
lock_path Path Lock file path; parent directories are created.
timeout float Seconds to keep retrying. 0 tries exactly once.
shared bool False Take LOCK_SH (concurrent readers) instead of LOCK_EX.

Returns: AsyncIterator[bool]

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