generalize Provider.APIKeyEnv / NATS.TokenEnv / Telegram.TokenEnv to SecretRef #940

Closed
opened 2026-10-27 13:38:23 +00:00 by sam · 0 comments
Owner

Follow-up to archie-core-xec, which only migrated Forge.TokenEnv (self-contained call site). Provider.APIKeyEnv is forwarded THREE different ways that all assume the secret is reachable by name in the daemon's own env, not resolved centrally:

  1. agentexec.NewRuntime -> passes the env-var NAME into ai-sdk/runtime's AuthConfig.APIKeyEnv, which lazily os.Getenv's it later (external module, cannot change its contract).
  2. agentexec.WorkerEnvironment / subprocess.go WorkerEnvironment() -> allowlist-forwards the NAME into a subprocess's environment for archie-agent to read itself.
  3. daemon.containerEnv() -> already eagerly resolves via os.Getenv and injects NAME=value into a container env (this one generalizes cleanly).

Migrating Provider.APIKeyEnv to SecretRef requires switching cases 1 and 2 from name-forwarding to eager-resolve-via-secret.Registry-then-inject-value (ai-sdk/runtime.AuthConfig.APIKey literal field already supports this per its ResolveAPIKey fallback chain -- no ai-sdk/runtime changes needed, just stop relying on its lazy os.Getenv path for non-env engines). Also migrate NATSConfig.TokenEnv and TelegramConfig.TokenEnv (each has a single simple os.Getenv call site, lower risk than Provider).

Design

secret.Registry must be threaded into agentexec.NewRuntime, WorkerEnvironment, and daemon.containerEnv (or a shared secret-resolution helper) so eager-resolve-then-inject replaces name-forwarding for engines other than the built-in env engine.

Acceptance Criteria

Provider.APIKeyEnv, NATSConfig.TokenEnv, TelegramConfig.TokenEnv replaced with SecretRef; all three consumption paths (in-process runtime, subprocess worker env, container env) resolve via secret.Registry; task check passes; adversarial review finds zero surviving findings; explicit test proving a non-env engine (e.g. a fake test engine) correctly delivers a provider API key to agentexec.NewRuntime via the AuthConfig.APIKey literal field, not APIKeyEnv.

Close reason

Closed


Imported from beads archie-core-1786637500667-412-04faa3e7 · GitHub #433 · type task · priority P2 · created 2026-08-08 · closed 2026-10-01

Follow-up to archie-core-xec, which only migrated Forge.TokenEnv (self-contained call site). Provider.APIKeyEnv is forwarded THREE different ways that all assume the secret is reachable by name in the daemon's own env, not resolved centrally: 1. agentexec.NewRuntime -> passes the env-var NAME into ai-sdk/runtime's AuthConfig.APIKeyEnv, which lazily os.Getenv's it later (external module, cannot change its contract). 2. agentexec.WorkerEnvironment / subprocess.go WorkerEnvironment() -> allowlist-forwards the NAME into a subprocess's environment for archie-agent to read itself. 3. daemon.containerEnv() -> already eagerly resolves via os.Getenv and injects NAME=value into a container env (this one generalizes cleanly). Migrating Provider.APIKeyEnv to SecretRef requires switching cases 1 and 2 from name-forwarding to eager-resolve-via-secret.Registry-then-inject-value (ai-sdk/runtime.AuthConfig.APIKey literal field already supports this per its ResolveAPIKey fallback chain -- no ai-sdk/runtime changes needed, just stop relying on its lazy os.Getenv path for non-env engines). Also migrate NATSConfig.TokenEnv and TelegramConfig.TokenEnv (each has a single simple os.Getenv call site, lower risk than Provider). ### Design secret.Registry must be threaded into agentexec.NewRuntime, WorkerEnvironment, and daemon.containerEnv (or a shared secret-resolution helper) so eager-resolve-then-inject replaces name-forwarding for engines other than the built-in env engine. ### Acceptance Criteria Provider.APIKeyEnv, NATSConfig.TokenEnv, TelegramConfig.TokenEnv replaced with SecretRef; all three consumption paths (in-process runtime, subprocess worker env, container env) resolve via secret.Registry; task check passes; adversarial review finds zero surviving findings; explicit test proving a non-env engine (e.g. a fake test engine) correctly delivers a provider API key to agentexec.NewRuntime via the AuthConfig.APIKey literal field, not APIKeyEnv. ### Close reason Closed --- _Imported from beads `archie-core-1786637500667-412-04faa3e7` · GitHub #433 · type task · priority P2 · created 2026-08-08 · closed 2026-10-01_
sam added the mediumtask labels 2026-10-27 13:38:23 +00:00
sam self-assigned this 2026-10-27 13:38:23 +00:00
sam closed this issue 2026-10-27 13:38:23 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#940