Skip to content

feat(agent): devops agent env gives an agent session its own expiring gateway key, run-index access and a read-only kube identity, written to its settings file or a child process and never printed, with --revoke and an audit of every grant #1154

Closed

Description

@dan-petty

Ready: implementation plan (refined 2026-10-17 at 3dd7fa6)

This section supersedes any text below that conflicts with it.

Decisions

  • Scope: this issue delivers the two slices that wait on nothing, and it closes when they merge. (a) is the DEVOPS_CLI_AI_GATEWAY_URL variable, the grant-aware 401 hint and the Claude Code deny rules. (b) is the k8s/agents/ identity, its Argo CD Application and the orphan-ignore for agent-grant-* Secrets. The grant itself (devops agent env, exec and list, the grant table, the record and the audit) moves to a new item, because it needs gateway virtual keys and the gateway has no database. Both new items are drafted (see Dependencies). The person applying this plan retitles the issue to: "feat(agent): agent sessions get a gateway URL variable, a grant-aware 401 hint, Claude Code deny rules and a read-only kube identity in k8s/agents".
  • 401 hint wording: when DEVOPS_CLI_AGENT_GRANT is set, credentials_error (src/devops_cli/ai/client/models.py:95) says the gateway rejected agent grant <id>, that the grant expired or was revoked, and that a person issues a new one. This replaces the generic "Set DEVOPS_CLI_AI_API_KEY" hint. It does not name devops agent env yet, because that command does not exist until the grant item, and the grant item adds the command name. The id is cut to 256 characters. Both callers get the hint: src/devops_cli/ai/client/base.py:127 and src/devops_cli/ai/gateway.py:266.
  • DEVOPS_CLI_AGENT_GRANT is declared as an environment-only constant in src/devops_cli/config/env.py, like ENV_DEVOPS_CLI_CONFIG (env.py:12). It is not a settings option.
  • Precedence of DEVOPS_CLI_AI_GATEWAY_URL: it sets ai.gateway_url like every other option variable. A task's own ai.tasks.<task>.api_base_url still wins for that task (src/devops_cli/config/settings.py:570-584), as it already wins over the config value. No special case is added.
  • Deny rules: all three land now, in permissions.deny of the checked-in .claude/settings.json: Read(//**/.claude/settings.local.json), Read(~/.claude/settings.json) and Read(~/.kube/**). ~/.kube/config holds the person's admin credentials today, and a person may already have pasted a key into a settings file's env block. The cost is that Claude Code's own settings skills can no longer read those two files, so a person edits them. The rules stop accidental reads only, not printenv or a script; the issue's Key questions already say so.
  • Where the agents namespace lives: in k8s/namespaces.yaml, with the other namespaces, which the base Application owns. It gets the same labels and Prune=false,Delete=false annotation as devops (k8s/namespaces.yaml:88-98), with Pod Security restricted.
  • Argo CD: k8s/agents/ gets its own Application, k8s/argocd/apps/agents.yaml (project homelab, destination namespace agents, automated prune and self-heal, and the same finalizer and retry as k8s/argocd/apps/devops.yaml). The devops Application also carries Image Updater and host overrides, and the agent identity should not be coupled to them. The homelab AppProject's destinations gain agents.
  • deploy-stack: both manifests join _MANIFESTS_BY_STACK["devops"] (src/devops_cli/commands/k8s/stack_lifecycle.py:194-203). AGENTS.md requires devops k8s deploy-stack --stack all to deploy every manifest, and the identity serves devops-cli's agents. Teardown deletes them in reverse, as it does the rest of the list.
  • No NetworkPolicy in agents: nothing runs there, and the identity cannot create pods anywhere.
  • Orphan-ignore: {group: '', kind: Secret, name: agent-grant-*} joins the homelab project's list (k8s/argocd/apps/projects.yaml:39-79), following the sh.helm.release.v1.* glob. Grant Secrets are runtime objects that the grant item creates. Without the entry, Argo CD warns about every live grant. Prune never touches untracked objects either way.
  • The open question about live reloads (does Claude Code apply an edited env block to a running session?): it moves to the grant item as a person check. Until it is confirmed, the grant command tells the person to start a new session. It does not affect (a) or (b).

Delivery

  1. PR 1 (S): the gateway URL variable, the grant-aware 401 hint and the deny rules. Refs feat(agent): devops agent env gives an agent session its own expiring gateway key, run-index access and a read-only kube identity, written to its settings file or a child process and never printed, with --revoke and an audit of every grant #1154. Tests first:

    • tests/test_config_env_overrides.py: DEVOPS_CLI_AI_GATEWAY_URL=https://example.com/v1 makes load_settings().ai.gateway_url equal that URL, and get_all_env_var_specs() lists the variable as not secret.
    • tests/test_ai_gateway.py: with DEVOPS_CLI_AGENT_GRANT=g-123 set, a 401 from the gateway raises AICredentialsError whose message names g-123 and not DEVOPS_CLI_AI_API_KEY. Without the variable, the message is unchanged. A 300-character id is cut to 256.
    • tests/test_claude_code_settings.py (new): .claude/settings.json parses, and its permissions.deny holds the three rules.

    Files: src/devops_cli/config/options.py (AI_GATEWAY_URL = "ai.gateway_url" beside AI_API_BASE_URL at :24, and in the list at :150), src/devops_cli/config/env.py (constant, OPTION_TO_ENV_VAR entry beside :125, EnvVarSpec beside :329-334, and ENV_AGENT_GRANT), src/devops_cli/ai/client/models.py, .claude/settings.json, the regenerated docs/ENV_VARS.md and docs/CONFIGURATION.md, the three test files, changelog.d/1154.md (### Added and ### Security) and docs/agent/tasks/task-1154-agent-session-prerequisites.md (In Progress, (a) ticked).

  2. PR 2 (S): the read-only agent identity under GitOps. Closes feat(agent): devops agent env gives an agent session its own expiring gateway key, run-index access and a read-only kube identity, written to its settings file or a child process and never printed, with --revoke and an audit of every grant #1154. Tests first:

    • tests/test_k8s_agents_manifests.py (new): the agents namespace in k8s/namespaces.yaml enforces restricted. ServiceAccount agents/devops-agent has automountServiceAccountToken: false. ClusterRoleBinding devops-agent-view has roleRef ClusterRole/view and that one subject. No other Role, ClusterRole, RoleBinding or ClusterRoleBinding under k8s/ names devops-agent. audit_rbac (src/devops_cli/k8s/rbac.py:170) returns no violation for the parsed bindings. _MANIFESTS_BY_STACK["devops"] lists both files.
    • tests/test_k8s_argocd_apps.py: test_projects_whitelists_and_orphaned_resources (:177) expects ("", "Secret", "agent-grant-*") and the agents destination. test_rendered_raw_objects_single_ownership (:217) and test_namespace_and_pvc_data_safety (:277) include k8s/agents.

    Files: k8s/namespaces.yaml, k8s/agents/kustomization.yaml, k8s/agents/serviceaccount.yaml, k8s/agents/clusterrolebinding.yaml, k8s/argocd/apps/agents.yaml, k8s/argocd/apps/projects.yaml, src/devops_cli/commands/k8s/stack_lifecycle.py and k8s/README.md. The README changes are: a new "Agent sessions" section on what the identity can and cannot do and how it is applied; agents/ in the Directory Structure; and the leaf Application counts at :396 and :631 going from 22 (8 raw) to 23 (9 raw). Also the two test files, the PR's lines in changelog.d/1154.md (### Added), and the task file set to Done with (b) ticked.

Acceptance criteria

  • DEVOPS_CLI_AI_GATEWAY_URL sets ai.gateway_url, the env spec lists it as not secret, and docs/ENV_VARS.md shows it.
  • With DEVOPS_CLI_AGENT_GRANT set, a gateway 401 names the grant id and says a person issues a new grant. Without it, the hint is unchanged.
  • .claude/settings.json denies Read(//**/.claude/settings.local.json), Read(~/.claude/settings.json) and Read(~/.kube/**).
  • k8s/agents/ holds only ServiceAccount devops-agent (automount off) and ClusterRoleBinding devops-agent-view to the built-in view. Nothing else in k8s/ grants that ServiceAccount a role, and audit_rbac reports no violation.
  • Namespace agents is restricted and carries Prune=false,Delete=false.
  • Argo CD Application agents syncs k8s/agents, the homelab project admits the agents destination, and agent-grant-* Secrets are ignored orphans.
  • devops k8s deploy-stack --stack devops (and --stack all) applies both manifests on a cluster without Argo CD, and the dry run lists them.
  • No test touches a cluster or the network, and each new test's call phase is under 1 s.
  • uv run devops docs check passes. CHANGELOG.md and docs/ROADMAP.md are not edited.
  • uv run devops ci passes.
  • Pending a person: after Argo CD syncs the merge (or after uv run devops k8s deploy-stack --stack devops on a cluster without Argo CD), these print no: kubectl auth can-i get secrets -A --as=system:serviceaccount:agents:devops-agent, kubectl auth can-i create pods/exec -n llm --as=system:serviceaccount:agents:devops-agent and kubectl auth can-i create jobs -n devops --as=system:serviceaccount:agents:devops-agent. And kubectl auth can-i list pods -A --as=system:serviceaccount:agents:devops-agent prints yes.

Current references

  • ai.gateway_url field: src/devops_cli/config/settings.py:470
  • Option-to-variable map, with no gateway entry: src/devops_cli/config/env.py:109
  • The run index variables (the pattern to follow): src/devops_cli/config/env.py:71-72, mapped at :159-160
  • credentials_error: src/devops_cli/ai/client/models.py:95-108
  • Its callers: src/devops_cli/ai/client/base.py:127, src/devops_cli/ai/gateway.py:266
  • Task endpoint folding: src/devops_cli/config/settings.py:570-584
  • .claude/ ignore rules: .gitignore:75-76
  • .claude/settings.json: has permissions.allow only, with no deny and no env
  • homelab AppProject destinations and orphan-ignore list: k8s/argocd/apps/projects.yaml:22-38, :39-79
  • The devops Application (the template for agents): k8s/argocd/apps/devops.yaml
  • devops namespace (the template for agents): k8s/namespaces.yaml:88-98
  • devops stack manifest list: src/devops_cli/commands/k8s/stack_lifecycle.py:194-203
  • Manifest-exists invariant: tests/test_architectural_invariants.py:1410
  • audit_rbac: src/devops_cli/k8s/rbac.py:170. The privileged roles it flags: src/devops_cli/config/constants.py:729-731

Dependencies and order


Problem

The owner's direction of 2026-10-04: once push-secrets works, the credentials can be read with kubectl, but devops-cli should get the functionality that sets up an agent environment.

An agent session (Claude Code in the devcontainer) runs devops from its shell. Today:

  • No gateway credential in the session. Model calls to https://ai.<domain>/v1 answer 401. The only gateway credential is LiteLLM's master key (general_settings.master_key: os.environ/LITELLM_MASTER_KEY, k8s/llm/gateway/configmap.yaml, from llm/llm-gateway-secrets master-key, k8s/llm/gateway/deployment.yaml:52-56). The master key is the proxy admin key: whoever holds it can mint and delete keys and call every model without limit.

  • The owner's rule. Agents never read, print or copy a credential value into a conversation. Today the only ways to give a session the key are a person pasting it into a shell or a settings file, or the agent copying it from the keyring or the cluster. Each of these breaks the rule or hands over the master key.

  • The keyring wins over the environment. build_default_resolver orders the providers keyring, Vault, environment, settings (src/devops_cli/security/secrets.py:338). Inside the devcontainer, the agent shares the person's keyring (one home volume = one identity). So DEVOPS_CLI_AI_API_KEY set for the agent is ignored whenever the keyring is unlocked and holds ai_api_key. That key is the person's key, which may belong to another provider.

  • No environment variable for the gateway URL. ai.gateway_url (src/devops_cli/config/settings.py:457, default http://localhost:4000/v1) has no entry in OPTION_TO_ENV_VAR (src/devops_cli/config/env.py:109). The run index has one: DEVOPS_CLI_RUNS_INDEX_URL and DEVOPS_CLI_RUNS_INDEX_PASSWORD (env.py:80-81).

  • The run index password lives only in the person's settings and keyring. devops ai runs connect reads it from llm/valkey-runs-auth and stores it there (src/devops_cli/commands/ai_runs.py:155-170). It uses secret_value (src/devops_cli/k8s/node_port.py:86), which decodes one Secret key and never logs it. That Secret is not live yet; feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741 creates it.

  • Kube access is the person's admin kubeconfig. kubectl auth can-i --list in the devcontainer shows *.* with every verb (read 2026-10-04). An agent can read every Secret, exec into every pod and delete anything. Cluster: Kubernetes v1.31 (k3s), so bound service-account tokens (kubectl create token --bound-object-kind Secret) are available.

  • The gateway cannot issue virtual keys yet. LiteLLM's virtual keys (/key/generate with duration, max_budget, rpm_limit, tpm_limit, max_parallel_requests, models, key_alias, metadata) need a Postgres database through DATABASE_URL. The gateway sets none:

    • The live Deployment's env names are LITELLM_MASTER_KEY, LITELLM_LOCAL_MODEL_COST_MAP, LITELLM_TELEMETRY, LITELLM_REDIS_HOST and LITELLM_REDIS_PORT (read 2026-10-04), the same as k8s/llm/gateway/deployment.yaml:47-65. The config's general_settings holds only master_key, store_model_in_db: false and proxy_batch_write_at (configmap.yaml:196-199).
    • No Postgres runs in the cluster (no database image in any pod, read 2026-10-04).
    • The gateway's NetworkPolicy allows egress only to the inference backends, Valkey and DNS (k8s/llm/gateway/networkpolicy.yaml).
    • The container has readOnlyRootFilesystem: true with only /tmp writable (deployment.yaml:36, :74-75). LiteLLM runs prisma migrate deploy at start-up once DATABASE_URL is set, and its production guide asks for LITELLM_MIGRATION_DIR on a writable emptyDir under a read-only root filesystem.

    LiteLLM offers no per-client scoped key without the database, so the database is a prerequisite item (see Key questions). It is not an option to hand a session the master key.

  • Budgets do not bind on local models. The gateway config sets no input_cost_per_token or output_cost_per_token, and its models are Ollama models with no cost in the bundled cost map (LITELLM_LOCAL_MODEL_COST_MAP=True). So max_budget limits spend only on models with a cost. On the local tiers, the limits are rpm_limit, tpm_limit and max_parallel_requests. The gateway runs one replica (deployment.yaml:12), so those counters hold in its process. LITELLM_REDIS_HOST is not a name in LiteLLM's documented settings (it reads REDIS_HOST), and the config has no cache or router_settings.redis_host. So no shared counter store should be assumed if the gateway is scaled out.

  • Switching the session to the keyring library's null backend (the fix below) hides every keyring credential, not only ai_api_key. KEYRING_KEYS (src/devops_cli/config/options.py:242) also holds github_token, grafana_token, grafana_password, argocd_token, argocd_password, qdrant_api_key, valkey_password, runs_index_password, logfire_token and cloudflare_api_token. Under the null backend _keyring_get returns nothing (_ensure_keyring_backend, src/devops_cli/config/settings.py:123-141, rejects a backend with priority 0 or less). GitHub still works through gh auth token (get_github_token, settings.py:1051). Commands that need Qdrant, Grafana, Argo CD or Cloudflare credentials stop working in a session that holds a grant.

  • Claude Code reads an env block from ~/.claude/settings.json (user scope) and .claude/settings.local.json (project-local scope, at the repository root; in a worktree, the main checkout's). It applies the block to the session and its tool subprocesses. Claude Code watches its settings files and applies most edits to a running session; env is not among the keys its documentation says are read only at start-up, but that has not been tried here. .claude/* is git-ignored here except .claude/settings.json (.gitignore:71-72). The checked-in .claude/settings.json has no env block and no deny rules today.

  • Permission rules cover file commands only. Claude Code applies Read deny rules to its file tools and to the file commands it recognises in Bash (cat, head, tail, sed), but not to printenv, env or a script that opens the file itself. In a rule, ./path is relative to the current directory and /path to the settings file's project, so a worktree session needs an absolute pattern to reach the main checkout's settings.local.json.

  • Existing pieces to reuse: secret_value (src/devops_cli/k8s/node_port.py:86) and fetch_secret_data (src/devops_cli/k8s/credentials.py:60) for reading cluster Secrets; node_port_address (node_port.py:77) for the run index URL; record_audit_event (src/devops_cli/core/audit.py:35, a 0600 JSONL log); the temp-file-and-os.replace write in save_settings (src/devops_cli/config/settings.py:1017, which sets no file mode, so the settings writer here sets 0600 itself); audit_rbac (src/devops_cli/k8s/rbac.py, behind devops k8s rbac-audit); CONST_KEYRING_SERVICE (src/devops_cli/config/constants.py:22, devops-cli); and the kubernetes==36.0.3, httpx2==2.13.0 and keyring==25.7.0 dependencies (pyproject.toml).

Proposed solution

A new command group, devops agent, issues each agent session its own credentials. These are a grant: an id, an agent name, an expiry, and the credentials minted for it. The command writes them where the agent's process reads them and never prints them. One table, held as data like #741's Secret table, lists the environment variables a grant sets, where each value comes from, and which item adds it.

What a grant contains

Env name Value Source when a person runs it (keyring unlocked) Source from the cluster (--source cluster) Lifetime
DEVOPS_CLI_AI_API_KEY a new LiteLLM virtual key, alias agent-<name>-<grant id> minted with the master key from keyring llm_gateway_master_key (#741) minted with llm/llm-gateway-secrets master-key, read with secret_value --ttl (LiteLLM duration)
DEVOPS_CLI_AI_PROVIDER gateway literal literal none
DEVOPS_CLI_AI_GATEWAY_URL (new) ai.gateway_url settings settings none
DEVOPS_CLI_RUNS_INDEX_URL runs.index_url, else node_port_address as in ai runs connect settings cluster none
DEVOPS_CLI_RUNS_INDEX_PASSWORD the run index password keyring runs_index_password llm/valkey-runs-auth password shared, see Key questions
KUBECONFIG path of a 0600 kubeconfig holding a bound token for ServiceAccount agents/devops-agent token from the TokenRequest API, made with the caller's context same --ttl
PYTHON_KEYRING_BACKEND keyring.backends.null.Keyring literal literal none
DEVOPS_CLI_AGENT_GRANT the grant id (not a secret) generated generated none
  • The master key never leaves the command. It is used for one POST /key/generate and one POST /key/delete on revoke, and is never written anywhere. It is sent to the gateway's admin routes at the root of ai.gateway_url, over the same tunnel HTTPS host the CLI already uses. Before minting, the command reads the gateway's /health/readiness and stops when its db field does not report a connected database, so a gateway without the database is named before any key is sent.
  • The person's keyring stays out of the session. PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring is the keyring library's own null backend, so devops in the agent session resolves credentials only from the environment. It never reads the person's ai_api_key, and feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's push-secrets refuses to run there because the backend is not an encrypted one. gh keeps its own store and is not affected. The other keyring credentials are hidden too (see Problem); the command's output lists the KEYRING_KEYS entries the session will not see.
  • Kube access. New manifests under k8s/agents/ (namespace agents, Pod Security restricted):
    • ServiceAccount devops-agent, automountServiceAccountToken: false.
    • ClusterRoleBinding devops-agent-view to the built-in view ClusterRole. On this cluster it aggregates only system:aggregate-to-view and the metrics reader (read 2026-10-04). It allows reads, including pods/log and ConfigMaps in every namespace, and no Secrets, serviceaccounts/token, pods/exec, pods/portforward or writes. A scan of the live ConfigMaps and pod env on 2026-10-04 found no literal credential (the matches were bearer_token_file paths).
    • No write access, and in particular no Job creation. feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's cluster Jobs run ENTRYPOINT ["devops"] with the devops-cli Secret (the master key as DEVOPS_CLI_AI_API_KEY, and GH_TOKEN) and egress to any public address on 443. Only the Job's args change, but args alone run any devops command with those credentials: unlimited model calls under the master key, outside every grant limit, and any GitHub write the CLI offers as the machine account, with the output readable through pods/log. Whether any command forwards the key to a host named in its args has not been audited; the CLI has many URL options. An admission policy on command, env or volumes does not close any of this. So devops k8s run-job stays with the person's context, and agent Job creation waits for the follow-up in Key questions.
    • The token comes from kubectl create token devops-agent -n agents --duration <ttl> --bound-object-kind Secret --bound-object-name agent-grant-<id> --bound-object-uid <uid>. The bound object is an empty Secret, agents/agent-grant-<id>, labelled with the grant id and agent name, created just before. Deleting it invalidates the token, so each grant is revoked on its own. The token is read from kubectl's captured stdout.
    • The kubeconfig copies only the server and CA of the caller's context, read with kubectl config view --minify --flatten -o jsonpath='{.clusters[0].cluster}', so the caller's client credentials are never read. It is written by Python as YAML at mode 0600, never with kubectl config set-credentials --token, which would put the token in argv.

Commands

devops agent env NAME [--target local|user] [--ttl 8h] [--rpm N] [--tpm N] [--max-parallel N] [--budget USD] [--models M]... [--kube/--no-kube] [--runs/--no-runs] [--source auto|keyring|cluster] [--context CTX] [--revoke] [--dry-run]

  • --target local (the default) merges the grant's names into the env block of the repository's .claude/settings.local.json. --target user uses ~/.claude/settings.json.

    • The file is read as JSON, and only the grant's keys are added or replaced. Other keys and other env entries stay as they were.
    • It is written atomically (temp file in the same directory, os.replace) with mode 0600, and an existing file's mode is tightened to 0600.
    • A file that is not valid JSON exits 1 and is left as it is.
  • --source. auto uses the keyring when it has an encrypted, unlocked backend. Otherwise it reads the cluster Secrets with the caller's context. keyring and cluster force one source. A locked keyring under --source keyring exits 1 naming devops devcontainer unlock-keyring, as in feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741.

  • Re-running for the same NAME refreshes the grant. It mints the new grant first, writes it, then revokes the old one, so the session is never left without a working key.

  • Limits. The defaults are --ttl 8h, --rpm 60 and --max-parallel 2, plus --models with the gateway's devops-* groups, the pinned review groups qwen3-coder:30b and gpt-oss:20b, and the embedding group bge-m3:latest (configmap.yaml). --ttl is capped at 7d. --budget is passed as max_budget and only binds on models with a cost; the help text says so.

  • --no-kube and --no-runs leave those rows out. A namespace or Secret that does not exist (agents before the manifests are applied, or llm/valkey-runs-auth before feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741) leaves its row out with a warning naming the command that creates it. The gateway key row is required.

  • Output. One line per env name with its source and state (minted, written, unchanged, revoked, skipped), followed by the target path, the expiry in UTC and the key alias. Never a value.

  • --dry-run reads settings and runs only kubectl get on names. It mints nothing, writes nothing, and prints the same lines as would ….

  • --revoke:

    • calls POST /key/delete with the grant's key alias (key_aliases);
    • deletes agents/agent-grant-<id>, which invalidates the token;
    • deletes the kubeconfig file;
    • removes the grant's names from the target file's env block, but only when they still hold the grant's values. The comparison is in memory, so a later grant or a person's own edit is not removed.

    Each step runs even when an earlier one failed, and the output names any step that did not complete.

devops agent exec NAME [same limits] -- CMD... mints a grant, runs CMD with the grant in its environment (os.environ plus the grant, passed to subprocess.run(env=...)), and revokes the grant when CMD exits, including on Ctrl-C. The values are never written to disk, except the kubeconfig, which is deleted on exit. If revocation fails, the expiry still ends the grant. The command exits with CMD's exit code.

devops agent list prints each grant from the local record: name, id, target, env names, expiry, key alias, and whether the grant's Secret still exists. --spend adds each key's spend and request count from LiteLLM, looked up by alias with the master key and printed as numbers only.

Record and audit

  • Local record. Each grant is recorded in <data dir>/agents/grants.json (0600) with the id, name, target path, env names, key alias, bound Secret name, kubeconfig path, expiry, the issuing user and the source. No values. --revoke and list read this record.
  • Audit log. Every mint, refresh and revoke writes one record_audit_event entry (agent.env.grant, agent.env.revoke, agent.exec) with the same fields, also without values.
  • On the gateway, the key's metadata carries devops_cli_grant, agent and issued_by. LiteLLM's own spend logs then attribute each request to the grant.
  • In the cluster, the grant Secret carries the grant id, agent name and expiry as labels and annotations. The API server's audit log then names the ServiceAccount.

A 401 names the fix

When DEVOPS_CLI_AGENT_GRANT is set and the gateway answers 401, the AI client's error names devops agent env <name> to refresh the grant. It no longer gives the generic missing-key hint.

Other changes

  • DEVOPS_CLI_AI_GATEWAY_URL joins OPTION_TO_ENV_VAR for ai.gateway_url, with an env spec entry.
  • The grant table is a frozen dataclass table in src/devops_cli/agent/grant.py. Later items add rows: the Gitea row (feat(k8s): the homelab runs gitea under argo cd as a read-write internal forge, served in-cluster over http and to workstations at https://git.<domain> through the cloudflare tunnel, with its admin secret pushed from the keyring #1081), and any further service an agent reaches.
  • The gateway calls use the existing httpx2 client with the master key in the Authorization header. The key is never placed in a URL. Secret reads use secret_value or fetch_secret_data. Tokens are made by kubectl, with output captured and never echoed.
  • The project's checked-in .claude/settings.json gains deny rules for Read(//**/.claude/settings.local.json), Read(~/.claude/settings.json) and Read(~/.kube/**). The absolute pattern also reaches the main checkout's file from a worktree session. Claude Code applies them to its file tools and to cat, head, tail and sed in Bash, not to printenv or a script, so they stop accidental reads only.
  • Help strings are added in lang/en/help.py, and the docs are regenerated. The k8s/README.md section "Agent sessions" describes applying k8s/agents/ and the person checks.
  • The PR adds changelog.d/<n>.md and the task file docs/agent/tasks/task-<n>-agent-env.md. CHANGELOG.md and docs/ROADMAP.md are not edited.

Acceptance criteria

In the gate. No network and no cluster. The tests use an httpx2 mock transport for the gateway, a patched subprocess runner for kubectl, a stub keyring and tmp_path homes. Together they take under 1 s, measured with uv run pytest tests/test_agent_env.py tests/test_k8s_agents_manifests.py --durations=0.

  • Grant, --target local:
    • .claude/settings.local.json gains exactly the grant table's env names and keeps every other key.
    • The file mode is 0600, including when an existing file was 0644.
    • Invalid JSON exits 1, and the file is left byte-for-byte unchanged.
  • Gateway key. One POST /key/generate:
    • It goes to the gateway root (no /v1), with Authorization: Bearer <master key>.
    • Its body carries key_alias, duration equal to --ttl, rpm_limit, max_parallel_requests, models and metadata.devops_cli_grant.
    • The written DEVOPS_CLI_AI_API_KEY is the key the response returned, and it is not the master key.
  • Master key nowhere.
    • The master key is not in the settings file, the record, the audit log or the kubeconfig.
    • No recorded argv, log record (caplog), stdout or stderr contains any test value: the master key, the virtual key, the run index password or the token.
  • Keyring isolation.
    • The env block sets PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring.
    • With that variable set and DEVOPS_CLI_AI_API_KEY set, get_ai_api_key(load_settings()) returns the environment value, even though the stub keyring holds a different ai_api_key.
  • Sources.
    • --source keyring reads llm_gateway_master_key and runs_index_password and runs no kubectl get secret.
    • --source cluster reads the two Secrets through secret_value and touches no keyring.
    • auto with a locked stub keyring falls back to the cluster.
    • --source keyring with a locked keyring exits 1 with the unlock hint and makes no gateway call.
  • Kube token.
    • Exactly one kubectl create token devops-agent -n agents --duration 8h --bound-object-kind Secret --bound-object-name agent-grant-<id> --bound-object-uid <uid> runs, after the grant Secret is created, and its argv holds no token.
    • The only kubectl config view call is the --minify --flatten -o jsonpath='{.clusters[0].cluster}' read. The kubeconfig's user holds only the token, and its cluster entry equals the caller's server and CA. No kubectl config set-credentials runs.
    • --no-kube runs neither command and writes no KUBECONFIG.
  • Refresh. A second run for the same name mints, writes, then deletes the old alias and the old grant Secret, in that order.
  • Revoke.
    • --revoke NAME runs POST /key/delete with the alias, kubectl delete secret agent-grant-<id> -n agents and the kubeconfig unlink, and removes the env names.
    • A gateway failure still runs the other steps and exits 1 naming the failed step.
    • A name whose value was replaced since the grant is left in the file.
  • exec.
    • The child receives the grant in its env argument.
    • No settings file is written.
    • The grant is revoked after the child exits, including when the child raises KeyboardInterrupt.
    • The command exits with the child's exit code (3 in the test).
  • Missing pieces.
    • With no agents namespace, the kube row is skipped with a warning naming devops k8s apply k8s/agents/ --template.
    • With no valkey-runs-auth, the runs rows are skipped, with a warning naming devops k8s push-secrets.
    • A gateway whose /health/readiness reports no connected database exits 1 before any POST. The message names the database prerequisite item. Nothing is written, and no fallback to the master key happens. A /key/generate that still fails the same way gets the same message.
  • --dry-run makes no POST, no write and no create/delete, and prints names and states only.
  • Record and audit.
    • grants.json and one audit entry per action hold the id, name, alias, env names and expiry.
    • A test that searches both files for every test value finds none.
  • Manifests (tests/test_k8s_agents_manifests.py):
    • The namespace agents is restricted, and the ServiceAccount has automount off.
    • The ClusterRoleBinding's roleRef is the built-in view.
    • No other Role, ClusterRole or binding names the ServiceAccount, so it has no write verb anywhere and no create on batch/jobs.
    • audit_rbac (the check behind devops k8s rbac-audit) reports no violation for the parsed manifests.
  • Env spec. DEVOPS_CLI_AI_GATEWAY_URL sets ai.gateway_url, and the env spec test lists it.
  • 401 hint. With DEVOPS_CLI_AGENT_GRANT set, a 401 from the gateway names devops agent env.
  • uv run devops agent --help lists env, exec and list, and uv run devops docs check passes.
  • uv run devops ci passes within its 5-minute budget.

Pending a person (keyring unlocked, after #741 and the gateway database item):

  1. uv run devops k8s apply k8s/agents/ --template --context <context>.

  2. uv run devops agent env reviewer --dry-run lists every row as would mint or would write, with no value.

  3. uv run devops agent env reviewer exits 0. stat -c %a .claude/settings.local.json prints 600.

  4. In a new Claude Code session in the repository, run these:

    • uv run devops ai gateway status --format json reports "healthy": true;
    • a one-line devops ai call succeeds;
    • kubectl auth can-i get secrets -A prints no;
    • kubectl auth can-i create pods/exec -n llm prints no.

    The agent runs these without reading or printing any value.

  5. From that session, kubectl auth can-i create jobs -n devops prints no, and uv run devops k8s run-job -- --version fails as forbidden. The same command from the person's own shell still succeeds.

  6. uv run devops agent list --spend shows the grant with a request count.

  7. uv run devops agent env reviewer --revoke. After it:

    • the next model call from the session answers 401, and its message names devops agent env reviewer;
    • kubectl --kubeconfig <path> get pods fails, or the file is gone.
  8. uv run devops agent exec reviewer -- uv run devops ai gateway status succeeds. After it, uv run devops agent list shows no live grant for reviewer.

Constraints. These hold for every command:

  • No value reaches argv, a log, stdout, stderr, the record or the audit log. A dry run shows names only.
  • The master key is used only inside the command and is never given to a session.
  • The kube identity a grant writes cannot read Secrets, exec, port-forward, or write anything, Jobs included.
  • These are limits on what a grant hands out, not a boundary against the session itself: the session runs as the person's user, beside the person's ~/.kube/config and keyring (see Key questions).
  • Every grant expires. Revoking one grant leaves the others working.

Key questions

Out of scope

Strategic alignment

Proposed design

Problem statement

The current devops agent environment setup lacks secure, expiring credentials for agent sessions. Agents run with the master key or the person's admin kubeconfig, which poses security risks. The solution is to implement a new devops agent command group that issues each agent session its own expiring gateway key, run-index access and a read-only kube identity, all written to settings files or child processes without printing any values.

Acceptance criteria

  • Criterion 1: DEVOPS_CLI_AI_GATEWAY_URL sets ai.gateway_url, the env spec lists it as not secret, and docs/ENV_VARS.md shows it.
    Verification: Run uv run pytest tests/test_config_env_overrides.py to verify that DEVOPS_CLI_AI_GATEWAY_URL=https://example.com/v1`` makes load_settings().ai.gateway_url equal that URL, and get_all_env_var_specs() lists the variable as not secret.
  • Criterion 2: With DEVOPS_CLI_AGENT_GRANT set, a gateway 401 names the grant id and says a person issues a new grant. Without it, the hint is unchanged.
    Verification: Run uv run pytest tests/test_ai_gateway.py to verify that with DEVOPS_CLI_AGENT_GRANT=g-123 set, a 401 from the gateway raises AICredentialsError whose message names g-123 and not DEVOPS_CLI_AI_API_KEY. Without the variable, the message is unchanged. A 300-character id is cut to 256.
  • Criterion 3: .claude/settings.json denies Read(//**/.claude/settings.local.json), Read(~/.claude/settings.json) and Read(~/.kube/**).
    Verification: Run uv run pytest tests/test_claude_code_settings.py to verify that .claude/settings.json parses, and its permissions.deny holds the three rules.
  • Criterion 4: k8s/agents/ holds only ServiceAccount devops-agent (automount off) and ClusterRoleBinding devops-agent-view to the built-in view. Nothing else in k8s/ grants that ServiceAccount a role, and audit_rbac reports no violation.
    Verification: Run uv run pytest tests/test_k8s_agents_manifests.py to verify that the agents namespace in k8s/namespaces.yaml enforces restricted. ServiceAccount agents/devops-agent has automountServiceAccountToken: false. ClusterRoleBinding devops-agent-view has roleRef ClusterRole/view and that one subject. No other Role, ClusterRole, RoleBinding or ClusterRoleBinding under k8s/ names devops-agent. audit_rbac (src/devops_cli/k8s/rbac.py:170) returns no violation for the parsed bindings.
  • Criterion 5: Namespace agents is restricted and carries Prune=false,Delete=false.
    Verification: Verify that k8s/namespaces.yaml contains the agents namespace with pod-security.kubernetes.io/enforce: restricted and argocd.argoproj.io/sync-options: Prune=false,Delete=false annotations.
  • Criterion 6: Argo CD Application agents syncs k8s/agents, the homelab project admits the agents destination, and agent-grant-* Secrets are ignored orphans.
    Verification: Run uv run pytest tests/test_k8s_argocd_apps.py to verify that test_projects_whitelists_and_orphaned_resources (:177) expects ("", "Secret", "agent-grant-*") and the agents destination. Also, verify that k8s/argocd/apps/projects.yaml contains agents in the destinations list.
  • Criterion 7: devops k8s deploy-stack --stack devops (and --stack all) applies both manifests on a cluster without Argo CD, and the dry run lists them.
    Verification: Run devops k8s deploy-stack --stack devops and verify that it applies both manifests on a cluster without Argo CD. Also, check that the dry run lists them.
  • Criterion 8: No test touches a cluster or the network, and each new test's call phase is under 1 s.
    Verification: Run uv run pytest tests/test_agent_env.py tests/test_k8s_agents_manifests.py --durations=0 to verify that all tests use mocks for network and cluster access and that the call phase of each test is under 1 second.
  • Criterion 9: uv run devops docs check passes. CHANGELOG.md and docs/ROADMAP.md are not edited.
    Verification: Run uv run devops docs check and ensure it passes without any errors.
  • Criterion 10: uv run devops ci passes.
    Verification: Run uv run devops ci to verify that all CI checks pass.

Key questions

  • Should the command name be devops agent?: Yes, proposed to be a top-level group with env, exec and list. (proposed)
  • Does the virtual key need the gateway database first?: Yes, a separate prerequisite item is needed for 'the LiteLLM gateway keeps keys in Postgres'. (proposed)
  • Can agents read their own grants or step around them?: Yes, agents can read their own grants through printenv or scripts, but the design relies on limits, expirations and revocation rather than hiding values. (proposed)
  • Should settings file or child process be used for credential storage?: Both should be supported with --target local as default for Claude Code sessions and exec keeping values off disk. (proposed)
  • What are the default limits for agent credentials?: Default limits are --ttl 8h, capped at 7d; --rpm 60; --max-parallel 2, and models limited to the devops-* groups, the pinned review groups and the embedding group. (proposed)
  • Who may mint agent credentials?: Whoever can read the master key, which today is a person with the keyring unlocked or an admin context. (proposed)
  • Why use bound Secret for kube token?: Bound tokens expire and leave no secret holding the token, but binding each token to an empty per-grant Secret is the Kubernetes mechanism that revokes one token without rotating the ServiceAccount. (proposed)
  • Why limit kube access to 'view' role only?: The 'view' role is the maintained built-in read-only role that excludes Secrets, tokens and exec. Job creation would be unsafe without proper virtual key scoping. (proposed)
  • Is the run index password shared?: Yes, the grant passes the shared password, list shows which sessions hold it, and rotation goes through feat(k8s): devops-cli runs in the homelab cluster as Jobs, and every cluster Secret is pushed from the keyring, also by deploy-stack (devops k8s push-secrets, devops k8s run-job) #741's push-secrets --rotate. (proposed)
  • Should cluster Jobs also use virtual keys?: Once the database item lands, a follow-up switches that row to a long-lived virtual key without an expiry, minted by push-secrets. (proposed)

Open questions

Fit

Fits in one pull request.

Suspected block

the gateway database item, to be filed with this one

Dependencies

None.

Activity

  1. added
    type/feature
    scope/ai
    scope/k8s
    scope/security
    priority/p1-high
    scope/agent
    on Oct 4, 2026
  2. Grantslip commented on Oct 4, 2026

    @Grantslip

    You can get the session off the admin kubeconfig without waiting on Postgres: create a dedicated ServiceAccount whose Role only allows get on the exact Secrets it needs (pin resourceNames), and have devops agent env write a session-local kubeconfig from kubectl create token <sa> --duration=30m. It expires on its own, and can-i --list shrinks to those two reads. For keyring-beats-env, a resolver override the agent-env command sets (e.g. env-only providers for that session) keeps the person's ai_api_key from reaching the agent without changing the order for humans. Until virtual keys exist, I'd rather take the 401 than any path that touches the master key.

    If you'd rather not hand-roll the expiring, per-tool part, Grantslip may fit (free two-week hosted trial): https://grantslip.com

  3. added this to the v0.2.37 milestone on Oct 11, 2026
  4. dan-petty commented on Oct 17, 2026

    @dan-petty
    OwnerAuthor

    Readiness check for v0.2.37, against release/v0.2.36 at 22d8748. Line numbers are at that commit.

    Status: blocked as a whole on an item not yet filed: the LiteLLM gateway needs a database to keep its keys in. Today the gateway has none (k8s/llm/gateway/configmap.yaml:187-191, k8s/llm/gateway/deployment.yaml). Two of the three slices below don't wait on it.

    Today

    • There is no devops agent command group.
    • The secret resolver tries the keyring first (src/devops_cli/security/secrets.py:346).
    • ai.gateway_url is not in src/devops_cli/config/env.py:109.

    References that moved

    • settings.py:457 → :470. _ensure_keyring_backend is at settings.py:133 and save_settings at :1157.
    • refactor(github): one github session per identity owning token, quota and transport #767 removed get_github_token. Its replacement is at src/devops_cli/core/process.py:288.
    • env.py:80-81 → :71-72, mapped at :159-160.
    • src/devops_cli/k8s/credentials.py:60 → :68.
    • KEYRING_KEYS: options.py:242 → :246. It no longer has github_token, and it adds the tavily, webhook and tunnel keys.
    • .gitignore:71-72 → :75-76.
    • ai agents: ai.py:853 → :906.
    • httpx2: 2.13.0 → 2.13.1.
    • The gateway configmap: :196-199 → :187-191.
    • The gateway deployment: :52-56 and :74-75 → :50 and :73.
    • The 401 hint is credentials_error in src/devops_cli/ai/client/models.py:94.

    Dependencies

    Proposed split

    • (a, S, unblocked) The DEVOPS_CLI_AI_GATEWAY_URL environment variable, the 401 hint, and deny rules in the Claude Code settings.
    • (b, S/M, unblocked) The k8s/agents/ manifests, the Argo CD Application, and tests/test_k8s_agents_manifests.py.
    • (c, M/L, waits on the gateway database item) agent/grant.py and commands/agent.py (env, exec, list, revoke), with tests/test_agent_env.py written first.

    Not yet tested: whether Claude Code applies a live edit to the env block in its settings.

  5. dan-petty commented on Oct 18, 2026

    @dan-petty
    OwnerAuthor

    Amendment (2026-10-18): the remainder after this item's planned PRs, folded here by intake

    devops roadmap intake judged the candidate below a duplicate of this item and filed nothing. It is the part of the agent-identity work that needs a new gateway feature (per-session grants, exec and list, revoke and an audit), which this item's refined plan leaves out. It is recorded here as follow-up scope, not as part of the pull requests already planned for this item. Candidate title: "feat(agent): devops agent env, exec and list give an agent session its own expiring gateway key, run-index access and read-only kube identity, never printed, with revoke and an audit of every grant".

    Friction

    An agent session (Claude Code in the devcontainer) runs devops and kubectl with the person's credentials, or with none:

    • The only gateway credential is the master key. A session gets it only when a person pastes it, which breaks the owner's rule that agents never handle credential values, and it hands over the proxy admin key.
    • The keyring wins over the environment. Inside the devcontainer the session shares the person's keyring (one home volume is one identity). So a DEVOPS_CLI_AI_API_KEY set for the agent is ignored whenever the keyring is unlocked and holds ai_api_key.
    • Kube access is the person's admin kubeconfig, which can read every Secret, exec into every pod and delete anything.

    #1154 delivered the parts that need no new gateway feature:

    • the DEVOPS_CLI_AI_GATEWAY_URL variable;
    • a 401 hint that names the grant in DEVOPS_CLI_AGENT_GRANT;
    • Claude Code Read deny rules for the settings files and ~/.kube;
    • ServiceAccount agents/devops-agent, bound to the built-in view role and synced by Argo CD's agents Application, with agent-grant-* Secrets as ignored orphans.

    The gateway database item gives the gateway virtual keys. What is still missing is the command that issues a session its own scoped, expiring credentials, writes them where the session reads them, and never prints them.

    Evidence

    Checked against main at 3dd7fa6, plus the two items above:

    • There is no devops agent command group. devops ai agents already exists and writes AGENTS.md (src/devops_cli/commands/ai.py:906), so this group is a top-level devops agent.
    • build_default_resolver orders the providers keyring, Vault, environment, then settings (src/devops_cli/security/secrets.py:346-349).
    • _ensure_keyring_backend rejects a backend whose priority is 0 or less (src/devops_cli/config/settings.py:133). So under keyring.backends.null.Keyring no KEYRING_KEYS entry (src/devops_cli/config/options.py:246) resolves, and devops reads credentials only from the environment.
    • The GitHub token comes from github_token (src/devops_cli/core/process.py:288), through gh's own store, so the null backend does not affect it.
    • save_settings writes through a temp file and os.replace but sets no file mode (src/devops_cli/config/settings.py:1157). A writer for files that hold values must set 0600 itself.
    • Pieces to reuse:
      • secret_value (src/devops_cli/k8s/node_port.py:86), as devops ai runs connect uses it (src/devops_cli/commands/ai_runs.py:155);
      • node_port_address (node_port.py:77);
      • fetch_secret_data (src/devops_cli/k8s/credentials.py:68);
      • record_audit_event (src/devops_cli/core/audit.py:35);
      • the keyring key llm_gateway_master_key (src/devops_cli/k8s/cluster_secrets.py:28);
      • audit_rbac (src/devops_cli/k8s/rbac.py:170);
      • the pinned httpx2==2.13.1, keyring==25.7.0 and kubernetes==36.0.3 (pyproject.toml:19, :22, :25).
    • credentials_error (src/devops_cli/ai/client/models.py:95) names the grant id after feat(agent): devops agent env gives an agent session its own expiring gateway key, run-index access and a read-only kube identity, written to its settings file or a child process and never printed, with --revoke and an audit of every grant #1154, but not yet a command to refresh it.
    • Not yet tried: whether Claude Code applies an edited env block to a session that is already running. Its documentation does not list env among the keys it reads only at start-up.

    Remedy

    Build the grant as #1154's body designed it ("Proposed solution", "Commands", "Record and audit", and the grant bullets of "Acceptance criteria"), without the parts #1154 already delivered:

    • Code. A frozen dataclass grant table goes in src/devops_cli/agent/grant.py, and the command group in src/devops_cli/commands/agent.py:
      • devops agent env NAME, with --target local|user, --ttl (default 8h, capped at 7d), --rpm (60), --tpm, --max-parallel (2), --budget, --models, --kube/--no-kube, --runs/--no-runs, --source auto|keyring|cluster, --context, --revoke and --dry-run;
      • devops agent exec NAME -- CMD...;
      • devops agent list [--spend].
    • Gateway key. One POST /key/generate at the gateway root, with the master key taken from the keyring or from llm/llm-gateway-secrets. It never leaves the command and never appears in argv, a log or a file.
      • Before it mints, the command reads /health/readiness and stops, naming the database item, when no database is connected. It never falls back to the master key.
      • Revoke is POST /key/delete by alias.
    • Kube identity. First an empty agents/agent-grant-<id> Secret, then a kubectl create token request for the devops-agent ServiceAccount in agents, with a --duration of the grant's lifetime, bound to the agent-grant-<id> object by name and uid, read from captured stdout.
      • The kubeconfig is written by Python at mode 0600, with only the caller's server and CA.
      • Deleting the Secret revokes that one token.
    • What a grant sets: DEVOPS_CLI_AI_API_KEY, DEVOPS_CLI_AI_PROVIDER=gateway, DEVOPS_CLI_AI_GATEWAY_URL, DEVOPS_CLI_RUNS_INDEX_URL, DEVOPS_CLI_RUNS_INDEX_PASSWORD, KUBECONFIG, PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring and DEVOPS_CLI_AGENT_GRANT.
      • The default target is the repository's .claude/settings.local.json; --target user writes ~/.claude/settings.json. The write is an atomic JSON merge at 0600, invalid JSON is left untouched, and only names that still hold the grant's values are removed on revoke.
      • exec passes the grant through subprocess.run(env=...), revokes it on exit (including Ctrl-C), and returns the child's exit code.
    • Record and audit. <data dir>/agents/grants.json (0600) and one record_audit_event per mint, refresh and revoke, holding names, ids, aliases and expiry, never values.
      • The key's metadata carries the grant id, agent name and issuer.
      • The command's output lists the KEYRING_KEYS entries the session will not see.
    • 401 hint. credentials_error adds devops agent env <name> to the grant message that feat(agent): devops agent env gives an agent session its own expiring gateway key, run-index access and a read-only kube identity, written to its settings file or a child process and never printed, with --revoke and an audit of every grant #1154 added.
    • No MCP tool. An MCP tool would let an agent mint its own credentials.
    • Tests first, in tests/test_agent_env.py: an httpx2 mock transport for the gateway, a patched subprocess runner for kubectl, a stub keyring and tmp_path homes, with no network or cluster, and under 1 s together. They cover feat(agent): devops agent env gives an agent session its own expiring gateway key, run-index access and a read-only kube identity, written to its settings file or a child process and never printed, with --revoke and an audit of every grant #1154's grant criteria: the target merge and mode, the /key/generate body, the master key absent everywhere, keyring isolation, the sources, the kube token argv, refresh order, revoke with partial failure, exec, missing namespace or Secret warnings, the missing-database stop, --dry-run making no request, and the record and audit holding no value.
    • Also: help strings in src/devops_cli/lang/en/help.py, regenerated docs, the "Agent sessions" section of k8s/README.md extended with the grant commands, a changelog.d/<n>.md fragment and a task file. CHANGELOG.md and docs/ROADMAP.md are not edited.
    • Pending a person (keyring unlocked, after the database item): feat(agent): devops agent env gives an agent session its own expiring gateway key, run-index access and a read-only kube identity, written to its settings file or a child process and never printed, with --revoke and an audit of every grant #1154's steps 2 to 8. One more check: after devops agent env reviewer, does the Claude Code session that is already running see the new env block? Until a person confirms it does, the output tells the person to start a new session.

    Depends on: the gateway database item (filed with this one) and #1154 (both of its PRs). #1081 later adds a Gitea row to the grant table without changing it.

    Out of scope: switching the cluster Jobs to a virtual key and giving the agent identity Job creation (a later item, once the database item lands), per-agent Valkey users, Qdrant read-only tokens, a narrower issuer role, and a separate devcontainer or home volume per agent.

  6. dan-petty commented on Oct 19, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1684, merged into release/v0.2.37 as 44f3965.

    Closes #1154

    13 file(s) changed.

    How it was verified

    Check runs at 69a1f3f:

    • Audit Defect PR Hardening: skipping
    • Prune PR DevContainer Images: pass
    • zizmor: pass
    • devops-cli: pass
    • bandit: pass
    • CodeQL: pass
    • Rule Pack Tests: pass
    • Static Analysis: pass
    • Analyze (python): pass
    • Tests & Coverage: pass
    • Fail-to-Pass Self-Check: pass
    • Changed-Test Independence: pass
    • Fail-to-Pass Check: pass
    • Analyze (actions): pass
    • Dependency Freshness: skipping
    • Service Image: skipping
    • DevContainer Image: skipping

    Acceptance Criteria of docs/agent/tasks/task-1154-agent-session-prerequisites.md:

    • DEVOPS_CLI_AI_GATEWAY_URL sets ai.gateway_url, the env spec lists it as not secret, and docs/ENV_VARS.md and docs/CONFIGURATION.md reflect it.
    • With DEVOPS_CLI_AGENT_GRANT set, a gateway 401 names the grant ID and says a person issues a new grant; without it, the hint is unchanged. Long grant IDs are capped at 256 characters.
    • .claude/settings.json denies Read(//**/.claude/settings.local.json), Read(~/.claude/settings.json), and Read(~/.kube/**).
    • Unit and integration tests verify environment overrides, grant 401 hints, and settings file deny rules.
    • uv run devops docs check passes with all generated documentation up to date.
    • k8s/agents/ holds ServiceAccount devops-agent (automount off) and ClusterRoleBinding devops-agent-view to the built-in view.
    • Namespace agents is restricted and carries Prune=false,Delete=false.
    • Argo CD Application agents syncs k8s/agents, the homelab project admits the agents destination, and agent-grant-* Secrets are ignored orphans.
    • devops k8s deploy-stack --stack devops (and --stack all) applies both manifests on a cluster without Argo CD, and the dry run lists them.
    • Pending a person: after Argo CD syncs the merge (or after uv run devops k8s deploy-stack --stack devops on a cluster without Argo CD), these print no: kubectl auth can-i get secrets -A --as=system:serviceaccount:agents:devops-agent, kubectl auth can-i create pods/exec -n llm --as=system:serviceaccount:agents:devops-agent and kubectl auth can-i create jobs -n devops --as=system:serviceaccount:agents:devops-agent. And kubectl auth can-i list pods -A --as=system:serviceaccount:agents:devops-agent prints yes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p1-highscope/agentscope/aiscope/k8sscope/securitytype/feature

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions