Class PathPolicy

java.lang.Object
io.agentscope.harness.agent.workspace.PathPolicy

public final class PathPolicy extends Object
Immutable allow-list of host directories that LocalFsMode.ROOTED accepts for absolute paths. Each root is stored absolute-normalized so child-of checks are cheap.

The Claude-Code-style two-layer Local FS uses PathPolicy.of(project, workspace, additionalRoots) to bound the agent's reach without forcing it into a single hard sandbox.

Empty policy (empty()) rejects every absolute path; use it only when the caller intends to fall back to relative-only access.

  • Method Details

    • empty

      public static PathPolicy empty()
      Returns a policy that allows no absolute paths.
    • of

      public static PathPolicy of(Path first, Path... rest)
      Builds a policy from one or more roots. null entries are skipped; remaining roots are absolute-normalized.
    • of

      public static PathPolicy of(Collection<Path> roots)
      Builds a policy from a collection of roots. null entries are skipped.
    • roots

      public List<Path> roots()
      Returns the configured roots in insertion order.
    • isEmpty

      public boolean isEmpty()
      true when no roots are configured.
    • isAllowed

      public boolean isAllowed(Path candidate)
      true when candidate is equal to or below one of the configured roots. Caller must pass an absolute path; relative paths return false.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object