Skip to content

fix(cli): refuse a tree leaf that is already a directory - #1224

Merged
Birfy merged 1 commit into
mainfrom
agent/1223-blocked-leaf
Nov 22, 2026
Merged

Birfy merged 1 commit into
mainfrom
agent/1223-blocked-leaf

Conversation

@Birfy

@Birfy Birfy commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #1223.

Base: 5ac5548
Tip SHA: d2b64b1

What changed

#1222 refuses a regular file sitting on the way to a tree leaf. The inverse hole was a directory sitting where the artifact wants a file: dest is a directory, dest/alpha is a directory, and the artifact writes alpha. show --diff and apply --dry-run advertised written: ["alpha"] while the real apply exited 2 with cannot write <dest>: Is a directory (the tree root, not the blocking leaf). apply --from was worse: shutil.copy2 nested the bytes at dest/alpha/alpha and reported success.

_check_apply_paths now also refuses a produced path that exists as a real directory, so show --diff, apply --dry-run, the real apply, --from, and --install-to agree on cannot write <leaf>: '<leaf>' is a directory, not a file and the preview still writes nothing. Existing #1221 / #1215 refusals and a sibling directory next to plain/written.md are unchanged. A symlink at the leaf stays with the dest-link refusal.

Red first

At this PR's base (5ac55481) in a clean worktree with only the new test file present:

PYTHONPATH=. python -m pytest -o addopts="" -p no:cacheprovider -q tests/test_apply_blocked_leaf.py
FF.FF
FAILED tests/test_apply_blocked_leaf.py::test_tree_leaf_blocked_by_a_directory_is_named_on_all_four_surfaces
AssertionError: show advertised a write the real apply refuses: {"written": ["alpha"], "unchanged": [], "extra": ["alpha/keep.txt"], "deleted": [], "backup": [], "noop": false}
assert None
tests/test_apply_blocked_leaf.py:95
4 failed, 1 passed

The failing assertion is assert show_error in test_tree_leaf_blocked_by_a_directory_is_named_on_all_four_surfaces. The sibling-directory control was already green on live main; it stays as a lock. --from exited 0 and advertised written: ["alpha"]; --install-to already failed the real write but with cannot write <dest>: Is a directory.

Ran at d2b64b1f

  • PYTHONPATH=. python -m pytest -o addopts="" -p no:cacheprovider -q tests/test_apply_blocked_leaf.py tests/test_apply_blocked_child.py tests/test_apply_blocked_parent.py 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 tests/test_skill_library_apply_install.py tests/test_demo_dest_link.py — 94 passed
  • python -m tools.gen_api_docs --check — docs/api.md is up to date
  • python -m tools.changelog_fragments check — 22 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 one sentence to docs/plugins.md; CI docs is the line.

Closes #1223.

After #1222, show --diff and apply --dry-run still advertised a tree
leaf as written when that path was already a directory, and the real
apply exited 2 naming the tree root (`Is a directory`). apply --from
silently nested the file at dest/alpha/alpha.

_check_apply_paths now also refuses a produced path that exists as a
real directory, so the four surfaces agree on
`cannot write <leaf>: '<leaf>' is a directory, not a file` and write
nothing.
@Birfy

Birfy commented Nov 22, 2026

Copy link
Copy Markdown
Collaborator Author

Review (Birfy)

Tip SHA: d2b64b1
Ran:

  • .github/scripts/risk_gate.py --repo ThinkFlowLab/agentdescent --pr 1224 → T3 (282 lines / 4 files; path agentdescent/evolution.py)
  • pytest -q tests/test_apply_blocked_leaf.py tests/test_apply_blocked_child.py tests/test_apply_blocked_parent.py 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 tests/test_skill_library_apply_install.py tests/test_demo_dest_link.py at this tip → 94 passed
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
  • python -m tools.changelog_fragments check → 22 changelog fragment(s) OK
  • Required CI at this tip → still running; --auto --squash armed
    Not run:
  • Full offline suite locally — the CI test matrix is the line
  • mkdocs build --strict — this host is offline (social fetches fonts.google.com); the diff only adds one sentence to docs/plugins.md, CI docs is the line
    Findings:
  • No actionable defects. After fix(cli): refuse a tree child blocked by a file before writing #1222, show --diff still advertised a tree leaf as written when that path was already a directory, the real apply exited 2 with cannot write <dest>: Is a directory, and apply --from nested the file at <leaf>/<leaf>. _check_apply_paths now also refuses a produced path that exists as a real directory, so the four surfaces agree on the blocking-directory sentence and the preview writes nothing. Existing fix(cli): show --diff advertises a written child that apply refuses (File exists) #1221 / fix(cli): refuse a destination blocked by a file before planning #1215 refusals and a sibling directory next to an unblocked plain/written.md are unchanged.
    Verdict: PASS

@github-actions github-actions Bot added risk:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller agent-pr Pull request opened by an agent labels Nov 22, 2026
@Birfy
Birfy enabled auto-merge (squash) November 22, 2026 22:31
@Birfy
Birfy merged commit 3759b54 into main Nov 22, 2026
12 checks passed
@Birfy
Birfy deleted the agent/1223-blocked-leaf branch November 22, 2026 22:57
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:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): a directory at a tree leaf is advertised as written, and apply --from writes inside it

1 participant