carlos / platform Public

group verb: never retry a credential failure; timeout tests (Astra r1)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude pushed by paul@keymail.dev 0e4102d19b8fecd2be3bcc5fd7862d153d46ba76 parent fd7378a
4 files changed, +99 −5
  • docs/superpowers/specs/2026-11-09-group-roll-verb-design.md +1 −1
  • internal/grouprollaws/group.go +36 −1
  • internal/grouprollaws/throttle_test.go +61 −2
  • internal/provision/testdata/plan14-root-reads-group-read-transport-retry.tsv +1 −1

CI passed — run details

diff --git a/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md b/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md
index e707b8636..05e64f076 100644
--- a/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md
+++ b/docs/superpowers/specs/2026-11-09-group-roll-verb-design.md
@@ -378,7 +378,7 @@ build to it.
| V15 | A box verb that exits non-zero is `remote` ("returned no complete result"), whatever it printed | The verb's last printable line is carried as `remote_said` ("The command on the member failed: <detail>"), non-printables made spaces, at most 512 characters; with nothing printable it stays `remote`. drain keeps its own report parsing | Dev W slot 2026-11-10: prepare's "pointer artifact does not match requested digest" reached the operator as "no complete result" |
| V16 | `plan` reports a missing provider observation as `record` (FileNotFoundError reached check()) | `plan` says `observation`, as preflight does | REPORT follow-up 3; flagship step 4 2026-11-11 |
| V17 | Every provider call is made once (`--cli-read-timeout`, retries 1) | Reads (the describes, caller identity, HeadBucket, S3 GET and list) are retried while AWS throttles them: four calls at most, about 1, 2 and 4 s apart, jittered; any other failure and the last throttle fail closed as before. Writes and box sessions are never retried. Bare `carlos system group`, its -h and an unknown verb print the group's help | Step-3 dev W4 2026-11-10: the group describe refused under ASG throttling (8a3d302) |
-| V18 | A request that gets no response is one failed call | A read whose request got no response at all (the SDK's RequestSendError: a reset or EOF on a reused connection, no call in CloudTrail) is retried as a throttle is (V17's budget); a timeout is not, and stays one bound. Writes and sessions are never retried | G5 release 1, dev, 2026-11-11: the post-prepare group describe failed in 14 ms with no CloudTrail call; resume closed it (8a3d302) |
+| V18 | A request that gets no response is one failed call | A read whose request got no response at all (the SDK's RequestSendError: a reset or EOF on a reused connection, no call in CloudTrail) is retried as a throttle is (V17's budget); a timeout is not, and stays one bound. A failure to get credentials (AssumeRole, SSO), throttled or unanswered, is never retried, so no credential call repeats. Writes and sessions are never retried | G5 release 1, dev, 2026-11-11: the post-prepare group describe failed in 14 ms with no CloudTrail call; resume closed it (8a3d302) |
Not deviations, recorded so nobody "fixes" them in the port: the drain-rerun
backoff and the TakeHost `wake_timeout` follow-ups from the held build stay
diff --git a/internal/grouprollaws/group.go b/internal/grouprollaws/group.go
index 3d189f893..511b93a02 100644
--- a/internal/grouprollaws/group.go
+++ b/internal/grouprollaws/group.go
@@ -19,6 +19,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/aws/retry"
+ v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4"
"github.com/aws/aws-sdk-go-v2/service/autoscaling"
astypes "github.com/aws/aws-sdk-go-v2/service/autoscaling/types"
"github.com/aws/aws-sdk-go-v2/service/ec2"
@@ -73,6 +74,9 @@ func newAdapter(cfg aws.Config, c grouproll.Config) *Adapter {
}
cfg.HTTPClient = freeze(cfg.HTTPClient)
cfg.APIOptions = append(append([]func(*middleware.Stack) error{}, cfg.APIOptions...), boundBodyOption)
+ if cfg.Credentials != nil {
+ cfg.Credentials = taggedCredentials{cfg.Credentials}
+ }
// Applied after the SDK's own endpoint resolution, so neither a profile
// nor the environment can redirect a client (spec §4).
return &Adapter{
@@ -195,7 +199,8 @@ func readCall[T any](parent context.Context, fn func(context.Context) (T, error)
raw = e
return o, e
})
- if err == nil || attempt >= throttleAttempts || parent.Err() != nil || !(throttled(raw) || unanswered(raw)) {
+ if err == nil || attempt >= throttleAttempts || parent.Err() != nil || signing(raw) ||
+ !(throttled(raw) || unanswered(raw)) {
return out, err
}
if werr := throttleWait(parent, attempt); werr != nil {
@@ -215,6 +220,36 @@ func throttled(err error) bool {
return err != nil && retry.IsErrorThrottles(retry.DefaultThrottles).IsErrorThrottle(err) == aws.TrueTernary
}
+// signing is a failure to get credentials for the request: an AssumeRole
+// or SSO token call that failed, which this SDK reports as "get identity"
+// (and older signers as v4.SigningError). Its nested error can be a
+// throttle or a RequestSendError, but retrying it would repeat the
+// credential issuance, not the read (Astra r1), so readCall never does.
+// newAdapter tags every provider failure as credentialError for this.
+func signing(err error) bool {
+ var c *credentialError
+ var s *v4.SigningError
+ return errors.As(err, &c) || errors.As(err, &s)
+}
+
+// credentialError is a credential provider's failure, tagged.
+type credentialError struct{ err error }
+
+func (e *credentialError) Error() string { return e.err.Error() }
+func (e *credentialError) Unwrap() error { return e.err }
+
+// taggedCredentials tags its provider's failures as credentialError and is
+// otherwise the provider itself (the SDK's cache stays in front of it).
+type taggedCredentials struct{ p aws.CredentialsProvider }
+
+func (t taggedCredentials) Retrieve(ctx context.Context) (aws.Credentials, error) {
+ c, err := t.p.Retrieve(ctx)
+ if err != nil {
+ return c, &credentialError{err}
+ }
+ return c, nil
+}
+
// unanswered is a read that got no response: the SDK's RequestSendError,
// the request could not be sent or its connection failed before an
// answer (a reused keep-alive connection the far end had closed: reset or
diff --git a/internal/grouprollaws/throttle_test.go b/internal/grouprollaws/throttle_test.go
index a9b973e61..e94e1b76c 100644
--- a/internal/grouprollaws/throttle_test.go
+++ b/internal/grouprollaws/throttle_test.go
@@ -2,11 +2,16 @@ package grouprollaws
import (
"context"
+ "net"
"net/http"
"reflect"
"strings"
"syscall"
"testing"
+
+ "github.com/aws/aws-sdk-go-v2/aws"
+ "github.com/aws/smithy-go"
+ smithyhttp "github.com/aws/smithy-go/transport/http"
)
const throttleXML = `<ErrorResponse><Error><Type>Sender</Type><Code>Throttling</Code><Message>Rate exceeded</Message></Error><RequestId>r</RequestId></ErrorResponse>`
@@ -146,9 +151,36 @@ func TestReadsRetryUnanswered(t *testing.T) {
}
}
-// A timeout is not "unanswered": it stays one call's bound (onStall's
-// headers then a body that never comes is the read timeout).
+// failDo fails every request with err before any response.
+type failDo struct {
+ err error
+ sent int
+}
+
+func (f *failDo) Do(*http.Request) (*http.Response, error) { f.sent++; return nil, f.err }
+
+// netTimeout is a dial or read timeout as the transport reports it.
+type netTimeout struct{}
+
+func (netTimeout) Error() string { return "i/o timeout" }
+func (netTimeout) Timeout() bool { return true }
+func (netTimeout) Temporary() bool { return true }
+
+// A timeout is not "unanswered": it stays one call's bound, whether the
+// transport fails before a response (a dial or header timeout, a deadline:
+// RequestSendError around a timeout) or the body stalls after headers.
func TestReadTimeoutNotRetried(t *testing.T) {
+ for name, e := range map[string]error{
+ "dial timeout": &net.OpError{Op: "dial", Net: "tcp", Err: netTimeout{}},
+ "deadline": context.DeadlineExceeded,
+ } {
+ waits := stubThrottleWait(t)
+ f := &failDo{err: e}
+ _, err := testAdapterWith(t, f).Describe(ctx)
+ if u := uncertainKey(t, err); !u.Timeout || f.sent != 1 || len(*waits) != 0 {
+ t.Fatalf("%s: %+v, sent %d, waits %v", name, u, f.sent, *waits)
+ }
+ }
waits := stubThrottleWait(t)
rec := newRecorder().onStall("DescribeAutoScalingGroups")
_, err := testAdapter(t, rec).Describe(ctx)
@@ -156,3 +188,30 @@ func TestReadTimeoutNotRetried(t *testing.T) {
t.Fatalf("stall: %+v, %d requests, waits %v", u, len(rec.requests()), *waits)
}
}
+
+// A read whose credentials could not be issued (an AssumeRole that got no
+// answer, or was throttled) is not retried: that would repeat the
+// credential call, not the read (Astra r1).
+func TestReadCredentialFailureNotRetried(t *testing.T) {
+ for name, e := range map[string]error{
+ "unanswered": &smithyhttp.RequestSendError{Err: syscall.ECONNRESET},
+ "throttled": &smithy.GenericAPIError{Code: "Throttling", Message: "Rate exceeded"},
+ } {
+ waits := stubThrottleWait(t)
+ calls := 0
+ rec := newRecorder().on("DescribeAutoScalingGroups", groupXML(2, 2, 3, [][2]string{{testIID, "InService"}}))
+ cfg := aws.Config{
+ Region: "eu-west-1",
+ HTTPClient: rec,
+ RetryMaxAttempts: 1,
+ Credentials: aws.CredentialsProviderFunc(func(context.Context) (aws.Credentials, error) {
+ calls++
+ return aws.Credentials{}, e
+ }),
+ }
+ _, err := newAdapter(cfg, testConfig()).Describe(ctx)
+ if uncertainKey(t, err).Key != "api" || calls != 1 || len(rec.requests()) != 0 || len(*waits) != 0 {
+ t.Fatalf("%s: %v, credential calls %d, requests %d, waits %v", name, err, calls, len(rec.requests()), *waits)
+ }
+ }
+}
diff --git a/internal/provision/testdata/plan14-root-reads-group-read-transport-retry.tsv b/internal/provision/testdata/plan14-root-reads-group-read-transport-retry.tsv
index 72f40daf5..ea3baf866 100644
--- a/internal/provision/testdata/plan14-root-reads-group-read-transport-retry.tsv
+++ b/internal/provision/testdata/plan14-root-reads-group-read-transport-retry.tsv
@@ -1,3 +1,3 @@
# Census overlay group-read-transport-retry, written by census-propose (#369). census-ruling-group-read-transport-retry, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-group-read-transport-retry.md.
# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
-@coverage internal/grouprollaws e1d3998565bb65d84af89082ef73ea839767b9a617294a463644ce0e7cedcfb4
+@coverage internal/grouprollaws 4072aeb1c55a9528afc83f2b16ce4c43f07912dc6dbdbbcc7e601160a8214657