carlos / platform Public

ha: P2b-1 CI fixes and haJSON depth cap

claude agent, operated by paul@keymail.dev e951b57788fa41821122b7af5fb958002ae447bc parent f9eadab
6 files changed, +59 −10
  • internal/console/ha_born_test.go +1 −0
  • internal/console/hacapacity.go +9 −5
  • internal/console/hacapacity_test.go +40 −0
  • internal/host/egress_nopolicy_linux_test.go +1 −1
  • internal/provision/demo_census_test.go +5 −1
  • internal/release/openers_test.go +3 −3

CI failed — run details

Intent

Attributed to this commit: 15.9 g CO₂e (2,023,157 tokens). This is an attribution, not a measurement — usage counted from this commit's own marker forward to the next one on region-ha-p2b-build, 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/internal/console/ha_born_test.go b/internal/console/ha_born_test.go
index 733b0d77c..5e68a0e6d 100644
--- a/internal/console/ha_born_test.go
+++ b/internal/console/ha_born_test.go
@@ -211,6 +211,7 @@ func TestImportUploadAndStoppedRefusedInHARegion(t *testing.T) {
func TestStaticRecordIsNotStampedAndDoesNotBlockAMove(t *testing.T) {
w := newOfflineWorld(t, oneEach...)
w.fx.srv.cfg.HARegions = []string{"ie"}
+ createCapacityEvidence(t, w.fx.srv, "allow", nil)
const staticHost = "site.shop.example.com"
u := instancesURL(w.fx, "bab", "shop")
if c, _, out := rawReq(t, http.MethodPost, u, w.token, `{"host":"`+staticHost+`","kind":"static","region":"ie"}`); c != http.StatusCreated {
diff --git a/internal/console/hacapacity.go b/internal/console/hacapacity.go
index ddaaeb9c3..6a47ee716 100644
--- a/internal/console/hacapacity.go
+++ b/internal/console/hacapacity.go
@@ -25,6 +25,7 @@ const (
haCapacityDeadline = 45 * time.Second
haCapacityLifetime = 120 * time.Second
haCapacityBodyLimit = 1 << 20
+ haCapacityJSONDepthLimit = 10000
haCapacityIdentityLimit = 64 << 10
haCapacityKeyLimit = 200
haCapacityRawStatusLimit = 1000
@@ -58,8 +59,8 @@ type haCapacityConfig struct {
// the last value. Configuration also refuses null at every depth.
func haJSON(raw []byte, noNull bool) error {
d := json.NewDecoder(bytes.NewReader(raw))
- var value func() error
- value = func() error {
+ var value func(int) error
+ value = func(depth int) error {
tok, err := d.Token()
if err != nil {
return err
@@ -71,6 +72,9 @@ func haJSON(raw []byte, noNull bool) error {
if !ok {
return nil
}
+ if depth >= haCapacityJSONDepthLimit {
+ return errHACapacity
+ }
switch delim {
case '{':
seen := map[string]bool{}
@@ -84,13 +88,13 @@ func haJSON(raw []byte, noNull bool) error {
return errHACapacity
}
seen[s] = true
- if err := value(); err != nil {
+ if err := value(depth + 1); err != nil {
return err
}
}
case '[':
for d.More() {
- if err := value(); err != nil {
+ if err := value(depth + 1); err != nil {
return err
}
}
@@ -100,7 +104,7 @@ func haJSON(raw []byte, noNull bool) error {
_, err = d.Token()
return err
}
- if err := value(); err != nil {
+ if err := value(0); err != nil {
return err
}
if _, err := d.Token(); err != io.EOF {
diff --git a/internal/console/hacapacity_test.go b/internal/console/hacapacity_test.go
index 4672cb2e9..b39b71438 100644
--- a/internal/console/hacapacity_test.go
+++ b/internal/console/hacapacity_test.go
@@ -424,6 +424,46 @@ func TestHACapacityGroupReferenceGolden(t *testing.T) {
}
}
+func TestHACapacityJSONDepthLimit(t *testing.T) {
+ for _, shape := range []struct{ name, open, close string }{
+ {"array", "[", "]"},
+ {"object", `{"value":`, "}"},
+ } {
+ for _, depth := range []int{9999, 10000, 10001} {
+ t.Run(fmt.Sprintf("boundary/%s/%d", shape.name, depth), func(t *testing.T) {
+ raw := []byte(strings.Repeat(shape.open, depth) + "0" + strings.Repeat(shape.close, depth))
+ for _, noNull := range []bool{false, true} {
+ err := haJSON(raw, noNull)
+ if depth <= 10000 && err != nil {
+ t.Fatalf("depth %d, noNull=%v: %v", depth, noNull, err)
+ }
+ if depth > 10000 && err != errHACapacity {
+ t.Fatalf("depth %d, noNull=%v: got %v, want malformed evidence", depth, noNull, err)
+ }
+ }
+ })
+ }
+ }
+ t.Run("malformed publication", func(t *testing.T) {
+ o, s, _ := haFixture(t)
+ raw := []byte(strings.Repeat("[", haCapacityBodyLimit))
+ if err := haJSON(raw, false); err != errHACapacity {
+ t.Fatalf("1 MiB of opening arrays: got %v, want depth refusal", err)
+ }
+ haPut(t, s, edgesFilePrefix+"leo.json", raw)
+ obs := haObserve(t, o)
+ if v := obs.Regional("ie", haTestNow); v.Complete {
+ t.Fatalf("malformed publication classified as complete: %+v", v)
+ }
+ if d := obs.Decide("ie", "hapair", haTestNow); d.Kind != HACapacityUnknown {
+ t.Fatalf("malformed publication did not remain unknown: %+v", d)
+ }
+ if b := obs.Blockers("ie", haTestNow); len(b) != 1 || b[0].Code != "edges_malformed" {
+ t.Fatalf("malformed publication blockers: %+v", b)
+ }
+ })
+}
+
func TestHACapacityUnknownIsNotZeroMalformed(t *testing.T) {
o, s, _ := haFixture(t)
keys := []string{edgesFilePrefix + "leo.json", haStatusPrefix + "leo.json", boxid.Key("leo")}
diff --git a/internal/host/egress_nopolicy_linux_test.go b/internal/host/egress_nopolicy_linux_test.go
index 44f1649f8..e4949cd7f 100644
--- a/internal/host/egress_nopolicy_linux_test.go
+++ b/internal/host/egress_nopolicy_linux_test.go
@@ -385,7 +385,7 @@ func TestEgressNoPolicyBoxPublishesAsMain(t *testing.T) {
mainBody := fmt.Sprintf(mainNoPolicyEdges, probeGen.Generation)
const addrsField = `"addrs":["10.0.1.5","fe80::1"],`
wantBody := strings.Replace(mainBody, `"generation":`, addrsField+`"generation":`, 1)
- wantBody = strings.Replace(wantBody, `"moves_protocol":`, `"burst_notices":true,"moves_protocol":`, 1)
+ wantBody = strings.Replace(wantBody, `"moves_protocol":`, `"named_pools":[],"burst_notices":true,"moves_protocol":`, 1)
if string(body) != wantBody {
t.Fatalf("the edges file is not main's plus addrs and burst_notices:\n%s\nwant:\n%s", body, wantBody)
}
diff --git a/internal/provision/demo_census_test.go b/internal/provision/demo_census_test.go
index 203e95cef..fac88c5d7 100644
--- a/internal/provision/demo_census_test.go
+++ b/internal/provision/demo_census_test.go
@@ -45,7 +45,11 @@ func demoWriteCensusInventory() []censusEntry {
{"internal/console/lifetimes_create.go", "Server.createRecordWithLifetimeLocked", "key-site", "key:RecordKey", "53402d617ed4f9616cba944027774a45b10df09f81bd5a7e3941f28915bf0c72"},
// Shared reservation after normalization, before any claim/record write.
// Existing proof, ownership and static CreateRecord behavior is retained.
- {"internal/console/domainattach.go", "Server.attachDomainAs", "record-writer", "key:CreateRecord", "abd913b9788cdc7d8bbb409d57f5b1a70128c9b60a9b40d71a5be8b98ec8ade5"},
+ // P2b-1 T3 reviewed change: gate a new HA first route on capacity before
+ // claim/lifetime/record writes; standing records retain reattachment.
+ // doorRefusal literals now use keyed fields. Same typed CreateRecord,
+ // record-writer class and key site; no new write authority.
+ {"internal/console/domainattach.go", "Server.attachDomainAs", "record-writer", "key:CreateRecord", "f354f571fc210ea5759ccfadad933abb157fed3e6595b059435a17805f21d434"},
} {
found := false
for i, old := range entries {
diff --git a/internal/release/openers_test.go b/internal/release/openers_test.go
index 624bd7cc9..c8eff14e5 100644
--- a/internal/release/openers_test.go
+++ b/internal/release/openers_test.go
@@ -39,10 +39,10 @@ type openerEntry struct {
count int
}
-// otherBucketOpeners are the sites that open a store which is not the
-// deployment bucket: through NewS3Store, NewS3StoreIn, an S3Store literal or
-// NewDirStore.
+// otherBucketOpeners are non-deployment stores and read-only deployment
+// observers: through NewS3Store, NewS3StoreIn, an S3Store literal or NewDirStore.
var otherBucketOpeners = map[string]openerEntry{
+ "internal/console/hacapacity_observe.go:newHACapacityStore": {"read-only deployment observer for control/edges/, status/boxes/ and identity records, with a one-attempt client; never writes, so no change-index bump is needed", 1},
"internal/host/hadepartures_wiring.go:armHADepartures": {"regional data bucket for termination proofs beside locks", 1},
"cmd/console/main.go:serve": {"console seed data store: the database/data bucket (seeds/), not the deployment bucket", 1},
"internal/host/seedwiring.go:seedDataOpener": {"this region's data bucket, where seeds/ lives", 1},