feat(agents): expose sandboxed file helpers to inline code #103

Open
CoreRasurae wants to merge 1 commits from feature/m1-inline-code-sandboxed-file-access into master

1 Commits

Author SHA1 Message Date
CoreRasurae db433d56c0 feat(agents): expose sandboxed file helpers to inline code
CI / typecheck (pull_request) Successful in 1m23s
CI / lint (pull_request) Successful in 1m45s
CI / quality (pull_request) Successful in 1m48s
CI / security (pull_request) Successful in 2m12s
CI / build (pull_request) Successful in 1m30s
CI / integration_tests (pull_request) Successful in 4m43s
CI / unit_tests (pull_request) Successful in 5m43s
CI / coverage (pull_request) Failing after 14m25s
CI / benchmark (pull_request) Failing after 19m12s
CI / status-check (pull_request) Failing after 10s
Inline-code tool bodies (§4.5.2) could not read or write file contents
dynamically: the §13.2.1 sandbox exposes no filesystem access, so the only
sanctioned path was static file_read → inline → file_write wiring, which
cannot express a runtime-computed path, multi-file access, or a
read-modify-write cycle in one body.

Per ADR-2035, expose exactly two injected local callables in unsafe mode:

  read_file(path, max_chars=None, offset=0) -> str
  write_file(path, content, mode="w") -> int

Both reuse the existing file_read/file_write validated cores (now extracted
into a shared FileAccessCore + SandboxRootPolicy so containment, ADR-2033
windowing, and the §4.5.5 write modes have a single implementation) and
return raw values rather than the LLM envelope. They confine every access to
the sandbox root — rejecting `..`, `~`, and any path whose resolved real path
(symlinks followed) escapes the root — raising ValueError so inline code can
catch it with the sandbox's own vocabulary. write_file additionally requires
_unsafe_mode in the invocation context; read_file does not, preserving the
read/write privilege split. In safe mode neither name is bound (NameError),
and the §13.2.1 built-in table is unchanged. The shared realpath containment
also closes a symlink-escape gap in the built-in tools.

The Actor Configuration Standard is revised to 1.2.0 (§4.5.2, §13.2.1,
§13.2.3, §13.3) recording the sanctioned helpers, with the rationale in the
ADR.

Refs: #93

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-08-04 17:34:58 +00:00