Repository navigation
Description
Implementation: AgentDescent (ours) — draft PR #1215 opened in this session; do not pick up.
Problem
#1204 closed the gap where show --diff advertised writes apply refuses. This is the next case past it, and it is not a #1204 regression: here apply does not refuse the destination, it fails while creating the parent.
Measured at 1aa816e0 (allowlist unset, blocker a regular file):
- text artifact,
--to <tmp>/blocker/rule.md:show --diff --jsonexits 0 withapply_plancarryingwould_write/writtenand noerror;apply --dry-runsays the same; the realapplyexits 2 withcannot write <dest>: File exists. Nothing is written, and the message names the destination — but the file it collides with is the parent, not the destination. - tree artifact rooted at
<tmp>/blocker/lib:showprintswritten: [alpha/SKILL.md, beta/SKILL.md];applyexits 2 withcannot write <root>: Not a directory. apply --from <file> --to <blocked>: exit 2, the sameFile exists.- control, missing parent with no blocker (
<tmp>/newdir/rule.md):show0,apply0, the file is written —#1125is intact.
Mechanism
- The parent is only materialised after the planning path returns: text write
cli.py:3616-3621,--from:3727-3732, the tree inside_write_to→materialize(wrapped at:3641). Every plan, including--dry-run, therefore never touches it. _cannot_write(cli.py:125) renders<dest>: <strerror>, soFile existsis the parent's errno printed against a destination that never existed.
Fix shape
One refusal, placed where every surface already passes through:
_refuse_blocked_parent(dest): walk up to the nearest existing ancestor; when it is not a directory, raise the ordinary run-store error withcannot write <dest>: '<ancestor>' is a file, not a directory— the actionable halfFile existsdoes not give.- Call it at the top of
_check_apply_paths(evolution.py:1582), before thecheck_write is not Noneguard, so it runs with the operator allowlist unset. That funnel is the one call site used byshowtext (cli.py:3117),applytext (:3593),--from(:3714),--install-to(:3812) and the tree path (evolution.py:2107) — soshow,--dry-runand the real write agree by construction instead of by three parallel checks. - Order: after the destination refusals (
_refuse_text_dest,_refuse_dest_link), whose messages must not change. Blocked-parent is the last destination check.
Acceptance
- All three shapes above:
show --diff/--jsonandapply --dry-runcarry anerrorequal to the realapply's message (not a hard-coded copy). - The message names the blocking ancestor, not only the destination.
- Control: a missing parent with no blocker still writes (
#1125behaviour unchanged), and the blocker file is untouched. - This intentionally changes
apply's message for this case (File exists→ the named ancestor);#1204's "message bytes unchanged" rule does not apply here, and the test must assert the new text. - Red-first at
1aa816e0: three new rows fail before the change. -
changelog.d/Fixedfragment; focused apply/show tests,tools.gen_api_docs --check,tools.changelog_fragments checkgreen.
Scope
agentdescent/evolution.py (_refuse_blocked_parent + one call at the top of _check_apply_paths), one test file, one changelog fragment. No cli.py change expected; no behaviour change for an existing destination or a creatable parent. T2.
Lineage: #1124 (missing parent dies at open) → #1125 (a fresh --to creates its parent) → this (a parent that is a file must be refused before anything is planned).
Activity
HugoXK commentedon Nov 21, 2026
Branch
agent/1208-blocked-parentat9911610a32bd10259c8a6eb8f8bca327d4666687, based on1aa816e0e155c2f59db1686e404a7ebae739d94b.One
_refuse_blocked_parentat the top of_check_apply_paths, two commits (test, then fix +Fixedfragment). Red at base:4 failed, 1 passed; green at tip:5 passed. PR follows.