Skip to content

fix(bench): list the candidate methods without building every port - #1279

Draft
HugoXK wants to merge 3 commits into
mainfrom
agent/1260-bench-import-cost
Draft

HugoXK wants to merge 3 commits into
mainfrom
agent/1260-bench-import-cost

Conversation

@HugoXK

@HugoXK HugoXK commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1260.

What changed

python -m bench.candidate_methods --help describes a table of fourteen ports, but importing the module built every port just to learn its name and its reserved proposal-call count: module.build(0).name at bench/candidate_methods.py:68 (base) and builder(0).proposal_calls_per_candidate at :72. build() loads a dataset, so --help needed a writable cache — OSError: [Errno 30] Read-only file system on a read-only ~/.cache, and on an empty one a GSM8K download — before it could print usage:.

After: each port publishes NAME and PROPOSAL_CALLS beside the FIDELITY it already publishes (examples/godel_agent/godel_agent_self_modify.py:31, examples/voyager/voyager_skill_library.py:45), and bench/candidate_methods.py:67-74 reads those constants instead of calling build. The port is the only place that knows its own identity, so that metadata belongs with it; a lookup table in bench/ would duplicate fourteen names and go stale when the next port lands. build(seed) keeps its signature and stays the only path that loads data. ALGORITHMS is complete immediately after import, and the names, fidelity strings, proposal-call counts, CLI flags and port order are unchanged — the new test pins all fourteen pairs and every count, so a lazily-built table cannot quietly drop a port.

