Skip to content

feat: validate path compatibility and drift checks#97

Closed
Patel230 wants to merge 2 commits into
mainfrom
pr/compat-drift-check
Closed

feat: validate path compatibility and drift checks#97
Patel230 wants to merge 2 commits into
mainfrom
pr/compat-drift-check

Conversation

@Patel230

Copy link
Copy Markdown
Contributor

Add path validation and structured-edit compatibility drift checks.

Patel230 and others added 2 commits July 13, 2026 20:17
Add a new drift check that compares hawk's own go.mod requirements for
tracked pins against what each external/ submodule declares. This helps
detect version mismatches that could cause silent build-time upgrades.

Related: docs/compatibility.md explains the drift concern in detail.
PatchTool, StructuredEditTool, and SmartCreateTool wrote/deleted files
from LLM-authored paths without calling validatePathAllowed, the sandbox
guard already used by file_write.go and file_edit.go. This let an LLM
escape the working directory / allowed-directories sandbox via these
three tools even though the equivalent Write/Edit tools were guarded.

Thread ctx through PatchParser.ApplyAll so each patch's path (including
the Delete File directive, which shares the same Apply function) is
validated before any filesystem mutation. Add the same guard check to
StructuredEditTool.Execute and SmartCreateTool.Execute before their
ReadFile/WriteFile/MkdirAll calls.

Add a regression test asserting PatchTool.Execute rejects a Create File
patch targeting a path outside the allowed directories and does not
create the file.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@Patel230 Patel230 enabled auto-merge (squash) July 14, 2026 09:25
@Patel230 Patel230 closed this Jul 14, 2026
auto-merge was automatically disabled July 14, 2026 09:32

Pull request was closed

@Patel230 Patel230 deleted the pr/compat-drift-check branch July 14, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant