fix(agents): reject malformed file_write path arguments before touching the filesystem #185

Merged
CoreRasurae merged 1 commit from bugfix/m1-file-write-path-validation into develop 2026-11-21 19:46:04 +00:00
Member

Summary

ToolAgent._validate_file_path_safety only checked a file_write file argument for traversal, absolute-path, and home-directory escapes. A corrupted path string (e.g. an LLM-hallucinated markup fragment concatenated onto a real path, or a whitespace-run from a bad string concatenation) passed validation unrejected and only failed deep inside FileAccessCore's OS call, surfacing an opaque [Errno 2] the agent had no way to self-correct from.

  • Adds a shared _validate_path_characters helper: rejects ASCII control characters, markup/shell metacharacters (<, >, ", |, backtick, backslash), and two-or-more consecutive whitespace characters, raising a descriptive ExecutionError naming the specific offending character(s)/pattern -- before any filesystem call.
  • Applied consistently to both _validate_file_path_safety (file_write) and _file_read_tool, per the issue's "apply consistently" subtask.
  • Legitimate relative paths -- single spaces, hyphens, underscores, dots within a segment, nested subdirectories -- are unaffected; existing traversal/absolute-path/home-directory checks are unchanged.
  • Removes @tdd_expected_fail from the two @tdd_issue_175 scenarios now that the bug is fixed (the underlying assertion now passes normally, not via inversion), and adds a control-character scenario, a legitimate-path regression scenario, and a file_read scenario for the consistency requirement.

Per the mandatory Bug Fix TDD Workflow, the companion TDD issue #176 (tagged @tdd_issue @tdd_issue_175 @tdd_expected_fail) was already written and merged first; this PR removes the @tdd_expected_fail tag now that the fix lands.

Test plan

  • nox -s unit_tests -- 3354 scenarios passing, including the 4 new/edited #175 scenarios
  • nox -s lint / nox -s format -- --check -- clean
  • nox -s typecheck -- 0 errors
  • nox -s security_scan -- 0 findings
  • nox -s dead_code -- clean
  • nox -s coverage_report -- 97.3% (threshold 96.5%)
  • Verified the TDD scenarios fail on the pre-fix code (bug reproduced) and pass normally post-fix

Closes #175

## Summary `ToolAgent._validate_file_path_safety` only checked a `file_write` `file` argument for traversal, absolute-path, and home-directory escapes. A corrupted path string (e.g. an LLM-hallucinated markup fragment concatenated onto a real path, or a whitespace-run from a bad string concatenation) passed validation unrejected and only failed deep inside `FileAccessCore`'s OS call, surfacing an opaque `[Errno 2]` the agent had no way to self-correct from. - Adds a shared `_validate_path_characters` helper: rejects ASCII control characters, markup/shell metacharacters (`<`, `>`, `"`, `|`, backtick, backslash), and two-or-more consecutive whitespace characters, raising a descriptive `ExecutionError` naming the specific offending character(s)/pattern -- before any filesystem call. - Applied consistently to both `_validate_file_path_safety` (`file_write`) and `_file_read_tool`, per the issue's "apply consistently" subtask. - Legitimate relative paths -- single spaces, hyphens, underscores, dots within a segment, nested subdirectories -- are unaffected; existing traversal/absolute-path/home-directory checks are unchanged. - Removes `@tdd_expected_fail` from the two `@tdd_issue_175` scenarios now that the bug is fixed (the underlying assertion now passes normally, not via inversion), and adds a control-character scenario, a legitimate-path regression scenario, and a `file_read` scenario for the consistency requirement. Per the mandatory Bug Fix TDD Workflow, the companion TDD issue #176 (tagged `@tdd_issue @tdd_issue_175 @tdd_expected_fail`) was already written and merged first; this PR removes the `@tdd_expected_fail` tag now that the fix lands. ## Test plan - [x] `nox -s unit_tests` -- 3354 scenarios passing, including the 4 new/edited `#175` scenarios - [x] `nox -s lint` / `nox -s format -- --check` -- clean - [x] `nox -s typecheck` -- 0 errors - [x] `nox -s security_scan` -- 0 findings - [x] `nox -s dead_code` -- clean - [x] `nox -s coverage_report` -- 97.3% (threshold 96.5%) - [x] Verified the TDD scenarios fail on the pre-fix code (bug reproduced) and pass normally post-fix Closes #175
fix(agents): reject malformed file_write path arguments before touching the filesystem
Some checks failed
CI / lint (pull_request) Successful in 44s
CI / typecheck (pull_request) Successful in 1m58s
CI / security (pull_request) Successful in 2m16s
CI / quality (pull_request) Successful in 2m22s
CI / build (pull_request) Successful in 1m6s
CI / integration_tests (pull_request) Successful in 3m27s
CI / benchmark (pull_request) Failing after 13m56s
CI / unit_tests (pull_request) Successful in 6m46s
CI / coverage (pull_request) Successful in 7m14s
CI / status-check (pull_request) Successful in 2s
4f67101a13
ToolAgent._validate_file_path_safety only checked a file_write `file`
argument for traversal, absolute-path, and home-directory escapes. A
corrupted path (e.g. an LLM-hallucinated markup fragment concatenated
onto a real path, or a whitespace-run from a bad string concatenation)
passed validation unrejected and only failed deep inside
FileAccessCore's OS call, surfacing an opaque `[Errno 2]` the agent
had no way to self-correct from.

Adds a shared `_validate_path_characters` check -- ASCII control
characters, markup/shell metacharacters (`<`, `>`, `"`, `|`, backtick,
backslash), and two-or-more consecutive whitespace characters are
rejected with a descriptive ExecutionError naming the specific
offending character(s)/pattern, before any filesystem call. Applied
to both `_validate_file_path_safety` (file_write) and `_file_read_tool`,
per the issue's "apply consistently" subtask. Legitimate relative
paths -- single spaces, hyphens, underscores, dots within a segment,
nested subdirectories -- are unaffected; traversal/absolute-path/
home-directory checks are unchanged.

Removes @tdd_expected_fail from the two @tdd_issue_175 scenarios now
that the bug is fixed (the underlying assertion passes normally), adds
a control-character scenario, a legitimate-path regression scenario,
and a file_read scenario for the consistency requirement. Coverage
97.3% (threshold 96.5%).

ISSUES CLOSED: #175
hurui200320 left a comment

PR Review: !185 (Ticket #175)

Verdict: Approve

The fix faithfully implements ticket #175: a shared _validate_path_characters helper rejects control characters, markup/shell metacharacters, and 2+ whitespace runs before any filesystem call, applied consistently to both file_write (via _validate_file_path_safety) and file_read, with traversal/absolute/home checks untouched. The TDD workflow is correctly completed (@tdd_expected_fail removed from the two @tdd_issue_175 scenarios; @tdd_issue/@tdd_issue_175 retained; #175 correctly blocked by the merged TDD issue #176). All acceptance criteria are met and the error message names the specific offending character/pattern (verified by direct execution). All quality gates were re-run locally on this branch: unit_tests 3354 scenarios passed, lint/format --check/typecheck (0 errors)/security_scan/dead_code clean, coverage_report 97.3%, and the most-affected Robot suites (symlink_safe_open, llm_tool_calling) 18/18 passed. New code regions have no uncovered lines.

Critical Issues

None

Major Issues

None

Minor Issues

  1. Non-string file argument now surfaces as a raw TypeError instead of a descriptive ExecutionError — src/cleveractors/agents/tool.py:84 (_validate_path_characters), reached from tool.py:1137 and tool.py:1022. For a malformed type argument (e.g. {"file": 123}), iterating a non-str raises TypeError: 'int' object is not iterable, which nothing catches. Verified empirically against this branch and the pre-fix commit: pre-fix the call raised ExecutionError: Invalid file path: _path_normpath: path should be string, bytes or os.PathLike, not int; post-fix, via ToolAgent.invoke() (Path B graph dispatch, which does not wrap exceptions) it is a raw TypeError, and via process_message it becomes the less actionable Tool execution failed: 'int' object is not iterable. This works against the ticket's core goal ("a clear ExecutionError describing exactly what about the path is invalid … specific enough that the calling agent can self-correct"). Recommendation: add an isinstance(filepath, str) guard at the top of _validate_path_characters raising a descriptive ExecutionError — this also fixes the same latent gap in _file_read_tool (whose shell-indicator check already crashed raw on non-str before this PR). Low severity: edge case, no security impact, not the ticket's reported scenario.

  2. Descriptive-message content is not asserted in the two updated file_write rejection scenarios — features/tool_agent.feature:517-547, step at features/steps/tool_agent_steps.py:272-295. The step only asserts an ExecutionError occurred with no OS-error text; it would still pass if the message regressed to a generic one. The ticket's acceptance criterion ("names the specific invalid character(s)/pattern") is only asserted in the new file_read scenario ("disallowed characters"); the whitespace-run message fragment ("consecutive whitespace") is asserted nowhere. Recommendation: strengthen the step (or the scenarios) to also assert the descriptive message fragments, locking in the self-correctability criterion.

Nits

  1. docs/tools/built-in-tools.md documents file_read's shell-command rejection heuristic (≈lines 211–214) but the new malformed-path rejection is not mentioned for file_read/file_write. Not required by the ticket (CHANGELOG covers it) — optional docs follow-up.

Summary

Clean, well-scoped bug fix that matches the ticket's subtasks point-for-point: helper created and called from _validate_file_path_safety, consistency subtask satisfied (file_read is the only sibling tool taking a path argument — verified), Behave scenarios cover markup corruption, control characters, whitespace runs, and legitimate-path regression, and the mandatory TDD workflow is properly closed out. Coverage of the new code is complete and the repo-wide gates all pass locally. The two minor items above (non-str argument error quality; message-content assertions) are worth a small follow-up but do not block merge. Red-tape items (base branch, labels, commit footer) excluded per review instructions; the PR has no prior reviewer comments and no author decisions deferring any scope.

## PR Review: !185 (Ticket #175) ### Verdict: Approve The fix faithfully implements ticket #175: a shared `_validate_path_characters` helper rejects control characters, markup/shell metacharacters, and 2+ whitespace runs **before** any filesystem call, applied consistently to both `file_write` (via `_validate_file_path_safety`) and `file_read`, with traversal/absolute/home checks untouched. The TDD workflow is correctly completed (`@tdd_expected_fail` removed from the two `@tdd_issue_175` scenarios; `@tdd_issue`/`@tdd_issue_175` retained; #175 correctly blocked by the merged TDD issue #176). All acceptance criteria are met and the error message names the specific offending character/pattern (verified by direct execution). All quality gates were re-run locally on this branch: `unit_tests` 3354 scenarios passed, `lint`/`format --check`/`typecheck` (0 errors)/`security_scan`/`dead_code` clean, `coverage_report` 97.3%, and the most-affected Robot suites (`symlink_safe_open`, `llm_tool_calling`) 18/18 passed. New code regions have no uncovered lines. ### Critical Issues None ### Major Issues None ### Minor Issues 1. **Non-string `file` argument now surfaces as a raw `TypeError` instead of a descriptive `ExecutionError`** — `src/cleveractors/agents/tool.py:84` (`_validate_path_characters`), reached from `tool.py:1137` and `tool.py:1022`. For a malformed *type* argument (e.g. `{"file": 123}`), iterating a non-`str` raises `TypeError: 'int' object is not iterable`, which nothing catches. Verified empirically against this branch and the pre-fix commit: pre-fix the call raised `ExecutionError: Invalid file path: _path_normpath: path should be string, bytes or os.PathLike, not int`; post-fix, via `ToolAgent.invoke()` (Path B graph dispatch, which does not wrap exceptions) it is a raw `TypeError`, and via `process_message` it becomes the less actionable `Tool execution failed: 'int' object is not iterable`. This works against the ticket's core goal ("a clear `ExecutionError` describing exactly what about the path is invalid … specific enough that the calling agent can self-correct"). Recommendation: add an `isinstance(filepath, str)` guard at the top of `_validate_path_characters` raising a descriptive `ExecutionError` — this also fixes the same latent gap in `_file_read_tool` (whose shell-indicator check already crashed raw on non-`str` before this PR). Low severity: edge case, no security impact, not the ticket's reported scenario. 2. **Descriptive-message content is not asserted in the two updated `file_write` rejection scenarios** — `features/tool_agent.feature:517-547`, step at `features/steps/tool_agent_steps.py:272-295`. The step only asserts an `ExecutionError` occurred with no OS-error text; it would still pass if the message regressed to a generic one. The ticket's acceptance criterion ("names the specific invalid character(s)/pattern") is only asserted in the new `file_read` scenario (`"disallowed characters"`); the whitespace-run message fragment ("consecutive whitespace") is asserted nowhere. Recommendation: strengthen the step (or the scenarios) to also assert the descriptive message fragments, locking in the self-correctability criterion. ### Nits 1. `docs/tools/built-in-tools.md` documents `file_read`'s shell-command rejection heuristic (≈lines 211–214) but the new malformed-path rejection is not mentioned for `file_read`/`file_write`. Not required by the ticket (CHANGELOG covers it) — optional docs follow-up. ### Summary Clean, well-scoped bug fix that matches the ticket's subtasks point-for-point: helper created and called from `_validate_file_path_safety`, consistency subtask satisfied (`file_read` is the only sibling tool taking a path argument — verified), Behave scenarios cover markup corruption, control characters, whitespace runs, and legitimate-path regression, and the mandatory TDD workflow is properly closed out. Coverage of the new code is complete and the repo-wide gates all pass locally. The two minor items above (non-`str` argument error quality; message-content assertions) are worth a small follow-up but do not block merge. Red-tape items (base branch, labels, commit footer) excluded per review instructions; the PR has no prior reviewer comments and no author decisions deferring any scope.
CoreRasurae force-pushed bugfix/m1-file-write-path-validation from 4f67101a13
Some checks failed
CI / lint (pull_request) Successful in 44s
CI / typecheck (pull_request) Successful in 1m58s
CI / security (pull_request) Successful in 2m16s
CI / quality (pull_request) Successful in 2m22s
CI / build (pull_request) Successful in 1m6s
CI / integration_tests (pull_request) Successful in 3m27s
CI / benchmark (pull_request) Failing after 13m56s
CI / unit_tests (pull_request) Successful in 6m46s
CI / coverage (pull_request) Successful in 7m14s
CI / status-check (pull_request) Successful in 2s
to 0228d7fa45
Some checks failed
CI / lint (pull_request) Successful in 45s
CI / typecheck (pull_request) Successful in 1m57s
CI / quality (pull_request) Successful in 2m19s
CI / security (pull_request) Successful in 2m42s
CI / build (pull_request) Successful in 2m25s
CI / integration_tests (pull_request) Successful in 4m27s
CI / unit_tests (pull_request) Successful in 6m37s
CI / coverage (pull_request) Successful in 6m47s
CI / status-check (pull_request) Successful in 2s
CI / benchmark (pull_request) Failing after 23m40s
2026-11-20 19:37:39 +00:00
Compare
Author
Member

@hurui200320 Thanks for the thorough review. I checked each point against the ticket's acceptance criteria (#175) and docs/index.md §4.5 (which documents file_read/file_write's file argument as a string) before touching anything. Summary below; new head commit is 0228d7f.

Minor Issue 1 (non-string file argument) — Fixed, with a correction to the suggested fix location

Confirmed: {"file": 123} on file_write reached _validate_path_characters untyped and raised a raw TypeError: 'int' object is not iterable on the character-set comprehension. Fixed by adding an isinstance(filepath, str) guard at the top of _validate_path_characters, raising ExecutionError("File path must be a string, got {type}: {value!r}").

However, I verified empirically that this fix alone does not also cover _file_read_tool as suggested — _file_read_tool crashes one step earlier, at its own shell-indicator heuristic (filepath.strip().split()[0]...), with AttributeError: 'int' object has no attribute 'strip', before _validate_path_characters is ever called. Reproduced directly:

>>> (123).strip()
AttributeError: 'int' object has no attribute 'strip'

So I moved the _validate_path_characters(filepath) call in _file_read_tool to run immediately after the empty-path check, before the shell-indicator block, instead of after it. I checked this reordering doesn't change behavior for any existing scenario: the only characters shared between the shell-indicator set and the illegal-path-character set are <, >, |, and no current scenario/test exercises a file_read call containing those alongside a shell-command-like string, so no precedence conflict was introduced. Added two new Behave scenarios (file_write and file_read, non-string file argument) to lock this in — both pass.

Minor Issue 2 (message-content assertions) — Fixed

The shared step the file write should be rejected by path validation before any filesystem call only asserted ExecutionError + absence of "Errno"/"No such file", so a regression to a generic message would still pass. Added And tool execution should fail with message containing "..." to all three affected scenarios (markup → "disallowed characters", whitespace-run → "consecutive whitespace", control-char → "disallowed characters"), reusing the existing generic step rather than writing a new one.

Nit (docs/tools/built-in-tools.md) — Not done, per your own note

You flagged this as "Not required by the ticket... optional docs follow-up," so I left it out of this PR to keep the diff scoped to #175's acceptance criteria. Happy to pick it up separately if you'd rather it not wait.

"Small follow-up" framing — addressed directly in this PR, not as an independent follow-up

Both minor issues are fixed in this same commit (amended, not a new one — the branch isn't merged yet, so there's no "already-shipped" history to preserve) rather than spun out into a separate issue/PR, since they're small, directly tied to #175's scope, and the ticket is still open.

Verification

  • nox -s unit_tests: 3356/3356 scenarios pass (3354 → +2 new: non-string file for both tools).
  • Coverage delta scoped to features/tool_agent.feature (not the full-suite threshold run): every added/changed line in tool.py (the isinstance guard, its branch, and the reordered call site) is exercised — no new uncovered lines.
  • nox -s lint / format -- --check / typecheck / security_scan / dead_code: all clean (one file needed ruff format, now applied).
  • CHANGELOG's #175 entry extended to mention the non-string case; no new entry added (still one atomic change).

Pushed to bugfix/m1-file-write-path-validation (force-pushed, since the commit was amended — branch is unprotected). Re-requesting your review when convenient.

@hurui200320 Thanks for the thorough review. I checked each point against the ticket's acceptance criteria (#175) and `docs/index.md` §4.5 (which documents `file_read`/`file_write`'s `file` argument as a `string`) before touching anything. Summary below; new head commit is `0228d7f`. ### Minor Issue 1 (non-string `file` argument) — Fixed, with a correction to the suggested fix location Confirmed: `{"file": 123}` on `file_write` reached `_validate_path_characters` untyped and raised a raw `TypeError: 'int' object is not iterable` on the character-set comprehension. Fixed by adding an `isinstance(filepath, str)` guard at the top of `_validate_path_characters`, raising `ExecutionError("File path must be a string, got {type}: {value!r}")`. However, I verified empirically that this fix alone does **not** also cover `_file_read_tool` as suggested — `_file_read_tool` crashes one step *earlier*, at its own shell-indicator heuristic (`filepath.strip().split()[0]...`), with `AttributeError: 'int' object has no attribute 'strip'`, before `_validate_path_characters` is ever called. Reproduced directly: ``` >>> (123).strip() AttributeError: 'int' object has no attribute 'strip' ``` So I moved the `_validate_path_characters(filepath)` call in `_file_read_tool` to run immediately after the empty-path check, *before* the shell-indicator block, instead of after it. I checked this reordering doesn't change behavior for any existing scenario: the only characters shared between the shell-indicator set and the illegal-path-character set are `<`, `>`, `|`, and no current scenario/test exercises a `file_read` call containing those alongside a shell-command-like string, so no precedence conflict was introduced. Added two new Behave scenarios (`file_write` and `file_read`, non-string `file` argument) to lock this in — both pass. ### Minor Issue 2 (message-content assertions) — Fixed The shared step `the file write should be rejected by path validation before any filesystem call` only asserted `ExecutionError` + absence of `"Errno"`/`"No such file"`, so a regression to a generic message would still pass. Added `And tool execution should fail with message containing "..."` to all three affected scenarios (markup → `"disallowed characters"`, whitespace-run → `"consecutive whitespace"`, control-char → `"disallowed characters"`), reusing the existing generic step rather than writing a new one. ### Nit (docs/tools/built-in-tools.md) — Not done, per your own note You flagged this as "Not required by the ticket... optional docs follow-up," so I left it out of this PR to keep the diff scoped to #175's acceptance criteria. Happy to pick it up separately if you'd rather it not wait. ### "Small follow-up" framing — addressed directly in this PR, not as an independent follow-up Both minor issues are fixed in this same commit (amended, not a new one — the branch isn't merged yet, so there's no "already-shipped" history to preserve) rather than spun out into a separate issue/PR, since they're small, directly tied to #175's scope, and the ticket is still open. ### Verification - `nox -s unit_tests`: 3356/3356 scenarios pass (3354 → +2 new: non-string `file` for both tools). - Coverage delta scoped to `features/tool_agent.feature` (not the full-suite threshold run): every added/changed line in `tool.py` (the `isinstance` guard, its branch, and the reordered call site) is exercised — no new uncovered lines. - `nox -s lint` / `format -- --check` / `typecheck` / `security_scan` / `dead_code`: all clean (one file needed `ruff format`, now applied). - CHANGELOG's #175 entry extended to mention the non-string case; no new entry added (still one atomic change). Pushed to `bugfix/m1-file-write-path-validation` (force-pushed, since the commit was amended — branch is unprotected). Re-requesting your review when convenient.
CoreRasurae force-pushed bugfix/m1-file-write-path-validation from 0228d7fa45
Some checks failed
CI / lint (pull_request) Successful in 45s
CI / typecheck (pull_request) Successful in 1m57s
CI / quality (pull_request) Successful in 2m19s
CI / security (pull_request) Successful in 2m42s
CI / build (pull_request) Successful in 2m25s
CI / integration_tests (pull_request) Successful in 4m27s
CI / unit_tests (pull_request) Successful in 6m37s
CI / coverage (pull_request) Successful in 6m47s
CI / status-check (pull_request) Successful in 2s
CI / benchmark (pull_request) Failing after 23m40s
to fe9ce14c59
Some checks failed
CI / lint (pull_request) Successful in 1m23s
CI / typecheck (pull_request) Successful in 2m9s
CI / quality (pull_request) Successful in 2m26s
CI / build (pull_request) Successful in 2m21s
CI / security (pull_request) Successful in 2m49s
CI / integration_tests (pull_request) Successful in 3m55s
CI / unit_tests (pull_request) Successful in 6m24s
CI / benchmark (pull_request) Failing after 23m19s
CI / coverage (pull_request) Successful in 7m32s
CI / status-check (pull_request) Successful in 1s
CI / lint (push) Successful in 1m19s
CI / quality (push) Successful in 1m18s
CI / security (push) Successful in 2m0s
CI / typecheck (push) Successful in 2m46s
CI / build (push) Successful in 1m57s
CI / integration_tests (push) Successful in 3m18s
CI / unit_tests (push) Successful in 6m45s
CI / benchmark (push) Failing after 15m49s
CI / coverage (push) Failing after 14m47s
CI / status-check (push) Has been cancelled
2026-11-21 19:11:46 +00:00
Compare
Author
Member