Diff: 17 files, +277/-31 — fourteen examples/*/ ports at +7/-2 each, bench/candidate_methods.py +6/-3, tests/test_bench_import_cost.py +167/-0, changelog.d/1260-bench-import-cost.md +6/-0.

--help output is byte-identical between base and tip: 2640 bytes for the matrix, 450 for candidate_methods_merge. Both sides were run with AGENTDESCENT_GSM8K_SAMPLE=1 and AGENTDESCENT_GSMHARD_SAMPLE=1 over an unwritable cache root (AGENTDESCENT_CACHE=/proc), because the base builds every port at import, GSM8K and GSM-HARD alike, before it can print anything: the GSM8K switch gets past the ports that read GSM8K, and reflexion, sica and godel_agent need the GSM-HARD one as well, since their build(0) reaches cache_path("gsmhard", …) at examples/_gsmhard_domain.py:174. The switches are what keep that import off the cache, so every /proc row states them: with no sample switch the base dies on the first port, promptbreeder's gsm8k_splits, with FileNotFoundError: [Errno 2] No such file or directory: '/proc/gsm8k' (examples/_gsm8k_domain.py:201); with AGENTDESCENT_GSM8K_SAMPLE=1 alone it gets past those ports and dies in reflexion's gsmhard_splits with FileNotFoundError: [Errno 2] No such file or directory: '/proc/gsmhard' (examples/_gsmhard_domain.py:174); with both it exits 0 and prints 2640 and 450 bytes. The tip needs no switch at all: it prints the same 2640 and 450 bytes, byte-identical to the base-with-both output, and exits 0.

Non-goal: no change to build(), to any dataset path, or to what a run records. No UI surface. No model or network call added.

Verification at the tip

Tip SHA: 1ca5fcb

Red at base 0a6e782f8f206eb1477d72f334e84c2ff0ba4b09, clean tree with only tests/test_bench_import_cost.py added, whole file in one run: 4 failed, 1 passed in 4.02s. Each failure is the import-time dataset load from bench/candidate_methods.py:68 ending in OSError: [Errno 30] Read-only file system; the pass is the control proving the stubbed cache actually raises (errno 30).

Two mutations prove the test bites on both domains at this tip. An import-time reflexion_episodic_memory.build(0) in bench/candidate_methods.py (GSM-HARD) now gives 4 failed, 1 passed in 3.96s — it read 5 passed while run() still inherited the GSM-HARD switch — and an import-time promptbreeder_genetic_prompts.build(0) (GSM8K) gives 4 failed, 1 passed in 3.98s. In both the single pass is the errno 30 control.

Ran:

  • pytest tests/test_bench_import_cost.py -q → 5 passed in 4.02s at this tip
  • pytest tests/test_candidate_methods.py tests/test_candidate_methods_report.py tests/test_textgrad_example.py tests/test_dynamic_cheatsheet.py tests/test_aflow_upstream.py tests/test_promptbreeder_algorithm1.py tests/test_self_refine_upstream.py tests/test_example_entrypoints.py tests/test_results_provenance.py -q → 333 passed
  • pytest tests/test_bench_main.py tests/test_bench_index.py -q → 8 passed
  • python -m tools.changelog_fragments check → 46 changelog fragment(s) OK (45 at base; this PR adds one)
  • python -m tools.gen_api_docs --check → docs/api.md is up to date
  • python -m bench.candidate_methods --help and python -m bench.candidate_methods_merge --help over AGENTDESCENT_CACHE=/proc: base with both sample switches, tip with no sample switches → rc 0 for all six runs, output byte-identical at 2640 / 450 bytes
  • base, AGENTDESCENT_CACHE=/proc, no sample switches → rc 1 FileNotFoundError: [Errno 2] No such file or directory: '/proc/gsm8k' (first port, promptbreeder), tip rc 0 with the same no-switch environment, usage: candidate_methods.py [-h]
  • base, AGENTDESCENT_CACHE=/proc, AGENTDESCENT_GSM8K_SAMPLE=1 only → rc 1 FileNotFoundError: [Errno 2] No such file or directory: '/proc/gsmhard' at reflexion → examples/_gsmhard_domain.py:174
  • grep -rnE "^\s+proposal_calls_per_candidate=[0-9]+,\s*$" examples/ --include=*.py → no matches; the 14 code arguments are all proposal_calls_per_candidate=PROPOSAL_CALLS,

Not run:

  • full pytest -q at this tip — it ran at the pre-rebase tip 0547fce (21 failed, 8146 passed, 52 skipped, the 21 all in the four environment-only files: test_sandbox_container.py 12, test_era_srbench.py 6, test_genesis_example.py 2, test_wheel_smoke.py 1). The rebase onto 0a6e782f brought main's own tests/, bench/__main__.py, docs and changelog files and touched none of this diff; the families above plus CI's test (3.9)–test (3.13) cover it.
  • mkdocs build --strict — no docs/ or mkdocs.yml change.

Risk

Nothing ever checked that a port's name matched its folder, at this tip or before it: source_fingerprint() (:88-89) globs examples/<key>/*.py, so a key that names no directory contributes nothing and that port's source drift silently stops changing the fingerprint, while the :540-541 guard compares policy.name to a key derived from the same constant and therefore cannot fire. The new pinned table compares ALGORITHMS to a literal list of the fourteen names (tests/test_bench_import_cost.py:105, :121), so it fails on a port that forgets NAME/PROPOSAL_CALLS and on a NAME edited alone, but neither list is checked against the filesystem: a renamed folder, or a NAME renamed together with that list, still leaves :88-89 globbing nothing. New here: the dry-run reservation reads PROPOSAL_CALLS (:630, :646) instead of build(0)'s policy, and :540-541 does not compare proposal_calls_per_candidate, so a port reserving a different number keeps the suite green and misprints only the dry run. Nothing here calls build(), so the pinned table proves published-to-table consistency, not that the constants are what build(0) returns: a mutation that sets name="other" in a port while NAME stays put reads 5 passed in tests/test_bench_import_cost.py and 3 passed in pytest tests/test_candidate_methods.py -k absolute_zero, whose only policy assertion is fidelity, and a build() that inlined a drifting literal tomorrow would not be caught. The cross-check that the constants are true is a one-time base↔tip dump of ALGORITHMS + PROPOSAL_CALLS_PER_CANDIDATE (0a6e782f vs this tip, fourteen entries each, diff empty), not a suite check; a build(0) assertion here would reinstate the dataset dependency this card removes.

@HugoXK HugoXK added bug Something isn't working area:bench Benchmarks, A/B runs and reports (bench/, reports/) labels Nov 25, 2026
@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Body edit, one line only: the --help byte-diff paragraph gets the condition it ran under — both sides with AGENTDESCENT_GSM8K_SAMPLE=1, because the base cannot reach usage: without it. Tip unchanged at d1ff29ded6c6722e648ec73a1c1684fd54d7f77a; no code, no push, no flip.

Importing bench.candidate_methods builds every port, and a build loads a
dataset, so the module's own --help needed a writable cache. These rows run a
fresh interpreter with cache_path raising OSError(30), switch off the suite's
bundled-sample shortcut so the real path is taken, and pin the whole table so a
lazier one cannot silently drop a port.
ALGORITHMS called build(0) for each port only to learn its name, and build
loads that port's dataset; the matrix's own --help therefore needed a writable
cache and a download on a clean one. Each port now publishes NAME and
PROPOSAL_CALLS beside FIDELITY, and the table reads those. build(seed) is
unchanged and still the only path that loads data.
@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Read at d1ff29ded6c6722e648ec73a1c1684fd54d7f77a (base 0a6e782f8f, draft, mergeable_state: clean). Python 3.10.12 / pytest 8.3.5, -o addopts="" -p no:cacheprovider, real HOME, PYTHONPATH at the tree.

The 24 pinned rows prove the constants exist, not that they are true. No row in tests/test_bench_import_cost.py calls build(). Scratch mutation: in examples/absolute_zero/absolute_zero_selfplay.py set name="other" while NAME stays "absolute_zero" → this file 5 passed; tests/test_candidate_methods.py -k absolute_zero → 3 passed (its only policy assertion is policy.fidelity == fidelity, :232-234). Reverted. The constants are true today because all fourteen build() bodies pass them — that is a code read, not something the test checks. A future build() that inlines a drifting literal would not be caught by tests/test_bench_import_cost.py:91-164.

Second gap on the same claim: gsmhard builds are masked. run() pops only AGENTDESCENT_GSM8K_SAMPLE (:79); tests/conftest.py:20 sets AGENTDESCENT_GSMHARD_SAMPLE=1, which the child inherits. Mutation: add an import-time reflexion_episodic_memory.build(0) (gsmhard) → 5 passed; add promptbreeder_genetic_prompts.build(0) (gsm8k) → 4 failed, 1 passed. So NO_CACHE's "any dataset load raises" (:56-57) does not hold for the three gsmhard ports, and a gsmhard-only regression in the import is invisible.

Red reproduces. Base 0a6e782f8f + only this test file: 4 failed, 1 passed in 4.33s (body 4.57s), all four the import-time OSError: [Errno 30] Read-only file system from bench/candidate_methods.py:68/:72 through the stub; the pass is the control.

The control is load-bearing, with a host caveat. Remove the stub and give the child a writable HOME (user-site on PYTHONPATH): control fails '' != 'raised 30'; with the stub it passes. On this box's read-only ~/.cache it passes either way, because the ambient cache_path raises the same errno 30 — this host cannot distinguish, a writable one can.

--help and the switch. Head with no switch at all: rc 0, 2640 bytes, usage:. Base with no switch: rc 1 EROFS. Base cannot reach usage with the body's single AGENTDESCENT_GSM8K_SAMPLE=1 on a clean cache: it dies at reflexion → examples/_gsmhard_domain.py:174 (cache_path("gsmhard", …)). With AGENTDESCENT_GSM8K_SAMPLE=1 AGENTDESCENT_GSMHARD_SAMPLE=1: base rc 0, 2640 bytes, byte-identical to the head; candidate_methods_merge --help 450 bytes byte-identical. So the switch is genuinely required, but a clean cache needs two, not the one the body names. /proc: base rc 1 FileNotFoundError: [Errno 2] No such file or directory: '/proc/gsm8k', head rc 0 usage: candidate_methods.py [-h], 2640 bytes.

Ports. Each of the fourteen defines NAME/PROPOSAL_CALLS once, its single MethodPolicy(...) uses name=NAME and proposal_calls_per_candidate=PROPOSAL_CALLS, and no numeric literal remains. The five builds with extra kwargs (gated, gateless, export_dir, per_instance, dry_run) have one MethodPolicy each and use the constants; none is a second copy. Sizes: bench/candidate_methods.py +6/−3, each port +7/−2.

Families: this file 5 passed; the nine-file set 333 passed in 64.01s; test_bench_main.py/test_bench_index.py 8 passed; fragments 46 OK (base 45 OK); API docs current.

No blocking finding at this sha: the two test-strength notes above are future-regression coverage, not present behaviour. No UI surface: bench metadata and tests only. Not run: full pytest -q (the body's pre-rebase run plus CI covers it), mkdocs build --strict (no docs/ change).

No merge action from QA: this report is advisory, the merge gate is the repo's review decision on the head sha, and the merge itself is executed by the repo's merge process.

@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Tip moved to 1ca5fcb2975b2fbed4f5a0eb6bd427d992ead141: run() in tests/test_bench_import_cost.py now pops AGENTDESCENT_GSMHARD_SAMPLE as well as AGENTDESCENT_GSM8K_SAMPLE, so the three GSM-HARD ports are covered — an import-time reflexion_episodic_memory.build(0) mutation reads 4 failed, 1 passed (it read 5 passed before the change), and promptbreeder_genetic_prompts.build(0) reads 4 failed, 1 passed.

About to edit the body for that, for the two-switch --help condition (_gsmhard_domain.py:174), and for one risk sentence: the pinned rows prove the constants exist, not that they are true.

@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Body edit: Verification restamped at 1ca5fcb2975b2fbed4f5a0eb6bd427d992ead141 — pytest tests/test_bench_import_cost.py -q gives 5 passed in 4.02s at this tip, and the mutation lines carry their numbers (4 failed, 1 passed in 3.96s for import-time reflexion_episodic_memory.build(0), 4 failed, 1 passed in 3.98s for promptbreeder_genetic_prompts.build(0)); the --help paragraph already names both switches and was re-measured (2640 / 450 bytes, cmp identical); Risk gains one clause — the pinned table proves published-to-table consistency, and a one-time base↔tip dump of ALGORITHMS + PROPOSAL_CALLS_PER_CANDIDATE (14 entries, diff empty) is the separate check that the constants are true.

@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Body edit at 1ca5fcb2975b2fbed4f5a0eb6bd427d992ead141: Tip SHA is already 1ca5fcb2, with the verification block re-run there (5 passed in 4.02s; mutations 4 failed, 1 passed at 3.96s and 3.98s); adding the diff components as the API reports them at Date 05:23:31Z — 17 files +277/-31, fourteen examples/*/ ports at +7/-2 each, bench/candidate_methods.py +6/-3, tests/test_bench_import_cost.py +167/-0, changelog.d/1260-bench-import-cost.md +6/-0; rewording the --help condition to say the import builds GSM8K and GSM-HARD ports alike and needs both switches; and folding the Risk gap into one sentence with Test's mutation (name="other" while NAME stays put: 5 passed in the new file, 3 passed in test_candidate_methods.py -k absolute_zero) plus the one-time base↔tip ALGORITHMS + PROPOSAL_CALLS_PER_CANDIDATE dump (14 entries, diff empty).

