test(agents): capture file_write accepting a malformed path bug (#175) #178
No reviewers
Labels
No labels
auto/blocked-by-deps
auto/ci-timeout
auto/claimed-implementer
auto/claimed-merge
auto/claimed-reviewer
auto/driver-down
auto/invariant-violation
auto/last-attempt-tier-0
auto/last-attempt-tier-1
auto/last-attempt-tier-2
auto/last-attempt-tier-min
Automation Tracking
auto/needs-conflict-resolution
auto/needs-implementer
auto/postmortem
auto/ready-to-merge
auto/restart-throttled
auto/revert
auto/sentinel
auto/stale-inactivity
auto/unstable
Blocked
Bounty
$100
Bounty
$1000
Bounty
$10000
Bounty
$20
Bounty
$2000
Bounty
$250
Bounty
$50
Bounty
$500
Bounty
$5000
Bounty
$750
MoSCoW
Could have
MoSCoW
Must have
MoSCoW
Should have
Needs Feedback
Points
1
Points
13
Points
2
Points
21
Points
3
Points
34
Points
5
Points
55
Points
8
Points
88
Priority
Backlog
Priority
CI Blocker
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Signed-off: Owner
Signed-off: Scrum Master
Signed-off: Tech Lead
Spike
State
Completed
State
Duplicate
State
In Progress
State
In Review
State
Paused
State
Unverified
State
Verified
State
Wont Do
Type
Automation
Type
Bug
Type
Discussion
Type
Documentation
Type
Epic
Type
Feature
Type
Legendary
Type
Refactor
Type
Support
Type
Task
Type
Testing
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Blocks
Reference
cleveragents/cleveractors-core!178
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "tdd/m1-file-write-path-validation"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds a failing-first Behave regression test proving issue #175:
ToolAgent._validate_file_path_safety(src/cleveractors/agents/tool.py) only checks afile_writefileargument for traversal, absolute-path, and home-directory escapes — it has no check that the string is a well-formed path containing only path-legal characters. A corrupted argument (an embedded HTML/markup fragment, or a whitespace-run indicating a concatenated/corrupted string) therefore sails through validation untouched and only fails deep insideFileAccessCore.write()with a rawOSError, instead of being rejected up front with a descriptiveExecutionError.Two scenarios are added to
features/tool_agent.feature(extending the existingfeatures/steps/tool_agent_steps.py, no new feature/step file):Both are tagged
@tdd_issue @tdd_issue_175 @tdd_expected_failper the mandatory Bug Fix TDD Workflow. Confirmed locally that removing@tdd_expected_failmakes both scenarios fail with a plainAssertionError(bug reproduced); with the tag present,TddExpectedFailPolicyinverts the failure sonox -s unit_testsstays green.The actual fix (a path-character/well-formedness check in
_validate_file_path_safety) lands separately onbugfix/m1-file-write-path-validationper issue #175.Test plan
nox -s lint— greennox -s format -- --check— greennox -s typecheck— green (Pyright strict, 0 errors)nox -s security_scan— green (bandit + semgrep, 0 findings)nox -s dead_code— green (vulture)nox -s unit_tests— green (3342 scenarios passed, including the 2 new TDD scenarios)nox -s coverage_report— 97.3% (≥ 96.5% threshold)nox -s integration_tests— green (382 Robot tests passed)AssertionErrorwith@tdd_expected_failremoved, and pass via inversion with it presentCloses #176
Refs #175
See approval below
PR Review: !178 (Ticket #176)
Verdict: Request Changes
The TDD-capture work — the actual deliverable of this ticket — is excellent and was fully verified locally: both new
@tdd_expected_failscenarios genuinely reproduce bug #175 (with the tag stripped they fail with plainAssertionErrors surfacing the raw[Errno 2] No such file or directory), pass via the inversion policy with the tag present, useassertonly, comply with the three-tag rules, and run against isolated per-scenario sandbox temp dirs (FileAccessCore.writenever creates parent directories, so the ENOENT reproduction is deterministic). A fullnox -s unit_testsrun on the PR head is green — 159 features / 3342 scenarios / 0 failed, matching the PR report — and agent-side skill loading (skills.py:239) still validates strictly, so the ADR-2034 D-5 default is untouched.However, the PR cannot be merged as-is: it carries a second, unrelated commit — the entire !177/#171
--relaxedfeature — that its title and description never mention. That is the one blocking finding below.No comments or reviews existed on this PR, and the author posted no responses elsewhere deciding items out-of-scope, so nothing was dropped from this review. Red-tape items (missing
ISSUES CLOSEDfooter on the test commit, unchecked subtask checkboxes on #176, develop-vs-master base) are excluded per reviewer instruction.Critical Issues
None
Major Issues
318b0a8b(feat(skills): add --relaxed flag to ease skill packaging checks, footerISSUES CLOSED: #171) is the parent of the TDD commit and accounts for 11 of the 13 changed files (~416 of 448 added lines:skill_packer.py,skill_schema.py,skill_unpacker.py, both CLIs, both skill feature/step files, docs, CHANGELOG), yet the PR title/body describe only the #176 test capture and never mention #171.feature/m1-skill-packer-relaxed-mode→develop), which is the branch #171's Metadata prescribes; this PR's branch is #176's metadata branchtdd/m1-file-write-path-validation.tdd/m1-file-write-path-validationontoorigin/develop, dropping318b0a8b— verified the TDD commit3080eeeis fully self-contained (onlyfeatures/tool_agent.feature+features/steps/tool_agent_steps.py) — and leave #171 to the already-approved !177. Alternatively, if bundling is intentional, retitle/describe the PR to cover both issues, addCloses #171, and close !177.Minor Issues
docs/guides/skill-packages.md:350-352andsrc/cleveractors/agents/skill_unpacker.py:252-258. The guide says unsupported top-level fields are written back "instead of raising a validation error" and that "without--relaxedan over-long description or an unsupported field still fails exactly as before". The second half is false for the unsupported field:SkillValidator.validatehas no unknown-key rejection, so strict unpack silently drops the field (verified in code; it never failed, before or after). Reword and scope the "still fails" sentence to the description-length case. (Same finding was raised on the identical commit in !177; not yet addressed.)src/cleveractors/agents/skill_schema.py:307-324._validate_lengthnow emitsmust be at least 1 characters (max: 1024), got Ninstead ofmust be 1-1024 characters, got Nfor every strict failure, includingcompatibility(max 500). Only themax_len=Nonecase needs new wording; keep the old format whenmax_len is not None(which also fixes the "1 characters" grammar). No test asserts the old text (verified by grep), so nothing breaks either way.features/skill_directory_packages.feature/features/skill_directory_unpacking.feature: no--relaxed×--checkor--relaxed×--outputscenarios (both explicitly listed in #171's AC), and "every other rejection still fires under--relaxed" is spot-checked for only 3 of the enumerated checks — name pattern/length, compatibility length,safe_modetype, resource-path validation, and name-matches-directory are not re-asserted under the flag. Risk is nil given the flag-orthogonal implementation, but the scenarios are one-liners and would close the AC exactly.Nits
features/skill_directory_packages.feature:181— "--relaxed does not relax the minimum description length" actually exercises the non-empty-string check (_require_stringrejects""before_validate_lengthruns). Behavior is correct and the AC is satisfied, but the scenario name overstates what is exercised.src/cleveractors/agents/skill_schema.py:207-209— therelaxeddocstring onSkillValidator.validatementions only the description max-length; under relaxed it also populatesSkill.extra_fields(round-trip data). Worth a sentence.src/cleveractors/agents/skill_unpacker.py:107-110— the "cannot clobber a known field" comment holds only for validator-produced Skills; a directly constructedSkill(extra_fields={"name": ...})would clobber rendered frontmatter becausefields.update()runs last. Consider noting the precondition.Summary
The #176 deliverable itself is done exactly right: the two scenarios cover the captured markup corruption from #175's evidence plus a second malformed shape (whitespace run) as the ticket demands, the
@tdd_expected_failinversion was independently re-verified in both directions on the PR head, and the full Behave suite (3342 scenarios) passes locally. The sole blocker is branch composition: the PR also carries the entire already-approved !177/#171 feature commit without mentioning it. Rebase the TDD commit ontoorigin/develop(or explicitly fold #171 into this PR's description and close !177), and optionally pick up the cheap docs/message-accuracy fixes already flagged on !177. Once the stray commit is removed, this is a clean Approve.PR Review: !178 (Ticket #176) — focused on commit
3080eee(updated review)Verdict: Approve
Supersedes my earlier review (#9873). Per the author's clarification, this PR depends on !177: the
feat(skills)commit318b0a8bat the base of this branch is !177's head — the branch was cut from it, which is why the feature code appears in this PR's raw diff. Under that assumption, the commit under review for ticket #176 is3080eeeonly (features/tool_agent.feature+features/steps/tool_agent_steps.py). The findings my earlier review raised against the--relaxedcommit (strict-unpack docs wording,_validate_lengthmessage text, #171 AC coverage gaps) belong to !177, are already recorded there, and are intentionally not re-reported here.Merge-order note (non-blocking): merge !177 first; once it lands, this PR's diff reduces to the TDD commit alone. If !178 merged first, develop would receive the #171 feature through a PR body that never describes it, and #171 would remain open with its implementation already merged.
Critical Issues
None
Major Issues
None
Minor Issues
None
Nits (informational, for the upcoming #175 fix branch)
ExecutionErrormessage contains neither"Errno"nor"No such file"— exactly as #176's subtasks prescribe. Heads-up for the fix: the eventual validation error message must not embed the underlying OS error text (e.g. don't quote[Errno 2] …inside the new message), or these scenarios will keep failing after@tdd_expected_failis removed.weird spaced/nested_dir/leaf.md) encodes the requirement that the fix reject whitespace-run/concatenated paths, not just markup characters. Per #175's expected behavior the fix must cover both shapes; if it only blacklists markup characters, this scenario will fail post-tag-removal — correctly forcing the broader check.Summary
The TDD capture fulfills every #176 acceptance criterion, and I re-verified it independently on the PR head rather than trusting the report:
@tdd_expected_failtemporarily stripped, both scenarios fail with plainAssertionError("Bug #175 reproduced: … raw OS error"), the captured stderr showingFile write failed … [Errno 2] No such file or directoryreaching the filesystem. With the tag restored, both pass via theTddExpectedFailPolicyinversion. (Temporary edit for verification only; working tree restored afterwards.)@tdd_issue @tdd_issue_175 @tdd_expected_failpresent and combination-valid; assertions useassertonly; no mocks added; malformed paths point at nonexistent parents inside per-scenario sandbox temp dirs, andFileAccessCore.writenever creates parent directories, so the ENOENT reproduction is deterministic — no real filesystem is touched.nox -s unit_testson this commit: 159 features / 3342 scenarios / 0 failed — matching the PR report; coverage unaffected (author reports 97.3%).TddExpectedFailPolicy.on_scenariofails the scenario if the bug is fixed without removing the tag, so the capture cannot silently rot.With the !177 dependency acknowledged, nothing blocks this PR. Recommended sequence: merge !177, then this PR (after which the diff is test-only), then the #175 fix removes the tag.
3080eeef5a547352e094547352e094e4bd277e87CoreRasurae referenced this pull request2026-11-30 12:18:16 +00:00