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:
1 parent
d67bd9b2cc
commit
30f7f3474a
17 files changed
+490
-11
No files matched your search
@@ -43,6 +43,7 @@ func newTenancyCmd() *cobra.Command {
|
||||
newLimitsCmd(open),
|
||||
newThreadsCmd(open),
|
||||
newRequestLogCmd(open),
|
||||
newResidencyCmd(open),
|
||||
newMemoryCmd(open),
|
||||
newMoveStoreCmd(),
|
||||
)
|
||||
|
||||
@@ -72,3 +72,53 @@ func share(f float64) string {
|
||||
}
|
||||
return fmt.Sprintf("%g%%", f*100)
|
||||
}
|
||||
|
||||
func newResidencyCmd(open opener) *cobra.Command {
|
||||
var (
|
||||
project string
|
||||
inCluster, anyway bool
|
||||
)
|
||||
cmd := &cobra.Command{
|
||||
Use: "residency",
|
||||
Short: "Keep a project's requests in the cluster, never sent to an outside provider",
|
||||
Long: "With --in-cluster, a model served by an outside provider (external:) is\n" +
|
||||
"refused to the project's keys, and never used for them as a fallback or\n" +
|
||||
"a canary: its prompts do not leave the machines the cluster runs on.\n" +
|
||||
"--anywhere lifts it. Without either, says how it stands.",
|
||||
Example: " llmgw keys residency --project Acme/legal --in-cluster",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, _ []string) error {
|
||||
if inCluster && anyway {
|
||||
return fmt.Errorf("--in-cluster or --anywhere, not both")
|
||||
}
|
||||
s, err := open(cmd.Context())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer s.Close()
|
||||
p, err := resolveProject(cmd.Context(), s, project)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if inCluster || anyway {
|
||||
if err := s.SetInCluster(cmd.Context(), p.ID, inCluster); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
on, err := s.InCluster(cmd.Context(), p.ID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if on {
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "%s's requests stay in the cluster.\n", p.Path)
|
||||
} else {
|
||||
fmt.Fprintf(cmd.OutOrStdout(), "%s's requests may go to outside providers its keys allow.\n", p.Path)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
cmd.Flags().StringVar(&project, "project", "", "project: id, path or unique name")
|
||||
cmd.Flags().BoolVar(&inCluster, "in-cluster", false, "keep its requests in the cluster")
|
||||
cmd.Flags().BoolVar(&anyway, "anywhere", false, "let them go to outside providers again")
|
||||
return cmd
|
||||
}
|
||||
@@ -264,6 +264,14 @@ func (m consoleModel) userMenu(u store.User) *menuDialog {
|
||||
yes: func(m *consoleModel) tea.Cmd { return m.runCLI("Delete "+who, "users", "delete", u.ID, "--yes") }}
|
||||
return nil
|
||||
}},
|
||||
menuItem{"Forget them…", func(m *consoleModel) tea.Cmd {
|
||||
m.confirmD = &confirmDialog{title: "Forget " + who,
|
||||
text: "For a request to be forgotten. Their usage stays, under a random name; their kept\n" +
|
||||
"requests, personal files and batches go; the audit log stops naming them; then\n" +
|
||||
"the account is removed. It cannot be undone.",
|
||||
yes: func(m *consoleModel) tea.Cmd { return m.runCLI("Forget "+who, "users", "forget", u.ID, "--yes") }}
|
||||
return nil
|
||||
}},
|
||||
)
|
||||
return &menuDialog{title: who, items: items}
|
||||
}
|
||||
@@ -508,6 +516,17 @@ func (m consoleModel) orgMenu(r orgRow) *menuDialog {
|
||||
items = append(items,
|
||||
retention("Keep conversations", "threads", "conversations", m.people.threads[r.id]),
|
||||
retention("Keep agent notes", "memory", "notes", m.people.notes[r.id]),
|
||||
menuItem{"Requests stay in the cluster…", func(m *consoleModel) tea.Cmd {
|
||||
m.menuD = &menuDialog{title: "Residency · " + r.path, items: []menuItem{
|
||||
{"In the cluster: never an outside provider", func(m *consoleModel) tea.Cmd {
|
||||
return m.runCLI("Residency", "keys", "residency", "--project="+r.id, "--in-cluster")
|
||||
}},
|
||||
{"Anywhere its keys allow", func(m *consoleModel) tea.Cmd {
|
||||
return m.runCLI("Residency", "keys", "residency", "--project="+r.id, "--anywhere")
|
||||
}},
|
||||
}}
|
||||
return nil
|
||||
}},
|
||||
menuItem{"Keep requests…", func(m *consoleModel) tea.Cmd {
|
||||
l := m.people.requests[r.id]
|
||||
sample := "1"
|
||||
|
||||
+44
-1
@@ -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
|
||||
}
|
||||
Reference in new issue
Block a user