feat: implement experiment, refinement, and race loop patterns with watch loop integration #16

Open
hugooconnor wants to merge 41 commits from hence/plan-IMPL-015 into main
hugooconnor commented 2026-03-20 09:57:02 +00:00 (Migrated from codeberg.org)

Summary

  • Repeatable tasks — new (repeatable "true") metadata field enables automatic respawn after completion/failure, with consecutive failure counter reset so transient failures don't exhaust the retry budget
  • Auto-merge control(auto-merge "false") metadata skips branch merge after completion, preserving branches for downstream inspection (race judge, experiment comparison)
  • Plan templateshence plan init --template {refinement,experiment-loop,race} scaffolds full plans with companion shell scripts (check-quality.sh, check-metric.sh, record-result.sh, judge.sh, merge-winner.sh)
  • Context injection — context constructor now assembles refinement context (iteration number, quality feedback, improvement guidance) and experiment context (metric name, direction, best value, results history) into agent prompts
  • Env var injectionHENCE_* environment variables (metric, direction, time budget, modifiable file, plan) are injected into evaluate-check commands, lifecycle scripts, and agent PTY sessions
  • Watch loop hardening — permanently-failed guard prevents infinite respawn loops, infrastructure failure resets cached state, and permanently-failed repeatable tasks are treated as terminal
  • Race judge integration — end-to-end tests for 3-approach race flow including judge verdict validation and merge-winner branch merging
  • Refinement defeater fix — corrected undercutting defeater syntax so quality-passed properly blocks ready-refine

Test plan

  • 6 watch loop integration tests (permanently-failed guard, state reset, terminal detection)
  • 6 refinement defeater CLI integration tests + 3 watch unit tests
  • 4 integration branch invariant tests (keep/discard/cumulative)
  • Race judge end-to-end tests (readiness, completion, verdict, merge)
  • Unit tests for repeatable metadata, auto-merge, failure counter reset, context construction
## Summary - **Repeatable tasks** — new `(repeatable "true")` metadata field enables automatic respawn after completion/failure, with consecutive failure counter reset so transient failures don't exhaust the retry budget - **Auto-merge control** — `(auto-merge "false")` metadata skips branch merge after completion, preserving branches for downstream inspection (race judge, experiment comparison) - **Plan templates** — `hence plan init --template {refinement,experiment-loop,race}` scaffolds full plans with companion shell scripts (check-quality.sh, check-metric.sh, record-result.sh, judge.sh, merge-winner.sh) - **Context injection** — context constructor now assembles refinement context (iteration number, quality feedback, improvement guidance) and experiment context (metric name, direction, best value, results history) into agent prompts - **Env var injection** — `HENCE_*` environment variables (metric, direction, time budget, modifiable file, plan) are injected into evaluate-check commands, lifecycle scripts, and agent PTY sessions - **Watch loop hardening** — permanently-failed guard prevents infinite respawn loops, infrastructure failure resets cached state, and permanently-failed repeatable tasks are treated as terminal - **Race judge integration** — end-to-end tests for 3-approach race flow including judge verdict validation and merge-winner branch merging - **Refinement defeater fix** — corrected undercutting defeater syntax so `quality-passed` properly blocks `ready-refine` ## Test plan - [x] 6 watch loop integration tests (permanently-failed guard, state reset, terminal detection) - [x] 6 refinement defeater CLI integration tests + 3 watch unit tests - [x] 4 integration branch invariant tests (keep/discard/cumulative) - [x] Race judge end-to-end tests (readiness, completion, verdict, merge) - [x] Unit tests for repeatable metadata, auto-merge, failure counter reset, context construction
This pull request has changes conflicting with the target branch.
  • plans/IMPL-015-experiment-loop.spl
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin hence/plan-IMPL-015:hence/plan-IMPL-015
git switch hence/plan-IMPL-015

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch main
git merge --no-ff hence/plan-IMPL-015
git switch hence/plan-IMPL-015
git rebase main
git switch main
git merge --ff-only hence/plan-IMPL-015
git switch hence/plan-IMPL-015
git rebase main
git switch main
git merge --no-ff hence/plan-IMPL-015
git switch main
git merge --squash hence/plan-IMPL-015
git switch main
git merge --ff-only hence/plan-IMPL-015
git switch main
git merge hence/plan-IMPL-015
git push origin main
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
anuna-research/hence!16
No description provided.