Files
cleveragents-core/features
CoreRasurae 07d104f831
CI / lint (pull_request) Failing after 2s
CI / typecheck (pull_request) Failing after 1s
CI / coverage (pull_request) Has been skipped
CI / security (pull_request) Failing after 2s
CI / quality (pull_request) Failing after 2s
CI / unit_tests (pull_request) Failing after 1s
CI / docker (pull_request) Has been skipped
CI / integration_tests (pull_request) Failing after 2s
CI / e2e_tests (pull_request) Failing after 2s
CI / build (pull_request) Failing after 2s
CI / helm (pull_request) Failing after 1s
CI / status-check (pull_request) Failing after 1s
CI / benchmark-publish (pull_request) Has been skipped
CI / benchmark-regression (pull_request) Has been skipped
feat(tool): add move_file, create_directory, and get_file_info built-in tools
Implemented three missing built-in resource tools from the specification:

- builtin/file-move: Move/rename files within sandbox boundaries using
  shutil.move with path traversal protection. Validates source exists
  and is a regular file, rejects directory destinations with clear
  error messages. Creates destination parent directories automatically.
- builtin/dir-create: Create directories with optional parent creation
  using Path.mkdir with sandbox validation. Returns accurate "created"
  field (false when directory already existed). Rejects paths that are
  existing regular files with a descriptive error.
- builtin/file-info: Retrieve comprehensive file metadata (size,
  permissions, timestamps, type, encoding) with ISO 8601 formatted dates.
  Uses st_birthtime when available (macOS/BSD) with st_ctime fallback
  (Linux). Permissions return only permission bits via stat.S_IMODE.
  Encoding detection validates UTF-8 decoding before reporting "utf-8";
  returns null for binary, non-UTF-8, or directory paths.

All tools follow the existing ToolSpec pattern with proper JSON Schema
definitions, capability metadata, and sandbox root validation. Added
to ALL_FILE_TOOLS and registration helpers.

Updated ChangeSetCapture to correctly track move operations: the wrapped
handler now detects move tools by tool name (consistent with
_detect_operation) and computes before/after hashes from the correct
paths. Added "move" detection to _detect_operation so file-move entries
get operation="move" (mapped to ChangeOperation.RENAME) instead of the
incorrect "modify" fallback. Fixed _file_hash to skip directories
(returns None) preventing IsADirectoryError when dir-create is wrapped
by ChangeSetCapture during plan execution.

Removed sandbox_root from new tool input_schemas to align with the 6
existing file tools which also omit it from their schemas.

Tests: 22 Behave BDD scenarios (up from 7), Robot integration tests
with on_timeout=kill, ASV benchmarks. Added path traversal tests for
all three tools, overwrite behavior test, existing directory test,
directory move rejection test, non-existent source test, directory
destination rejection test, changeset integration tests for file-move
and dir-create, binary file encoding test, permissions format test,
and destination parent directory creation test.

Review fixes applied (PR #1070 review):
| # | Finding | Resolution |
|---|---------|------------|
| P1-1 | _file_hash crashes on directories | Added p.is_dir() guard |
| P2-1 | file-move incorrect dest for dir targets | Reject directory destinations |
| P2-2 | Changeset move detection via input fields | Use tool_spec.name instead |
| P2-3 | st_ctime mislabeled as "created" on Linux | Use st_birthtime with fallback |
| P2-4 | _detect_operation returns "modify" for no-op | Handle created=False + null hashes |
| P2-5 | permissions includes file type bits | Use stat.S_IMODE() |
| P2-6 | _detect_encoding reports utf-8 for non-UTF-8 | Validate with chunk.decode("utf-8") |
| P3-1 | dir-create FileExistsError on regular file | Explicit pre-check with ValueError |
| P3-2 | Misleading error for non-existent source | Separate exists/is_file checks |

ISSUES CLOSED: #883
2026-04-02 08:11:22 +00:00
..
2026-02-23 03:11:12 +00:00