Skip to content

feat(cloud): active-target selection core (set_active_target)#67

Merged
sourcehawk merged 6 commits into
feature/cloud-context-mcpfrom
feature/cloud-context-mcp--target-core
May 31, 2026
Merged

feat(cloud): active-target selection core (set_active_target)#67
sourcehawk merged 6 commits into
feature/cloud-context-mcpfrom
feature/cloud-context-mcp--target-core

Conversation

@sourcehawk
Copy link
Copy Markdown
Owner

Description

Towards #44

Adds the provider-agnostic core that lets the operator agent pick which project (GCP) or account (AWS) subsequent run_cli commands run against, from a deployment-pinned set. The cloud MCP Server now holds the active target as in-memory session state and injects a provider-supplied env var into each run_cli child process, never via os.Setenv — the same per-exec discipline the identity probe follows. This is PR A of the feature: it lands the Provider interface extension, the server state and selectable-set logic, the set_active_target tool, and the run_cli guard, all driven against the in-package fake. The GCP/AWS account config and launcher wiring follow in PR B.

Changes

  • Provider interface gains ConfiguredTargets() []Target and ActiveTargetEnv(targetID string) []string; new Target{ID,Name} type.
  • Server tracks an activeTarget; selectableTargets resolves it from configured targets → scope.Projects → live inventory, and setActive rejects any id outside that set so the agent can never name an arbitrary target.
  • subprocessEnv appends the provider's active-target env per exec; a single selectable target is default-active from session start.
  • New set_active_target tool (registered between session_status and run_cli, added to ToolSpecs()); the wire test enforces the catalog match.
  • run_cli returns an actionable error pointing at set_active_target when no target is active and more than one is selectable.
  • session_status reports the active target via a new IdentityStatus.ActiveTarget field.
  • The real gcp/aws providers implement the two new methods to keep the tree compiling (gcp: CLOUDSDK_CORE_PROJECT; aws: AWS_PROFILE); PR B fleshes out the AWS accounts/profile generation.

Challenges

Widening the Provider interface broke the compile-time conformance assertions in the gcp/aws providers and a probe test double. Rather than land a red build, this PR gives them the methods now — gcp in its final form, aws in the minimal correct shape that PR B's profile-name logic replaces.

Related

  • PR B (provider impls + AWS accounts config + launcher wiring) builds on this.
  • Design: docs/superpowers/specs/2026-05-31-cloud-active-target-selection-design.md.

Testing

make test-go (race-clean, 43 packages, 0 failures) and make lint (0 issues) both green. New tests in pkg/mcp/cloud cover: the fake satisfying the extended interface; selectableTargets across all three fallback sources; setActive membership rejection; subprocessEnv target injection; single- vs multi-target default-active; the set_active_target tool (valid + rejected ids); run_cli's no-active-target guard and its release once a target is set; and session_status reporting the active target. The wire test fails if set_active_target registration drifts from ToolSpecs(). No frontend/ changes.

🤖 Generated with Claude Code

sourcehawk and others added 6 commits May 31, 2026 04:52
…owup)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…ication

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…gured

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The Provider interface gained ConfiguredTargets and ActiveTargetEnv, so the
gcp and aws realizations and the providers-package probe double must implement
them to keep the tree compiling. gcp pins CLOUDSDK_CORE_PROJECT and returns no
configured set (its set is scope/inventory); aws pins AWS_PROFILE. The
deployment-configured aws accounts list arrives with the AWS accounts config.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sourcehawk sourcehawk merged commit ab11261 into feature/cloud-context-mcp May 31, 2026
4 checks passed
@sourcehawk sourcehawk deleted the feature/cloud-context-mcp--target-core branch May 31, 2026 03:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant