Skip to content

fix(cli): refuse a FIFO, socket or device at a tree leaf, in the previews and in the write - #1243

Merged
Birfy merged 2 commits into
mainfrom
agent/1225-non-regular-leaf
Nov 24, 2026
Merged

Birfy merged 2 commits into
mainfrom
agent/1225-non-regular-leaf

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1225

What changed

A tree leaf that is not a regular file is now refused by both previews and by the write, with one sentence naming the object, instead of being advertised as written.

Before, on a tree run whose destination holds a FIFO, a socket or a device at a leaf: show --diff and apply --dry-run exited 0 and listed the leaf under written; the backup copy died inside shutil (SpecialFileError); the real apply exited 2 with the errno of a leaf it never named; apply --no-backup blocked forever in open(..., "w") after rewriting the leaves that sort before the blocked one, leaving a half-applied tree; and show --diff itself never returned, because load_tree opens the destination before the refusal funnel runs.

Three changes, one per path:

  • write side: _refuse_blocked_leaf tests the leaf with os.lstat + S_ISREG instead of os.path.isdir, so a directory keeps its is a directory, not a file wording and a FIFO, socket or device gets is a named pipe, is a socket, is a character device, is a block device or is a special file. #1223 was this test one object type over; #1231's two link shapes are checked before it and the helper skips a symlink, so its sentence cannot pre-empt that rule.
  • read side: load_tree refuses a non-regular entry before open, and reuses one os.lstat for the size the old os.path.getsize asked for a second time — a read can no longer block on a FIFO.
  • prune: prune=True refuses a stray FIFO it did not evolve instead of deleting it through the backup copy.

