carlos / platform Public

release: key the proof gate's manifest cache by the full promotion stamp

App pointers carry milliseconds, so two promotions of one version inside
a second shared a cache key and the second could reuse a stale manifest
hash (Astra R4 P2). Key with UnixNano.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev c8b943ab071fc05ab38250d064ba288d285acfb7 parent e1b32e3
2 files changed, +37 −2
  • internal/release/proofgate.go +2 −2
  • internal/release/proofgate_test.go +35 −0
diff --git a/internal/release/proofgate.go b/internal/release/proofgate.go
index 318179aa8..89182113d 100644
--- a/internal/release/proofgate.go
+++ b/internal/release/proofgate.go
@@ -57,7 +57,7 @@ type ProofWait struct {
type promotionKey struct {
acct, app, version string
- promotedAt int64
+ promotedAt int64 // UnixNano: app pointers carry milliseconds
}
type missKey struct{ host, sha string }
@@ -310,7 +310,7 @@ func (g *ProofGate) admit(ctx context.Context, s Store, optDir string, rt regist
// rootfs image: Manifest.BoxArtifact), from the staged sibling when there is
// one and the bucket otherwise, cached per promotion.
func (g *ProofGate) manifestSHA(ctx context.Context, s Store, optDir, acct, app string, ptr *ChannelPointer) (string, error) {
- k := promotionKey{acct, app, ptr.Version, ptr.PromotedAt.Unix()}
+ k := promotionKey{acct, app, ptr.Version, ptr.PromotedAt.UnixNano()}
g.mu.Lock()
sha, ok := g.shas[k]
g.mu.Unlock()
diff --git a/internal/release/proofgate_test.go b/internal/release/proofgate_test.go
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)
+ }
+}