Authentication files
Session construction, page protection and access predicates. Public metadata supplies scope; unsafe metadata supplies preferences.
System explanation · Choosing checks
Source files
| File | Responsibility / entry points |
|---|---|
src/lib/auth/client.tsx
|
Client session provider and actor refresh when Clerk identity changes. SessionProvider, useSession |
src/lib/auth/page.tsx
|
ProtectedPage and getPageActor: page redirects/capabilities and navigation
provider. ProtectedPage, getPageActor |
src/lib/auth/roster.ts
|
Synthetic 14-person staff graph and role-based fixture actor lookup. demoRoster, demoActor |
src/lib/auth/actor.ts
|
Role and session actor schemas, and the small actor shape saved in records. roleSchema, actorSchema, Actor, ActorRef, actorRef, sameActor |
src/lib/auth/scope.ts
|
Capability table, examiner scope, visibility predicates and AccessError. AccessError, can, Capability, examinerScope, canAccessReview, assertReviewAccess |
src/lib/auth/server.ts
|
Clerk/test session to validated Actor; cached reads and account-setup errors. AccountSetupError, ServerSession, getServerSession, getActor |
Tests
| File | Responsibility / entry points |
|---|---|
src/lib/auth/scope.test.ts
|
Checks scope. Example: “staff graph limits examiner ownership and supervisor coverage across teams”. |