Repository navigation
refactor(auth): split store_postgres.go into group, session and admin files - #1546
Conversation
…_postgres_groups.go Pure move inside package auth; function bodies are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_postgres_groups.go Pure move inside package auth; function bodies are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ssions.go Pure move inside package auth; function bodies are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…_postgres_admin.go Pure move inside package auth; function bodies are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nto store_postgres_admin.go Pure move inside package auth; function bodies are unchanged. Closes #86 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Separate domain operations from the core store file internal/auth/store_postgres.go, internal/auth/store_postgres_admin.go, internal/auth/store_postgres_groups.go, internal/auth/store_postgres_sessions.go |
The core store file removes admin, group, and session methods and related code. The operations are defined in the corresponding domain-specific files. |
Admin membership and invariant operations internal/auth/store_postgres_admin.go |
Admin helpers check active membership, count group members, detect specified database constraint violations, and create the first admin through a conditional insert within an advisory-lock transaction. |
Group persistence and row scanning internal/auth/store_postgres.go, internal/auth/store_postgres_groups.go |
Group retrieval, creation, updates, deletion, and listing use PostgreSQL queries. The group scanner handles permissions and nullable creator IDs. |
Session persistence and cleanup internal/auth/store_postgres_sessions.go |
Session methods create, retrieve, and delete sessions, delete a user’s sessions, and clean up expired sessions. |
Priority:
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Refactor
Suggested reviewers: iamjsd
Merge Risk: 
Minimal · up to 7b9e1
-
The store split preserves the inspected implementations and is ready to merge after normal checks.
Pre-merge checks: 
4 · 
1
-
Failed checks: 1 inconclusive Passed checks: 4 passed-
Full details: Out of Scope Changes check
-
Explanation
The changes remain within issue [
#86]. They move PostgreSQL store declarations into same-package group, session, and admin files. The diff evidence shows import and blank-line updates only in addition to the moves. No unrelated behavior, API, or call-site changes are identified.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 3 files.
-
Full details: Linked Issues check
-
Explanation
Issue [
#86] requires all affected files to stay below 500 lines, movement-only changes, and passinggo build ./...,go vet ./..., andgo test ./internal/auth/... -count=1. The PR reports file sizes of 297, 211, 111, and 249 lines. The diff moves declarations between same-package files and changes only imports and blank lines. The PR reports the build and auth tests, but it reportsgo vet ./internal/auth/and race-test variants instead of the requiredgo vet ./...and exact test command. The available evidence does not establish those two required checks.Resolution
Provide results for
go vet ./...andgo test ./internal/auth/... -count=1at the reviewed head.
-
Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands.
|
Independent review 2 (claude-fleet, cold): APPROVE 7b9e1c5 Scope: internal/auth/store_postgres.go split into store_postgres_admin.go, store_postgres_groups.go and store_postgres_sessions.go. 4 files, +571/-538, base 1d10f08. Commit sizes are 224, 186, 213, 165 and 321 changed lines, all 400 or fewer. Findings: none. Pure-move proof:
Verified (light, under the heavy lock):
Reviewed by an independent agent with no author context (second reviewer). Review only: nothing was pushed, and the GitHub review state is unchanged. |
|
VERDICT: APPROVE 7b9e1c5
|
|
Local verification at
|
Closes #86.
internal/auth/store_postgres.gowas 835 lines, over the repo's 500-line ceiling. This PR splits it with a pure move inside packageauth. No function body, signature, name or comment changes; only the files the declarations live in, and their import blocks.store_postgres.goNewPostgresStore, user CRUD,nullTimePtr,scanUser,Pingstore_postgres_groups.go(new)GetGroup,CreateGroup,UpdateGroup,DeleteGroup,ListGroups,scanGroupstore_postgres_sessions.go(new)CreateSession,GetSession,DeleteSession,DeleteUserSessions,CleanupExpiredSessionsstore_postgres_admin.go(new)isDuplicateKeyError,isEmailDuplicateError,isLastAdminConstraintViolation,AdminExists,CountGroupMembers,withAdminInvariantLock,CreateAdminIfNoneThere are five commits, one move each, each ≤400 added+deleted lines: 224, 186, 213, 165 and 321.
Verification:
store_postgres.goand from the four files at HEAD. Both sides have 34 declarations, and the sorted sets are identical.package auth, import blocks and blank lines.go build ./...andgo vet ./internal/auth/pass after every commit.go test -race ./internal/auth/passes, and so doesgo test -race -tags integration ./internal/auth/on real Postgres (testcontainers).🤖 Generated with Claude Code
Summary by CodeRabbit