Repository navigation
fix(acp): carry deny/ask rules from a BOM-saved Claude settings file - #16423
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing to check. [DESIGN-REVIEWED] dc7bc65 Description read[DESCRIPTION-READ] 93b4092ab6241c3268f8dc8d7bfa9dab34080090f7f98af3d7ab923a2f2fc570 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (3 items) — 3 justifiedIntent: when a person saves their project's Claude settings file with a UTF-8 BOM, its deny/ask rules and its hooks/sandbox guard should still reach the session. This is a FIX.
[FIRST-PRINCIPLES-REVIEWED] dc7bc65 Description read[DESCRIPTION-READ] 9ab8b67b97f7e66aa57bef932273a67402ff85f51f48813ecedf1c1caee8c713 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
f26c52b to
64f7cc7
Compare
…gs file A Windows editor saves UTF-8 "with BOM" by default, and json.loads refuses a leading U+FEFF. _project_settings_restrictions read a project's .claude/settings*.json that way as "no rules", so excluding the project tier dropped its deny/ask rules, and a hooks or sandbox key no longer withheld the exclusion. It now parses through kiro_crew.user_json. Regression tests also cover the agent.json overrides and the owned-spec hook sanitizer, which read through agent._load_json and are BOM-safe on main. Refs #13656
64f7cc7 to
dc7bc65
Compare
|
[operator: iamwhatever] First Principles BLOCK on Fixed in |
Problem / Motivation
Goal: a hand-edited
agent.json, owned kiro agent spec, or project Claude settings file saved with a UTF-8 BOM is read as what it says, not as an empty or absent file.Windows editors (Notepad, PowerShell
Out-File, VS Code "UTF-8 with BOM") writeEF BB BFbefore the JSON, andjson.loadson decoded text refuses a leading U+FEFF. Three readers still parse that way:build_agent_configreads~/.kiro/crew/agent.json(the user's agent overrides) throughagent._load_json, which answers{}. The overrides silently stop applying._sanitize_agent_hooksreads the owned kiro agent specs the same way, sees{}, and skips the file, so a legacy hook key kiro-cli rejects stays in it._project_settings_restrictionsreads a project's.claude/settings.local.json/.claude/settings.jsonand answers[]("no rules") on a parse error. When Crew leaves the project tier out of a claude session, it carries those files'permissions.deny/permissions.askrules inline. A BOM-saved file dropped them, and ahooksorsandboxkey in it no longer withheld the exclusion.Why it matters
One invisible byte, added by an ordinary editor, turns off a user's agent overrides, and in the Claude case drops the project's deny/ask rules from the session. The MCP config, agent-spec and workspace
cli.jsonreaders already accept the mark (#13635, #16209, #16251). These are the remaining readers from the #13656 audit outside the openconfig.json(#16283 / #16286) and.env(#15596) PRs.Not a goal
config.jsonreaders. They belong to fix(config): read a config.json saved with a UTF-8 BOM #16283 and its follow-up.agent._load_jsonstays strict on purpose: it also readsconfig.json, and must agree withKiroCrewConfig.load(pinned bytest_agent_loader_keeps_judging_crew_config_like_the_config_loader)..envreaders (fix(config): read a byte-order-marked .env the same way everywhere #15596).What changed (motivation → approach → change)
Symptom →
_project_settings_restrictionscallsjson.loadson decoded text → parse through the existingkiro_crew.user_json.loads_user_json, the one mechanism #16209 added for user-owned JSON.acp/client.py_project_settings_restrictions: a BOM-saved project.claude/settings*.jsonhas its deny/ask rules carried, and itshooks/sandboxkeys withhold the exclusion as for a plain file.user_json.py: docstring names the file classes it now serves, and notes that a reader handingjson.loadsraw bytes already drops the mark.agent.jsonoverrides and owned-spec hook sanitizer were already made BOM-safe on main by fix(config): read a BOM-saved config.json in every remaining reader #16432 (throughagent._load_json). This PR keeps no code change there, only regression tests.Reader inventory for #13656
Found from the sinks (
json.load/json.loadson a file read), then classed by who owns and edits the file.Changed here:
acp.client._project_settings_restrictions.claude/settings*.jsonAlready BOM-safe on main (no change needed):
agent._load_jsoncallers:build_agent_config(agent.jsonoverrides),_sanitize_agent_hooks(owned specs),config.jsonreadsacp.skill_projection._settings(global + workspacecli.json)json.loads(bytes); its encoding detection already decodes a leading BOMproviders/acp.pycli.json overlay readersagent_spec_format,~/.claude.jsonviadashboard/handlers/mcp.py, onboarding scanDeliberately left:
config.jsonreaders not yet converted.envreaderssandbox.kiro_internal_sandbox_enabled(~/.kiro/settings/amazon-internal.json)agent._existing_specs_are_mineplatform/governance._read_json_fileapp.json,AppManifest.from_json_file, install/registry pipeline) and theme packageshooks.json, crons, ledgers,.meta.json, workflow library, seed provenance, etc.)json.dumps; no BOM appears unless a person edits internal stateBackwards compatibility
Compatible: input without a leading U+FEFF parses exactly as before. The only newly accepted input is one leading U+FEFF.
Removes nothing: the change only widens what one reader accepts.
Tests
test/test_claude_project_settings_bom.py: a BOM-saved project settings file's deny/ask rules are returned, and a BOM-saved file withhookswithholds the exclusion (None). Both fail with theclient.pyhunk reverted ([] == [('deny', …)],[] is None).test/test_agent.py::TestInstallAgent::test_fresh_install_applies_bom_saved_user_overridesandTestKiroHooksFiltering::test_sanitize_agent_hooks_repairs_a_bom_saved_owned_file: regression cover for the fix(config): read a BOM-saved config.json in every remaining reader #16432 behaviour at the two user-facing callers (override applied; repaired spec written back without the mark).Local: BOM, user-json and agent BOM tests pass on base
150fce3c3c; flake8 clean.Manual verification
N/A — unit coverage drives the changed reader with a real BOM-prefixed file.
Related Issues
Refs #13656
Pattern harvest
Rule candidate: semgrep
Pattern:
json.loads(<path>.read_text(...))/json.loads(raw.decode("utf-8"))on a user-owned config path instead ofkiro_crew.user_json;json.loads(bytes)is already BOM-safe.Checklist