Skip to content

fix(cli): show --diff checks only the destination, so it advertises a write apply refuses on the backup path #1188

Open

Description

@HugoXK

Slice of #1082 (itself the remainder of #963). The write-dir row only.

AGENTDESCENT_SURFACE_WRITE_DIRS is enforced on the MCP surface today; the other write paths still accept a path outside it, so a worker that writes out of its allowed dirs is caught by review, not by code.

What changes

  • apply: refuse a target outside the allowed dirs before anything touches disk, including the materialised tree it builds on the way.
  • show --diff: when the diff would write, apply the same check to the paths it names, so the preview cannot advertise a write the apply would refuse.
  • the materialised tree itself, not only the final rename.

Acceptance

  • a path outside the allowed dirs is refused with the offending path and the allowed dirs named in the message; nothing is created, truncated or renamed (no partial file, no mtime change on an existing file);
  • the same call with a path inside the allowed dirs still writes and still passes its existing tests;
  • offline tests only — no new sandbox, no auth layer, no network;
  • Partial: #1082, Partial: #963 (the parent stays open for its other two rows); changelog fragment; the env var's docs line says which paths it now covers.

Evidence the PR must carry

  • red-first: the refusal test fails on the PR's base, with the failing id and the exact command;
  • green at the tip, same command;
  • the per-file diff.

Sequencing: red test and branch work can start now; the PR opens when a queue slot frees (the Lead says when), so a review seat never has three AD PRs at once.

Activity

  1. self-assigned this
    on Nov 20, 2026
  2. added
    enhancementNew feature or request
    area:pluginsHost plugins and installers: Claude Code, Codex, DSH, OpenCode, MCP server
    area:cliThe agentdescent command line (cli.py, doctor, plan/evolve/status/apply)
    on Nov 20, 2026
  3. HugoXK commented on Nov 20, 2026

    @HugoXK
    CollaboratorAuthor

    Closing as already shipped — opened by me from #1082's acceptance text without reading that issue's own thread. My error.

    Evidence: #1082's comment at 2026-11-20T05:12:58Z records the write-dir row as shipped by PR #1087, and the later slice PRs (#1088, #1178) built on the same helper. The row this slice asked for — AGENTDESCENT_SURFACE_WRITE_DIRS applied on apply, on show --diff and on the materialised tree, refused before disk — is therefore already carried by a merged PR, and Partial: #1082 / Partial: #963 already live on those carriers.

    What remains of #1082 is only its middle row (host-worker budget defaults: max_concurrency, a per-Ticket cap, and the USD question), which is deliberately not sliced yet because it edits the same mcp.py helper as #1186, still in review. That is recorded on the parent.

    No work lost: Dev-2 had not pushed anything, no branch reached the remote.

  4. changed the title [-]feat(cli): enforce AGENTDESCENT_SURFACE_WRITE_DIRS on apply, show --diff and the materialised tree (slice of #1082)[/-] [+]fix(cli): `show --diff` checks only the destination, so it advertises a write `apply` refuses on the backup path[/+] on Nov 20, 2026
  5. reopened this on Nov 20, 2026
  6. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Nov 20, 2026
  7. HugoXK commented on Nov 20, 2026

    @HugoXK
    CollaboratorAuthor

    Reopening — my earlier close was too broad, and the correction is narrower than the original issue.

    I closed this as "already shipped by #1087". That is true for apply and for the materialised tree, and not true for show --diff, which is one of the three lines this issue names. What #1087 shipped, read at f5017f93:

    • apply → _check_apply_paths(dest, plan["written"], slot, check_write) (cli.py:3549, :3670, :3768), and that helper checks dest, every written leaf, and the backup slot (evolution.py:1582-1590).
    • show → _refuse_plan_outside_write_dirs(payload, target) (cli.py:3093-3109) checks only the target, never the leaves and never the backup path, though its own docstring says it must not print a plan naming a file apply would refuse.

    So the contract breaks at exactly one seam: AGENTDESCENT_SURFACE_WRITE_DIRS covering the destination while $AGENTDESCENT_HOME/backups/... sits outside it (a directory artifact backs up under the home, not beside the target — cli.py:3638-3640). Then show --diff reports written: ["SKILL.md"], noop: false and apply exits 2 with backup '.../ad-home/backups/demo-.../bak-0' is outside the operator's write allowlist. A preview that advertises a write the apply refuses is the exact failure #1082 asked to prevent.

    Acceptance (narrowed to the one seam)

    • show --diff applies the same check set apply does: destination, every path in written, and the backup slot when one would be taken; a plan it cannot apply is reported as an error instead of as written;
    • the text-file case (backup is a sibling .bak-N, inside the allowlist when the dest is) stays green and unchanged;
    • one offline test that is red at base for the right reason — the preview claims a write, then the same call through apply exits 2 — not a reshaped assertion;
    • no change to apply's own refusal, to the allowlist semantics, or to the tree path;
    • Partial: #1082 / Partial: #963 (their other rows stay closed).

    Evidence the PR must carry: the red run at the PR's base with the failing id and command, green at the tip, per-file diff.

    Sequencing: red test may be prepared now on a local branch; the PR opens when a queue slot frees. Note for whoever picks it up: AGENTDESCENT_SURFACE_WRITE_DIRS unset must keep today's allow-anywhere (cli.py:3437-3439), so the test must set the variable explicitly.

  8. removed
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Nov 20, 2026
  9. HugoXK commented on Nov 20, 2026

    @HugoXK
    CollaboratorAuthor

    Claim renewed: the controller expired agent-working on this issue in its 22:27:21Z run, before the branch was on the remote.

    • branch: agent/1188-show-diff-write-dirs
    • base: 8d75685aecdecb9a93056d8abee661b827a83c28
    • red re-taken at that base, PR opens against main after it

    One PR for this issue.

  10. added
    agent-workingAn agent has claimed this issue (the claim comment names the branch)
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-workingAn agent has claimed this issue (the claim comment names the branch)area:cliThe agentdescent command line (cli.py, doctor, plan/evolve/status/apply)area:pluginsHost plugins and installers: Claude Code, Codex, DSH, OpenCode, MCP serverenhancementNew feature or request

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions