Pixir.Tools.Workspace (pixir v0.1.12)

Copy Markdown View Source

Workspace confinement (CONTEXT.md): the v0.1 safety floor. File Tools resolve a user/model-supplied path against the Workspace root and refuse anything that escapes it. Containment is lexical, accepts the root itself, and treats / as containing all absolute descendants. Symlink resolution is deliberately out of scope for v0.1.

Summary

Functions

Resolve path (relative or absolute) against workspace, confined to it. Returns {:ok, absolute_path} or a structured :outside_workspace error.

Whether path resolves to the Workspace root or one of its descendants.

Functions

confine(workspace, path)

@spec confine(String.t(), String.t()) :: {:ok, String.t()} | {:error, map()}

Resolve path (relative or absolute) against workspace, confined to it. Returns {:ok, absolute_path} or a structured :outside_workspace error.

contains?(workspace, path)

@spec contains?(String.t(), String.t()) :: boolean()

Whether path resolves to the Workspace root or one of its descendants.