MCPcopy Create free account
hub / github.com/github/gh-aw / computeIntegrityCacheKey

Function computeIntegrityCacheKey

pkg/workflow/cache_integrity.go:188–205  ·  view source on GitHub ↗

computeIntegrityCacheKey returns the effective cache key for a cache entry, incorporating the integrity level and policy hash prefix. The key always starts with "memory-{integrityLevel}-{policyHash}-" to ensure cache isolation across integrity levels and guard policies, even when the user has specif

(cache CacheMemoryEntry, githubConfig *GitHubToolConfig)

Source from the content-addressed store, hash-verified

186// githubConfig may be nil for workflows without a GitHub guard policy, in which case the
187// sentinel value "nopolicy" and the default integrity level "none" are used.
188func computeIntegrityCacheKey(cache CacheMemoryEntry, githubConfig *GitHubToolConfig) string {
189 integrityLevel := cacheIntegrityLevel(githubConfig)
190 policyHash := computePolicyHash(githubConfig)
191 integrityPrefix := fmt.Sprintf("memory-%s-%s-", integrityLevel, policyHash)
192
193 // If a custom key was explicitly set, prefix it with the integrity/policy namespace
194 // to prevent cross-integrity or cross-policy cache sharing.
195 if cache.Key != "" && cache.Key != generateDefaultCacheKey(cache.ID) {
196 customKey := cache.Key
197 runIdSuffix := "-${{ github.run_id }}"
198 if !strings.HasSuffix(customKey, runIdSuffix) {
199 customKey = customKey + runIdSuffix
200 }
201 return integrityPrefix + customKey
202 }
203
204 return generateIntegrityAwareCacheKey(cache.ID, integrityLevel, policyHash)
205}
206
207// generateIntegrityAwareCacheKey generates the new-format cache key that includes
208// the integrity level and policy hash as prefixes.

Calls 4

cacheIntegrityLevelFunction · 0.85
computePolicyHashFunction · 0.85
generateDefaultCacheKeyFunction · 0.85