Forgetting a person and keeping requests in the cluster: users forget, keys residency --in-cluster

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ilker ManapandClaude Opus 5.5 committed 2026-10-04 23:27:31 +02:00
1 parent d67bd9b2cc
commit 30f7f3474a
17 files changed
+490 -11

No files matched your search

+44 -1
View File
@@ -35,7 +35,7 @@ func newUsersCmd() *cobra.Command {
newUserStateCmd(open, "reinstate", store.UserActive,
"Let a suspended account work again"),
newUserCreateCmd(open), newUserResetPasswordCmd(open),
newUserJoinCmd(open), newUserLeaveCmd(open), newUserDeleteCmd(open),
newUserJoinCmd(open), newUserLeaveCmd(open), newUserDeleteCmd(open), newUserForgetCmd(open),
newUserAdminCmd(open, "promote", true, "Let an account see the cluster dashboard at /admin"),
newUserAdminCmd(open, "demote", false, "Take away access to the cluster dashboard"),
newUserRoleCmd(open))
@@ -489,3 +489,46 @@ func newUserDeleteCmd(open userOpener) *cobra.Command {
cmd.Flags().BoolVar(&yes, "yes", false, "confirm")
return cmd
}
func newUserForgetCmd(open userOpener) *cobra.Command {
var yes bool
cmd := &cobra.Command{
Use: "forget <user>",
Short: "Erase a person: their account, what was kept of their requests, and their name",
Long: "For a request to be forgotten (GDPR article 17). Beyond delete:\n\n" +
" - their usage — every request record and every sum — is kept, so the\n" +
" totals stay true, under a random pseudonym that links to nothing;\n" +
" - their requests kept by `keys requests`, and their personal files and\n" +
" batches, are deleted;\n" +
" - their name and email are taken out of the audit log;\n" +
" - then the account goes, as delete does.\n\n" +
"Conversations and agent notes belong to projects, not people, and are\n" +
"left: a project forgets them by its retention. Backups taken before\n" +
"still hold everything until they age out.",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
s, err := open(cmd)
if err != nil {
return err
}
defer s.Close()
u, err := resolveUser(cmd.Context(), s, args[0])
if err != nil {
return err
}
if !yes {
return fmt.Errorf("this erases %s and cannot be undone; run again with --yes", u.Email)
}
f, err := s.ForgetUser(cmd.Context(), u.ID, time.Now())
if err != nil {
return err
}
fmt.Fprintf(cmd.OutOrStdout(), "%s forgotten. Their usage (%d requests, %d sums) is now %s; "+
"%d kept requests, %d files and %d batches deleted; %d audit lines no longer name them.\n",
u.Email, f.UsageRows, f.RollupRows, f.Pseudonym, f.Requests, f.Files, f.Batches, f.AuditEvents)
return nil
},
}
cmd.Flags().BoolVar(&yes, "yes", false, "confirm")
return cmd
}