Trim comments to the non-obvious why
Test and deploy / test (push) Successful in 28s
Test and deploy / deploy (push) Successful in 31s

Drop narration, history and restated-code comments across the repo,
keep short ones for security boundaries, upstream quirks and ordering
constraints, and record the convention in CLAUDE.md.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
2026-11-24 20:49:03 +00:00
co-authored by Claude Opus 5.5
parent effddd2794
commit 4530cb8dc4
222 changed files with 1173 additions and 5423 deletions
+4 -12
View File
@@ -18,9 +18,6 @@ import (
// CreateUser is the resolver for the createUser field.
func (r *mutationResolver) CreateUser(ctx context.Context, input model.CreateUserInput) (*models.User, error) {
// Only an existing admin can create accounts (@admin in the schema) —
// there is no public sign-up. New users are created non-admin;
// setUserAdmin promotes them.
hashedPassword, err := bcrypt.GenerateFromPassword([]byte(input.Password), bcrypt.DefaultCost)
if err != nil {
return nil, err
@@ -55,8 +52,7 @@ func (r *mutationResolver) SetUserAdmin(ctx context.Context, id int, admin bool)
return nil, fmt.Errorf("unauthorized")
}
// Guards against the last admin demoting themselves and locking everyone
// out of the admin UI.
// Stops the last admin locking everyone out.
if uint(id) == callerID {
return nil, fmt.Errorf("cannot change your own admin status")
}
@@ -76,10 +72,8 @@ func (r *mutationResolver) SetUserAdmin(ctx context.Context, id int, admin bool)
// SetUserPermissions is the resolver for the setUserPermissions field.
func (r *mutationResolver) SetUserPermissions(ctx context.Context, id int, permissions []string) (*models.User, error) {
// The whole list is replaced, so the admin panel sends every ticked box
// each time. An unknown key is refused rather than dropped, so a stale
// front end cannot silently save less than it showed. The stored list is
// rebuilt in registry order, which also drops duplicates.
// Full replace. Unknown keys are refused so a stale UI can't silently
// save less than it showed.
want := map[string]bool{}
for _, key := range permissions {
if !services.ValidPermission(key) {
@@ -99,8 +93,7 @@ func (r *mutationResolver) SetUserPermissions(ctx context.Context, id int, permi
return nil, fmt.Errorf("user not found")
}
// No token bump needed: the permission gate reads this column on every
// request, so the change applies to the user's next one.
// No token bump: the gate reads this column on every request.
user.Permissions = granted
if err := r.Store.DB.Save(&user).Error; err != nil {
return nil, err
@@ -129,6 +122,5 @@ func (r *queryResolver) User(ctx context.Context, id int) (*models.User, error)
// PermissionTypes is the resolver for the permissionTypes field.
func (r *queryResolver) PermissionTypes(ctx context.Context) ([]*services.PermissionType, error) {
// A copy, so nothing downstream can write through to the registry.
return ptrs(slices.Clone(services.PermissionTypes)), nil
}