orxtra v0.13.0 /tool.src.orxtra.tool._path
On this page

Path containment enforcement: resolve_and_check canonicalizes a path and rejects escapes past the read root, and check_write_scope further restricts writes to an allowed scope list. Both raise PathError.

#tool.src.orxtra.tool._path

#tool.src.orxtra.tool._path

#PathError

Raised when a path violates containment or scope rules.

#resolve_and_check

python
def resolve_and_check(raw_path: str, root: Path) -> Path

Resolve raw_path against root, canonicalize, check containment.

Args:

  • raw_path: The raw path string from the tool caller.
  • root: The boundary root (must already be resolved/canonical).

Returns:

  • The resolved, canonical path.

Raises:

  • PathError: If the path is empty, or escapes the root boundary.

#check_write_scope

python
def check_write_scope(resolved: Path, scope: list[Path] | None, root: Path) -> None

Check if resolved path is within write scope.

Args:

  • resolved: Already-resolved path (from resolve_and_check).
  • scope: List of allowed write paths, or None for unrestricted.
  • root: The read root boundary (for error messages).

Raises:

  • PathError: If the path is outside all scope paths.
Search