@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Body pre-report: body: state the sample switches on each /proc row at head 1ca5fcb2975b2fbed4f5a0eb6bd427d992ead141 (updated_at 05:24:31Z). Re-measured over AGENTDESCENT_CACHE=/proc: base with no sample switch → rc 1 FileNotFoundError: '/proc/gsm8k' (first port, promptbreeder); base with AGENTDESCENT_GSM8K_SAMPLE=1 only → rc 1 FileNotFoundError: '/proc/gsmhard' at reflexion → examples/_gsmhard_domain.py:174; base with both → rc 0, 2640/450 bytes; tip with none and with both → rc 0, md5 identical to the base-with-both output.

That replaces the row's OSError: [Errno 30] with FileNotFoundError: [Errno 2], because /proc is unwritable through makedirs (ENOENT), not a read-only filesystem (EROFS) — errno 30 stays only where it is real: a read-only ~/.cache and the test's stubbed cache_path. One PATCH follows; no code change, head unchanged.

tests/conftest.py sets AGENTDESCENT_GSM8K_SAMPLE and
AGENTDESCENT_GSMHARD_SAMPLE, and run() popped only the first. The three
GSM-HARD ports (godel_agent, reflexion, sica) therefore loaded their bundled
sample, so an import-time build() of one of them passed the test that is
supposed to catch it. Pop both.

