region HA G3-B10: unreadable or unplaceable edges fail closed (review F1-F3)
StorageUnproven refuses scoped HA creates while any edges file could not be read or parsed, or names an invalid placement. Capacity refusals name the region by label. HADataStoreRegions returns an exported type.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
cmd/console/main.go+1 −1internal/console/ha_pool_scope_test.go+38 −5internal/console/hacapacity.go+30 −3internal/console/nocapacity.go+6 −2
CI failed — run details
Intent
<task-notification> <task-id>adf187754adb71ae0</task-id> <tool-use-id>toolu_01CXyCgP5PnuGp9MCMVyMze9</tool-use-id> <output-file>/home/paulca/.cache/tmp/claude-1001/-home-paulca-amadan-net-carlos-platform/265811d8-fa99-4f28-a191-8a01ce8693ac/tasks/adf187754adb71ae0.output</output-file> <status>completed</status> <summary>Agent "Opus review B10 create path" finished</summary> <note>A task-notification fires each time this agent stops with no live background children of its own. The user can send it another message and resume it, so the same task-id may notify more than once.</note> <result>**Verdict: fixes needed.** The committed change (7c5ed587..HEAD) does what the plan asks on all six checks. I found one P2 gap in the I-B10 gate and three P3s. The targeted tests pass: `TestHAPool*` in `./internal/console` (14.8s) and `TestBuildHADataStores` in `./cmd/console`. I had to run them with the sandbox off, because the sandbox made the default Go cache read-only. **Heads-up first.** The worktree has uncommitted edits made since the start-of-session snapshot, so another session is working in it right now. They change wording only: the I-B10 sentence and the leftover-check 503 ("could not check this instance's data… check data access for this region"). They also edit two existing tests, `hacreate_test.go` and `hap2_wiring_test.go`. That looks like Task 5's copy pass. If it is committed, the "existing tests unmodified" check no longer holds for the branch. I reviewed HEAD. ## Findings **F1, P2: a mismatched file whose read fails slips past I-B10 for that pass.** - `internal/console/hacapacity_observe.go:383-385` marks a file `malformed` when its read fails (S3 GET error, or body over the size limit), not only when the JSON is bad. - `MixedStorage` skips malformed files (`hacapacity.go:314`). - `Decide` answers Allow whenever at least one box is eligible (`hacapacity.go:345`), even if another file is unknown. - Scenario: in scoped `us`, box "leo" is healthy and box "mismatch" points at another bucket. One observation pass gets a transient 5xx reading `control/edges/mismatch.json`. For that pass's lifetime (up to 120s), pool `ha` creates are admitted. The file in the bucket is well-formed, so this breaks "any well-formed file blocks". - Smallest fix: record read errors separately from parse errors (for example `f.readErr`). For a scoped region, have `MixedStorage`, or a sibling check in `requireHACreateCapacity`, refuse with 503 and Retry-After 60 when any file had a read error. Add one witness: fail the GET on the mismatched key and expect 503. **F2, P3: a file with an invalid `placement` value is not checked by I-B10.** - `hacapacity.go:320`: a file with an invalid placement string (e.g. `"US"`) is skipped, and `Decide` still allows if another box is eligible. - Defensible as "not placed in the region", and it matches how `scope` treats it. Worth a comment saying so, or fail closed in scoped regions. **F3, P3: `HADataStoreRegions` is exported but returns an unexported type.** - `hacapacity.go:189` returns `map[string]haCoordinates`. Return a small exported struct, or keep the parse inside `buildHADataStores`. **F4, P3: the no-room error now carries the label, so its log line does too.** - `nocapacity.go:181`: `noCapacityError.Region` now holds the label (also used by the move door, `apiinstancemove.go:721`). `claimResponseRefusal` logs `err`, so that log line shows the label rather than the code. - `noRoom` still logs and alerts with the code (`nocapacity.go:165-171`), so this is cosmetic. ## The six checks 1. **I-B10 gate holds, apart from F1.** - Not tied to age: no `available`/freshness filter in `MixedStorage`. The edges LIST has no age filter, and both the S3 and directory paths list every key (only `status/` objects older than 24h are dropped). An over-cap list fails closed through `Decide` returning unknown. - The check runs whether or not the observation is still current, and only when `haCreate` is true and the region has `ha_pools` (`nocapacity.go:50-60`). Home is matched as `""`, consistent with `scope`. - The refusal names the region label (`offlinePlace`) and the box. Retry-After is set at `apiinstances.go:2342` and `apisidecars.go:452`. Domain attach cannot reach this gate because pool `""` can never be listed in `ha_pools`. 2. **Plain creates in a scoped region are gate-for-gate identical to a non-HA region.** All create-path gates moved to `haCreate`: `apiinstances.go:1839/1957/2010/2281/2346`, `hacreate.go:20`, `apisidecars.go:369/418`, `domainattach.go:228`, `seedmove.go:59`. The `haRegion` callers left are transfer-only (`seedmove.go:83-94`, `apiinstances.go:2331` seeded/import, `apiplacements.go`). 3. **Scoped leftover check is correct** (`createleftovers.go:208-228`). - Duplicate and read-error answers come first. - Then two LISTs with a limit of 1: `HibernatePrefix(...)+"/"` and `moves/<host>/`, against `HADataStores[homeRegionOut(region)]`, keyed by code. - 503 when `HibernateBucket` is empty, the store is missing, it has no paged listing, or a list errors; 409 on any key. - Never uses `SeedData` or `dbReplica`, and no bucket name appears in responses. - A non-pageable store errors inside `firstHALeftover` and becomes 503. 4. **Invalid config:** with HA regions set, `haScopeInvalid` returns a 503 with Retry-After 60 before F5 (the existing "not available yet" refusal) and before any LIST (`createleftovers.go:168`). Non-HA-data creates get the unknown-capacity 503. The observer parses the same config and fails, so the two agree. Dev's shape (valid config, no `ha_pools`) is unchanged. 5. **Store builder** (`main.go:2091`) builds a store only for regions with `ha_pools`, home included, using the config's bucket and region. A failed build logs and leaves no store, so creates there get 503. The timing wrapper keeps the paged listing. Requiring `HomeRegion` makes the home keying consistent. 6. **Tests:** - Real `NewServer` and real handlers; the observer is injected. - The stale-file witness uses a 24h-old file, and the seeded simulation (500 iterations, ages up to 48h) would catch a freshness filter or a dropped call. - Committed changes add only the two new test files. VERDICT: FIXES NEEDED (F1)</result> <usage><subagent_tokens>123769</subagent_tokens><tool_uses>37</tool_uses><duration_ms>342224</duration_ms></usage> </task-notification>
Attributed to this commit: 43.6 g CO₂e (5,089,604 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-g3-b10, never backward from it. A turn that produced more than one commit books all of its tokens to the last one, and a concurrent session on this branch can add to the same figure. Some of it was priced using the shared default rate, because no model-specific factor row exists yet for at least one model involved. The Carbon view has the repo total, which is never derived from this attribution.
diff --git a/cmd/console/main.go b/cmd/console/main.go| index ea509bdc1..97c495774 100644 |
| --- a/cmd/console/main.go |
| +++ b/cmd/console/main.go |
| @@ -2095,7 +2095,7 @@ func buildHADataStores(ctx context.Context, cfg console.Config, rec *perf.Record |
| } |
| stores := make(map[string]release.Store) |
| for code, coords := range regions { |
| - store, err := open(ctx, coords.DataBucket, coords.DataBucketRegion) |
| + store, err := open(ctx, coords.Bucket, coords.Region) |
| if err != nil { |
| log.Printf("console: HA data store for %s: %v", code, err) |
| continue |
diff --git a/internal/console/ha_pool_scope_test.go b/internal/console/ha_pool_scope_test.go| index 69c263dd9..92370e298 100644 |
| --- a/internal/console/ha_pool_scope_test.go |
| +++ b/internal/console/ha_pool_scope_test.go |
| @@ -612,6 +612,36 @@ func TestHAPoolTransfersRemainRegional(t *testing.T) { |
| }) |
| } |
| +// TestHAPoolUnprovenStorage: a box whose edges file cannot be read or parsed |
| +// (the observer marks both malformed), or whose placement is not a valid |
| +// region, could be on any bucket, so scoped HA creates fail closed (Opus |
| +// create-path review F1, F2). Plain creates are untouched. |
| +func TestHAPoolUnprovenStorage(t *testing.T) { |
| + for _, mode := range []string{"malformed", "bad-placement"} { |
| + t.Run(mode, func(t *testing.T) { |
| + w := haPoolWorldNew(t, "us", "ha", nil) |
| + if mode == "malformed" { |
| + haPut(t, w.evidence, "control/edges/mismatch.json", []byte(`{"v":`)) |
| + } else { |
| + w.edge(t, "mismatch", func(m map[string]any) { m["placement"] = "US" }) |
| + } |
| + w.refresh() |
| + code, hdr, out := w.post(t, false, w.body(false)) |
| + want := fmt.Sprintf(haCapacityUnknownRefusal, w.srv.offlinePlace("us")) |
| + if code != 503 || hdr.Get("Retry-After") != "60" || errorText(out) != want { |
| + t.Fatalf("unproven=%d %v %s", code, hdr, out) |
| + } |
| + w.noWrites(t) |
| + m := titoManifest() |
| + m.Pool, m.Regions = "", nil |
| + enableInstances(t, w.consoleFixture, "titogo", m) |
| + if code, _, out = w.post(t, false, `{"host":"plain.go.tito.io","region":"us"}`); code != 201 { |
| + t.Fatalf("plain create blocked=%d %s", code, out) |
| + } |
| + }) |
| + } |
| +} |
| + |
| func TestHAPoolMixedStorageSeededSimulation(t *testing.T) { |
| w := haPoolWorldNew(t, "us", "ha", nil) |
| golden := haGolden(t) |
| @@ -619,7 +649,7 @@ func TestHAPoolMixedStorageSeededSimulation(t *testing.T) { |
| for _, seed := range []int64{1, 10, 23, 2026, 591} { |
| rng := rand.New(rand.NewSource(seed)) |
| for iteration := 0; iteration < 100; iteration++ { |
| - wantMixed := false |
| + wantMixed, wantUnproven := false, false |
| for i := 0; i < 4; i++ { |
| placement := []string{"us", "", "uk"}[rng.Intn(3)] |
| bucket := []string{w.bucket, "other-data", "", "bad/bucket"}[rng.Intn(4)] |
| @@ -628,6 +658,9 @@ func TestHAPoolMixedStorageSeededSimulation(t *testing.T) { |
| if !malformed && placement == "us" && (bucket == "other-data" || bucketRegion == "eu-west-2") { |
| wantMixed = true |
| } |
| + if malformed { |
| + wantUnproven = true |
| + } |
| body := haEdit(t, golden, func(m map[string]any) { |
| m["placement"], m["data_bucket"], m["data_bucket_region"] = placement, bucket, bucketRegion |
| m["named_pools"] = [][]string{{"ha"}, {"other"}, nil}[rng.Intn(3)] |
| @@ -648,13 +681,13 @@ func TestHAPoolMixedStorageSeededSimulation(t *testing.T) { |
| ref := w.srv.requireHACreateCapacity(context.Background(), "us", "ha") |
| if ref == nil { |
| admitted++ |
| - if wantMixed { |
| - t.Fatalf("I-B10 seed=%d iteration=%d: admitted ha create with mismatched storage", seed, iteration) |
| + if wantMixed || wantUnproven { |
| + t.Fatalf("I-B10 seed=%d iteration=%d: admitted ha create with mismatched or unproven storage", seed, iteration) |
| } |
| } else { |
| refused++ |
| - if !wantMixed || ref.Status != 503 || ref.haCapacityRetryAfter != 60 { |
| - t.Fatalf("seed=%d iteration=%d mixed=%v refusal=%+v", seed, iteration, wantMixed, ref) |
| + if !(wantMixed || wantUnproven) || ref.Status != 503 || ref.haCapacityRetryAfter != 60 { |
| + t.Fatalf("seed=%d iteration=%d mixed=%v unproven=%v refusal=%+v", seed, iteration, wantMixed, wantUnproven, ref) |
| } |
| } |
| } |
diff --git a/internal/console/hacapacity.go b/internal/console/hacapacity.go| index b90545f5e..c2fab489a 100644 |
| --- a/internal/console/hacapacity.go |
| +++ b/internal/console/hacapacity.go |
| @@ -186,15 +186,19 @@ func parseHACapacityConfig(raw string, regions []string, home string) (*haCapaci |
| c.universe = slices.Compact(c.universe) |
| return &c, nil |
| } |
| -func HADataStoreRegions(cfg Config) (map[string]haCoordinates, error) { |
| + |
| +// HADataStore is a scoped region's configured data bucket. |
| +type HADataStore struct{ Bucket, Region string } |
| + |
| +func HADataStoreRegions(cfg Config) (map[string]HADataStore, error) { |
| c, err := parseHACapacityConfig(cfg.HACapacityConfig, cfg.HARegions, cfg.HomeRegion) |
| if err != nil { |
| return nil, err |
| } |
| - regions := make(map[string]haCoordinates) |
| + regions := make(map[string]HADataStore) |
| for region, coords := range c.Regions { |
| if len(coords.HAPools) > 0 { |
| - regions[region] = coords |
| + regions[region] = HADataStore{Bucket: coords.DataBucket, Region: coords.DataBucketRegion} |
| } |
| } |
| return regions, nil |
| @@ -319,6 +323,7 @@ func (o *HACapacityObservation) MixedStorage(region string) (box string, mixed b |
| valid = true |
| } |
| if !valid || !provision.ValidRegion(placement) || placement != wantPlacement { |
| + // StorageUnproven refuses files whose placement cannot be read. |
| continue |
| } |
| bucket, valid := haField[string](f.fields, "data_bucket") |
| @@ -333,6 +338,28 @@ func (o *HACapacityObservation) MixedStorage(region string) (box string, mixed b |
| return "", false |
| } |
| +// StorageUnproven names a box whose edges file could not be read or parsed, |
| +// or whose placement is not a valid region: such a box could be placed in |
| +// any region on any bucket, so I-B10 cannot be proven for a scoped create. |
| +func (o *HACapacityObservation) StorageUnproven() (box string, unproven bool) { |
| + if o == nil { |
| + return "", false |
| + } |
| + for _, f := range o.files { |
| + if f.malformed { |
| + return f.ref, true |
| + } |
| + placement, valid := haField[string](f.fields, "placement") |
| + if _, present := f.fields["placement"]; !present { |
| + continue |
| + } |
| + if !valid || !provision.ValidRegion(placement) { |
| + return f.ref, true |
| + } |
| + } |
| + return "", false |
| +} |
| + |
| func (o *HACapacityObservation) Regional(region string, now time.Time) HACapacityRegional { |
| n, complete, _ := o.project(region, "", false, now) |
| return HACapacityRegional{n, complete} |
diff --git a/internal/console/nocapacity.go b/internal/console/nocapacity.go| index 2e4c9394f..c9580837a 100644 |
| --- a/internal/console/nocapacity.go |
| +++ b/internal/console/nocapacity.go |
| @@ -58,6 +58,10 @@ func (s *Server) requireHACreateCapacity(ctx context.Context, region, pool strin |
| log.Printf("console: HA create in %s: mixed storage in %s", name, edgesfile.Prefix+box+".json") |
| return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: fmt.Sprintf("%s has a box using different data storage: %s. Nothing was created. An operator must reconfigure or retire that box.", s.offlinePlace(region), box), haCapacityRetryAfter: 60} |
| } |
| + if box, unproven := obs.StorageUnproven(); unproven { |
| + log.Printf("console: HA create in %s: storage unproven: %s", name, edgesfile.Prefix+box+".json") |
| + return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: fmt.Sprintf(haCapacityUnknownRefusal, s.offlinePlace(region)), haCapacityRetryAfter: 60} |
| + } |
| } |
| if available { |
| decision = obs.Decide(name, pool, s.haCapacity.Load().clock.Now(), sidecarPlacement...) |
| @@ -71,9 +75,9 @@ func (s *Server) requireHACreateCapacity(ctx context.Context, region, pool strin |
| ref.haCapacityRetryAfter = 60 |
| return ref |
| default: |
| - msg := fmt.Sprintf(haCapacityUnknownRefusal, name) |
| + msg := fmt.Sprintf(haCapacityUnknownRefusal, s.offlinePlace(region)) |
| if decision.MissingNamedPoolsOnly { |
| - msg = fmt.Sprintf(haCapacityPoolRefusal, pool, name) |
| + msg = fmt.Sprintf(haCapacityPoolRefusal, pool, s.offlinePlace(region)) |
| } |
| return &doorRefusal{Status: http.StatusServiceUnavailable, Msg: msg, haCapacityRetryAfter: 60} |
| } |