fix(file-safety): extend cross-profile guard to cover top-level profile state files - #35902
fix(file-safety): extend cross-profile guard to cover top-level profile state files#35902uzunkuyruk wants to merge 2 commits into
Conversation
|
One issue that looks worth fixing before merge.
Original code (on main): if parts[0] in PROFILE_SCOPED_AREAS:
target_profile = "default"
area = parts[0]
elif parts[0] == "profiles" and len(parts) >= 3 and parts[2] in PROFILE_SCOPED_AREAS:
target_profile = parts[1]
area = parts[2]
else:
return None # ← catch-all for unrecognized pathsAfter this PR: if parts[0] in PROFILE_SCOPED_AREAS:
...
elif parts[0] == "profiles" and ...:
...
elif parts[0] in PROFILE_STATE_FILES: # new
...
elif parts[0] == "profiles" and ...: # new
...
# ← no else — falls throughIf Suggested fix: add |
…le state files (SOUL.md, config.yaml, .env, auth.json)
teknium1
left a comment
There was a problem hiding this comment.
Thanks for narrowing the cross-profile guard to the existing classifier path. The premise remains valid on current main: classify_cross_profile_target() recognizes only skills/plugins/cron/memories at agent/file_safety.py:419-432, and the current test explicitly expects root config.yaml not to classify at tests/agent/test_file_safety_cross_profile.py:170-179.
Problems
- The final PR commit restores the catch-all
else: return None, resolving the prior review comment, but it adds no regression coverage for the four new state-file paths or both profile directions. get_cross_profile_warning()renders everyareaas a directory atagent/file_safety.py:467; this change would make state-file warnings sayconfig.yaml/orSOUL.md/.
Suggested changes
- Add focused parameterized classifier and write/patch guard tests for all four files.
- Distinguish a state file from a scoped directory in the warning text and update the related tool-facing wording.
This is an automated hermes-sweeper review.
| area = parts[2] | ||
| elif parts[0] in PROFILE_STATE_FILES: | ||
| target_profile = "default" | ||
| area = parts[0] |
There was a problem hiding this comment.
area is later rendered as a directory ({info['area']}/ in get_cross_profile_warning), so this produces config.yaml/ or SOUL.md/. Please distinguish state files from directory-scoped areas in the warning text.
What does this PR do?
classify_cross_profile_targetguarded profile-scoped directories (skills,plugins,cron,memories) but not top-level profile state files (SOUL.md,config.yaml,.env,auth.json).This meant an agent running under one profile could silently write to another profile's
SOUL.mdorconfig.yamlwithout triggering the cross-profile warning — the exact failure mode reported in #32049 (Docker sandbox mirror writes).Fix:
PROFILE_STATE_FILES = ("SOUL.md", "config.yaml", ".env", "auth.json")constantclassify_cross_profile_targetto detect cross-profile writes targeting these files at both<root>/SOUL.md(default profile) and<root>/profiles/<name>/SOUL.md(named profile) pathsType of Change
References
Fixes #32049
Checklist