Foundry.FileSystem (Foundry v0.4.0)

Copy Markdown View Source

Validated file read boundary for all project file access in channels and controllers.

All file reads that originate from the Studio UI or copilot shell must go through this module. Direct File.read!/1 calls from channels are forbidden (enforced by Foundry.LintRules.FileWriteRule in later phases).

Permits reading any file within the project root. Path traversal attacks are prevented by expanding paths and verifying they remain within the root boundary.

See ADR-020 §File system access via Foundry.FileSystem.

Summary

Types

read_error()

@type read_error() :: :outside_boundary | :not_found | File.posix()

write_error()

@type write_error() :: :outside_boundary | File.posix()

Functions

read(project_root, relative_path)

@spec read(project_root :: String.t(), relative_path :: String.t()) ::
  {:ok, String.t()} | {:error, read_error()}

write(project_root, relative_path, content)

@spec write(
  project_root :: String.t(),
  relative_path :: String.t(),
  content :: String.t()
) ::
  :ok | {:error, write_error()}