Skip to content

fix(cli): show --diff previews directory and symlink refusals (#1204) - #1206

Merged
Birfy merged 1 commit into
mainfrom
agent/1204-show-dest-refusals
Nov 21, 2026
Merged

Birfy merged 1 commit into
mainfrom
agent/1204-show-dest-refusals

Conversation

@Birfy

@Birfy Birfy commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator

Closes #1204.

Base: 2dff12b
Tip SHA: f8d5a79

What changed

#1200 taught show --diff to preview the operator write-dir boundary.
The other half of apply's destination refusals was still missing, so
show advertised writes that apply exits 2 on:

  • a text artifact whose spec.target is a directory;
  • a text artifact whose spec.target is a symlink;
  • a tree artifact whose root is a symlink.

apply's text-destination checks (os.path.isdir(dest) and
_refuse_dest_link(...)) now live in one helper, _refuse_text_dest,
that both apply_payload and the text branch of show_payload call, so
the preview cannot drift. The tree branch of show calls
_refuse_dest_link(dest, dest) before _write_to, the same refusal
apply makes (and that _write_to would not see, because it abspaths
the root). apply's behaviour and its message bytes stay unchanged.
show stays read-only: it reports the refusal in apply_plan.error,
does not raise, and does not touch the destination.

docs/plugins.md records the same destination refusals next to the
write-dir paragraph from #1188.

Red first, at this PR's base (2dff12b6) in a clean worktree with only
the new test file present:

PYTHONPATH=. python -m pytest -o addopts="" -p no:cacheprovider -q tests/test_show_dest_refusals.py
3 failed, 1 passed in 0.84s

show --diff --json returned apply_plan with written and no error
for a directory dest, a text symlink dest, and a tree symlink root. The
regular-file control already passed.

Ran at f8d5a79f

  • PYTHONPATH=. python -m pytest -o addopts="" -p no:cacheprovider -q tests/test_show_dest_refusals.py tests/test_write_dirs_apply_show.py tests/test_apply_symlink_dest.py tests/test_apply_noop.py tests/test_cli_apply_created_target.py tests/test_cli_apply_text_missing_parent.py tests/test_apply_backup_away_from_skills.py tests/test_apply_from.py tests/test_cli_write_error.py — 56 passed;
  • python -m tools.gen_api_docs --check — docs/api.md is up to date;
  • python -m tools.changelog_fragments check — 14 changelog fragment(s) OK.

Not run

  • Full offline suite locally — the CI test matrix is the line.
  • mkdocs build --strict in its exact form: this host is offline and the
    social plugin fetches fonts.google.com. The diff adds two sentences
    to docs/plugins.md; CI docs is the line.

#1200 taught show --diff about the operator write-dir boundary. The other
half of apply's destination refusals was still missing: a text artifact
whose target is a directory or a symlink, and a tree whose root is a
symlink, were advertised as written while the same apply exited 2.

The two text-destination checks now live in one helper that both
apply_payload and show_payload call, so the preview cannot drift. The
tree branch of show calls _refuse_dest_link(dest, dest) before
_write_to, the same refusal apply makes. show stays read-only: it
reports apply's own message in apply_plan.error and does not raise.

Closes #1204
@Birfy

Birfy commented Nov 21, 2026

Copy link
Copy Markdown
Collaborator Author

Review (Birfy)

Tip SHA: f8d5a79
Ran:

  • .github/scripts/risk_gate.py --repo ThinkFlowLab/agentdescent --pr 1206 → T2 (192 lines / 4 files)
  • pytest -o addopts="" -p no:cacheprovider -q tests/test_show_dest_refusals.py tests/test_write_dirs_apply_show.py tests/test_apply_symlink_dest.py tests/test_apply_noop.py tests/test_cli_apply_created_target.py tests/test_cli_apply_text_missing_parent.py tests/test_apply_backup_away_from_skills.py tests/test_apply_from.py tests/test_cli_write_error.py at this tip → 56 passed
  • python -m tools.changelog_fragments check → 14 fragments OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
  • Required CI at this tip → still running (build, test (3.9)–test (3.13), otel-wire queued); --auto --squash armed
    Not run:
  • Full offline suite locally — the CI test matrix is the line
  • mkdocs build --strict locally — the diff adds two sentences to docs/plugins.md; CI docs is the line
    Findings:
  • No actionable defects. For a text artifact, show --diff now runs _refuse_text_dest — the same directory and symlink checks apply_payload uses — before the write-dir preview from fix(cli): show --diff checks only the destination, so it advertises a write apply refuses on the backup path #1188. For a tree, it calls _refuse_dest_link(dest, dest) before _write_to, the refusal apply makes and that _write_to would not see. Equality is asserted against apply's own --json error, show exits 0, and the destination is left untouched. Apply's message bytes are unchanged.
    Verdict: PASS

@github-actions github-actions Bot added risk:T2 Risk tier T2 (package code or an unnamed path), set by the controller from the diff agent-pr Pull request opened by an agent labels Nov 21, 2026
@Birfy
Birfy enabled auto-merge (squash) November 21, 2026 16:22
@Birfy
Birfy merged commit 1aa816e into main Nov 21, 2026
12 checks passed
@Birfy
Birfy deleted the agent/1204-show-dest-refusals branch November 21, 2026 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr Pull request opened by an agent risk:T2 Risk tier T2 (package code or an unnamed path), set by the controller from the diff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): show --diff still previews writes apply refuses -- directory and symlink destinations

1 participant