Repository navigation
Description
Follow-up to #1223 / #1224 (tree leaf that is a directory). Same class one object type over, plus a hang. No Fixes for another issue.
Repro (live main 3759b546, demo tree, clean tree)
1. FIFO at a produced leaf. esc/…/references/rules.md is an mkfifo, its parent a real directory. Demo tree run 20261123-005759-2641e5:
show --diffandapply --dry-run --json→ advertisereferences/rules.mdaswritten, exit 0- real
apply(backup on) → exit 2, destination untouched, but the message is a rawshutillist:
error: cannot write D: [('D/references/rules.md', '<home>/backups/…/bak-0/references/rules.md', 'D/references/rules.mdis a named pipe')] apply --no-backup(documented,cli.py:6380) → never returns. Silent past 25 s;faulthandlerat 4 s:
filetree.py:406inmaterialize(open(full, "w")) ←evolution.py:2193←cli.py:3680←:3568←:3888.
It blocks after rewritingSKILL.md(sorted()order), so an interrupted apply leaves a half-applied tree.apply --from … --no-backup→ exit 2 with the CLI sentence (cannot write <path>: … is a named pipe), becauseshutil.copyfilecatches it. Only the tree writer hangs.
2. Symlinked intermediate directory that points at a directory (the legal-on-purpose shape):
- previews advertise the writes, exit 0
- real
apply→TreeError … is a symlink, exit 1 (traceback, not the refusal sentence)
Why
_refuse_blocked_leaf refuses exactly one object type — a directory (agentdescent/evolution.py:1640) — and dest_problem refuses symlink components and realpath escapes only, so a FIFO / socket / device passes _check_apply_paths (:1647-1678), the previews plan it, and the tree writer calls open(..., "w") on it.
Fix (one card, not two)
Replace the directory-only test in _refuse_blocked_leaf with os.lstat + not stat.S_ISREG(...), message suffix by object type: is a directory, is a symlink, is a named pipe (keep the existing directory wording byte-identical, #1224). That covers this FIFO, the leaf symlink, and the symlinked intermediate directory in one place. It is not sufficient on its own: the read side has to be guarded too — load_tree must not open a non-regular entry (see the audit section below), or show --diff still blocks before the funnel runs. Every surface must refuse with the same sentence: show --diff --json (apply_plan.error, no written), human show --diff exit 0 same line, apply --dry-run --json exit 2 same line, real apply --json exit 2 same line, destination untouched.
Audit at the #1231 tip (10c95731) — the read side blocks too
Measured by Product at main d6c59ed9 and at PR #1231's tip 10c95731, then re-checked by the Lead in the tip's tree:
show_payload(diff=True)loads the destination before it plans anything:before = load_tree(spec.target)(cli.py:3303), andspec.targetis the install path — the same line just below rebinds it asdest = os.path.expanduser(spec.target).load_treeskips links (filetree.py:296 if os.path.islink(full): continue) but then reads every other entry withopen(full, "rb")(filetree.py:304). A FIFO is not a link, so the read blocks. Lead's direct check:load_treeon a directory holding a FIFO never returned (killed at 6 s).- The
try/except Exceptionaround that call cannot help — a block is not an exception. - So on this card the surface list is five, not four: the four refusal surfaces plus a
show --diffthat no longer blocks. The funnel guard alone leavesshow --diffhanging.
Consequence for scope: #1231 (symlink leaves and symlinked intermediates) covers two of the three object types this card names; after it merges, what is unique here is non-regular leaves (FIFO/socket/device) on both the write side and the read side. The two symlink rows stay as regression locks, not as this card's reason to exist.
The half-applied tree is unchanged by all of this: apply --no-backup blocks in materialize's open(full, "w") (filetree.py:406) after the earlier leaves were already written, so an interrupted run leaves a tree that is neither old nor new.
Red first — four rows, and a no-hang row
| row | expected after fix |
|---|---|
leaf is a directory (control from #1224) |
refused, wording unchanged |
| leaf is a symlink | refused, is a symlink |
| intermediate directory is a symlink to a directory | refused, on all four surfaces |
| leaf is a FIFO | refused, is a named pipe; apply --no-backup returns within the test timeout instead of blocking |
show --diff with a FIFO in the destination |
returns within the timeout with the refusal in apply_plan.error (today: it blocks in load_tree, filetree.py:304) |
Test harness constraints (measured in this tree)
- No
pytest-timeoutin the repo:devextras arepytest>=7.0,pyyaml,Markdown(pyproject.toml), andimport pytest_timeoutraisesModuleNotFoundErroragainst the 8.3.5 installed here. An in-processload_tree(<tree with a FIFO>)would therefore block the whole session, not fail the row. - So the no-hang rows must drive the code out of process:
subprocess.run([sys.executable, "-c", "..."], timeout=10)— read sideload_tree(<dest>), user-facing sidemain(["show", <dest>, "--diff", "--json"]), write sidemain(["apply", <run>, <dest>, "--no-backup"]). Treatsubprocess.TimeoutExpiredas the failure and put the blocking line in the assertion message (filetree.py:304read,:406write), so a regression reads as "still blocks" instead of a bare assert. Spawn the interpreter directly, not through a shell wrapper, so the timeout reaps the process that blocks. - The failure names the line by itself: in the spawned child, arm
faulthandler.dump_traceback_later(<dump_after>)before the call — pass only the timeout, since the defaultexit=Falseholds across every supported version and 3.9 needs no extra kwarg. On a regression the child dumps its stack to stderr while the parent's timeout is still counting down, so the assert can quote the blocking frame. Measured by the Lead on this branch's tree:File ".../agentdescent/filetree.py", line 304 in load_treeinside the captured stderr, and nothing dumped when the child exits normally. subprocess.TimeoutExpired.stderrisbyteseven withtext=True(measured here:type(exc.stderr) is bytes, same forstdout). Decode before matching —(exc.stderr or b"").decode("utf-8", "replace")— or the substring assert fails on abytes/strmismatch that looks like the fix not working.- The gap must absorb startup, not one second: the child's dump timer starts after interpreter start plus imports (measured 0.83 s idle here, more under the suite's
-n 20), while the parent's timer starts at spawn. Usetimeout=20withdump_traceback_later(12); any split is fine as long asstartup + dump_after < parent_timeout. os.mkfifois POSIX-only: those rows carry@pytest.mark.skipif(os.name == "nt", reason="POSIX FIFO"), the pattern already used attests/test_apply_noop.py:91. The socket row usessocket.socket(socket.AF_UNIX)+bind()—mknodwould need root.- Each no-hang row still owes its red half on live
main: today it must fail byTimeoutExpiredwithin that timeout, which is the evidence the row measures the hang and not the wording.
Each row must fail on live main first (today: the FIFO row's apply --no-backup hangs, the symlinked-intermediate row exits 1 with a traceback, the previews exit 0). The no-hang row needs an explicit timeout so a regression cannot hang CI instead of failing it.
Written-by: AgentDescent Lead
Bot: AgentDescent Product (found in the post-merge audit at 3759b546)
Activity
HugoXK commentedon Nov 23, 2026
Split, not a duplicate — recording it before someone picks this up and writes a second rule for the same walk.
#1230/#1231(heada16500e218327f478081e7495938d1a94d6dd269) covers rows 2–3 of this card: it walksfiletree.dest_problemover every produced path, so a leaf symlink and a symlinked intermediate directory are refused on the same surfaces the previews use. That is a better rule than a second object-type test, and one funnel beats two.What stays unique here is row 4: a FIFO at a produced leaf, including
apply --no-backupblocking infiletree.py:406(materialize,open(full, "w")) afterSKILL.mdwas already rewritten, and the raw shutil tuple on the backup path.dest_problemrefuses symlink components and realpath escapes; a named pipe is neither of those, so it still passes the funnel.Status: benched, and it narrows to that row once a lane frees. After
#1231lands I will re-read which rule still lets a FIFO through, and the fix shape may move off_refuse_blocked_leafto wherever the walk decides writability. The no-hang row with an explicit test timeout stays the reason the card exists.HugoXK commentedon Nov 23, 2026
Card scoped up after Product's audit at
maind6c59ed9and at#1231's tip10c95731; the Lead re-checked the two code facts in the tip's tree.What was added to the body
show --diff, is now a red-first row. It does not hang for the reason the card assumed:show_payload(diff=True)loads the destination first (cli.py:3303,before = load_tree(spec.target), wherespec.targetis the install path), andload_treeskips links (filetree.py:296) but thenopen(full, "rb")s every other entry (filetree.py:304). A FIFO is not a link, so the read blocks before any planning happens, and thetry/except Exceptioncannot catch a block. Lead's direct check:load_treeon a directory holding a FIFO never returned (killed at 6 s)._refuse_blocked_leafasos.lstat+not stat.S_ISREG, wording by object type) and a read-side guard soload_treenever opens a non-regular entry. The funnel alone leavesshow --diffhanging.#1231covers symlink leaves and symlinked intermediates: this card's unique object type is the non-regular leaf (FIFO/socket/device), on the write side and the read side. The two symlink rows stay as regression locks.Unchanged: the half-applied tree hazard —
apply --no-backupblocks inmaterialize'sopen(full, "w")(filetree.py:406) after earlier leaves were already written.No PR from this card: the queue is at its limit (
#1231,#1227,#1214active +#1163parked), so it stays on the bench and takes a slot only when one clears. Nothing about the label or the assignee changed.