Skip to content

fix: Take back the retired MultiEdit/LS/NotebookRead denies (#574) - #635

Merged
cwiklik merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/574-retired-deny-takeback
Oct 27, 2026
Merged

cwiklik merged 1 commit into
rossoctl:mainfrom
cwiklik:fix/574-retired-deny-takeback

Conversation

@cwiklik

@cwiklik cwiklik commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

What

Closes #574. A repository configured before #572 still lists MultiEdit, LS and NotebookRead in permissions.deny, and current Claude Code warns at every start about each one. 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 had this mechanism for the whole deny list; that code is now dropDenies, and the plain arm calls it with the retired names. The Cortex call passes () => true, so its behaviour is unchanged.

Two details the issue leaves open

  • The take-back runs after the additions. permissions.deny is therefore never empty at that point, so dropAt cannot reach the emptied-container (emptyInner) path.
  • A refused removal does not fail the run (the soft argument). dropAt's guards throw ConfigConflict, which would abort the whole sbx 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 — and up carries on. Cortex keeps the hard behaviour: there, a kept deny would stop Claude Code loading CLAUDE.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; and rm after the take-back still restoring the developer's original file. One case in sbx-agent-config-guard.test.ts for the refused removal, which also checks the entry comes out once the edit behaves.

Mutation testing — each reintroduced and shown to fail the suite:

# Mutation Tests that failed
M1 take-back removed entirely 5
M2 soft off (a guard failure fails up) 1
M3 wanted matches everything 5
M4 dropped not fed to the manifest filter 3
M5 record kept for one already gone by hand 1

vitest run for @moca/mocactl: 1547 passed, 4 skipped (74 files). tsc --noEmit clean. Prettier clean on all five files.

make lint and make typecheck both die at pnpm install (ERR_PNPM_IGNORED_BUILDS) on this machine, so tsc and Prettier were run directly — the same gates CI checks. The pnpm-workspace.yaml churn that pnpm install leaves behind is reverted and not in the diff.

Docs

Assisted-By: Claude Code

…#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]>
@cwiklik
cwiklik requested a review from pdettori as a code owner October 27, 2026 15:41
@cwiklik cwiklik added the ready-for-ai-review Request automated AI code review from clawgenti label Oct 27, 2026

@ingpaolodettori-dev ingpaolodettori-dev 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.

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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment thread docs/sbx/user-guide.md
| `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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

@cwiklik
cwiklik merged commit 9c8af88 into rossoctl:main Oct 27, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-ai-review Request automated AI code review from clawgenti

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sbx up: take back the retired MultiEdit/LS/NotebookRead denies it wrote before #572

2 participants