Skip to content

API Reference parrot.flows.dev_loop.test_scope.mirror

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

parrot.flows.dev_loop.test_scope.mirror

View source

Mirror-of-directories test selection, moved verbatim from QANode (FEAT-563 M1).

Function deepest_existing_dir

Walk tests_root/subdirs upwards to the first existing directory (was qa.py:679).

deepest_existing_dir(tests_root: str, subdirs: tuple[str, ...], worktree_path: str) -> str

Parameter Type Default Description
tests_root str packages/<dist>/tests — verified to exist by the caller, so this always terminates with a real path.
subdirs tuple[str, ...] The source-relative directory chain to mirror.
worktree_path str Root the paths are relative to.

Returns: str — The deepest existing mirrored directory, at worst tests_root itself.

Function distribution_of

Return '' for packages//…, 'root' for tests/…; raise ValueError otherwise.

distribution_of(path: str) -> str

Parameter Type Default Description
path str A repo-relative path.

Returns: str — "root" for a path under the repo-root tests/ tree, or the distribution name for a path under packages/<dist>/.

Raises:

  • ValueError — When the path is under neither tree.

Function prune_nested

Drop targets already covered by a broader target; sorted (was qa.py:703).

prune_nested(targets: set[str]) -> list[str]

Parameter Type Default Description
targets set[str] Candidate test paths.

Returns: list[str] — The surviving paths, sorted.

Function pytest_file_target_for

Resolve one changed path to an existing test module, never a directory.

A changed test module maps to itself. A source module maps to the first existing test_<name>.py at the corresponding package-test depth, walking towards the distribution's tests root.

pytest_file_target_for(path: str, worktree_path: str) -> str | None

Parameter Type Default Description
path str A repo-relative changed file path.
worktree_path str Root the path is relative to.

Returns: str | None — An existing repo-relative test file, or None when no file maps.

Function pytest_file_targets

Map changed files to existing test files only, sorted and de-duplicated.

pytest_file_targets(files: Sequence[str], worktree_path: str) -> list[str]

Parameter Type Default Description
files Sequence[str]
worktree_path str

Returns: list[str]

Function pytest_target_for

Resolve one changed path to its narrowest existing test target (was qa.py:633).

pytest_target_for(path: str, worktree_path: str) -> str | None

Parameter Type Default Description
path str A repo-relative changed file path.
worktree_path str Root the path is relative to.

Returns: str | None — The test path to hand pytest, or None when the file maps to nothing that exists on disk.

Function pytest_targets

Map changed files to the narrowest existing test targets (was QANode._pytest_targets, qa.py:588).

Mapping a change to packages/<dist>/tests is correct but far too coarse: for ai-parrot that is the entire 1250-module core suite (~9 minutes), which is what the derived gate used to run for a three-file change. The repo mirrors its source tree under tests/ (src/parrot/flows/dev_loop/ -> tests/flows/dev_loop/), so each changed file resolves instead to the deepest mirrored directory that actually exists, walking up towards packages/<dist>/tests until one does.

pytest_targets(files: Sequence[str], worktree_path: str) -> list[str]

Parameter Type Default Description
files Sequence[str] Changed file paths, repo-relative.
worktree_path str Root the paths are relative to, for existence checks.

Returns: list[str] — Existing test paths, sorted, with any target already covered by an ancestor target removed; empty when nothing mapped.

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