Skip to content

cli: apply --from blocks on a non-regular entry in the source tree instead of refusing it #1246

Done

Description

@HugoXK

apply --from <dir> classifies the source tree with _files() (agentdescent/cli.py:3860-3866), which refuses symlinks and nothing else: a FIFO or socket in the source is returned as a planned file. The comparison then opens it:

3882    unchanged = [rel for rel in planned
3883                 if _same(os.path.join(src, rel), os.path.join(dest, rel))]
...
3874        with open(a_path, "rb") as fa, open(b_path, "rb") as fb:

a_path is the source path, so open() on a FIFO with no writer blocks forever, before the funnel even runs (_check_apply_paths is called on the dest side, :3898). Measured with a FIFO at src/lib/references/rules.md and a regular file at the same rel in dest: rc=124 under a 15 s child ceiling, identical at base b4647375 and at #1243's tip 0967151c — this is not a regression from #1243, it is the same class of defect one surface over: a hang where a refusal belongs, and the sentence '<path>' is a named pipe already exists for every other surface.

Scope: treat a non-regular source entry as a refusal on this surface — either in _files (alongside the symlink rule, so the message names the entry and the reason) or in _same before either open. No behaviour change for regular files; the symlink refusal sentence stays as it is.

Acceptance:

  • a FIFO in the source tree stops apply --from with a named refusal naming '<rel>' is a named pipe, exit 2, in the dry run and the real run alike, with no backup slot taken;
  • the same for a socket and (where it can be created) a device;
  • --from over two regular trees is byte-for-byte unchanged (the existing --from rows stay green);
  • no unbounded open() on a source path survives: the only paths that reach open are regular files by lstat.

Separate, smaller item found in the same read, not in scope here: a non-regular entry in dest that is not among written/deleted (a stray FIFO) passes the preview (exit 0, no error key) and then dies in the backup copy with a raw shutil tuple list (cannot write <slot>: [('<slot>/stray', …, 'is a named pipe')]), leaving the same half-applied shape #1225 removed elsewhere. Recorded in our ledger; it wants its own card.

Bot: AgentDescent Reviewer
Written-by: AgentDescent Lead

Activity

  1. added
    bug
    area:cli
    risk:T2
    on Nov 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:clibugrisk:T2

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions