Repository navigation
fix: Take back the retired MultiEdit/LS/NotebookRead denies (#574) - #635
Conversation
…#574) rossoctl#572 dropped `MultiEdit`, `LS` and `NotebookRead` from `CLAUDE_DENY`, because current Claude Code warns at every start about a deny rule naming no known tool. A repository configured before that still lists all three, and re-running `sbx up` added the new entries without taking the old ones out, so those three warnings stayed until `sbx rm` then `sbx up`, or a hand edit. `sbx up` records what it added in `.sbx/agent-config.json` (op `item` on `permissions.deny`), so it can take back exactly the retired entries it wrote itself. Cortex mode already did this for the whole deny list; that code is now `dropDenies`, and the plain arm calls it with the retired names. One the developer wrote is not in the record, so it stays. Two details the issue leaves open: - The take-back runs after the additions, so `permissions.deny` is never empty at that point and `dropAt` cannot reach the emptied-container path. - A refused removal does not fail the run (`soft`). `dropAt`'s guards throw `ConfigConflict`, which would abort the whole `sbx up`; clearing a cosmetic warning is not worth failing a sandbox creation, so the entry and its record are left alone and `up` carries on. Cortex keeps the hard behaviour, where a kept deny would stop Claude Code loading CLAUDE.md. Tests: seven cases for the take-back (a re-run clearing the three and updating the record, a second run as a no-op, a hand-written entry kept, a list holding both a recorded and a hand-written copy, a record dropped for one already gone by hand, a dry run writing nothing, and `rm` still restoring the original file), plus one in the guard suite for the refused removal. Five mutations reintroduced and each shown to fail the suite. Assisted-By: Claude (Anthropic AI) <[email protected]> Signed-off-by: cwiklik <[email protected]>
ingpaolodettori-dev
left a comment
There was a problem hiding this comment.
Summary
The take-back looks correct. It removes only recorded items, the soft-refusal restore covers everything edit() mutates, splicing while iterating a copy is safe, and the Cortex path is unchanged. The tests cover the record/hand-written/dry-run/rm cases. Two nits inline.
Author: cwiklik (MEMBER — maintainer)
Areas reviewed: TypeScript, tests, Docs
Agent/IDE config (.claude/.vscode): none
Commits: 1 commit, all signed-off: yes
CI status: passing
| if (!soft || !(err instanceof ConfigConflict)) throw err; | ||
| doc.text = was.text; | ||
| doc.data = was.data; | ||
| dropped.splice(dropped.indexOf(r), 1); |
There was a problem hiding this comment.
nit: A soft refusal is completely silent: the developer keeps the three startup warnings, and every later up retries and fails quietly. Consider surfacing it, e.g. a warnings entry on AgentConfigResult (like removeAgentConfig returns) that names the file and the entry to remove by hand.
| | `CLAUDE.md`, `AGENTS.md` | A block between `<!-- sbx:begin -->` and `<!-- sbx:end -->` telling the agent how the sandbox works (below) | | ||
| | `.sbx/` | `sandbox.json`, the binding (your sandbox's id and the service URL), and `agent-config.json`, the record of what `up` added. `.sbx/` is listed in `.git/info/exclude`, never in your `.gitignore` | | ||
|
|
||
| An older mocactl also denied `MultiEdit`, `LS` and `NotebookRead`, which current Claude Code does |
There was a problem hiding this comment.
nit: Inserted here, this paragraph separates the table from "They are ordinary files in your working tree…", so "They" now reads as the three denies. Moving it below that paragraph, or starting the next one with "These files are…", keeps the reference clear.
What
Closes #574. A repository configured before #572 still lists
MultiEdit,LSandNotebookReadinpermissions.deny, and current Claude Code warns at every start about each one. Re-runningsbx upadded the new entries without taking the old ones out, so those three warnings stayed untilsbx rmthensbx up, or a hand edit.sbx uprecords what it added in.sbx/agent-config.json(opitemonpermissions.deny), so it can take back exactly the retired entries it wrote itself. Cortex mode already had this mechanism for the whole deny list; that code is nowdropDenies, and the plain arm calls it with the retired names. The Cortex call passes() => true, so its behaviour is unchanged.CLAUDE_RETIREDnames the three fix(sbx): steer agents through the MCP server's instructions; deny only known tools #572 dropped — denies to recognise, not denies to add.Two details the issue leaves open
permissions.denyis therefore never empty at that point, sodropAtcannot reach the emptied-container (emptyInner) path.softargument).dropAt's guards throwConfigConflict, which would abort the wholesbx up. Clearing a cosmetic warning is not worth failing a sandbox creation, so a refusal restores the document, keeps the record — a later run retries — andupcarries on. Cortex keeps the hard behaviour: there, a kept deny would stop Claude Code loadingCLAUDE.md.Tests
Seven cases in
sbx-agent-config.test.ts: a re-run clearing the three and updating the record; a second run as a no-op; a hand-written entry kept; a list holding both a recorded and a hand-written copy; a record dropped for one already gone by hand; a dry run writing nothing; andrmafter the take-back still restoring the developer's original file. One case insbx-agent-config-guard.test.tsfor the refused removal, which also checks the entry comes out once the edit behaves.Mutation testing — each reintroduced and shown to fail the suite:
softoff (a guard failure failsup)wantedmatches everythingdroppednot fed to the manifest filtervitest runfor@moca/mocactl: 1547 passed, 4 skipped (74 files).tsc --noEmitclean. Prettier clean on all five files.make lintandmake typecheckboth die atpnpm install(ERR_PNPM_IGNORED_BUILDS) on this machine, sotscand Prettier were run directly — the same gates CI checks. Thepnpm-workspace.yamlchurn thatpnpm installleaves behind is reverted and not in the diff.Docs
docs/sbx/user-guide.md§4: tells the developer a re-run clears the three warnings, and that one they wrote stays.Assisted-By: Claude Code