Factory for creating scoped StateGuard