code
Clone this repository
https://tangled.org/bretton.dev/coves
git@knot.bretton.dev:bretton.dev/coves
For self-hosted knots, clone URLs may differ based on your setup.
Remove unused cid and created_at columns from batch vote query. These fields were
being fetched but never used in the result mapping.
Changes:
- Remove cid and created_at from SELECT clause
- Keep only subject_uri, direction, and uri (all actively used)
- Maintain same query performance characteristics
This reduces memory usage and network overhead for viewer state hydration without
changing behavior. Each comment query fetches vote state for potentially hundreds
of comments, so column reduction has meaningful impact at scale.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Type assertions on map values return pointers to loop variables, which can cause
nil pointer dereferences or incorrect values if addresses are taken directly.
Changes:
- Create explicit copies of type-asserted direction and voteURI values
- Take addresses of copies instead of loop variables for Viewer.Vote and Viewer.VoteURI
- Add DefaultRepliesPerParent package-level constant (was magic number)
- Document constant rationale: balances UX context with query performance
This fixes potential nil pointer panics in comment viewer state hydration and
improves code maintainability by making magic numbers visible and documented.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive documentation explaining return value semantics for malformed URIs.
Changes:
- Clarify that empty string indicates "unknown/unsupported collection"
- Document that callers should validate return value before using for DB queries
- Add examples of expected collection names (e.g., "social.coves.feed.comment")
- Explain format expectations (at://did/collection/rkey)
This addresses PR review feedback about input validation documentation. Empty string
is the correct sentinel value indicating unparseable/invalid URIs, and callers must
handle this appropriately.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace hardcoded post-only count updates with collection-aware routing that handles
both posts and comments. This enables proper vote and reply count tracking for comments.
Changes:
- Extract collection from subject/parent URIs using ExtractCollectionFromURI
- Route updates to correct table based on collection type:
- social.coves.community.post → posts table
- social.coves.feed.comment → comments table
- Add comprehensive error handling for unknown collections
- Maintain atomic transaction boundaries for data integrity
This prepares the indexing pipeline for Phase 2B comment voting where votes can target
either posts OR comments. Previously, all votes assumed post subjects.
Performance: ExtractCollectionFromURI is 1,000-20,000x faster than DB lookups for
collection detection.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
When comments arrive before their parent posts (common with cross-repo Jetstream ordering),
post comment_count would remain at 0 even after comments were successfully indexed.
Changes:
- Add indexPostAndReconcileCounts() method to post consumer
- Use atomic transaction to insert post + reconcile comment count
- Reconciliation query counts all non-deleted comments with matching parent_uri
- Update constructor signature to accept database for transaction support
This fixes P0 data integrity issue where posts had permanently stale comment counts.
Test coverage:
- Existing integration tests validate reconciliation behavior
- Post consumer now matches comment consumer pattern (lines 343-356)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Run go fmt, gofumpt, and make lint-fix to ensure code quality:
Formatting fixes:
- Standardize import block formatting across all files
- Apply gofumpt strict formatting rules
- Remove nil checks where len() is sufficient (gosimple)
Code cleanup:
- Remove unused setupIdentityResolver function from tests
- Fix comment_consumer.go: omit unnecessary nil checks
All critical lint issues resolved ✅
Only fieldalignment optimization suggestions remain (non-critical)
Files affected: 17 Go files across:
- cmd/server
- internal/api/handlers/comments
- internal/atproto/jetstream
- internal/core (comments, posts)
- internal/db/postgres
- tests/integration
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>