Documentation
¶
Overview ¶
Package paths provides the safe-path and containment primitives (PRD §6, §15) the orchestration core builds on: canonical absolute paths with symlinks resolved, segment-aware containment checks for worktree enforcement, and discovery of the repository root that holds .orchestrator/. Every helper fails closed: a path that cannot be verified yields an error, never a permissive default.
Index ¶
Constants ¶
const OrchestratorDir = ".orchestrator"
OrchestratorDir is the name of the repo-root directory Orch owns.
Variables ¶
var ErrNotFound = errors.New("no " + OrchestratorDir + " directory found")
ErrNotFound reports that no ancestor directory contains .orchestrator/. Callers test for it with errors.Is.
Functions ¶
func Canonical ¶
Canonical returns path as an absolute, symlink-resolved, cleaned path. The target need not exist: the deepest existing ancestor is resolved and the remaining components are appended lexically, so a write destination can be checked before anything creates it. Any failure other than non-existence (for example permission denied) is an error so callers fail closed. Unresolved Windows redirecting reparse ancestors are rejected, not trusted as ordinary prefixes when EvalSymlinks falls back from a missing target.
func DirectoryID ¶ added in v0.17.0
DirectoryID is a stable filesystem identity while this directory exists. It is not a hash of directory contents.
func FindOutermostRoot ¶
FindOutermostRoot walks from startDir to the filesystem root and returns the outermost ancestor that contains an .orchestrator directory — the opposite selection from FindRoot, which stops at the innermost. The guard (PRD §23) needs the outermost hit: a Delivery worktree checkout carries the committed .orchestrator/config.toml, so an innermost search would resolve a path under <root>/.orchestrator/worktrees/issue-N/ to the worktree itself, whose missing machine-local state.json would read as Assist and wrongly deny every executor write. The same fail-closed rules as FindRoot apply: an unreadable ancestor, or an .orchestrator entry that is not a real directory (a symlink does not count), is an error; ErrNotFound wraps when no ancestor qualifies.
func FindRoot ¶
FindRoot walks from startDir toward the filesystem root and returns the first directory containing an .orchestrator directory. It returns an error wrapping ErrNotFound when no ancestor qualifies, and fails closed on anything it cannot trust: an unreadable ancestor, or an .orchestrator entry that is not a real directory (a symlink does not count).
func Inside ¶
Inside reports whether path is contained in root; path equal to root counts as inside. Both arguments are canonicalized first, so a symlink cannot smuggle a path out of root and ".." segments cannot fake containment. The comparison is segment-aware: /repo-2 is not inside /repo. An unverifiable path is an error, and callers must treat it as "deny".
Types ¶
This section is empty.