| index 3662a32df..2ddc9f518 100644 |
| --- a/internal/release/proofgate_test.go |
| +++ b/internal/release/proofgate_test.go |
| @@ -663,3 +663,38 @@ func TestProofGateRequires(t *testing.T) { |
| t.Fatalf("broken policy: Requires = %v, %v; want true, true", req, perr) |
| } |
| } |
| + |
| +// Two promotions of one version inside the same second (pointers carry |
| +// milliseconds) are different promotions: the second pass reads the |
| +// manifest again instead of reusing the hash the first pass cached. |
| +func TestProofManifestCacheKeysTheFullPromotionStamp(t *testing.T) { |
| + opt := t.TempDir() |
| + s := NewDirStore(t.TempDir()) |
| + g := NewProofGate(filepath.Join(t.TempDir(), "proof-policy.json"), t.TempDir()) |
| + stage := func(sha string) { |
| + t.Helper() |
| + raw, err := json.Marshal(Manifest{Schema: 1, App: "console", Version: "new", Kind: "binary", |
| + Artifacts: map[string]Artifact{adoptPlatform: {File: "console-" + adoptPlatform, SHA256: sha}}}) |
| + if err != nil { |
| + t.Fatal(err) |
| + } |
| + if err := StageManifest(opt, "bab", "new", "console", raw); err != nil { |
| + t.Fatal(err) |
| + } |
| + } |
| + second := time.Date(2026, 10, 6, 10, 0, 0, 0, time.UTC) |
| + first, retry := strings.Repeat("a", 64), strings.Repeat("b", 64) |
| + |
| + stage(first) |
| + got, err := g.manifestSHA(context.Background(), s, opt, "bab", "console", |
| + &ChannelPointer{Version: "new", PromotedAt: second.Add(100 * time.Millisecond)}) |
| + if err != nil || got != first { |
| + t.Fatalf("first promotion: %q, %v; want %q", got, err, first) |
| + } |
| + stage(retry) |
| + got, err = g.manifestSHA(context.Background(), s, opt, "bab", "console", |
| + &ChannelPointer{Version: "new", PromotedAt: second.Add(800 * time.Millisecond)}) |
| + if err != nil || got != retry { |
| + t.Fatalf("second promotion in the same second: %q, %v; want %q (not the first pass's cached hash)", got, err, retry) |
| + } |
| +} |