One more fix on top of the above, found during an informal discussion with the project owner rather than in your review, but worth recording here since it's in the same commit (fe9ce14):

Cross-platform (Windows) path separator — fixed

_ILLEGAL_PATH_CHARS includes ` \` because it's never legitimate content in a path segment (shell escape character). But the original whole-string character scan would also flag a native Windows path using \ as its separator (e.g. subdir\leaf.v) as corrupted — this project has a confirmed requirement to run on Windows hosts (already evidenced by the bundled-skill-script support invoking .bat files via cmd.exe, per docs/guides/skill-packages.md/docs/tools/built-in-tools.md), so that's a real regression for that platform, not a theoretical one.

Fix: _validate_path_characters now splits the path into segments via pathlib.PurePath before scanning for illegal characters. PurePath resolves to PureWindowsPath or PurePosixPath based on os.name — the same auto-detection os.path itself already relies on — so a Windows host's native \ separator is consumed as a segment boundary and never seen by the character check, while on a POSIX host \ is still not a separator and a string using it as one is still rejected (preserving the original hardening there). The leading anchor of an absolute/drive/UNC path is excluded from the character scan — its legality is handled separately by the existing absolute-path/traversal/sandbox checks downstream.

Since CI only runs on Linux, added Behave scenarios that simulate os.name == "nt" via unittest.mock.patch (a standard, non-LLM test technique) to exercise the Windows branch deterministically: a Windows-style path is accepted end-to-end through _file_write_tool, an illegal character embedded in a Windows path segment is still rejected, and a bare backslash path is still rejected on the current (POSIX) CI host. All in features/tool_coverage_gaps.feature.

Re-verified: nox -s unit_tests 3360/3360 scenarios pass; coverage delta scoped to the two pertinent feature files shows no new uncovered lines; lint/format/typecheck/security_scan/dead_code all clean. Pushed as fe9ce14 (force-pushed, amended, unprotected branch).

One more fix on top of the above, found during an informal discussion with the project owner rather than in your review, but worth recording here since it's in the same commit (`fe9ce14`): ### Cross-platform (Windows) path separator — fixed `_ILLEGAL_PATH_CHARS` includes `` ` \` `` because it's never legitimate *content* in a path segment (shell escape character). But the original whole-string character scan would also flag a **native Windows path using `\` as its separator** (e.g. `subdir\leaf.v`) as corrupted — this project has a confirmed requirement to run on Windows hosts (already evidenced by the bundled-skill-script support invoking `.bat` files via `cmd.exe`, per `docs/guides/skill-packages.md`/`docs/tools/built-in-tools.md`), so that's a real regression for that platform, not a theoretical one. Fix: `_validate_path_characters` now splits the path into segments via `pathlib.PurePath` before scanning for illegal characters. `PurePath` resolves to `PureWindowsPath` or `PurePosixPath` based on `os.name` — the same auto-detection `os.path` itself already relies on — so a Windows host's native `\` separator is consumed as a segment boundary and never seen by the character check, while on a POSIX host `\` is still not a separator and a string using it as one is still rejected (preserving the original hardening there). The leading anchor of an absolute/drive/UNC path is excluded from the character scan — its legality is handled separately by the existing absolute-path/traversal/sandbox checks downstream. Since CI only runs on Linux, added Behave scenarios that simulate `os.name == "nt"` via `unittest.mock.patch` (a standard, non-LLM test technique) to exercise the Windows branch deterministically: a Windows-style path is accepted end-to-end through `_file_write_tool`, an illegal character embedded in a Windows path segment is still rejected, and a bare backslash path is still rejected on the current (POSIX) CI host. All in `features/tool_coverage_gaps.feature`. Re-verified: `nox -s unit_tests` 3360/3360 scenarios pass; coverage delta scoped to the two pertinent feature files shows no new uncovered lines; `lint`/`format`/`typecheck`/`security_scan`/`dead_code` all clean. Pushed as `fe9ce14` (force-pushed, amended, unprotected branch).
CoreRasurae deleted branch bugfix/m1-file-write-path-validation 2026-11-21 19:46:04 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
cleveragents/cleveractors-core!185
No description provided.