console-slow-writes: an over-cap manifest fails the program check closed (Astra round 2, P2)
validateManifest sets no size limit, so a manifest over the 1 MiB read cap may be a valid release declaring a program. Skipping it let a ship of another program through without --program-change when that release was the only one declaring a program. readProgramManifest now answers an over-cap manifest as a store error does: the check fails closed, in the listing's order. TestOversizedValidManifestStillRefusesAProgramChange (a valid manifest with a long commit field) fails on the skip and passes now; TestPreviousProgramBoundsWhatItHolds expects the closed failure and keeps its byte and reader bounds.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2 files changed,
+34
−11
internal/release/program.go+10 −6internal/release/program_bound_test.go+24 −5
diff --git a/internal/release/program.go b/internal/release/program.go| index ed7c703f8..acb26ac43 100644 |
| --- a/internal/release/program.go |
| +++ b/internal/release/program.go |
| @@ -133,8 +133,11 @@ func ReleaseProgram(files map[string][]byte) (string, error) { |
| // so at most previousProgramReads bodies of that size are in memory at |
| // once, and once a manifest is judged its worker keeps only the three |
| // fields the comparison reads (program, built-at and version). A manifest |
| -// over the cap is skipped as one that does not validate: no ship door |
| -// writes one within a hundredth of it. |
| +// over the cap fails the check closed, as a store error does: nothing in |
| +// validateManifest limits a manifest's size, so one too large to read may |
| +// be a valid release declaring a program, and skipping it would let a |
| +// mismatched ship through. No ship door writes one within a hundredth of |
| +// the cap. |
| func PreviousProgram(ctx context.Context, s Store, acct, app string) (string, string, error) { |
| vers, _, err := VersionCandidates(ctx, s, acct, app, 20) |
| if err != nil { |
| @@ -194,9 +197,10 @@ type programRead struct { |
| // readProgramManifest reads and judges one version's manifest for |
| // PreviousProgram, separating parse errors (skipped) from store errors |
| -// (which fail closed). It opens the manifest with OpenQualified, the same |
| -// key and the same not-found answer GetManifest's GetQualified gives, and |
| -// reads no further than maxProgramManifestBytes and one byte. |
| +// and over-cap manifests (which fail closed). It opens the manifest with |
| +// OpenQualified, the same key and the same not-found answer GetManifest's |
| +// GetQualified gives, and reads no further than maxProgramManifestBytes |
| +// and one byte. |
| func readProgramManifest(ctx context.Context, s Store, acct, app, v string) programRead { |
| rc, _, err := OpenQualified(ctx, s, ManifestKey(acct, app, v)) |
| if err != nil { |
| @@ -211,7 +215,7 @@ func readProgramManifest(ctx context.Context, s Store, acct, app, v string) prog |
| return programRead{storeErr: err} |
| } |
| if len(raw) > maxProgramManifestBytes { |
| - return programRead{skip: fmt.Sprintf("validation error: manifest is over %d bytes", maxProgramManifestBytes)} |
| + return programRead{storeErr: fmt.Errorf("manifest %s/%s is over %d bytes, more than the program check reads", app, v, maxProgramManifestBytes)} |
| } |
| var m Manifest |
| if err := json.Unmarshal(raw, &m); err != nil { |
diff --git a/internal/release/program_bound_test.go b/internal/release/program_bound_test.go| index 051058d67..4b9e5040b 100644 |
| --- a/internal/release/program_bound_test.go |
| +++ b/internal/release/program_bound_test.go |
| @@ -92,9 +92,9 @@ func (s *boundStore) Get(ctx context.Context, key string) ([]byte, string, error |
| } |
| // TestPreviousProgramBoundsWhatItHolds: a manifest that never ends is read |
| -// no further than the cap and one byte and skipped, the valid ones still |
| -// answer, at most previousProgramReads are open at once, and the bytes |
| -// held by open readers never pass that many caps. |
| +// no further than the cap and one byte and fails the check closed, at most |
| +// previousProgramReads are open at once, and the bytes held by open readers |
| +// never pass that many caps. |
| func TestPreviousProgramBoundsWhatItHolds(t *testing.T) { |
| dir := NewDirStore(t.TempDir()) |
| art := map[string]Artifact{adoptPlatform: {File: adoptPlatform, SHA256: strings.Repeat("a", 64), Size: 1}} |
| @@ -109,8 +109,8 @@ func TestPreviousProgramBoundsWhatItHolds(t *testing.T) { |
| } |
| s := &boundStore{Store: dir, huge: huge, read: map[string]int64{}} |
| got, ver, err := PreviousProgram(context.Background(), s, "bab", "console") |
| - if err != nil || got != "example.com/console" || ver != "v18" { |
| - t.Fatalf("PreviousProgram = %q %q %v, want example.com/console from v18 (v19 is endless and skipped)", got, ver, err) |
| + if err == nil || !strings.Contains(err.Error(), "more than the program check reads") { |
| + t.Fatalf("PreviousProgram = %q %q %v, want the over-cap manifest to fail the check", got, ver, err) |
| } |
| for v := range huge { |
| if n := s.read[ManifestKey("bab", "console", v)]; n > maxProgramManifestBytes+1 { |
| @@ -127,3 +127,22 @@ func TestPreviousProgramBoundsWhatItHolds(t *testing.T) { |
| t.Errorf("%d manifest readers left open", s.open) |
| } |
| } |
| + |
| +// TestOversizedValidManifestStillRefusesAProgramChange: the app's only |
| +// previous release declares its program in a manifest that validates but is |
| +// over the cap (a long commit field). A ship of another program without |
| +// --program-change is refused, not let through as if there were no previous |
| +// program (Astra, console-slow-writes round 2, P2). |
| +func TestOversizedValidManifestStillRefusesAProgramChange(t *testing.T) { |
| + s := NewDirStore(t.TempDir()) |
| + art := map[string]Artifact{adoptPlatform: {File: adoptPlatform, SHA256: strings.Repeat("a", 64), Size: 1}} |
| + putManifest(t, s, "v1", Manifest{Schema: 1, App: "console", Version: "v1", Kind: "binary", |
| + BuiltAt: "2026-01-01T00:00:00Z", Artifacts: art, Program: "example.com/console", |
| + Commit: strings.Repeat("a", maxProgramManifestBytes)}) |
| + if _, err := GetManifest(context.Background(), s, "bab", "console", "v1"); err != nil { |
| + t.Fatalf("the oversized manifest should still validate: %v", err) |
| + } |
| + if err := shipWithProgram(t, s, "v2", tinyProgram(t, "example.com/carlos"), false); err == nil { |
| + t.Fatal("a ship of another program was let through past an oversized previous manifest") |
| + } |
| +} |