Skip to content

Scope

scope

Scope loader for the echo corpus.

Reads the optional ~/axm/echo.toml config to decide which workspace roots the corpus extractor walks. Self-contained: only tomllib + pathlib, zero external dependency (AC5).

Graceful degradation is the hard contract: a missing file, a missing workspace_roots key, or a malformed TOML never raises -- it falls back to the current working directory as the single root. There is no upward disk auto-discovery.

NOTE (rule of three): a future axm-config package may own this loading once a third consumer appears. Until then we deliberately avoid coupling to an unbuilt package and keep the loader local.

config_path()

Return the path to the echo config (~/axm/echo.toml).

Does not check existence; callers degrade gracefully when absent.

Source code in packages/axm-echo/src/axm_echo/scope.py
Python
def config_path() -> Path:
    """Return the path to the echo config (``~/axm/echo.toml``).

    Does not check existence; callers degrade gracefully when absent.
    """
    return Path.home() / _CONFIG_RELATIVE

load_scope()

Return the workspace roots to scan, with graceful degradation.

Reads workspace_roots from ~/axm/echo.toml when present and well-formed. On any failure (file absent, unreadable, invalid TOML, missing or empty workspace_roots) returns [Path.cwd()] so the caller still has the current workspace to scan -- never an exception.

Returns:

Type Description
list[Path]

Resolved, de-duplicated workspace root paths. Always non-empty.

Source code in packages/axm-echo/src/axm_echo/scope.py
Python
def load_scope() -> list[Path]:
    """Return the workspace roots to scan, with graceful degradation.

    Reads ``workspace_roots`` from ``~/axm/echo.toml`` when present and
    well-formed. On any failure (file absent, unreadable, invalid TOML,
    missing or empty ``workspace_roots``) returns ``[Path.cwd()]`` so the
    caller still has the current workspace to scan -- never an exception.

    Returns:
        Resolved, de-duplicated workspace root paths. Always non-empty.
    """
    roots = _read_configured_roots()
    if not roots:
        return [Path.cwd().resolve()]
    return roots