Guard / foldkit-guard
Who is asking
Pass G.Principal to RemoteServer.handlers and provide the resolved
principal per request:
ts
const handlers = RemoteServer.handlers(backend.server, G.Principal)
// per request: `body` is what it sent, and authentication resolved `principal`
RemoteServer.answer(handlers, body).pipe(Effect.provideService(G.Principal, principal))For live hubs, pass Policy.keyOf so subscribers with identical principals share
refetches while claim changes (such as updated projectIds) get distinct keys:
ts
const hub = Effect.gen(function* () {
return yield* RemoteServer.liveHub([...backend.server.entities.values()], {
key: Policy.keyOf,
})
})On the client, scope persisted caches with G.key(user) (RemotePersistence's
scope) and call Remote.forget on sign-in or sign-out so cached rows from an
earlier user clear immediately.