feat: author attribution for shared reviews#131
Merged
tomasz-tomczyk merged 1 commit intomainfrom Apr 27, 2026
Merged
Conversation
Add proper author attribution when sharing a review from crit to crit-web. Replaces the placeholder "imported" author with two complementary signals: - author_display_name (cosmetic) flows through from CLI config / git user / GitHub / "Anonymous" fallback. - user_id (verified identity) is stamped on comments only when the bearer token verifies, never trusted from the payload. Server attribution rules: - Existing comment matched by external_id keeps its user_id (preserves foreign attribution on roundtrip). - Anon request -> user_id = NULL regardless of payload. - Authed request: payload user_id matching current_user wins; anything else (including spoof attempts) drops to NULL. Other changes: - comments.user_id nullable FK to users.id (ON DELETE SET NULL) - unique index on (review_id, external_id) WHERE external_id IS NOT NULL - demo export filter switched to a configurable allowlist of comment IDs (DEMO_COMMENT_IDS env var) — replaces the legacy author_identity = "imported" - /api/auth/whoami returns id so the CLI can cache it - test-only POST /api/test/seed-user for integration tests - demo review filter (LiveView) now also keeps current_user's own comments Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
5 tasks
Codecov Report❌ Patch coverage is
❌ Your patch status has failed because the patch coverage (77.22%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #131 +/- ##
==========================================
- Coverage 76.11% 75.80% -0.31%
==========================================
Files 52 52
Lines 1524 1579 +55
==========================================
+ Hits 1160 1197 +37
- Misses 364 382 +18
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
"imported"placeholder author with proper attribution: a cosmeticauthor_display_nameand a verifieduser_id(UUID FK tousers.id).user_idas untrusted intent — only the bearer token decides what gets stamped. Existing comments matched byexternal_idkeep their originaluser_idon roundtrip (preserves foreign-author attribution).author_identity == "imported"to a configurable allowlist of comment IDs (DEMO_COMMENT_IDSenv var).current_user_id-matched comments so authed visitors see their own comments.comments.user_idnullable FK (ON DELETE SET NULL) + partial unique index on(review_id, external_id).POST /api/test/seed-user(gated byMix.env() in [:test, :dev]) for integration tests./api/auth/whoamireturnsidso the CLI can cache it.Review
Test plan
mix precommit— 460/460 passmix test test/crit/reviews_test.exs test/crit_web/live/review_live_test.exs— 130/130 pass./scripts/e2e-share.sh) — all 24 attribution + share-sync tests passDEMO_COMMENT_IDSfly secret post-deploySee also: tomasz-tomczyk/crit#371 (CLI side)
🤖 Generated with Claude Code