Measured after the change: an import-time reflexion_episodic_memory.build(0)
fails 4 and passes 1, and promptbreeder_genetic_prompts.build(0) still fails
4 and passes 1 (the control). Before the change the reflexion mutation read
5 passed.

Refs #1260.
@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Body pre-report: body: correct the Risk sentence about the name-to-folder check at head 1ca5fcb2975b2fbed4f5a0eb6bd427d992ead141 (updated_at 05:33:47Z). The live first Risk sentence claims build(0) checked each port's name against its folder; it did not: source_fingerprint() (bench/candidate_methods.py:88-89) globs examples/<key>/*.py, so a key that names no directory contributes nothing, and the :540-541 guard compares policy.name to a key derived from the same constant, so it cannot fire. Replacing that one sentence with the statement you supplied and leaving the rest of the paragraph, the cross-check sentence and the /proc rows untouched. One PATCH follows; no code, test, push or flip.

@HugoXK

HugoXK commented Nov 25, 2026

Copy link
Copy Markdown
Collaborator Author

Body pre-report: body: correct the direction of the name-to-folder claim at head 1ca5fcb2975b2fbed4f5a0eb6bd427d992ead141 (updated_at 06:10:57Z, 7534 chars). Risk sentence 2 becomes: the pin's two name assertions (tests/test_bench_import_cost.py:105, :121) compare ALGORITHMS to a literal list, so a NAME edited alone does fail, while a renamed folder — or a NAME renamed together with that list — is checked by nothing, because bench/candidate_methods.py:88-89 globs examples/<key>/*.py. Sentences 1 and 3 untouched. One PATCH follows; no code, no push, no flip.

