v3/docs/adr/ADR-340-retrospective-harness-optimization.md
Status: Proposed
Authors: claude (dream-cycle agent, 2026-06-07)
Dream Cycle Issue: Dream Cycle 2026-06-07, intelligence surface
Source: arXiv:2606.05922 — "Retrospective Harness Optimization: Improving LLM Agents via Self-Preference over Trajectory Rollouts"
RHO (arXiv:2606.05922, Grade A, code available: github.com/wbopan/retro-harness) demonstrates that a single self-supervised optimization cycle raises SWE-Bench Pro pass rate from 59% to 78% (+19pp) without any external grading signal. The method:
Ruflo's current SONA intelligence loop collects trajectory data via hooks post-task --train-patterns and stores it in ReasoningBank, but has no mechanism to retrospectively compare trajectory outcomes and propose harness improvements. The 4-step RETRIEVE → JUDGE → DISTILL → CONSOLIDATE pipeline distills patterns but does not produce harness diffs.
No existing ADR in the 085–130 range covers self-supervised harness optimization. ADR-076 (structured distillation) and ADR-078 (hybrid retrieval and outcome signal) address pattern extraction but not harness self-modification.
Add a retrospective-optimize subcommand to @claude-flow/hooks that:
post-task) to score each rollout pair; selects the Condorcet winner~/.claude-flow/harness.json with a rollback checkpoint; logs the update to the intelligence hook trajectoryThe command is designed to run as a nightly background worker (hooks worker dispatch --trigger retrospective-optimize) and does not block interactive sessions.
Positive:
Negative / Risks:
Mitigation:
--max-budget-usd flag (default 0.25)claude-flow performance benchmark --suite swe-bench-pro| File | Change |
|---|---|
v3/@claude-flow/hooks/src/commands/retrospective-optimize.ts | New command (~200 LOC) |
v3/@claude-flow/hooks/src/workers/retrospective-worker.ts | Background worker registration (~80 LOC) |
v3/@claude-flow/hooks/src/index.ts | Export new command |
v3/@claude-flow/memory/src/reasoning-bank.ts | Add getCoreset(n, filter) method (~40 LOC) |
Total estimated: ~320 LOC. No breaking API changes.