Repository navigation
Conversation
6 tasks
At 1aa816e the three shapes exit 0 from show --diff and apply --dry-run, then exit 2 from the real apply with "cannot write <dest>: File exists" -- the parent's errno printed against a destination that never existed. Each row takes show's error, apply --dry-run's error and apply's error and requires them to be equal, so a preview that hard-codes a message apply does not produce fails too. The deep-parent row (blocker/a/b/rule.md) pins the walk-up to the nearest existing ancestor; the control row keeps #1125 (a missing parent with no blocker still writes). Red at 1aa816e: 4 failed, 1 passed in 2.79s.
apply materialises a missing parent only after the plan is returned, so show and --dry-run never reached the failing step. _check_apply_paths is the one funnel they all use, so the refusal lives at its top: walk up to the nearest existing ancestor and, when it is not a directory, raise "cannot write <dest>: '<ancestor>' is a file, not a directory" before the allowlist guard. This intentionally changes apply's message for this case; #1204's "message bytes unchanged" rule covers the destination refusals only. A missing parent with no blocker still writes (#1125), and the changelog fragment records the preview change.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #1208.
What changed
show --diffandapply --dry-runused to advertise a write whose nearest existing parent is a regular file, and the realapplyonly failed at the moment it created that parent:--to <tmp>/blocker/rule.md(withblockera file):show/--dry-runreturned the plan, the write exited 2 withcannot write <dest>: File exists— the parent's errno printed against a destination that never existed;Not a directoryatmaterialize;apply --from <file> --to <blocked>: same shape.One refusal now sits at the funnel every surface already uses:
_refuse_blocked_parent(dest)walks up to the nearest existing ancestor (os.path.lexists, so a deep<blocker>/a/b/rule.mdfails like<blocker>/rule.md) and raisescannot write <dest>: '<ancestor>' is a file, not a directory._check_apply_paths(evolution.py:1582), before thecheck_write is not Noneguard: the blocked parent is a filesystem property, not a question of who is writing, so the preview sees it with the operator allowlist unset — that guard is exactly what hid it before.showtext (cli.py:3117),applytext (:3593),--from(:3714),--install-to(:3812), tree writer (evolution.py:2107). One call site meansshow,--dry-runand the real write agree by construction, not by three parallel checks.This intentionally changes
apply's message for this case (File exists→ the named ancestor):File existsnamed a destination that never existed. The#1204"message bytes unchanged" rule is about the refusal half and does not apply here.#1125is intact: a missing parent with no blocker is still created and the file written.Verification at the tip
Tip SHA:
9911610a32bd10259c8a6eb8f8bca327d4666687Ran:
pytest -q -o addopts='' tests/test_apply_blocked_parent.py→5 passedpytest -q -o addopts='' tests/test_show_dest_refusals.py tests/test_write_dirs_apply_show.py(the#1204/#1188rows, unchanged) →7 passed1aa816e0→4 failed, 1 passed(the passer is the missing-parent control)python -m tools.gen_api_docs --check→docs/api.md is up to datepython -m tools.changelog_fragments check→15 changelog fragment(s) OKNot run:
pytest -q— the CI matrix is the linemkdocs build --strict— this diff changes nodocs/page and nomkdocs.ymlScope
agentdescent/evolution.py(one helper plus its call in_check_apply_paths), one test file, one changelog fragment. Nocli.pychange; existing destination and creatable-parent behaviour unchanged. T2.