Repository navigation
Normalize HOME in code-mode paths, so the guard sees a new hint folder - #74
Merged
Merged
Conversation
guardedDirs built its folders from HOME as the environment gives it. With HOME=/home/u/ the hint folder was /home/u//.claude/code-mode/hints, and isUnder needs a normalized folder. The guard also checks the real path of each folder, but a folder that does not exist yet has none. So the first Write into a new hint or function folder got past the guard. A file written this way still did not load without an approval in the ledger. Move the loop that normalizes a path from resolvePath to normalizePath in paths.ts. codeModePath and guardedDirs use it, so the loaders and the guard name the same normalized folders for HOME and the project root. Raise the version to 0.12.17. A person whose HOME is not normalized must approve their user hints and saved functions again one time: the ledger key is the hash of the path. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
[Medium impact] The PR appears safe to merge; no actionable issues were found.
|
resolvePath built the full path in a nested ternary inside the call to normalizePath. Put the full path in a constant again, as before the change to normalizePath, and give it to normalizePath. The behavior does not change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Intent
Close a gap in the hint-file guard: when
$HOMEis not normalized (/home/u/,/,/home//u), the first Write into a hint or function folder that does not exist yet must be denied.Drift
$.session.root()goes through the same helper).resolvePathnow calls the newnormalizePathinhooks/paths.ts. The loop is unchanged, only moved.Decisions
codeModePath,guardedDirs), not inhomeOfor inisUnder. Then the loaders, the ledger and the guard all use the same path text. A fix inhomeOfmisses the project root. A fix inisUndercorrects only the compare.//ledger entries are not pruned and stay in$.store.Evidence
Before:
resolvePath/isUnder/hintsFolder(separate session, not in this PR) found this input:{"p":"~/.claude/code-mode/hints/x.md","home":"/home/u/","cwd":"/repo/sub","resolved":"/home/u/.claude/code-mode/hints/x.md","guarded":"/home/u//.claude/code-mode/hints"}.isUnderprecondition:path="/" dir="//".claude plugin test .with the new tests and the old hooks:243 pass,5 fail. The 5 new tests fail, for example(fail) the hint-file guard > guards the folders when HOME is /home/u/withReceived: "written".After:
pass P4 guard sees a write into HOME hint folder.claude plugin test .:248 pass,0 fail..claude/skills/verify/drive.mjs),HOME=/Users/gpavanello/:/Users/gpavanello/.claude/code-mode/hints/verify-guard-probe.mdreturnedcode-mode: hint files and saved functions steer the model, so they cannot be written with file tools. ...note.txtreturnedFile created successfully at: note.txt.hints/andfunctions/folders exist, so their real paths already guarded them. A temporary HOME loses the login.node tests/smoke.e2e.mjs: 11 of 11 pass.tests/code.check.mjs,tests/docs.check.mjs,tests/runner.integration.mjs,tsc -p tsconfig.pure.json,tsc -p tsconfig.json,scripts/format.sh --check .Reading map
Tests changed:
tests/hints.test.tssessionhelper takeshomeandroot. The defaults keep the old setup.Config:
.claude-plugin/plugin.json: version 0.12.16 → 0.12.17.Public API (exported functions):
hooks/paths.ts10-26: newnormalizePath.codeModePathnow normalizes.hooks/paths.ts43-51:guardedDirsnormalizespluginRootand the plugins folder.hooks/hints.ts16, 495-498:resolvePathcallsnormalizePath.🤖 Generated with Claude Code