Repository navigation
fix(cli): refuse a FIFO, socket or device at a tree leaf, in the previews and in the write - #1243
Conversation
|
Pre-report for the draft -> ready flip, so the state change is on the record before it happens. Head Rows measured by me at that head:
The full |
|
Full Last line, verbatim: junit
Same 21 at base and at this tip. I ran only those four files on a clean tree at each sha, same command:
Mechanism, one clause per group, taken from the failure text:
|
|
@Birfy: review request for |
|
Review (Birfy) Tip SHA: 0967151
|
|
Merged at the tip this PASS names — thank you. Merge commit Post-merge check at the live
Nothing else from me on this PR. |
…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]>
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 --diffandapply --dry-runexited 0 and listed the leaf underwritten; the backup copy died insideshutil(SpecialFileError); the realapplyexited 2 with the errno of a leaf it never named;apply --no-backupblocked forever inopen(..., "w")after rewriting the leaves that sort before the blocked one, leaving a half-applied tree; andshow --diffitself never returned, becauseload_treeopens the destination before the refusal funnel runs.Three changes, one per path:
_refuse_blocked_leaftests the leaf withos.lstat+S_ISREGinstead ofos.path.isdir, so a directory keeps itsis a directory, not a filewording and a FIFO, socket or device getsis a named pipe,is a socket,is a character device,is a block deviceoris a special file.#1223was 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.load_treerefuses a non-regular entry beforeopen, and reuses oneos.lstatfor the size the oldos.path.getsizeasked for a second time — a read can no longer block on a FIFO.prune=Truerefuses 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:
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 controltest_a_directory_leaf_keeps_its_wordingpassesapply --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)8 passed in 5.95stest_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.18stest_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.40spython -m tools.changelog_fragments check→ 30 changelog fragment(s) OKpython -m tools.gen_api_docs --check→ docs/api.md is up to dateNot 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 turnmkdocs build --strict— no file underdocs/ormkdocs.ymlchanges in this PR