carlos / platform Public

edge: shorten the asset cap in the oversized e2e test so it cannot time out

The unsized case wrote 32 MiB to a fill temp file on each edge inside
the client's 30 s; a loaded runner's disk outran it on main 80385b81.
assetcache.MaxBody becomes a test-shortenable var (default unchanged);
the test runs at a 1 MiB cap. Census envelope re-pin approved (#280).
Fixes #649.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Squashed from fix-asset-e2e-unsized-flake into main.
claude agent, operated by paul@keymail.dev baf506ea4484e8e28d54ff28213c41c43818a4f7 parent 80385b8
7 files changed, +40 −9
  • docs/superpowers/notes/census-proposal-fix-asset-e2e-unsized-flake.md +11 −0
  • internal/assetcache/fill.go +3 −3
  • internal/assetcache/fill_test.go +4 −4
  • internal/edge/asset_e2e_test.go +17 −1
  • internal/edge/asset_local_test.go +1 −1
  • internal/provision/testdata/plan14-root-reads-chain.tsv +1 −0
  • internal/provision/testdata/plan14-root-reads-fix-asset-e2e-unsized-flake.tsv +3 −0

CI passed — run details

diff --git a/docs/superpowers/notes/census-proposal-fix-asset-e2e-unsized-flake.md b/docs/superpowers/notes/census-proposal-fix-asset-e2e-unsized-flake.md
new file mode 100644
index 000000000..79a184377
--- /dev/null
+++ b/docs/superpowers/notes/census-proposal-fix-asset-e2e-unsized-flake.md
@@ -0,0 +1,11 @@
+# Census approval: fix-asset-e2e-unsized-flake
+
+Ruling `census-ruling-fix-asset-e2e-unsized-flake`. The independent reviewer approves or rejects every change below, 0 with a new disposition; nothing goes to the census owner (Paul, #280, 2026-10-26).
+
+Envelopes re-pinned: `internal/assetcache`.
+
+Review: a model from the other family than the author reads the branch's diff against main on the amadan.net remote (`origin` or `amadan`, whichever points at amadan.net) and gives a verdict for every unit and every re-pinned envelope above. For a unit, compare the change with its recorded disposition and basis below; for an envelope, read every changed function in the package and what it reaches. Reject if the change lets root open, run, query or follow anything it did not before from a path or input a tenant, an app or a box agent can create, write or name; if it weakens a check, refusal, validation, argument or environment the basis relies on; or if the diff cannot settle either. Otherwise approve. Record each verdict on #280 with the tip. A rejected unit goes back to the author to correct; nothing escalates to the census owner.
+
+Seal: `3c1d54d297da31d147cdb4e1ad4627f759c8cb8eae2db53cc92218db35e59c7b` → `3c1d54d297da31d147cdb4e1ad4627f759c8cb8eae2db53cc92218db35e59c7b`.
+
+Overlay: `internal/provision/testdata/plan14-root-reads-fix-asset-e2e-unsized-flake.tsv`, appended to `internal/provision/testdata/plan14-root-reads-chain.tsv`.
diff --git a/internal/assetcache/fill.go b/internal/assetcache/fill.go
index 6821550ff..467b3155d 100644
--- a/internal/assetcache/fill.go
+++ b/internal/assetcache/fill.go
@@ -13,10 +13,10 @@ import (
"sync"
)
-const (
- // MaxBody is the largest identity body the store will hold.
- MaxBody = 32 << 20
+// MaxBody is the largest identity body the store will hold. A variable only so a test can shorten it.
+var MaxBody int64 = 32 << 20
+const (
// metaReserve is the disk a reservation sets aside for the .meta file.
metaReserve = 64 << 10
diff --git a/internal/assetcache/fill_test.go b/internal/assetcache/fill_test.go
index ebe943689..217e2909b 100644
--- a/internal/assetcache/fill_test.go
+++ b/internal/assetcache/fill_test.go
@@ -29,7 +29,7 @@ func (f *fakeFS) setFree(v uint64) {
f.mu.Unlock()
}
-const worstReserve = 2*MaxBody + metaReserve
+var worstReserve = 2*MaxBody + metaReserve
// fillStore opens a Store over a real temporary directory with a fake FS that
// has plenty of room, and a budget big enough for many worst-case fills.
@@ -98,7 +98,7 @@ func TestReserveRefusesTooLarge(t *testing.T) {
func TestReserveRefusesBelowTheFloor(t *testing.T) {
s, fs, _ := fillStore(t)
fs.total = 8 << 30
- fs.free = 8<<30*15/100 + worstReserve // exactly one reservation above the floor
+ fs.free = 8<<30*15/100 + uint64(worstReserve) // exactly one reservation above the floor
first, err := s.Reserve(testKey("shop", "/a"), -1)
if err != nil {
t.Fatalf("first reservation: %v", err)
@@ -257,7 +257,7 @@ func TestWritePastMaxBodyFails(t *testing.T) {
}
defer f.Abort()
chunk := make([]byte, 1<<20)
- for i := 0; i < MaxBody>>20; i++ {
+ for i := int64(0); i < MaxBody>>20; i++ {
if _, err := f.Write(chunk); err != nil {
t.Fatalf("chunk %d: %v", i, err)
}
@@ -418,7 +418,7 @@ func TestReserveResamplesWhenACommitLandsAfterItsSample(t *testing.T) {
floor := uint64(total) * floorPercent / 100
body := make([]byte, 1<<20)
onDisk := uint64(len(body)) + 4096 // what the fake disk loses when a commits
- start := floor + worstReserve + onDisk/2
+ start := floor + uint64(worstReserve) + onDisk/2
fs.total = total
fs.setFree(start)
diff --git a/internal/edge/asset_e2e_test.go b/internal/edge/asset_e2e_test.go
index 9174762e5..f06704e53 100644
--- a/internal/edge/asset_e2e_test.go
+++ b/internal/edge/asset_e2e_test.go
@@ -1321,8 +1321,14 @@ func TestAssetE2EFarCatchBehindALocalWildcard(t *testing.T) {
}
}
+// The cap is shortened to 1 MiB for the test: past the cap an unsized body
+// has been written to disk on both edges up to the cap, and at the real
+// 32 MiB that is 64 MiB of writes a loaded CI runner's disk took longer to
+// absorb than the client's 30 s (main 80385b81). The paths under test are
+// the production ones; only the number is smaller.
func TestAssetE2EOversizedResponseIsStoredNowhere(t *testing.T) {
- big := strings.Repeat("x", 33<<20)
+ shortenAssetMaxBody(t, 1<<20)
+ big := strings.Repeat("x", int(assetcache.MaxBody)+512<<10)
x := newAssetE2E(t, assetE2EOpts{handler: func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/javascript")
w.Header().Set("Cache-Control", "public, max-age=3600")
@@ -1357,6 +1363,16 @@ func TestAssetE2EOversizedResponseIsStoredNowhere(t *testing.T) {
}
}
+// shortenAssetMaxBody sets the store's body cap to n until the test ends.
+// Call it before building a scene: cleanups run last-in first-out, so the
+// cap comes back after the scene's servers have stopped reading it.
+func shortenAssetMaxBody(t *testing.T, n int64) {
+ t.Helper()
+ old := assetcache.MaxBody
+ assetcache.MaxBody = n
+ t.Cleanup(func() { assetcache.MaxBody = old })
+}
+
// The far edge's published view names a generation, then an owner, that the
// home no longer holds (the home has moved on; its edges file has not been
// republished yet). The fill's assertion fails at the home, so it is an
diff --git a/internal/edge/asset_local_test.go b/internal/edge/asset_local_test.go
index 1be33b9f9..783055143 100644
--- a/internal/edge/asset_local_test.go
+++ b/internal/edge/asset_local_test.go
@@ -276,7 +276,7 @@ func TestLocalFillSendsNoCookieOrAuthorization(t *testing.T) {
}
func TestLocalRefusedResponseServedNotStored(t *testing.T) {
- big := strings.Repeat("x", assetcache.MaxBody+1)
+ big := strings.Repeat("x", int(assetcache.MaxBody)+1)
cases := []struct {
name string
h http.HandlerFunc
diff --git a/internal/provision/testdata/plan14-root-reads-chain.tsv b/internal/provision/testdata/plan14-root-reads-chain.tsv
index f3b8315b8..6a922131c 100644
--- a/internal/provision/testdata/plan14-root-reads-chain.tsv
+++ b/internal/provision/testdata/plan14-root-reads-chain.tsv
@@ -110,3 +110,4 @@ plan14-root-reads-demo-api-claim-paths.tsv ebeaa693941f5592cd7bc3458effc2a333a8d
plan14-root-reads-demo-moved-capability.tsv ebeaa693941f5592cd7bc3458effc2a333a8d12ba4f192a93d0aa32589048939
plan14-root-reads-demo-snapshot-unit-check.tsv 1e83ce23d7d1306e3963f802fecf8c914a2624726255e3bc30382104e568adde
plan14-root-reads-region-ha-g2-fixes.tsv 3c1d54d297da31d147cdb4e1ad4627f759c8cb8eae2db53cc92218db35e59c7b
+plan14-root-reads-fix-asset-e2e-unsized-flake.tsv 3c1d54d297da31d147cdb4e1ad4627f759c8cb8eae2db53cc92218db35e59c7b
diff --git a/internal/provision/testdata/plan14-root-reads-fix-asset-e2e-unsized-flake.tsv b/internal/provision/testdata/plan14-root-reads-fix-asset-e2e-unsized-flake.tsv
new file mode 100644
index 000000000..515f8eb48
--- /dev/null
+++ b/internal/provision/testdata/plan14-root-reads-fix-asset-e2e-unsized-flake.tsv
@@ -0,0 +1,3 @@
+# Census overlay fix-asset-e2e-unsized-flake, written by census-propose (#369). census-ruling-fix-asset-e2e-unsized-flake, approved on #280 before the merge; the approval card is docs/superpowers/notes/census-proposal-fix-asset-e2e-unsized-flake.md.
+# 0 body, 0 sites, 1 envelope: each changed unit re-frozen at its existing disposition with its claim appended.
+@coverage internal/assetcache 02b19496ead8d1ba47b07f6d2fe8d3cbd3cc6fb7d57389e216f47c8ce0a32a58