A directory leaf (#1223) and a symlinked leaf (#1231) keep their existing sentences; both are pinned by control rows. No model or network call. Non-goal: a hardlink at a leaf, which stays out of this slice.

Verification at the tip

Tip SHA: 0967151
Ran:

  • red first at the live main b4647375985709fc1fc37df2374ee3c4cb0b646c (this PR's merge base), clean tree with this PR's test file only (sha1 53431d2f, byte-identical to the tip's copy): 7 failed, 1 passed in 63.93s — test_a_fifo_leaf_is_named_by_the_dry_run, test_a_fifo_leaf_is_named_by_the_real_apply, test_a_fifo_leaf_is_named_by_show_diff, test_human_show_diff_is_named_and_does_not_block, test_a_fifo_leaf_does_not_hang_apply_no_backup, test_prune_refuses_to_delete_a_fifo_it_did_not_evolve, test_a_socket_leaf_is_refused; the control test_a_directory_leaf_keeps_its_wording passes
  • the three blocking rows at that base fail as a child killed at its own ceiling, not as a refusal: apply --no-backup blocked: timeout 20 killed the child (rc=124), show --diff --json blocked: timeout 20 killed the child (rc=124), show --diff blocked: timeout 20 killed the child (rc=124)
  • at the tip, new file: 8 passed in 5.95s
  • apply/write family (test_apply_noop.py, test_apply_symlink_dest.py, test_apply_blocked_parent.py, test_apply_blocked_child.py, test_apply_blocked_leaf.py, test_apply_refusal_walk.py, test_apply_from.py, test_apply_backup_away_from_skills.py, test_skill_library_apply_install.py, test_filetree.py, this file): 106 passed in 27.18s
  • test_apply_backup_blocked.py (the suite merged in fix(cli): refuse a blocked backup root on every apply surface #1227, unchanged here): 5 passed in 5.40s
  • python -m tools.changelog_fragments check → 30 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
    Not run:
  • pytest -q — the full suite runs in the background at this tip; the conclusion is posted on this PR rather than waited on in the authoring turn
  • mkdocs build --strict — no file under docs/ or mkdocs.yml changes in this PR

@HugoXK HugoXK added area:cli The agentdescent command line (cli.py, doctor, plan/evolve/status/apply) bug Something isn't working labels Nov 23, 2026
@HugoXK

HugoXK commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Pre-report for the draft -> ready flip, so the state change is on the record before it happens.

Head 0967151c70b1bad2a1eb40b831d13a927942dbb3, rebased onto live main b4647375985709fc1fc37df2374ee3c4cb0b646c (the rebase applied with no conflict: #1227's backup-slot insertion in _check_apply_paths and this branch's _refuse_blocked_leaf rewrite sit in different hunks, and the funnel body is diff-identical to main).

Rows measured by me at that head:

  • red first at b4647375985709fc1fc37df2374ee3c4cb0b646c, clean tree with this PR's test file only: 7 failed, 1 passed in 63.93s; the three blocking rows each die at their own timeout 20 ceiling (rc=124)
  • new file at the tip: 8 passed in 5.95s
  • apply/write family (11 files, listed in the body): 106 passed in 27.18s
  • test_apply_backup_blocked.py: 5 passed in 5.40s
  • python -m tools.gen_api_docs --check -> docs/api.md is up to date
  • python -m tools.changelog_fragments check -> 30 changelog fragment(s) OK

The full pytest -q at this head is running in the background with junit; its conclusion will be posted here as a comment rather than waited on in this turn.

@HugoXK
HugoXK marked this pull request as ready for review November 23, 2026 22:39
@github-actions github-actions Bot added risk:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller agent-pr Pull request opened by an agent labels Nov 23, 2026
@HugoXK

HugoXK commented Nov 23, 2026

Copy link
Copy Markdown
Collaborator Author

Full pytest -q at the ready tip 0967151c70b1bad2a1eb40b831d13a927942dbb3 finished; this is the conclusion the body defers to.

Last line, verbatim:

21 failed, 8059 passed, 51 skipped, 527 warnings in 2501.29s (0:41:41)

junit runs/20261123-1631-rebase/B-1225/junit-0967151.xml (1,077,475 bytes): tests=8131 failures=21 errors=0 skipped=51. The 21 are four files, none of them touched by this PR:

  • tests/test_sandbox_container.py — 12 (11 [docker], 1 plain)
  • tests/test_era_srbench.py — 6
  • tests/test_genesis_example.py — 2
  • tests/test_wheel_smoke.py — 1 (test_wheel_smoke_removes_inherited_python_overrides)

Same 21 at base and at this tip. I ran only those four files on a clean tree at each sha, same command:

pytest tests/test_sandbox_container.py tests/test_era_srbench.py tests/test_genesis_example.py tests/test_wheel_smoke.py -o addopts="" -q
  • b4647375985709fc1fc37df2374ee3c4cb0b646c: 21 failed, 285 passed, 13 skipped in 468.00s
  • 0967151c70b1bad2a1eb40b831d13a927942dbb3: 21 failed, 285 passed, 13 skipped in 492.44s
  • the two FAILED id lists are set-identical (diff empty)

Mechanism, one clause per group, taken from the failure text:

  • sandbox container rows: EngineError: docker run --detach failed (125): Unable to find image 'python:3.11-slim' locally — the daemon has no egress to registry-1.docker.io (dial tcp …:443: i/o timeout), so no row can start a container
  • test_era_srbench.py: assert valid, error with error == "MemoryError: " from the Bubblewrap-sandboxed evaluator, i.e. the sandboxed child dies before scoring
  • test_genesis_example.py: toolchain_root('claude') returns /usr/lib/node_modules/@anthropic-ai/claude-code on this host, and the other row gets EngineError: the workspace … did not appear inside the container
  • test_wheel_smoke.py: mktemp: failed to create directory via template '/home/xuke/work/tmp/dsh/tmp.XXXXXXXXX': Read-only file system

tests/test_sandbox_container.py, tests/test_era_srbench.py, tests/test_genesis_example.py and tests/test_wheel_smoke.py touch none of agentdescent/evolution.py, agentdescent/filetree.py, tests/test_apply_non_regular_leaf.py, or the FIFO/socket/device leaf path; this PR's own rows and the apply/write family are the runs listed in the body. The full suite is not green on this host and this comment does not claim it is.

@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

@Birfy: review request for #1243 at tip 0967151c70b1bad2a1eb40b831d13a927942dbb3 (base b4647375).

@Birfy

Birfy commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator

Review (Birfy)

Tip SHA: 0967151
Ran:

  • .github/scripts/risk_gate.py --repo ThinkFlowLab/agentdescent --pr 1243 → T3 (path agentdescent/evolution.py; 367 lines / 4 files)
  • pytest -q -o addopts='' tests/test_apply_non_regular_leaf.py at this tip → 8 passed
  • python -m tools.changelog_fragments check → 30 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
  • Required CI at this tip (build, test 3.9–3.13) → SUCCESS
    Not run:
  • Full offline suite locally — the CI test matrix is the line
    Findings:
  • No actionable defects. _refuse_blocked_leaf now refuses any non-regular, non-symlink leaf (FIFO, socket, device) with a sentence that names the kind, and load_tree refuses the same before open so show --diff cannot block on a FIFO. A directory leaf keeps the fix(cli): refuse a tree leaf that is already a directory #1224 wording. Symlinks stay _refuse_link_in_dest's job.
    Verdict: PASS

@Birfy
Birfy merged commit de3624f into main Nov 24, 2026
15 of 16 checks passed
@Birfy
Birfy deleted the agent/1225-non-regular-leaf branch November 24, 2026 04:33
@HugoXK

HugoXK commented Nov 24, 2026

Copy link
Copy Markdown
Collaborator Author

Merged at the tip this PASS names — thank you.

Merge commit de3624fab6dfa53e08a057a1a370031f991f3b8d; main is now eb9acd5e8e417241cec2a60517c7f89272b0d5be (#1244 landed on top). #1225 closed as completed (2026-11-24T04:33:04Z).

Post-merge check at the live main (eb9acd5e, fresh clone, clean tree):

  • pytest -q -o addopts='' tests/test_apply_non_regular_leaf.py -> 8 passed in 5.20s
  • apply/write family, 12 files (the 11 named in the body plus test_apply_backup_blocked.py) -> 111 passed in 23.98s
  • python -m tools.changelog_fragments check -> 31 changelog fragment(s) OK
  • python -m tools.gen_api_docs --check -> docs/api.md is up to date

Nothing else from me on this PR.

Birfy pushed a commit that referenced this pull request Nov 24, 2026
…1239) (#1250)

Closes #1239.

## What changed

Four files, docs plus the test that pins them:

- `docs/bench-index.md` (new) — one table for the sixteen `bench/*.py`
modules
that carry `if __name__ == "__main__"`, split into the eight that run
offline
and the eight that make live model calls. Every row gives what the
module
measures, its command, and the committed artefact under `bench/results/`
when
  one exists (`—` where the module writes a file you name yourself).
- The split is by what a run actually needs, and the key-gated rows name
the
key rather than gesturing at one: `--provider openai` and `--provider
glm`
read **`OPENAI_API_KEY`**, `--provider claude` reads
**`ANTHROPIC_API_KEY`**
(`agentdescent/agents.py:737`), and the `metasearch_*` pair is offline
under
`--dry-run`, so it needs no key at all. That distinction is the part a
reader
  acts on, so it is in the page and repeated in the PR body.
- `mkdocs.yml` — one nav line, `Benchmarks you can run — the index:
bench-index.md`, inside **Examples and results**, immediately above the
two
  bench pages it indexes.
- `tests/test_bench_index.py` (new) — the page ↔ tree pin: the set of
`bench/*.py` with a top-level `if __name__ == "__main__"` (read from the
AST,
  not by grepping) must equal the set of modules the page gives a
  `python -m bench.<module>` command for, checked in both directions.
- `changelog.d/1239-bench-index.md` — category `Added`.

Nothing else moved: no `bench/` change, no `agentdescent/` change, no
results
file, no page besides the new one.

## Red first

The new test is red on today's tree by construction, since the page does
not
exist. Measured at this PR's base `b4647375` in a fresh worktree with
only the new
test file copied in:

```
$ pytest tests/test_bench_index.py
FAILED tests/test_bench_index.py::test_index_page_exists
FAILED tests/test_bench_index.py::test_every_runnable_bench_module_has_a_row
E  AssertionError: bench modules with a __main__ block but no row in docs/bench-index.md:
   ['ab_allocator', 'ab_replay', 'ab_run', 'baselines_run', 'candidate_methods',
    'candidate_methods_merge', 'candidate_methods_report', 'long_horizon',
    'matrix_report', 'matrix_run', 'metasearch_algotune', 'metasearch_slots',
    'openevolve_agentdescent', 'population_engine', 'run', 'self_evolution'].
   Add a row (what it measures, command, offline or key-gated, evidence file) in
   the same change as the module.
2 failed, 1 passed in 3.54s
```

With the page in place: `3 passed in 0.50s`.

## Acceptance loop

Sixteen `--help` invocations, no `FAIL` line:

```
$ for m in ab_allocator ab_replay ab_run baselines_run candidate_methods \
           candidate_methods_merge candidate_methods_report long_horizon \
           matrix_report matrix_run metasearch_algotune metasearch_slots \
           openevolve_agentdescent population_engine run self_evolution; do
    python3 -m bench.$m --help >/dev/null 2>&1 || echo FAIL $m
  done
(no output — every module exits 0)
```

`bench/` is byte-identical between `d6c59ed9` and this PR's base
`b4647375`
(`git diff --stat d6c59ed b464737 -- bench/` is empty), so the sixteen
`--help` reads and the flag check below were re-run once and still hold
at the
base.

That loop needs two environment facts, both written into the page and
both
reproduced here rather than hidden:

- `HOME` must be writable. `agentdescent/dataloader.py:40` hardcodes
  `~/.cache/agentdescent`, so on a box with a read-only `$HOME` the two
  `candidate_methods*` modules die at import with
`OSError: [Errno 30] Read-only file system:
'/home/xuke/.cache/agentdescent'`.
  The loop above ran with `HOME` pointed at a scratch directory.
- `bench/candidate_methods.py` and `bench/candidate_methods_merge.py`
build
  their algorithm registry at import time from the GSM8K splits, so even
`--help` loads the dataset. With no network and no `pyarrow` the
loader's own
message names the way out: `AGENTDESCENT_GSM8K_SAMPLE=1` (bundled 96-row
sample). The loop ran with it set; the other fourteen modules are
unaffected
  by it.

## Other gates

- Every flag on the page exists in the module's own `--help`: the
sixteen rows
  were extracted from the Markdown and each `--flag` compared against
  `python3 -m bench.<module> --help` — `16 rows, 0 missing flags`.
- `python3 -m tools.changelog_fragments check` → `30 changelog
fragment(s) OK`
- `python3 -m tools.gen_api_docs --check` → `docs/api.md is up to date`
- `pytest tests/test_site_navigation.py tests/test_bench_index.py` → `6
passed`

Tip SHA: `1f1d7db701740643a25fea6837084bf5f5fadacc`

Not run:

- `mkdocs build --strict` — this box has no `mkdocs` and no network to
install
  it (`pip download mkdocs` produces no wheel; `import mkdocs` raises
`ModuleNotFoundError`), so the strict build cannot be produced locally.
The
  nav change is covered by `tests/test_site_navigation.py` (reads
`mkdocs.yml` and passes) and by the required `build` check in CI, which
runs
  the same strict build on the tip.

One correction to the card's measurement, no action needed: `bench/`
holds
**19** `.py` files at `b4647375`, not 20 — the sixteen with `__main__`
plus
`harness.py`, `rsi_bench.py` and `__init__.py`. The sixteen-module list
in the
card is exactly right and is what the test and the page carry; the test
derives
the set from the tree either way, so the count in prose cannot rot.


## Forward-merge to the live main

`#1243` (`de3624fab6df`) and `#1244` (`eb9acd5e8e41`) landed, so this
branch was
forward-merged with `git merge origin/main` (no rebase, no force-push)
onto
`eb9acd5e8e417241cec2a60517c7f89272b0d5be`. Nothing in this PR
conflicted and no
file of this PR changed: the merge brought `agentdescent/`,
`tests/test_apply_non_regular_leaf.py`,
`tests/test_mcp_ticket_remainder_label.py` and two changelog fragments.

Re-measured at the merge head
`ab75f2e8062ca3bb8c70d91faded244b222df850`:

- `pytest tests/test_bench_index.py tests/test_site_navigation.py` → `6
passed in 0.68s`
- sixteen-module `--help` loop (`HOME` writable,
  `AGENTDESCENT_GSM8K_SAMPLE=1`) → `fails=0`
- page ↔ help flag check → `16 rows, 0 missing flags`
- `python3 -m tools.changelog_fragments check` → `32 changelog
fragment(s) OK`
  (30 at the old base, plus `changelog.d/1225-non-regular-leaf.md` and
  `changelog.d/1241-ticket-remainder-label.md` from the merge)
- `python3 -m tools.gen_api_docs --check` → `docs/api.md is up to date`

The red-first block above was measured at the old base `b4647375` and
stays as
that record; `docs/bench-index.md` and `tests/test_bench_index.py` are
byte-identical before and after the merge.

Citation fix at `1f1d7db701740643a25fea6837084bf5f5fadacc`: the `claude`
key
now cites `agentdescent/agents.py:737`, not `agentdescent/backends.py`,
which
never names that provider. Re-measured at that head: `6 passed in
0.85s`,
`16 rows, 0 missing flags`.

ready at ab75f2e (flip: ready_for_review 2026-11-24T04:43:26Z)

## Correction (appended; branch updated to main)

- Live tip: `aac952f73ef923f02eda0b0f1b2b395a3ab1ac47`
- Base: `22ea7528915a761c579dc4c7f47d8444c159cd8a`
- The merge commit only moved the base onto `main`; the diff is
unchanged
  (`4 files, +156/−0`). It supersedes `1f1d7db7…` as the tip this PR is
  judged at; the `Tip SHA:` line above is left as written.

---------

Co-authored-by: AgentDescent Dev-4 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agent-pr Pull request opened by an agent area:cli The agentdescent command line (cli.py, doctor, plan/evolve/status/apply) bug Something isn't working risk:T3 Risk tier T3 (core loop, release, process; needs Danyang's click), set by the controller

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): a FIFO or symlinked leaf passes the previews and hangs apply --no-backup

2 participants