fix: evolution formula must commit results via PR before closing (#1047)

- Add `cleanup` step: removes per-generation candidate files and
  generation_*.jsonl records after they are aggregated into the evidence
  file, preventing disk exhaustion (cf. run #1025 at 91% usage).

- Rewrite `deliver` step with mandatory ordering:
  1. `git checkout -- .` to discard unrelated working-tree modifications
     before staging result files (evidence JSON, champion .push3, manifest).
  2. Commit to branch `evidence/evolution-run-{run_id}` (not directly to main).
  3. Push and create PR — if this fails, post an error comment and leave the
     issue OPEN; do not proceed to step 4.
  4. Post summary comment only after PR URL is confirmed, with mandatory
     link to the PR.

- Update `products.evidence_file` delivery to PR branch (was "commit to main").
- Update `products.issue_comment` to enforce ordering and non-close-on-failure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
johba 2026-03-21 12:47:59 +00:00
parent a6f26453a0
commit 0edda8bb4b

View file

@ -196,36 +196,83 @@ the run; "no_improvement" otherwise.
output = "evidence/evolution/{date}.json" output = "evidence/evolution/{date}.json"
schema = "evidence/README.md" schema = "evidence/README.md"
[[steps]]
id = "cleanup"
description = """
Remove intermediate per-generation candidate files that are not part of the
final results. Only the following files are retained after this step:
tmp/evolution/run_NNN/best.push3 global champion
tmp/evolution/run_NNN/diff.txt constant delta vs seed
tmp/evolution/run_NNN/evolution.log full run transcript
tools/push3-evolution/seeds/run{NNN}_*.push3
top-N newly admitted seeds
( elites per generation)
Files removed:
tmp/evolution/run_NNN/generation_*.jsonl per-candidate fitness records
(already aggregated into evidence)
tmp/evolution/run_NNN/candidate_*.push3 intermediate per-generation
candidates that are not elites
Rationale: the evolution box reached 91% disk utilisation in run #1025 because
these intermediate files were never cleaned up. Aggregated fitness data is
preserved in evidence/evolution/{date}.json; the per-candidate .push3 files for
non-elite generations are not needed once the evidence file is written.
"""
[[steps]] [[steps]]
id = "deliver" id = "deliver"
description = """ description = """
Commit evidence and champion files, open PR, post summary comment. Commit results to a branch, push, open PR, then post summary comment.
ORDERING IS MANDATORY each sub-step must complete before the next begins.
Do NOT post to the issue before the PR URL is available.
1. Commit evidence/evolution/{date}.json to main. 1. CLEAN GIT STATE
Run `git checkout -- .` to discard any working-tree modifications that are
2. Open a Codeberg PR targeting main containing: NOT part of the evolution results (e.g. .sol files left over from a prior
session, scratch files). Only stage files that belong to this run:
- evidence/evolution/{date}.json
- tools/push3-evolution/seeds/evo_run{NNN}_champion.push3 - tools/push3-evolution/seeds/evo_run{NNN}_champion.push3
(copied from tmp/evolution/run_NNN/best.push3) - tools/push3-evolution/seeds/manifest.jsonl
- Updated tools/push3-evolution/seeds/manifest.jsonl Verify `git diff --check` passes before committing.
(with newly admitted candidates and fresh fitness scores)
PR title: "evo: run{NNN} champion — fitness={best_fitness}" 2. COMMIT TO BRANCH
PR body: generation-by-generation table (gen, best, mean, worst fitness), Create branch evidence/evolution-run-{run_id} from master.
Commit the staged result files with message:
"evo: run{NNN} results — fitness={best_fitness}"
The commit MUST include all three files above.
3. PUSH AND CREATE PR
Push the branch to origin.
Open a Codeberg PR targeting master:
Title: "evo: run{NNN} champion — fitness={best_fitness}"
Body: generation-by-generation table (gen, best, mean, worst fitness),
top-3 admitted candidates with fitness scores, constant diff vs top-3 admitted candidates with fitness scores, constant diff vs
seed (from diff.txt), link to evidence file. seed (from diff.txt), link to evidence file.
If `git push` or PR creation fails:
a. Post an error comment to the originating issue with the failure reason
and the path of the local evidence file.
b. Leave the issue OPEN.
c. Exit with a non-zero status do NOT proceed to step 4.
3. Post summary comment to originating issue: 4. POST SUMMARY COMMENT (only after PR URL is confirmed)
Post a comment to the originating issue containing:
- Verdict (improved / no_improvement). - Verdict (improved / no_improvement).
- Best fitness achieved and which generation it was found in. - Best fitness achieved and which generation it was found in.
- Admission count: N candidates added to seed pool. - Admission count: N candidates added to seed pool.
- Link to champion PR (if new best found) and evidence file. - Link to the champion PR (required do not post without it).
- If no_improvement: include best fitness achieved and seed pool size. - Link to evidence file committed in the PR.
- If no_improvement: best fitness achieved and seed pool size.
Do NOT close the issue in this step; closing is the orchestrator's
responsibility once the PR is merged.
""" """
# ── Products ─────────────────────────────────────────────────────────────────── # ── Products ───────────────────────────────────────────────────────────────────
[products.evidence_file] [products.evidence_file]
path = "evidence/evolution/{date}.json" path = "evidence/evolution/{date}.json"
delivery = "commit to main" delivery = "PR to main (same PR as champion_files, on branch evidence/evolution-run-{run_id})"
schema = "evidence/README.md" # see ## Schema: evolution/YYYY-MM-DD.json schema = "evidence/README.md" # see ## Schema: evolution/YYYY-MM-DD.json
[products.champion_files] [products.champion_files]
@ -240,9 +287,11 @@ delivery = "PR to main (same PR as champion_files)"
note = "Updated with newly admitted entries and fitness scores from evaluate-seeds." note = "Updated with newly admitted entries and fitness scores from evaluate-seeds."
[products.issue_comment] [products.issue_comment]
delivery = "post to originating issue" delivery = "post to originating issue AFTER PR is created and URL is confirmed"
content = "verdict (improved/no_improvement), best fitness, generation found, admission count, link to champion PR and evidence file" content = "verdict (improved/no_improvement), best fitness, generation found, admission count, link to champion PR (mandatory), link to evidence file"
on_failure = "include best fitness achieved, last generation completed, full log available in tmp/evolution/run_NNN/evolution.log" on_pr_failure = "post error comment with failure reason and local evidence path; leave issue OPEN; do not close"
on_run_failure = "include best fitness achieved, last generation completed, full log available in tmp/evolution/run_NNN/evolution.log; do not close issue"
ordering_note = "The comment MUST NOT be posted before the PR URL exists. Closing the issue is the orchestrator's responsibility after PR merge, not this formula's."
# ── Resources ────────────────────────────────────────────────────────────────── # ── Resources ──────────────────────────────────────────────────────────────────