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

+50
View File
@@ -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
}