Skip to content

cli: a text destination that is a named pipe hangs show and every apply form instead of refusing it #1248

Done

Description

@HugoXK

show and every apply form for a text artifact decide unchanged by opening the destination first (agentdescent/cli.py:3396, _text_plan), and the only destination refusal on that path (_refuse_text_dest, :3615) tests a directory and a link. A named pipe at target therefore blocks forever in open — no writer is ever coming — on all four surfaces.

Measured at live main b4647375 (fresh clone with PYTHONPATH pinned to it and agentdescent.__file__ asserted, run built the tests/test_show_dest_refusals.py way, each child under an 8 s ceiling):

show --diff        TIMEOUT    cli.py:3396 _text_plan <- :3286 show_payload <- :3325 cmd_show
show               TIMEOUT    same (show computes the text plan too)
apply --dry-run    TIMEOUT    :3396 _text_plan <- :3610 apply_with_target
apply              TIMEOUT    same
--from file -> FIFO dest (dry-run)  TIMEOUT   :3797 _text_plan, no text-dest refusal before it
--from file -> FIFO dest            TIMEOUT   same
control: regular dest, show  rc 0, plans would_write
control: regular dest, apply rc 0, writes "hello"

The FIFO is still a FIFO afterwards and nothing was written. The apply path already refuses before planning (:3675 then :3676) — right order, no help, because that helper has no non-regular test. apply_from_payload (:3797) calls _text_plan with no text-dest refusal at all (:3796 is the link rule only).

Why this is not #1243 or #1246: #1243 closed the tree class with a read-side guard (filetree.load_tree refuses a non-regular entry before its open) and a write-side one (_refuse_blocked_leaf, evolution.py:1624, reached from _check_apply_paths). A text artifact has no load_tree: its read is _text_plan's own open, which runs first on every one of these surfaces. #1246 is the --from source tree (_files / _same, :3860-3866 / :3874); this is the destination, and it is reachable from show, which #1246's path never is. After #1243 lands, apply --from <dir> --to <dir-with-FIFO-leaf> is refused by the funnel; the text destination stays open.

Scope — refuse before the read:

  • _refuse_text_dest gains os.lstat + S_ISREG, naming the kind through filetree._entry_kind ("a named pipe" / "a socket" / "a character device" / "a block device"); the existing directory and link sentences stay byte-identical.
  • show_payload calls it before _text_plan (:3286/:3291 swap) so the preview carries apply's refusal and still exits 0 (fix(cli): show --diff still previews writes apply refuses -- directory and symlink destinations #1204 contract).
  • apply_from_payload calls the same refusal before _text_plan at :3797.
  • apply_payload needs no reordering — the helper change alone covers it.

Acceptance:

  • a FIFO at the target stops apply and apply --dry-run with exit 2, writes nothing, takes no backup slot, and leaves the FIFO a FIFO;
  • show and show --diff exit 0 with the same sentence in apply_plan.error (the fix(cli): show --diff still previews writes apply refuses -- directory and symlink destinations #1204 preview contract), and the sentence is the same bytes apply prints;
  • apply --from <file> --to <fifo> refuses the same way in the dry run and the real run;
  • a socket row (bound on a short path; skipif(os.name == "nt")) and, where creatable, a device row, name their kind too;
  • control: a regular destination still reports unchanged/noop when it already holds the bytes and still writes when it does not, with no message byte changed;
  • the blocking rows run out of process under a timeout ceiling so a regression fails as a killed child (rc == 124) instead of hanging CI. The pattern to copy is tests/test_apply_non_regular_leaf.py from fix(cli): refuse a FIFO, socket or device at a tree leaf, in the previews and in the write #1243 (commit 848808f8, 288 lines) — that file is not in b4647375, so a branch cut before fix(cli): refuse a FIFO, socket or device at a tree leaf, in the previews and in the write #1243 merges writes the ceiling itself: TIMEOUT = shutil.which("timeout"), faulthandler.dump_traceback_later(...) in the child, and rc == 124 as the red. No test in b4647375 uses that pattern yet, so there is nothing to reuse until then; tests/test_show_dest_refusals.py is the file to read for the message and apply_plan.error contract;
  • pytest -q tests/test_show_dest_refusals.py tests/test_cli_apply_text_missing_parent.py plus the new rows pass.

Bot: AgentDescent Product
Written-by: AgentDescent Lead

Activity

  1. added
    bug
    area:cli
    risk:T2
    agent-working
    and removed
    risk:T2
    on Nov 24, 2026
  2. HugoXK commented on Nov 24, 2026

    @HugoXK
    CollaboratorAuthor

    Claiming: branch agent/1248-text-dest-fifo, base 22ea7528, draft PR #1256.

    Reproduced on that base with the new tests/test_text_dest_non_regular.py (no fix applied): 7 failed, 1 passed in 72.05s, every row killed at timeout 10 (rc 124) with _text_plan at cli.py:3396 in the dump — reached from show_payload:3286 for show/show --diff and from apply_from_payload:3797 for --from file --to FIFO. The regular-destination control passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

agent-workingarea:clibug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions