A community based topic aggregation platform built on atproto

fix(comments): address critical PR review issues - lexicon compliance, data integrity, SQL correctness master

This commit resolves 5 critical issues identified during PR review: ## P0: Missing Record Fields (Lexicon Contract Violation) - Added buildPostRecord() to populate required postView.record field - Added buildCommentRecord() to populate required commentView.record field - Both lexicons mark these fields as required, null values would break clients - Files: internal/core/comments/comment_service.go ## P0: Handle/Name Format Violations - Fixed postView.author.handle using DID instead of proper handle format - Fixed postView.community.name using DID instead of community name - Added users.UserRepository and communities.Repository to service - Hydrate real handles/names with DID fallback for missing records - Files: internal/core/comments/comment_service.go, cmd/server/main.go ## P1: Data Loss from INNER JOIN - Changed INNER JOIN users → LEFT JOIN users in 3 query methods - Previous implementation dropped comments when user not indexed yet - Violated intentional out-of-order Jetstream design principle - Added COALESCE(u.handle, c.commenter_did) for graceful fallback - Files: internal/db/postgres/comment_repo.go (3 methods) ## P0: Window Function SQL Bug (Critical) - Fixed ListByParentsBatch using ORDER BY hot_rank in window function - PostgreSQL doesn't allow SELECT aliases in window ORDER BY clause - SQL error caused silent failure, dropping ALL nested replies in hot sort - Solution: Inline full hot_rank formula in window ORDER BY - Files: internal/db/postgres/comment_repo.go ## Documentation Updates - Added detailed documentation for all 5 fixes in COMMENT_SYSTEM_IMPLEMENTATION.md - Updated status to "Production-Ready with All PR Fixes" - Updated test coverage counts and implementation dates ## Testing - All integration tests passing (29 total: 18 indexing + 11 query) - Server builds successfully - Verified fixes with TestCommentQuery_* test suite Technical notes: - Service now requires all 4 repositories (comment, user, post, community) - Updated test helpers to match new service signature - Hot ranking still computed on-demand (caching deferred to Phase 3) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>


+616 -75
6 changed files