Skip to content

Replace draft/bench/improve loop with acumen epoch + knowledge wiki - #13

Open
PauBadiaM wants to merge 10 commits into
mainfrom
epoch-refactor
Open

Replace draft/bench/improve loop with acumen epoch + knowledge wiki#13
PauBadiaM wants to merge 10 commits into
mainfrom
epoch-refactor

Conversation

@PauBadiaM

Copy link
Copy Markdown
Collaborator

What

Reshapes acumen's optimization loop from the manual draftbenchimprove cycle into a single, resumable training epoch.

acumen epoch runs one epoch end to end:

  1. Bench the current arm on the train split (first epoch also benches the noskill baseline on valid).
  2. Wiki — one agent per task distils that arm's runs into a persistent, cumulative wiki/<task>/observations.md + hypothesis.md (one terse [version][model] block per epoch, from noskill up).
  3. Improve — create the first skill (from the noskill wiki + filtered source) or improve the latest, reading the wiki + parent skill + staged train transcripts.
  4. Bench the new version on the held-out valid split.

It resolves state from disk, so a crashed epoch resumes on the right step and a finished one starts the next.

Changes

  • New wiki.py — cumulative, resume-safe per-task knowledge base; parallel agents; brevity-enforced prompt; filtered-source + discover_skills=False isolation; .arms marker for idempotency.
  • Reworked improve.py — wiki-driven, create-or-improve, filtered package source; keeps the held-out-split guard hook (renamed find_valid_access/make_valid_guard).
  • New epoch.py + acumen epoch; add acumen wiki; retire acumen draft.
  • Rename the held-out split testvalid (reserving test for a future train/valid/test split) across paths, tasks, report, check, review, taskgen, scaffold, prompts, and tests.
  • bench: a free codex sandbox preflight probe so a namespace/sandbox failure is reported up front instead of once per paid run; raise the auth-probe budget cap (PREFLIGHT_MAX_USD) so premium models can pass preflight (pre-existing bug that also blocked acumen bench with Opus).
  • Docs: minimal README rewrite and the shipped acumen self-skill (_skills/data/**) updated to the new loop.

Validation

  • 291 tests pass; ruff clean.
  • End-to-end on a toy package (sensorloom) across six models (opus/sonnet/haiku + sol/terra/luna) and six generated tasks: the created skill lifted the weakest model's held-out pass rate (haiku 4/6 → 6/6 on valid) without regressing the others.

API may change freely (dev phase); this PR is not backward compatible with the old command set.

🤖 Generated with Claude Code

Reshape the optimization loop into a resumable training epoch. `acumen epoch`
benches the current arm on the training split, distils each task's runs into a
persistent per-task wiki (observations.md + hypothesis.md, one [version][model]
block per epoch from noskill up), creates or improves the skill from that wiki,
then benches the new version on the held-out split.

- New `wiki.py`: cumulative, resume-safe per-task notes (one agent per task, in
  parallel); terse-by-design prompt; filtered-source isolation.
- Rework `improve.py`: reads the wiki + parent skill + staged train transcripts
  + filtered package source; creates v1 when no version exists, improves after.
- New `epoch.py` + `acumen epoch`; add `acumen wiki`; retire `acumen draft`.
- Rename the held-out split `test` -> `valid` (reserving `test` for a future
  train/valid/test split) across paths, tasks, report, check, review, taskgen,
  scaffold, prompts, and tests.
- bench: free codex sandbox preflight probe so a namespace/sandbox failure is
  reported up front instead of per paid run; raise the auth-probe budget cap
  (PREFLIGHT_MAX_USD) so premium models can pass preflight.
- Rewrite the README (minimal) and the shipped acumen self-skill for the new loop.

Validated end-to-end on a toy package across six models; the skill lifted the
weakest model's held-out pass rate without regressing the others.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@codecov-commenter

codecov-commenter commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 58.81007% with 360 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.83%. Comparing base (dfedfe0) to head (b25a4f8).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/acumen/cli.py 55.91% 179 Missing ⚠️
src/acumen/wiki.py 51.67% 101 Missing ⚠️
src/acumen/improve.py 25.00% 36 Missing ⚠️
src/acumen/agents.py 30.00% 21 Missing ⚠️
src/acumen/epoch.py 61.11% 7 Missing ⚠️
src/acumen/bench.py 16.66% 5 Missing ⚠️
src/acumen/logs.py 0.00% 3 Missing ⚠️
src/acumen/prompts.py 87.50% 2 Missing ⚠️
src/acumen/training.py 97.80% 2 Missing ⚠️
src/acumen/trajectory.py 87.50% 2 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #13      +/-   ##
==========================================
- Coverage   78.44%   77.83%   -0.61%     
==========================================
  Files          30       31       +1     
  Lines        5336     5821     +485     
==========================================
+ Hits         4186     4531     +345     
- Misses       1150     1290     +140     
Files with missing lines Coverage Δ
src/acumen/__init__.py 100.00% <100.00%> (ø)
src/acumen/check.py 94.17% <ø> (ø)
src/acumen/paths.py 84.52% <100.00%> (ø)
src/acumen/report.py 89.75% <100.00%> (ø)
src/acumen/review.py 93.52% <ø> (ø)
src/acumen/scaffold.py 92.30% <ø> (ø)
src/acumen/taskgen.py 60.48% <100.00%> (ø)
src/acumen/tasks.py 75.25% <100.00%> (ø)
src/acumen/prompts.py 77.27% <87.50%> (+0.80%) ⬆️
src/acumen/training.py 97.80% <97.80%> (ø)
... and 9 more

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

PauBadiaM and others added 9 commits September 9, 2026 17:04
…age sum

The transcript/trajectory footer for Claude runs summed the session file's
per-message usage. Each Claude turn re-sends the whole conversation, so every
turn's usage already counts the cached prefix; summing across turns overcounts
badly (a real run showed input/cached/output of 22/230109/2999 and a priced cost
of $0.53 vs the $0.32 the run was actually billed). result.json was already
correct — it records the authoritative ResultMessage.usage, whose priced cost
matches Claude's own total_cost_usd.

Thread that authoritative usage into the trajectory so the footer matches
result.json: build_trajectory / from_claude_transcript / from_claude_records take
a `usage` override, and the runner and LiveLog.finalize pass ResultMessage.usage.
The per-message sum remains only as a fallback for rendering a bare transcript
with no result. Also fix a shadowing bug where the loop's per-message `usage`
clobbered the new parameter.

Codex is unaffected: it reports usage once per turn.completed as a single total,
which the mapper takes directly (never summed).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`acumen fit` drives the epoch loop like training a model: it runs `acumen epoch`
back to back, tracks held-out validation mean success, and stops on `--patience`
(default 2, no strict improvement over the best-so-far) or the `--max-epochs`
hard cap (default 10); `--epochs N` runs exactly N and disables early stopping.

- New `training.py`: build the per-epoch training curve from the runs tree
  (epoch N's train arm = v(N-1)/noskill, valid arm = vN), write `training.csv`
  (mean success and mean cost per run, overall and per model, train and valid),
  and the pure early-stop rule (`patience_exhausted`, `epochs_since_best`,
  `best_version`). Rebuilt from disk each epoch, so `fit` is resumable.
- Factor `_run_one_epoch` + `_prepare_pass` out of `_cmd_epoch` so `epoch` and
  `fit` share one epoch implementation; `fit` prepares the target/rates once.
- Each epoch prints a tqdm-style line with train/valid success, best/patience.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
acumen bundled its own skill (guidance for using acumen) under `_skills/`, exposed
via the `acumen-install-skills` console script. It had drifted out of date with the
epoch/wiki/fit workflow, so drop it: delete `src/acumen/_skills/`, its
`[project.scripts]` entry, and the README install note.

Unrelated: `acumen ship` — which packages a *target* package's skill into a
`<dist>-install-skills` script (`SHIP_INSTALL_TEMPLATE`, ship.py) — is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
codex exec prints this to stderr whenever its stdin is not a TTY (acumen
wires it to /dev/null), then reads immediate EOF. It is harmless but reads
as a confusing prompt during a run, so drop it in the stderr drain.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`acumen epoch` and `acumen fit` now show one in-place progress bar per
phase (bench train, wiki, an "inferring skill" spinner, bench valid),
each filling per finished run with a running mean success rate and
cumulative cost, in place of the per-run scrolling logs.

- Bar unit is one matrix cell (model x task x rep); success = passed/done.
- Bars by default; --verbose restores the full scrolling logs.
- Output auto-detects: live \r bars on a TTY with --stream off, else a
  plain throttled-line fallback so files/CI stay readable. Genuine harness
  failures (provider-exhausted / sandbox-blocked) still surface to stderr.
- bench/wiki/improve standalone commands are unchanged.

update_wiki gains an optional on_plan(total) callback so the wiki bar has
an accurate denominator (recorded tasks are skipped without a callback).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
_cmd_fit called build_training_rows(runs, cfg, tasks) but the function
takes two args and ignores tasks, so every fit run crashed while writing
the training curve — after a full epoch had already been spent. The unit
tests call it with two args, so the suite stayed green. Drop the stray
argument at both call sites and add a regression test that drives the
post-epoch path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codex logs its own tracing to stderr (rollout writes after a session
ends, sandbox-denied commands under approval_policy=never, malformed
apply_patch attempts). None signal an acumen fault and all are kept in
the run transcript, but each line is unique so StderrFilter never dedupes
them — they flood the console and corrupt the \r progress bars. Drop
lines matching the Codex tracing shape in _drain_stderr, keeping them in
the noise sink so _sandbox_failure still detects real bwrap/landlock
errors (which are bare and still print).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The phase bar mixed conventions without saying so: success was a running
mean pass-rate while cost was a cumulative sum. Spell both out —
"success N% (mean)" and "$X total" — so the numbers are unambiguous.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The improve step reported cost and turns but not how long it took, unlike
the phase bars. Time the call and include it — "(2m41s, $5.24, 79 turns)"
in bar mode, and "over N turns in 2m41s" in verbose.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants