Skip to content

fix(hooks): session-state exemption checks filePath key for Create tool#971

Merged
magicpro97 merged 3 commits into
mainfrom
fix/fp1-create-tool-filepath-key
Jun 8, 2026
Merged

fix(hooks): session-state exemption checks filePath key for Create tool#971
magicpro97 merged 3 commits into
mainfrom
fix/fp1-create-tool-filepath-key

Conversation

@magicpro97

Copy link
Copy Markdown
Owner

Root Cause

FP-1 session-state exemption (allowing Create/ Edit to .copilot/session-state/) checked only toolArgs["path"], but Copilot CLI Create tool sends the file path as filePath in toolInput / input, not as path in toolArgs.

This caused the exemption to never matchTentacleEnforceRule falsely denied Create calls writing research reports to .copilot/session-state/*/research/.

Changes

hooks/rules/tentacle.py

  • TentacleEnforceRule.evaluate(): now checks toolArgs.path, toolArgs.filePath, and input.filePath

hooks/enforce-tentacle.py

  • Standalone mirror: same fix — checks toolArgs.path, toolInput.filePath, and input.filePath

Verification

Test Input Result
Create.copilot/session-state/ (toolInput.filePath) ALLOW
Createsrc/main.py (project code) DENY ✅ (tentacle still enforces real multi-module edits)
Create.copilot/session-state/ (old toolArgs.path) ALLOW ✅ (backward compatible)

Closes false positive TENTACLE REQUIRED denial when writing research files to session-state.

…e tool

FP-1 exemption checked only toolArgs['path'] but Copilot CLI Create tool
sends the file path as filePath in toolInput/input, not as path in toolArgs.
This caused false-positive tentacle denials when writing research reports
to .copilot/session-state/*/research/.

Now checks all three locations: toolArgs.path, toolInput.filePath, input.filePath.
Copilot AI review requested due to automatic review settings June 8, 2026 14:36

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a false-positive in tentacle enforcement where create/edit operations targeting .copilot/session-state/... were incorrectly blocked because the hook only looked for toolArgs["path"], while the Copilot CLI Create tool commonly reports the path as filePath (in toolInput / input).

Changes:

  • Update TentacleEnforceRule.evaluate() to exempt session-state writes when the path is provided via filePath.
  • Update the legacy standalone hooks/enforce-tentacle.py mirror to apply the same exemption for filePath.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
hooks/rules/tentacle.py Extends the session-state exemption to recognize filePath (including merged toolInput) so Create/Edit to session-state isn’t blocked.
hooks/enforce-tentacle.py Mirrors the exemption update for the standalone enforcement script by reading filePath from additional payload locations.

Comment thread hooks/enforce-tentacle.py
Comment on lines 223 to +228
if tool_name in ("edit", "create"):
file_path = (data.get("toolArgs") or {}).get("path", "")
file_path = (
(data.get("toolArgs") or {}).get("path", "")
or (data.get("toolInput") or {}).get("filePath", "")
or (data.get("input") or {}).get("filePath", "")
)
Comment thread hooks/rules/tentacle.py
Comment on lines +207 to +213
# Note: Create tool sends path as filePath in toolInput/input, not "path" in toolArgs.
if tool_name in ("edit", "create"):
file_path = tool_args.get("path", "")
file_path = (
tool_args.get("path", "")
or tool_args.get("filePath", "")
or (data.get("input") or {}).get("filePath", "")
)
@magicpro97

Copy link
Copy Markdown
Owner Author

Addressed both review comments:

Comment 1 (enforce-tentacle.py missing toolArgs.filePath): ✅ Fixed — added or (data.get("toolArgs") or {}).get("filePath", "") to the standalone exemption check.

Comment 2 (missing regression tests): ✅ Added 2 new Section 19 tests:

  • FP-1: TentacleEnforceRule create to session-state via toolInput.filePath → None
  • FP-1: TentacleEnforceRule create to session-state via input.filePath → None

Verification: 967/967 tests passed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

Comment thread hooks/enforce-tentacle.py
Comment on lines +222 to +229
# Note: Create tool sends path as filePath in toolInput/input, not "path" in toolArgs.
if tool_name in ("edit", "create"):
file_path = (data.get("toolArgs") or {}).get("path", "")
file_path = (
(data.get("toolArgs") or {}).get("path", "")
or (data.get("toolArgs") or {}).get("filePath", "")
or (data.get("toolInput") or {}).get("filePath", "")
or (data.get("input") or {}).get("filePath", "")
)
Add Section 19e functional tests verifying that standalone
enforce-tentacle.py correctly exempts session-state writes
via toolInput.filePath, input.filePath, and toolArgs.filePath.
@magicpro97

Copy link
Copy Markdown
Owner Author

Addressed the latest review comment:

Comment 3 (standalone enforce-tentacle.py missing filePath tests): ✅ Added 3 new Section 19e functional tests covering:

  • create via toolInput.filePath → allowed (no deny output)
  • create via input.filePath → allowed (no deny output)
  • create via toolArgs.filePath → allowed (no deny output)

Verification: 970/970 tests passed.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@magicpro97 magicpro97 merged commit f770fb2 into main Jun 8, 2026
35 checks passed
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.

2 participants