Birfy added a commit that referenced this pull request Nov 25, 2026
)

Closes #1283

## What changed
`source_fingerprint` used to glob `examples/<ALGORITHMS key>/*.py` and,
when the key named no directory, add zero paths and raise nothing. A
port whose `name` drifted off its folder then stopped changing the
fingerprint, so cached results were no longer invalidated by edits to
that port.

`algorithm_source_dir` now requires each key to be a real directory
before the glob, and `source_fingerprint` goes through it. The check is
filesystem-only: no dataset load and no `build(0)`. A missing folder
fails with `FileNotFoundError` naming the key and the path.

A second test pins each `PROPOSAL_CALLS_PER_CANDIDATE` entry to
`builder(0).proposal_calls_per_candidate`. On main that constant is
still derived from the policy, so the pin is already true by
construction; it is the check #1283 asked for once a port spells the
reservation as a separate literal (as #1279 proposes).

Not a goal: changing how the matrix is built, loading less at import, or
altering the fingerprint of a valid matrix beyond this file's own bytes.

## Verification at the tip
Tip SHA: ae2070a — base
`a0d70e49d2c09908c04cf352db23b6d3a0572737`, 1 commit.

Ran:
- `pytest -q -o addopts='' tests/test_candidate_algorithm_folders.py` →
5 passed in 0.97s
- `python -m tools.changelog_fragments check` → 48 changelog fragment(s)
OK
  - `python -m tools.gen_api_docs --check` → docs/api.md is up to date

Not run: full `pytest -q` — the delta is the helper, its tests, and a
changelog fragment; required CI will cover test 3.9–3.13, build,
otel-wire.

This branch has not been deployed

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

Labels

area:bench Benchmarks, A/B runs and reports (bench/, reports/) bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bench: importing bench.candidate_methods builds every port, so --help needs the dataset cache

2 participants