fix(cloud): review round 2 — bounded output, degraded-identity reporting, absolute binary, doc/field cleanup - #66
Merged
sourcehawk merged 6 commits intoMay 31, 2026
Conversation
…bounded execCLI buffered the full stdout/stderr in memory and truncated only after the process returned, so a command emitting a very large response could consume unbounded memory despite defaultOutputLimit. Capture stdout/stderr through a bounded limitedWriter that retains at most limit bytes each and records overflow, so the cap is effective during the run. Every existing guarantee is preserved: no shell, explicit minimal env, closed stdin, Truncated set on overflow, stderr captured and capped, non-zero exit as a normal CLIResult, real start/exec failure as a Go error. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
When the provider failed to resolve an identity, Probe returned Valid:false with an empty AssumedIdentity even though the caller passed the pinned identity in expected, so session_status no longer named which pinned identity was degraded. Fall back to expected whenever the resulting status has an empty AssumedIdentity, on both the degraded and valid paths, so the displayed identity is always the pinned one. Degrade-never-error semantics are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
A provider construction failure (e.g. a missing gcloud/aws binary) returned
IdentityStatus{Provider, Valid:false, Hint} with no AssumedIdentity, so
preflight and connections reported the degraded source without the identity
the operator must fix. Carry src.AssumedIdentity through the construction-error
status, mirroring the probe-path fallback so both ProbeSource exits name the
pinned identity.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The harness relies on a fixed absolute binary path so a later subprocess env/PATH change cannot redirect what executes, but exec.LookPath returns a relative path (flagged with exec.ErrDot) when PATH carries relative entries. Pass the LookPath result through filepath.Abs in each provider's New(), recovering the relative path on ErrDot and erroring if it still cannot be made absolute. Applied identically to gcp and aws. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The comment claimed output was shaped/redacted, but run_cli returns the provider CLI's raw stdout/stderr, only truncated. State that CLIResult carries the raw CLI stdout (and stderr), capped at the output limit with Truncated set when exceeded, so callers do not assume shaping or redaction beyond truncation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Command.Redact was advertised in the allowlist schema and documented as marking output for secret-scrubbing, but nothing read it before returning run_cli output, so it promised protection that did not exist. No shipped default_commands.json sets it. Remove the field and its doc; run_cli is the gated escape hatch returning raw (truncated) output by design, and typed tools are where projection lives. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Towards #44
Addresses a round of verified Copilot review findings on the read-only cloud-context MCP. Six independent fixes: the harness no longer risks unbounded memory on a large CLI response, a degraded session now names which pinned identity is broken, the provider CLI is pinned to an absolute path so a later PATH change cannot redirect it, and the output-result doc and an unused field are corrected to match what the code actually does. One commit per finding.
Changes
execCLIcaptured stdout/stderr throughbytes.Bufferand truncated only after the process returned, so a very large response could buffer in full before being capped. It now captures through alimitedWriterthat retains at mostlimitbytes each and flags overflow, so the cap is effective while the process runs. All existing guarantees hold: no shell, explicit minimal env, closed stdin,Truncatedon overflow, stderr captured and capped, non-zero exit as a normalCLIResult, real start/exec failure as a Go error.cloud.Probefell back to an emptyAssumedIdentitywhen the provider could not resolve one, sosession_statuscould not say which pinned credential was degraded. It now falls back to theexpectedidentity.ProbeSourcereturned a construction-error status (missinggcloud/aws) without the identity, so preflight and connections reported a degraded source with no identity to fix. It now carriessrc.AssumedIdentitythrough.exec.LookPathreturns a relative path (flagged withexec.ErrDot) whenPATHhas relative entries. Both providers'New()now pass the result throughfilepath.Abs, so a later subprocess env/PATH change cannot reinterpret the binary.CLIResultdoc. It claimed output was shaped/redacted;run_clireturns the raw CLI stdout/stderr, only truncated. The doc now says so.Command.Redactfield. It was advertised in the allowlist schema and documented as marking output for secret-scrubbing, but nothing read it before returningrun_clioutput. No shippeddefault_commands.jsonsets it.Testing
make test-gois green and race-clean across the whole module;make lintreports 0 issues. Each fix landed test-first: a shell-free large-output cap assertion for the harness, degraded- and valid-path identity-fallback assertions forcloud.Probe, a construction-failure identity assertion forProbeSource, and an absolute-path assertion under a relativePATHfor both providers. Nofrontend/changes.🤖 Generated with Claude Code